From 09bed43f97604acec07dda88aa310e95ec9e6268 Mon Sep 17 00:00:00 2001 From: Ley0k Date: Sun, 27 Mar 2016 11:49:47 +0200 Subject: [PATCH] Hard reset --- CHANGELOG.txt | 13 + COPYING.txt | 281 + LAYOUT.txt | 20 + Makefile | 1862 ++ PLEASE_USE_VS2013.txt | 4 + README.txt | 95 + TODO.TXT | 25 + .../main/models/omtests/test01_bonetype1.tik | 12 + .../omtests/test01_bonetype1/readme.txt | 3 + .../omtests/test01_bonetype1/test01.md5mesh | 1999 ++ .../test01_bonetype1/test01_bonetype1.RAY | Bin 0 -> 151947 bytes .../test01_bonetype1/test01_bonetype1.skc | Bin 0 -> 384 bytes .../test01_bonetype1/test01_bonetype1.skd | Bin 0 -> 39940 bytes .../test01_bonetype1/test01bones.md5mesh | 11 + build/main/models/omtests/testhoserot1.tik | 12 + .../omtests/testhoserot1/testhoserot1.RAY | Bin 0 -> 170627 bytes .../omtests/testhoserot1/testhoserot1.md5mesh | 2407 ++ .../omtests/testhoserot1/testhoserot1.skc | Bin 0 -> 480 bytes .../omtests/testhoserot1/testhoserot1.skd | Bin 0 -> 48284 bytes code/AL/VERSION | 16 + code/AL/al.h | 506 + code/AL/alc.h | 166 + code/AL/alctypes.h | 142 + code/AL/altypes.h | 352 + code/AL/alut.h | 90 + code/SDL2/include/SDL.h | 163 + code/SDL2/include/SDL_assert.h | 284 + code/SDL2/include/SDL_atomic.h | 260 + code/SDL2/include/SDL_audio.h | 506 + code/SDL2/include/SDL_bits.h | 97 + code/SDL2/include/SDL_blendmode.h | 63 + code/SDL2/include/SDL_clipboard.h | 71 + code/SDL2/include/SDL_config.h | 55 + code/SDL2/include/SDL_config.h.cmake | 395 + code/SDL2/include/SDL_config.h.in | 333 + code/SDL2/include/SDL_config_android.h | 144 + code/SDL2/include/SDL_config_iphoneos.h | 155 + code/SDL2/include/SDL_config_macosx.h | 184 + code/SDL2/include/SDL_config_minimal.h | 81 + code/SDL2/include/SDL_config_pandora.h | 124 + code/SDL2/include/SDL_config_psp.h | 140 + code/SDL2/include/SDL_config_windows.h | 210 + code/SDL2/include/SDL_config_winrt.h | 190 + code/SDL2/include/SDL_config_wiz.h | 118 + code/SDL2/include/SDL_copying.h | 20 + code/SDL2/include/SDL_cpuinfo.h | 156 + code/SDL2/include/SDL_egl.h | 1396 ++ code/SDL2/include/SDL_endian.h | 239 + code/SDL2/include/SDL_error.h | 76 + code/SDL2/include/SDL_events.h | 723 + code/SDL2/include/SDL_filesystem.h | 136 + code/SDL2/include/SDL_gamecontroller.h | 316 + code/SDL2/include/SDL_gesture.h | 87 + code/SDL2/include/SDL_haptic.h | 1225 + code/SDL2/include/SDL_hints.h | 517 + code/SDL2/include/SDL_joystick.h | 253 + code/SDL2/include/SDL_keyboard.h | 217 + code/SDL2/include/SDL_keycode.h | 341 + code/SDL2/include/SDL_loadso.h | 81 + code/SDL2/include/SDL_log.h | 211 + code/SDL2/include/SDL_main.h | 155 + code/SDL2/include/SDL_messagebox.h | 144 + code/SDL2/include/SDL_mouse.h | 224 + code/SDL2/include/SDL_mutex.h | 251 + code/SDL2/include/SDL_name.h | 33 + code/SDL2/include/SDL_opengl.h | 11126 +++++++++ code/SDL2/include/SDL_opengles.h | 38 + code/SDL2/include/SDL_opengles2.h | 2790 +++ code/SDL2/include/SDL_pixels.h | 429 + code/SDL2/include/SDL_platform.h | 164 + code/SDL2/include/SDL_power.h | 75 + code/SDL2/include/SDL_quit.h | 58 + code/SDL2/include/SDL_rect.h | 138 + code/SDL2/include/SDL_render.h | 870 + code/SDL2/include/SDL_revision.h | 2 + code/SDL2/include/SDL_rwops.h | 232 + code/SDL2/include/SDL_scancode.h | 401 + code/SDL2/include/SDL_shape.h | 143 + code/SDL2/include/SDL_stdinc.h | 405 + code/SDL2/include/SDL_surface.h | 503 + code/SDL2/include/SDL_system.h | 191 + code/SDL2/include/SDL_syswm.h | 272 + code/SDL2/include/SDL_test.h | 68 + code/SDL2/include/SDL_test_assert.h | 105 + code/SDL2/include/SDL_test_common.h | 188 + code/SDL2/include/SDL_test_compare.h | 69 + code/SDL2/include/SDL_test_crc32.h | 124 + code/SDL2/include/SDL_test_font.h | 76 + code/SDL2/include/SDL_test_fuzzer.h | 384 + code/SDL2/include/SDL_test_harness.h | 123 + code/SDL2/include/SDL_test_images.h | 78 + code/SDL2/include/SDL_test_log.h | 67 + code/SDL2/include/SDL_test_md5.h | 129 + code/SDL2/include/SDL_test_random.h | 115 + code/SDL2/include/SDL_thread.h | 287 + code/SDL2/include/SDL_timer.h | 115 + code/SDL2/include/SDL_touch.h | 86 + code/SDL2/include/SDL_types.h | 29 + code/SDL2/include/SDL_version.h | 162 + code/SDL2/include/SDL_video.h | 979 + code/SDL2/include/begin_code.h | 140 + code/SDL2/include/close_code.h | 37 + code/SDL2/include/doxyfile | 1555 ++ code/asm/ftola.s | 160 + code/asm/matha.s | 424 + code/asm/qasm.h | 46 + code/asm/snapvectora.s | 103 + code/asm/snd_mixa.s | 217 + code/botlib/aasfile.h | 267 + code/botlib/be_aas.h | 213 + code/botlib/be_aas_bsp.h | 89 + code/botlib/be_aas_bspq3.c | 487 + code/botlib/be_aas_cluster.c | 1545 ++ code/botlib/be_aas_cluster.h | 38 + code/botlib/be_aas_debug.c | 777 + code/botlib/be_aas_debug.h | 62 + code/botlib/be_aas_def.h | 304 + code/botlib/be_aas_entity.c | 437 + code/botlib/be_aas_entity.h | 63 + code/botlib/be_aas_file.c | 582 + code/botlib/be_aas_file.h | 42 + code/botlib/be_aas_funcs.h | 47 + code/botlib/be_aas_main.c | 429 + code/botlib/be_aas_main.h | 61 + code/botlib/be_aas_move.c | 1101 + code/botlib/be_aas_move.h | 71 + code/botlib/be_aas_optimize.c | 312 + code/botlib/be_aas_optimize.h | 33 + code/botlib/be_aas_reach.c | 4538 ++++ code/botlib/be_aas_reach.h | 68 + code/botlib/be_aas_route.c | 2210 ++ code/botlib/be_aas_route.h | 67 + code/botlib/be_aas_routealt.c | 240 + code/botlib/be_aas_routealt.h | 40 + code/botlib/be_aas_sample.c | 1394 ++ code/botlib/be_aas_sample.h | 69 + code/botlib/be_ai_char.c | 790 + code/botlib/be_ai_char.h | 48 + code/botlib/be_ai_chat.c | 3042 +++ code/botlib/be_ai_chat.h | 113 + code/botlib/be_ai_gen.c | 134 + code/botlib/be_ai_gen.h | 33 + code/botlib/be_ai_goal.c | 1821 ++ code/botlib/be_ai_goal.h | 118 + code/botlib/be_ai_move.c | 3570 +++ code/botlib/be_ai_move.h | 142 + code/botlib/be_ai_weap.c | 543 + code/botlib/be_ai_weap.h | 104 + code/botlib/be_ai_weight.c | 918 + code/botlib/be_ai_weight.h | 83 + code/botlib/be_ea.c | 508 + code/botlib/be_ea.h | 66 + code/botlib/be_interface.c | 895 + code/botlib/be_interface.h | 57 + code/botlib/botlib.h | 516 + code/botlib/l_crc.c | 151 + code/botlib/l_crc.h | 29 + code/botlib/l_libvar.c | 295 + code/botlib/l_libvar.h | 63 + code/botlib/l_log.c | 169 + code/botlib/l_log.h | 46 + code/botlib/l_memory.c | 463 + code/botlib/l_memory.h | 76 + code/botlib/l_precomp.c | 3230 +++ code/botlib/l_precomp.h | 180 + code/botlib/l_script.c | 1433 ++ code/botlib/l_script.h | 247 + code/botlib/l_struct.c | 462 + code/botlib/l_struct.h | 75 + code/botlib/l_utils.h | 37 + code/botlib/lcc.mak | 55 + code/botlib/linux-i386.mak | 92 + code/bspc/Conscript | 75 + code/bspc/Makefile | 114 + code/bspc/_files.c | 63 + code/bspc/aas_areamerging.c | 390 + code/bspc/aas_areamerging.h | 24 + code/bspc/aas_cfg.c | 256 + code/bspc/aas_cfg.h | 73 + code/bspc/aas_create.c | 1150 + code/bspc/aas_create.h | 136 + code/bspc/aas_edgemelting.c | 108 + code/bspc/aas_edgemelting.h | 24 + code/bspc/aas_facemerging.c | 282 + code/bspc/aas_facemerging.h | 24 + code/bspc/aas_file.c | 549 + code/bspc/aas_file.h | 25 + code/bspc/aas_gsubdiv.c | 656 + code/bspc/aas_gsubdiv.h | 25 + code/bspc/aas_map.c | 893 + code/bspc/aas_map.h | 23 + code/bspc/aas_prunenodes.c | 89 + code/bspc/aas_prunenodes.h | 24 + code/bspc/aas_store.c | 1082 + code/bspc/aas_store.h | 107 + code/bspc/aasfile.h | 252 + code/bspc/be_aas_bspc.c | 292 + code/bspc/be_aas_bspc.h | 23 + code/bspc/brushbsp.c | 1887 ++ code/bspc/bspc.c | 991 + code/bspc/bspc.vcproj | 1777 ++ code/bspc/cfgq3.c | 84 + code/bspc/csg.c | 1007 + code/bspc/faces.c | 978 + code/bspc/gldraw.c | 232 + code/bspc/glfile.c | 149 + code/bspc/l_bsp_ent.c | 180 + code/bspc/l_bsp_ent.h | 58 + code/bspc/l_bsp_hl.c | 888 + code/bspc/l_bsp_hl.h | 314 + code/bspc/l_bsp_q1.c | 620 + code/bspc/l_bsp_q1.h | 275 + code/bspc/l_bsp_q3.c | 824 + code/bspc/l_bsp_q3.h | 81 + code/bspc/l_bsp_sin.c | 1186 + code/bspc/l_bsp_sin.h | 106 + code/bspc/l_cmd.c | 1230 + code/bspc/l_cmd.h | 157 + code/bspc/l_log.c | 215 + code/bspc/l_log.h | 42 + code/bspc/l_math.c | 289 + code/bspc/l_math.h | 93 + code/bspc/l_mem.c | 441 + code/bspc/l_mem.h | 51 + code/bspc/l_poly.c | 1411 ++ code/bspc/l_poly.h | 120 + code/bspc/l_qfiles.c | 568 + code/bspc/l_qfiles.h | 91 + code/bspc/l_threads.c | 1510 ++ code/bspc/l_threads.h | 45 + code/bspc/l_utils.c | 259 + code/bspc/l_utils.h | 79 + code/bspc/lcc.mak | 61 + code/bspc/leakfile.c | 101 + code/bspc/linux-i386.mak | 109 + code/bspc/map.c | 1260 + code/bspc/map_hl.c | 1114 + code/bspc/map_q1.c | 1174 + code/bspc/map_q2.c | 445 + code/bspc/map_q3.c | 697 + code/bspc/map_sin.c | 1211 + code/bspc/nodraw.c | 47 + code/bspc/portals.c | 1297 ++ code/bspc/prtfile.c | 287 + code/bspc/q2files.h | 1 + code/bspc/q3files.h | 436 + code/bspc/qbsp.h | 483 + code/bspc/qfiles.h | 487 + code/bspc/sinfiles.h | 365 + code/bspc/tetrahedron.c | 1389 ++ code/bspc/tetrahedron.h | 24 + code/bspc/textures.c | 117 + code/bspc/tree.c | 285 + code/bspc/writebsp.c | 595 + code/cgame/cg_beam.c | 1231 + code/cgame/cg_consolecmds.c | 336 + code/cgame/cg_draw.c | 1576 ++ code/cgame/cg_drawtools.c | 245 + code/cgame/cg_effects.c | 453 + code/cgame/cg_ents.c | 580 + code/cgame/cg_eventSystem.c | 613 + code/cgame/cg_info.c | 55 + code/cgame/cg_local.h | 985 + code/cgame/cg_localents.c | 683 + code/cgame/cg_main.c | 816 + code/cgame/cg_marks.c | 2049 ++ code/cgame/cg_modelanim.c | 355 + code/cgame/cg_parsemsg.c | 653 + code/cgame/cg_particles.c | 2018 ++ code/cgame/cg_players.c | 396 + code/cgame/cg_playerstate.c | 180 + code/cgame/cg_predict.c | 556 + code/cgame/cg_public.h | 585 + code/cgame/cg_rain.c | 175 + code/cgame/cg_servercmds.c | 540 + code/cgame/cg_snapshot.c | 492 + code/cgame/cg_specialfx.c | 234 + code/cgame/cg_ubersound.c | 298 + code/cgame/cg_view.c | 919 + code/cgame/cg_viewmodelanim.c | 606 + code/cgame/cg_weapons.c | 446 + code/cgame_hook/animate.h | 1 + code/cgame_hook/asm.h | 183 + code/cgame_hook/cgame/cg_hook.cpp | 294 + code/cgame_hook/cgame/cg_hook.h | 6 + code/cgame_hook/cgame/cg_hud.cpp | 648 + code/cgame_hook/cgame/cg_hud.h | 65 + code/cgame_hook/cgame/cg_parsemsg.cpp | 872 + code/cgame_hook/cgame/cg_servercmds.cpp | 164 + code/cgame_hook/cgame/cg_servercmds.h | 7 + code/cgame_hook/cgame/cg_viewmodelanim.cpp | 1521 ++ code/cgame_hook/cgame/cg_viewmodelanim.h | 55 + code/cgame_hook/cgame/cl_sound.cpp | 100 + code/cgame_hook/cgame/cl_sound.h | 10 + code/cgame_hook/cgamex86.cpp | 592 + code/cgame_hook/cgamex86.h | 788 + code/cgame_hook/game.cpp | 62 + code/cgame_hook/game.h | 40 + code/cgame_hook/hook.cpp | 414 + code/cgame_hook/hook.h | 129 + code/cgame_hook/img/IMAGE.h | 88 + code/cgame_hook/img/IMAGE_CalculateStride.cpp | 38 + code/cgame_hook/img/IMAGE_ExpandPalette.cpp | 62 + code/cgame_hook/img/IMAGE_Load.cpp | 53 + code/cgame_hook/img/IMAGE_Load24BitBMP.cpp | 96 + code/cgame_hook/img/IMAGE_Load8BitBMP.cpp | 123 + code/cgame_hook/img/IMAGE_LoadAlpha.cpp | 74 + code/cgame_hook/img/IMAGE_LoadBMP.cpp | 59 + .../img/IMAGE_LoadCompressedTrueColorTGA.cpp | 183 + code/cgame_hook/img/IMAGE_LoadTGA.cpp | 60 + .../img/IMAGE_LoadUncompressed8BitTGA.cpp | 114 + .../IMAGE_LoadUncompressedTrueColorTGA.cpp | 99 + code/cgame_hook/img/TORUS.cpp | 98 + code/cgame_hook/img/TORUS.h | 42 + code/cgame_hook/level.cpp | 46 + code/cgame_hook/level.h | 70 + code/cgame_hook/ogl/OtherOGL.cpp | 2506 ++ code/cgame_hook/ogl/opengl32.cpp | 51 + code/cgame_hook/ogl/opengl_api.h | 790 + code/cgame_hook/renderer/glext.h | 12754 ++++++++++ code/cgame_hook/renderer/qfx_glprogs.h | 1078 + code/cgame_hook/renderer/qfx_hooks.cpp | 191 + code/cgame_hook/renderer/qfx_library.h | 42 + code/cgame_hook/renderer/qfx_log.cpp | 138 + code/cgame_hook/renderer/qfx_log.h | 42 + code/cgame_hook/renderer/qfx_opengl.cpp | 1519 ++ code/cgame_hook/renderer/qfx_opengl.h | 1945 ++ code/cgame_hook/renderer/qfx_renderer.cpp | 1585 ++ code/cgame_hook/renderer/qfx_renderer.h | 179 + code/cgame_hook/renderer/qfx_settings.cpp | 94 + code/cgame_hook/renderer/qfx_settings.h | 42 + code/cgame_hook/renderer/qfx_shader.cpp | 200 + code/cgame_hook/renderer/qfx_shader.h | 50 + code/cgame_hook/renderer/r_postprocess.cpp | 2581 ++ code/cgame_hook/renderer_api.h | 561 + code/cgame_hook/resource.h | 15 + code/cgame_hook/script/canimate.cpp | 156 + code/cgame_hook/script/canimate.h | 25 + code/cgame_hook/script/centity.cpp | 449 + code/cgame_hook/script/centity.h | 85 + code/cgame_hook/script/clientgamecommand.cpp | 353 + code/cgame_hook/script/clientgamecommand.h | 72 + .../cgame_hook/script/clientservercommand.cpp | 296 + code/cgame_hook/script/clientservercommand.h | 26 + code/cgame_hook/script/cplayer.cpp | 688 + code/cgame_hook/script/cplayer.h | 97 + code/cgame_hook/script/earthquake.cpp | 232 + code/cgame_hook/script/earthquake.h | 53 + code/cgame_hook/script/level.cpp | 64 + code/cgame_hook/script/level.h | 58 + code/cgame_hook/script/scriptslave.cpp | 319 + code/cgame_hook/script/scriptslave.h | 71 + code/cgame_hook/script/vision.h | 147 + code/client/cl_avi.cpp | 671 + code/client/cl_cgame.cpp | 1202 + code/client/cl_cin.cpp | 1692 ++ code/client/cl_console.cpp | 789 + code/client/cl_consolecmds.cpp | 173 + code/client/cl_curl.cpp | 330 + code/client/cl_curl.h | 101 + code/client/cl_input.cpp | 1019 + code/client/cl_inv.cpp | 337 + code/client/cl_inv.h | 194 + code/client/cl_invrender.cpp | 224 + code/client/cl_invrender.h | 98 + code/client/cl_keys.cpp | 1881 ++ code/client/cl_main.cpp | 4366 ++++ code/client/cl_net_chan.cpp | 167 + code/client/cl_parse.cpp | 857 + code/client/cl_scrn.cpp | 563 + code/client/cl_ui.c | 1212 + code/client/cl_ui.cpp | 5972 +++++ code/client/cl_ui.h | 120 + code/client/cl_uibind.cpp | 304 + code/client/cl_uibind.h | 134 + code/client/cl_uidmbox.cpp | 121 + code/client/cl_uidmbox.h | 67 + code/client/cl_uifilepicker.cpp | 93 + code/client/cl_uifilepicker.h | 59 + code/client/cl_uigmbox.cpp | 127 + code/client/cl_uigmbox.h | 67 + code/client/cl_uilangame.cpp | 64 + code/client/cl_uilangame.h | 48 + code/client/cl_uiloadsave.cpp | 83 + code/client/cl_uiloadsave.h | 57 + code/client/cl_uimaprunner.cpp | 68 + code/client/cl_uimaprunner.h | 59 + code/client/cl_uiminicon.cpp | 89 + code/client/cl_uiminicon.h | 57 + code/client/cl_uimpmappicker.cpp | 93 + code/client/cl_uimpmappicker.h | 58 + code/client/cl_uiplayermodelpicker.cpp | 83 + code/client/cl_uiplayermodelpicker.h | 56 + code/client/cl_uiserverlist.cpp | 100 + code/client/cl_uiserverlist.h | 58 + code/client/cl_uisoundpicker.cpp | 43 + code/client/cl_uisoundpicker.h | 36 + code/client/cl_uistd.cpp | 715 + code/client/cl_uistd.h | 104 + code/client/cl_uiview3d.cpp | 238 + code/client/cl_uiview3d.h | 74 + code/client/client.h | 662 + code/client/keycodes.h | 279 + code/client/keys.h | 65 + code/client/qal.c | 336 + code/client/qal.h | 250 + code/client/skeletor_imports.cpp | 58 + code/client/snd_adpcm.c | 333 + code/client/snd_codec.c | 240 + code/client/snd_codec.h | 115 + code/client/snd_codec_mp3.c | 717 + code/client/snd_codec_ogg.c | 474 + code/client/snd_codec_wav.c | 296 + code/client/snd_dma_new.cpp | 1658 ++ code/client/snd_local.h | 340 + code/client/snd_main.c | 984 + code/client/snd_mem.c | 280 + code/client/snd_mix.c | 799 + code/client/snd_openal_new.c | 2760 +++ code/client/snd_public.h | 122 + code/client/snd_wavelet.c | 256 + code/client/usignal.cpp | 240 + code/game/PlayerStart.cpp | 215 + code/game/PlayerStart.h | 93 + code/game/VehicleCollisionEntity.cpp | 99 + code/game/VehicleCollisionEntity.h | 61 + code/game/VehicleSlot.cpp | 162 + code/game/VehicleSlot.h | 102 + code/game/VehicleSoundEntity.cpp | 188 + code/game/VehicleSoundEntity.h | 68 + code/game/actor.cpp | 6802 ++++++ code/game/actor.h | 1476 ++ code/game/actor_aim.cpp | 82 + code/game/actor_alarm.cpp | 179 + code/game/actor_anim.cpp | 79 + code/game/actor_animapi.cpp | 400 + code/game/actor_animcurious.cpp | 85 + code/game/actor_balcony.cpp | 416 + code/game/actor_cover.cpp | 987 + code/game/actor_curious.cpp | 133 + code/game/actor_disguise_common.cpp | 104 + code/game/actor_disguise_officier.cpp | 91 + code/game/actor_disguise_rover.cpp | 90 + code/game/actor_disguise_salute.cpp | 100 + code/game/actor_disguise_sentry.cpp | 90 + code/game/actor_dog.cpp | 121 + code/game/actor_grenade.cpp | 213 + code/game/actor_idle.cpp | 57 + code/game/actor_killed.cpp | 76 + code/game/actor_machinegunner.cpp | 106 + code/game/actor_noclip.cpp | 56 + code/game/actor_pain.cpp | 67 + code/game/actor_patrol.cpp | 90 + code/game/actor_runner.cpp | 90 + code/game/actor_turret.cpp | 394 + code/game/actor_weaponless.cpp | 89 + code/game/actorenemy.cpp | 239 + code/game/actorenemy.h | 118 + code/game/actorpath.cpp | 676 + code/game/actorpath.h | 156 + code/game/ammo.cpp | 183 + code/game/ammo.h | 83 + code/game/animate.cpp | 752 + code/game/animate.h | 210 + code/game/armor.cpp | 102 + code/game/armor.h | 44 + code/game/b_files.cpp | 487 + code/game/b_local.h | 167 + code/game/b_nav.cpp | 632 + code/game/b_navgen.cpp | 3089 +++ code/game/barrels.cpp | 607 + code/game/barrels.h | 95 + code/game/be_aas.h | 210 + code/game/be_ai_char.h | 32 + code/game/be_ai_chat.h | 97 + code/game/be_ai_gen.h | 17 + code/game/be_ai_goal.h | 102 + code/game/be_ai_move.h | 126 + code/game/be_ai_weap.h | 90 + code/game/be_ea.h | 51 + code/game/beam.cpp | 879 + code/game/beam.h | 126 + code/game/bg_lib.cpp | 2119 ++ code/game/bg_local.h | 88 + code/game/bg_misc.cpp | 398 + code/game/bg_pmove.cpp | 1801 ++ code/game/bg_public.h | 602 + code/game/bg_slidemove.cpp | 322 + code/game/body.cpp | 80 + code/game/body.h | 43 + code/game/botlib.h | 506 + code/game/botmenudef.h | 287 + code/game/bspline.cpp | 956 + code/game/bspline.h | 584 + code/game/camera.cpp | 3641 +++ code/game/camera.h | 473 + code/game/characterstate.cpp | 1205 + code/game/characterstate.h | 419 + code/game/chars.h | 134 + code/game/container.cpp | 243 + code/game/container.h | 538 + code/game/crateobject.cpp | 541 + code/game/crateobject.h | 75 + code/game/debuglines.cpp | 876 + code/game/debuglines.h | 71 + code/game/decals.cpp | 91 + code/game/decals.h | 61 + code/game/dm_manager.cpp | 1304 ++ code/game/dm_manager.h | 169 + code/game/dm_team.cpp | 768 + code/game/dm_team.h | 107 + code/game/doors.cpp | 1864 ++ code/game/doors.h | 266 + code/game/earthquake.cpp | 310 + code/game/earthquake.h | 80 + code/game/effectentity.cpp | 39 + code/game/effectentity.h | 38 + code/game/entity.cpp | 6924 ++++++ code/game/entity.h | 948 + code/game/events.h | 70 + code/game/explosion.cpp | 684 + code/game/explosion.h | 140 + code/game/g_active.cpp | 955 + code/game/g_arenas.cpp | 93 + code/game/g_bot.cpp | 60 + code/game/g_client.cpp | 1103 + code/game/g_items.cpp | 25 + code/game/g_local.h | 594 + code/game/g_main.cpp | 1643 ++ code/game/g_main.h | 54 + code/game/g_mem.cpp | 58 + code/game/g_mmove.cpp | 625 + code/game/g_phys.cpp | 1664 ++ code/game/g_phys.h | 81 + code/game/g_public.h | 1163 + code/game/g_session.cpp | 130 + code/game/g_utils.cpp | 2790 +++ code/game/g_vmove.cpp | 645 + code/game/g_weapon.cpp | 1085 + code/game/game.cpp | 545 + code/game/game.h | 234 + code/game/gamecmds.cpp | 805 + code/game/gamecmds.h | 59 + code/game/gamecvars.cpp | 479 + code/game/gamecvars.h | 233 + code/game/gibs.cpp | 315 + code/game/gibs.h | 92 + code/game/gravpath.cpp | 797 + code/game/gravpath.h | 206 + code/game/grenadehint.cpp | 101 + code/game/grenadehint.h | 57 + code/game/health.cpp | 84 + code/game/health.h | 43 + code/game/huddraw.cpp | 344 + code/game/huddraw.h | 53 + code/game/inv.h | 166 + code/game/inventoryitem.cpp | 98 + code/game/inventoryitem.h | 56 + code/game/ipfilter.cpp | 360 + code/game/ipfilter.h | 33 + code/game/item.cpp | 1141 + code/game/item.h | 155 + code/game/level.cpp | 2073 ++ code/game/level.h | 294 + code/game/light.cpp | 152 + code/game/light.h | 40 + code/game/lodthing.cpp | 299 + code/game/lodthing.h | 80 + code/game/match.h | 134 + code/game/misc.cpp | 3725 +++ code/game/misc.h | 604 + code/game/movegrid.cpp | 151 + code/game/movegrid.h | 123 + code/game/mover.cpp | 283 + code/game/mover.h | 68 + code/game/nature.cpp | 175 + code/game/nature.h | 91 + code/game/navigate.cpp | 3486 +++ code/game/navigate.h | 366 + code/game/player.cpp | 14703 ++++++++++++ code/game/player.h | 1149 + code/game/player_combat.cpp | 275 + code/game/player_util.cpp | 631 + code/game/playerbot.cpp | 1667 ++ code/game/playerbot.h | 175 + code/game/portal.cpp | 161 + code/game/portal.h | 50 + code/game/prioritystack.h | 165 + code/game/scriptslave.cpp | 2313 ++ code/game/scriptslave.h | 280 + code/game/sentient.cpp | 4539 ++++ code/game/sentient.h | 399 + code/game/simpleactor.cpp | 1078 + code/game/simpleactor.h | 239 + code/game/soundman.cpp | 1793 ++ code/game/soundman.h | 114 + code/game/spawners.cpp | 532 + code/game/spawners.h | 133 + code/game/specialfx.cpp | 1067 + code/game/specialfx.h | 178 + code/game/spline.h | 350 + code/game/stack.h | 146 + code/game/surfaceflags.h | 92 + code/game/syn.h | 34 + code/game/trigger.cpp | 3208 +++ code/game/trigger.h | 721 + code/game/ulinklist.h | 414 + code/game/umap.h | 339 + code/game/vehicle.cpp | 6603 ++++++ code/game/vehicle.h | 811 + code/game/vehicleturret.cpp | 730 + code/game/vehicleturret.h | 108 + code/game/viewthing.cpp | 1013 + code/game/viewthing.h | 117 + code/game/weapon.cpp | 4597 ++++ code/game/weapon.h | 522 + code/game/weapturret.cpp | 1488 ++ code/game/weapturret.h | 140 + code/game/weaputils.cpp | 2954 +++ code/game/weaputils.h | 350 + code/game/windows.cpp | 188 + code/game/windows.h | 51 + code/globalcpp/Linklist.h | 148 + code/globalcpp/archive.cpp | 1286 + code/globalcpp/archive.h | 415 + code/globalcpp/archive_dummy.cpp | 381 + code/globalcpp/baseimp.h | 90 + code/globalcpp/basemain.cpp | 129 + code/globalcpp/basemain.h | 4 + code/globalcpp/class.cpp | 914 + code/globalcpp/class.h | 281 + code/globalcpp/compiler.cpp | 1949 ++ code/globalcpp/compiler.h | 177 + code/globalcpp/console.cpp | 266 + code/globalcpp/console.h | 52 + code/globalcpp/const_str.h | 128 + code/globalcpp/container.h | 491 + code/globalcpp/containerclass.h | 62 + code/globalcpp/crc32.h | 88 + code/globalcpp/dbgheap.cpp | 226 + code/globalcpp/dbgheap.h | 64 + code/globalcpp/dummy/dummy_base.cpp | 268 + code/globalcpp/dummy/dummy_base.h | 56 + code/globalcpp/dummy/dummy_game.cpp | 60 + code/globalcpp/dummy/dummy_level.cpp | 46 + code/globalcpp/dummy/game.h | 38 + code/globalcpp/dummy/level.h | 68 + code/globalcpp/g_spawn.cpp | 1406 ++ code/globalcpp/g_spawn.h | 81 + code/globalcpp/gamescript.cpp | 1057 + code/globalcpp/gamescript.h | 179 + code/globalcpp/glb_local.h | 82 + code/globalcpp/hud.cpp | 1938 ++ code/globalcpp/hud.h | 212 + code/globalcpp/listener.cpp | 4773 ++++ code/globalcpp/listener.h | 700 + code/globalcpp/lz77.cpp | 971 + code/globalcpp/lz77.h | 53 + code/globalcpp/md5.cpp | 381 + code/globalcpp/md5.h | 91 + code/globalcpp/object.cpp | 34 + code/globalcpp/object.h | 48 + code/globalcpp/parm.cpp | 91 + code/globalcpp/parm.h | 55 + code/globalcpp/parser/parsetree.cpp | 341 + code/globalcpp/parser/parsetree.h | 148 + code/globalcpp/parser/yyLexer.cpp | 2678 +++ code/globalcpp/parser/yyLexer.h | 326 + code/globalcpp/parser/yyLexer.l | 283 + code/globalcpp/parser/yyParser.cpp | 2648 +++ code/globalcpp/parser/yyParser.h | 159 + code/globalcpp/parser/yyParser.yy | 265 + code/globalcpp/safeptr.h | 244 + code/globalcpp/script.cpp | 1188 + code/globalcpp/script.h | 180 + code/globalcpp/scriptexception.cpp | 73 + code/globalcpp/scriptexception.h | 54 + code/globalcpp/scriptmaster.cpp | 9299 ++++++++ code/globalcpp/scriptmaster.h | 587 + code/globalcpp/scriptopcodes.cpp | 236 + code/globalcpp/scriptopcodes.h | 186 + code/globalcpp/scripttimer.cpp | 275 + code/globalcpp/scripttimer.h | 83 + code/globalcpp/scriptvariable.cpp | 2520 ++ code/globalcpp/scriptvariable.h | 306 + code/globalcpp/scriptvm.cpp | 2314 ++ code/globalcpp/scriptvm.h | 328 + code/globalcpp/simpleentity.cpp | 592 + code/globalcpp/simpleentity.h | 130 + code/globalcpp/slre.c | 437 + code/globalcpp/slre.h | 60 + code/globalcpp/vector.h | 1237 + code/globalcpp/world.cpp | 581 + code/globalcpp/world.h | 111 + code/jpeg-8c/README | 326 + code/jpeg-8c/jaricom.c | 153 + code/jpeg-8c/jcapimin.c | 288 + code/jpeg-8c/jcapistd.c | 161 + code/jpeg-8c/jcarith.c | 934 + code/jpeg-8c/jccoefct.c | 453 + code/jpeg-8c/jccolor.c | 459 + code/jpeg-8c/jcdctmgr.c | 482 + code/jpeg-8c/jchuff.c | 1576 ++ code/jpeg-8c/jcinit.c | 65 + code/jpeg-8c/jcmainct.c | 293 + code/jpeg-8c/jcmarker.c | 682 + code/jpeg-8c/jcmaster.c | 858 + code/jpeg-8c/jcomapi.c | 106 + code/jpeg-8c/jconfig.h | 60 + code/jpeg-8c/jcparam.c | 632 + code/jpeg-8c/jcprepct.c | 358 + code/jpeg-8c/jcsample.c | 545 + code/jpeg-8c/jctrans.c | 382 + code/jpeg-8c/jdapimin.c | 396 + code/jpeg-8c/jdapistd.c | 275 + code/jpeg-8c/jdarith.c | 772 + code/jpeg-8c/jdatadst.c | 267 + code/jpeg-8c/jdatasrc.c | 274 + code/jpeg-8c/jdcoefct.c | 736 + code/jpeg-8c/jdcolor.c | 396 + code/jpeg-8c/jdct.h | 393 + code/jpeg-8c/jddctmgr.c | 384 + code/jpeg-8c/jdhuff.c | 1541 ++ code/jpeg-8c/jdinput.c | 661 + code/jpeg-8c/jdmainct.c | 512 + code/jpeg-8c/jdmarker.c | 1406 ++ code/jpeg-8c/jdmaster.c | 533 + code/jpeg-8c/jdmerge.c | 400 + code/jpeg-8c/jdpostct.c | 290 + code/jpeg-8c/jdsample.c | 361 + code/jpeg-8c/jdtrans.c | 140 + code/jpeg-8c/jerror.c | 254 + code/jpeg-8c/jerror.h | 304 + code/jpeg-8c/jfdctflt.c | 174 + code/jpeg-8c/jfdctfst.c | 230 + code/jpeg-8c/jfdctint.c | 4348 ++++ code/jpeg-8c/jidctflt.c | 235 + code/jpeg-8c/jidctfst.c | 368 + code/jpeg-8c/jidctint.c | 5137 ++++ code/jpeg-8c/jinclude.h | 91 + code/jpeg-8c/jmemmgr.c | 1118 + code/jpeg-8c/jmemnobs.c | 109 + code/jpeg-8c/jmemsys.h | 198 + code/jpeg-8c/jmorecfg.h | 371 + code/jpeg-8c/jpegint.h | 407 + code/jpeg-8c/jpeglib.h | 1160 + code/jpeg-8c/jquant1.c | 856 + code/jpeg-8c/jquant2.c | 1310 ++ code/jpeg-8c/jutils.c | 231 + code/jpeg-8c/jversion.h | 14 + code/libcurl/curl/curl.h | 1563 ++ code/libcurl/curl/curlver.h | 56 + code/libcurl/curl/easy.h | 81 + code/libcurl/curl/mprintf.h | 62 + code/libcurl/curl/multi.h | 344 + code/libcurl/curl/stdcheaders.h | 34 + code/libcurl/curl/types.h | 1 + code/libmad/include/mad.h | 968 + code/libs/macosx/libSDL-1.2.0.dylib | Bin 0 -> 4474044 bytes code/libs/macosx/libSDLmain.a | Bin 0 -> 97816 bytes code/libs/nix/libSDL.a | Bin 0 -> 658224 bytes code/libs/nix/libSDLmain.a | Bin 0 -> 836 bytes code/libs/nix/libcurl.a | Bin 0 -> 253484 bytes code/libs/nix/libmad.a | Bin 0 -> 269908 bytes code/libs/nix/libopenal32.a | Bin 0 -> 111334 bytes code/libs/win32/OpenAL32.lib | Bin 0 -> 116274 bytes code/libs/win32/SDL2.dll | Bin 0 -> 1007104 bytes code/libs/win32/SDL2.lib | Bin 0 -> 116400 bytes code/libs/win32/SDL2main.lib | Bin 0 -> 40536 bytes code/libs/win32/glew32.lib | Bin 0 -> 606480 bytes code/libs/win32/glew32s.lib | Bin 0 -> 2056556 bytes code/libs/win32/libmad.lib | Bin 0 -> 230418 bytes code/libs/win64/OpenAL32.lib | Bin 0 -> 116896 bytes code/libs/win64/SDL2.dll | Bin 0 -> 1190400 bytes code/libs/win64/SDL2.lib | Bin 0 -> 113700 bytes code/libs/win64/SDL2main.lib | Bin 0 -> 42824 bytes code/libs/win64/SDL2test.lib | Bin 0 -> 842536 bytes code/libs/win64/glew32.lib | Bin 0 -> 606480 bytes code/libs/win64/glew32s.lib | Bin 0 -> 2056556 bytes code/libs/win64/libmad.lib | Bin 0 -> 221180 bytes code/mohcgame/cg_consolecmds.c | 130 + code/mohcgame/cg_draw.c | 84 + code/mohcgame/cg_local.h | 499 + code/mohcgame/cg_main.c | 318 + code/mohcgame/cg_public.h | 254 + code/mohcgame/cg_servercmds.c | 379 + code/mohcgame/cg_syscalls.c | 485 + code/mohcgame/cg_view.c | 40 + code/mohui/ui_local.h | 312 + code/mohui/ui_main.cpp | 144 + code/mohui/ui_model.cpp | 121 + code/mohui/ui_public.h | 208 + code/mohui/ui_quarks.cpp | 1165 + code/mohui/ui_syscalls.c | 452 + code/mohui/ui_urc.cpp | 716 + code/null/mac_net.c | 65 + code/null/null_client.c | 122 + code/null/null_cm.c | 27 + code/null/null_glimp.c | 56 + code/null/null_input.c | 41 + code/null/null_main.c | 117 + code/null/null_net.c | 86 + code/null/null_server.c | 42 + code/null/null_snddma.c | 63 + code/null/null_sys.c | 41 + code/null/null_tiki.c | 32 + code/png/png.c | 4490 ++++ code/png/png.h | 3292 +++ code/png/pngconf.h | 622 + code/png/pngdebug.h | 153 + code/png/pngerror.c | 963 + code/png/pngget.c | 1219 + code/png/pnginfo.h | 259 + code/png/pnglibconf.h | 214 + code/png/pngmem.c | 281 + code/png/pngpread.c | 1174 + code/png/pngpriv.h | 1908 ++ code/png/pngread.c | 4134 ++++ code/png/pngrio.c | 120 + code/png/pngrtran.c | 4997 ++++ code/png/pngrutil.c | 4476 ++++ code/png/pngset.c | 1640 ++ code/png/pngstruct.h | 488 + code/png/pngtrans.c | 849 + code/png/pngwio.c | 168 + code/png/pngwrite.c | 2459 ++ code/png/pngwtran.c | 574 + code/png/pngwutil.c | 3031 +++ code/png/zconf.h | 511 + code/png/zlib.h | 1768 ++ code/qcommon/alias.c | 839 + code/qcommon/alias.h | 115 + code/qcommon/cm_fencemask.c | 645 + code/qcommon/cm_load.c | 1248 + code/qcommon/cm_local.h | 262 + code/qcommon/cm_patch.c | 1734 ++ code/qcommon/cm_patch.h | 103 + code/qcommon/cm_polylib.c | 737 + code/qcommon/cm_polylib.h | 66 + code/qcommon/cm_public.h | 109 + code/qcommon/cm_terrain.c | 1632 ++ code/qcommon/cm_terrain.h | 72 + code/qcommon/cm_test.c | 657 + code/qcommon/cm_trace.c | 1943 ++ code/qcommon/cm_trace_lbd.cpp | 622 + code/qcommon/cmd.c | 968 + code/qcommon/common.cpp | 2282 ++ code/qcommon/con_arrayset.h | 166 + code/qcommon/con_set.cpp | 119 + code/qcommon/con_set.h | 652 + code/qcommon/configurator.cpp | 986 + code/qcommon/configurator.h | 110 + code/qcommon/crc.c | 125 + code/qcommon/crc.h | 30 + code/qcommon/cvar.c | 1114 + code/qcommon/files.c | 3614 +++ code/qcommon/huffman.c | 440 + code/qcommon/localization.cpp | 555 + code/qcommon/localization.h | 75 + code/qcommon/md4.c | 208 + code/qcommon/md5.c | 310 + code/qcommon/mem_blockalloc.cpp | 35 + code/qcommon/mem_blockalloc.h | 417 + code/qcommon/mem_tempalloc.cpp | 68 + code/qcommon/mem_tempalloc.h | 39 + code/qcommon/memory.c | 453 + code/qcommon/msg.c | 2513 ++ code/qcommon/net_chan.c | 795 + code/qcommon/net_ip.c | 1396 ++ code/qcommon/puff.c | 758 + code/qcommon/puff.h | 43 + code/qcommon/q_math.c | 4191 ++++ code/qcommon/q_platform.h | 298 + code/qcommon/q_shared.c | 2038 ++ code/qcommon/q_shared.h | 2153 ++ code/qcommon/qcommon.h | 1490 ++ code/qcommon/qfiles.h | 838 + code/qcommon/queue.h | 239 + code/qcommon/short3.h | 259 + code/qcommon/stack.h | 158 + code/qcommon/str.cpp | 747 + code/qcommon/str.h | 776 + code/qcommon/surfaceflags.h | 120 + code/qcommon/tiki.h | 161 + code/qcommon/tiki_script.cpp | 1391 ++ code/qcommon/tiki_script.h | 152 + code/qcommon/unistd.h | 47 + code/qcommon/unzip.c | 4368 ++++ code/qcommon/unzip.h | 347 + code/qcommon/vm.c | 888 + code/qcommon/vm_interpreted.c | 921 + code/qcommon/vm_local.h | 183 + code/qcommon/vm_none.c | 10 + code/qcommon/vm_ppc.c | 2064 ++ code/qcommon/vm_x86.c | 1237 + code/qcommon/vm_x86_64.c | 1138 + code/qcommon/vm_x86_64_assembler.c | 1419 ++ code/renderer_gl3/gl_shader.cpp | 3682 +++ code/renderer_gl3/gl_shader.h | 2541 ++ code/renderer_gl3/sdl_gamma.c | 90 + code/renderer_gl3/sdl_glimp.c | 1704 ++ code/renderer_gl3/tr_animation.c | 1639 ++ code/renderer_gl3/tr_animation_mdm.c | 2427 ++ code/renderer_gl3/tr_backend.cpp | 11827 ++++++++++ code/renderer_gl3/tr_bsp.c | 9296 ++++++++ code/renderer_gl3/tr_cmds.c | 818 + code/renderer_gl3/tr_curve.c | 1012 + code/renderer_gl3/tr_decals.c | 1012 + code/renderer_gl3/tr_fbo.c | 1013 + code/renderer_gl3/tr_flares.c | 567 + code/renderer_gl3/tr_font.c | 918 + code/renderer_gl3/tr_image.c | 3780 +++ code/renderer_gl3/tr_image_dds.c | 1190 + code/renderer_gl3/tr_image_exr.cpp | 104 + code/renderer_gl3/tr_image_jpg.c | 450 + code/renderer_gl3/tr_image_png.c | 316 + code/renderer_gl3/tr_image_tga.c | 297 + code/renderer_gl3/tr_image_webp.c | 73 + code/renderer_gl3/tr_init.cpp | 2446 ++ code/renderer_gl3/tr_light.c | 2042 ++ code/renderer_gl3/tr_local.h | 5180 +++++ code/renderer_gl3/tr_main.c | 3495 +++ code/renderer_gl3/tr_marks.c | 516 + code/renderer_gl3/tr_mesh.c | 476 + code/renderer_gl3/tr_model.c | 936 + code/renderer_gl3/tr_model_md3.c | 517 + code/renderer_gl3/tr_model_md5.c | 732 + code/renderer_gl3/tr_model_mdc.c | 875 + code/renderer_gl3/tr_model_mdm.c | 951 + code/renderer_gl3/tr_model_psk.c | 1001 + code/renderer_gl3/tr_model_skel.c | 671 + code/renderer_gl3/tr_model_skel.h | 34 + code/renderer_gl3/tr_noise.c | 96 + code/renderer_gl3/tr_scene.c | 789 + code/renderer_gl3/tr_shade.cpp | 5550 +++++ code/renderer_gl3/tr_shade_calc.c | 1280 + code/renderer_gl3/tr_shader.c | 6834 ++++++ code/renderer_gl3/tr_shadows.c | 85 + code/renderer_gl3/tr_skin.c | 463 + code/renderer_gl3/tr_sky.cpp | 995 + code/renderer_gl3/tr_surface.c | 2423 ++ code/renderer_gl3/tr_vbo.c | 798 + code/renderer_gl3/tr_world.cpp | 2534 ++ code/renderer_gl3/xreal_qfiles.h | 576 + code/renderercommon/iqm.h | 129 + code/renderercommon/qgl.h | 772 + code/renderercommon/tr_common.h | 190 + code/renderercommon/tr_font.c | 1352 ++ code/renderercommon/tr_image_bmp.c | 238 + code/renderercommon/tr_image_jpg.c | 437 + code/renderercommon/tr_image_pcx.c | 150 + code/renderercommon/tr_image_png.c | 2485 ++ code/renderercommon/tr_image_tga.c | 307 + code/renderercommon/tr_noise.c | 91 + code/renderercommon/tr_public.h | 298 + code/renderercommon/tr_types.h | 63 + code/renderergl2/glsl/bokeh_fp.glsl | 70 + code/renderergl2/glsl/bokeh_vp.glsl | 13 + code/renderergl2/glsl/calclevels4x_fp.glsl | 60 + code/renderergl2/glsl/calclevels4x_vp.glsl | 13 + code/renderergl2/glsl/depthblur_fp.glsl | 58 + code/renderergl2/glsl/depthblur_vp.glsl | 12 + code/renderergl2/glsl/dlight_fp.glsl | 12 + code/renderergl2/glsl/dlight_vp.glsl | 92 + code/renderergl2/glsl/down4x_fp.glsl | 34 + code/renderergl2/glsl/down4x_vp.glsl | 13 + code/renderergl2/glsl/fogpass_fp.glsl | 9 + code/renderergl2/glsl/fogpass_vp.glsl | 117 + code/renderergl2/glsl/generic_fp.glsl | 12 + code/renderergl2/glsl/generic_vp.glsl | 239 + code/renderergl2/glsl/lightall_fp.glsl | 610 + code/renderergl2/glsl/lightall_vp.glsl | 247 + code/renderergl2/glsl/pshadow_fp.glsl | 98 + code/renderergl2/glsl/pshadow_vp.glsl | 15 + code/renderergl2/glsl/shadowfill_fp.glsl | 41 + code/renderergl2/glsl/shadowfill_vp.glsl | 89 + code/renderergl2/glsl/shadowmask_fp.glsl | 143 + code/renderergl2/glsl/shadowmask_vp.glsl | 18 + code/renderergl2/glsl/ssao_fp.glsl | 86 + code/renderergl2/glsl/ssao_vp.glsl | 12 + code/renderergl2/glsl/texturecolor_fp.glsl | 10 + code/renderergl2/glsl/texturecolor_vp.glsl | 13 + code/renderergl2/glsl/tonemap_fp.glsl | 54 + code/renderergl2/glsl/tonemap_vp.glsl | 27 + code/renderergl2/tr_animation.c | 523 + code/renderergl2/tr_backend.c | 1742 ++ code/renderergl2/tr_bsp.c | 4142 ++++ code/renderergl2/tr_cmds.c | 597 + code/renderergl2/tr_curve.c | 761 + code/renderergl2/tr_draw.c | 505 + code/renderergl2/tr_extensions.c | 735 + code/renderergl2/tr_extramath.c | 226 + code/renderergl2/tr_extramath.h | 77 + code/renderergl2/tr_extratypes.h | 40 + code/renderergl2/tr_fbo.c | 860 + code/renderergl2/tr_fbo.h | 71 + code/renderergl2/tr_flares.c | 557 + code/renderergl2/tr_glsl.c | 1535 ++ code/renderergl2/tr_image.c | 3262 +++ code/renderergl2/tr_init.c | 1812 ++ code/renderergl2/tr_light.c | 517 + code/renderergl2/tr_local.h | 3053 +++ code/renderergl2/tr_main.c | 3147 +++ code/renderergl2/tr_marks.c | 474 + code/renderergl2/tr_mesh.c | 422 + code/renderergl2/tr_model.cpp | 1443 ++ code/renderergl2/tr_model_iqm.c | 1200 + code/renderergl2/tr_postprocess.c | 523 + code/renderergl2/tr_postprocess.h | 33 + code/renderergl2/tr_progs.c | 1734 ++ code/renderergl2/tr_scene.c | 685 + code/renderergl2/tr_shade.c | 1776 ++ code/renderergl2/tr_shade_calc.c | 1030 + code/renderergl2/tr_shader.c | 4151 ++++ code/renderergl2/tr_shadows.c | 325 + code/renderergl2/tr_sky.c | 911 + code/renderergl2/tr_sprite.c | 66 + code/renderergl2/tr_staticmodels.cpp | 473 + code/renderergl2/tr_subs.c | 52 + code/renderergl2/tr_surface.c | 1695 ++ code/renderergl2/tr_swipe.cpp | 43 + code/renderergl2/tr_terrain.c | 34 + code/renderergl2/tr_util.cpp | 281 + code/renderergl2/tr_vbo.c | 793 + code/renderergl2/tr_world.c | 853 + code/sdl/sdl_gamma.c | 96 + code/sdl/sdl_glimp.c | 867 + code/sdl/sdl_icon.h | 132 + code/sdl/sdl_input.c | 1006 + code/sdl/sdl_snd.c | 295 + code/server/game.cpp | 62 + code/server/game.h | 40 + code/server/level.cpp | 46 + code/server/level.h | 70 + code/server/server.h | 533 + code/server/sv_bot.c | 632 + code/server/sv_ccmds.c | 1526 ++ code/server/sv_client.c | 1580 ++ code/server/sv_game.c | 1687 ++ code/server/sv_init.c | 1086 + code/server/sv_main.c | 996 + code/server/sv_net_chan.c | 207 + code/server/sv_rankings.c | 1537 ++ code/server/sv_snapshot.c | 728 + code/server/sv_snd.c | 103 + code/server/sv_world.c | 862 + code/skeletor/SkelMat3.h | 220 + code/skeletor/SkelMat4.h | 390 + code/skeletor/SkelQuat.h | 310 + code/skeletor/SkelVec3.h | 219 + code/skeletor/SkelVec4.h | 72 + code/skeletor/bonetable.cpp | 309 + code/skeletor/skeletor.cpp | 1009 + code/skeletor/skeletor.h | 192 + .../skeletor/skeletor_animation_file_format.h | 109 + code/skeletor/skeletor_internal.h | 218 + code/skeletor/skeletor_loadanimation.cpp | 436 + code/skeletor/skeletor_model_file_format.h | 92 + code/skeletor/skeletor_model_files.cpp | 209 + code/skeletor/skeletor_name_lists.h | 70 + code/skeletor/skeletor_utilities.cpp | 334 + code/skeletor/skeletorbones.cpp | 1165 + code/skeletor/tokenizer.cpp | 23 + code/skeletor/tokenizer.h | 68 + code/sys/con_log.c | 129 + code/sys/con_passive.c | 68 + code/sys/con_tty.c | 459 + code/sys/con_win32.c | 360 + code/sys/sys_loadlib.h | 44 + code/sys/sys_local.h | 61 + code/sys/sys_main.c | 851 + code/sys/sys_unix.c | 510 + code/sys/sys_win32.c | 800 + code/sys/win_resource.h | 44 + code/sys/win_resource.rc | 76 + code/tiki/tiki_anim.cpp | 391 + code/tiki/tiki_anim.h | 52 + code/tiki/tiki_cache.cpp | 496 + code/tiki/tiki_cache.h | 52 + code/tiki/tiki_commands.cpp | 38 + code/tiki/tiki_commands.h | 38 + code/tiki/tiki_files.cpp | 1028 + code/tiki/tiki_files.h | 72 + code/tiki/tiki_frame.cpp | 149 + code/tiki/tiki_frame.h | 40 + code/tiki/tiki_imports.cpp | 58 + code/tiki/tiki_imports.h | 42 + code/tiki/tiki_main.cpp | 198 + code/tiki/tiki_main.h | 48 + code/tiki/tiki_parse.cpp | 1286 + code/tiki/tiki_parse.h | 57 + code/tiki/tiki_shared.h | 413 + code/tiki/tiki_skel.cpp | 983 + code/tiki/tiki_skel.h | 50 + code/tiki/tiki_surface.cpp | 64 + code/tiki/tiki_surface.h | 39 + code/tiki/tiki_tag.cpp | 147 + code/tiki/tiki_tag.h | 47 + code/tiki/tiki_utility.cpp | 238 + code/tiki/tiki_utility.h | 47 + code/tools/GL/glew.h | 19367 ++++++++++++++++ code/tools/GL/glxew.h | 1771 ++ code/tools/GL/wglew.h | 1452 ++ code/tools/asm/README.Id | 10 + code/tools/asm/cmdlib.c | 1138 + code/tools/asm/cmdlib.h | 152 + code/tools/asm/lib.txt | 31 + code/tools/asm/mathlib.h | 94 + code/tools/asm/notes.txt | 16 + code/tools/asm/ops.txt | 132 + code/tools/asm/opstrings.h | 175 + code/tools/asm/q3asm.c | 1640 ++ code/tools/cgame_wrapper/cg_consolecmds.c | 88 + code/tools/cgame_wrapper/cg_draw.c | 90 + code/tools/cgame_wrapper/cg_main.c | 188 + code/tools/cgame_wrapper/cg_skeletor.c | 844 + code/tools/cgame_wrapper/cg_tiki.c | 137 + code/tools/cgame_wrapper/cgame_wrapper.sln | 20 + .../tools/cgame_wrapper/cgame_wrapper.vcxproj | 80 + .../cgame_wrapper.vcxproj.filters | 39 + .../cgame_wrapper/cgame_wrapper.vcxproj.user | 13 + code/tools/cgame_wrapper/qcommon.h | 921 + code/tools/lcc/COPYRIGHT | 61 + code/tools/lcc/LOG | 91 + code/tools/lcc/README | 21 + code/tools/lcc/README.id | 3 + code/tools/lcc/cpp/cpp.c | 322 + code/tools/lcc/cpp/cpp.h | 166 + code/tools/lcc/cpp/eval.c | 524 + code/tools/lcc/cpp/getopt.c | 53 + code/tools/lcc/cpp/hideset.c | 112 + code/tools/lcc/cpp/include.c | 154 + code/tools/lcc/cpp/lex.c | 580 + code/tools/lcc/cpp/macro.c | 515 + code/tools/lcc/cpp/nlist.c | 104 + code/tools/lcc/cpp/tokens.c | 370 + code/tools/lcc/cpp/unix.c | 128 + code/tools/lcc/doc/4.html | 754 + code/tools/lcc/doc/bprint.1 | 83 + code/tools/lcc/doc/bprint.pdf | Bin 0 -> 4963 bytes code/tools/lcc/doc/install.html | 796 + code/tools/lcc/doc/lcc.1 | 605 + code/tools/lcc/doc/lcc.pdf | Bin 0 -> 16421 bytes code/tools/lcc/etc/bytecode.c | 66 + code/tools/lcc/etc/lcc.c | 797 + code/tools/lcc/lburg/gram.c | 682 + code/tools/lcc/lburg/gram.y | 202 + code/tools/lcc/lburg/lburg.1 | 179 + code/tools/lcc/lburg/lburg.c | 671 + code/tools/lcc/lburg/lburg.h | 65 + code/tools/lcc/src/alloc.c | 94 + code/tools/lcc/src/bind.c | 8 + code/tools/lcc/src/bytecode.c | 365 + code/tools/lcc/src/c.h | 723 + code/tools/lcc/src/config.h | 102 + code/tools/lcc/src/dag.c | 736 + code/tools/lcc/src/dagcheck.md | 210 + code/tools/lcc/src/decl.c | 1162 + code/tools/lcc/src/enode.c | 545 + code/tools/lcc/src/error.c | 137 + code/tools/lcc/src/event.c | 28 + code/tools/lcc/src/expr.c | 711 + code/tools/lcc/src/gen.c | 830 + code/tools/lcc/src/init.c | 318 + code/tools/lcc/src/inits.c | 7 + code/tools/lcc/src/input.c | 135 + code/tools/lcc/src/lex.c | 923 + code/tools/lcc/src/list.c | 56 + code/tools/lcc/src/main.c | 225 + code/tools/lcc/src/null.c | 74 + code/tools/lcc/src/output.c | 135 + code/tools/lcc/src/prof.c | 228 + code/tools/lcc/src/profio.c | 276 + code/tools/lcc/src/simp.c | 587 + code/tools/lcc/src/stmt.c | 696 + code/tools/lcc/src/string.c | 122 + code/tools/lcc/src/sym.c | 314 + code/tools/lcc/src/symbolic.c | 494 + code/tools/lcc/src/token.h | 133 + code/tools/lcc/src/trace.c | 181 + code/tools/lcc/src/tree.c | 223 + code/tools/lcc/src/types.c | 748 + code/tools/md5_2_skX/NOTES.txt | 25 + code/tools/md5_2_skX/doom3md5model.c | 1104 + code/tools/md5_2_skX/loadtiki.c | 593 + code/tools/md5_2_skX/md5_2_skX.c | 991 + code/tools/md5_2_skX/md5_2_skX.h | 192 + code/tools/md5_2_skX/misc_utils.c | 272 + code/tools/md5_2_skX/writeobj.c | 78 + code/tools/md5_2_skX/writeskl.c | 181 + code/tools/md5_2_skX/writetiki.c | 138 + code/tools/ommap/brush.c | 861 + code/tools/ommap/brush_primit.c | 52 + code/tools/ommap/bsp.c | 606 + code/tools/ommap/common/aselib.c | 933 + code/tools/ommap/common/aselib.h | 31 + code/tools/ommap/common/bspfile.c | 627 + code/tools/ommap/common/bspfile.h | 150 + code/tools/ommap/common/cmdlib.c | 1231 + code/tools/ommap/common/cmdlib.h | 161 + code/tools/ommap/common/imagelib.c | 1164 + code/tools/ommap/common/imagelib.h | 44 + code/tools/ommap/common/l3dslib.c | 300 + code/tools/ommap/common/l3dslib.h | 26 + code/tools/ommap/common/mathlib.c | 434 + code/tools/ommap/common/mathlib.h | 96 + code/tools/ommap/common/md4.c | 277 + code/tools/ommap/common/mutex.c | 197 + code/tools/ommap/common/mutex.h | 28 + code/tools/ommap/common/polylib.c | 740 + code/tools/ommap/common/polylib.h | 57 + code/tools/ommap/common/polyset.h | 51 + code/tools/ommap/common/qfiles.h | 489 + code/tools/ommap/common/scriplib.c | 400 + code/tools/ommap/common/scriplib.h | 55 + code/tools/ommap/common/surfaceflags.h | 72 + code/tools/ommap/common/threads.c | 441 + code/tools/ommap/common/threads.h | 31 + code/tools/ommap/common/trilib.c | 231 + code/tools/ommap/common/trilib.h | 27 + code/tools/ommap/facebsp.c | 379 + code/tools/ommap/fog.c | 554 + code/tools/ommap/gldraw.c | 294 + code/tools/ommap/glfile.c | 148 + code/tools/ommap/leakfile.c | 100 + code/tools/ommap/libs/cmdlib.h | 97 + code/tools/ommap/libs/cmdlib/cmdlib.cpp | 550 + code/tools/ommap/libs/cmdlib/cmdlib.vcproj | 156 + code/tools/ommap/libs/jpeg6/README | 385 + code/tools/ommap/libs/jpeg6/jchuff.h | 34 + code/tools/ommap/libs/jpeg6/jcomapi.cpp | 94 + code/tools/ommap/libs/jpeg6/jconfig.h | 41 + code/tools/ommap/libs/jpeg6/jdapimin.cpp | 400 + code/tools/ommap/libs/jpeg6/jdapistd.cpp | 275 + code/tools/ommap/libs/jpeg6/jdatasrc.cpp | 204 + code/tools/ommap/libs/jpeg6/jdcoefct.cpp | 725 + code/tools/ommap/libs/jpeg6/jdcolor.cpp | 367 + code/tools/ommap/libs/jpeg6/jdct.h | 176 + code/tools/ommap/libs/jpeg6/jddctmgr.cpp | 270 + code/tools/ommap/libs/jpeg6/jdhuff.cpp | 574 + code/tools/ommap/libs/jpeg6/jdhuff.h | 202 + code/tools/ommap/libs/jpeg6/jdinput.cpp | 381 + code/tools/ommap/libs/jpeg6/jdmainct.cpp | 512 + code/tools/ommap/libs/jpeg6/jdmarker.cpp | 1052 + code/tools/ommap/libs/jpeg6/jdmaster.cpp | 557 + code/tools/ommap/libs/jpeg6/jdpostct.cpp | 290 + code/tools/ommap/libs/jpeg6/jdsample.cpp | 478 + code/tools/ommap/libs/jpeg6/jdtrans.cpp | 122 + code/tools/ommap/libs/jpeg6/jerror.cpp | 231 + code/tools/ommap/libs/jpeg6/jerror.h | 273 + code/tools/ommap/libs/jpeg6/jfdctflt.cpp | 168 + code/tools/ommap/libs/jpeg6/jidctflt.cpp | 241 + code/tools/ommap/libs/jpeg6/jinclude.h | 91 + code/tools/ommap/libs/jpeg6/jmemmgr.cpp | 1115 + code/tools/ommap/libs/jpeg6/jmemnobs.cpp | 103 + code/tools/ommap/libs/jpeg6/jmemsys.h | 182 + code/tools/ommap/libs/jpeg6/jmorecfg.h | 346 + code/tools/ommap/libs/jpeg6/jpeg6.vcproj | 775 + code/tools/ommap/libs/jpeg6/jpegint.h | 388 + code/tools/ommap/libs/jpeg6/jpgload.cpp | 142 + code/tools/ommap/libs/jpeg6/jutils.cpp | 175 + code/tools/ommap/libs/jpeg6/jversion.h | 14 + code/tools/ommap/libs/jpeg6d.lib | Bin 0 -> 699544 bytes code/tools/ommap/libs/jpeglib.h | 1087 + code/tools/ommap/libs/pak/pak.vcproj | 236 + code/tools/ommap/libs/pak/pakstuff.cpp | 1211 + code/tools/ommap/libs/pak/unzip.cpp | 4546 ++++ code/tools/ommap/libs/pak/unzip.h | 300 + code/tools/ommap/libs/pakd.lib | Bin 0 -> 262102 bytes code/tools/ommap/libs/pakstuff.h | 141 + code/tools/ommap/libs/str.h | 214 + code/tools/ommap/light.c | 2149 ++ code/tools/ommap/light.h | 151 + code/tools/ommap/light_trace.c | 944 + code/tools/ommap/lightmaps.c | 398 + code/tools/ommap/lightv.c | 5750 +++++ code/tools/ommap/map.c | 1291 + code/tools/ommap/mesh.c | 682 + code/tools/ommap/mesh.h | 48 + code/tools/ommap/misc_model.c | 472 + code/tools/ommap/nodraw.c | 47 + code/tools/ommap/patch.c | 286 + code/tools/ommap/portals.c | 843 + code/tools/ommap/prtfile.c | 272 + code/tools/ommap/qbsp.h | 455 + code/tools/ommap/shaders.c | 642 + code/tools/ommap/shaders.h | 71 + code/tools/ommap/soundv.c | 5744 +++++ code/tools/ommap/surface.c | 1158 + code/tools/ommap/terrain.c | 1255 + code/tools/ommap/tjunction.c | 551 + code/tools/ommap/tree.c | 146 + code/tools/ommap/vis.c | 1197 + code/tools/ommap/vis.h | 162 + code/tools/ommap/visflow.c | 1657 ++ code/tools/ommap/writebsp.c | 418 + code/tools/testutils/conevent.cpp | 136 + code/tools/testutils/conevent.h | 44 + code/tools/testutils/main.cpp | 391 + code/tools/testutils/tests/array1.txt | 12 + code/tools/testutils/tests/hello.txt | 3 + .../tests/linked_private_script1.txt | 11 + .../tests/linked_private_script2.txt | 14 + code/tools/testutils/tests/make_array.txt | 9 + code/tools/testutils/tests/mutex.txt | 31 + code/tools/testutils/tests/targetname.txt | 17 + code/tools/testutils/ubersdk.h | 19 + code/tools/zlib/adler32.c | 179 + code/tools/zlib/compress.c | 80 + code/tools/zlib/crc32.c | 425 + code/tools/zlib/crc32.h | 441 + code/tools/zlib/deflate.c | 1967 ++ code/tools/zlib/deflate.h | 346 + code/tools/zlib/gzclose.c | 25 + code/tools/zlib/gzguts.h | 209 + code/tools/zlib/gzlib.c | 634 + code/tools/zlib/gzread.c | 594 + code/tools/zlib/gzwrite.c | 577 + code/tools/zlib/infback.c | 640 + code/tools/zlib/inffast.c | 340 + code/tools/zlib/inffast.h | 11 + code/tools/zlib/inffixed.h | 94 + code/tools/zlib/inflate.c | 1512 ++ code/tools/zlib/inflate.h | 122 + code/tools/zlib/inftrees.c | 306 + code/tools/zlib/inftrees.h | 62 + code/tools/zlib/trees.c | 1226 + code/tools/zlib/trees.h | 128 + code/tools/zlib/uncompr.c | 59 + code/tools/zlib/zconf.h | 511 + code/tools/zlib/zlib.h | 1768 ++ code/tools/zlib/zutil.c | 324 + code/tools/zlib/zutil.h | 253 + code/uilib/editfield.h | 42 + code/uilib/ucolor.cpp | 307 + code/uilib/ucolor.h | 89 + code/uilib/ui_extern.h | 88 + code/uilib/ui_init.cpp | 164 + code/uilib/ui_local.h | 37 + code/uilib/ui_public.h | 233 + code/uilib/uibind.cpp | 127 + code/uilib/uibind.h | 55 + code/uilib/uibindlist.cpp | 230 + code/uilib/uibindlist.h | 82 + code/uilib/uibutton.cpp | 247 + code/uilib/uibutton.h | 102 + code/uilib/uicheckbox.cpp | 150 + code/uilib/uicheckbox.h | 60 + code/uilib/uicommon.h | 23 + code/uilib/uiconsole.cpp | 496 + code/uilib/uiconsole.h | 172 + code/uilib/uidialog.cpp | 96 + code/uilib/uidialog.h | 47 + code/uilib/uifield.cpp | 80 + code/uilib/uifield.h | 46 + code/uilib/uifloatwnd.cpp | 189 + code/uilib/uifloatwnd.h | 79 + code/uilib/uifont.cpp | 352 + code/uilib/uifont.h | 54 + code/uilib/uiglobalgamelist.cpp | 37 + code/uilib/uiglobalgamelist.h | 37 + code/uilib/uihorizscroll.cpp | 230 + code/uilib/uihorizscroll.h | 77 + code/uilib/uilabel.cpp | 253 + code/uilib/uilabel.h | 72 + code/uilib/uilangamelist.cpp | 249 + code/uilib/uilangamelist.h | 90 + code/uilib/uilayout.cpp | 296 + code/uilib/uilayout.h | 52 + code/uilib/uilist.cpp | 160 + code/uilib/uilist.h | 74 + code/uilib/uilistbox.cpp | 284 + code/uilib/uilistbox.h | 95 + code/uilib/uilistctrl.cpp | 343 + code/uilib/uilistctrl.h | 107 + code/uilib/uimenu.cpp | 987 + code/uilib/uimenu.h | 110 + code/uilib/uimledit.cpp | 288 + code/uilib/uimledit.h | 90 + code/uilib/uinotepad.cpp | 266 + code/uilib/uinotepad.h | 106 + code/uilib/uipoint2d.h | 68 + code/uilib/uipopupmenu.cpp | 265 + code/uilib/uipopupmenu.h | 113 + code/uilib/uipulldownmenu.cpp | 255 + code/uilib/uipulldownmenu.h | 106 + code/uilib/uipulldownmenucontainer.cpp | 170 + code/uilib/uipulldownmenucontainer.h | 58 + code/uilib/uirect2d.h | 220 + code/uilib/uisize2d.h | 69 + code/uilib/uislider.cpp | 262 + code/uilib/uislider.h | 90 + code/uilib/uistatus.cpp | 183 + code/uilib/uistatus.h | 82 + code/uilib/uivertscroll.cpp | 232 + code/uilib/uivertscroll.h | 77 + code/uilib/uiwidget.cpp | 3236 +++ code/uilib/uiwidget.h | 370 + code/uilib/uiwinman.cpp | 1222 + code/uilib/uiwinman.h | 109 + code/uilib/ulist.h | 355 + code/uilib/usignal.h | 51 + cross-make-mingw.sh | 6 + ida/ida.h | 8299 +++++++ ida/ida_ui.h | 135 + ida/ui/cl_inv.h | 100 + ida/ui/cl_invrender.h | 43 + ida/ui/cl_uibind.h | 63 + ida/ui/cl_uidmbox.h | 37 + ida/ui/cl_uifilepicker.h | 30 + ida/ui/cl_uigmbox.h | 35 + ida/ui/cl_uilangame.h | 27 + ida/ui/cl_uiloadsave.h | 26 + ida/ui/cl_uimaprunner.h | 39 + ida/ui/cl_uiminicon.h | 32 + ida/ui/cl_uimpmappicker.h | 28 + ida/ui/cl_uiplayermodelpicker.h | 29 + ida/ui/cl_uiserverlist.h | 30 + ida/ui/cl_uisoundpicker.h | 25 + ida/ui/cl_uistd.h | 61 + ida/ui/cl_uiview3d.h | 37 + ida/ui/editfield.h | 32 + ida/ui/ucolor.h | 44 + ida/ui/uibind.h | 34 + ida/ui/uibindlist.h | 40 + ida/ui/uibutton.h | 44 + ida/ui/uicheckbox.h | 33 + ida/ui/uiconsole.h | 74 + ida/ui/uidialog.h | 28 + ida/ui/uifield.h | 27 + ida/ui/uifloatwnd.h | 40 + ida/ui/uifont.h | 30 + ida/ui/uiglobalgamelist.h | 25 + ida/ui/uihorizscroll.h | 42 + ida/ui/uilabel.h | 34 + ida/ui/uilangamelist.h | 47 + ida/ui/uilayout.h | 31 + ida/ui/uilist.h | 47 + ida/ui/uilistbox.h | 45 + ida/ui/uilistctrl.h | 58 + ida/ui/uimenu.h | 39 + ida/ui/uimledit.h | 48 + ida/ui/uinotepad.h | 58 + ida/ui/uipoint2d.h | 26 + ida/ui/uipopupmenu.h | 46 + ida/ui/uipulldownmenu.h | 42 + ida/ui/uipulldownmenucontainer.h | 28 + ida/ui/uirect2d.h | 26 + ida/ui/uisize2d.h | 26 + ida/ui/uislider.h | 51 + ida/ui/uistatus.h | 44 + ida/ui/uivertscroll.h | 40 + ida/ui/uiwidget.h | 107 + ida/ui/uiwinman.h | 44 + ida/ui/ulist.h | 33 + ida/ui/usignal.h | 33 + make-macosx-ub.sh | 232 + misc/def/cgame.def | 2 + misc/def/cgame_hook.def | 2 + misc/def/game.def | 2 + misc/def/mohui.def | 3 + misc/def/q3_ui.def | 3 + misc/def/ui.def | 3 + misc/flex/FlexLexer.h | 206 + misc/flex/README.txt | 64 + misc/flex/UNISTD_ERROR.readme | 4 + misc/flex/custom_build_rules/how_to_use.txt | 1 + .../win_flex_bison_custom_build.props | 43 + .../win_flex_bison_custom_build.targets | 178 + .../win_flex_bison_custom_build.xml | 521 + misc/flex/data/Makefile.am | 30 + misc/flex/data/Makefile.in | 1639 ++ misc/flex/data/README | 70 + misc/flex/data/bison.m4 | 610 + misc/flex/data/c++-skel.m4 | 26 + misc/flex/data/c++.m4 | 205 + misc/flex/data/c-like.m4 | 44 + misc/flex/data/c-skel.m4 | 26 + misc/flex/data/c.m4 | 722 + misc/flex/data/glr.c | 2589 +++ misc/flex/data/glr.cc | 346 + misc/flex/data/java-skel.m4 | 26 + misc/flex/data/java.m4 | 304 + misc/flex/data/lalr1.cc | 1143 + misc/flex/data/lalr1.java | 927 + misc/flex/data/location.cc | 299 + misc/flex/data/m4sugar/foreach.m4 | 362 + misc/flex/data/m4sugar/m4sugar.m4 | 3301 +++ misc/flex/data/stack.hh | 121 + misc/flex/data/xslt/bison.xsl | 105 + misc/flex/data/xslt/xml2dot.xsl | 397 + misc/flex/data/xslt/xml2text.xsl | 569 + misc/flex/data/xslt/xml2xhtml.xsl | 745 + misc/flex/data/yacc.c | 2065 ++ misc/flex/state.log | 0 misc/flex/win_bison.exe | Bin 0 -> 514048 bytes misc/flex/win_flex.exe | Bin 0 -> 546816 bytes misc/msvc10/cgame/cgame.vcproj | 334 + misc/msvc10/cgame_hook/cgame_hook.vcproj | 796 + misc/msvc10/game/game.vcproj | 1302 ++ misc/msvc10/omohaaded/omohaaded.vcproj | 680 + misc/msvc10/openmohaa/openmohaa.sln | 56 + misc/msvc10/openmohaa/openmohaa.vcproj | 1352 ++ misc/msvc10/testutils/testutils.vcproj | 538 + misc/msvc12_13/FLEX_Bison/FLEX_Bison.vcxproj | 160 + .../FLEX_Bison/FLEX_Bison.vcxproj.filters | 7 + misc/msvc12_13/cgame/cgame.vcxproj | 208 + misc/msvc12_13/cgame/cgame.vcxproj.filters | 129 + misc/msvc12_13/cgame_hook/cgame_hook.vcxproj | 246 + .../cgame_hook/cgame_hook.vcxproj.filters | 444 + misc/msvc12_13/game/game.vcxproj | 437 + misc/msvc12_13/game/game.vcxproj.filters | 795 + misc/msvc12_13/mohui/mohui.vcxproj | 178 + misc/msvc12_13/mohui/mohui.vcxproj.filters | 54 + misc/msvc12_13/omohaaded/omohaaded.vcxproj | 340 + .../omohaaded/omohaaded.vcxproj.filters | 445 + .../omohconverter/omohconverter.vcxproj | 315 + .../omohconverter.vcxproj.filters | 450 + misc/msvc12_13/openmohaa/openmohaa.sln | 132 + misc/msvc12_13/openmohaa/openmohaa.vcxproj | 791 + .../openmohaa/openmohaa.vcxproj.filters | 1468 ++ .../snippets/function_comment.snippet | 27 + misc/msvc12_13/testutils/testutils.vcxproj | 245 + .../testutils/testutils.vcxproj.filters | 288 + misc/nix/cgame/.cproject | 212 + misc/nix/cgame/.project | 209 + .../nix/cgame/.settings/language.settings.xml | 25 + misc/nix/cgame/headers/IGNORE | 0 misc/nix/cgame/src/IGNORE | 0 misc/nix/game/.cproject | 235 + misc/nix/game/.project | 1349 ++ misc/nix/game/.settings/language.settings.xml | 25 + misc/nix/game/headers/IGNORE | 0 misc/nix/game/parser/IGNORE | 0 misc/nix/game/src/IGNORE | 0 misc/nix/omohaaded/.cproject | 225 + misc/nix/omohaaded/.project | 615 + .../omohaaded/.settings/language.settings.xml | 25 + .../.settings/org.eclipse.cdt.core.prefs | 3 + .../org.eclipse.cdt.managedbuilder.core.prefs | 13 + misc/nix/omohaaded/headers/IGNORE | 0 misc/nix/omohaaded/src/botlib/IGNORE | 0 misc/nix/openmohaa/.cproject | 268 + misc/nix/openmohaa/.project | 1417 ++ .../openmohaa/.settings/language.settings.xml | 25 + misc/nix/openmohaa/headers/IGNORE | 0 misc/nix/openmohaa/src/botlib/IGNORE | 0 misc/nix/openmohaa/src/jpeg/IGNORE | 0 misc/nix/openmohaa/src/png/IGNORE | 0 misc/nix/openmohaa/zlib/IGNORE | 0 misc/nix/testutils/.cproject | 195 + misc/nix/testutils/.project | 409 + .../testutils/.settings/language.settings.xml | 25 + misc/nix/testutils/headers/IGNORE | 0 misc/nix/testutils/parser/IGNORE | 0 misc/nix/testutils/src/IGNORE | 0 misc/openmohaa.icns | Bin 0 -> 68021 bytes misc/openmohaa.ico | Bin 0 -> 43302 bytes misc/openmohaa.png | Bin 0 -> 10761 bytes misc/openmohaa.svg | 246 + misc/setup/MacOSX/SLA-dmg.sh | 73 + misc/setup/Makefile | 15 + misc/setup/Solaris_pkg.sh | 135 + misc/setup/doit | 112 + misc/setup/ioq3demo.sh | 50 + misc/setup/ioquake3.SlackBuild | 77 + misc/setup/ioquake3.sh | 50 + misc/setup/pkg/ioq3ded.sh | 41 + misc/setup/pkg/ioquake3.sh | 41 + misc/setup/pkg/ioquake3/depend | 3 + misc/setup/pkg/ioquake3/pkginfo.template | 12 + misc/setup/pkg/ioquake3/postinstall | 21 + misc/setup/pkg/ioquake3/postremove | 21 + misc/setup/pkg/ioquake3/preinstall | 10 + misc/setup/pkg/ioquake3/preremove | 10 + misc/setup/pkg/ioquake3/prototype.template | 8 + misc/setup/pkg/ioquake3/space | 1 + misc/setup/pkg/ioquake3d/depend | 2 + misc/setup/pkg/ioquake3d/pkginfo.template | 12 + misc/setup/pkg/ioquake3d/postinstall | 10 + misc/setup/pkg/ioquake3d/postremove | 10 + misc/setup/pkg/ioquake3d/preinstall | 10 + misc/setup/pkg/ioquake3d/preremove | 10 + misc/setup/pkg/ioquake3d/prototype.template | 7 + misc/setup/pkg/ioquake3d/space | 1 + misc/setup/preuninstall.sh | 2 + misc/setup/setup.xml.in | 111 + misc/setup/slack-desc | 12 + misc/setup/splash.xpm | 2289 ++ ui/hud.txt | 7 + ui/hud2.txt | 7 + ui/ingame.txt | 16 + ui/menudef.h | 311 + ui/menus.txt | 39 + 1594 files changed, 892326 insertions(+) create mode 100644 CHANGELOG.txt create mode 100644 COPYING.txt create mode 100644 LAYOUT.txt create mode 100644 Makefile create mode 100644 PLEASE_USE_VS2013.txt create mode 100644 README.txt create mode 100644 TODO.TXT create mode 100644 build/main/models/omtests/test01_bonetype1.tik create mode 100644 build/main/models/omtests/test01_bonetype1/readme.txt create mode 100644 build/main/models/omtests/test01_bonetype1/test01.md5mesh create mode 100644 build/main/models/omtests/test01_bonetype1/test01_bonetype1.RAY create mode 100644 build/main/models/omtests/test01_bonetype1/test01_bonetype1.skc create mode 100644 build/main/models/omtests/test01_bonetype1/test01_bonetype1.skd create mode 100644 build/main/models/omtests/test01_bonetype1/test01bones.md5mesh create mode 100644 build/main/models/omtests/testhoserot1.tik create mode 100644 build/main/models/omtests/testhoserot1/testhoserot1.RAY create mode 100644 build/main/models/omtests/testhoserot1/testhoserot1.md5mesh create mode 100644 build/main/models/omtests/testhoserot1/testhoserot1.skc create mode 100644 build/main/models/omtests/testhoserot1/testhoserot1.skd create mode 100644 code/AL/VERSION create mode 100644 code/AL/al.h create mode 100644 code/AL/alc.h create mode 100644 code/AL/alctypes.h create mode 100644 code/AL/altypes.h create mode 100644 code/AL/alut.h create mode 100644 code/SDL2/include/SDL.h create mode 100644 code/SDL2/include/SDL_assert.h create mode 100644 code/SDL2/include/SDL_atomic.h create mode 100644 code/SDL2/include/SDL_audio.h create mode 100644 code/SDL2/include/SDL_bits.h create mode 100644 code/SDL2/include/SDL_blendmode.h create mode 100644 code/SDL2/include/SDL_clipboard.h create mode 100644 code/SDL2/include/SDL_config.h create mode 100644 code/SDL2/include/SDL_config.h.cmake create mode 100644 code/SDL2/include/SDL_config.h.in create mode 100644 code/SDL2/include/SDL_config_android.h create mode 100644 code/SDL2/include/SDL_config_iphoneos.h create mode 100644 code/SDL2/include/SDL_config_macosx.h create mode 100644 code/SDL2/include/SDL_config_minimal.h create mode 100644 code/SDL2/include/SDL_config_pandora.h create mode 100644 code/SDL2/include/SDL_config_psp.h create mode 100644 code/SDL2/include/SDL_config_windows.h create mode 100644 code/SDL2/include/SDL_config_winrt.h create mode 100644 code/SDL2/include/SDL_config_wiz.h create mode 100644 code/SDL2/include/SDL_copying.h create mode 100644 code/SDL2/include/SDL_cpuinfo.h create mode 100644 code/SDL2/include/SDL_egl.h create mode 100644 code/SDL2/include/SDL_endian.h create mode 100644 code/SDL2/include/SDL_error.h create mode 100644 code/SDL2/include/SDL_events.h create mode 100644 code/SDL2/include/SDL_filesystem.h create mode 100644 code/SDL2/include/SDL_gamecontroller.h create mode 100644 code/SDL2/include/SDL_gesture.h create mode 100644 code/SDL2/include/SDL_haptic.h create mode 100644 code/SDL2/include/SDL_hints.h create mode 100644 code/SDL2/include/SDL_joystick.h create mode 100644 code/SDL2/include/SDL_keyboard.h create mode 100644 code/SDL2/include/SDL_keycode.h create mode 100644 code/SDL2/include/SDL_loadso.h create mode 100644 code/SDL2/include/SDL_log.h create mode 100644 code/SDL2/include/SDL_main.h create mode 100644 code/SDL2/include/SDL_messagebox.h create mode 100644 code/SDL2/include/SDL_mouse.h create mode 100644 code/SDL2/include/SDL_mutex.h create mode 100644 code/SDL2/include/SDL_name.h create mode 100644 code/SDL2/include/SDL_opengl.h create mode 100644 code/SDL2/include/SDL_opengles.h create mode 100644 code/SDL2/include/SDL_opengles2.h create mode 100644 code/SDL2/include/SDL_pixels.h create mode 100644 code/SDL2/include/SDL_platform.h create mode 100644 code/SDL2/include/SDL_power.h create mode 100644 code/SDL2/include/SDL_quit.h create mode 100644 code/SDL2/include/SDL_rect.h create mode 100644 code/SDL2/include/SDL_render.h create mode 100644 code/SDL2/include/SDL_revision.h create mode 100644 code/SDL2/include/SDL_rwops.h create mode 100644 code/SDL2/include/SDL_scancode.h create mode 100644 code/SDL2/include/SDL_shape.h create mode 100644 code/SDL2/include/SDL_stdinc.h create mode 100644 code/SDL2/include/SDL_surface.h create mode 100644 code/SDL2/include/SDL_system.h create mode 100644 code/SDL2/include/SDL_syswm.h create mode 100644 code/SDL2/include/SDL_test.h create mode 100644 code/SDL2/include/SDL_test_assert.h create mode 100644 code/SDL2/include/SDL_test_common.h create mode 100644 code/SDL2/include/SDL_test_compare.h create mode 100644 code/SDL2/include/SDL_test_crc32.h create mode 100644 code/SDL2/include/SDL_test_font.h create mode 100644 code/SDL2/include/SDL_test_fuzzer.h create mode 100644 code/SDL2/include/SDL_test_harness.h create mode 100644 code/SDL2/include/SDL_test_images.h create mode 100644 code/SDL2/include/SDL_test_log.h create mode 100644 code/SDL2/include/SDL_test_md5.h create mode 100644 code/SDL2/include/SDL_test_random.h create mode 100644 code/SDL2/include/SDL_thread.h create mode 100644 code/SDL2/include/SDL_timer.h create mode 100644 code/SDL2/include/SDL_touch.h create mode 100644 code/SDL2/include/SDL_types.h create mode 100644 code/SDL2/include/SDL_version.h create mode 100644 code/SDL2/include/SDL_video.h create mode 100644 code/SDL2/include/begin_code.h create mode 100644 code/SDL2/include/close_code.h create mode 100644 code/SDL2/include/doxyfile create mode 100644 code/asm/ftola.s create mode 100644 code/asm/matha.s create mode 100644 code/asm/qasm.h create mode 100644 code/asm/snapvectora.s create mode 100644 code/asm/snd_mixa.s create mode 100644 code/botlib/aasfile.h create mode 100644 code/botlib/be_aas.h create mode 100644 code/botlib/be_aas_bsp.h create mode 100644 code/botlib/be_aas_bspq3.c create mode 100644 code/botlib/be_aas_cluster.c create mode 100644 code/botlib/be_aas_cluster.h create mode 100644 code/botlib/be_aas_debug.c create mode 100644 code/botlib/be_aas_debug.h create mode 100644 code/botlib/be_aas_def.h create mode 100644 code/botlib/be_aas_entity.c create mode 100644 code/botlib/be_aas_entity.h create mode 100644 code/botlib/be_aas_file.c create mode 100644 code/botlib/be_aas_file.h create mode 100644 code/botlib/be_aas_funcs.h create mode 100644 code/botlib/be_aas_main.c create mode 100644 code/botlib/be_aas_main.h create mode 100644 code/botlib/be_aas_move.c create mode 100644 code/botlib/be_aas_move.h create mode 100644 code/botlib/be_aas_optimize.c create mode 100644 code/botlib/be_aas_optimize.h create mode 100644 code/botlib/be_aas_reach.c create mode 100644 code/botlib/be_aas_reach.h create mode 100644 code/botlib/be_aas_route.c create mode 100644 code/botlib/be_aas_route.h create mode 100644 code/botlib/be_aas_routealt.c create mode 100644 code/botlib/be_aas_routealt.h create mode 100644 code/botlib/be_aas_sample.c create mode 100644 code/botlib/be_aas_sample.h create mode 100644 code/botlib/be_ai_char.c create mode 100644 code/botlib/be_ai_char.h create mode 100644 code/botlib/be_ai_chat.c create mode 100644 code/botlib/be_ai_chat.h create mode 100644 code/botlib/be_ai_gen.c create mode 100644 code/botlib/be_ai_gen.h create mode 100644 code/botlib/be_ai_goal.c create mode 100644 code/botlib/be_ai_goal.h create mode 100644 code/botlib/be_ai_move.c create mode 100644 code/botlib/be_ai_move.h create mode 100644 code/botlib/be_ai_weap.c create mode 100644 code/botlib/be_ai_weap.h create mode 100644 code/botlib/be_ai_weight.c create mode 100644 code/botlib/be_ai_weight.h create mode 100644 code/botlib/be_ea.c create mode 100644 code/botlib/be_ea.h create mode 100644 code/botlib/be_interface.c create mode 100644 code/botlib/be_interface.h create mode 100644 code/botlib/botlib.h create mode 100644 code/botlib/l_crc.c create mode 100644 code/botlib/l_crc.h create mode 100644 code/botlib/l_libvar.c create mode 100644 code/botlib/l_libvar.h create mode 100644 code/botlib/l_log.c create mode 100644 code/botlib/l_log.h create mode 100644 code/botlib/l_memory.c create mode 100644 code/botlib/l_memory.h create mode 100644 code/botlib/l_precomp.c create mode 100644 code/botlib/l_precomp.h create mode 100644 code/botlib/l_script.c create mode 100644 code/botlib/l_script.h create mode 100644 code/botlib/l_struct.c create mode 100644 code/botlib/l_struct.h create mode 100644 code/botlib/l_utils.h create mode 100644 code/botlib/lcc.mak create mode 100644 code/botlib/linux-i386.mak create mode 100644 code/bspc/Conscript create mode 100644 code/bspc/Makefile create mode 100644 code/bspc/_files.c create mode 100644 code/bspc/aas_areamerging.c create mode 100644 code/bspc/aas_areamerging.h create mode 100644 code/bspc/aas_cfg.c create mode 100644 code/bspc/aas_cfg.h create mode 100644 code/bspc/aas_create.c create mode 100644 code/bspc/aas_create.h create mode 100644 code/bspc/aas_edgemelting.c create mode 100644 code/bspc/aas_edgemelting.h create mode 100644 code/bspc/aas_facemerging.c create mode 100644 code/bspc/aas_facemerging.h create mode 100644 code/bspc/aas_file.c create mode 100644 code/bspc/aas_file.h create mode 100644 code/bspc/aas_gsubdiv.c create mode 100644 code/bspc/aas_gsubdiv.h create mode 100644 code/bspc/aas_map.c create mode 100644 code/bspc/aas_map.h create mode 100644 code/bspc/aas_prunenodes.c create mode 100644 code/bspc/aas_prunenodes.h create mode 100644 code/bspc/aas_store.c create mode 100644 code/bspc/aas_store.h create mode 100644 code/bspc/aasfile.h create mode 100644 code/bspc/be_aas_bspc.c create mode 100644 code/bspc/be_aas_bspc.h create mode 100644 code/bspc/brushbsp.c create mode 100644 code/bspc/bspc.c create mode 100644 code/bspc/bspc.vcproj create mode 100644 code/bspc/cfgq3.c create mode 100644 code/bspc/csg.c create mode 100644 code/bspc/faces.c create mode 100644 code/bspc/gldraw.c create mode 100644 code/bspc/glfile.c create mode 100644 code/bspc/l_bsp_ent.c create mode 100644 code/bspc/l_bsp_ent.h create mode 100644 code/bspc/l_bsp_hl.c create mode 100644 code/bspc/l_bsp_hl.h create mode 100644 code/bspc/l_bsp_q1.c create mode 100644 code/bspc/l_bsp_q1.h create mode 100644 code/bspc/l_bsp_q3.c create mode 100644 code/bspc/l_bsp_q3.h create mode 100644 code/bspc/l_bsp_sin.c create mode 100644 code/bspc/l_bsp_sin.h create mode 100644 code/bspc/l_cmd.c create mode 100644 code/bspc/l_cmd.h create mode 100644 code/bspc/l_log.c create mode 100644 code/bspc/l_log.h create mode 100644 code/bspc/l_math.c create mode 100644 code/bspc/l_math.h create mode 100644 code/bspc/l_mem.c create mode 100644 code/bspc/l_mem.h create mode 100644 code/bspc/l_poly.c create mode 100644 code/bspc/l_poly.h create mode 100644 code/bspc/l_qfiles.c create mode 100644 code/bspc/l_qfiles.h create mode 100644 code/bspc/l_threads.c create mode 100644 code/bspc/l_threads.h create mode 100644 code/bspc/l_utils.c create mode 100644 code/bspc/l_utils.h create mode 100644 code/bspc/lcc.mak create mode 100644 code/bspc/leakfile.c create mode 100644 code/bspc/linux-i386.mak create mode 100644 code/bspc/map.c create mode 100644 code/bspc/map_hl.c create mode 100644 code/bspc/map_q1.c create mode 100644 code/bspc/map_q2.c create mode 100644 code/bspc/map_q3.c create mode 100644 code/bspc/map_sin.c create mode 100644 code/bspc/nodraw.c create mode 100644 code/bspc/portals.c create mode 100644 code/bspc/prtfile.c create mode 100644 code/bspc/q2files.h create mode 100644 code/bspc/q3files.h create mode 100644 code/bspc/qbsp.h create mode 100644 code/bspc/qfiles.h create mode 100644 code/bspc/sinfiles.h create mode 100644 code/bspc/tetrahedron.c create mode 100644 code/bspc/tetrahedron.h create mode 100644 code/bspc/textures.c create mode 100644 code/bspc/tree.c create mode 100644 code/bspc/writebsp.c create mode 100644 code/cgame/cg_beam.c create mode 100644 code/cgame/cg_consolecmds.c create mode 100644 code/cgame/cg_draw.c create mode 100644 code/cgame/cg_drawtools.c create mode 100644 code/cgame/cg_effects.c create mode 100644 code/cgame/cg_ents.c create mode 100644 code/cgame/cg_eventSystem.c create mode 100644 code/cgame/cg_info.c create mode 100644 code/cgame/cg_local.h create mode 100644 code/cgame/cg_localents.c create mode 100644 code/cgame/cg_main.c create mode 100644 code/cgame/cg_marks.c create mode 100644 code/cgame/cg_modelanim.c create mode 100644 code/cgame/cg_parsemsg.c create mode 100644 code/cgame/cg_particles.c create mode 100644 code/cgame/cg_players.c create mode 100644 code/cgame/cg_playerstate.c create mode 100644 code/cgame/cg_predict.c create mode 100644 code/cgame/cg_public.h create mode 100644 code/cgame/cg_rain.c create mode 100644 code/cgame/cg_servercmds.c create mode 100644 code/cgame/cg_snapshot.c create mode 100644 code/cgame/cg_specialfx.c create mode 100644 code/cgame/cg_ubersound.c create mode 100644 code/cgame/cg_view.c create mode 100644 code/cgame/cg_viewmodelanim.c create mode 100644 code/cgame/cg_weapons.c create mode 100644 code/cgame_hook/animate.h create mode 100644 code/cgame_hook/asm.h create mode 100644 code/cgame_hook/cgame/cg_hook.cpp create mode 100644 code/cgame_hook/cgame/cg_hook.h create mode 100644 code/cgame_hook/cgame/cg_hud.cpp create mode 100644 code/cgame_hook/cgame/cg_hud.h create mode 100644 code/cgame_hook/cgame/cg_parsemsg.cpp create mode 100644 code/cgame_hook/cgame/cg_servercmds.cpp create mode 100644 code/cgame_hook/cgame/cg_servercmds.h create mode 100644 code/cgame_hook/cgame/cg_viewmodelanim.cpp create mode 100644 code/cgame_hook/cgame/cg_viewmodelanim.h create mode 100644 code/cgame_hook/cgame/cl_sound.cpp create mode 100644 code/cgame_hook/cgame/cl_sound.h create mode 100644 code/cgame_hook/cgamex86.cpp create mode 100644 code/cgame_hook/cgamex86.h create mode 100644 code/cgame_hook/game.cpp create mode 100644 code/cgame_hook/game.h create mode 100644 code/cgame_hook/hook.cpp create mode 100644 code/cgame_hook/hook.h create mode 100644 code/cgame_hook/img/IMAGE.h create mode 100644 code/cgame_hook/img/IMAGE_CalculateStride.cpp create mode 100644 code/cgame_hook/img/IMAGE_ExpandPalette.cpp create mode 100644 code/cgame_hook/img/IMAGE_Load.cpp create mode 100644 code/cgame_hook/img/IMAGE_Load24BitBMP.cpp create mode 100644 code/cgame_hook/img/IMAGE_Load8BitBMP.cpp create mode 100644 code/cgame_hook/img/IMAGE_LoadAlpha.cpp create mode 100644 code/cgame_hook/img/IMAGE_LoadBMP.cpp create mode 100644 code/cgame_hook/img/IMAGE_LoadCompressedTrueColorTGA.cpp create mode 100644 code/cgame_hook/img/IMAGE_LoadTGA.cpp create mode 100644 code/cgame_hook/img/IMAGE_LoadUncompressed8BitTGA.cpp create mode 100644 code/cgame_hook/img/IMAGE_LoadUncompressedTrueColorTGA.cpp create mode 100644 code/cgame_hook/img/TORUS.cpp create mode 100644 code/cgame_hook/img/TORUS.h create mode 100644 code/cgame_hook/level.cpp create mode 100644 code/cgame_hook/level.h create mode 100644 code/cgame_hook/ogl/OtherOGL.cpp create mode 100644 code/cgame_hook/ogl/opengl32.cpp create mode 100644 code/cgame_hook/ogl/opengl_api.h create mode 100644 code/cgame_hook/renderer/glext.h create mode 100644 code/cgame_hook/renderer/qfx_glprogs.h create mode 100644 code/cgame_hook/renderer/qfx_hooks.cpp create mode 100644 code/cgame_hook/renderer/qfx_library.h create mode 100644 code/cgame_hook/renderer/qfx_log.cpp create mode 100644 code/cgame_hook/renderer/qfx_log.h create mode 100644 code/cgame_hook/renderer/qfx_opengl.cpp create mode 100644 code/cgame_hook/renderer/qfx_opengl.h create mode 100644 code/cgame_hook/renderer/qfx_renderer.cpp create mode 100644 code/cgame_hook/renderer/qfx_renderer.h create mode 100644 code/cgame_hook/renderer/qfx_settings.cpp create mode 100644 code/cgame_hook/renderer/qfx_settings.h create mode 100644 code/cgame_hook/renderer/qfx_shader.cpp create mode 100644 code/cgame_hook/renderer/qfx_shader.h create mode 100644 code/cgame_hook/renderer/r_postprocess.cpp create mode 100644 code/cgame_hook/renderer_api.h create mode 100644 code/cgame_hook/resource.h create mode 100644 code/cgame_hook/script/canimate.cpp create mode 100644 code/cgame_hook/script/canimate.h create mode 100644 code/cgame_hook/script/centity.cpp create mode 100644 code/cgame_hook/script/centity.h create mode 100644 code/cgame_hook/script/clientgamecommand.cpp create mode 100644 code/cgame_hook/script/clientgamecommand.h create mode 100644 code/cgame_hook/script/clientservercommand.cpp create mode 100644 code/cgame_hook/script/clientservercommand.h create mode 100644 code/cgame_hook/script/cplayer.cpp create mode 100644 code/cgame_hook/script/cplayer.h create mode 100644 code/cgame_hook/script/earthquake.cpp create mode 100644 code/cgame_hook/script/earthquake.h create mode 100644 code/cgame_hook/script/level.cpp create mode 100644 code/cgame_hook/script/level.h create mode 100644 code/cgame_hook/script/scriptslave.cpp create mode 100644 code/cgame_hook/script/scriptslave.h create mode 100644 code/cgame_hook/script/vision.h create mode 100644 code/client/cl_avi.cpp create mode 100644 code/client/cl_cgame.cpp create mode 100644 code/client/cl_cin.cpp create mode 100644 code/client/cl_console.cpp create mode 100644 code/client/cl_consolecmds.cpp create mode 100644 code/client/cl_curl.cpp create mode 100644 code/client/cl_curl.h create mode 100644 code/client/cl_input.cpp create mode 100644 code/client/cl_inv.cpp create mode 100644 code/client/cl_inv.h create mode 100644 code/client/cl_invrender.cpp create mode 100644 code/client/cl_invrender.h create mode 100644 code/client/cl_keys.cpp create mode 100644 code/client/cl_main.cpp create mode 100644 code/client/cl_net_chan.cpp create mode 100644 code/client/cl_parse.cpp create mode 100644 code/client/cl_scrn.cpp create mode 100644 code/client/cl_ui.c create mode 100644 code/client/cl_ui.cpp create mode 100644 code/client/cl_ui.h create mode 100644 code/client/cl_uibind.cpp create mode 100644 code/client/cl_uibind.h create mode 100644 code/client/cl_uidmbox.cpp create mode 100644 code/client/cl_uidmbox.h create mode 100644 code/client/cl_uifilepicker.cpp create mode 100644 code/client/cl_uifilepicker.h create mode 100644 code/client/cl_uigmbox.cpp create mode 100644 code/client/cl_uigmbox.h create mode 100644 code/client/cl_uilangame.cpp create mode 100644 code/client/cl_uilangame.h create mode 100644 code/client/cl_uiloadsave.cpp create mode 100644 code/client/cl_uiloadsave.h create mode 100644 code/client/cl_uimaprunner.cpp create mode 100644 code/client/cl_uimaprunner.h create mode 100644 code/client/cl_uiminicon.cpp create mode 100644 code/client/cl_uiminicon.h create mode 100644 code/client/cl_uimpmappicker.cpp create mode 100644 code/client/cl_uimpmappicker.h create mode 100644 code/client/cl_uiplayermodelpicker.cpp create mode 100644 code/client/cl_uiplayermodelpicker.h create mode 100644 code/client/cl_uiserverlist.cpp create mode 100644 code/client/cl_uiserverlist.h create mode 100644 code/client/cl_uisoundpicker.cpp create mode 100644 code/client/cl_uisoundpicker.h create mode 100644 code/client/cl_uistd.cpp create mode 100644 code/client/cl_uistd.h create mode 100644 code/client/cl_uiview3d.cpp create mode 100644 code/client/cl_uiview3d.h create mode 100644 code/client/client.h create mode 100644 code/client/keycodes.h create mode 100644 code/client/keys.h create mode 100644 code/client/qal.c create mode 100644 code/client/qal.h create mode 100644 code/client/skeletor_imports.cpp create mode 100644 code/client/snd_adpcm.c create mode 100644 code/client/snd_codec.c create mode 100644 code/client/snd_codec.h create mode 100644 code/client/snd_codec_mp3.c create mode 100644 code/client/snd_codec_ogg.c create mode 100644 code/client/snd_codec_wav.c create mode 100644 code/client/snd_dma_new.cpp create mode 100644 code/client/snd_local.h create mode 100644 code/client/snd_main.c create mode 100644 code/client/snd_mem.c create mode 100644 code/client/snd_mix.c create mode 100644 code/client/snd_openal_new.c create mode 100644 code/client/snd_public.h create mode 100644 code/client/snd_wavelet.c create mode 100644 code/client/usignal.cpp create mode 100644 code/game/PlayerStart.cpp create mode 100644 code/game/PlayerStart.h create mode 100644 code/game/VehicleCollisionEntity.cpp create mode 100644 code/game/VehicleCollisionEntity.h create mode 100644 code/game/VehicleSlot.cpp create mode 100644 code/game/VehicleSlot.h create mode 100644 code/game/VehicleSoundEntity.cpp create mode 100644 code/game/VehicleSoundEntity.h create mode 100644 code/game/actor.cpp create mode 100644 code/game/actor.h create mode 100644 code/game/actor_aim.cpp create mode 100644 code/game/actor_alarm.cpp create mode 100644 code/game/actor_anim.cpp create mode 100644 code/game/actor_animapi.cpp create mode 100644 code/game/actor_animcurious.cpp create mode 100644 code/game/actor_balcony.cpp create mode 100644 code/game/actor_cover.cpp create mode 100644 code/game/actor_curious.cpp create mode 100644 code/game/actor_disguise_common.cpp create mode 100644 code/game/actor_disguise_officier.cpp create mode 100644 code/game/actor_disguise_rover.cpp create mode 100644 code/game/actor_disguise_salute.cpp create mode 100644 code/game/actor_disguise_sentry.cpp create mode 100644 code/game/actor_dog.cpp create mode 100644 code/game/actor_grenade.cpp create mode 100644 code/game/actor_idle.cpp create mode 100644 code/game/actor_killed.cpp create mode 100644 code/game/actor_machinegunner.cpp create mode 100644 code/game/actor_noclip.cpp create mode 100644 code/game/actor_pain.cpp create mode 100644 code/game/actor_patrol.cpp create mode 100644 code/game/actor_runner.cpp create mode 100644 code/game/actor_turret.cpp create mode 100644 code/game/actor_weaponless.cpp create mode 100644 code/game/actorenemy.cpp create mode 100644 code/game/actorenemy.h create mode 100644 code/game/actorpath.cpp create mode 100644 code/game/actorpath.h create mode 100644 code/game/ammo.cpp create mode 100644 code/game/ammo.h create mode 100644 code/game/animate.cpp create mode 100644 code/game/animate.h create mode 100644 code/game/armor.cpp create mode 100644 code/game/armor.h create mode 100644 code/game/b_files.cpp create mode 100644 code/game/b_local.h create mode 100644 code/game/b_nav.cpp create mode 100644 code/game/b_navgen.cpp create mode 100644 code/game/barrels.cpp create mode 100644 code/game/barrels.h create mode 100644 code/game/be_aas.h create mode 100644 code/game/be_ai_char.h create mode 100644 code/game/be_ai_chat.h create mode 100644 code/game/be_ai_gen.h create mode 100644 code/game/be_ai_goal.h create mode 100644 code/game/be_ai_move.h create mode 100644 code/game/be_ai_weap.h create mode 100644 code/game/be_ea.h create mode 100644 code/game/beam.cpp create mode 100644 code/game/beam.h create mode 100644 code/game/bg_lib.cpp create mode 100644 code/game/bg_local.h create mode 100644 code/game/bg_misc.cpp create mode 100644 code/game/bg_pmove.cpp create mode 100644 code/game/bg_public.h create mode 100644 code/game/bg_slidemove.cpp create mode 100644 code/game/body.cpp create mode 100644 code/game/body.h create mode 100644 code/game/botlib.h create mode 100644 code/game/botmenudef.h create mode 100644 code/game/bspline.cpp create mode 100644 code/game/bspline.h create mode 100644 code/game/camera.cpp create mode 100644 code/game/camera.h create mode 100644 code/game/characterstate.cpp create mode 100644 code/game/characterstate.h create mode 100644 code/game/chars.h create mode 100644 code/game/container.cpp create mode 100644 code/game/container.h create mode 100644 code/game/crateobject.cpp create mode 100644 code/game/crateobject.h create mode 100644 code/game/debuglines.cpp create mode 100644 code/game/debuglines.h create mode 100644 code/game/decals.cpp create mode 100644 code/game/decals.h create mode 100644 code/game/dm_manager.cpp create mode 100644 code/game/dm_manager.h create mode 100644 code/game/dm_team.cpp create mode 100644 code/game/dm_team.h create mode 100644 code/game/doors.cpp create mode 100644 code/game/doors.h create mode 100644 code/game/earthquake.cpp create mode 100644 code/game/earthquake.h create mode 100644 code/game/effectentity.cpp create mode 100644 code/game/effectentity.h create mode 100644 code/game/entity.cpp create mode 100644 code/game/entity.h create mode 100644 code/game/events.h create mode 100644 code/game/explosion.cpp create mode 100644 code/game/explosion.h create mode 100644 code/game/g_active.cpp create mode 100644 code/game/g_arenas.cpp create mode 100644 code/game/g_bot.cpp create mode 100644 code/game/g_client.cpp create mode 100644 code/game/g_items.cpp create mode 100644 code/game/g_local.h create mode 100644 code/game/g_main.cpp create mode 100644 code/game/g_main.h create mode 100644 code/game/g_mem.cpp create mode 100644 code/game/g_mmove.cpp create mode 100644 code/game/g_phys.cpp create mode 100644 code/game/g_phys.h create mode 100644 code/game/g_public.h create mode 100644 code/game/g_session.cpp create mode 100644 code/game/g_utils.cpp create mode 100644 code/game/g_vmove.cpp create mode 100644 code/game/g_weapon.cpp create mode 100644 code/game/game.cpp create mode 100644 code/game/game.h create mode 100644 code/game/gamecmds.cpp create mode 100644 code/game/gamecmds.h create mode 100644 code/game/gamecvars.cpp create mode 100644 code/game/gamecvars.h create mode 100644 code/game/gibs.cpp create mode 100644 code/game/gibs.h create mode 100644 code/game/gravpath.cpp create mode 100644 code/game/gravpath.h create mode 100644 code/game/grenadehint.cpp create mode 100644 code/game/grenadehint.h create mode 100644 code/game/health.cpp create mode 100644 code/game/health.h create mode 100644 code/game/huddraw.cpp create mode 100644 code/game/huddraw.h create mode 100644 code/game/inv.h create mode 100644 code/game/inventoryitem.cpp create mode 100644 code/game/inventoryitem.h create mode 100644 code/game/ipfilter.cpp create mode 100644 code/game/ipfilter.h create mode 100644 code/game/item.cpp create mode 100644 code/game/item.h create mode 100644 code/game/level.cpp create mode 100644 code/game/level.h create mode 100644 code/game/light.cpp create mode 100644 code/game/light.h create mode 100644 code/game/lodthing.cpp create mode 100644 code/game/lodthing.h create mode 100644 code/game/match.h create mode 100644 code/game/misc.cpp create mode 100644 code/game/misc.h create mode 100644 code/game/movegrid.cpp create mode 100644 code/game/movegrid.h create mode 100644 code/game/mover.cpp create mode 100644 code/game/mover.h create mode 100644 code/game/nature.cpp create mode 100644 code/game/nature.h create mode 100644 code/game/navigate.cpp create mode 100644 code/game/navigate.h create mode 100644 code/game/player.cpp create mode 100644 code/game/player.h create mode 100644 code/game/player_combat.cpp create mode 100644 code/game/player_util.cpp create mode 100644 code/game/playerbot.cpp create mode 100644 code/game/playerbot.h create mode 100644 code/game/portal.cpp create mode 100644 code/game/portal.h create mode 100644 code/game/prioritystack.h create mode 100644 code/game/scriptslave.cpp create mode 100644 code/game/scriptslave.h create mode 100644 code/game/sentient.cpp create mode 100644 code/game/sentient.h create mode 100644 code/game/simpleactor.cpp create mode 100644 code/game/simpleactor.h create mode 100644 code/game/soundman.cpp create mode 100644 code/game/soundman.h create mode 100644 code/game/spawners.cpp create mode 100644 code/game/spawners.h create mode 100644 code/game/specialfx.cpp create mode 100644 code/game/specialfx.h create mode 100644 code/game/spline.h create mode 100644 code/game/stack.h create mode 100644 code/game/surfaceflags.h create mode 100644 code/game/syn.h create mode 100644 code/game/trigger.cpp create mode 100644 code/game/trigger.h create mode 100644 code/game/ulinklist.h create mode 100644 code/game/umap.h create mode 100644 code/game/vehicle.cpp create mode 100644 code/game/vehicle.h create mode 100644 code/game/vehicleturret.cpp create mode 100644 code/game/vehicleturret.h create mode 100644 code/game/viewthing.cpp create mode 100644 code/game/viewthing.h create mode 100644 code/game/weapon.cpp create mode 100644 code/game/weapon.h create mode 100644 code/game/weapturret.cpp create mode 100644 code/game/weapturret.h create mode 100644 code/game/weaputils.cpp create mode 100644 code/game/weaputils.h create mode 100644 code/game/windows.cpp create mode 100644 code/game/windows.h create mode 100644 code/globalcpp/Linklist.h create mode 100644 code/globalcpp/archive.cpp create mode 100644 code/globalcpp/archive.h create mode 100644 code/globalcpp/archive_dummy.cpp create mode 100644 code/globalcpp/baseimp.h create mode 100644 code/globalcpp/basemain.cpp create mode 100644 code/globalcpp/basemain.h create mode 100644 code/globalcpp/class.cpp create mode 100644 code/globalcpp/class.h create mode 100644 code/globalcpp/compiler.cpp create mode 100644 code/globalcpp/compiler.h create mode 100644 code/globalcpp/console.cpp create mode 100644 code/globalcpp/console.h create mode 100644 code/globalcpp/const_str.h create mode 100644 code/globalcpp/container.h create mode 100644 code/globalcpp/containerclass.h create mode 100644 code/globalcpp/crc32.h create mode 100644 code/globalcpp/dbgheap.cpp create mode 100644 code/globalcpp/dbgheap.h create mode 100644 code/globalcpp/dummy/dummy_base.cpp create mode 100644 code/globalcpp/dummy/dummy_base.h create mode 100644 code/globalcpp/dummy/dummy_game.cpp create mode 100644 code/globalcpp/dummy/dummy_level.cpp create mode 100644 code/globalcpp/dummy/game.h create mode 100644 code/globalcpp/dummy/level.h create mode 100644 code/globalcpp/g_spawn.cpp create mode 100644 code/globalcpp/g_spawn.h create mode 100644 code/globalcpp/gamescript.cpp create mode 100644 code/globalcpp/gamescript.h create mode 100644 code/globalcpp/glb_local.h create mode 100644 code/globalcpp/hud.cpp create mode 100644 code/globalcpp/hud.h create mode 100644 code/globalcpp/listener.cpp create mode 100644 code/globalcpp/listener.h create mode 100644 code/globalcpp/lz77.cpp create mode 100644 code/globalcpp/lz77.h create mode 100644 code/globalcpp/md5.cpp create mode 100644 code/globalcpp/md5.h create mode 100644 code/globalcpp/object.cpp create mode 100644 code/globalcpp/object.h create mode 100644 code/globalcpp/parm.cpp create mode 100644 code/globalcpp/parm.h create mode 100644 code/globalcpp/parser/parsetree.cpp create mode 100644 code/globalcpp/parser/parsetree.h create mode 100644 code/globalcpp/parser/yyLexer.cpp create mode 100644 code/globalcpp/parser/yyLexer.h create mode 100644 code/globalcpp/parser/yyLexer.l create mode 100644 code/globalcpp/parser/yyParser.cpp create mode 100644 code/globalcpp/parser/yyParser.h create mode 100644 code/globalcpp/parser/yyParser.yy create mode 100644 code/globalcpp/safeptr.h create mode 100644 code/globalcpp/script.cpp create mode 100644 code/globalcpp/script.h create mode 100644 code/globalcpp/scriptexception.cpp create mode 100644 code/globalcpp/scriptexception.h create mode 100644 code/globalcpp/scriptmaster.cpp create mode 100644 code/globalcpp/scriptmaster.h create mode 100644 code/globalcpp/scriptopcodes.cpp create mode 100644 code/globalcpp/scriptopcodes.h create mode 100644 code/globalcpp/scripttimer.cpp create mode 100644 code/globalcpp/scripttimer.h create mode 100644 code/globalcpp/scriptvariable.cpp create mode 100644 code/globalcpp/scriptvariable.h create mode 100644 code/globalcpp/scriptvm.cpp create mode 100644 code/globalcpp/scriptvm.h create mode 100644 code/globalcpp/simpleentity.cpp create mode 100644 code/globalcpp/simpleentity.h create mode 100644 code/globalcpp/slre.c create mode 100644 code/globalcpp/slre.h create mode 100644 code/globalcpp/vector.h create mode 100644 code/globalcpp/world.cpp create mode 100644 code/globalcpp/world.h create mode 100644 code/jpeg-8c/README create mode 100644 code/jpeg-8c/jaricom.c create mode 100644 code/jpeg-8c/jcapimin.c create mode 100644 code/jpeg-8c/jcapistd.c create mode 100644 code/jpeg-8c/jcarith.c create mode 100644 code/jpeg-8c/jccoefct.c create mode 100644 code/jpeg-8c/jccolor.c create mode 100644 code/jpeg-8c/jcdctmgr.c create mode 100644 code/jpeg-8c/jchuff.c create mode 100644 code/jpeg-8c/jcinit.c create mode 100644 code/jpeg-8c/jcmainct.c create mode 100644 code/jpeg-8c/jcmarker.c create mode 100644 code/jpeg-8c/jcmaster.c create mode 100644 code/jpeg-8c/jcomapi.c create mode 100644 code/jpeg-8c/jconfig.h create mode 100644 code/jpeg-8c/jcparam.c create mode 100644 code/jpeg-8c/jcprepct.c create mode 100644 code/jpeg-8c/jcsample.c create mode 100644 code/jpeg-8c/jctrans.c create mode 100644 code/jpeg-8c/jdapimin.c create mode 100644 code/jpeg-8c/jdapistd.c create mode 100644 code/jpeg-8c/jdarith.c create mode 100644 code/jpeg-8c/jdatadst.c create mode 100644 code/jpeg-8c/jdatasrc.c create mode 100644 code/jpeg-8c/jdcoefct.c create mode 100644 code/jpeg-8c/jdcolor.c create mode 100644 code/jpeg-8c/jdct.h create mode 100644 code/jpeg-8c/jddctmgr.c create mode 100644 code/jpeg-8c/jdhuff.c create mode 100644 code/jpeg-8c/jdinput.c create mode 100644 code/jpeg-8c/jdmainct.c create mode 100644 code/jpeg-8c/jdmarker.c create mode 100644 code/jpeg-8c/jdmaster.c create mode 100644 code/jpeg-8c/jdmerge.c create mode 100644 code/jpeg-8c/jdpostct.c create mode 100644 code/jpeg-8c/jdsample.c create mode 100644 code/jpeg-8c/jdtrans.c create mode 100644 code/jpeg-8c/jerror.c create mode 100644 code/jpeg-8c/jerror.h create mode 100644 code/jpeg-8c/jfdctflt.c create mode 100644 code/jpeg-8c/jfdctfst.c create mode 100644 code/jpeg-8c/jfdctint.c create mode 100644 code/jpeg-8c/jidctflt.c create mode 100644 code/jpeg-8c/jidctfst.c create mode 100644 code/jpeg-8c/jidctint.c create mode 100644 code/jpeg-8c/jinclude.h create mode 100644 code/jpeg-8c/jmemmgr.c create mode 100644 code/jpeg-8c/jmemnobs.c create mode 100644 code/jpeg-8c/jmemsys.h create mode 100644 code/jpeg-8c/jmorecfg.h create mode 100644 code/jpeg-8c/jpegint.h create mode 100644 code/jpeg-8c/jpeglib.h create mode 100644 code/jpeg-8c/jquant1.c create mode 100644 code/jpeg-8c/jquant2.c create mode 100644 code/jpeg-8c/jutils.c create mode 100644 code/jpeg-8c/jversion.h create mode 100644 code/libcurl/curl/curl.h create mode 100644 code/libcurl/curl/curlver.h create mode 100644 code/libcurl/curl/easy.h create mode 100644 code/libcurl/curl/mprintf.h create mode 100644 code/libcurl/curl/multi.h create mode 100644 code/libcurl/curl/stdcheaders.h create mode 100644 code/libcurl/curl/types.h create mode 100644 code/libmad/include/mad.h create mode 100644 code/libs/macosx/libSDL-1.2.0.dylib create mode 100644 code/libs/macosx/libSDLmain.a create mode 100644 code/libs/nix/libSDL.a create mode 100644 code/libs/nix/libSDLmain.a create mode 100644 code/libs/nix/libcurl.a create mode 100644 code/libs/nix/libmad.a create mode 100644 code/libs/nix/libopenal32.a create mode 100644 code/libs/win32/OpenAL32.lib create mode 100644 code/libs/win32/SDL2.dll create mode 100644 code/libs/win32/SDL2.lib create mode 100644 code/libs/win32/SDL2main.lib create mode 100644 code/libs/win32/glew32.lib create mode 100644 code/libs/win32/glew32s.lib create mode 100644 code/libs/win32/libmad.lib create mode 100644 code/libs/win64/OpenAL32.lib create mode 100644 code/libs/win64/SDL2.dll create mode 100644 code/libs/win64/SDL2.lib create mode 100644 code/libs/win64/SDL2main.lib create mode 100644 code/libs/win64/SDL2test.lib create mode 100644 code/libs/win64/glew32.lib create mode 100644 code/libs/win64/glew32s.lib create mode 100644 code/libs/win64/libmad.lib create mode 100644 code/mohcgame/cg_consolecmds.c create mode 100644 code/mohcgame/cg_draw.c create mode 100644 code/mohcgame/cg_local.h create mode 100644 code/mohcgame/cg_main.c create mode 100644 code/mohcgame/cg_public.h create mode 100644 code/mohcgame/cg_servercmds.c create mode 100644 code/mohcgame/cg_syscalls.c create mode 100644 code/mohcgame/cg_view.c create mode 100644 code/mohui/ui_local.h create mode 100644 code/mohui/ui_main.cpp create mode 100644 code/mohui/ui_model.cpp create mode 100644 code/mohui/ui_public.h create mode 100644 code/mohui/ui_quarks.cpp create mode 100644 code/mohui/ui_syscalls.c create mode 100644 code/mohui/ui_urc.cpp create mode 100644 code/null/mac_net.c create mode 100644 code/null/null_client.c create mode 100644 code/null/null_cm.c create mode 100644 code/null/null_glimp.c create mode 100644 code/null/null_input.c create mode 100644 code/null/null_main.c create mode 100644 code/null/null_net.c create mode 100644 code/null/null_server.c create mode 100644 code/null/null_snddma.c create mode 100644 code/null/null_sys.c create mode 100644 code/null/null_tiki.c create mode 100644 code/png/png.c create mode 100644 code/png/png.h create mode 100644 code/png/pngconf.h create mode 100644 code/png/pngdebug.h create mode 100644 code/png/pngerror.c create mode 100644 code/png/pngget.c create mode 100644 code/png/pnginfo.h create mode 100644 code/png/pnglibconf.h create mode 100644 code/png/pngmem.c create mode 100644 code/png/pngpread.c create mode 100644 code/png/pngpriv.h create mode 100644 code/png/pngread.c create mode 100644 code/png/pngrio.c create mode 100644 code/png/pngrtran.c create mode 100644 code/png/pngrutil.c create mode 100644 code/png/pngset.c create mode 100644 code/png/pngstruct.h create mode 100644 code/png/pngtrans.c create mode 100644 code/png/pngwio.c create mode 100644 code/png/pngwrite.c create mode 100644 code/png/pngwtran.c create mode 100644 code/png/pngwutil.c create mode 100644 code/png/zconf.h create mode 100644 code/png/zlib.h create mode 100644 code/qcommon/alias.c create mode 100644 code/qcommon/alias.h create mode 100644 code/qcommon/cm_fencemask.c create mode 100644 code/qcommon/cm_load.c create mode 100644 code/qcommon/cm_local.h create mode 100644 code/qcommon/cm_patch.c create mode 100644 code/qcommon/cm_patch.h create mode 100644 code/qcommon/cm_polylib.c create mode 100644 code/qcommon/cm_polylib.h create mode 100644 code/qcommon/cm_public.h create mode 100644 code/qcommon/cm_terrain.c create mode 100644 code/qcommon/cm_terrain.h create mode 100644 code/qcommon/cm_test.c create mode 100644 code/qcommon/cm_trace.c create mode 100644 code/qcommon/cm_trace_lbd.cpp create mode 100644 code/qcommon/cmd.c create mode 100644 code/qcommon/common.cpp create mode 100644 code/qcommon/con_arrayset.h create mode 100644 code/qcommon/con_set.cpp create mode 100644 code/qcommon/con_set.h create mode 100644 code/qcommon/configurator.cpp create mode 100644 code/qcommon/configurator.h create mode 100644 code/qcommon/crc.c create mode 100644 code/qcommon/crc.h create mode 100644 code/qcommon/cvar.c create mode 100644 code/qcommon/files.c create mode 100644 code/qcommon/huffman.c create mode 100644 code/qcommon/localization.cpp create mode 100644 code/qcommon/localization.h create mode 100644 code/qcommon/md4.c create mode 100644 code/qcommon/md5.c create mode 100644 code/qcommon/mem_blockalloc.cpp create mode 100644 code/qcommon/mem_blockalloc.h create mode 100644 code/qcommon/mem_tempalloc.cpp create mode 100644 code/qcommon/mem_tempalloc.h create mode 100644 code/qcommon/memory.c create mode 100644 code/qcommon/msg.c create mode 100644 code/qcommon/net_chan.c create mode 100644 code/qcommon/net_ip.c create mode 100644 code/qcommon/puff.c create mode 100644 code/qcommon/puff.h create mode 100644 code/qcommon/q_math.c create mode 100644 code/qcommon/q_platform.h create mode 100644 code/qcommon/q_shared.c create mode 100644 code/qcommon/q_shared.h create mode 100644 code/qcommon/qcommon.h create mode 100644 code/qcommon/qfiles.h create mode 100644 code/qcommon/queue.h create mode 100644 code/qcommon/short3.h create mode 100644 code/qcommon/stack.h create mode 100644 code/qcommon/str.cpp create mode 100644 code/qcommon/str.h create mode 100644 code/qcommon/surfaceflags.h create mode 100644 code/qcommon/tiki.h create mode 100644 code/qcommon/tiki_script.cpp create mode 100644 code/qcommon/tiki_script.h create mode 100644 code/qcommon/unistd.h create mode 100644 code/qcommon/unzip.c create mode 100644 code/qcommon/unzip.h create mode 100644 code/qcommon/vm.c create mode 100644 code/qcommon/vm_interpreted.c create mode 100644 code/qcommon/vm_local.h create mode 100644 code/qcommon/vm_none.c create mode 100644 code/qcommon/vm_ppc.c create mode 100644 code/qcommon/vm_x86.c create mode 100644 code/qcommon/vm_x86_64.c create mode 100644 code/qcommon/vm_x86_64_assembler.c create mode 100644 code/renderer_gl3/gl_shader.cpp create mode 100644 code/renderer_gl3/gl_shader.h create mode 100644 code/renderer_gl3/sdl_gamma.c create mode 100644 code/renderer_gl3/sdl_glimp.c create mode 100644 code/renderer_gl3/tr_animation.c create mode 100644 code/renderer_gl3/tr_animation_mdm.c create mode 100644 code/renderer_gl3/tr_backend.cpp create mode 100644 code/renderer_gl3/tr_bsp.c create mode 100644 code/renderer_gl3/tr_cmds.c create mode 100644 code/renderer_gl3/tr_curve.c create mode 100644 code/renderer_gl3/tr_decals.c create mode 100644 code/renderer_gl3/tr_fbo.c create mode 100644 code/renderer_gl3/tr_flares.c create mode 100644 code/renderer_gl3/tr_font.c create mode 100644 code/renderer_gl3/tr_image.c create mode 100644 code/renderer_gl3/tr_image_dds.c create mode 100644 code/renderer_gl3/tr_image_exr.cpp create mode 100644 code/renderer_gl3/tr_image_jpg.c create mode 100644 code/renderer_gl3/tr_image_png.c create mode 100644 code/renderer_gl3/tr_image_tga.c create mode 100644 code/renderer_gl3/tr_image_webp.c create mode 100644 code/renderer_gl3/tr_init.cpp create mode 100644 code/renderer_gl3/tr_light.c create mode 100644 code/renderer_gl3/tr_local.h create mode 100644 code/renderer_gl3/tr_main.c create mode 100644 code/renderer_gl3/tr_marks.c create mode 100644 code/renderer_gl3/tr_mesh.c create mode 100644 code/renderer_gl3/tr_model.c create mode 100644 code/renderer_gl3/tr_model_md3.c create mode 100644 code/renderer_gl3/tr_model_md5.c create mode 100644 code/renderer_gl3/tr_model_mdc.c create mode 100644 code/renderer_gl3/tr_model_mdm.c create mode 100644 code/renderer_gl3/tr_model_psk.c create mode 100644 code/renderer_gl3/tr_model_skel.c create mode 100644 code/renderer_gl3/tr_model_skel.h create mode 100644 code/renderer_gl3/tr_noise.c create mode 100644 code/renderer_gl3/tr_scene.c create mode 100644 code/renderer_gl3/tr_shade.cpp create mode 100644 code/renderer_gl3/tr_shade_calc.c create mode 100644 code/renderer_gl3/tr_shader.c create mode 100644 code/renderer_gl3/tr_shadows.c create mode 100644 code/renderer_gl3/tr_skin.c create mode 100644 code/renderer_gl3/tr_sky.cpp create mode 100644 code/renderer_gl3/tr_surface.c create mode 100644 code/renderer_gl3/tr_vbo.c create mode 100644 code/renderer_gl3/tr_world.cpp create mode 100644 code/renderer_gl3/xreal_qfiles.h create mode 100644 code/renderercommon/iqm.h create mode 100644 code/renderercommon/qgl.h create mode 100644 code/renderercommon/tr_common.h create mode 100644 code/renderercommon/tr_font.c create mode 100644 code/renderercommon/tr_image_bmp.c create mode 100644 code/renderercommon/tr_image_jpg.c create mode 100644 code/renderercommon/tr_image_pcx.c create mode 100644 code/renderercommon/tr_image_png.c create mode 100644 code/renderercommon/tr_image_tga.c create mode 100644 code/renderercommon/tr_noise.c create mode 100644 code/renderercommon/tr_public.h create mode 100644 code/renderercommon/tr_types.h create mode 100644 code/renderergl2/glsl/bokeh_fp.glsl create mode 100644 code/renderergl2/glsl/bokeh_vp.glsl create mode 100644 code/renderergl2/glsl/calclevels4x_fp.glsl create mode 100644 code/renderergl2/glsl/calclevels4x_vp.glsl create mode 100644 code/renderergl2/glsl/depthblur_fp.glsl create mode 100644 code/renderergl2/glsl/depthblur_vp.glsl create mode 100644 code/renderergl2/glsl/dlight_fp.glsl create mode 100644 code/renderergl2/glsl/dlight_vp.glsl create mode 100644 code/renderergl2/glsl/down4x_fp.glsl create mode 100644 code/renderergl2/glsl/down4x_vp.glsl create mode 100644 code/renderergl2/glsl/fogpass_fp.glsl create mode 100644 code/renderergl2/glsl/fogpass_vp.glsl create mode 100644 code/renderergl2/glsl/generic_fp.glsl create mode 100644 code/renderergl2/glsl/generic_vp.glsl create mode 100644 code/renderergl2/glsl/lightall_fp.glsl create mode 100644 code/renderergl2/glsl/lightall_vp.glsl create mode 100644 code/renderergl2/glsl/pshadow_fp.glsl create mode 100644 code/renderergl2/glsl/pshadow_vp.glsl create mode 100644 code/renderergl2/glsl/shadowfill_fp.glsl create mode 100644 code/renderergl2/glsl/shadowfill_vp.glsl create mode 100644 code/renderergl2/glsl/shadowmask_fp.glsl create mode 100644 code/renderergl2/glsl/shadowmask_vp.glsl create mode 100644 code/renderergl2/glsl/ssao_fp.glsl create mode 100644 code/renderergl2/glsl/ssao_vp.glsl create mode 100644 code/renderergl2/glsl/texturecolor_fp.glsl create mode 100644 code/renderergl2/glsl/texturecolor_vp.glsl create mode 100644 code/renderergl2/glsl/tonemap_fp.glsl create mode 100644 code/renderergl2/glsl/tonemap_vp.glsl create mode 100644 code/renderergl2/tr_animation.c create mode 100644 code/renderergl2/tr_backend.c create mode 100644 code/renderergl2/tr_bsp.c create mode 100644 code/renderergl2/tr_cmds.c create mode 100644 code/renderergl2/tr_curve.c create mode 100644 code/renderergl2/tr_draw.c create mode 100644 code/renderergl2/tr_extensions.c create mode 100644 code/renderergl2/tr_extramath.c create mode 100644 code/renderergl2/tr_extramath.h create mode 100644 code/renderergl2/tr_extratypes.h create mode 100644 code/renderergl2/tr_fbo.c create mode 100644 code/renderergl2/tr_fbo.h create mode 100644 code/renderergl2/tr_flares.c create mode 100644 code/renderergl2/tr_glsl.c create mode 100644 code/renderergl2/tr_image.c create mode 100644 code/renderergl2/tr_init.c create mode 100644 code/renderergl2/tr_light.c create mode 100644 code/renderergl2/tr_local.h create mode 100644 code/renderergl2/tr_main.c create mode 100644 code/renderergl2/tr_marks.c create mode 100644 code/renderergl2/tr_mesh.c create mode 100644 code/renderergl2/tr_model.cpp create mode 100644 code/renderergl2/tr_model_iqm.c create mode 100644 code/renderergl2/tr_postprocess.c create mode 100644 code/renderergl2/tr_postprocess.h create mode 100644 code/renderergl2/tr_progs.c create mode 100644 code/renderergl2/tr_scene.c create mode 100644 code/renderergl2/tr_shade.c create mode 100644 code/renderergl2/tr_shade_calc.c create mode 100644 code/renderergl2/tr_shader.c create mode 100644 code/renderergl2/tr_shadows.c create mode 100644 code/renderergl2/tr_sky.c create mode 100644 code/renderergl2/tr_sprite.c create mode 100644 code/renderergl2/tr_staticmodels.cpp create mode 100644 code/renderergl2/tr_subs.c create mode 100644 code/renderergl2/tr_surface.c create mode 100644 code/renderergl2/tr_swipe.cpp create mode 100644 code/renderergl2/tr_terrain.c create mode 100644 code/renderergl2/tr_util.cpp create mode 100644 code/renderergl2/tr_vbo.c create mode 100644 code/renderergl2/tr_world.c create mode 100644 code/sdl/sdl_gamma.c create mode 100644 code/sdl/sdl_glimp.c create mode 100644 code/sdl/sdl_icon.h create mode 100644 code/sdl/sdl_input.c create mode 100644 code/sdl/sdl_snd.c create mode 100644 code/server/game.cpp create mode 100644 code/server/game.h create mode 100644 code/server/level.cpp create mode 100644 code/server/level.h create mode 100644 code/server/server.h create mode 100644 code/server/sv_bot.c create mode 100644 code/server/sv_ccmds.c create mode 100644 code/server/sv_client.c create mode 100644 code/server/sv_game.c create mode 100644 code/server/sv_init.c create mode 100644 code/server/sv_main.c create mode 100644 code/server/sv_net_chan.c create mode 100644 code/server/sv_rankings.c create mode 100644 code/server/sv_snapshot.c create mode 100644 code/server/sv_snd.c create mode 100644 code/server/sv_world.c create mode 100644 code/skeletor/SkelMat3.h create mode 100644 code/skeletor/SkelMat4.h create mode 100644 code/skeletor/SkelQuat.h create mode 100644 code/skeletor/SkelVec3.h create mode 100644 code/skeletor/SkelVec4.h create mode 100644 code/skeletor/bonetable.cpp create mode 100644 code/skeletor/skeletor.cpp create mode 100644 code/skeletor/skeletor.h create mode 100644 code/skeletor/skeletor_animation_file_format.h create mode 100644 code/skeletor/skeletor_internal.h create mode 100644 code/skeletor/skeletor_loadanimation.cpp create mode 100644 code/skeletor/skeletor_model_file_format.h create mode 100644 code/skeletor/skeletor_model_files.cpp create mode 100644 code/skeletor/skeletor_name_lists.h create mode 100644 code/skeletor/skeletor_utilities.cpp create mode 100644 code/skeletor/skeletorbones.cpp create mode 100644 code/skeletor/tokenizer.cpp create mode 100644 code/skeletor/tokenizer.h create mode 100644 code/sys/con_log.c create mode 100644 code/sys/con_passive.c create mode 100644 code/sys/con_tty.c create mode 100644 code/sys/con_win32.c create mode 100644 code/sys/sys_loadlib.h create mode 100644 code/sys/sys_local.h create mode 100644 code/sys/sys_main.c create mode 100644 code/sys/sys_unix.c create mode 100644 code/sys/sys_win32.c create mode 100644 code/sys/win_resource.h create mode 100644 code/sys/win_resource.rc create mode 100644 code/tiki/tiki_anim.cpp create mode 100644 code/tiki/tiki_anim.h create mode 100644 code/tiki/tiki_cache.cpp create mode 100644 code/tiki/tiki_cache.h create mode 100644 code/tiki/tiki_commands.cpp create mode 100644 code/tiki/tiki_commands.h create mode 100644 code/tiki/tiki_files.cpp create mode 100644 code/tiki/tiki_files.h create mode 100644 code/tiki/tiki_frame.cpp create mode 100644 code/tiki/tiki_frame.h create mode 100644 code/tiki/tiki_imports.cpp create mode 100644 code/tiki/tiki_imports.h create mode 100644 code/tiki/tiki_main.cpp create mode 100644 code/tiki/tiki_main.h create mode 100644 code/tiki/tiki_parse.cpp create mode 100644 code/tiki/tiki_parse.h create mode 100644 code/tiki/tiki_shared.h create mode 100644 code/tiki/tiki_skel.cpp create mode 100644 code/tiki/tiki_skel.h create mode 100644 code/tiki/tiki_surface.cpp create mode 100644 code/tiki/tiki_surface.h create mode 100644 code/tiki/tiki_tag.cpp create mode 100644 code/tiki/tiki_tag.h create mode 100644 code/tiki/tiki_utility.cpp create mode 100644 code/tiki/tiki_utility.h create mode 100644 code/tools/GL/glew.h create mode 100644 code/tools/GL/glxew.h create mode 100644 code/tools/GL/wglew.h create mode 100644 code/tools/asm/README.Id create mode 100644 code/tools/asm/cmdlib.c create mode 100644 code/tools/asm/cmdlib.h create mode 100644 code/tools/asm/lib.txt create mode 100644 code/tools/asm/mathlib.h create mode 100644 code/tools/asm/notes.txt create mode 100644 code/tools/asm/ops.txt create mode 100644 code/tools/asm/opstrings.h create mode 100644 code/tools/asm/q3asm.c create mode 100644 code/tools/cgame_wrapper/cg_consolecmds.c create mode 100644 code/tools/cgame_wrapper/cg_draw.c create mode 100644 code/tools/cgame_wrapper/cg_main.c create mode 100644 code/tools/cgame_wrapper/cg_skeletor.c create mode 100644 code/tools/cgame_wrapper/cg_tiki.c create mode 100644 code/tools/cgame_wrapper/cgame_wrapper.sln create mode 100644 code/tools/cgame_wrapper/cgame_wrapper.vcxproj create mode 100644 code/tools/cgame_wrapper/cgame_wrapper.vcxproj.filters create mode 100644 code/tools/cgame_wrapper/cgame_wrapper.vcxproj.user create mode 100644 code/tools/cgame_wrapper/qcommon.h create mode 100644 code/tools/lcc/COPYRIGHT create mode 100644 code/tools/lcc/LOG create mode 100644 code/tools/lcc/README create mode 100644 code/tools/lcc/README.id create mode 100644 code/tools/lcc/cpp/cpp.c create mode 100644 code/tools/lcc/cpp/cpp.h create mode 100644 code/tools/lcc/cpp/eval.c create mode 100644 code/tools/lcc/cpp/getopt.c create mode 100644 code/tools/lcc/cpp/hideset.c create mode 100644 code/tools/lcc/cpp/include.c create mode 100644 code/tools/lcc/cpp/lex.c create mode 100644 code/tools/lcc/cpp/macro.c create mode 100644 code/tools/lcc/cpp/nlist.c create mode 100644 code/tools/lcc/cpp/tokens.c create mode 100644 code/tools/lcc/cpp/unix.c create mode 100644 code/tools/lcc/doc/4.html create mode 100644 code/tools/lcc/doc/bprint.1 create mode 100644 code/tools/lcc/doc/bprint.pdf create mode 100644 code/tools/lcc/doc/install.html create mode 100644 code/tools/lcc/doc/lcc.1 create mode 100644 code/tools/lcc/doc/lcc.pdf create mode 100644 code/tools/lcc/etc/bytecode.c create mode 100644 code/tools/lcc/etc/lcc.c create mode 100644 code/tools/lcc/lburg/gram.c create mode 100644 code/tools/lcc/lburg/gram.y create mode 100644 code/tools/lcc/lburg/lburg.1 create mode 100644 code/tools/lcc/lburg/lburg.c create mode 100644 code/tools/lcc/lburg/lburg.h create mode 100644 code/tools/lcc/src/alloc.c create mode 100644 code/tools/lcc/src/bind.c create mode 100644 code/tools/lcc/src/bytecode.c create mode 100644 code/tools/lcc/src/c.h create mode 100644 code/tools/lcc/src/config.h create mode 100644 code/tools/lcc/src/dag.c create mode 100644 code/tools/lcc/src/dagcheck.md create mode 100644 code/tools/lcc/src/decl.c create mode 100644 code/tools/lcc/src/enode.c create mode 100644 code/tools/lcc/src/error.c create mode 100644 code/tools/lcc/src/event.c create mode 100644 code/tools/lcc/src/expr.c create mode 100644 code/tools/lcc/src/gen.c create mode 100644 code/tools/lcc/src/init.c create mode 100644 code/tools/lcc/src/inits.c create mode 100644 code/tools/lcc/src/input.c create mode 100644 code/tools/lcc/src/lex.c create mode 100644 code/tools/lcc/src/list.c create mode 100644 code/tools/lcc/src/main.c create mode 100644 code/tools/lcc/src/null.c create mode 100644 code/tools/lcc/src/output.c create mode 100644 code/tools/lcc/src/prof.c create mode 100644 code/tools/lcc/src/profio.c create mode 100644 code/tools/lcc/src/simp.c create mode 100644 code/tools/lcc/src/stmt.c create mode 100644 code/tools/lcc/src/string.c create mode 100644 code/tools/lcc/src/sym.c create mode 100644 code/tools/lcc/src/symbolic.c create mode 100644 code/tools/lcc/src/token.h create mode 100644 code/tools/lcc/src/trace.c create mode 100644 code/tools/lcc/src/tree.c create mode 100644 code/tools/lcc/src/types.c create mode 100644 code/tools/md5_2_skX/NOTES.txt create mode 100644 code/tools/md5_2_skX/doom3md5model.c create mode 100644 code/tools/md5_2_skX/loadtiki.c create mode 100644 code/tools/md5_2_skX/md5_2_skX.c create mode 100644 code/tools/md5_2_skX/md5_2_skX.h create mode 100644 code/tools/md5_2_skX/misc_utils.c create mode 100644 code/tools/md5_2_skX/writeobj.c create mode 100644 code/tools/md5_2_skX/writeskl.c create mode 100644 code/tools/md5_2_skX/writetiki.c create mode 100644 code/tools/ommap/brush.c create mode 100644 code/tools/ommap/brush_primit.c create mode 100644 code/tools/ommap/bsp.c create mode 100644 code/tools/ommap/common/aselib.c create mode 100644 code/tools/ommap/common/aselib.h create mode 100644 code/tools/ommap/common/bspfile.c create mode 100644 code/tools/ommap/common/bspfile.h create mode 100644 code/tools/ommap/common/cmdlib.c create mode 100644 code/tools/ommap/common/cmdlib.h create mode 100644 code/tools/ommap/common/imagelib.c create mode 100644 code/tools/ommap/common/imagelib.h create mode 100644 code/tools/ommap/common/l3dslib.c create mode 100644 code/tools/ommap/common/l3dslib.h create mode 100644 code/tools/ommap/common/mathlib.c create mode 100644 code/tools/ommap/common/mathlib.h create mode 100644 code/tools/ommap/common/md4.c create mode 100644 code/tools/ommap/common/mutex.c create mode 100644 code/tools/ommap/common/mutex.h create mode 100644 code/tools/ommap/common/polylib.c create mode 100644 code/tools/ommap/common/polylib.h create mode 100644 code/tools/ommap/common/polyset.h create mode 100644 code/tools/ommap/common/qfiles.h create mode 100644 code/tools/ommap/common/scriplib.c create mode 100644 code/tools/ommap/common/scriplib.h create mode 100644 code/tools/ommap/common/surfaceflags.h create mode 100644 code/tools/ommap/common/threads.c create mode 100644 code/tools/ommap/common/threads.h create mode 100644 code/tools/ommap/common/trilib.c create mode 100644 code/tools/ommap/common/trilib.h create mode 100644 code/tools/ommap/facebsp.c create mode 100644 code/tools/ommap/fog.c create mode 100644 code/tools/ommap/gldraw.c create mode 100644 code/tools/ommap/glfile.c create mode 100644 code/tools/ommap/leakfile.c create mode 100644 code/tools/ommap/libs/cmdlib.h create mode 100644 code/tools/ommap/libs/cmdlib/cmdlib.cpp create mode 100644 code/tools/ommap/libs/cmdlib/cmdlib.vcproj create mode 100644 code/tools/ommap/libs/jpeg6/README create mode 100644 code/tools/ommap/libs/jpeg6/jchuff.h create mode 100644 code/tools/ommap/libs/jpeg6/jcomapi.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jconfig.h create mode 100644 code/tools/ommap/libs/jpeg6/jdapimin.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdapistd.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdatasrc.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdcoefct.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdcolor.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdct.h create mode 100644 code/tools/ommap/libs/jpeg6/jddctmgr.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdhuff.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdhuff.h create mode 100644 code/tools/ommap/libs/jpeg6/jdinput.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdmainct.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdmarker.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdmaster.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdpostct.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdsample.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jdtrans.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jerror.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jerror.h create mode 100644 code/tools/ommap/libs/jpeg6/jfdctflt.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jidctflt.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jinclude.h create mode 100644 code/tools/ommap/libs/jpeg6/jmemmgr.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jmemnobs.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jmemsys.h create mode 100644 code/tools/ommap/libs/jpeg6/jmorecfg.h create mode 100644 code/tools/ommap/libs/jpeg6/jpeg6.vcproj create mode 100644 code/tools/ommap/libs/jpeg6/jpegint.h create mode 100644 code/tools/ommap/libs/jpeg6/jpgload.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jutils.cpp create mode 100644 code/tools/ommap/libs/jpeg6/jversion.h create mode 100644 code/tools/ommap/libs/jpeg6d.lib create mode 100644 code/tools/ommap/libs/jpeglib.h create mode 100644 code/tools/ommap/libs/pak/pak.vcproj create mode 100644 code/tools/ommap/libs/pak/pakstuff.cpp create mode 100644 code/tools/ommap/libs/pak/unzip.cpp create mode 100644 code/tools/ommap/libs/pak/unzip.h create mode 100644 code/tools/ommap/libs/pakd.lib create mode 100644 code/tools/ommap/libs/pakstuff.h create mode 100644 code/tools/ommap/libs/str.h create mode 100644 code/tools/ommap/light.c create mode 100644 code/tools/ommap/light.h create mode 100644 code/tools/ommap/light_trace.c create mode 100644 code/tools/ommap/lightmaps.c create mode 100644 code/tools/ommap/lightv.c create mode 100644 code/tools/ommap/map.c create mode 100644 code/tools/ommap/mesh.c create mode 100644 code/tools/ommap/mesh.h create mode 100644 code/tools/ommap/misc_model.c create mode 100644 code/tools/ommap/nodraw.c create mode 100644 code/tools/ommap/patch.c create mode 100644 code/tools/ommap/portals.c create mode 100644 code/tools/ommap/prtfile.c create mode 100644 code/tools/ommap/qbsp.h create mode 100644 code/tools/ommap/shaders.c create mode 100644 code/tools/ommap/shaders.h create mode 100644 code/tools/ommap/soundv.c create mode 100644 code/tools/ommap/surface.c create mode 100644 code/tools/ommap/terrain.c create mode 100644 code/tools/ommap/tjunction.c create mode 100644 code/tools/ommap/tree.c create mode 100644 code/tools/ommap/vis.c create mode 100644 code/tools/ommap/vis.h create mode 100644 code/tools/ommap/visflow.c create mode 100644 code/tools/ommap/writebsp.c create mode 100644 code/tools/testutils/conevent.cpp create mode 100644 code/tools/testutils/conevent.h create mode 100644 code/tools/testutils/main.cpp create mode 100644 code/tools/testutils/tests/array1.txt create mode 100644 code/tools/testutils/tests/hello.txt create mode 100644 code/tools/testutils/tests/linked_private_script1.txt create mode 100644 code/tools/testutils/tests/linked_private_script2.txt create mode 100644 code/tools/testutils/tests/make_array.txt create mode 100644 code/tools/testutils/tests/mutex.txt create mode 100644 code/tools/testutils/tests/targetname.txt create mode 100644 code/tools/testutils/ubersdk.h create mode 100644 code/tools/zlib/adler32.c create mode 100644 code/tools/zlib/compress.c create mode 100644 code/tools/zlib/crc32.c create mode 100644 code/tools/zlib/crc32.h create mode 100644 code/tools/zlib/deflate.c create mode 100644 code/tools/zlib/deflate.h create mode 100644 code/tools/zlib/gzclose.c create mode 100644 code/tools/zlib/gzguts.h create mode 100644 code/tools/zlib/gzlib.c create mode 100644 code/tools/zlib/gzread.c create mode 100644 code/tools/zlib/gzwrite.c create mode 100644 code/tools/zlib/infback.c create mode 100644 code/tools/zlib/inffast.c create mode 100644 code/tools/zlib/inffast.h create mode 100644 code/tools/zlib/inffixed.h create mode 100644 code/tools/zlib/inflate.c create mode 100644 code/tools/zlib/inflate.h create mode 100644 code/tools/zlib/inftrees.c create mode 100644 code/tools/zlib/inftrees.h create mode 100644 code/tools/zlib/trees.c create mode 100644 code/tools/zlib/trees.h create mode 100644 code/tools/zlib/uncompr.c create mode 100644 code/tools/zlib/zconf.h create mode 100644 code/tools/zlib/zlib.h create mode 100644 code/tools/zlib/zutil.c create mode 100644 code/tools/zlib/zutil.h create mode 100644 code/uilib/editfield.h create mode 100644 code/uilib/ucolor.cpp create mode 100644 code/uilib/ucolor.h create mode 100644 code/uilib/ui_extern.h create mode 100644 code/uilib/ui_init.cpp create mode 100644 code/uilib/ui_local.h create mode 100644 code/uilib/ui_public.h create mode 100644 code/uilib/uibind.cpp create mode 100644 code/uilib/uibind.h create mode 100644 code/uilib/uibindlist.cpp create mode 100644 code/uilib/uibindlist.h create mode 100644 code/uilib/uibutton.cpp create mode 100644 code/uilib/uibutton.h create mode 100644 code/uilib/uicheckbox.cpp create mode 100644 code/uilib/uicheckbox.h create mode 100644 code/uilib/uicommon.h create mode 100644 code/uilib/uiconsole.cpp create mode 100644 code/uilib/uiconsole.h create mode 100644 code/uilib/uidialog.cpp create mode 100644 code/uilib/uidialog.h create mode 100644 code/uilib/uifield.cpp create mode 100644 code/uilib/uifield.h create mode 100644 code/uilib/uifloatwnd.cpp create mode 100644 code/uilib/uifloatwnd.h create mode 100644 code/uilib/uifont.cpp create mode 100644 code/uilib/uifont.h create mode 100644 code/uilib/uiglobalgamelist.cpp create mode 100644 code/uilib/uiglobalgamelist.h create mode 100644 code/uilib/uihorizscroll.cpp create mode 100644 code/uilib/uihorizscroll.h create mode 100644 code/uilib/uilabel.cpp create mode 100644 code/uilib/uilabel.h create mode 100644 code/uilib/uilangamelist.cpp create mode 100644 code/uilib/uilangamelist.h create mode 100644 code/uilib/uilayout.cpp create mode 100644 code/uilib/uilayout.h create mode 100644 code/uilib/uilist.cpp create mode 100644 code/uilib/uilist.h create mode 100644 code/uilib/uilistbox.cpp create mode 100644 code/uilib/uilistbox.h create mode 100644 code/uilib/uilistctrl.cpp create mode 100644 code/uilib/uilistctrl.h create mode 100644 code/uilib/uimenu.cpp create mode 100644 code/uilib/uimenu.h create mode 100644 code/uilib/uimledit.cpp create mode 100644 code/uilib/uimledit.h create mode 100644 code/uilib/uinotepad.cpp create mode 100644 code/uilib/uinotepad.h create mode 100644 code/uilib/uipoint2d.h create mode 100644 code/uilib/uipopupmenu.cpp create mode 100644 code/uilib/uipopupmenu.h create mode 100644 code/uilib/uipulldownmenu.cpp create mode 100644 code/uilib/uipulldownmenu.h create mode 100644 code/uilib/uipulldownmenucontainer.cpp create mode 100644 code/uilib/uipulldownmenucontainer.h create mode 100644 code/uilib/uirect2d.h create mode 100644 code/uilib/uisize2d.h create mode 100644 code/uilib/uislider.cpp create mode 100644 code/uilib/uislider.h create mode 100644 code/uilib/uistatus.cpp create mode 100644 code/uilib/uistatus.h create mode 100644 code/uilib/uivertscroll.cpp create mode 100644 code/uilib/uivertscroll.h create mode 100644 code/uilib/uiwidget.cpp create mode 100644 code/uilib/uiwidget.h create mode 100644 code/uilib/uiwinman.cpp create mode 100644 code/uilib/uiwinman.h create mode 100644 code/uilib/ulist.h create mode 100644 code/uilib/usignal.h create mode 100644 cross-make-mingw.sh create mode 100644 ida/ida.h create mode 100644 ida/ida_ui.h create mode 100644 ida/ui/cl_inv.h create mode 100644 ida/ui/cl_invrender.h create mode 100644 ida/ui/cl_uibind.h create mode 100644 ida/ui/cl_uidmbox.h create mode 100644 ida/ui/cl_uifilepicker.h create mode 100644 ida/ui/cl_uigmbox.h create mode 100644 ida/ui/cl_uilangame.h create mode 100644 ida/ui/cl_uiloadsave.h create mode 100644 ida/ui/cl_uimaprunner.h create mode 100644 ida/ui/cl_uiminicon.h create mode 100644 ida/ui/cl_uimpmappicker.h create mode 100644 ida/ui/cl_uiplayermodelpicker.h create mode 100644 ida/ui/cl_uiserverlist.h create mode 100644 ida/ui/cl_uisoundpicker.h create mode 100644 ida/ui/cl_uistd.h create mode 100644 ida/ui/cl_uiview3d.h create mode 100644 ida/ui/editfield.h create mode 100644 ida/ui/ucolor.h create mode 100644 ida/ui/uibind.h create mode 100644 ida/ui/uibindlist.h create mode 100644 ida/ui/uibutton.h create mode 100644 ida/ui/uicheckbox.h create mode 100644 ida/ui/uiconsole.h create mode 100644 ida/ui/uidialog.h create mode 100644 ida/ui/uifield.h create mode 100644 ida/ui/uifloatwnd.h create mode 100644 ida/ui/uifont.h create mode 100644 ida/ui/uiglobalgamelist.h create mode 100644 ida/ui/uihorizscroll.h create mode 100644 ida/ui/uilabel.h create mode 100644 ida/ui/uilangamelist.h create mode 100644 ida/ui/uilayout.h create mode 100644 ida/ui/uilist.h create mode 100644 ida/ui/uilistbox.h create mode 100644 ida/ui/uilistctrl.h create mode 100644 ida/ui/uimenu.h create mode 100644 ida/ui/uimledit.h create mode 100644 ida/ui/uinotepad.h create mode 100644 ida/ui/uipoint2d.h create mode 100644 ida/ui/uipopupmenu.h create mode 100644 ida/ui/uipulldownmenu.h create mode 100644 ida/ui/uipulldownmenucontainer.h create mode 100644 ida/ui/uirect2d.h create mode 100644 ida/ui/uisize2d.h create mode 100644 ida/ui/uislider.h create mode 100644 ida/ui/uistatus.h create mode 100644 ida/ui/uivertscroll.h create mode 100644 ida/ui/uiwidget.h create mode 100644 ida/ui/uiwinman.h create mode 100644 ida/ui/ulist.h create mode 100644 ida/ui/usignal.h create mode 100644 make-macosx-ub.sh create mode 100644 misc/def/cgame.def create mode 100644 misc/def/cgame_hook.def create mode 100644 misc/def/game.def create mode 100644 misc/def/mohui.def create mode 100644 misc/def/q3_ui.def create mode 100644 misc/def/ui.def create mode 100644 misc/flex/FlexLexer.h create mode 100644 misc/flex/README.txt create mode 100644 misc/flex/UNISTD_ERROR.readme create mode 100644 misc/flex/custom_build_rules/how_to_use.txt create mode 100644 misc/flex/custom_build_rules/win_flex_bison_custom_build.props create mode 100644 misc/flex/custom_build_rules/win_flex_bison_custom_build.targets create mode 100644 misc/flex/custom_build_rules/win_flex_bison_custom_build.xml create mode 100644 misc/flex/data/Makefile.am create mode 100644 misc/flex/data/Makefile.in create mode 100644 misc/flex/data/README create mode 100644 misc/flex/data/bison.m4 create mode 100644 misc/flex/data/c++-skel.m4 create mode 100644 misc/flex/data/c++.m4 create mode 100644 misc/flex/data/c-like.m4 create mode 100644 misc/flex/data/c-skel.m4 create mode 100644 misc/flex/data/c.m4 create mode 100644 misc/flex/data/glr.c create mode 100644 misc/flex/data/glr.cc create mode 100644 misc/flex/data/java-skel.m4 create mode 100644 misc/flex/data/java.m4 create mode 100644 misc/flex/data/lalr1.cc create mode 100644 misc/flex/data/lalr1.java create mode 100644 misc/flex/data/location.cc create mode 100644 misc/flex/data/m4sugar/foreach.m4 create mode 100644 misc/flex/data/m4sugar/m4sugar.m4 create mode 100644 misc/flex/data/stack.hh create mode 100644 misc/flex/data/xslt/bison.xsl create mode 100644 misc/flex/data/xslt/xml2dot.xsl create mode 100644 misc/flex/data/xslt/xml2text.xsl create mode 100644 misc/flex/data/xslt/xml2xhtml.xsl create mode 100644 misc/flex/data/yacc.c create mode 100644 misc/flex/state.log create mode 100644 misc/flex/win_bison.exe create mode 100644 misc/flex/win_flex.exe create mode 100644 misc/msvc10/cgame/cgame.vcproj create mode 100644 misc/msvc10/cgame_hook/cgame_hook.vcproj create mode 100644 misc/msvc10/game/game.vcproj create mode 100644 misc/msvc10/omohaaded/omohaaded.vcproj create mode 100644 misc/msvc10/openmohaa/openmohaa.sln create mode 100644 misc/msvc10/openmohaa/openmohaa.vcproj create mode 100644 misc/msvc10/testutils/testutils.vcproj create mode 100644 misc/msvc12_13/FLEX_Bison/FLEX_Bison.vcxproj create mode 100644 misc/msvc12_13/FLEX_Bison/FLEX_Bison.vcxproj.filters create mode 100644 misc/msvc12_13/cgame/cgame.vcxproj create mode 100644 misc/msvc12_13/cgame/cgame.vcxproj.filters create mode 100644 misc/msvc12_13/cgame_hook/cgame_hook.vcxproj create mode 100644 misc/msvc12_13/cgame_hook/cgame_hook.vcxproj.filters create mode 100644 misc/msvc12_13/game/game.vcxproj create mode 100644 misc/msvc12_13/game/game.vcxproj.filters create mode 100644 misc/msvc12_13/mohui/mohui.vcxproj create mode 100644 misc/msvc12_13/mohui/mohui.vcxproj.filters create mode 100644 misc/msvc12_13/omohaaded/omohaaded.vcxproj create mode 100644 misc/msvc12_13/omohaaded/omohaaded.vcxproj.filters create mode 100644 misc/msvc12_13/omohconverter/omohconverter.vcxproj create mode 100644 misc/msvc12_13/omohconverter/omohconverter.vcxproj.filters create mode 100644 misc/msvc12_13/openmohaa/openmohaa.sln create mode 100644 misc/msvc12_13/openmohaa/openmohaa.vcxproj create mode 100644 misc/msvc12_13/openmohaa/openmohaa.vcxproj.filters create mode 100644 misc/msvc12_13/snippets/function_comment.snippet create mode 100644 misc/msvc12_13/testutils/testutils.vcxproj create mode 100644 misc/msvc12_13/testutils/testutils.vcxproj.filters create mode 100644 misc/nix/cgame/.cproject create mode 100644 misc/nix/cgame/.project create mode 100644 misc/nix/cgame/.settings/language.settings.xml create mode 100644 misc/nix/cgame/headers/IGNORE create mode 100644 misc/nix/cgame/src/IGNORE create mode 100644 misc/nix/game/.cproject create mode 100644 misc/nix/game/.project create mode 100644 misc/nix/game/.settings/language.settings.xml create mode 100644 misc/nix/game/headers/IGNORE create mode 100644 misc/nix/game/parser/IGNORE create mode 100644 misc/nix/game/src/IGNORE create mode 100644 misc/nix/omohaaded/.cproject create mode 100644 misc/nix/omohaaded/.project create mode 100644 misc/nix/omohaaded/.settings/language.settings.xml create mode 100644 misc/nix/omohaaded/.settings/org.eclipse.cdt.core.prefs create mode 100644 misc/nix/omohaaded/.settings/org.eclipse.cdt.managedbuilder.core.prefs create mode 100644 misc/nix/omohaaded/headers/IGNORE create mode 100644 misc/nix/omohaaded/src/botlib/IGNORE create mode 100644 misc/nix/openmohaa/.cproject create mode 100644 misc/nix/openmohaa/.project create mode 100644 misc/nix/openmohaa/.settings/language.settings.xml create mode 100644 misc/nix/openmohaa/headers/IGNORE create mode 100644 misc/nix/openmohaa/src/botlib/IGNORE create mode 100644 misc/nix/openmohaa/src/jpeg/IGNORE create mode 100644 misc/nix/openmohaa/src/png/IGNORE create mode 100644 misc/nix/openmohaa/zlib/IGNORE create mode 100644 misc/nix/testutils/.cproject create mode 100644 misc/nix/testutils/.project create mode 100644 misc/nix/testutils/.settings/language.settings.xml create mode 100644 misc/nix/testutils/headers/IGNORE create mode 100644 misc/nix/testutils/parser/IGNORE create mode 100644 misc/nix/testutils/src/IGNORE create mode 100644 misc/openmohaa.icns create mode 100644 misc/openmohaa.ico create mode 100644 misc/openmohaa.png create mode 100644 misc/openmohaa.svg create mode 100644 misc/setup/MacOSX/SLA-dmg.sh create mode 100644 misc/setup/Makefile create mode 100644 misc/setup/Solaris_pkg.sh create mode 100644 misc/setup/doit create mode 100644 misc/setup/ioq3demo.sh create mode 100644 misc/setup/ioquake3.SlackBuild create mode 100644 misc/setup/ioquake3.sh create mode 100644 misc/setup/pkg/ioq3ded.sh create mode 100644 misc/setup/pkg/ioquake3.sh create mode 100644 misc/setup/pkg/ioquake3/depend create mode 100644 misc/setup/pkg/ioquake3/pkginfo.template create mode 100644 misc/setup/pkg/ioquake3/postinstall create mode 100644 misc/setup/pkg/ioquake3/postremove create mode 100644 misc/setup/pkg/ioquake3/preinstall create mode 100644 misc/setup/pkg/ioquake3/preremove create mode 100644 misc/setup/pkg/ioquake3/prototype.template create mode 100644 misc/setup/pkg/ioquake3/space create mode 100644 misc/setup/pkg/ioquake3d/depend create mode 100644 misc/setup/pkg/ioquake3d/pkginfo.template create mode 100644 misc/setup/pkg/ioquake3d/postinstall create mode 100644 misc/setup/pkg/ioquake3d/postremove create mode 100644 misc/setup/pkg/ioquake3d/preinstall create mode 100644 misc/setup/pkg/ioquake3d/preremove create mode 100644 misc/setup/pkg/ioquake3d/prototype.template create mode 100644 misc/setup/pkg/ioquake3d/space create mode 100644 misc/setup/preuninstall.sh create mode 100644 misc/setup/setup.xml.in create mode 100644 misc/setup/slack-desc create mode 100644 misc/setup/splash.xpm create mode 100644 ui/hud.txt create mode 100644 ui/hud2.txt create mode 100644 ui/ingame.txt create mode 100644 ui/menudef.h create mode 100644 ui/menus.txt diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100644 index 00000000..c4f83adc --- /dev/null +++ b/CHANGELOG.txt @@ -0,0 +1,13 @@ +=== Patch 1.12 === + +>>> Client : +- Added GFX features such as bloom, SSAO & FXAA +- Added support of .vision files +- Added support of custom weapons and view model animations + +>>> Game : +- Added more scripting functions +- Lot more.. + + +THIS CHANGELOG IS NOT COMPLETED YET. diff --git a/COPYING.txt b/COPYING.txt new file mode 100644 index 00000000..98443f35 --- /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/LAYOUT.txt b/LAYOUT.txt new file mode 100644 index 00000000..06a17efd --- /dev/null +++ b/LAYOUT.txt @@ -0,0 +1,20 @@ +File layout +====================== + +build/ --> Output files +code/ --> OpenMoHAA source code +code/cgame --> Client game code +code/cgame_hook --> Client game patch for MoHAA (hooks the default cgamex86.dll) +code/client --> Client (network stuff, snapshots, etc) +code/game --> Server game code (game logic stuff, etc) +code/globalcpp --> C++ Global stuff such as the Script Engine & Parser +code/mohui --> MoHAA User Interface +code/null --> Null redirector (used by the OpenMoHAA Dedicated Server) +code/qcommon --> Global shared stuff such as maths +code/renderer --> OpenMoHAA renderer +code/renderer_gl3 --> Newest renderer (not working and buggy) +code/sdl(12) --> SDL code +code/server --> Server code (networkn snapshots, handling clients etc) +code/sys --> Main application system +code/testutils --> Test utility for scripts and various stuff +misc/ --> Project stuff, definition files and various resources stuff. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..45193df4 --- /dev/null +++ b/Makefile @@ -0,0 +1,1862 @@ +# +# OpenMoHAA Makefile +# +# GNU Make required +# + +# wombat: we do not use/need QVMs currently +BUILD_GAME_QVM = 0 + + +COMPILE_PLATFORM=$(shell uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]') + +COMPILE_ARCH=$(shell uname -m | sed -e s/i.86/i386/) + +ifeq ($(COMPILE_PLATFORM),sunos) + # Solaris uname and GNU uname differ + COMPILE_ARCH=$(shell uname -p | sed -e s/i.86/i386/) +endif +ifeq ($(COMPILE_PLATFORM),darwin) + # Apple does some things a little differently... + COMPILE_ARCH=$(shell uname -p | sed -e s/i.86/i386/) +endif + +ifeq ($(COMPILE_PLATFORM),mingw32) + ifeq ($(COMPILE_ARCH),i386) + COMPILE_ARCH=x86 + endif +endif + +ifndef BUILD_CLIENT + BUILD_CLIENT = +endif +ifndef BUILD_CLIENT_SMP + BUILD_CLIENT_SMP = +endif +ifndef BUILD_SERVER + BUILD_SERVER = +endif +ifndef BUILD_GAME_SO + BUILD_GAME_SO = +endif +ifndef BUILD_GAME_QVM + BUILD_GAME_QVM = +endif + +ifneq ($(PLATFORM),darwin) + BUILD_CLIENT_SMP = 0 +endif + +############################################################################# +# +# If you require a different configuration from the defaults below, create a +# new file named "Makefile.local" in the same directory as this file and define +# your parameters there. This allows you to change configuration without +# causing problems with keeping up to date with the repository. +# +############################################################################# +-include Makefile.local + +ifndef PLATFORM +PLATFORM=$(COMPILE_PLATFORM) +endif +export PLATFORM + +ifeq ($(COMPILE_ARCH),powerpc) + COMPILE_ARCH=ppc +endif + +ifndef ARCH +ARCH=$(COMPILE_ARCH) +endif +export ARCH + +ifneq ($(PLATFORM),$(COMPILE_PLATFORM)) + CROSS_COMPILING=1 +else + CROSS_COMPILING=0 + + ifneq ($(ARCH),$(COMPILE_ARCH)) + CROSS_COMPILING=1 + endif +endif +export CROSS_COMPILING + +ifndef COPYDIR +COPYDIR="/usr/local/games/openmohaa" +endif + +ifndef MOUNT_DIR +MOUNT_DIR=code +endif + +ifndef BUILD_DIR +BUILD_DIR=build +endif + +ifndef GENERATE_DEPENDENCIES +GENERATE_DEPENDENCIES=1 +endif + +ifndef USE_OPENAL +USE_OPENAL=1 +endif + +ifndef USE_OPENAL_DLOPEN +USE_OPENAL_DLOPEN=0 +endif + +ifndef USE_CURL +USE_CURL=1 +endif + +ifndef USE_CURL_DLOPEN + ifeq ($(PLATFORM),mingw32) + USE_CURL_DLOPEN=0 + else + USE_CURL_DLOPEN=1 + endif +endif + +ifndef USE_CODEC_VORBIS +USE_CODEC_VORBIS=0 +endif + +ifndef USE_LOCAL_HEADERS +USE_LOCAL_HEADERS=1 +endif + +############################################################################# + +BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH) +BR=$(BUILD_DIR)/release-$(PLATFORM)-$(ARCH) +CDIR=$(MOUNT_DIR)/client +SDIR=$(MOUNT_DIR)/server +RDIR=$(MOUNT_DIR)/renderer +CMDIR=$(MOUNT_DIR)/qcommon +SDLDIR=$(MOUNT_DIR)/sdl +ASMDIR=$(MOUNT_DIR)/asm +SYSDIR=$(MOUNT_DIR)/sys +GDIR=$(MOUNT_DIR)/game +CGDIR=$(MOUNT_DIR)/cgame +BLIBDIR=$(MOUNT_DIR)/botlib +NDIR=$(MOUNT_DIR)/null +UIDIR=$(MOUNT_DIR)/mohui +Q3UIDIR=$(MOUNT_DIR)/mohui +JPDIR=$(MOUNT_DIR)/jpeg-6 +Q3ASMDIR=$(MOUNT_DIR)/tools/asm +LBURGDIR=$(MOUNT_DIR)/tools/lcc/lburg +Q3CPPDIR=$(MOUNT_DIR)/tools/lcc/cpp +Q3LCCETCDIR=$(MOUNT_DIR)/tools/lcc/etc +Q3LCCSRCDIR=$(MOUNT_DIR)/tools/lcc/src +LOKISETUPDIR=misc/setup +SDLHDIR=$(MOUNT_DIR)/SDL12 +LIBSDIR=$(MOUNT_DIR)/libs +TEMPDIR=/tmp + +# extract version info +VERSION=$(shell grep "\#define *PRODUCT_VERSION" $(CMDIR)/q_shared.h | \ + sed -e 's/[^"]*"\(.*\)"/\1/') + +USE_SVN= +ifeq ($(wildcard .svn),.svn) + SVN_REV=$(shell LANG=C svnversion .) + ifneq ($(SVN_REV),) + SVN_VERSION=$(VERSION)_SVN$(SVN_REV) + USE_SVN=1 + endif +endif +ifneq ($(USE_SVN),1) + SVN_VERSION=$(VERSION) +endif + + +############################################################################# +# SETUP AND BUILD -- LINUX +############################################################################# + +## Defaults +LIB=lib + +INSTALL=install +MKDIR=mkdir + +ifeq ($(PLATFORM),linux) + + ifeq ($(ARCH),alpha) + ARCH=axp + else + ifeq ($(ARCH),x86_64) + LIB=lib64 + else + ifeq ($(ARCH),ppc64) + LIB=lib64 + else + ifeq ($(ARCH),s390x) + LIB=lib64 + endif + endif + endif + endif + + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -pipe -DUSE_ICON $(shell sdl-config --cflags) + + ifeq ($(USE_OPENAL),1) + BASE_CFLAGS += -DUSE_OPENAL + ifeq ($(USE_OPENAL_DLOPEN),1) + BASE_CFLAGS += -DUSE_OPENAL_DLOPEN + endif + endif + + ifeq ($(USE_CURL),1) + BASE_CFLAGS += -DUSE_CURL + ifeq ($(USE_CURL_DLOPEN),1) + BASE_CFLAGS += -DUSE_CURL_DLOPEN + endif + endif + + ifeq ($(USE_CODEC_VORBIS),1) + BASE_CFLAGS += -DUSE_CODEC_VORBIS + endif + + OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer + + ifeq ($(ARCH),x86_64) + OPTIMIZE = -O3 -fomit-frame-pointer -ffast-math -funroll-loops \ + -falign-loops=2 -falign-jumps=2 -falign-functions=2 \ + -fstrength-reduce + # experimental x86_64 jit compiler! you need GNU as + HAVE_VM_COMPILED = true + else + ifeq ($(ARCH),i386) + OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \ + -funroll-loops -falign-loops=2 -falign-jumps=2 \ + -falign-functions=2 -fstrength-reduce + HAVE_VM_COMPILED=true + else + ifeq ($(ARCH),ppc) + BASE_CFLAGS += -maltivec + HAVE_VM_COMPILED=false + endif + endif + endif + + ifneq ($(HAVE_VM_COMPILED),true) + BASE_CFLAGS += -DNO_VM_COMPILED + endif + + SHLIBEXT=so + SHLIBCFLAGS=-fPIC + SHLIBLDFLAGS=-shared $(LDFLAGS) + + THREAD_LDFLAGS=-lpthread + LDFLAGS=-ldl -lm + + CLIENT_LDFLAGS=$(shell sdl-config --libs) -lGL + + ifeq ($(USE_OPENAL),1) + ifneq ($(USE_OPENAL_DLOPEN),1) + CLIENT_LDFLAGS += -lopenal + endif + endif + + ifeq ($(USE_CURL),1) + ifneq ($(USE_CURL_DLOPEN),1) + CLIENT_LDFLAGS += -lcurl + endif + endif + + ifeq ($(USE_CODEC_VORBIS),1) + CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg + endif + + ifeq ($(ARCH),i386) + # linux32 make ... + BASE_CFLAGS += -m32 + LDFLAGS+=-m32 + else + ifeq ($(ARCH),ppc64) + BASE_CFLAGS += -m64 + LDFLAGS += -m64 + endif + endif + + DEBUG_CFLAGS = $(BASE_CFLAGS) -g -O0 + RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) + +else # ifeq Linux + +############################################################################# +# SETUP AND BUILD -- MAC OS X +############################################################################# + +ifeq ($(PLATFORM),darwin) + HAVE_VM_COMPILED=true + CLIENT_LDFLAGS= + OPTIMIZE= + + # building the QVMs on MacOSX is broken, atm. + BUILD_GAME_QVM=0 + + BASE_CFLAGS = -Wall -Wimplicit -Wstrict-prototypes + + ifeq ($(ARCH),ppc) + OPTIMIZE += -faltivec -O3 + endif + ifeq ($(ARCH),i386) + OPTIMIZE += -march=prescott -mfpmath=sse + # x86 vm will crash without -mstackrealign since MMX instructions will be + # used no matter what and they corrupt the frame pointer in VM calls + BASE_CFLAGS += -mstackrealign + endif + + BASE_CFLAGS += -fno-strict-aliasing -DMACOS_X -fno-common -pipe + + ifeq ($(USE_OPENAL),1) + BASE_CFLAGS += -DUSE_OPENAL + ifneq ($(USE_OPENAL_DLOPEN),1) + CLIENT_LDFLAGS += -framework OpenAL + else + BASE_CFLAGS += -DUSE_OPENAL_DLOPEN + endif + endif + + ifeq ($(USE_CURL),1) + BASE_CFLAGS += -DUSE_CURL + ifneq ($(USE_CURL_DLOPEN),1) + CLIENT_LDFLAGS += -lcurl + else + BASE_CFLAGS += -DUSE_CURL_DLOPEN + endif + endif + + ifeq ($(USE_CODEC_VORBIS),1) + BASE_CFLAGS += -DUSE_CODEC_VORBIS + CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg + endif + + BASE_CFLAGS += -D_THREAD_SAFE=1 + + ifeq ($(USE_LOCAL_HEADERS),1) + BASE_CFLAGS += -I$(SDLHDIR)/include + endif + + # We copy sdlmain before ranlib'ing it so that subversion doesn't think + # the file has been modified by each build. + LIBSDLMAIN=$(B)/libSDLmain.a + LIBSDLMAINSRC=$(LIBSDIR)/macosx/libSDLmain.a + CLIENT_LDFLAGS += -framework Cocoa -framework IOKit -framework OpenGL \ + $(LIBSDIR)/macosx/libSDL-1.2.0.dylib + + OPTIMIZE += -ffast-math -falign-loops=16 + + ifneq ($(HAVE_VM_COMPILED),true) + BASE_CFLAGS += -DNO_VM_COMPILED + endif + + DEBUG_CFLAGS = $(BASE_CFLAGS) -g -O0 + + RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) + + SHLIBEXT=dylib + SHLIBCFLAGS=-fPIC -fno-common + SHLIBLDFLAGS=-dynamiclib $(LDFLAGS) + + NOTSHLIBCFLAGS=-mdynamic-no-pic + + TOOLS_CFLAGS += -DMACOS_X + +else # ifeq darwin + + +############################################################################# +# SETUP AND BUILD -- MINGW32 +############################################################################# + +ifeq ($(PLATFORM),mingw32) + +ifndef WINDRES +WINDRES=windres +endif + + ARCH=x86 + + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -DUSE_ICON + + ifeq ($(USE_LOCAL_HEADERS),1) + BASE_CFLAGS += -I$(SDLHDIR)/include + endif + + ifeq ($(USE_OPENAL),1) + BASE_CFLAGS += -DUSE_OPENAL=1 -DUSE_OPENAL_DLOPEN + endif + + ifeq ($(USE_CURL),1) + BASE_CFLAGS += -DUSE_CURL + ifneq ($(USE_CURL_DLOPEN),1) + BASE_CFLAGS += -DCURL_STATICLIB + endif + endif + + ifeq ($(USE_CODEC_VORBIS),1) + BASE_CFLAGS += -DUSE_CODEC_VORBIS + endif + + OPTIMIZE = -O3 -march=i586 -fno-omit-frame-pointer -ffast-math \ + -falign-loops=2 -funroll-loops -falign-jumps=2 -falign-functions=2 \ + -fstrength-reduce + + HAVE_VM_COMPILED = true + + SHLIBEXT=dll + SHLIBCFLAGS= + SHLIBLDFLAGS=-shared $(LDFLAGS) + + BINEXT=.exe + + LDFLAGS= -lwsock32 -lwinmm + CLIENT_LDFLAGS = -mwindows -lgdi32 -lole32 -lopengl32 + + ifeq ($(USE_CURL),1) + ifneq ($(USE_CURL_DLOPEN),1) + CLIENT_LDFLAGS += $(LIBSDIR)/win32/libcurl.a + endif + endif + + ifeq ($(USE_CODEC_VORBIS),1) + CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg + endif + + ifeq ($(ARCH),x86) + # build 32bit + BASE_CFLAGS += -m32 + LDFLAGS+=-m32 + endif + + DEBUG_CFLAGS=$(BASE_CFLAGS) -g -O0 + RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) + + # libmingw32 must be linked before libSDLmain + CLIENT_LDFLAGS += -lmingw32 \ + $(LIBSDIR)/win32/libSDLmain.a \ + $(LIBSDIR)/win32/libSDL.dll.a + + BUILD_CLIENT_SMP = 0 + +else # ifeq mingw32 + +############################################################################# +# SETUP AND BUILD -- FREEBSD +############################################################################# + +ifeq ($(PLATFORM),freebsd) + + ifneq (,$(findstring alpha,$(shell uname -m))) + ARCH=axp + else #default to i386 + ARCH=i386 + endif #alpha test + + + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -DUSE_ICON $(shell sdl-config --cflags) + + ifeq ($(USE_OPENAL),1) + BASE_CFLAGS += -DUSE_OPENAL + ifeq ($(USE_OPENAL_DLOPEN),1) + BASE_CFLAGS += -DUSE_OPENAL_DLOPEN + endif + endif + + ifeq ($(USE_CODEC_VORBIS),1) + BASE_CFLAGS += -DUSE_CODEC_VORBIS + endif + + ifeq ($(ARCH),axp) + BASE_CFLAGS += -DNO_VM_COMPILED + RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -ffast-math -funroll-loops \ + -fomit-frame-pointer -fexpensive-optimizations + else + ifeq ($(ARCH),i386) + RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -mtune=pentiumpro \ + -march=pentium -fomit-frame-pointer -pipe -ffast-math \ + -falign-loops=2 -falign-jumps=2 -falign-functions=2 \ + -funroll-loops -fstrength-reduce + HAVE_VM_COMPILED=true + else + BASE_CFLAGS += -DNO_VM_COMPILED + endif + endif + + DEBUG_CFLAGS=$(BASE_CFLAGS) -g + + SHLIBEXT=so + SHLIBCFLAGS=-fPIC + SHLIBLDFLAGS=-shared $(LDFLAGS) + + THREAD_LDFLAGS=-lpthread + # don't need -ldl (FreeBSD) + LDFLAGS=-lm + + CLIENT_LDFLAGS = + + CLIENT_LDFLAGS += $(shell sdl-config --libs) -lGL + + ifeq ($(USE_OPENAL),1) + ifneq ($(USE_OPENAL_DLOPEN),1) + CLIENT_LDFLAGS += $(THREAD_LDFLAGS) -lopenal + endif + endif + + ifeq ($(USE_CODEC_VORBIS),1) + CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg + endif + + +else # ifeq freebsd + +############################################################################# +# SETUP AND BUILD -- OPENBSD +############################################################################# + +ifeq ($(PLATFORM),openbsd) + + #default to i386, no tests done on anything else + ARCH=i386 + + + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -DUSE_ICON $(shell sdl-config --cflags) + + ifeq ($(USE_OPENAL),1) + BASE_CFLAGS += -DUSE_OPENAL + ifeq ($(USE_OPENAL_DLOPEN),1) + BASE_CFLAGS += -DUSE_OPENAL_DLOPEN + endif + endif + + ifeq ($(USE_CODEC_VORBIS),1) + BASE_CFLAGS += -DUSE_CODEC_VORBIS + endif + + BASE_CFLAGS += -DNO_VM_COMPILED -I/usr/X11R6/include -I/usr/local/include + RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 \ + -march=pentium -fomit-frame-pointer -pipe -ffast-math \ + -falign-loops=2 -falign-jumps=2 -falign-functions=2 \ + -funroll-loops -fstrength-reduce + HAVE_VM_COMPILED=false + + DEBUG_CFLAGS=$(BASE_CFLAGS) -g + + SHLIBEXT=so + SHLIBCFLAGS=-fPIC + SHLIBLDFLAGS=-shared $(LDFLAGS) + + THREAD_LDFLAGS=-lpthread + LDFLAGS=-lm + + CLIENT_LDFLAGS = + + CLIENT_LDFLAGS += $(shell sdl-config --libs) -lGL + + ifeq ($(USE_OPENAL),1) + ifneq ($(USE_OPENAL_DLOPEN),1) + CLIENT_LDFLAGS += $(THREAD_LDFLAGS) -lopenal + endif + endif + + ifeq ($(USE_CODEC_VORBIS),1) + CLIENT_LDFLAGS += -lvorbisfile -lvorbis -logg + endif + + +else # ifeq openbsd + +############################################################################# +# SETUP AND BUILD -- NETBSD +############################################################################# + +ifeq ($(PLATFORM),netbsd) + + ifeq ($(shell uname -m),i386) + ARCH=i386 + endif + + LDFLAGS=-lm + SHLIBEXT=so + SHLIBCFLAGS=-fPIC + SHLIBLDFLAGS=-shared $(LDFLAGS) + THREAD_LDFLAGS=-lpthread + + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes + + ifneq ($(ARCH),i386) + BASE_CFLAGS += -DNO_VM_COMPILED + endif + + DEBUG_CFLAGS=$(BASE_CFLAGS) -g + + BUILD_CLIENT = 0 + BUILD_GAME_QVM = 0 + +else # ifeq netbsd + +############################################################################# +# SETUP AND BUILD -- IRIX +############################################################################# + +ifeq ($(PLATFORM),irix64) + + ARCH=mips #default to MIPS + + CC = c99 + MKDIR = mkdir -p + + BASE_CFLAGS=-Dstricmp=strcasecmp -Xcpluscomm -woff 1185 \ + -I. $(shell sdl-config --cflags) -I$(ROOT)/usr/include -DNO_VM_COMPILED + RELEASE_CFLAGS=$(BASE_CFLAGS) -O3 + DEBUG_CFLAGS=$(BASE_CFLAGS) -g + + SHLIBEXT=so + SHLIBCFLAGS= + SHLIBLDFLAGS=-shared + + LDFLAGS=-ldl -lm -lgen + # FIXME: The X libraries probably aren't necessary? + CLIENT_LDFLAGS=-L/usr/X11/$(LIB) $(shell sdl-config --libs) -lGL \ + -lX11 -lXext -lm + +else # ifeq IRIX + +############################################################################# +# SETUP AND BUILD -- SunOS +############################################################################# + +ifeq ($(PLATFORM),sunos) + + CC=gcc + INSTALL=ginstall + MKDIR=gmkdir + COPYDIR="/usr/local/share/games/quake3" + + ifneq (,$(findstring i86pc,$(shell uname -m))) + ARCH=i386 + else #default to sparc + ARCH=sparc + endif + + ifneq ($(ARCH),i386) + ifneq ($(ARCH),sparc) + $(error arch $(ARCH) is currently not supported) + endif + endif + + + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ + -pipe -DUSE_ICON $(shell sdl-config --cflags) + + OPTIMIZE = -O3 -ffast-math -funroll-loops + + ifeq ($(ARCH),sparc) + OPTIMIZE = -O3 -ffast-math -falign-loops=2 \ + -falign-jumps=2 -falign-functions=2 -fstrength-reduce \ + -mtune=ultrasparc -mv8plus -mno-faster-structs \ + -funroll-loops + else + ifeq ($(ARCH),i386) + OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \ + -funroll-loops -falign-loops=2 -falign-jumps=2 \ + -falign-functions=2 -fstrength-reduce + HAVE_VM_COMPILED=true + BASE_CFLAGS += -m32 + LDFLAGS += -m32 + BASE_CFLAGS += -I/usr/X11/include/NVIDIA + CLIENT_LDFLAGS += -L/usr/X11/lib/NVIDIA -R/usr/X11/lib/NVIDIA + endif + endif + + ifneq ($(HAVE_VM_COMPILED),true) + BASE_CFLAGS += -DNO_VM_COMPILED + endif + + DEBUG_CFLAGS = $(BASE_CFLAGS) -ggdb -O0 + + RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) + + SHLIBEXT=so + SHLIBCFLAGS=-fPIC + SHLIBLDFLAGS=-shared $(LDFLAGS) + + THREAD_LDFLAGS=-lpthread + LDFLAGS=-lsocket -lnsl -ldl -lm + + BOTCFLAGS=-O0 + + CLIENT_LDFLAGS +=$(shell sdl-config --libs) -lGL + +else # ifeq sunos + +############################################################################# +# SETUP AND BUILD -- GENERIC +############################################################################# + BASE_CFLAGS=-DNO_VM_COMPILED + DEBUG_CFLAGS=$(BASE_CFLAGS) -g + RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 + + SHLIBEXT=so + SHLIBCFLAGS=-fPIC + SHLIBLDFLAGS=-shared + +endif #Linux +endif #darwin +endif #mingw32 +endif #FreeBSD +endif #OpenBSD +endif #NetBSD +endif #IRIX +endif #SunOS + +TARGETS = + +ifneq ($(BUILD_SERVER),0) + TARGETS += $(B)/omohaaded.$(ARCH)$(BINEXT) +endif + +ifneq ($(BUILD_CLIENT),0) + TARGETS += $(B)/openmohaa.$(ARCH)$(BINEXT) + ifneq ($(BUILD_CLIENT_SMP),0) + TARGETS += $(B)/openmohaa-smp.$(ARCH)$(BINEXT) + endif +endif + +ifneq ($(BUILD_GAME_SO),0) + TARGETS += \ + $(B)/main/cgame$(ARCH)opm.$(SHLIBEXT) \ + $(B)/main/game$(ARCH)opm.$(SHLIBEXT) \ + $(B)/main/ui$(ARCH)opm.$(SHLIBEXT) #\ +# $(B)/missionpack/cgame$(ARCH).$(SHLIBEXT) \ +# $(B)/missionpack/qagame$(ARCH).$(SHLIBEXT) \ +# $(B)/missionpack/ui$(ARCH).$(SHLIBEXT) +endif + +ifneq ($(BUILD_GAME_QVM),0) + ifneq ($(CROSS_COMPILING),1) + TARGETS += \ + $(B)/main/vm/opencgame.qvm \ + $(B)/main/vm/opengame.qvm \ + $(B)/main/vm/openui.qvm #\ +# $(B)/missionpack/vm/qagame.qvm \ +# $(B)/missionpack/vm/cgame.qvm \ +# $(B)/missionpack/vm/ui.qvm + endif +endif + +ifdef DEFAULT_BASEDIR + BASE_CFLAGS += -DDEFAULT_BASEDIR=\\\"$(DEFAULT_BASEDIR)\\\" +endif + +ifeq ($(USE_LOCAL_HEADERS),1) + BASE_CFLAGS += -DUSE_LOCAL_HEADERS +endif + +ifeq ($(GENERATE_DEPENDENCIES),1) + DEPEND_CFLAGS = -MMD +else + DEPEND_CFLAGS = +endif + +ifeq ($(USE_SVN),1) + BASE_CFLAGS += -DSVN_VERSION=\\\"$(SVN_VERSION)\\\" +endif + +ifeq ($(V),1) +echo_cmd=@: +Q= +else +echo_cmd=@echo +Q=@ +endif + +define DO_CC +$(echo_cmd) "CC $<" +$(Q)$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -o $@ -c $< +endef + +define DO_SMP_CC +$(echo_cmd) "SMP_CC $<" +$(Q)$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -DSMP -o $@ -c $< +endef + +define DO_BOT_CC +$(echo_cmd) "BOT_CC $<" +$(Q)$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) $(BOTCFLAGS) -DBOTLIB -o $@ -c $< +endef + +ifeq ($(GENERATE_DEPENDENCIES),1) + DO_QVM_DEP=cat $(@:%.o=%.d) | sed -e 's/\.o/\.asm/g' >> $(@:%.o=%.d) +endif + +define DO_SHLIB_CC +$(echo_cmd) "SHLIB_CC $<" +$(Q)$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< +$(Q)$(DO_QVM_DEP) +endef + +define DO_SHLIB_CC_MISSIONPACK +$(echo_cmd) "SHLIB_CC_MISSIONPACK $<" +$(Q)$(CC) -DMISSIONPACK $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< +$(Q)$(DO_QVM_DEP) +endef + +define DO_AS +$(echo_cmd) "AS $<" +$(Q)$(CC) $(CFLAGS) -x assembler-with-cpp -o $@ -c $< +endef + +define DO_DED_CC +$(echo_cmd) "DED_CC $<" +$(Q)$(CC) $(NOTSHLIBCFLAGS) -DDEDICATED $(CFLAGS) -o $@ -c $< +endef + +define DO_WINDRES +$(echo_cmd) "WINDRES $<" +$(Q)$(WINDRES) -i $< -o $@ +endef + + +############################################################################# +# MAIN TARGETS +############################################################################# + +default: release +all: debug release + +debug: + @$(MAKE) targets B=$(BD) CFLAGS="$(CFLAGS) $(DEPEND_CFLAGS) \ + $(DEBUG_CFLAGS)" V=$(V) + +release: + @$(MAKE) targets B=$(BR) CFLAGS="$(CFLAGS) $(DEPEND_CFLAGS) \ + $(RELEASE_CFLAGS)" V=$(V) + +# Create the build directories, check libraries and print out +# an informational message, then start building +targets: makedirs + @echo "" + @echo "Building openmohaa in $(B):" + @echo " PLATFORM: $(PLATFORM)" + @echo " ARCH: $(ARCH)" + @echo " COMPILE_PLATFORM: $(COMPILE_PLATFORM)" + @echo " COMPILE_ARCH: $(COMPILE_ARCH)" + @echo " CC: $(CC)" + @echo "" + @echo " CFLAGS:" + @for i in $(CFLAGS); \ + do \ + echo " $$i"; \ + done + @echo "" + @echo " LDFLAGS:" + @for i in $(LDFLAGS); \ + do \ + echo " $$i"; \ + done + @echo "" + @echo " Output:" + @for i in $(TARGETS); \ + do \ + echo " $$i"; \ + done + @echo "" + @$(MAKE) $(TARGETS) V=$(V) + +makedirs: + @if [ ! -d $(BUILD_DIR) ];then $(MKDIR) $(BUILD_DIR);fi + @if [ ! -d $(B) ];then $(MKDIR) $(B);fi + @if [ ! -d $(B)/client ];then $(MKDIR) $(B)/client;fi + @if [ ! -d $(B)/clientsmp ];then $(MKDIR) $(B)/clientsmp;fi + @if [ ! -d $(B)/ded ];then $(MKDIR) $(B)/ded;fi + @if [ ! -d $(B)/main ];then $(MKDIR) $(B)/main;fi + @if [ ! -d $(B)/main/cgame ];then $(MKDIR) $(B)/main/cgame;fi + @if [ ! -d $(B)/main/game ];then $(MKDIR) $(B)/main/game;fi + @if [ ! -d $(B)/main/ui ];then $(MKDIR) $(B)/main/ui;fi + @if [ ! -d $(B)/main/qcommon ];then $(MKDIR) $(B)/main/qcommon;fi + @if [ ! -d $(B)/main/vm ];then $(MKDIR) $(B)/main/vm;fi +# @if [ ! -d $(B)/missionpack ];then $(MKDIR) $(B)/missionpack;fi +# @if [ ! -d $(B)/missionpack/cgame ];then $(MKDIR) $(B)/missionpack/cgame;fi +# @if [ ! -d $(B)/missionpack/game ];then $(MKDIR) $(B)/missionpack/game;fi +# @if [ ! -d $(B)/missionpack/ui ];then $(MKDIR) $(B)/missionpack/ui;fi +# @if [ ! -d $(B)/missionpack/qcommon ];then $(MKDIR) $(B)/missionpack/qcommon;fi +# @if [ ! -d $(B)/missionpack/vm ];then $(MKDIR) $(B)/missionpack/vm;fi + @if [ ! -d $(B)/tools ];then $(MKDIR) $(B)/tools;fi + @if [ ! -d $(B)/tools/asm ];then $(MKDIR) $(B)/tools/asm;fi + @if [ ! -d $(B)/tools/etc ];then $(MKDIR) $(B)/tools/etc;fi + @if [ ! -d $(B)/tools/rcc ];then $(MKDIR) $(B)/tools/rcc;fi + @if [ ! -d $(B)/tools/cpp ];then $(MKDIR) $(B)/tools/cpp;fi + @if [ ! -d $(B)/tools/lburg ];then $(MKDIR) $(B)/tools/lburg;fi + +############################################################################# +# QVM BUILD TOOLS +############################################################################# + +TOOLS_OPTIMIZE = -g -O2 -Wall -fno-strict-aliasing +TOOLS_CFLAGS = $(TOOLS_OPTIMIZE) \ + -DTEMPDIR=\"$(TEMPDIR)\" -DSYSTEM=\"\" \ + -I$(Q3LCCSRCDIR) \ + -I$(LBURGDIR) +TOOLS_LDFLAGS = + +ifeq ($(GENERATE_DEPENDENCIES),1) + TOOLS_CFLAGS += -MMD +endif + +define DO_TOOLS_CC +$(echo_cmd) "TOOLS_CC $<" +$(Q)$(CC) $(TOOLS_CFLAGS) -o $@ -c $< +endef + +define DO_TOOLS_CC_DAGCHECK +$(echo_cmd) "TOOLS_CC_DAGCHECK $<" +$(Q)$(CC) $(TOOLS_CFLAGS) -Wno-unused -o $@ -c $< +endef + +LBURG = $(B)/tools/lburg/lburg$(BINEXT) +DAGCHECK_C = $(B)/tools/rcc/dagcheck.c +Q3RCC = $(B)/tools/q3rcc$(BINEXT) +Q3CPP = $(B)/tools/q3cpp$(BINEXT) +Q3LCC = $(B)/tools/q3lcc$(BINEXT) +Q3ASM = $(B)/tools/q3asm$(BINEXT) + +LBURGOBJ= \ + $(B)/tools/lburg/lburg.o \ + $(B)/tools/lburg/gram.o + +$(B)/tools/lburg/%.o: $(LBURGDIR)/%.c + $(DO_TOOLS_CC) + +$(LBURG): $(LBURGOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(TOOLS_LDFLAGS) -o $@ $^ + +Q3RCCOBJ = \ + $(B)/tools/rcc/alloc.o \ + $(B)/tools/rcc/bind.o \ + $(B)/tools/rcc/bytecode.o \ + $(B)/tools/rcc/dag.o \ + $(B)/tools/rcc/dagcheck.o \ + $(B)/tools/rcc/decl.o \ + $(B)/tools/rcc/enode.o \ + $(B)/tools/rcc/error.o \ + $(B)/tools/rcc/event.o \ + $(B)/tools/rcc/expr.o \ + $(B)/tools/rcc/gen.o \ + $(B)/tools/rcc/init.o \ + $(B)/tools/rcc/inits.o \ + $(B)/tools/rcc/input.o \ + $(B)/tools/rcc/lex.o \ + $(B)/tools/rcc/list.o \ + $(B)/tools/rcc/main.o \ + $(B)/tools/rcc/null.o \ + $(B)/tools/rcc/output.o \ + $(B)/tools/rcc/prof.o \ + $(B)/tools/rcc/profio.o \ + $(B)/tools/rcc/simp.o \ + $(B)/tools/rcc/stmt.o \ + $(B)/tools/rcc/string.o \ + $(B)/tools/rcc/sym.o \ + $(B)/tools/rcc/symbolic.o \ + $(B)/tools/rcc/trace.o \ + $(B)/tools/rcc/tree.o \ + $(B)/tools/rcc/types.o + +$(DAGCHECK_C): $(LBURG) $(Q3LCCSRCDIR)/dagcheck.md + $(echo_cmd) "LBURG $(Q3LCCSRCDIR)/dagcheck.md" + $(Q)$(LBURG) $(Q3LCCSRCDIR)/dagcheck.md $@ + +$(B)/tools/rcc/dagcheck.o: $(DAGCHECK_C) + $(DO_TOOLS_CC_DAGCHECK) + +$(B)/tools/rcc/%.o: $(Q3LCCSRCDIR)/%.c + $(DO_TOOLS_CC) + +$(Q3RCC): $(Q3RCCOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(TOOLS_LDFLAGS) -o $@ $^ + +Q3CPPOBJ = \ + $(B)/tools/cpp/cpp.o \ + $(B)/tools/cpp/lex.o \ + $(B)/tools/cpp/nlist.o \ + $(B)/tools/cpp/tokens.o \ + $(B)/tools/cpp/macro.o \ + $(B)/tools/cpp/eval.o \ + $(B)/tools/cpp/include.o \ + $(B)/tools/cpp/hideset.o \ + $(B)/tools/cpp/getopt.o \ + $(B)/tools/cpp/unix.o + +$(B)/tools/cpp/%.o: $(Q3CPPDIR)/%.c + $(DO_TOOLS_CC) + +$(Q3CPP): $(Q3CPPOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(TOOLS_LDFLAGS) -o $@ $^ + +Q3LCCOBJ = \ + $(B)/tools/etc/lcc.o \ + $(B)/tools/etc/bytecode.o + +$(B)/tools/etc/%.o: $(Q3LCCETCDIR)/%.c + $(DO_TOOLS_CC) + +$(Q3LCC): $(Q3LCCOBJ) $(Q3RCC) $(Q3CPP) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(TOOLS_LDFLAGS) -o $@ $(Q3LCCOBJ) + +define DO_Q3LCC +$(echo_cmd) "Q3LCC $<" +$(Q)$(Q3LCC) -o $@ $< +endef + +define DO_Q3LCC_MISSIONPACK +$(echo_cmd) "Q3LCC_MISSIONPACK $<" +$(Q)$(Q3LCC) -DMISSIONPACK -o $@ $< +endef + + +Q3ASMOBJ = \ + $(B)/tools/asm/q3asm.o \ + $(B)/tools/asm/cmdlib.o + +$(B)/tools/asm/%.o: $(Q3ASMDIR)/%.c + $(DO_TOOLS_CC) + +$(Q3ASM): $(Q3ASMOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(TOOLS_LDFLAGS) -o $@ $^ + + +############################################################################# +# CLIENT/SERVER +############################################################################# + +Q3OBJ = \ + $(B)/client/cl_cgame.o \ + $(B)/client/cl_cin.o \ + $(B)/client/cl_console.o \ + $(B)/client/cl_input.o \ + $(B)/client/cl_keys.o \ + $(B)/client/cl_main.o \ + $(B)/client/cl_net_chan.o \ + $(B)/client/cl_parse.o \ + $(B)/client/cl_scrn.o \ + $(B)/client/cl_ui.o \ + $(B)/client/cl_avi.o \ + \ + $(B)/client/cm_load.o \ + $(B)/client/cm_patch.o \ + $(B)/client/cm_terrain.o \ + $(B)/client/cm_polylib.o \ + $(B)/client/cm_test.o \ + $(B)/client/cm_trace.o \ + \ + $(B)/client/cmd.o \ + $(B)/client/common.o \ + $(B)/client/cvar.o \ + $(B)/client/files.o \ + $(B)/client/md4.o \ + $(B)/client/md5.o \ + $(B)/client/msg.o \ + $(B)/client/net_chan.o \ + $(B)/client/net_ip.o \ + $(B)/client/huffman.o \ + $(B)/client/tiki.o \ + \ + $(B)/client/snd_adpcm.o \ + $(B)/client/snd_dma.o \ + $(B)/client/snd_mem.o \ + $(B)/client/snd_mix.o \ + $(B)/client/snd_wavelet.o \ + \ + $(B)/client/snd_main.o \ + $(B)/client/snd_codec.o \ + $(B)/client/snd_codec_wav.o \ + $(B)/client/snd_codec_ogg.o \ + \ + $(B)/client/qal.o \ + $(B)/client/snd_openal.o \ + \ + $(B)/client/cl_curl.o \ + \ + $(B)/client/sv_bot.o \ + $(B)/client/sv_ccmds.o \ + $(B)/client/sv_client.o \ + $(B)/client/sv_game.o \ + $(B)/client/sv_init.o \ + $(B)/client/sv_main.o \ + $(B)/client/sv_net_chan.o \ + $(B)/client/sv_snapshot.o \ + $(B)/client/sv_world.o \ + \ + $(B)/client/q_math.o \ + $(B)/client/q_shared.o \ + \ + $(B)/client/unzip.o \ + $(B)/client/puff.o \ + $(B)/client/vm.o \ + $(B)/client/vm_interpreted.o \ + \ + $(B)/client/be_aas_bspq3.o \ + $(B)/client/be_aas_cluster.o \ + $(B)/client/be_aas_debug.o \ + $(B)/client/be_aas_entity.o \ + $(B)/client/be_aas_file.o \ + $(B)/client/be_aas_main.o \ + $(B)/client/be_aas_move.o \ + $(B)/client/be_aas_optimize.o \ + $(B)/client/be_aas_reach.o \ + $(B)/client/be_aas_route.o \ + $(B)/client/be_aas_routealt.o \ + $(B)/client/be_aas_sample.o \ + $(B)/client/be_ai_char.o \ + $(B)/client/be_ai_chat.o \ + $(B)/client/be_ai_gen.o \ + $(B)/client/be_ai_goal.o \ + $(B)/client/be_ai_move.o \ + $(B)/client/be_ai_weap.o \ + $(B)/client/be_ai_weight.o \ + $(B)/client/be_ea.o \ + $(B)/client/be_interface.o \ + $(B)/client/l_crc.o \ + $(B)/client/l_libvar.o \ + $(B)/client/l_log.o \ + $(B)/client/l_memory.o \ + $(B)/client/l_precomp.o \ + $(B)/client/l_script.o \ + $(B)/client/l_struct.o \ + \ + $(B)/client/jcapimin.o \ + $(B)/client/jchuff.o \ + $(B)/client/jcinit.o \ + $(B)/client/jccoefct.o \ + $(B)/client/jccolor.o \ + $(B)/client/jfdctflt.o \ + $(B)/client/jcdctmgr.o \ + $(B)/client/jcphuff.o \ + $(B)/client/jcmainct.o \ + $(B)/client/jcmarker.o \ + $(B)/client/jcmaster.o \ + $(B)/client/jcomapi.o \ + $(B)/client/jcparam.o \ + $(B)/client/jcprepct.o \ + $(B)/client/jcsample.o \ + $(B)/client/jdapimin.o \ + $(B)/client/jdapistd.o \ + $(B)/client/jdatasrc.o \ + $(B)/client/jdcoefct.o \ + $(B)/client/jdcolor.o \ + $(B)/client/jddctmgr.o \ + $(B)/client/jdhuff.o \ + $(B)/client/jdinput.o \ + $(B)/client/jdmainct.o \ + $(B)/client/jdmarker.o \ + $(B)/client/jdmaster.o \ + $(B)/client/jdpostct.o \ + $(B)/client/jdsample.o \ + $(B)/client/jdtrans.o \ + $(B)/client/jerror.o \ + $(B)/client/jidctflt.o \ + $(B)/client/jmemmgr.o \ + $(B)/client/jmemnobs.o \ + $(B)/client/jutils.o \ + \ + $(B)/client/tr_animation.o \ + $(B)/client/tr_backend.o \ + $(B)/client/tr_bsp.o \ + $(B)/client/tr_cmds.o \ + $(B)/client/tr_curve.o \ + $(B)/client/tr_flares.o \ + $(B)/client/tr_font.o \ + $(B)/client/tr_image.o \ + $(B)/client/tr_init.o \ + $(B)/client/tr_light.o \ + $(B)/client/tr_main.o \ + $(B)/client/tr_marks.o \ + $(B)/client/tr_mesh.o \ + $(B)/client/tr_model.o \ + $(B)/client/tr_noise.o \ + $(B)/client/tr_scene.o \ + $(B)/client/tr_shade.o \ + $(B)/client/tr_shade_calc.o \ + $(B)/client/tr_shader.o \ + $(B)/client/tr_shadows.o \ + $(B)/client/tr_sky.o \ + $(B)/client/tr_sprite.o \ + $(B)/client/tr_surface.o \ + $(B)/client/tr_world.o \ + \ + $(B)/client/sdl_gamma.o \ + $(B)/client/sdl_input.o \ + $(B)/client/sdl_snd.o \ + \ + $(B)/client/con_passive.o \ + $(B)/client/con_log.o \ + $(B)/client/sys_main.o + +ifeq ($(ARCH),i386) + Q3OBJ += \ + $(B)/client/snd_mixa.o \ + $(B)/client/matha.o \ + $(B)/client/ftola.o \ + $(B)/client/snapvectora.o +endif +ifeq ($(ARCH),x86) + Q3OBJ += \ + $(B)/client/snd_mixa.o \ + $(B)/client/matha.o \ + $(B)/client/ftola.o \ + $(B)/client/snapvectora.o +endif + +ifeq ($(HAVE_VM_COMPILED),true) + ifeq ($(ARCH),i386) + Q3OBJ += $(B)/client/vm_x86.o + endif + ifeq ($(ARCH),x86) + Q3OBJ += $(B)/client/vm_x86.o + endif + ifeq ($(ARCH),x86_64) + Q3OBJ += $(B)/client/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o + endif + ifeq ($(ARCH),ppc) + Q3OBJ += $(B)/client/vm_ppc.o + endif +endif + +ifeq ($(PLATFORM),mingw32) + Q3OBJ += \ + $(B)/client/win_resource.o \ + $(B)/client/sys_win32.o +else + Q3OBJ += \ + $(B)/client/sys_unix.o +endif + +Q3POBJ += \ + $(B)/client/sdl_glimp.o + +Q3POBJ_SMP += \ + $(B)/clientsmp/sdl_glimp.o + +$(B)/openmohaa.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ) $(LIBSDLMAIN) + $(echo_cmd) "LD $@" + $(Q)$(CC) -o $@ $(Q3OBJ) $(Q3POBJ) $(CLIENT_LDFLAGS) \ + $(LDFLAGS) $(LIBSDLMAIN) + +$(B)/openmohaa-smp.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ_SMP) $(LIBSDLMAIN) + $(echo_cmd) "LD $@" + $(Q)$(CC) -o $@ $(Q3OBJ) $(Q3POBJ_SMP) $(CLIENT_LDFLAGS) \ + $(THREAD_LDFLAGS) $(LDFLAGS) $(LIBSDLMAIN) + +ifneq ($(strip $(LIBSDLMAIN)),) +ifneq ($(strip $(LIBSDLMAINSRC)),) +$(LIBSDLMAIN) : $(LIBSDLMAINSRC) + cp $< $@ + ranlib $@ +endif +endif + + + +############################################################################# +# DEDICATED SERVER +############################################################################# + +Q3DOBJ = \ + $(B)/ded/sv_bot.o \ + $(B)/ded/sv_client.o \ + $(B)/ded/sv_ccmds.o \ + $(B)/ded/sv_game.o \ + $(B)/ded/sv_init.o \ + $(B)/ded/sv_main.o \ + $(B)/ded/sv_net_chan.o \ + $(B)/ded/sv_snapshot.o \ + $(B)/ded/sv_world.o \ + \ + $(B)/ded/cm_load.o \ + $(B)/ded/cm_patch.o \ + $(B)/ded/cm_terrain.o \ + $(B)/ded/cm_polylib.o \ + $(B)/ded/cm_test.o \ + $(B)/ded/cm_trace.o \ + $(B)/ded/cmd.o \ + $(B)/ded/common.o \ + $(B)/ded/cvar.o \ + $(B)/ded/files.o \ + $(B)/ded/md4.o \ + $(B)/ded/msg.o \ + $(B)/ded/net_chan.o \ + $(B)/ded/net_ip.o \ + $(B)/ded/huffman.o \ + $(B)/ded/tiki.o \ + \ + $(B)/ded/q_math.o \ + $(B)/ded/q_shared.o \ + \ + $(B)/ded/unzip.o \ + $(B)/ded/vm.o \ + $(B)/ded/vm_interpreted.o \ + \ + $(B)/ded/be_aas_bspq3.o \ + $(B)/ded/be_aas_cluster.o \ + $(B)/ded/be_aas_debug.o \ + $(B)/ded/be_aas_entity.o \ + $(B)/ded/be_aas_file.o \ + $(B)/ded/be_aas_main.o \ + $(B)/ded/be_aas_move.o \ + $(B)/ded/be_aas_optimize.o \ + $(B)/ded/be_aas_reach.o \ + $(B)/ded/be_aas_route.o \ + $(B)/ded/be_aas_routealt.o \ + $(B)/ded/be_aas_sample.o \ + $(B)/ded/be_ai_char.o \ + $(B)/ded/be_ai_chat.o \ + $(B)/ded/be_ai_gen.o \ + $(B)/ded/be_ai_goal.o \ + $(B)/ded/be_ai_move.o \ + $(B)/ded/be_ai_weap.o \ + $(B)/ded/be_ai_weight.o \ + $(B)/ded/be_ea.o \ + $(B)/ded/be_interface.o \ + $(B)/ded/l_crc.o \ + $(B)/ded/l_libvar.o \ + $(B)/ded/l_log.o \ + $(B)/ded/l_memory.o \ + $(B)/ded/l_precomp.o \ + $(B)/ded/l_script.o \ + $(B)/ded/l_struct.o \ + \ + $(B)/ded/null_client.o \ + $(B)/ded/null_input.o \ + $(B)/ded/null_snddma.o \ + \ + $(B)/ded/con_log.o \ + $(B)/ded/sys_main.o + +ifeq ($(ARCH),i386) + Q3DOBJ += \ + $(B)/ded/ftola.o \ + $(B)/ded/snapvectora.o \ + $(B)/ded/matha.o +endif +ifeq ($(ARCH),x86) + Q3DOBJ += \ + $(B)/ded/ftola.o \ + $(B)/ded/snapvectora.o \ + $(B)/ded/matha.o +endif + +ifeq ($(HAVE_VM_COMPILED),true) + ifeq ($(ARCH),i386) + Q3DOBJ += $(B)/ded/vm_x86.o + endif + ifeq ($(ARCH),x86) + Q3DOBJ += $(B)/ded/vm_x86.o + endif + ifeq ($(ARCH),x86_64) + Q3DOBJ += $(B)/ded/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o + endif + ifeq ($(ARCH),ppc) + Q3DOBJ += $(B)/ded/vm_ppc.o + endif +endif + +ifeq ($(PLATFORM),mingw32) + Q3DOBJ += \ + $(B)/ded/win_resource.o \ + $(B)/ded/sys_win32.o \ + $(B)/ded/con_win32.o +else + Q3DOBJ += \ + $(B)/ded/sys_unix.o \ + $(B)/ded/con_tty.o +endif + +$(B)/omohaaded.$(ARCH)$(BINEXT): $(Q3DOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) -o $@ $(Q3DOBJ) $(LDFLAGS) + + + +############################################################################# +## BASEQ3 CGAME +############################################################################# + +Q3CGOBJ_ = \ + $(B)/main/cgame/cg_main.o \ + $(B)/main/game/bg_misc.o \ + $(B)/main/game/bg_pmove.o \ + $(B)/main/game/bg_slidemove.o \ + $(B)/main/game/bg_lib.o \ + $(B)/main/cgame/cg_beam.o \ + $(B)/main/cgame/cg_consolecmds.o \ + $(B)/main/cgame/cg_draw.o \ + $(B)/main/cgame/cg_drawtools.o \ + $(B)/main/cgame/cg_effects.o \ + $(B)/main/cgame/cg_ents.o \ + $(B)/main/cgame/cg_eventSystem.o \ + $(B)/main/cgame/cg_info.o \ + $(B)/main/cgame/cg_localents.o \ + $(B)/main/cgame/cg_marks.o \ + $(B)/main/cgame/cg_modelanim.o \ + $(B)/main/cgame/cg_parsemsg.o \ + $(B)/main/cgame/cg_players.o \ + $(B)/main/cgame/cg_playerstate.o \ + $(B)/main/cgame/cg_predict.o \ + $(B)/main/cgame/cg_rain.o \ + $(B)/main/cgame/cg_servercmds.o \ + $(B)/main/cgame/cg_snapshot.o \ + $(B)/main/cgame/cg_specialfx.o \ + $(B)/main/cgame/cg_ubersound.o \ + $(B)/main/cgame/cg_view.o \ + $(B)/main/cgame/cg_viewmodelanim.o \ + $(B)/main/cgame/cg_weapons.o \ + \ + $(B)/main/qcommon/q_math.o \ + $(B)/main/qcommon/q_shared.o + +Q3CGOBJ = $(Q3CGOBJ_) $(B)/main/cgame/cg_syscalls.o +Q3CGVMOBJ = $(Q3CGOBJ_:%.o=%.asm) + +$(B)/main/cgame$(ARCH)opm.$(SHLIBEXT): $(Q3CGOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(SHLIBLDFLAGS) -o $@ $(Q3CGOBJ) + +$(B)/main/vm/cgame.qvm: $(Q3CGVMOBJ) $(CGDIR)/cg_syscalls.asm $(Q3ASM) + $(echo_cmd) "Q3ASM $@" + $(Q)$(Q3ASM) -o $@ $(Q3CGVMOBJ) $(CGDIR)/cg_syscalls.asm + +############################################################################# +## MISSIONPACK CGAME +############################################################################# + +MPCGOBJ_ = \ + $(B)/missionpack/cgame/cg_main.o \ + $(B)/missionpack/game/bg_misc.o \ + $(B)/missionpack/game/bg_pmove.o \ + $(B)/missionpack/game/bg_slidemove.o \ + $(B)/missionpack/game/bg_lib.o \ + $(B)/missionpack/cgame/cg_consolecmds.o \ + $(B)/missionpack/cgame/cg_draw.o \ + $(B)/missionpack/cgame/cg_drawtools.o \ + $(B)/missionpack/cgame/cg_effects.o \ + $(B)/missionpack/cgame/cg_ents.o \ + $(B)/missionpack/cgame/cg_info.o \ + $(B)/missionpack/cgame/cg_localents.o \ + $(B)/missionpack/cgame/cg_marks.o \ + $(B)/missionpack/cgame/cg_players.o \ + $(B)/missionpack/cgame/cg_playerstate.o \ + $(B)/missionpack/cgame/cg_predict.o \ + $(B)/missionpack/cgame/cg_servercmds.o \ + $(B)/missionpack/cgame/cg_snapshot.o \ + $(B)/missionpack/cgame/cg_view.o \ + $(B)/missionpack/cgame/cg_weapons.o \ + \ + $(B)/missionpack/qcommon/q_math.o \ + $(B)/missionpack/qcommon/q_shared.o + +MPCGOBJ = $(MPCGOBJ_) $(B)/missionpack/cgame/cg_syscalls.o +MPCGVMOBJ = $(MPCGOBJ_:%.o=%.asm) + +$(B)/missionpack/cgame$(ARCH).$(SHLIBEXT): $(MPCGOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(SHLIBLDFLAGS) -o $@ $(MPCGOBJ) + +$(B)/missionpack/vm/cgame.qvm: $(MPCGVMOBJ) $(CGDIR)/cg_syscalls.asm $(Q3ASM) + $(echo_cmd) "Q3ASM $@" + $(Q)$(Q3ASM) -o $@ $(MPCGVMOBJ) $(CGDIR)/cg_syscalls.asm + + + +############################################################################# +## BASEQ3 GAME +############################################################################# + +Q3GOBJ_ = \ + $(B)/main/game/g_main.o \ + $(B)/main/game/ai_chat.o \ + $(B)/main/game/ai_cmd.o \ + $(B)/main/game/ai_dmnet.o \ + $(B)/main/game/ai_dmq3.o \ + $(B)/main/game/ai_main.o \ + $(B)/main/game/ai_team.o \ + $(B)/main/game/ai_vcmd.o \ + $(B)/main/game/bg_misc.o \ + $(B)/main/game/bg_pmove.o \ + $(B)/main/game/bg_slidemove.o \ + $(B)/main/game/bg_lib.o \ + $(B)/main/game/g_active.o \ + $(B)/main/game/g_arenas.o \ + $(B)/main/game/g_bot.o \ + $(B)/main/game/g_client.o \ + $(B)/main/game/g_cmds.o \ + $(B)/main/game/g_combat.o \ + $(B)/main/game/g_items.o \ + $(B)/main/game/g_mem.o \ + $(B)/main/game/g_misc.o \ + $(B)/main/game/g_missile.o \ + $(B)/main/game/g_mover.o \ + $(B)/main/game/g_session.o \ + $(B)/main/game/g_spawn.o \ + $(B)/main/game/g_svcmds.o \ + $(B)/main/game/g_target.o \ + $(B)/main/game/g_team.o \ + $(B)/main/game/g_trigger.o \ + $(B)/main/game/g_utils.o \ + $(B)/main/game/g_weapon.o \ + \ + $(B)/main/qcommon/q_math.o \ + $(B)/main/qcommon/q_shared.o + +Q3GOBJ = $(Q3GOBJ_) $(B)/main/game/g_syscalls.o +Q3GVMOBJ = $(Q3GOBJ_:%.o=%.asm) + +$(B)/main/game$(ARCH)opm.$(SHLIBEXT): $(Q3GOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(SHLIBLDFLAGS) -o $@ $(Q3GOBJ) + +$(B)/main/vm/qagame.qvm: $(Q3GVMOBJ) $(GDIR)/g_syscalls.asm $(Q3ASM) + $(echo_cmd) "Q3ASM $@" + $(Q)$(Q3ASM) -o $@ $(Q3GVMOBJ) $(GDIR)/g_syscalls.asm + +############################################################################# +## MISSIONPACK GAME +############################################################################# + +MPGOBJ_ = \ + $(B)/missionpack/game/g_main.o \ + $(B)/missionpack/game/ai_chat.o \ + $(B)/missionpack/game/ai_cmd.o \ + $(B)/missionpack/game/ai_dmnet.o \ + $(B)/missionpack/game/ai_dmq3.o \ + $(B)/missionpack/game/ai_main.o \ + $(B)/missionpack/game/ai_team.o \ + $(B)/missionpack/game/ai_vcmd.o \ + $(B)/missionpack/game/bg_misc.o \ + $(B)/missionpack/game/bg_pmove.o \ + $(B)/missionpack/game/bg_slidemove.o \ + $(B)/missionpack/game/bg_lib.o \ + $(B)/missionpack/game/g_active.o \ + $(B)/missionpack/game/g_arenas.o \ + $(B)/missionpack/game/g_bot.o \ + $(B)/missionpack/game/g_client.o \ + $(B)/missionpack/game/g_cmds.o \ + $(B)/missionpack/game/g_combat.o \ + $(B)/missionpack/game/g_items.o \ + $(B)/missionpack/game/g_mem.o \ + $(B)/missionpack/game/g_misc.o \ + $(B)/missionpack/game/g_missile.o \ + $(B)/missionpack/game/g_mover.o \ + $(B)/missionpack/game/g_session.o \ + $(B)/missionpack/game/g_spawn.o \ + $(B)/missionpack/game/g_svcmds.o \ + $(B)/missionpack/game/g_target.o \ + $(B)/missionpack/game/g_team.o \ + $(B)/missionpack/game/g_trigger.o \ + $(B)/missionpack/game/g_utils.o \ + $(B)/missionpack/game/g_weapon.o \ + \ + $(B)/missionpack/qcommon/q_math.o \ + $(B)/missionpack/qcommon/q_shared.o + +MPGOBJ = $(MPGOBJ_) $(B)/missionpack/game/g_syscalls.o +MPGVMOBJ = $(MPGOBJ_:%.o=%.asm) + +$(B)/missionpack/qagame$(ARCH).$(SHLIBEXT): $(MPGOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(SHLIBLDFLAGS) -o $@ $(MPGOBJ) + +$(B)/missionpack/vm/qagame.qvm: $(MPGVMOBJ) $(GDIR)/g_syscalls.asm $(Q3ASM) + $(echo_cmd) "Q3ASM $@" + $(Q)$(Q3ASM) -o $@ $(MPGVMOBJ) $(GDIR)/g_syscalls.asm + + + +############################################################################# +## BASEQ3 UI +############################################################################# + +Q3UIOBJ_ = \ + $(B)/main/ui/ui_main.o \ + $(B)/main/ui/ui_model.o \ + $(B)/main/ui/ui_quarks.o \ + $(B)/main/ui/ui_urc.o \ + \ + $(B)/main/qcommon/q_math.o \ + $(B)/main/qcommon/q_shared.o + +Q3UIOBJ = $(Q3UIOBJ_) $(B)/main/ui/ui_syscalls.o +Q3UIVMOBJ = $(Q3UIOBJ_:%.o=%.asm) + +$(B)/main/ui$(ARCH)opm.$(SHLIBEXT): $(Q3UIOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3UIOBJ) + +$(B)/main/vm/ui.qvm: $(Q3UIVMOBJ) $(UIDIR)/ui_syscalls.asm $(Q3ASM) + $(echo_cmd) "Q3ASM $@" + $(Q)$(Q3ASM) -o $@ $(Q3UIVMOBJ) $(UIDIR)/ui_syscalls.asm + +############################################################################# +## MISSIONPACK UI +############################################################################# + +MPUIOBJ_ = \ + $(B)/missionpack/ui/ui_main.o \ + $(B)/missionpack/ui/ui_atoms.o \ + $(B)/missionpack/ui/ui_gameinfo.o \ + $(B)/missionpack/ui/ui_model.o \ + $(B)/missionpack/ui/ui_players.o \ + \ + $(B)/missionpack/game/bg_misc.o \ + $(B)/missionpack/game/bg_lib.o \ + \ + $(B)/missionpack/qcommon/q_math.o \ + $(B)/missionpack/qcommon/q_shared.o + +MPUIOBJ = $(MPUIOBJ_) $(B)/missionpack/ui/ui_syscalls.o +MPUIVMOBJ = $(MPUIOBJ_:%.o=%.asm) + +$(B)/missionpack/ui$(ARCH).$(SHLIBEXT): $(MPUIOBJ) + $(echo_cmd) "LD $@" + $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(MPUIOBJ) + +$(B)/missionpack/vm/ui.qvm: $(MPUIVMOBJ) $(UIDIR)/ui_syscalls.asm $(Q3ASM) + $(echo_cmd) "Q3ASM $@" + $(Q)$(Q3ASM) -o $@ $(MPUIVMOBJ) $(UIDIR)/ui_syscalls.asm + + + +############################################################################# +## CLIENT/SERVER RULES +############################################################################# + +$(B)/client/%.o: $(ASMDIR)/%.s + $(DO_AS) + +$(B)/client/%.o: $(CDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(SDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(CMDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(BLIBDIR)/%.c + $(DO_BOT_CC) + +$(B)/client/%.o: $(JPDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(RDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(SDLDIR)/%.c + $(DO_CC) + +$(B)/clientsmp/%.o: $(SDLDIR)/%.c + $(DO_SMP_CC) + +$(B)/client/%.o: $(SYSDIR)/%.c + $(DO_CC) + +$(B)/client/%.o: $(SYSDIR)/%.rc + $(DO_WINDRES) + + +$(B)/ded/%.o: $(ASMDIR)/%.s + $(DO_AS) + +$(B)/ded/%.o: $(SDIR)/%.c + $(DO_DED_CC) + +$(B)/ded/%.o: $(CMDIR)/%.c + $(DO_DED_CC) + +$(B)/ded/%.o: $(BLIBDIR)/%.c + $(DO_BOT_CC) + +$(B)/ded/%.o: $(SYSDIR)/%.c + $(DO_DED_CC) + +$(B)/ded/%.o: $(SYSDIR)/%.rc + $(DO_WINDRES) + +$(B)/ded/%.o: $(NDIR)/%.c + $(DO_DED_CC) + +# Extra dependencies to ensure the SVN version is incorporated +ifeq ($(USE_SVN),1) + $(B)/client/cl_console.o : .svn/entries + $(B)/client/common.o : .svn/entries + $(B)/ded/common.o : .svn/entries +endif + + +############################################################################# +## GAME MODULE RULES +############################################################################# + +$(B)/main/cgame/%.o: $(CGDIR)/%.c + $(DO_SHLIB_CC) + +$(B)/main/cgame/%.asm: $(CGDIR)/%.c $(Q3LCC) + $(DO_Q3LCC) + +$(B)/missionpack/cgame/%.o: $(CGDIR)/%.c + $(DO_SHLIB_CC_MISSIONPACK) + +$(B)/missionpack/cgame/%.asm: $(CGDIR)/%.c $(Q3LCC) + $(DO_Q3LCC_MISSIONPACK) + + +$(B)/main/game/%.o: $(GDIR)/%.c + $(DO_SHLIB_CC) + +$(B)/main/game/%.asm: $(GDIR)/%.c $(Q3LCC) + $(DO_Q3LCC) + +$(B)/missionpack/game/%.o: $(GDIR)/%.c + $(DO_SHLIB_CC_MISSIONPACK) + +$(B)/missionpack/game/%.asm: $(GDIR)/%.c $(Q3LCC) + $(DO_Q3LCC_MISSIONPACK) + + +$(B)/main/ui/%.o: $(Q3UIDIR)/%.c + $(DO_SHLIB_CC) + +$(B)/main/ui/%.asm: $(Q3UIDIR)/%.c $(Q3LCC) + $(DO_Q3LCC) + +$(B)/missionpack/ui/%.o: $(UIDIR)/%.c + $(DO_SHLIB_CC_MISSIONPACK) + +$(B)/missionpack/ui/%.asm: $(UIDIR)/%.c $(Q3LCC) + $(DO_Q3LCC_MISSIONPACK) + + +$(B)/main/qcommon/%.o: $(CMDIR)/%.c + $(DO_SHLIB_CC) + +$(B)/main/qcommon/%.asm: $(CMDIR)/%.c $(Q3LCC) + $(DO_Q3LCC) + +$(B)/missionpack/qcommon/%.o: $(CMDIR)/%.c + $(DO_SHLIB_CC_MISSIONPACK) + +$(B)/missionpack/qcommon/%.asm: $(CMDIR)/%.c $(Q3LCC) + $(DO_Q3LCC_MISSIONPACK) + + +############################################################################# +# MISC +############################################################################# + +OBJ = $(Q3OBJ) $(Q3POBJ) $(Q3POBJ_SMP) $(Q3DOBJ) \ + $(MPGOBJ) $(Q3GOBJ) $(Q3CGOBJ) $(MPCGOBJ) $(Q3UIOBJ) $(MPUIOBJ) \ + $(MPGVMOBJ) $(Q3GVMOBJ) $(Q3CGVMOBJ) $(MPCGVMOBJ) $(Q3UIVMOBJ) $(MPUIVMOBJ) +TOOLSOBJ = $(LBURGOBJ) $(Q3CPPOBJ) $(Q3RCCOBJ) $(Q3LCCOBJ) $(Q3ASMOBJ) + + +copyfiles: release + @if [ ! -d $(COPYDIR)/main ]; then echo "You need to set COPYDIR to where your Quake3 data is!"; fi + -$(MKDIR) -p -m 0755 $(COPYDIR)/main + -$(MKDIR) -p -m 0755 $(COPYDIR)/missionpack + +ifneq ($(BUILD_CLIENT),0) + $(INSTALL) -s -m 0755 $(BR)/openmohaa.$(ARCH)$(BINEXT) $(COPYDIR)/openmohaa.$(ARCH)$(BINEXT) +endif + +# Don't copy the SMP until it's working together with SDL. +#ifneq ($(BUILD_CLIENT_SMP),0) +# $(INSTALL) -s -m 0755 $(BR)/openmohaa-smp.$(ARCH)$(BINEXT) $(COPYDIR)/openmohaa-smp.$(ARCH)$(BINEXT) +#endif + +ifneq ($(BUILD_SERVER),0) + @if [ -f $(BR)/omohaaded.$(ARCH)$(BINEXT) ]; then \ + $(INSTALL) -s -m 0755 $(BR)/omohaaded.$(ARCH)$(BINEXT) $(COPYDIR)/omohaaded.$(ARCH)$(BINEXT); \ + fi +endif + +ifneq ($(BUILD_GAME_SO),0) + $(INSTALL) -s -m 0755 $(BR)/main/cgame$(ARCH).$(SHLIBEXT) \ + $(COPYDIR)/main/. + $(INSTALL) -s -m 0755 $(BR)/main/qagame$(ARCH).$(SHLIBEXT) \ + $(COPYDIR)/main/. + $(INSTALL) -s -m 0755 $(BR)/main/ui$(ARCH).$(SHLIBEXT) \ + $(COPYDIR)/main/. + -$(MKDIR) -p -m 0755 $(COPYDIR)/missionpack + $(INSTALL) -s -m 0755 $(BR)/missionpack/cgame$(ARCH).$(SHLIBEXT) \ + $(COPYDIR)/missionpack/. + $(INSTALL) -s -m 0755 $(BR)/missionpack/qagame$(ARCH).$(SHLIBEXT) \ + $(COPYDIR)/missionpack/. + $(INSTALL) -s -m 0755 $(BR)/missionpack/ui$(ARCH).$(SHLIBEXT) \ + $(COPYDIR)/missionpack/. +endif + +clean: clean-debug clean-release + @$(MAKE) -C $(LOKISETUPDIR) clean + +clean-debug: + @$(MAKE) clean2 B=$(BD) + +clean-release: + @$(MAKE) clean2 B=$(BR) + +clean2: + @echo "CLEAN $(B)" + @rm -f $(OBJ) + @rm -f $(OBJ_D_FILES) + @rm -f $(TARGETS) + +toolsclean: toolsclean-debug toolsclean-release + +toolsclean-debug: + @$(MAKE) toolsclean2 B=$(BD) + +toolsclean-release: + @$(MAKE) toolsclean2 B=$(BR) + +toolsclean2: + @echo "TOOLS_CLEAN $(B)" + @rm -f $(TOOLSOBJ) + @rm -f $(TOOLSOBJ_D_FILES) + @rm -f $(LBURG) $(DAGCHECK_C) $(Q3RCC) $(Q3CPP) $(Q3LCC) $(Q3ASM) + +distclean: clean toolsclean + @rm -rf $(BUILD_DIR) + +installer: release + @$(MAKE) VERSION=$(VERSION) -C $(LOKISETUPDIR) V=$(V) + +dist: + rm -rf openmohaa-$(SVN_VERSION) + svn export . openmohaa-$(SVN_VERSION) + tar --owner=root --group=root --force-local -cjf openmohaa-$(SVN_VERSION).tar.bz2 openmohaa-$(SVN_VERSION) + rm -rf openmohaa-$(SVN_VERSION) + +############################################################################# +# DEPENDENCIES +############################################################################# + +OBJ_D_FILES=$(filter %.d,$(OBJ:%.o=%.d)) +TOOLSOBJ_D_FILES=$(filter %.d,$(TOOLSOBJ:%.o=%.d)) +-include $(OBJ_D_FILES) $(TOOLSOBJ_D_FILES) + +.PHONY: all clean clean2 clean-debug clean-release copyfiles \ + debug default dist distclean installer makedirs \ + release targets \ + toolsclean toolsclean2 toolsclean-debug toolsclean-release diff --git a/PLEASE_USE_VS2013.txt b/PLEASE_USE_VS2013.txt new file mode 100644 index 00000000..9ea83aa8 --- /dev/null +++ b/PLEASE_USE_VS2013.txt @@ -0,0 +1,4 @@ +Sorry about that. + +I made so much modifications for the UI, so I didn't add files to the VS2008/Eclipse projects yet. +So it's advised to use VS2013 if you want to compile successfully. \ No newline at end of file diff --git a/README.txt b/README.txt new file mode 100644 index 00000000..d8b54db7 --- /dev/null +++ b/README.txt @@ -0,0 +1,95 @@ +<<<<<<< HEAD + / _ \ _ __ ___ _ __ | \/ |/ _ \| | | | / \ / \ +| | | | '_ \ / _ \ '_ \| |\/| | | | | |_| | / _ \ / _ \ +| |_| | |_) | __/ | | | | | | |_| | _ |/ ___ \ / ___ \ + \___/| .__/ \___|_| |_|_| |_|\___/|_| |_/_/ \_\/_/ \_\ + |_| + +Alert +======================= +The OpenMoHAA client build is currently unusable due to the UI being reimplemented, please don't use it. +Currently only the server version is working. + +Running +======================= +Backup gamex86.dll (rename it to gamex86.bak). +Rename cgamex86.dll to cgamex86mohaa.dll. + +a) extract archive to your MOHAA installation directory. +-or- +b) Copy all pak*.pk3 files and the sound/ directory from your MOHAA/main +directory into openmohaa's 'main' directory. + +If you have problems running the game : + +You may need to install Microsoft Visual C++ 2010 Redistributable from +http://www.microsoft.com/download/en/details.aspx?id=5555 + +or you may need to install Microsoft Visual C++ Redistributable Packages for Visual Studio 2013 from +http://www.microsoft.com/en-us/download/details.aspx?id=40784 + +You can now start a local MOHAA/OpenMOHAA server or play on a server. + +Compiling +======================= +*NIX: +make sure you have compiler + libraries installed +Required extra libaries: libopenal-dev libsdl-dev libmad-dev +OpenGL: sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev +OpenAL: sudo apt-get install libopenal1 libopenal-dev +ALUT: sudo apt-get install libalut0 libalut-dev + +Download and install Eclipse with your NIX OS version +http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/marsr + +Start Eclipse and set the workspace path to misc/nix. +Then import an existing workspace using the path to misc/nix. + +Clean and compile by using Eclipse + +WIN: + +Visual Studio 2008 -> Open misc/msvc8/openmohaa/openmohaa.sln. +Visual Studio 2012 -> Open misc/msvc12_13/openmohaa/openmohaa.sln and set all projects platform toolset to v110 if you get the compilation error. +Visual Studio 2013 -> Open misc/msvc12_13/openmohaa/openmohaa.sln +OpenGL32.lib should be shipped with any Visual Studio versions. + +GENERAL: +You don't need anything else as everything needed is in the repository. +Now you can compile the solution. + +===== +SDL +http://www.libsdl.org/ download Source code, compile +===== +OpenAL +http://connect.creativelabs.com/openal/default.aspx download OpenAL soft source +download CMake at http://www.cmake.org/cmake/resources/software.html +run cmake on OpenAL, compile +===== +LibMAD +http://www.underbit.com/products/mad/ download source code, compile +===== + +Miscellaneous +======================= + +Output files : + +build/testutils_x** --> can be placed anywhere, it's just a test tool for scripts. + +build/openmohaa_x** --> MOHAA/ +build/omohaaded_x** --> MOHAA/ + +build/main/cgamex**opm --> MOHAA/main +build/main/gamex** --> MOHAA/main (BACKUP MOHAA/main/gamex86.dll FIRST) +build/main/uix**opm --> MOHAA/main +build/main/cgamex86 --> MOHAA/main (RENAME MOHAA/main/cgamex86.dll to cgamex86mohaa.dll FIRST) + +That's all, now run MOHAA or OpenMOHAA and start a local server. + +URL +======================= +http://openmohaa.sf.net/ +http://www.x-null.net/ +http://www.mods-r-us.net diff --git a/TODO.TXT b/TODO.TXT new file mode 100644 index 00000000..49361291 --- /dev/null +++ b/TODO.TXT @@ -0,0 +1,25 @@ +//// //// //// //// //// +/// OpenMoHAA - TODO /// +//// //// //// //// //// + +================ += Server code = +================ +1) Fix some crashes + +================ += Client = +================ +2) Better client/sound implementation +3) Better renderer implementation (light, fog) +4) Better cgame implementation (using FAKK2) +5) UI implementation (unfortunately, the mohaa UI is fully based on FAKK 2 sources but isn't available anywhere) + +================ += Game code = +================ +6) Finish the vehicle implementation +--- Open Beta --- +7) Actors/SinglePlayer +8) SH/BT features (there are not much things to implement I guess) +--- Release --- \ No newline at end of file diff --git a/build/main/models/omtests/test01_bonetype1.tik b/build/main/models/omtests/test01_bonetype1.tik new file mode 100644 index 00000000..bb5ae3db --- /dev/null +++ b/build/main/models/omtests/test01_bonetype1.tik @@ -0,0 +1,12 @@ +TIKI + +// su44: test MoHAA model + +setup { + scale 1 + skelmodel models/omtests/test01_bonetype1/test01_bonetype1.skd +} + +animations { + idle models/omtests/test01_bonetype1/test01_bonetype1.skc +} \ No newline at end of file diff --git a/build/main/models/omtests/test01_bonetype1/readme.txt b/build/main/models/omtests/test01_bonetype1/readme.txt new file mode 100644 index 00000000..5c1ff42d --- /dev/null +++ b/build/main/models/omtests/test01_bonetype1/readme.txt @@ -0,0 +1,3 @@ +su44: a simple MoHAA model exported by Lightray3d. +Use "spawn omtests/test01_bonetype1.tik" console command to spawn it in game, +and "tiki_dumpbones omtests/test01_bonetype1.tik" to dump it's bonelist (names and types) to console. \ No newline at end of file diff --git a/build/main/models/omtests/test01_bonetype1/test01.md5mesh b/build/main/models/omtests/test01_bonetype1/test01.md5mesh new file mode 100644 index 00000000..5b93b514 --- /dev/null +++ b/build/main/models/omtests/test01_bonetype1/test01.md5mesh @@ -0,0 +1,1999 @@ +MD5Version 10 + +numJoints 3 +numMeshes 4 + +joints { + "Bone1" -1 ( 0.000000 0.000000 0.000000 ) ( 0.000000 0.000000 0.000000 ) // + "Bone2" 0 ( 0.000000 0.000000 63.999954 ) ( 0.000000 0.000000 0.000000 ) //Bone1 + "Bone3" 1 ( 0.000000 63.999958 63.999962 ) ( 0.000000 0.000000 0.000000 ) //Bone2 +} + +mesh { + // meshes: bone2_shpere + shader "" + + numverts 158 + vert 0 ( 1.000000 0.000000 ) 0 1 + vert 1 ( 1.000000 0.071429 ) 1 1 + vert 2 ( 0.916667 0.071429 ) 2 1 + vert 3 ( 0.833333 0.071429 ) 3 1 + vert 4 ( 0.750000 0.071429 ) 4 1 + vert 5 ( 0.666667 0.071429 ) 5 1 + vert 6 ( 0.583333 0.071429 ) 6 1 + vert 7 ( 0.500000 0.071429 ) 7 1 + vert 8 ( 0.416667 0.071429 ) 8 1 + vert 9 ( 0.333333 0.071429 ) 9 1 + vert 10 ( 0.250000 0.071429 ) 10 1 + vert 11 ( 0.166667 0.071429 ) 11 1 + vert 12 ( 0.083333 0.071429 ) 12 1 + vert 13 ( 1.000000 0.142857 ) 13 1 + vert 14 ( 0.916667 0.142857 ) 14 1 + vert 15 ( 0.833333 0.142857 ) 15 1 + vert 16 ( 0.750000 0.142857 ) 16 1 + vert 17 ( 0.666667 0.142857 ) 17 1 + vert 18 ( 0.583333 0.142857 ) 18 1 + vert 19 ( 0.500000 0.142857 ) 19 1 + vert 20 ( 0.416667 0.142857 ) 20 1 + vert 21 ( 0.333333 0.142857 ) 21 1 + vert 22 ( 0.250000 0.142857 ) 22 1 + vert 23 ( 0.166667 0.142857 ) 23 1 + vert 24 ( 0.083333 0.142857 ) 24 1 + vert 25 ( 1.000000 0.214286 ) 25 1 + vert 26 ( 0.916667 0.214286 ) 26 1 + vert 27 ( 0.833333 0.214286 ) 27 1 + vert 28 ( 0.750000 0.214286 ) 28 1 + vert 29 ( 0.666667 0.214286 ) 29 1 + vert 30 ( 0.583333 0.214286 ) 30 1 + vert 31 ( 0.500000 0.214286 ) 31 1 + vert 32 ( 0.416667 0.214286 ) 32 1 + vert 33 ( 0.333333 0.214286 ) 33 1 + vert 34 ( 0.250000 0.214286 ) 34 1 + vert 35 ( 0.166667 0.214286 ) 35 1 + vert 36 ( 0.083333 0.214286 ) 36 1 + vert 37 ( 1.000000 0.285714 ) 37 1 + vert 38 ( 0.916667 0.285714 ) 38 1 + vert 39 ( 0.833333 0.285714 ) 39 1 + vert 40 ( 0.750000 0.285714 ) 40 1 + vert 41 ( 0.666667 0.285714 ) 41 1 + vert 42 ( 0.583333 0.285714 ) 42 1 + vert 43 ( 0.500000 0.285714 ) 43 1 + vert 44 ( 0.416667 0.285714 ) 44 1 + vert 45 ( 0.333333 0.285714 ) 45 1 + vert 46 ( 0.250000 0.285714 ) 46 1 + vert 47 ( 0.166667 0.285714 ) 47 1 + vert 48 ( 0.083333 0.285714 ) 48 1 + vert 49 ( 1.000000 0.357143 ) 49 1 + vert 50 ( 0.916667 0.357143 ) 50 1 + vert 51 ( 0.833333 0.357143 ) 51 1 + vert 52 ( 0.750000 0.357143 ) 52 1 + vert 53 ( 0.666667 0.357143 ) 53 1 + vert 54 ( 0.583333 0.357143 ) 54 1 + vert 55 ( 0.500000 0.357143 ) 55 1 + vert 56 ( 0.416667 0.357143 ) 56 1 + vert 57 ( 0.333333 0.357143 ) 57 1 + vert 58 ( 0.250000 0.357143 ) 58 1 + vert 59 ( 0.166667 0.357143 ) 59 1 + vert 60 ( 0.083333 0.357143 ) 60 1 + vert 61 ( 1.000000 0.428571 ) 61 1 + vert 62 ( 0.916667 0.428571 ) 62 1 + vert 63 ( 0.833333 0.428571 ) 63 1 + vert 64 ( 0.750000 0.428571 ) 64 1 + vert 65 ( 0.666667 0.428571 ) 65 1 + vert 66 ( 0.583333 0.428571 ) 66 1 + vert 67 ( 0.500000 0.428571 ) 67 1 + vert 68 ( 0.416667 0.428571 ) 68 1 + vert 69 ( 0.333333 0.428571 ) 69 1 + vert 70 ( 0.250000 0.428571 ) 70 1 + vert 71 ( 0.166667 0.428571 ) 71 1 + vert 72 ( 0.083333 0.428571 ) 72 1 + vert 73 ( 1.000000 0.500000 ) 73 1 + vert 74 ( 0.916667 0.500000 ) 74 1 + vert 75 ( 0.833333 0.500000 ) 75 1 + vert 76 ( 0.750000 0.500000 ) 76 1 + vert 77 ( 0.666667 0.500000 ) 77 1 + vert 78 ( 0.583333 0.500000 ) 78 1 + vert 79 ( 0.500000 0.500000 ) 79 1 + vert 80 ( 0.416667 0.500000 ) 80 1 + vert 81 ( 0.333333 0.500000 ) 81 1 + vert 82 ( 0.250000 0.500000 ) 82 1 + vert 83 ( 0.166667 0.500000 ) 83 1 + vert 84 ( 0.083333 0.500000 ) 84 1 + vert 85 ( 1.000000 0.571429 ) 85 1 + vert 86 ( 0.916667 0.571429 ) 86 1 + vert 87 ( 0.833333 0.571429 ) 87 1 + vert 88 ( 0.750000 0.571429 ) 88 1 + vert 89 ( 0.666667 0.571429 ) 89 1 + vert 90 ( 0.583333 0.571429 ) 90 1 + vert 91 ( 0.500000 0.571429 ) 91 1 + vert 92 ( 0.416667 0.571429 ) 92 1 + vert 93 ( 0.333333 0.571429 ) 93 1 + vert 94 ( 0.250000 0.571429 ) 94 1 + vert 95 ( 0.166667 0.571429 ) 95 1 + vert 96 ( 0.083333 0.571429 ) 96 1 + vert 97 ( 1.000000 0.642857 ) 97 1 + vert 98 ( 0.916667 0.642857 ) 98 1 + vert 99 ( 0.833333 0.642857 ) 99 1 + vert 100 ( 0.750000 0.642857 ) 100 1 + vert 101 ( 0.666667 0.642857 ) 101 1 + vert 102 ( 0.583333 0.642857 ) 102 1 + vert 103 ( 0.500000 0.642857 ) 103 1 + vert 104 ( 0.416667 0.642857 ) 104 1 + vert 105 ( 0.333333 0.642857 ) 105 1 + vert 106 ( 0.250000 0.642857 ) 106 1 + vert 107 ( 0.166667 0.642857 ) 107 1 + vert 108 ( 0.083333 0.642857 ) 108 1 + vert 109 ( 1.000000 0.714286 ) 109 1 + vert 110 ( 0.916667 0.714286 ) 110 1 + vert 111 ( 0.833333 0.714286 ) 111 1 + vert 112 ( 0.750000 0.714286 ) 112 1 + vert 113 ( 0.666667 0.714286 ) 113 1 + vert 114 ( 0.583333 0.714286 ) 114 1 + vert 115 ( 0.500000 0.714286 ) 115 1 + vert 116 ( 0.416667 0.714286 ) 116 1 + vert 117 ( 0.333333 0.714286 ) 117 1 + vert 118 ( 0.250000 0.714286 ) 118 1 + vert 119 ( 0.166667 0.714286 ) 119 1 + vert 120 ( 0.083333 0.714286 ) 120 1 + vert 121 ( 1.000000 0.785714 ) 121 1 + vert 122 ( 0.916667 0.785714 ) 122 1 + vert 123 ( 0.833333 0.785714 ) 123 1 + vert 124 ( 0.750000 0.785714 ) 124 1 + vert 125 ( 0.666667 0.785714 ) 125 1 + vert 126 ( 0.583333 0.785714 ) 126 1 + vert 127 ( 0.500000 0.785714 ) 127 1 + vert 128 ( 0.416667 0.785714 ) 128 1 + vert 129 ( 0.333333 0.785714 ) 129 1 + vert 130 ( 0.250000 0.785714 ) 130 1 + vert 131 ( 0.166667 0.785714 ) 131 1 + vert 132 ( 0.083333 0.785714 ) 132 1 + vert 133 ( 1.000000 0.857143 ) 133 1 + vert 134 ( 0.916667 0.857143 ) 134 1 + vert 135 ( 0.833333 0.857143 ) 135 1 + vert 136 ( 0.750000 0.857143 ) 136 1 + vert 137 ( 0.666667 0.857143 ) 137 1 + vert 138 ( 0.583333 0.857143 ) 138 1 + vert 139 ( 0.500000 0.857143 ) 139 1 + vert 140 ( 0.416667 0.857143 ) 140 1 + vert 141 ( 0.333333 0.857143 ) 141 1 + vert 142 ( 0.250000 0.857143 ) 142 1 + vert 143 ( 0.166667 0.857143 ) 143 1 + vert 144 ( 0.083333 0.857143 ) 144 1 + vert 145 ( 1.000000 0.928572 ) 145 1 + vert 146 ( 0.916667 0.928572 ) 146 1 + vert 147 ( 0.833333 0.928572 ) 147 1 + vert 148 ( 0.750000 0.928572 ) 148 1 + vert 149 ( 0.666667 0.928572 ) 149 1 + vert 150 ( 0.583333 0.928572 ) 150 1 + vert 151 ( 0.500000 0.928572 ) 151 1 + vert 152 ( 0.416667 0.928572 ) 152 1 + vert 153 ( 0.333333 0.928572 ) 153 1 + vert 154 ( 0.250000 0.928572 ) 154 1 + vert 155 ( 0.166667 0.928572 ) 155 1 + vert 156 ( 0.083333 0.928572 ) 156 1 + vert 157 ( 0.500000 1.000000 ) 157 1 + + numtris 312 + tri 0 0 1 2 + tri 1 0 2 3 + tri 2 0 3 4 + tri 3 0 4 5 + tri 4 0 5 6 + tri 5 0 6 7 + tri 6 0 7 8 + tri 7 0 8 9 + tri 8 0 9 10 + tri 9 0 10 11 + tri 10 0 11 12 + tri 11 0 12 1 + tri 12 1 13 14 + tri 13 1 14 2 + tri 14 2 14 15 + tri 15 2 15 3 + tri 16 3 15 16 + tri 17 3 16 4 + tri 18 4 16 17 + tri 19 4 17 5 + tri 20 5 17 18 + tri 21 5 18 6 + tri 22 6 18 19 + tri 23 6 19 7 + tri 24 7 19 20 + tri 25 7 20 8 + tri 26 8 20 21 + tri 27 8 21 9 + tri 28 9 21 22 + tri 29 9 22 10 + tri 30 10 22 23 + tri 31 10 23 11 + tri 32 11 23 24 + tri 33 11 24 12 + tri 34 12 24 13 + tri 35 12 13 1 + tri 36 13 25 26 + tri 37 13 26 14 + tri 38 14 26 27 + tri 39 14 27 15 + tri 40 15 27 28 + tri 41 15 28 16 + tri 42 16 28 29 + tri 43 16 29 17 + tri 44 17 29 30 + tri 45 17 30 18 + tri 46 18 30 31 + tri 47 18 31 19 + tri 48 19 31 32 + tri 49 19 32 20 + tri 50 20 32 33 + tri 51 20 33 21 + tri 52 21 33 34 + tri 53 21 34 22 + tri 54 22 34 35 + tri 55 22 35 23 + tri 56 23 35 36 + tri 57 23 36 24 + tri 58 24 36 25 + tri 59 24 25 13 + tri 60 25 37 38 + tri 61 25 38 26 + tri 62 26 38 39 + tri 63 26 39 27 + tri 64 27 39 40 + tri 65 27 40 28 + tri 66 28 40 41 + tri 67 28 41 29 + tri 68 29 41 42 + tri 69 29 42 30 + tri 70 30 42 43 + tri 71 30 43 31 + tri 72 31 43 44 + tri 73 31 44 32 + tri 74 32 44 45 + tri 75 32 45 33 + tri 76 33 45 46 + tri 77 33 46 34 + tri 78 34 46 47 + tri 79 34 47 35 + tri 80 35 47 48 + tri 81 35 48 36 + tri 82 36 48 37 + tri 83 36 37 25 + tri 84 37 49 50 + tri 85 37 50 38 + tri 86 38 50 51 + tri 87 38 51 39 + tri 88 39 51 52 + tri 89 39 52 40 + tri 90 40 52 53 + tri 91 40 53 41 + tri 92 41 53 54 + tri 93 41 54 42 + tri 94 42 54 55 + tri 95 42 55 43 + tri 96 43 55 56 + tri 97 43 56 44 + tri 98 44 56 57 + tri 99 44 57 45 + tri 100 45 57 58 + tri 101 45 58 46 + tri 102 46 58 59 + tri 103 46 59 47 + tri 104 47 59 60 + tri 105 47 60 48 + tri 106 48 60 49 + tri 107 48 49 37 + tri 108 49 61 62 + tri 109 49 62 50 + tri 110 50 62 63 + tri 111 50 63 51 + tri 112 51 63 64 + tri 113 51 64 52 + tri 114 52 64 65 + tri 115 52 65 53 + tri 116 53 65 66 + tri 117 53 66 54 + tri 118 54 66 67 + tri 119 54 67 55 + tri 120 55 67 68 + tri 121 55 68 56 + tri 122 56 68 69 + tri 123 56 69 57 + tri 124 57 69 70 + tri 125 57 70 58 + tri 126 58 70 71 + tri 127 58 71 59 + tri 128 59 71 72 + tri 129 59 72 60 + tri 130 60 72 61 + tri 131 60 61 49 + tri 132 61 73 74 + tri 133 61 74 62 + tri 134 62 74 75 + tri 135 62 75 63 + tri 136 63 75 76 + tri 137 63 76 64 + tri 138 64 76 77 + tri 139 64 77 65 + tri 140 65 77 78 + tri 141 65 78 66 + tri 142 66 78 79 + tri 143 66 79 67 + tri 144 67 79 80 + tri 145 67 80 68 + tri 146 68 80 81 + tri 147 68 81 69 + tri 148 69 81 82 + tri 149 69 82 70 + tri 150 70 82 83 + tri 151 70 83 71 + tri 152 71 83 84 + tri 153 71 84 72 + tri 154 72 84 73 + tri 155 72 73 61 + tri 156 73 85 86 + tri 157 73 86 74 + tri 158 74 86 87 + tri 159 74 87 75 + tri 160 75 87 88 + tri 161 75 88 76 + tri 162 76 88 89 + tri 163 76 89 77 + tri 164 77 89 90 + tri 165 77 90 78 + tri 166 78 90 91 + tri 167 78 91 79 + tri 168 79 91 92 + tri 169 79 92 80 + tri 170 80 92 93 + tri 171 80 93 81 + tri 172 81 93 94 + tri 173 81 94 82 + tri 174 82 94 95 + tri 175 82 95 83 + tri 176 83 95 96 + tri 177 83 96 84 + tri 178 84 96 85 + tri 179 84 85 73 + tri 180 85 97 98 + tri 181 85 98 86 + tri 182 86 98 99 + tri 183 86 99 87 + tri 184 87 99 100 + tri 185 87 100 88 + tri 186 88 100 101 + tri 187 88 101 89 + tri 188 89 101 102 + tri 189 89 102 90 + tri 190 90 102 103 + tri 191 90 103 91 + tri 192 91 103 104 + tri 193 91 104 92 + tri 194 92 104 105 + tri 195 92 105 93 + tri 196 93 105 106 + tri 197 93 106 94 + tri 198 94 106 107 + tri 199 94 107 95 + tri 200 95 107 108 + tri 201 95 108 96 + tri 202 96 108 97 + tri 203 96 97 85 + tri 204 97 109 110 + tri 205 97 110 98 + tri 206 98 110 111 + tri 207 98 111 99 + tri 208 99 111 112 + tri 209 99 112 100 + tri 210 100 112 113 + tri 211 100 113 101 + tri 212 101 113 114 + tri 213 101 114 102 + tri 214 102 114 115 + tri 215 102 115 103 + tri 216 103 115 116 + tri 217 103 116 104 + tri 218 104 116 117 + tri 219 104 117 105 + tri 220 105 117 118 + tri 221 105 118 106 + tri 222 106 118 119 + tri 223 106 119 107 + tri 224 107 119 120 + tri 225 107 120 108 + tri 226 108 120 109 + tri 227 108 109 97 + tri 228 109 121 122 + tri 229 109 122 110 + tri 230 110 122 123 + tri 231 110 123 111 + tri 232 111 123 124 + tri 233 111 124 112 + tri 234 112 124 125 + tri 235 112 125 113 + tri 236 113 125 126 + tri 237 113 126 114 + tri 238 114 126 127 + tri 239 114 127 115 + tri 240 115 127 128 + tri 241 115 128 116 + tri 242 116 128 129 + tri 243 116 129 117 + tri 244 117 129 130 + tri 245 117 130 118 + tri 246 118 130 131 + tri 247 118 131 119 + tri 248 119 131 132 + tri 249 119 132 120 + tri 250 120 132 121 + tri 251 120 121 109 + tri 252 121 133 134 + tri 253 121 134 122 + tri 254 122 134 135 + tri 255 122 135 123 + tri 256 123 135 136 + tri 257 123 136 124 + tri 258 124 136 137 + tri 259 124 137 125 + tri 260 125 137 138 + tri 261 125 138 126 + tri 262 126 138 139 + tri 263 126 139 127 + tri 264 127 139 140 + tri 265 127 140 128 + tri 266 128 140 141 + tri 267 128 141 129 + tri 268 129 141 142 + tri 269 129 142 130 + tri 270 130 142 143 + tri 271 130 143 131 + tri 272 131 143 144 + tri 273 131 144 132 + tri 274 132 144 133 + tri 275 132 133 121 + tri 276 133 145 146 + tri 277 133 146 134 + tri 278 134 146 147 + tri 279 134 147 135 + tri 280 135 147 148 + tri 281 135 148 136 + tri 282 136 148 149 + tri 283 136 149 137 + tri 284 137 149 150 + tri 285 137 150 138 + tri 286 138 150 151 + tri 287 138 151 139 + tri 288 139 151 152 + tri 289 139 152 140 + tri 290 140 152 153 + tri 291 140 153 141 + tri 292 141 153 154 + tri 293 141 154 142 + tri 294 142 154 155 + tri 295 142 155 143 + tri 296 143 155 156 + tri 297 143 156 144 + tri 298 144 156 145 + tri 299 144 145 133 + tri 300 157 156 155 + tri 301 157 155 154 + tri 302 157 154 153 + tri 303 157 153 152 + tri 304 157 152 151 + tri 305 157 151 150 + tri 306 157 150 149 + tri 307 157 149 148 + tri 308 157 148 147 + tri 309 157 147 146 + tri 310 157 146 145 + tri 311 157 145 156 + + numweights 158 + weight 0 1 1.000000 ( -7.999999 0.268350 0.019733 ) + weight 1 1 1.000000 ( -7.799421 0.268350 1.799900 ) + weight 2 1 1.000000 ( -7.799421 -0.621734 1.561405 ) + weight 3 1 1.000000 ( -7.799421 -1.273320 0.909817 ) + weight 4 1 1.000000 ( -7.799421 -1.511817 0.019733 ) + weight 5 1 1.000000 ( -7.799421 -1.273320 -0.870342 ) + weight 6 1 1.000000 ( -7.799421 -0.621734 -1.521931 ) + weight 7 1 1.000000 ( -7.799421 0.268349 -1.760426 ) + weight 8 1 1.000000 ( -7.799421 1.158433 -1.521931 ) + weight 9 1 1.000000 ( -7.799421 1.810019 -0.870342 ) + weight 10 1 1.000000 ( -7.799421 2.048517 0.019733 ) + weight 11 1 1.000000 ( -7.799421 1.810020 0.909817 ) + weight 12 1 1.000000 ( -7.799421 1.158434 1.561405 ) + weight 13 1 1.000000 ( -7.207749 0.268350 3.490803 ) + weight 14 1 1.000000 ( -7.207749 -1.467185 3.025768 ) + weight 15 1 1.000000 ( -7.207749 -2.737684 1.755268 ) + weight 16 1 1.000000 ( -7.207749 -3.202720 0.019733 ) + weight 17 1 1.000000 ( -7.207749 -2.737684 -1.715794 ) + weight 18 1 1.000000 ( -7.207749 -1.467185 -2.986294 ) + weight 19 1 1.000000 ( -7.207749 0.268349 -3.451328 ) + weight 20 1 1.000000 ( -7.207749 2.003884 -2.986294 ) + weight 21 1 1.000000 ( -7.207749 3.274384 -1.715794 ) + weight 22 1 1.000000 ( -7.207749 3.739419 0.019733 ) + weight 23 1 1.000000 ( -7.207749 3.274385 1.755268 ) + weight 24 1 1.000000 ( -7.207749 2.003887 3.025768 ) + weight 25 1 1.000000 ( -6.254651 0.268350 5.007648 ) + weight 26 1 1.000000 ( -6.254651 -2.225609 4.339397 ) + weight 27 1 1.000000 ( -6.254651 -4.051313 2.513691 ) + weight 28 1 1.000000 ( -6.254651 -4.719567 0.019733 ) + weight 29 1 1.000000 ( -6.254651 -4.051313 -2.474220 ) + weight 30 1 1.000000 ( -6.254651 -2.225609 -4.299923 ) + weight 31 1 1.000000 ( -6.254651 0.268349 -4.968178 ) + weight 32 1 1.000000 ( -6.254651 2.762308 -4.299923 ) + weight 33 1 1.000000 ( -6.254651 4.588012 -2.474220 ) + weight 34 1 1.000000 ( -6.254651 5.256268 0.019733 ) + weight 35 1 1.000000 ( -6.254651 4.588015 2.513691 ) + weight 36 1 1.000000 ( -6.254651 2.762312 4.339397 ) + weight 37 1 1.000000 ( -4.987916 0.268350 6.274387 ) + weight 38 1 1.000000 ( -4.987916 -2.858975 5.436420 ) + weight 39 1 1.000000 ( -4.987916 -5.148336 3.147060 ) + weight 40 1 1.000000 ( -4.987916 -5.986300 0.019733 ) + weight 41 1 1.000000 ( -4.987916 -5.148336 -3.107586 ) + weight 42 1 1.000000 ( -4.987916 -2.858976 -5.396946 ) + weight 43 1 1.000000 ( -4.987916 0.268349 -6.234913 ) + weight 44 1 1.000000 ( -4.987916 3.395674 -5.396946 ) + weight 45 1 1.000000 ( -4.987916 5.685035 -3.107586 ) + weight 46 1 1.000000 ( -4.987916 6.523001 0.019733 ) + weight 47 1 1.000000 ( -4.987916 5.685038 3.147053 ) + weight 48 1 1.000000 ( -4.987916 3.395679 5.436420 ) + weight 49 1 1.000000 ( -3.471070 0.268350 7.227482 ) + weight 50 1 1.000000 ( -3.471070 -3.335525 6.261829 ) + weight 51 1 1.000000 ( -3.471070 -5.973744 3.623608 ) + weight 52 1 1.000000 ( -3.471070 -6.939400 0.019733 ) + weight 53 1 1.000000 ( -3.471070 -5.973743 -3.584133 ) + weight 54 1 1.000000 ( -3.471070 -3.335525 -6.222355 ) + weight 55 1 1.000000 ( -3.471070 0.268349 -7.188011 ) + weight 56 1 1.000000 ( -3.471070 3.872223 -6.222355 ) + weight 57 1 1.000000 ( -3.471070 6.510443 -3.584137 ) + weight 58 1 1.000000 ( -3.471070 7.476099 0.019733 ) + weight 59 1 1.000000 ( -3.471070 6.510446 3.623608 ) + weight 60 1 1.000000 ( -3.471070 3.872229 6.261829 ) + weight 61 1 1.000000 ( -1.780168 0.268350 7.819157 ) + weight 62 1 1.000000 ( -1.780168 -3.631361 6.774235 ) + weight 63 1 1.000000 ( -1.780168 -6.486147 3.919445 ) + weight 64 1 1.000000 ( -1.780168 -7.531073 0.019733 ) + weight 65 1 1.000000 ( -1.780168 -6.486147 -3.879971 ) + weight 66 1 1.000000 ( -1.780168 -3.631361 -6.734756 ) + weight 67 1 1.000000 ( -1.780168 0.268349 -7.779682 ) + weight 68 1 1.000000 ( -1.780168 4.168058 -6.734760 ) + weight 69 1 1.000000 ( -1.780168 7.022846 -3.879974 ) + weight 70 1 1.000000 ( -1.780168 8.067771 0.019733 ) + weight 71 1 1.000000 ( -1.780168 7.022850 3.919437 ) + weight 72 1 1.000000 ( -1.780168 4.168066 6.774227 ) + weight 73 1 1.000000 ( -0.000001 0.268350 8.019733 ) + weight 74 1 1.000000 ( -0.000001 -3.731649 6.947933 ) + weight 75 1 1.000000 ( -0.000001 -6.659853 4.019733 ) + weight 76 1 1.000000 ( -0.000001 -7.731648 0.019733 ) + weight 77 1 1.000000 ( -0.000001 -6.659853 -3.980259 ) + weight 78 1 1.000000 ( -0.000001 -3.731650 -6.908463 ) + weight 79 1 1.000000 ( -0.000001 0.268349 -7.980259 ) + weight 80 1 1.000000 ( -0.000001 4.268348 -6.908463 ) + weight 81 1 1.000000 ( -0.000001 7.196549 -3.980263 ) + weight 82 1 1.000000 ( -0.000001 8.268348 0.019733 ) + weight 83 1 1.000000 ( -0.000001 7.196554 4.019726 ) + weight 84 1 1.000000 ( -0.000001 4.268353 6.947933 ) + weight 85 1 1.000000 ( 1.780166 0.268350 7.819157 ) + weight 86 1 1.000000 ( 1.780166 -3.631361 6.774235 ) + weight 87 1 1.000000 ( 1.780166 -6.486147 3.919445 ) + weight 88 1 1.000000 ( 1.780166 -7.531073 0.019733 ) + weight 89 1 1.000000 ( 1.780166 -6.486147 -3.879971 ) + weight 90 1 1.000000 ( 1.780166 -3.631361 -6.734756 ) + weight 91 1 1.000000 ( 1.780166 0.268349 -7.779682 ) + weight 92 1 1.000000 ( 1.780166 4.168058 -6.734760 ) + weight 93 1 1.000000 ( 1.780166 7.022846 -3.879974 ) + weight 94 1 1.000000 ( 1.780166 8.067772 0.019733 ) + weight 95 1 1.000000 ( 1.780166 7.022850 3.919445 ) + weight 96 1 1.000000 ( 1.780166 4.168066 6.774227 ) + weight 97 1 1.000000 ( 3.471068 0.268350 7.227482 ) + weight 98 1 1.000000 ( 3.471068 -3.335525 6.261829 ) + weight 99 1 1.000000 ( 3.471068 -5.973744 3.623608 ) + weight 100 1 1.000000 ( 3.471068 -6.939401 0.019733 ) + weight 101 1 1.000000 ( 3.471068 -5.973744 -3.584133 ) + weight 102 1 1.000000 ( 3.471068 -3.335526 -6.222355 ) + weight 103 1 1.000000 ( 3.471068 0.268349 -7.188011 ) + weight 104 1 1.000000 ( 3.471068 3.872223 -6.222355 ) + weight 105 1 1.000000 ( 3.471068 6.510443 -3.584137 ) + weight 106 1 1.000000 ( 3.471068 7.476099 0.019733 ) + weight 107 1 1.000000 ( 3.471068 6.510447 3.623608 ) + weight 108 1 1.000000 ( 3.471068 3.872230 6.261829 ) + weight 109 1 1.000000 ( 4.987916 0.268350 6.274387 ) + weight 110 1 1.000000 ( 4.987916 -2.858975 5.436420 ) + weight 111 1 1.000000 ( 4.987916 -5.148336 3.147060 ) + weight 112 1 1.000000 ( 4.987916 -5.986300 0.019733 ) + weight 113 1 1.000000 ( 4.987916 -5.148336 -3.107586 ) + weight 114 1 1.000000 ( 4.987916 -2.858976 -5.396946 ) + weight 115 1 1.000000 ( 4.987916 0.268349 -6.234913 ) + weight 116 1 1.000000 ( 4.987916 3.395674 -5.396946 ) + weight 117 1 1.000000 ( 4.987916 5.685035 -3.107586 ) + weight 118 1 1.000000 ( 4.987916 6.523001 0.019733 ) + weight 119 1 1.000000 ( 4.987916 5.685038 3.147053 ) + weight 120 1 1.000000 ( 4.987916 3.395679 5.436420 ) + weight 121 1 1.000000 ( 6.254651 0.268350 5.007648 ) + weight 122 1 1.000000 ( 6.254651 -2.225608 4.339397 ) + weight 123 1 1.000000 ( 6.254651 -4.051312 2.513691 ) + weight 124 1 1.000000 ( 6.254651 -4.719566 0.019733 ) + weight 125 1 1.000000 ( 6.254651 -4.051312 -2.474216 ) + weight 126 1 1.000000 ( 6.254651 -2.225609 -4.299923 ) + weight 127 1 1.000000 ( 6.254651 0.268349 -4.968178 ) + weight 128 1 1.000000 ( 6.254651 2.762307 -4.299923 ) + weight 129 1 1.000000 ( 6.254651 4.588010 -2.474220 ) + weight 130 1 1.000000 ( 6.254651 5.256267 0.019733 ) + weight 131 1 1.000000 ( 6.254651 4.588014 2.513691 ) + weight 132 1 1.000000 ( 6.254651 2.762311 4.339397 ) + weight 133 1 1.000000 ( 7.207749 0.268350 3.490803 ) + weight 134 1 1.000000 ( 7.207749 -1.467184 3.025768 ) + weight 135 1 1.000000 ( 7.207749 -2.737683 1.755268 ) + weight 136 1 1.000000 ( 7.207749 -3.202718 0.019733 ) + weight 137 1 1.000000 ( 7.207749 -2.737683 -1.715794 ) + weight 138 1 1.000000 ( 7.207749 -1.467185 -2.986294 ) + weight 139 1 1.000000 ( 7.207749 0.268349 -3.451328 ) + weight 140 1 1.000000 ( 7.207749 2.003883 -2.986294 ) + weight 141 1 1.000000 ( 7.207749 3.274383 -1.715794 ) + weight 142 1 1.000000 ( 7.207749 3.739419 0.019733 ) + weight 143 1 1.000000 ( 7.207749 3.274384 1.755268 ) + weight 144 1 1.000000 ( 7.207749 2.003886 3.025768 ) + weight 145 1 1.000000 ( 7.799423 0.268350 1.799900 ) + weight 146 1 1.000000 ( 7.799423 -0.621733 1.561405 ) + weight 147 1 1.000000 ( 7.799423 -1.273319 0.909817 ) + weight 148 1 1.000000 ( 7.799423 -1.511816 0.019733 ) + weight 149 1 1.000000 ( 7.799423 -1.273319 -0.870342 ) + weight 150 1 1.000000 ( 7.799423 -0.621733 -1.521927 ) + weight 151 1 1.000000 ( 7.799423 0.268349 -1.760426 ) + weight 152 1 1.000000 ( 7.799423 1.158432 -1.521927 ) + weight 153 1 1.000000 ( 7.799423 1.810018 -0.870342 ) + weight 154 1 1.000000 ( 7.799423 2.048515 0.019733 ) + weight 155 1 1.000000 ( 7.799423 1.810019 0.909817 ) + weight 156 1 1.000000 ( 7.799423 1.158433 1.561405 ) + weight 157 1 1.000000 ( 7.999999 0.268350 0.019733 ) +} + +mesh { + // meshes: bone3_sphere + shader "" + + numverts 158 + vert 0 ( 1.000000 0.000000 ) 0 1 + vert 1 ( 1.000000 0.071429 ) 1 1 + vert 2 ( 0.916667 0.071429 ) 2 1 + vert 3 ( 0.833333 0.071429 ) 3 1 + vert 4 ( 0.750000 0.071429 ) 4 1 + vert 5 ( 0.666667 0.071429 ) 5 1 + vert 6 ( 0.583333 0.071429 ) 6 1 + vert 7 ( 0.500000 0.071429 ) 7 1 + vert 8 ( 0.416667 0.071429 ) 8 1 + vert 9 ( 0.333333 0.071429 ) 9 1 + vert 10 ( 0.250000 0.071429 ) 10 1 + vert 11 ( 0.166667 0.071429 ) 11 1 + vert 12 ( 0.083333 0.071429 ) 12 1 + vert 13 ( 1.000000 0.142857 ) 13 1 + vert 14 ( 0.916667 0.142857 ) 14 1 + vert 15 ( 0.833333 0.142857 ) 15 1 + vert 16 ( 0.750000 0.142857 ) 16 1 + vert 17 ( 0.666667 0.142857 ) 17 1 + vert 18 ( 0.583333 0.142857 ) 18 1 + vert 19 ( 0.500000 0.142857 ) 19 1 + vert 20 ( 0.416667 0.142857 ) 20 1 + vert 21 ( 0.333333 0.142857 ) 21 1 + vert 22 ( 0.250000 0.142857 ) 22 1 + vert 23 ( 0.166667 0.142857 ) 23 1 + vert 24 ( 0.083333 0.142857 ) 24 1 + vert 25 ( 1.000000 0.214286 ) 25 1 + vert 26 ( 0.916667 0.214286 ) 26 1 + vert 27 ( 0.833333 0.214286 ) 27 1 + vert 28 ( 0.750000 0.214286 ) 28 1 + vert 29 ( 0.666667 0.214286 ) 29 1 + vert 30 ( 0.583333 0.214286 ) 30 1 + vert 31 ( 0.500000 0.214286 ) 31 1 + vert 32 ( 0.416667 0.214286 ) 32 1 + vert 33 ( 0.333333 0.214286 ) 33 1 + vert 34 ( 0.250000 0.214286 ) 34 1 + vert 35 ( 0.166667 0.214286 ) 35 1 + vert 36 ( 0.083333 0.214286 ) 36 1 + vert 37 ( 1.000000 0.285714 ) 37 1 + vert 38 ( 0.916667 0.285714 ) 38 1 + vert 39 ( 0.833333 0.285714 ) 39 1 + vert 40 ( 0.750000 0.285714 ) 40 1 + vert 41 ( 0.666667 0.285714 ) 41 1 + vert 42 ( 0.583333 0.285714 ) 42 1 + vert 43 ( 0.500000 0.285714 ) 43 1 + vert 44 ( 0.416667 0.285714 ) 44 1 + vert 45 ( 0.333333 0.285714 ) 45 1 + vert 46 ( 0.250000 0.285714 ) 46 1 + vert 47 ( 0.166667 0.285714 ) 47 1 + vert 48 ( 0.083333 0.285714 ) 48 1 + vert 49 ( 1.000000 0.357143 ) 49 1 + vert 50 ( 0.916667 0.357143 ) 50 1 + vert 51 ( 0.833333 0.357143 ) 51 1 + vert 52 ( 0.750000 0.357143 ) 52 1 + vert 53 ( 0.666667 0.357143 ) 53 1 + vert 54 ( 0.583333 0.357143 ) 54 1 + vert 55 ( 0.500000 0.357143 ) 55 1 + vert 56 ( 0.416667 0.357143 ) 56 1 + vert 57 ( 0.333333 0.357143 ) 57 1 + vert 58 ( 0.250000 0.357143 ) 58 1 + vert 59 ( 0.166667 0.357143 ) 59 1 + vert 60 ( 0.083333 0.357143 ) 60 1 + vert 61 ( 1.000000 0.428571 ) 61 1 + vert 62 ( 0.916667 0.428571 ) 62 1 + vert 63 ( 0.833333 0.428571 ) 63 1 + vert 64 ( 0.750000 0.428571 ) 64 1 + vert 65 ( 0.666667 0.428571 ) 65 1 + vert 66 ( 0.583333 0.428571 ) 66 1 + vert 67 ( 0.500000 0.428571 ) 67 1 + vert 68 ( 0.416667 0.428571 ) 68 1 + vert 69 ( 0.333333 0.428571 ) 69 1 + vert 70 ( 0.250000 0.428571 ) 70 1 + vert 71 ( 0.166667 0.428571 ) 71 1 + vert 72 ( 0.083333 0.428571 ) 72 1 + vert 73 ( 1.000000 0.500000 ) 73 1 + vert 74 ( 0.916667 0.500000 ) 74 1 + vert 75 ( 0.833333 0.500000 ) 75 1 + vert 76 ( 0.750000 0.500000 ) 76 1 + vert 77 ( 0.666667 0.500000 ) 77 1 + vert 78 ( 0.583333 0.500000 ) 78 1 + vert 79 ( 0.500000 0.500000 ) 79 1 + vert 80 ( 0.416667 0.500000 ) 80 1 + vert 81 ( 0.333333 0.500000 ) 81 1 + vert 82 ( 0.250000 0.500000 ) 82 1 + vert 83 ( 0.166667 0.500000 ) 83 1 + vert 84 ( 0.083333 0.500000 ) 84 1 + vert 85 ( 1.000000 0.571429 ) 85 1 + vert 86 ( 0.916667 0.571429 ) 86 1 + vert 87 ( 0.833333 0.571429 ) 87 1 + vert 88 ( 0.750000 0.571429 ) 88 1 + vert 89 ( 0.666667 0.571429 ) 89 1 + vert 90 ( 0.583333 0.571429 ) 90 1 + vert 91 ( 0.500000 0.571429 ) 91 1 + vert 92 ( 0.416667 0.571429 ) 92 1 + vert 93 ( 0.333333 0.571429 ) 93 1 + vert 94 ( 0.250000 0.571429 ) 94 1 + vert 95 ( 0.166667 0.571429 ) 95 1 + vert 96 ( 0.083333 0.571429 ) 96 1 + vert 97 ( 1.000000 0.642857 ) 97 1 + vert 98 ( 0.916667 0.642857 ) 98 1 + vert 99 ( 0.833333 0.642857 ) 99 1 + vert 100 ( 0.750000 0.642857 ) 100 1 + vert 101 ( 0.666667 0.642857 ) 101 1 + vert 102 ( 0.583333 0.642857 ) 102 1 + vert 103 ( 0.500000 0.642857 ) 103 1 + vert 104 ( 0.416667 0.642857 ) 104 1 + vert 105 ( 0.333333 0.642857 ) 105 1 + vert 106 ( 0.250000 0.642857 ) 106 1 + vert 107 ( 0.166667 0.642857 ) 107 1 + vert 108 ( 0.083333 0.642857 ) 108 1 + vert 109 ( 1.000000 0.714286 ) 109 1 + vert 110 ( 0.916667 0.714286 ) 110 1 + vert 111 ( 0.833333 0.714286 ) 111 1 + vert 112 ( 0.750000 0.714286 ) 112 1 + vert 113 ( 0.666667 0.714286 ) 113 1 + vert 114 ( 0.583333 0.714286 ) 114 1 + vert 115 ( 0.500000 0.714286 ) 115 1 + vert 116 ( 0.416667 0.714286 ) 116 1 + vert 117 ( 0.333333 0.714286 ) 117 1 + vert 118 ( 0.250000 0.714286 ) 118 1 + vert 119 ( 0.166667 0.714286 ) 119 1 + vert 120 ( 0.083333 0.714286 ) 120 1 + vert 121 ( 1.000000 0.785714 ) 121 1 + vert 122 ( 0.916667 0.785714 ) 122 1 + vert 123 ( 0.833333 0.785714 ) 123 1 + vert 124 ( 0.750000 0.785714 ) 124 1 + vert 125 ( 0.666667 0.785714 ) 125 1 + vert 126 ( 0.583333 0.785714 ) 126 1 + vert 127 ( 0.500000 0.785714 ) 127 1 + vert 128 ( 0.416667 0.785714 ) 128 1 + vert 129 ( 0.333333 0.785714 ) 129 1 + vert 130 ( 0.250000 0.785714 ) 130 1 + vert 131 ( 0.166667 0.785714 ) 131 1 + vert 132 ( 0.083333 0.785714 ) 132 1 + vert 133 ( 1.000000 0.857143 ) 133 1 + vert 134 ( 0.916667 0.857143 ) 134 1 + vert 135 ( 0.833333 0.857143 ) 135 1 + vert 136 ( 0.750000 0.857143 ) 136 1 + vert 137 ( 0.666667 0.857143 ) 137 1 + vert 138 ( 0.583333 0.857143 ) 138 1 + vert 139 ( 0.500000 0.857143 ) 139 1 + vert 140 ( 0.416667 0.857143 ) 140 1 + vert 141 ( 0.333333 0.857143 ) 141 1 + vert 142 ( 0.250000 0.857143 ) 142 1 + vert 143 ( 0.166667 0.857143 ) 143 1 + vert 144 ( 0.083333 0.857143 ) 144 1 + vert 145 ( 1.000000 0.928572 ) 145 1 + vert 146 ( 0.916667 0.928572 ) 146 1 + vert 147 ( 0.833333 0.928572 ) 147 1 + vert 148 ( 0.750000 0.928572 ) 148 1 + vert 149 ( 0.666667 0.928572 ) 149 1 + vert 150 ( 0.583333 0.928572 ) 150 1 + vert 151 ( 0.500000 0.928572 ) 151 1 + vert 152 ( 0.416667 0.928572 ) 152 1 + vert 153 ( 0.333333 0.928572 ) 153 1 + vert 154 ( 0.250000 0.928572 ) 154 1 + vert 155 ( 0.166667 0.928572 ) 155 1 + vert 156 ( 0.083333 0.928572 ) 156 1 + vert 157 ( 0.500000 1.000000 ) 157 1 + + numtris 312 + tri 0 0 1 2 + tri 1 0 2 3 + tri 2 0 3 4 + tri 3 0 4 5 + tri 4 0 5 6 + tri 5 0 6 7 + tri 6 0 7 8 + tri 7 0 8 9 + tri 8 0 9 10 + tri 9 0 10 11 + tri 10 0 11 12 + tri 11 0 12 1 + tri 12 1 13 14 + tri 13 1 14 2 + tri 14 2 14 15 + tri 15 2 15 3 + tri 16 3 15 16 + tri 17 3 16 4 + tri 18 4 16 17 + tri 19 4 17 5 + tri 20 5 17 18 + tri 21 5 18 6 + tri 22 6 18 19 + tri 23 6 19 7 + tri 24 7 19 20 + tri 25 7 20 8 + tri 26 8 20 21 + tri 27 8 21 9 + tri 28 9 21 22 + tri 29 9 22 10 + tri 30 10 22 23 + tri 31 10 23 11 + tri 32 11 23 24 + tri 33 11 24 12 + tri 34 12 24 13 + tri 35 12 13 1 + tri 36 13 25 26 + tri 37 13 26 14 + tri 38 14 26 27 + tri 39 14 27 15 + tri 40 15 27 28 + tri 41 15 28 16 + tri 42 16 28 29 + tri 43 16 29 17 + tri 44 17 29 30 + tri 45 17 30 18 + tri 46 18 30 31 + tri 47 18 31 19 + tri 48 19 31 32 + tri 49 19 32 20 + tri 50 20 32 33 + tri 51 20 33 21 + tri 52 21 33 34 + tri 53 21 34 22 + tri 54 22 34 35 + tri 55 22 35 23 + tri 56 23 35 36 + tri 57 23 36 24 + tri 58 24 36 25 + tri 59 24 25 13 + tri 60 25 37 38 + tri 61 25 38 26 + tri 62 26 38 39 + tri 63 26 39 27 + tri 64 27 39 40 + tri 65 27 40 28 + tri 66 28 40 41 + tri 67 28 41 29 + tri 68 29 41 42 + tri 69 29 42 30 + tri 70 30 42 43 + tri 71 30 43 31 + tri 72 31 43 44 + tri 73 31 44 32 + tri 74 32 44 45 + tri 75 32 45 33 + tri 76 33 45 46 + tri 77 33 46 34 + tri 78 34 46 47 + tri 79 34 47 35 + tri 80 35 47 48 + tri 81 35 48 36 + tri 82 36 48 37 + tri 83 36 37 25 + tri 84 37 49 50 + tri 85 37 50 38 + tri 86 38 50 51 + tri 87 38 51 39 + tri 88 39 51 52 + tri 89 39 52 40 + tri 90 40 52 53 + tri 91 40 53 41 + tri 92 41 53 54 + tri 93 41 54 42 + tri 94 42 54 55 + tri 95 42 55 43 + tri 96 43 55 56 + tri 97 43 56 44 + tri 98 44 56 57 + tri 99 44 57 45 + tri 100 45 57 58 + tri 101 45 58 46 + tri 102 46 58 59 + tri 103 46 59 47 + tri 104 47 59 60 + tri 105 47 60 48 + tri 106 48 60 49 + tri 107 48 49 37 + tri 108 49 61 62 + tri 109 49 62 50 + tri 110 50 62 63 + tri 111 50 63 51 + tri 112 51 63 64 + tri 113 51 64 52 + tri 114 52 64 65 + tri 115 52 65 53 + tri 116 53 65 66 + tri 117 53 66 54 + tri 118 54 66 67 + tri 119 54 67 55 + tri 120 55 67 68 + tri 121 55 68 56 + tri 122 56 68 69 + tri 123 56 69 57 + tri 124 57 69 70 + tri 125 57 70 58 + tri 126 58 70 71 + tri 127 58 71 59 + tri 128 59 71 72 + tri 129 59 72 60 + tri 130 60 72 61 + tri 131 60 61 49 + tri 132 61 73 74 + tri 133 61 74 62 + tri 134 62 74 75 + tri 135 62 75 63 + tri 136 63 75 76 + tri 137 63 76 64 + tri 138 64 76 77 + tri 139 64 77 65 + tri 140 65 77 78 + tri 141 65 78 66 + tri 142 66 78 79 + tri 143 66 79 67 + tri 144 67 79 80 + tri 145 67 80 68 + tri 146 68 80 81 + tri 147 68 81 69 + tri 148 69 81 82 + tri 149 69 82 70 + tri 150 70 82 83 + tri 151 70 83 71 + tri 152 71 83 84 + tri 153 71 84 72 + tri 154 72 84 73 + tri 155 72 73 61 + tri 156 73 85 86 + tri 157 73 86 74 + tri 158 74 86 87 + tri 159 74 87 75 + tri 160 75 87 88 + tri 161 75 88 76 + tri 162 76 88 89 + tri 163 76 89 77 + tri 164 77 89 90 + tri 165 77 90 78 + tri 166 78 90 91 + tri 167 78 91 79 + tri 168 79 91 92 + tri 169 79 92 80 + tri 170 80 92 93 + tri 171 80 93 81 + tri 172 81 93 94 + tri 173 81 94 82 + tri 174 82 94 95 + tri 175 82 95 83 + tri 176 83 95 96 + tri 177 83 96 84 + tri 178 84 96 85 + tri 179 84 85 73 + tri 180 85 97 98 + tri 181 85 98 86 + tri 182 86 98 99 + tri 183 86 99 87 + tri 184 87 99 100 + tri 185 87 100 88 + tri 186 88 100 101 + tri 187 88 101 89 + tri 188 89 101 102 + tri 189 89 102 90 + tri 190 90 102 103 + tri 191 90 103 91 + tri 192 91 103 104 + tri 193 91 104 92 + tri 194 92 104 105 + tri 195 92 105 93 + tri 196 93 105 106 + tri 197 93 106 94 + tri 198 94 106 107 + tri 199 94 107 95 + tri 200 95 107 108 + tri 201 95 108 96 + tri 202 96 108 97 + tri 203 96 97 85 + tri 204 97 109 110 + tri 205 97 110 98 + tri 206 98 110 111 + tri 207 98 111 99 + tri 208 99 111 112 + tri 209 99 112 100 + tri 210 100 112 113 + tri 211 100 113 101 + tri 212 101 113 114 + tri 213 101 114 102 + tri 214 102 114 115 + tri 215 102 115 103 + tri 216 103 115 116 + tri 217 103 116 104 + tri 218 104 116 117 + tri 219 104 117 105 + tri 220 105 117 118 + tri 221 105 118 106 + tri 222 106 118 119 + tri 223 106 119 107 + tri 224 107 119 120 + tri 225 107 120 108 + tri 226 108 120 109 + tri 227 108 109 97 + tri 228 109 121 122 + tri 229 109 122 110 + tri 230 110 122 123 + tri 231 110 123 111 + tri 232 111 123 124 + tri 233 111 124 112 + tri 234 112 124 125 + tri 235 112 125 113 + tri 236 113 125 126 + tri 237 113 126 114 + tri 238 114 126 127 + tri 239 114 127 115 + tri 240 115 127 128 + tri 241 115 128 116 + tri 242 116 128 129 + tri 243 116 129 117 + tri 244 117 129 130 + tri 245 117 130 118 + tri 246 118 130 131 + tri 247 118 131 119 + tri 248 119 131 132 + tri 249 119 132 120 + tri 250 120 132 121 + tri 251 120 121 109 + tri 252 121 133 134 + tri 253 121 134 122 + tri 254 122 134 135 + tri 255 122 135 123 + tri 256 123 135 136 + tri 257 123 136 124 + tri 258 124 136 137 + tri 259 124 137 125 + tri 260 125 137 138 + tri 261 125 138 126 + tri 262 126 138 139 + tri 263 126 139 127 + tri 264 127 139 140 + tri 265 127 140 128 + tri 266 128 140 141 + tri 267 128 141 129 + tri 268 129 141 142 + tri 269 129 142 130 + tri 270 130 142 143 + tri 271 130 143 131 + tri 272 131 143 144 + tri 273 131 144 132 + tri 274 132 144 133 + tri 275 132 133 121 + tri 276 133 145 146 + tri 277 133 146 134 + tri 278 134 146 147 + tri 279 134 147 135 + tri 280 135 147 148 + tri 281 135 148 136 + tri 282 136 148 149 + tri 283 136 149 137 + tri 284 137 149 150 + tri 285 137 150 138 + tri 286 138 150 151 + tri 287 138 151 139 + tri 288 139 151 152 + tri 289 139 152 140 + tri 290 140 152 153 + tri 291 140 153 141 + tri 292 141 153 154 + tri 293 141 154 142 + tri 294 142 154 155 + tri 295 142 155 143 + tri 296 143 155 156 + tri 297 143 156 144 + tri 298 144 156 145 + tri 299 144 145 133 + tri 300 157 156 155 + tri 301 157 155 154 + tri 302 157 154 153 + tri 303 157 153 152 + tri 304 157 152 151 + tri 305 157 151 150 + tri 306 157 150 149 + tri 307 157 149 148 + tri 308 157 148 147 + tri 309 157 147 146 + tri 310 157 146 145 + tri 311 157 145 156 + + numweights 158 + weight 0 2 1.000000 ( -7.999999 0.122692 0.019714 ) + weight 1 2 1.000000 ( -7.799421 0.122692 1.799881 ) + weight 2 2 1.000000 ( -7.799421 -0.767384 1.561378 ) + weight 3 2 1.000000 ( -7.799421 -1.418972 0.909798 ) + weight 4 2 1.000000 ( -7.799421 -1.657467 0.019707 ) + weight 5 2 1.000000 ( -7.799421 -1.418972 -0.870365 ) + weight 6 2 1.000000 ( -7.799421 -0.767384 -1.521954 ) + weight 7 2 1.000000 ( -7.799421 0.122692 -1.760448 ) + weight 8 2 1.000000 ( -7.799421 1.012775 -1.521954 ) + weight 9 2 1.000000 ( -7.799421 1.664364 -0.870365 ) + weight 10 2 1.000000 ( -7.799421 1.902859 0.019707 ) + weight 11 2 1.000000 ( -7.799421 1.664364 0.909790 ) + weight 12 2 1.000000 ( -7.799421 1.012775 1.561378 ) + weight 13 2 1.000000 ( -7.207748 0.122692 3.490784 ) + weight 14 2 1.000000 ( -7.207748 -1.612835 3.025742 ) + weight 15 2 1.000000 ( -7.207748 -2.883335 1.755249 ) + weight 16 2 1.000000 ( -7.207748 -3.348370 0.019707 ) + weight 17 2 1.000000 ( -7.207748 -2.883335 -1.715816 ) + weight 18 2 1.000000 ( -7.207748 -1.612835 -2.986317 ) + weight 19 2 1.000000 ( -7.207748 0.122692 -3.451351 ) + weight 20 2 1.000000 ( -7.207748 1.858227 -2.986317 ) + weight 21 2 1.000000 ( -7.207748 3.128727 -1.715816 ) + weight 22 2 1.000000 ( -7.207748 3.593761 0.019707 ) + weight 23 2 1.000000 ( -7.207748 3.128727 1.755241 ) + weight 24 2 1.000000 ( -7.207748 1.858227 3.025742 ) + weight 25 2 1.000000 ( -6.254650 0.122692 5.007629 ) + weight 26 2 1.000000 ( -6.254650 -2.371258 4.339371 ) + weight 27 2 1.000000 ( -6.254650 -4.196964 2.513672 ) + weight 28 2 1.000000 ( -6.254650 -4.865219 0.019707 ) + weight 29 2 1.000000 ( -6.254650 -4.196964 -2.474243 ) + weight 30 2 1.000000 ( -6.254650 -2.371258 -4.299946 ) + weight 31 2 1.000000 ( -6.254650 0.122692 -4.968201 ) + weight 32 2 1.000000 ( -6.254650 2.616650 -4.299946 ) + weight 33 2 1.000000 ( -6.254650 4.442356 -2.474243 ) + weight 34 2 1.000000 ( -6.254650 5.110607 0.019707 ) + weight 35 2 1.000000 ( -6.254650 4.442356 2.513664 ) + weight 36 2 1.000000 ( -6.254650 2.616657 4.339371 ) + weight 37 2 1.000000 ( -4.987916 0.122692 6.274361 ) + weight 38 2 1.000000 ( -4.987916 -3.004627 5.436401 ) + weight 39 2 1.000000 ( -4.987916 -5.293987 3.147034 ) + weight 40 2 1.000000 ( -4.987916 -6.131950 0.019707 ) + weight 41 2 1.000000 ( -4.987916 -5.293987 -3.107609 ) + weight 42 2 1.000000 ( -4.987916 -3.004627 -5.396969 ) + weight 43 2 1.000000 ( -4.987916 0.122692 -6.234932 ) + weight 44 2 1.000000 ( -4.987916 3.250019 -5.396969 ) + weight 45 2 1.000000 ( -4.987916 5.539379 -3.107609 ) + weight 46 2 1.000000 ( -4.987916 6.377346 0.019707 ) + weight 47 2 1.000000 ( -4.987916 5.539379 3.147034 ) + weight 48 2 1.000000 ( -4.987916 3.250019 5.436394 ) + weight 49 2 1.000000 ( -3.471069 0.122692 7.227463 ) + weight 50 2 1.000000 ( -3.471069 -3.481174 6.261803 ) + weight 51 2 1.000000 ( -3.471069 -6.119396 3.623589 ) + weight 52 2 1.000000 ( -3.471069 -7.085049 0.019707 ) + weight 53 2 1.000000 ( -3.471069 -6.119396 -3.584156 ) + weight 54 2 1.000000 ( -3.471069 -3.481174 -6.222378 ) + weight 55 2 1.000000 ( -3.471069 0.122692 -7.188034 ) + weight 56 2 1.000000 ( -3.471069 3.726566 -6.222378 ) + weight 57 2 1.000000 ( -3.471069 6.364788 -3.584160 ) + weight 58 2 1.000000 ( -3.471069 7.330441 0.019707 ) + weight 59 2 1.000000 ( -3.471069 6.364788 3.623581 ) + weight 60 2 1.000000 ( -3.471069 3.726574 6.261803 ) + weight 61 2 1.000000 ( -1.780167 0.122692 7.819130 ) + weight 62 2 1.000000 ( -1.780167 -3.777012 6.774208 ) + weight 63 2 1.000000 ( -1.780167 -6.631798 3.919418 ) + weight 64 2 1.000000 ( -1.780167 -7.676723 0.019707 ) + weight 65 2 1.000000 ( -1.780167 -6.631798 -3.879993 ) + weight 66 2 1.000000 ( -1.780167 -3.777012 -6.734779 ) + weight 67 2 1.000000 ( -1.780167 0.122692 -7.779705 ) + weight 68 2 1.000000 ( -1.780167 4.022404 -6.734779 ) + weight 69 2 1.000000 ( -1.780167 6.877186 -3.879997 ) + weight 70 2 1.000000 ( -1.780167 7.922115 0.019707 ) + weight 71 2 1.000000 ( -1.780167 6.877193 3.919418 ) + weight 72 2 1.000000 ( -1.780167 4.022411 6.774208 ) + weight 73 2 1.000000 ( -0.000001 0.122692 8.019714 ) + weight 74 2 1.000000 ( -0.000001 -3.877300 6.947914 ) + weight 75 2 1.000000 ( -0.000001 -6.805504 4.019707 ) + weight 76 2 1.000000 ( -0.000001 -7.877300 0.019707 ) + weight 77 2 1.000000 ( -0.000001 -6.805504 -3.980282 ) + weight 78 2 1.000000 ( -0.000001 -3.877300 -6.908485 ) + weight 79 2 1.000000 ( -0.000001 0.122692 -7.980282 ) + weight 80 2 1.000000 ( -0.000001 4.122692 -6.908485 ) + weight 81 2 1.000000 ( -0.000001 7.050892 -3.980286 ) + weight 82 2 1.000000 ( -0.000001 8.122692 0.019707 ) + weight 83 2 1.000000 ( -0.000001 7.050900 4.019707 ) + weight 84 2 1.000000 ( -0.000001 4.122700 6.947914 ) + weight 85 2 1.000000 ( 1.780166 0.122692 7.819138 ) + weight 86 2 1.000000 ( 1.780166 -3.777012 6.774208 ) + weight 87 2 1.000000 ( 1.780166 -6.631798 3.919418 ) + weight 88 2 1.000000 ( 1.780166 -7.676723 0.019707 ) + weight 89 2 1.000000 ( 1.780166 -6.631798 -3.879993 ) + weight 90 2 1.000000 ( 1.780166 -3.777012 -6.734779 ) + weight 91 2 1.000000 ( 1.780166 0.122692 -7.779705 ) + weight 92 2 1.000000 ( 1.780166 4.022404 -6.734779 ) + weight 93 2 1.000000 ( 1.780166 6.877186 -3.879997 ) + weight 94 2 1.000000 ( 1.780166 7.922115 0.019707 ) + weight 95 2 1.000000 ( 1.780166 6.877193 3.919418 ) + weight 96 2 1.000000 ( 1.780166 4.022411 6.774208 ) + weight 97 2 1.000000 ( 3.471068 0.122692 7.227463 ) + weight 98 2 1.000000 ( 3.471068 -3.481174 6.261803 ) + weight 99 2 1.000000 ( 3.471068 -6.119396 3.623589 ) + weight 100 2 1.000000 ( 3.471068 -7.085052 0.019707 ) + weight 101 2 1.000000 ( 3.471068 -6.119396 -3.584156 ) + weight 102 2 1.000000 ( 3.471068 -3.481174 -6.222378 ) + weight 103 2 1.000000 ( 3.471068 0.122692 -7.188034 ) + weight 104 2 1.000000 ( 3.471068 3.726566 -6.222378 ) + weight 105 2 1.000000 ( 3.471068 6.364788 -3.584160 ) + weight 106 2 1.000000 ( 3.471068 7.330441 0.019707 ) + weight 107 2 1.000000 ( 3.471068 6.364788 3.623581 ) + weight 108 2 1.000000 ( 3.471068 3.726574 6.261803 ) + weight 109 2 1.000000 ( 4.987916 0.122692 6.274361 ) + weight 110 2 1.000000 ( 4.987916 -3.004627 5.436401 ) + weight 111 2 1.000000 ( 4.987916 -5.293987 3.147034 ) + weight 112 2 1.000000 ( 4.987916 -6.131950 0.019707 ) + weight 113 2 1.000000 ( 4.987916 -5.293987 -3.107609 ) + weight 114 2 1.000000 ( 4.987916 -3.004627 -5.396969 ) + weight 115 2 1.000000 ( 4.987916 0.122692 -6.234932 ) + weight 116 2 1.000000 ( 4.987916 3.250019 -5.396969 ) + weight 117 2 1.000000 ( 4.987916 5.539379 -3.107609 ) + weight 118 2 1.000000 ( 4.987916 6.377346 0.019707 ) + weight 119 2 1.000000 ( 4.987916 5.539379 3.147034 ) + weight 120 2 1.000000 ( 4.987916 3.250019 5.436394 ) + weight 121 2 1.000000 ( 6.254651 0.122692 5.007629 ) + weight 122 2 1.000000 ( 6.254651 -2.371258 4.339371 ) + weight 123 2 1.000000 ( 6.254651 -4.196964 2.513672 ) + weight 124 2 1.000000 ( 6.254651 -4.865219 0.019707 ) + weight 125 2 1.000000 ( 6.254651 -4.196964 -2.474239 ) + weight 126 2 1.000000 ( 6.254651 -2.371258 -4.299946 ) + weight 127 2 1.000000 ( 6.254651 0.122692 -4.968201 ) + weight 128 2 1.000000 ( 6.254651 2.616650 -4.299946 ) + weight 129 2 1.000000 ( 6.254651 4.442356 -2.474243 ) + weight 130 2 1.000000 ( 6.254651 5.110607 0.019707 ) + weight 131 2 1.000000 ( 6.254651 4.442356 2.513664 ) + weight 132 2 1.000000 ( 6.254651 2.616657 4.339371 ) + weight 133 2 1.000000 ( 7.207749 0.122692 3.490776 ) + weight 134 2 1.000000 ( 7.207749 -1.612835 3.025742 ) + weight 135 2 1.000000 ( 7.207749 -2.883335 1.755241 ) + weight 136 2 1.000000 ( 7.207749 -3.348370 0.019707 ) + weight 137 2 1.000000 ( 7.207749 -2.883335 -1.715816 ) + weight 138 2 1.000000 ( 7.207749 -1.612835 -2.986317 ) + weight 139 2 1.000000 ( 7.207749 0.122692 -3.451351 ) + weight 140 2 1.000000 ( 7.207749 1.858227 -2.986317 ) + weight 141 2 1.000000 ( 7.207749 3.128727 -1.715816 ) + weight 142 2 1.000000 ( 7.207749 3.593761 0.019707 ) + weight 143 2 1.000000 ( 7.207749 3.128727 1.755241 ) + weight 144 2 1.000000 ( 7.207749 1.858227 3.025742 ) + weight 145 2 1.000000 ( 7.799421 0.122692 1.799873 ) + weight 146 2 1.000000 ( 7.799421 -0.767384 1.561378 ) + weight 147 2 1.000000 ( 7.799421 -1.418968 0.909790 ) + weight 148 2 1.000000 ( 7.799421 -1.657467 0.019707 ) + weight 149 2 1.000000 ( 7.799421 -1.418968 -0.870365 ) + weight 150 2 1.000000 ( 7.799421 -0.767384 -1.521950 ) + weight 151 2 1.000000 ( 7.799421 0.122692 -1.760448 ) + weight 152 2 1.000000 ( 7.799421 1.012775 -1.521950 ) + weight 153 2 1.000000 ( 7.799421 1.664364 -0.870365 ) + weight 154 2 1.000000 ( 7.799421 1.902859 0.019707 ) + weight 155 2 1.000000 ( 7.799421 1.664364 0.909790 ) + weight 156 2 1.000000 ( 7.799421 1.012775 1.561378 ) + weight 157 2 1.000000 ( 7.999999 0.122692 0.019714 ) +} + +mesh { + // meshes: bone1_sphere + shader "" + + numverts 158 + vert 0 ( 1.000000 0.000000 ) 0 1 + vert 1 ( 1.000000 0.071429 ) 1 1 + vert 2 ( 0.916667 0.071429 ) 2 1 + vert 3 ( 0.833333 0.071429 ) 3 1 + vert 4 ( 0.750000 0.071429 ) 4 1 + vert 5 ( 0.666667 0.071429 ) 5 1 + vert 6 ( 0.583333 0.071429 ) 6 1 + vert 7 ( 0.500000 0.071429 ) 7 1 + vert 8 ( 0.416667 0.071429 ) 8 1 + vert 9 ( 0.333333 0.071429 ) 9 1 + vert 10 ( 0.250000 0.071429 ) 10 1 + vert 11 ( 0.166667 0.071429 ) 11 1 + vert 12 ( 0.083333 0.071429 ) 12 1 + vert 13 ( 1.000000 0.142857 ) 13 1 + vert 14 ( 0.916667 0.142857 ) 14 1 + vert 15 ( 0.833333 0.142857 ) 15 1 + vert 16 ( 0.750000 0.142857 ) 16 1 + vert 17 ( 0.666667 0.142857 ) 17 1 + vert 18 ( 0.583333 0.142857 ) 18 1 + vert 19 ( 0.500000 0.142857 ) 19 1 + vert 20 ( 0.416667 0.142857 ) 20 1 + vert 21 ( 0.333333 0.142857 ) 21 1 + vert 22 ( 0.250000 0.142857 ) 22 1 + vert 23 ( 0.166667 0.142857 ) 23 1 + vert 24 ( 0.083333 0.142857 ) 24 1 + vert 25 ( 1.000000 0.214286 ) 25 1 + vert 26 ( 0.916667 0.214286 ) 26 1 + vert 27 ( 0.833333 0.214286 ) 27 1 + vert 28 ( 0.750000 0.214286 ) 28 1 + vert 29 ( 0.666667 0.214286 ) 29 1 + vert 30 ( 0.583333 0.214286 ) 30 1 + vert 31 ( 0.500000 0.214286 ) 31 1 + vert 32 ( 0.416667 0.214286 ) 32 1 + vert 33 ( 0.333333 0.214286 ) 33 1 + vert 34 ( 0.250000 0.214286 ) 34 1 + vert 35 ( 0.166667 0.214286 ) 35 1 + vert 36 ( 0.083333 0.214286 ) 36 1 + vert 37 ( 1.000000 0.285714 ) 37 1 + vert 38 ( 0.916667 0.285714 ) 38 1 + vert 39 ( 0.833333 0.285714 ) 39 1 + vert 40 ( 0.750000 0.285714 ) 40 1 + vert 41 ( 0.666667 0.285714 ) 41 1 + vert 42 ( 0.583333 0.285714 ) 42 1 + vert 43 ( 0.500000 0.285714 ) 43 1 + vert 44 ( 0.416667 0.285714 ) 44 1 + vert 45 ( 0.333333 0.285714 ) 45 1 + vert 46 ( 0.250000 0.285714 ) 46 1 + vert 47 ( 0.166667 0.285714 ) 47 1 + vert 48 ( 0.083333 0.285714 ) 48 1 + vert 49 ( 1.000000 0.357143 ) 49 1 + vert 50 ( 0.916667 0.357143 ) 50 1 + vert 51 ( 0.833333 0.357143 ) 51 1 + vert 52 ( 0.750000 0.357143 ) 52 1 + vert 53 ( 0.666667 0.357143 ) 53 1 + vert 54 ( 0.583333 0.357143 ) 54 1 + vert 55 ( 0.500000 0.357143 ) 55 1 + vert 56 ( 0.416667 0.357143 ) 56 1 + vert 57 ( 0.333333 0.357143 ) 57 1 + vert 58 ( 0.250000 0.357143 ) 58 1 + vert 59 ( 0.166667 0.357143 ) 59 1 + vert 60 ( 0.083333 0.357143 ) 60 1 + vert 61 ( 1.000000 0.428571 ) 61 1 + vert 62 ( 0.916667 0.428571 ) 62 1 + vert 63 ( 0.833333 0.428571 ) 63 1 + vert 64 ( 0.750000 0.428571 ) 64 1 + vert 65 ( 0.666667 0.428571 ) 65 1 + vert 66 ( 0.583333 0.428571 ) 66 1 + vert 67 ( 0.500000 0.428571 ) 67 1 + vert 68 ( 0.416667 0.428571 ) 68 1 + vert 69 ( 0.333333 0.428571 ) 69 1 + vert 70 ( 0.250000 0.428571 ) 70 1 + vert 71 ( 0.166667 0.428571 ) 71 1 + vert 72 ( 0.083333 0.428571 ) 72 1 + vert 73 ( 1.000000 0.500000 ) 73 1 + vert 74 ( 0.916667 0.500000 ) 74 1 + vert 75 ( 0.833333 0.500000 ) 75 1 + vert 76 ( 0.750000 0.500000 ) 76 1 + vert 77 ( 0.666667 0.500000 ) 77 1 + vert 78 ( 0.583333 0.500000 ) 78 1 + vert 79 ( 0.500000 0.500000 ) 79 1 + vert 80 ( 0.416667 0.500000 ) 80 1 + vert 81 ( 0.333333 0.500000 ) 81 1 + vert 82 ( 0.250000 0.500000 ) 82 1 + vert 83 ( 0.166667 0.500000 ) 83 1 + vert 84 ( 0.083333 0.500000 ) 84 1 + vert 85 ( 1.000000 0.571429 ) 85 1 + vert 86 ( 0.916667 0.571429 ) 86 1 + vert 87 ( 0.833333 0.571429 ) 87 1 + vert 88 ( 0.750000 0.571429 ) 88 1 + vert 89 ( 0.666667 0.571429 ) 89 1 + vert 90 ( 0.583333 0.571429 ) 90 1 + vert 91 ( 0.500000 0.571429 ) 91 1 + vert 92 ( 0.416667 0.571429 ) 92 1 + vert 93 ( 0.333333 0.571429 ) 93 1 + vert 94 ( 0.250000 0.571429 ) 94 1 + vert 95 ( 0.166667 0.571429 ) 95 1 + vert 96 ( 0.083333 0.571429 ) 96 1 + vert 97 ( 1.000000 0.642857 ) 97 1 + vert 98 ( 0.916667 0.642857 ) 98 1 + vert 99 ( 0.833333 0.642857 ) 99 1 + vert 100 ( 0.750000 0.642857 ) 100 1 + vert 101 ( 0.666667 0.642857 ) 101 1 + vert 102 ( 0.583333 0.642857 ) 102 1 + vert 103 ( 0.500000 0.642857 ) 103 1 + vert 104 ( 0.416667 0.642857 ) 104 1 + vert 105 ( 0.333333 0.642857 ) 105 1 + vert 106 ( 0.250000 0.642857 ) 106 1 + vert 107 ( 0.166667 0.642857 ) 107 1 + vert 108 ( 0.083333 0.642857 ) 108 1 + vert 109 ( 1.000000 0.714286 ) 109 1 + vert 110 ( 0.916667 0.714286 ) 110 1 + vert 111 ( 0.833333 0.714286 ) 111 1 + vert 112 ( 0.750000 0.714286 ) 112 1 + vert 113 ( 0.666667 0.714286 ) 113 1 + vert 114 ( 0.583333 0.714286 ) 114 1 + vert 115 ( 0.500000 0.714286 ) 115 1 + vert 116 ( 0.416667 0.714286 ) 116 1 + vert 117 ( 0.333333 0.714286 ) 117 1 + vert 118 ( 0.250000 0.714286 ) 118 1 + vert 119 ( 0.166667 0.714286 ) 119 1 + vert 120 ( 0.083333 0.714286 ) 120 1 + vert 121 ( 1.000000 0.785714 ) 121 1 + vert 122 ( 0.916667 0.785714 ) 122 1 + vert 123 ( 0.833333 0.785714 ) 123 1 + vert 124 ( 0.750000 0.785714 ) 124 1 + vert 125 ( 0.666667 0.785714 ) 125 1 + vert 126 ( 0.583333 0.785714 ) 126 1 + vert 127 ( 0.500000 0.785714 ) 127 1 + vert 128 ( 0.416667 0.785714 ) 128 1 + vert 129 ( 0.333333 0.785714 ) 129 1 + vert 130 ( 0.250000 0.785714 ) 130 1 + vert 131 ( 0.166667 0.785714 ) 131 1 + vert 132 ( 0.083333 0.785714 ) 132 1 + vert 133 ( 1.000000 0.857143 ) 133 1 + vert 134 ( 0.916667 0.857143 ) 134 1 + vert 135 ( 0.833333 0.857143 ) 135 1 + vert 136 ( 0.750000 0.857143 ) 136 1 + vert 137 ( 0.666667 0.857143 ) 137 1 + vert 138 ( 0.583333 0.857143 ) 138 1 + vert 139 ( 0.500000 0.857143 ) 139 1 + vert 140 ( 0.416667 0.857143 ) 140 1 + vert 141 ( 0.333333 0.857143 ) 141 1 + vert 142 ( 0.250000 0.857143 ) 142 1 + vert 143 ( 0.166667 0.857143 ) 143 1 + vert 144 ( 0.083333 0.857143 ) 144 1 + vert 145 ( 1.000000 0.928572 ) 145 1 + vert 146 ( 0.916667 0.928572 ) 146 1 + vert 147 ( 0.833333 0.928572 ) 147 1 + vert 148 ( 0.750000 0.928572 ) 148 1 + vert 149 ( 0.666667 0.928572 ) 149 1 + vert 150 ( 0.583333 0.928572 ) 150 1 + vert 151 ( 0.500000 0.928572 ) 151 1 + vert 152 ( 0.416667 0.928572 ) 152 1 + vert 153 ( 0.333333 0.928572 ) 153 1 + vert 154 ( 0.250000 0.928572 ) 154 1 + vert 155 ( 0.166667 0.928572 ) 155 1 + vert 156 ( 0.083333 0.928572 ) 156 1 + vert 157 ( 0.500000 1.000000 ) 157 1 + + numtris 312 + tri 0 0 1 2 + tri 1 0 2 3 + tri 2 0 3 4 + tri 3 0 4 5 + tri 4 0 5 6 + tri 5 0 6 7 + tri 6 0 7 8 + tri 7 0 8 9 + tri 8 0 9 10 + tri 9 0 10 11 + tri 10 0 11 12 + tri 11 0 12 1 + tri 12 1 13 14 + tri 13 1 14 2 + tri 14 2 14 15 + tri 15 2 15 3 + tri 16 3 15 16 + tri 17 3 16 4 + tri 18 4 16 17 + tri 19 4 17 5 + tri 20 5 17 18 + tri 21 5 18 6 + tri 22 6 18 19 + tri 23 6 19 7 + tri 24 7 19 20 + tri 25 7 20 8 + tri 26 8 20 21 + tri 27 8 21 9 + tri 28 9 21 22 + tri 29 9 22 10 + tri 30 10 22 23 + tri 31 10 23 11 + tri 32 11 23 24 + tri 33 11 24 12 + tri 34 12 24 13 + tri 35 12 13 1 + tri 36 13 25 26 + tri 37 13 26 14 + tri 38 14 26 27 + tri 39 14 27 15 + tri 40 15 27 28 + tri 41 15 28 16 + tri 42 16 28 29 + tri 43 16 29 17 + tri 44 17 29 30 + tri 45 17 30 18 + tri 46 18 30 31 + tri 47 18 31 19 + tri 48 19 31 32 + tri 49 19 32 20 + tri 50 20 32 33 + tri 51 20 33 21 + tri 52 21 33 34 + tri 53 21 34 22 + tri 54 22 34 35 + tri 55 22 35 23 + tri 56 23 35 36 + tri 57 23 36 24 + tri 58 24 36 25 + tri 59 24 25 13 + tri 60 25 37 38 + tri 61 25 38 26 + tri 62 26 38 39 + tri 63 26 39 27 + tri 64 27 39 40 + tri 65 27 40 28 + tri 66 28 40 41 + tri 67 28 41 29 + tri 68 29 41 42 + tri 69 29 42 30 + tri 70 30 42 43 + tri 71 30 43 31 + tri 72 31 43 44 + tri 73 31 44 32 + tri 74 32 44 45 + tri 75 32 45 33 + tri 76 33 45 46 + tri 77 33 46 34 + tri 78 34 46 47 + tri 79 34 47 35 + tri 80 35 47 48 + tri 81 35 48 36 + tri 82 36 48 37 + tri 83 36 37 25 + tri 84 37 49 50 + tri 85 37 50 38 + tri 86 38 50 51 + tri 87 38 51 39 + tri 88 39 51 52 + tri 89 39 52 40 + tri 90 40 52 53 + tri 91 40 53 41 + tri 92 41 53 54 + tri 93 41 54 42 + tri 94 42 54 55 + tri 95 42 55 43 + tri 96 43 55 56 + tri 97 43 56 44 + tri 98 44 56 57 + tri 99 44 57 45 + tri 100 45 57 58 + tri 101 45 58 46 + tri 102 46 58 59 + tri 103 46 59 47 + tri 104 47 59 60 + tri 105 47 60 48 + tri 106 48 60 49 + tri 107 48 49 37 + tri 108 49 61 62 + tri 109 49 62 50 + tri 110 50 62 63 + tri 111 50 63 51 + tri 112 51 63 64 + tri 113 51 64 52 + tri 114 52 64 65 + tri 115 52 65 53 + tri 116 53 65 66 + tri 117 53 66 54 + tri 118 54 66 67 + tri 119 54 67 55 + tri 120 55 67 68 + tri 121 55 68 56 + tri 122 56 68 69 + tri 123 56 69 57 + tri 124 57 69 70 + tri 125 57 70 58 + tri 126 58 70 71 + tri 127 58 71 59 + tri 128 59 71 72 + tri 129 59 72 60 + tri 130 60 72 61 + tri 131 60 61 49 + tri 132 61 73 74 + tri 133 61 74 62 + tri 134 62 74 75 + tri 135 62 75 63 + tri 136 63 75 76 + tri 137 63 76 64 + tri 138 64 76 77 + tri 139 64 77 65 + tri 140 65 77 78 + tri 141 65 78 66 + tri 142 66 78 79 + tri 143 66 79 67 + tri 144 67 79 80 + tri 145 67 80 68 + tri 146 68 80 81 + tri 147 68 81 69 + tri 148 69 81 82 + tri 149 69 82 70 + tri 150 70 82 83 + tri 151 70 83 71 + tri 152 71 83 84 + tri 153 71 84 72 + tri 154 72 84 73 + tri 155 72 73 61 + tri 156 73 85 86 + tri 157 73 86 74 + tri 158 74 86 87 + tri 159 74 87 75 + tri 160 75 87 88 + tri 161 75 88 76 + tri 162 76 88 89 + tri 163 76 89 77 + tri 164 77 89 90 + tri 165 77 90 78 + tri 166 78 90 91 + tri 167 78 91 79 + tri 168 79 91 92 + tri 169 79 92 80 + tri 170 80 92 93 + tri 171 80 93 81 + tri 172 81 93 94 + tri 173 81 94 82 + tri 174 82 94 95 + tri 175 82 95 83 + tri 176 83 95 96 + tri 177 83 96 84 + tri 178 84 96 85 + tri 179 84 85 73 + tri 180 85 97 98 + tri 181 85 98 86 + tri 182 86 98 99 + tri 183 86 99 87 + tri 184 87 99 100 + tri 185 87 100 88 + tri 186 88 100 101 + tri 187 88 101 89 + tri 188 89 101 102 + tri 189 89 102 90 + tri 190 90 102 103 + tri 191 90 103 91 + tri 192 91 103 104 + tri 193 91 104 92 + tri 194 92 104 105 + tri 195 92 105 93 + tri 196 93 105 106 + tri 197 93 106 94 + tri 198 94 106 107 + tri 199 94 107 95 + tri 200 95 107 108 + tri 201 95 108 96 + tri 202 96 108 97 + tri 203 96 97 85 + tri 204 97 109 110 + tri 205 97 110 98 + tri 206 98 110 111 + tri 207 98 111 99 + tri 208 99 111 112 + tri 209 99 112 100 + tri 210 100 112 113 + tri 211 100 113 101 + tri 212 101 113 114 + tri 213 101 114 102 + tri 214 102 114 115 + tri 215 102 115 103 + tri 216 103 115 116 + tri 217 103 116 104 + tri 218 104 116 117 + tri 219 104 117 105 + tri 220 105 117 118 + tri 221 105 118 106 + tri 222 106 118 119 + tri 223 106 119 107 + tri 224 107 119 120 + tri 225 107 120 108 + tri 226 108 120 109 + tri 227 108 109 97 + tri 228 109 121 122 + tri 229 109 122 110 + tri 230 110 122 123 + tri 231 110 123 111 + tri 232 111 123 124 + tri 233 111 124 112 + tri 234 112 124 125 + tri 235 112 125 113 + tri 236 113 125 126 + tri 237 113 126 114 + tri 238 114 126 127 + tri 239 114 127 115 + tri 240 115 127 128 + tri 241 115 128 116 + tri 242 116 128 129 + tri 243 116 129 117 + tri 244 117 129 130 + tri 245 117 130 118 + tri 246 118 130 131 + tri 247 118 131 119 + tri 248 119 131 132 + tri 249 119 132 120 + tri 250 120 132 121 + tri 251 120 121 109 + tri 252 121 133 134 + tri 253 121 134 122 + tri 254 122 134 135 + tri 255 122 135 123 + tri 256 123 135 136 + tri 257 123 136 124 + tri 258 124 136 137 + tri 259 124 137 125 + tri 260 125 137 138 + tri 261 125 138 126 + tri 262 126 138 139 + tri 263 126 139 127 + tri 264 127 139 140 + tri 265 127 140 128 + tri 266 128 140 141 + tri 267 128 141 129 + tri 268 129 141 142 + tri 269 129 142 130 + tri 270 130 142 143 + tri 271 130 143 131 + tri 272 131 143 144 + tri 273 131 144 132 + tri 274 132 144 133 + tri 275 132 133 121 + tri 276 133 145 146 + tri 277 133 146 134 + tri 278 134 146 147 + tri 279 134 147 135 + tri 280 135 147 148 + tri 281 135 148 136 + tri 282 136 148 149 + tri 283 136 149 137 + tri 284 137 149 150 + tri 285 137 150 138 + tri 286 138 150 151 + tri 287 138 151 139 + tri 288 139 151 152 + tri 289 139 152 140 + tri 290 140 152 153 + tri 291 140 153 141 + tri 292 141 153 154 + tri 293 141 154 142 + tri 294 142 154 155 + tri 295 142 155 143 + tri 296 143 155 156 + tri 297 143 156 144 + tri 298 144 156 145 + tri 299 144 145 133 + tri 300 157 156 155 + tri 301 157 155 154 + tri 302 157 154 153 + tri 303 157 153 152 + tri 304 157 152 151 + tri 305 157 151 150 + tri 306 157 150 149 + tri 307 157 149 148 + tri 308 157 148 147 + tri 309 157 147 146 + tri 310 157 146 145 + tri 311 157 145 156 + + numweights 158 + weight 0 0 1.000000 ( -8.000000 0.181969 0.355668 ) + weight 1 0 1.000000 ( -7.799423 0.181969 2.135836 ) + weight 2 0 1.000000 ( -7.799423 -0.708115 1.897339 ) + weight 3 0 1.000000 ( -7.799423 -1.359701 1.245752 ) + weight 4 0 1.000000 ( -7.799423 -1.598199 0.355668 ) + weight 5 0 1.000000 ( -7.799423 -1.359701 -0.534415 ) + weight 6 0 1.000000 ( -7.799423 -0.708115 -1.186002 ) + weight 7 0 1.000000 ( -7.799423 0.181968 -1.424499 ) + weight 8 0 1.000000 ( -7.799423 1.072052 -1.186002 ) + weight 9 0 1.000000 ( -7.799423 1.723639 -0.534416 ) + weight 10 0 1.000000 ( -7.799423 1.962136 0.355668 ) + weight 11 0 1.000000 ( -7.799423 1.723639 1.245751 ) + weight 12 0 1.000000 ( -7.799423 1.072053 1.897338 ) + weight 13 0 1.000000 ( -7.207749 0.181969 3.826738 ) + weight 14 0 1.000000 ( -7.207749 -1.553566 3.361703 ) + weight 15 0 1.000000 ( -7.207749 -2.824066 2.091203 ) + weight 16 0 1.000000 ( -7.207749 -3.289101 0.355668 ) + weight 17 0 1.000000 ( -7.207749 -2.824066 -1.379867 ) + weight 18 0 1.000000 ( -7.207749 -1.553566 -2.650366 ) + weight 19 0 1.000000 ( -7.207749 0.181968 -3.115401 ) + weight 20 0 1.000000 ( -7.207749 1.917503 -2.650367 ) + weight 21 0 1.000000 ( -7.207749 3.188003 -1.379868 ) + weight 22 0 1.000000 ( -7.207749 3.653039 0.355667 ) + weight 23 0 1.000000 ( -7.207749 3.188004 2.091202 ) + weight 24 0 1.000000 ( -7.207749 1.917506 3.361702 ) + weight 25 0 1.000000 ( -6.254651 0.181969 5.343586 ) + weight 26 0 1.000000 ( -6.254651 -2.311990 4.675333 ) + weight 27 0 1.000000 ( -6.254651 -4.137694 2.849627 ) + weight 28 0 1.000000 ( -6.254651 -4.805950 0.355668 ) + weight 29 0 1.000000 ( -6.254651 -4.137694 -2.138291 ) + weight 30 0 1.000000 ( -6.254651 -2.311991 -3.963995 ) + weight 31 0 1.000000 ( -6.254651 0.181968 -4.632249 ) + weight 32 0 1.000000 ( -6.254651 2.675927 -3.963996 ) + weight 33 0 1.000000 ( -6.254651 4.501632 -2.138292 ) + weight 34 0 1.000000 ( -6.254651 5.169887 0.355666 ) + weight 35 0 1.000000 ( -6.254651 4.501634 2.849625 ) + weight 36 0 1.000000 ( -6.254651 2.675931 4.675331 ) + weight 37 0 1.000000 ( -4.987917 0.181969 6.610320 ) + weight 38 0 1.000000 ( -4.987917 -2.945357 5.772356 ) + weight 39 0 1.000000 ( -4.987917 -5.234717 3.482994 ) + weight 40 0 1.000000 ( -4.987917 -6.072682 0.355668 ) + weight 41 0 1.000000 ( -4.987917 -5.234717 -2.771657 ) + weight 42 0 1.000000 ( -4.987917 -2.945357 -5.061018 ) + weight 43 0 1.000000 ( -4.987917 0.181968 -5.898983 ) + weight 44 0 1.000000 ( -4.987917 3.309293 -5.061018 ) + weight 45 0 1.000000 ( -4.987917 5.598655 -2.771659 ) + weight 46 0 1.000000 ( -4.987917 6.436620 0.355666 ) + weight 47 0 1.000000 ( -4.987917 5.598658 3.482991 ) + weight 48 0 1.000000 ( -4.987917 3.309298 5.772354 ) + weight 49 0 1.000000 ( -3.471070 0.181969 7.563418 ) + weight 50 0 1.000000 ( -3.471070 -3.421906 6.597764 ) + weight 51 0 1.000000 ( -3.471070 -6.060125 3.959543 ) + weight 52 0 1.000000 ( -3.471070 -7.025782 0.355668 ) + weight 53 0 1.000000 ( -3.471070 -6.060125 -3.248207 ) + weight 54 0 1.000000 ( -3.471070 -3.421907 -5.886425 ) + weight 55 0 1.000000 ( -3.471070 0.181968 -6.852081 ) + weight 56 0 1.000000 ( -3.471070 3.785842 -5.886426 ) + weight 57 0 1.000000 ( -3.471070 6.424061 -3.248209 ) + weight 58 0 1.000000 ( -3.471070 7.389719 0.355665 ) + weight 59 0 1.000000 ( -3.471070 6.424066 3.959540 ) + weight 60 0 1.000000 ( -3.471070 3.785848 6.597761 ) + weight 61 0 1.000000 ( -1.780168 0.181969 8.155090 ) + weight 62 0 1.000000 ( -1.780168 -3.717743 7.110167 ) + weight 63 0 1.000000 ( -1.780168 -6.572529 4.255380 ) + weight 64 0 1.000000 ( -1.780168 -7.617454 0.355668 ) + weight 65 0 1.000000 ( -1.780168 -6.572528 -3.544043 ) + weight 66 0 1.000000 ( -1.780168 -3.717743 -6.398829 ) + weight 67 0 1.000000 ( -1.780168 0.181968 -7.443754 ) + weight 68 0 1.000000 ( -1.780168 4.081677 -6.398829 ) + weight 69 0 1.000000 ( -1.780168 6.936464 -3.544045 ) + weight 70 0 1.000000 ( -1.780168 7.981390 0.355665 ) + weight 71 0 1.000000 ( -1.780168 6.936469 4.255375 ) + weight 72 0 1.000000 ( -1.780168 4.081685 7.110164 ) + weight 73 0 1.000000 ( -0.000001 0.181969 8.355667 ) + weight 74 0 1.000000 ( -0.000001 -3.818031 7.283871 ) + weight 75 0 1.000000 ( -0.000001 -6.746233 4.355668 ) + weight 76 0 1.000000 ( -0.000001 -7.818030 0.355668 ) + weight 77 0 1.000000 ( -0.000001 -6.746233 -3.644331 ) + weight 78 0 1.000000 ( -0.000001 -3.818031 -6.572534 ) + weight 79 0 1.000000 ( -0.000001 0.181968 -7.644331 ) + weight 80 0 1.000000 ( -0.000001 4.181966 -6.572535 ) + weight 81 0 1.000000 ( -0.000001 7.110169 -3.644333 ) + weight 82 0 1.000000 ( -0.000001 8.181968 0.355665 ) + weight 83 0 1.000000 ( -0.000001 7.110174 4.355663 ) + weight 84 0 1.000000 ( -0.000001 4.181973 7.283868 ) + weight 85 0 1.000000 ( 1.780167 0.181969 8.155090 ) + weight 86 0 1.000000 ( 1.780167 -3.717743 7.110167 ) + weight 87 0 1.000000 ( 1.780167 -6.572529 4.255380 ) + weight 88 0 1.000000 ( 1.780167 -7.617455 0.355668 ) + weight 89 0 1.000000 ( 1.780167 -6.572529 -3.544044 ) + weight 90 0 1.000000 ( 1.780167 -3.717743 -6.398829 ) + weight 91 0 1.000000 ( 1.780167 0.181968 -7.443755 ) + weight 92 0 1.000000 ( 1.780167 4.081678 -6.398830 ) + weight 93 0 1.000000 ( 1.780167 6.936466 -3.544045 ) + weight 94 0 1.000000 ( 1.780167 7.981391 0.355665 ) + weight 95 0 1.000000 ( 1.780167 6.936470 4.255375 ) + weight 96 0 1.000000 ( 1.780167 4.081685 7.110165 ) + weight 97 0 1.000000 ( 3.471069 0.181969 7.563418 ) + weight 98 0 1.000000 ( 3.471069 -3.421907 6.597764 ) + weight 99 0 1.000000 ( 3.471069 -6.060126 3.959544 ) + weight 100 0 1.000000 ( 3.471069 -7.025782 0.355668 ) + weight 101 0 1.000000 ( 3.471069 -6.060125 -3.248207 ) + weight 102 0 1.000000 ( 3.471069 -3.421907 -5.886425 ) + weight 103 0 1.000000 ( 3.471069 0.181968 -6.852081 ) + weight 104 0 1.000000 ( 3.471069 3.785842 -5.886426 ) + weight 105 0 1.000000 ( 3.471069 6.424063 -3.248209 ) + weight 106 0 1.000000 ( 3.471069 7.389719 0.355665 ) + weight 107 0 1.000000 ( 3.471069 6.424066 3.959540 ) + weight 108 0 1.000000 ( 3.471069 3.785848 6.597761 ) + weight 109 0 1.000000 ( 4.987917 0.181969 6.610320 ) + weight 110 0 1.000000 ( 4.987917 -2.945357 5.772356 ) + weight 111 0 1.000000 ( 4.987917 -5.234717 3.482994 ) + weight 112 0 1.000000 ( 4.987917 -6.072682 0.355668 ) + weight 113 0 1.000000 ( 4.987917 -5.234717 -2.771657 ) + weight 114 0 1.000000 ( 4.987917 -2.945357 -5.061018 ) + weight 115 0 1.000000 ( 4.987917 0.181968 -5.898983 ) + weight 116 0 1.000000 ( 4.987917 3.309293 -5.061018 ) + weight 117 0 1.000000 ( 4.987917 5.598655 -2.771659 ) + weight 118 0 1.000000 ( 4.987917 6.436620 0.355666 ) + weight 119 0 1.000000 ( 4.987917 5.598658 3.482991 ) + weight 120 0 1.000000 ( 4.987917 3.309298 5.772354 ) + weight 121 0 1.000000 ( 6.254652 0.181969 5.343585 ) + weight 122 0 1.000000 ( 6.254652 -2.311990 4.675332 ) + weight 123 0 1.000000 ( 6.254652 -4.137693 2.849627 ) + weight 124 0 1.000000 ( 6.254652 -4.805949 0.355668 ) + weight 125 0 1.000000 ( 6.254652 -4.137693 -2.138290 ) + weight 126 0 1.000000 ( 6.254652 -2.311990 -3.963995 ) + weight 127 0 1.000000 ( 6.254652 0.181968 -4.632248 ) + weight 128 0 1.000000 ( 6.254652 2.675926 -3.963995 ) + weight 129 0 1.000000 ( 6.254652 4.501630 -2.138292 ) + weight 130 0 1.000000 ( 6.254652 5.169886 0.355666 ) + weight 131 0 1.000000 ( 6.254652 4.501633 2.849625 ) + weight 132 0 1.000000 ( 6.254652 2.675930 4.675330 ) + weight 133 0 1.000000 ( 7.207750 0.181969 3.826737 ) + weight 134 0 1.000000 ( 7.207750 -1.553566 3.361702 ) + weight 135 0 1.000000 ( 7.207750 -2.824065 2.091203 ) + weight 136 0 1.000000 ( 7.207750 -3.289100 0.355668 ) + weight 137 0 1.000000 ( 7.207750 -2.824065 -1.379866 ) + weight 138 0 1.000000 ( 7.207750 -1.553566 -2.650365 ) + weight 139 0 1.000000 ( 7.207750 0.181968 -3.115400 ) + weight 140 0 1.000000 ( 7.207750 1.917502 -2.650365 ) + weight 141 0 1.000000 ( 7.207750 3.188002 -1.379867 ) + weight 142 0 1.000000 ( 7.207750 3.653037 0.355667 ) + weight 143 0 1.000000 ( 7.207750 3.188003 2.091201 ) + weight 144 0 1.000000 ( 7.207750 1.917505 3.361701 ) + weight 145 0 1.000000 ( 7.799423 0.181969 2.135834 ) + weight 146 0 1.000000 ( 7.799423 -0.708114 1.897337 ) + weight 147 0 1.000000 ( 7.799423 -1.359700 1.245751 ) + weight 148 0 1.000000 ( 7.799423 -1.598197 0.355668 ) + weight 149 0 1.000000 ( 7.799423 -1.359700 -0.534414 ) + weight 150 0 1.000000 ( 7.799423 -0.708114 -1.186000 ) + weight 151 0 1.000000 ( 7.799423 0.181968 -1.424497 ) + weight 152 0 1.000000 ( 7.799423 1.072051 -1.186000 ) + weight 153 0 1.000000 ( 7.799423 1.723637 -0.534415 ) + weight 154 0 1.000000 ( 7.799423 1.962134 0.355668 ) + weight 155 0 1.000000 ( 7.799423 1.723638 1.245750 ) + weight 156 0 1.000000 ( 7.799423 1.072053 1.897336 ) + weight 157 0 1.000000 ( 8.000000 0.181969 0.355668 ) +} + +mesh { + // meshes: Skin3 + shader "" + + numverts 24 + vert 0 ( 0.000000 0.000000 ) 0 1 + vert 1 ( 1.000000 0.000000 ) 1 1 + vert 2 ( 1.000000 1.000000 ) 2 1 + vert 3 ( 0.000000 1.000000 ) 3 1 + vert 4 ( 1.000000 0.000000 ) 4 1 + vert 5 ( 1.000000 1.000000 ) 5 1 + vert 6 ( 0.000000 1.000000 ) 6 1 + vert 7 ( 0.000000 0.000000 ) 7 1 + vert 8 ( 1.000000 0.000000 ) 8 1 + vert 9 ( 1.000000 1.000000 ) 9 1 + vert 10 ( 0.000000 1.000000 ) 10 1 + vert 11 ( 0.000000 0.000000 ) 11 1 + vert 12 ( 0.000000 0.000000 ) 12 1 + vert 13 ( 1.000000 0.000000 ) 13 1 + vert 14 ( 1.000000 1.000000 ) 14 1 + vert 15 ( 0.000000 1.000000 ) 15 1 + vert 16 ( 0.000000 1.000000 ) 16 1 + vert 17 ( 0.000000 0.000000 ) 17 1 + vert 18 ( 1.000000 0.000000 ) 18 1 + vert 19 ( 1.000000 1.000000 ) 19 1 + vert 20 ( 1.000000 1.000000 ) 20 1 + vert 21 ( 0.000000 1.000000 ) 21 1 + vert 22 ( 0.000000 0.000000 ) 22 1 + vert 23 ( 1.000000 0.000000 ) 23 1 + + numtris 12 + tri 0 0 1 2 + tri 1 2 3 0 + tri 2 4 5 6 + tri 3 6 7 4 + tri 4 8 9 10 + tri 5 10 11 8 + tri 6 12 13 14 + tri 7 14 15 12 + tri 8 16 17 18 + tri 9 18 19 16 + tri 10 20 21 22 + tri 11 22 23 20 + + numweights 24 + weight 0 0 1.000000 ( 15.752778 -15.001534 0.000027 ) + weight 1 0 1.000000 ( 15.752778 16.216137 0.000027 ) + weight 2 0 1.000000 ( 15.752778 16.216137 -31.298512 ) + weight 3 0 1.000000 ( 15.752778 -15.001534 -31.298512 ) + weight 4 0 1.000000 ( -15.901435 -15.001534 0.000027 ) + weight 5 0 1.000000 ( -15.901435 -15.001534 -31.298512 ) + weight 6 0 1.000000 ( -15.901435 16.216137 -31.298512 ) + weight 7 0 1.000000 ( -15.901435 16.216137 0.000027 ) + weight 8 0 1.000000 ( -15.901435 -15.001534 -31.298512 ) + weight 9 0 1.000000 ( 15.752778 -15.001534 -31.298512 ) + weight 10 0 1.000000 ( 15.752778 16.216137 -31.298512 ) + weight 11 0 1.000000 ( -15.901435 16.216137 -31.298512 ) + weight 12 0 1.000000 ( -15.901435 -15.001534 0.000027 ) + weight 13 0 1.000000 ( 15.752778 -15.001534 0.000027 ) + weight 14 0 1.000000 ( 15.752778 -15.001534 -31.298512 ) + weight 15 0 1.000000 ( -15.901435 -15.001534 -31.298512 ) + weight 16 0 1.000000 ( -15.901435 16.216137 0.000027 ) + weight 17 0 1.000000 ( 15.752778 16.216137 0.000027 ) + weight 18 0 1.000000 ( 15.752778 -15.001534 0.000027 ) + weight 19 0 1.000000 ( -15.901435 -15.001534 0.000027 ) + weight 20 0 1.000000 ( -15.901435 16.216137 -31.298512 ) + weight 21 0 1.000000 ( 15.752778 16.216137 -31.298512 ) + weight 22 0 1.000000 ( 15.752778 16.216137 0.000027 ) + weight 23 0 1.000000 ( -15.901435 16.216137 0.000027 ) +} + diff --git a/build/main/models/omtests/test01_bonetype1/test01_bonetype1.RAY b/build/main/models/omtests/test01_bonetype1/test01_bonetype1.RAY new file mode 100644 index 0000000000000000000000000000000000000000..241910c00e6ff0a2ce760b3da2640677a18b1a51 GIT binary patch literal 151947 zcmY!ma*PyYU|{fIU|_hx#Q+Bi+zbo?3=9kg+zbpMj0_AdJPZs9%nS@m_!$^dUNA6l z{9s^6k6>iT4`5=DVPs%nWPo5MxCsyjOdLcrFf=&AthhH(&w+s<#EF5S!JffE#*N{| zO}iI9FC8JekjVynWF9$eh~4Dq9Mv;iLI6t|um_2OFuET>Vla%HW{p>ip{7}j8GC1i zIhe+mFL(URV!9t@&Sw_W(KHJSj8U5G5CEk?G|lid%Yr5WQVYY#Y4%XV2YZxqmVtpG zK;)rg#iK=z|NsBr_y7NYI~YbYl4LH(ev&nfY8X}_fF%vU(=5oN$nqdI3?rvmaGLC!tX3d;w2MY}lAEXAx2hlJ-hz4Ph7y^UZ`{)=U3n?3r28KF51_s~6 zl6XVPA`?_+LNRhag0U$x9HRS#QwjqE0|_Y$}4TG}6X!02L@lK=%N0SGU0W~s}jV6zg8Sg~;dNg?u z8Bilr*=X_@nek4fudyZ%GdV;r)QCufa43WJKpE^&dut$TK^TWFl7vTlp{T(H3Rf6r zU>NOYpoY%K<$=-!itk5zp(w#I!a1YKV}vIF{N5i;9{9s&gv*X5j}e{#@OytWdEgJ9 z5iW~0dF;_a^g@j(3!u?nC^-B;!3@J-0W1Ve9zGcbg@DO}=+Ry%mH--| zLXh-;>O8|{fAxL^a^89Eo z6e%!9JaaU8jQAvgF91f92fol5@p7ZdW5g!`d;u_;Jn)6ih?m2fJWhBbdZDJ21<`0P z6dZn_V1{9^02Tr!52CS1gM~nHFbo#JLcruf^k^>>O8|{fAxL^a^89Eo6e%!9JaaU8 zjQAvgF91f92fol5@p7ZdW5g!`d;u_;Jn)6ih?m2fJp3XMy-+jCf@riC3JyO|FvBod z01E+=2hmuh!9pN87zPVqAz<<#dbAgcC4fe#5F|Yyd49APiWC?lo;jL4Mtl;$7XYKl z17GNjc)8K!G2)W|z5p0a9{56M#LHn#9#_&3y-;(?f@riC3JyO|FvBod01E+=2hmuh z!9pN87zPVqAz<<#dbAgcC4fe#5F|Yyd49APiWC?lo;jL4Mtl;$7XYKl17GNjc)8K! zG2)W|z5p0a9{56M#LHn#9#N%;UZ@3SK{VP61&1Ffm|++!fQ5j`gJ>+$U?Gqk41)!* z5HNWVJ=zP!53xLt&fiHAMyxeH=81YE}UjU3I z4}76B;^nX=j|a_&UZ^EyK{VP61&1Ffm|++!fQ5j`gJ>+$U?Gqk41)!*5HNWVJ=zP! z53xLt&fiHAMyxeH=81YE}UjU3I4}76B;^nX= zkF-gMUZ|k~MPW4B3k3%sD41awEP#c8$%AMt(qJKw91Md6un;hL5Ix!p#S%axR0xtD zkUT%y3q=Zy5zib=9wR;p;0u7!lLx-g8S!$X$z#MP0ek^4nmq7@&WM-8nmmfuBlSX!C<>#|UMM*D zK*0>dU;!)yOddpIkp>HarYMX?d!gXq0|he-g9We< zFnJJ-MH(ywl7nHe02Tr!528nVp;!WFgbG2@1Cr-Qd!a~yG2)q{$z#MP0ek^4nmq7@ z&WM*AO&%jY3E&HW(d27!La_wU2o-{)2PDsr_Ck>YW5hE@lgEfp0{8-8GLsbz~n(R7HO~$NDhX<0$2!` zJcu6cg<=Vy5h?^p4@jOL?S&!*#)xN*CXW%H1n>pGX!5`pIwM|gG8V^Sd&NBOQc??8AV|<+6x5-A1Ih%7%YH=fXRbsEYe^hkQ@wy1+Wk>c@RC?3&j#Z zBUA{I9*{gg+6zSrj1kWqO&%jY3E&HW(d2c$R|xlT3<2@fgIpC{{5}2LHF>!}`Lv|6 zAk|92ke3V7aZuYJ6i$zE{=tlVN-{0TQIr%O5a&`#f+CH9=*a){zupPeMv#6428AsM zqpBGKk^h;1$JqX1Mm{Aa2`KU@Nj#_lOfC-;al}PFGU{J(^FshnC9{FD& z5s%kn%nXbS6*&wH$kiGp)gx*E4GiyUeU?3AZG)Yv<0KnU@%`uj{{t&CzaP*PNpSk} z|G$HpH;bb%*95fOj_g)M#DnyMA|8a1RWLA+7x^GFFwFvqV#BEJn8(1t0KyiG3=Aun zLF)hh|9?O`wbM?7tHFtZp<(~k?CS=pi`zDWT#bzX|Ns9VVrzpvOb^3~g*N~H*YCfQ zecd2saoa|S{GBO3!6vrNY<7w?Dc^tN;=4T-<}G%}rh(YVCc^Y6BtNr{Fe%@E{o=bl z=H@MS2ot|*%J0vThnTodP;TEF;V^;Q^ukcp1wEq13ay#tpNAd_Gi-9(TcP+WsdbTDtRJ9+7y4Z_6T z>z><#(jzGK{1*hy-OWALK_0Aqgsb_digy{*$jCWw0 zma^aO>YY6fQqPb~+FejVO6Cti?=Om+Jj;|~xt5v0dpnWF;_$V8^PeGTykkW4f) z(?77LsTu4>Hr;dk^o{%onh4UfV9f)2kQ-Tb&+XGQ@J)pSeoR+fRMC#eTxNCQy`5Gh(vhTN2r4z@rl>I&N2liz#)!|LyFg*(M zZ|?_%eRuqUeVI&k&=d}m1%=69-V!H}eRf8E`+n%0BWNN>Pl3Gs0gx+fjr{g~*Exq| zA}EiZHY@_0Sbyz~jhWOlf+m9WOn4LnHnHy79UD++K~gx#jf?CV9AIuVW~#HB6@P%B zi6A{NHySb3+0BeUfaJ!;{y+y%ID&lrUgw-$jFBHf6G3`F;Ry2eJDqcO(MEnqCN2)j z2j^>$thLlLJF#nb@aAifzd(9GaSe(YE2(F8qSx*~^EF7ewLj1SmL508AF$(Msw0>l zL3&{6aYOt8J5HuLr1ZGXp1}c>XF%!ypP`@KADwdqO$6xyEKVB+8Z%x5~1uQ#zx2j}aKRJZ+))+p}3v3ft= zd<`-Yqz4q&?Wu12AFff{e|`0SXubx?g6xZuDsuwK%CU0pzs|D;Z+e93Sr93Ape@yH zzbq@~{%bsIpy?4L3ks8~XY!o7Qr-45`A*+g&%}>1pa6;;^q2wZ`7xvOKxeAken#Kv z`|6nZ_akBklt;T1a-4cn-S*3`*>7`qjUqu4L3#py&pXha>b75Q&3>CZYZQ@8Tz1mH z0pv!IulMn+u~TK`BxoW?56F!mU+?8vW2eH(iDcrx3zHmR;aJPWZ!hgTonSbE^uWTg zhKb)^%6B?aI7S$+0OxCv8y~Mxw2xT5A8)<}g*`|QD6T9Ic5ZND)qr~M|LHAv}k`$+=_P@VzV$LTxWu9=CS zV4eZ#0p%G`&gJl(Zr8-b56v^obLWHeby-i3(>fcu{m<{u*fU$t6R(LdJtvNza9C?2 zxBuDw8GB~wc_Nuu_|xn_&iyW@)i!ebkCj~9CwE<&pot(o8sFDCtg?~Yf3)P{KH2Nq zNG9s+Uvj|ByUl5fjof~oc?SEvUf^#5fZPbuQ;_NDu-Qg#KleO?{hlviEdY@0vHtzw ze7)61ZvQkr&;4chXW-4(Fg>8S2DxIYp6CA3`!k^V8YBy{@8rZ{r!_Wm`vtCR?|)x% z5pQ~g>Dlne?EomG_^)g4e^+u5njS&2r9aIMRA**6ZL*QuANAtEKCXENc=HTQ&xy@z z4s5iM+aLMjz&_4-2GBeMk_F|_bpCXwZ8mcIWA4we0r>({Iv``@k^-hDqviMkP)J4J zpJ6ja&lAbS9YK)}AUA?cyj611j`zAYK{tZ*fZPZ&@n*?IJD%&>NG6_pz10B}jvybf z%`>pid4azL0CFQp4=5Zr*vRc?oo8U5{Q}kk0LkX;xd6`Bpp-B}&(pr+-VD6?8m0#n z*PyVUuIFjres2aeUxQ??yx!{I;@#%77nB~aYuleLxrjGk!}J7XdOGX@rN`^q_NPiN zLi069_H0n311QfdvXR?g{^Ee0z&rzjc?P5hlxG&&$n7tCalnp$o&hw^Fsa3X^L0^4 zpHrLToqdicL-t$}PRDB^OizdVbB9*PJNq0?hU~d0oQ`CoZDr^Ij4w=ykla@88uo`|g*xA({9}WB&mc`*x=e$2RK7@uNNOl7MJ#fCB;CN@>dExZ^J5Pn+&DStJpt$aLytD6| zaQglor$V6l8YKHdWB-A(D+`_K9q;VBS>m=|_1YV}`5LCDASv}go#UN-H%i?0t6X~n z&DS7VP?$K&q&rnP-q|-V@ZmnT6P|eU3`|dl?C}GYj(7IW4SWa=El7P0k_F}KJo{v) z7RNjLyiSJLToO(vXd+0D0n4)k&5n2Wd7cchxhR|t&4nNn>o1i%fZRCA@yqH3Nd=2s!NDnBks~zv`yDXe;pLrq#ny*2! zlR_^zz|!O65;yyQSKkm!k03p;^!TX6&HnGzH%RGm=B086P@dWDcxPWJD0QE}U%P@_ z0n!7?Gus^R>?;X;X!rj(tak0b^LRgKBra)jzti6LiThmLZtYH7Ux_yt!t`{Q{c_mz zK5?Im+pXOR>nowT5F~4!k#QiYr`Kur`^0?}i~sEFO$;Y!B1liiu^SGv-Y4!WU;JlZ zPhvQdiLHI-5A3jfV5u``s z^N$0`?-TbOcD`kuy1o+0#61bE4*mS8PWA5-_cbj3W7m@yPS8Y<9*ySf2kPD@?yFz? z$F4gu9LYrW-47h@R24Y&y-(aHC>CiSzWW=&a0KaT2&^~&icJBrNc*te-;ly_x+tR~ zXe+pQ?M0n$S%cyi8KcKFNDnBkLE)IRzS3UA`Ia>zuJw06aM*RN-6{Kh;=U<~ z;r2O;{}4=%AUy&%svJORcyeO6efHu%Na^u(LaPHP&lJB;+~>9Xo1M5=B*8ob(o=El zhC|W&#C@K-zuAe2MMCq;9`m-XpnNUDHNk0H^g)Ad(T;}5zJ;-oeGSudC4j+kYxF^b zt~t z=67(u*4XjI7&Ny4ns0#l7Dl7{8l(pl*XldI7=z{(Kzbl?4KfjApSDPWld9+}lS`Xp z_j58Z;7#E$JrnlS9Z(USWpZ(I?0yag251Tg$wpnyJFp=(#mU(~b2B3Y!~W}=V+ooF z(xV`B_kfdu=4J*4hW*zz$0C^s%A?vM2~LT#4s4m^V6+9|bJTelbYFw?c*OlbkTC1O zmWd8VTR=WX_}Xt;hXcrs>o*l{2E_^}c3|NLqtQ(S=>fTM-KN6LpjZLL4#GqwuV)Tg zA_Yzo?^!lq+#GAqO++|?^eos@cR>6-%jOH4W9_+6!cpCu1)Q%hvP=Z|*nZhd#;q{7 z!Dw_hg7kpm`U1;DkdN(`zGU2raHF=@GY3$5jORSC_4eji`%grqN06Qw3mY8bI1g;S zwK>-QBT9OVnAYI{$}>j_*|xGUFxX!uBF}*Ifbz`YLbk2U3=H;H;CZI%&SQH}z6RCT zyWc0;`MKS)CRAU;^nmK?UGEd^eBEwYBkF6AEU2CVl|AdI$l!wI#j7E+bm>y7lo%KG^t~W7!e;vGh z1j)kc>w@=*cAy%_*$sag4$}jQ>-_hLcAz@m$qiP9gJeN&1l8AV?-T8W#3J{H5~ycj zdO-Dc>-$7IL9xjFA@F(zBnt{hP<`F_KGCjw@t=L21nNSV9#DPV@IKM5Yw@3b9q_sk zBn!%;p!#~^`$Rig&s)1etqxfD!D#ew1nB|Q*Aw0++R1p{+MNWiuR$h)>RwQN4U)Cq z{ml;4nu3`GqtQ(S=>gT({qGa)tag911GT0gc?M)6sO|;T*Y)oc?OGDU?FqGeV0u9H zb=~_!yXM4jdqlejBs&9IUxQ3cSzl@Y(hGmv45kMZ*B}!?b^Hr2SlbLF3#xlT=`rDb zqMe*rq`e7&_9ILWC_To5!d@)W-Wc9~1j&NxUQnKy@;=e7bnzchD#u$F!t{XZ>&fpE z?MfE^0i|+iUHDTq&H#0Jy@ zfy4|*7St~U^%W*L-mxnVe7KLBKwkl-2h>-X=y=DjDDdGvt`o4n0!S9rSBCay?CzDg z?dQ3Mzdr-h1MSb)-7Rt3&wUNnp8?5Eg7&W)9q-s(7Ea%_9zJ z^;57u7f2T5Mo|A6B+GchbN@;L{X&=?Q2)B#@s1tC3D5m2;Qd07tYc;90Z`wy#_^7w z%(XZBK)!&*2#iLL8IT@O-?iHDj-B+iH~a3CxIyb{kcpr?3hG}MJKnL|e==mxH3I!> zm>y97y2$a4-M*6{d#=L!*C1I?Um4`aF2_4|pivLd=m*SgFdE&BAUz;Ab~@g%1C4rs zMn4d#2h>*v^{?9<@7P@{akJMTFirt-1xOF5f8FMI$L?y0o4q=GoB||k3hiHaJKnJa zjRf5~jejf!rUw+)Ab(vDPPe~#8a9>!lAQwWU$1ezW5;^J)4mYYBL**-M6`X-eGSqB zN{_1@@7S@N@U$<0kN1E~oD1z=gWUM@>Ki*yuN@YCFdE%NkRDK;0lD$V)i-vaUOOZl zndi<2=WEb-_zD|2d&UPdY!(n64+rZ3jfXF{k+WxbFvDg(@_4udXlxrawztei&OYqL zfqi0x$M(Q_Kx2DLZRG4jUmVyc3Lo18xe+wh3>pvLWg}d&3 zud|V}e_nENA0P5qvjZq!gT})_zAnB$V-LvZFq2?3x``k?pz&~!uZ!-_*aPx8A{;?u z+o17qkbN;P4%qP$9fTMt&N<0^os*_pcxK?iJ-Ab1kY3{=THXgp&M$TSv zo`Jm$;rSV`9?*FBCL1|>&}g?c^8AbgXlxslXSUnO*@IFy58*i^upUsJ*=8eW4@%wK z@Hr$&wG-ex3Yx!eNp-W|zGlD8Gs5%NU_GGu>*iE9`)zCX+koc0Au$6oF$Ow+-J0rV z&+j{Z9}#nL4j?_Cxj2w3_#< znor(_JYVRr0Xl!(mFi}He~se)M}+4z!FoV(-I?lUe{YTA{)fnOnqd2)rOKSTQ{C*V znfUkf5T17h>zNQKcL3yyDklE@+{p8;4xqVc(A+Rc_9)MqeITF1avzLF&V`_m0_g$G z4TIcxglEk@kk1h@1InY&`D=UmHT(AvF@Fs%3!wAY_Ht|X??IWrc31?RzXsXI;yc|A zv{C@(HW-cWMvxwm8#_|n?3sP1+kxig5pMi_0X~0iFU!hlf1B_+00)pB==`<43@fMo zE#!3o4q?#wYf#MGTcc>dVGY5x3Sd2;xCVv&-8G8#>(?NyRd8T}&R@5uy4iOy@!NkS zyq*HA2b3P$Qr+y^nfUELAg`xz*bJS&Zb)^rKgF}g4zzv)7Je`qJsd%LKzXJ<)y@7S z&l)=&_?nMLOP_)BC}_PI%d`}G^Q(7kdNv=n<+sb~9=uMu2>1l9wJYu0Hg_AXM-_9Y>&K?2(c zS|`OmEyW(RGAy3(Iw`Oo&^jrQD?ls5;*i%#Ie^xVf!1%lQV{-ffyHezJ zdk&zrW1#VHkbQPi&+IN;Be=E@tOpd=pm4O6dS-VKd2OLXV?SiQ8Az5}_ne(J;q{MT zJ)ram@)wuxIXf-n^^Xp#5bMqCU770a+6b@F1nU9i8E#N|WU8}kg|E@PKjkMlkAl{R zN0^k`vtD{<16mCWD)e0{k6#~oMpCJ|Wc z3ey8x>k4wkhaFe;Cc@Xcf@Ec(>%&3z@ri`(TTNg+E=&(-J#LsuxjnB)*uGWp^|&Be zedzjdkgT_P%Rbx7_}2`>^nl_z)TG?r%e-Zu&1Kk{VUR4yji7bSAlc-1#rxju#J{c? zrU$gHImD#gKIvWYzSr<|%^+D&I5xbj1g++_zb7cS59AA2jKFC0m;viKcL=na+y1Vg z+&&)o+G~)Bp!yoRKHT2m^1D4j1lEVc^g!2#+v{I`w@yI=EiwDuh>=- zSi=t219juvomXtD;A_}Hva6u$!$INrS2)b>7lC#5Fg>tv{39G@_Y=O(9wd7Yx;`9~ zwrtE>?B)~L3jostifd4cvo>$Bn+M+u0Fni*M+dDB2gxS9E4IrfuwMbD2bLb=-xb?s z!S^eGWI=1@LF>aoZrm#9SJbYkmkb7Wkkb7Wkkb7Wk zkb7Wkkb7Wkkb7Wkkb7Wkkb7Wkkb7Wkkb7Wkkb9nP%Z0lK#s;|u#s;|u#s;|u#s;|u z#s;|u#s;|u#s;|u#s;|u#s;|u#s;|u#s--KauX=OKL8O7pc)r;umFq=qCvGaLI7hHH?i=0g?fUia^sBjE$-SBnwJg zAk{E7LIp?$Br3|lz<|s~RRNL(r9O}f7#pDiBm)u^V_;xFW}~VA$%4`+NCk|IPyvzw ziHb8YFd(y0Re)qcDHx;z#zv?B$$&&97#J9k*{CW&vY<2$QUPNlRDfhaqM$U6%tloK zk_Cx?RKVCEJ|rcBL?js)7^D~&7?9bhDnPQJTmVu5VMZKz}N^CAQ_OT0s{jBG8;kkU_fT0ssPD?as)^PjEztMk^zaTFfcG6vr$!mWI;Isqyol9r~t`;L_z5t znT@IfBnwLCAQdn+LIp@fm4Sglje&synT@IfBn!#~AQdn+LIp?$B&rV0cQ7`p3Xm)) zM}Snr*a#IM8IY(30|Nsx8&w5J7L+4EDqw7c3Xlv)RFi>$0hx`e0wfE{5g-*XHbMnR z1|+J*z`%gaMpXfl1?32k3K$!q0we(zD0Lg$vbr~2KklCmzK(e450a5{DBUFH7K%#mK3=GI@R23juP>ukp zfUyxOKr$dveFg>wWHzb_kSr)ifK(zD0Lg$vO&Ay$klCmzK(e450a5{DBUFH7K%$`g%8=QpDnPQJ905`RVz)8>)cs476Rpd0~G0b?UnfMh_Tpd*Hm*{CW&vY;FRQUPNlRDfhaq81Dc49IL$ z6(CtqjsU5Eu@NdjG9Xb)1_lOXHmVAcEGS2SRKVB>6(AXqs1*YP12P*`1xOZ@BS0!( zY=jDs3`o?Pfq?;;jj9493(6576)-kJ1xN-YY6ChTj)8#z#zs{Ek_F`mkZKqkp#mfW z5(TAqWHzb_kSr*jgH*uS2o)d^(2y-?mN+E{QB{Cs zK{*1X0>(zD0Lg$v9T*rGklCmzK(e450a5{DBUFH7K%$Ne3=GI@R23juP>ukpfUyxO zKr$dv(6Ld-Y*ZB>Sx}AuserK&DnK$IQD+7Q24ps>3Xm))M}Sno*a#IM8IY(80|Nsx z8&w5J7L+4EDqw7c3Xlv))RlpO0hx`e0wfE{5g-*XHbMnR1|;gnz`%gaMpXfl1?32k z3K$!q0weukpfUyxOKr$dvZw3YiWHzb_ zkSr)ifK(zD0Lg$v{TUb-klCmzK(e450a5{DBUFH7K%xN* z3=GI@R23juP>ukpfUyxOKr$dv(4n2kY*ZB>Sx}AuserK&DnK$I(I5r}24ps>3Xm)) zM}Sno*a#IM8IWi&0|Nsx8&w5J7L*G>Dqw7c3Xlv)G=zbH0hx`e0wfE{5g-*XHbMnR z1|$kf@5pRa6(CtqItQtMu@NdjBB2Zn3}Flm49IL$6(CtqjsU5Eu@NdjG9b}#XugB7 zQB{CsLAd~=8pcMb0Lg$vBN!OKc?HHsRRNL(6(AXqXdD9r12P*` z1xOZ@BS0!(Y=jDs3`jJdfq?;;jj9493(6576)-kJ1xN-Yn!v!ofXqf!0g?sf2#^XG z8=(Ru0}=(LcVsrI3Xm))or6@s*a#IMkwgXth9m|C24ps>3Xm))7l2g2*a#IM8IWi) zG~dD4s476Rpj-e_4PzrzfMh_Tpu>!j*{CW&vY;FRQUPNlRDfhaqM#GFk=dv!K(e45 z0a5{DBUFH7K%!|33=GI@R23juP>ukpfUyxOKr$fFbOr_nWHzb_kSr)ifKfXqf!0g?sf2#^XG8=(Ru0}?G}U|>LIqpASOf^q~%1&obQ z0g?fUmM}0dAhS_bfMh{A0;B@QMyLSEfJ93f7#NV*s476Rpd0~G0b?UnfMh_TWef}q z$ZS*I3=9m&Y*ZB>Sx}AuserK&DnK$I(Rv0324ps>3Xm))M}Sno z*a#IM8IUOG@P1@AstS-SC`W))z}N^CAQ_NoBLf2iG8714A1F0|PP}RRu^ElnX#AU~Gg6 zkPJw)9h&c8Y*ZB>Sx}AusfMu;DnK$I(GCU%24ps>3Xm))M}Sno*a#IM8IWiv0|Nsx z8&w5J7L+4EDqw7c3Xlv)w2Og(0hx`e0wfE{5g-*XHbMnR1|-_ez`%gaMpXfl1?32k z3K$!q0weSx}AuserK&DnK$I(FqI;49IL$ z6(CtqjsU5Eu@NdjG9XbSx}AusfMu;DnK$I(J2fJ49IL$6(CtqjsU5Eu@NdjG9b~Z z3=9m&Y*ZB>Sx}AuserK&DnK$I(P<0}49IL$6(CtqjsU5Eu@NdjG9c0E3=9m&Y*ZB> zSx}AuserK&DnK$I(HRU349IL$6(CtqE&!>3u@NdjG9b~J3=H7B0%N190Lg-K1V}ZE zjZguS0g29HU|>LIqpASOf^q~%1&obQ0g?fU&Sqd>KxU(=0Lg-K1V{ypjZguS0g29G zU|>LIqpASOf^q~%1&obQ0g?fUg3>!O8&w5J7L?9GDqw7cin$C73?MT=Zb4?FssPD? zd<;?nW2347$%4Waqyol9RRNL(#TZBhjE$-SBnwI-AQdn+stS-SC?$eaz}ToNK(e6p z4pISQqpASOf^ro|1&ocV0wfE{yC4-XHmVAcET~ifserLjRe)qcp$$?2W2347$$~;2 zqyol^LHCc%s7-KEh2B4Q+HQiA;IO%W?2KK5lQ8uDu@4gz4PIx56WTR;fWhszEknaX z@cm=&Cny@c$`0QE+P%QQ0J=*IWMb>gW+%|?Ocqz(?QtUF{xOh=4N1@JLANuRUwO9& zbgL7>M2&YfP8ssePM{mBZVAfm(-a|m|CmFu%YKL3$L)hn%J<(Cl-s8v5@v@m@m)}r z)0vBnpq)sXbD<`m@7v!%83%2fWc#&Zbaz*XC;(cX1uh=3?+!j~qB*fJKHW75A zmJfkF$6yoHuk2?iSZD(>(bv3XpZDc=dk`jq+_<%+2JCCl9{6tr_C21sm*3eC+FuSb5fs-6VUYXBEH1yZ0qrkGxUrS3$qD2}P)ax^C}#)q1!T7rXh$*x zgLWK%TJ#`skckTxHQIyR2)YIBsGyu3Xb(KXM5T~sCr~(oObmNhY+&d zgTfJHV(7bKyGuK->_wPpcdi*8*Z$@$c5VdD5&)Yx;j=v~uKmng>|8Iuvq6{$a^vZX zjo_Q%_(j6(juSZV0Bj=XReOdP8TKGI@`;4mfkF#mA}Aa|c?KlQzw3%EXa_ndypS=r za0KNUPE&yY;a>Zx?n7F z^Kb8GotCnHa{PgP#Y}b3TnLf{h2u}&67a2Spj)^=r_6w20~w>o3@98g$lD(PxdLIGsr{8R?;5*V{cLc)2HouiI=^k#>iy7s4Uz@9F-)oqe7BbbE9d?z1kN1; z=>fYjN)CLtmpCiu{>waTpy?4L3kt`JXYxQN!tH1GoxZP@!2M$&J)m&ZnAr(B5pF-5 z@AQ2&O#J&1F$2oiZ3;O~ARnAsz263OiyCqmg4oC<1;|8jT>qYT0CZE^$<_O99;{JB zGI5J_s}szPJ9yUEDG|7T3}m7~xw-?)ji8hG6j?cuOe}xY;RFiD38`-TOPKiWL8tkF z+=YzM-FQO1&w(LI?m&O4+x}uEetTZu=}6%?$D#`y*Pz?$Zmm(YS6_qw{xOgnCAt=a z^ED_}++3q*ueN4CG+%>cL2mrT)(XCBPMej}el3CX1VMU0ZhUZG!2xu`m=-Ii{TiM% zNa=B_bt^c}fMQ0_ce)+u<~3v=gV^Z44k%Z50Oc7_%n0~Sw*%e028nCX%}1cPE`i=Z zW_oYNo;ifiTLri5CqVBXGr0%3vkYOP#qVOL?E76#p!=mj=Y)bz%>=m%86&$9FKc3Ms7do z<}T3rmIxECSEPgE8gzr&96itd8bsVb_QB!^IA4Qq7@Muym3>h9050o}X?G6fl$ zBzw8!qMZ;C_m2fI1UP`)2)YmKQprU-!Ry*cZd4KJb^?VX=;klb{bQMg&#gT$!)c=f zC>%j|mVxdc%Xk560f2n1cd!Q>*C027?h-2@e75cZ3*j^1d<}BrG(AuI;`=k8`5I&* z$c>=%NXq?VGn_U$fYRe0P#T8bKZY8PS@*lZDLnke0Xr7LXA~a*h2w{BYr!cz?8N~) z=6MFty6~TB9JszNEa?N^?PWy7{bL|Kptw$Oe-6Ie%Mg117{rYrSsURZC$_d8r&Px~ z`xLId*#|ne89C*E*vP2|q-VnExC0v!PB^4E-q|OA?ajW2C2mM=+|-)xo3TLmkM*1if#z$FEXa)~R~9-|INsTJ8+w-*$fw8{-Pa&DUPwwk0P+{;<}T%H zZ=m@aWFjaW?Pb!zCW1~*XC`p}7)TE&9Cyeb2b;J&@ZmnD6Q0mK1Cj;h>n!_Zr!L1k z`zD@(+$DzWJ`fw-jo`Rud3K=F@y@;pr$THl2&W^N_`A5>3FO8GP|RF=WB0HG|NUbi zR|quZIe^>Kml=_@}rXoM$FE-q|-5baFa@ zI|V?lFlfkg0Oc9bJ#JG#IpTyTG|x2MdAuJK*9nXJold?_+-C;8OAO>LWQ^=akRDK6 z2bleGIPpGlpQ+oe-SO)ykxcY?Qs9)()9bY0ed0dQZ4^xe?jHl0IAK@efq-K-9Ol1I z+y}aiqA@WX$;AH^sZKkuwL6tS?-Fw-aDN2I#0}7`}fxf&0fmdO&Wx5Lj_w5%kWoX^a0r^EF5o6plUosZO9fu!47g+XuQO1vyqg zZ1k7`hhy{g15@57?hD%eZ6D~C6oeZ=aozne!3lKpm#G`%E-{cP$Qa#3P+UiR{&Ar8 zed0b7w_Dbrn_Lhk7ISwv!Q9vcy-N()G!Prz#E$I^4gpX%HZJ~S*OeF!&DS7bOCIcX zx=~f&ln1?kES|uD;|-QSSHQR+rNIIclq0=k>zxC8#X zYd|LcX#5M#*OMXX!~U4VEo+3Yr4IIj)8qN~iTnB!!|hWD+&>03QSgofC_SEgpSZ6t zG2A|R@gJo0Si;=_&NDyXC+@S`{S9;@4&L4{$ix|-a6ERy;m7;LeYU&5fo{Zs<{8i} zSD?5S=9=I%EA9AJ^>aJHH#C7_0~sU73`h?st`7t-IL=HvzE$nqPVfy)5MP62XVn%s z1w8F_`q3l0Re*tE|2ZP=Qre(eaUdY{p2PPZ(XIRp4ExV+jzw~#{P7egA+8Rmc|CVF z--6yHhU`8N8{Lf?j@>*^u&}{lZqFU?on_zu|A&Sn#El8yxL%v)z8Q22*P%@xH-St+ z#^@&A5c&ho*K5+;H-m2BI=JcMCWNm+Zd4a3aPpfg2fj;;n0vE8Zv3#P?tt%HIg<;U zWA}sZ%|e(63dc3EDNYXMoLkr!81`Qw;{GvkI11f8U|-I;g_VI}|K-iG&^!b3H7Kst zMG~B(-m@6*-1N~18Kb-L z#e#K?;q>=#^?wdH}f;l1o_yW z?Qqprgo#{IpcX)f6O-Fk;|H5#?H>|x|JaWO4;?`1k%rYIXwH>wV8u~!TusV&s5!cY!8a-#Krwi``;(pl@odY7$~k2 z%zioSd!J}m2EBg_;%ktJpn3*WUr&FZXa_27`H8rH3|!9~yWueHeWD$xwB-|vgyw6I ziJ-a=R9`2(PqgbN^8PVUT?i^46QOsOf$kqexDi%gS3~a~YbN6UF<5fH^S;`&^=wCIzx)Uou(iYJ3#eJ^L0=Qz|IDGXBomoSbYsLu`My&eg=Vd56DDV zeO>!L(XKTy+#VEK2oquT^`ZBPcA(q!TK(|1%|Ir?>g$8=6YW5^>$Uj7+GZeGSbcp2 zdjFU_f%YRv&ktyQeHeQGm>j(Q2$F@>*XQ0R+D%>j#}3q91;qw3Mvoa-eSP+QqTQ6m zf9x9IZCudJN1(U{^{+v5|@VsoCr{oWuwptuJ0uR*tkZ8;rcb51xNnhQa)pnf5! ze+{}fYaQqoE&_c8kRDLK5Y$%y-J7*G@ZmntUB!@?0m*{;uAu%k=*BA0EnNIW+&>2D zyMp@H9gcVGK(}!5U4!*!KqlUW_OC&=g@NuL%Oc|bu>;WlHR!f5(EVeXr(k_9kcl8S zg8J8Gj(6-p_m6D=`JBL=R3JBk`q!n<`^VOUdc@#;v_{k>eS} zMviNc9#A+!`>uANu?^7O*@$oi#WkpZ4GNQ-Q{a2q@!miRG7%itEYA*r?gPs{6|x7> zzXr*|`q!X%n;iJij)TA$07wt4e_iEx$8J*KLpyf(7yw8X)OQ8-uhSjx*nw_&*CgWp zFX#5d$N1F6??fo~2xPJ^b z9uB%AP3pS#{u?D1q3v*xiLmi-&}~ql8@1{QkC8gS#=}9kcTLyx+z%R2hNK>li6A$E z#&NgU$k~HNp_2)Z<2r!c2pY!)-DAZ%&tQKN@;I&oC>%j!&8uzX?BA7K+y@#r2IXaB zjGV7Qt^kGOkIicitg?}_e_L{Kp8)b$vjZruLF3^dAJh?f{}?!~TaF(9-9J_fy?+eh zYuI==$V9&v2kiKWxPJ^Zjtg=l$V6Z0on;6UL1WFJa0JB+XjbG4;duoI&{#7l96_$& zxUOyg8F^m80X7~Ek_Fu*RzP^}!vQuP4szoRJx}|5ec=#F{Is2C- z7w!13YeQ>S(2Z4~xCYH%gKlR6&C-ExXaczl86&$9qz4q&p!sXi?M$j`_S@Wr&tHRN zLG!Ml`RmE4ZuUQYrtd3b;>TO|fb@XoT|skklTzL6fA~z_SIWeX)dk2Y2gF8CJ+S#}kSl)sOt%BAEs;^#Zz{dqDnbi9fIpv>FN$*C1KgdNYuH#!}Drg%MbT z1kwXrZw9(o%}DCmzEJoYB#AYZ@IIkzvIz&a_A9*`SB>!d)gc&T%4Ul@Fy z6i5~nj-a(%pu4@|nCkXTAh4DTqz4p^ptW3}yS8GP>h|@+*K&bmL2(UQZw7K>@U=U8 z^a-pt1L*<9HE6vV$c;hQ?(ETnuQvn9g4Ria+z67@HS)9jsdJ9t{bQhYQXn^i!coV_ z&knSX4iPh;wOpWZ1o@yh{(xORfpvQzSAf=Xfx;1VA6QTP0lPf-x;>CAY`qyM9PJ?M z&GsOd5+F8mNdeLWTW-Gn+wcUF~%* zzq9crygnS<4tGd;23qTCuXFjGjgNT?w2ccg5wxxuwAK}Lx7V4SSN6sbxPJ_!2ehsk zwAK}L>(uF;SN2A~gRON1$-WP&a)PeMwFj-e2CXVa_A!W!>}!yo0}Hn9hpxv3-#>Ol zP!7qBu=U{}H+q`4>;tWQ2AP74(M@~+T^|l|qlbCRK6B(X!ww)fZf&UnhhxyY;(bpE zuWNPyxe>aq**@@H@xCX>>zW-v;aKys5^UmqLAiY&g~RaX8IZ5R;duVgevlhMcb0t+ z4uj74fMh}W8niwP5wxxuUYpW5Vm~9boIjL9zKj zILz)5@;ZA5*!pmg8?DS+>_F@Kk>eS}#)xa^`f!jdEX`Z&ypZ<-fZYg6k09B|cg1!k zg!e0e-3UsLAU8(5E4C{}-ml;Q3P(_$0hzc@P|l8(@SX}tINm-E+NEI+y0eT0zNZ3o zml!Cnp*u)q8x&u#yT3s31!IHa3&sY;7mN*x zFBlsXUobYvJuo)NJuo)NJuo)NJuo)NJuo)NJuo)NJ+QmKK<k7mMiGgZshzgJh z=x!;H9vB-{1xOZja}-DgjE$-SBn!G13Zw$YMpXfl1>O1tQUPP5ssPD??sNjFfU!|k zfMh{8Hi1;Y*r+N%vY`8zKq_EtR23ju&}~Z~6)-lc3Xm-5E+vo(7#mduNEUQc5=aG% zjj9493lagTfU!Y*NT`EYpxa|Ww;Z9f5h_5kp!fi(KxRW!fMh_Tpj(cR*&x*j6(Ctq zjDb|Z*a#IM8IUOGmLp^~stS-SC{95tU~Gg6kPJu^bjuMk8&w5J78L6s6)-kJ1xN-Y z3cBS8nT@IfBnwIxAQdn+LIp?$BnrCa2$_wl0wfDcIUp4 z6(AXqDCm|WWHzb_kSr)ifK6(AXqDCm|WWHzb_kSr)ifK6(AXqDCm|WWHzb_kSr)ifKJIl%tloKk_F`mkO~+Zp#mfW5(V9I zgv>@&0g?sf2#^XG8=(Ru0}=(@a)iuARRNL(JIl%tloKk_F`mkO~+Zp#mfW5(V9Igv>@&0g?sf2#^XG8=(Ru0}=(@ za)iuARRNL(JIl%tloKk_F`m zkO~+Zp#mfW5(V9Igv>@&0g?sf2#^XG8=(Ru0}=(LcVsrI3Xm))or6@s*a#IM5zy^1 zpj(cR*{CW&vY;FRQUPNlRDfhaqM%!jklCmzK(e450a5{DBUFH7K%$^qj*!`?DnPQJ z905`RVzTaJ*~s476Rpd0~G0b?UnfMh_Tpj(cR*{CW&vY;FRQUPNlRDfha zqM%!jklCmzK(e450a5{DBUFH7K%$^qj*!`?DnPQJ905`RVzTaJ*~s476R zpd0~G0b?UnfMh_Tpj(cR*{CW&vY;FRQUPNlRDfhaqM%!jklCmzK(e450a5{DBUFH7 zK%$^qj*!`?DnPQJ905`RVz^p4C%RRNL(rE`!97#pDiBm%lU1~e>*%tloK zk_F`mkO~+Zp#mfW5(Nz@A+u3cfMh{A0;B@QMyLSEfJ8yJ93it&Re)qcIRc~t#zv?B z$$&&bw;Um}QB{CsK{*1X0>(zD0Lg$vLAM+svr$!mWI;Isqyol9r~t`;L_xP4A+u3c zfMh{A0;B@QMyLSEfJ8yJ93it&Re)qcIRc~t#zv?B$$&&bw;Um}QB{CsK{*1X0>(zD z0Lg$vLAM+svr$!mWI;Isqyol9r~t`;L_xP4A+u3cfMh{A0;B@QMyLSEfJ8yJ93it& zRe)qcIRc~t#zv?B$$&&b=^dGkssbbnO6MRIFg8L3NCb3y4Ct04WHzb_kSr)ifK6(AXqDCm|WWHzb_kSr)ifK6(AXqDCm|W zWHzb_kSr)ifK(zD0EvKZj{)6sgv>@&0g?sf2#^XG8=(Ru0}=(@ za)iuARRNL(JIl%tloKk_F`m zkO~+Zp#mfW5(V9Igv>@&0g?sf2#^XG8=(Ru0}=(@a)iuARRNL(JIl%tloKk_F`mkO~+Zp#mfW5(V9Igv>@&0g?sf z2#^XG8=(Ru0}=(@a)iuARRNL(6(AAN?J=NRj*!`?DnPQJ905`RVzTaJ*~s476R zpd0~G0b?UnfMh_Tpj(cR*{CW&vY;FRQUPNlRDfhaqM%!jklCmzK(e450a5{DBUFH7 zK%$^qj*!`?DnPQJ905`RVzTaJ*~s476Rpd0~G0b?UnfMh_Tpj(cR*{CW& zvY;FRQUPNlRDfhaqM%!jklCmzK(e450a5{DBUFH7K%$^qj*!`?DnPQJ905`RVzTaJ*~s476Rpd0~G0b?UnfMh_Tpj(cR*{CW&vY;FRQUPNlRDfhaqM-DS%tloK zk_Dx6kO~+Zp#mfVx;+MT%MmggRRu^Elp{bYU~Gg6kPJu^bjuMk8&w5J7L+4EDqw7c z3Xlv)6m-iGG8@&0g?sf2#^XG8=(Ru0}=(@a)iuA zRRNL(JIl%tloKk_F`mkO~+Z zp#mfW5(V9Igv>@&0g?sf2#^XG8=(Ru0}=(@a)iuARRNL(JIl%tloKk_Fux22ufIBUFH7K%$^qj*!`?DnPQJd&58~ zU~Gg6kPJu^l*W0Lg-K1V{ypjZguS0f~Zc z7D8sDssPD?as)^PjEztMk^zZ=?k_@SqpASOf^q~%1&obQ0g?fUf^JDdW}~VA$%1kO zNCk|IPyvzwiGuE8LT00?0Lg-K1V{ypjZguS0f~Zcd_rcUssPD?as)^PjEztMk^zZ= z?v+AjqpASOf^q~%1&obQ0g?fUf^M%uW}~VA$%1kONCk|IPyvzwiGuFPLT00?0Lg-K z1V{ypjZguS0f~Zc;zDMlssPD?as)^PjEztMk^zZ=ZlFSDqpASOf^q~%1&obQ0g?fU zg3>!O8&w5J7L?9GDqw7c3efFWATvO2L1v?>0Lg-U3{nAOqpASOg2EM~0>(yF0g?s9 z9!Ld@jj9493rZs(6)-lc3Xm))C4yAI*r+N%vY_-1QUPP5ssPD?aurAgjE$-SBn!&B zAQdn+stS-SsDuEifU!|kfMh|T4N?JPqpASOf*}^0Il^K#iJoG8UmvsFd71* zAut*Ol!XBEP0ahp4C9LnGE$2`Ly(jiK0vzdr_0-)V@$WTVw44+I`Z%T{{z0dzYavr z`*Psl|NjnQFPR+AZ(s#YdE;;)XzwHfgW4V-jH+0{k%7VFFcNlVU@(DVWR(r}pz&bP z-T;^=rdco<5|1 zBoemo41s;oAQNGFKqfMZgzY;G)&nyU6ecgvO$VDe8+w-*C}kjH&}x223Tv@NqI2-5>H@z_otNU?zgxcm$drxkSS3Kt4x~6%ZRe zW?*_iCUS~|*@1ixG7l1t?3SJOKW;es`f&Bm9tW@ z%N)RZKxTqWT+k4702J4tyPKS(p6zodaQ_&x9+1BrrJn6`1M7jA2(qtg{)YV^6X(Sr z*yl?4922k`L3%(Y&W%5?&jqXpW+EsYXUx|;05Z`5bW)5i!LwEl!1RDjv^VnG2l6?{ zJV-c#^60K4cko?eEZ6SXI1@e(<^W6&C>)uu-LV0M7Q)0m1z+vwK-~yBac2?XGiwgO z^nlz5x_=CEXBo&$P$=7S_&7Ar->@Gf%b?IbkbR*0$LB$DaDjXdG7l1tE4~XK5Z_b_zDtbRcly2t0{4%BOoZtHxq``e z`aV!-Axs42(PZl>;QP*Itln<}@;S_HFdE&BFg+k&PhY*?2IO;uiAhe{4$@FJg60Hz0IA}B{_fc3ykOyZs3;Fw?r&NHg4oc5at z+&>2L7fcVx6)LQp_8Y-^U?vtjX*>AOnF>zf?7q|OKt6~07Dl7{8m0&2MmG4JWgrt- z=gtS`(Y@`L9YFUzJ-Rnz59oABm`N}i*+gVLp!=R4-kY%pbgL7{JO&1k?5+lz1IpWX zIDlmDL(cp}DR)4oqMHcQv%yAg|Gkon`#@($B1}BjwERH)%Q&zbdFC1H4|#C_Z@vb( z0;UJ#3hsFZ`-8!HKxTquvw{zS^EK#xDbU%e=>*Q;MAiceDbUSbX<$7t6G8S}PBJ_I zk_DY|3i1WWr^p!H*DyUGH}YTC-hUT-wkXU*P?+5Qyzl@>7Igm@$mhtWf!OFK!t{W` z5p@3;$mbyQATa~Vqvc2TfKAlDKf`9Go+sXO89}~==>eIjcYlTr=yY0yi6y6l9qxW! zcwoJa9QYJm5d!y*flP$yS!W{$J_T18tOsN!NLEi{v%~EqL$Hb5^9=0c37lJttOsNw z=ycyWupXF+r+%CT=W9?ng3eoAdT$2a`Wj>+Ob^J{pd7ITtOsVIiN4jxd;taSj%vYqhU4?0yF*~cI@ zvagZ#v^d_`$9lqZ|3vT^)-V%IE-l0}3sK ziPqjl4zpwT8~~*r9_U?S$fkkV=qAGSfKm_lwKt$s(81$A5MRHXc-CS0BmV<6j(7I4 zoba??MBtoxP|U#eR6E|;2fDLtAy^N{l_1&46>l7NNN%&Mb-c6hig3C;!wLNNk0I*; zxdN0U{vQYFftmPe;#mjD%vx}s0o^6WLg2i9kcluoAYX%S8W$Pvu}3bLpxAtfy`rI=)UuKKWHS*p_<9D<$dD5htA+TF7Vc_ z$aUT48G$6v?YiEVq*RK+ygajj~$xcC+=%q{AXV`f&0fmCc^YIzE9lOviQ%w zF0dYuD?zfFL6;5)>2x?ud=I%x%#pzT5y*NbyieRGCKkEh0jvjRqTZp;;C$WxK5-xD zRu2aP_m6>0gz4#fpSUl1edT_8upXF+>Oq$d%)FR%p!0nq$o2a>2;9Q~G7+Yy<9*`3 z&cyKj?O;7H6G35Oa`+6`MAzNlz_+M@@(D6V&NCnrVR}F&y6pZ2_BqHrNX&rpsI~FC z10Y}Tb%op|hHM&$jcy`L56IVhTyI%}e2y?tYHpK*+2Jz>dfzARYartOF_0T!dV1a` z?yHC1KZY=|<@;TSh0t&m5sS1BAaE}X$V8YPkgtWsBJKUbdO&7^WP8*9gYz}WzLfQq z_GV7_?;k_f(+!DhdsDC;xQXBII&kWAIDqoZgv4l0flP$y0lC6+_cuFHupW?!pgXBR`TD{JR>$xYwVU6{ zFE9bcEjmVyYh*oPCu%ppkzZi)|9?F+UxQ@lMU@<=5Pj+J`e)Z>1_p-x*NM1G38v@O z&#uk?|Nq~24Xg*|M%9Pc4=haVc1TiH-h3T=3l{_4vIpb}n4Uyc<;~YN$L{|Rz9R}| zqMzwf#I`JunkN_HDPxJn-Q5+$|tC zGBPmWZR5h+2-0)^_S`KXH-bV7WF7+pNEQ?(MnRVj{9e_x1tbG9l~ByU^!!@Yv;`WD z(7F(0A}EhW&--#<>gg$4N(;||d`!@dFg;UFPuWsZcoux~8p4gMFSRhy6C02b%hKZMm{J)*f{88X*&5dK&w8 zZMnQT)*f{88pu3IIEKGuas<`apL?c);@WX{0PYx`wjJs>kdZtQM* z>@Xv-+u_{w*<0>xjV$qilCR`$0 zSQr@WuY%J*eiLDOjJZU%Ff%aNgF*{r9s@(uoyYc|d=09vLAPodd4lhdL`mHY3=Q_k zZba5o`99Ik&=XwlL-RFA7F1_|>TA&5UJkpz?UMwTBe>m&tOw)@``zF6Nr3f$TnUne z)z>xe6T!Djc7V$|{3gQmfLsBs3qf0z86dtkfY#S-(7VLe5x9R0)92S7dm-6bYP;QldWJ@xMs?X02qk0IRH4y~`t-zVC2B!=5h z0JmZA$2Ck(87QO@!|nUQdO&7^?CXct*Pw6&)z^yN`0pP>)&mMh&>f=+U_EdXp>;1P z^~i`t+8cq}g81Fo57h%oJdg( z-{L=Z?eI44Kh-z~P`-xtukEZ(gZo@~^EI*_&`n&Hr@?(LXubx?g8F!%{&l0{9Xn7T z4|LlSvim@6WH%z~0o?~S8PYFAGO_Q?!2?>EwGJ(i`=#~^fcqx6!x3a6Oi#1p9Xn8e z7jkDAC>%kuu)Z?LL{N`$3E?}R9bkGuCW89ci@|zeCc^sHpgYo7PI&GI`2yrqWQ^`> zm>$r5V4&N(C&BxLAUA@-5!Am1-TWm88K=OT3z7A-Io`1ofQ(Z>b0J6;lt)4RYmkYc zTev_zM|K~GjqXO69*~KkTev_z2l<(S0c0YquM9G=8+w-*$P{FZZX!$%$i%L|hoIZI zklgqN+P`jcykmE}#LZrY!2M$&SHSduQrxW)H+yNY9*`?RvatR&NEXyro_#t5@4W}e zdO+zBG1C4}&%!9ZQG;RzX54RV*uD$;bcq|cj zID$-s=>gq31sb2e4b}rP6C?{84+qJDMume2+&_k_2joW3sBj=y56nc6eW3Ahkcps? zYtU#ka_R=LkyALxM3^3siJ*~dP-ub7gZLU0j-c^yknDq!i~EGY;5h>PzJ}=mg%s~~ZTsh7JunktW7{ATLF3^f4`$%a z*C02-^ngqRjfV?^^}tMojctQu1?L&qyMyOi@VgPF2NY5Q^9=0Wz^Ty!90F3z3-GVe;zM3^3siT{1T^R7rH{z1%N+k@tY_krjBaEBwv6)-&@ z6G3ysd%=1@{szg0BId8{L9@6o!1I&%O@!$I-3JDm#eELe12Yk1-(JZ4wS6OGjvepq zBOq76^nmW#0?kf?W}HFhL1G3JCZPFikPi;=tl0^CVueGtx_=DhbC7uq3{RFm1LteUmn9CM+n^?1 zyJKSkUOR?6g(K?$-RLyo+8rBnupW?^AX)p{$M%EP&VcTuGBWbp_k+OwW5{|yt}rz6 z+xH!;2WDc`UdVbgkbSe_59|ZowgmDiGDh|_$V8YP&>c}T;}7h!g0JrZ$H|z)b;J41Xeb(SLPx!+TyLM-f8CVa@#4QD1?O|>N-9Pr1!2M$&6JdHlCW7uC`vcYkGtrX6#{skk z59I5~@dxY(t=j{c2-5>HaZ>yNJH)y@kZd$`y&1?vQ0iU`UMGk@W?*_iCW2D;BCsBq z8*Mp!9Bi(!g7XY$eVZz1wHKayfI+T+=>eJePv@MS3Rn-!#Ipro?WNVi!6rI0)!Bi3 zfta^*Sr6#8 zB$vzYY;3`LU?zTbGu{9G_9uIgiPbx=>!UcRXeZj4FT(cnYff|-G0z| zT#$*Mgv0jj6qLieE(K&FOb^IJ(9K;tzSPWMb9ME4I;KJs>kdK2Tb4#~!rK9u&$Sg~RNQg4fLB zHxZ@>Wa0^&H()&= z6aWAJ56;)1mC~RR!KZEy=vZ3t-C-a;3?r8m$a+BYTi$RzAQM4;1JNMdFna$O0|Nu- zJ{f6GA@Epy-Ktf#Fg7S`VRwIl?ze%lLHFCh*r5AuU~JI+HZV5mej6AYbT18z4Z7b3 z#s=MQ17m~kw}G)i?t!sE?t!sE?t$I?1#%CJ4RQ~R4RQ~R4RQ~R4RQ~R4RQ~R4RQ~R z4RQ~R4RQ~R4RQ~R4RQ~R4RR0c?k|vgU~G_kU~G_kU~G_kU~G_kU~G_kU~G_kU~G_k zU~G_kU~G_kU~G_kU~G_kV0V9k+yi5S+yi5S+yi5S+yi5S+yi5S+yi5S+yi5S+yi5S z+yi5S+yi5S+yi5S+ygQTl+!@&fw4jEfw4jEfw4jEfw4jEfw7@9xYrAE50pQ8|JdmL zV+^451G^s#lzw1rQ2K$fLFom?2BjYu8#s;Nl7#ozHVRwIl(ld+= zO3yGh$UQJN$UQJN$UQJN$UQJN$UQJN$UQJN$UQJN$UQJN$UQJN$UU&Tzd-JRu|e*E zu|e*Eu|e*Eu|e*Eu|e*Eu|e*Eu|e*Eu|e*Eu|e*Eu|e*Eu|ej5+yu(+klV#T`~6@$ zOkr#g4XUjnDnPQ}Eu#z!3@|pT3Xm-5<|vS(yF0g?sX*aT7mW2347$%5`<0;zzpQB{CsLANb|RKVD%DnPQJyOcmG zU~E(sAXy%eGy?+zjE$-SBnuJ&DT1*g|8z}N^CAQ_M-=$0d7HmVAcEGSMvDqw7c3Xlv)6m-iGG8@&0g?r!K9C9+8=(Ru0}=(@a)iuA zRRNL(rB9Fw7#pDiBm)u!-ExG?MpXfl1*Kq+3K$!q0weJIl%tloKk_Dx4kO~+Z zp#mfW5(TAqWHzb_kSs_9qyokU@gXT0Bm%lU26W32G8Sx`C$serK&DnKHj+haht93it&Re)qcIRc~t#zv?B$$&&bw;Um}QB{Cs zK{*1X0>(zD0Lg$vLAM+svr$!mWI;Isqyol9r~t`;L_xP4A+u3cfMh{A0;B@QMyLSE zfJ8yJ93it&Re)qcIRc~t#zv?B$$&&bw;Um}QB{CsK{*1X0>(zD0Lg$vLAM+svr$!m zWI;Isqyol9r~t`;L_xP4A+u3cfMh{A0;B@QMyLSEfJ8yJ93it&Re)qcIRc~t#zv?B z$$&&bw;Um}QB{CsK{*1X0>(zD0Lg$vLBmPNY*ZB>Sx}AuserK&DnK$IQBZnEW}~VA z$%4{3NCk|IPyrGF-5vwFukpfUyxOKr$dv(2x=`8&w5J7L+4EDqw7c3Xlv)6m-iG zG8 zSx}AuserK&DnK$IQP3?%$ZS*~R23juP>ukpfUyxOKr$dv&@D&EY*ZB>Sx}AuserK&DnK$IQP3?%$ZS*< zAX!k30I7hn5h_43AW_gQN62hc6(CtqjsU5Eu@NdjG9XdVEl0>~R23juP>ukpfUyxO zKr$dv&@D&EY*ZB>Sx}AuserK&DnK$IQP3?%$ZS*(zD0Lg$vLAM+svr$!mWI;Is zqyol9r~t`;L_xP4A+u3cfMh{A0;B@QMyLSEfJ8yJ93it&Re)qcIRc~t#zv?B$$&&b zw;Um}QB{CsK{*1X0>(zD0Lg$vL3bh{vr$!mWI;Isqyol9r~t`;L_zn5A+u3cfMh{A z0;B@QMyLSEfJ8y}hat03Re)qcIRc~t#zv?B$$&&b_lF^~QB{CsK{*1X0>(zD0Lg$v zLFpZtjj9493rgo86)-kJ1xTclfq?;Z%MmggRRu^Elp{bYU~Gg6kPJu^bjuMk8&w5J z7L+4EDqw7c3Xlv)w1$C!0hx`e0wfE{5g-*XHbMnR1|$l)JIl%tloKk_F`mkO~+Z zp#mfW5(V9Igv>@&0g?sf2#^XG8=(Ru0}=(@a)iuARRNL(zTaJ*~s476Rpd0~G0b?UnfMh_Tpj(cR*{CW&vY;FRQUPNlRDfhaqM%!j zklCmzK(e450a5{DBUFH7K%$^qj*!`?DnPQJ905`RVzTaJ*~s476Rpd0~G z0b?UnfMh_Tpj(cR*{CW&vY;FRQUPNlRDfhaqM%!jklCmzK(e450a5{DBUFH7K%$^q zj*!`?DnPQJ905`RVzTaJ*~s476Rpd0~G0b?UnfMh_Tp!AN+MpXfl1*LP4 z3K$!q0we;u%?EVn4>B871xOZ@BS0!(Y=jDs3`i7ovk)>HRRu^Elp{bYU~Gg6kPJu^ zbbk>t8&w5J7L+4EDqw7c3Xlv)6m&}xG8PhQUPNlRDf>3 z0+|7F3o;v31xOa;V~`3M8&w5J78I@^6)-lc3Xm))_CP9NY*ZB>Sx_1QserLjRe)qc zDG{Us#zs{Ek_DxAkO~+ZRRu^El&e50U~E(sAX!k}1*w3sQB{CsK_vu81&ocV0wfCx zZIB8W8&w5J78LRz6)-kT1!%3`C>{-g(GVC7fzc2c4S~@RpezKMU6~l(a4|4|)@p-H z3eL{V1Fhizv4<+oGTdr=+d0=>+Lsr6>WEuT-9dM@f`gICzYZpF*ElZS)#%7u_XxB! z1BVwudnXYX)b;>jRK@hae+;xP7lc9Uw?S*{7#I?{YaBh;3J&steFJha%#9#60)tj~ zLwwL+kE{o@YZRsfLW5+N?P_!+)kK&c+$KgP|2hcUH3P8=;XaT!x*I_zg7jcF5#(!- zEJ!EBG!Tj3M3^2-6Ww#_4uWK%zJ{J1hTlYFJ+OP+Ksq28CJS{VNhX5yU^fvKCJYP> zM4JfHgWE(>eGM`ZqzAi+pl}5F01^%$6699gF@qXXAoUCk2$MnS5!u92@zniq>!08~ z4+dRNiFoS%H()&=(?PNzAHdu=q3EgInOiA%&%s02(_i$|?lf2r$V8A2kWB=ML1GBM zuhI1&d<`-YMqNib89O+?p&>PC<(C`=H(#xxCND!Pg2dJy>=o17y-$EXaq)gBghpnJ*Xx!fQDE>20&c}Wx~%z0rMLmVE|%->;Taq3}S;Y zhz&9anGF^r(oB$En0jOyZXQ$+&PQ?&vR;rp2!oV^Xb^_6K{NvcWXC3`z69;)1Bt=d zAQ}{E58!(^L9!rKpnZEFHbMnx7anLA9jIl6%tojH$$<8^fn<@{2o<26YoMKHpq*pL zY=jDs3}{anNEVrmPyuQ!fOfHf%t2-&RDfhad$B;W$ZUiP&@L;`E-8>X$ZUiPkPK)K z6i61CjZgvF-2`$W$Q)!gLIp?$w0{XCi_C_p0EI6#u(MT6XkJNXNlt2to@1CNL#jeR zQGQlxatT8TLr!r_er`!>aY=Cuh%_*aPs-0rEvYO>HN+6mE6z?~(9%mP%h0R=Q#DSR z`DK~KnfZANPGOGvPGKGjZkai$#R?iA=|qUC#2TlZ%#tc&7qF;t3Ru)QrN%iiCr80Q zO~IwKq*B9B*GN;rH$Npc2c)VZ7sQHBttiMZDgmiS5vXy=EJ{r-iBPZr+Xm7Q0a6rE n!(f`2mzfJ<=ca&}pqV2E22gmy!V$yn9@$K{OB0bwOTD0H%cfq?;v8}`E_zx=Ovg0T^FgFT4-6(VO2Vx!^)d#C)o mR6~V={9;rII1eIUlwSfDL1lpCjR@#BQoyg@n1Fs`Jo*7<3@m5> literal 0 HcmV?d00001 diff --git a/build/main/models/omtests/test01_bonetype1/test01_bonetype1.skd b/build/main/models/omtests/test01_bonetype1/test01_bonetype1.skd new file mode 100644 index 0000000000000000000000000000000000000000..60c2037feb1d6a2422919175461abaceeb4548a4 GIT binary patch literal 39940 zcmWIc_H|)pU|=XoEiN%I)GN+TVIT{zFfcGMGcYhrVPIhRz{tSBFo#5AVCv^EFgWGs zr5fVVUY=i+laiF5mx@CT$odcl28INXzo3|bp}`)8!R9Lz<(EKgQYgqT2D6NCmj5!vU}Eevg4<~Xx6>Ghc_3kso%q~DjGe}CJB`7127CJ`fP&5_zBr>GwFp-bf~?1h zEf^UX=0Rma$%TcVfnkXb1H%+U1_l{@hy=)OOb{jmhz6w%5En#)(h7(TqCsg7#0Jr9 zAO-^i1BhmavOzQllntUep==P%1!aS1ZYUc>^FY}k8srWT=4D`D;A3E50I@+d$W0&& zV)HXFfZYh9LGA-#5L*D6ra?5wtso3y3oB$7#Kio5DoG(2!q(-3=9k) zHi!oKAA~_{2?hoR5F12;!UBXrY*1K$*dQ7d9w1thfq_Aafq?4WdEe0>U7+ z2?GNIhz+7a;R3=SwkZPx1BeZxLE!?zAhsC;0|ST+qCw#T!XUOe0|Nty4WdEe0>U7+ z1p@;Ehz+7a;R3=Swj~1t1BeZxLE!?zAhs0)0|ST+qCw#T!XUOa0|Nty4WdEe0>U7+ z4FdxMhz+7a;R3=SHYhAWY!D3!4-jq3z`$U~z`y`vgJ@8=fG~({&%nR{VuNT>vgP1`r!WgTe)bLF`}#1_lrtM1#Twgh6aj z8wJD$(V%bvVGtV>79ci=289QR4rO3q2xDMi0I@+dC|p1o#14ms9f$^n3kZYQ5ey6r zAU22wg$oFS*pUnj3?Md$289aU6RC@es15Df|s5S_@tz>vhizyM-{Xi&I-Fo>ND4LcAG3KtLtu|aJY5F12; z!UcpuY*3>J#0JrzZ~p^7{tzph8>6og$oFS*aZv>3?Md$289a< zgV==(3=AMPhz5lV2!q%~3=9k)Hi!m=3kZYQ#S9D#AU22wg$oFS*d+`M3?Md$289a< zgV?1E3=AMPhz5lV2!q&V3=9k)Hi!m=3kZYQ<30I@+dC_F%PB?ALP6$1kUhz+7a;R3=Sb~QBYKr|>^Kp4cXVPIeYu|YH_TtFDa zu4Q0g0I@+dC|p1o#I9ptU;wc}G$>p^7{sn;U|;~TK{O~_Kp4bsU|?VXu|YH_TtFDa zZiMz}Kr|>^Kp4bsVqjnZu|YH_TtFDaZf0O$0I@+dC|p1o#BO0=U;wc}G$>p^7{msJ z1&9rzLE!U762Ll5Ghz+7a;R3=Sb|(V^ z1BeZxLE!?zAa)l60|ST+qCw#T!XS1x0|Nty4WdEe0>U764+8@Ohz+7a;R3=Sb}s`1 z1BeZxLE!?zAa)-E0|ST+qCw#T!XS1(0|Nty4WdEe0>U8n1O^5M5F12;!UcpuY*1K$ z*dQ7d9w2%m0|Ub(1_lNY8$^S`1%yHD$p^7{s2+z`y`v zgJ@8=fG~(Xje&sy#0JrzZ~>xIX289a<30I@+d zC_LseK!yWAdO&Ot4Kf$R2GJn9L2M8Wavz8dqCtKDu|YJ*pCC4f289KP4WdEe1!99} zP?&<)AQ}|zAU22wxdX%o(IEFRFf{B3brDZaP&9;$2|)UVATdyX2qgCR|NjHpshxHV zD;C;Bn3V5-aOvG18}k-BkX)SSBwL6&n7#)4J5zpw)hi@Fvj?f)E-1I}wQ!i-hE-Yi zxYU2ul;5v#=Qvos|GVOSB|ER!284#cwa!MC{Fbt_b)hiXg|pO z50~EAIGeZZ12xHT`Ij@b({4fNL$LX~1?B9%3y1AX483ZHOMSch6nl{QAouvaE4G`t z^UB`&t5)Guzj@tr`vXw-gW~GQrFS+A3=KHdKa*m10EG|8{BOcxcB=&C><+Hd!l`~Y z$b4w{XYRaW>+`PIu5Q&TTU_p+;6BA36u<1#Qud2nyR*kp>KQowNP7y|p{JimOP_($ zPe5k81IM(K{SHiZ`)0-;0H+^Z>bIZSz29J&BUt@kopbw4jQs3C=?9m3Gc)}I3)Vca z=bV9$H z_fzK_IQ`&K4|0Ejy!`=?`s!TZ=j=dk0;L~Z>Kpq59boP^lX_1>b8Fm&zgN|tep0s@&}jtgaW<;5qG*Ax>DWtH!|_>|K~FuoPKbrk6F@q zAmD)l*!;(96!#xpy&s%@aH-$KHXWRPI#b>DE3k6zKhCoToPKbr2bsShQtklAJxspS z_ti7;?+2AXxYUE(|6@ky0Z{nJuGw#Mca0*bT(`%i9+Z9pe$P7q3ZH#EYwXlmIroFg zA6)8}oiuO&nGaIm$i#2Y>pOiPDE;74|L?*i2ax+aQr-4HTBB(1x_Uo2{oqm`VY~vI zep*u9_Uo{6+V9|515Q7<)U#ZibIXXZ~(>cRvWqf zZue*GnWpCnPCwF~lQ7Z`^W6F1^mF3)35RVqa{F(VT-?WZT^pQ!aH%i+X?8&4`&x%h zHgfxU<{9h{eQ^MsesHPR*}vpKL8d2I{R}aG&^u&^O^&o@QJ-Y!)BVECpi7! zQV&W$87;>TY_XBsf2ZW49p80raQeZeen(KG1IYXhHgfy9<{8+>zc>I+Ke*JNd%e{G z=Kh&_p7t&GW`NTVF7-KkE`Za|W=QzhpD(!xPCvNRUwOUNAt2M!VXcka{>&E#>_Bb; zr5{}C&jv+0fa15s@y|;IQxqnLFLvZ@RrT&%1{sRUt(;d1U@9euMoW6hKsSt4b z!KHoz|2=T}sdv1y?{10Peu-;u!088<`WG7e4-_P&9;k4gz9+JAlmZ zcf7NY>4c~K^uUMU^n*)%Pv`}QhNRR3&5n2WT^3HaFFp|hPCvNR8{51Gryr1ipOm=S zvtN4yPCvNRPYS)@01E#$$2k ztjN8Mk$$@GJl+p#Z+Dpea>#w3xUX^XpMAZF;o$UxOTBqU#(|DwHymcXPuwRV7P;SU z_cw6*!KJ>n@B9IS8&wWn?-Tc>tgqZZ!|m2?Q2QB|`ksFu!0Bhz`^0^%iQ)VE7ykjL zA6)7|<`)E39GLn(ai81nZ~Mf=BEjhgmwJ%<6`HRf0EN$X=Udik>np+O2bX$K`qB9O z<3Pjv#C`RP|Jd~=hJ(`&F74a8?ieon%R#`f1P2REA1l0F}UDc-90Pb2Bj5U)&rEE`M;TkC@is0E*vT?-T9v{BBt% zLdzc=Pa%x-Q+4ODJt+Nv%Ach7iFQ7_zwHwjiv*`1TF7>eTr}cfJ9jGkv-2Dw){@_v%G9Og_G`>%? z>sb6}AIMFh_A@T^AoqjHp9$|1?G!w3?FN;Jps>WH9+ZASnrU=yg}u2gB>pQGoa;<K!XX4}jVy zMUHpu4xS9za~<0L!KEIQen9P?F2_4|eSr_{K??dmwHoZ`)7vZ9Xs|Dp7vFN55egNm-;Et_D_c69Xo+* zZ|t6xxPj9TF7g6n_;9M=DG91=?B#RT5BU`59+`0&ocm* zKe*Jx`d=Gt(f_gs^<`g|Tm+{dTffYgJ=azJhZl|Q)DgUp{0DR%&*{xHv)eIPf1${$?nk;Z@QJ?Zy?N9Tp0jD2a>VHGWf4WlL z?C-Bpw4bvEG(Of~hf95!F=YIwBh}5mg^Az(kI!^)`oX212|E7Mp6X_QoM(-lGAk!I z{oqo+89M&MGA+fP=h__`U+DPr&fI8>^z&%xGjRF=jX$$aOR;w{^4rI*dk#GQj7$AG z==d|+v=sY=@dx%fFx7#}A6)8BzmwHh80gXR{ z)LR<)*@4E~LFosV`nk~YXOR1+#~-i@VX6bCA6)8dq2tdW_4ZQF>~@03=Ns&BsfUd} zgVeL=p0hJB@&l(IT0F2A#JgU)|F-Ij}y ze(q2C2~Izt`7eBrypGEpFrooK~X2rZ-&f&fz&6zE8e$e=as#n@&}iCu=(fW_Jh=45R}^onll5HKe*I` z+}{A1|FW07{BDmMbp8vMdQkcS&3}Q+@7;ODHtSt6c>V&H`g->%_8{{?>VFG|+1(P9 z1E(Kc>Q{m0r_RNJ=Hu+0%v_O^}3d-4i5Do*UA6)7|^LL>6FHoQTOm?`zne6Zlpz;~SNAI8h{r?}Fen8_1pn2F) zJQ@O{Aut*OBOwG}doqmUiwiPF_hf+gX@K?>fc9sAXwZHP5C*Y9`wBp85DnUc0m2|Q zXkP({4WdDNFhCf@2JI^Vu|YIwKL!Yc*r0s{AU22w?ZE(H5F50w0K^8-pgkBM3}S=! z6@b_v8ng!kgh6c3z5);%M1%HVfG~&++E)N#gJ{qm3=jsfLHi0oY!D6Fg8{-IHfWy# zhz+7abt8xdt*r;`F#xeaG-y8t2!q(5eFY#khz5lV2!q(5eFY#khz5lV2!q(5eFY#k zhz5lV2!q(5eFY#khz5lV2!q(5eFY#khz5lV2!q(5eFY#khz5lV2!q(5eFY#khz5lV z2!q(5eFY#khz5lV2!q(5eFY#khz5lV2!q(5eFY#khz5lV2!q(5umG_^G$=ekG-z!- zXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({ z4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe z0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RC@es15Df|s5Di*e5877%VuNT}5F12;_F#Z8hz;6T0Ahn^&>jpB2C+f=3P5ZS4cdbN!XUQm=$;JlUIWm+ z0#G=CXi&I-Fo+G>R{&yzXi!*zFo+G>R{&yzXwV)E5C*Y9`wBp85DnUc0m2|QXkP({ z4WdDNFhCf@2JJHdu|c#gbRPz2Z9Qm@0Z0r)gZ5*9Fo+G>R{&yzXwV)E5C*Y9`wBp8 z5DnUc0m2|QXkP({4WdDNFhCf@2JI^Vu|YIw4+aQ>*r0s{AU22w?ZE(H5F50w0K^8- zpl|_U5F50w0K^8-pl|_U5F50w0K^8-pl|_U5F50w0K^8-pl|_U5F50w0K^8-pl|_U z5E~R0AU22wg$IZRt*r;`F#xeaG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtc zD*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-U zG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{msJ1&9rzLE!;b1|T+w2BjMi4O&|d+G7A>gJ{rx3=jsfLHi0oY!D6Fg8{-IHfUb~hz+7adoVy4 z#0Kpv0I@+dXb%PmgV>;b1t2zv289a;b1t2zv289a;b1t2zv289a;b z1t2zv289a;b1t2zv289a;b1t2zv289a;b1t2zv289a<30I@+d zC_F$kXuUsZ{Xd8eqCw#T!XP$ij{t}bqCw#T!XP$i9|4FBqCw#T!XP$iuK|b+qCw#T z!XP$iKLUsiqCw#T!XP$i&jN@IqCw#T!XP$iUjv8@qCw#T!XP$i?*oVpqCw#T!XP$i ze*}mPqCw#T!XP$i4+V$~qCw#T!XP$ie*=gOqCw#T!XP#%EI@1!4GIs?eh82_NDqh& zqCw_@*dQ8YH;4_QLGA;wK{Ut@AU22w`4hwj(V(yZu|YH_yg+Oa4GL2b8$^S`9mEFF zAa{V+AR6Qj(ApJoDG|e?;4wnbSq-qg6_CC8pfN+xo(u-J-?j`53vEDq4kWL<+XEWs z1j!+!r1#I>d1WtX92+zyjnDlF=MRC#u=h(`erMwa9h1hT9uz(aVGluL#{2gR z%GrV31e(*prGCMpMthL?pzsfUS8TTt%bpAr_j6vghq>R|yv0r*JZ6u&Cj&+OgwOV% z@BxKCzet$fF)VvBP}Fl?wP$#dVGjyV{#{pW+xtQ8@iX$< z_Xo?K3}p2n_g|2=KLAqSdhL#lJ#PogHW%5R`s!sZY4|)*fd5 zADwe{-bQ}lISpLu1#CSWK<;Oqma^Yd>Y1G>c+RlF4wrfZhBOCI_<-Vfe*6JD4J>;y zko^lX|G?@8_8|31Mt*jneIlSWiMY%MxgQk2pf&irR_)(&2g{xenEB#rC&1~a!ES*= zf2!Ml(EPDDmOUBB>Ngw`KcH}@%b_*ZZGQ_B|9);?%sm;%>N|Yf4lq1W0Po>=utstJ zW-NO$kkvm}KO3BWK<<}h<=lS;%bpBm^I2Hv9YFC5T7z$VZ^j0~9_Jj-PMMwXZ9ANmq)?ufO+0F+G8OWW<0jD33 zdeEAqS6KFBAgc$NFYwsy0BBE1@QVZcII-->KvoZO|BuaU!0IdS&#;+_WlsjOdT{ta z_heiyxo8J+6Quk>>~TR>AHWdc05Tu6M}%{pfqfE|JsHUAXE<$i0J$Hu$7P0|r+qGX z%@nBo!EU~V@ELIW*$dheb6wm143<3^=;njMe}|3S{_qzE>{#a+fY)^3N)I6SfB3f6 z0kj5R4ac4gnEC%y^A zkNbq@{(dZbGLY3vTsnNHAx;?8!h@zhlQEaQXr5Ik;Eiwjbms(40Ij z_khg5kd%6$%<;~?#eomO`$RzPA6)7|?%yGM`~YZAN&l%38_+%xQ2B#PJt+Mousl0Z z=Xhry&$Typ53%gYKz6@CL!JZ3{7T5475hb4_GBQdk63fs;XzXBfkx<_46~Dyt8j=;6ppmJ`qs;h0DJN z4S5cr_&xDHai5;st=$RGHPOgx@L}dR-Fdtp6g~lFzZ@36Puw?k@t=JySoUNftDmr| z@Ib(^8xAGVJsIv;_GBQd-(Y^_z=7*k4$Iyr?n_!PX@C2KLqbMfWrU#`^0^=yT929iA93T zA6(|o0J;Cz4TtK9N492q?*Om!2i0GoFaph6f#z#r=7aWRfWqfM0E1)sHL0yU3=I1( zVA+#_tbT)P#esm(dk*t@?rgrfId=cg|Np^jf^eC?;n>Xs1q&M-uCfSj2K6D2M<3k8 zz~BHHs)w&pLN@<~&>wL6Sy#hja(Q#?es%^1j6E61>Otmz*i(1FdF{K+ObiVBLHk5N zF z$J#%{vL^#s{f`9?9YEp#>}S_z4h9B$kefi|4=(p;fZQK?&tdQTM7w-9?0Yg`=7aWR zfYMKb*)NAF?-T7nc|{P*o(yF5;QV{+h6891M}K1Y{yHpsGLY57%AYFeo{UT^doqyK z!^)qD?-T8WL1hV+JsHUALFR+XpWgS0c72Qg>}yX92d{}n-gAJg9_;?+>!3YecFAto z_hcZe2Zax)`~mGL0p(w8doqyK!^)pp&>jdJdoqyK!^)on?-T7n`)A7hK;<*)o(yF5 zu=3}~`$RiAu}FJ)EPFCg)I-akbMF)FrY`Ot)j zQ2VC=x+fzM%bpBm^AAAVKgEuBK>H{6uMT_&Uek)td{FzR-tmr|^tCtp?v%KJ(+@87 zAoqjXCm{DHp9%r(*#)nO#-$z{J}l2bdtU7(2R^jpJmCpmQ;$nMto@Vjcn8#0vRA~i zCj;5Pp!Nx<{R7%V1KK}R4Q?Nz?#Vz_4{QI-f$qsD!?Gs>Sv|;nQ2S?{;~hJxYj5l> zVA+#_tRB|>*YfZ_^|1ce78^Nxj(GTf5x6!(Eb-L_2BSnISy9u_u_yZ zKbAci$nF94UqI$>vXQgrzOHTm7R#OtWc4$gApI|pdqDeVioyL;Q2W^oqkad)7p(ua z%tp>$Y@UIA7?wR5=;njMAGGJ=WywW5K`eVRkky0S59)t`_9%eH67E6Ae~{PU!_>k+o4`|N;Xe>v>cRINI!Ds#l=$?!dJZtuW+yqKLxYUE(4;r5V z?NKW^X({&abk6Pb!m=j=-F(paEojdH zXivsuEPFDL)q~s*8XpFk?{e+V9)0NeGcNal!Ur_|406A&k)Ivt%pp+v!KEHFehV@m zS6O=pf&!WxuAVm_GBQNe_+AZ{h;|5ka|b+mVM%vG52I3tA7BU z|B3+Z;docPZ#R}b8OZ8E=7Z*sKD?Yv==>Kh z^`P)c2m_xalzwoj2hSg!KLk3%%>IFJnB8S8doqyS{{TAw1#-W&d5fJE zczzIdPX>y5==>KbJR{!~+kwu61En8a?g5z(3;(^4`8#m>!KEJT{@cgF`v_lVhi@oc z+_n)^K7;y(=>1dBo(xd}5F12; z_F#Z8hz;6T0Ahn^&>jpB2C+f=3_xrU4XPVKG-z!-XkP({4WdEe0>U6RXkP({4WdEe z0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6R zXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({ z4WdEe0>U6RC@es15Df|s5DnUE0NPgoVuNTVuNT<`7a%r>2JOKBVGtX%{{qAY(V#sTAPi!I_7#BGAR4p>1B5|r z(7pl?8$??`_hEq8pnU}(K8Ob0ivhwQHfUb~hz+7a_hNuBhz;6T0Ahn^(7hNS3}S=! z6@b_v8Wb)d3}S=A0>lQU6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({ z4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe z0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RXkP({4WdEe0>U6RC@es15Df|s5DnUE z0NPgoVuNT zVuNT;b1t2zv289a< zgV>;b1t2zv289a;b1t2zv289a;b1t2zv289a;b1t2zv289a;b z1t2zv289a;b1t2zv289a;b1t2zv289a;b1t2zv289a;b1t2zv z289a<30I@+dC_F%PEA*}h5F50=02D4D3}S=!6@b_v8Wb)d3}S=!6@b_v8Wb)d z3}S=!6@b_v8Wb)d3}S=!6@b_v8Wb)d3}S=!6@b_v8Wb)d3}S=!6@b_v8Wb)d3}S=! z6@b_v8Wb)d3}S=!6@b_v8Wb)d3}S=!6@b_v8Wb)d3}S=!6@b_v8Wb)d3}S=A0>lQ< zpzr|Ep!NQs_5UC?hz5lV2!q(5Jpv#$hz5lV2!q(5eFPvjhz5lV2!q(5y#^pQhz5lV z2!q(5{Rkj7hz5lV2!q(5JqsWKZhz5lV2!q(5 z{ShEGhz5lV2!q(5Jrp1|hz5lV2!q(5{S6>Chz5lV2!q(5umG_^G$=ek`yoK$AUz;9 zhz6MpVuNUq-5@rI2DuN!2GJltfY=}!3#Y!D3!cMuyy zgWLgPgJ_UDKxTEVH&Az??G(HIG_k;RDAR2-j?EnA&e?TP6%1%~ln;mG){`*Vs z_IN_i2}0gO08@W|%1^NRj*T1+AoZXzT^1~RGLY4?x|{B2xbq1#hP^-SUGcsiEPFDL z)vx1PxBpDZe6V_V^Ok+0;4xR!JsHUAPfR?sALf1rk+6NBeIlSWiMZSkGC%t~2Y8Rg ztesc(renD$1KE6#`(K`$4p#r;(mNZ_J`vEED=zadhFaPE4&4S;e?U;qj#C8lo(yF3 z|66q0!^}^9S8O*G%bpBm^~MYC*w;Ya4~i=h@R&X7o(yF5uIj(-Vd29m5@rW-6KG5t zm-|8HAAyGd+?`i!Q?cyHKsKM>=^~t9*9ezu0vjc_C!uSJrCRp}lAgg!e@NsZ}hQBk8doqyKUoH4* zFRvEv(4FeG-*5H)J+L`>UPLGqC#mYZUk2!m=j=**)Q>W`ffX=-vy^{s)koK;;iU z^AFzSz+_Yz`=I-vL&S>z)i`^UpOcKM?;i4y+!uCMXZQ<^@##Aod&}tIrBP z1WrF7_k+${eSl?82C{mP`InOn!S`f@zc{cDOuEpfXbgX_D|qF972$Dmci)0$?lHOi0GxiB93l5)h+?@X z16e)D{P~ak4}jE9#c@vtvieqr=mRrj_ki!En0zwC26T2cDE;7aKPde;xZDQs$>7DY zCj;4hYwse5*|B>LR6E`QpSisd%bpBm^)Dx$by)t$A8h^=;dJ}|$1(S0AgiBT@y20? zbvhe-VaJY4%JMK&7gZJ7XR7Tjb%>;vikb>xd&?69y@^UbpYLyVUJ}`2C{n1 zpi2jYbUGYB_eOxugg3&nCj(i%-l5On^waS^aUbZ+dC=MOp!y4!`_+Rk9hiAB=|KDY z#C^`Yzk%=W0F^(u)Pvk_a`?=F3GWm49df;84RRAG{oqm$N#*=*64*VUbLwNAF!y92tM5(!4^BTI z|AO{p6l2+wfujEVT?bB`4hK+p`rx=H16jT1+$M*zw#N=LUp8)DvS=aJdop0^L3=Vl z>F2@*R!8plEt~)U|Gy7(_X2255GYL1`*$Gq^P)-)REWNGNKjSY4BDUY56hkmWb;)Y zUO%ufvD<<5e+X!Q$o@r}3O9q=&$!I@)BOcbKlg9X-Ew_%?0(SQ7ohZmOFhW^?KYVQ z_};f{0jUM)0i_>Y>Ot-|3c7UQeb3Y_dhIvC`$Rx$K^U8VLFp%Y-j@RlTDEM#wI>7F zzpF2`I+z4qIJ6af59rJF7w-=;T%M;B^{Yzk|~c@*V=1`hTi%4xsb{YX5-ly_gJXKY-gmxYUE% z51{rBNImGD3~YNckj?LVbMSx`r2PZFCu0qG&n4QYyW`4 zNAlVmJCK{|R;{wdSfSJ!acRo1%fcjscJpo}a4(!9WCj(hM zQvb_d@VYkm?mkHS*~}ij{0Es2>K{S-U*LN(La^+~KsF!N{{p!ObWaATPX$Up$a^M` z)q~6j^}j&(WPt881i1-Rf8kOOazCj51u}mXjy)O3=7Z7?sQ(2rKM=>B3}p4N{ugKu z3h17U=UDb+AghP?Q<9@hT?xd(Jlh9{Oi8OZ99`d{FCG6b;f$v{>Q z>wkgvWO%IEZvz|uLEb|EQ!lM{0-S!9|62tbAF%)D1HNYzT>juv4;udooHG@4#)G{w zj(akY&HsZK{{h_tvHux(d;|5K3}p48(D5J8o`wb{{{5i4PeJJimwQ0w?}dz?*dO9q zvk!E)Dk%NnQV()Jbo|Hu`Re_9VBjnNqma zgT`+`Ote%N?7j6KvoYL-?q8N3XWe#raC*&J`qs*!R4N_1z+u@)xsSjOv>%uF2Az@-8~K( z|3O}Z4>KQhPX?&{)3A{PtiF2ZmAxTY?#Vz_|JBWO|NGmYK=;1ee-sYe2f8~QRDa#@v&EZ2orW{1-@l=)2;5Em-zsAgc$NA9bDsya!^RpxnL> zSoUNfs|UIN#<}UBGsf%%F2CDjk7Z8=vU*VZc@?@1tiE#R727B*_hcZe|8CJ~4>BL* z{`bORc89U-$v{@GwBU|CX#Nhg$HLyc#m*i)KiGhBPX@Aj6X^UG$o%Mc#dcX(?#Vz_ zuf5=o{qBOu2g&u@PMx0#P-hZ`Ktz7ARz2j-)<)D2GAZgJ41P})8M*xX|_8)-u8i4i{fG}tu0Z0sF4`@w1 zNDhQS`vO2>pnU+KHUA(v5C*OD2Z@2!^@H?-|)i+@DiDBxal7Afp>4%sDCL2I}T<(FY2aT11 z6@%1*80hNVbLtKvxgSkErh8!OG0kVd>K>4KkbkkOhr~C?T@c)04^s~bABZSuEfgX5 zL(E54kLi9;c!KZd%9=H1u<~JaPDR%WB_aOWWQ;$3SU{?=v8>W9j z;R#ZYa1TTs0|UtY*wusli*OIJdQA7j!Ut15$o<&O2e}8K9;6Ot2X^%!_aNMltRB-n TApe5YBg_YxJvgzaOK=1L4&=YR literal 0 HcmV?d00001 diff --git a/build/main/models/omtests/test01_bonetype1/test01bones.md5mesh b/build/main/models/omtests/test01_bonetype1/test01bones.md5mesh new file mode 100644 index 00000000..2f5a02c7 --- /dev/null +++ b/build/main/models/omtests/test01_bonetype1/test01bones.md5mesh @@ -0,0 +1,11 @@ +MD5Version 10 + +numJoints 3 +numMeshes 0 + +joints { + "Bone1" -1 ( 0.000000 0 0 ) ( 0.000000 0.000000 0.000000 ) // + "Bone2" 0 ( 0.000000 0 64 ) ( 0.000000 0.000000 0.000000 ) //Bone1 + "Bone3" 1 ( 0.000000 64 64 ) ( 0.000000 0.000000 0.000000 ) //Bone2 +} + diff --git a/build/main/models/omtests/testhoserot1.tik b/build/main/models/omtests/testhoserot1.tik new file mode 100644 index 00000000..4028f2f4 --- /dev/null +++ b/build/main/models/omtests/testhoserot1.tik @@ -0,0 +1,12 @@ +TIKI + +// su44: bones "Bone4" is a hoserot (type5) with +// parent "Bone2" and target "Bone3" +setup { + scale 1 + skelmodel models/omtests/testhoserot1/testhoserot1.skd +} + +animations { + idle models/omtests/testhoserot1/testhoserot1.skc +} \ No newline at end of file diff --git a/build/main/models/omtests/testhoserot1/testhoserot1.RAY b/build/main/models/omtests/testhoserot1/testhoserot1.RAY new file mode 100644 index 0000000000000000000000000000000000000000..32f28389e950507e2a5fb315b2a401beee84ea6d GIT binary patch literal 170627 zcmY!ma*PyYU|{fIU|_hx#Q+Bi+zbo?3=9kg+zbpMj0_AdJPZtS%nS^R_!$^dUNA7Q z{a|27T*%0fK9h+-hLM4RkpY64;3hyAFmVvgz|i0bv*O-FJqHGc5GMwP273kv88?O- zH|<{dymW-A$F6ab5zf82>~o=z#b$9!svbkiNP>(nl*g8&mJYsTFlsc z-tLR3^~w;Z&n%|x>b7)DOB;5Gqr z+kkn1!z)4$Ii0#L4KHU+B)vz=Sx}&kVv0fllm^iZz(`jbPz6}jLS;rK1qzP_ zCI*HFj0_B{3=9m+3=9mjX3n&Og$9TZQUl|IXc!+vgD^-8fkEwkbc~RNlnu!83@!`| z4KA4GAnO@rkAx7o#K6Fyug}Y+ukY*cp^%oDld6!JmzJ;L;_s&(qTuS{8KMyC=i?e2 ztPtrRs^IPCAFdGY;TQtqsRy|#xcGbexod*7^Ku1yyMPU_QgE}1$uCIF%gxV7OpHk? z&CE%O$xY16i^R4C59**z2fW?UM|1H+*B(CWJM71 zu+*aB%=|nn1yf$G;L@VB#N^asFvlrB55zLz*YPtj)bTMe_$HRb8&VdPppp%W zk#iA@O_|{k-6xz<7#J8p7{rIsAT|gi=Ts0I8wRPvj$!Tu(b!d>mJowajZJE9K}jXN zfW+m%QSo6P0vKr+lodvk$FPrgB0V^oJctaak*RDnd5p|>C(_rW$%Dv%8kx#QlgG%6 zcOrd_HF=oGA$p-kL>h!c8MFt=V2|2c16d2gICPODJlYFI4K7f)!Y~8FXg32jbVe=@ zlqOJoKiUgL362rY8BHD|JOSYM{%G>RA3h^ob~Jg6@C1P0`=iMNfB1}WS**!pmky#A zYD`%GjrKyp;Rgz47zPVqAz<<#8jCbo2qXu?U;!)yOddp!_Cm1)&f^}qrFh1z!>q&(d04WlK{Q|7)>7dLTALwjV6x~ zp9Js)z-aQo7dj(e4r}tbl!oYqno|};qrFgY_<@2MhQR_@2$(#G#v%f^}qrFh1z!>q&(d04WlK{Q|7)>7dLTALwjV6x~p9Js)z-aQo z7dj(e4r}s=C`I%_Ehr13(OxJx{6N7B!(ag{1WX=8W03|6f#hHqEP#c8$%E+8UMQ9T z8lggv^nm2~(OxK0V2pU?X!02GNdR8}j3y6!p)=y;Mw7>gPXhP?U^IE)3!M=!hc$WJ zYew`!Eh!74(OxJx{6N7B!(ag{1WX=8W03|6f#hHqEP#c8$%E+8UMQ9T8lggv^nm2~ z(OxK0V2pU?X!02GNdR8}j3y6!p)=y;Mw7>gPXhP?U^IE)3!M=!hc$VmOhWWR4Gky? zqtRX{IQT%p48vdnECfs*L}QT#3xVWd7%YH=fXRdC(OxK)02-k}ko17$`O#h|QecdD z=4kR5@ksz*0E{LNe4#Vq?NP#ipnWM>L#3uoK z0Wg|8@P*EZmm5tUBR&b>3xLt&fiHAMyd2i#QLrAV7ivUN7>)Kq!NCU#W*7zwU?E`g zAR3D_SO_Es!(ag{1WX=8kM=^b1keZ-f}{r|&yV&(kpg4HGe?uhh))9e0$?+$U?Gqk z41)!*5HNWVJ=zP!53xLt&fiHAMyxeH=81YE} zUjU3I4}76B;^nX=kD4<`y-*X1!f3P?3JyL{FvBod01E+=2hmuh!9pN87zPVqAz<<# zdbAgcC4fe#5F|Yyd49APiWC?lo;jL4Mtl;$7XYKl17GNjc)8K!G2)W|z5p0a9{56M z#LHn#9!$59dZDHih0$m)6dZh@V1{9^02Tr!52CS1gM~nHFbo#JLcruf^k^>>O8|{f zAxL^a^89Eo6e%!9JaaU8jQAvgF91f92fol5@p7ZdW5g!`d;u_;Jn)6ih?m2fJUU(? z^+L@k3Zv0pC^+~)!3@J-0W1Ve9zGcbg@DO}=+Ry%mH--|LXh-;5;5RqPiwBcGDQ4RRDEnGE7wN=ZLtk_%xWK+6&T;z@Uf+VN^APJn}z*BObrU zCNeNGd_pVsDXFf9TIB!v|KE|7p@D8W-w(6cC%x21D)ddUmid2)@KrYxBSS?F0|Tr9 zL1_aEHERqEZ+gGCef~mo``eDWcA$#;&;S1imS%oGped5z^ymM72NiD?M`5lBXt9m# zRz#Ku=?7(b5JpzPz(8KM2bqCs7DyBuMs>$L1_lNYwqRsnSiuZZ|M&m@1KO#bc0ydB zv!4ZXZF!1<@={zez!-~yu}V-;#W=i{TcGjPT?ly`#%cG z?Yk}%|?ZZsU_kR$S+jmVk49P^*Ka2LCx!C9gl1+J6ysvlX6u|>Giy!qgMP&k6zXlLHCZ{_88dqAcjV{{WidO+a_ za)qsV%f1zt-|az|2(oWSON~>IN%?*uk+6NTLUQ|%O#`vfO$6z2I2X4+(4>67ph(z0 z86mlS2ophJQungbDcGcZ|KXii_Re@$OwdG-o`iFU_Jdq;Xy=u^)87>%naG*iY3KH} z!U<%b#^rZ5Ip!?{O$6yl2z|Iez@&V?`sH^v+2$=sCbqjzu?M*kWZw%xIXg3vFoGt6 z^nlz5a>a8&IXhF4FeDQR6te>;u0bgw$h^gl=khxnWYa)wbQ3{(KyeLnMWA_$9rxvTHV6}UuX}C} zN{^t_BPbGPw@6TqUJbnLvs)-Ahm^u6xKFVM<(UYR^8H_TUa_@!S4_}E zkRDK;0lDJK&MUU&?~0)&-dp+%oUdJew>hy)OWAL7<<1^osb_digy~7hjCWw3ma^aY z%AGwvQqPb~+Fel6ZMC*f%+`$L)P_Ql5^AZQ{;kHRuX2cc;x`$L%O_Qk~?Kr+$H zO#i^Dre-JJX({_Z>73igV&q5AM3A0_H4p50rlsuvsB>-~vymT?i7`KY4uIksWTLv% zvwbDk?%>VWAYX&@fZ`ftqMFpReZ|-AK=U<77G&QqrAjBxX({__;t%ZWV5-BL!eM$I z%)7mxV_M4o>i7fu+L`L0DI6pV3X?y)C17708Tsvdp>vL)i6A`z^7aQnZZtIV+xJ}O z9FmEkJbKEo$cb-S%Kq4EcWgku0HtbVjGV$jt^nyNcocI06jCwQ?%1eGJwq~akv)S0 z%#CtPb#}e+2MD?mqzC3kS*AL>p7;YuCN}m5I)K6verj!D%V`o8k}Hy=SaLN{{R885}@)29$byjr{CB>6{~I zB1jJ?&wx^okCC6Hofn*a3_zvt_+u;O~-OaORpA#!5K@&lG0`7Db9TBcly3MCVrHm zBy2GQ((__Q=K+wv7=5Sjt7YQfkBAvi9_>`f0f(dWn*BC+)+iD*5v0fA_q+q3aCBO; z-{$rjMI;lKoiuO&xe*j5`+3&bDY0@AG!di+xlTKbh80*j?bq?F zK}wI?PZ~IY@(d`H@B2)*Yh&Ukm}fwGKzRm~KJNKUw`*nMhvpf^x%0vKx}>Ma>70$+ zeuIZI_B82v;x!Sb=fLq34rguT_Uk{Kv8Peb6UoHFpJoTL?sqw@v60(+Lpj`={u6?w@{t2Ht!P(*ug@Z8mcIC+m6cpLTx+ zG+%>cLH3=PSnLGy0nc^q{r^fX;!Te*Jrf?e9av=}x1amE_Wr*m7oq79BwPB^>_Am! zmeXb%x&3i34(#KYXMi`)!1V0cyyn0r8@c_lFAnTupJxEgGay+|9!=vZK%oUGDL^Lf2#Rz7xe;XIt&)p&yw|k}nh4SZawEvZ zn&@!adJ4xn%Z`TGA{1N){I_*(!VSAg_@!V%=_e{&7&8(+X$03g|%Jr}_F zdYz5j{yBP{_WAc_;LX=CJ)pQ=Ya_RRww|Yb-n|*nd<~Ml@_MTSC_Qelk=rkRUEBV2 z$wj>R8m0%79@pE*?H9YQZGWodA~auvWX}dgI)L&F$c;fS4%i9IGa#5}KzcxV2IR)T z7YFS4=NUlr43k&x3>$4nH05>=VECX5X$7HzX6EY3x7XWZ&-8 z<#=Zw>j}^O69OON4M&h0L3$israN>x-r2`;!gGIr;6rFQf@CM~-vj6CIgWSsofS^s zFLF8rZ@z}<0mb!f$24VgQn>@jjT0R2>=U^5#_o2B8$lC6dO&XMcf7NY|Job7TP1EtCiaA0a5%lP&Au07hpW~f*g-&Nssd-D?^(0mP&ofLY(0hAt79q;UWTjFN__v#yh=@Fy{lpa$Y@9cY1 z;%5Kn>Kml=IP+4u11QhTa=f!|Uf@H!zsK>{t{_){^nmirOvgL><_12r`*R#tyLR7s zydN|Ym$bOwDgAxozAM(ZcBiec#G4CYdM23ta!7lhxbL#{t=*~XE1|g%Bx|0LaUiLu z*JoiTf%O!}o7k{0EvIL9(DQ>E};%n)W_%pV#hh`$WYe@#Yzr9)afT2d2JH+~>Lb z+ddJoNNAn`$%68A-@^o_jQ5HAjyvD7PFr6|&_s|PiO)X{fYQe?=UdjP>no8=+>y}g z(8r(ZRPjD>U*qCGcD;$=1Wg3#k!Zetp!|K}zJ|qr?0OQzkxW$I{lMXNRe@94`^0^` zVv+W_yT1_(N06R`z={Kd-Lgi+wf^o04m+;3J0-kN+&3*T+&+ErAA;!-q=(@~l|%gd#C=l} z!|l@+|3ONRrxRKo5_)=_^4=%ztKR+1j#Dg>V4eZ#DL8h+As3Y5c7LCLft-3T%fq^BVCo4Pm~8 z(dfPg=>f&H%KH{$(A>g}Xh%axT!Tym*{3B^;579MyXm>jvHJxX81SZWn4W??bqA(= zVK+UyId;DQ0|PXLgJh#F=N(udo8qKot-pnlfnopk&9MYc1nChFx_dy;T7L@z1H=An zn`4no1m#gJkp!oIn^tX^g(0-6YXMlf7{1LpzML^0oB*5-Y42c@BRiZsUhJAk_FX;p!(YK zeWKm8#PI$31jg(?J ziFQ4U|Lp4^P#41Vfa>e6_lb7hi~sCvhu4K5Sx_DY)z|&+6YUf{Z|w%PRFG3Qh>e`W zVR}IIb>I6$J9*DryFo1#M9hHdUQm5K;eDc=_3m$Wk_6fmAQM4)K=n1q6;`{y*-60L z6d+kp-3zL(Gu|iKH6(`HuP4y%f$0I&*Xi#Q?Le)=b?|l%NOqbiq`uCA#I=2lH~zL+ z)t$%oAU&YC&VgT(pm1Eg_zyU=ATje(HO>K)uR;CmD~@;UZk-OX*-xN< z4bubaUte~-V|Vj(h|NBD{~9C<>KB6g3O60^*tG{f-1mteBJAUBq{?f(t$&wyknLHpMoj(6-p zJ;vr!`1@QiJ)pR5cf4bFK{$PX(n6uL zcE65$?%xgX7lLFRD?<-}`mXhkckC3ez1c^o?+Vic>burC-mz1-_GTZV?+TIy)8ub8;ejvvRh>adI zAUz;Ab~@g%1C4rsMn4eg5!6=(^{+u;a4!qdJ6KHdY8oeS+>uXns-2O4v@L|{w`rU#T~);Zp>tr2Ya?ebeqDS2HNxYM4j?_C@y9hba`s}^wfA2| z9)EOzjfZcwk+Yws=ed8~eS%}8U_GF?-eMzX4;o2cdmm|x6l@=89CwqAoIT?_gZhv29SES!E+XKM9g1<^+4yZ?N6=VZ-X*_?GOWbHlxLHQaqe+_bl`S#}3v5 zaw90NnS7_)f#&5QWe>={@6h>cP$-MDa@v0)ybiztqz5#A-J0rVFUHDg{}Fi|fI}E` z{(3^HoBj1QiuM|739eND>jA}ef2y1PwKaT8kKDmXAf=dUNGy4g1{@!Q`dyq*HA z2b3N`uBd0?x4(hBp2A@>bpEmQb_B~9M(bCn=wyIu`e?6+sC3y zaP16O4`}TS)3g-(LL7v=njA|z$Y0)4&-QsCuR#La2U;h^HZ8^e zz0SFP69})90_y>-lVY8gV*gI(+`fL~by5zXwPT>QTp%BKGS%&yLU=6~SPy6|7ss>| zdk?0%eUsy1Gr6E}1m#iCdNYuT|E}KIV&-wh(;t7pZUNzSdtg1Fa0JCnU;F{P z`N-?`96)QwK<#jledbcn>^QFzTw4g%1Bz>qug#>M*>PM)T3hG#r}`Z zIXe!*>mR{-Kqf67mA9tEurk2EQ_|91JEjS+$M;V?a*_2CgF<@R4Mzq2ufuMY>wK7pc*b z7u$7ZZw!I8t}s2IwXPv1<@TbxuI!D5uXP2<%0kzNgJg|F!uA~}upSqt2eckH*reRv zP$X>MG5C61kgPs*eRz;bxqZ5M%f9sl)(pe+fZ{sPq})Euyk*}y_?lsmEXa+Zb0+>%&1NHe7zUr;5P(aF`y@`f!km^_So6sf4c&2g%mEPqBx& z@z%~OwucF0QCU7XYRQ6xW~>=WpI(r+Wpq7XTy+T8|D|9}bf3d{=A-+IxW9 z<^i#h+dVKnu=LpRuGp>{zFz?(+YVhH4$3nELUML*3GAtW>4D`Lejz!#H}E|bfB*jn z=W9@D2678ePPhS2&UHdNNx*tQz6Q+zaOZ>@aOYfy?j!;2T>c)e zVd_EtllBy{gSiLB2Dt~u2Dt~u2Dt~u2Dt~u2Dt~u2Dt~u2Dt~u2Dt~u2Dt~u2Dt~u z2D#@{ZZzCIFgD0NFgD0NFgD0NFgD0NFgD0NFgD0NFgD0NFgD0NFgD0NFgD0NFgD0N z(w>vx?t!sE?t!sE?t!sE?t!sE?t!sE?t!sE?t!sE?t!sE?t!sE?t!sE?t!sE?kT># z4elNo8{{4s8{{4s8{{4s8{{4s8{{4s8{{4s8{{4s8{{4s8{{4s8{{4s8|0o9xwql& zfw4jEfw4jEfw4jEfw4jEfw4jEfw4jEfw4jEfw4jEfw4jEfw4jEfw4jE0ht9$&oDN~ zJuo)NJuo)NJuo)NJuo(u2Je*yxd+N;0J#Uo2Dt~u2Dt~u2Dt~u2DwMaQwVGhD8Iwl zAosx7Aosx7Aosx7Aosx7AoE~skb7Wkkb7Wkkb7Wkkb7Wkkb7WkkbB%GsleR>V}slS zV}slSV}slSV}slSV}slSV}slSV}slSV}slSV}slSV}slSV}smNeA^7}9vBL&&UP<+AIAosx7 zAosx7Aosx7Aosx7Aosx7Aosx7Aosx7Aosx7Aosx7Aosx7AouLdjfRI0j16)Rj16)R zj16)Rj16)Rj16)Rj16)Rj16)Rj16)Rj16)Rj16)Rj16+n(`~tM_rTa7_rTa7_rTa7 z_rTa7_rTa7_rTa7_rTa7_rTa7_rTa7_rTa7_rTa7b3kqa<@X05f&nyk0XtFx#s<-# z76n8FNEWfZOBmz6G1;$2I0g`0}+Xp!y1jI&F0TN+@s(`UkRe)sKp((zD0Lg$vMHv_vklCmzK(e6J2T}oJBUFH7K%!#MGzw#*ssPD?(kDnY zjEztMk^zZ|GcYh9vr$!mWI-tyqyol9r~t`;L?sv)7?9bhDnPQJG!9Y$Vz zG>*(hRRNL(iGWnV*dRV6C4)pH85kI(7#J9k*{CW&vY=c5QUPNlRDfhaqSDZO2V(zD0Lg$vWf>S4klCmzK(e450a5{D zBUFH7K%#OC3=GI@R23juP%Z$efUyxOKr$dvc?JdsWHzb_kSr)ifKQ&-fXqf!0g?sf2#^XG8=(Ru0}|C{U|>LIqpASOf^q~%1&obQ0g?fU z>M$@cAhS_bfMh{A0;B@QMyLSEfJAi}7#NV*s476Rpd0~G0b?UnfMh_TdJGH<$ZS*< zAX!k30I7hn5h_43AW?k=1_op{stS-SC`W))z}N^CAQ_OT0RsaAG8!1&obQ0g?fUf)2() zW}~VA$%1kONCk|IPyvzwiJCAlFd(y0Re)qcIRc~t#zv?B$$&&bH|HU(zD0Lg$vLH8aYvr$!mWI;Isqyol9r~t`;L_w!!A+u3cfMh{A0;B@QMyLSEfJ7}A z7#NV*s476Rpd0~G0b?UnfMh_TmJAFG$ZS*ukpfUyxOKr$dv z7X}6fWHzb_kSr)ifKPhQUPNlRDeW085kJ67#J9k*{CW&vY;FRQUPNlRDfhaqTUP) z49IL$6(CtqjsU5Eu@NdjG9XbO$S@HDjE$-SBn!$BAk{E7LIp?$B(zD0Lg$v0~r_?klCmzK(e450a5{DBUFH7K%zkm3=GI@ zR23juP>ukpfUyxOKr$fFULIqpASOf^q~%1&obQ0g?fUMl&!lAhS_bfMh{A0;B@Q zMyLSEfJ9>$7#NV*s476Rpd0~G0b?UnfMh_Tu?!3h$ZS*Dqw7c z3Xlv)G#{GpU~E(sAX!k30I7zt5h_43AkhK_1_op{stS-SC`W))z}N^CAQ_NoAp-*g zG8Sx}AuserK&DnK$I(Fz6z24ps> z3Xm))M}Sno*a#IM8IUL_y(6(zD0Lg$v>lhdqklCmzK(e450a5{DBUFH7K%(^w3=GI@R23ju zP>ukpfUyxOKr$dv(6tT7Y*ZB>Sx}AuserK&DnK$I(MARa24ps>3Xm))M}Sno*a#IM z8IWib0|Nsx8&w5J7L+4EDqw7c3Xlv)w3&f{0hx`e0wfE{5g-*XHbMnR1|-_Tz`%ga zMpXfl1?32k3K$!q0we6(EsT1_p*U1_lOXHmVAcEGQR% zRKVB>6(AXqXgf6D!PuxOK(e450a6WPBUFH7K%yNC3=GI@R23juP>ukpfUyxOKr$fF zP6h@BWHzb_kSr)ifK(zD0Lg$v`xzJ*klCmzK(e450a5{DBUFH7K%x^E z7#NV*s476Rpd0~G0b?UnfMh_Tp!AN+MpXfl1*LP43K$!q0wgk#fq`KX0|Nsx8&w5J z7L*G>Dqw7c3Xlv)bTTyG!PuxOK(e450a6WPBUFH7K%!F^7#NV*s476Rpd0~G0b?Un zfMh_TQyCZ-klCmzK(e450a5{DBUFH7K%&za7#NV*s476Rpd0~G0b?UnfMh_T(-{~T zklCmzK(e450a5{DBUFH7K%z4k7#NV*s476Rpj-e_0b?UnfMh_TGZ`4bc?HHsRRNL( z(yF0g?rUD@X;5jj9493yLw23K$zz1xOZ@MnEcHY*ZB>Sx`y@serLj zRe)qc=^dm3#zs{Ek_F`|kO~+ZRRu^Ely^ZYU~E(sAX!kU08#;CqpASOf(yF z0g?rUJV*tM4O0PH>o%xe;`$)>%P0JAMLt;6ZL&u&B`<L~=>KX&z<4Z=i_8&6zp1jmfCNSNI{0_PpT+{o}e!yc64oJ7Lx?h48wrEpL1!_JOj$PwL7oay1grgns{gFvjgC`{@vyzF)d~PrfYZh{FTIi z{}@OQD6SbY;~m7OrR?8$?arP*lFyJ#%`dOlE8T|AQM4x{ozr}0nja1HP`OgSV%oX zGBIU)vlGmXwnW@N1~PHMt+)0tH`+k&AA{r>kn97;HYZRxg6_j((>-UGOyFD{ke&}V z9uA;z1l@okV3){Lhm;;c;Rwnzpm>{W z32?p!o!>Sy)ouUY)%*9HC2;>3NDnBk z3+xs+%t&?Hzi0LSJ!jS^+CyRnBzv;C%xTZs4kys`%FM4URXaHoUcLmJ%MiS`n-BSG+%>cL2e9{ zDg*mkoRxF`83N~yf%Jgg7$tWA7oZvy z86(%OAU&XP)R@_M0OUpq-|72GnfUi3Vg{72TNQGgK=*Wstl4k#kih+8AQM4x-SB(f z0nlw>!fW>1JXoWMWa1|4Rws}fK_-H3)Y2eu#vI5*gK~8TkQ+fJuH{){r_RcWWMavq z4ku7JE=+aXpUA{-|HlXa{bL{#cc}L{Fht26Sdi+rKY@wg{chu=5)wLZa>pJgZ++# z&$m3_k+JdsL#C(0K^wXKpz}{1Ucg!aAYWgrNC(F?=EhQ9sq^okIicifbLbxd2wLh|G5UxJOeTj6xYf8 z=}xBAU#Y_7=kc*IIeKo z=l}}GBQ|pTKhHI=2Za`-Gz0ls?_du&u2G8RZ-2S`QwC$e}KL7Us$c>=%_{>Ib|D9{v_D@SLLi07qL{K<_ z^2`exx&4|i4%j`POZfgVP&k6}49FE4FAmr}n`;2gGyhcM!1Z-ONuLwwRxRI?A$!ge zI3FFP2b8Y^+@CvuZcFkx8M5b$a5|ES*1|3vZw{|BIxX%Qn2Nc%9skckV-uN+u#y~+V}CzZHZKkD-30Dj0hu^sdxJwj^YsHK-Y4!WUi`fYovv3E zI90z-+$Ss+X&+ADUKo&xF9h#6JP52f0J>pJNG#GmZ1*>$aFn>w4~}b{4~hFgH}AX; zz<+lQ$iyFwf5G`$`$OWssP&ch?*eXFBYX{VBPc!IdY`y&QewD$6oLD7z$OabaR8;q zo9`3%O-u~8k6io*DLsP15tL_^zfas3yZf6Rp*w&;CW6E9*bRqe?-TdM?EVJ2MF*N^ zK(}0h;#!Dnf>Z3n1zQ~2Z*D?PH83`E>H+Bi#r2K=2FI9(3%1y|-`oT`pAq6~knGIb z0w>U2O8gogro`SqHbJ%GKtSj{2R;oCQ`r4u2ovRwr#OM`dy-nAvgOw1*!@3>+#R!Z>cOy6)h3+262(#M)x&iIX=2#>XL2<1nlHlYycb>_PO&^Vj zxql24*A;R94|vR-XR>|MMqxb*++ktL+gSibxqq|Y#ZL>pw z(A@(mC;l3}`~TnWHi{cLr23pxLHCcPMwnjP9Ba=^L^!@!@X&!_Z`}d2)Ckk7n`1$# z8_Cya>?VNY`bB`X3CK;yqYr|7j#3|@yK%}lMn}-N+4BHv6Hw|t7JbkN;cJi^LFw_Y zr{~t&n`7-i6OkT&EO_VuN{@d$J-6Q49BcmxB|U<|5tL_GQ{X-wg<&EsJ=eJdrVSID+(m>zQLW9IDrqY_cuE^ zc$)&`Mo?V{s;|Q!cg@*n5oq^-^uX%tP{>_#_L=Z@4@eePU+aBHv;)<>+JX4nW*|MV z`darxqFvqU-t?9u}t+Hsx0 zKL!BO1M6Qebi8Ai7WmMP^8{=p4kQceyMp@HYL0j8K9#uHD-#%}0OSRC$2)eW*WTD2BjWxsSpRyH;~hJb zYj5n1mbgLdLeLFTptuH&hwrhGv)_MjhRp=Rxy&7H|*!P$4*q#Gu92YdU2fEv<{>6cPf8b+#AQM4j&7ko|kcpsMxb6}j ze{=wiHG{?BW6K$Yae8ptuH&hlB1&Yk=M*1~LU1qnikh>z3mOK=*;w-=DDu6j}&3 zg2r({Zai)yXRq_(fE^3rF?$ElI4;PI$86;6wO<^tW1fdJX72zRYX*hmV;ed9E7!E` z1&FwR3^djZ3dct_a`u<6Y1{LcBF!r}z{bNt;RqTJSGYs?{xR5iI4B%JJ6y$z7yD#uLBuTXs;J60OUr$MOv%j-?zs(f_^Vc9fptuIjUr$bTv%kH1 zzs+U%{541xH17(Ui<_J3W-sVFeIIBR5;^67*vP2|qz5$b3Yv?Xlj>$K;5&UEXciKZ zdO)(Exna=!HOM|;R?huL3CtIQ^nmAvA1F9XN_DdrV&&X_1U_E~l7-D*!|oqrC*uAw z*!(r7t{xOgnKSaub=7#NSnE3be`NHO1 zK_-I25i~apy4&j+&zgOr1m=c8dO+a_ni~e)?e&yr%{~$M+%QNMl&?Ya*B}#x*X-W| znu`X-1~NvE8Bkn<=C45}3a#0{=RSP?8e}49-WBA=x>PrN1>fm*okZL}2AX#Txv@6Y z&0gMjx?Kl+jvZtoXl@uZf4wx-&Hfz=r#;B$$nFEN(cK7|8wSl^FG+Q?f6KyY5Ar!8 z^}yz@x1_q+uUVsLzm~vS1&}LX^VgeG-RxJdQM6wJU#kF;1-TJ4f4w->%^s9ezY%f& z7|4yF`RhfgZuap^{PtgcVCyMBCW68dlxIM>@I22NJJ9+KkWY~@y01au2+A{{Tyc(P zjU6w1%?IdyDNtNH{cdv-o|a;N?%Ew2ej@H41I6`&jCcp3X({$+uidfXlY*@`1DOa~ zCk0wN1CrfmxiKaFz&=j` z>w7?YKx?@`>w7@1NRB_S&jY@`2P6wyZw9*WNlxn7z6c`jAA_wo1Ksx|EA?z&_%+xX zB#?<9H-gqlfn-4|!|VvGlLF}hxe>HZif>wqJ!oZ^Eqt96NEQ^1ptW3}8>{M=>h{$V zasL=796@WjKzD7`GS%&?i9Y}x83vgMifhn%Gf-Io;Kx?@`;rM-Oiv8XA19rjib$cLLr1fU@ptWOnZxFtJ3~9ZYy@}K_ zyE`{vYYRapg4_s7kL=S@?7!=rvx_6J{t=`H1l>>fP3N3lEPVYVNEQ^1usl=D zRA(1XV2vh74=5aAd8UY|&Mqt-wnF2^l%EcuxCX5c4>u{de{lJojSJ!R;ox>SL(((* zFq3lo`q5wXP1Jb+xM<`-`|~A_9D9v#6~W0K_-IS z2wK++@>lP>;(dR1BCTr%hhsHleYm}nkla2Z)?S0d(E+kP++I;gZXe3pYj9kH)`x>) zChPLMJst$^9|O4&l&?YS!$C2VdHLNQck>o#Ndb}tt!oCk5tMoac3!b9BfN&)0kp0e zz7$~kmvjCtO0Jog*4Q@HtH$d7wpmjm8eL$o4kAXr0be|0D&N0w^ zGB7qMykU2Lf$sl-u|fCSz}O574)!oM=zbd*8+5-7j18LMfU!aM+rZeM`)y!s(ET<0kY><0kY><0kY><0kY><0kY><0kY><0kY><0kY><0kY><0k zY><0EW`WWe$UQJN$UQJN$UQJN$UQJN$UQJNlm;D1%K&l@ls|g^81(KkPiRserLjRe)qcHzk2oz}ToNK(ZhakO~+Z#D|1B zhy}Vm26W32Ivb$^BnyfUkP2irLC1jZguS1;rRh1&obQ0g?fUf^IoN zW}~VA$%5h(qyol9r~t`;L_xP4A+u3cfMh|j4pISQBUFH7K%$^qj*!`?DnPQJbOBNU zVzTaJ*~s476Rpp*kr0b?UnfMh_TBBS?@{r~^}0m_|YpmYwpF$r|z5hBDu zq974a8b@X$RDfhaDnRKSnT@IfBnuJ&serLTd`L@&0g?sf2#^XG8=(Ru0}=(@a)iuARRNL(JIl%tloKk_F`mkO~+Zp#mfW5(V9Igv>@&0g?sf2#^XG z8=(Ru0}=(@a)iuARRNL(GA4QUPNlRDfhaqM%!j zklCmzK(e5F!$2xvY=jDs3`i7o%MmggRRu^ElnX#AU~Gg6kPJu^bjuMk8&w5J7L+4E zDqw7c3Xlv)6qMeP*{CW&vY>PhQUPNlRDeW4x5t2PIYMTmssPD?as)^PjEztMk^zZ= zZaG3`qpASOf^q~%1&obQ0g?fUf^IoNW}~VA$%1kONCk|IPyvzwiGpr9LT00?0Lg-K z1V{ypjZguS0f}mj-aiH|*Fkv&bW0NGmLp^~BE&$VAX!k3KxQLUfMh@_K(`zrvr$!m zWI;Isqyol9r~t`;L_xP4A+u3cfMh{A0;B@QMyLSEfJ8y*9hr@)0wfDc=O7g@HbMnR z1az_u=$0d7HmVAcEGS2SRKVB>6(AXqDCm|WWHzb_kSr)ifK z6(AXqDCm|WWHzb_kSyrlFpvru8=(Ru0}=(@a)iuARRNL(-5Ul{0b?UnfMh_TmZSHN zf%85nuYhhz0;P9kHX_78q99pNI!9(BRDfhbx5t2PIYMTmssPD?as)^PjEztMk^zZ= zhLn)ms476Rpd0~G0b?UnfMh_Tpj(cR*{CW&vY;FRQUPNlRDfhaqM%!jklCmzK(e45 z0a5{DBUFH7K%$^qj*!`?DnPQJ905`RVzTaJ*~s476Rpd0~G0b?UnfMh_T zpj(cR*{CW&vY;FRQUPNlRDfhaqM%!jklCmzK(e451yTWHBUFH7K%$^qj*!`?DnPQJ zd&58~U~Gg6kPJu^bjuMk8&w5J7IbeINCk|IPyvzwiGpr9LT00?0Lg-K1V{ypjZguS z0f~arJ2D$p1xOZ@&Os_*Y=jDs2Sx}AuserK&DnK$IQP3?%$ZS*< zAX!k30I7hn5h_43AW_gQN62hc6(CtqjsU5Eu@NdjG9XdVEl0>~R23juP>ukpfUyxO zKr$dv&@D&EY*ZB>Sx}AuserK&DnK$IQP3?%$ZS*~R23juP>ukpfUyxOKr$dv&@D&EY*ZB>Sx}AuserK& zDnK$IQP3?%$ZS*qV?ehYA+u3cfMh{A0;B@QMyLSEfJ8yJ93it&Re)qcIRc~t#zv?B$$&&b zw;Um}QB{CsK{*1X0>(zD0Lg$vLAM+svr$!mWI;Isqyol9r~t`;L_xP4A+u3cfMh{A z0;B@QMyLSEfJ8yJ93it&Re)qcIRc~t#zv?B$$&&bw;Um}QB{CsK{*1X0>(zD0Lg$v zLAM+svr$!mWI;Isqyol9r~t`;L_xP4A+u3cfMh{A0;B@QMyLSEfJ8yJ93it&Re)qc zIRc~t#zv?B$$&&bw;Um}QB{CsK{*1X0>(zD0Lg$vLFpZtjj9493rgo86)-kJ1xN&R zdkpB7BV;zJ3Xm))M}Sno*a#IM8IUOGmLp^~stS-SC`W))z}N^CAQ_M-=$0d7HmVAc zEGS2SRKVB>6(AXqDCm|WWHzb_kSr)ifK6(AXqDCm|WWHzb_ zkSr)ifK6(AXqC@8%nvr$!mWI^d1qyol9r~rw8ZjS-oa)iuA zRRNL(JIl%tloKk_F`mkO~+Z zp#mfW5(V9Igv>@&0g?sf2#^XG8=(Ru0}=(@a)iuARRNL(JIl%tloKk_F`mkO~+Zp#mfW5(V9Igv>@&0g?sf2#^XG z8=(Ru0}=(@a)iuARRNL(JIl z%tloKk_F`mkO~+Zp#mfW5(TAqWHzb_kSr*jgH*uS2o)d^(CsmxTaJ*~s476Rpd0~G z0b?UnfMh_Tpj(cR*{CW&vY;FRQUPNlRDfhaqM%!jklCmzK(e450a5{DBUFH7K%$^q zj*!`?DnPQJ905`RVzTaJ*~s476Rpd0~G0b?UnfMh_Tpj(cR*{CW&vY;FR zQUPNlRDfhaqM%!jklCmzK(e450a5{DBUFH7K%$^qj*!`?DnPQJ905`RVz zTaJ*~s476Rpd0~G0b?UnfMh_Tpj(cR*{CW&vY;FRQUPNlRDfhaqM%!jklCmzK(e45 z0a5{DBUFH7K%$`Zj?6|?0g?r!bC3!c8=(Ru0=mrybmtE;8&w5J7L+4EDqw7c3Xlv) z6m+u?G86(Ctq8Ud+*u~AikWI-trqyol9RRNL(rFW1D7#mduNEVc1V{ypjj9493kq$J3K$zz1xOYY@*ov3HcSO*t=}jf4S~@R7!85Z z5Eu=C(GZ|41iEiy-aiIf2SS;t1FL&`WVGFjpP%iP23`X1IsW(m{{c_kUk9S*eL3*& z|9^*&mrRalH?V@Hym2@bw09DLL2VBZMpdlf$iQH77zsNwFql9wvdRW~(0DLtZvadb z(=3<_I*o7xXuruk1_lNYwqRsnSOMB7!0`Y7{{tdnR(7&d+dw|u57NIpJA4C3H8KXR z@P^phV2`W^bW$cr&oZzc5bOSwpI{R^HgY%wo0RWYxcqKU9D)7i$a;cI%J<7(ezzwU ztOsTytGnrbhC83^K_)&Gl-s99;Qld?i7-7N6Q2mm?NbHoftk3DYu)}cCG){1PJUOs zZ{yA@w#YsPv5|cZG7+W+Wa6ZE#rrmZ^}tL#G4afPP&k6z7-!zH&y~RaV;~b@dO#+| znz!t80qcR82(mBxJjZ^JiRvO@`(6^*7Y#BIrUzuAnn>8b7hpXw6G36}^4xT=iFL8;pXtOsN! zNET$@5omhUh2A9wau+hj=0=bnkcm1XVRm=Gcb36SWVh_J|8X0VXZG#9Vhi#GvS}bT zx`{A7AQSiQykgr6KF0xM;=QHM!1>zkWr+j(w3Pi5uin|?K=?cuxE{7?Df=f}y|c$2 ztOsVI{q1A>mDR$*COR?I?VCgRY>NXhJs=YundMN0L3-P*Y;A+_W2RGe+(2-Fg+kw*hxLx=L^;Y zGZAE8)%*?nK_)JUKd{e+@Hr-6H-hwlOq?HoV4pQu56nbRn9P{3c>rXhgOT4pkk3K! zi;R)u8stWp9*~Llpc83y&q4DwNcLi=mEEo+_X8l=g;(#`xDq}O<^W6&C>$4Dy<_77 z)&q0no`SFTbLMM;Zzt1ds)w?lVEw12XZa&N(|TupW?^Alc;8nGU}tx7mSAw3T{hx9ckY`^S*= zfK0TJdSzPI2Nau5Mt*jGzbAde_5MBgz-PX}OkDC^_(1TSsSY67BRp&NDG<1S3}hlq59l7N!#r#D$%FO4O#GGJ za=1j!I+uy>(zaMn}7|1*Z29Rv{shQw>-3GcrYK`K4 z&}n8MpCV)A^oXnn!G7}^VvhUzcjsxwfZu?asXUyR}#{^jq$Q3G( zGv=VV5G1?eyYK<=O|=I=Ve-#s`o2cOXQLf}=>gsC_19WTPG~Rj&*u*ER z3Ew{kas^Be$i&C1A@`4g%!7nul9RTB^rqSaARp}JSz|}&{xOh=Fg>7f+y%XV3}Ip% z?*xZqH#xv=Y+&NIXC-_N-T{~%kQ?in`0ZK1dO&7^?Aw;V)Zv!oHak!_K3t<{A4TB) zF=Ra;6CbQmw2uVqfti@ZJHf#*!3>nFzZ12-LFQ+kV+$vyI&T<@aXn znL+rxRd87V(zD4%ZvV1-;4?TuON<#97(gcOYOpz=ynTnm7SQcXB^UScT_=417)%ey z6?aO&XNw}4c&cgnf%unkU=z9L8SD=re7@xYm>!UcT=NX}`-Anse4Q422%N7$vY-=0 z9f`Pq45kO<>uGwP`yIe~U?zg>yPRZrV1td^e$b6tw@NPJ&DWrig6UarBe!4Zy7vB? zU_CGsL1A+H^TGq`Y~=PQyg0CrhwxdZ2Vi zr^E5iK4JKsWiS&v-W)ujmRainx&w=t`^P{g!t{V#0lR+;WF7+pNY>=?18}~c>Ud`# z=#=nf1nwV0)-%QN&OXqcWlO<&KxTquLH5mmw%fr$`E~EdhDJ9lN|5t>kE9ikA=Y5;~*1ZdO)t|4Scu{bW%IWJczGBdDO<` z_5o0s_!Dve7|2AJ9#G8qLGK?!m}u=?1lnRxUXUHpMBk6Js@9$WL1MM9T3v#aOi)ZxDRyym>q%pBarp< zy-(Z+x_`_TtOsVI-l5Ond|mrKabN2C%Kf%(`0uy?nF!NU^FDDO=nfPcupXF+%0ZV7 z%)FR%V8Z*veVvKn``ZcJ!vQi8rU&G&j>Pc&ZD2hx6G35Oa`?=F$?p^Qx$XY8PmI7_ zAs`cBdM3S3+~>Oc+dfgS9+-)sJZf$H?!cz^iTn1s-LeMVq6UgzWQ?48KqkWUY-cMZrym>$rL zcPZ;D?fb!cKxTqud%xdxVAbhx$b{Y{2D*6-e0^>MtK*A9zl^K) zem6mO8;p(YMr1wD5B)N(-1{ATLlek61_qGqyr_}`6{0U4c1IuF@b~}!eK&}>O9`fD zSM8mWVB&Te#v+)NY3P7Dl7{8m6a|B?5f^SR7an%tVlV+ifxr)P8B-407YY z|Nrr}!(sjc>8bhBz8U03P-ub7LxiJI(4_-*bLF-$F)-}EwmBB>Jw+fBLE#9}V>?%F z3nK%={;Oa;ATvR-pgbBq@5_P3J$E*rWtj-NagCsfFg=TU?rc88G7)sw95i2pOk94c z)xjj_(t-7h7H;|f|Gyo`=dkdD(dgj_)3a{T!Y%*)|F;AA9OOcXuj|?#JM6c~JdnA^ zaVzL9F%}~3AA{-1*yFhM3jEG8keMJihQ4HS1l8A{<~#+*arS}GtuVL2XmmHi^n9H2 zbTjDm(JZhYn2FtOj~%8Yb~}WZtln~WbFBSaaN0th&q6m5rYEdq^_DxEW9{F7^}tNr zajDfIU-YGeps3Uq76t};kk4UmgVE?F!t@A;N^N0gV6X@I9Aq8?L(`qd_Mm(Xs;_h3 zC)z#myk(t6_`XoMo}BlIcK1DRS*L>afXoD$2&ywc^>xkrL_6Ev-}Xs?%MskZM%Dwm zv&?4qw|$aeJunkt^)={LEzs?f?F8;01DOcZ1G;MqRExBM^}tLtfY#Tg?-T7n_4N{0 z{AD=EM3|lu=$&PY!FpgOg6x}nG3h|#`$RiXo5GpE{bL{#VR{NJrq+TN&jvzgA-Y431EdH~v9ejT$%tTNgwKaYRx}Vg}+WppULiIJs zjW9in-Y42wxr6VMh30FJtOT^a2HoRkwfmc$6u5nW-;FRmpnKdbcYm{!1nYshu^n1p zCxCpN7;ZlW+=jt#B1}&_$k&PC_LISSU?#%q-o*EbcA(TP?~T802J#n756Bgu)GY_r z12eH7T3^?`PXyh#X0How3*vVpOb;km$caVT>wxvZOa#@v6>X0l@<2E2LE1fd>uZo3 zVR}G0w{P(uP`d}(YW}Ah=K#vrp#F7@;~hJp(;+sX-UO_KfYHb$1+t!M$2)d{r$cNI z{cDgcsE-HjU)zEDcx>QyKW<+m>jB-))D!p++_M7tnSlW$+x6z)0j_B&k zfqG>yx4~$1H^TJvJKnJa-JQ(?@6UitMCxDLf%?}Lr||c=ko8P)ykiIIUz>yVfLsZZ zh4rs{9q)j8I{PPs`*`?$4b#)(c*hRZ6P^Ut12Yj6j-bA4D=3t&z1eqZMCc^s4 zpm^&Dd}zl(U3a!$k|6h#&Pkw5n0bV z8#((($T%*N8$sj7pz(0f9ax~T=4;@wMBI4>WFkz@1{*nh&{#8Qv=-z-@W`+O(%7~= zXoOdji2KK2dO)rKjiGCR^?=NT*#{aA2i@%j8o3SukI52tBS;U(M9|1}Fjx=FL{K<_ z#+pI0_ew7A69kVN<2Mne2juI!B^UPzfc3yk1m#iCcsMAOlkU&hGaEd%jo(C=9#Hy7 zygy^lEU+G!iLkM4P)Z1YallT1@R+>=OwVc?Is32|2kiL4dSE8P#$s0a9r25?Vo}5z)XaVZG&P4G`4*gJdc6jM3^2>*iYBpbJ2m2`D=UVyer;(jjRV` zB6Qvrny*2!KcMs1pxeSg^Sp<_bAR~V2-5?)Elin}bN?Z*9+So^tnPZ2}UxQ>p z;Ru?)?nrgBKgP3WpAv!l$B^}aLh2~bnth63Juo+d@@On%{@PxSi2KJtCc^Z9Tpw%e=fSA9wZ(-uM|3u*aF_0@@dO#u7%*1d15v&JhV!o5MgD*7C9OGGI2l6>A{9rVC zIKuRROa$G?2l6?{JO+jbOP_)Bwd2bY2ha^t-q-Hfn1k1j;r2DM9?%U^Uf1r}n1S_x z%mm4T);xjM&VcUCGBEPn_Z7Sj2EU0gJs?-;8~N?~0@edFu?o803?w@z{=hy%@LC=G zCc^Z9+&DY_z&-=89+-)9pzF;*CYnh-+m}Y*{xOihV0u6%no2#}mkQPcGZAE8(fkej zK_-H3)N%!{c_QpakRFhU-*nFHa{=ptnFtD#Df2ZCfWi^95^XYp`^P|Tgy{jf!iuSG z-z2aen2De~x-H5507&-o)jNAEz-!0wyAh@bw%fLrQoYQ$c-QqHI4l2 zeiOKV4CF?b9*~I|Mt*j`z>fz|Ic51`od*VR}F&PK`fcXA9N? zGcg*v-V9_SD0Qy}uM@;?B1{j+L{REp1=a&I(U!xvI2-5>{ z1!zs2Dp(K9#Ipro?WNVi9k{2Z*jqBy+4Y0hTjDnnrU&E-3#K}|KCm8;iT9`c1n299 zjT{c3`<}`#zq1Jeul2@lBC;OPeNSbV-`NC%^}tO0>SntC{q0ZoAQR{8yt20rylxf0 zi7-7N6KC(dvbPqj2WH|@u66rCYimI!ii(8oy9!=gi{C_;9*~J5B4PWkfc3yk+zwqI z4l*&syk(y?c>OPa6JdHlCI*|g?6U&vftd)hFX}wUevoX#yW)Mz3EV#h3P+fpV3TtD z`gg_qmVx!aOaz6=jdRn%Cf*U0+b0fQM~&Z&Fg+j>Zwt!p69emknFz|GuR^zhO?0^Y zZcixT_2CXMJs=b9FTdLZ3N4U%;I-Ed-z_@rVQ!qe^NMX7cs)9PH^TIQOq{dxift=c z56DbVm?$l{V-H$q4+=*SkubZ5;5GC3O@!$InJ6q0X7>QB2WFxPbbUC;#8C4VyL|Av ze*7lF^ngqR<%m469+-*R3+~wOE}3r+GO_(#vE2ml-UIw5!t{VlYa1A^?*zSxdcRm@aX+xpiltaCj+~4tZvmRTNoP@zOcK$K=<3g*r5AuU~JI+ zHZV5mej6AYbiWOZ4Z4>G#s=MQ17m~kw}G)i_uIhOAosx7Aosx7AosxT{sOrN#s;|u z#s;|u#s;|u#s;|u#s;|u#s;|u#s;|u#s;|u#s;|u#s;|u#s;|ucJ~*^Juo)NJuo)N zJuo)NJuo)NJuo)NJuo)NJuo)NJuo)NJuo)NJuo)NJuo)NJ+QmKK<FDzQUPP5ssPD?ZWRNmfU!|kfMh|pih)$X z*r+N%vY=bVKq_EtR23ju&|OL(6)-lc3Xm)hNSc8Gd`A~0g?f!0Nrwg%m%4Or~t`=Vhp4L#zv?B$$&&bw;Um}QB{Cs zL2(LF0b?UnfMh_Tpj(cR*{CW&vY=Q8serK&DnK$IQP3?%$ZS*u@NdjG9Xcr(fh~1cU6GWIp~%o&@D&EY($8GL_xBkG>*(h zr~t`;RDjYuG8hzg5&_*F1G?o1nT@IfBn!$BAQdn+LIp?$BnrCa z2$_wl0wfE{5g-*XHbMnR1|$l)6(AXq zC@8%nvr$!mWI^d1qyol9r~rw8ZjS-oa)iuARRNL(JIl%tloKk_F`mkO~+Zp#mfW5(V9Igv>@&0g?sf2#^XG8=(Ru z0}=(@a)iuARRNL(K2+%tloK zk_F`mkO~+Zp#mfW5(V8KhRjA)0g?sf2#^XG8=(Ru0}=(@ABN0ERRNL( z6(AXqDCm|WWHzb_kSr)ifK6(AXqDCm|WWHzb_kSr)ifK6(AXqDCm|WWHzb_kSr)ifK(zD0Lg$vLAM+svr$!mWI;Isqyol9r~t`;L_xP4A+u3cfMh{A0;B@QMyLSEfJ8yJ z93it&Re)qcIRc~t#zv?B$$&&bw;Um}QB{CsK{*1X0>(zD0Lg$vLAM+svr$!mWI;Is zqyol9r~t`;L_xP4A+u3cfMh{A0;B@QMyLSEfJ8y*9hr@)0wfDc=O7g@HbMnR1ax~0 z=$0d7HmVAcEGS2SRKVB>6(AXqDCm|WWHzb_kSr)ifK6(AXq zDCm|WWHzb_kSr)ifK6(AXqDCm|WWHzb_kSr)ifK@&0g?sf2#^XG8=(Ru0}=(@a)iuARRNL(JIl%tloKk_F`mkO~+Zp#mfW5{+hHU_fT0 zssPD?as)^PjEztMk^zZ=ZaG3`qpASOf^q~%1&obQ0g?fUf^IoNW}~VA$%1kONCk|I zPyvzwiGpr9LT00?0Lg-K1V{ypjZguS0f~ZcIYMTmssPD?as)^PjEztMk^zZ=ZaG3` zqpASOf^q~%1&obQ0g?fUg3>!O8&w5J7L?9GDqw7c3Xlls_88DDN62hc6(CtqjsU5E zu@NdjG9XdVEl0>~R23juP>ukpfUyxOKr$dv(5aTlY*ZB>Sx}AuserK&DnK$IQP3?% z$ZS*~R23juP>ukp zfUyxOKr$dv&@D&EY*ZB>Sx}AuserK&DnK$IQP3?%$ZS*~R23juP>ukpfUyxOKr$dv&@D&EY*ZB>Sx}Au zserK&DnK$IQBZnEW}~VA$%4{3NCk|IPyrIjWnf?c-ExG?MpXfl1?32k3K$!q0weJIl%tloKk_F`mkO~+Zp#mfW5(V9Igv>@&0g?sf2#^XG8=(Ru0}=(@a)iuARRNL( zJIl%tloKk_F`mkO~+Zp#mfW z5(V9Igv>@&0g?sf2#^XG8=(Ru0}=(@a)iuARRNL(JIl%tloKk_F`mkO~+Zp#mfW5(V9Igv>@&0g?sf2#^XG8=(Ru z0}=(LcVsrI3Xm))or6@s*a#IMkxB*z2GA`>$ZS*6(AXqDCm|WWHzb_kSr)ifKSx}AuserK&DnK$IQP9mo$ZS*ukpfUyxOKr$dv&|OT(Y*ZB> zSx}AuserK&DnK$IQP7P~$ZS*ukpfUyxOKr$dv&>dOGY*ZB>Sx}AuserK&DnK$IQP53X$ZS*< zAX!k30I7hn5h_43AW_f_RLE>p6(CtqjsU5Eu@NdjG9XbS&)xGDqw6>6(CtqxPnx`*r+N%vY^-lserLjRe)qcX#}JK#zs{E zk_DwikO~+ZRRu^El-@xqU~E(sAX!kZ0;zzpQB{CsL3tOX0>(yF0g?rk5FiyWHmVAc zEGV==Dqw6>6(Ctq$b(eC*f15KwSJ>`Gz3ONU^E0qLtr!nMnizI5a9M;VtB*FzyMmS z4KgV>J2MZoh6BVNs`$ynLi>Lg>+A)mbAV4BamlGW=+0JfFg*F!!8q<3$HluE9eL{> zftF_A@FHmMBm#rl9w3aWnEv;Vf!5`MFlhZYXpJ2MLp*nlqX%2TK|Zi=KrV*45yVDd z&4caDBJrCD(}QWEYfjxkkSx^K&{GESn~1Cjc8?oK2L!`pp>8C}M35frCc?r5 zbRI0k9uSG!*C1EG^x!s;R9}Nk1nI$UA}Aa|J^;B4f*bIj;0kghx*mkdp!A3=TPmKq z|84yfyywB7>nRaW-Twxx2jm`*EXW5iH%=&eYIo*V3SKv&>*+6gYIho}2V^412goLZ z#2_(5T+Be!GcX{04KfkrYfvadWI7TaRtmU$gybQJ z$>_NdSxt-s5R+i0BAbY=2i1)rSx`74e2r-u$W(L_(e)tm zH^|q>vZdmw_HXN-;61q>T~CR4s{I?V9*}E5ZbS|fkQm5K=osCN=z0)t1epkOBT_hm z7KP#6`H!v#VH(IiFj+)6f?@*$5RN8PIMxkSsDAp#rwM60}1SnT=2Zk^$`r1IZ$@5h_5f z1<)=Q&^}CLHbMnR2DBFoB#X>Or~vJ<0_~ClnS;zmr~t`;_CSGTk=Y0ppxsR%7lO<| zW+PO9WI+3uK(feemC;XoXQe}B;Fi^=;10ZHI!F)0n%_1zYxEoxp?W?Bci2I4 zElBof`5Q+OM+UHo--0{#9e8xb0AHC7(xd1gbAUm+$qr=V*WiwQ`yX8~fS3rn;}_&c zkcqH*@ma6>MtmlM^nlz5G7(lUKJ8WC2r*E7ACcJjMc8$q7Ei-XH%iPub{>)j8 z*ViCD8kNci9&9yrNX<;#&pdbazTb0JLw&tR`uu@K3vPjZz1%r?fAbW9{jn}b@!nkw z(vw{~73}L}&cXYerU>khaXGpH;zp1x$k%tjusE-B4&LwU;%ZnsMF4Lb1EdG!>*KTM zIjnRJ-tXh$YFINxz#d{^;fBoz9-G{7O#Q{=yyl1Aex~C}`$Z;g$Lnj5o(!G&2PVz5 zb6EXDZ$IO4rTxN_wnKd_UODZ+&+;>1U$3|zwx9Wq-~JmfEb+z+NRNQRIk2ynUl7~R zbjNT1^%s`Vm;u?BRPxF()QQ!3-4DI}l9RUY`+rOcudhLRZpG*vIO4U!VeJpS{SuS5 z@B4R53F>Q*eV}msw3E$w)dewd3TM3Ihu1`q9#A;u*j;y63Dv`J#}8^^Te|y!pvfm4 zie&+Tq_?BJ#bt8y5qMLR%a8l4cfK}h-@aYG+xKlZkH%{v z$k(z7dI#7pK61D^Y2Ut`zT5Y0GmnOv2=W0aW^UYJcU~sl4?d~$+v!rgCW7>UVn$*1 zZ-=E&Jzr0kLQMpfub^-Qm1YcAw{1*zDBbUJb`stc4$=b(M^I_@|H`(FNe-p^ozG5! zrf`t#3%dj0m;te2eBFCufuX&3!2a8pMezC> zqz9B|K>51o!~#P*?|}WcE{h=f8dUaxQuu@u3pPHwEVAFyJAj~xpt1*)!uwAw*!b|W z$bJj&03;JZWjH8i*spFg3_m+*U!nv4m;t#FREC3MhVAM$!?3fH_9ZwV#|$X0MNn!@ zL=6cGPf&XhQd5HD7#Kit9U;g9+E4+q0Mx64x)D@oykX*U0@VtjI^#RI)&eO4=|o^; z6G3_|>M1yYY6XQuW&6KD^*~|J0Y+eK_z@ExctWNMo<}kxMVumjZ2+__qRaxK->r_>$bCSJAuka zP+2ECX}cXUE4=Ihm36WJ;a`7Q2E$>Vu7KJcYyspBFaZl>N!4pov#-jO+w9#Hux`HA;{ z+@Z4lXCH-ZkZxDi(N zwDbRVTJb|~|DR(@_EwX&<8>oQ52)<9#3y%P`47GQzmF-|TTa>zbt6a?R6ee#|K6|ZqUxW03N(xaSg#+g%?c2A-Jlg)O zFU;4Vk_l9rrCEJ*vd}!c@6kO$50SRN^k{zH|UoO7Di0xKI;8B@-wd7kPbjS}fha?@6rPMo60# zcb)<10fpm%(ANhRN%!x29Ba4n>*-RciJ#79x_JHg`j*5 z$}@^r%{GEcKTt~rk{&@Og32CH3ZHU9!O+}0!2a1~5xl+z=>e5JpcFp&go2@&cYyuV z%OXf_1eK4V)YE@L!SK;#5m5O^&_q!A2ueMDClm}HUKRnBk4Pqh%5YFPg6s}FJIOB5 z0n}f>9gZM%pfVg3jv#gbq})d`5fn3;O&>s;PC*Jl9X6B8^X$H-H&yq8 z@+flZ2CT`ke_0$szMi$-y`$0V`L`ebaX@bfg#jD#4;~h%($Df^qx8?%55!BNJ zl|2eqw;9GclnoYWILlT=wY71|r7x966`f6G3i-xQT&* zh>xOG4D?1>!ZasZWPpkCbCAA0tn5)jdg z6R(^G_BE&-zUqRQ{rtS{ji7!PJ~x8&fZ`g|4qtge%zj>8_eR7h7s!pE@)6W81lb1~ zEd-7H;WH7W2UI?S`h{zL=-Got3x$yTg$|%x2nt7#ebA9Vy!{!F8$r1c6pkw{h}kpV z@!JpTOG3i2E#2J#RN{jAh1VzTvm)N{Tb-! zj6DZvWCn!skIp!N`ZJ)CA|*4?9%FRI0n|1FxpAp;usvvWCV}vny#uIi26E#P=U{u# z=uA9(%pR2fVPh$)A?e>9)SJK;Gax;n{tPJ3toos64;z1hq;OFB2en8+Zd?sX|MsBt zkIzJq9#D%E;dI#B1e!MKs_W-*#pYgpk5WC>;a`MP=5xL z9Qj7bW;RwLG!0p_S%YJJ47U2t!N+`5M$i0+l_tLAemp zL&7`i3ep4WA%V)CTcBJB=^-ITG{I#Ls7)b%sLcNSqYy(L!eap7vIo?rkULanf9_F; zA!ytH;zn4W0ky*uG864VV*sH3JU(B8^nmgVs2v`knP?9h1CWKc!$I{LsCEUlq(FHl z+~ueN5n}*gH-cJHpga@ia?}8248Q@D9ziYpWk2-n-9rG#yS`w9-A)C1}(+?=$}4x@h!PCcM@ z_+sgPyQjqUufZ_`YKJcZ*LKMLYf$^7r}e1KCcqNiyO>S;<7?rDPCkDwF|$`zoV zCa8A`Nj;#r2DN)YalH}}*ZYkL_X{0B?H*8EgVM)uXkQXxVp7Q~M^Fj}$%6W!pwx;l z7lK>?YVCniI4Jdqq4ZrrsRz^o0EOepN&D=!n@1DVi*o?A06^h*V$wd)_&HK94iwj* zRthMtL9G-bdz#=@3Mj5YtrU!&Cb(?|O5vb(7LmPSaN7)&!a+3&YHzr~{=}Ixpd*;T z=l3Jnpk4x`c3@ygu!kg7h+#z*a#JOu%9(^CYT+yF&jy| z0WRJ=*WW(x>^`s>(7E{M&YXd=6YQPN?gX=IlM0a3G}yz`oIT?Ms)Iln>>kKj_Y4fP zW=4XW`pd4`4L3J+|0mmzz*hSkT}fEK66*V-MKmGI-Cts19LN*^?W3^9e}&}*O3QE z;tcj@pz#9L2X>FK@n$4xHH>22dLINVkWY*vrz&aA1J@*LUs;xO+h9#{=$n2783P2khdY zeg~yJgc=2S_=C~|%>AHr0<)_&$-o|2Jz*&se>Bm`mx zNCqSVN*gdXh!0T#S}h3@1<4|_5h{>ZNg}fmDnR-{G9b4gvk@vlDek^!keW+PO< zR-l4pk=Y0ppfCW*fK(u}5h_5tbU-RVvdC4y1?bFgkP472G8>@+ zWH(3#qym|ZPyssI9;5;!i_Au-0G(V93Qv%0k=Y0pAUA+yKq`>g2o<1{>p?0&vdCG9VSmY=jC~1_rQRkSsDAp#tQ7kPJu#G8>@+baFjN1xOZ|jZgtPmmZXIKt4uh zBUFI=0g?f!KxQLUfX<}{sQ}3$vk@vlJ_X5uR3NhvDnRGbgH(WIk=Y0pAb)^lKq`>g z2o<1n=|L($vdC@+bYeV6 z1xOZ|jZguy8zci#fy_pz0G${QQUQ`hW+PO9&VvVqC&;zPY=jDs8$dE3707Ia3eb7* zAQd24WHv$t$PFMFkP2irLIvnNc#sN^EHWFR0_1*>3`hks8=(Sp9y~||NEVrmPyssa z9h7oFK1OCERDk>ek^!keW+PO9PJ0Kb0Ldb=5h_6b0Lg$U;wEA$s)56DnM=k$$(TKvk@vlC&q(RfMk)`2o)grgJeJ|kl6?opq3g) z1xOZ|jZgtPQy!FZKt4uhBUFI=0g?f!KxQLUfXg2o<0+4y1!zeONCik1nT=2Z+6DwVB^_iFG8>@+ zq#q;$Qi04yr~sXi4pIS#BUFIg0FnWzKxQLUfX*%lsQ}3$vk@vl?gz<$R3Nhv zDnMtKgH(WIk=Y0ppgser)d%u1G8>@+h&9fK(u} z5h_4^D3A(}EHWFR0^|>n3`hks8=(T!+XJZp$s)56DnMZXk^!keW+PO9auG-cNEVrm zPyxyXp!3{813$=YgbL6}?Vyv^L8_412o)fGAQ_MfWHv$tC>MZKfMk)`2o<1n*g@y0 zgKR=(BUFI&gJeJ|kl6?opfl7#DnPQxY=jDs-5?o|3S>4y1t=GQRDfiW*$5S&Q`SMJ zq=Q_G%tojHxd9{tQi04yr~sXi4pISOr~vgDK&?KIkCE936(E0rWI!sA*$5S&z6(eNNEVrmPyzA> zNCu<=nT=2Z>O+B4fMk)`2o)fIfMh@_kl6?opuQYP1xOZ|jZgs!1CR_z1u`3<0#v$y zRDfiW*$5S&TmU+G9+aby*$5S&Gvz^N!h=*Hvk@vl`am)u707Ia3Q#TpsQ}3$vk@vl zC&q(LdOr~tVEBm+``%tojHo#hTv0g^># zBUFIg50U|?KxQLUfN}vy1xOZ|jZgvVGk{usARi;M5h_6b0Lg$@+6b2v}kP2ir zLItRF0jU7VBC`=HK)C?a76audWHv$t=mdRG8wjKdnT=2Z(g%_OsX%5URDf~;NCik1 znT=2ZI(r<{_5j(0%tojH=?BSxR3NhvDnMuKgH(WIk=Y0pAiF^_AQi}LgbGkD0I2}U zBC`=HK&SA7>U@xEk=Y0pAUA+yKq`>g2o<1H_(3W_vdCG9VSmY=jEXDf}Q6 zAX#KKLIueEAQ_MfWHv$tC>MZKfMk)`2o<0{1E_Ta@-Z?Sp#tO&kPJu#G8>@+)OP`? z0Ldb=5h_6b0Lg$G~PXmM?+vV1V%$(D1?BsRZM7JNoGk-YKop?m?uN3LO@Y| zR%&tyLrQ8+aZG-0NosLPaSVve$S+PU$}cfQ;pi1-r!XkEW#*(7D`;rxC6#4p)_|!R zr_B7a%;L=aJO!sPM}4O-4`fw|5LJmaPC1z+RmLu0y~ZhEQR9>v=fs>G1^+Y!m(r3- z4MSZcO$Fcll++xMs)}3?D?YWNAit;tq#i|}#wD{THMt~0!2)a>NJ9ijQA7=cX<}Yx hE{L6*0%n44Dqvs$mD{j*0" + + numverts 158 + vert 0 ( 1.000000 0.000000 ) 0 1 + vert 1 ( 1.000000 0.071429 ) 1 1 + vert 2 ( 0.916667 0.071429 ) 2 1 + vert 3 ( 0.833333 0.071429 ) 3 1 + vert 4 ( 0.750000 0.071429 ) 4 1 + vert 5 ( 0.666667 0.071429 ) 5 1 + vert 6 ( 0.583333 0.071429 ) 6 1 + vert 7 ( 0.500000 0.071429 ) 7 1 + vert 8 ( 0.416667 0.071429 ) 8 1 + vert 9 ( 0.333333 0.071429 ) 9 1 + vert 10 ( 0.250000 0.071429 ) 10 1 + vert 11 ( 0.166667 0.071429 ) 11 1 + vert 12 ( 0.083333 0.071429 ) 12 1 + vert 13 ( 1.000000 0.142857 ) 13 1 + vert 14 ( 0.916667 0.142857 ) 14 1 + vert 15 ( 0.833333 0.142857 ) 15 1 + vert 16 ( 0.750000 0.142857 ) 16 1 + vert 17 ( 0.666667 0.142857 ) 17 1 + vert 18 ( 0.583333 0.142857 ) 18 1 + vert 19 ( 0.500000 0.142857 ) 19 1 + vert 20 ( 0.416667 0.142857 ) 20 1 + vert 21 ( 0.333333 0.142857 ) 21 1 + vert 22 ( 0.250000 0.142857 ) 22 1 + vert 23 ( 0.166667 0.142857 ) 23 1 + vert 24 ( 0.083333 0.142857 ) 24 1 + vert 25 ( 1.000000 0.214286 ) 25 1 + vert 26 ( 0.916667 0.214286 ) 26 1 + vert 27 ( 0.833333 0.214286 ) 27 1 + vert 28 ( 0.750000 0.214286 ) 28 1 + vert 29 ( 0.666667 0.214286 ) 29 1 + vert 30 ( 0.583333 0.214286 ) 30 1 + vert 31 ( 0.500000 0.214286 ) 31 1 + vert 32 ( 0.416667 0.214286 ) 32 1 + vert 33 ( 0.333333 0.214286 ) 33 1 + vert 34 ( 0.250000 0.214286 ) 34 1 + vert 35 ( 0.166667 0.214286 ) 35 1 + vert 36 ( 0.083333 0.214286 ) 36 1 + vert 37 ( 1.000000 0.285714 ) 37 1 + vert 38 ( 0.916667 0.285714 ) 38 1 + vert 39 ( 0.833333 0.285714 ) 39 1 + vert 40 ( 0.750000 0.285714 ) 40 1 + vert 41 ( 0.666667 0.285714 ) 41 1 + vert 42 ( 0.583333 0.285714 ) 42 1 + vert 43 ( 0.500000 0.285714 ) 43 1 + vert 44 ( 0.416667 0.285714 ) 44 1 + vert 45 ( 0.333333 0.285714 ) 45 1 + vert 46 ( 0.250000 0.285714 ) 46 1 + vert 47 ( 0.166667 0.285714 ) 47 1 + vert 48 ( 0.083333 0.285714 ) 48 1 + vert 49 ( 1.000000 0.357143 ) 49 1 + vert 50 ( 0.916667 0.357143 ) 50 1 + vert 51 ( 0.833333 0.357143 ) 51 1 + vert 52 ( 0.750000 0.357143 ) 52 1 + vert 53 ( 0.666667 0.357143 ) 53 1 + vert 54 ( 0.583333 0.357143 ) 54 1 + vert 55 ( 0.500000 0.357143 ) 55 1 + vert 56 ( 0.416667 0.357143 ) 56 1 + vert 57 ( 0.333333 0.357143 ) 57 1 + vert 58 ( 0.250000 0.357143 ) 58 1 + vert 59 ( 0.166667 0.357143 ) 59 1 + vert 60 ( 0.083333 0.357143 ) 60 1 + vert 61 ( 1.000000 0.428571 ) 61 1 + vert 62 ( 0.916667 0.428571 ) 62 1 + vert 63 ( 0.833333 0.428571 ) 63 1 + vert 64 ( 0.750000 0.428571 ) 64 1 + vert 65 ( 0.666667 0.428571 ) 65 1 + vert 66 ( 0.583333 0.428571 ) 66 1 + vert 67 ( 0.500000 0.428571 ) 67 1 + vert 68 ( 0.416667 0.428571 ) 68 1 + vert 69 ( 0.333333 0.428571 ) 69 1 + vert 70 ( 0.250000 0.428571 ) 70 1 + vert 71 ( 0.166667 0.428571 ) 71 1 + vert 72 ( 0.083333 0.428571 ) 72 1 + vert 73 ( 1.000000 0.500000 ) 73 1 + vert 74 ( 0.916667 0.500000 ) 74 1 + vert 75 ( 0.833333 0.500000 ) 75 1 + vert 76 ( 0.750000 0.500000 ) 76 1 + vert 77 ( 0.666667 0.500000 ) 77 1 + vert 78 ( 0.583333 0.500000 ) 78 1 + vert 79 ( 0.500000 0.500000 ) 79 1 + vert 80 ( 0.416667 0.500000 ) 80 1 + vert 81 ( 0.333333 0.500000 ) 81 1 + vert 82 ( 0.250000 0.500000 ) 82 1 + vert 83 ( 0.166667 0.500000 ) 83 1 + vert 84 ( 0.083333 0.500000 ) 84 1 + vert 85 ( 1.000000 0.571429 ) 85 1 + vert 86 ( 0.916667 0.571429 ) 86 1 + vert 87 ( 0.833333 0.571429 ) 87 1 + vert 88 ( 0.750000 0.571429 ) 88 1 + vert 89 ( 0.666667 0.571429 ) 89 1 + vert 90 ( 0.583333 0.571429 ) 90 1 + vert 91 ( 0.500000 0.571429 ) 91 1 + vert 92 ( 0.416667 0.571429 ) 92 1 + vert 93 ( 0.333333 0.571429 ) 93 1 + vert 94 ( 0.250000 0.571429 ) 94 1 + vert 95 ( 0.166667 0.571429 ) 95 1 + vert 96 ( 0.083333 0.571429 ) 96 1 + vert 97 ( 1.000000 0.642857 ) 97 1 + vert 98 ( 0.916667 0.642857 ) 98 1 + vert 99 ( 0.833333 0.642857 ) 99 1 + vert 100 ( 0.750000 0.642857 ) 100 1 + vert 101 ( 0.666667 0.642857 ) 101 1 + vert 102 ( 0.583333 0.642857 ) 102 1 + vert 103 ( 0.500000 0.642857 ) 103 1 + vert 104 ( 0.416667 0.642857 ) 104 1 + vert 105 ( 0.333333 0.642857 ) 105 1 + vert 106 ( 0.250000 0.642857 ) 106 1 + vert 107 ( 0.166667 0.642857 ) 107 1 + vert 108 ( 0.083333 0.642857 ) 108 1 + vert 109 ( 1.000000 0.714286 ) 109 1 + vert 110 ( 0.916667 0.714286 ) 110 1 + vert 111 ( 0.833333 0.714286 ) 111 1 + vert 112 ( 0.750000 0.714286 ) 112 1 + vert 113 ( 0.666667 0.714286 ) 113 1 + vert 114 ( 0.583333 0.714286 ) 114 1 + vert 115 ( 0.500000 0.714286 ) 115 1 + vert 116 ( 0.416667 0.714286 ) 116 1 + vert 117 ( 0.333333 0.714286 ) 117 1 + vert 118 ( 0.250000 0.714286 ) 118 1 + vert 119 ( 0.166667 0.714286 ) 119 1 + vert 120 ( 0.083333 0.714286 ) 120 1 + vert 121 ( 1.000000 0.785714 ) 121 1 + vert 122 ( 0.916667 0.785714 ) 122 1 + vert 123 ( 0.833333 0.785714 ) 123 1 + vert 124 ( 0.750000 0.785714 ) 124 1 + vert 125 ( 0.666667 0.785714 ) 125 1 + vert 126 ( 0.583333 0.785714 ) 126 1 + vert 127 ( 0.500000 0.785714 ) 127 1 + vert 128 ( 0.416667 0.785714 ) 128 1 + vert 129 ( 0.333333 0.785714 ) 129 1 + vert 130 ( 0.250000 0.785714 ) 130 1 + vert 131 ( 0.166667 0.785714 ) 131 1 + vert 132 ( 0.083333 0.785714 ) 132 1 + vert 133 ( 1.000000 0.857143 ) 133 1 + vert 134 ( 0.916667 0.857143 ) 134 1 + vert 135 ( 0.833333 0.857143 ) 135 1 + vert 136 ( 0.750000 0.857143 ) 136 1 + vert 137 ( 0.666667 0.857143 ) 137 1 + vert 138 ( 0.583333 0.857143 ) 138 1 + vert 139 ( 0.500000 0.857143 ) 139 1 + vert 140 ( 0.416667 0.857143 ) 140 1 + vert 141 ( 0.333333 0.857143 ) 141 1 + vert 142 ( 0.250000 0.857143 ) 142 1 + vert 143 ( 0.166667 0.857143 ) 143 1 + vert 144 ( 0.083333 0.857143 ) 144 1 + vert 145 ( 1.000000 0.928572 ) 145 1 + vert 146 ( 0.916667 0.928572 ) 146 1 + vert 147 ( 0.833333 0.928572 ) 147 1 + vert 148 ( 0.750000 0.928572 ) 148 1 + vert 149 ( 0.666667 0.928572 ) 149 1 + vert 150 ( 0.583333 0.928572 ) 150 1 + vert 151 ( 0.500000 0.928572 ) 151 1 + vert 152 ( 0.416667 0.928572 ) 152 1 + vert 153 ( 0.333333 0.928572 ) 153 1 + vert 154 ( 0.250000 0.928572 ) 154 1 + vert 155 ( 0.166667 0.928572 ) 155 1 + vert 156 ( 0.083333 0.928572 ) 156 1 + vert 157 ( 0.500000 1.000000 ) 157 1 + + numtris 312 + tri 0 0 1 2 + tri 1 0 2 3 + tri 2 0 3 4 + tri 3 0 4 5 + tri 4 0 5 6 + tri 5 0 6 7 + tri 6 0 7 8 + tri 7 0 8 9 + tri 8 0 9 10 + tri 9 0 10 11 + tri 10 0 11 12 + tri 11 0 12 1 + tri 12 1 13 14 + tri 13 1 14 2 + tri 14 2 14 15 + tri 15 2 15 3 + tri 16 3 15 16 + tri 17 3 16 4 + tri 18 4 16 17 + tri 19 4 17 5 + tri 20 5 17 18 + tri 21 5 18 6 + tri 22 6 18 19 + tri 23 6 19 7 + tri 24 7 19 20 + tri 25 7 20 8 + tri 26 8 20 21 + tri 27 8 21 9 + tri 28 9 21 22 + tri 29 9 22 10 + tri 30 10 22 23 + tri 31 10 23 11 + tri 32 11 23 24 + tri 33 11 24 12 + tri 34 12 24 13 + tri 35 12 13 1 + tri 36 13 25 26 + tri 37 13 26 14 + tri 38 14 26 27 + tri 39 14 27 15 + tri 40 15 27 28 + tri 41 15 28 16 + tri 42 16 28 29 + tri 43 16 29 17 + tri 44 17 29 30 + tri 45 17 30 18 + tri 46 18 30 31 + tri 47 18 31 19 + tri 48 19 31 32 + tri 49 19 32 20 + tri 50 20 32 33 + tri 51 20 33 21 + tri 52 21 33 34 + tri 53 21 34 22 + tri 54 22 34 35 + tri 55 22 35 23 + tri 56 23 35 36 + tri 57 23 36 24 + tri 58 24 36 25 + tri 59 24 25 13 + tri 60 25 37 38 + tri 61 25 38 26 + tri 62 26 38 39 + tri 63 26 39 27 + tri 64 27 39 40 + tri 65 27 40 28 + tri 66 28 40 41 + tri 67 28 41 29 + tri 68 29 41 42 + tri 69 29 42 30 + tri 70 30 42 43 + tri 71 30 43 31 + tri 72 31 43 44 + tri 73 31 44 32 + tri 74 32 44 45 + tri 75 32 45 33 + tri 76 33 45 46 + tri 77 33 46 34 + tri 78 34 46 47 + tri 79 34 47 35 + tri 80 35 47 48 + tri 81 35 48 36 + tri 82 36 48 37 + tri 83 36 37 25 + tri 84 37 49 50 + tri 85 37 50 38 + tri 86 38 50 51 + tri 87 38 51 39 + tri 88 39 51 52 + tri 89 39 52 40 + tri 90 40 52 53 + tri 91 40 53 41 + tri 92 41 53 54 + tri 93 41 54 42 + tri 94 42 54 55 + tri 95 42 55 43 + tri 96 43 55 56 + tri 97 43 56 44 + tri 98 44 56 57 + tri 99 44 57 45 + tri 100 45 57 58 + tri 101 45 58 46 + tri 102 46 58 59 + tri 103 46 59 47 + tri 104 47 59 60 + tri 105 47 60 48 + tri 106 48 60 49 + tri 107 48 49 37 + tri 108 49 61 62 + tri 109 49 62 50 + tri 110 50 62 63 + tri 111 50 63 51 + tri 112 51 63 64 + tri 113 51 64 52 + tri 114 52 64 65 + tri 115 52 65 53 + tri 116 53 65 66 + tri 117 53 66 54 + tri 118 54 66 67 + tri 119 54 67 55 + tri 120 55 67 68 + tri 121 55 68 56 + tri 122 56 68 69 + tri 123 56 69 57 + tri 124 57 69 70 + tri 125 57 70 58 + tri 126 58 70 71 + tri 127 58 71 59 + tri 128 59 71 72 + tri 129 59 72 60 + tri 130 60 72 61 + tri 131 60 61 49 + tri 132 61 73 74 + tri 133 61 74 62 + tri 134 62 74 75 + tri 135 62 75 63 + tri 136 63 75 76 + tri 137 63 76 64 + tri 138 64 76 77 + tri 139 64 77 65 + tri 140 65 77 78 + tri 141 65 78 66 + tri 142 66 78 79 + tri 143 66 79 67 + tri 144 67 79 80 + tri 145 67 80 68 + tri 146 68 80 81 + tri 147 68 81 69 + tri 148 69 81 82 + tri 149 69 82 70 + tri 150 70 82 83 + tri 151 70 83 71 + tri 152 71 83 84 + tri 153 71 84 72 + tri 154 72 84 73 + tri 155 72 73 61 + tri 156 73 85 86 + tri 157 73 86 74 + tri 158 74 86 87 + tri 159 74 87 75 + tri 160 75 87 88 + tri 161 75 88 76 + tri 162 76 88 89 + tri 163 76 89 77 + tri 164 77 89 90 + tri 165 77 90 78 + tri 166 78 90 91 + tri 167 78 91 79 + tri 168 79 91 92 + tri 169 79 92 80 + tri 170 80 92 93 + tri 171 80 93 81 + tri 172 81 93 94 + tri 173 81 94 82 + tri 174 82 94 95 + tri 175 82 95 83 + tri 176 83 95 96 + tri 177 83 96 84 + tri 178 84 96 85 + tri 179 84 85 73 + tri 180 85 97 98 + tri 181 85 98 86 + tri 182 86 98 99 + tri 183 86 99 87 + tri 184 87 99 100 + tri 185 87 100 88 + tri 186 88 100 101 + tri 187 88 101 89 + tri 188 89 101 102 + tri 189 89 102 90 + tri 190 90 102 103 + tri 191 90 103 91 + tri 192 91 103 104 + tri 193 91 104 92 + tri 194 92 104 105 + tri 195 92 105 93 + tri 196 93 105 106 + tri 197 93 106 94 + tri 198 94 106 107 + tri 199 94 107 95 + tri 200 95 107 108 + tri 201 95 108 96 + tri 202 96 108 97 + tri 203 96 97 85 + tri 204 97 109 110 + tri 205 97 110 98 + tri 206 98 110 111 + tri 207 98 111 99 + tri 208 99 111 112 + tri 209 99 112 100 + tri 210 100 112 113 + tri 211 100 113 101 + tri 212 101 113 114 + tri 213 101 114 102 + tri 214 102 114 115 + tri 215 102 115 103 + tri 216 103 115 116 + tri 217 103 116 104 + tri 218 104 116 117 + tri 219 104 117 105 + tri 220 105 117 118 + tri 221 105 118 106 + tri 222 106 118 119 + tri 223 106 119 107 + tri 224 107 119 120 + tri 225 107 120 108 + tri 226 108 120 109 + tri 227 108 109 97 + tri 228 109 121 122 + tri 229 109 122 110 + tri 230 110 122 123 + tri 231 110 123 111 + tri 232 111 123 124 + tri 233 111 124 112 + tri 234 112 124 125 + tri 235 112 125 113 + tri 236 113 125 126 + tri 237 113 126 114 + tri 238 114 126 127 + tri 239 114 127 115 + tri 240 115 127 128 + tri 241 115 128 116 + tri 242 116 128 129 + tri 243 116 129 117 + tri 244 117 129 130 + tri 245 117 130 118 + tri 246 118 130 131 + tri 247 118 131 119 + tri 248 119 131 132 + tri 249 119 132 120 + tri 250 120 132 121 + tri 251 120 121 109 + tri 252 121 133 134 + tri 253 121 134 122 + tri 254 122 134 135 + tri 255 122 135 123 + tri 256 123 135 136 + tri 257 123 136 124 + tri 258 124 136 137 + tri 259 124 137 125 + tri 260 125 137 138 + tri 261 125 138 126 + tri 262 126 138 139 + tri 263 126 139 127 + tri 264 127 139 140 + tri 265 127 140 128 + tri 266 128 140 141 + tri 267 128 141 129 + tri 268 129 141 142 + tri 269 129 142 130 + tri 270 130 142 143 + tri 271 130 143 131 + tri 272 131 143 144 + tri 273 131 144 132 + tri 274 132 144 133 + tri 275 132 133 121 + tri 276 133 145 146 + tri 277 133 146 134 + tri 278 134 146 147 + tri 279 134 147 135 + tri 280 135 147 148 + tri 281 135 148 136 + tri 282 136 148 149 + tri 283 136 149 137 + tri 284 137 149 150 + tri 285 137 150 138 + tri 286 138 150 151 + tri 287 138 151 139 + tri 288 139 151 152 + tri 289 139 152 140 + tri 290 140 152 153 + tri 291 140 153 141 + tri 292 141 153 154 + tri 293 141 154 142 + tri 294 142 154 155 + tri 295 142 155 143 + tri 296 143 155 156 + tri 297 143 156 144 + tri 298 144 156 145 + tri 299 144 145 133 + tri 300 157 156 155 + tri 301 157 155 154 + tri 302 157 154 153 + tri 303 157 153 152 + tri 304 157 152 151 + tri 305 157 151 150 + tri 306 157 150 149 + tri 307 157 149 148 + tri 308 157 148 147 + tri 309 157 147 146 + tri 310 157 146 145 + tri 311 157 145 156 + + numweights 158 + weight 0 1 1.000000 ( -7.999999 0.268350 0.019730 ) + weight 1 1 1.000000 ( -7.799419 0.268350 1.799904 ) + weight 2 1 1.000000 ( -7.799419 -0.621734 1.561401 ) + weight 3 1 1.000000 ( -7.799419 -1.273320 0.909821 ) + weight 4 1 1.000000 ( -7.799419 -1.511817 0.019730 ) + weight 5 1 1.000000 ( -7.799419 -1.273320 -0.870335 ) + weight 6 1 1.000000 ( -7.799419 -0.621734 -1.521923 ) + weight 7 1 1.000000 ( -7.799419 0.268349 -1.760418 ) + weight 8 1 1.000000 ( -7.799419 1.158433 -1.521923 ) + weight 9 1 1.000000 ( -7.799419 1.810019 -0.870335 ) + weight 10 1 1.000000 ( -7.799419 2.048517 0.019730 ) + weight 11 1 1.000000 ( -7.799419 1.810020 0.909821 ) + weight 12 1 1.000000 ( -7.799419 1.158434 1.561401 ) + weight 13 1 1.000000 ( -7.207747 0.268350 3.490807 ) + weight 14 1 1.000000 ( -7.207747 -1.467185 3.025764 ) + weight 15 1 1.000000 ( -7.207747 -2.737684 1.755264 ) + weight 16 1 1.000000 ( -7.207747 -3.202720 0.019730 ) + weight 17 1 1.000000 ( -7.207747 -2.737684 -1.715786 ) + weight 18 1 1.000000 ( -7.207747 -1.467185 -2.986286 ) + weight 19 1 1.000000 ( -7.207747 0.268349 -3.451321 ) + weight 20 1 1.000000 ( -7.207747 2.003884 -2.986286 ) + weight 21 1 1.000000 ( -7.207747 3.274384 -1.715786 ) + weight 22 1 1.000000 ( -7.207747 3.739419 0.019730 ) + weight 23 1 1.000000 ( -7.207747 3.274385 1.755264 ) + weight 24 1 1.000000 ( -7.207747 2.003887 3.025764 ) + weight 25 1 1.000000 ( -6.254651 0.268350 5.007645 ) + weight 26 1 1.000000 ( -6.254651 -2.225609 4.339394 ) + weight 27 1 1.000000 ( -6.254651 -4.051311 2.513695 ) + weight 28 1 1.000000 ( -6.254651 -4.719565 0.019730 ) + weight 29 1 1.000000 ( -6.254651 -4.051311 -2.474213 ) + weight 30 1 1.000000 ( -6.254651 -2.225609 -4.299915 ) + weight 31 1 1.000000 ( -6.254651 0.268349 -4.968170 ) + weight 32 1 1.000000 ( -6.254651 2.762308 -4.299915 ) + weight 33 1 1.000000 ( -6.254651 4.588012 -2.474213 ) + weight 34 1 1.000000 ( -6.254651 5.256268 0.019730 ) + weight 35 1 1.000000 ( -6.254651 4.588015 2.513695 ) + weight 36 1 1.000000 ( -6.254651 2.762312 4.339394 ) + weight 37 1 1.000000 ( -4.987916 0.268350 6.274384 ) + weight 38 1 1.000000 ( -4.987916 -2.858975 5.436417 ) + weight 39 1 1.000000 ( -4.987916 -5.148335 3.147057 ) + weight 40 1 1.000000 ( -4.987916 -5.986300 0.019730 ) + weight 41 1 1.000000 ( -4.987916 -5.148335 -3.107578 ) + weight 42 1 1.000000 ( -4.987916 -2.858976 -5.396938 ) + weight 43 1 1.000000 ( -4.987916 0.268349 -6.234905 ) + weight 44 1 1.000000 ( -4.987916 3.395674 -5.396938 ) + weight 45 1 1.000000 ( -4.987916 5.685035 -3.107578 ) + weight 46 1 1.000000 ( -4.987916 6.523001 0.019730 ) + weight 47 1 1.000000 ( -4.987916 5.685038 3.147057 ) + weight 48 1 1.000000 ( -4.987916 3.395679 5.436417 ) + weight 49 1 1.000000 ( -3.471070 0.268350 7.227486 ) + weight 50 1 1.000000 ( -3.471070 -3.335525 6.261826 ) + weight 51 1 1.000000 ( -3.471070 -5.973742 3.623611 ) + weight 52 1 1.000000 ( -3.471070 -6.939400 0.019730 ) + weight 53 1 1.000000 ( -3.471070 -5.973742 -3.584126 ) + weight 54 1 1.000000 ( -3.471070 -3.335525 -6.222347 ) + weight 55 1 1.000000 ( -3.471070 0.268349 -7.188004 ) + weight 56 1 1.000000 ( -3.471070 3.872223 -6.222347 ) + weight 57 1 1.000000 ( -3.471070 6.510443 -3.584129 ) + weight 58 1 1.000000 ( -3.471070 7.476099 0.019730 ) + weight 59 1 1.000000 ( -3.471070 6.510446 3.623611 ) + weight 60 1 1.000000 ( -3.471070 3.872229 6.261826 ) + weight 61 1 1.000000 ( -1.780168 0.268350 7.819160 ) + weight 62 1 1.000000 ( -1.780168 -3.631361 6.774239 ) + weight 63 1 1.000000 ( -1.780168 -6.486145 3.919441 ) + weight 64 1 1.000000 ( -1.780168 -7.531073 0.019730 ) + weight 65 1 1.000000 ( -1.780168 -6.486145 -3.879963 ) + weight 66 1 1.000000 ( -1.780168 -3.631361 -6.734749 ) + weight 67 1 1.000000 ( -1.780168 0.268349 -7.779675 ) + weight 68 1 1.000000 ( -1.780168 4.168056 -6.734753 ) + weight 69 1 1.000000 ( -1.780168 7.022846 -3.879967 ) + weight 70 1 1.000000 ( -1.780168 8.067769 0.019730 ) + weight 71 1 1.000000 ( -1.780168 7.022850 3.919434 ) + weight 72 1 1.000000 ( -1.780168 4.168066 6.774223 ) + weight 73 1 1.000000 ( -0.000001 0.268350 8.019737 ) + weight 74 1 1.000000 ( -0.000001 -3.731649 6.947929 ) + weight 75 1 1.000000 ( -0.000001 -6.659853 4.019730 ) + weight 76 1 1.000000 ( -0.000001 -7.731647 0.019730 ) + weight 77 1 1.000000 ( -0.000001 -6.659853 -3.980251 ) + weight 78 1 1.000000 ( -0.000001 -3.731650 -6.908455 ) + weight 79 1 1.000000 ( -0.000001 0.268349 -7.980251 ) + weight 80 1 1.000000 ( -0.000001 4.268348 -6.908455 ) + weight 81 1 1.000000 ( -0.000001 7.196548 -3.980255 ) + weight 82 1 1.000000 ( -0.000001 8.268346 0.019730 ) + weight 83 1 1.000000 ( -0.000001 7.196554 4.019722 ) + weight 84 1 1.000000 ( -0.000001 4.268353 6.947929 ) + weight 85 1 1.000000 ( 1.780166 0.268350 7.819160 ) + weight 86 1 1.000000 ( 1.780166 -3.631361 6.774239 ) + weight 87 1 1.000000 ( 1.780166 -6.486145 3.919441 ) + weight 88 1 1.000000 ( 1.780166 -7.531073 0.019730 ) + weight 89 1 1.000000 ( 1.780166 -6.486145 -3.879963 ) + weight 90 1 1.000000 ( 1.780166 -3.631361 -6.734749 ) + weight 91 1 1.000000 ( 1.780166 0.268349 -7.779675 ) + weight 92 1 1.000000 ( 1.780166 4.168056 -6.734753 ) + weight 93 1 1.000000 ( 1.780166 7.022846 -3.879967 ) + weight 94 1 1.000000 ( 1.780166 8.067770 0.019730 ) + weight 95 1 1.000000 ( 1.780166 7.022850 3.919441 ) + weight 96 1 1.000000 ( 1.780166 4.168066 6.774223 ) + weight 97 1 1.000000 ( 3.471068 0.268350 7.227486 ) + weight 98 1 1.000000 ( 3.471068 -3.335525 6.261826 ) + weight 99 1 1.000000 ( 3.471068 -5.973742 3.623611 ) + weight 100 1 1.000000 ( 3.471068 -6.939401 0.019730 ) + weight 101 1 1.000000 ( 3.471068 -5.973742 -3.584126 ) + weight 102 1 1.000000 ( 3.471068 -3.335526 -6.222347 ) + weight 103 1 1.000000 ( 3.471068 0.268349 -7.188004 ) + weight 104 1 1.000000 ( 3.471068 3.872223 -6.222347 ) + weight 105 1 1.000000 ( 3.471068 6.510443 -3.584129 ) + weight 106 1 1.000000 ( 3.471068 7.476099 0.019730 ) + weight 107 1 1.000000 ( 3.471068 6.510447 3.623611 ) + weight 108 1 1.000000 ( 3.471068 3.872230 6.261826 ) + weight 109 1 1.000000 ( 4.987916 0.268350 6.274384 ) + weight 110 1 1.000000 ( 4.987916 -2.858975 5.436417 ) + weight 111 1 1.000000 ( 4.987916 -5.148335 3.147057 ) + weight 112 1 1.000000 ( 4.987916 -5.986300 0.019730 ) + weight 113 1 1.000000 ( 4.987916 -5.148335 -3.107578 ) + weight 114 1 1.000000 ( 4.987916 -2.858976 -5.396938 ) + weight 115 1 1.000000 ( 4.987916 0.268349 -6.234905 ) + weight 116 1 1.000000 ( 4.987916 3.395674 -5.396938 ) + weight 117 1 1.000000 ( 4.987916 5.685035 -3.107578 ) + weight 118 1 1.000000 ( 4.987916 6.523001 0.019730 ) + weight 119 1 1.000000 ( 4.987916 5.685038 3.147057 ) + weight 120 1 1.000000 ( 4.987916 3.395679 5.436417 ) + weight 121 1 1.000000 ( 6.254651 0.268350 5.007645 ) + weight 122 1 1.000000 ( 6.254651 -2.225608 4.339394 ) + weight 123 1 1.000000 ( 6.254651 -4.051311 2.513695 ) + weight 124 1 1.000000 ( 6.254651 -4.719564 0.019730 ) + weight 125 1 1.000000 ( 6.254651 -4.051311 -2.474209 ) + weight 126 1 1.000000 ( 6.254651 -2.225609 -4.299915 ) + weight 127 1 1.000000 ( 6.254651 0.268349 -4.968170 ) + weight 128 1 1.000000 ( 6.254651 2.762307 -4.299915 ) + weight 129 1 1.000000 ( 6.254651 4.588008 -2.474213 ) + weight 130 1 1.000000 ( 6.254651 5.256267 0.019730 ) + weight 131 1 1.000000 ( 6.254651 4.588014 2.513695 ) + weight 132 1 1.000000 ( 6.254651 2.762311 4.339394 ) + weight 133 1 1.000000 ( 7.207747 0.268350 3.490807 ) + weight 134 1 1.000000 ( 7.207747 -1.467184 3.025764 ) + weight 135 1 1.000000 ( 7.207747 -2.737683 1.755264 ) + weight 136 1 1.000000 ( 7.207747 -3.202718 0.019730 ) + weight 137 1 1.000000 ( 7.207747 -2.737683 -1.715786 ) + weight 138 1 1.000000 ( 7.207747 -1.467185 -2.986286 ) + weight 139 1 1.000000 ( 7.207747 0.268349 -3.451321 ) + weight 140 1 1.000000 ( 7.207747 2.003883 -2.986286 ) + weight 141 1 1.000000 ( 7.207747 3.274383 -1.715786 ) + weight 142 1 1.000000 ( 7.207747 3.739419 0.019730 ) + weight 143 1 1.000000 ( 7.207747 3.274384 1.755264 ) + weight 144 1 1.000000 ( 7.207747 2.003886 3.025764 ) + weight 145 1 1.000000 ( 7.799423 0.268350 1.799904 ) + weight 146 1 1.000000 ( 7.799423 -0.621733 1.561401 ) + weight 147 1 1.000000 ( 7.799423 -1.273319 0.909821 ) + weight 148 1 1.000000 ( 7.799423 -1.511816 0.019730 ) + weight 149 1 1.000000 ( 7.799423 -1.273319 -0.870335 ) + weight 150 1 1.000000 ( 7.799423 -0.621733 -1.521919 ) + weight 151 1 1.000000 ( 7.799423 0.268349 -1.760418 ) + weight 152 1 1.000000 ( 7.799423 1.158432 -1.521919 ) + weight 153 1 1.000000 ( 7.799423 1.810018 -0.870335 ) + weight 154 1 1.000000 ( 7.799423 2.048515 0.019730 ) + weight 155 1 1.000000 ( 7.799423 1.810019 0.909821 ) + weight 156 1 1.000000 ( 7.799423 1.158433 1.561401 ) + weight 157 1 1.000000 ( 7.999999 0.268350 0.019730 ) +} + +mesh { + // meshes: Skin1 + shader "" + + numverts 158 + vert 0 ( 1.000000 0.000000 ) 0 1 + vert 1 ( 1.000000 0.071429 ) 1 1 + vert 2 ( 0.916667 0.071429 ) 2 1 + vert 3 ( 0.833333 0.071429 ) 3 1 + vert 4 ( 0.750000 0.071429 ) 4 1 + vert 5 ( 0.666667 0.071429 ) 5 1 + vert 6 ( 0.583333 0.071429 ) 6 1 + vert 7 ( 0.500000 0.071429 ) 7 1 + vert 8 ( 0.416667 0.071429 ) 8 1 + vert 9 ( 0.333333 0.071429 ) 9 1 + vert 10 ( 0.250000 0.071429 ) 10 1 + vert 11 ( 0.166667 0.071429 ) 11 1 + vert 12 ( 0.083333 0.071429 ) 12 1 + vert 13 ( 1.000000 0.142857 ) 13 1 + vert 14 ( 0.916667 0.142857 ) 14 1 + vert 15 ( 0.833333 0.142857 ) 15 1 + vert 16 ( 0.750000 0.142857 ) 16 1 + vert 17 ( 0.666667 0.142857 ) 17 1 + vert 18 ( 0.583333 0.142857 ) 18 1 + vert 19 ( 0.500000 0.142857 ) 19 1 + vert 20 ( 0.416667 0.142857 ) 20 1 + vert 21 ( 0.333333 0.142857 ) 21 1 + vert 22 ( 0.250000 0.142857 ) 22 1 + vert 23 ( 0.166667 0.142857 ) 23 1 + vert 24 ( 0.083333 0.142857 ) 24 1 + vert 25 ( 1.000000 0.214286 ) 25 1 + vert 26 ( 0.916667 0.214286 ) 26 1 + vert 27 ( 0.833333 0.214286 ) 27 1 + vert 28 ( 0.750000 0.214286 ) 28 1 + vert 29 ( 0.666667 0.214286 ) 29 1 + vert 30 ( 0.583333 0.214286 ) 30 1 + vert 31 ( 0.500000 0.214286 ) 31 1 + vert 32 ( 0.416667 0.214286 ) 32 1 + vert 33 ( 0.333333 0.214286 ) 33 1 + vert 34 ( 0.250000 0.214286 ) 34 1 + vert 35 ( 0.166667 0.214286 ) 35 1 + vert 36 ( 0.083333 0.214286 ) 36 1 + vert 37 ( 1.000000 0.285714 ) 37 1 + vert 38 ( 0.916667 0.285714 ) 38 1 + vert 39 ( 0.833333 0.285714 ) 39 1 + vert 40 ( 0.750000 0.285714 ) 40 1 + vert 41 ( 0.666667 0.285714 ) 41 1 + vert 42 ( 0.583333 0.285714 ) 42 1 + vert 43 ( 0.500000 0.285714 ) 43 1 + vert 44 ( 0.416667 0.285714 ) 44 1 + vert 45 ( 0.333333 0.285714 ) 45 1 + vert 46 ( 0.250000 0.285714 ) 46 1 + vert 47 ( 0.166667 0.285714 ) 47 1 + vert 48 ( 0.083333 0.285714 ) 48 1 + vert 49 ( 1.000000 0.357143 ) 49 1 + vert 50 ( 0.916667 0.357143 ) 50 1 + vert 51 ( 0.833333 0.357143 ) 51 1 + vert 52 ( 0.750000 0.357143 ) 52 1 + vert 53 ( 0.666667 0.357143 ) 53 1 + vert 54 ( 0.583333 0.357143 ) 54 1 + vert 55 ( 0.500000 0.357143 ) 55 1 + vert 56 ( 0.416667 0.357143 ) 56 1 + vert 57 ( 0.333333 0.357143 ) 57 1 + vert 58 ( 0.250000 0.357143 ) 58 1 + vert 59 ( 0.166667 0.357143 ) 59 1 + vert 60 ( 0.083333 0.357143 ) 60 1 + vert 61 ( 1.000000 0.428571 ) 61 1 + vert 62 ( 0.916667 0.428571 ) 62 1 + vert 63 ( 0.833333 0.428571 ) 63 1 + vert 64 ( 0.750000 0.428571 ) 64 1 + vert 65 ( 0.666667 0.428571 ) 65 1 + vert 66 ( 0.583333 0.428571 ) 66 1 + vert 67 ( 0.500000 0.428571 ) 67 1 + vert 68 ( 0.416667 0.428571 ) 68 1 + vert 69 ( 0.333333 0.428571 ) 69 1 + vert 70 ( 0.250000 0.428571 ) 70 1 + vert 71 ( 0.166667 0.428571 ) 71 1 + vert 72 ( 0.083333 0.428571 ) 72 1 + vert 73 ( 1.000000 0.500000 ) 73 1 + vert 74 ( 0.916667 0.500000 ) 74 1 + vert 75 ( 0.833333 0.500000 ) 75 1 + vert 76 ( 0.750000 0.500000 ) 76 1 + vert 77 ( 0.666667 0.500000 ) 77 1 + vert 78 ( 0.583333 0.500000 ) 78 1 + vert 79 ( 0.500000 0.500000 ) 79 1 + vert 80 ( 0.416667 0.500000 ) 80 1 + vert 81 ( 0.333333 0.500000 ) 81 1 + vert 82 ( 0.250000 0.500000 ) 82 1 + vert 83 ( 0.166667 0.500000 ) 83 1 + vert 84 ( 0.083333 0.500000 ) 84 1 + vert 85 ( 1.000000 0.571429 ) 85 1 + vert 86 ( 0.916667 0.571429 ) 86 1 + vert 87 ( 0.833333 0.571429 ) 87 1 + vert 88 ( 0.750000 0.571429 ) 88 1 + vert 89 ( 0.666667 0.571429 ) 89 1 + vert 90 ( 0.583333 0.571429 ) 90 1 + vert 91 ( 0.500000 0.571429 ) 91 1 + vert 92 ( 0.416667 0.571429 ) 92 1 + vert 93 ( 0.333333 0.571429 ) 93 1 + vert 94 ( 0.250000 0.571429 ) 94 1 + vert 95 ( 0.166667 0.571429 ) 95 1 + vert 96 ( 0.083333 0.571429 ) 96 1 + vert 97 ( 1.000000 0.642857 ) 97 1 + vert 98 ( 0.916667 0.642857 ) 98 1 + vert 99 ( 0.833333 0.642857 ) 99 1 + vert 100 ( 0.750000 0.642857 ) 100 1 + vert 101 ( 0.666667 0.642857 ) 101 1 + vert 102 ( 0.583333 0.642857 ) 102 1 + vert 103 ( 0.500000 0.642857 ) 103 1 + vert 104 ( 0.416667 0.642857 ) 104 1 + vert 105 ( 0.333333 0.642857 ) 105 1 + vert 106 ( 0.250000 0.642857 ) 106 1 + vert 107 ( 0.166667 0.642857 ) 107 1 + vert 108 ( 0.083333 0.642857 ) 108 1 + vert 109 ( 1.000000 0.714286 ) 109 1 + vert 110 ( 0.916667 0.714286 ) 110 1 + vert 111 ( 0.833333 0.714286 ) 111 1 + vert 112 ( 0.750000 0.714286 ) 112 1 + vert 113 ( 0.666667 0.714286 ) 113 1 + vert 114 ( 0.583333 0.714286 ) 114 1 + vert 115 ( 0.500000 0.714286 ) 115 1 + vert 116 ( 0.416667 0.714286 ) 116 1 + vert 117 ( 0.333333 0.714286 ) 117 1 + vert 118 ( 0.250000 0.714286 ) 118 1 + vert 119 ( 0.166667 0.714286 ) 119 1 + vert 120 ( 0.083333 0.714286 ) 120 1 + vert 121 ( 1.000000 0.785714 ) 121 1 + vert 122 ( 0.916667 0.785714 ) 122 1 + vert 123 ( 0.833333 0.785714 ) 123 1 + vert 124 ( 0.750000 0.785714 ) 124 1 + vert 125 ( 0.666667 0.785714 ) 125 1 + vert 126 ( 0.583333 0.785714 ) 126 1 + vert 127 ( 0.500000 0.785714 ) 127 1 + vert 128 ( 0.416667 0.785714 ) 128 1 + vert 129 ( 0.333333 0.785714 ) 129 1 + vert 130 ( 0.250000 0.785714 ) 130 1 + vert 131 ( 0.166667 0.785714 ) 131 1 + vert 132 ( 0.083333 0.785714 ) 132 1 + vert 133 ( 1.000000 0.857143 ) 133 1 + vert 134 ( 0.916667 0.857143 ) 134 1 + vert 135 ( 0.833333 0.857143 ) 135 1 + vert 136 ( 0.750000 0.857143 ) 136 1 + vert 137 ( 0.666667 0.857143 ) 137 1 + vert 138 ( 0.583333 0.857143 ) 138 1 + vert 139 ( 0.500000 0.857143 ) 139 1 + vert 140 ( 0.416667 0.857143 ) 140 1 + vert 141 ( 0.333333 0.857143 ) 141 1 + vert 142 ( 0.250000 0.857143 ) 142 1 + vert 143 ( 0.166667 0.857143 ) 143 1 + vert 144 ( 0.083333 0.857143 ) 144 1 + vert 145 ( 1.000000 0.928572 ) 145 1 + vert 146 ( 0.916667 0.928572 ) 146 1 + vert 147 ( 0.833333 0.928572 ) 147 1 + vert 148 ( 0.750000 0.928572 ) 148 1 + vert 149 ( 0.666667 0.928572 ) 149 1 + vert 150 ( 0.583333 0.928572 ) 150 1 + vert 151 ( 0.500000 0.928572 ) 151 1 + vert 152 ( 0.416667 0.928572 ) 152 1 + vert 153 ( 0.333333 0.928572 ) 153 1 + vert 154 ( 0.250000 0.928572 ) 154 1 + vert 155 ( 0.166667 0.928572 ) 155 1 + vert 156 ( 0.083333 0.928572 ) 156 1 + vert 157 ( 0.500000 1.000000 ) 157 1 + + numtris 312 + tri 0 0 1 2 + tri 1 0 2 3 + tri 2 0 3 4 + tri 3 0 4 5 + tri 4 0 5 6 + tri 5 0 6 7 + tri 6 0 7 8 + tri 7 0 8 9 + tri 8 0 9 10 + tri 9 0 10 11 + tri 10 0 11 12 + tri 11 0 12 1 + tri 12 1 13 14 + tri 13 1 14 2 + tri 14 2 14 15 + tri 15 2 15 3 + tri 16 3 15 16 + tri 17 3 16 4 + tri 18 4 16 17 + tri 19 4 17 5 + tri 20 5 17 18 + tri 21 5 18 6 + tri 22 6 18 19 + tri 23 6 19 7 + tri 24 7 19 20 + tri 25 7 20 8 + tri 26 8 20 21 + tri 27 8 21 9 + tri 28 9 21 22 + tri 29 9 22 10 + tri 30 10 22 23 + tri 31 10 23 11 + tri 32 11 23 24 + tri 33 11 24 12 + tri 34 12 24 13 + tri 35 12 13 1 + tri 36 13 25 26 + tri 37 13 26 14 + tri 38 14 26 27 + tri 39 14 27 15 + tri 40 15 27 28 + tri 41 15 28 16 + tri 42 16 28 29 + tri 43 16 29 17 + tri 44 17 29 30 + tri 45 17 30 18 + tri 46 18 30 31 + tri 47 18 31 19 + tri 48 19 31 32 + tri 49 19 32 20 + tri 50 20 32 33 + tri 51 20 33 21 + tri 52 21 33 34 + tri 53 21 34 22 + tri 54 22 34 35 + tri 55 22 35 23 + tri 56 23 35 36 + tri 57 23 36 24 + tri 58 24 36 25 + tri 59 24 25 13 + tri 60 25 37 38 + tri 61 25 38 26 + tri 62 26 38 39 + tri 63 26 39 27 + tri 64 27 39 40 + tri 65 27 40 28 + tri 66 28 40 41 + tri 67 28 41 29 + tri 68 29 41 42 + tri 69 29 42 30 + tri 70 30 42 43 + tri 71 30 43 31 + tri 72 31 43 44 + tri 73 31 44 32 + tri 74 32 44 45 + tri 75 32 45 33 + tri 76 33 45 46 + tri 77 33 46 34 + tri 78 34 46 47 + tri 79 34 47 35 + tri 80 35 47 48 + tri 81 35 48 36 + tri 82 36 48 37 + tri 83 36 37 25 + tri 84 37 49 50 + tri 85 37 50 38 + tri 86 38 50 51 + tri 87 38 51 39 + tri 88 39 51 52 + tri 89 39 52 40 + tri 90 40 52 53 + tri 91 40 53 41 + tri 92 41 53 54 + tri 93 41 54 42 + tri 94 42 54 55 + tri 95 42 55 43 + tri 96 43 55 56 + tri 97 43 56 44 + tri 98 44 56 57 + tri 99 44 57 45 + tri 100 45 57 58 + tri 101 45 58 46 + tri 102 46 58 59 + tri 103 46 59 47 + tri 104 47 59 60 + tri 105 47 60 48 + tri 106 48 60 49 + tri 107 48 49 37 + tri 108 49 61 62 + tri 109 49 62 50 + tri 110 50 62 63 + tri 111 50 63 51 + tri 112 51 63 64 + tri 113 51 64 52 + tri 114 52 64 65 + tri 115 52 65 53 + tri 116 53 65 66 + tri 117 53 66 54 + tri 118 54 66 67 + tri 119 54 67 55 + tri 120 55 67 68 + tri 121 55 68 56 + tri 122 56 68 69 + tri 123 56 69 57 + tri 124 57 69 70 + tri 125 57 70 58 + tri 126 58 70 71 + tri 127 58 71 59 + tri 128 59 71 72 + tri 129 59 72 60 + tri 130 60 72 61 + tri 131 60 61 49 + tri 132 61 73 74 + tri 133 61 74 62 + tri 134 62 74 75 + tri 135 62 75 63 + tri 136 63 75 76 + tri 137 63 76 64 + tri 138 64 76 77 + tri 139 64 77 65 + tri 140 65 77 78 + tri 141 65 78 66 + tri 142 66 78 79 + tri 143 66 79 67 + tri 144 67 79 80 + tri 145 67 80 68 + tri 146 68 80 81 + tri 147 68 81 69 + tri 148 69 81 82 + tri 149 69 82 70 + tri 150 70 82 83 + tri 151 70 83 71 + tri 152 71 83 84 + tri 153 71 84 72 + tri 154 72 84 73 + tri 155 72 73 61 + tri 156 73 85 86 + tri 157 73 86 74 + tri 158 74 86 87 + tri 159 74 87 75 + tri 160 75 87 88 + tri 161 75 88 76 + tri 162 76 88 89 + tri 163 76 89 77 + tri 164 77 89 90 + tri 165 77 90 78 + tri 166 78 90 91 + tri 167 78 91 79 + tri 168 79 91 92 + tri 169 79 92 80 + tri 170 80 92 93 + tri 171 80 93 81 + tri 172 81 93 94 + tri 173 81 94 82 + tri 174 82 94 95 + tri 175 82 95 83 + tri 176 83 95 96 + tri 177 83 96 84 + tri 178 84 96 85 + tri 179 84 85 73 + tri 180 85 97 98 + tri 181 85 98 86 + tri 182 86 98 99 + tri 183 86 99 87 + tri 184 87 99 100 + tri 185 87 100 88 + tri 186 88 100 101 + tri 187 88 101 89 + tri 188 89 101 102 + tri 189 89 102 90 + tri 190 90 102 103 + tri 191 90 103 91 + tri 192 91 103 104 + tri 193 91 104 92 + tri 194 92 104 105 + tri 195 92 105 93 + tri 196 93 105 106 + tri 197 93 106 94 + tri 198 94 106 107 + tri 199 94 107 95 + tri 200 95 107 108 + tri 201 95 108 96 + tri 202 96 108 97 + tri 203 96 97 85 + tri 204 97 109 110 + tri 205 97 110 98 + tri 206 98 110 111 + tri 207 98 111 99 + tri 208 99 111 112 + tri 209 99 112 100 + tri 210 100 112 113 + tri 211 100 113 101 + tri 212 101 113 114 + tri 213 101 114 102 + tri 214 102 114 115 + tri 215 102 115 103 + tri 216 103 115 116 + tri 217 103 116 104 + tri 218 104 116 117 + tri 219 104 117 105 + tri 220 105 117 118 + tri 221 105 118 106 + tri 222 106 118 119 + tri 223 106 119 107 + tri 224 107 119 120 + tri 225 107 120 108 + tri 226 108 120 109 + tri 227 108 109 97 + tri 228 109 121 122 + tri 229 109 122 110 + tri 230 110 122 123 + tri 231 110 123 111 + tri 232 111 123 124 + tri 233 111 124 112 + tri 234 112 124 125 + tri 235 112 125 113 + tri 236 113 125 126 + tri 237 113 126 114 + tri 238 114 126 127 + tri 239 114 127 115 + tri 240 115 127 128 + tri 241 115 128 116 + tri 242 116 128 129 + tri 243 116 129 117 + tri 244 117 129 130 + tri 245 117 130 118 + tri 246 118 130 131 + tri 247 118 131 119 + tri 248 119 131 132 + tri 249 119 132 120 + tri 250 120 132 121 + tri 251 120 121 109 + tri 252 121 133 134 + tri 253 121 134 122 + tri 254 122 134 135 + tri 255 122 135 123 + tri 256 123 135 136 + tri 257 123 136 124 + tri 258 124 136 137 + tri 259 124 137 125 + tri 260 125 137 138 + tri 261 125 138 126 + tri 262 126 138 139 + tri 263 126 139 127 + tri 264 127 139 140 + tri 265 127 140 128 + tri 266 128 140 141 + tri 267 128 141 129 + tri 268 129 141 142 + tri 269 129 142 130 + tri 270 130 142 143 + tri 271 130 143 131 + tri 272 131 143 144 + tri 273 131 144 132 + tri 274 132 144 133 + tri 275 132 133 121 + tri 276 133 145 146 + tri 277 133 146 134 + tri 278 134 146 147 + tri 279 134 147 135 + tri 280 135 147 148 + tri 281 135 148 136 + tri 282 136 148 149 + tri 283 136 149 137 + tri 284 137 149 150 + tri 285 137 150 138 + tri 286 138 150 151 + tri 287 138 151 139 + tri 288 139 151 152 + tri 289 139 152 140 + tri 290 140 152 153 + tri 291 140 153 141 + tri 292 141 153 154 + tri 293 141 154 142 + tri 294 142 154 155 + tri 295 142 155 143 + tri 296 143 155 156 + tri 297 143 156 144 + tri 298 144 156 145 + tri 299 144 145 133 + tri 300 157 156 155 + tri 301 157 155 154 + tri 302 157 154 153 + tri 303 157 153 152 + tri 304 157 152 151 + tri 305 157 151 150 + tri 306 157 150 149 + tri 307 157 149 148 + tri 308 157 148 147 + tri 309 157 147 146 + tri 310 157 146 145 + tri 311 157 145 156 + + numweights 158 + weight 0 2 1.000000 ( -7.999999 0.122684 0.019707 ) + weight 1 2 1.000000 ( -7.799419 0.122684 1.799866 ) + weight 2 2 1.000000 ( -7.799419 -0.767376 1.561371 ) + weight 3 2 1.000000 ( -7.799419 -1.418964 0.909798 ) + weight 4 2 1.000000 ( -7.799419 -1.657459 0.019707 ) + weight 5 2 1.000000 ( -7.799419 -1.418964 -0.870365 ) + weight 6 2 1.000000 ( -7.799419 -0.767376 -1.521954 ) + weight 7 2 1.000000 ( -7.799419 0.122684 -1.760448 ) + weight 8 2 1.000000 ( -7.799419 1.012775 -1.521954 ) + weight 9 2 1.000000 ( -7.799419 1.664371 -0.870365 ) + weight 10 2 1.000000 ( -7.799419 1.902866 0.019707 ) + weight 11 2 1.000000 ( -7.799419 1.664371 0.909775 ) + weight 12 2 1.000000 ( -7.799419 1.012775 1.561371 ) + weight 13 2 1.000000 ( -7.207747 0.122684 3.490784 ) + weight 14 2 1.000000 ( -7.207747 -1.612827 3.025742 ) + weight 15 2 1.000000 ( -7.207747 -2.883327 1.755234 ) + weight 16 2 1.000000 ( -7.207747 -3.348362 0.019707 ) + weight 17 2 1.000000 ( -7.207747 -2.883327 -1.715816 ) + weight 18 2 1.000000 ( -7.207747 -1.612827 -2.986317 ) + weight 19 2 1.000000 ( -7.207747 0.122684 -3.451351 ) + weight 20 2 1.000000 ( -7.207747 1.858234 -2.986317 ) + weight 21 2 1.000000 ( -7.207747 3.128719 -1.715816 ) + weight 22 2 1.000000 ( -7.207747 3.593761 0.019707 ) + weight 23 2 1.000000 ( -7.207747 3.128719 1.755234 ) + weight 24 2 1.000000 ( -7.207747 1.858234 3.025742 ) + weight 25 2 1.000000 ( -6.254650 0.122684 5.007622 ) + weight 26 2 1.000000 ( -6.254650 -2.371250 4.339371 ) + weight 27 2 1.000000 ( -6.254650 -4.196957 2.513672 ) + weight 28 2 1.000000 ( -6.254650 -4.865211 0.019707 ) + weight 29 2 1.000000 ( -6.254650 -4.196957 -2.474243 ) + weight 30 2 1.000000 ( -6.254650 -2.371250 -4.299946 ) + weight 31 2 1.000000 ( -6.254650 0.122684 -4.968201 ) + weight 32 2 1.000000 ( -6.254650 2.616650 -4.299946 ) + weight 33 2 1.000000 ( -6.254650 4.442348 -2.474243 ) + weight 34 2 1.000000 ( -6.254650 5.110615 0.019707 ) + weight 35 2 1.000000 ( -6.254650 4.442348 2.513657 ) + weight 36 2 1.000000 ( -6.254650 2.616650 4.339371 ) + weight 37 2 1.000000 ( -4.987916 0.122684 6.274361 ) + weight 38 2 1.000000 ( -4.987916 -3.004620 5.436394 ) + weight 39 2 1.000000 ( -4.987916 -5.293980 3.147034 ) + weight 40 2 1.000000 ( -4.987916 -6.131943 0.019707 ) + weight 41 2 1.000000 ( -4.987916 -5.293980 -3.107609 ) + weight 42 2 1.000000 ( -4.987916 -3.004620 -5.396969 ) + weight 43 2 1.000000 ( -4.987916 0.122684 -6.234932 ) + weight 44 2 1.000000 ( -4.987916 3.250011 -5.396969 ) + weight 45 2 1.000000 ( -4.987916 5.539387 -3.107609 ) + weight 46 2 1.000000 ( -4.987916 6.377354 0.019707 ) + weight 47 2 1.000000 ( -4.987916 5.539387 3.147034 ) + weight 48 2 1.000000 ( -4.987916 3.250011 5.436394 ) + weight 49 2 1.000000 ( -3.471069 0.122684 7.227455 ) + weight 50 2 1.000000 ( -3.471069 -3.481167 6.261803 ) + weight 51 2 1.000000 ( -3.471069 -6.119389 3.623589 ) + weight 52 2 1.000000 ( -3.471069 -7.085041 0.019707 ) + weight 53 2 1.000000 ( -3.471069 -6.119389 -3.584156 ) + weight 54 2 1.000000 ( -3.471069 -3.481167 -6.222378 ) + weight 55 2 1.000000 ( -3.471069 0.122684 -7.188034 ) + weight 56 2 1.000000 ( -3.471069 3.726566 -6.222378 ) + weight 57 2 1.000000 ( -3.471069 6.364796 -3.584160 ) + weight 58 2 1.000000 ( -3.471069 7.330441 0.019707 ) + weight 59 2 1.000000 ( -3.471069 6.364796 3.623566 ) + weight 60 2 1.000000 ( -3.471069 3.726582 6.261803 ) + weight 61 2 1.000000 ( -1.780167 0.122684 7.819130 ) + weight 62 2 1.000000 ( -1.780167 -3.777004 6.774208 ) + weight 63 2 1.000000 ( -1.780167 -6.631790 3.919411 ) + weight 64 2 1.000000 ( -1.780167 -7.676716 0.019707 ) + weight 65 2 1.000000 ( -1.780167 -6.631790 -3.879993 ) + weight 66 2 1.000000 ( -1.780167 -3.777004 -6.734779 ) + weight 67 2 1.000000 ( -1.780167 0.122684 -7.779705 ) + weight 68 2 1.000000 ( -1.780167 4.022411 -6.734779 ) + weight 69 2 1.000000 ( -1.780167 6.877186 -3.879997 ) + weight 70 2 1.000000 ( -1.780167 7.922115 0.019707 ) + weight 71 2 1.000000 ( -1.780167 6.877193 3.919411 ) + weight 72 2 1.000000 ( -1.780167 4.022411 6.774208 ) + weight 73 2 1.000000 ( -0.000001 0.122684 8.019707 ) + weight 74 2 1.000000 ( -0.000001 -3.877293 6.947914 ) + weight 75 2 1.000000 ( -0.000001 -6.805496 4.019707 ) + weight 76 2 1.000000 ( -0.000001 -7.877293 0.019707 ) + weight 77 2 1.000000 ( -0.000001 -6.805496 -3.980282 ) + weight 78 2 1.000000 ( -0.000001 -3.877293 -6.908485 ) + weight 79 2 1.000000 ( -0.000001 0.122684 -7.980282 ) + weight 80 2 1.000000 ( -0.000001 4.122700 -6.908485 ) + weight 81 2 1.000000 ( -0.000001 7.050892 -3.980286 ) + weight 82 2 1.000000 ( -0.000001 8.122700 0.019707 ) + weight 83 2 1.000000 ( -0.000001 7.050900 4.019707 ) + weight 84 2 1.000000 ( -0.000001 4.122707 6.947914 ) + weight 85 2 1.000000 ( 1.780166 0.122684 7.819138 ) + weight 86 2 1.000000 ( 1.780166 -3.777004 6.774208 ) + weight 87 2 1.000000 ( 1.780166 -6.631790 3.919411 ) + weight 88 2 1.000000 ( 1.780166 -7.676716 0.019707 ) + weight 89 2 1.000000 ( 1.780166 -6.631790 -3.879993 ) + weight 90 2 1.000000 ( 1.780166 -3.777004 -6.734779 ) + weight 91 2 1.000000 ( 1.780166 0.122684 -7.779705 ) + weight 92 2 1.000000 ( 1.780166 4.022411 -6.734779 ) + weight 93 2 1.000000 ( 1.780166 6.877186 -3.879997 ) + weight 94 2 1.000000 ( 1.780166 7.922115 0.019707 ) + weight 95 2 1.000000 ( 1.780166 6.877193 3.919411 ) + weight 96 2 1.000000 ( 1.780166 4.022411 6.774208 ) + weight 97 2 1.000000 ( 3.471068 0.122684 7.227455 ) + weight 98 2 1.000000 ( 3.471068 -3.481167 6.261803 ) + weight 99 2 1.000000 ( 3.471068 -6.119389 3.623589 ) + weight 100 2 1.000000 ( 3.471068 -7.085045 0.019707 ) + weight 101 2 1.000000 ( 3.471068 -6.119389 -3.584156 ) + weight 102 2 1.000000 ( 3.471068 -3.481167 -6.222378 ) + weight 103 2 1.000000 ( 3.471068 0.122684 -7.188034 ) + weight 104 2 1.000000 ( 3.471068 3.726566 -6.222378 ) + weight 105 2 1.000000 ( 3.471068 6.364796 -3.584160 ) + weight 106 2 1.000000 ( 3.471068 7.330441 0.019707 ) + weight 107 2 1.000000 ( 3.471068 6.364796 3.623566 ) + weight 108 2 1.000000 ( 3.471068 3.726582 6.261803 ) + weight 109 2 1.000000 ( 4.987916 0.122684 6.274361 ) + weight 110 2 1.000000 ( 4.987916 -3.004620 5.436394 ) + weight 111 2 1.000000 ( 4.987916 -5.293980 3.147034 ) + weight 112 2 1.000000 ( 4.987916 -6.131943 0.019707 ) + weight 113 2 1.000000 ( 4.987916 -5.293980 -3.107609 ) + weight 114 2 1.000000 ( 4.987916 -3.004620 -5.396969 ) + weight 115 2 1.000000 ( 4.987916 0.122684 -6.234932 ) + weight 116 2 1.000000 ( 4.987916 3.250011 -5.396969 ) + weight 117 2 1.000000 ( 4.987916 5.539387 -3.107609 ) + weight 118 2 1.000000 ( 4.987916 6.377354 0.019707 ) + weight 119 2 1.000000 ( 4.987916 5.539387 3.147034 ) + weight 120 2 1.000000 ( 4.987916 3.250011 5.436394 ) + weight 121 2 1.000000 ( 6.254651 0.122684 5.007622 ) + weight 122 2 1.000000 ( 6.254651 -2.371250 4.339371 ) + weight 123 2 1.000000 ( 6.254651 -4.196957 2.513672 ) + weight 124 2 1.000000 ( 6.254651 -4.865211 0.019707 ) + weight 125 2 1.000000 ( 6.254651 -4.196957 -2.474239 ) + weight 126 2 1.000000 ( 6.254651 -2.371250 -4.299946 ) + weight 127 2 1.000000 ( 6.254651 0.122684 -4.968201 ) + weight 128 2 1.000000 ( 6.254651 2.616650 -4.299946 ) + weight 129 2 1.000000 ( 6.254651 4.442348 -2.474243 ) + weight 130 2 1.000000 ( 6.254651 5.110615 0.019707 ) + weight 131 2 1.000000 ( 6.254651 4.442348 2.513657 ) + weight 132 2 1.000000 ( 6.254651 2.616650 4.339371 ) + weight 133 2 1.000000 ( 7.207747 0.122684 3.490776 ) + weight 134 2 1.000000 ( 7.207747 -1.612827 3.025742 ) + weight 135 2 1.000000 ( 7.207747 -2.883327 1.755234 ) + weight 136 2 1.000000 ( 7.207747 -3.348362 0.019707 ) + weight 137 2 1.000000 ( 7.207747 -2.883327 -1.715816 ) + weight 138 2 1.000000 ( 7.207747 -1.612827 -2.986317 ) + weight 139 2 1.000000 ( 7.207747 0.122684 -3.451351 ) + weight 140 2 1.000000 ( 7.207747 1.858234 -2.986317 ) + weight 141 2 1.000000 ( 7.207747 3.128719 -1.715816 ) + weight 142 2 1.000000 ( 7.207747 3.593761 0.019707 ) + weight 143 2 1.000000 ( 7.207747 3.128719 1.755234 ) + weight 144 2 1.000000 ( 7.207747 1.858234 3.025742 ) + weight 145 2 1.000000 ( 7.799419 0.122684 1.799866 ) + weight 146 2 1.000000 ( 7.799419 -0.767376 1.561371 ) + weight 147 2 1.000000 ( 7.799419 -1.418961 0.909775 ) + weight 148 2 1.000000 ( 7.799419 -1.657459 0.019707 ) + weight 149 2 1.000000 ( 7.799419 -1.418961 -0.870365 ) + weight 150 2 1.000000 ( 7.799419 -0.767376 -1.521950 ) + weight 151 2 1.000000 ( 7.799419 0.122684 -1.760448 ) + weight 152 2 1.000000 ( 7.799419 1.012775 -1.521950 ) + weight 153 2 1.000000 ( 7.799419 1.664371 -0.870365 ) + weight 154 2 1.000000 ( 7.799419 1.902866 0.019707 ) + weight 155 2 1.000000 ( 7.799419 1.664371 0.909775 ) + weight 156 2 1.000000 ( 7.799419 1.012775 1.561371 ) + weight 157 2 1.000000 ( 7.999999 0.122684 0.019707 ) +} + +mesh { + // meshes: Skin2 + shader "" + + numverts 158 + vert 0 ( 1.000000 0.000000 ) 0 1 + vert 1 ( 1.000000 0.071429 ) 1 1 + vert 2 ( 0.916667 0.071429 ) 2 1 + vert 3 ( 0.833333 0.071429 ) 3 1 + vert 4 ( 0.750000 0.071429 ) 4 1 + vert 5 ( 0.666667 0.071429 ) 5 1 + vert 6 ( 0.583333 0.071429 ) 6 1 + vert 7 ( 0.500000 0.071429 ) 7 1 + vert 8 ( 0.416667 0.071429 ) 8 1 + vert 9 ( 0.333333 0.071429 ) 9 1 + vert 10 ( 0.250000 0.071429 ) 10 1 + vert 11 ( 0.166667 0.071429 ) 11 1 + vert 12 ( 0.083333 0.071429 ) 12 1 + vert 13 ( 1.000000 0.142857 ) 13 1 + vert 14 ( 0.916667 0.142857 ) 14 1 + vert 15 ( 0.833333 0.142857 ) 15 1 + vert 16 ( 0.750000 0.142857 ) 16 1 + vert 17 ( 0.666667 0.142857 ) 17 1 + vert 18 ( 0.583333 0.142857 ) 18 1 + vert 19 ( 0.500000 0.142857 ) 19 1 + vert 20 ( 0.416667 0.142857 ) 20 1 + vert 21 ( 0.333333 0.142857 ) 21 1 + vert 22 ( 0.250000 0.142857 ) 22 1 + vert 23 ( 0.166667 0.142857 ) 23 1 + vert 24 ( 0.083333 0.142857 ) 24 1 + vert 25 ( 1.000000 0.214286 ) 25 1 + vert 26 ( 0.916667 0.214286 ) 26 1 + vert 27 ( 0.833333 0.214286 ) 27 1 + vert 28 ( 0.750000 0.214286 ) 28 1 + vert 29 ( 0.666667 0.214286 ) 29 1 + vert 30 ( 0.583333 0.214286 ) 30 1 + vert 31 ( 0.500000 0.214286 ) 31 1 + vert 32 ( 0.416667 0.214286 ) 32 1 + vert 33 ( 0.333333 0.214286 ) 33 1 + vert 34 ( 0.250000 0.214286 ) 34 1 + vert 35 ( 0.166667 0.214286 ) 35 1 + vert 36 ( 0.083333 0.214286 ) 36 1 + vert 37 ( 1.000000 0.285714 ) 37 1 + vert 38 ( 0.916667 0.285714 ) 38 1 + vert 39 ( 0.833333 0.285714 ) 39 1 + vert 40 ( 0.750000 0.285714 ) 40 1 + vert 41 ( 0.666667 0.285714 ) 41 1 + vert 42 ( 0.583333 0.285714 ) 42 1 + vert 43 ( 0.500000 0.285714 ) 43 1 + vert 44 ( 0.416667 0.285714 ) 44 1 + vert 45 ( 0.333333 0.285714 ) 45 1 + vert 46 ( 0.250000 0.285714 ) 46 1 + vert 47 ( 0.166667 0.285714 ) 47 1 + vert 48 ( 0.083333 0.285714 ) 48 1 + vert 49 ( 1.000000 0.357143 ) 49 1 + vert 50 ( 0.916667 0.357143 ) 50 1 + vert 51 ( 0.833333 0.357143 ) 51 1 + vert 52 ( 0.750000 0.357143 ) 52 1 + vert 53 ( 0.666667 0.357143 ) 53 1 + vert 54 ( 0.583333 0.357143 ) 54 1 + vert 55 ( 0.500000 0.357143 ) 55 1 + vert 56 ( 0.416667 0.357143 ) 56 1 + vert 57 ( 0.333333 0.357143 ) 57 1 + vert 58 ( 0.250000 0.357143 ) 58 1 + vert 59 ( 0.166667 0.357143 ) 59 1 + vert 60 ( 0.083333 0.357143 ) 60 1 + vert 61 ( 1.000000 0.428571 ) 61 1 + vert 62 ( 0.916667 0.428571 ) 62 1 + vert 63 ( 0.833333 0.428571 ) 63 1 + vert 64 ( 0.750000 0.428571 ) 64 1 + vert 65 ( 0.666667 0.428571 ) 65 1 + vert 66 ( 0.583333 0.428571 ) 66 1 + vert 67 ( 0.500000 0.428571 ) 67 1 + vert 68 ( 0.416667 0.428571 ) 68 1 + vert 69 ( 0.333333 0.428571 ) 69 1 + vert 70 ( 0.250000 0.428571 ) 70 1 + vert 71 ( 0.166667 0.428571 ) 71 1 + vert 72 ( 0.083333 0.428571 ) 72 1 + vert 73 ( 1.000000 0.500000 ) 73 1 + vert 74 ( 0.916667 0.500000 ) 74 1 + vert 75 ( 0.833333 0.500000 ) 75 1 + vert 76 ( 0.750000 0.500000 ) 76 1 + vert 77 ( 0.666667 0.500000 ) 77 1 + vert 78 ( 0.583333 0.500000 ) 78 1 + vert 79 ( 0.500000 0.500000 ) 79 1 + vert 80 ( 0.416667 0.500000 ) 80 1 + vert 81 ( 0.333333 0.500000 ) 81 1 + vert 82 ( 0.250000 0.500000 ) 82 1 + vert 83 ( 0.166667 0.500000 ) 83 1 + vert 84 ( 0.083333 0.500000 ) 84 1 + vert 85 ( 1.000000 0.571429 ) 85 1 + vert 86 ( 0.916667 0.571429 ) 86 1 + vert 87 ( 0.833333 0.571429 ) 87 1 + vert 88 ( 0.750000 0.571429 ) 88 1 + vert 89 ( 0.666667 0.571429 ) 89 1 + vert 90 ( 0.583333 0.571429 ) 90 1 + vert 91 ( 0.500000 0.571429 ) 91 1 + vert 92 ( 0.416667 0.571429 ) 92 1 + vert 93 ( 0.333333 0.571429 ) 93 1 + vert 94 ( 0.250000 0.571429 ) 94 1 + vert 95 ( 0.166667 0.571429 ) 95 1 + vert 96 ( 0.083333 0.571429 ) 96 1 + vert 97 ( 1.000000 0.642857 ) 97 1 + vert 98 ( 0.916667 0.642857 ) 98 1 + vert 99 ( 0.833333 0.642857 ) 99 1 + vert 100 ( 0.750000 0.642857 ) 100 1 + vert 101 ( 0.666667 0.642857 ) 101 1 + vert 102 ( 0.583333 0.642857 ) 102 1 + vert 103 ( 0.500000 0.642857 ) 103 1 + vert 104 ( 0.416667 0.642857 ) 104 1 + vert 105 ( 0.333333 0.642857 ) 105 1 + vert 106 ( 0.250000 0.642857 ) 106 1 + vert 107 ( 0.166667 0.642857 ) 107 1 + vert 108 ( 0.083333 0.642857 ) 108 1 + vert 109 ( 1.000000 0.714286 ) 109 1 + vert 110 ( 0.916667 0.714286 ) 110 1 + vert 111 ( 0.833333 0.714286 ) 111 1 + vert 112 ( 0.750000 0.714286 ) 112 1 + vert 113 ( 0.666667 0.714286 ) 113 1 + vert 114 ( 0.583333 0.714286 ) 114 1 + vert 115 ( 0.500000 0.714286 ) 115 1 + vert 116 ( 0.416667 0.714286 ) 116 1 + vert 117 ( 0.333333 0.714286 ) 117 1 + vert 118 ( 0.250000 0.714286 ) 118 1 + vert 119 ( 0.166667 0.714286 ) 119 1 + vert 120 ( 0.083333 0.714286 ) 120 1 + vert 121 ( 1.000000 0.785714 ) 121 1 + vert 122 ( 0.916667 0.785714 ) 122 1 + vert 123 ( 0.833333 0.785714 ) 123 1 + vert 124 ( 0.750000 0.785714 ) 124 1 + vert 125 ( 0.666667 0.785714 ) 125 1 + vert 126 ( 0.583333 0.785714 ) 126 1 + vert 127 ( 0.500000 0.785714 ) 127 1 + vert 128 ( 0.416667 0.785714 ) 128 1 + vert 129 ( 0.333333 0.785714 ) 129 1 + vert 130 ( 0.250000 0.785714 ) 130 1 + vert 131 ( 0.166667 0.785714 ) 131 1 + vert 132 ( 0.083333 0.785714 ) 132 1 + vert 133 ( 1.000000 0.857143 ) 133 1 + vert 134 ( 0.916667 0.857143 ) 134 1 + vert 135 ( 0.833333 0.857143 ) 135 1 + vert 136 ( 0.750000 0.857143 ) 136 1 + vert 137 ( 0.666667 0.857143 ) 137 1 + vert 138 ( 0.583333 0.857143 ) 138 1 + vert 139 ( 0.500000 0.857143 ) 139 1 + vert 140 ( 0.416667 0.857143 ) 140 1 + vert 141 ( 0.333333 0.857143 ) 141 1 + vert 142 ( 0.250000 0.857143 ) 142 1 + vert 143 ( 0.166667 0.857143 ) 143 1 + vert 144 ( 0.083333 0.857143 ) 144 1 + vert 145 ( 1.000000 0.928572 ) 145 1 + vert 146 ( 0.916667 0.928572 ) 146 1 + vert 147 ( 0.833333 0.928572 ) 147 1 + vert 148 ( 0.750000 0.928572 ) 148 1 + vert 149 ( 0.666667 0.928572 ) 149 1 + vert 150 ( 0.583333 0.928572 ) 150 1 + vert 151 ( 0.500000 0.928572 ) 151 1 + vert 152 ( 0.416667 0.928572 ) 152 1 + vert 153 ( 0.333333 0.928572 ) 153 1 + vert 154 ( 0.250000 0.928572 ) 154 1 + vert 155 ( 0.166667 0.928572 ) 155 1 + vert 156 ( 0.083333 0.928572 ) 156 1 + vert 157 ( 0.500000 1.000000 ) 157 1 + + numtris 312 + tri 0 0 1 2 + tri 1 0 2 3 + tri 2 0 3 4 + tri 3 0 4 5 + tri 4 0 5 6 + tri 5 0 6 7 + tri 6 0 7 8 + tri 7 0 8 9 + tri 8 0 9 10 + tri 9 0 10 11 + tri 10 0 11 12 + tri 11 0 12 1 + tri 12 1 13 14 + tri 13 1 14 2 + tri 14 2 14 15 + tri 15 2 15 3 + tri 16 3 15 16 + tri 17 3 16 4 + tri 18 4 16 17 + tri 19 4 17 5 + tri 20 5 17 18 + tri 21 5 18 6 + tri 22 6 18 19 + tri 23 6 19 7 + tri 24 7 19 20 + tri 25 7 20 8 + tri 26 8 20 21 + tri 27 8 21 9 + tri 28 9 21 22 + tri 29 9 22 10 + tri 30 10 22 23 + tri 31 10 23 11 + tri 32 11 23 24 + tri 33 11 24 12 + tri 34 12 24 13 + tri 35 12 13 1 + tri 36 13 25 26 + tri 37 13 26 14 + tri 38 14 26 27 + tri 39 14 27 15 + tri 40 15 27 28 + tri 41 15 28 16 + tri 42 16 28 29 + tri 43 16 29 17 + tri 44 17 29 30 + tri 45 17 30 18 + tri 46 18 30 31 + tri 47 18 31 19 + tri 48 19 31 32 + tri 49 19 32 20 + tri 50 20 32 33 + tri 51 20 33 21 + tri 52 21 33 34 + tri 53 21 34 22 + tri 54 22 34 35 + tri 55 22 35 23 + tri 56 23 35 36 + tri 57 23 36 24 + tri 58 24 36 25 + tri 59 24 25 13 + tri 60 25 37 38 + tri 61 25 38 26 + tri 62 26 38 39 + tri 63 26 39 27 + tri 64 27 39 40 + tri 65 27 40 28 + tri 66 28 40 41 + tri 67 28 41 29 + tri 68 29 41 42 + tri 69 29 42 30 + tri 70 30 42 43 + tri 71 30 43 31 + tri 72 31 43 44 + tri 73 31 44 32 + tri 74 32 44 45 + tri 75 32 45 33 + tri 76 33 45 46 + tri 77 33 46 34 + tri 78 34 46 47 + tri 79 34 47 35 + tri 80 35 47 48 + tri 81 35 48 36 + tri 82 36 48 37 + tri 83 36 37 25 + tri 84 37 49 50 + tri 85 37 50 38 + tri 86 38 50 51 + tri 87 38 51 39 + tri 88 39 51 52 + tri 89 39 52 40 + tri 90 40 52 53 + tri 91 40 53 41 + tri 92 41 53 54 + tri 93 41 54 42 + tri 94 42 54 55 + tri 95 42 55 43 + tri 96 43 55 56 + tri 97 43 56 44 + tri 98 44 56 57 + tri 99 44 57 45 + tri 100 45 57 58 + tri 101 45 58 46 + tri 102 46 58 59 + tri 103 46 59 47 + tri 104 47 59 60 + tri 105 47 60 48 + tri 106 48 60 49 + tri 107 48 49 37 + tri 108 49 61 62 + tri 109 49 62 50 + tri 110 50 62 63 + tri 111 50 63 51 + tri 112 51 63 64 + tri 113 51 64 52 + tri 114 52 64 65 + tri 115 52 65 53 + tri 116 53 65 66 + tri 117 53 66 54 + tri 118 54 66 67 + tri 119 54 67 55 + tri 120 55 67 68 + tri 121 55 68 56 + tri 122 56 68 69 + tri 123 56 69 57 + tri 124 57 69 70 + tri 125 57 70 58 + tri 126 58 70 71 + tri 127 58 71 59 + tri 128 59 71 72 + tri 129 59 72 60 + tri 130 60 72 61 + tri 131 60 61 49 + tri 132 61 73 74 + tri 133 61 74 62 + tri 134 62 74 75 + tri 135 62 75 63 + tri 136 63 75 76 + tri 137 63 76 64 + tri 138 64 76 77 + tri 139 64 77 65 + tri 140 65 77 78 + tri 141 65 78 66 + tri 142 66 78 79 + tri 143 66 79 67 + tri 144 67 79 80 + tri 145 67 80 68 + tri 146 68 80 81 + tri 147 68 81 69 + tri 148 69 81 82 + tri 149 69 82 70 + tri 150 70 82 83 + tri 151 70 83 71 + tri 152 71 83 84 + tri 153 71 84 72 + tri 154 72 84 73 + tri 155 72 73 61 + tri 156 73 85 86 + tri 157 73 86 74 + tri 158 74 86 87 + tri 159 74 87 75 + tri 160 75 87 88 + tri 161 75 88 76 + tri 162 76 88 89 + tri 163 76 89 77 + tri 164 77 89 90 + tri 165 77 90 78 + tri 166 78 90 91 + tri 167 78 91 79 + tri 168 79 91 92 + tri 169 79 92 80 + tri 170 80 92 93 + tri 171 80 93 81 + tri 172 81 93 94 + tri 173 81 94 82 + tri 174 82 94 95 + tri 175 82 95 83 + tri 176 83 95 96 + tri 177 83 96 84 + tri 178 84 96 85 + tri 179 84 85 73 + tri 180 85 97 98 + tri 181 85 98 86 + tri 182 86 98 99 + tri 183 86 99 87 + tri 184 87 99 100 + tri 185 87 100 88 + tri 186 88 100 101 + tri 187 88 101 89 + tri 188 89 101 102 + tri 189 89 102 90 + tri 190 90 102 103 + tri 191 90 103 91 + tri 192 91 103 104 + tri 193 91 104 92 + tri 194 92 104 105 + tri 195 92 105 93 + tri 196 93 105 106 + tri 197 93 106 94 + tri 198 94 106 107 + tri 199 94 107 95 + tri 200 95 107 108 + tri 201 95 108 96 + tri 202 96 108 97 + tri 203 96 97 85 + tri 204 97 109 110 + tri 205 97 110 98 + tri 206 98 110 111 + tri 207 98 111 99 + tri 208 99 111 112 + tri 209 99 112 100 + tri 210 100 112 113 + tri 211 100 113 101 + tri 212 101 113 114 + tri 213 101 114 102 + tri 214 102 114 115 + tri 215 102 115 103 + tri 216 103 115 116 + tri 217 103 116 104 + tri 218 104 116 117 + tri 219 104 117 105 + tri 220 105 117 118 + tri 221 105 118 106 + tri 222 106 118 119 + tri 223 106 119 107 + tri 224 107 119 120 + tri 225 107 120 108 + tri 226 108 120 109 + tri 227 108 109 97 + tri 228 109 121 122 + tri 229 109 122 110 + tri 230 110 122 123 + tri 231 110 123 111 + tri 232 111 123 124 + tri 233 111 124 112 + tri 234 112 124 125 + tri 235 112 125 113 + tri 236 113 125 126 + tri 237 113 126 114 + tri 238 114 126 127 + tri 239 114 127 115 + tri 240 115 127 128 + tri 241 115 128 116 + tri 242 116 128 129 + tri 243 116 129 117 + tri 244 117 129 130 + tri 245 117 130 118 + tri 246 118 130 131 + tri 247 118 131 119 + tri 248 119 131 132 + tri 249 119 132 120 + tri 250 120 132 121 + tri 251 120 121 109 + tri 252 121 133 134 + tri 253 121 134 122 + tri 254 122 134 135 + tri 255 122 135 123 + tri 256 123 135 136 + tri 257 123 136 124 + tri 258 124 136 137 + tri 259 124 137 125 + tri 260 125 137 138 + tri 261 125 138 126 + tri 262 126 138 139 + tri 263 126 139 127 + tri 264 127 139 140 + tri 265 127 140 128 + tri 266 128 140 141 + tri 267 128 141 129 + tri 268 129 141 142 + tri 269 129 142 130 + tri 270 130 142 143 + tri 271 130 143 131 + tri 272 131 143 144 + tri 273 131 144 132 + tri 274 132 144 133 + tri 275 132 133 121 + tri 276 133 145 146 + tri 277 133 146 134 + tri 278 134 146 147 + tri 279 134 147 135 + tri 280 135 147 148 + tri 281 135 148 136 + tri 282 136 148 149 + tri 283 136 149 137 + tri 284 137 149 150 + tri 285 137 150 138 + tri 286 138 150 151 + tri 287 138 151 139 + tri 288 139 151 152 + tri 289 139 152 140 + tri 290 140 152 153 + tri 291 140 153 141 + tri 292 141 153 154 + tri 293 141 154 142 + tri 294 142 154 155 + tri 295 142 155 143 + tri 296 143 155 156 + tri 297 143 156 144 + tri 298 144 156 145 + tri 299 144 145 133 + tri 300 157 156 155 + tri 301 157 155 154 + tri 302 157 154 153 + tri 303 157 153 152 + tri 304 157 152 151 + tri 305 157 151 150 + tri 306 157 150 149 + tri 307 157 149 148 + tri 308 157 148 147 + tri 309 157 147 146 + tri 310 157 146 145 + tri 311 157 145 156 + + numweights 158 + weight 0 0 1.000000 ( -8.000000 0.181969 0.355668 ) + weight 1 0 1.000000 ( -7.799423 0.181969 2.135836 ) + weight 2 0 1.000000 ( -7.799423 -0.708115 1.897339 ) + weight 3 0 1.000000 ( -7.799423 -1.359701 1.245752 ) + weight 4 0 1.000000 ( -7.799423 -1.598199 0.355668 ) + weight 5 0 1.000000 ( -7.799423 -1.359701 -0.534415 ) + weight 6 0 1.000000 ( -7.799423 -0.708115 -1.186002 ) + weight 7 0 1.000000 ( -7.799423 0.181968 -1.424499 ) + weight 8 0 1.000000 ( -7.799423 1.072052 -1.186002 ) + weight 9 0 1.000000 ( -7.799423 1.723639 -0.534416 ) + weight 10 0 1.000000 ( -7.799423 1.962136 0.355668 ) + weight 11 0 1.000000 ( -7.799423 1.723639 1.245751 ) + weight 12 0 1.000000 ( -7.799423 1.072053 1.897338 ) + weight 13 0 1.000000 ( -7.207747 0.181969 3.826738 ) + weight 14 0 1.000000 ( -7.207747 -1.553566 3.361703 ) + weight 15 0 1.000000 ( -7.207747 -2.824066 2.091203 ) + weight 16 0 1.000000 ( -7.207747 -3.289101 0.355668 ) + weight 17 0 1.000000 ( -7.207747 -2.824066 -1.379867 ) + weight 18 0 1.000000 ( -7.207747 -1.553566 -2.650366 ) + weight 19 0 1.000000 ( -7.207747 0.181968 -3.115401 ) + weight 20 0 1.000000 ( -7.207747 1.917503 -2.650367 ) + weight 21 0 1.000000 ( -7.207747 3.188003 -1.379868 ) + weight 22 0 1.000000 ( -7.207747 3.653039 0.355667 ) + weight 23 0 1.000000 ( -7.207747 3.188004 2.091202 ) + weight 24 0 1.000000 ( -7.207747 1.917506 3.361702 ) + weight 25 0 1.000000 ( -6.254651 0.181969 5.343585 ) + weight 26 0 1.000000 ( -6.254651 -2.311990 4.675333 ) + weight 27 0 1.000000 ( -6.254651 -4.137692 2.849627 ) + weight 28 0 1.000000 ( -6.254651 -4.805950 0.355668 ) + weight 29 0 1.000000 ( -6.254651 -4.137692 -2.138291 ) + weight 30 0 1.000000 ( -6.254651 -2.311991 -3.963995 ) + weight 31 0 1.000000 ( -6.254651 0.181968 -4.632247 ) + weight 32 0 1.000000 ( -6.254651 2.675927 -3.963996 ) + weight 33 0 1.000000 ( -6.254651 4.501632 -2.138292 ) + weight 34 0 1.000000 ( -6.254651 5.169887 0.355666 ) + weight 35 0 1.000000 ( -6.254651 4.501634 2.849625 ) + weight 36 0 1.000000 ( -6.254651 2.675931 4.675331 ) + weight 37 0 1.000000 ( -4.987916 0.181969 6.610320 ) + weight 38 0 1.000000 ( -4.987916 -2.945357 5.772356 ) + weight 39 0 1.000000 ( -4.987916 -5.234715 3.482994 ) + weight 40 0 1.000000 ( -4.987916 -6.072680 0.355668 ) + weight 41 0 1.000000 ( -4.987916 -5.234715 -2.771657 ) + weight 42 0 1.000000 ( -4.987916 -2.945357 -5.061018 ) + weight 43 0 1.000000 ( -4.987916 0.181968 -5.898983 ) + weight 44 0 1.000000 ( -4.987916 3.309293 -5.061018 ) + weight 45 0 1.000000 ( -4.987916 5.598655 -2.771659 ) + weight 46 0 1.000000 ( -4.987916 6.436620 0.355666 ) + weight 47 0 1.000000 ( -4.987916 5.598658 3.482991 ) + weight 48 0 1.000000 ( -4.987916 3.309298 5.772354 ) + weight 49 0 1.000000 ( -3.471070 0.181969 7.563416 ) + weight 50 0 1.000000 ( -3.471070 -3.421906 6.597764 ) + weight 51 0 1.000000 ( -3.471070 -6.060123 3.959543 ) + weight 52 0 1.000000 ( -3.471070 -7.025782 0.355668 ) + weight 53 0 1.000000 ( -3.471070 -6.060123 -3.248207 ) + weight 54 0 1.000000 ( -3.471070 -3.421907 -5.886425 ) + weight 55 0 1.000000 ( -3.471070 0.181968 -6.852079 ) + weight 56 0 1.000000 ( -3.471070 3.785842 -5.886425 ) + weight 57 0 1.000000 ( -3.471070 6.424059 -3.248209 ) + weight 58 0 1.000000 ( -3.471070 7.389719 0.355665 ) + weight 59 0 1.000000 ( -3.471070 6.424066 3.959540 ) + weight 60 0 1.000000 ( -3.471070 3.785848 6.597761 ) + weight 61 0 1.000000 ( -1.780168 0.181969 8.155088 ) + weight 62 0 1.000000 ( -1.780168 -3.717743 7.110167 ) + weight 63 0 1.000000 ( -1.780168 -6.572527 4.255380 ) + weight 64 0 1.000000 ( -1.780168 -7.617454 0.355668 ) + weight 65 0 1.000000 ( -1.780168 -6.572526 -3.544043 ) + weight 66 0 1.000000 ( -1.780168 -3.717743 -6.398829 ) + weight 67 0 1.000000 ( -1.780168 0.181968 -7.443754 ) + weight 68 0 1.000000 ( -1.780168 4.081676 -6.398829 ) + weight 69 0 1.000000 ( -1.780168 6.936462 -3.544045 ) + weight 70 0 1.000000 ( -1.780168 7.981390 0.355665 ) + weight 71 0 1.000000 ( -1.780168 6.936469 4.255373 ) + weight 72 0 1.000000 ( -1.780168 4.081685 7.110164 ) + weight 73 0 1.000000 ( -0.000001 0.181969 8.355665 ) + weight 74 0 1.000000 ( -0.000001 -3.818031 7.283871 ) + weight 75 0 1.000000 ( -0.000001 -6.746233 4.355668 ) + weight 76 0 1.000000 ( -0.000001 -7.818028 0.355668 ) + weight 77 0 1.000000 ( -0.000001 -6.746233 -3.644331 ) + weight 78 0 1.000000 ( -0.000001 -3.818031 -6.572534 ) + weight 79 0 1.000000 ( -0.000001 0.181968 -7.644331 ) + weight 80 0 1.000000 ( -0.000001 4.181964 -6.572535 ) + weight 81 0 1.000000 ( -0.000001 7.110168 -3.644333 ) + weight 82 0 1.000000 ( -0.000001 8.181966 0.355665 ) + weight 83 0 1.000000 ( -0.000001 7.110174 4.355661 ) + weight 84 0 1.000000 ( -0.000001 4.181973 7.283866 ) + weight 85 0 1.000000 ( 1.780167 0.181969 8.155088 ) + weight 86 0 1.000000 ( 1.780167 -3.717743 7.110167 ) + weight 87 0 1.000000 ( 1.780167 -6.572527 4.255380 ) + weight 88 0 1.000000 ( 1.780167 -7.617455 0.355668 ) + weight 89 0 1.000000 ( 1.780167 -6.572527 -3.544044 ) + weight 90 0 1.000000 ( 1.780167 -3.717743 -6.398829 ) + weight 91 0 1.000000 ( 1.780167 0.181968 -7.443755 ) + weight 92 0 1.000000 ( 1.780167 4.081676 -6.398829 ) + weight 93 0 1.000000 ( 1.780167 6.936466 -3.544045 ) + weight 94 0 1.000000 ( 1.780167 7.981390 0.355665 ) + weight 95 0 1.000000 ( 1.780167 6.936470 4.255373 ) + weight 96 0 1.000000 ( 1.780167 4.081685 7.110165 ) + weight 97 0 1.000000 ( 3.471069 0.181969 7.563416 ) + weight 98 0 1.000000 ( 3.471069 -3.421907 6.597764 ) + weight 99 0 1.000000 ( 3.471069 -6.060124 3.959544 ) + weight 100 0 1.000000 ( 3.471069 -7.025782 0.355668 ) + weight 101 0 1.000000 ( 3.471069 -6.060123 -3.248207 ) + weight 102 0 1.000000 ( 3.471069 -3.421907 -5.886425 ) + weight 103 0 1.000000 ( 3.471069 0.181968 -6.852079 ) + weight 104 0 1.000000 ( 3.471069 3.785842 -5.886425 ) + weight 105 0 1.000000 ( 3.471069 6.424063 -3.248209 ) + weight 106 0 1.000000 ( 3.471069 7.389719 0.355665 ) + weight 107 0 1.000000 ( 3.471069 6.424066 3.959540 ) + weight 108 0 1.000000 ( 3.471069 3.785848 6.597761 ) + weight 109 0 1.000000 ( 4.987916 0.181969 6.610320 ) + weight 110 0 1.000000 ( 4.987916 -2.945357 5.772356 ) + weight 111 0 1.000000 ( 4.987916 -5.234715 3.482994 ) + weight 112 0 1.000000 ( 4.987916 -6.072680 0.355668 ) + weight 113 0 1.000000 ( 4.987916 -5.234715 -2.771657 ) + weight 114 0 1.000000 ( 4.987916 -2.945357 -5.061018 ) + weight 115 0 1.000000 ( 4.987916 0.181968 -5.898983 ) + weight 116 0 1.000000 ( 4.987916 3.309293 -5.061018 ) + weight 117 0 1.000000 ( 4.987916 5.598655 -2.771659 ) + weight 118 0 1.000000 ( 4.987916 6.436620 0.355666 ) + weight 119 0 1.000000 ( 4.987916 5.598658 3.482991 ) + weight 120 0 1.000000 ( 4.987916 3.309298 5.772354 ) + weight 121 0 1.000000 ( 6.254652 0.181969 5.343585 ) + weight 122 0 1.000000 ( 6.254652 -2.311990 4.675332 ) + weight 123 0 1.000000 ( 6.254652 -4.137691 2.849627 ) + weight 124 0 1.000000 ( 6.254652 -4.805949 0.355668 ) + weight 125 0 1.000000 ( 6.254652 -4.137691 -2.138290 ) + weight 126 0 1.000000 ( 6.254652 -2.311990 -3.963995 ) + weight 127 0 1.000000 ( 6.254652 0.181968 -4.632246 ) + weight 128 0 1.000000 ( 6.254652 2.675926 -3.963995 ) + weight 129 0 1.000000 ( 6.254652 4.501628 -2.138292 ) + weight 130 0 1.000000 ( 6.254652 5.169886 0.355666 ) + weight 131 0 1.000000 ( 6.254652 4.501633 2.849625 ) + weight 132 0 1.000000 ( 6.254652 2.675930 4.675330 ) + weight 133 0 1.000000 ( 7.207748 0.181969 3.826737 ) + weight 134 0 1.000000 ( 7.207748 -1.553566 3.361702 ) + weight 135 0 1.000000 ( 7.207748 -2.824065 2.091203 ) + weight 136 0 1.000000 ( 7.207748 -3.289100 0.355668 ) + weight 137 0 1.000000 ( 7.207748 -2.824065 -1.379866 ) + weight 138 0 1.000000 ( 7.207748 -1.553566 -2.650365 ) + weight 139 0 1.000000 ( 7.207748 0.181968 -3.115400 ) + weight 140 0 1.000000 ( 7.207748 1.917502 -2.650365 ) + weight 141 0 1.000000 ( 7.207748 3.188002 -1.379867 ) + weight 142 0 1.000000 ( 7.207748 3.653037 0.355667 ) + weight 143 0 1.000000 ( 7.207748 3.188003 2.091201 ) + weight 144 0 1.000000 ( 7.207748 1.917505 3.361701 ) + weight 145 0 1.000000 ( 7.799423 0.181969 2.135834 ) + weight 146 0 1.000000 ( 7.799423 -0.708114 1.897337 ) + weight 147 0 1.000000 ( 7.799423 -1.359700 1.245751 ) + weight 148 0 1.000000 ( 7.799423 -1.598197 0.355668 ) + weight 149 0 1.000000 ( 7.799423 -1.359700 -0.534414 ) + weight 150 0 1.000000 ( 7.799423 -0.708114 -1.186000 ) + weight 151 0 1.000000 ( 7.799423 0.181968 -1.424497 ) + weight 152 0 1.000000 ( 7.799423 1.072051 -1.186000 ) + weight 153 0 1.000000 ( 7.799423 1.723637 -0.534415 ) + weight 154 0 1.000000 ( 7.799423 1.962134 0.355668 ) + weight 155 0 1.000000 ( 7.799423 1.723638 1.245750 ) + weight 156 0 1.000000 ( 7.799423 1.072053 1.897336 ) + weight 157 0 1.000000 ( 8.000000 0.181969 0.355668 ) +} + +mesh { + // meshes: Skin3 + shader "" + + numverts 20 + vert 0 ( 0.000000 0.000000 ) 0 1 + vert 1 ( 1.000000 0.000000 ) 1 1 + vert 2 ( 1.000000 1.000000 ) 2 1 + vert 3 ( 0.000000 1.000000 ) 3 1 + vert 4 ( 1.000000 0.000000 ) 4 1 + vert 5 ( 1.000000 1.000000 ) 5 1 + vert 6 ( 0.000000 1.000000 ) 6 1 + vert 7 ( 0.000000 0.000000 ) 7 1 + vert 8 ( 1.000000 0.000000 ) 8 1 + vert 9 ( 1.000000 1.000000 ) 9 1 + vert 10 ( 0.000000 1.000000 ) 10 1 + vert 11 ( 0.000000 0.000000 ) 11 1 + vert 12 ( 0.000000 0.000000 ) 12 1 + vert 13 ( 1.000000 0.000000 ) 13 1 + vert 14 ( 0.000000 1.000000 ) 14 1 + vert 15 ( 0.000000 1.000000 ) 15 1 + vert 16 ( 0.000000 0.000000 ) 16 1 + vert 17 ( 1.000000 1.000000 ) 17 1 + vert 18 ( 1.000000 1.000000 ) 18 1 + vert 19 ( 1.000000 0.000000 ) 19 1 + + numtris 12 + tri 0 0 1 2 + tri 1 2 3 0 + tri 2 4 5 6 + tri 3 6 7 4 + tri 4 8 9 10 + tri 5 10 11 8 + tri 6 12 13 9 + tri 7 9 14 12 + tri 8 15 16 13 + tri 9 13 17 15 + tri 10 18 10 16 + tri 11 16 19 18 + + numweights 20 + weight 0 0 1.000000 ( 15.752776 -15.001534 0.000027 ) + weight 1 0 1.000000 ( 15.752776 16.216133 0.000027 ) + weight 2 0 1.000000 ( 15.752776 16.216133 -31.298508 ) + weight 3 0 1.000000 ( 15.752776 -15.001534 -31.298508 ) + weight 4 0 1.000000 ( -15.901433 -15.001534 0.000027 ) + weight 5 0 1.000000 ( -15.901433 -15.001534 -31.298508 ) + weight 6 0 1.000000 ( -15.901433 16.216133 -31.298508 ) + weight 7 0 1.000000 ( -15.901433 16.216133 0.000027 ) + weight 8 0 1.000000 ( -15.901433 -15.001534 -31.298508 ) + weight 9 0 1.000000 ( 15.752776 -15.001534 -31.298508 ) + weight 10 0 1.000000 ( 15.752776 16.216133 -31.298508 ) + weight 11 0 1.000000 ( -15.901433 16.216133 -31.298508 ) + weight 12 0 1.000000 ( -15.901433 -15.001534 0.000027 ) + weight 13 0 1.000000 ( 15.752776 -15.001534 0.000027 ) + weight 14 0 1.000000 ( -15.901433 -15.001534 -31.298508 ) + weight 15 0 1.000000 ( -15.901433 16.216133 0.000027 ) + weight 16 0 1.000000 ( 15.752776 16.216133 0.000027 ) + weight 17 0 1.000000 ( -15.901433 -15.001534 0.000027 ) + weight 18 0 1.000000 ( -15.901433 16.216133 -31.298508 ) + weight 19 0 1.000000 ( -15.901433 16.216133 0.000027 ) +} + +mesh { + // meshes: GeoSphere1 + shader "" + + numverts 102 + vert 0 ( 1.000000 0.100000 ) 0 1 + vert 1 ( 0.750000 0.100000 ) 1 1 + vert 2 ( 1.000000 0.000000 ) 2 1 + vert 3 ( 0.875000 0.151064 ) 3 1 + vert 4 ( 0.750000 0.200000 ) 4 1 + vert 5 ( 1.000000 0.200000 ) 5 1 + vert 6 ( 0.829325 0.252330 ) 6 1 + vert 7 ( 0.750000 0.300000 ) 7 1 + vert 8 ( 0.920675 0.252330 ) 8 1 + vert 9 ( 1.000000 0.300000 ) 9 1 + vert 10 ( 0.810997 0.372661 ) 10 1 + vert 11 ( 0.750000 0.400000 ) 11 1 + vert 12 ( 0.875000 0.362894 ) 12 1 + vert 13 ( 0.939003 0.372661 ) 13 1 + vert 14 ( 1.000000 0.400000 ) 14 1 + vert 15 ( 0.800000 0.500000 ) 15 1 + vert 16 ( 0.750000 0.500000 ) 16 1 + vert 17 ( 0.850000 0.500000 ) 17 1 + vert 18 ( 0.900000 0.500000 ) 18 1 + vert 19 ( 0.950000 0.500000 ) 19 1 + vert 20 ( 1.000000 0.500000 ) 20 1 + vert 21 ( 0.250000 0.100000 ) 21 1 + vert 22 ( 0.125000 0.151064 ) 22 1 + vert 23 ( 0.250000 0.200000 ) 23 1 + vert 24 ( 0.079325 0.252330 ) 24 1 + vert 25 ( 0.170675 0.252330 ) 25 1 + vert 26 ( 0.250000 0.300000 ) 26 1 + vert 27 ( 0.060997 0.372661 ) 27 1 + vert 28 ( 0.125000 0.362894 ) 28 1 + vert 29 ( 0.189003 0.372661 ) 29 1 + vert 30 ( 0.250000 0.400000 ) 30 1 + vert 31 ( 0.050000 0.500000 ) 31 1 + vert 32 ( 0.100000 0.500000 ) 32 1 + vert 33 ( 0.150000 0.500000 ) 33 1 + vert 34 ( 0.200000 0.500000 ) 34 1 + vert 35 ( 0.250000 0.500000 ) 35 1 + vert 36 ( 0.500000 0.100000 ) 36 1 + vert 37 ( 0.375000 0.151064 ) 37 1 + vert 38 ( 0.500000 0.200000 ) 38 1 + vert 39 ( 0.329325 0.252330 ) 39 1 + vert 40 ( 0.420675 0.252330 ) 40 1 + vert 41 ( 0.500000 0.300000 ) 41 1 + vert 42 ( 0.310997 0.372661 ) 42 1 + vert 43 ( 0.375000 0.362894 ) 43 1 + vert 44 ( 0.439003 0.372661 ) 44 1 + vert 45 ( 0.500000 0.400000 ) 45 1 + vert 46 ( 0.300000 0.500000 ) 46 1 + vert 47 ( 0.350000 0.500000 ) 47 1 + vert 48 ( 0.400000 0.500000 ) 48 1 + vert 49 ( 0.450000 0.500000 ) 49 1 + vert 50 ( 0.500000 0.500000 ) 50 1 + vert 51 ( 0.625000 0.151064 ) 51 1 + vert 52 ( 0.579325 0.252330 ) 52 1 + vert 53 ( 0.670675 0.252330 ) 53 1 + vert 54 ( 0.560997 0.372661 ) 54 1 + vert 55 ( 0.625000 0.362894 ) 55 1 + vert 56 ( 0.689003 0.372661 ) 56 1 + vert 57 ( 0.550000 0.500000 ) 57 1 + vert 58 ( 0.600000 0.500000 ) 58 1 + vert 59 ( 0.650000 0.500000 ) 59 1 + vert 60 ( 0.700000 0.500000 ) 60 1 + vert 61 ( 0.750000 0.900000 ) 61 1 + vert 62 ( 1.000000 0.900000 ) 62 1 + vert 63 ( 0.500000 1.000000 ) 63 1 + vert 64 ( 0.875000 0.848936 ) 64 1 + vert 65 ( 1.000000 0.800000 ) 65 1 + vert 66 ( 0.750000 0.800000 ) 66 1 + vert 67 ( 0.920675 0.747670 ) 67 1 + vert 68 ( 1.000000 0.700000 ) 68 1 + vert 69 ( 0.829325 0.747670 ) 69 1 + vert 70 ( 0.750000 0.700000 ) 70 1 + vert 71 ( 0.939003 0.627339 ) 71 1 + vert 72 ( 1.000000 0.600000 ) 72 1 + vert 73 ( 0.875000 0.637106 ) 73 1 + vert 74 ( 0.810997 0.627339 ) 74 1 + vert 75 ( 0.750000 0.600000 ) 75 1 + vert 76 ( 0.250000 0.900000 ) 76 1 + vert 77 ( 0.125000 0.848936 ) 77 1 + vert 78 ( 0.250000 0.800000 ) 78 1 + vert 79 ( 0.170675 0.747670 ) 79 1 + vert 80 ( 0.250000 0.700000 ) 80 1 + vert 81 ( 0.079325 0.747670 ) 81 1 + vert 82 ( 0.189003 0.627339 ) 82 1 + vert 83 ( 0.250000 0.600000 ) 83 1 + vert 84 ( 0.125000 0.637106 ) 84 1 + vert 85 ( 0.060997 0.627339 ) 85 1 + vert 86 ( 0.500000 0.900000 ) 86 1 + vert 87 ( 0.375000 0.848936 ) 87 1 + vert 88 ( 0.500000 0.800000 ) 88 1 + vert 89 ( 0.420675 0.747670 ) 89 1 + vert 90 ( 0.500000 0.700000 ) 90 1 + vert 91 ( 0.329325 0.747670 ) 91 1 + vert 92 ( 0.439003 0.627339 ) 92 1 + vert 93 ( 0.500000 0.600000 ) 93 1 + vert 94 ( 0.375000 0.637106 ) 94 1 + vert 95 ( 0.310997 0.627339 ) 95 1 + vert 96 ( 0.625000 0.848936 ) 96 1 + vert 97 ( 0.670675 0.747670 ) 97 1 + vert 98 ( 0.579325 0.747670 ) 98 1 + vert 99 ( 0.689003 0.627339 ) 99 1 + vert 100 ( 0.625000 0.637106 ) 100 1 + vert 101 ( 0.560997 0.627339 ) 101 1 + + numtris 200 + tri 0 0 1 2 + tri 1 3 4 1 + tri 2 0 3 1 + tri 3 5 3 0 + tri 4 6 7 4 + tri 5 3 6 4 + tri 6 8 6 3 + tri 7 5 8 3 + tri 8 9 8 5 + tri 9 10 11 7 + tri 10 6 10 7 + tri 11 12 10 6 + tri 12 8 12 6 + tri 13 13 12 8 + tri 14 9 13 8 + tri 15 14 13 9 + tri 16 15 16 11 + tri 17 10 15 11 + tri 18 17 15 10 + tri 19 12 17 10 + tri 20 18 17 12 + tri 21 13 18 12 + tri 22 19 18 13 + tri 23 14 19 13 + tri 24 20 19 14 + tri 25 21 0 2 + tri 26 22 5 0 + tri 27 21 22 0 + tri 28 23 22 21 + tri 29 24 9 5 + tri 30 22 24 5 + tri 31 25 24 22 + tri 32 23 25 22 + tri 33 26 25 23 + tri 34 27 14 9 + tri 35 24 27 9 + tri 36 28 27 24 + tri 37 25 28 24 + tri 38 29 28 25 + tri 39 26 29 25 + tri 40 30 29 26 + tri 41 31 20 14 + tri 42 27 31 14 + tri 43 32 31 27 + tri 44 28 32 27 + tri 45 33 32 28 + tri 46 29 33 28 + tri 47 34 33 29 + tri 48 30 34 29 + tri 49 35 34 30 + tri 50 36 21 2 + tri 51 37 23 21 + tri 52 36 37 21 + tri 53 38 37 36 + tri 54 39 26 23 + tri 55 37 39 23 + tri 56 40 39 37 + tri 57 38 40 37 + tri 58 41 40 38 + tri 59 42 30 26 + tri 60 39 42 26 + tri 61 43 42 39 + tri 62 40 43 39 + tri 63 44 43 40 + tri 64 41 44 40 + tri 65 45 44 41 + tri 66 46 35 30 + tri 67 42 46 30 + tri 68 47 46 42 + tri 69 43 47 42 + tri 70 48 47 43 + tri 71 44 48 43 + tri 72 49 48 44 + tri 73 45 49 44 + tri 74 50 49 45 + tri 75 1 36 2 + tri 76 51 38 36 + tri 77 1 51 36 + tri 78 4 51 1 + tri 79 52 41 38 + tri 80 51 52 38 + tri 81 53 52 51 + tri 82 4 53 51 + tri 83 7 53 4 + tri 84 54 45 41 + tri 85 52 54 41 + tri 86 55 54 52 + tri 87 53 55 52 + tri 88 56 55 53 + tri 89 7 56 53 + tri 90 11 56 7 + tri 91 57 50 45 + tri 92 54 57 45 + tri 93 58 57 54 + tri 94 55 58 54 + tri 95 59 58 55 + tri 96 56 59 55 + tri 97 60 59 56 + tri 98 11 60 56 + tri 99 16 60 11 + tri 100 61 62 63 + tri 101 64 65 62 + tri 102 61 64 62 + tri 103 66 64 61 + tri 104 67 68 65 + tri 105 64 67 65 + tri 106 69 67 64 + tri 107 66 69 64 + tri 108 70 69 66 + tri 109 71 72 68 + tri 110 67 71 68 + tri 111 73 71 67 + tri 112 69 73 67 + tri 113 74 73 69 + tri 114 70 74 69 + tri 115 75 74 70 + tri 116 19 20 72 + tri 117 71 19 72 + tri 118 18 19 71 + tri 119 73 18 71 + tri 120 17 18 73 + tri 121 74 17 73 + tri 122 15 17 74 + tri 123 75 15 74 + tri 124 16 15 75 + tri 125 62 76 63 + tri 126 77 78 76 + tri 127 62 77 76 + tri 128 65 77 62 + tri 129 79 80 78 + tri 130 77 79 78 + tri 131 81 79 77 + tri 132 65 81 77 + tri 133 68 81 65 + tri 134 82 83 80 + tri 135 79 82 80 + tri 136 84 82 79 + tri 137 81 84 79 + tri 138 85 84 81 + tri 139 68 85 81 + tri 140 72 85 68 + tri 141 34 35 83 + tri 142 82 34 83 + tri 143 33 34 82 + tri 144 84 33 82 + tri 145 32 33 84 + tri 146 85 32 84 + tri 147 31 32 85 + tri 148 72 31 85 + tri 149 20 31 72 + tri 150 76 86 63 + tri 151 87 88 86 + tri 152 76 87 86 + tri 153 78 87 76 + tri 154 89 90 88 + tri 155 87 89 88 + tri 156 91 89 87 + tri 157 78 91 87 + tri 158 80 91 78 + tri 159 92 93 90 + tri 160 89 92 90 + tri 161 94 92 89 + tri 162 91 94 89 + tri 163 95 94 91 + tri 164 80 95 91 + tri 165 83 95 80 + tri 166 49 50 93 + tri 167 92 49 93 + tri 168 48 49 92 + tri 169 94 48 92 + tri 170 47 48 94 + tri 171 95 47 94 + tri 172 46 47 95 + tri 173 83 46 95 + tri 174 35 46 83 + tri 175 86 61 63 + tri 176 96 66 61 + tri 177 86 96 61 + tri 178 88 96 86 + tri 179 97 70 66 + tri 180 96 97 66 + tri 181 98 97 96 + tri 182 88 98 96 + tri 183 90 98 88 + tri 184 99 75 70 + tri 185 97 99 70 + tri 186 100 99 97 + tri 187 98 100 97 + tri 188 101 100 98 + tri 189 90 101 98 + tri 190 93 101 90 + tri 191 60 16 75 + tri 192 99 60 75 + tri 193 59 60 99 + tri 194 100 59 99 + tri 195 58 59 100 + tri 196 101 58 100 + tri 197 57 58 101 + tri 198 93 57 101 + tri 199 50 57 93 + + numweights 102 + weight 0 3 1.000000 ( -7.608452 0.030722 2.726370 ) + weight 1 3 1.000000 ( -7.608452 -2.441414 0.254234 ) + weight 2 3 1.000000 ( -8.000000 0.030722 0.254234 ) + weight 3 3 1.000000 ( -7.115871 -2.554270 2.839226 ) + weight 4 3 1.000000 ( -6.472136 -4.671560 0.254234 ) + weight 5 3 1.000000 ( -6.472136 0.030722 4.956516 ) + weight 6 3 1.000000 ( -5.615288 -4.974171 2.978123 ) + weight 7 3 1.000000 ( -4.702281 -6.441414 0.254234 ) + weight 8 3 1.000000 ( -5.615288 -2.693167 5.259127 ) + weight 9 3 1.000000 ( -4.702281 0.030722 6.726370 ) + weight 10 3 1.000000 ( -3.115694 -6.803060 3.009572 ) + weight 11 3 1.000000 ( -2.472136 -7.577730 0.254234 ) + weight 12 3 1.000000 ( -3.340279 -5.109440 5.394396 ) + weight 13 3 1.000000 ( -3.115694 -2.724616 7.088016 ) + weight 14 3 1.000000 ( -2.472136 0.030722 7.862686 ) + weight 15 3 1.000000 ( 0.000000 -7.577730 2.726370 ) + weight 16 3 1.000000 ( 0.000000 -7.969278 0.254234 ) + weight 17 3 1.000000 ( 0.000000 -6.441414 4.956516 ) + weight 18 3 1.000000 ( 0.000000 -4.671560 6.726370 ) + weight 19 3 1.000000 ( 0.000000 -2.441414 7.862686 ) + weight 20 3 1.000000 ( 0.000000 0.030722 8.254234 ) + weight 21 3 1.000000 ( -7.608452 2.502857 0.254234 ) + weight 22 3 1.000000 ( -7.115871 2.615713 2.839226 ) + weight 23 3 1.000000 ( -6.472136 4.733003 0.254234 ) + weight 24 3 1.000000 ( -5.615288 2.754611 5.259127 ) + weight 25 3 1.000000 ( -5.615288 5.035614 2.978123 ) + weight 26 3 1.000000 ( -4.702281 6.502857 0.254234 ) + weight 27 3 1.000000 ( -3.115694 2.786060 7.088016 ) + weight 28 3 1.000000 ( -3.340279 5.170883 5.394396 ) + weight 29 3 1.000000 ( -3.115694 6.864503 3.009572 ) + weight 30 3 1.000000 ( -2.472136 7.639174 0.254234 ) + weight 31 3 1.000000 ( 0.000000 2.502857 7.862686 ) + weight 32 3 1.000000 ( 0.000000 4.733003 6.726370 ) + weight 33 3 1.000000 ( 0.000000 6.502857 4.956516 ) + weight 34 3 1.000000 ( 0.000000 7.639174 2.726370 ) + weight 35 3 1.000000 ( 0.000000 8.030722 0.254234 ) + weight 36 3 1.000000 ( -7.608452 0.030722 -2.217901 ) + weight 37 3 1.000000 ( -7.115871 2.615713 -2.330757 ) + weight 38 3 1.000000 ( -6.472136 0.030722 -4.448047 ) + weight 39 3 1.000000 ( -5.615288 5.035614 -2.469655 ) + weight 40 3 1.000000 ( -5.615288 2.754611 -4.750658 ) + weight 41 3 1.000000 ( -4.702281 0.030722 -6.217901 ) + weight 42 3 1.000000 ( -3.115694 6.864503 -2.501104 ) + weight 43 3 1.000000 ( -3.340279 5.170883 -4.885927 ) + weight 44 3 1.000000 ( -3.115694 2.786060 -6.579547 ) + weight 45 3 1.000000 ( -2.472136 0.030722 -7.354218 ) + weight 46 3 1.000000 ( 0.000000 7.639174 -2.217901 ) + weight 47 3 1.000000 ( 0.000000 6.502857 -4.448047 ) + weight 48 3 1.000000 ( 0.000000 4.733003 -6.217901 ) + weight 49 3 1.000000 ( 0.000000 2.502857 -7.354218 ) + weight 50 3 1.000000 ( 0.000000 0.030722 -7.745765 ) + weight 51 3 1.000000 ( -7.115871 -2.554270 -2.330757 ) + weight 52 3 1.000000 ( -5.615288 -2.693167 -4.750658 ) + weight 53 3 1.000000 ( -5.615288 -4.974171 -2.469655 ) + weight 54 3 1.000000 ( -3.115694 -2.724616 -6.579547 ) + weight 55 3 1.000000 ( -3.340279 -5.109440 -4.885927 ) + weight 56 3 1.000000 ( -3.115694 -6.803060 -2.501104 ) + weight 57 3 1.000000 ( 0.000000 -2.441414 -7.354218 ) + weight 58 3 1.000000 ( 0.000000 -4.671560 -6.217901 ) + weight 59 3 1.000000 ( 0.000000 -6.441414 -4.448047 ) + weight 60 3 1.000000 ( 0.000000 -7.577730 -2.217901 ) + weight 61 3 1.000000 ( 7.608452 -2.441414 0.254234 ) + weight 62 3 1.000000 ( 7.608452 0.030722 2.726370 ) + weight 63 3 1.000000 ( 8.000000 0.030722 0.254234 ) + weight 64 3 1.000000 ( 7.115871 -2.554270 2.839226 ) + weight 65 3 1.000000 ( 6.472136 0.030722 4.956516 ) + weight 66 3 1.000000 ( 6.472136 -4.671560 0.254234 ) + weight 67 3 1.000000 ( 5.615288 -2.693167 5.259127 ) + weight 68 3 1.000000 ( 4.702281 0.030722 6.726370 ) + weight 69 3 1.000000 ( 5.615288 -4.974171 2.978123 ) + weight 70 3 1.000000 ( 4.702281 -6.441414 0.254234 ) + weight 71 3 1.000000 ( 3.115694 -2.724616 7.088016 ) + weight 72 3 1.000000 ( 2.472136 0.030722 7.862686 ) + weight 73 3 1.000000 ( 3.340279 -5.109440 5.394396 ) + weight 74 3 1.000000 ( 3.115694 -6.803060 3.009572 ) + weight 75 3 1.000000 ( 2.472136 -7.577730 0.254234 ) + weight 76 3 1.000000 ( 7.608452 2.502857 0.254234 ) + weight 77 3 1.000000 ( 7.115871 2.615713 2.839226 ) + weight 78 3 1.000000 ( 6.472136 4.733003 0.254234 ) + weight 79 3 1.000000 ( 5.615288 5.035614 2.978123 ) + weight 80 3 1.000000 ( 4.702281 6.502857 0.254234 ) + weight 81 3 1.000000 ( 5.615288 2.754611 5.259127 ) + weight 82 3 1.000000 ( 3.115694 6.864503 3.009572 ) + weight 83 3 1.000000 ( 2.472136 7.639174 0.254234 ) + weight 84 3 1.000000 ( 3.340279 5.170883 5.394396 ) + weight 85 3 1.000000 ( 3.115694 2.786060 7.088016 ) + weight 86 3 1.000000 ( 7.608452 0.030722 -2.217901 ) + weight 87 3 1.000000 ( 7.115871 2.615713 -2.330757 ) + weight 88 3 1.000000 ( 6.472136 0.030722 -4.448047 ) + weight 89 3 1.000000 ( 5.615288 2.754611 -4.750658 ) + weight 90 3 1.000000 ( 4.702281 0.030722 -6.217901 ) + weight 91 3 1.000000 ( 5.615288 5.035614 -2.469655 ) + weight 92 3 1.000000 ( 3.115694 2.786060 -6.579547 ) + weight 93 3 1.000000 ( 2.472136 0.030722 -7.354218 ) + weight 94 3 1.000000 ( 3.340279 5.170883 -4.885927 ) + weight 95 3 1.000000 ( 3.115694 6.864503 -2.501104 ) + weight 96 3 1.000000 ( 7.115871 -2.554270 -2.330757 ) + weight 97 3 1.000000 ( 5.615288 -4.974171 -2.469655 ) + weight 98 3 1.000000 ( 5.615288 -2.693167 -4.750658 ) + weight 99 3 1.000000 ( 3.115694 -6.803060 -2.501104 ) + weight 100 3 1.000000 ( 3.340279 -5.109440 -4.885927 ) + weight 101 3 1.000000 ( 3.115694 -2.724616 -6.579547 ) +} + diff --git a/build/main/models/omtests/testhoserot1/testhoserot1.skc b/build/main/models/omtests/testhoserot1/testhoserot1.skc new file mode 100644 index 0000000000000000000000000000000000000000..a9d3b09e06cf8c6e0f82fa383f3fb17add93b186 GIT binary patch literal 480 zcmWIccJ$+AfPe>#3=G`Ym2DwB1j)g`!0>>9fq{{Mfx#uG?w~tc!NKt4UkBs3YaCD8 zO>h!+vp z|BkE-4OsO%<>#duDiq`wqiTfnAo4}|C2$c`21wqBfPNzd{Q8Xv=r<;y--LjE6Fm9> DHt;vQ literal 0 HcmV?d00001 diff --git a/build/main/models/omtests/testhoserot1/testhoserot1.skd b/build/main/models/omtests/testhoserot1/testhoserot1.skd new file mode 100644 index 0000000000000000000000000000000000000000..f01a3878ec8600b5957b83716ae5a55c634e5f3b GIT binary patch literal 48284 zcmWIc_H|)pU|=XoEiTE(FHSAWFEP|B&Q4(<5rE8KVPIgG0y2w<)kF#=cVFM!^ptE5W>K~kN|QE6f-b1*uyZ`e1)R?5(WsXAio&QGQwdV zNEoaV#K3`xvC{}{r;!58PGcPAfrLSJ;&T%*b{fO&G=|%00x}#2CS)floum`LfIgi3(5x3+)y@%=7F+7G{_ww%*(*Qz{kMA0Ahn^kefgl#O7yU0J{-H zgWLzgAhrMl0|ST+qCsv2VGvu8fq?M1%YT z!XUN?0|Nty4WdDQ17Q$bl!1W(#0JqIe}XWGEylpW0Ahn^ke@*q#1>~@U;wc}G|2xT z3}Q<#Fff4FAQ}`FAPi!I!UDtw(V*}E(UJ@d3{ngX3?Md$289aZihz5lV2!q%f z3=9k)Hi!m=3kZYQnhXpKAU22wg$oFS*jfw>3?Md$289a(3=AMPhz5lV2!q%< z3=9k)Hi!m=3kZYQx(o~qAU22wg$oFS*m?{M3?Md$289a-f3u1$4P`H3Fh;6{Y zzyM-{Xi&I-Fo+Eb3lJMbgTezugX#=Wc?n{JXi&I-Fo+E*XF+Tb4GI?!2C+e9A&3p4 zLE!?zAhsz30|ST+qCw#T!XUO80|Nty4WdEe0>U7+IRgU&hz+7a;R3=Swgm$N1BeZx zLE!?zAhsm~0|ST+qCw#T!XUO40|Nty4WdEe0>U7+H3I_!hz+7a;R3=SwhaRV1BeZx zLE!?zAT}s0Kx_~V3J(x%%fP^3$H2e_7$v1`r!WgTe)bLF^y~1_lrtM1#TwghA|J1_lNY8$^S`1%yFtP+bmUgJ@8= zfG~&+3JVY$M1#TuM29jkFoZEMFo4(~8Wb)d3}S~v!wy7)!Ucpu><9)11`r!WgTe)b zLF`Bd1_lrtM1#TwghA{m1_lNY8$^S`1%yHDXa)ub5F12;!Ucpu>=*_H1`r!WgTe)b zLF`xt1_lrtM1#TwghA{$1_lNY8$^S`1%yHDcm@Ur5F12;!UcpuY)~5##0JrzZ~jMU|;~TK{O~_Kp4bMhK3!8289a<93y2M(LE!?zAU3FN z3u1$4P`H3Fh@Hm3zyM-{Xi&I-Fo>Pbz`y`vgJ@8=fG~)i!N9-(VuNTPaz`y`vgJ@8=fG~)i!@$4*VuNT#0JrzZ~U769RmXchz+7a;R3=Sc0B_F1BeZxLE!?zAa(--0|ST+qCw#T!XS1dv|k0HLE!?z zAa)Z20|ST+qCw#T!XS1t0|Nty4WdEe0>U6RsQ&<$J71`r!WgTe)bLF`Uw{{=*Y!Ucpu>@Efd z1`r!WgTe)bLF{e@1_lrtM1#TwghA{c1_lNY8$^S`1%yHDUIqpR5F12;!Ucpu>^=qt z1`r!WgTe)bLF|481_lrtM1#TwghA{H3=9k)Hi!m=3kZYQps)b3K{O~lK=ecg28Kxt z3=AMPhz5lV2!q&@pU8nbOr_n5F12;!Ucpu>=_IU3?Md$289azzyM-{Xi&I-Fo+Eb3lJMbgTiAj0|Ns{9Ha-t z2GJmML2M8WvKzz((IEGM*dQ9@2M`-XgZv3%gJ@7#fY=}!6kZ@Uhz5lzhz+7a;SOSh zXplQVY!D4{$N&HJ`$1jA@7duSApK-WzYrt_>JNd${{H`eKs&Y5j$y$(B61Go9NN(STRa!XJgUok07q>siqz><#+#h06zCX~s#g6;(I~xXu2At}jNijQs!Uq&z0wQ5{3kBuu z4zAL|sebpm=k}oR4>u{_|7GVDTl06tc6F;(+2V5l1otWSp!j8;ma^aY%AGwvQqREY zN7_@!4n6(cTlx%~eiAa{9fYQ(>8GT+e1Z{KsBbKvxYOFhW_0rK_-c&DZ8kGXcoMpfz=IQ`&K&zah3SMVt2 z0LXkD)djnKhOab{-E&mG4iwfsB;dSesHN@XV2gO zir>;yxBaJA@89!%jUsp)^;B*&M*5LdI{{8V3+xs+l%%@t-^H_LpCc=$J*fP_r9Pp6 z??AwvE{C2}xBbmb{QDpJOb4eQTbC#h8pZu$YxaZF4=(lV*rtQi zPjjlHI{jYh}fYT2y^&s;bBIOQrrMm5B^qs!1mWh8qsQkgD9_0QPGdd4|-0!qz zzs>D6ilB1c9+!Gh`f>O@??6YY+x~q#YwQ$RIroFgA6)8}oiuO&nGf=B2@}7)w(oRs z`oX3C--SsIAosVWy6u0wM$x`-^?q>r!KFUJcm+89^rpJ)S77C|U&pfsoPKbrXSq1Z z0Tlk-pz!yZZr94hZx1SeaH-#Z(!c=}zh`aa_Uk{Kv8Peb6P$jeJttwLAI7=!!RhC~ z@e>ZKZRGYJDY>{$_PRDW{oqnx_|xow!uPcf%WUNK3(YgwAN}G0IQ`&Kud#p0frLy? zhix`;`zPyp?w@uaG~?i4k4ycL{{7(ev&u$pKlgR*{eMd?g3}K!^&s;nJaRj*$wqE} z?27~Y*ykC5(+@87r9aIM?AW~Kz*ZZ%{SNnM*i6y$1g9Td>OtuzqUAVP{mqh#c0AX$ z!RZH=`W-=$4j}VE?)f*@z`pUt0dV@krT*OOtqvgfueFieKU>e!KJVTPaQeZeK4;Gb zaQazqBe!4dy0-nPl8fNFD*IOMx;SVxD@WlZ;{&@!A^n*+N*`P=VQ2a7E-Pvb$ zGGxzY;dF5NDZaf8BmFR`#evh$1o!6-KOOJv6TkLm->wojaQeZe-nKIIz=MPn4xNs7 z_OYDs+}|Jg5S)H+seh)i|A52GbcflFclMnTPTwzlIs{z);8H(<{~kE~G&tVbcd^86 zzty!j;Pit_{S%G-2Lh5(57au|*|#9@;XdXQp5XL@OFhW_6|%<~58~fzuBz_4Sv^9YE&yIo{d#qPCvNR8{51Gr=JwZJNw?0xY_@?`UaeSaH*dZdcgq{ z{xco#?3)|-(C*K1PjLFdrGDn6atBcSroB(xciH;Z?$q^_;PkU1_cliQ>Av%LKd8Mu z!R(jAocD?QmM#9XuP!khoPKbrH_ym8FyYt@hqdn$_eqOI?$_A;4V->(sc-B%e?Z|z zl|%dc#C^%@EB8ma-r5anKjTv0^X~&V{cL%kxUVuXeE){Uf57PnmwJ%-0f7|!KHpjLaT#B^YsIz?-Td&h(+4x?EVH$Ke*JZ?|$Hr5Lj`b@_pjIl=YSNWlp!O zLG5Q;>Zgh_I)d7V@$VD&O-&59Ph0#4oPKbr*WdlXf#F7#L+<;;eO0@^*>Q+Pg3}K! z^`{eB9SV-!aA5y^U@PZ$9n=5+>%r*~!(vMZ(>t4E_rLo8ADn)0sc)9OdSJoA1_zb*Eykce?B>}00t^iMLH#dW>Otlg?5R7TXsy46fq`NFwau~M^n*)%)aASb z0z!8W{N1!_%R~pGEg(06)PgX!@ByVCi@5&>io7kh{QUpl?#AX=aQeZe-fvom1IT8!yeb?CvNS5TpWU2xzn>u6~C zqvI)Lj~+f%cOKh=(hsQoS@k~AE_(O3eY|3k;Pit_Jt+Tz${&mOiFQ*H!}sSc{sT@w zxYUEn2T=Kw{65hRl-K!PLHWzU9+!Gp`7`l-q8*P|kX-@xS$F7+VuLFG@^`$W6$ z#eep-Cx(O54=(i}_k+rxzW0fC@}9SLgUUouSmII-NiAWu*0Q(8lwEMlNXD$*WLXMT>juv z4=R5^;SX~E;>CaL8WO|7=?9m3Sow3=@s8ci(;+tdpzR;`Nh%oW=cj6%133M-KXbugG)WE{nPGv$L@k~`u?UKyObDO`KA57a&Z^}lebcdQIO0BWC< zJKnLobuwhn6=?ehmwHh80kwZR9q-tI+IpZiAE^I@OFgXp(+Ki!iJQIMwKw4OgG)WE z{R49UW#M%DrQr5qgB>pQu=WoqJh@JI+Sdd=1g9Td>Zd^4KkFRt*zsL^V|TH{4V->( zshC!=@G5|0=$1hLL_4=gtSGA5i~mg^iqj^os-g1m+ol(+@87u>RK? z8##Ni>)QLTmRtm>1`6?5}!p z0GxhssRx-4>c6bFk+XkUa&aH;b!~9@gG)WE|Fr?+-}^K6%z*a4aH$8SA5i~mosFD* z?27|--17{;ef7s&lH^*rslAAtI&4R*NH!}?!K zY~<`E<{8-gy*L0)Ke*Jx`d=$;T(krAuR;BHTSnLR%DI0t&l+(0!KFS7I{wp^ z>Sq6FjpBaIHK6eg2YX!V*FeXAx>DWj%b580OZ!d-rypGELFN}k%7Mmn?2q%T*(b%y z2~Iz_)WgPqdQ;u(-Pi2ja|=5DgG)Uq{eZ@QK;gsWJKe61i65MPaH(Ge9sg-fb+Z>^ z<+T6Evj&`gaH;_N<)X@&}jt&Cv0mzf)7}rLWwvNr8?(@63(HNI&-&$!gDgN{FQPD`<$6MtZz5K|pE{oqn>1RZ~7o|a$DX6cRJ_x^&9zt(+@87AoD@vw;a<_>^+$3_DzmI03LtFr5-l^3{wC1 z>YY8N(D7$n>OtuTH2w_ouceWn-4~s6;PGc%>gPhopF#fZi$7pDpQ#R8azk$&z^`3X)xp!u&5lX82}U03!-zbgi(A6)96 zKO6dF-F7=@F z1DgK=slU1NitV9y#o+XVOMSij6nmKYiXvflZbEY4^n*+ND#ZMky}x;jo$eLT{9uC} zF7@}I^IxFw?|4^i*S+(KEvWy6OFd|Q4K)7+ieG*qIlDK)Vc_(GOFd}*4mAG->I-t` zgd1?@T;BldUx4ON(feP2|NjT4AJBLLXdZSHkA}c#2#kinNC*Mgo(#}hSaSV4x+i0F zPX=hO0cc;r=$;G)2GG6&(Ebb%4GI?!2C+f=3P5ZS4GJp|2C+f=3P5ZS4cdbN!XP$i zUjc{>qCtBwKp4aZ?JEGWK{RL&1_*=LpnU}(Hi!o8!2n?p8?>(g#0JrzJs2PiVuSV- zfY=}!vR{&yzXwV)E5C*Y9`wT#A5IwplgMk6GzW@|2 zAPi!I%2p5?M1#TzMB7656@b{Fy#}B?7$6K{gZ34G*dQ9T2LpsbY|y>}5F13BK=)yQ z*r0s{AU=o&?ZE(H5F50w0K^8-pgkBM3}S=!6@b_v8ng!kgh6c3z5);%M1%HVfG~*d zI=UwVyw?D1B5|r(7pl?8$^Tl zV1O`)4cb=#VuNVV9t;o$u|fL`Kx_~VN;e=Hw6-3!#{k3z(V+bpAPi!I_7#BGAR4p> z1B5|r(7pl?8$^TlV1O`)4cb=#VuNVV9t;o$u|fL^Kx_~V+JgbYAU0@U0f-HvL3=Pj z7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtc zD*&-UG$>p^7{msJ1&9rzLE!*r0s{AU22w?ZE(H z5F50w0K^8-pgkBM3}S=!7=YLy8ng!kgh6c3z5);%M1%HVfG~&++E)N#gJ{qm3=jsf zLHi0oY!D6Fg8{-IHfUb~hz+7a;R3=SHYhAWY!D3!4-gGnTMyb}0Ahn^P`H3Fhz;6T z0Ahn^P`H3Fhz;6f0Ahn^P`H3Fhz;6T0Ahn^P`H3Fhz;6T0Ahn^P`H3Fhz;6T0Ahn^ zP`H3Fhz;6T0Ahn^P`H3Fhz;6T0Ahn^P`H3Fhz;6T0Ahn^P`H3Fhz;6T0Ahn^P`H3F zhz;6T0Ahn^P`H3Fhz$x05F12;!UIHu*4Bge7=YLy8Wb)d3}S=!6@b_v8Wb)d3}S=! z6@b_v8Wb)d3}S=!6@b_v8Wb)d3}SbU?#Te3s{q<-0177%4GI?!2C+f=5kPDZ4GJp| z2C+eV7C>we4cdbN!XP$iUjv8@qCtBwKp4aZ?R@~TK{RL&1_*=Lp#2dbHi!o8!2n?p z8?=W4#0JrzJs2PiVuSWKfY=}!va)BLwZ!2Z@39WH31Wwq+<-XaibR0xI+z&F}StM*9Xq*`|CXLJeAoCqA#DVurIPbc$ zw-w8t3}o{`?oT)m*^{At`JD~OO`tJXT;_wqCn4@_}Ly5KA=4!P9kA;cd_ir zKvB!e#NJy?B96p&YnM#n0qo{>hCOlb^sJU z44Lr`pf&zgOm+K0upIkztw%bpBm^#vUk2O3sCu!rtB z*f#;oo(yF56THI?fWn7sTFUcZ-Zk`2D17Ex8B-=%m?j>VbwinmxN_c z2D17OHXaTj_k-MHD)r3n+zre<8OZ7l7}6X-;q!TF%Ko?U2ka7=F!y92s|T463V%?1 z%`x(`yMbj-2C{mP`$6$LBh_vHp4I#JoWZgu1EyYF?F2ae6xc0r0Il(V&a-A8AC^5C z$m%B?5B+0}Kxo96);l?yOPV|9LfN&e;KF4+OIM z3+rct(+|i!Vyv9|Ph;7Wfvg^Eew5q+kogk6)AyBP*^_~+9^`(FnVsN07Q$=x+dP2I z$s_MkKvoY*KMl}58Ebjg*r{XLlYy+>pj_PnWd4FwxBUrB{Pw?nF!y92tKXsC=fDsp zcVK6#+x{hM6z%)5?8!h@uhF#_oPO4U_HeLp+F!@ACj(hM$ovEM6~OUphk=y^R~>(gjokj67YFwJpNqLC16e)D{XaIZIk3}4Zhz_h88#E4Yl85G zPs{NGyKLn4Zz;KGCyZrJ2D14E3;_-x^N-lb?f*R2z&;nto(yF5E1WhufZV^_MsELn zJx_bNJD@dF4R*NP;~{(ooPM6!$nC##P22t{mOUBh=7YljxsBX@jTZ;(p3TMFlYy)r z>#(~S90Qct($&PpSnM2m}LD!Ta_HZDpFE|}{ zU_-(QhgQcs`&dtS?(f60Cj(hM$ECvu9=u3*0PP6??a5ep3Uf~evicP}9)Z&jXphD1 z61V-*SoUNfs|T5XAu07hjpLnty8<8X`+Xd9PX@Ajko$MY9zW3KcxT_%Qz15>b&{a= z55Dk8V0m_6y5pUF-><&0yN_j02D14A4S5bA^Q$3yR_y0u*^_~+K4Z;khX+Zi2c#VD z?0Y4gZa?WHXw7DW9WM9$nDh#qewZEa>|-x=v;T=@PX@aA4KLCimO9?qH$CtnXq_i` zO%N{g0~+!iK=Hfved0b@w_CdtplhO$*Wkm=edcbrtYK@S zak&Q+J`taP960elabNM`KXzSM_GBQNKVy4?LqPNO16A)6_X&wb+J|A;lYy-Mh2R~B z2Z0p_v_B;7i&|f4|1JQuX1u`;mwSFR{spI>o9`3%O-u~8kHoSk1KIo^f_EH1;lJ#C z;=Y*O-|RqZ-a%^;ahVTx|FIhmF%K7Pv2VY*3ADBY)Heg=G4%c#Xio+xe0BsdIPz(D znBv-#0do&X{RGvD0|BA;93)q$Y`M8PcK>%QdoqyKFF1DdK*7QWhmJyD@cxJWn?7!0 zU~m8p)x*~)A*(+j^aq@N*46NsT-qGFpAE~N3}p2n^FQpVJCG4(w?&YFVgDH{doqyK zgWWH5_khRTc_!O8eKZ2~Ye8WH!nnexBJTfzloNlA-u?e?cN@!|3}o{)-Znb~2;Dtk zmKtGtb#tse6P7(0$m(A#c<8{ex9-660BaLaTpf!(XoS8e16lo)Z;Xzh_VXW4&#kvM z$J&4T{~x@j443Z|TNwg;u31hZcbRqqq+av}K_Tz}zG56-{GZa5^qPqgbx4BuaeWlsjO`LOb*<9(tX zD6hA=f%2CF%AO2l^|111()&a^A+gB)fmrrrAgc$N4=R7!-Y43vg6wGnuW7~W{^sik zTHYtxHMwEmlYwkLD11QWPxt#oJGI^4?BuZQ$v{>Q&cDsq4}?PYtk`E_*^_~+9#;P7 zen_;7TwiIg6$mPyQTJpZtA~|8r`{*pNsC3=D`VM{fubH-{+xsCS+Q%zvL^#sJ=p!n zZa5S>-mz0T8Daz4=Ljl)kk{bD)Pwe9fWimV{@LJo$8L7u!+qbd?8!h@4{ASv>cDUWf@MzzviTdJ?H|yd38oXC`&VMwlYy)r zWIm|LSBOp zQxDpc0SX^b{|mHdqW;B!eShX+?#Vz_59+^w+UFqkp#2Ybu3Qx?xew}Jpzg^)RuAicfy`%{XRtp8%bpBm^&s;>{TI-l5~k9N`#^ivL3?^|`4{B= zADh=40PXpxzdvKobZGwzmwIscv>ZQh%tp>$`^5n}W-NO$klh37zktktWFu#P`I@#p zKbAci$m(JJFOd5|{V(}Dn0qpi)x-KJZtueVA+#_tRCck(D)2Uz0jKdd+x7+oXLSNd_dzr zwW)6Q^1jpUIBJ#{sT%6=XloG@nYGNfvg_neo*`hO-r#q zd+m-5AC^5CF!i848KCs@AOk%9Y`@pYZ{J!S%sm;%>OteTpz%qN`N{DI_IY60lYy)r zG(HR({{-y`kd=D2FC5FB3}p4N@n^niDfXbTWLqqIGLY4S%mTj4+eVsT`-nC8OZ8E%!&0F@pxD1-#LEV#q ztbPG>{tL8+qxW6$zCSxL_hcZe2bm9=KLV*&6q4Hqnx6vIU%31Wa=*j*L!kLA`^?Ml z_PAr&lYwkLDE%aaJ=_lpPyU@(Y)i51$v{>Qnm+=W584AEEfQvTTo7|l2C{nC{1+%Z z^UPc9o?+ROfubHd{{`A3((;b1t2zv2JKY=VGtX%#{k3z(V)F5APi!I z?s@>RK{RNu3J8PPpt~MGY!D6Fs{+CxHt4Pg5F12;_Nss|hz;6*0b+w_&>jpB2C+f= zE}5F12;!UcpuY*1K$*dQ7d9v~XDwjQ*v0K^8-pl|_U5F50w0K^8-pl|_U z5F50w0K^8-pl|_U5F50w0K^8-pl|_U5F50w0K^8-pl|_U5F50w0K^8-pl|_U5F50w z0K^8-pl|_U5F50w0K^8-pl|_U5F50w0K^8-pl|_U5F50w0K^8-pl|_U5F50w0K^8- zpl|_U5E~R0AU22wg$IZRt*r;`D*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^ z7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtc zD*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{mtcD*&-UG$>p^7{msJ1&9rz zLE!(h#0JrzZ~hDka30B{+k;4I`{)wR6K2?Q^ z-}bQZ(Gdx=yMtv<2C{mP`A4APzjx;q+g>btGLY4?TXx$2xc$kVZCc9y30Lpzv4_ry zA@4bWsR!MY0ZMOfFH0Oi>K&Qt_RYq!Cj(i%{q1A>mDR!>Sf{1zXV5*j&l}603}p3n zdrc0wTw?{BZzuI^pD&g@8OZ7vGz1+0g%8L*^WzWfv&OO~16e)D{HpmI_Jh>h8~N=6 zxd}9v`81y}FbxIpK`aH$8SpIu4r2iT{j?AK$evje#abj~I&^?M4w z+RvG<30D78=bW7vmOUBB?ziReacG{uVL!-x8>we@JFjBy$v{@0d^*$Nx8ycEkopDj z2kf-4?8!h@@5tff-~bJOCnG<*KUnr;AgjMx@YP;kE!+WgZ$#tj{d?{~=j4(19Kh6r z?#Te9pQZm+f$y<6%(G^nJeEBf$m*AT7d{X?XR1R>s@wh+CjR}{_GBQd|CQcyz%#+j zp%t`;V2$E_&^$N;1L~d(WcA^vW`ffX=-vnw$ecg;oI70Z2bq8HCI@(r#b2N4`x>z9 z$v`%L#dqNY;+ty0>L0Jhz9$1&Jt+OeTTeLva{n$IdoqyKCpl?5NJGsBony#?<(>>= z^>Mrt9F9TV|6q-xeI%AW8OZ9lzaBxg81E+_- zKHzg6!D~8jg=evowuAqisScof8kXGyuXzEVGmgB*A7(yiPX;Lc>}|j7uo<+*A9Btq zcugWM^}8Bu4k&Nm0anj7&tShlmOUBB=AUX>ejxs39N0aeH9-zo_GBQdPYXT-PCuY~ zAcU@K@4ty`RxEBOjJ;?pHKQBD6!A5Ss|NR*@ zuya~*`4^Oa%8%>;n}4O`qMay~JsHU6mz)lE0GSWEcZ7SMfqgobJsHUA^)xm++)gqC ztx?)PL(kJb3(Gwj$m&o1I15fc8*SwFi(J>XKZ9jY2C{k+jm-{0FXJ3Q;TiMdfE^c> zdoqyKcb*P*kl((;0ko%~;Y7$D(AmSFHHpY;@L}pf_hf+5PZRqmhYrU(`-HE(*>@Yu zJsHUA8yTVxJXE+0z9$3Mo(yF59d8aEP|K`!nBsV6A87sGQY?Eikky-9egIBC6CCgC zyIJD4Ul7Zl3}p2n^XEVEKQPhp&c0q8_hcZeZ)J!+FgxtVc(O1tlrwY$N^-2i6i(P5&I=r_GBQde>(B3!}3S|2Pz%!?7JeIZXa?Sb591c z`pFe<9Ck=Q#d-9T3v#aHxUY1F_%64YcMLbx#Jedc8xR!Re>}ed4~3#PI!X zSoUNft5*)XbYSMiqyv-QC+>6I{cWEpmOUBB>Ot-|Ieg~8#`lT)_PX7&PQ-Fg2C{lk z`mr{CcVNN$#C?s6|JZ@t1Zw}_3Qw`QO%5RQ>)t2s6BdiK2d(J_wV!dRZ}@)KVd2H3 z17(o#vG2DBtr?)3lQ^po*Eao>c*aC^``5zslCxXkbUe%FCjr^6u=a*v3e z7?yi7kj>Ye+vHHz_SoV1po&%VA&>jm=`Z>3O)p1w!!3}@@ z|KE2V%RL#$>gPq39Hr?Qr9;m9M7#T*;CpDmzvCS{(4JAAYnbNc+bQ)c!F)1*+ds@5w+`4{QJQINq@X-T5^M%bpBm^|1C&i{l+TfopH} z-Nmve16e)D{h;x#v2L zJsHUA-$2_xHI8@eKyg)w<(>>=^|1C&o#P!l&^;L~SoUNftB19JK=+PFUV8(IGjRIB zx#w=l#eJZC z^q~G1KKFzAM{8~5>=W!+LK|$RJU&umOUBB>Ot0EPFDL)q}>jZLYC8fbP|>V5+kN-Q597Ke+sRw&1J1 zv|6|WXiq@d<##s0(D^UqJqj@MLHA^U>aT{49ANdccV5|Bi)Bv+vih%Xru*OD{$vj_ zUqmEq-xVzPWFV_w%C&AkX#NGHKG?ivpVei|JsHUAw?pT@f=$Zp>)#dcTZUy%2C{mP z`BCRN_Jh>l7L?m3hUK0NWc48T-#9lNtls|eyFDS$`7d1Ib1~G)?p5fv{UGz_?7U(N zI`a%v{@_yo-J;VTX1=gUnB4;`doqySqqN|TJ!t+8WPXTwi(MXgeh~GZ3}p2t(D^Tr z`nGq)cKulH$v{@Gz2J`h?vnZ7__`-3X9v1l9+ZA?xgRwD_5AiHd(fT?@47vpC2=6* zzGj$7#J8pav&_oz`y_!6N2go$$_vi0|Ns{3{)pTodBmm z?t^m}8tmh_YaBh;3J&tsJu*jC-vC^OvkPs$^A&?gVZx%gb&Dk zkb01NASxIbAZwwphbKrq$o(MqfYg_Wr|y4K|70J;znJa;g(tH5{-URLr*EY|-GyB} z$UQLgL3Tjg17hKJKTJKcT96KW;SZAUFM7J~^sN+d`vb&BR}XVPEPPPS$8_<+nr zq$BL=LH>oAUm~7r|EB&4XlXl0D@J^Q+=HwhqzGa@D88_p4+?*n`4F`rUAWbQ%ts1O zaK3`XFYfS%nGZ5~uwqb|>Ykb(T#%7klnUBpK!!t4FfcHH)-8jyg38n*oD2+4WEdDk z6c`w4K$oO2K*9)Co`T9!SegQruOK$4Yz47FW+0cZATbahqz6>4g4iH2ka`dw#0HhG zAT~%0R1Sm6U{LuCQVZgP*r2i(#0H6h)PndRHmD2+u|Z-Wb3l9$8&qC{*dQ@b`3x$P zLFR(Y0P#U=SlJB{1DOHhgV>;Q8^i{Qfy@B$L2Ou=4iW>I58{K^p!x{J28oG+0)T;m z0TfnZ&^iYs1QG}FL2Pjb1_lrtBqjl^V?cffiGlbaHs}r*5E~>0QV-&T*q}RcKx~j0 zXm1+GPLLl#YC(Ju8?;{y#0H6h)PndRHs~H45E~>0G6%#5u|ZJ`VuQp$ci({g12Pw6 z28a)0gYLcou|Z-WGeCS08+7*#hz$}0nE~R1*r2;_Kx~j0$b1kV#0K4c17d^3K=<8% z!T=Ojp#4K2KY{olaS$KG2JNQ;u|Z;>Jyak!g4BV;KztAzw1*1B28n^xgZLmeXb%;L z4H5(Gn*!Mh(hpJ#;)B?reN!MdNDQPF#0RlK`=&r_kQm4u5Ff+_?VAFzL1Li2QXv0; z%mtYN;)B?ry;2}HNDO2Kh!0|eI))%NNDO2Kh!0|evMq=W5(AkJ;)B?ry;2}HNDP$6 zKw$t1D^U9hh)l z3o--52eCo>sX%Oy7|09|AH)XjrvkA-Vjwd>d=MM7p9;hViGj=q@j+}*{syr@VxYZ5 zpvneR$beNdo1Pat(5F%Tcb2JLqOu|Z-W^&mco z4GIeo8zctW`vltO1kw*u3*v*=pgm3?Hb@Ml7Q_d!L3?^YY>*hp91tJG289KP4H5&D zC7?VAG8be9h!0|e${r9KBnC1A#0RlKWfh1G5(Ak5;)B?rvJJ!riGj=q@j+}*Jb>6B zF;G~5_E&+z3bdaJw08=`2Z@9DAT}s0Kx~j0Xb%-=zZ6IvNDRaWv7;Fn7(i^07)U*c z4`PGD0>lQ1f%Z*-_DF&BgVcifAU0@!6o?HH1E~e^L2S_eC=eSY1~Lc42eCn60b+y1 zKxGLi4}#1EnE~R1*r2ip#0H6h%mDF0Y*1MRVuQp$W`Ou0HmGa^u|Z-W^Fe$N8x#*9 zHb@K<7NEQZ3MDsK8Otp3lJM52HKwlO8X#nATbah#0Krx00+Peix%OL$AwIDu-4Qk7P*dQ^GS`Z(^2JPJfu|Z-Wb3l9$8x$5GHb@Lq zmVojJ$Xt*aAU=oV3cGthQrdNU-nN zAZ3TH-hAuh0~(de2OexSby(&cyuWFR!2TGQqZ>f(IdjGbL;W7<^9QnPr-I$H(m8m) zkBh5e%@hG}9|f0skb92Lp69Uohu(h1<4XI5CvCS|<`-gLWY~yde&L4A2QqZ#ADA@L z&SCilvHeVU{PtgeVYw0Ho>?ZE=9cKUALx6M4-zBZ`Otuf6klvtw;6_=owP5(q14{kxEQB;Q2qk>7vz2rhV(;0eNYCh{so0kgdmHf!lAPL z-@thtJT75}EB{{9Q*Z#~$CS*({p@pB+x?%j+V21V|F*dDKwek1)R4a z=Htp=hfAh|&0q6FZ@?RKE_Z&

7FYi2@-}b)rGHR<{C`ZzUUJfQyY!=acDU3Z zP+sT&%8%gua>vj9>I+Ll(AmYf@=J#J1+aT=PTIF`ukUudt>)48dN(R?FH*hf@19XM8|a9oF;!ieFIr={unSN}u+i z^m*pY8Jy}t@dZksT_+Y8T6+iB-vy_CNl>#4tNEbt1f~D~SGF0ZIF#C3L-Hd|^&s~n z?M>DFpzy($o?9a49Jn=U-@e_D z{IdVokq0=<2j!P#-Ioq5lJ4L4IM#0CS4bUWe+EbW0&@R>(ANhPubOQHm4%=(5#(1~ ztoa4xU;n$`4i#$2^rK*pEB%1l1EBPCV$wcPTVVfj-|hQq zlMHa04{D!)(kI(hvyJ{|C+$mgDBXYd3=hum1l5nA@V}<>(eM$Z{@p)orX)`Fp!ydS zzf(^r7+H7+><8&dOH;$C9#p@B(vQN`ZH93UrTgQ~PTFT|Y>ZPqsJ#J7pNfad>_P2k zP?`X>H`3G6Fw#Ro#b*bQ`$6R!Nd3}BS2n=f=eX2^(hsQogtP+~7$EI!25_4Rz5NVY z2LMtJGCwsl(H_*^{snDs-wTe!aF6-c#}2Ue_DbhqdyCJL;qB*hXM8Z!?~y+505Ts` z{x5S5wr_-#oeUuVg4$&0?g6O>g+ItWYk%n3Be#b=((N(KFWj)%0jWJ~KQFI)Bdk3P ziUV}>#Ve*8I@32es#gpzV2F=7Z8dsQs|wf|xzy9l!n8!0iVIdtBy&(gVo- z*Cy?=LvG)C&Q!o~e_Oh{15*3e?s4os16cbOlt$6rUuiA}c0Z`THr70Ahuq$dmsG|u zU-@{b11Nui+8bvl?Xv^5|Cd4A|G3-(%3q-N#!TscJLL91F86@aGswT7^!YWo!w%FR zWMpWt!<9Zk8FX2jWu=eB<=U{tKdomu}ziR-u>CwXnlzu?vGsyf^ zKlJPwjw{(qP1<7gV2~pR~_zGg5mGmwQ0z4OE{dWG32!+8a{f_)@UP z6= 402 +------------------- +Headers are from OpenAL CVS 6th August 2005: +$ cvs -d:pserver:guest@opensource.creative.com:/usr/local/cvs-repository +login +(use password "guest") +$ cvs -d:pserver:guest@opensource.creative.com:/usr/local/cvs-repository +co -D "6 Aug 2005" openal + +SVN revision >= 374 +------------------- +Standard OpenAL 1.0 headers diff --git a/code/AL/al.h b/code/AL/al.h new file mode 100644 index 00000000..fd9a5375 --- /dev/null +++ b/code/AL/al.h @@ -0,0 +1,506 @@ +#ifndef __al_h_ +#define __al_h_ + +/** + * OpenAL cross platform audio library + * Copyright (C) 1999-2000 by authors. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * Or go to http://www.gnu.org/copyleft/lgpl.html + */ +#include "altypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* WIN32, not Xbox */ +#ifdef _WIN32 +#ifndef _XBOX +#ifdef _OPENAL32LIB +#define ALAPI __declspec(dllexport) +#else +#define ALAPI __declspec(dllimport) +#endif +#define ALAPIENTRY __cdecl +#define AL_CALLBACK +#endif +#endif + +#ifdef TARGET_OS_MAC +#if TARGET_OS_MAC +#pragma export on +#endif +#endif + +#ifndef ALAPI +#define ALAPI +#endif + +#ifndef ALAPIENTRY +#define ALAPIENTRY +#endif + +#ifndef CALLBACK +#define AL_CALLBACK +#endif + +#define OPENAL + +#ifndef AL_NO_PROTOTYPES + +/* + * Renderer State management + */ +ALAPI void ALAPIENTRY alEnable( ALenum capability ); + +ALAPI void ALAPIENTRY alDisable( ALenum capability ); + +ALAPI ALboolean ALAPIENTRY alIsEnabled( ALenum capability ); + + +/* + * State retrieval + */ +ALAPI const ALchar* ALAPIENTRY alGetString( ALenum param ); + +ALAPI void ALAPIENTRY alGetBooleanv( ALenum param, ALboolean* data ); + +ALAPI void ALAPIENTRY alGetIntegerv( ALenum param, ALint* data ); + +ALAPI void ALAPIENTRY alGetFloatv( ALenum param, ALfloat* data ); + +ALAPI void ALAPIENTRY alGetDoublev( ALenum param, ALdouble* data ); + +ALAPI ALboolean ALAPIENTRY alGetBoolean( ALenum param ); + +ALAPI ALint ALAPIENTRY alGetInteger( ALenum param ); + +ALAPI ALfloat ALAPIENTRY alGetFloat( ALenum param ); + +ALAPI ALdouble ALAPIENTRY alGetDouble( ALenum param ); + + +/* + * Error support. + * Obtain the most recent error generated in the AL state machine. + */ +ALAPI ALenum ALAPIENTRY alGetError( ALvoid ); + + +/* + * Extension support. + * Query for the presence of an extension, and obtain any appropriate + * function pointers and enum values. + */ +ALAPI ALboolean ALAPIENTRY alIsExtensionPresent( const ALchar* extname ); + +ALAPI void* ALAPIENTRY alGetProcAddress( const ALchar* fname ); + +ALAPI ALenum ALAPIENTRY alGetEnumValue( const ALchar* ename ); + + +/* + * LISTENER + * Listener represents the location and orientation of the + * 'user' in 3D-space. + * + * Properties include: - + * + * Gain AL_GAIN ALfloat + * Position AL_POSITION ALfloat[3] + * Velocity AL_VELOCITY ALfloat[3] + * Orientation AL_ORIENTATION ALfloat[6] (Forward then Up vectors) +*/ + +/* + * Set Listener parameters + */ +ALAPI void ALAPIENTRY alListenerf( ALenum param, ALfloat value ); + +ALAPI void ALAPIENTRY alListener3f( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); + +ALAPI void ALAPIENTRY alListenerfv( ALenum param, const ALfloat* values ); + +ALAPI void ALAPIENTRY alListeneri( ALenum param, ALint value ); + +ALAPI void ALAPIENTRY alListener3i( ALenum param, ALint value1, ALint value2, ALint value3 ); + +ALAPI void ALAPIENTRY alListeneriv( ALenum param, const ALint* values ); + +/* + * Get Listener parameters + */ +ALAPI void ALAPIENTRY alGetListenerf( ALenum param, ALfloat* value ); + +ALAPI void ALAPIENTRY alGetListener3f( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); + +ALAPI void ALAPIENTRY alGetListenerfv( ALenum param, ALfloat* values ); + +ALAPI void ALAPIENTRY alGetListeneri( ALenum param, ALint* value ); + +ALAPI void ALAPIENTRY alGetListener3i( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); + +ALAPI void ALAPIENTRY alGetListeneriv( ALenum param, ALint* values ); + + +/** + * SOURCE + * Sources represent individual sound objects in 3D-space. + * Sources take the PCM data provided in the specified Buffer, + * apply Source-specific modifications, and then + * submit them to be mixed according to spatial arrangement etc. + * + * Properties include: - + * + * Gain AL_GAIN ALfloat + * Min Gain AL_MIN_GAIN ALfloat + * Max Gain AL_MAX_GAIN ALfloat + * Position AL_POSITION ALfloat[3] + * Velocity AL_VELOCITY ALfloat[3] + * Direction AL_DIRECTION ALfloat[3] + * Head Relative Mode AL_SOURCE_RELATIVE ALint (AL_TRUE or AL_FALSE) + * Reference Distance AL_REFERENCE_DISTANCE ALfloat + * Max Distance AL_MAX_DISTANCE ALfloat + * RollOff Factor AL_ROLLOFF_FACTOR ALfloat + * Inner Angle AL_CONE_INNER_ANGLE ALint or ALfloat + * Outer Angle AL_CONE_OUTER_ANGLE ALint or ALfloat + * Cone Outer Gain AL_CONE_OUTER_GAIN ALint or ALfloat + * Pitch AL_PITCH ALfloat + * Looping AL_LOOPING ALint (AL_TRUE or AL_FALSE) + * MS Offset AL_MSEC_OFFSET ALint or ALfloat + * Byte Offset AL_BYTE_OFFSET ALint or ALfloat + * Sample Offset AL_SAMPLE_OFFSET ALint or ALfloat + * Attached Buffer AL_BUFFER ALint + * State (Query only) AL_SOURCE_STATE ALint + * Buffers Queued (Query only) AL_BUFFERS_QUEUED ALint + * Buffers Processed (Query only) AL_BUFFERS_PROCESSED ALint + */ + +/* Create Source objects */ +ALAPI void ALAPIENTRY alGenSources( ALsizei n, ALuint* sources ); + +/* Delete Source objects */ +ALAPI void ALAPIENTRY alDeleteSources( ALsizei n, const ALuint* sources ); + +/* Verify a handle is a valid Source */ +ALAPI ALboolean ALAPIENTRY alIsSource( ALuint sid ); + +/* + * Set Source parameters + */ +ALAPI void ALAPIENTRY alSourcef( ALuint sid, ALenum param, ALfloat value ); + +ALAPI void ALAPIENTRY alSource3f( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); + +ALAPI void ALAPIENTRY alSourcefv( ALuint sid, ALenum param, const ALfloat* values ); + +ALAPI void ALAPIENTRY alSourcei( ALuint sid, ALenum param, ALint value ); + +ALAPI void ALAPIENTRY alSource3i( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); + +ALAPI void ALAPIENTRY alSourceiv( ALuint sid, ALenum param, const ALint* values ); + +/* + * Get Source parameters + */ +ALAPI void ALAPIENTRY alGetSourcef( ALuint sid, ALenum param, ALfloat* value ); + +ALAPI void ALAPIENTRY alGetSource3f( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); + +ALAPI void ALAPIENTRY alGetSourcefv( ALuint sid, ALenum param, ALfloat* values ); + +ALAPI void ALAPIENTRY alGetSourcei( ALuint sid, ALenum param, ALint* value ); + +ALAPI void ALAPIENTRY alGetSource3i( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); + +ALAPI void ALAPIENTRY alGetSourceiv( ALuint sid, ALenum param, ALint* values ); + + +/* + * Source vector based playback calls + */ + +/* Play, replay, or resume (if paused) a list of Sources */ +ALAPI void ALAPIENTRY alSourcePlayv( ALsizei ns, const ALuint *sids ); + +/* Stop a list of Sources */ +ALAPI void ALAPIENTRY alSourceStopv( ALsizei ns, const ALuint *sids ); + +/* Rewind a list of Sources */ +ALAPI void ALAPIENTRY alSourceRewindv( ALsizei ns, const ALuint *sids ); + +/* Pause a list of Sources */ +ALAPI void ALAPIENTRY alSourcePausev( ALsizei ns, const ALuint *sids ); + +/* + * Source based playback calls + */ + +/* Play, replay, or resume a Source */ +ALAPI void ALAPIENTRY alSourcePlay( ALuint sid ); + +/* Stop a Source */ +ALAPI void ALAPIENTRY alSourceStop( ALuint sid ); + +/* Rewind a Source (set playback postiton to beginning) */ +ALAPI void ALAPIENTRY alSourceRewind( ALuint sid ); + +/* Pause a Source */ +ALAPI void ALAPIENTRY alSourcePause( ALuint sid ); + +/* + * Source Queuing + */ +ALAPI void ALAPIENTRY alSourceQueueBuffers( ALuint sid, ALsizei numEntries, const ALuint *bids ); + +ALAPI void ALAPIENTRY alSourceUnqueueBuffers( ALuint sid, ALsizei numEntries, ALuint *bids ); + + +/** + * BUFFER + * Buffer objects are storage space for sample data. + * Buffers are referred to by Sources. One Buffer can be used + * by multiple Sources. + * + * Properties include: - + * + * Frequency (Query only) AL_FREQUENCY ALint + * Size (Query only) AL_SIZE ALint + * Bits (Query only) AL_BITS ALint + * Channels (Query only) AL_CHANNELS ALint + */ + +/* Create Buffer objects */ +ALAPI void ALAPIENTRY alGenBuffers( ALsizei n, ALuint* buffers ); + +/* Delete Buffer objects */ +ALAPI void ALAPIENTRY alDeleteBuffers( ALsizei n, const ALuint* buffers ); + +/* Verify a handle is a valid Buffer */ +ALAPI ALboolean ALAPIENTRY alIsBuffer( ALuint bid ); + +/* Specify the data to be copied into a buffer */ +ALAPI void ALAPIENTRY alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); + +/* + * Set Buffer parameters + */ +ALAPI void ALAPIENTRY alBufferf( ALuint bid, ALenum param, ALfloat value ); + +ALAPI void ALAPIENTRY alBuffer3f( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); + +ALAPI void ALAPIENTRY alBufferfv( ALuint bid, ALenum param, const ALfloat* values ); + +ALAPI void ALAPIENTRY alBufferi( ALuint bid, ALenum param, ALint value ); + +ALAPI void ALAPIENTRY alBuffer3i( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); + +ALAPI void ALAPIENTRY alBufferiv( ALuint bid, ALenum param, const ALint* values ); + +/* + * Get Buffer parameters + */ +ALAPI void ALAPIENTRY alGetBufferf( ALuint bid, ALenum param, ALfloat* value ); + +ALAPI void ALAPIENTRY alGetBuffer3f( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); + +ALAPI void ALAPIENTRY alGetBufferfv( ALuint bid, ALenum param, ALfloat* values ); + +ALAPI void ALAPIENTRY alGetBufferi( ALuint bid, ALenum param, ALint* value ); + +ALAPI void ALAPIENTRY alGetBuffer3i( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); + +ALAPI void ALAPIENTRY alGetBufferiv( ALuint bid, ALenum param, ALint* values ); + + +/* + * Global Parameters + */ +ALAPI void ALAPIENTRY alDopplerFactor( ALfloat value ); + +ALAPI void ALAPIENTRY alDopplerVelocity( ALfloat value ); + +ALAPI void ALAPIENTRY alSpeedOfSound( ALfloat value ); + +ALAPI void ALAPIENTRY alDistanceModel( ALenum distanceModel ); + +#else /* AL_NO_PROTOTYPES */ + +/* +void (ALAPIENTRY *alEnable)( ALenum capability ); +void (ALAPIENTRY *alDisable)( ALenum capability ); +ALboolean (ALAPIENTRY *alIsEnabled)( ALenum capability ); +const ALchar* (ALAPIENTRY *alGetString)( ALenum param ); +void (ALAPIENTRY *alGetBooleanv)( ALenum param, ALboolean* data ); +void (ALAPIENTRY *alGetIntegerv)( ALenum param, ALint* data ); +void (ALAPIENTRY *alGetFloatv)( ALenum param, ALfloat* data ); +void (ALAPIENTRY *alGetDoublev)( ALenum param, ALdouble* data ); +ALboolean (ALAPIENTRY *alGetBoolean)( ALenum param ); +ALint (ALAPIENTRY *alGetInteger)( ALenum param ); +ALfloat (ALAPIENTRY *alGetFloat)( ALenum param ); +ALdouble (ALAPIENTRY *alGetDouble)( ALenum param ); +ALenum (ALAPIENTRY *alGetError)( ALvoid ); +ALboolean (ALAPIENTRY *alIsExtensionPresent)(const ALchar* extname ); +void* (ALAPIENTRY *alGetProcAddress)( const ALchar* fname ); +ALenum (ALAPIENTRY *alGetEnumValue)( const ALchar* ename ); +void (ALAPIENTRY *alListenerf)( ALenum param, ALfloat value ); +void (ALAPIENTRY *alListener3f)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +void (ALAPIENTRY *alListenerfv)( ALenum param, const ALfloat* values ); +void (ALAPIENTRY *alListeneri)( ALenum param, ALint value ); +void (ALAPIENTRY *alListener3i)( ALenum param, ALint value1, ALint value2, ALint value3 ); +void (ALAPIENTRY *alListeneriv)( ALenum param, const ALint* values ); +void (ALAPIENTRY *alGetListenerf)( ALenum param, ALfloat* value ); +void (ALAPIENTRY *alGetListener3f)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); +void (ALAPIENTRY *alGetListenerfv)( ALenum param, ALfloat* values ); +void (ALAPIENTRY *alGetListeneri)( ALenum param, ALint* value ); +void (ALAPIENTRY *alGetListener3i)( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); +void (ALAPIENTRY *alGetListeneriv)( ALenum param, ALint* values ); +void (ALAPIENTRY *alGenSources)( ALsizei n, ALuint* sources ); +void (ALAPIENTRY *alDeleteSources)( ALsizei n, const ALuint* sources ); +ALboolean (ALAPIENTRY *alIsSource)( ALuint sid ); +void (ALAPIENTRY *alSourcef)( ALuint sid, ALenum param, ALfloat value); +void (ALAPIENTRY *alSource3f)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +void (ALAPIENTRY *alSourcefv)( ALuint sid, ALenum param, const ALfloat* values ); +void (ALAPIENTRY *alSourcei)( ALuint sid, ALenum param, ALint value); +void (ALAPIENTRY *alSource3i)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); +void (ALAPIENTRY *alSourceiv)( ALuint sid, ALenum param, const ALint* values ); +void (ALAPIENTRY *alGetSourcef)( ALuint sid, ALenum param, ALfloat* value ); +void (ALAPIENTRY *alGetSource3f)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); +void (ALAPIENTRY *alGetSourcefv)( ALuint sid, ALenum param, ALfloat* values ); +void (ALAPIENTRY *alGetSourcei)( ALuint sid, ALenum param, ALint* value ); +void (ALAPIENTRY *alGetSource3i)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); +void (ALAPIENTRY *alGetSourceiv)( ALuint sid, ALenum param, ALint* values ); +void (ALAPIENTRY *alSourcePlayv)( ALsizei ns, const ALuint *sids ); +void (ALAPIENTRY *alSourceStopv)( ALsizei ns, const ALuint *sids ); +void (ALAPIENTRY *alSourceRewindv)( ALsizei ns, const ALuint *sids ); +void (ALAPIENTRY *alSourcePausev)( ALsizei ns, const ALuint *sids ); +void (ALAPIENTRY *alSourcePlay)( ALuint sid ); +void (ALAPIENTRY *alSourceStop)( ALuint sid ); +void (ALAPIENTRY *alSourceRewind)( ALuint sid ); +void (ALAPIENTRY *alSourcePause)( ALuint sid ); +void (ALAPIENTRY *alSourceQueueBuffers)( ALuint sid, ALsizei numEntries, const ALuint *bids ); +void (ALAPIENTRY *alSourceUnqueueBuffers)( ALuint sid, ALsizei numEntries, ALuint *bids ); +void (ALAPIENTRY *alGenBuffers)( ALsizei n, ALuint* buffers ); +void (ALAPIENTRY *alDeleteBuffers)( ALsizei n, const ALuint* buffers ); +ALboolean (ALAPIENTRY *alIsBuffer)( ALuint bid ); +void (ALAPIENTRY *alBufferData)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); +void (ALAPIENTRY *alBufferf)( ALuint bid, ALenum param, ALfloat value); +void (ALAPIENTRY *alBuffer3f)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +void (ALAPIENTRY *alBufferfv)( ALuint bid, ALenum param, const ALfloat* values ); +void (ALAPIENTRY *alBufferi)( ALuint bid, ALenum param, ALint value); +void (ALAPIENTRY *alBuffer3i)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); +void (ALAPIENTRY *alBufferiv)( ALuint bid, ALenum param, const ALint* values ); +void (ALAPIENTRY *alGetBufferf)( ALuint bid, ALenum param, ALfloat* value ); +void (ALAPIENTRY *alGetBuffer3f)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); +void (ALAPIENTRY *alGetBufferfv)( ALuint bid, ALenum param, ALfloat* values ); +void (ALAPIENTRY *alGetBufferi)( ALuint bid, ALenum param, ALint* value ); +void (ALAPIENTRY *alGetBuffer3i)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); +void (ALAPIENTRY *alGetBufferiv)( ALuint bid, ALenum param, ALint* values ); +void (ALAPIENTRY *alDopplerFactor)( ALfloat value ); +void (ALAPIENTRY *alDopplerVelocity)( ALfloat value ); +void (ALAPIENTRY *alSpeedOfSound)( ALfloat value ); +void (ALAPIENTRY *alDistanceModel)( ALenum distanceModel ); +*/ +/* Type Definitions */ + +typedef void (ALAPIENTRY *LPALENABLE)( ALenum capability ); +typedef void (ALAPIENTRY *LPALDISABLE)( ALenum capability ); +typedef ALboolean (ALAPIENTRY *LPALISENABLED)( ALenum capability ); +typedef const ALchar* (ALAPIENTRY *LPALGETSTRING)( ALenum param ); +typedef void (ALAPIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data ); +typedef void (ALAPIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data ); +typedef void (ALAPIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data ); +typedef void (ALAPIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data ); +typedef ALboolean (ALAPIENTRY *LPALGETBOOLEAN)( ALenum param ); +typedef ALint (ALAPIENTRY *LPALGETINTEGER)( ALenum param ); +typedef ALfloat (ALAPIENTRY *LPALGETFLOAT)( ALenum param ); +typedef ALdouble (ALAPIENTRY *LPALGETDOUBLE)( ALenum param ); +typedef ALenum (ALAPIENTRY *LPALGETERROR)( ALvoid ); +typedef ALboolean (ALAPIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname ); +typedef void* (ALAPIENTRY *LPALGETPROCADDRESS)( const ALchar* fname ); +typedef ALenum (ALAPIENTRY *LPALGETENUMVALUE)( const ALchar* ename ); +typedef void (ALAPIENTRY *LPALLISTENERF)( ALenum param, ALfloat value ); +typedef void (ALAPIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +typedef void (ALAPIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values ); +typedef void (ALAPIENTRY *LPALLISTENERI)( ALenum param, ALint value ); +typedef void (ALAPIENTRY *LPALLISTENER3I)( ALenum param, ALint value1, ALint value2, ALint value3 ); +typedef void (ALAPIENTRY *LPALLISTENERIV)( ALenum param, const ALint* values ); +typedef void (ALAPIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value ); +typedef void (ALAPIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); +typedef void (ALAPIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values ); +typedef void (ALAPIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value ); +typedef void (ALAPIENTRY *LPALGETLISTENER3I)( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); +typedef void (ALAPIENTRY *LPALGETLISTENERIV)( ALenum param, ALint* values ); +typedef void (ALAPIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources ); +typedef void (ALAPIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources ); +typedef ALboolean (ALAPIENTRY *LPALISSOURCE)( ALuint sid ); +typedef void (ALAPIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value); +typedef void (ALAPIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +typedef void (ALAPIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values ); +typedef void (ALAPIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value); +typedef void (ALAPIENTRY *LPALSOURCE3I)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); +typedef void (ALAPIENTRY *LPALSOURCEIV)( ALuint sid, ALenum param, const ALint* values ); +typedef void (ALAPIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value ); +typedef void (ALAPIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); +typedef void (ALAPIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values ); +typedef void (ALAPIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value ); +typedef void (ALAPIENTRY *LPALGETSOURCE3I)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); +typedef void (ALAPIENTRY *LPALGETSOURCEIV)( ALuint sid, ALenum param, ALint* values ); +typedef void (ALAPIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids ); +typedef void (ALAPIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids ); +typedef void (ALAPIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids ); +typedef void (ALAPIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids ); +typedef void (ALAPIENTRY *LPALSOURCEPLAY)( ALuint sid ); +typedef void (ALAPIENTRY *LPALSOURCESTOP)( ALuint sid ); +typedef void (ALAPIENTRY *LPALSOURCEREWIND)( ALuint sid ); +typedef void (ALAPIENTRY *LPALSOURCEPAUSE)( ALuint sid ); +typedef void (ALAPIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids ); +typedef void (ALAPIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids ); +typedef void (ALAPIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers ); +typedef void (ALAPIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers ); +typedef ALboolean (ALAPIENTRY *LPALISBUFFER)( ALuint bid ); +typedef void (ALAPIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); +typedef void (ALAPIENTRY *LPALBUFFERF)( ALuint bid, ALenum param, ALfloat value); +typedef void (ALAPIENTRY *LPALBUFFER3F)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); +typedef void (ALAPIENTRY *LPALBUFFERFV)( ALuint bid, ALenum param, const ALfloat* values ); +typedef void (ALAPIENTRY *LPALBUFFERI)( ALuint bid, ALenum param, ALint value); +typedef void (ALAPIENTRY *LPALBUFFER3I)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); +typedef void (ALAPIENTRY *LPALBUFFERIV)( ALuint bid, ALenum param, const ALint* values ); +typedef void (ALAPIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value ); +typedef void (ALAPIENTRY *LPALGETBUFFER3F)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); +typedef void (ALAPIENTRY *LPALGETBUFFERFV)( ALuint bid, ALenum param, ALfloat* values ); +typedef void (ALAPIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value ); +typedef void (ALAPIENTRY *LPALGETBUFFER3I)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); +typedef void (ALAPIENTRY *LPALGETBUFFERIV)( ALuint bid, ALenum param, ALint* values ); +typedef void (ALAPIENTRY *LPALDOPPLERFACTOR)( ALfloat value ); +typedef void (ALAPIENTRY *LPALDOPPLERVELOCITY)( ALfloat value ); +typedef void (ALAPIENTRY *LPALSPEEDOFSOUND)( ALfloat value ); +typedef void (ALAPIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel ); + +#endif /* AL_NO_PROTOTYPES */ + +#ifdef TARGET_OS_MAC +#if TARGET_OS_MAC +#pragma export off +#endif /* TARGET_OS_MAC */ +#endif /* TARGET_OS_MAC */ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __al_h_ */ diff --git a/code/AL/alc.h b/code/AL/alc.h new file mode 100644 index 00000000..f3a41bce --- /dev/null +++ b/code/AL/alc.h @@ -0,0 +1,166 @@ +#ifndef ALC_CONTEXT_H_ +#define ALC_CONTEXT_H_ + +#include "altypes.h" +#include "alctypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ALC_VERSION_0_1 1 + +#ifdef _WIN32 + typedef struct ALCdevice_struct ALCdevice; + typedef struct ALCcontext_struct ALCcontext; + #ifndef _XBOX + #ifdef _OPENAL32LIB + #define ALCAPI __declspec(dllexport) + #else + #define ALCAPI __declspec(dllimport) + #endif + #define ALCAPIENTRY __cdecl + #endif +#endif + +#ifdef TARGET_OS_MAC + #if TARGET_OS_MAC + #pragma export on + #endif +#endif + +#ifndef ALCAPI + #define ALCAPI +#endif + +#ifndef ALCAPIENTRY + #define ALCAPIENTRY +#endif + + +#ifndef ALC_NO_PROTOTYPES + +/* + * Context Management + */ +ALCAPI ALCcontext * ALCAPIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist ); + +ALCAPI ALCboolean ALCAPIENTRY alcMakeContextCurrent( ALCcontext *context ); + +ALCAPI void ALCAPIENTRY alcProcessContext( ALCcontext *context ); + +ALCAPI void ALCAPIENTRY alcSuspendContext( ALCcontext *context ); + +ALCAPI void ALCAPIENTRY alcDestroyContext( ALCcontext *context ); + +ALCAPI ALCcontext * ALCAPIENTRY alcGetCurrentContext( ALCvoid ); + +ALCAPI ALCdevice* ALCAPIENTRY alcGetContextsDevice( ALCcontext *context ); + + +/* + * Device Management + */ +ALCAPI ALCdevice * ALCAPIENTRY alcOpenDevice( const ALchar *devicename ); + +ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice( ALCdevice *device ); + + +/* + * Error support. + * Obtain the most recent Context error + */ +ALCAPI ALCenum ALCAPIENTRY alcGetError( ALCdevice *device ); + + +/* + * Extension support. + * Query for the presence of an extension, and obtain any appropriate + * function pointers and enum values. + */ +ALCAPI ALCboolean ALCAPIENTRY alcIsExtensionPresent( ALCdevice *device, const ALCchar *extname ); + +ALCAPI void * ALCAPIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname ); + +ALCAPI ALCenum ALCAPIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname ); + + +/* + * Query functions + */ +ALCAPI const ALCchar * ALCAPIENTRY alcGetString( ALCdevice *device, ALCenum param ); + +ALCAPI void ALCAPIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data ); + + +/* + * Capture functions + */ +ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); + +ALCAPI ALCboolean ALCAPIENTRY alcCaptureCloseDevice( ALCdevice *device ); + +ALCAPI void ALCAPIENTRY alcCaptureStart( ALCdevice *device ); + +ALCAPI void ALCAPIENTRY alcCaptureStop( ALCdevice *device ); + +ALCAPI void ALCAPIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); + +#else /* ALC_NO_PROTOTYPES */ +/* +ALCAPI ALCcontext * (ALCAPIENTRY *alcCreateContext)( ALCdevice *device, const ALCint* attrlist ); +ALCAPI ALCboolean (ALCAPIENTRY *alcMakeContextCurrent)( ALCcontext *context ); +ALCAPI void (ALCAPIENTRY *alcProcessContext)( ALCcontext *context ); +ALCAPI void (ALCAPIENTRY *alcSuspendContext)( ALCcontext *context ); +ALCAPI void (ALCAPIENTRY *alcDestroyContext)( ALCcontext *context ); +ALCAPI ALCcontext * (ALCAPIENTRY *alcGetCurrentContext)( ALCvoid ); +ALCAPI ALCdevice * (ALCAPIENTRY *alcGetContextsDevice)( ALCcontext *context ); +ALCAPI ALCdevice * (ALCAPIENTRY *alcOpenDevice)( const ALCchar *devicename ); +ALCAPI ALCboolean (ALCAPIENTRY *alcCloseDevice)( ALCdevice *device ); +ALCAPI ALCenum (ALCAPIENTRY *alcGetError)( ALCdevice *device ); +ALCAPI ALCboolean (ALCAPIENTRY *alcIsExtensionPresent)( ALCdevice *device, const ALCchar *extname ); +ALCAPI void * (ALCAPIENTRY *alcGetProcAddress)( ALCdevice *device, const ALCchar *funcname ); +ALCAPI ALCenum (ALCAPIENTRY *alcGetEnumValue)( ALCdevice *device, const ALCchar *enumname ); +ALCAPI const ALCchar* (ALCAPIENTRY *alcGetString)( ALCdevice *device, ALCenum param ); +ALCAPI void (ALCAPIENTRY *alcGetIntegerv)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest ); +ALCAPI ALCdevice * (ALCAPIENTRY *alcCaptureOpenDevice)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); +ALCAPI ALCboolean (ALCAPIENTRY *alcCaptureCloseDevice)( ALCdevice *device ); +ALCAPI void (ALCAPIENTRY *alcCaptureStart)( ALCdevice *device ); +ALCAPI void (ALCAPIENTRY *alcCaptureStop)( ALCdevice *device ); +ALCAPI void (ALCAPIENTRY *alcCaptureSamples)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); +*/ +/* Type definitions */ +typedef ALCcontext * (ALCAPIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist); +typedef ALCboolean (ALCAPIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context ); +typedef void (ALCAPIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context ); +typedef void (ALCAPIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context ); +typedef void (ALCAPIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context ); +typedef ALCcontext * (ALCAPIENTRY *LPALCGETCURRENTCONTEXT)( ALCvoid ); +typedef ALCdevice * (ALCAPIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context ); +typedef ALCdevice * (ALCAPIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename ); +typedef ALCboolean (ALCAPIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device ); +typedef ALCenum (ALCAPIENTRY *LPALCGETERROR)( ALCdevice *device ); +typedef ALCboolean (ALCAPIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname ); +typedef void * (ALCAPIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname ); +typedef ALCenum (ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname ); +typedef const ALCchar* (ALCAPIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param ); +typedef void (ALCAPIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest ); +typedef ALCdevice * (ALCAPIENTRY *LPALCCAPTUREOPENDEVICE)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); +typedef ALCboolean (ALCAPIENTRY *LPALCCAPTURECLOSEDEVICE)( ALCdevice *device ); +typedef void (ALCAPIENTRY *LPALCCAPTURESTART)( ALCdevice *device ); +typedef void (ALCAPIENTRY *LPALCCAPTURESTOP)( ALCdevice *device ); +typedef void (ALCAPIENTRY *LPALCCAPTURESAMPLES)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); + +#endif /* ALC_NO_PROTOTYPES */ + +#ifdef TARGET_OS_MAC +#if TARGET_OS_MAC +#pragma export off +#endif /* TARGET_OS_MAC */ +#endif /* TARGET_OS_MAC */ + +#ifdef __cplusplus +} +#endif + +#endif /* ALC_CONTEXT_H_ */ diff --git a/code/AL/alctypes.h b/code/AL/alctypes.h new file mode 100644 index 00000000..181384b0 --- /dev/null +++ b/code/AL/alctypes.h @@ -0,0 +1,142 @@ +#ifndef _ALCTYPES_H_ +#define _ALCTYPES_H_ + +#if !defined(_WIN32) +struct _AL_device; +typedef struct _AL_device ALCdevice; + +typedef void ALCcontext; +#endif /* _WIN32 */ + +typedef int ALCenum; + +/** ALC boolean type. */ +typedef char ALCboolean; + +/** ALC 8bit signed byte. */ +typedef char ALCbyte; + +/** ALC 8bit unsigned byte. */ +typedef unsigned char ALCubyte; + +/** OpenAL 8bit char */ +typedef char ALCchar; + +/** ALC 16bit signed short integer type. */ +typedef short ALCshort; + +/** ALC 16bit unsigned short integer type. */ +typedef unsigned short ALCushort; + +/** ALC 32bit unsigned integer type. */ +typedef unsigned ALCuint; + +/** ALC 32bit signed integer type. */ +typedef int ALCint; + +/** ALC 32bit floating point type. */ +typedef float ALCfloat; + +/** ALC 64bit double point type. */ +typedef double ALCdouble; + +/** ALC 32bit type. */ +typedef int ALCsizei; + +/** ALC void type */ +typedef void ALCvoid; + +/* Enumerant values begin at column 50. No tabs. */ + +/* bad value */ +#define ALC_INVALID 0 + +/* Boolean False. */ +#define ALC_FALSE 0 + +/* Boolean True. */ +#define ALC_TRUE 1 + +/** + * followed by Hz + */ +#define ALC_FREQUENCY 0x1007 + +/** + * followed by Hz + */ +#define ALC_REFRESH 0x1008 + +/** + * followed by AL_TRUE, AL_FALSE + */ +#define ALC_SYNC 0x1009 + +/** + * followed by Num of requested Mono (3D) Sources + */ +#define ALC_MONO_SOURCES 0x1010 + +/** + * followed by Num of requested Stereo Sources + */ +#define ALC_STEREO_SOURCES 0x1011 + +/** + * errors + */ + +/** + * No error + */ +#define ALC_NO_ERROR ALC_FALSE + +/** + * No device + */ +#define ALC_INVALID_DEVICE 0xA001 + +/** + * invalid context ID + */ +#define ALC_INVALID_CONTEXT 0xA002 + +/** + * bad enum + */ +#define ALC_INVALID_ENUM 0xA003 + +/** + * bad value + */ +#define ALC_INVALID_VALUE 0xA004 + +/** + * Out of memory. + */ +#define ALC_OUT_OF_MEMORY 0xA005 + + + +/** + * The Specifier string for default device + */ +#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004 +#define ALC_DEVICE_SPECIFIER 0x1005 +#define ALC_EXTENSIONS 0x1006 + +#define ALC_MAJOR_VERSION 0x1000 +#define ALC_MINOR_VERSION 0x1001 + +#define ALC_ATTRIBUTES_SIZE 0x1002 +#define ALC_ALL_ATTRIBUTES 0x1003 + +/** + * Capture extension + */ +#define ALC_CAPTURE_DEVICE_SPECIFIER 0x310 +#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311 +#define ALC_CAPTURE_SAMPLES 0x312 + + +#endif /* _ALCTYPES_H */ diff --git a/code/AL/altypes.h b/code/AL/altypes.h new file mode 100644 index 00000000..3ec959fd --- /dev/null +++ b/code/AL/altypes.h @@ -0,0 +1,352 @@ +#ifndef _AL_TYPES_H_ +#define _AL_TYPES_H_ + +/* define platform type */ +#if !defined(MACINTOSH_AL) && !defined(LINUX_AL) && !defined(WINDOWS_AL) + #ifdef __APPLE__ + #define MACINTOSH_AL + #else + #ifdef _WIN32 + #define WINDOWS_AL + #else + #define LINUX_AL + #endif + #endif +#endif + +/** OpenAL bool type. */ +typedef char ALboolean; + +/** OpenAL 8bit signed byte. */ +typedef char ALbyte; + +/** OpenAL 8bit unsigned byte. */ +typedef unsigned char ALubyte; + +/** OpenAL 8bit char */ +typedef char ALchar; + +/** OpenAL 16bit signed short integer type. */ +typedef short ALshort; + +/** OpenAL 16bit unsigned short integer type. */ +typedef unsigned short ALushort; + +/** OpenAL 32bit unsigned integer type. */ +typedef unsigned int ALuint; + +/** OpenAL 32bit signed integer type. */ +typedef int ALint; + +/** OpenAL 32bit floating point type. */ +typedef float ALfloat; + +/** OpenAL 64bit double point type. */ +typedef double ALdouble; + +/** OpenAL 32bit type. */ +typedef int ALsizei; + +/** OpenAL void type (for params, not returns). */ +typedef void ALvoid; + +/** OpenAL enumerations. */ +typedef int ALenum; + +/** OpenAL bitfields. */ +typedef unsigned int ALbitfield; + +/** OpenAL clamped float. */ +typedef ALfloat ALclampf; + +/** Openal clamped double. */ +typedef ALdouble ALclampd; + +/* Enumerant values begin at column 50. No tabs. */ + +/* bad value */ +#define AL_INVALID -1 + +#define AL_NONE 0 + +/* Boolean False. */ +#define AL_FALSE 0 + +/** Boolean True. */ +#define AL_TRUE 1 + +/** Indicate Source has relative coordinates. */ +#define AL_SOURCE_RELATIVE 0x202 + + + +/** + * Directional source, inner cone angle, in degrees. + * Range: [0-360] + * Default: 360 + */ +#define AL_CONE_INNER_ANGLE 0x1001 + +/** + * Directional source, outer cone angle, in degrees. + * Range: [0-360] + * Default: 360 + */ +#define AL_CONE_OUTER_ANGLE 0x1002 + +/** + * Specify the pitch to be applied, either at source, + * or on mixer results, at listener. + * Range: [0.5-2.0] + * Default: 1.0 + */ +#define AL_PITCH 0x1003 + +/** + * Specify the current location in three dimensional space. + * OpenAL, like OpenGL, uses a right handed coordinate system, + * where in a frontal default view X (thumb) points right, + * Y points up (index finger), and Z points towards the + * viewer/camera (middle finger). + * To switch from a left handed coordinate system, flip the + * sign on the Z coordinate. + * Listener position is always in the world coordinate system. + */ +#define AL_POSITION 0x1004 + +/** Specify the current direction. */ +#define AL_DIRECTION 0x1005 + +/** Specify the current velocity in three dimensional space. */ +#define AL_VELOCITY 0x1006 + +/** + * Indicate whether source is looping. + * Type: ALboolean? + * Range: [AL_TRUE, AL_FALSE] + * Default: FALSE. + */ +#define AL_LOOPING 0x1007 + +/** + * Indicate the buffer to provide sound samples. + * Type: ALuint. + * Range: any valid Buffer id. + */ +#define AL_BUFFER 0x1009 + +/** + * Indicate the gain (volume amplification) applied. + * Type: ALfloat. + * Range: ]0.0- ] + * A value of 1.0 means un-attenuated/unchanged. + * Each division by 2 equals an attenuation of -6dB. + * Each multiplicaton with 2 equals an amplification of +6dB. + * A value of 0.0 is meaningless with respect to a logarithmic + * scale; it is interpreted as zero volume - the channel + * is effectively disabled. + */ +#define AL_GAIN 0x100A + +/* + * Indicate minimum source attenuation + * Type: ALfloat + * Range: [0.0 - 1.0] + * + * Logarthmic + */ +#define AL_MIN_GAIN 0x100D + +/** + * Indicate maximum source attenuation + * Type: ALfloat + * Range: [0.0 - 1.0] + * + * Logarthmic + */ +#define AL_MAX_GAIN 0x100E + +/** + * Indicate listener orientation. + * + * at/up + */ +#define AL_ORIENTATION 0x100F + +/** + * Specify the channel mask. (Creative) + * Type: ALuint + * Range: [0 - 255] + */ +#define AL_CHANNEL_MASK 0x3000 + + +/** + * Source state information. + */ +#define AL_SOURCE_STATE 0x1010 +#define AL_INITIAL 0x1011 +#define AL_PLAYING 0x1012 +#define AL_PAUSED 0x1013 +#define AL_STOPPED 0x1014 + +/** + * Buffer Queue params + */ +#define AL_BUFFERS_QUEUED 0x1015 +#define AL_BUFFERS_PROCESSED 0x1016 + +/** + * Source buffer position information + */ +#define AL_SEC_OFFSET 0x1024 +#define AL_SAMPLE_OFFSET 0x1025 +#define AL_BYTE_OFFSET 0x1026 + +/* + * Source type (Static, Streaming or undetermined) + * Source is Static if a Buffer has been attached using AL_BUFFER + * Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers + * Source is undetermined when it has the NULL buffer attached + */ +#define AL_SOURCE_TYPE 0x1027 +#define AL_STATIC 0x1028 +#define AL_STREAMING 0x1029 +#define AL_UNDETERMINED 0x1030 + +/** Sound samples: format specifier. */ +#define AL_FORMAT_MONO8 0x1100 +#define AL_FORMAT_MONO16 0x1101 +#define AL_FORMAT_STEREO8 0x1102 +#define AL_FORMAT_STEREO16 0x1103 + +/** + * source specific reference distance + * Type: ALfloat + * Range: 0.0 - +inf + * + * At 0.0, no distance attenuation occurs. Default is + * 1.0. + */ +#define AL_REFERENCE_DISTANCE 0x1020 + +/** + * source specific rolloff factor + * Type: ALfloat + * Range: 0.0 - +inf + * + */ +#define AL_ROLLOFF_FACTOR 0x1021 + +/** + * Directional source, outer cone gain. + * + * Default: 0.0 + * Range: [0.0 - 1.0] + * Logarithmic + */ +#define AL_CONE_OUTER_GAIN 0x1022 + +/** + * Indicate distance above which sources are not + * attenuated using the inverse clamped distance model. + * + * Default: +inf + * Type: ALfloat + * Range: 0.0 - +inf + */ +#define AL_MAX_DISTANCE 0x1023 + +/** + * Sound samples: frequency, in units of Hertz [Hz]. + * This is the number of samples per second. Half of the + * sample frequency marks the maximum significant + * frequency component. + */ +#define AL_FREQUENCY 0x2001 +#define AL_BITS 0x2002 +#define AL_CHANNELS 0x2003 +#define AL_SIZE 0x2004 +#define AL_DATA 0x2005 + +/** + * Buffer state. + * + * Not supported for public use (yet). + */ +#define AL_UNUSED 0x2010 +#define AL_PENDING 0x2011 +#define AL_PROCESSED 0x2012 + + +/** Errors: No Error. */ +#define AL_NO_ERROR AL_FALSE + +/** + * Invalid Name paramater passed to AL call. + */ +#define AL_INVALID_NAME 0xA001 + +/** + * Invalid parameter passed to AL call. + */ +#define AL_ILLEGAL_ENUM 0xA002 +#define AL_INVALID_ENUM 0xA002 + +/** + * Invalid enum parameter value. + */ +#define AL_INVALID_VALUE 0xA003 + +/** + * Illegal call. + */ +#define AL_ILLEGAL_COMMAND 0xA004 +#define AL_INVALID_OPERATION 0xA004 + + +/** + * No mojo. + */ +#define AL_OUT_OF_MEMORY 0xA005 + + +/** Context strings: Vendor Name. */ +#define AL_VENDOR 0xB001 +#define AL_VERSION 0xB002 +#define AL_RENDERER 0xB003 +#define AL_EXTENSIONS 0xB004 + +/** Global tweakage. */ + +/** + * Doppler scale. Default 1.0 + */ +#define AL_DOPPLER_FACTOR 0xC000 + +/** + * Tweaks speed of propagation. + */ +#define AL_DOPPLER_VELOCITY 0xC001 + +/** + * Speed of Sound in units per second + */ +#define AL_SPEED_OF_SOUND 0xC003 + +/** + * Distance models + * + * used in conjunction with DistanceModel + * + * implicit: NONE, which disances distance attenuation. + */ +#define AL_DISTANCE_MODEL 0xD000 +#define AL_INVERSE_DISTANCE 0xD001 +#define AL_INVERSE_DISTANCE_CLAMPED 0xD002 +#define AL_LINEAR_DISTANCE 0xD003 +#define AL_LINEAR_DISTANCE_CLAMPED 0xD004 +#define AL_EXPONENT_DISTANCE 0xD005 +#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006 + +#endif diff --git a/code/AL/alut.h b/code/AL/alut.h new file mode 100644 index 00000000..e29ae582 --- /dev/null +++ b/code/AL/alut.h @@ -0,0 +1,90 @@ +#ifndef _ALUT_H_ +#define _ALUT_H_ + +/* define platform type */ +#if !defined(MACINTOSH_AL) && !defined(LINUX_AL) && !defined(WINDOWS_AL) + #ifdef __APPLE__ + #define MACINTOSH_AL + #else + #ifdef _WIN32 + #define WINDOWS_AL + #else + #define LINUX_AL + #endif + #endif +#endif + +#include "altypes.h" + +#ifdef _WIN32 +#define ALUTAPI +#define ALUTAPIENTRY __cdecl +#define AL_CALLBACK +#else /* _WIN32 */ + +#ifdef TARGET_OS_MAC +#if TARGET_OS_MAC +#pragma export on +#endif /* TARGET_OS_MAC */ +#endif /* TARGET_OS_MAC */ + +#ifndef ALUTAPI +#define ALUTAPI +#endif + +#ifndef ALUTAPIENTRY +#define ALUTAPIENTRY +#endif + +#ifndef AL_CALLBACK +#define AL_CALLBACK +#endif + +#endif /* _WIN32 */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ALUT_NO_PROTOTYPES + +ALUTAPI void ALUTAPIENTRY alutInit(int *argc, char *argv[]); +ALUTAPI void ALUTAPIENTRY alutExit(ALvoid); + +#ifndef MACINTOSH_AL +/* Windows and Linux versions have a loop parameter, Macintosh doesn't */ +ALUTAPI void ALUTAPIENTRY alutLoadWAVFile(ALbyte *file, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq, ALboolean *loop); +ALUTAPI void ALUTAPIENTRY alutLoadWAVMemory(ALbyte *memory, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq, ALboolean *loop); +#else +ALUTAPI void ALUTAPIENTRY alutLoadWAVFile(ALbyte *file, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq); +ALUTAPI void ALUTAPIENTRY alutLoadWAVMemory(ALbyte *memory, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq); +#endif + +ALUTAPI void ALUTAPIENTRY alutUnloadWAV(ALenum format, ALvoid *data, ALsizei size, ALsizei freq); + +#else /* ALUT_NO_PROTOTYPES */ + + void (ALUTAPIENTRY *alutInit)( int *argc, char *argv[] ); + void (ALUTAPIENTRY *alutExit)( ALvoid ); +#ifndef MACINTOSH_AL + void (ALUTAPIENTRY *alutLoadWAVFile)( ALbyte *file,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq,ALboolean *loop ); + void (ALUTAPIENTRY *alutLoadWAVMemory)( ALbyte *memory,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq,ALboolean *loop ); +#else + void (ALUTAPIENTRY *alutLoadWAVFile( ALbyte *file,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq ); + void (ALUTAPIENTRY *alutLoadWAVMemory)( ALbyte *memory,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq ); +#endif + void (ALUTAPIENTRY *alutUnloadWAV)( ALenum format,ALvoid *data,ALsizei size,ALsizei freq ); + +#endif /* ALUT_NO_PROTOTYPES */ + +#ifdef TARGET_OS_MAC +#if TARGET_OS_MAC +#pragma export off +#endif /* TARGET_OS_MAC */ +#endif /* TARGET_OS_MAC */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/code/SDL2/include/SDL.h b/code/SDL2/include/SDL.h new file mode 100644 index 00000000..a9077095 --- /dev/null +++ b/code/SDL2/include/SDL.h @@ -0,0 +1,163 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL.h + * + * Main include header for the SDL library + */ + +/** + * \mainpage Simple DirectMedia Layer (SDL) + * + * http://www.libsdl.org/ + * + * \section intro_sec Introduction + * + * Simple DirectMedia Layer is a cross-platform development library designed + * to provide low level access to audio, keyboard, mouse, joystick, and + * graphics hardware via OpenGL and Direct3D. It is used by video playback + * software, emulators, and popular games including Valve's award winning + * catalog and many Humble Bundle games. + * + * SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. + * Support for other platforms may be found in the source code. + * + * SDL is written in C, works natively with C++, and there are bindings + * available for several other languages, including C# and Python. + * + * This library is distributed under the zlib license, which can be found + * in the file "COPYING.txt". + * + * The best way to learn how to use SDL is to check out the header files in + * the "include" subdirectory and the programs in the "test" subdirectory. + * The header files and test programs are well commented and always up to date. + * More documentation and FAQs are available online at: + * http://wiki.libsdl.org/ + * + * If you need help with the library, or just want to discuss SDL related + * issues, you can join the developers mailing list: + * http://www.libsdl.org/mailing-list.php + * + * Enjoy! + * Sam Lantinga (slouken@libsdl.org) + */ + +#ifndef _SDL_H +#define _SDL_H + +#include "SDL_main.h" +#include "SDL_stdinc.h" +#include "SDL_assert.h" +#include "SDL_atomic.h" +#include "SDL_audio.h" +#include "SDL_clipboard.h" +#include "SDL_cpuinfo.h" +#include "SDL_endian.h" +#include "SDL_error.h" +#include "SDL_events.h" +#include "SDL_filesystem.h" +#include "SDL_joystick.h" +#include "SDL_gamecontroller.h" +#include "SDL_haptic.h" +#include "SDL_hints.h" +#include "SDL_loadso.h" +#include "SDL_log.h" +#include "SDL_messagebox.h" +#include "SDL_mutex.h" +#include "SDL_power.h" +#include "SDL_render.h" +#include "SDL_rwops.h" +#include "SDL_system.h" +#include "SDL_thread.h" +#include "SDL_timer.h" +#include "SDL_version.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* As of version 0.5, SDL is loaded dynamically into the application */ + +/** + * \name SDL_INIT_* + * + * These are the flags which may be passed to SDL_Init(). You should + * specify the subsystems which you will be using in your application. + */ +/* @{ */ +#define SDL_INIT_TIMER 0x00000001 +#define SDL_INIT_AUDIO 0x00000010 +#define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ +#define SDL_INIT_JOYSTICK 0x00000200 /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ +#define SDL_INIT_HAPTIC 0x00001000 +#define SDL_INIT_GAMECONTROLLER 0x00002000 /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ +#define SDL_INIT_EVENTS 0x00004000 +#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ +#define SDL_INIT_EVERYTHING ( \ + SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ + SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ + ) +/* @} */ + +/** + * This function initializes the subsystems specified by \c flags + * Unless the ::SDL_INIT_NOPARACHUTE flag is set, it will install cleanup + * signal handlers for some commonly ignored fatal signals (like SIGSEGV). + */ +extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); + +/** + * This function initializes specific SDL subsystems + */ +extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); + +/** + * This function cleans up specific SDL subsystems + */ +extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); + +/** + * This function returns a mask of the specified subsystems which have + * previously been initialized. + * + * If \c flags is 0, it returns a mask of all initialized subsystems. + */ +extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); + +/** + * This function cleans up all initialized subsystems. You should + * call it upon all exit conditions. + */ +extern DECLSPEC void SDLCALL SDL_Quit(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_H */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_assert.h b/code/SDL2/include/SDL_assert.h new file mode 100644 index 00000000..42348f7d --- /dev/null +++ b/code/SDL2/include/SDL_assert.h @@ -0,0 +1,284 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_assert_h +#define _SDL_assert_h + +#include "SDL_config.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SDL_ASSERT_LEVEL +#ifdef SDL_DEFAULT_ASSERT_LEVEL +#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL +#elif defined(_DEBUG) || defined(DEBUG) || \ + (defined(__GNUC__) && !defined(__OPTIMIZE__)) +#define SDL_ASSERT_LEVEL 2 +#else +#define SDL_ASSERT_LEVEL 1 +#endif +#endif /* SDL_ASSERT_LEVEL */ + +/* +These are macros and not first class functions so that the debugger breaks +on the assertion line and not in some random guts of SDL, and so each +assert can have unique static variables associated with it. +*/ + +#if defined(_MSC_VER) +/* Don't include intrin.h here because it contains C++ code */ + extern void __cdecl __debugbreak(void); + #define SDL_TriggerBreakpoint() __debugbreak() +#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) +#elif defined(HAVE_SIGNAL_H) + #include + #define SDL_TriggerBreakpoint() raise(SIGTRAP) +#else + /* How do we trigger breakpoints on this platform? */ + #define SDL_TriggerBreakpoint() +#endif + +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ +# define SDL_FUNCTION __func__ +#elif ((__GNUC__ >= 2) || defined(_MSC_VER)) +# define SDL_FUNCTION __FUNCTION__ +#else +# define SDL_FUNCTION "???" +#endif +#define SDL_FILE __FILE__ +#define SDL_LINE __LINE__ + +/* +sizeof (x) makes the compiler still parse the expression even without +assertions enabled, so the code is always checked at compile time, but +doesn't actually generate code for it, so there are no side effects or +expensive checks at run time, just the constant size of what x WOULD be, +which presumably gets optimized out as unused. +This also solves the problem of... + + int somevalue = blah(); + SDL_assert(somevalue == 1); + +...which would cause compiles to complain that somevalue is unused if we +disable assertions. +*/ + +#ifdef _MSC_VER /* stupid /W4 warnings. */ +#define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__) +#else +#define SDL_NULL_WHILE_LOOP_CONDITION (0) +#endif + +#define SDL_disabled_assert(condition) \ + do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) + +typedef enum +{ + SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */ + SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */ + SDL_ASSERTION_ABORT, /**< Terminate the program. */ + SDL_ASSERTION_IGNORE, /**< Ignore the assert. */ + SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */ +} SDL_assert_state; + +typedef struct SDL_assert_data +{ + int always_ignore; + unsigned int trigger_count; + const char *condition; + const char *filename; + int linenum; + const char *function; + const struct SDL_assert_data *next; +} SDL_assert_data; + +#if (SDL_ASSERT_LEVEL > 0) + +/* Never call this directly. Use the SDL_assert* macros. */ +extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, + const char *, + const char *, int) +#if defined(__clang__) +#if __has_feature(attribute_analyzer_noreturn) +/* this tells Clang's static analysis that we're a custom assert function, + and that the analyzer should assume the condition was always true past this + SDL_assert test. */ + __attribute__((analyzer_noreturn)) +#endif +#endif +; + +/* the do {} while(0) avoids dangling else problems: + if (x) SDL_assert(y); else blah(); + ... without the do/while, the "else" could attach to this macro's "if". + We try to handle just the minimum we need here in a macro...the loop, + the static vars, and break points. The heavy lifting is handled in + SDL_ReportAssertion(), in SDL_assert.c. +*/ +#define SDL_enabled_assert(condition) \ + do { \ + while ( !(condition) ) { \ + static struct SDL_assert_data assert_data = { \ + 0, 0, #condition, 0, 0, 0, 0 \ + }; \ + const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \ + SDL_FUNCTION, \ + SDL_FILE, \ + SDL_LINE); \ + if (state == SDL_ASSERTION_RETRY) { \ + continue; /* go again. */ \ + } else if (state == SDL_ASSERTION_BREAK) { \ + SDL_TriggerBreakpoint(); \ + } \ + break; /* not retrying. */ \ + } \ + } while (SDL_NULL_WHILE_LOOP_CONDITION) + +#endif /* enabled assertions support code */ + +/* Enable various levels of assertions. */ +#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */ +# define SDL_assert(condition) SDL_disabled_assert(condition) +# define SDL_assert_release(condition) SDL_disabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 1 /* release settings. */ +# define SDL_assert(condition) SDL_disabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 2 /* normal settings. */ +# define SDL_assert(condition) SDL_enabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */ +# define SDL_assert(condition) SDL_enabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition) +#else +# error Unknown assertion level. +#endif + +/* this assertion is never disabled at any level. */ +#define SDL_assert_always(condition) SDL_enabled_assert(condition) + + +typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)( + const SDL_assert_data* data, void* userdata); + +/** + * \brief Set an application-defined assertion handler. + * + * This allows an app to show its own assertion UI and/or force the + * response to an assertion failure. If the app doesn't provide this, SDL + * will try to do the right thing, popping up a system-specific GUI dialog, + * and probably minimizing any fullscreen windows. + * + * This callback may fire from any thread, but it runs wrapped in a mutex, so + * it will only fire from one thread at a time. + * + * Setting the callback to NULL restores SDL's original internal handler. + * + * This callback is NOT reset to SDL's internal handler upon SDL_Quit()! + * + * \return SDL_assert_state value of how to handle the assertion failure. + * + * \param handler Callback function, called when an assertion fails. + * \param userdata A pointer passed to the callback as-is. + */ +extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( + SDL_AssertionHandler handler, + void *userdata); + +/** + * \brief Get the default assertion handler. + * + * This returns the function pointer that is called by default when an + * assertion is triggered. This is an internal function provided by SDL, + * that is used for assertions when SDL_SetAssertionHandler() hasn't been + * used to provide a different function. + * + * \return The default SDL_AssertionHandler that is called when an assert triggers. + */ +extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void); + +/** + * \brief Get the current assertion handler. + * + * This returns the function pointer that is called when an assertion is + * triggered. This is either the value last passed to + * SDL_SetAssertionHandler(), or if no application-specified function is + * set, is equivalent to calling SDL_GetDefaultAssertionHandler(). + * + * \param puserdata Pointer to a void*, which will store the "userdata" + * pointer that was passed to SDL_SetAssertionHandler(). + * This value will always be NULL for the default handler. + * If you don't care about this data, it is safe to pass + * a NULL pointer to this function to ignore it. + * \return The SDL_AssertionHandler that is called when an assert triggers. + */ +extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata); + +/** + * \brief Get a list of all assertion failures. + * + * Get all assertions triggered since last call to SDL_ResetAssertionReport(), + * or the start of the program. + * + * The proper way to examine this data looks something like this: + * + * + * const SDL_assert_data *item = SDL_GetAssertionReport(); + * while (item) { + * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", + * item->condition, item->function, item->filename, + * item->linenum, item->trigger_count, + * item->always_ignore ? "yes" : "no"); + * item = item->next; + * } + * + * + * \return List of all assertions. + * \sa SDL_ResetAssertionReport + */ +extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void); + +/** + * \brief Reset the list of all assertion failures. + * + * Reset list of all assertions triggered. + * + * \sa SDL_GetAssertionReport + */ +extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_assert_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_atomic.h b/code/SDL2/include/SDL_atomic.h new file mode 100644 index 00000000..bb3a9b65 --- /dev/null +++ b/code/SDL2/include/SDL_atomic.h @@ -0,0 +1,260 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_atomic.h + * + * Atomic operations. + * + * IMPORTANT: + * If you are not an expert in concurrent lockless programming, you should + * only be using the atomic lock and reference counting functions in this + * file. In all other cases you should be protecting your data structures + * with full mutexes. + * + * The list of "safe" functions to use are: + * SDL_AtomicLock() + * SDL_AtomicUnlock() + * SDL_AtomicIncRef() + * SDL_AtomicDecRef() + * + * Seriously, here be dragons! + * ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + * + * You can find out a little more about lockless programming and the + * subtle issues that can arise here: + * http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx + * + * There's also lots of good information here: + * http://www.1024cores.net/home/lock-free-algorithms + * http://preshing.com/ + * + * These operations may or may not actually be implemented using + * processor specific atomic operations. When possible they are + * implemented as true processor specific atomic operations. When that + * is not possible the are implemented using locks that *do* use the + * available atomic operations. + * + * All of the atomic operations that modify memory are full memory barriers. + */ + +#ifndef _SDL_atomic_h_ +#define _SDL_atomic_h_ + +#include "SDL_stdinc.h" +#include "SDL_platform.h" + +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name SDL AtomicLock + * + * The atomic locks are efficient spinlocks using CPU instructions, + * but are vulnerable to starvation and can spin forever if a thread + * holding a lock has been terminated. For this reason you should + * minimize the code executed inside an atomic lock and never do + * expensive things like API or system calls while holding them. + * + * The atomic locks are not safe to lock recursively. + * + * Porting Note: + * The spin lock functions and type are required and can not be + * emulated because they are used in the atomic emulation code. + */ +/* @{ */ + +typedef int SDL_SpinLock; + +/** + * \brief Try to lock a spin lock by setting it to a non-zero value. + * + * \param lock Points to the lock. + * + * \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock); + +/** + * \brief Lock a spin lock by setting it to a non-zero value. + * + * \param lock Points to the lock. + */ +extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); + +/** + * \brief Unlock a spin lock by setting it to 0. Always returns immediately + * + * \param lock Points to the lock. + */ +extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); + +/* @} *//* SDL AtomicLock */ + + +/** + * The compiler barrier prevents the compiler from reordering + * reads and writes to globally visible variables across the call. + */ +#if defined(_MSC_VER) && (_MSC_VER > 1200) +void _ReadWriteBarrier(void); +#pragma intrinsic(_ReadWriteBarrier) +#define SDL_CompilerBarrier() _ReadWriteBarrier() +#elif defined(__GNUC__) +#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") +#else +#define SDL_CompilerBarrier() \ +{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); } +#endif + +/** + * Memory barriers are designed to prevent reads and writes from being + * reordered by the compiler and being seen out of order on multi-core CPUs. + * + * A typical pattern would be for thread A to write some data and a flag, + * and for thread B to read the flag and get the data. In this case you + * would insert a release barrier between writing the data and the flag, + * guaranteeing that the data write completes no later than the flag is + * written, and you would insert an acquire barrier between reading the + * flag and reading the data, to ensure that all the reads associated + * with the flag have completed. + * + * In this pattern you should always see a release barrier paired with + * an acquire barrier and you should gate the data reads/writes with a + * single flag variable. + * + * For more information on these semantics, take a look at the blog post: + * http://preshing.com/20120913/acquire-and-release-semantics + */ +#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory") +#elif defined(__GNUC__) && defined(__arm__) +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") +#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) +#ifdef __thumb__ +/* The mcr instruction isn't available in thumb mode, use real functions */ +extern DECLSPEC void SDLCALL SDL_MemoryBarrierRelease(); +extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquire(); +#else +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") +#endif /* __thumb__ */ +#else +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") +#endif /* __GNUC__ && __arm__ */ +#else +/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */ +#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier() +#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier() +#endif + +/** + * \brief A type representing an atomic integer value. It is a struct + * so people don't accidentally use numeric operations on it. + */ +typedef struct { int value; } SDL_atomic_t; + +/** + * \brief Set an atomic variable to a new value if it is currently an old value. + * + * \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. + * + * \note If you don't know what this function is for, you shouldn't use it! +*/ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval); + +/** + * \brief Set an atomic variable to a value. + * + * \return The previous value of the atomic variable. + */ +extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v); + +/** + * \brief Get the value of an atomic variable + */ +extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); + +/** + * \brief Add to an atomic variable. + * + * \return The previous value of the atomic variable. + * + * \note This same style can be used for any number operation + */ +extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v); + +/** + * \brief Increment an atomic variable used as a reference count. + */ +#ifndef SDL_AtomicIncRef +#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1) +#endif + +/** + * \brief Decrement an atomic variable used as a reference count. + * + * \return SDL_TRUE if the variable reached zero after decrementing, + * SDL_FALSE otherwise + */ +#ifndef SDL_AtomicDecRef +#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1) +#endif + +/** + * \brief Set a pointer to a new value if it is currently an old value. + * + * \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise. + * + * \note If you don't know what this function is for, you shouldn't use it! +*/ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval); + +/** + * \brief Set a pointer to a value atomically. + * + * \return The previous value of the pointer. + */ +extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v); + +/** + * \brief Get the value of a pointer atomically. + */ +extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + +#include "close_code.h" + +#endif /* _SDL_atomic_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_audio.h b/code/SDL2/include/SDL_audio.h new file mode 100644 index 00000000..4c987d51 --- /dev/null +++ b/code/SDL2/include/SDL_audio.h @@ -0,0 +1,506 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_audio.h + * + * Access to the raw audio mixing buffer for the SDL library. + */ + +#ifndef _SDL_audio_h +#define _SDL_audio_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_endian.h" +#include "SDL_mutex.h" +#include "SDL_thread.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Audio format flags. + * + * These are what the 16 bits in SDL_AudioFormat currently mean... + * (Unspecified bits are always zero). + * + * \verbatim + ++-----------------------sample is signed if set + || + || ++-----------sample is bigendian if set + || || + || || ++---sample is float if set + || || || + || || || +---sample bit size---+ + || || || | | + 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 + \endverbatim + * + * There are macros in SDL 2.0 and later to query these bits. + */ +typedef Uint16 SDL_AudioFormat; + +/** + * \name Audio flags + */ +/* @{ */ + +#define SDL_AUDIO_MASK_BITSIZE (0xFF) +#define SDL_AUDIO_MASK_DATATYPE (1<<8) +#define SDL_AUDIO_MASK_ENDIAN (1<<12) +#define SDL_AUDIO_MASK_SIGNED (1<<15) +#define SDL_AUDIO_BITSIZE(x) (x & SDL_AUDIO_MASK_BITSIZE) +#define SDL_AUDIO_ISFLOAT(x) (x & SDL_AUDIO_MASK_DATATYPE) +#define SDL_AUDIO_ISBIGENDIAN(x) (x & SDL_AUDIO_MASK_ENDIAN) +#define SDL_AUDIO_ISSIGNED(x) (x & SDL_AUDIO_MASK_SIGNED) +#define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x)) +#define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x)) +#define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x)) + +/** + * \name Audio format flags + * + * Defaults to LSB byte order. + */ +/* @{ */ +#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ +#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ +#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ +#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */ +#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */ +#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ +#define AUDIO_U16 AUDIO_U16LSB +#define AUDIO_S16 AUDIO_S16LSB +/* @} */ + +/** + * \name int32 support + */ +/* @{ */ +#define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */ +#define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */ +#define AUDIO_S32 AUDIO_S32LSB +/* @} */ + +/** + * \name float32 support + */ +/* @{ */ +#define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */ +#define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */ +#define AUDIO_F32 AUDIO_F32LSB +/* @} */ + +/** + * \name Native audio byte ordering + */ +/* @{ */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define AUDIO_U16SYS AUDIO_U16LSB +#define AUDIO_S16SYS AUDIO_S16LSB +#define AUDIO_S32SYS AUDIO_S32LSB +#define AUDIO_F32SYS AUDIO_F32LSB +#else +#define AUDIO_U16SYS AUDIO_U16MSB +#define AUDIO_S16SYS AUDIO_S16MSB +#define AUDIO_S32SYS AUDIO_S32MSB +#define AUDIO_F32SYS AUDIO_F32MSB +#endif +/* @} */ + +/** + * \name Allow change flags + * + * Which audio format changes are allowed when opening a device. + */ +/* @{ */ +#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001 +#define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002 +#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004 +#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE) +/* @} */ + +/* @} *//* Audio flags */ + +/** + * This function is called when the audio device needs more data. + * + * \param userdata An application-specific parameter saved in + * the SDL_AudioSpec structure + * \param stream A pointer to the audio data buffer. + * \param len The length of that buffer in bytes. + * + * Once the callback returns, the buffer will no longer be valid. + * Stereo samples are stored in a LRLRLR ordering. + */ +typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream, + int len); + +/** + * The calculated values in this structure are calculated by SDL_OpenAudio(). + */ +typedef struct SDL_AudioSpec +{ + int freq; /**< DSP frequency -- samples per second */ + SDL_AudioFormat format; /**< Audio data format */ + Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */ + Uint8 silence; /**< Audio buffer silence value (calculated) */ + Uint16 samples; /**< Audio buffer size in samples (power of 2) */ + Uint16 padding; /**< Necessary for some compile environments */ + Uint32 size; /**< Audio buffer size in bytes (calculated) */ + SDL_AudioCallback callback; + void *userdata; +} SDL_AudioSpec; + + +struct SDL_AudioCVT; +typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt, + SDL_AudioFormat format); + +/** + * A structure to hold a set of audio conversion filters and buffers. + */ +#ifdef __GNUC__ +/* This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't + pad it out to 88 bytes to guarantee ABI compatibility between compilers. + vvv + The next time we rev the ABI, make sure to size the ints and add padding. +*/ +#define SDL_AUDIOCVT_PACKED __attribute__((packed)) +#else +#define SDL_AUDIOCVT_PACKED +#endif +/* */ +typedef struct SDL_AudioCVT +{ + int needed; /**< Set to 1 if conversion possible */ + SDL_AudioFormat src_format; /**< Source audio format */ + SDL_AudioFormat dst_format; /**< Target audio format */ + double rate_incr; /**< Rate conversion increment */ + Uint8 *buf; /**< Buffer to hold entire audio data */ + int len; /**< Length of original audio buffer */ + int len_cvt; /**< Length of converted audio buffer */ + int len_mult; /**< buffer must be len*len_mult big */ + double len_ratio; /**< Given len, final size is len*len_ratio */ + SDL_AudioFilter filters[10]; /**< Filter list */ + int filter_index; /**< Current audio conversion function */ +} SDL_AUDIOCVT_PACKED SDL_AudioCVT; + + +/* Function prototypes */ + +/** + * \name Driver discovery functions + * + * These functions return the list of built in audio drivers, in the + * order that they are normally initialized by default. + */ +/* @{ */ +extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); +extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); +/* @} */ + +/** + * \name Initialization and cleanup + * + * \internal These functions are used internally, and should not be used unless + * you have a specific need to specify the audio driver you want to + * use. You should normally use SDL_Init() or SDL_InitSubSystem(). + */ +/* @{ */ +extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); +extern DECLSPEC void SDLCALL SDL_AudioQuit(void); +/* @} */ + +/** + * This function returns the name of the current audio driver, or NULL + * if no driver has been initialized. + */ +extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); + +/** + * This function opens the audio device with the desired parameters, and + * returns 0 if successful, placing the actual hardware parameters in the + * structure pointed to by \c obtained. If \c obtained is NULL, the audio + * data passed to the callback function will be guaranteed to be in the + * requested format, and will be automatically converted to the hardware + * audio format if necessary. This function returns -1 if it failed + * to open the audio device, or couldn't set up the audio thread. + * + * When filling in the desired audio spec structure, + * - \c desired->freq should be the desired audio frequency in samples-per- + * second. + * - \c desired->format should be the desired audio format. + * - \c desired->samples is the desired size of the audio buffer, in + * samples. This number should be a power of two, and may be adjusted by + * the audio driver to a value more suitable for the hardware. Good values + * seem to range between 512 and 8096 inclusive, depending on the + * application and CPU speed. Smaller values yield faster response time, + * but can lead to underflow if the application is doing heavy processing + * and cannot fill the audio buffer in time. A stereo sample consists of + * both right and left channels in LR ordering. + * Note that the number of samples is directly related to time by the + * following formula: \code ms = (samples*1000)/freq \endcode + * - \c desired->size is the size in bytes of the audio buffer, and is + * calculated by SDL_OpenAudio(). + * - \c desired->silence is the value used to set the buffer to silence, + * and is calculated by SDL_OpenAudio(). + * - \c desired->callback should be set to a function that will be called + * when the audio device is ready for more data. It is passed a pointer + * to the audio buffer, and the length in bytes of the audio buffer. + * This function usually runs in a separate thread, and so you should + * protect data structures that it accesses by calling SDL_LockAudio() + * and SDL_UnlockAudio() in your code. + * - \c desired->userdata is passed as the first parameter to your callback + * function. + * + * The audio device starts out playing silence when it's opened, and should + * be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready + * for your audio callback function to be called. Since the audio driver + * may modify the requested size of the audio buffer, you should allocate + * any local mixing buffers after you open the audio device. + */ +extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, + SDL_AudioSpec * obtained); + +/** + * SDL Audio Device IDs. + * + * A successful call to SDL_OpenAudio() is always device id 1, and legacy + * SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls + * always returns devices >= 2 on success. The legacy calls are good both + * for backwards compatibility and when you don't care about multiple, + * specific, or capture devices. + */ +typedef Uint32 SDL_AudioDeviceID; + +/** + * Get the number of available devices exposed by the current driver. + * Only valid after a successfully initializing the audio subsystem. + * Returns -1 if an explicit list of devices can't be determined; this is + * not an error. For example, if SDL is set up to talk to a remote audio + * server, it can't list every one available on the Internet, but it will + * still allow a specific host to be specified to SDL_OpenAudioDevice(). + * + * In many common cases, when this function returns a value <= 0, it can still + * successfully open the default device (NULL for first argument of + * SDL_OpenAudioDevice()). + */ +extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture); + +/** + * Get the human-readable name of a specific audio device. + * Must be a value between 0 and (number of audio devices-1). + * Only valid after a successfully initializing the audio subsystem. + * The values returned by this function reflect the latest call to + * SDL_GetNumAudioDevices(); recall that function to redetect available + * hardware. + * + * The string returned by this function is UTF-8 encoded, read-only, and + * managed internally. You are not to free it. If you need to keep the + * string for any length of time, you should make your own copy of it, as it + * will be invalid next time any of several other SDL functions is called. + */ +extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, + int iscapture); + + +/** + * Open a specific audio device. Passing in a device name of NULL requests + * the most reasonable default (and is equivalent to calling SDL_OpenAudio()). + * + * The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but + * some drivers allow arbitrary and driver-specific strings, such as a + * hostname/IP address for a remote audio server, or a filename in the + * diskaudio driver. + * + * \return 0 on error, a valid device ID that is >= 2 on success. + * + * SDL_OpenAudio(), unlike this function, always acts on device ID 1. + */ +extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char + *device, + int iscapture, + const + SDL_AudioSpec * + desired, + SDL_AudioSpec * + obtained, + int + allowed_changes); + + + +/** + * \name Audio state + * + * Get the current audio state. + */ +/* @{ */ +typedef enum +{ + SDL_AUDIO_STOPPED = 0, + SDL_AUDIO_PLAYING, + SDL_AUDIO_PAUSED +} SDL_AudioStatus; +extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); + +extern DECLSPEC SDL_AudioStatus SDLCALL +SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); +/* @} *//* Audio State */ + +/** + * \name Pause audio functions + * + * These functions pause and unpause the audio callback processing. + * They should be called with a parameter of 0 after opening the audio + * device to start playing sound. This is so you can safely initialize + * data for your callback function after opening the audio device. + * Silence will be written to the audio device during the pause. + */ +/* @{ */ +extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); +extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, + int pause_on); +/* @} *//* Pause audio functions */ + +/** + * This function loads a WAVE from the data source, automatically freeing + * that source if \c freesrc is non-zero. For example, to load a WAVE file, + * you could do: + * \code + * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); + * \endcode + * + * If this function succeeds, it returns the given SDL_AudioSpec, + * filled with the audio data format of the wave data, and sets + * \c *audio_buf to a malloc()'d buffer containing the audio data, + * and sets \c *audio_len to the length of that audio buffer, in bytes. + * You need to free the audio buffer with SDL_FreeWAV() when you are + * done with it. + * + * This function returns NULL and sets the SDL error message if the + * wave file cannot be opened, uses an unknown data format, or is + * corrupt. Currently raw and MS-ADPCM WAVE files are supported. + */ +extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, + int freesrc, + SDL_AudioSpec * spec, + Uint8 ** audio_buf, + Uint32 * audio_len); + +/** + * Loads a WAV from a file. + * Compatibility convenience function. + */ +#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ + SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) + +/** + * This function frees data previously allocated with SDL_LoadWAV_RW() + */ +extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf); + +/** + * This function takes a source format and rate and a destination format + * and rate, and initializes the \c cvt structure with information needed + * by SDL_ConvertAudio() to convert a buffer of audio data from one format + * to the other. + * + * \return -1 if the format conversion is not supported, 0 if there's + * no conversion needed, or 1 if the audio filter is set up. + */ +extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, + SDL_AudioFormat src_format, + Uint8 src_channels, + int src_rate, + SDL_AudioFormat dst_format, + Uint8 dst_channels, + int dst_rate); + +/** + * Once you have initialized the \c cvt structure using SDL_BuildAudioCVT(), + * created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of + * audio data in the source format, this function will convert it in-place + * to the desired format. + * + * The data conversion may expand the size of the audio data, so the buffer + * \c cvt->buf should be allocated after the \c cvt structure is initialized by + * SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long. + */ +extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt); + +#define SDL_MIX_MAXVOLUME 128 +/** + * This takes two audio buffers of the playing audio format and mixes + * them, performing addition, volume adjustment, and overflow clipping. + * The volume ranges from 0 - 128, and should be set to ::SDL_MIX_MAXVOLUME + * for full audio volume. Note this does not change hardware volume. + * This is provided for convenience -- you can mix your own audio data. + */ +extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src, + Uint32 len, int volume); + +/** + * This works like SDL_MixAudio(), but you specify the audio format instead of + * using the format of audio device 1. Thus it can be used when no audio + * device is open at all. + */ +extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, + const Uint8 * src, + SDL_AudioFormat format, + Uint32 len, int volume); + +/** + * \name Audio lock functions + * + * The lock manipulated by these functions protects the callback function. + * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that + * the callback function is not running. Do not call these from the callback + * function or you will cause deadlock. + */ +/* @{ */ +extern DECLSPEC void SDLCALL SDL_LockAudio(void); +extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev); +extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); +extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); +/* @} *//* Audio lock functions */ + +/** + * This function shuts down audio processing and closes the audio device. + */ +extern DECLSPEC void SDLCALL SDL_CloseAudio(void); +extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_audio_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_bits.h b/code/SDL2/include/SDL_bits.h new file mode 100644 index 00000000..341524fd --- /dev/null +++ b/code/SDL2/include/SDL_bits.h @@ -0,0 +1,97 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_bits.h + * + * Functions for fiddling with bits and bitmasks. + */ + +#ifndef _SDL_bits_h +#define _SDL_bits_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_bits.h + */ + +/** + * Get the index of the most significant bit. Result is undefined when called + * with 0. This operation can also be stated as "count leading zeroes" and + * "log base 2". + * + * \return Index of the most significant bit, or -1 if the value is 0. + */ +SDL_FORCE_INLINE int +SDL_MostSignificantBitIndex32(Uint32 x) +{ +#if defined(__GNUC__) && __GNUC__ >= 4 + /* Count Leading Zeroes builtin in GCC. + * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html + */ + if (x == 0) { + return -1; + } + return 31 - __builtin_clz(x); +#else + /* Based off of Bit Twiddling Hacks by Sean Eron Anderson + * , released in the public domain. + * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog + */ + const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; + const int S[] = {1, 2, 4, 8, 16}; + + int msbIndex = 0; + int i; + + if (x == 0) { + return -1; + } + + for (i = 4; i >= 0; i--) + { + if (x & b[i]) + { + x >>= S[i]; + msbIndex |= S[i]; + } + } + + return msbIndex; +#endif +} + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_bits_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_blendmode.h b/code/SDL2/include/SDL_blendmode.h new file mode 100644 index 00000000..8c257be9 --- /dev/null +++ b/code/SDL2/include/SDL_blendmode.h @@ -0,0 +1,63 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_blendmode.h + * + * Header file declaring the SDL_BlendMode enumeration + */ + +#ifndef _SDL_blendmode_h +#define _SDL_blendmode_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The blend mode used in SDL_RenderCopy() and drawing operations. + */ +typedef enum +{ + SDL_BLENDMODE_NONE = 0x00000000, /**< no blending + dstRGBA = srcRGBA */ + SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending + dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) + dstA = srcA + (dstA * (1-srcA)) */ + SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending + dstRGB = (srcRGB * srcA) + dstRGB + dstA = dstA */ + SDL_BLENDMODE_MOD = 0x00000004 /**< color modulate + dstRGB = srcRGB * dstRGB + dstA = dstA */ +} SDL_BlendMode; + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_clipboard.h b/code/SDL2/include/SDL_clipboard.h new file mode 100644 index 00000000..74e2b32f --- /dev/null +++ b/code/SDL2/include/SDL_clipboard.h @@ -0,0 +1,71 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_clipboard.h + * + * Include file for SDL clipboard handling + */ + +#ifndef _SDL_clipboard_h +#define _SDL_clipboard_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * \brief Put UTF-8 text into the clipboard + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); + +/** + * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() + * + * \sa SDL_SetClipboardText() + */ +extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); + +/** + * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_clipboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_config.h b/code/SDL2/include/SDL_config.h new file mode 100644 index 00000000..9a2e51c5 --- /dev/null +++ b/code/SDL2/include/SDL_config.h @@ -0,0 +1,55 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_h +#define _SDL_config_h + +#include "SDL_platform.h" + +/** + * \file SDL_config.h + */ + +/* Add any platform that doesn't build using the configure system. */ +#ifdef USING_PREMAKE_CONFIG_H +#include "SDL_config_premake.h" +#elif defined(__WIN32__) +#include "SDL_config_windows.h" +#elif defined(__WINRT__) +#include "SDL_config_winrt.h" +#elif defined(__MACOSX__) +#include "SDL_config_macosx.h" +#elif defined(__IPHONEOS__) +#include "SDL_config_iphoneos.h" +#elif defined(__ANDROID__) +#include "SDL_config_android.h" +#elif defined(__PSP__) +#include "SDL_config_psp.h" +#else +/* This is a minimal configuration just to get SDL running on new platforms */ +#include "SDL_config_minimal.h" +#endif /* platform config */ + +#ifdef USING_GENERATED_CONFIG_H +#error Wrong SDL_config.h, check your include path? +#endif + +#endif /* _SDL_config_h */ diff --git a/code/SDL2/include/SDL_config.h.cmake b/code/SDL2/include/SDL_config.h.cmake new file mode 100644 index 00000000..b6fb53aa --- /dev/null +++ b/code/SDL2/include/SDL_config.h.cmake @@ -0,0 +1,395 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_h +#define _SDL_config_h + +/** + * \file SDL_config.h.in + * + * This is a set of defines to configure the SDL features + */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +/* C language features */ +#cmakedefine const @HAVE_CONST@ +#cmakedefine inline @HAVE_INLINE@ +#cmakedefine volatile @HAVE_VOLATILE@ + +/* C datatypes */ +/* Define SIZEOF_VOIDP for 64/32 architectures */ +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else +#define SIZEOF_VOIDP 4 +#endif + +#cmakedefine HAVE_GCC_ATOMICS @HAVE_GCC_ATOMICS@ +#cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@ +#cmakedefine HAVE_PTHREAD_SPINLOCK @HAVE_PTHREAD_SPINLOCK@ + +/* Comment this if you want to build without any C library requirements */ +#cmakedefine HAVE_LIBC 1 +#if HAVE_LIBC + +/* Useful headers */ +#cmakedefine HAVE_ALLOCA_H 1 +#cmakedefine HAVE_SYS_TYPES_H 1 +#cmakedefine HAVE_STDIO_H 1 +#cmakedefine STDC_HEADERS 1 +#cmakedefine HAVE_STDLIB_H 1 +#cmakedefine HAVE_STDARG_H 1 +#cmakedefine HAVE_MALLOC_H 1 +#cmakedefine HAVE_MEMORY_H 1 +#cmakedefine HAVE_STRING_H 1 +#cmakedefine HAVE_STRINGS_H 1 +#cmakedefine HAVE_INTTYPES_H 1 +#cmakedefine HAVE_STDINT_H 1 +#cmakedefine HAVE_CTYPE_H 1 +#cmakedefine HAVE_MATH_H 1 +#cmakedefine HAVE_ICONV_H 1 +#cmakedefine HAVE_SIGNAL_H 1 +#cmakedefine HAVE_ALTIVEC_H 1 +#cmakedefine HAVE_PTHREAD_NP_H 1 +#cmakedefine HAVE_LIBUDEV_H 1 +#cmakedefine HAVE_DBUS_DBUS_H 1 + +/* C library functions */ +#cmakedefine HAVE_MALLOC 1 +#cmakedefine HAVE_CALLOC 1 +#cmakedefine HAVE_REALLOC 1 +#cmakedefine HAVE_FREE 1 +#cmakedefine HAVE_ALLOCA 1 +#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ +#cmakedefine HAVE_GETENV 1 +#cmakedefine HAVE_SETENV 1 +#cmakedefine HAVE_PUTENV 1 +#cmakedefine HAVE_UNSETENV 1 +#endif +#cmakedefine HAVE_QSORT 1 +#cmakedefine HAVE_ABS 1 +#cmakedefine HAVE_BCOPY 1 +#cmakedefine HAVE_MEMSET 1 +#cmakedefine HAVE_MEMCPY 1 +#cmakedefine HAVE_MEMMOVE 1 +#cmakedefine HAVE_MEMCMP 1 +#cmakedefine HAVE_STRLEN 1 +#cmakedefine HAVE_STRLCPY 1 +#cmakedefine HAVE_STRLCAT 1 +#cmakedefine HAVE_STRDUP 1 +#cmakedefine HAVE__STRREV 1 +#cmakedefine HAVE__STRUPR 1 +#cmakedefine HAVE__STRLWR 1 +#cmakedefine HAVE_INDEX 1 +#cmakedefine HAVE_RINDEX 1 +#cmakedefine HAVE_STRCHR 1 +#cmakedefine HAVE_STRRCHR 1 +#cmakedefine HAVE_STRSTR 1 +#cmakedefine HAVE_ITOA 1 +#cmakedefine HAVE__LTOA 1 +#cmakedefine HAVE__UITOA 1 +#cmakedefine HAVE__ULTOA 1 +#cmakedefine HAVE_STRTOL 1 +#cmakedefine HAVE_STRTOUL 1 +#cmakedefine HAVE__I64TOA 1 +#cmakedefine HAVE__UI64TOA 1 +#cmakedefine HAVE_STRTOLL 1 +#cmakedefine HAVE_STRTOULL 1 +#cmakedefine HAVE_STRTOD 1 +#cmakedefine HAVE_ATOI 1 +#cmakedefine HAVE_ATOF 1 +#cmakedefine HAVE_STRCMP 1 +#cmakedefine HAVE_STRNCMP 1 +#cmakedefine HAVE__STRICMP 1 +#cmakedefine HAVE_STRCASECMP 1 +#cmakedefine HAVE__STRNICMP 1 +#cmakedefine HAVE_STRNCASECMP 1 +#cmakedefine HAVE_VSSCANF 1 +#cmakedefine HAVE_VSNPRINTF 1 +#cmakedefine HAVE_M_PI 1 +#cmakedefine HAVE_ATAN 1 +#cmakedefine HAVE_ATAN2 1 +#cmakedefine HAVE_ACOS 1 +#cmakedefine HAVE_ASIN 1 +#cmakedefine HAVE_CEIL 1 +#cmakedefine HAVE_COPYSIGN 1 +#cmakedefine HAVE_COS 1 +#cmakedefine HAVE_COSF 1 +#cmakedefine HAVE_FABS 1 +#cmakedefine HAVE_FLOOR 1 +#cmakedefine HAVE_LOG 1 +#cmakedefine HAVE_POW 1 +#cmakedefine HAVE_SCALBN 1 +#cmakedefine HAVE_SIN 1 +#cmakedefine HAVE_SINF 1 +#cmakedefine HAVE_SQRT 1 +#cmakedefine HAVE_FSEEKO 1 +#cmakedefine HAVE_FSEEKO64 1 +#cmakedefine HAVE_SIGACTION 1 +#cmakedefine HAVE_SA_SIGACTION 1 +#cmakedefine HAVE_SETJMP 1 +#cmakedefine HAVE_NANOSLEEP 1 +#cmakedefine HAVE_SYSCONF 1 +#cmakedefine HAVE_SYSCTLBYNAME 1 +#cmakedefine HAVE_CLOCK_GETTIME 1 +#cmakedefine HAVE_GETPAGESIZE 1 +#cmakedefine HAVE_MPROTECT 1 +#cmakedefine HAVE_ICONV 1 +#cmakedefine HAVE_PTHREAD_SETNAME_NP 1 +#cmakedefine HAVE_PTHREAD_SET_NAME_NP 1 +#cmakedefine HAVE_SEM_TIMEDWAIT 1 +#elif __WIN32__ +#cmakedefine HAVE_STDARG_H 1 +#cmakedefine HAVE_STDDEF_H 1 +#else +/* We may need some replacement for stdarg.h here */ +#include +#endif /* HAVE_LIBC */ + +/* SDL internal assertion support */ +#cmakedefine SDL_DEFAULT_ASSERT_LEVEL @SDL_DEFAULT_ASSERT_LEVEL@ + +/* Allow disabling of core subsystems */ +#cmakedefine SDL_ATOMIC_DISABLED @SDL_ATOMIC_DISABLED@ +#cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@ +#cmakedefine SDL_CPUINFO_DISABLED @SDL_CPUINFO_DISABLED@ +#cmakedefine SDL_EVENTS_DISABLED @SDL_EVENTS_DISABLED@ +#cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@ +#cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@ +#cmakedefine SDL_HAPTIC_DISABLED @SDL_HAPTIC_DISABLED@ +#cmakedefine SDL_LOADSO_DISABLED @SDL_LOADSO_DISABLED@ +#cmakedefine SDL_RENDER_DISABLED @SDL_RENDER_DISABLED@ +#cmakedefine SDL_THREADS_DISABLED @SDL_THREADS_DISABLED@ +#cmakedefine SDL_TIMERS_DISABLED @SDL_TIMERS_DISABLED@ +#cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@ +#cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@ +#cmakedefine SDL_FILESYSTEM_DISABLED @SDL_FILESYSTEM_DISABLED@ + +/* Enable various audio drivers */ +#cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@ +#cmakedefine SDL_AUDIO_DRIVER_ALSA_DYNAMIC @SDL_AUDIO_DRIVER_ALSA_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_ARTS @SDL_AUDIO_DRIVER_ARTS@ +#cmakedefine SDL_AUDIO_DRIVER_ARTS_DYNAMIC @SDL_AUDIO_DRIVER_ARTS_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO @SDL_AUDIO_DRIVER_PULSEAUDIO@ +#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC @SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_HAIKU @SDL_AUDIO_DRIVER_HAIKU@ +#cmakedefine SDL_AUDIO_DRIVER_BSD @SDL_AUDIO_DRIVER_BSD@ +#cmakedefine SDL_AUDIO_DRIVER_COREAUDIO @SDL_AUDIO_DRIVER_COREAUDIO@ +#cmakedefine SDL_AUDIO_DRIVER_DISK @SDL_AUDIO_DRIVER_DISK@ +#cmakedefine SDL_AUDIO_DRIVER_DUMMY @SDL_AUDIO_DRIVER_DUMMY@ +#cmakedefine SDL_AUDIO_DRIVER_XAUDIO2 @SDL_AUDIO_DRIVER_XAUDIO2@ +#cmakedefine SDL_AUDIO_DRIVER_DSOUND @SDL_AUDIO_DRIVER_DSOUND@ +#cmakedefine SDL_AUDIO_DRIVER_ESD @SDL_AUDIO_DRIVER_ESD@ +#cmakedefine SDL_AUDIO_DRIVER_ESD_DYNAMIC @SDL_AUDIO_DRIVER_ESD_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_NAS @SDL_AUDIO_DRIVER_NAS@ +#cmakedefine SDL_AUDIO_DRIVER_NAS_DYNAMIC @SDL_AUDIO_DRIVER_NAS_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_SNDIO @SDL_AUDIO_DRIVER_SNDIO@ +#cmakedefine SDL_AUDIO_DRIVER_SNDIO_DYNAMIC @SDL_AUDIO_DRIVER_SNDIO_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_OSS @SDL_AUDIO_DRIVER_OSS@ +#cmakedefine SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H @SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H@ +#cmakedefine SDL_AUDIO_DRIVER_PAUDIO @SDL_AUDIO_DRIVER_PAUDIO@ +#cmakedefine SDL_AUDIO_DRIVER_QSA @SDL_AUDIO_DRIVER_QSA@ +#cmakedefine SDL_AUDIO_DRIVER_SUNAUDIO @SDL_AUDIO_DRIVER_SUNAUDIO@ +#cmakedefine SDL_AUDIO_DRIVER_WINMM @SDL_AUDIO_DRIVER_WINMM@ +#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND @SDL_AUDIO_DRIVER_FUSIONSOUND@ +#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC @SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC@ + +/* Enable various input drivers */ +#cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ +#cmakedefine SDL_INPUT_LINUXKD @SDL_INPUT_LINUXKD@ +#cmakedefine SDL_INPUT_TSLIB @SDL_INPUT_TSLIB@ +#cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@ +#cmakedefine SDL_JOYSTICK_DINPUT @SDL_JOYSTICK_DINPUT@ +#cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@ +#cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@ +#cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@ +#cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@ +#cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@ +#cmakedefine SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H@ +#cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@ +#cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@ +#cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@ +#cmakedefine SDL_HAPTIC_DINPUT @SDL_HAPTIC_DINPUT@ + +/* Enable various shared object loading systems */ +#cmakedefine SDL_LOADSO_HAIKU @SDL_LOADSO_HAIKU@ +#cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@ +#cmakedefine SDL_LOADSO_DUMMY @SDL_LOADSO_DUMMY@ +#cmakedefine SDL_LOADSO_LDG @SDL_LOADSO_LDG@ +#cmakedefine SDL_LOADSO_WINDOWS @SDL_LOADSO_WINDOWS@ + +/* Enable various threading systems */ +#cmakedefine SDL_THREAD_PTHREAD @SDL_THREAD_PTHREAD@ +#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX@ +#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP@ +#cmakedefine SDL_THREAD_WINDOWS @SDL_THREAD_WINDOWS@ + +/* Enable various timer systems */ +#cmakedefine SDL_TIMER_HAIKU @SDL_TIMER_HAIKU@ +#cmakedefine SDL_TIMER_DUMMY @SDL_TIMER_DUMMY@ +#cmakedefine SDL_TIMER_UNIX @SDL_TIMER_UNIX@ +#cmakedefine SDL_TIMER_WINDOWS @SDL_TIMER_WINDOWS@ +#cmakedefine SDL_TIMER_WINCE @SDL_TIMER_WINCE@ + +/* Enable various video drivers */ +#cmakedefine SDL_VIDEO_DRIVER_HAIKU @SDL_VIDEO_DRIVER_HAIKU@ +#cmakedefine SDL_VIDEO_DRIVER_COCOA @SDL_VIDEO_DRIVER_COCOA@ +#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB @SDL_VIDEO_DRIVER_DIRECTFB@ +#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@ +#cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@ +#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@ +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@ + +#if 0 +/* !!! FIXME: in configure script version, missing here: */ +#undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON +#endif + +#cmakedefine SDL_VIDEO_DRIVER_MIR @SDL_VIDEO_DRIVER_MIR@ +#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC @SDL_VIDEO_DRIVER_MIR_DYNAMIC@ +#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON@ +#cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS @SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE @SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XCURSOR @SDL_VIDEO_DRIVER_X11_XCURSOR@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XINERAMA @SDL_VIDEO_DRIVER_X11_XINERAMA@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2 @SDL_VIDEO_DRIVER_X11_XINPUT2@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH @SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XRANDR @SDL_VIDEO_DRIVER_X11_XRANDR@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XSCRNSAVER @SDL_VIDEO_DRIVER_X11_XSCRNSAVER@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XSHAPE @SDL_VIDEO_DRIVER_X11_XSHAPE@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XVIDMODE @SDL_VIDEO_DRIVER_X11_XVIDMODE@ +#cmakedefine SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS @SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS@ +#cmakedefine SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 @SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32@ +#cmakedefine SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY @SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY@ +#cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@ + +#cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@ +#cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@ +#cmakedefine SDL_VIDEO_RENDER_OGL @SDL_VIDEO_RENDER_OGL@ +#cmakedefine SDL_VIDEO_RENDER_OGL_ES @SDL_VIDEO_RENDER_OGL_ES@ +#cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@ +#cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@ + +/* Enable OpenGL support */ +#cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ +#cmakedefine SDL_VIDEO_OPENGL_ES @SDL_VIDEO_OPENGL_ES@ +#cmakedefine SDL_VIDEO_OPENGL_ES2 @SDL_VIDEO_OPENGL_ES2@ +#cmakedefine SDL_VIDEO_OPENGL_BGL @SDL_VIDEO_OPENGL_BGL@ +#cmakedefine SDL_VIDEO_OPENGL_CGL @SDL_VIDEO_OPENGL_CGL@ +#cmakedefine SDL_VIDEO_OPENGL_GLX @SDL_VIDEO_OPENGL_GLX@ +#cmakedefine SDL_VIDEO_OPENGL_WGL @SDL_VIDEO_OPENGL_WGL@ +#cmakedefine SDL_VIDEO_OPENGL_EGL @SDL_VIDEO_OPENGL_EGL@ +#cmakedefine SDL_VIDEO_OPENGL_OSMESA @SDL_VIDEO_OPENGL_OSMESA@ +#cmakedefine SDL_VIDEO_OPENGL_OSMESA_DYNAMIC @SDL_VIDEO_OPENGL_OSMESA_DYNAMIC@ + +/* Enable system power support */ +#cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@ +#cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@ +#cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@ +#cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@ +#cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@ + +/* Enable system filesystem support */ +#cmakedefine SDL_FILESYSTEM_HAIKU @SDL_FILESYSTEM_HAIKU@ +#cmakedefine SDL_FILESYSTEM_COCOA @SDL_FILESYSTEM_COCOA@ +#cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@ +#cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@ +#cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@ + +/* Enable assembly routines */ +#cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@ +#cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@ + + +/* Platform specific definitions */ +#if !defined(__WIN32__) +# if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H) +typedef unsigned int size_t; +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +typedef unsigned long uintptr_t; +# endif /* if (stdint.h isn't available) */ +#else /* __WIN32__ */ +# if !defined(_STDINT_H_) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H) +# if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#define HAVE_STDINT_H 1 +# elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +# ifndef _UINTPTR_T_DEFINED +# ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +# else +typedef unsigned int uintptr_t; +# endif +#define _UINTPTR_T_DEFINED +# endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +# if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +# endif +# if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +# endif +# else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +# ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +# endif +typedef unsigned int uintptr_t; +# endif /* __GNUC__ || _MSC_VER */ +# endif /* !_STDINT_H_ && !HAVE_STDINT_H */ +#endif /* __WIN32__ */ + +#endif /* _SDL_config_h */ diff --git a/code/SDL2/include/SDL_config.h.in b/code/SDL2/include/SDL_config.h.in new file mode 100644 index 00000000..689dcf83 --- /dev/null +++ b/code/SDL2/include/SDL_config.h.in @@ -0,0 +1,333 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_h +#define _SDL_config_h + +/** + * \file SDL_config.h.in + * + * This is a set of defines to configure the SDL features + */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +/* Make sure that this isn't included by Visual C++ */ +#ifdef _MSC_VER +#error You should run hg revert SDL_config.h +#endif + +/* C language features */ +#undef const +#undef inline +#undef volatile + +/* C datatypes */ +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else +#define SIZEOF_VOIDP 4 +#endif +#undef HAVE_GCC_ATOMICS +#undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET +#undef HAVE_PTHREAD_SPINLOCK + +/* Comment this if you want to build without any C library requirements */ +#undef HAVE_LIBC +#if HAVE_LIBC + +/* Useful headers */ +#undef HAVE_ALLOCA_H +#undef HAVE_SYS_TYPES_H +#undef HAVE_STDIO_H +#undef STDC_HEADERS +#undef HAVE_STDLIB_H +#undef HAVE_STDARG_H +#undef HAVE_MALLOC_H +#undef HAVE_MEMORY_H +#undef HAVE_STRING_H +#undef HAVE_STRINGS_H +#undef HAVE_INTTYPES_H +#undef HAVE_STDINT_H +#undef HAVE_CTYPE_H +#undef HAVE_MATH_H +#undef HAVE_ICONV_H +#undef HAVE_SIGNAL_H +#undef HAVE_ALTIVEC_H +#undef HAVE_PTHREAD_NP_H +#undef HAVE_LIBUDEV_H +#undef HAVE_DBUS_DBUS_H + +/* C library functions */ +#undef HAVE_MALLOC +#undef HAVE_CALLOC +#undef HAVE_REALLOC +#undef HAVE_FREE +#undef HAVE_ALLOCA +#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ +#undef HAVE_GETENV +#undef HAVE_SETENV +#undef HAVE_PUTENV +#undef HAVE_UNSETENV +#endif +#undef HAVE_QSORT +#undef HAVE_ABS +#undef HAVE_BCOPY +#undef HAVE_MEMSET +#undef HAVE_MEMCPY +#undef HAVE_MEMMOVE +#undef HAVE_MEMCMP +#undef HAVE_STRLEN +#undef HAVE_STRLCPY +#undef HAVE_STRLCAT +#undef HAVE_STRDUP +#undef HAVE__STRREV +#undef HAVE__STRUPR +#undef HAVE__STRLWR +#undef HAVE_INDEX +#undef HAVE_RINDEX +#undef HAVE_STRCHR +#undef HAVE_STRRCHR +#undef HAVE_STRSTR +#undef HAVE_ITOA +#undef HAVE__LTOA +#undef HAVE__UITOA +#undef HAVE__ULTOA +#undef HAVE_STRTOL +#undef HAVE_STRTOUL +#undef HAVE__I64TOA +#undef HAVE__UI64TOA +#undef HAVE_STRTOLL +#undef HAVE_STRTOULL +#undef HAVE_STRTOD +#undef HAVE_ATOI +#undef HAVE_ATOF +#undef HAVE_STRCMP +#undef HAVE_STRNCMP +#undef HAVE__STRICMP +#undef HAVE_STRCASECMP +#undef HAVE__STRNICMP +#undef HAVE_STRNCASECMP +#undef HAVE_SSCANF +#undef HAVE_VSSCANF +#undef HAVE_SNPRINTF +#undef HAVE_VSNPRINTF +#undef HAVE_M_PI +#undef HAVE_ATAN +#undef HAVE_ATAN2 +#undef HAVE_ACOS +#undef HAVE_ASIN +#undef HAVE_CEIL +#undef HAVE_COPYSIGN +#undef HAVE_COS +#undef HAVE_COSF +#undef HAVE_FABS +#undef HAVE_FLOOR +#undef HAVE_LOG +#undef HAVE_POW +#undef HAVE_SCALBN +#undef HAVE_SIN +#undef HAVE_SINF +#undef HAVE_SQRT +#undef HAVE_FSEEKO +#undef HAVE_FSEEKO64 +#undef HAVE_SIGACTION +#undef HAVE_SA_SIGACTION +#undef HAVE_SETJMP +#undef HAVE_NANOSLEEP +#undef HAVE_SYSCONF +#undef HAVE_SYSCTLBYNAME +#undef HAVE_CLOCK_GETTIME +#undef HAVE_GETPAGESIZE +#undef HAVE_MPROTECT +#undef HAVE_ICONV +#undef HAVE_PTHREAD_SETNAME_NP +#undef HAVE_PTHREAD_SET_NAME_NP +#undef HAVE_SEM_TIMEDWAIT + +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 +#endif /* HAVE_LIBC */ + +/* SDL internal assertion support */ +#undef SDL_DEFAULT_ASSERT_LEVEL + +/* Allow disabling of core subsystems */ +#undef SDL_ATOMIC_DISABLED +#undef SDL_AUDIO_DISABLED +#undef SDL_CPUINFO_DISABLED +#undef SDL_EVENTS_DISABLED +#undef SDL_FILE_DISABLED +#undef SDL_JOYSTICK_DISABLED +#undef SDL_HAPTIC_DISABLED +#undef SDL_LOADSO_DISABLED +#undef SDL_RENDER_DISABLED +#undef SDL_THREADS_DISABLED +#undef SDL_TIMERS_DISABLED +#undef SDL_VIDEO_DISABLED +#undef SDL_POWER_DISABLED +#undef SDL_FILESYSTEM_DISABLED + +/* Enable various audio drivers */ +#undef SDL_AUDIO_DRIVER_ALSA +#undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC +#undef SDL_AUDIO_DRIVER_ARTS +#undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC +#undef SDL_AUDIO_DRIVER_PULSEAUDIO +#undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC +#undef SDL_AUDIO_DRIVER_HAIKU +#undef SDL_AUDIO_DRIVER_BSD +#undef SDL_AUDIO_DRIVER_COREAUDIO +#undef SDL_AUDIO_DRIVER_DISK +#undef SDL_AUDIO_DRIVER_DUMMY +#undef SDL_AUDIO_DRIVER_XAUDIO2 +#undef SDL_AUDIO_DRIVER_DSOUND +#undef SDL_AUDIO_DRIVER_ESD +#undef SDL_AUDIO_DRIVER_ESD_DYNAMIC +#undef SDL_AUDIO_DRIVER_NAS +#undef SDL_AUDIO_DRIVER_NAS_DYNAMIC +#undef SDL_AUDIO_DRIVER_SNDIO +#undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC +#undef SDL_AUDIO_DRIVER_OSS +#undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H +#undef SDL_AUDIO_DRIVER_PAUDIO +#undef SDL_AUDIO_DRIVER_QSA +#undef SDL_AUDIO_DRIVER_SUNAUDIO +#undef SDL_AUDIO_DRIVER_WINMM +#undef SDL_AUDIO_DRIVER_FUSIONSOUND +#undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC + +/* Enable various input drivers */ +#undef SDL_INPUT_LINUXEV +#undef SDL_INPUT_LINUXKD +#undef SDL_INPUT_TSLIB +#undef SDL_JOYSTICK_HAIKU +#undef SDL_JOYSTICK_DINPUT +#undef SDL_JOYSTICK_DUMMY +#undef SDL_JOYSTICK_IOKIT +#undef SDL_JOYSTICK_LINUX +#undef SDL_JOYSTICK_WINMM +#undef SDL_JOYSTICK_USBHID +#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H +#undef SDL_HAPTIC_DUMMY +#undef SDL_HAPTIC_LINUX +#undef SDL_HAPTIC_IOKIT +#undef SDL_HAPTIC_DINPUT + +/* Enable various shared object loading systems */ +#undef SDL_LOADSO_HAIKU +#undef SDL_LOADSO_DLOPEN +#undef SDL_LOADSO_DUMMY +#undef SDL_LOADSO_LDG +#undef SDL_LOADSO_WINDOWS + +/* Enable various threading systems */ +#undef SDL_THREAD_PTHREAD +#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX +#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP +#undef SDL_THREAD_WINDOWS + +/* Enable various timer systems */ +#undef SDL_TIMER_HAIKU +#undef SDL_TIMER_DUMMY +#undef SDL_TIMER_UNIX +#undef SDL_TIMER_WINDOWS + +/* Enable various video drivers */ +#undef SDL_VIDEO_DRIVER_HAIKU +#undef SDL_VIDEO_DRIVER_COCOA +#undef SDL_VIDEO_DRIVER_DIRECTFB +#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC +#undef SDL_VIDEO_DRIVER_DUMMY +#undef SDL_VIDEO_DRIVER_WINDOWS +#undef SDL_VIDEO_DRIVER_WAYLAND +#undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON +#undef SDL_VIDEO_DRIVER_MIR +#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC +#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON +#undef SDL_VIDEO_DRIVER_X11 +#undef SDL_VIDEO_DRIVER_RPI +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE +#undef SDL_VIDEO_DRIVER_X11_XCURSOR +#undef SDL_VIDEO_DRIVER_X11_XINERAMA +#undef SDL_VIDEO_DRIVER_X11_XINPUT2 +#undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#undef SDL_VIDEO_DRIVER_X11_XRANDR +#undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER +#undef SDL_VIDEO_DRIVER_X11_XSHAPE +#undef SDL_VIDEO_DRIVER_X11_XVIDMODE +#undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS +#undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 +#undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY +#undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM + +#undef SDL_VIDEO_RENDER_D3D +#undef SDL_VIDEO_RENDER_D3D11 +#undef SDL_VIDEO_RENDER_OGL +#undef SDL_VIDEO_RENDER_OGL_ES +#undef SDL_VIDEO_RENDER_OGL_ES2 +#undef SDL_VIDEO_RENDER_DIRECTFB + +/* Enable OpenGL support */ +#undef SDL_VIDEO_OPENGL +#undef SDL_VIDEO_OPENGL_ES +#undef SDL_VIDEO_OPENGL_ES2 +#undef SDL_VIDEO_OPENGL_BGL +#undef SDL_VIDEO_OPENGL_CGL +#undef SDL_VIDEO_OPENGL_EGL +#undef SDL_VIDEO_OPENGL_GLX +#undef SDL_VIDEO_OPENGL_WGL +#undef SDL_VIDEO_OPENGL_OSMESA +#undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC + +/* Enable system power support */ +#undef SDL_POWER_LINUX +#undef SDL_POWER_WINDOWS +#undef SDL_POWER_MACOSX +#undef SDL_POWER_HAIKU +#undef SDL_POWER_HARDWIRED + +/* Enable system filesystem support */ +#undef SDL_FILESYSTEM_HAIKU +#undef SDL_FILESYSTEM_COCOA +#undef SDL_FILESYSTEM_DUMMY +#undef SDL_FILESYSTEM_UNIX +#undef SDL_FILESYSTEM_WINDOWS + +/* Enable assembly routines */ +#undef SDL_ASSEMBLY_ROUTINES +#undef SDL_ALTIVEC_BLITTERS + +#endif /* _SDL_config_h */ diff --git a/code/SDL2/include/SDL_config_android.h b/code/SDL2/include/SDL_config_android.h new file mode 100644 index 00000000..738dd94c --- /dev/null +++ b/code/SDL2/include/SDL_config_android.h @@ -0,0 +1,144 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_android_h +#define _SDL_config_android_h + +#include "SDL_platform.h" + +/** + * \file SDL_config_android.h + * + * This is a configuration that can be used to build SDL for Android + */ + +#include + +#define HAVE_GCC_ATOMICS 1 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 + +#define SIZEOF_VOIDP 4 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_ANDROID 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_ANDROID 1 +#define SDL_HAPTIC_DUMMY 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_DLOPEN 1 + +/* Enable various threading systems */ +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 + +/* Enable various timer systems */ +#define SDL_TIMER_UNIX 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_ANDROID 1 + +/* Enable OpenGL ES */ +#define SDL_VIDEO_OPENGL_ES 1 +#define SDL_VIDEO_OPENGL_ES2 1 +#define SDL_VIDEO_OPENGL_EGL 1 +#define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES2 1 + +/* Enable system power support */ +#define SDL_POWER_ANDROID 1 + +/* !!! FIXME: what does Android do for filesystem stuff? */ +#define SDL_FILESYSTEM_DUMMY 1 + +#endif /* _SDL_config_android_h */ diff --git a/code/SDL2/include/SDL_config_iphoneos.h b/code/SDL2/include/SDL_config_iphoneos.h new file mode 100644 index 00000000..a0f55b6a --- /dev/null +++ b/code/SDL2/include/SDL_config_iphoneos.h @@ -0,0 +1,155 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_iphoneos_h +#define _SDL_config_iphoneos_h + +#include "SDL_platform.h" + +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else +#define SIZEOF_VOIDP 4 +#endif + +#define HAVE_GCC_ATOMICS 1 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 +#define HAVE_SYSCTLBYNAME 1 + +/* enable iPhone version of Core Audio driver */ +#define SDL_AUDIO_DRIVER_COREAUDIO 1 +/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ +#define SDL_HAPTIC_DISABLED 1 + +/* Enable Unix style SO loading */ +/* Technically this works, but it violates the iPhone developer agreement */ +/* #define SDL_LOADSO_DLOPEN 1 */ + +/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + +/* Enable various threading systems */ +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 + +/* Enable various timer systems */ +#define SDL_TIMER_UNIX 1 + +/* Supported video drivers */ +#define SDL_VIDEO_DRIVER_UIKIT 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +/* enable OpenGL ES */ +#define SDL_VIDEO_OPENGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES2 1 + +/* Enable system power support */ +#define SDL_POWER_UIKIT 1 + +/* enable iPhone keyboard support */ +#define SDL_IPHONE_KEYBOARD 1 + +/* enable joystick subsystem */ +#define SDL_JOYSTICK_DISABLED 0 + +/* Set max recognized G-force from accelerometer + See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed + */ +#define SDL_IPHONE_MAX_GFORCE 5.0 + +/* enable filesystem support */ +#define SDL_FILESYSTEM_COCOA 1 + +#endif /* _SDL_config_iphoneos_h */ diff --git a/code/SDL2/include/SDL_config_macosx.h b/code/SDL2/include/SDL_config_macosx.h new file mode 100644 index 00000000..e627aef2 --- /dev/null +++ b/code/SDL2/include/SDL_config_macosx.h @@ -0,0 +1,184 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_macosx_h +#define _SDL_config_macosx_h + +#include "SDL_platform.h" + +/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ +#include + +/* This is a set of defines to configure the SDL features */ + +#ifdef __LP64__ + #define SIZEOF_VOIDP 8 +#else + #define SIZEOF_VOIDP 4 +#endif + +/* Useful headers */ +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 +#define HAVE_SYSCTLBYNAME 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_COREAUDIO 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_IOKIT 1 +#define SDL_HAPTIC_IOKIT 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_DLOPEN 1 + +/* Enable various threading systems */ +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 + +/* Enable various timer systems */ +#define SDL_TIMER_UNIX 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_COCOA 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 +#undef SDL_VIDEO_DRIVER_X11 +#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/usr/X11R6/lib/libXi.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" +#define SDL_VIDEO_DRIVER_X11_XINERAMA 1 +#define SDL_VIDEO_DRIVER_X11_XRANDR 1 +#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 +#define SDL_VIDEO_DRIVER_X11_XSHAPE 1 +#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 +#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 + +#ifdef MAC_OS_X_VERSION_10_8 +/* + * No matter the versions targeted, this is the 10.8 or later SDK, so you have + * to use the external Xquartz, which is a more modern Xlib. Previous SDKs + * used an older Xlib. + */ +#define SDL_VIDEO_DRIVER_X11_XINPUT2 1 +#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 +#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 +#endif + +#ifndef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 1 +#endif + +/* Enable OpenGL support */ +#ifndef SDL_VIDEO_OPENGL +#define SDL_VIDEO_OPENGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_CGL +#define SDL_VIDEO_OPENGL_CGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_GLX +#define SDL_VIDEO_OPENGL_GLX 1 +#endif + +/* Enable system power support */ +#define SDL_POWER_MACOSX 1 + +/* enable filesystem support */ +#define SDL_FILESYSTEM_COCOA 1 + +/* Enable assembly routines */ +#define SDL_ASSEMBLY_ROUTINES 1 +#ifdef __ppc__ +#define SDL_ALTIVEC_BLITTERS 1 +#endif + +#endif /* _SDL_config_macosx_h */ diff --git a/code/SDL2/include/SDL_config_minimal.h b/code/SDL2/include/SDL_config_minimal.h new file mode 100644 index 00000000..1bddafea --- /dev/null +++ b/code/SDL2/include/SDL_config_minimal.h @@ -0,0 +1,81 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_minimal_h +#define _SDL_config_minimal_h + +#include "SDL_platform.h" + +/** + * \file SDL_config_minimal.h + * + * This is the minimal configuration that can be used to build SDL. + */ + +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 + +/* Most everything except Visual Studio 2008 and earlier has stdint.h now */ +#if defined(_MSC_VER) && (_MSC_VER < 1600) +/* Here are some reasonable defaults */ +typedef unsigned int size_t; +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +typedef unsigned long uintptr_t; +#else +#define HAVE_STDINT_H 1 +#endif /* Visual Studio 2008 */ + +#ifdef __GNUC__ +#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 +#endif + +/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ +#define SDL_JOYSTICK_DISABLED 1 + +/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ +#define SDL_HAPTIC_DISABLED 1 + +/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + +/* Enable the stub thread support (src/thread/generic/\*.c) */ +#define SDL_THREADS_DISABLED 1 + +/* Enable the stub timer support (src/timer/dummy/\*.c) */ +#define SDL_TIMERS_DISABLED 1 + +/* Enable the dummy video driver (src/video/dummy/\*.c) */ +#define SDL_VIDEO_DRIVER_DUMMY 1 + +/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ +#define SDL_FILESYSTEM_DUMMY 1 + +#endif /* _SDL_config_minimal_h */ diff --git a/code/SDL2/include/SDL_config_pandora.h b/code/SDL2/include/SDL_config_pandora.h new file mode 100644 index 00000000..ac8b0850 --- /dev/null +++ b/code/SDL2/include/SDL_config_pandora.h @@ -0,0 +1,124 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_h +#define _SDL_config_h + +/* This is a set of defines to configure the SDL features */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else +#define SIZEOF_VOIDP 4 +#endif + +#define SDL_BYTEORDER 1234 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_ICONV_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_STRLEN 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 + +#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_OSS 1 + +#define SDL_INPUT_LINUXEV 1 +#define SDL_INPUT_TSLIB 1 +#define SDL_JOYSTICK_LINUX 1 +#define SDL_HAPTIC_LINUX 1 + +#define SDL_LOADSO_DLOPEN 1 + +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 + +#define SDL_TIMER_UNIX 1 +#define SDL_FILESYSTEM_UNIX 1 + +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_X11 1 +#define SDL_VIDEO_DRIVER_PANDORA 1 +#define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_OPENGL_ES 1 + +#endif /* _SDL_config_h */ diff --git a/code/SDL2/include/SDL_config_psp.h b/code/SDL2/include/SDL_config_psp.h new file mode 100644 index 00000000..2f9d023c --- /dev/null +++ b/code/SDL2/include/SDL_config_psp.h @@ -0,0 +1,140 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_psp_h +#define _SDL_config_psp_h + +#include "SDL_platform.h" + + + +#ifdef __GNUC__ +#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 +#endif + +#define HAVE_GCC_ATOMICS 1 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +/* #define HAVE_SYSCONF 1 */ +/* #define HAVE_SIGACTION 1 */ + + +/* PSP isn't that sophisticated */ +#define LACKS_SYS_MMAN_H 1 + +/* Enable the stub thread support (src/thread/psp/\*.c) */ +#define SDL_THREAD_PSP 1 + +/* Enable the stub timer support (src/timer/psp/\*.c) */ +#define SDL_TIMERS_PSP 1 + +/* Enable the stub joystick driver (src/joystick/psp/\*.c) */ +#define SDL_JOYSTICK_PSP 1 + +/* Enable the stub audio driver (src/audio/psp/\*.c) */ +#define SDL_AUDIO_DRIVER_PSP 1 + +/* PSP video dirver */ +#define SDL_VIDEO_DRIVER_PSP 1 + +/* PSP render dirver */ +#define SDL_VIDEO_RENDER_PSP 1 + +#define SDL_POWER_PSP 1 + +/* !!! FIXME: what does PSP do for filesystem stuff? */ +#define SDL_FILESYSTEM_DUMMY 1 + +/* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */ +#define SDL_HAPTIC_DISABLED 1 + +/* PSP can't load shared object (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + + +#endif /* _SDL_config_psp_h */ diff --git a/code/SDL2/include/SDL_config_windows.h b/code/SDL2/include/SDL_config_windows.h new file mode 100644 index 00000000..35eda465 --- /dev/null +++ b/code/SDL2/include/SDL_config_windows.h @@ -0,0 +1,210 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_windows_h +#define _SDL_config_windows_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ + +#ifdef _WIN64 +# define SIZEOF_VOIDP 8 +#else +# define SIZEOF_VOIDP 4 +#endif + +/* This is disabled by default to avoid C runtime dependencies and manifest requirements */ +#ifdef HAVE_LIBC +/* Useful headers */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE__LTOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_CEIL 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#if _MSC_VER >= 1800 +#define HAVE_STRTOLL 1 +#define HAVE_VSSCANF 1 +#define HAVE_COPYSIGN 1 +#define HAVE_SCALBN 1 +#endif +#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) +#define HAVE_M_PI 1 +#endif +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#endif + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_DSOUND 1 +#define SDL_AUDIO_DRIVER_XAUDIO2 1 +#define SDL_AUDIO_DRIVER_WINMM 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_DINPUT 1 +#define SDL_HAPTIC_DINPUT 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WINDOWS 1 + +/* Enable various threading systems */ +#define SDL_THREAD_WINDOWS 1 + +/* Enable various timer systems */ +#define SDL_TIMER_WINDOWS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_WINDOWS 1 + +#ifndef SDL_VIDEO_RENDER_D3D +#define SDL_VIDEO_RENDER_D3D 1 +#endif +#ifndef SDL_VIDEO_RENDER_D3D11 +#define SDL_VIDEO_RENDER_D3D11 0 +#endif + +/* Enable OpenGL support */ +#ifndef SDL_VIDEO_OPENGL +#define SDL_VIDEO_OPENGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_WGL +#define SDL_VIDEO_OPENGL_WGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_ES2 +#define SDL_VIDEO_OPENGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_EGL +#define SDL_VIDEO_OPENGL_EGL 1 +#endif + + +/* Enable system power support */ +#define SDL_POWER_WINDOWS 1 + +/* Enable filesystem support */ +#define SDL_FILESYSTEM_WINDOWS 1 + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* _SDL_config_windows_h */ diff --git a/code/SDL2/include/SDL_config_winrt.h b/code/SDL2/include/SDL_config_winrt.h new file mode 100644 index 00000000..78b43ab6 --- /dev/null +++ b/code/SDL2/include/SDL_config_winrt.h @@ -0,0 +1,190 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_windows_h +#define _SDL_config_windows_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ + +#ifdef _WIN64 +# define SIZEOF_VOIDP 8 +#else +# define SIZEOF_VOIDP 4 +#endif + +/* Useful headers */ +#define HAVE_LIBC 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +//#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +//#define HAVE_ITOA 1 // TODO, WinRT: consider using _itoa_s instead +//#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead +//#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +//#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_VSNPRINTF 1 +//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_CEIL 1 +#define HAVE__COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +//#define HAVE_SCALBN 1 +#define HAVE__SCALB 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE__FSEEKI64 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_XAUDIO2 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +// TODO, WinRT: Get haptic support working +#define SDL_HAPTIC_DISABLED 1 + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#define SDL_JOYSTICK_DISABLED 1 +#else +#define SDL_JOYSTICK_XINPUT 1 +#endif + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WINDOWS 1 + +/* Enable various threading systems */ +#define SDL_THREAD_STDCPP 1 + +/* Enable various timer systems */ +#define SDL_TIMER_WINDOWS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_WINRT 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +/* Enable OpenGL ES 2.0 (via a modified ANGLE library) */ +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP /* TODO, WinRT: try adding OpenGL ES 2 support for Windows Phone 8 */ +#define SDL_VIDEO_OPENGL_ES2 1 +#define SDL_VIDEO_OPENGL_EGL 1 +#endif + +/* Enable appropriate renderer(s) */ +#define SDL_VIDEO_RENDER_D3D11 1 + +#if SDL_VIDEO_OPENGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 1 +#endif + +/* Enable system power support */ +#define SDL_POWER_WINRT 1 + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* _SDL_config_windows_h */ diff --git a/code/SDL2/include/SDL_config_wiz.h b/code/SDL2/include/SDL_config_wiz.h new file mode 100644 index 00000000..7efc20bc --- /dev/null +++ b/code/SDL2/include/SDL_config_wiz.h @@ -0,0 +1,118 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_h +#define _SDL_config_h + +/* This is a set of defines to configure the SDL features */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +#define SDL_BYTEORDER 1234 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_ICONV_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_STRLEN 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_POW 1 + +#define SDL_CDROM_DISABLED 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_OSS 1 + +#define SDL_INPUT_LINUXEV 1 +#define SDL_INPUT_TSLIB 1 +#define SDL_JOYSTICK_LINUX 1 +#define SDL_HAPTIC_LINUX 1 + +#define SDL_LOADSO_DLOPEN 1 + +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 + +#define SDL_TIMER_UNIX 1 + +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_PANDORA 1 +#define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_OPENGL_ES 1 + +#endif /* _SDL_config_h */ diff --git a/code/SDL2/include/SDL_copying.h b/code/SDL2/include/SDL_copying.h new file mode 100644 index 00000000..0964da84 --- /dev/null +++ b/code/SDL2/include/SDL_copying.h @@ -0,0 +1,20 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ diff --git a/code/SDL2/include/SDL_cpuinfo.h b/code/SDL2/include/SDL_cpuinfo.h new file mode 100644 index 00000000..1f6efd38 --- /dev/null +++ b/code/SDL2/include/SDL_cpuinfo.h @@ -0,0 +1,156 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_cpuinfo.h + * + * CPU feature detection for SDL. + */ + +#ifndef _SDL_cpuinfo_h +#define _SDL_cpuinfo_h + +#include "SDL_stdinc.h" + +/* Need to do this here because intrin.h has C++ code in it */ +/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ +#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) +#include +#ifndef _WIN64 +#define __MMX__ +#define __3dNOW__ +#endif +#define __SSE__ +#define __SSE2__ +#elif defined(__MINGW64_VERSION_MAJOR) +#include +#else +#ifdef __ALTIVEC__ +#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) +#include +#undef pixel +#endif +#endif +#ifdef __MMX__ +#include +#endif +#ifdef __3dNOW__ +#include +#endif +#ifdef __SSE__ +#include +#endif +#ifdef __SSE2__ +#include +#endif +#endif + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is a guess for the cacheline size used for padding. + * Most x86 processors have a 64 byte cache line. + * The 64-bit PowerPC processors have a 128 byte cache line. + * We'll use the larger value to be generally safe. + */ +#define SDL_CACHELINE_SIZE 128 + +/** + * This function returns the number of CPU cores available. + */ +extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); + +/** + * This function returns the L1 cache line size of the CPU + * + * This is useful for determining multi-threaded structure padding + * or SIMD prefetch sizes. + */ +extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); + +/** + * This function returns true if the CPU has the RDTSC instruction. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); + +/** + * This function returns true if the CPU has AltiVec features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); + +/** + * This function returns true if the CPU has MMX features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); + +/** + * This function returns true if the CPU has 3DNow! features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); + +/** + * This function returns true if the CPU has SSE features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); + +/** + * This function returns true if the CPU has SSE2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); + +/** + * This function returns true if the CPU has SSE3 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); + +/** + * This function returns true if the CPU has SSE4.1 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); + +/** + * This function returns true if the CPU has SSE4.2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); + +/** + * This function returns true if the CPU has AVX features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); + +/** + * This function returns the amount of RAM configured in the system, in MB. + */ +extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_cpuinfo_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_egl.h b/code/SDL2/include/SDL_egl.h new file mode 100644 index 00000000..d312f042 --- /dev/null +++ b/code/SDL2/include/SDL_egl.h @@ -0,0 +1,1396 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_opengles.h + * + * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. + */ +#ifndef _MSC_VER + +#include + +#else /* _MSC_VER */ + +/* EGL headers for Visual Studio */ + +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. +* +* $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ +* +* Adopters may modify this file to suit their platform. Adopters are +* encouraged to submit platform specific modifications to the Khronos +* group so that they can be included in future versions of this file. +* Please submit changes by sending them to the public Khronos Bugzilla +* (http://khronos.org/bugzilla) by filing a bug against product +* "Khronos (general)" component "Registry". +* +* A predefined template which fills in some of the bug fields can be +* reached using http://tinyurl.com/khrplatform-h-bugreport, but you +* must create a Bugzilla login first. +* +* +* See the Implementer's Guidelines for information about where this file +* should be located on your system and for more details of its use: +* http://www.khronos.org/registry/implementers_guide.pdf +* +* This file should be included as +* #include +* by Khronos client API header files that use its types and defines. +* +* The types in khrplatform.h should only be used to define API-specific types. +* +* Types defined in khrplatform.h: +* khronos_int8_t signed 8 bit +* khronos_uint8_t unsigned 8 bit +* khronos_int16_t signed 16 bit +* khronos_uint16_t unsigned 16 bit +* khronos_int32_t signed 32 bit +* khronos_uint32_t unsigned 32 bit +* khronos_int64_t signed 64 bit +* khronos_uint64_t unsigned 64 bit +* khronos_intptr_t signed same number of bits as a pointer +* khronos_uintptr_t unsigned same number of bits as a pointer +* khronos_ssize_t signed size +* khronos_usize_t unsigned size +* khronos_float_t signed 32 bit floating point +* khronos_time_ns_t unsigned 64 bit time in nanoseconds +* khronos_utime_nanoseconds_t unsigned time interval or absolute time in +* nanoseconds +* khronos_stime_nanoseconds_t signed time interval in nanoseconds +* khronos_boolean_enum_t enumerated boolean type. This should +* only be used as a base type when a client API's boolean type is +* an enum. Client APIs which use an integer or other type for +* booleans cannot use this as the base type for their boolean. +* +* Tokens defined in khrplatform.h: +* +* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. +* +* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. +* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. +* +* Calling convention macros defined in this file: +* KHRONOS_APICALL +* KHRONOS_APIENTRY +* KHRONOS_APIATTRIBUTES +* +* These may be used in function prototypes as: +* +* KHRONOS_APICALL void KHRONOS_APIENTRY funcname( +* int arg1, +* int arg2) KHRONOS_APIATTRIBUTES; +*/ + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APICALL +*------------------------------------------------------------------------- +* This precedes the return type of the function in the function prototype. +*/ +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APIENTRY +*------------------------------------------------------------------------- +* This follows the return type of the function and precedes the function +* name in the function prototype. +*/ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) +/* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APIATTRIBUTES +*------------------------------------------------------------------------- +* This follows the closing parenthesis of the function prototype arguments. +*/ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- +* basic type definitions +*-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* +* Using +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* +* Using +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* +* Win32 +*/ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* +* Sun or Digital +*/ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* +* Hypothetical platform with no float or int64 support +*/ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* +* Generic fallback +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* +* Types that are (so far) the same on all platforms +*/ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* +* Types that differ between LLP64 and LP64 architectures - in LLP64, +* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears +* to be the only LLP64 architecture in current use. +*/ +#ifdef _WIN64 +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* +* Float type +*/ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types +* +* These types can be used to represent a time interval in nanoseconds or +* an absolute Unadjusted System Time. Unadjusted System Time is the number +* of nanoseconds since some arbitrary system event (e.g. since the last +* time the system booted). The Unadjusted System Time is an unsigned +* 64 bit value that wraps back to 0 every 584 years. Time intervals +* may be either signed or unsigned. +*/ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* +* Dummy value used to pad enum types to 32 bits. +*/ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* +* Enumerated boolean type +* +* Values other than zero should be considered to be true. Therefore +* comparisons should not be made against KHRONOS_TRUE. +*/ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ + + +#ifndef __eglplatform_h_ +#define __eglplatform_h_ + +/* +** Copyright (c) 2007-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Platform-specific types and definitions for egl.h +* $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $ +* +* Adopters may modify khrplatform.h and this file to suit their platform. +* You are encouraged to submit all modifications to the Khronos group so that +* they can be included in future versions of this file. Please submit changes +* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) +* by filing a bug against product "EGL" component "Registry". +*/ + +/*#include */ + +/* Macros used in EGL function prototype declarations. +* +* EGL functions should be prototyped as: +* +* EGLAPI return-type EGLAPIENTRY eglFunction(arguments); +* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); +* +* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h +*/ + +#ifndef EGLAPI +#define EGLAPI KHRONOS_APICALL +#endif + +#ifndef EGLAPIENTRY +#define EGLAPIENTRY KHRONOS_APIENTRY +#endif +#define EGLAPIENTRYP EGLAPIENTRY* + +/* The types NativeDisplayType, NativeWindowType, and NativePixmapType +* are aliases of window-system-dependent types, such as X Display * or +* Windows Device Context. They must be defined in platform-specific +* code below. The EGL-prefixed versions of Native*Type are the same +* types, renamed in EGL 1.3 so all types in the API start with "EGL". +* +* Khronos STRONGLY RECOMMENDS that you use the default definitions +* provided below, since these changes affect both binary and source +* portability of applications using EGL running on different EGL +* implementations. +*/ + +#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include + +#if __WINRT__ +#include +typedef IUnknown * EGLNativeWindowType; +typedef int EGLNativeDisplayType; +typedef HBITMAP EGLNativePixmapType; +#else +typedef HDC EGLNativeDisplayType; +typedef HBITMAP EGLNativePixmapType; +typedef HWND EGLNativeWindowType; +#endif + +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ + +typedef int EGLNativeDisplayType; +typedef void *EGLNativeWindowType; +typedef void *EGLNativePixmapType; + +#elif defined(WL_EGL_PLATFORM) + +typedef struct wl_display *EGLNativeDisplayType; +typedef struct wl_egl_pixmap *EGLNativePixmapType; +typedef struct wl_egl_window *EGLNativeWindowType; + +#elif defined(__GBM__) + +typedef struct gbm_device *EGLNativeDisplayType; +typedef struct gbm_bo *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(ANDROID) /* Android */ + +struct ANativeWindow; +struct egl_native_pixmap_t; + +typedef struct ANativeWindow *EGLNativeWindowType; +typedef struct egl_native_pixmap_t *EGLNativePixmapType; +typedef void *EGLNativeDisplayType; + +#elif defined(MIR_EGL_PLATFORM) + +#include +typedef MirEGLNativeDisplayType EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef MirEGLNativeWindowType EGLNativeWindowType; + +#elif defined(__unix__) + +#ifdef MESA_EGL_NO_X11_HEADERS + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#else + +/* X11 (tentative) */ +#include +#include + +typedef Display *EGLNativeDisplayType; +typedef Pixmap EGLNativePixmapType; +typedef Window EGLNativeWindowType; + +#endif /* MESA_EGL_NO_X11_HEADERS */ + +#else +#error "Platform not recognized" +#endif + +/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ +typedef EGLNativeDisplayType NativeDisplayType; +typedef EGLNativePixmapType NativePixmapType; +typedef EGLNativeWindowType NativeWindowType; + + +/* Define EGLint. This must be a signed integral type large enough to contain +* all legal attribute names and values passed into and out of EGL, whether +* their type is boolean, bitmask, enumerant (symbolic constant), integer, +* handle, or other. While in general a 32-bit integer will suffice, if +* handles are 64 bit types, then EGLint should be defined as a signed 64-bit +* integer type. +*/ +typedef khronos_int32_t EGLint; + +#endif /* __eglplatform_h */ + +/* -*- mode: c; tab-width: 8; -*- */ +/* vi: set sw=4 ts=8: */ +/* Reference version of egl.h for EGL 1.4. +* $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $ +*/ + +/* +** Copyright (c) 2007-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#ifndef __egl_h_ +#define __egl_h_ + +/* All platform-dependent types and macro boilerplate (such as EGLAPI +* and EGLAPIENTRY) should go in eglplatform.h. +*/ +/*#include */ + +#ifdef __cplusplus +extern "C" { +#endif + + /* EGL Types */ + /* EGLint is defined in eglplatform.h */ + typedef unsigned int EGLBoolean; + typedef unsigned int EGLenum; + typedef void *EGLConfig; + typedef void *EGLContext; + typedef void *EGLDisplay; + typedef void *EGLSurface; + typedef void *EGLClientBuffer; + + /* EGL Versioning */ +#define EGL_VERSION_1_0 1 +#define EGL_VERSION_1_1 1 +#define EGL_VERSION_1_2 1 +#define EGL_VERSION_1_3 1 +#define EGL_VERSION_1_4 1 + + /* EGL Enumerants. Bitmasks and other exceptional cases aside, most + * enums are assigned unique values starting at 0x3000. + */ + + /* EGL aliases */ +#define EGL_FALSE 0 +#define EGL_TRUE 1 + + /* Out-of-band handle values */ +#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) +#define EGL_NO_CONTEXT ((EGLContext)0) +#define EGL_NO_DISPLAY ((EGLDisplay)0) +#define EGL_NO_SURFACE ((EGLSurface)0) + + /* Out-of-band attribute value */ +#define EGL_DONT_CARE ((EGLint)-1) + + /* Errors / GetError return values */ +#define EGL_SUCCESS 0x3000 +#define EGL_NOT_INITIALIZED 0x3001 +#define EGL_BAD_ACCESS 0x3002 +#define EGL_BAD_ALLOC 0x3003 +#define EGL_BAD_ATTRIBUTE 0x3004 +#define EGL_BAD_CONFIG 0x3005 +#define EGL_BAD_CONTEXT 0x3006 +#define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DISPLAY 0x3008 +#define EGL_BAD_MATCH 0x3009 +#define EGL_BAD_NATIVE_PIXMAP 0x300A +#define EGL_BAD_NATIVE_WINDOW 0x300B +#define EGL_BAD_PARAMETER 0x300C +#define EGL_BAD_SURFACE 0x300D +#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */ + + /* Reserved 0x300F-0x301F for additional errors */ + + /* Config attributes */ +#define EGL_BUFFER_SIZE 0x3020 +#define EGL_ALPHA_SIZE 0x3021 +#define EGL_BLUE_SIZE 0x3022 +#define EGL_GREEN_SIZE 0x3023 +#define EGL_RED_SIZE 0x3024 +#define EGL_DEPTH_SIZE 0x3025 +#define EGL_STENCIL_SIZE 0x3026 +#define EGL_CONFIG_CAVEAT 0x3027 +#define EGL_CONFIG_ID 0x3028 +#define EGL_LEVEL 0x3029 +#define EGL_MAX_PBUFFER_HEIGHT 0x302A +#define EGL_MAX_PBUFFER_PIXELS 0x302B +#define EGL_MAX_PBUFFER_WIDTH 0x302C +#define EGL_NATIVE_RENDERABLE 0x302D +#define EGL_NATIVE_VISUAL_ID 0x302E +#define EGL_NATIVE_VISUAL_TYPE 0x302F +#define EGL_SAMPLES 0x3031 +#define EGL_SAMPLE_BUFFERS 0x3032 +#define EGL_SURFACE_TYPE 0x3033 +#define EGL_TRANSPARENT_TYPE 0x3034 +#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 +#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 +#define EGL_TRANSPARENT_RED_VALUE 0x3037 +#define EGL_NONE 0x3038 /* Attrib list terminator */ +#define EGL_BIND_TO_TEXTURE_RGB 0x3039 +#define EGL_BIND_TO_TEXTURE_RGBA 0x303A +#define EGL_MIN_SWAP_INTERVAL 0x303B +#define EGL_MAX_SWAP_INTERVAL 0x303C +#define EGL_LUMINANCE_SIZE 0x303D +#define EGL_ALPHA_MASK_SIZE 0x303E +#define EGL_COLOR_BUFFER_TYPE 0x303F +#define EGL_RENDERABLE_TYPE 0x3040 +#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */ +#define EGL_CONFORMANT 0x3042 + + /* Reserved 0x3041-0x304F for additional config attributes */ + + /* Config attribute values */ +#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */ +#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */ +#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */ +#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */ +#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */ + + /* More config attribute values, for EGL_TEXTURE_FORMAT */ +#define EGL_NO_TEXTURE 0x305C +#define EGL_TEXTURE_RGB 0x305D +#define EGL_TEXTURE_RGBA 0x305E +#define EGL_TEXTURE_2D 0x305F + + /* Config attribute mask bits */ +#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */ + +#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */ +#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */ +#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */ +#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */ + + /* QueryString targets */ +#define EGL_VENDOR 0x3053 +#define EGL_VERSION 0x3054 +#define EGL_EXTENSIONS 0x3055 +#define EGL_CLIENT_APIS 0x308D + + /* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */ +#define EGL_HEIGHT 0x3056 +#define EGL_WIDTH 0x3057 +#define EGL_LARGEST_PBUFFER 0x3058 +#define EGL_TEXTURE_FORMAT 0x3080 +#define EGL_TEXTURE_TARGET 0x3081 +#define EGL_MIPMAP_TEXTURE 0x3082 +#define EGL_MIPMAP_LEVEL 0x3083 +#define EGL_RENDER_BUFFER 0x3086 +#define EGL_VG_COLORSPACE 0x3087 +#define EGL_VG_ALPHA_FORMAT 0x3088 +#define EGL_HORIZONTAL_RESOLUTION 0x3090 +#define EGL_VERTICAL_RESOLUTION 0x3091 +#define EGL_PIXEL_ASPECT_RATIO 0x3092 +#define EGL_SWAP_BEHAVIOR 0x3093 +#define EGL_MULTISAMPLE_RESOLVE 0x3099 + + /* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */ +#define EGL_BACK_BUFFER 0x3084 +#define EGL_SINGLE_BUFFER 0x3085 + + /* OpenVG color spaces */ +#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */ +#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */ + + /* OpenVG alpha formats */ +#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */ +#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */ + + /* Constant scale factor by which fractional display resolutions & + * aspect ratio are scaled when queried as integer values. + */ +#define EGL_DISPLAY_SCALING 10000 + + /* Unknown display resolution/aspect ratio */ +#define EGL_UNKNOWN ((EGLint)-1) + + /* Back buffer swap behaviors */ +#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */ +#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */ + + /* CreatePbufferFromClientBuffer buffer types */ +#define EGL_OPENVG_IMAGE 0x3096 + + /* QueryContext targets */ +#define EGL_CONTEXT_CLIENT_TYPE 0x3097 + + /* CreateContext attributes */ +#define EGL_CONTEXT_CLIENT_VERSION 0x3098 + + /* Multisample resolution behaviors */ +#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */ +#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */ + + /* BindAPI/QueryAPI targets */ +#define EGL_OPENGL_ES_API 0x30A0 +#define EGL_OPENVG_API 0x30A1 +#define EGL_OPENGL_API 0x30A2 + + /* GetCurrentSurface targets */ +#define EGL_DRAW 0x3059 +#define EGL_READ 0x305A + + /* WaitNative engines */ +#define EGL_CORE_NATIVE_ENGINE 0x305B + + /* EGL 1.2 tokens renamed for consistency in EGL 1.3 */ +#define EGL_COLORSPACE EGL_VG_COLORSPACE +#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT +#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB +#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR +#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE +#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE + + /* EGL extensions must request enum blocks from the Khronos + * API Registrar, who maintains the enumerant registry. Submit + * a bug in Khronos Bugzilla against task "Registry". + */ + + + + /* EGL Functions */ + + EGLAPI EGLint EGLAPIENTRY eglGetError(void); + + EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id); + EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor); + EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy); + + EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name); + + EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, + EGLint config_size, EGLint *num_config); + EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, + EGLConfig *configs, EGLint config_size, + EGLint *num_config); + EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, + EGLint attribute, EGLint *value); + + EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, + EGLNativeWindowType win, + const EGLint *attrib_list); + EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, + const EGLint *attrib_list); + EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, + EGLNativePixmapType pixmap, + const EGLint *attrib_list); + EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface); + EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, + EGLint attribute, EGLint *value); + + EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api); + EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void); + + EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void); + + EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void); + + EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer( + EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, + EGLConfig config, const EGLint *attrib_list); + + EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, + EGLint attribute, EGLint value); + EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); + EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); + + + EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval); + + + EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, + EGLContext share_context, + const EGLint *attrib_list); + EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx); + EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, + EGLSurface read, EGLContext ctx); + + EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void); + EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw); + EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void); + EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, + EGLint attribute, EGLint *value); + + EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void); + EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine); + EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); + EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, + EGLNativePixmapType target); + + /* This is a generic function pointer type, whose name indicates it must + * be cast to the proper type *and calling convention* before use. + */ + typedef void(*__eglMustCastToProperFunctionPointerType)(void); + + /* Now, define eglGetProcAddress using the generic function ptr. type */ + EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY + eglGetProcAddress(const char *procname); + +#ifdef __cplusplus +} +#endif + +#endif /* __egl_h_ */ + + + + +#ifndef __eglext_h_ +#define __eglext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + + /* + ** Copyright (c) 2007-2013 The Khronos Group Inc. + ** + ** Permission is hereby granted, free of charge, to any person obtaining a + ** copy of this software and/or associated documentation files (the + ** "Materials"), to deal in the Materials without restriction, including + ** without limitation the rights to use, copy, modify, merge, publish, + ** distribute, sublicense, and/or sell copies of the Materials, and to + ** permit persons to whom the Materials are furnished to do so, subject to + ** the following conditions: + ** + ** The above copyright notice and this permission notice shall be included + ** in all copies or substantial portions of the Materials. + ** + ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + */ + +/* #include */ + + /*************************************************************/ + + /* Header file version number */ + /* Current version at http://www.khronos.org/registry/egl/ */ + /* $Revision: 21254 $ on $Date: 2013-04-25 03:11:55 -0700 (Thu, 25 Apr 2013) $ */ +#define EGL_EGLEXT_VERSION 16 + +#ifndef EGL_KHR_config_attribs +#define EGL_KHR_config_attribs 1 +#define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */ +#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */ +#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */ +#endif + +#ifndef EGL_KHR_lock_surface +#define EGL_KHR_lock_surface 1 +#define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ +#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ +#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */ +#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */ +#define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */ +#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */ +#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */ +#define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */ +#define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */ +#define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */ +#define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */ +#define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */ +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); + EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLBoolean(EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface); +#endif + +#ifndef EGL_KHR_image +#define EGL_KHR_image 1 +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */ + typedef void *EGLImageKHR; +#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); + EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLImageKHR(EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); +#endif + +#ifndef EGL_KHR_vg_parent_image +#define EGL_KHR_vg_parent_image 1 +#define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */ +#endif + +#ifndef EGL_KHR_gl_texture_2D_image +#define EGL_KHR_gl_texture_2D_image 1 +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */ +#endif + +#ifndef EGL_KHR_gl_texture_cubemap_image +#define EGL_KHR_gl_texture_cubemap_image 1 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */ +#endif + +#ifndef EGL_KHR_gl_texture_3D_image +#define EGL_KHR_gl_texture_3D_image 1 +#define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */ +#endif + +#ifndef EGL_KHR_gl_renderbuffer_image +#define EGL_KHR_gl_renderbuffer_image 1 +#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */ +#endif + +#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */ +#ifndef EGL_KHR_reusable_sync +#define EGL_KHR_reusable_sync 1 + + typedef void* EGLSyncKHR; + typedef khronos_utime_nanoseconds_t EGLTimeKHR; + +#define EGL_SYNC_STATUS_KHR 0x30F1 +#define EGL_SIGNALED_KHR 0x30F2 +#define EGL_UNSIGNALED_KHR 0x30F3 +#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 +#define EGL_CONDITION_SATISFIED_KHR 0x30F6 +#define EGL_SYNC_TYPE_KHR 0x30F7 +#define EGL_SYNC_REUSABLE_KHR 0x30FA +#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR bitfield */ +#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull +#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); + EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync); + EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); + EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); + EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLSyncKHR(EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); + typedef EGLint(EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif +#endif + +#ifndef EGL_KHR_image_base +#define EGL_KHR_image_base 1 + /* Most interfaces defined by EGL_KHR_image_pixmap above */ +#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */ +#endif + +#ifndef EGL_KHR_image_pixmap +#define EGL_KHR_image_pixmap 1 + /* Interfaces defined by EGL_KHR_image above */ +#endif + +#ifndef EGL_IMG_context_priority +#define EGL_IMG_context_priority 1 +#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 +#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 +#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 +#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 +#endif + +#ifndef EGL_KHR_lock_surface2 +#define EGL_KHR_lock_surface2 1 +#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 +#endif + +#ifndef EGL_NV_coverage_sample +#define EGL_NV_coverage_sample 1 +#define EGL_COVERAGE_BUFFERS_NV 0x30E0 +#define EGL_COVERAGE_SAMPLES_NV 0x30E1 +#endif + +#ifndef EGL_NV_depth_nonlinear +#define EGL_NV_depth_nonlinear 1 +#define EGL_DEPTH_ENCODING_NV 0x30E2 +#define EGL_DEPTH_ENCODING_NONE_NV 0 +#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 +#endif + +#if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */ +#ifndef EGL_NV_sync +#define EGL_NV_sync 1 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 +#define EGL_SYNC_STATUS_NV 0x30E7 +#define EGL_SIGNALED_NV 0x30E8 +#define EGL_UNSIGNALED_NV 0x30E9 +#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 +#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull +#define EGL_ALREADY_SIGNALED_NV 0x30EA +#define EGL_TIMEOUT_EXPIRED_NV 0x30EB +#define EGL_CONDITION_SATISFIED_NV 0x30EC +#define EGL_SYNC_TYPE_NV 0x30ED +#define EGL_SYNC_CONDITION_NV 0x30EE +#define EGL_SYNC_FENCE_NV 0x30EF +#define EGL_NO_SYNC_NV ((EGLSyncNV)0) + typedef void* EGLSyncNV; + typedef khronos_utime_nanoseconds_t EGLTimeNV; +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV(EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); + EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV(EGLSyncNV sync); + EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV(EGLSyncNV sync); + EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV(EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); + EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV(EGLSyncNV sync, EGLenum mode); + EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV(EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLSyncNV(EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); + typedef EGLint(EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif +#endif + +#if KHRONOS_SUPPORT_INT64 /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */ +#ifndef EGL_KHR_fence_sync +#define EGL_KHR_fence_sync 1 + /* Reuses most tokens and entry points from EGL_KHR_reusable_sync */ +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 +#define EGL_SYNC_CONDITION_KHR 0x30F8 +#define EGL_SYNC_FENCE_KHR 0x30F9 +#endif +#endif + +#ifndef EGL_HI_clientpixmap +#define EGL_HI_clientpixmap 1 + + /* Surface Attribute */ +#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 + /* + * Structure representing a client pixmap + * (pixmap's data is in client-space memory). + */ + struct EGLClientPixmapHI + { + void* pData; + EGLint iWidth; + EGLint iHeight; + EGLint iStride; + }; +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap); +#endif /* EGL_HI_clientpixmap */ + +#ifndef EGL_HI_colorformats +#define EGL_HI_colorformats 1 + /* Config Attribute */ +#define EGL_COLOR_FORMAT_HI 0x8F70 + /* Color Formats */ +#define EGL_COLOR_RGB_HI 0x8F71 +#define EGL_COLOR_RGBA_HI 0x8F72 +#define EGL_COLOR_ARGB_HI 0x8F73 +#endif /* EGL_HI_colorformats */ + +#ifndef EGL_MESA_drm_image +#define EGL_MESA_drm_image 1 +#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 /* CreateDRMImageMESA attribute */ +#define EGL_DRM_BUFFER_USE_MESA 0x31D1 /* CreateDRMImageMESA attribute */ +#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 /* EGL_IMAGE_FORMAT_MESA attribute value */ +#define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */ +#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 +#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */ +#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */ +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA(EGLDisplay dpy, const EGLint *attrib_list); + EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA(EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLImageKHR(EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif + +#ifndef EGL_NV_post_sub_buffer +#define EGL_NV_post_sub_buffer 1 +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLBoolean(EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif + +#ifndef EGL_ANGLE_query_surface_pointer +#define EGL_ANGLE_query_surface_pointer 1 +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#endif + typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#endif + +#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle +#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 +#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 +#endif + +#ifndef EGL_NV_coverage_sample_resolve +#define EGL_NV_coverage_sample_resolve 1 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 +#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 +#endif + +#if KHRONOS_SUPPORT_INT64 /* EGLuint64NV requires 64-bit uint support */ +#ifndef EGL_NV_system_time +#define EGL_NV_system_time 1 + typedef khronos_utime_nanoseconds_t EGLuint64NV; +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void); + EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLuint64NV(EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); + typedef EGLuint64NV(EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); +#endif +#endif + +#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */ +#ifndef EGL_KHR_stream +#define EGL_KHR_stream 1 + typedef void* EGLStreamKHR; + typedef khronos_uint64_t EGLuint64KHR; +#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) +#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 +#define EGL_PRODUCER_FRAME_KHR 0x3212 +#define EGL_CONSUMER_FRAME_KHR 0x3213 +#define EGL_STREAM_STATE_KHR 0x3214 +#define EGL_STREAM_STATE_CREATED_KHR 0x3215 +#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 +#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 +#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 +#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 +#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A +#define EGL_BAD_STREAM_KHR 0x321B +#define EGL_BAD_STATE_KHR 0x321C +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list); + EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream); + EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); + EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); + EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLStreamKHR(EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_consumer_gltexture +#define EGL_KHR_stream_consumer_gltexture 1 +#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream); + EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream); + EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_producer_eglsurface +#define EGL_KHR_stream_producer_eglsurface 1 +#define EGL_STREAM_BIT_KHR 0x0800 +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_producer_aldatalocator +#define EGL_KHR_stream_producer_aldatalocator 1 +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_fifo +#define EGL_KHR_stream_fifo 1 + /* reuse EGLTimeKHR */ +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC +#define EGL_STREAM_TIME_NOW_KHR 0x31FD +#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE +#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif +#endif + +#ifndef EGL_EXT_create_context_robustness +#define EGL_EXT_create_context_robustness 1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 +#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF +#endif + +#ifndef EGL_ANGLE_d3d_share_handle_client_buffer +#define EGL_ANGLE_d3d_share_handle_client_buffer 1 + /* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */ +#endif + +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 +#endif + +#ifndef EGL_KHR_surfaceless_context +#define EGL_KHR_surfaceless_context 1 + /* No tokens/entry points, just relaxes an error condition */ +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_cross_process_fd +#define EGL_KHR_stream_cross_process_fd 1 + typedef int EGLNativeFileDescriptorKHR; +#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream); + EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLNativeFileDescriptorKHR(EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); + typedef EGLStreamKHR(EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif +#endif + +#ifndef EGL_EXT_multiview_window +#define EGL_EXT_multiview_window 1 +#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 +#endif + +#ifndef EGL_KHR_wait_sync +#define EGL_KHR_wait_sync 1 +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLint(EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif + +#ifndef EGL_NV_post_convert_rounding +#define EGL_NV_post_convert_rounding 1 + /* No tokens or entry points, just relaxes behavior of SwapBuffers */ +#endif + +#ifndef EGL_NV_native_query +#define EGL_NV_native_query 1 +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV(EGLDisplay dpy, EGLNativeDisplayType* display_id); + EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV(EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType* window); + EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV(EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType* pixmap); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC)(EGLDisplay dpy, EGLNativeDisplayType *display_id); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); + typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#endif + +#ifndef EGL_NV_3dvision_surface +#define EGL_NV_3dvision_surface 1 +#define EGL_AUTO_STEREO_NV 0x3136 +#endif + +#ifndef EGL_ANDROID_framebuffer_target +#define EGL_ANDROID_framebuffer_target 1 +#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 +#endif + +#ifndef EGL_ANDROID_blob_cache +#define EGL_ANDROID_blob_cache 1 + typedef khronos_ssize_t EGLsizeiANDROID; + typedef void(*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); + typedef EGLsizeiANDROID(*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif + +#ifndef EGL_ANDROID_image_native_buffer +#define EGL_ANDROID_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_ANDROID 0x3140 +#endif + +#ifndef EGL_ANDROID_native_fence_sync +#define EGL_ANDROID_native_fence_sync 1 +#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 +#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 +#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 +#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSyncKHR); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLint(EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy, EGLSyncKHR); +#endif + +#ifndef EGL_ANDROID_recordable +#define EGL_ANDROID_recordable 1 +#define EGL_RECORDABLE_ANDROID 0x3142 +#endif + +#ifndef EGL_EXT_buffer_age +#define EGL_EXT_buffer_age 1 +#define EGL_BUFFER_AGE_EXT 0x313D +#endif + +#ifndef EGL_EXT_image_dma_buf_import +#define EGL_EXT_image_dma_buf_import 1 +#define EGL_LINUX_DMA_BUF_EXT 0x3270 +#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 +#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 +#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 +#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B +#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C +#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E +#define EGL_ITU_REC601_EXT 0x327F +#define EGL_ITU_REC709_EXT 0x3280 +#define EGL_ITU_REC2020_EXT 0x3281 +#define EGL_YUV_FULL_RANGE_EXT 0x3282 +#define EGL_YUV_NARROW_RANGE_EXT 0x3283 +#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 +#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 +#endif + +#ifndef EGL_ARM_pixmap_multisample_discard +#define EGL_ARM_pixmap_multisample_discard 1 +#define EGL_DISCARD_SAMPLES_ARM 0x3286 +#endif + +#ifndef EGL_EXT_swap_buffers_with_damage +#define EGL_EXT_swap_buffers_with_damage 1 +#ifdef EGL_EGLEXT_PROTOTYPES + EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif /* EGL_EGLEXT_PROTOTYPES */ + typedef EGLBoolean(EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)(EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif + +/* #include */ + +#ifdef __cplusplus +} +#endif + +#endif /* __eglext_h_ */ + + + +#endif /* _MSC_VER */ diff --git a/code/SDL2/include/SDL_endian.h b/code/SDL2/include/SDL_endian.h new file mode 100644 index 00000000..161c418d --- /dev/null +++ b/code/SDL2/include/SDL_endian.h @@ -0,0 +1,239 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_endian.h + * + * Functions for reading and writing endian-specific values + */ + +#ifndef _SDL_endian_h +#define _SDL_endian_h + +#include "SDL_stdinc.h" + +/** + * \name The two types of endianness + */ +/* @{ */ +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 +/* @} */ + +#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ +#ifdef __linux__ +#include +#define SDL_BYTEORDER __BYTE_ORDER +#else /* __linux __ */ +#if defined(__hppa__) || \ + defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ + (defined(__MIPS__) && defined(__MISPEB__)) || \ + defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ + defined(__sparc__) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#endif +#endif /* __linux __ */ +#endif /* !SDL_BYTEORDER */ + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_endian.h + */ +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + int result; + + __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); + return (Uint16)result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#else +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("bswap %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("bswapl %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + Uint32 result; + + __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); + __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); + __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); + return result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#else +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | + ((x >> 8) & 0x0000FF00) | (x >> 24))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + union + { + struct + { + Uint32 a, b; + } s; + Uint64 u; + } v; + v.u = x; + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), + "1"(v.s. + b)); + return v.u; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + __asm__("bswapq %0": "=r"(x):"0"(x)); + return x; +} +#else +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + Uint32 hi, lo; + + /* Separate into high and low 32-bit values and swap them */ + lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x >>= 32; + hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x = SDL_Swap32(lo); + x <<= 32; + x |= SDL_Swap32(hi); + return (x); +} +#endif + + +SDL_FORCE_INLINE float +SDL_SwapFloat(float x) +{ + union + { + float f; + Uint32 ui32; + } swapper; + swapper.f = x; + swapper.ui32 = SDL_Swap32(swapper.ui32); + return swapper.f; +} + + +/** + * \name Swap to native + * Byteswap item from the specified endianness to the native endianness. + */ +/* @{ */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) +#define SDL_SwapFloatLE(X) (X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) +#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) +#else +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) +#define SDL_SwapFloatBE(X) (X) +#endif +/* @} *//* Swap to native */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_endian_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_error.h b/code/SDL2/include/SDL_error.h new file mode 100644 index 00000000..5776cfa2 --- /dev/null +++ b/code/SDL2/include/SDL_error.h @@ -0,0 +1,76 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_error.h + * + * Simple error message routines for SDL. + */ + +#ifndef _SDL_error_h +#define _SDL_error_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Public functions */ +/* SDL_SetError() unconditionally returns -1. */ +extern DECLSPEC int SDLCALL SDL_SetError(const char *fmt, ...); +extern DECLSPEC const char *SDLCALL SDL_GetError(void); +extern DECLSPEC void SDLCALL SDL_ClearError(void); + +/** + * \name Internal error functions + * + * \internal + * Private error reporting function - used internally. + */ +/* @{ */ +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) +#define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) +typedef enum +{ + SDL_ENOMEM, + SDL_EFREAD, + SDL_EFWRITE, + SDL_EFSEEK, + SDL_UNSUPPORTED, + SDL_LASTERROR +} SDL_errorcode; +/* SDL_Error() unconditionally returns -1. */ +extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); +/* @} *//* Internal error functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_error_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_events.h b/code/SDL2/include/SDL_events.h new file mode 100644 index 00000000..fc5a145e --- /dev/null +++ b/code/SDL2/include/SDL_events.h @@ -0,0 +1,723 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_events.h + * + * Include file for SDL event handling. + */ + +#ifndef _SDL_events_h +#define _SDL_events_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_keyboard.h" +#include "SDL_mouse.h" +#include "SDL_joystick.h" +#include "SDL_gamecontroller.h" +#include "SDL_quit.h" +#include "SDL_gesture.h" +#include "SDL_touch.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* General keyboard/mouse state definitions */ +#define SDL_RELEASED 0 +#define SDL_PRESSED 1 + +/** + * \brief The types of events that can be delivered. + */ +typedef enum +{ + SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */ + + /* Application events */ + SDL_QUIT = 0x100, /**< User-requested quit */ + + /* These application events have special meaning on iOS, see README-ios.txt for details */ + SDL_APP_TERMINATING, /**< The application is being terminated by the OS + Called on iOS in applicationWillTerminate() + Called on Android in onDestroy() + */ + SDL_APP_LOWMEMORY, /**< The application is low on memory, free memory if possible. + Called on iOS in applicationDidReceiveMemoryWarning() + Called on Android in onLowMemory() + */ + SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background + Called on iOS in applicationWillResignActive() + Called on Android in onPause() + */ + SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time + Called on iOS in applicationDidEnterBackground() + Called on Android in onPause() + */ + SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground + Called on iOS in applicationWillEnterForeground() + Called on Android in onResume() + */ + SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive + Called on iOS in applicationDidBecomeActive() + Called on Android in onResume() + */ + + /* Window events */ + SDL_WINDOWEVENT = 0x200, /**< Window state change */ + SDL_SYSWMEVENT, /**< System specific event */ + + /* Keyboard events */ + SDL_KEYDOWN = 0x300, /**< Key pressed */ + SDL_KEYUP, /**< Key released */ + SDL_TEXTEDITING, /**< Keyboard text editing (composition) */ + SDL_TEXTINPUT, /**< Keyboard text input */ + + /* Mouse events */ + SDL_MOUSEMOTION = 0x400, /**< Mouse moved */ + SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ + SDL_MOUSEBUTTONUP, /**< Mouse button released */ + SDL_MOUSEWHEEL, /**< Mouse wheel motion */ + + /* Joystick events */ + SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */ + SDL_JOYBALLMOTION, /**< Joystick trackball motion */ + SDL_JOYHATMOTION, /**< Joystick hat position change */ + SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ + SDL_JOYBUTTONUP, /**< Joystick button released */ + SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */ + SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */ + + /* Game controller events */ + SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */ + SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */ + SDL_CONTROLLERBUTTONUP, /**< Game controller button released */ + SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */ + SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */ + SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */ + + /* Touch events */ + SDL_FINGERDOWN = 0x700, + SDL_FINGERUP, + SDL_FINGERMOTION, + + /* Gesture events */ + SDL_DOLLARGESTURE = 0x800, + SDL_DOLLARRECORD, + SDL_MULTIGESTURE, + + /* Clipboard events */ + SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */ + + /* Drag and drop events */ + SDL_DROPFILE = 0x1000, /**< The system requests a file open */ + + /* Render events */ + SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset */ + + /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, + * and should be allocated with SDL_RegisterEvents() + */ + SDL_USEREVENT = 0x8000, + + /** + * This last event is only for bounding internal arrays + */ + SDL_LASTEVENT = 0xFFFF +} SDL_EventType; + +/** + * \brief Fields shared by every event + */ +typedef struct SDL_CommonEvent +{ + Uint32 type; + Uint32 timestamp; +} SDL_CommonEvent; + +/** + * \brief Window state change event data (event.window.*) + */ +typedef struct SDL_WindowEvent +{ + Uint32 type; /**< ::SDL_WINDOWEVENT */ + Uint32 timestamp; + Uint32 windowID; /**< The associated window */ + Uint8 event; /**< ::SDL_WindowEventID */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint32 data1; /**< event dependent data */ + Sint32 data2; /**< event dependent data */ +} SDL_WindowEvent; + +/** + * \brief Keyboard button event structure (event.key.*) + */ +typedef struct SDL_KeyboardEvent +{ + Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ + Uint32 timestamp; + Uint32 windowID; /**< The window with keyboard focus, if any */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 repeat; /**< Non-zero if this is a key repeat */ + Uint8 padding2; + Uint8 padding3; + SDL_Keysym keysym; /**< The key that was pressed or released */ +} SDL_KeyboardEvent; + +#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32) +/** + * \brief Keyboard text editing event structure (event.edit.*) + */ +typedef struct SDL_TextEditingEvent +{ + Uint32 type; /**< ::SDL_TEXTEDITING */ + Uint32 timestamp; + Uint32 windowID; /**< The window with keyboard focus, if any */ + char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ + Sint32 start; /**< The start cursor of selected editing text */ + Sint32 length; /**< The length of selected editing text */ +} SDL_TextEditingEvent; + + +#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32) +/** + * \brief Keyboard text input event structure (event.text.*) + */ +typedef struct SDL_TextInputEvent +{ + Uint32 type; /**< ::SDL_TEXTINPUT */ + Uint32 timestamp; + Uint32 windowID; /**< The window with keyboard focus, if any */ + char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ +} SDL_TextInputEvent; + +/** + * \brief Mouse motion event structure (event.motion.*) + */ +typedef struct SDL_MouseMotionEvent +{ + Uint32 type; /**< ::SDL_MOUSEMOTION */ + Uint32 timestamp; + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Uint32 state; /**< The current button state */ + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ + Sint32 xrel; /**< The relative motion in the X direction */ + Sint32 yrel; /**< The relative motion in the Y direction */ +} SDL_MouseMotionEvent; + +/** + * \brief Mouse button event structure (event.button.*) + */ +typedef struct SDL_MouseButtonEvent +{ + Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ + Uint32 timestamp; + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Uint8 button; /**< The mouse button index */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */ + Uint8 padding1; + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ +} SDL_MouseButtonEvent; + +/** + * \brief Mouse wheel event structure (event.wheel.*) + */ +typedef struct SDL_MouseWheelEvent +{ + Uint32 type; /**< ::SDL_MOUSEWHEEL */ + Uint32 timestamp; + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */ + Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */ +} SDL_MouseWheelEvent; + +/** + * \brief Joystick axis motion event structure (event.jaxis.*) + */ +typedef struct SDL_JoyAxisEvent +{ + Uint32 type; /**< ::SDL_JOYAXISMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 axis; /**< The joystick axis index */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 value; /**< The axis value (range: -32768 to 32767) */ + Uint16 padding4; +} SDL_JoyAxisEvent; + +/** + * \brief Joystick trackball motion event structure (event.jball.*) + */ +typedef struct SDL_JoyBallEvent +{ + Uint32 type; /**< ::SDL_JOYBALLMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 ball; /**< The joystick trackball index */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 xrel; /**< The relative motion in the X direction */ + Sint16 yrel; /**< The relative motion in the Y direction */ +} SDL_JoyBallEvent; + +/** + * \brief Joystick hat position change event structure (event.jhat.*) + */ +typedef struct SDL_JoyHatEvent +{ + Uint32 type; /**< ::SDL_JOYHATMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 hat; /**< The joystick hat index */ + Uint8 value; /**< The hat position value. + * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP + * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT + * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN + * + * Note that zero means the POV is centered. + */ + Uint8 padding1; + Uint8 padding2; +} SDL_JoyHatEvent; + +/** + * \brief Joystick button event structure (event.jbutton.*) + */ +typedef struct SDL_JoyButtonEvent +{ + Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 button; /**< The joystick button index */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 padding1; + Uint8 padding2; +} SDL_JoyButtonEvent; + +/** + * \brief Joystick device event structure (event.jdevice.*) + */ +typedef struct SDL_JoyDeviceEvent +{ + Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */ + Uint32 timestamp; + Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */ +} SDL_JoyDeviceEvent; + + +/** + * \brief Game controller axis motion event structure (event.caxis.*) + */ +typedef struct SDL_ControllerAxisEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 value; /**< The axis value (range: -32768 to 32767) */ + Uint16 padding4; +} SDL_ControllerAxisEvent; + + +/** + * \brief Game controller button event structure (event.cbutton.*) + */ +typedef struct SDL_ControllerButtonEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 button; /**< The controller button (SDL_GameControllerButton) */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 padding1; + Uint8 padding2; +} SDL_ControllerButtonEvent; + + +/** + * \brief Controller device event structure (event.cdevice.*) + */ +typedef struct SDL_ControllerDeviceEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */ + Uint32 timestamp; + Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */ +} SDL_ControllerDeviceEvent; + + +/** + * \brief Touch finger event structure (event.tfinger.*) + */ +typedef struct SDL_TouchFingerEvent +{ + Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */ + Uint32 timestamp; + SDL_TouchID touchId; /**< The touch device id */ + SDL_FingerID fingerId; + float x; /**< Normalized in the range 0...1 */ + float y; /**< Normalized in the range 0...1 */ + float dx; /**< Normalized in the range 0...1 */ + float dy; /**< Normalized in the range 0...1 */ + float pressure; /**< Normalized in the range 0...1 */ +} SDL_TouchFingerEvent; + + +/** + * \brief Multiple Finger Gesture Event (event.mgesture.*) + */ +typedef struct SDL_MultiGestureEvent +{ + Uint32 type; /**< ::SDL_MULTIGESTURE */ + Uint32 timestamp; + SDL_TouchID touchId; /**< The touch device index */ + float dTheta; + float dDist; + float x; + float y; + Uint16 numFingers; + Uint16 padding; +} SDL_MultiGestureEvent; + + +/** + * \brief Dollar Gesture Event (event.dgesture.*) + */ +typedef struct SDL_DollarGestureEvent +{ + Uint32 type; /**< ::SDL_DOLLARGESTURE */ + Uint32 timestamp; + SDL_TouchID touchId; /**< The touch device id */ + SDL_GestureID gestureId; + Uint32 numFingers; + float error; + float x; /**< Normalized center of gesture */ + float y; /**< Normalized center of gesture */ +} SDL_DollarGestureEvent; + + +/** + * \brief An event used to request a file open by the system (event.drop.*) + * This event is disabled by default, you can enable it with SDL_EventState() + * \note If you enable this event, you must free the filename in the event. + */ +typedef struct SDL_DropEvent +{ + Uint32 type; /**< ::SDL_DROPFILE */ + Uint32 timestamp; + char *file; /**< The file name, which should be freed with SDL_free() */ +} SDL_DropEvent; + + +/** + * \brief The "quit requested" event + */ +typedef struct SDL_QuitEvent +{ + Uint32 type; /**< ::SDL_QUIT */ + Uint32 timestamp; +} SDL_QuitEvent; + +/** + * \brief OS Specific event + */ +typedef struct SDL_OSEvent +{ + Uint32 type; /**< ::SDL_QUIT */ + Uint32 timestamp; +} SDL_OSEvent; + +/** + * \brief A user-defined event type (event.user.*) + */ +typedef struct SDL_UserEvent +{ + Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */ + Uint32 timestamp; + Uint32 windowID; /**< The associated window if any */ + Sint32 code; /**< User defined event code */ + void *data1; /**< User defined data pointer */ + void *data2; /**< User defined data pointer */ +} SDL_UserEvent; + + +struct SDL_SysWMmsg; +typedef struct SDL_SysWMmsg SDL_SysWMmsg; + +/** + * \brief A video driver dependent system event (event.syswm.*) + * This event is disabled by default, you can enable it with SDL_EventState() + * + * \note If you want to use this event, you should include SDL_syswm.h. + */ +typedef struct SDL_SysWMEvent +{ + Uint32 type; /**< ::SDL_SYSWMEVENT */ + Uint32 timestamp; + SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */ +} SDL_SysWMEvent; + +/** + * \brief General event structure + */ +typedef union SDL_Event +{ + Uint32 type; /**< Event type, shared with all events */ + SDL_CommonEvent common; /**< Common event data */ + SDL_WindowEvent window; /**< Window event data */ + SDL_KeyboardEvent key; /**< Keyboard event data */ + SDL_TextEditingEvent edit; /**< Text editing event data */ + SDL_TextInputEvent text; /**< Text input event data */ + SDL_MouseMotionEvent motion; /**< Mouse motion event data */ + SDL_MouseButtonEvent button; /**< Mouse button event data */ + SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */ + SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */ + SDL_JoyBallEvent jball; /**< Joystick ball event data */ + SDL_JoyHatEvent jhat; /**< Joystick hat event data */ + SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ + SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ + SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */ + SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */ + SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */ + SDL_QuitEvent quit; /**< Quit request event data */ + SDL_UserEvent user; /**< Custom event data */ + SDL_SysWMEvent syswm; /**< System dependent window event data */ + SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ + SDL_MultiGestureEvent mgesture; /**< Gesture event data */ + SDL_DollarGestureEvent dgesture; /**< Gesture event data */ + SDL_DropEvent drop; /**< Drag and drop event data */ + + /* This is necessary for ABI compatibility between Visual C++ and GCC + Visual C++ will respect the push pack pragma and use 52 bytes for + this structure, and GCC will use the alignment of the largest datatype + within the union, which is 8 bytes. + + So... we'll add padding to force the size to be 56 bytes for both. + */ + Uint8 padding[56]; +} SDL_Event; + + +/* Function prototypes */ + +/** + * Pumps the event loop, gathering events from the input devices. + * + * This function updates the event queue and internal input device state. + * + * This should only be run in the thread that sets the video mode. + */ +extern DECLSPEC void SDLCALL SDL_PumpEvents(void); + +/* @{ */ +typedef enum +{ + SDL_ADDEVENT, + SDL_PEEKEVENT, + SDL_GETEVENT +} SDL_eventaction; + +/** + * Checks the event queue for messages and optionally returns them. + * + * If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to + * the back of the event queue. + * + * If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front + * of the event queue, within the specified minimum and maximum type, + * will be returned and will not be removed from the queue. + * + * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front + * of the event queue, within the specified minimum and maximum type, + * will be returned and will be removed from the queue. + * + * \return The number of events actually stored, or -1 if there was an error. + * + * This function is thread-safe. + */ +extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, + SDL_eventaction action, + Uint32 minType, Uint32 maxType); +/* @} */ + +/** + * Checks to see if certain event types are in the event queue. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type); +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType); + +/** + * This function clears events from the event queue + */ +extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type); +extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); + +/** + * \brief Polls for currently pending events. + * + * \return 1 if there are any pending events, or 0 if there are none available. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event); + +/** + * \brief Waits indefinitely for the next available event. + * + * \return 1, or 0 if there was an error while waiting for events. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event); + +/** + * \brief Waits until the specified timeout (in milliseconds) for the next + * available event. + * + * \return 1, or 0 if there was an error while waiting for events. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + * \param timeout The timeout (in milliseconds) to wait for next event. + */ +extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event, + int timeout); + +/** + * \brief Add an event to the event queue. + * + * \return 1 on success, 0 if the event was filtered, or -1 if the event queue + * was full or there was some other error. + */ +extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event); + +typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event); + +/** + * Sets up a filter to process all events before they change internal state and + * are posted to the internal event queue. + * + * The filter is prototyped as: + * \code + * int SDL_EventFilter(void *userdata, SDL_Event * event); + * \endcode + * + * If the filter returns 1, then the event will be added to the internal queue. + * If it returns 0, then the event will be dropped from the queue, but the + * internal state will still be updated. This allows selective filtering of + * dynamically arriving events. + * + * \warning Be very careful of what you do in the event filter function, as + * it may run in a different thread! + * + * There is one caveat when dealing with the ::SDL_QuitEvent event type. The + * event filter is only called when the window manager desires to close the + * application window. If the event filter returns 1, then the window will + * be closed, otherwise the window will remain open if possible. + * + * If the quit event is generated by an interrupt signal, it will bypass the + * internal queue and be delivered to the application at the next event poll. + */ +extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, + void *userdata); + +/** + * Return the current event filter - can be used to "chain" filters. + * If there is no event filter set, this function returns SDL_FALSE. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter, + void **userdata); + +/** + * Add a function which is called when an event is added to the queue. + */ +extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, + void *userdata); + +/** + * Remove an event watch function added with SDL_AddEventWatch() + */ +extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, + void *userdata); + +/** + * Run the filter function on the current event queue, removing any + * events for which the filter returns 0. + */ +extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, + void *userdata); + +/* @{ */ +#define SDL_QUERY -1 +#define SDL_IGNORE 0 +#define SDL_DISABLE 0 +#define SDL_ENABLE 1 + +/** + * This function allows you to set the state of processing certain events. + * - If \c state is set to ::SDL_IGNORE, that event will be automatically + * dropped from the event queue and will not event be filtered. + * - If \c state is set to ::SDL_ENABLE, that event will be processed + * normally. + * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the + * current processing state of the specified event. + */ +extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); +/* @} */ +#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY) + +/** + * This function allocates a set of user-defined events, and returns + * the beginning event number for that set of events. + * + * If there aren't enough user-defined events left, this function + * returns (Uint32)-1 + */ +extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_events_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_filesystem.h b/code/SDL2/include/SDL_filesystem.h new file mode 100644 index 00000000..de3e227d --- /dev/null +++ b/code/SDL2/include/SDL_filesystem.h @@ -0,0 +1,136 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_filesystem.h + * + * \brief Include file for filesystem SDL API functions + */ + +#ifndef _SDL_filesystem_h +#define _SDL_filesystem_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Get the path where the application resides. + * + * Get the "base path". This is the directory where the application was run + * from, which is probably the installation directory, and may or may not + * be the process's current working directory. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * Some platforms can't determine the application's path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \return String of base dir in UTF-8 encoding, or NULL on error. + * + * \sa SDL_GetPrefPath + */ +extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); + +/** + * \brief Get the user-and-app-specific path where files can be written. + * + * Get the "pref dir". This is meant to be where users can write personal + * files (preferences and save games, etc) that are specific to your + * application. This directory is unique per user, per application. + * + * This function will decide the appropriate location in the native filesystem, + * create the directory if necessary, and return a string of the absolute + * path to the directory in UTF-8 encoding. + * + * On Windows, the string might look like: + * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" + * + * On Linux, the string might look like: + * "/home/bob/.local/share/My Program Name/" + * + * On Mac OS X, the string might look like: + * "/Users/bob/Library/Application Support/My Program Name/" + * + * (etc.) + * + * You specify the name of your organization (if it's not a real organization, + * your name or an Internet domain you own might do) and the name of your + * application. These should be untranslated proper names. + * + * Both the org and app strings may become part of a directory name, so + * please follow these rules: + * + * - Try to use the same org string (including case-sensitivity) for + * all your applications that use this function. + * - Always use a unique app string for each one, and make sure it never + * changes for an app once you've decided on it. + * - Unicode characters are legal, as long as it's UTF-8 encoded, but... + * - ...only use letters, numbers, and spaces. Avoid punctuation like + * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * You should assume the path returned by this function is the only safe + * place to write files (and that SDL_GetBasePath(), while it might be + * writable, or even the parent of the returned path, aren't where you + * should be writing things). + * + * Some platforms can't determine the pref path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \param org The name of your organization. + * \param app The name of your application. + * \return UTF-8 string of user dir in platform-dependent notation. NULL + * if there's a problem (creating directory failed, etc). + * + * \sa SDL_GetBasePath + */ +extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_system_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_gamecontroller.h b/code/SDL2/include/SDL_gamecontroller.h new file mode 100644 index 00000000..b00ad713 --- /dev/null +++ b/code/SDL2/include/SDL_gamecontroller.h @@ -0,0 +1,316 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_gamecontroller.h + * + * Include file for SDL game controller event handling + */ + +#ifndef _SDL_gamecontroller_h +#define _SDL_gamecontroller_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_rwops.h" +#include "SDL_joystick.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_gamecontroller.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + * for game controllers, and load appropriate drivers. + * + * If you would like to receive controller updates while the application + * is in the background, you should set the following hint before calling + * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + */ + +/* The gamecontroller structure used to identify an SDL game controller */ +struct _SDL_GameController; +typedef struct _SDL_GameController SDL_GameController; + + +typedef enum +{ + SDL_CONTROLLER_BINDTYPE_NONE = 0, + SDL_CONTROLLER_BINDTYPE_BUTTON, + SDL_CONTROLLER_BINDTYPE_AXIS, + SDL_CONTROLLER_BINDTYPE_HAT +} SDL_GameControllerBindType; + +/** + * Get the SDL joystick layer binding for this controller button/axis mapping + */ +typedef struct SDL_GameControllerButtonBind +{ + SDL_GameControllerBindType bindType; + union + { + int button; + int axis; + struct { + int hat; + int hat_mask; + } hat; + } value; + +} SDL_GameControllerButtonBind; + + +/** + * To count the number of game controllers in the system for the following: + * int nJoysticks = SDL_NumJoysticks(); + * int nGameControllers = 0; + * for ( int i = 0; i < nJoysticks; i++ ) { + * if ( SDL_IsGameController(i) ) { + * nGameControllers++; + * } + * } + * + * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is: + * guid,name,mappings + * + * Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones. + * Under Windows there is a reserved GUID of "xinput" that covers any XInput devices. + * The mapping format for joystick is: + * bX - a joystick button, index X + * hX.Y - hat X with value Y + * aX - axis X of the joystick + * Buttons can be used as a controller axis and vice versa. + * + * This string shows an example of a valid mapping for a controller + * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", + * + */ + +/** + * Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform() + * A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt + * + * If \c freerw is non-zero, the stream will be closed after being read. + * + * \return number of mappings added, -1 on error + */ +extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW( SDL_RWops * rw, int freerw ); + +/** + * Load a set of mappings from a file, filtered by the current SDL_GetPlatform() + * + * Convenience macro. + */ +#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1) + +/** + * Add or update an existing mapping configuration + * + * \return 1 if mapping is added, 0 if updated, -1 on error + */ +extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping( const char* mappingString ); + +/** + * Get a mapping string for a GUID + * + * \return the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available + */ +extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid ); + +/** + * Get a mapping string for an open GameController + * + * \return the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available + */ +extern DECLSPEC char * SDLCALL SDL_GameControllerMapping( SDL_GameController * gamecontroller ); + +/** + * Is the joystick on this index supported by the game controller interface? + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index); + + +/** + * Get the implementation dependent name of a game controller. + * This can be called before any controllers are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); + +/** + * Open a game controller for use. + * The index passed as an argument refers to the N'th game controller on the system. + * This index is the value which will identify this controller in future controller + * events. + * + * \return A controller identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index); + +/** + * Return the name for this currently opened controller + */ +extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); + +/** + * Returns SDL_TRUE if the controller has been opened and currently connected, + * or SDL_FALSE if it has not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller); + +/** + * Get the underlying joystick object used by a controller + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); + +/** + * Enable/disable controller event polling. + * + * If controller events are disabled, you must call SDL_GameControllerUpdate() + * yourself and check the state of the controller when you want controller + * information. + * + * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); + +/** + * Update the current state of the open game controllers. + * + * This is called automatically by the event loop if any game controller + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); + + +/** + * The list of axes available from a controller + */ +typedef enum +{ + SDL_CONTROLLER_AXIS_INVALID = -1, + SDL_CONTROLLER_AXIS_LEFTX, + SDL_CONTROLLER_AXIS_LEFTY, + SDL_CONTROLLER_AXIS_RIGHTX, + SDL_CONTROLLER_AXIS_RIGHTY, + SDL_CONTROLLER_AXIS_TRIGGERLEFT, + SDL_CONTROLLER_AXIS_TRIGGERRIGHT, + SDL_CONTROLLER_AXIS_MAX +} SDL_GameControllerAxis; + +/** + * turn this string into a axis mapping + */ +extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString); + +/** + * turn this axis enum into a string mapping + */ +extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis); + +/** + * Get the SDL joystick layer binding for this controller button mapping + */ +extern DECLSPEC SDL_GameControllerButtonBind SDLCALL +SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller, + SDL_GameControllerAxis axis); + +/** + * Get the current state of an axis control on a game controller. + * + * The state is a value ranging from -32768 to 32767. + * + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL +SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, + SDL_GameControllerAxis axis); + +/** + * The list of buttons available from a controller + */ +typedef enum +{ + SDL_CONTROLLER_BUTTON_INVALID = -1, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + SDL_CONTROLLER_BUTTON_MAX +} SDL_GameControllerButton; + +/** + * turn this string into a button mapping + */ +extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString); + +/** + * turn this button enum into a string mapping + */ +extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button); + +/** + * Get the SDL joystick layer binding for this controller button mapping + */ +extern DECLSPEC SDL_GameControllerButtonBind SDLCALL +SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller, + SDL_GameControllerButton button); + + +/** + * Get the current state of a button on a game controller. + * + * The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, + SDL_GameControllerButton button); + +/** + * Close a controller previously opened with SDL_GameControllerOpen(). + */ +extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_gamecontroller_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_gesture.h b/code/SDL2/include/SDL_gesture.h new file mode 100644 index 00000000..dbc16924 --- /dev/null +++ b/code/SDL2/include/SDL_gesture.h @@ -0,0 +1,87 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_gesture.h + * + * Include file for SDL gesture event handling. + */ + +#ifndef _SDL_gesture_h +#define _SDL_gesture_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "SDL_touch.h" + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef Sint64 SDL_GestureID; + +/* Function prototypes */ + +/** + * \brief Begin Recording a gesture on the specified touch, or all touches (-1) + * + * + */ +extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); + + +/** + * \brief Save all currently loaded Dollar Gesture templates + * + * + */ +extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); + +/** + * \brief Save a currently loaded Dollar Gesture template + * + * + */ +extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); + + +/** + * \brief Load Dollar Gesture templates from a file + * + * + */ +extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_gesture_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_haptic.h b/code/SDL2/include/SDL_haptic.h new file mode 100644 index 00000000..234975ab --- /dev/null +++ b/code/SDL2/include/SDL_haptic.h @@ -0,0 +1,1225 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_haptic.h + * + * \brief The SDL Haptic subsystem allows you to control haptic (force feedback) + * devices. + * + * The basic usage is as follows: + * - Initialize the Subsystem (::SDL_INIT_HAPTIC). + * - Open a Haptic Device. + * - SDL_HapticOpen() to open from index. + * - SDL_HapticOpenFromJoystick() to open from an existing joystick. + * - Create an effect (::SDL_HapticEffect). + * - Upload the effect with SDL_HapticNewEffect(). + * - Run the effect with SDL_HapticRunEffect(). + * - (optional) Free the effect with SDL_HapticDestroyEffect(). + * - Close the haptic device with SDL_HapticClose(). + * + * \par Simple rumble example: + * \code + * SDL_Haptic *haptic; + * + * // Open the device + * haptic = SDL_HapticOpen( 0 ); + * if (haptic == NULL) + * return -1; + * + * // Initialize simple rumble + * if (SDL_HapticRumbleInit( haptic ) != 0) + * return -1; + * + * // Play effect at 50% strength for 2 seconds + * if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0) + * return -1; + * SDL_Delay( 2000 ); + * + * // Clean up + * SDL_HapticClose( haptic ); + * \endcode + * + * \par Complete example: + * \code + * int test_haptic( SDL_Joystick * joystick ) { + * SDL_Haptic *haptic; + * SDL_HapticEffect effect; + * int effect_id; + * + * // Open the device + * haptic = SDL_HapticOpenFromJoystick( joystick ); + * if (haptic == NULL) return -1; // Most likely joystick isn't haptic + * + * // See if it can do sine waves + * if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0) { + * SDL_HapticClose(haptic); // No sine effect + * return -1; + * } + * + * // Create the effect + * memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default + * effect.type = SDL_HAPTIC_SINE; + * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates + * effect.periodic.direction.dir[0] = 18000; // Force comes from south + * effect.periodic.period = 1000; // 1000 ms + * effect.periodic.magnitude = 20000; // 20000/32767 strength + * effect.periodic.length = 5000; // 5 seconds long + * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength + * effect.periodic.fade_length = 1000; // Takes 1 second to fade away + * + * // Upload the effect + * effect_id = SDL_HapticNewEffect( haptic, &effect ); + * + * // Test the effect + * SDL_HapticRunEffect( haptic, effect_id, 1 ); + * SDL_Delay( 5000); // Wait for the effect to finish + * + * // We destroy the effect, although closing the device also does this + * SDL_HapticDestroyEffect( haptic, effect_id ); + * + * // Close the device + * SDL_HapticClose(haptic); + * + * return 0; // Success + * } + * \endcode + * + * You can also find out more information on my blog: + * http://bobbens.dyndns.org/journal/2010/sdl_haptic/ + * + * \author Edgar Simo Serra + */ + +#ifndef _SDL_haptic_h +#define _SDL_haptic_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_joystick.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * \typedef SDL_Haptic + * + * \brief The haptic structure used to identify an SDL haptic. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticOpenFromJoystick + * \sa SDL_HapticClose + */ +struct _SDL_Haptic; +typedef struct _SDL_Haptic SDL_Haptic; + + +/** + * \name Haptic features + * + * Different haptic features a device can have. + */ +/* @{ */ + +/** + * \name Haptic effects + */ +/* @{ */ + +/** + * \brief Constant effect supported. + * + * Constant haptic effect. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_CONSTANT (1<<0) + +/** + * \brief Sine wave effect supported. + * + * Periodic haptic effect that simulates sine waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SINE (1<<1) + +/** + * \brief Left/Right effect supported. + * + * Haptic effect for direct control over high/low frequency motors. + * + * \sa SDL_HapticLeftRight + * \warning this value was SDL_HAPTIC_SQUARE right before 2.0.0 shipped. Sorry, + * we ran out of bits, and this is important for XInput devices. + */ +#define SDL_HAPTIC_LEFTRIGHT (1<<2) + +/* !!! FIXME: put this back when we have more bits in 2.1 */ +/* #define SDL_HAPTIC_SQUARE (1<<2) */ + +/** + * \brief Triangle wave effect supported. + * + * Periodic haptic effect that simulates triangular waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_TRIANGLE (1<<3) + +/** + * \brief Sawtoothup wave effect supported. + * + * Periodic haptic effect that simulates saw tooth up waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SAWTOOTHUP (1<<4) + +/** + * \brief Sawtoothdown wave effect supported. + * + * Periodic haptic effect that simulates saw tooth down waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SAWTOOTHDOWN (1<<5) + +/** + * \brief Ramp effect supported. + * + * Ramp haptic effect. + * + * \sa SDL_HapticRamp + */ +#define SDL_HAPTIC_RAMP (1<<6) + +/** + * \brief Spring effect supported - uses axes position. + * + * Condition haptic effect that simulates a spring. Effect is based on the + * axes position. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_SPRING (1<<7) + +/** + * \brief Damper effect supported - uses axes velocity. + * + * Condition haptic effect that simulates dampening. Effect is based on the + * axes velocity. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_DAMPER (1<<8) + +/** + * \brief Inertia effect supported - uses axes acceleration. + * + * Condition haptic effect that simulates inertia. Effect is based on the axes + * acceleration. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_INERTIA (1<<9) + +/** + * \brief Friction effect supported - uses axes movement. + * + * Condition haptic effect that simulates friction. Effect is based on the + * axes movement. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_FRICTION (1<<10) + +/** + * \brief Custom effect is supported. + * + * User defined custom haptic effect. + */ +#define SDL_HAPTIC_CUSTOM (1<<11) + +/* @} *//* Haptic effects */ + +/* These last few are features the device has, not effects */ + +/** + * \brief Device can set global gain. + * + * Device supports setting the global gain. + * + * \sa SDL_HapticSetGain + */ +#define SDL_HAPTIC_GAIN (1<<12) + +/** + * \brief Device can set autocenter. + * + * Device supports setting autocenter. + * + * \sa SDL_HapticSetAutocenter + */ +#define SDL_HAPTIC_AUTOCENTER (1<<13) + +/** + * \brief Device can be queried for effect status. + * + * Device can be queried for effect status. + * + * \sa SDL_HapticGetEffectStatus + */ +#define SDL_HAPTIC_STATUS (1<<14) + +/** + * \brief Device can be paused. + * + * \sa SDL_HapticPause + * \sa SDL_HapticUnpause + */ +#define SDL_HAPTIC_PAUSE (1<<15) + + +/** + * \name Direction encodings + */ +/* @{ */ + +/** + * \brief Uses polar coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_POLAR 0 + +/** + * \brief Uses cartesian coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_CARTESIAN 1 + +/** + * \brief Uses spherical coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_SPHERICAL 2 + +/* @} *//* Direction encodings */ + +/* @} *//* Haptic features */ + +/* + * Misc defines. + */ + +/** + * \brief Used to play a device an infinite number of times. + * + * \sa SDL_HapticRunEffect + */ +#define SDL_HAPTIC_INFINITY 4294967295U + + +/** + * \brief Structure that represents a haptic direction. + * + * Directions can be specified by: + * - ::SDL_HAPTIC_POLAR : Specified by polar coordinates. + * - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. + * - ::SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates. + * + * Cardinal directions of the haptic device are relative to the positioning + * of the device. North is considered to be away from the user. + * + * The following diagram represents the cardinal directions: + * \verbatim + .--. + |__| .-------. + |=.| |.-----.| + |--| || || + | | |'-----'| + |__|~')_____(' + [ COMPUTER ] + + + North (0,-1) + ^ + | + | + (1,0) West <----[ HAPTIC ]----> East (-1,0) + | + | + v + South (0,1) + + + [ USER ] + \|||/ + (o o) + ---ooO-(_)-Ooo--- + \endverbatim + * + * If type is ::SDL_HAPTIC_POLAR, direction is encoded by hundredths of a + * degree starting north and turning clockwise. ::SDL_HAPTIC_POLAR only uses + * the first \c dir parameter. The cardinal directions would be: + * - North: 0 (0 degrees) + * - East: 9000 (90 degrees) + * - South: 18000 (180 degrees) + * - West: 27000 (270 degrees) + * + * If type is ::SDL_HAPTIC_CARTESIAN, direction is encoded by three positions + * (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses + * the first three \c dir parameters. The cardinal directions would be: + * - North: 0,-1, 0 + * - East: -1, 0, 0 + * - South: 0, 1, 0 + * - West: 1, 0, 0 + * + * The Z axis represents the height of the effect if supported, otherwise + * it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you + * can use any multiple you want, only the direction matters. + * + * If type is ::SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. + * The first two \c dir parameters are used. The \c dir parameters are as + * follows (all values are in hundredths of degrees): + * - Degrees from (1, 0) rotated towards (0, 1). + * - Degrees towards (0, 0, 1) (device needs at least 3 axes). + * + * + * Example of force coming from the south with all encodings (force coming + * from the south means the user will have to pull the stick to counteract): + * \code + * SDL_HapticDirection direction; + * + * // Cartesian directions + * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding. + * direction.dir[0] = 0; // X position + * direction.dir[1] = 1; // Y position + * // Assuming the device has 2 axes, we don't need to specify third parameter. + * + * // Polar directions + * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding. + * direction.dir[0] = 18000; // Polar only uses first parameter + * + * // Spherical coordinates + * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding + * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters. + * \endcode + * + * \sa SDL_HAPTIC_POLAR + * \sa SDL_HAPTIC_CARTESIAN + * \sa SDL_HAPTIC_SPHERICAL + * \sa SDL_HapticEffect + * \sa SDL_HapticNumAxes + */ +typedef struct SDL_HapticDirection +{ + Uint8 type; /**< The type of encoding. */ + Sint32 dir[3]; /**< The encoded direction. */ +} SDL_HapticDirection; + + +/** + * \brief A structure containing a template for a Constant effect. + * + * The struct is exclusive to the ::SDL_HAPTIC_CONSTANT effect. + * + * A constant effect applies a constant force in the specified direction + * to the joystick. + * + * \sa SDL_HAPTIC_CONSTANT + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticConstant +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_CONSTANT */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Constant */ + Sint16 level; /**< Strength of the constant effect. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticConstant; + +/** + * \brief A structure containing a template for a Periodic effect. + * + * The struct handles the following effects: + * - ::SDL_HAPTIC_SINE + * - ::SDL_HAPTIC_LEFTRIGHT + * - ::SDL_HAPTIC_TRIANGLE + * - ::SDL_HAPTIC_SAWTOOTHUP + * - ::SDL_HAPTIC_SAWTOOTHDOWN + * + * A periodic effect consists in a wave-shaped effect that repeats itself + * over time. The type determines the shape of the wave and the parameters + * determine the dimensions of the wave. + * + * Phase is given by hundredth of a cycle meaning that giving the phase a value + * of 9000 will displace it 25% of its period. Here are sample values: + * - 0: No phase displacement. + * - 9000: Displaced 25% of its period. + * - 18000: Displaced 50% of its period. + * - 27000: Displaced 75% of its period. + * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred. + * + * Examples: + * \verbatim + SDL_HAPTIC_SINE + __ __ __ __ + / \ / \ / \ / + / \__/ \__/ \__/ + + SDL_HAPTIC_SQUARE + __ __ __ __ __ + | | | | | | | | | | + | |__| |__| |__| |__| | + + SDL_HAPTIC_TRIANGLE + /\ /\ /\ /\ /\ + / \ / \ / \ / \ / + / \/ \/ \/ \/ + + SDL_HAPTIC_SAWTOOTHUP + /| /| /| /| /| /| /| + / | / | / | / | / | / | / | + / |/ |/ |/ |/ |/ |/ | + + SDL_HAPTIC_SAWTOOTHDOWN + \ |\ |\ |\ |\ |\ |\ | + \ | \ | \ | \ | \ | \ | \ | + \| \| \| \| \| \| \| + \endverbatim + * + * \sa SDL_HAPTIC_SINE + * \sa SDL_HAPTIC_LEFTRIGHT + * \sa SDL_HAPTIC_TRIANGLE + * \sa SDL_HAPTIC_SAWTOOTHUP + * \sa SDL_HAPTIC_SAWTOOTHDOWN + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticPeriodic +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_SINE, ::SDL_HAPTIC_LEFTRIGHT, + ::SDL_HAPTIC_TRIANGLE, ::SDL_HAPTIC_SAWTOOTHUP or + ::SDL_HAPTIC_SAWTOOTHDOWN */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Periodic */ + Uint16 period; /**< Period of the wave. */ + Sint16 magnitude; /**< Peak value. */ + Sint16 offset; /**< Mean value of the wave. */ + Uint16 phase; /**< Horizontal shift given by hundredth of a cycle. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticPeriodic; + +/** + * \brief A structure containing a template for a Condition effect. + * + * The struct handles the following effects: + * - ::SDL_HAPTIC_SPRING: Effect based on axes position. + * - ::SDL_HAPTIC_DAMPER: Effect based on axes velocity. + * - ::SDL_HAPTIC_INERTIA: Effect based on axes acceleration. + * - ::SDL_HAPTIC_FRICTION: Effect based on axes movement. + * + * Direction is handled by condition internals instead of a direction member. + * The condition effect specific members have three parameters. The first + * refers to the X axis, the second refers to the Y axis and the third + * refers to the Z axis. The right terms refer to the positive side of the + * axis and the left terms refer to the negative side of the axis. Please + * refer to the ::SDL_HapticDirection diagram for which side is positive and + * which is negative. + * + * \sa SDL_HapticDirection + * \sa SDL_HAPTIC_SPRING + * \sa SDL_HAPTIC_DAMPER + * \sa SDL_HAPTIC_INERTIA + * \sa SDL_HAPTIC_FRICTION + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticCondition +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_SPRING, ::SDL_HAPTIC_DAMPER, + ::SDL_HAPTIC_INERTIA or ::SDL_HAPTIC_FRICTION */ + SDL_HapticDirection direction; /**< Direction of the effect - Not used ATM. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Condition */ + Uint16 right_sat[3]; /**< Level when joystick is to the positive side. */ + Uint16 left_sat[3]; /**< Level when joystick is to the negative side. */ + Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */ + Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */ + Uint16 deadband[3]; /**< Size of the dead zone. */ + Sint16 center[3]; /**< Position of the dead zone. */ +} SDL_HapticCondition; + +/** + * \brief A structure containing a template for a Ramp effect. + * + * This struct is exclusively for the ::SDL_HAPTIC_RAMP effect. + * + * The ramp effect starts at start strength and ends at end strength. + * It augments in linear fashion. If you use attack and fade with a ramp + * the effects get added to the ramp effect making the effect become + * quadratic instead of linear. + * + * \sa SDL_HAPTIC_RAMP + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticRamp +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_RAMP */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Ramp */ + Sint16 start; /**< Beginning strength level. */ + Sint16 end; /**< Ending strength level. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticRamp; + +/** + * \brief A structure containing a template for a Left/Right effect. + * + * This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect. + * + * The Left/Right effect is used to explicitly control the large and small + * motors, commonly found in modern game controllers. One motor is high + * frequency, the other is low frequency. + * + * \sa SDL_HAPTIC_LEFTRIGHT + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticLeftRight +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_LEFTRIGHT */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + + /* Rumble */ + Uint16 large_magnitude; /**< Control of the large controller motor. */ + Uint16 small_magnitude; /**< Control of the small controller motor. */ +} SDL_HapticLeftRight; + +/** + * \brief A structure containing a template for the ::SDL_HAPTIC_CUSTOM effect. + * + * A custom force feedback effect is much like a periodic effect, where the + * application can define its exact shape. You will have to allocate the + * data yourself. Data should consist of channels * samples Uint16 samples. + * + * If channels is one, the effect is rotated using the defined direction. + * Otherwise it uses the samples in data for the different axes. + * + * \sa SDL_HAPTIC_CUSTOM + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticCustom +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_CUSTOM */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Custom */ + Uint8 channels; /**< Axes to use, minimum of one. */ + Uint16 period; /**< Sample periods. */ + Uint16 samples; /**< Amount of samples. */ + Uint16 *data; /**< Should contain channels*samples items. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticCustom; + +/** + * \brief The generic template for any haptic effect. + * + * All values max at 32767 (0x7FFF). Signed values also can be negative. + * Time values unless specified otherwise are in milliseconds. + * + * You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767 + * value. Neither delay, interval, attack_length nor fade_length support + * ::SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends. + * + * Additionally, the ::SDL_HAPTIC_RAMP effect does not support a duration of + * ::SDL_HAPTIC_INFINITY. + * + * Button triggers may not be supported on all devices, it is advised to not + * use them if possible. Buttons start at index 1 instead of index 0 like + * the joystick. + * + * If both attack_length and fade_level are 0, the envelope is not used, + * otherwise both values are used. + * + * Common parts: + * \code + * // Replay - All effects have this + * Uint32 length; // Duration of effect (ms). + * Uint16 delay; // Delay before starting effect. + * + * // Trigger - All effects have this + * Uint16 button; // Button that triggers effect. + * Uint16 interval; // How soon before effect can be triggered again. + * + * // Envelope - All effects except condition effects have this + * Uint16 attack_length; // Duration of the attack (ms). + * Uint16 attack_level; // Level at the start of the attack. + * Uint16 fade_length; // Duration of the fade out (ms). + * Uint16 fade_level; // Level at the end of the fade. + * \endcode + * + * + * Here we have an example of a constant effect evolution in time: + * \verbatim + Strength + ^ + | + | effect level --> _________________ + | / \ + | / \ + | / \ + | / \ + | attack_level --> | \ + | | | <--- fade_level + | + +--------------------------------------------------> Time + [--] [---] + attack_length fade_length + + [------------------][-----------------------] + delay length + \endverbatim + * + * Note either the attack_level or the fade_level may be above the actual + * effect level. + * + * \sa SDL_HapticConstant + * \sa SDL_HapticPeriodic + * \sa SDL_HapticCondition + * \sa SDL_HapticRamp + * \sa SDL_HapticLeftRight + * \sa SDL_HapticCustom + */ +typedef union SDL_HapticEffect +{ + /* Common for all force feedback effects */ + Uint16 type; /**< Effect type. */ + SDL_HapticConstant constant; /**< Constant effect. */ + SDL_HapticPeriodic periodic; /**< Periodic effect. */ + SDL_HapticCondition condition; /**< Condition effect. */ + SDL_HapticRamp ramp; /**< Ramp effect. */ + SDL_HapticLeftRight leftright; /**< Left/Right effect. */ + SDL_HapticCustom custom; /**< Custom effect. */ +} SDL_HapticEffect; + + +/* Function prototypes */ +/** + * \brief Count the number of haptic devices attached to the system. + * + * \return Number of haptic devices detected on the system. + */ +extern DECLSPEC int SDLCALL SDL_NumHaptics(void); + +/** + * \brief Get the implementation dependent name of a Haptic device. + * + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + * + * \param device_index Index of the device to get its name. + * \return Name of the device or NULL on error. + * + * \sa SDL_NumHaptics + */ +extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index); + +/** + * \brief Opens a Haptic device for usage. + * + * The index passed as an argument refers to the N'th Haptic device on this + * system. + * + * When opening a haptic device, its gain will be set to maximum and + * autocenter will be disabled. To modify these values use + * SDL_HapticSetGain() and SDL_HapticSetAutocenter(). + * + * \param device_index Index of the device to open. + * \return Device identifier or NULL on error. + * + * \sa SDL_HapticIndex + * \sa SDL_HapticOpenFromMouse + * \sa SDL_HapticOpenFromJoystick + * \sa SDL_HapticClose + * \sa SDL_HapticSetGain + * \sa SDL_HapticSetAutocenter + * \sa SDL_HapticPause + * \sa SDL_HapticStopAll + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index); + +/** + * \brief Checks if the haptic device at index has been opened. + * + * \param device_index Index to check to see if it has been opened. + * \return 1 if it has been opened or 0 if it hasn't. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticIndex + */ +extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index); + +/** + * \brief Gets the index of a haptic device. + * + * \param haptic Haptic device to get the index of. + * \return The index of the haptic device or -1 on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticOpened + */ +extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic); + +/** + * \brief Gets whether or not the current mouse has haptic capabilities. + * + * \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't. + * + * \sa SDL_HapticOpenFromMouse + */ +extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void); + +/** + * \brief Tries to open a haptic device from the current mouse. + * + * \return The haptic device identifier or NULL on error. + * + * \sa SDL_MouseIsHaptic + * \sa SDL_HapticOpen + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void); + +/** + * \brief Checks to see if a joystick has haptic features. + * + * \param joystick Joystick to test for haptic capabilities. + * \return 1 if the joystick is haptic, 0 if it isn't + * or -1 if an error ocurred. + * + * \sa SDL_HapticOpenFromJoystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick); + +/** + * \brief Opens a Haptic device for usage from a Joystick device. + * + * You must still close the haptic device seperately. It will not be closed + * with the joystick. + * + * When opening from a joystick you should first close the haptic device before + * closing the joystick device. If not, on some implementations the haptic + * device will also get unallocated and you'll be unable to use force feedback + * on that device. + * + * \param joystick Joystick to create a haptic device from. + * \return A valid haptic device identifier on success or NULL on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticClose + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick * + joystick); + +/** + * \brief Closes a Haptic device previously opened with SDL_HapticOpen(). + * + * \param haptic Haptic device to close. + */ +extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic); + +/** + * \brief Returns the number of effects a haptic device can store. + * + * On some platforms this isn't fully supported, and therefore is an + * approximation. Always check to see if your created effect was actually + * created and do not rely solely on SDL_HapticNumEffects(). + * + * \param haptic The haptic device to query effect max. + * \return The number of effects the haptic device can store or + * -1 on error. + * + * \sa SDL_HapticNumEffectsPlaying + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic); + +/** + * \brief Returns the number of effects a haptic device can play at the same + * time. + * + * This is not supported on all platforms, but will always return a value. + * Added here for the sake of completeness. + * + * \param haptic The haptic device to query maximum playing effects. + * \return The number of effects the haptic device can play at the same time + * or -1 on error. + * + * \sa SDL_HapticNumEffects + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic); + +/** + * \brief Gets the haptic devices supported features in bitwise matter. + * + * Example: + * \code + * if (SDL_HapticQuery(haptic) & SDL_HAPTIC_CONSTANT) { + * printf("We have constant haptic effect!"); + * } + * \endcode + * + * \param haptic The haptic device to query. + * \return Haptic features in bitwise manner (OR'd). + * + * \sa SDL_HapticNumEffects + * \sa SDL_HapticEffectSupported + */ +extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic); + + +/** + * \brief Gets the number of haptic axes the device has. + * + * \sa SDL_HapticDirection + */ +extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic); + +/** + * \brief Checks to see if effect is supported by haptic. + * + * \param haptic Haptic device to check on. + * \param effect Effect to check to see if it is supported. + * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * + * \sa SDL_HapticQuery + * \sa SDL_HapticNewEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic, + SDL_HapticEffect * + effect); + +/** + * \brief Creates a new haptic effect on the device. + * + * \param haptic Haptic device to create the effect on. + * \param effect Properties of the effect to create. + * \return The id of the effect on success or -1 on error. + * + * \sa SDL_HapticUpdateEffect + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic, + SDL_HapticEffect * effect); + +/** + * \brief Updates the properties of an effect. + * + * Can be used dynamically, although behaviour when dynamically changing + * direction may be strange. Specifically the effect may reupload itself + * and start playing from the start. You cannot change the type either when + * running SDL_HapticUpdateEffect(). + * + * \param haptic Haptic device that has the effect. + * \param effect Effect to update. + * \param data New effect properties to use. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticNewEffect + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic, + int effect, + SDL_HapticEffect * data); + +/** + * \brief Runs the haptic effect on its associated haptic device. + * + * If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over + * repeating the envelope (attack and fade) every time. If you only want the + * effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length + * parameter. + * + * \param haptic Haptic device to run the effect on. + * \param effect Identifier of the haptic effect to run. + * \param iterations Number of iterations to run the effect. Use + * ::SDL_HAPTIC_INFINITY for infinity. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticStopEffect + * \sa SDL_HapticDestroyEffect + * \sa SDL_HapticGetEffectStatus + */ +extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic, + int effect, + Uint32 iterations); + +/** + * \brief Stops the haptic effect on its associated haptic device. + * + * \param haptic Haptic device to stop the effect on. + * \param effect Identifier of the effect to stop. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic, + int effect); + +/** + * \brief Destroys a haptic effect on the device. + * + * This will stop the effect if it's running. Effects are automatically + * destroyed when the device is closed. + * + * \param haptic Device to destroy the effect on. + * \param effect Identifier of the effect to destroy. + * + * \sa SDL_HapticNewEffect + */ +extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic, + int effect); + +/** + * \brief Gets the status of the current effect on the haptic device. + * + * Device must support the ::SDL_HAPTIC_STATUS feature. + * + * \param haptic Haptic device to query the effect status on. + * \param effect Identifier of the effect to query its status. + * \return 0 if it isn't playing, 1 if it is playing or -1 on error. + * + * \sa SDL_HapticRunEffect + * \sa SDL_HapticStopEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic, + int effect); + +/** + * \brief Sets the global gain of the device. + * + * Device must support the ::SDL_HAPTIC_GAIN feature. + * + * The user may specify the maximum gain by setting the environment variable + * SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to + * SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the + * maximum. + * + * \param haptic Haptic device to set the gain on. + * \param gain Value to set the gain to, should be between 0 and 100. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain); + +/** + * \brief Sets the global autocenter of the device. + * + * Autocenter should be between 0 and 100. Setting it to 0 will disable + * autocentering. + * + * Device must support the ::SDL_HAPTIC_AUTOCENTER feature. + * + * \param haptic Haptic device to set autocentering on. + * \param autocenter Value to set autocenter to, 0 disables autocentering. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic, + int autocenter); + +/** + * \brief Pauses a haptic device. + * + * Device must support the ::SDL_HAPTIC_PAUSE feature. Call + * SDL_HapticUnpause() to resume playback. + * + * Do not modify the effects nor add new ones while the device is paused. + * That can cause all sorts of weird errors. + * + * \param haptic Haptic device to pause. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticUnpause + */ +extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic); + +/** + * \brief Unpauses a haptic device. + * + * Call to unpause after SDL_HapticPause(). + * + * \param haptic Haptic device to pause. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticPause + */ +extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic); + +/** + * \brief Stops all the currently playing effects on a haptic device. + * + * \param haptic Haptic device to stop. + * \return 0 on success or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic); + +/** + * \brief Checks to see if rumble is supported on a haptic device. + * + * \param haptic Haptic device to check to see if it supports rumble. + * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic); + +/** + * \brief Initializes the haptic device for simple rumble playback. + * + * \param haptic Haptic device to initialize for simple rumble playback. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic); + +/** + * \brief Runs simple rumble on a haptic device + * + * \param haptic Haptic device to play rumble effect on. + * \param strength Strength of the rumble to play as a 0-1 float value. + * \param length Length of the rumble to play in milliseconds. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length ); + +/** + * \brief Stops the simple rumble on a haptic device. + * + * \param haptic Haptic to stop the rumble on. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_haptic_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_hints.h b/code/SDL2/include/SDL_hints.h new file mode 100644 index 00000000..b98ce683 --- /dev/null +++ b/code/SDL2/include/SDL_hints.h @@ -0,0 +1,517 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_hints.h + * + * Official documentation for SDL configuration variables + * + * This file contains functions to set and get configuration hints, + * as well as listing each of them alphabetically. + * + * The convention for naming hints is SDL_HINT_X, where "SDL_X" is + * the environment variable that can be used to override the default. + * + * In general these hints are just that - they may or may not be + * supported or applicable on any given platform, but they provide + * a way for an application or user to give the library a hint as + * to how they would like the library to work. + */ + +#ifndef _SDL_hints_h +#define _SDL_hints_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief A variable controlling how 3D acceleration is used to accelerate the SDL screen surface. + * + * SDL can try to accelerate the SDL screen surface by using streaming + * textures with a 3D rendering engine. This variable controls whether and + * how this is done. + * + * This variable can be set to the following values: + * "0" - Disable 3D acceleration + * "1" - Enable 3D acceleration, using the default renderer. + * "X" - Enable 3D acceleration, using X where X is one of the valid rendering drivers. (e.g. "direct3d", "opengl", etc.) + * + * By default SDL tries to make a best guess for each platform whether + * to use acceleration or not. + */ +#define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION" + +/** + * \brief A variable specifying which render driver to use. + * + * If the application doesn't pick a specific renderer to use, this variable + * specifies the name of the preferred renderer. If the preferred renderer + * can't be initialized, the normal default renderer is used. + * + * This variable is case insensitive and can be set to the following values: + * "direct3d" + * "opengl" + * "opengles2" + * "opengles" + * "software" + * + * The default varies by platform, but it's the first one in the list that + * is available on the current platform. + */ +#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER" + +/** + * \brief A variable controlling whether the OpenGL render driver uses shaders if they are available. + * + * This variable can be set to the following values: + * "0" - Disable shaders + * "1" - Enable shaders + * + * By default shaders are used if OpenGL supports them. + */ +#define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS" + +/** + * \brief A variable controlling whether the Direct3D device is initialized for thread-safe operations. + * + * This variable can be set to the following values: + * "0" - Thread-safety is not enabled (faster) + * "1" - Thread-safety is enabled + * + * By default the Direct3D device is created with thread-safety disabled. + */ +#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE" + +/** + * \brief A variable controlling whether to enable Direct3D 11+'s Debug Layer. + * + * This variable does not have any effect on the Direct3D 9 based renderer. + * + * This variable can be set to the following values: + * "0" - Disable Debug Layer use + * "1" - Enable Debug Layer use + * + * By default, SDL does not use Direct3D Debug Layer. + */ +#define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_HINT_RENDER_DIRECT3D11_DEBUG" + +/** + * \brief A variable controlling the scaling quality + * + * This variable can be set to the following values: + * "0" or "nearest" - Nearest pixel sampling + * "1" or "linear" - Linear filtering (supported by OpenGL and Direct3D) + * "2" or "best" - Currently this is the same as "linear" + * + * By default nearest pixel sampling is used + */ +#define SDL_HINT_RENDER_SCALE_QUALITY "SDL_RENDER_SCALE_QUALITY" + +/** + * \brief A variable controlling whether updates to the SDL screen surface should be synchronized with the vertical refresh, to avoid tearing. + * + * This variable can be set to the following values: + * "0" - Disable vsync + * "1" - Enable vsync + * + * By default SDL does not sync screen surface updates with vertical refresh. + */ +#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" + +/** + * \brief A variable controlling whether the screensaver is enabled. + * + * This variable can be set to the following values: + * "0" - Disable screensaver + * "1" - Enable screensaver + * + * By default SDL will disable the screensaver. + */ +#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER "SDL_VIDEO_ALLOW_SCREENSAVER" + +/** + * \brief A variable controlling whether the X11 VidMode extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable XVidMode + * "1" - Enable XVidMode + * + * By default SDL will use XVidMode if it is available. + */ +#define SDL_HINT_VIDEO_X11_XVIDMODE "SDL_VIDEO_X11_XVIDMODE" + +/** + * \brief A variable controlling whether the X11 Xinerama extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable Xinerama + * "1" - Enable Xinerama + * + * By default SDL will use Xinerama if it is available. + */ +#define SDL_HINT_VIDEO_X11_XINERAMA "SDL_VIDEO_X11_XINERAMA" + +/** + * \brief A variable controlling whether the X11 XRandR extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable XRandR + * "1" - Enable XRandR + * + * By default SDL will not use XRandR because of window manager issues. + */ +#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR" + +/** + * \brief A variable controlling whether grabbing input grabs the keyboard + * + * This variable can be set to the following values: + * "0" - Grab will affect only the mouse + * "1" - Grab will affect mouse and keyboard + * + * By default SDL will not grab the keyboard so system shortcuts still work. + */ +#define SDL_HINT_GRAB_KEYBOARD "SDL_GRAB_KEYBOARD" + +/** +* \brief A variable controlling whether relative mouse mode is implemented using mouse warping +* +* This variable can be set to the following values: +* "0" - Relative mouse mode uses raw input +* "1" - Relative mouse mode uses mouse warping +* +* By default SDL will use raw input for relative mouse mode +*/ +#define SDL_HINT_MOUSE_RELATIVE_MODE_WARP "SDL_MOUSE_RELATIVE_MODE_WARP" + +/** + * \brief Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true. + * + */ +#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" + +/** + * \brief A variable controlling whether the idle timer is disabled on iOS. + * + * When an iOS app does not receive touches for some time, the screen is + * dimmed automatically. For games where the accelerometer is the only input + * this is problematic. This functionality can be disabled by setting this + * hint. + * + * This variable can be set to the following values: + * "0" - Enable idle timer + * "1" - Disable idle timer + */ +#define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED" + +/** + * \brief A variable controlling which orientations are allowed on iOS. + * + * In some circumstances it is necessary to be able to explicitly control + * which UI orientations are allowed. + * + * This variable is a space delimited list of the following values: + * "LandscapeLeft", "LandscapeRight", "Portrait" "PortraitUpsideDown" + */ +#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS" + +/** + * \brief A variable controlling whether an Android built-in accelerometer should be + * listed as a joystick device, rather than listing actual joysticks only. + * + * This variable can be set to the following values: + * "0" - List only real joysticks and accept input from them + * "1" - List real joysticks along with the accelerometer as if it were a 3 axis joystick (the default). + */ +#define SDL_HINT_ACCELEROMETER_AS_JOYSTICK "SDL_ACCELEROMETER_AS_JOYSTICK" + + +/** + * \brief A variable that lets you disable the detection and use of Xinput gamepad devices + * + * The variable can be set to the following values: + * "0" - Disable XInput detection (only uses direct input) + * "1" - Enable XInput detection (the default) + */ +#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED" + + +/** + * \brief A variable that lets you manually hint extra gamecontroller db entries + * + * The variable should be newline delimited rows of gamecontroller config data, see SDL_gamecontroller.h + * + * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) + * You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping() + */ +#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG" + + +/** + * \brief A variable that lets you enable joystick (and gamecontroller) events even when your app is in the background. + * + * The variable can be set to the following values: + * "0" - Disable joystick & gamecontroller input events when the + * application is in the background. + * "1" - Enable joystick & gamecontroller input events when the + * application is in the background. + * + * The default value is "0". This hint may be set at any time. + */ +#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS" + + +/** + * \brief If set to 0 then never set the top most bit on a SDL Window, even if the video mode expects it. + * This is a debugging aid for developers and not expected to be used by end users. The default is "1" + * + * This variable can be set to the following values: + * "0" - don't allow topmost + * "1" - allow topmost + */ +#define SDL_HINT_ALLOW_TOPMOST "SDL_ALLOW_TOPMOST" + + +/** + * \brief A variable that controls the timer resolution, in milliseconds. + * + * The higher resolution the timer, the more frequently the CPU services + * timer interrupts, and the more precise delays are, but this takes up + * power and CPU time. This hint is only used on Windows 7 and earlier. + * + * See this blog post for more information: + * http://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ + * + * If this variable is set to "0", the system timer resolution is not set. + * + * The default value is "1". This hint may be set at any time. + */ +#define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION" + + +/** + * \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac) + */ +#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED" + +/** + * \brief A variable that determines whether ctrl+click should generate a right-click event on Mac + * + * If present, holding ctrl while left clicking will generate a right click + * event when on Mac. + */ +#define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK" + +/** +* \brief A variable specifying which shader compiler to preload when using the Chrome ANGLE binaries +* +* SDL has EGL and OpenGL ES2 support on Windows via the ANGLE project. It +* can use two different sets of binaries, those compiled by the user from source +* or those provided by the Chrome browser. In the later case, these binaries require +* that SDL loads a DLL providing the shader compiler. +* +* This variable can be set to the following values: +* "d3dcompiler_46.dll" - default, best for Vista or later. +* "d3dcompiler_43.dll" - for XP support. +* "none" - do not load any library, useful if you compiled ANGLE from source and included the compiler in your binaries. +* +*/ +#define SDL_HINT_VIDEO_WIN_D3DCOMPILER "SDL_VIDEO_WIN_D3DCOMPILER" + +/** +* \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p"). +* +* If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has +* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly +* created SDL_Window: +* +* 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is +* needed for example when sharing an OpenGL context across multiple windows. +* +* 2. The flag SDL_WINDOW_OPENGL will be set on the new window so it can be used for +* OpenGL rendering. +* +* This variable can be set to the following values: +* The address (as a string "%p") of the SDL_Window* that new windows created with SDL_CreateWindowFrom() should +* share a pixel format with. +*/ +#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT" + +/* + * \brief A URL to a WinRT app's privacy policy + * + * All network-enabled WinRT apps must make a privacy policy available to its + * users. On Windows 8, 8.1, and RT, Microsoft mandates that this policy be + * be available in the Windows Settings charm, as accessed from within the app. + * SDL provides code to add a URL-based link there, which can point to the app's + * privacy policy. + * + * To setup a URL to an app's privacy policy, set SDL_HINT_WINRT_PRIVACY_POLICY_URL + * before calling any SDL_Init functions. The contents of the hint should + * be a valid URL. For example, "http://www.example.com". + * + * The default value is "", which will prevent SDL from adding a privacy policy + * link to the Settings charm. This hint should only be set during app init. + * + * The label text of an app's "Privacy Policy" link may be customized via another + * hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. + * + * Please note that on Windows Phone, Microsoft does not provide standard UI + * for displaying a privacy policy link, and as such, SDL_HINT_WINRT_PRIVACY_POLICY_URL + * will not get used on that platform. Network-enabled phone apps should display + * their privacy policy through some other, in-app means. + */ +#define SDL_HINT_WINRT_PRIVACY_POLICY_URL "SDL_HINT_WINRT_PRIVACY_POLICY_URL" + +/** \brief Label text for a WinRT app's privacy policy link + * + * Network-enabled WinRT apps must include a privacy policy. On Windows 8, 8.1, and RT, + * Microsoft mandates that this policy be available via the Windows Settings charm. + * SDL provides code to add a link there, with it's label text being set via the + * optional hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. + * + * Please note that a privacy policy's contents are not set via this hint. A separate + * hint, SDL_HINT_WINRT_PRIVACY_POLICY_URL, is used to link to the actual text of the + * policy. + * + * The contents of this hint should be encoded as a UTF8 string. + * + * The default value is "Privacy Policy". This hint should only be set during app + * initialization, preferably before any calls to SDL_Init. + * + * For additional information on linking to a privacy policy, see the documentation for + * SDL_HINT_WINRT_PRIVACY_POLICY_URL. + */ +#define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_HINT_WINRT_PRIVACY_POLICY_LABEL" + +/** \brief If set to 1, back button press events on Windows Phone 8+ will be marked as handled. + * + * TODO, WinRT: document SDL_HINT_WINRT_HANDLE_BACK_BUTTON need and use + * For now, more details on why this is needed can be found at the + * beginning of the following web page: + * http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx + */ +#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_HINT_WINRT_HANDLE_BACK_BUTTON" + +/** + * \brief A variable that dictates policy for fullscreen Spaces on Mac OS X. + * + * This hint only applies to Mac OS X. + * + * The variable can be set to the following values: + * "0" - Disable Spaces support (FULLSCREEN_DESKTOP won't use them and + * SDL_WINDOW_RESIZABLE windows won't offer the "fullscreen" + * button on their titlebars). + * "1" - Enable Spaces support (FULLSCREEN_DESKTOP will use them and + * SDL_WINDOW_RESIZABLE windows will offer the "fullscreen" + * button on their titlebars. + * + * The default value is "1". Spaces are disabled regardless of this hint if + * the OS isn't at least Mac OS X Lion (10.7). This hint must be set before + * any windows are created. + */ +#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES" + + +/** + * \brief An enumeration of hint priorities + */ +typedef enum +{ + SDL_HINT_DEFAULT, + SDL_HINT_NORMAL, + SDL_HINT_OVERRIDE +} SDL_HintPriority; + + +/** + * \brief Set a hint with a specific priority + * + * The priority controls the behavior when setting a hint that already + * has a value. Hints will replace existing hints of their priority and + * lower. Environment variables are considered to have override priority. + * + * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, + const char *value, + SDL_HintPriority priority); + +/** + * \brief Set a hint with normal priority + * + * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, + const char *value); + +/** + * \brief Get a hint + * + * \return The string value of a hint variable. + */ +extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); + +/** + * \brief Add a function to watch a particular hint + * + * \param name The hint to watch + * \param callback The function to call when the hint value changes + * \param userdata A pointer to pass to the callback function + */ +typedef void (*SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue); +extern DECLSPEC void SDLCALL SDL_AddHintCallback(const char *name, + SDL_HintCallback callback, + void *userdata); + +/** + * \brief Remove a function watching a particular hint + * + * \param name The hint being watched + * \param callback The function being called when the hint value changes + * \param userdata A pointer being passed to the callback function + */ +extern DECLSPEC void SDLCALL SDL_DelHintCallback(const char *name, + SDL_HintCallback callback, + void *userdata); + +/** + * \brief Clear all hints + * + * This function is called during SDL_Quit() to free stored hints. + */ +extern DECLSPEC void SDLCALL SDL_ClearHints(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_hints_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_joystick.h b/code/SDL2/include/SDL_joystick.h new file mode 100644 index 00000000..b0b1c667 --- /dev/null +++ b/code/SDL2/include/SDL_joystick.h @@ -0,0 +1,253 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_joystick.h + * + * Include file for SDL joystick event handling + * + * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks, with the exact joystick + * behind a device_index changing as joysticks are plugged and unplugged. + * + * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted + * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in. + * + * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of + * the device (a X360 wired controller for example). This identifier is platform dependent. + * + * + */ + +#ifndef _SDL_joystick_h +#define _SDL_joystick_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_joystick.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + * for joysticks, and load appropriate drivers. + * + * If you would like to receive joystick updates while the application + * is in the background, you should set the following hint before calling + * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + */ + +/* The joystick structure used to identify an SDL joystick */ +struct _SDL_Joystick; +typedef struct _SDL_Joystick SDL_Joystick; + +/* A structure that encodes the stable unique id for a joystick device */ +typedef struct { + Uint8 data[16]; +} SDL_JoystickGUID; + +typedef Sint32 SDL_JoystickID; + + +/* Function prototypes */ +/** + * Count the number of joysticks attached to the system right now + */ +extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); + +/** + * Get the implementation dependent name of a joystick. + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index); + +/** + * Open a joystick for use. + * The index passed as an argument refers tothe N'th joystick on the system. + * This index is the value which will identify this joystick in future joystick + * events. + * + * \return A joystick identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); + +/** + * Return the name for this currently opened joystick. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick); + +/** + * Return the GUID for the joystick at this index + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index); + +/** + * Return the GUID for this opened joystick + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick); + +/** + * Return a string representation for this guid. pszGUID must point to at least 33 bytes + * (32 for the string plus a NULL terminator). + */ +extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID); + +/** + * convert a string into a joystick formatted guid + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID); + +/** + * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick); + +/** + * Get the instance ID of an opened joystick or -1 if the joystick is invalid. + */ +extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick); + +/** + * Get the number of general axis controls on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick); + +/** + * Get the number of trackballs on a joystick. + * + * Joystick trackballs have only relative motion events associated + * with them and their state cannot be polled. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick); + +/** + * Get the number of POV hats on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick); + +/** + * Get the number of buttons on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick); + +/** + * Update the current state of the open joysticks. + * + * This is called automatically by the event loop if any joystick + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); + +/** + * Enable/disable joystick event polling. + * + * If joystick events are disabled, you must call SDL_JoystickUpdate() + * yourself and check the state of the joystick when you want joystick + * information. + * + * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); + +/** + * Get the current state of an axis control on a joystick. + * + * The state is a value ranging from -32768 to 32767. + * + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, + int axis); + +/** + * \name Hat positions + */ +/* @{ */ +#define SDL_HAT_CENTERED 0x00 +#define SDL_HAT_UP 0x01 +#define SDL_HAT_RIGHT 0x02 +#define SDL_HAT_DOWN 0x04 +#define SDL_HAT_LEFT 0x08 +#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) +#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) +#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) +#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) +/* @} */ + +/** + * Get the current state of a POV hat on a joystick. + * + * The hat indices start at index 0. + * + * \return The return value is one of the following positions: + * - ::SDL_HAT_CENTERED + * - ::SDL_HAT_UP + * - ::SDL_HAT_RIGHT + * - ::SDL_HAT_DOWN + * - ::SDL_HAT_LEFT + * - ::SDL_HAT_RIGHTUP + * - ::SDL_HAT_RIGHTDOWN + * - ::SDL_HAT_LEFTUP + * - ::SDL_HAT_LEFTDOWN + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick, + int hat); + +/** + * Get the ball axis change since the last poll. + * + * \return 0, or -1 if you passed it invalid parameters. + * + * The ball indices start at index 0. + */ +extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick, + int ball, int *dx, int *dy); + +/** + * Get the current state of a button on a joystick. + * + * The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick, + int button); + +/** + * Close a joystick previously opened with SDL_JoystickOpen(). + */ +extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_joystick_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_keyboard.h b/code/SDL2/include/SDL_keyboard.h new file mode 100644 index 00000000..586a26cf --- /dev/null +++ b/code/SDL2/include/SDL_keyboard.h @@ -0,0 +1,217 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_keyboard.h + * + * Include file for SDL keyboard event handling + */ + +#ifndef _SDL_keyboard_h +#define _SDL_keyboard_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_keycode.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The SDL keysym structure, used in key events. + * + * \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event. + */ +typedef struct SDL_Keysym +{ + SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ + SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */ + Uint16 mod; /**< current key modifiers */ + Uint32 unused; +} SDL_Keysym; + +/* Function prototypes */ + +/** + * \brief Get the window which currently has keyboard focus. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); + +/** + * \brief Get a snapshot of the current state of the keyboard. + * + * \param numkeys if non-NULL, receives the length of the returned array. + * + * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. + * + * \b Example: + * \code + * const Uint8 *state = SDL_GetKeyboardState(NULL); + * if ( state[SDL_SCANCODE_RETURN] ) { + * printf(" is pressed.\n"); + * } + * \endcode + */ +extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); + +/** + * \brief Get the current key modifier state for the keyboard. + */ +extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); + +/** + * \brief Set the current key modifier state for the keyboard. + * + * \note This does not change the keyboard state, only the key modifier flags. + */ +extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); + +/** + * \brief Get the key code corresponding to the given scancode according + * to the current keyboard layout. + * + * See ::SDL_Keycode for details. + * + * \sa SDL_GetKeyName() + */ +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); + +/** + * \brief Get the scancode corresponding to the given key code according to the + * current keyboard layout. + * + * See ::SDL_Scancode for details. + * + * \sa SDL_GetScancodeName() + */ +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); + +/** + * \brief Get a human-readable name for a scancode. + * + * \return A pointer to the name for the scancode. + * If the scancode doesn't have a name, this function returns + * an empty string (""). + * + * \sa SDL_Scancode + */ +extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); + +/** + * \brief Get a scancode from a human-readable name + * + * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized + * + * \sa SDL_Scancode + */ +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); + +/** + * \brief Get a human-readable name for a key. + * + * \return A pointer to a UTF-8 string that stays valid at least until the next + * call to this function. If you need it around any longer, you must + * copy it. If the key doesn't have a name, this function returns an + * empty string (""). + * + * \sa SDL_Key + */ +extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); + +/** + * \brief Get a key code from a human-readable name + * + * \return key code, or SDLK_UNKNOWN if the name wasn't recognized + * + * \sa SDL_Keycode + */ +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); + +/** + * \brief Start accepting Unicode text input events. + * This function will show the on-screen keyboard if supported. + * + * \sa SDL_StopTextInput() + * \sa SDL_SetTextInputRect() + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC void SDLCALL SDL_StartTextInput(void); + +/** + * \brief Return whether or not Unicode text input events are enabled. + * + * \sa SDL_StartTextInput() + * \sa SDL_StopTextInput() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void); + +/** + * \brief Stop receiving any text input events. + * This function will hide the on-screen keyboard if supported. + * + * \sa SDL_StartTextInput() + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC void SDLCALL SDL_StopTextInput(void); + +/** + * \brief Set the rectangle used to type Unicode text inputs. + * This is used as a hint for IME and on-screen keyboard placement. + * + * \sa SDL_StartTextInput() + */ +extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); + +/** + * \brief Returns whether the platform has some screen keyboard support. + * + * \return SDL_TRUE if some keyboard support is available else SDL_FALSE. + * + * \note Not all screen keyboard functions are supported on all platforms. + * + * \sa SDL_IsScreenKeyboardShown() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void); + +/** + * \brief Returns whether the screen keyboard is shown for given window. + * + * \param window The window for which screen keyboard should be queried. + * + * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE. + * + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_keyboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_keycode.h b/code/SDL2/include/SDL_keycode.h new file mode 100644 index 00000000..d5f5dd0a --- /dev/null +++ b/code/SDL2/include/SDL_keycode.h @@ -0,0 +1,341 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_keycode.h + * + * Defines constants which identify keyboard keys and modifiers. + */ + +#ifndef _SDL_keycode_h +#define _SDL_keycode_h + +#include "SDL_stdinc.h" +#include "SDL_scancode.h" + +/** + * \brief The SDL virtual key representation. + * + * Values of this type are used to represent keyboard keys using the current + * layout of the keyboard. These values include Unicode values representing + * the unmodified character that would be generated by pressing the key, or + * an SDLK_* constant for those keys that do not generate characters. + */ +typedef Sint32 SDL_Keycode; + +#define SDLK_SCANCODE_MASK (1<<30) +#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) + +enum +{ + SDLK_UNKNOWN = 0, + + SDLK_RETURN = '\r', + SDLK_ESCAPE = '\033', + SDLK_BACKSPACE = '\b', + SDLK_TAB = '\t', + SDLK_SPACE = ' ', + SDLK_EXCLAIM = '!', + SDLK_QUOTEDBL = '"', + SDLK_HASH = '#', + SDLK_PERCENT = '%', + SDLK_DOLLAR = '$', + SDLK_AMPERSAND = '&', + SDLK_QUOTE = '\'', + SDLK_LEFTPAREN = '(', + SDLK_RIGHTPAREN = ')', + SDLK_ASTERISK = '*', + SDLK_PLUS = '+', + SDLK_COMMA = ',', + SDLK_MINUS = '-', + SDLK_PERIOD = '.', + SDLK_SLASH = '/', + SDLK_0 = '0', + SDLK_1 = '1', + SDLK_2 = '2', + SDLK_3 = '3', + SDLK_4 = '4', + SDLK_5 = '5', + SDLK_6 = '6', + SDLK_7 = '7', + SDLK_8 = '8', + SDLK_9 = '9', + SDLK_COLON = ':', + SDLK_SEMICOLON = ';', + SDLK_LESS = '<', + SDLK_EQUALS = '=', + SDLK_GREATER = '>', + SDLK_QUESTION = '?', + SDLK_AT = '@', + /* + Skip uppercase letters + */ + SDLK_LEFTBRACKET = '[', + SDLK_BACKSLASH = '\\', + SDLK_RIGHTBRACKET = ']', + SDLK_CARET = '^', + SDLK_UNDERSCORE = '_', + SDLK_BACKQUOTE = '`', + SDLK_a = 'a', + SDLK_b = 'b', + SDLK_c = 'c', + SDLK_d = 'd', + SDLK_e = 'e', + SDLK_f = 'f', + SDLK_g = 'g', + SDLK_h = 'h', + SDLK_i = 'i', + SDLK_j = 'j', + SDLK_k = 'k', + SDLK_l = 'l', + SDLK_m = 'm', + SDLK_n = 'n', + SDLK_o = 'o', + SDLK_p = 'p', + SDLK_q = 'q', + SDLK_r = 'r', + SDLK_s = 's', + SDLK_t = 't', + SDLK_u = 'u', + SDLK_v = 'v', + SDLK_w = 'w', + SDLK_x = 'x', + SDLK_y = 'y', + SDLK_z = 'z', + + SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK), + + SDLK_F1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1), + SDLK_F2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2), + SDLK_F3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3), + SDLK_F4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4), + SDLK_F5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5), + SDLK_F6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6), + SDLK_F7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7), + SDLK_F8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8), + SDLK_F9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9), + SDLK_F10 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10), + SDLK_F11 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11), + SDLK_F12 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12), + + SDLK_PRINTSCREEN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN), + SDLK_SCROLLLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK), + SDLK_PAUSE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE), + SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT), + SDLK_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME), + SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP), + SDLK_DELETE = '\177', + SDLK_END = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END), + SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN), + SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT), + SDLK_LEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT), + SDLK_DOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN), + SDLK_UP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP), + + SDLK_NUMLOCKCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR), + SDLK_KP_DIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE), + SDLK_KP_MULTIPLY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY), + SDLK_KP_MINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS), + SDLK_KP_PLUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS), + SDLK_KP_ENTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER), + SDLK_KP_1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1), + SDLK_KP_2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2), + SDLK_KP_3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3), + SDLK_KP_4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4), + SDLK_KP_5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5), + SDLK_KP_6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6), + SDLK_KP_7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7), + SDLK_KP_8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8), + SDLK_KP_9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9), + SDLK_KP_0 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0), + SDLK_KP_PERIOD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD), + + SDLK_APPLICATION = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION), + SDLK_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER), + SDLK_KP_EQUALS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS), + SDLK_F13 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13), + SDLK_F14 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14), + SDLK_F15 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15), + SDLK_F16 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16), + SDLK_F17 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17), + SDLK_F18 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18), + SDLK_F19 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19), + SDLK_F20 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20), + SDLK_F21 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21), + SDLK_F22 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22), + SDLK_F23 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23), + SDLK_F24 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24), + SDLK_EXECUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE), + SDLK_HELP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP), + SDLK_MENU = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU), + SDLK_SELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT), + SDLK_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP), + SDLK_AGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN), + SDLK_UNDO = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO), + SDLK_CUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT), + SDLK_COPY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY), + SDLK_PASTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE), + SDLK_FIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND), + SDLK_MUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE), + SDLK_VOLUMEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP), + SDLK_VOLUMEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN), + SDLK_KP_COMMA = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA), + SDLK_KP_EQUALSAS400 = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400), + + SDLK_ALTERASE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE), + SDLK_SYSREQ = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ), + SDLK_CANCEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL), + SDLK_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR), + SDLK_PRIOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR), + SDLK_RETURN2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2), + SDLK_SEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR), + SDLK_OUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT), + SDLK_OPER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER), + SDLK_CLEARAGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN), + SDLK_CRSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL), + SDLK_EXSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL), + + SDLK_KP_00 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00), + SDLK_KP_000 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000), + SDLK_THOUSANDSSEPARATOR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR), + SDLK_DECIMALSEPARATOR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR), + SDLK_CURRENCYUNIT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT), + SDLK_CURRENCYSUBUNIT = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT), + SDLK_KP_LEFTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN), + SDLK_KP_RIGHTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN), + SDLK_KP_LEFTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE), + SDLK_KP_RIGHTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE), + SDLK_KP_TAB = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB), + SDLK_KP_BACKSPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE), + SDLK_KP_A = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A), + SDLK_KP_B = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B), + SDLK_KP_C = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C), + SDLK_KP_D = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D), + SDLK_KP_E = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E), + SDLK_KP_F = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F), + SDLK_KP_XOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR), + SDLK_KP_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER), + SDLK_KP_PERCENT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT), + SDLK_KP_LESS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS), + SDLK_KP_GREATER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER), + SDLK_KP_AMPERSAND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND), + SDLK_KP_DBLAMPERSAND = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND), + SDLK_KP_VERTICALBAR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR), + SDLK_KP_DBLVERTICALBAR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR), + SDLK_KP_COLON = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON), + SDLK_KP_HASH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH), + SDLK_KP_SPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE), + SDLK_KP_AT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT), + SDLK_KP_EXCLAM = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM), + SDLK_KP_MEMSTORE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE), + SDLK_KP_MEMRECALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL), + SDLK_KP_MEMCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR), + SDLK_KP_MEMADD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD), + SDLK_KP_MEMSUBTRACT = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT), + SDLK_KP_MEMMULTIPLY = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY), + SDLK_KP_MEMDIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE), + SDLK_KP_PLUSMINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS), + SDLK_KP_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR), + SDLK_KP_CLEARENTRY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY), + SDLK_KP_BINARY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY), + SDLK_KP_OCTAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL), + SDLK_KP_DECIMAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL), + SDLK_KP_HEXADECIMAL = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL), + + SDLK_LCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL), + SDLK_LSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT), + SDLK_LALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT), + SDLK_LGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI), + SDLK_RCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL), + SDLK_RSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT), + SDLK_RALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT), + SDLK_RGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI), + + SDLK_MODE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE), + + SDLK_AUDIONEXT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIONEXT), + SDLK_AUDIOPREV = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPREV), + SDLK_AUDIOSTOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOSTOP), + SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPLAY), + SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOMUTE), + SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIASELECT), + SDLK_WWW = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WWW), + SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MAIL), + SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALCULATOR), + SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COMPUTER), + SDLK_AC_SEARCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH), + SDLK_AC_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME), + SDLK_AC_BACK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK), + SDLK_AC_FORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD), + SDLK_AC_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP), + SDLK_AC_REFRESH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH), + SDLK_AC_BOOKMARKS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS), + + SDLK_BRIGHTNESSDOWN = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSDOWN), + SDLK_BRIGHTNESSUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSUP), + SDLK_DISPLAYSWITCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DISPLAYSWITCH), + SDLK_KBDILLUMTOGGLE = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMTOGGLE), + SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMDOWN), + SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMUP), + SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EJECT), + SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP) +}; + +/** + * \brief Enumeration of valid key mods (possibly OR'd together). + */ +typedef enum +{ + KMOD_NONE = 0x0000, + KMOD_LSHIFT = 0x0001, + KMOD_RSHIFT = 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LGUI = 0x0400, + KMOD_RGUI = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000 +} SDL_Keymod; + +#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) +#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) +#define KMOD_ALT (KMOD_LALT|KMOD_RALT) +#define KMOD_GUI (KMOD_LGUI|KMOD_RGUI) + +#endif /* _SDL_keycode_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_loadso.h b/code/SDL2/include/SDL_loadso.h new file mode 100644 index 00000000..0359eae1 --- /dev/null +++ b/code/SDL2/include/SDL_loadso.h @@ -0,0 +1,81 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_loadso.h + * + * System dependent library loading routines + * + * Some things to keep in mind: + * \li These functions only work on C function names. Other languages may + * have name mangling and intrinsic language support that varies from + * compiler to compiler. + * \li Make sure you declare your function pointers with the same calling + * convention as the actual library function. Your code will crash + * mysteriously if you do not do this. + * \li Avoid namespace collisions. If you load a symbol from the library, + * it is not defined whether or not it goes into the global symbol + * namespace for the application. If it does and it conflicts with + * symbols in your code or other shared libraries, you will not get + * the results you expect. :) + */ + +#ifndef _SDL_loadso_h +#define _SDL_loadso_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This function dynamically loads a shared object and returns a pointer + * to the object handle (or NULL if there was an error). + * The 'sofile' parameter is a system dependent name of the object file. + */ +extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); + +/** + * Given an object handle, this function looks up the address of the + * named function in the shared object and returns it. This address + * is no longer valid after calling SDL_UnloadObject(). + */ +extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, + const char *name); + +/** + * Unload a shared object from memory. + */ +extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_loadso_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_log.h b/code/SDL2/include/SDL_log.h new file mode 100644 index 00000000..5c2bca59 --- /dev/null +++ b/code/SDL2/include/SDL_log.h @@ -0,0 +1,211 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_log.h + * + * Simple log messages with categories and priorities. + * + * By default logs are quiet, but if you're debugging SDL you might want: + * + * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN); + * + * Here's where the messages go on different platforms: + * Windows: debug output stream + * Android: log output + * Others: standard error output (stderr) + */ + +#ifndef _SDL_log_h +#define _SDL_log_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * \brief The maximum size of a log message + * + * Messages longer than the maximum size will be truncated + */ +#define SDL_MAX_LOG_MESSAGE 4096 + +/** + * \brief The predefined log categories + * + * By default the application category is enabled at the INFO level, + * the assert category is enabled at the WARN level, test is enabled + * at the VERBOSE level and all other categories are enabled at the + * CRITICAL level. + */ +enum +{ + SDL_LOG_CATEGORY_APPLICATION, + SDL_LOG_CATEGORY_ERROR, + SDL_LOG_CATEGORY_ASSERT, + SDL_LOG_CATEGORY_SYSTEM, + SDL_LOG_CATEGORY_AUDIO, + SDL_LOG_CATEGORY_VIDEO, + SDL_LOG_CATEGORY_RENDER, + SDL_LOG_CATEGORY_INPUT, + SDL_LOG_CATEGORY_TEST, + + /* Reserved for future SDL library use */ + SDL_LOG_CATEGORY_RESERVED1, + SDL_LOG_CATEGORY_RESERVED2, + SDL_LOG_CATEGORY_RESERVED3, + SDL_LOG_CATEGORY_RESERVED4, + SDL_LOG_CATEGORY_RESERVED5, + SDL_LOG_CATEGORY_RESERVED6, + SDL_LOG_CATEGORY_RESERVED7, + SDL_LOG_CATEGORY_RESERVED8, + SDL_LOG_CATEGORY_RESERVED9, + SDL_LOG_CATEGORY_RESERVED10, + + /* Beyond this point is reserved for application use, e.g. + enum { + MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, + MYAPP_CATEGORY_AWESOME2, + MYAPP_CATEGORY_AWESOME3, + ... + }; + */ + SDL_LOG_CATEGORY_CUSTOM +}; + +/** + * \brief The predefined log priorities + */ +typedef enum +{ + SDL_LOG_PRIORITY_VERBOSE = 1, + SDL_LOG_PRIORITY_DEBUG, + SDL_LOG_PRIORITY_INFO, + SDL_LOG_PRIORITY_WARN, + SDL_LOG_PRIORITY_ERROR, + SDL_LOG_PRIORITY_CRITICAL, + SDL_NUM_LOG_PRIORITIES +} SDL_LogPriority; + + +/** + * \brief Set the priority of all log categories + */ +extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority); + +/** + * \brief Set the priority of a particular log category + */ +extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category, + SDL_LogPriority priority); + +/** + * \brief Get the priority of a particular log category + */ +extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); + +/** + * \brief Reset all priorities to default. + * + * \note This is called in SDL_Quit(). + */ +extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void); + +/** + * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO + */ +extern DECLSPEC void SDLCALL SDL_Log(const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE + */ +extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_DEBUG + */ +extern DECLSPEC void SDLCALL SDL_LogDebug(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_INFO + */ +extern DECLSPEC void SDLCALL SDL_LogInfo(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_WARN + */ +extern DECLSPEC void SDLCALL SDL_LogWarn(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_ERROR + */ +extern DECLSPEC void SDLCALL SDL_LogError(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL + */ +extern DECLSPEC void SDLCALL SDL_LogCritical(int category, const char *fmt, ...); + +/** + * \brief Log a message with the specified category and priority. + */ +extern DECLSPEC void SDLCALL SDL_LogMessage(int category, + SDL_LogPriority priority, + const char *fmt, ...); + +/** + * \brief Log a message with the specified category and priority. + */ +extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, + SDL_LogPriority priority, + const char *fmt, va_list ap); + +/** + * \brief The prototype for the log output function + */ +typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); + +/** + * \brief Get the current log output function. + */ +extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata); + +/** + * \brief This function allows you to replace the default log output + * function with one of your own. + */ +extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_log_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_main.h b/code/SDL2/include/SDL_main.h new file mode 100644 index 00000000..2e8fae95 --- /dev/null +++ b/code/SDL2/include/SDL_main.h @@ -0,0 +1,155 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_main_h +#define _SDL_main_h + +#include "SDL_stdinc.h" + +/** + * \file SDL_main.h + * + * Redefine main() on some platforms so that it is called by SDL. + */ + +#ifndef SDL_MAIN_HANDLED +#if defined(__WIN32__) +/* On Windows SDL provides WinMain(), which parses the command line and passes + the arguments to your main function. + + If you provide your own WinMain(), you may define SDL_MAIN_HANDLED + */ +#define SDL_MAIN_AVAILABLE + +#elif defined(__WINRT__) +/* On WinRT, SDL provides a main function that initializes CoreApplication, + creating an instance of IFrameworkView in the process. + + Please note that #include'ing SDL_main.h is not enough to get a main() + function working. In non-XAML apps, the file, + src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled + into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be + called, with a pointer to the Direct3D-hosted XAML control passed in. +*/ +#define SDL_MAIN_NEEDED + +#elif defined(__IPHONEOS__) +/* On iOS SDL provides a main function that creates an application delegate + and starts the iOS application run loop. + + See src/video/uikit/SDL_uikitappdelegate.m for more details. + */ +#define SDL_MAIN_NEEDED + +#elif defined(__ANDROID__) +/* On Android SDL provides a Java class in SDLActivity.java that is the + main activity entry point. + + See README-android.txt for more details on extending that class. + */ +#define SDL_MAIN_NEEDED + +#endif +#endif /* SDL_MAIN_HANDLED */ + +#ifdef __cplusplus +#define C_LINKAGE "C" +#else +#define C_LINKAGE +#endif /* __cplusplus */ + +/** + * \file SDL_main.h + * + * The application's main() function must be called with C linkage, + * and should be declared like this: + * \code + * #ifdef __cplusplus + * extern "C" + * #endif + * int main(int argc, char *argv[]) + * { + * } + * \endcode + */ + +#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) +#define main SDL_main +#endif + +/** + * The prototype for the application's main() function + */ +extern C_LINKAGE int SDL_main(int argc, char *argv[]); + + +#include "begin_code.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This is called by the real SDL main function to let the rest of the + * library know that initialization was done properly. + * + * Calling this yourself without knowing what you're doing can cause + * crashes and hard to diagnose problems with your application. + */ +extern DECLSPEC void SDLCALL SDL_SetMainReady(void); + +#ifdef __WIN32__ + +/** + * This can be called to set the application class at startup + */ +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, + void *hInst); +extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); + +#endif /* __WIN32__ */ + + +#ifdef __WINRT__ + +/** + * \brief Initializes and launches an SDL/WinRT application. + * + * \param mainFunction The SDL app's C-style main(). + * \param xamlBackgroundPanel An optional, XAML-based, background panel. + * For Non-XAML apps, this value must be set to NULL. For XAML apps, + * pass in a pointer to a SwapChainBackgroundPanel, casted to an + * IInspectable (via reinterpret_cast). + * \ret 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more + * information on the failure. + */ +extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel); + +#endif /* __WINRT__ */ + + +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_main_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_messagebox.h b/code/SDL2/include/SDL_messagebox.h new file mode 100644 index 00000000..6004da0f --- /dev/null +++ b/code/SDL2/include/SDL_messagebox.h @@ -0,0 +1,144 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_messagebox_h +#define _SDL_messagebox_h + +#include "SDL_stdinc.h" +#include "SDL_video.h" /* For SDL_Window */ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief SDL_MessageBox flags. If supported will display warning icon, etc. + */ +typedef enum +{ + SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */ + SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */ + SDL_MESSAGEBOX_INFORMATION = 0x00000040 /**< informational dialog */ +} SDL_MessageBoxFlags; + +/** + * \brief Flags for SDL_MessageBoxButtonData. + */ +typedef enum +{ + SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */ + SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */ +} SDL_MessageBoxButtonFlags; + +/** + * \brief Individual button data. + */ +typedef struct +{ + Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */ + int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */ + const char * text; /**< The UTF-8 button text */ +} SDL_MessageBoxButtonData; + +/** + * \brief RGB value used in a message box color scheme + */ +typedef struct +{ + Uint8 r, g, b; +} SDL_MessageBoxColor; + +typedef enum +{ + SDL_MESSAGEBOX_COLOR_BACKGROUND, + SDL_MESSAGEBOX_COLOR_TEXT, + SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, + SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, + SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, + SDL_MESSAGEBOX_COLOR_MAX +} SDL_MessageBoxColorType; + +/** + * \brief A set of colors to use for message box dialogs + */ +typedef struct +{ + SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX]; +} SDL_MessageBoxColorScheme; + +/** + * \brief MessageBox structure containing title, text, window, etc. + */ +typedef struct +{ + Uint32 flags; /**< ::SDL_MessageBoxFlags */ + SDL_Window *window; /**< Parent window, can be NULL */ + const char *title; /**< UTF-8 title */ + const char *message; /**< UTF-8 message text */ + + int numbuttons; + const SDL_MessageBoxButtonData *buttons; + + const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */ +} SDL_MessageBoxData; + +/** + * \brief Create a modal message box. + * + * \param messageboxdata The SDL_MessageBoxData structure with title, text, etc. + * \param buttonid The pointer to which user id of hit button should be copied. + * + * \return -1 on error, otherwise 0 and buttonid contains user id of button + * hit or -1 if dialog was closed. + * + * \note This function should be called on the thread that created the parent + * window, or on the main thread if the messagebox has no parent. It will + * block execution of that thread until the user clicks a button or + * closes the messagebox. + */ +extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); + +/** + * \brief Create a simple modal message box + * + * \param flags ::SDL_MessageBoxFlags + * \param title UTF-8 title text + * \param message UTF-8 message text + * \param window The parent window, or NULL for no parent + * + * \return 0 on success, -1 on error + * + * \sa SDL_ShowMessageBox + */ +extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_messagebox_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_mouse.h b/code/SDL2/include/SDL_mouse.h new file mode 100644 index 00000000..ebfd18fa --- /dev/null +++ b/code/SDL2/include/SDL_mouse.h @@ -0,0 +1,224 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_mouse.h + * + * Include file for SDL mouse event handling. + */ + +#ifndef _SDL_mouse_h +#define _SDL_mouse_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */ + +/** + * \brief Cursor types for SDL_CreateSystemCursor. + */ +typedef enum +{ + SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */ + SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */ + SDL_SYSTEM_CURSOR_WAIT, /**< Wait */ + SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */ + SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */ + SDL_SYSTEM_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */ + SDL_SYSTEM_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */ + SDL_SYSTEM_CURSOR_SIZEWE, /**< Double arrow pointing west and east */ + SDL_SYSTEM_CURSOR_SIZENS, /**< Double arrow pointing north and south */ + SDL_SYSTEM_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */ + SDL_SYSTEM_CURSOR_NO, /**< Slashed circle or crossbones */ + SDL_SYSTEM_CURSOR_HAND, /**< Hand */ + SDL_NUM_SYSTEM_CURSORS +} SDL_SystemCursor; + +/* Function prototypes */ + +/** + * \brief Get the window which currently has mouse focus. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); + +/** + * \brief Retrieve the current state of the mouse. + * + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse cursor position relative to the focus window for the currently + * selected mouse. You can pass NULL for either x or y. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y); + +/** + * \brief Retrieve the relative state of the mouse. + * + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse deltas since the last call to SDL_GetRelativeMouseState(). + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); + +/** + * \brief Moves the mouse to the given position within the window. + * + * \param window The window to move the mouse into, or NULL for the current mouse focus + * \param x The x coordinate within the window + * \param y The y coordinate within the window + * + * \note This function generates a mouse motion event + */ +extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, + int x, int y); + +/** + * \brief Set relative mouse mode. + * + * \param enabled Whether or not to enable relative mode + * + * \return 0 on success, or -1 if relative mode is not supported. + * + * While the mouse is in relative mode, the cursor is hidden, and the + * driver will try to report continuous motion in the current window. + * Only relative motion events will be delivered, the mouse position + * will not change. + * + * \note This function will flush any pending mouse motion. + * + * \sa SDL_GetRelativeMouseMode() + */ +extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); + +/** + * \brief Query whether relative mouse mode is enabled. + * + * \sa SDL_SetRelativeMouseMode() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); + +/** + * \brief Create a cursor, using the specified bitmap data and + * mask (in MSB format). + * + * The cursor width must be a multiple of 8 bits. + * + * The cursor is created in black and white according to the following: + * + * + * + * + * + * + *
data mask resulting pixel on screen
0 1 White
1 1 Black
0 0 Transparent
1 0 Inverted color if possible, black + * if not.
+ * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, + const Uint8 * mask, + int w, int h, int hot_x, + int hot_y); + +/** + * \brief Create a color cursor. + * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, + int hot_x, + int hot_y); + +/** + * \brief Create a system cursor. + * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id); + +/** + * \brief Set the active cursor. + */ +extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor); + +/** + * \brief Return the active cursor. + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); + +/** + * \brief Return the default cursor. + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void); + +/** + * \brief Frees a cursor created with SDL_CreateCursor(). + * + * \sa SDL_CreateCursor() + */ +extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); + +/** + * \brief Toggle whether or not the cursor is shown. + * + * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current + * state. + * + * \return 1 if the cursor is shown, or 0 if the cursor is hidden. + */ +extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); + +/** + * Used as a mask when testing buttons in buttonstate. + * - Button 1: Left mouse button + * - Button 2: Middle mouse button + * - Button 3: Right mouse button + */ +#define SDL_BUTTON(X) (1 << ((X)-1)) +#define SDL_BUTTON_LEFT 1 +#define SDL_BUTTON_MIDDLE 2 +#define SDL_BUTTON_RIGHT 3 +#define SDL_BUTTON_X1 4 +#define SDL_BUTTON_X2 5 +#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) +#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) +#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) +#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) +#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_mutex.h b/code/SDL2/include/SDL_mutex.h new file mode 100644 index 00000000..3e8b4dbe --- /dev/null +++ b/code/SDL2/include/SDL_mutex.h @@ -0,0 +1,251 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_mutex_h +#define _SDL_mutex_h + +/** + * \file SDL_mutex.h + * + * Functions to provide thread synchronization primitives. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Synchronization functions which can time out return this value + * if they time out. + */ +#define SDL_MUTEX_TIMEDOUT 1 + +/** + * This is the timeout value which corresponds to never time out. + */ +#define SDL_MUTEX_MAXWAIT (~(Uint32)0) + + +/** + * \name Mutex functions + */ +/* @{ */ + +/* The SDL mutex structure, defined in SDL_sysmutex.c */ +struct SDL_mutex; +typedef struct SDL_mutex SDL_mutex; + +/** + * Create a mutex, initialized unlocked. + */ +extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); + +/** + * Lock the mutex. + * + * \return 0, or -1 on error. + */ +#define SDL_mutexP(m) SDL_LockMutex(m) +extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); + +/** + * Try to lock the mutex + * + * \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); + +/** + * Unlock the mutex. + * + * \return 0, or -1 on error. + * + * \warning It is an error to unlock a mutex that has not been locked by + * the current thread, and doing so results in undefined behavior. + */ +#define SDL_mutexV(m) SDL_UnlockMutex(m) +extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); + +/** + * Destroy a mutex. + */ +extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); + +/* @} *//* Mutex functions */ + + +/** + * \name Semaphore functions + */ +/* @{ */ + +/* The SDL semaphore structure, defined in SDL_syssem.c */ +struct SDL_semaphore; +typedef struct SDL_semaphore SDL_sem; + +/** + * Create a semaphore, initialized with value, returns NULL on failure. + */ +extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); + +/** + * Destroy a semaphore. + */ +extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem); + +/** + * This function suspends the calling thread until the semaphore pointed + * to by \c sem has a positive count. It then atomically decreases the + * semaphore count. + */ +extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem); + +/** + * Non-blocking variant of SDL_SemWait(). + * + * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would + * block, and -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); + +/** + * Variant of SDL_SemWait() with a timeout in milliseconds. + * + * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not + * succeed in the allotted time, and -1 on error. + * + * \warning On some platforms this function is implemented by looping with a + * delay of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); + +/** + * Atomically increases the semaphore's count (not blocking). + * + * \return 0, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); + +/** + * Returns the current count of the semaphore. + */ +extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); + +/* @} *//* Semaphore functions */ + + +/** + * \name Condition variable functions + */ +/* @{ */ + +/* The SDL condition variable structure, defined in SDL_syscond.c */ +struct SDL_cond; +typedef struct SDL_cond SDL_cond; + +/** + * Create a condition variable. + * + * Typical use of condition variables: + * + * Thread A: + * SDL_LockMutex(lock); + * while ( ! condition ) { + * SDL_CondWait(cond, lock); + * } + * SDL_UnlockMutex(lock); + * + * Thread B: + * SDL_LockMutex(lock); + * ... + * condition = true; + * ... + * SDL_CondSignal(cond); + * SDL_UnlockMutex(lock); + * + * There is some discussion whether to signal the condition variable + * with the mutex locked or not. There is some potential performance + * benefit to unlocking first on some platforms, but there are some + * potential race conditions depending on how your code is structured. + * + * In general it's safer to signal the condition variable while the + * mutex is locked. + */ +extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); + +/** + * Destroy a condition variable. + */ +extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond); + +/** + * Restart one of the threads that are waiting on the condition variable. + * + * \return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); + +/** + * Restart all threads that are waiting on the condition variable. + * + * \return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); + +/** + * Wait on the condition variable, unlocking the provided mutex. + * + * \warning The mutex must be locked before entering this function! + * + * The mutex is re-locked once the condition variable is signaled. + * + * \return 0 when it is signaled, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); + +/** + * Waits for at most \c ms milliseconds, and returns 0 if the condition + * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not + * signaled in the allotted time, and -1 on error. + * + * \warning On some platforms this function is implemented by looping with a + * delay of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, + SDL_mutex * mutex, Uint32 ms); + +/* @} *//* Condition variable functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mutex_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_name.h b/code/SDL2/include/SDL_name.h new file mode 100644 index 00000000..719666ff --- /dev/null +++ b/code/SDL2/include/SDL_name.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDLname_h_ +#define _SDLname_h_ + +#if defined(__STDC__) || defined(__cplusplus) +#define NeedFunctionPrototypes 1 +#endif + +#define SDL_NAME(X) SDL_##X + +#endif /* _SDLname_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_opengl.h b/code/SDL2/include/SDL_opengl.h new file mode 100644 index 00000000..b48ea7ab --- /dev/null +++ b/code/SDL2/include/SDL_opengl.h @@ -0,0 +1,11126 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_opengl.h + * + * This is a simple file to encapsulate the OpenGL API headers. + */ + +#ifndef _SDL_opengl_h +#define _SDL_opengl_h + +#include "SDL_config.h" + +#ifndef __IPHONEOS__ + +#ifdef __WIN32__ +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +#define NOMINMAX /* Don't defined min() and max() */ +#endif +#include +#endif + +#ifdef __glext_h_ +/* Someone has already included glext.h */ +#define NO_SDL_GLEXT +#endif +#ifndef NO_SDL_GLEXT +#define __glext_h_ /* Don't let gl.h include glext.h */ +#endif +#if defined(__MACOSX__) +#include /* Header File For The OpenGL Library */ +#define __X_GL_H +#else +#include /* Header File For The OpenGL Library */ +#endif +#ifndef NO_SDL_GLEXT +#undef __glext_h_ +#endif + +/** + * \file SDL_opengl.h + * + * This file is included because glext.h is not available on some systems. + * If you don't want this version included, simply define ::NO_SDL_GLEXT. + * + * The latest version is available from: + * http://www.opengl.org/registry/ + */ + +/** + * \def NO_SDL_GLEXT + * + * Define this if you have your own version of glext.h and want to disable the + * version included in SDL_opengl.h. + */ + +#if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY) +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007-2010 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated $Date: 2010-08-03 01:30:25 -0700 (Tue, 03 Aug 2010) $ */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 64 +/* Function declaration macros - to move into glplatform.h */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif + +#ifndef GL_ARB_imaging_DEPRECATED +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#endif + +#ifndef GL_VERSION_1_5_DEPRECATED +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC1_ALPHA 0x8589 +#define GL_SRC2_ALPHA 0x858A +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_VERSION_2_0_DEPRECATED +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +#endif + +#ifndef GL_VERSION_2_1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#endif + +#ifndef GL_VERSION_2_1_DEPRECATED +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#endif + +#ifndef GL_VERSION_3_0 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_DEPTH_BUFFER 0x8223 +#define GL_STENCIL_BUFFER 0x8224 +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +/* Reuse tokens from ARB_depth_buffer_float */ +/* reuse GL_DEPTH_COMPONENT32F */ +/* reuse GL_DEPTH32F_STENCIL8 */ +/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_DEFAULT */ +/* reuse GL_FRAMEBUFFER_UNDEFINED */ +/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ +/* reuse GL_INDEX */ +/* reuse GL_MAX_RENDERBUFFER_SIZE */ +/* reuse GL_DEPTH_STENCIL */ +/* reuse GL_UNSIGNED_INT_24_8 */ +/* reuse GL_DEPTH24_STENCIL8 */ +/* reuse GL_TEXTURE_STENCIL_SIZE */ +/* reuse GL_TEXTURE_RED_TYPE */ +/* reuse GL_TEXTURE_GREEN_TYPE */ +/* reuse GL_TEXTURE_BLUE_TYPE */ +/* reuse GL_TEXTURE_ALPHA_TYPE */ +/* reuse GL_TEXTURE_DEPTH_TYPE */ +/* reuse GL_UNSIGNED_NORMALIZED */ +/* reuse GL_FRAMEBUFFER_BINDING */ +/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_BINDING */ +/* reuse GL_READ_FRAMEBUFFER */ +/* reuse GL_DRAW_FRAMEBUFFER */ +/* reuse GL_READ_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_SAMPLES */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* reuse GL_FRAMEBUFFER_COMPLETE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ +/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ +/* reuse GL_MAX_COLOR_ATTACHMENTS */ +/* reuse GL_COLOR_ATTACHMENT0 */ +/* reuse GL_COLOR_ATTACHMENT1 */ +/* reuse GL_COLOR_ATTACHMENT2 */ +/* reuse GL_COLOR_ATTACHMENT3 */ +/* reuse GL_COLOR_ATTACHMENT4 */ +/* reuse GL_COLOR_ATTACHMENT5 */ +/* reuse GL_COLOR_ATTACHMENT6 */ +/* reuse GL_COLOR_ATTACHMENT7 */ +/* reuse GL_COLOR_ATTACHMENT8 */ +/* reuse GL_COLOR_ATTACHMENT9 */ +/* reuse GL_COLOR_ATTACHMENT10 */ +/* reuse GL_COLOR_ATTACHMENT11 */ +/* reuse GL_COLOR_ATTACHMENT12 */ +/* reuse GL_COLOR_ATTACHMENT13 */ +/* reuse GL_COLOR_ATTACHMENT14 */ +/* reuse GL_COLOR_ATTACHMENT15 */ +/* reuse GL_DEPTH_ATTACHMENT */ +/* reuse GL_STENCIL_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_RENDERBUFFER_WIDTH */ +/* reuse GL_RENDERBUFFER_HEIGHT */ +/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ +/* reuse GL_STENCIL_INDEX1 */ +/* reuse GL_STENCIL_INDEX4 */ +/* reuse GL_STENCIL_INDEX8 */ +/* reuse GL_STENCIL_INDEX16 */ +/* reuse GL_RENDERBUFFER_RED_SIZE */ +/* reuse GL_RENDERBUFFER_GREEN_SIZE */ +/* reuse GL_RENDERBUFFER_BLUE_SIZE */ +/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ +/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ +/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ +/* reuse GL_MAX_SAMPLES */ +/* Reuse tokens from ARB_framebuffer_sRGB */ +/* reuse GL_FRAMEBUFFER_SRGB */ +/* Reuse tokens from ARB_half_float_vertex */ +/* reuse GL_HALF_FLOAT */ +/* Reuse tokens from ARB_map_buffer_range */ +/* reuse GL_MAP_READ_BIT */ +/* reuse GL_MAP_WRITE_BIT */ +/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ +/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ +/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ +/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ +/* Reuse tokens from ARB_texture_compression_rgtc */ +/* reuse GL_COMPRESSED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_RG_RGTC2 */ +/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ +/* Reuse tokens from ARB_texture_rg */ +/* reuse GL_RG */ +/* reuse GL_RG_INTEGER */ +/* reuse GL_R8 */ +/* reuse GL_R16 */ +/* reuse GL_RG8 */ +/* reuse GL_RG16 */ +/* reuse GL_R16F */ +/* reuse GL_R32F */ +/* reuse GL_RG16F */ +/* reuse GL_RG32F */ +/* reuse GL_R8I */ +/* reuse GL_R8UI */ +/* reuse GL_R16I */ +/* reuse GL_R16UI */ +/* reuse GL_R32I */ +/* reuse GL_R32UI */ +/* reuse GL_RG8I */ +/* reuse GL_RG8UI */ +/* reuse GL_RG16I */ +/* reuse GL_RG16UI */ +/* reuse GL_RG32I */ +/* reuse GL_RG32UI */ +/* Reuse tokens from ARB_vertex_array_object */ +/* reuse GL_VERTEX_ARRAY_BINDING */ +#endif + +#ifndef GL_VERSION_3_0_DEPRECATED +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_TEXTURE_LUMINANCE_TYPE */ +/* reuse GL_TEXTURE_INTENSITY_TYPE */ +#endif + +#ifndef GL_VERSION_3_1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +/* Reuse tokens from ARB_copy_buffer */ +/* reuse GL_COPY_READ_BUFFER */ +/* reuse GL_COPY_WRITE_BUFFER */ +/* Reuse tokens from ARB_draw_instanced (none) */ +/* Reuse tokens from ARB_uniform_buffer_object */ +/* reuse GL_UNIFORM_BUFFER */ +/* reuse GL_UNIFORM_BUFFER_BINDING */ +/* reuse GL_UNIFORM_BUFFER_START */ +/* reuse GL_UNIFORM_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ +/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ +/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ +/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ +/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ +/* reuse GL_UNIFORM_TYPE */ +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_INDEX */ +/* reuse GL_UNIFORM_OFFSET */ +/* reuse GL_UNIFORM_ARRAY_STRIDE */ +/* reuse GL_UNIFORM_MATRIX_STRIDE */ +/* reuse GL_UNIFORM_IS_ROW_MAJOR */ +/* reuse GL_UNIFORM_BLOCK_BINDING */ +/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ +/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_INVALID_INDEX */ +#endif + +#ifndef GL_VERSION_3_2 +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* Reuse tokens from ARB_depth_clamp */ +/* reuse GL_DEPTH_CLAMP */ +/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ +/* Reuse tokens from ARB_fragment_coord_conventions (none) */ +/* Reuse tokens from ARB_provoking_vertex */ +/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +/* Reuse tokens from ARB_seamless_cube_map */ +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ +/* Reuse tokens from ARB_sync */ +/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ +/* reuse GL_OBJECT_TYPE */ +/* reuse GL_SYNC_CONDITION */ +/* reuse GL_SYNC_STATUS */ +/* reuse GL_SYNC_FLAGS */ +/* reuse GL_SYNC_FENCE */ +/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ +/* reuse GL_UNSIGNALED */ +/* reuse GL_SIGNALED */ +/* reuse GL_ALREADY_SIGNALED */ +/* reuse GL_TIMEOUT_EXPIRED */ +/* reuse GL_CONDITION_SATISFIED */ +/* reuse GL_WAIT_FAILED */ +/* reuse GL_TIMEOUT_IGNORED */ +/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ +/* reuse GL_TIMEOUT_IGNORED */ +/* Reuse tokens from ARB_texture_multisample */ +/* reuse GL_SAMPLE_POSITION */ +/* reuse GL_SAMPLE_MASK */ +/* reuse GL_SAMPLE_MASK_VALUE */ +/* reuse GL_MAX_SAMPLE_MASK_WORDS */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_SAMPLES */ +/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ +/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ +/* reuse GL_MAX_INTEGER_SAMPLES */ +/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +/* Reuse tokens from ARB_blend_func_extended */ +/* reuse GL_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_ALPHA */ +/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ +/* Reuse tokens from ARB_explicit_attrib_location (none) */ +/* Reuse tokens from ARB_occlusion_query2 */ +/* reuse GL_ANY_SAMPLES_PASSED */ +/* Reuse tokens from ARB_sampler_objects */ +/* reuse GL_SAMPLER_BINDING */ +/* Reuse tokens from ARB_shader_bit_encoding (none) */ +/* Reuse tokens from ARB_texture_rgb10_a2ui */ +/* reuse GL_RGB10_A2UI */ +/* Reuse tokens from ARB_texture_swizzle */ +/* reuse GL_TEXTURE_SWIZZLE_R */ +/* reuse GL_TEXTURE_SWIZZLE_G */ +/* reuse GL_TEXTURE_SWIZZLE_B */ +/* reuse GL_TEXTURE_SWIZZLE_A */ +/* reuse GL_TEXTURE_SWIZZLE_RGBA */ +/* Reuse tokens from ARB_timer_query */ +/* reuse GL_TIME_ELAPSED */ +/* reuse GL_TIMESTAMP */ +/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ +/* reuse GL_INT_2_10_10_10_REV */ +#endif + +#ifndef GL_VERSION_4_0 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +/* Reuse tokens from ARB_texture_query_lod (none) */ +/* Reuse tokens from ARB_draw_buffers_blend (none) */ +/* Reuse tokens from ARB_draw_indirect */ +/* reuse GL_DRAW_INDIRECT_BUFFER */ +/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_gpu_shader5 */ +/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +/* Reuse tokens from ARB_gpu_shader_fp64 */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +/* Reuse tokens from ARB_shader_subroutine */ +/* reuse GL_ACTIVE_SUBROUTINES */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ +/* reuse GL_MAX_SUBROUTINES */ +/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +/* Reuse tokens from ARB_tessellation_shader */ +/* reuse GL_PATCHES */ +/* reuse GL_PATCH_VERTICES */ +/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ +/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ +/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ +/* reuse GL_TESS_GEN_MODE */ +/* reuse GL_TESS_GEN_SPACING */ +/* reuse GL_TESS_GEN_VERTEX_ORDER */ +/* reuse GL_TESS_GEN_POINT_MODE */ +/* reuse GL_ISOLINES */ +/* reuse GL_FRACTIONAL_ODD */ +/* reuse GL_FRACTIONAL_EVEN */ +/* reuse GL_MAX_PATCH_VERTICES */ +/* reuse GL_MAX_TESS_GEN_LEVEL */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_CONTROL_SHADER */ +/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ +/* Reuse tokens from ARB_transform_feedback2 */ +/* reuse GL_TRANSFORM_FEEDBACK */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ +/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ +/* Reuse tokens from ARB_transform_feedback3 */ +/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_VERSION_4_1 +/* Reuse tokens from ARB_ES2_compatibility */ +/* reuse GL_FIXED */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ +/* reuse GL_LOW_FLOAT */ +/* reuse GL_MEDIUM_FLOAT */ +/* reuse GL_HIGH_FLOAT */ +/* reuse GL_LOW_INT */ +/* reuse GL_MEDIUM_INT */ +/* reuse GL_HIGH_INT */ +/* reuse GL_SHADER_COMPILER */ +/* reuse GL_NUM_SHADER_BINARY_FORMATS */ +/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ +/* reuse GL_MAX_VARYING_VECTORS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ +/* Reuse tokens from ARB_get_program_binary */ +/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ +/* reuse GL_PROGRAM_BINARY_LENGTH */ +/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ +/* reuse GL_PROGRAM_BINARY_FORMATS */ +/* Reuse tokens from ARB_separate_shader_objects */ +/* reuse GL_VERTEX_SHADER_BIT */ +/* reuse GL_FRAGMENT_SHADER_BIT */ +/* reuse GL_GEOMETRY_SHADER_BIT */ +/* reuse GL_TESS_CONTROL_SHADER_BIT */ +/* reuse GL_TESS_EVALUATION_SHADER_BIT */ +/* reuse GL_ALL_SHADER_BITS */ +/* reuse GL_PROGRAM_SEPARABLE */ +/* reuse GL_ACTIVE_PROGRAM */ +/* reuse GL_PROGRAM_PIPELINE_BINDING */ +/* Reuse tokens from ARB_shader_precision (none) */ +/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ +/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ +/* reuse GL_MAX_VIEWPORTS */ +/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ +/* reuse GL_VIEWPORT_BOUNDS_RANGE */ +/* reuse GL_LAYER_PROVOKING_VERTEX */ +/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ +/* reuse GL_UNDEFINED_VERTEX */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#endif + +#ifndef GL_ARB_draw_instanced +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#endif + +#ifndef GL_ARB_framebuffer_object_DEPRECATED +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_HALF_FLOAT 0x140B +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_ARB_texture_rg +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#endif + +#ifndef GL_ARB_compatibility +/* ARB_compatibility just defines tokens from core 3.0 */ +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#endif + +#ifndef GL_ARB_shader_texture_lod +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_DEPTH_CLAMP 0x864F +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#endif + +#ifndef GL_ARB_sync +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#endif + +#ifndef GL_ARB_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_ARB_draw_buffers_blend +#endif + +#ifndef GL_ARB_sample_shading +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif + +#ifndef GL_ARB_texture_gather +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#endif + +#ifndef GL_ARB_texture_query_lod +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_SRC1_COLOR 0x88F9 +/* reuse GL_SRC1_ALPHA */ +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#endif + +#ifndef GL_ARB_explicit_attrib_location +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_SAMPLER_BINDING 0x8919 +#endif + +#ifndef GL_ARB_shader_bit_encoding +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_RGB10_A2UI 0x906F +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#endif + +#ifndef GL_ARB_timer_query +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ +#define GL_INT_2_10_10_10_REV 0x8D9F +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +/* reuse GL_TRIANGLES */ +/* reuse GL_QUADS */ +#define GL_ISOLINES 0x8E7A +/* reuse GL_EQUAL */ +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +/* reuse GL_CCW */ +/* reuse GL_CW */ +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +/* reuse GL_RGB32F */ +/* reuse GL_RGB32UI */ +/* reuse GL_RGB32I */ +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#endif + +#ifndef GL_ARB_shader_precision +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +/* reuse GL_RGB32I */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +#endif + +#ifndef GL_ARB_viewport_array +/* reuse GL_SCISSOR_BOX */ +/* reuse GL_VIEWPORT */ +/* reuse GL_DEPTH_RANGE */ +/* reuse GL_SCISSOR_TEST */ +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +#endif + +#ifndef GL_ARB_cl_event +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +#endif + +#ifndef GL_ARB_debug_output +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +#endif + +#ifndef GL_ARB_robustness +/* reuse GL_NO_ERROR */ +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif + +#ifndef GL_ARB_shader_stencil_export +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif + +#ifndef GL_EXT_timer_query +#define GL_TIME_ELAPSED_EXT 0x88BF +#endif + +#ifndef GL_EXT_gpu_program_parameters +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ +/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ +/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ +/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +/* reuse GL_LINES_ADJACENCY_EXT */ +/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ +/* reuse GL_TRIANGLES_ADJACENCY_EXT */ +/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +/* reuse GL_PROGRAM_POINT_SIZE_EXT */ +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#endif + +#ifndef GL_EXT_draw_instanced +#endif + +#ifndef GL_EXT_packed_float +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif + +#ifndef GL_EXT_texture_array +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +#endif + +#ifndef GL_NV_fragment_program4 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef GL_NV_geometry_shader4 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +#endif + +#ifndef GL_EXT_draw_buffers2 +#endif + +#ifndef GL_NV_transform_feedback +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +#endif + +#ifndef GL_EXT_texture_integer +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +#endif + +#ifndef GL_GREMEDY_frame_terminator +#endif + +#ifndef GL_NV_conditional_render +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +#endif + +#ifndef GL_NV_present_video +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +#endif + +#ifndef GL_EXT_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +#endif + +#ifndef GL_ATI_meminfo +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +#endif + +#ifndef GL_AMD_texture_texture4 +#endif + +#ifndef GL_AMD_vertex_shader_tesselator +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +/* reuse GL_RED_SNORM */ +/* reuse GL_RG_SNORM */ +/* reuse GL_RGB_SNORM */ +/* reuse GL_RGBA_SNORM */ +/* reuse GL_R8_SNORM */ +/* reuse GL_RG8_SNORM */ +/* reuse GL_RGB8_SNORM */ +/* reuse GL_RGBA8_SNORM */ +/* reuse GL_R16_SNORM */ +/* reuse GL_RG16_SNORM */ +/* reuse GL_RGB16_SNORM */ +/* reuse GL_RGBA16_SNORM */ +/* reuse GL_SIGNED_NORMALIZED */ +#endif + +#ifndef GL_AMD_draw_buffers_blend +#endif + +#ifndef GL_APPLE_texture_range +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +/* reuse GL_STORAGE_CACHED_APPLE */ +/* reuse GL_STORAGE_SHARED_APPLE */ +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */ +/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */ +#endif + +#ifndef GL_NV_video_capture +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +#endif + +#ifndef GL_NV_copy_image +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +#endif + +#ifndef GL_NV_texture_barrier +#endif + +#ifndef GL_AMD_shader_stencil_export +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB */ +#endif + +#ifndef GL_AMD_conservative_depth +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +/* reuse GL_PATCHES */ +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +/* reuse GL_READ_WRITE */ +/* reuse GL_WRITE_ONLY */ +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +/* reuse GL_INT64_NV */ +/* reuse GL_UNSIGNED_INT64_NV */ +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_COVERAGE_SAMPLES_NV 0x80A9 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +#endif + +#ifndef GL_AMD_debug_output +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +#if defined(__APPLE__) +typedef long GLintptr; +typedef long GLsizeiptr; +#else +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +#if defined(__APPLE__) +typedef long GLintptrARB; +typedef long GLsizeiptrARB; +#else +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for program/shader text and shader object handles */ +typedef char GLcharARB; +#if defined(__APPLE__) +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif +#endif + +/* GL type for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif + +#ifndef GL_EXT_timer_query +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#endif + +#ifndef GL_ARB_sync +typedef int64_t GLint64; +typedef uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + +#ifndef GL_ARB_cl_event +/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ +struct _cl_context; +struct _cl_event; +#endif + +#ifndef GL_ARB_debug_output +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_AMD_debug_output +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_NV_vdpau_interop +typedef GLintptr GLvdpauSurfaceNV; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_VERSION_1_2_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_VERSION_1_3_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_VERSION_1_4_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +/* OpenGL 3.0 also reuses entry points from these extensions: */ +/* ARB_framebuffer_object */ +/* ARB_map_buffer_range */ +/* ARB_vertex_array_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +#endif + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +/* OpenGL 3.1 also reuses entry points from these extensions: */ +/* ARB_copy_buffer */ +/* ARB_uniform_buffer_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +#endif + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +/* OpenGL 3.2 also reuses entry points from these extensions: */ +/* ARB_draw_elements_base_vertex */ +/* ARB_provoking_vertex */ +/* ARB_sync */ +/* ARB_texture_multisample */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +/* OpenGL 3.3 also reuses entry points from these extensions: */ +/* ARB_blend_func_extended */ +/* ARB_sampler_objects */ +/* ARB_explicit_attrib_location, but it has none */ +/* ARB_occlusion_query2 (no entry points) */ +/* ARB_shader_bit_encoding (no entry points) */ +/* ARB_texture_rgb10_a2ui (no entry points) */ +/* ARB_texture_swizzle (no entry points) */ +/* ARB_timer_query */ +/* ARB_vertex_type_2_10_10_10_rev */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +/* OpenGL 4.0 also reuses entry points from these extensions: */ +/* ARB_texture_query_lod (no entry points) */ +/* ARB_draw_indirect */ +/* ARB_gpu_shader5 (no entry points) */ +/* ARB_gpu_shader_fp64 */ +/* ARB_shader_subroutine */ +/* ARB_tessellation_shader */ +/* ARB_texture_buffer_object_rgb32 (no entry points) */ +/* ARB_texture_cube_map_array (no entry points) */ +/* ARB_texture_gather (no entry points) */ +/* ARB_transform_feedback2 */ +/* ARB_transform_feedback3 */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLclampf value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLclampf value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +/* OpenGL 4.1 also reuses entry points from these extensions: */ +/* ARB_ES2_compatibility */ +/* ARB_get_program_binary */ +/* ARB_separate_shader_objects */ +/* ARB_shader_precision (no entry points) */ +/* ARB_vertex_attrib_64bit */ +/* ARB_viewport_array */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf value, GLboolean invert); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); +#endif + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLclampf value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#endif + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#endif + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +#endif + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLclampf n, GLclampf f); +GLAPI void APIENTRY glClearDepthf (GLclampf d); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLclampf d); +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* *strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* *strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +#endif + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLclampd *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLclampd n, GLclampd f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#endif + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLuint count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLuint count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#endif + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#endif + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#endif + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#endif + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#endif + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +#endif + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#endif + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#endif + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#endif + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif + +#ifndef GL_AMD_vertex_shader_tesselator +#define GL_AMD_vertex_shader_tesselator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#endif + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#endif + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#endif + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#endif + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif + + +#ifdef __cplusplus +} +#endif + +#endif +#endif /* NO_SDL_GLEXT */ + +#endif /* !__IPHONEOS__ */ + +#endif /* _SDL_opengl_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_opengles.h b/code/SDL2/include/SDL_opengles.h new file mode 100644 index 00000000..d88e1573 --- /dev/null +++ b/code/SDL2/include/SDL_opengles.h @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_opengles.h + * + * This is a simple file to encapsulate the OpenGL ES 1.X API headers. + */ + +#ifdef __IPHONEOS__ +#include +#include +#else +#include +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif diff --git a/code/SDL2/include/SDL_opengles2.h b/code/SDL2/include/SDL_opengles2.h new file mode 100644 index 00000000..2c054792 --- /dev/null +++ b/code/SDL2/include/SDL_opengles2.h @@ -0,0 +1,2790 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_opengles.h + * + * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. + */ +#ifndef _MSC_VER +#ifdef __IPHONEOS__ +#include +#include +#else +#include +#include +#endif + +#else /* _MSC_VER */ + +/* OpenGL ES2 headers for Visual Studio */ + +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. +* +* $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ +* +* Adopters may modify this file to suit their platform. Adopters are +* encouraged to submit platform specific modifications to the Khronos +* group so that they can be included in future versions of this file. +* Please submit changes by sending them to the public Khronos Bugzilla +* (http://khronos.org/bugzilla) by filing a bug against product +* "Khronos (general)" component "Registry". +* +* A predefined template which fills in some of the bug fields can be +* reached using http://tinyurl.com/khrplatform-h-bugreport, but you +* must create a Bugzilla login first. +* +* +* See the Implementer's Guidelines for information about where this file +* should be located on your system and for more details of its use: +* http://www.khronos.org/registry/implementers_guide.pdf +* +* This file should be included as +* #include +* by Khronos client API header files that use its types and defines. +* +* The types in khrplatform.h should only be used to define API-specific types. +* +* Types defined in khrplatform.h: +* khronos_int8_t signed 8 bit +* khronos_uint8_t unsigned 8 bit +* khronos_int16_t signed 16 bit +* khronos_uint16_t unsigned 16 bit +* khronos_int32_t signed 32 bit +* khronos_uint32_t unsigned 32 bit +* khronos_int64_t signed 64 bit +* khronos_uint64_t unsigned 64 bit +* khronos_intptr_t signed same number of bits as a pointer +* khronos_uintptr_t unsigned same number of bits as a pointer +* khronos_ssize_t signed size +* khronos_usize_t unsigned size +* khronos_float_t signed 32 bit floating point +* khronos_time_ns_t unsigned 64 bit time in nanoseconds +* khronos_utime_nanoseconds_t unsigned time interval or absolute time in +* nanoseconds +* khronos_stime_nanoseconds_t signed time interval in nanoseconds +* khronos_boolean_enum_t enumerated boolean type. This should +* only be used as a base type when a client API's boolean type is +* an enum. Client APIs which use an integer or other type for +* booleans cannot use this as the base type for their boolean. +* +* Tokens defined in khrplatform.h: +* +* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. +* +* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. +* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. +* +* Calling convention macros defined in this file: +* KHRONOS_APICALL +* KHRONOS_APIENTRY +* KHRONOS_APIATTRIBUTES +* +* These may be used in function prototypes as: +* +* KHRONOS_APICALL void KHRONOS_APIENTRY funcname( +* int arg1, +* int arg2) KHRONOS_APIATTRIBUTES; +*/ + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APICALL +*------------------------------------------------------------------------- +* This precedes the return type of the function in the function prototype. +*/ +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APIENTRY +*------------------------------------------------------------------------- +* This follows the return type of the function and precedes the function +* name in the function prototype. +*/ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) +/* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APIATTRIBUTES +*------------------------------------------------------------------------- +* This follows the closing parenthesis of the function prototype arguments. +*/ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- +* basic type definitions +*-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* +* Using +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* +* Using +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* +* Win32 +*/ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* +* Sun or Digital +*/ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* +* Hypothetical platform with no float or int64 support +*/ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* +* Generic fallback +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* +* Types that are (so far) the same on all platforms +*/ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* +* Types that differ between LLP64 and LP64 architectures - in LLP64, +* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears +* to be the only LLP64 architecture in current use. +*/ +#ifdef _WIN64 +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* +* Float type +*/ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types +* +* These types can be used to represent a time interval in nanoseconds or +* an absolute Unadjusted System Time. Unadjusted System Time is the number +* of nanoseconds since some arbitrary system event (e.g. since the last +* time the system booted). The Unadjusted System Time is an unsigned +* 64 bit value that wraps back to 0 every 584 years. Time intervals +* may be either signed or unsigned. +*/ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* +* Dummy value used to pad enum types to 32 bits. +*/ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* +* Enumerated boolean type +* +* Values other than zero should be considered to be true. Therefore +* comparisons should not be made against KHRONOS_TRUE. +*/ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ + + +#ifndef __gl2platform_h_ +#define __gl2platform_h_ + +/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "OpenGL-ES" component "Registry". + */ + +/*#include */ + +#ifndef GL_APICALL +#define GL_APICALL KHRONOS_APICALL +#endif + +#ifndef GL_APIENTRY +#define GL_APIENTRY KHRONOS_APIENTRY +#endif + +#endif /* __gl2platform_h_ */ + +#ifndef __gl2_h_ +#define __gl2_h_ + +/* $Revision: 16803 $ on $Date:: 2012-02-02 09:49:18 -0800 #$ */ + +/*#include */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/*------------------------------------------------------------------------- + * Data type definitions + *-----------------------------------------------------------------------*/ + +typedef void GLvoid; +typedef char GLchar; +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef khronos_int8_t GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; + +/* GL types for handling large vertex buffer objects */ +typedef khronos_intptr_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; + +/* OpenGL ES core versions */ +#define GL_ES_VERSION_2_0 1 + +/* ClearBufferMask */ +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 + +/* Boolean */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* BeginMode */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 + +/* AlphaFunction (not supported in ES20) */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* BlendingFactorDest */ +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 + +/* BlendingFactorSrc */ +/* GL_ZERO */ +/* GL_ONE */ +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +/* GL_SRC_ALPHA */ +/* GL_ONE_MINUS_SRC_ALPHA */ +/* GL_DST_ALPHA */ +/* GL_ONE_MINUS_DST_ALPHA */ + +/* BlendEquationSeparate */ +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ +#define GL_BLEND_EQUATION_ALPHA 0x883D + +/* BlendSubtract */ +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B + +/* Separate Blend Functions */ +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 + +/* Buffer Objects */ +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 + +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 + +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 + +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 + +/* CullFaceMode */ +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 + +/* DepthFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* EnableCap */ +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 + +/* ErrorCode */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 + +/* FrontFaceDirection */ +#define GL_CW 0x0900 +#define GL_CCW 0x0901 + +/* GetPName */ +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +/* GL_SCISSOR_TEST */ +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +/* GL_POLYGON_OFFSET_FILL */ +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB + +/* GetTextureParameter */ +/* GL_TEXTURE_MAG_FILTER */ +/* GL_TEXTURE_MIN_FILTER */ +/* GL_TEXTURE_WRAP_S */ +/* GL_TEXTURE_WRAP_T */ + +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 + +/* HintMode */ +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* HintTarget */ +#define GL_GENERATE_MIPMAP_HINT 0x8192 + +/* DataType */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C + +/* PixelFormat */ +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +/* PixelType */ +/* GL_UNSIGNED_BYTE */ +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 + +/* Shaders */ +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D + +/* StencilFunction */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 + +/* StencilOp */ +/* GL_ZERO */ +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 + +/* StringName */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* TextureMagFilter */ +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 + +/* TextureMinFilter */ +/* GL_NEAREST */ +/* GL_LINEAR */ +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 + +/* TextureParameterName */ +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 + +/* TextureTarget */ +/* GL_TEXTURE_2D */ +#define GL_TEXTURE 0x1702 + +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C + +/* TextureUnit */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 + +/* TextureWrapMode */ +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 + +/* Uniform Types */ +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 + +/* Vertex Arrays */ +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F + +/* Read Format */ +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B + +/* Shader Source */ +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA + +/* Shader Binary */ +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 + +/* Shader Precision-Specified Types */ +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 + +/* Framebuffer Object. */ +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 + +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 + +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 + +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 + +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 + +#define GL_NONE 0 + +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD + +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 + +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 + +/*------------------------------------------------------------------------- + * GL core functions. + *-----------------------------------------------------------------------*/ + +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); +GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); +GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); +GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); + +#ifdef __cplusplus +} +#endif + +#endif /* __gl2_h_ */ + + +#ifndef __gl2ext_h_ +#define __gl2ext_h_ + +/* $Revision: 19436 $ on $Date:: 2012-10-10 10:37:04 -0700 #$ */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +#ifndef GL_APIENTRYP +# define GL_APIENTRYP GL_APIENTRY* +#endif + +/*------------------------------------------------------------------------* + * OES extension tokens + *------------------------------------------------------------------------*/ + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_ETC1_RGB8_OES 0x8D64 +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_DEPTH_COMPONENT24_OES 0x81A6 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#endif + +/* GL_OES_depth_texture */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +typedef void* GLeglImageOES; +#endif + +/* GL_OES_EGL_image_external */ +#ifndef GL_OES_EGL_image_external +/* GLeglImageOES defined in GL_OES_EGL_image already. */ +#define GL_TEXTURE_EXTERNAL_OES 0x8D65 +#define GL_SAMPLER_EXTERNAL_OES 0x8D66 +#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 +#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 +#endif + +/* GL_OES_element_index_uint */ +#ifndef GL_OES_element_index_uint +#define GL_UNSIGNED_INT 0x1405 +#endif + +/* GL_OES_get_program_binary */ +#ifndef GL_OES_get_program_binary +#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE +#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_WRITE_ONLY_OES 0x88B9 +#define GL_BUFFER_ACCESS_OES 0x88BB +#define GL_BUFFER_MAPPED_OES 0x88BC +#define GL_BUFFER_MAP_POINTER_OES 0x88BD +#endif + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_ALPHA8_OES 0x803C +#define GL_DEPTH_COMPONENT16_OES 0x81A5 +/* reuse GL_DEPTH_COMPONENT24_OES */ +/* reuse GL_DEPTH24_STENCIL8_OES */ +/* reuse GL_DEPTH_COMPONENT32_OES */ +#define GL_LUMINANCE4_ALPHA4_OES 0x8043 +#define GL_LUMINANCE8_ALPHA8_OES 0x8045 +#define GL_LUMINANCE8_OES 0x8040 +#define GL_RGBA4_OES 0x8056 +#define GL_RGB5_A1_OES 0x8057 +#define GL_RGB565_OES 0x8D62 +/* reuse GL_RGB8_OES */ +/* reuse GL_RGBA8_OES */ +/* reuse GL_RGB10_EXT */ +/* reuse GL_RGB10_A2_EXT */ +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_RGB8_OES 0x8051 +#define GL_RGBA8_OES 0x8058 +#endif + +/* GL_OES_standard_derivatives */ +#ifndef GL_OES_standard_derivatives +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_STENCIL_INDEX1_OES 0x8D46 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_STENCIL_INDEX4_OES 0x8D47 +#endif + +#ifndef GL_OES_surfaceless_context +#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 +#endif + +/* GL_OES_texture_3D */ +#ifndef GL_OES_texture_3D +#define GL_TEXTURE_WRAP_R_OES 0x8072 +#define GL_TEXTURE_3D_OES 0x806F +#define GL_TEXTURE_BINDING_3D_OES 0x806A +#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 +#define GL_SAMPLER_3D_OES 0x8B5F +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 +#endif + +/* GL_OES_texture_float */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_texture_float_linear */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_texture_half_float */ +#ifndef GL_OES_texture_half_float +#define GL_HALF_FLOAT_OES 0x8D61 +#endif + +/* GL_OES_texture_half_float_linear */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_texture_npot */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_vertex_array_object */ +#ifndef GL_OES_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 +#endif + +/* GL_OES_vertex_half_float */ +/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */ + +/* GL_OES_vertex_type_10_10_10_2 */ +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 +#define GL_INT_10_10_10_2_OES 0x8DF7 +#endif + +/*------------------------------------------------------------------------* + * KHR extension tokens + *------------------------------------------------------------------------*/ + +#ifndef GL_KHR_debug +typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +/* PROGRAM_PIPELINE only in GL */ +#define GL_SAMPLER 0x82E6 +/* DISPLAY_LIST only in GL */ +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + +/*------------------------------------------------------------------------* + * AMD extension tokens + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_3DC_X_AMD 0x87F9 +#define GL_3DC_XY_AMD 0x87FA +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#endif + +/* GL_AMD_performance_monitor */ +#ifndef GL_AMD_performance_monitor +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +#endif + +/* GL_AMD_program_binary_Z400 */ +#ifndef GL_AMD_program_binary_Z400 +#define GL_Z400_BINARY_AMD 0x8740 +#endif + +/*------------------------------------------------------------------------* + * ANGLE extension tokens + *------------------------------------------------------------------------*/ + +/* GL_ANGLE_framebuffer_blit */ +#ifndef GL_ANGLE_framebuffer_blit +#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA +#endif + +/* GL_ANGLE_framebuffer_multisample */ +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 +#define GL_MAX_SAMPLES_ANGLE 0x8D57 +#endif + +/* GL_ANGLE_instanced_arrays */ +#ifndef GL_ANGLE_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE +#endif + +/* GL_ANGLE_pack_reverse_row_order */ +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 +#endif + +/* GL_ANGLE_texture_usage */ +#ifndef GL_ANGLE_texture_usage +#define GL_TEXTURE_USAGE_ANGLE 0x93A2 +#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 +#endif + +/* GL_ANGLE_translated_shader_source */ +#ifndef GL_ANGLE_translated_shader_source +#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 +#endif + +/*------------------------------------------------------------------------* + * APPLE extension tokens + *------------------------------------------------------------------------*/ + +/* GL_APPLE_copy_texture_levels */ +/* No new tokens introduced by this extension. */ + +/* GL_APPLE_framebuffer_multisample */ +#ifndef GL_APPLE_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 +#define GL_MAX_SAMPLES_APPLE 0x8D57 +#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA +#endif + +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync + +#ifndef __gl3_h_ +/* These types are defined with reference to + * in the Apple extension spec, but here we use the Khronos + * portable types in khrplatform.h, and assume those types + * are always defined. + * If any other extensions using these types are defined, + * the typedefs must move out of this block and be shared. + */ +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + +#define GL_SYNC_OBJECT_APPLE 0x8A53 +#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 +#define GL_OBJECT_TYPE_APPLE 0x9112 +#define GL_SYNC_CONDITION_APPLE 0x9113 +#define GL_SYNC_STATUS_APPLE 0x9114 +#define GL_SYNC_FLAGS_APPLE 0x9115 +#define GL_SYNC_FENCE_APPLE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 +#define GL_UNSIGNALED_APPLE 0x9118 +#define GL_SIGNALED_APPLE 0x9119 +#define GL_ALREADY_SIGNALED_APPLE 0x911A +#define GL_TIMEOUT_EXPIRED_APPLE 0x911B +#define GL_CONDITION_SATISFIED_APPLE 0x911C +#define GL_WAIT_FAILED_APPLE 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 +#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull +#endif + +/* GL_APPLE_texture_format_BGRA8888 */ +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_BGRA_EXT 0x80E1 +#endif + +/* GL_APPLE_texture_max_level */ +#ifndef GL_APPLE_texture_max_level +#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D +#endif + +/*------------------------------------------------------------------------* + * ARM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_ARM_mali_program_binary */ +#ifndef GL_ARM_mali_program_binary +#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 +#endif + +/* GL_ARM_mali_shader_binary */ +#ifndef GL_ARM_mali_shader_binary +#define GL_MALI_SHADER_BINARY_ARM 0x8F60 +#endif + +/* GL_ARM_rgba8 */ +/* No new tokens introduced by this extension. */ + +/*------------------------------------------------------------------------* + * EXT extension tokens + *------------------------------------------------------------------------*/ + +/* GL_EXT_blend_minmax */ +#ifndef GL_EXT_blend_minmax +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#endif + +/* GL_EXT_color_buffer_half_float */ +#ifndef GL_EXT_color_buffer_half_float +#define GL_RGBA16F_EXT 0x881A +#define GL_RGB16F_EXT 0x881B +#define GL_RG16F_EXT 0x822F +#define GL_R16F_EXT 0x822D +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 +#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17 +#endif + +/* GL_EXT_debug_label */ +#ifndef GL_EXT_debug_label +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +#endif + +/* GL_EXT_debug_marker */ +/* No new tokens introduced by this extension. */ + +/* GL_EXT_discard_framebuffer */ +#ifndef GL_EXT_discard_framebuffer +#define GL_COLOR_EXT 0x1800 +#define GL_DEPTH_EXT 0x1801 +#define GL_STENCIL_EXT 0x1802 +#endif + +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_MAP_READ_BIT_EXT 0x0001 +#define GL_MAP_WRITE_BIT_EXT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 +#endif + +/* GL_EXT_multisampled_render_to_texture */ +#ifndef GL_EXT_multisampled_render_to_texture +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C +/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +/* GL_EXT_multiview_draw_buffers */ +#ifndef GL_EXT_multiview_draw_buffers +#define GL_COLOR_ATTACHMENT_EXT 0x90F0 +#define GL_MULTIVIEW_EXT 0x90F1 +#define GL_DRAW_BUFFER_EXT 0x0C01 +#define GL_READ_BUFFER_EXT 0x0C02 +#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 +#endif + +/* GL_EXT_multi_draw_arrays */ +/* No new tokens introduced by this extension. */ + +/* GL_EXT_occlusion_query_boolean */ +#ifndef GL_EXT_occlusion_query_boolean +#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A +#define GL_CURRENT_QUERY_EXT 0x8865 +#define GL_QUERY_RESULT_EXT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 +#endif + +/* GL_EXT_read_format_bgra */ +#ifndef GL_EXT_read_format_bgra +#define GL_BGRA_EXT 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 +#endif + +/* GL_EXT_robustness */ +#ifndef GL_EXT_robustness +/* reuse GL_NO_ERROR */ +#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 +#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 +#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 +#define GL_NO_RESET_NOTIFICATION_EXT 0x8261 +#endif + +/* GL_EXT_separate_shader_objects */ +#ifndef GL_EXT_separate_shader_objects +#define GL_VERTEX_SHADER_BIT_EXT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 +#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE_EXT 0x8258 +#define GL_ACTIVE_PROGRAM_EXT 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A +#endif + +/* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif + +/* GL_EXT_shader_texture_lod */ +/* No new tokens introduced by this extension. */ + +/* GL_EXT_shadow_samplers */ +#ifndef GL_EXT_shadow_samplers +#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C +#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D +#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E +#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 +#endif + +/* GL_EXT_sRGB */ +#ifndef GL_EXT_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 +#endif + +/* GL_EXT_texture_compression_dxt1 */ +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#endif + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_BGRA_EXT 0x80E1 +#endif + +/* GL_EXT_texture_rg */ +#ifndef GL_EXT_texture_rg +#define GL_RED_EXT 0x1903 +#define GL_RG_EXT 0x8227 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#endif + +/* GL_EXT_texture_storage */ +#ifndef GL_EXT_texture_storage +#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F +#define GL_ALPHA8_EXT 0x803C +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_RGBA32F_EXT 0x8814 +#define GL_RGB32F_EXT 0x8815 +#define GL_ALPHA32F_EXT 0x8816 +#define GL_LUMINANCE32F_EXT 0x8818 +#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 +/* reuse GL_RGBA16F_EXT */ +/* reuse GL_RGB16F_EXT */ +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGB10_EXT 0x8052 +#define GL_BGRA8_EXT 0x93A1 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +#define GL_R16F_EXT 0x822D +#define GL_RG16F_EXT 0x822F +#endif + +/* GL_EXT_texture_type_2_10_10_10_REV */ +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 +#endif + +/* GL_EXT_unpack_subimage */ +#ifndef GL_EXT_unpack_subimage +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#endif + +/*------------------------------------------------------------------------* + * DMP extension tokens + *------------------------------------------------------------------------*/ + +/* GL_DMP_shader_binary */ +#ifndef GL_DMP_shader_binary +#define GL_SHADER_BINARY_DMP 0x9250 +#endif + +/*------------------------------------------------------------------------* + * FJ extension tokens + *------------------------------------------------------------------------*/ + +/* GL_FJ_shader_binary_GCCSO */ +#ifndef GL_FJ_shader_binary_GCCSO +#define GCCSO_SHADER_BINARY_FJ 0x9260 +#endif + +/*------------------------------------------------------------------------* + * IMG extension tokens + *------------------------------------------------------------------------*/ + +/* GL_IMG_program_binary */ +#ifndef GL_IMG_program_binary +#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 +#endif + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_BGRA_IMG 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 +#endif + +/* GL_IMG_shader_binary */ +#ifndef GL_IMG_shader_binary +#define GL_SGX_BINARY_IMG 0x8C0A +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif + +/* GL_IMG_multisampled_render_to_texture */ +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 +#define GL_MAX_SAMPLES_IMG 0x9135 +#define GL_TEXTURE_SAMPLES_IMG 0x9136 +#endif + +/*------------------------------------------------------------------------* + * NV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_NV_coverage_sample */ +#ifndef GL_NV_coverage_sample +#define GL_COVERAGE_COMPONENT_NV 0x8ED0 +#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 +#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 +#define GL_COVERAGE_BUFFERS_NV 0x8ED3 +#define GL_COVERAGE_SAMPLES_NV 0x8ED4 +#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 +#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 +#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 +#define GL_COVERAGE_BUFFER_BIT_NV 0x8000 +#endif + +/* GL_NV_depth_nonlinear */ +#ifndef GL_NV_depth_nonlinear +#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C +#endif + +/* GL_NV_draw_buffers */ +#ifndef GL_NV_draw_buffers +#define GL_MAX_DRAW_BUFFERS_NV 0x8824 +#define GL_DRAW_BUFFER0_NV 0x8825 +#define GL_DRAW_BUFFER1_NV 0x8826 +#define GL_DRAW_BUFFER2_NV 0x8827 +#define GL_DRAW_BUFFER3_NV 0x8828 +#define GL_DRAW_BUFFER4_NV 0x8829 +#define GL_DRAW_BUFFER5_NV 0x882A +#define GL_DRAW_BUFFER6_NV 0x882B +#define GL_DRAW_BUFFER7_NV 0x882C +#define GL_DRAW_BUFFER8_NV 0x882D +#define GL_DRAW_BUFFER9_NV 0x882E +#define GL_DRAW_BUFFER10_NV 0x882F +#define GL_DRAW_BUFFER11_NV 0x8830 +#define GL_DRAW_BUFFER12_NV 0x8831 +#define GL_DRAW_BUFFER13_NV 0x8832 +#define GL_DRAW_BUFFER14_NV 0x8833 +#define GL_DRAW_BUFFER15_NV 0x8834 +#define GL_COLOR_ATTACHMENT0_NV 0x8CE0 +#define GL_COLOR_ATTACHMENT1_NV 0x8CE1 +#define GL_COLOR_ATTACHMENT2_NV 0x8CE2 +#define GL_COLOR_ATTACHMENT3_NV 0x8CE3 +#define GL_COLOR_ATTACHMENT4_NV 0x8CE4 +#define GL_COLOR_ATTACHMENT5_NV 0x8CE5 +#define GL_COLOR_ATTACHMENT6_NV 0x8CE6 +#define GL_COLOR_ATTACHMENT7_NV 0x8CE7 +#define GL_COLOR_ATTACHMENT8_NV 0x8CE8 +#define GL_COLOR_ATTACHMENT9_NV 0x8CE9 +#define GL_COLOR_ATTACHMENT10_NV 0x8CEA +#define GL_COLOR_ATTACHMENT11_NV 0x8CEB +#define GL_COLOR_ATTACHMENT12_NV 0x8CEC +#define GL_COLOR_ATTACHMENT13_NV 0x8CED +#define GL_COLOR_ATTACHMENT14_NV 0x8CEE +#define GL_COLOR_ATTACHMENT15_NV 0x8CEF +#endif + +/* GL_NV_fbo_color_attachments */ +#ifndef GL_NV_fbo_color_attachments +#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF +/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */ +#endif + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +/* GL_NV_read_buffer */ +#ifndef GL_NV_read_buffer +#define GL_READ_BUFFER_NV 0x0C02 +#endif + +/* GL_NV_read_buffer_front */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_depth */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_depth_stencil */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_stencil */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_texture_compression_s3tc_update */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_texture_npot_2D_mipmap */ +/* No new tokens introduced by this extension. */ + +/*------------------------------------------------------------------------* + * QCOM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_QCOM_alpha_test */ +#ifndef GL_QCOM_alpha_test +#define GL_ALPHA_TEST_QCOM 0x0BC0 +#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 +#define GL_ALPHA_TEST_REF_QCOM 0x0BC2 +#endif + +/* GL_QCOM_binning_control */ +#ifndef GL_QCOM_binning_control +#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 +#define GL_CPU_OPTIMIZED_QCOM 0x8FB1 +#define GL_GPU_OPTIMIZED_QCOM 0x8FB2 +#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 +#endif + +/* GL_QCOM_driver_control */ +/* No new tokens introduced by this extension. */ + +/* GL_QCOM_extended_get */ +#ifndef GL_QCOM_extended_get +#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 +#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 +#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 +#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 +#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 +#define GL_TEXTURE_TYPE_QCOM 0x8BD7 +#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 +#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 +#define GL_TEXTURE_TARGET_QCOM 0x8BDA +#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB +#define GL_STATE_RESTORE 0x8BDC +#endif + +/* GL_QCOM_extended_get2 */ +/* No new tokens introduced by this extension. */ + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 +#endif + +/* GL_QCOM_writeonly_rendering */ +#ifndef GL_QCOM_writeonly_rendering +#define GL_WRITEONLY_RENDERING_QCOM 0x8823 +#endif + +/* GL_QCOM_tiled_rendering */ +#ifndef GL_QCOM_tiled_rendering +#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 +#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 +#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 +#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 +#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 +#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 +#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 +#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 +#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 +#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 +#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 +#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 +#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 +#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 +#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 +#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 +#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 +#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 +#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 +#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 +#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 +#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 +#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 +#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 +#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 +#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 +#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 +#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 +#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 +#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 +#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 +#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 +#endif + +/*------------------------------------------------------------------------* + * VIV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_VIV_shader_binary */ +#ifndef GL_VIV_shader_binary +#define GL_SHADER_BINARY_VIV 0x8FC4 +#endif + +/*------------------------------------------------------------------------* + * End of extension tokens, start of corresponding extension functions + *------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------* + * OES extension functions + *------------------------------------------------------------------------*/ + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_OES_compressed_ETC1_RGB8_texture 1 +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_OES_depth24 1 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_OES_depth32 1 +#endif + +/* GL_OES_depth_texture */ +#ifndef GL_OES_depth_texture +#define GL_OES_depth_texture 1 +#endif + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#endif + +/* GL_OES_EGL_image_external */ +#ifndef GL_OES_EGL_image_external +#define GL_OES_EGL_image_external 1 +/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */ +#endif + +/* GL_OES_element_index_uint */ +#ifndef GL_OES_element_index_uint +#define GL_OES_element_index_uint 1 +#endif + +/* GL_OES_fbo_render_mipmap */ +#ifndef GL_OES_fbo_render_mipmap +#define GL_OES_fbo_render_mipmap 1 +#endif + +/* GL_OES_fragment_precision_high */ +#ifndef GL_OES_fragment_precision_high +#define GL_OES_fragment_precision_high 1 +#endif + +/* GL_OES_get_program_binary */ +#ifndef GL_OES_get_program_binary +#define GL_OES_get_program_binary 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); +#endif +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_OES_mapbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); +GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid** params); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params); +#endif + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_OES_packed_depth_stencil 1 +#endif + +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_OES_required_internalformat 1 +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_OES_rgb8_rgba8 1 +#endif + +/* GL_OES_standard_derivatives */ +#ifndef GL_OES_standard_derivatives +#define GL_OES_standard_derivatives 1 +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_OES_stencil1 1 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_OES_stencil4 1 +#endif + +#ifndef GL_OES_surfaceless_context +#define GL_OES_surfaceless_context 1 +#endif + +/* GL_OES_texture_3D */ +#ifndef GL_OES_texture_3D +#define GL_OES_texture_3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#endif +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#endif + +/* GL_OES_texture_float */ +#ifndef GL_OES_texture_float +#define GL_OES_texture_float 1 +#endif + +/* GL_OES_texture_float_linear */ +#ifndef GL_OES_texture_float_linear +#define GL_OES_texture_float_linear 1 +#endif + +/* GL_OES_texture_half_float */ +#ifndef GL_OES_texture_half_float +#define GL_OES_texture_half_float 1 +#endif + +/* GL_OES_texture_half_float_linear */ +#ifndef GL_OES_texture_half_float_linear +#define GL_OES_texture_half_float_linear 1 +#endif + +/* GL_OES_texture_npot */ +#ifndef GL_OES_texture_npot +#define GL_OES_texture_npot 1 +#endif + +/* GL_OES_vertex_array_object */ +#ifndef GL_OES_vertex_array_object +#define GL_OES_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); +#endif +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); +#endif + +/* GL_OES_vertex_half_float */ +#ifndef GL_OES_vertex_half_float +#define GL_OES_vertex_half_float 1 +#endif + +/* GL_OES_vertex_type_10_10_10_2 */ +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_OES_vertex_type_10_10_10_2 1 +#endif + +/*------------------------------------------------------------------------* + * KHR extension functions + *------------------------------------------------------------------------*/ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GL_APICALL void GL_APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GL_APICALL void GL_APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GL_APICALL void GL_APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GL_APICALL void GL_APIENTRY glPopDebugGroup (void); +GL_APICALL void GL_APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glGetPointerv (GLenum pname, void **params); +#endif +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params); +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif + + +/*------------------------------------------------------------------------* + * AMD extension functions + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_AMD_compressed_3DC_texture 1 +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_AMD_compressed_ATC_texture 1 +#endif + +/* AMD_performance_monitor */ +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); +GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); +typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif + +/* GL_AMD_program_binary_Z400 */ +#ifndef GL_AMD_program_binary_Z400 +#define GL_AMD_program_binary_Z400 1 +#endif + +/*------------------------------------------------------------------------* + * ANGLE extension functions + *------------------------------------------------------------------------*/ + +/* GL_ANGLE_framebuffer_blit */ +#ifndef GL_ANGLE_framebuffer_blit +#define GL_ANGLE_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +/* GL_ANGLE_framebuffer_multisample */ +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_ANGLE_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_ANGLE_instanced_arrays +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); +#endif +typedef void (GL_APIENTRYP PFLGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFLGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +typedef void (GL_APIENTRYP PFLGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); +#endif + +/* GL_ANGLE_pack_reverse_row_order */ +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_ANGLE_pack_reverse_row_order 1 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_ANGLE_texture_compression_dxt3 1 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_ANGLE_texture_compression_dxt5 1 +#endif + +/* GL_ANGLE_texture_usage */ +#ifndef GL_ANGLE_texture_usage +#define GL_ANGLE_texture_usage 1 +#endif + +#ifndef GL_ANGLE_translated_shader_source +#define GL_ANGLE_translated_shader_source 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); +#endif +typedef void (GL_APIENTRYP PFLGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); +#endif + +/*------------------------------------------------------------------------* + * APPLE extension functions + *------------------------------------------------------------------------*/ + +/* GL_APPLE_copy_texture_levels */ +#ifndef GL_APPLE_copy_texture_levels +#define GL_APPLE_copy_texture_levels 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif +typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif + +/* GL_APPLE_framebuffer_multisample */ +#ifndef GL_APPLE_framebuffer_multisample +#define GL_APPLE_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); +#endif + +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync +#define GL_APPLE_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +/* GL_APPLE_texture_format_BGRA8888 */ +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_APPLE_texture_format_BGRA8888 1 +#endif + +/* GL_APPLE_texture_max_level */ +#ifndef GL_APPLE_texture_max_level +#define GL_APPLE_texture_max_level 1 +#endif + +/*------------------------------------------------------------------------* + * ARM extension functions + *------------------------------------------------------------------------*/ + +/* GL_ARM_mali_program_binary */ +#ifndef GL_ARM_mali_program_binary +#define GL_ARM_mali_program_binary 1 +#endif + +/* GL_ARM_mali_shader_binary */ +#ifndef GL_ARM_mali_shader_binary +#define GL_ARM_mali_shader_binary 1 +#endif + +/* GL_ARM_rgba8 */ +#ifndef GL_ARM_rgba8 +#define GL_ARM_rgba8 1 +#endif + +/*------------------------------------------------------------------------* + * EXT extension functions + *------------------------------------------------------------------------*/ + +/* GL_EXT_blend_minmax */ +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#endif + +/* GL_EXT_color_buffer_half_float */ +#ifndef GL_EXT_color_buffer_half_float +#define GL_EXT_color_buffer_half_float 1 +#endif + +/* GL_EXT_debug_label */ +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif + +/* GL_EXT_debug_marker */ +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void); +#endif +typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#endif + +/* GL_EXT_discard_framebuffer */ +#ifndef GL_EXT_discard_framebuffer +#define GL_EXT_discard_framebuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif +typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif + +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_EXT_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + +/* GL_EXT_multisampled_render_to_texture */ +#ifndef GL_EXT_multisampled_render_to_texture +#define GL_EXT_multisampled_render_to_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif + +/* GL_EXT_multiview_draw_buffers */ +#ifndef GL_EXT_multiview_draw_buffers +#define GL_EXT_multiview_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); +GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); +GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); +#endif +typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +/* GL_EXT_occlusion_query_boolean */ +#ifndef GL_EXT_occlusion_query_boolean +#define GL_EXT_occlusion_query_boolean 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); +#endif +typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +/* GL_EXT_read_format_bgra */ +#ifndef GL_EXT_read_format_bgra +#define GL_EXT_read_format_bgra 1 +#endif + +/* GL_EXT_robustness */ +#ifndef GL_EXT_robustness +#define GL_EXT_robustness 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void); +GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, float *params); +GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#endif +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, float *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#endif + +/* GL_EXT_separate_shader_objects */ +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program); +GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings); +GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines); +GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint x); +GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint x, GLint y); +GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z); +GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat x); +GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings); +typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint x, GLint y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif + +/* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#endif + +/* GL_EXT_shader_texture_lod */ +#ifndef GL_EXT_shader_texture_lod +#define GL_EXT_shader_texture_lod 1 +#endif + +/* GL_EXT_shadow_samplers */ +#ifndef GL_EXT_shadow_samplers +#define GL_EXT_shadow_samplers 1 +#endif + +/* GL_EXT_sRGB */ +#ifndef GL_EXT_sRGB +#define GL_EXT_sRGB 1 +#endif + +/* GL_EXT_texture_compression_dxt1 */ +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_EXT_texture_compression_dxt1 1 +#endif + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_EXT_texture_format_BGRA8888 1 +#endif + +/* GL_EXT_texture_rg */ +#ifndef GL_EXT_texture_rg +#define GL_EXT_texture_rg 1 +#endif + +/* GL_EXT_texture_storage */ +#ifndef GL_EXT_texture_storage +#define GL_EXT_texture_storage 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif + +/* GL_EXT_texture_type_2_10_10_10_REV */ +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_EXT_texture_type_2_10_10_10_REV 1 +#endif + +/* GL_EXT_unpack_subimage */ +#ifndef GL_EXT_unpack_subimage +#define GL_EXT_unpack_subimage 1 +#endif + +/*------------------------------------------------------------------------* + * DMP extension functions + *------------------------------------------------------------------------*/ + +/* GL_DMP_shader_binary */ +#ifndef GL_DMP_shader_binary +#define GL_DMP_shader_binary 1 +#endif + +/*------------------------------------------------------------------------* + * FJ extension functions + *------------------------------------------------------------------------*/ + +/* GL_FJ_shader_binary_GCCSO */ +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_FJ_shader_binary_GCCSO 1 +#endif + +/*------------------------------------------------------------------------* + * IMG extension functions + *------------------------------------------------------------------------*/ + +/* GL_IMG_program_binary */ +#ifndef GL_IMG_program_binary +#define GL_IMG_program_binary 1 +#endif + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_IMG_read_format 1 +#endif + +/* GL_IMG_shader_binary */ +#ifndef GL_IMG_shader_binary +#define GL_IMG_shader_binary 1 +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_IMG_texture_compression_pvrtc 1 +#endif + +/* GL_IMG_multisampled_render_to_texture */ +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_IMG_multisampled_render_to_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif + +/*------------------------------------------------------------------------* + * NV extension functions + *------------------------------------------------------------------------*/ + +/* GL_NV_coverage_sample */ +#ifndef GL_NV_coverage_sample +#define GL_NV_coverage_sample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); +GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); +#endif +typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); +typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); +#endif + +/* GL_NV_depth_nonlinear */ +#ifndef GL_NV_depth_nonlinear +#define GL_NV_depth_nonlinear 1 +#endif + +/* GL_NV_draw_buffers */ +#ifndef GL_NV_draw_buffers +#define GL_NV_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); +#endif + +/* GL_NV_fbo_color_attachments */ +#ifndef GL_NV_fbo_color_attachments +#define GL_NV_fbo_color_attachments 1 +#endif + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *); +GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint); +GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint); +GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint); +GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint, GLenum); +#endif +typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +/* GL_NV_read_buffer */ +#ifndef GL_NV_read_buffer +#define GL_NV_read_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode); +#endif +typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); +#endif + +/* GL_NV_read_buffer_front */ +#ifndef GL_NV_read_buffer_front +#define GL_NV_read_buffer_front 1 +#endif + +/* GL_NV_read_depth */ +#ifndef GL_NV_read_depth +#define GL_NV_read_depth 1 +#endif + +/* GL_NV_read_depth_stencil */ +#ifndef GL_NV_read_depth_stencil +#define GL_NV_read_depth_stencil 1 +#endif + +/* GL_NV_read_stencil */ +#ifndef GL_NV_read_stencil +#define GL_NV_read_stencil 1 +#endif + +/* GL_NV_texture_compression_s3tc_update */ +#ifndef GL_NV_texture_compression_s3tc_update +#define GL_NV_texture_compression_s3tc_update 1 +#endif + +/* GL_NV_texture_npot_2D_mipmap */ +#ifndef GL_NV_texture_npot_2D_mipmap +#define GL_NV_texture_npot_2D_mipmap 1 +#endif + +/*------------------------------------------------------------------------* + * QCOM extension functions + *------------------------------------------------------------------------*/ + +/* GL_QCOM_alpha_test */ +#ifndef GL_QCOM_alpha_test +#define GL_QCOM_alpha_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); +#endif +typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); +#endif + +/* GL_QCOM_binning_control */ +#ifndef GL_QCOM_binning_control +#define GL_QCOM_binning_control 1 +#endif + +/* GL_QCOM_driver_control */ +#ifndef GL_QCOM_driver_control +#define GL_QCOM_driver_control 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); +GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); +GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); +#endif +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +#endif + +/* GL_QCOM_extended_get */ +#ifndef GL_QCOM_extended_get +#define GL_QCOM_extended_get 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); +GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); +GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params); +#endif +typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params); +#endif + +/* GL_QCOM_extended_get2 */ +#ifndef GL_QCOM_extended_get2 +#define GL_QCOM_extended_get2 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); +GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); +GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif +typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_QCOM_perfmon_global_mode 1 +#endif + +/* GL_QCOM_writeonly_rendering */ +#ifndef GL_QCOM_writeonly_rendering +#define GL_QCOM_writeonly_rendering 1 +#endif + +/* GL_QCOM_tiled_rendering */ +#ifndef GL_QCOM_tiled_rendering +#define GL_QCOM_tiled_rendering 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); +#endif +typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); +#endif + +/*------------------------------------------------------------------------* + * VIV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_VIV_shader_binary */ +#ifndef GL_VIV_shader_binary +#define GL_VIV_shader_binary 1 +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __gl2ext_h_ */ + +#endif /* _MSC_VER */ + +#ifndef APIENTRY +#define APIENTRY GL_APIENTRY +#endif diff --git a/code/SDL2/include/SDL_pixels.h b/code/SDL2/include/SDL_pixels.h new file mode 100644 index 00000000..3131af7b --- /dev/null +++ b/code/SDL2/include/SDL_pixels.h @@ -0,0 +1,429 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_pixels.h + * + * Header for the enumerated pixel format definitions. + */ + +#ifndef _SDL_pixels_h +#define _SDL_pixels_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Transparency definitions + * + * These define alpha as the opacity of a surface. + */ +/* @{ */ +#define SDL_ALPHA_OPAQUE 255 +#define SDL_ALPHA_TRANSPARENT 0 +/* @} */ + +/** Pixel type. */ +enum +{ + SDL_PIXELTYPE_UNKNOWN, + SDL_PIXELTYPE_INDEX1, + SDL_PIXELTYPE_INDEX4, + SDL_PIXELTYPE_INDEX8, + SDL_PIXELTYPE_PACKED8, + SDL_PIXELTYPE_PACKED16, + SDL_PIXELTYPE_PACKED32, + SDL_PIXELTYPE_ARRAYU8, + SDL_PIXELTYPE_ARRAYU16, + SDL_PIXELTYPE_ARRAYU32, + SDL_PIXELTYPE_ARRAYF16, + SDL_PIXELTYPE_ARRAYF32 +}; + +/** Bitmap pixel order, high bit -> low bit. */ +enum +{ + SDL_BITMAPORDER_NONE, + SDL_BITMAPORDER_4321, + SDL_BITMAPORDER_1234 +}; + +/** Packed component order, high bit -> low bit. */ +enum +{ + SDL_PACKEDORDER_NONE, + SDL_PACKEDORDER_XRGB, + SDL_PACKEDORDER_RGBX, + SDL_PACKEDORDER_ARGB, + SDL_PACKEDORDER_RGBA, + SDL_PACKEDORDER_XBGR, + SDL_PACKEDORDER_BGRX, + SDL_PACKEDORDER_ABGR, + SDL_PACKEDORDER_BGRA +}; + +/** Array component order, low byte -> high byte. */ +enum +{ + SDL_ARRAYORDER_NONE, + SDL_ARRAYORDER_RGB, + SDL_ARRAYORDER_RGBA, + SDL_ARRAYORDER_ARGB, + SDL_ARRAYORDER_BGR, + SDL_ARRAYORDER_BGRA, + SDL_ARRAYORDER_ABGR +}; + +/** Packed component layout. */ +enum +{ + SDL_PACKEDLAYOUT_NONE, + SDL_PACKEDLAYOUT_332, + SDL_PACKEDLAYOUT_4444, + SDL_PACKEDLAYOUT_1555, + SDL_PACKEDLAYOUT_5551, + SDL_PACKEDLAYOUT_565, + SDL_PACKEDLAYOUT_8888, + SDL_PACKEDLAYOUT_2101010, + SDL_PACKEDLAYOUT_1010102 +}; + +#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D) + +#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \ + ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \ + ((bits) << 8) | ((bytes) << 0)) + +#define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F) +#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F) +#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F) +#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F) +#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF) +#define SDL_BYTESPERPIXEL(X) \ + (SDL_ISPIXELFORMAT_FOURCC(X) ? \ + ((((X) == SDL_PIXELFORMAT_YUY2) || \ + ((X) == SDL_PIXELFORMAT_UYVY) || \ + ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF)) + +#define SDL_ISPIXELFORMAT_INDEXED(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) + +#define SDL_ISPIXELFORMAT_ALPHA(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) + +/* The flag is set to 1 because 0x1? is not in the printable ASCII range */ +#define SDL_ISPIXELFORMAT_FOURCC(format) \ + ((format) && (SDL_PIXELFLAG(format) != 1)) + +/* Note: If you modify this list, update SDL_GetPixelFormatName() */ +enum +{ + SDL_PIXELFORMAT_UNKNOWN, + SDL_PIXELFORMAT_INDEX1LSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, + 1, 0), + SDL_PIXELFORMAT_INDEX1MSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, + 1, 0), + SDL_PIXELFORMAT_INDEX4LSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, + 4, 0), + SDL_PIXELFORMAT_INDEX4MSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, + 4, 0), + SDL_PIXELFORMAT_INDEX8 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), + SDL_PIXELFORMAT_RGB332 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_332, 8, 1), + SDL_PIXELFORMAT_RGB444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_4444, 12, 2), + SDL_PIXELFORMAT_RGB555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_1555, 15, 2), + SDL_PIXELFORMAT_BGR555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_1555, 15, 2), + SDL_PIXELFORMAT_ARGB4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_RGBA4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_ABGR4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_BGRA4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_ARGB1555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_1555, 16, 2), + SDL_PIXELFORMAT_RGBA5551 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_5551, 16, 2), + SDL_PIXELFORMAT_ABGR1555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_1555, 16, 2), + SDL_PIXELFORMAT_BGRA5551 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_5551, 16, 2), + SDL_PIXELFORMAT_RGB565 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_565, 16, 2), + SDL_PIXELFORMAT_BGR565 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_565, 16, 2), + SDL_PIXELFORMAT_RGB24 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, + 24, 3), + SDL_PIXELFORMAT_BGR24 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, + 24, 3), + SDL_PIXELFORMAT_RGB888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_RGBX8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_BGR888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_BGRX8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_ARGB8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_RGBA8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_ABGR8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_BGRA8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_ARGB2101010 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_2101010, 32, 4), + + SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */ + SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), + SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */ + SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), + SDL_PIXELFORMAT_YUY2 = /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), + SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), + SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U') +}; + +typedef struct SDL_Color +{ + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 a; +} SDL_Color; +#define SDL_Colour SDL_Color + +typedef struct SDL_Palette +{ + int ncolors; + SDL_Color *colors; + Uint32 version; + int refcount; +} SDL_Palette; + +/** + * \note Everything in the pixel format structure is read-only. + */ +typedef struct SDL_PixelFormat +{ + Uint32 format; + SDL_Palette *palette; + Uint8 BitsPerPixel; + Uint8 BytesPerPixel; + Uint8 padding[2]; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; + Uint8 Rloss; + Uint8 Gloss; + Uint8 Bloss; + Uint8 Aloss; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; + int refcount; + struct SDL_PixelFormat *next; +} SDL_PixelFormat; + +/** + * \brief Get the human readable name of a pixel format + */ +extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format); + +/** + * \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks. + * + * \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible. + * + * \sa SDL_MasksToPixelFormatEnum() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, + int *bpp, + Uint32 * Rmask, + Uint32 * Gmask, + Uint32 * Bmask, + Uint32 * Amask); + +/** + * \brief Convert a bpp and RGBA masks to an enumerated pixel format. + * + * \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion + * wasn't possible. + * + * \sa SDL_PixelFormatEnumToMasks() + */ +extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, + Uint32 Rmask, + Uint32 Gmask, + Uint32 Bmask, + Uint32 Amask); + +/** + * \brief Create an SDL_PixelFormat structure from a pixel format enum. + */ +extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); + +/** + * \brief Free an SDL_PixelFormat structure. + */ +extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); + +/** + * \brief Create a palette structure with the specified number of color + * entries. + * + * \return A new palette, or NULL if there wasn't enough memory. + * + * \note The palette entries are initialized to white. + * + * \sa SDL_FreePalette() + */ +extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); + +/** + * \brief Set the palette for a pixel format structure. + */ +extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, + SDL_Palette *palette); + +/** + * \brief Set a range of colors in a palette. + * + * \param palette The palette to modify. + * \param colors An array of colors to copy into the palette. + * \param firstcolor The index of the first palette entry to modify. + * \param ncolors The number of entries to modify. + * + * \return 0 on success, or -1 if not all of the colors could be set. + */ +extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, + const SDL_Color * colors, + int firstcolor, int ncolors); + +/** + * \brief Free a palette created with SDL_AllocPalette(). + * + * \sa SDL_AllocPalette() + */ +extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); + +/** + * \brief Maps an RGB triple to an opaque pixel value for a given pixel format. + * + * \sa SDL_MapRGBA + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format, + Uint8 r, Uint8 g, Uint8 b); + +/** + * \brief Maps an RGBA quadruple to a pixel value for a given pixel format. + * + * \sa SDL_MapRGB + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format, + Uint8 r, Uint8 g, Uint8 b, + Uint8 a); + +/** + * \brief Get the RGB components from a pixel of the specified format. + * + * \sa SDL_GetRGBA + */ +extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, + const SDL_PixelFormat * format, + Uint8 * r, Uint8 * g, Uint8 * b); + +/** + * \brief Get the RGBA components from a pixel of the specified format. + * + * \sa SDL_GetRGB + */ +extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, + const SDL_PixelFormat * format, + Uint8 * r, Uint8 * g, Uint8 * b, + Uint8 * a); + +/** + * \brief Calculate a 256 entry gamma ramp for a gamma value. + */ +extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_pixels_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_platform.h b/code/SDL2/include/SDL_platform.h new file mode 100644 index 00000000..dbe71a70 --- /dev/null +++ b/code/SDL2/include/SDL_platform.h @@ -0,0 +1,164 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_platform.h + * + * Try to get a standard set of platform defines. + */ + +#ifndef _SDL_platform_h +#define _SDL_platform_h + +#if defined(_AIX) +#undef __AIX__ +#define __AIX__ 1 +#endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif +#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) +#undef __BSDI__ +#define __BSDI__ 1 +#endif +#if defined(_arch_dreamcast) +#undef __DREAMCAST__ +#define __DREAMCAST__ 1 +#endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#undef __FREEBSD__ +#define __FREEBSD__ 1 +#endif +#if defined(hpux) || defined(__hpux) || defined(__hpux__) +#undef __HPUX__ +#define __HPUX__ 1 +#endif +#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) +#undef __IRIX__ +#define __IRIX__ 1 +#endif +#if defined(linux) || defined(__linux) || defined(__linux__) +#undef __LINUX__ +#define __LINUX__ 1 +#endif +#if defined(ANDROID) || defined(__ANDROID__) +#undef __ANDROID__ +#undef __LINUX__ /* do we need to do this? */ +#define __ANDROID__ 1 +#endif + +#if defined(__APPLE__) +/* lets us know what version of Mac OS X we're compiling on */ +#include "AvailabilityMacros.h" +#include "TargetConditionals.h" +#if TARGET_OS_IPHONE +/* if compiling for iPhone */ +#undef __IPHONEOS__ +#define __IPHONEOS__ 1 +#undef __MACOSX__ +#else +/* if not compiling for iPhone */ +#undef __MACOSX__ +#define __MACOSX__ 1 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +# error SDL for Mac OS X only supports deploying on 10.5 and above. +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */ +#endif /* TARGET_OS_IPHONE */ +#endif /* defined(__APPLE__) */ + +#if defined(__NetBSD__) +#undef __NETBSD__ +#define __NETBSD__ 1 +#endif +#if defined(__OpenBSD__) +#undef __OPENBSD__ +#define __OPENBSD__ 1 +#endif +#if defined(__OS2__) +#undef __OS2__ +#define __OS2__ 1 +#endif +#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) +#undef __OSF__ +#define __OSF__ 1 +#endif +#if defined(__QNXNTO__) +#undef __QNXNTO__ +#define __QNXNTO__ 1 +#endif +#if defined(riscos) || defined(__riscos) || defined(__riscos__) +#undef __RISCOS__ +#define __RISCOS__ 1 +#endif +#if defined(__SVR4) +#undef __SOLARIS__ +#define __SOLARIS__ 1 +#endif + +#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) +/* Try to find out if we're compiling for WinRT or non-WinRT */ +/* If _USING_V110_SDK71_ is defined it means we are using the v110_xp or v120_xp toolset. */ +#if defined(_MSC_VER) && (_MSC_VER >= 1700) && !(_USING_V110_SDK71_) /* _MSC_VER==1700 for MSVC 2012 */ +#include +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#undef __WINDOWS__ +#define __WINDOWS__ 1 +/* See if we're compiling for WinRT: */ +#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +#undef __WINRT__ +#define __WINRT__ 1 +#endif +#else +#undef __WINDOWS__ +#define __WINDOWS__ 1 +#endif /* _MSC_VER < 1700 */ +#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ + +#if defined(__WINDOWS__) +#undef __WIN32__ +#define __WIN32__ 1 +#endif +#if defined(__PSP__) +#undef __PSP__ +#define __PSP__ 1 +#endif + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Gets the name of the platform. + */ +extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_platform_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_power.h b/code/SDL2/include/SDL_power.h new file mode 100644 index 00000000..cf71c982 --- /dev/null +++ b/code/SDL2/include/SDL_power.h @@ -0,0 +1,75 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_power_h +#define _SDL_power_h + +/** + * \file SDL_power.h + * + * Header for the SDL power management routines. + */ + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The basic state for the system's power supply. + */ +typedef enum +{ + SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ + SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ + SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ + SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ + SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ +} SDL_PowerState; + + +/** + * \brief Get the current power supply details. + * + * \param secs Seconds of battery life left. You can pass a NULL here if + * you don't care. Will return -1 if we can't determine a + * value, or we're not running on a battery. + * + * \param pct Percentage of battery life left, between 0 and 100. You can + * pass a NULL here if you don't care. Will return -1 if we + * can't determine a value, or we're not running on a battery. + * + * \return The state of the battery (if any). + */ +extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_power_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_quit.h b/code/SDL2/include/SDL_quit.h new file mode 100644 index 00000000..8a786445 --- /dev/null +++ b/code/SDL2/include/SDL_quit.h @@ -0,0 +1,58 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_quit.h + * + * Include file for SDL quit event handling. + */ + +#ifndef _SDL_quit_h +#define _SDL_quit_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/** + * \file SDL_quit.h + * + * An ::SDL_QUIT event is generated when the user tries to close the application + * window. If it is ignored or filtered out, the window will remain open. + * If it is not ignored or filtered, it is queued normally and the window + * is allowed to close. When the window is closed, screen updates will + * complete, but have no effect. + * + * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) + * and SIGTERM (system termination request), if handlers do not already + * exist, that generate ::SDL_QUIT events as well. There is no way + * to determine the cause of an ::SDL_QUIT event, but setting a signal + * handler in your application will override the default generation of + * quit events for that signal. + * + * \sa SDL_Quit() + */ + +/* There are no functions directly affecting the quit event */ + +#define SDL_QuitRequested() \ + (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) + +#endif /* _SDL_quit_h */ diff --git a/code/SDL2/include/SDL_rect.h b/code/SDL2/include/SDL_rect.h new file mode 100644 index 00000000..0a95a334 --- /dev/null +++ b/code/SDL2/include/SDL_rect.h @@ -0,0 +1,138 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_rect.h + * + * Header file for SDL_rect definition and management functions. + */ + +#ifndef _SDL_rect_h +#define _SDL_rect_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_pixels.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The structure that defines a point + * + * \sa SDL_EnclosePoints + */ +typedef struct SDL_Point +{ + int x; + int y; +} SDL_Point; + +/** + * \brief A rectangle, with the origin at the upper left. + * + * \sa SDL_RectEmpty + * \sa SDL_RectEquals + * \sa SDL_HasIntersection + * \sa SDL_IntersectRect + * \sa SDL_UnionRect + * \sa SDL_EnclosePoints + */ +typedef struct SDL_Rect +{ + int x, y; + int w, h; +} SDL_Rect; + +/** + * \brief Returns true if the rectangle has no area. + */ +SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r) +{ + return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE; +} + +/** + * \brief Returns true if the two rectangles are equal. + */ +SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) +{ + return (a && b && (a->x == b->x) && (a->y == b->y) && + (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE; +} + +/** + * \brief Determine whether two rectangles intersect. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, + const SDL_Rect * B); + +/** + * \brief Calculate the intersection of two rectangles. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, + const SDL_Rect * B, + SDL_Rect * result); + +/** + * \brief Calculate the union of two rectangles. + */ +extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, + const SDL_Rect * B, + SDL_Rect * result); + +/** + * \brief Calculate a minimal rectangle enclosing a set of points + * + * \return SDL_TRUE if any points were within the clipping rect + */ +extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, + int count, + const SDL_Rect * clip, + SDL_Rect * result); + +/** + * \brief Calculate the intersection of a rectangle and line segment. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * + rect, int *X1, + int *Y1, int *X2, + int *Y2); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_rect_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_render.h b/code/SDL2/include/SDL_render.h new file mode 100644 index 00000000..77f706a9 --- /dev/null +++ b/code/SDL2/include/SDL_render.h @@ -0,0 +1,870 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_render.h + * + * Header file for SDL 2D rendering functions. + * + * This API supports the following features: + * * single pixel points + * * single pixel lines + * * filled rectangles + * * texture images + * + * The primitives may be drawn in opaque, blended, or additive modes. + * + * The texture images may be drawn in opaque, blended, or additive modes. + * They can have an additional color tint or alpha modulation applied to + * them, and may also be stretched with linear interpolation. + * + * This API is designed to accelerate simple 2D operations. You may + * want more functionality such as polygons and particle effects and + * in that case you should use SDL's OpenGL/Direct3D support or one + * of the many good 3D engines. + * + * These functions must be called from the main thread. + * See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995 + */ + +#ifndef _SDL_render_h +#define _SDL_render_h + +#include "SDL_stdinc.h" +#include "SDL_rect.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Flags used when creating a rendering context + */ +typedef enum +{ + SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ + SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware + acceleration */ + SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized + with the refresh rate */ + SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports + rendering to texture */ +} SDL_RendererFlags; + +/** + * \brief Information on the capabilities of a render driver or context. + */ +typedef struct SDL_RendererInfo +{ + const char *name; /**< The name of the renderer */ + Uint32 flags; /**< Supported ::SDL_RendererFlags */ + Uint32 num_texture_formats; /**< The number of available texture formats */ + Uint32 texture_formats[16]; /**< The available texture formats */ + int max_texture_width; /**< The maximimum texture width */ + int max_texture_height; /**< The maximimum texture height */ +} SDL_RendererInfo; + +/** + * \brief The access pattern allowed for a texture. + */ +typedef enum +{ + SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ + SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */ + SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ +} SDL_TextureAccess; + +/** + * \brief The texture channel modulation used in SDL_RenderCopy(). + */ +typedef enum +{ + SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */ + SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */ + SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */ +} SDL_TextureModulate; + +/** + * \brief Flip constants for SDL_RenderCopyEx + */ +typedef enum +{ + SDL_FLIP_NONE = 0x00000000, /**< Do not flip */ + SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */ + SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */ +} SDL_RendererFlip; + +/** + * \brief A structure representing rendering state + */ +struct SDL_Renderer; +typedef struct SDL_Renderer SDL_Renderer; + +/** + * \brief An efficient driver-specific representation of pixel data + */ +struct SDL_Texture; +typedef struct SDL_Texture SDL_Texture; + + +/* Function prototypes */ + +/** + * \brief Get the number of 2D rendering drivers available for the current + * display. + * + * A render driver is a set of code that handles rendering and texture + * management on a particular display. Normally there is only one, but + * some drivers may have several available with different capabilities. + * + * \sa SDL_GetRenderDriverInfo() + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); + +/** + * \brief Get information about a specific 2D rendering driver for the current + * display. + * + * \param index The index of the driver to query information about. + * \param info A pointer to an SDL_RendererInfo struct to be filled with + * information on the rendering driver. + * + * \return 0 on success, -1 if the index was out of range. + * + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, + SDL_RendererInfo * info); + +/** + * \brief Create a window and default renderer + * + * \param width The width of the window + * \param height The height of the window + * \param window_flags The flags used to create the window + * \param window A pointer filled with the window, or NULL on error + * \param renderer A pointer filled with the renderer, or NULL on error + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer( + int width, int height, Uint32 window_flags, + SDL_Window **window, SDL_Renderer **renderer); + + +/** + * \brief Create a 2D rendering context for a window. + * + * \param window The window where rendering is displayed. + * \param index The index of the rendering driver to initialize, or -1 to + * initialize the first one supporting the requested flags. + * \param flags ::SDL_RendererFlags. + * + * \return A valid rendering context or NULL if there was an error. + * + * \sa SDL_CreateSoftwareRenderer() + * \sa SDL_GetRendererInfo() + * \sa SDL_DestroyRenderer() + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window, + int index, Uint32 flags); + +/** + * \brief Create a 2D software rendering context for a surface. + * + * \param surface The surface where rendering is done. + * + * \return A valid rendering context or NULL if there was an error. + * + * \sa SDL_CreateRenderer() + * \sa SDL_DestroyRenderer() + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface); + +/** + * \brief Get the renderer associated with a window. + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window); + +/** + * \brief Get information about a rendering context. + */ +extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, + SDL_RendererInfo * info); + +/** + * \brief Get the output size of a rendering context. + */ +extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer, + int *w, int *h); + +/** + * \brief Create a texture for a rendering context. + * + * \param renderer The renderer. + * \param format The format of the texture. + * \param access One of the enumerated values in ::SDL_TextureAccess. + * \param w The width of the texture in pixels. + * \param h The height of the texture in pixels. + * + * \return The created texture is returned, or 0 if no rendering context was + * active, the format was unsupported, or the width or height were out + * of range. + * + * \sa SDL_QueryTexture() + * \sa SDL_UpdateTexture() + * \sa SDL_DestroyTexture() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, + Uint32 format, + int access, int w, + int h); + +/** + * \brief Create a texture from an existing surface. + * + * \param renderer The renderer. + * \param surface The surface containing pixel data used to fill the texture. + * + * \return The created texture is returned, or 0 on error. + * + * \note The surface is not modified or freed by this function. + * + * \sa SDL_QueryTexture() + * \sa SDL_DestroyTexture() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface); + +/** + * \brief Query the attributes of a texture + * + * \param texture A texture to be queried. + * \param format A pointer filled in with the raw format of the texture. The + * actual format may differ, but pixel transfers will use this + * format. + * \param access A pointer filled in with the actual access to the texture. + * \param w A pointer filled in with the width of the texture in pixels. + * \param h A pointer filled in with the height of the texture in pixels. + * + * \return 0 on success, or -1 if the texture is not valid. + */ +extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, + Uint32 * format, int *access, + int *w, int *h); + +/** + * \brief Set an additional color value used in render copy operations. + * + * \param texture The texture to update. + * \param r The red color value multiplied into copy operations. + * \param g The green color value multiplied into copy operations. + * \param b The blue color value multiplied into copy operations. + * + * \return 0 on success, or -1 if the texture is not valid or color modulation + * is not supported. + * + * \sa SDL_GetTextureColorMod() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, + Uint8 r, Uint8 g, Uint8 b); + + +/** + * \brief Get the additional color value used in render copy operations. + * + * \param texture The texture to query. + * \param r A pointer filled in with the current red color value. + * \param g A pointer filled in with the current green color value. + * \param b A pointer filled in with the current blue color value. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureColorMod() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, + Uint8 * r, Uint8 * g, + Uint8 * b); + +/** + * \brief Set an additional alpha value used in render copy operations. + * + * \param texture The texture to update. + * \param alpha The alpha value multiplied into copy operations. + * + * \return 0 on success, or -1 if the texture is not valid or alpha modulation + * is not supported. + * + * \sa SDL_GetTextureAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, + Uint8 alpha); + +/** + * \brief Get the additional alpha value used in render copy operations. + * + * \param texture The texture to query. + * \param alpha A pointer filled in with the current alpha value. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, + Uint8 * alpha); + +/** + * \brief Set the blend mode used for texture copy operations. + * + * \param texture The texture to update. + * \param blendMode ::SDL_BlendMode to use for texture blending. + * + * \return 0 on success, or -1 if the texture is not valid or the blend mode is + * not supported. + * + * \note If the blend mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetTextureBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for texture copy operations. + * + * \param texture The texture to query. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, + SDL_BlendMode *blendMode); + +/** + * \brief Update the given texture rectangle with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param pixels The raw pixel data. + * \param pitch The number of bytes between rows of pixel data. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note This is a fairly slow function. + */ +extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const void *pixels, int pitch); + +/** + * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param Yplane The raw pixel data for the Y plane. + * \param Ypitch The number of bytes between rows of pixel data for the Y plane. + * \param Uplane The raw pixel data for the U plane. + * \param Upitch The number of bytes between rows of pixel data for the U plane. + * \param Vplane The raw pixel data for the V plane. + * \param Vpitch The number of bytes between rows of pixel data for the V plane. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note You can use SDL_UpdateTexture() as long as your pixel data is + * a contiguous block of Y and U/V planes in the proper order, but + * this function is available if your pixel data is not contiguous. + */ +extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); + +/** + * \brief Lock a portion of the texture for write-only pixel access. + * + * \param texture The texture to lock for access, which was created with + * ::SDL_TEXTUREACCESS_STREAMING. + * \param rect A pointer to the rectangle to lock for access. If the rect + * is NULL, the entire texture will be locked. + * \param pixels This is filled in with a pointer to the locked pixels, + * appropriately offset by the locked area. + * \param pitch This is filled in with the pitch of the locked pixels. + * + * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. + * + * \sa SDL_UnlockTexture() + */ +extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, + const SDL_Rect * rect, + void **pixels, int *pitch); + +/** + * \brief Unlock a texture, uploading the changes to video memory, if needed. + * + * \sa SDL_LockTexture() + */ +extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); + +/** + * \brief Determines whether a window supports the use of render targets + * + * \param renderer The renderer that will be checked + * + * \return SDL_TRUE if supported, SDL_FALSE if not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer); + +/** + * \brief Set a texture as the current rendering target. + * + * \param renderer The renderer. + * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target + * + * \return 0 on success, or -1 on error + * + * \sa SDL_GetRenderTarget() + */ +extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, + SDL_Texture *texture); + +/** + * \brief Get the current render target or NULL for the default render target. + * + * \return The current render target + * + * \sa SDL_SetRenderTarget() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); + +/** + * \brief Set device independent resolution for rendering + * + * \param renderer The renderer for which resolution should be set. + * \param w The width of the logical resolution + * \param h The height of the logical resolution + * + * This function uses the viewport and scaling functionality to allow a fixed logical + * resolution for rendering, regardless of the actual output resolution. If the actual + * output resolution doesn't have the same aspect ratio the output rendering will be + * centered within the output display. + * + * If the output display is a window, mouse events in the window will be filtered + * and scaled so they seem to arrive within the logical resolution. + * + * \note If this function results in scaling or subpixel drawing by the + * rendering backend, it will be handled using the appropriate + * quality hints. + * + * \sa SDL_RenderGetLogicalSize() + * \sa SDL_RenderSetScale() + * \sa SDL_RenderSetViewport() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h); + +/** + * \brief Get device independent resolution for rendering + * + * \param renderer The renderer from which resolution should be queried. + * \param w A pointer filled with the width of the logical resolution + * \param h A pointer filled with the height of the logical resolution + * + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h); + +/** + * \brief Set the drawing area for rendering on the current target. + * + * \param renderer The renderer for which the drawing area should be set. + * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target. + * + * The x,y of the viewport rect represents the origin for rendering. + * + * \return 0 on success, or -1 on error + * + * \note If the window associated with the renderer is resized, the viewport is automatically reset. + * + * \sa SDL_RenderGetViewport() + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Get the drawing area for the current target. + * + * \sa SDL_RenderSetViewport() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, + SDL_Rect * rect); + +/** + * \brief Set the clip rectangle for the current target. + * + * \param renderer The renderer for which clip rectangle should be set. + * \param rect A pointer to the rectangle to set as the clip rectangle, or + * NULL to disable clipping. + * + * \return 0 on success, or -1 on error + * + * \sa SDL_RenderGetClipRect() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Get the clip rectangle for the current target. + * + * \param renderer The renderer from which clip rectangle should be queried. + * \param rect A pointer filled in with the current clip rectangle, or + * an empty rectangle if clipping is disabled. + * + * \sa SDL_RenderSetClipRect() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer, + SDL_Rect * rect); + +/** + * \brief Set the drawing scale for rendering on the current target. + * + * \param renderer The renderer for which the drawing scale should be set. + * \param scaleX The horizontal scaling factor + * \param scaleY The vertical scaling factor + * + * The drawing coordinates are scaled by the x/y scaling factors + * before they are used by the renderer. This allows resolution + * independent drawing with a single coordinate system. + * + * \note If this results in scaling or subpixel drawing by the + * rendering backend, it will be handled using the appropriate + * quality hints. For best results use integer scaling factors. + * + * \sa SDL_RenderGetScale() + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer, + float scaleX, float scaleY); + +/** + * \brief Get the drawing scale for the current target. + * + * \param renderer The renderer from which drawing scale should be queried. + * \param scaleX A pointer filled in with the horizontal scaling factor + * \param scaleY A pointer filled in with the vertical scaling factor + * + * \sa SDL_RenderSetScale() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer, + float *scaleX, float *scaleY); + +/** + * \brief Set the color used for drawing operations (Rect, Line and Clear). + * + * \param renderer The renderer for which drawing color should be set. + * \param r The red value used to draw on the rendering target. + * \param g The green value used to draw on the rendering target. + * \param b The blue value used to draw on the rendering target. + * \param a The alpha value used to draw on the rendering target, usually + * ::SDL_ALPHA_OPAQUE (255). + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer, + Uint8 r, Uint8 g, Uint8 b, + Uint8 a); + +/** + * \brief Get the color used for drawing operations (Rect, Line and Clear). + * + * \param renderer The renderer from which drawing color should be queried. + * \param r A pointer to the red value used to draw on the rendering target. + * \param g A pointer to the green value used to draw on the rendering target. + * \param b A pointer to the blue value used to draw on the rendering target. + * \param a A pointer to the alpha value used to draw on the rendering target, + * usually ::SDL_ALPHA_OPAQUE (255). + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer, + Uint8 * r, Uint8 * g, Uint8 * b, + Uint8 * a); + +/** + * \brief Set the blend mode used for drawing operations (Fill and Line). + * + * \param renderer The renderer for which blend mode should be set. + * \param blendMode ::SDL_BlendMode to use for blending. + * + * \return 0 on success, or -1 on error + * + * \note If the blend mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetRenderDrawBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for drawing operations. + * + * \param renderer The renderer from which blend mode should be queried. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 on error + * + * \sa SDL_SetRenderDrawBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, + SDL_BlendMode *blendMode); + +/** + * \brief Clear the current rendering target with the drawing color + * + * This function clears the entire rendering target, ignoring the viewport. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer); + +/** + * \brief Draw a point on the current rendering target. + * + * \param renderer The renderer which should draw a point. + * \param x The x coordinate of the point. + * \param y The y coordinate of the point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, + int x, int y); + +/** + * \brief Draw multiple points on the current rendering target. + * + * \param renderer The renderer which should draw multiple points. + * \param points The points to draw + * \param count The number of points to draw + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, + int count); + +/** + * \brief Draw a line on the current rendering target. + * + * \param renderer The renderer which should draw a line. + * \param x1 The x coordinate of the start point. + * \param y1 The y coordinate of the start point. + * \param x2 The x coordinate of the end point. + * \param y2 The y coordinate of the end point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, + int x1, int y1, int x2, int y2); + +/** + * \brief Draw a series of connected lines on the current rendering target. + * + * \param renderer The renderer which should draw multiple lines. + * \param points The points along the lines + * \param count The number of points, drawing count-1 lines + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, + int count); + +/** + * \brief Draw a rectangle on the current rendering target. + * + * \param renderer The renderer which should draw a rectangle. + * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Draw some number of rectangles on the current rendering target. + * + * \param renderer The renderer which should draw multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, + const SDL_Rect * rects, + int count); + +/** + * \brief Fill a rectangle on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill a rectangle. + * \param rect A pointer to the destination rectangle, or NULL for the entire + * rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect * rects, + int count); + +/** + * \brief Copy a portion of the texture to the current rendering target. + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect); + +/** + * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect + * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done aroud dstrect.w/2, dstrect.h/2) + * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect, + const double angle, + const SDL_Point *center, + const SDL_RendererFlip flip); + +/** + * \brief Read pixels from the current rendering target. + * + * \param renderer The renderer from which pixels should be read. + * \param rect A pointer to the rectangle to read, or NULL for the entire + * render target. + * \param format The desired format of the pixel data, or 0 to use the format + * of the rendering target + * \param pixels A pointer to be filled in with the pixel data + * \param pitch The pitch of the pixels parameter. + * + * \return 0 on success, or -1 if pixel reading is not supported. + * + * \warning This is a very slow operation, and should not be used frequently. + */ +extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, + const SDL_Rect * rect, + Uint32 format, + void *pixels, int pitch); + +/** + * \brief Update the screen with rendering performed. + */ +extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer); + +/** + * \brief Destroy the specified texture. + * + * \sa SDL_CreateTexture() + * \sa SDL_CreateTextureFromSurface() + */ +extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); + +/** + * \brief Destroy the rendering context for a window and free associated + * textures. + * + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); + + +/** + * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with + * OpenGL instructions. + * + * \param texture The SDL texture to bind + * \param texw A pointer to a float that will be filled with the texture width + * \param texh A pointer to a float that will be filled with the texture height + * + * \return 0 on success, or -1 if the operation is not supported + */ +extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh); + +/** + * \brief Unbind a texture from the current OpenGL/ES/ES2 context. + * + * \param texture The SDL texture to unbind + * + * \return 0 on success, or -1 if the operation is not supported + */ +extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_render_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_revision.h b/code/SDL2/include/SDL_revision.h new file mode 100644 index 00000000..a75dc330 --- /dev/null +++ b/code/SDL2/include/SDL_revision.h @@ -0,0 +1,2 @@ +#define SDL_REVISION "hg-8628:b558f99d48f0" +#define SDL_REVISION_NUMBER 8628 diff --git a/code/SDL2/include/SDL_rwops.h b/code/SDL2/include/SDL_rwops.h new file mode 100644 index 00000000..4bdd7876 --- /dev/null +++ b/code/SDL2/include/SDL_rwops.h @@ -0,0 +1,232 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_rwops.h + * + * This file provides a general interface for SDL to read and write + * data streams. It can easily be extended to files, memory, etc. + */ + +#ifndef _SDL_rwops_h +#define _SDL_rwops_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* RWops Types */ +#define SDL_RWOPS_UNKNOWN 0 /* Unknown stream type */ +#define SDL_RWOPS_WINFILE 1 /* Win32 file */ +#define SDL_RWOPS_STDFILE 2 /* Stdio file */ +#define SDL_RWOPS_JNIFILE 3 /* Android asset */ +#define SDL_RWOPS_MEMORY 4 /* Memory stream */ +#define SDL_RWOPS_MEMORY_RO 5 /* Read-Only memory stream */ + +/** + * This is the read/write operation structure -- very basic. + */ +typedef struct SDL_RWops +{ + /** + * Return the size of the file in this rwops, or -1 if unknown + */ + Sint64 (SDLCALL * size) (struct SDL_RWops * context); + + /** + * Seek to \c offset relative to \c whence, one of stdio's whence values: + * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END + * + * \return the final offset in the data stream, or -1 on error. + */ + Sint64 (SDLCALL * seek) (struct SDL_RWops * context, Sint64 offset, + int whence); + + /** + * Read up to \c maxnum objects each of size \c size from the data + * stream to the area pointed at by \c ptr. + * + * \return the number of objects read, or 0 at error or end of file. + */ + size_t (SDLCALL * read) (struct SDL_RWops * context, void *ptr, + size_t size, size_t maxnum); + + /** + * Write exactly \c num objects each of size \c size from the area + * pointed at by \c ptr to data stream. + * + * \return the number of objects written, or 0 at error or end of file. + */ + size_t (SDLCALL * write) (struct SDL_RWops * context, const void *ptr, + size_t size, size_t num); + + /** + * Close and free an allocated SDL_RWops structure. + * + * \return 0 if successful or -1 on write error when flushing data. + */ + int (SDLCALL * close) (struct SDL_RWops * context); + + Uint32 type; + union + { +#if defined(ANDROID) + struct + { + void *fileNameRef; + void *inputStreamRef; + void *readableByteChannelRef; + void *readMethod; + void *assetFileDescriptorRef; + long position; + long size; + long offset; + int fd; + } androidio; +#elif defined(__WIN32__) + struct + { + SDL_bool append; + void *h; + struct + { + void *data; + size_t size; + size_t left; + } buffer; + } windowsio; +#endif + +#ifdef HAVE_STDIO_H + struct + { + SDL_bool autoclose; + FILE *fp; + } stdio; +#endif + struct + { + Uint8 *base; + Uint8 *here; + Uint8 *stop; + } mem; + struct + { + void *data1; + void *data2; + } unknown; + } hidden; + +} SDL_RWops; + + +/** + * \name RWFrom functions + * + * Functions to create SDL_RWops structures from various data streams. + */ +/* @{ */ + +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, + const char *mode); + +#ifdef HAVE_STDIO_H +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, + SDL_bool autoclose); +#else +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp, + SDL_bool autoclose); +#endif + +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, + int size); + +/* @} *//* RWFrom functions */ + + +extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); +extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); + +#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ +#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ +#define RW_SEEK_END 2 /**< Seek relative to the end of data */ + +/** + * \name Read/write macros + * + * Macros to easily read and write from an SDL_RWops structure. + */ +/* @{ */ +#define SDL_RWsize(ctx) (ctx)->size(ctx) +#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) +#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) +#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) +#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) +#define SDL_RWclose(ctx) (ctx)->close(ctx) +/* @} *//* Read/write macros */ + + +/** + * \name Read endian functions + * + * Read an item of the specified endianness and return in native format. + */ +/* @{ */ +extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); +/* @} *//* Read endian functions */ + +/** + * \name Write endian functions + * + * Write an item of native format to the specified endianness. + */ +/* @{ */ +extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); +/* @} *//* Write endian functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_rwops_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_scancode.h b/code/SDL2/include/SDL_scancode.h new file mode 100644 index 00000000..4b3be28f --- /dev/null +++ b/code/SDL2/include/SDL_scancode.h @@ -0,0 +1,401 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_scancode.h + * + * Defines keyboard scancodes. + */ + +#ifndef _SDL_scancode_h +#define _SDL_scancode_h + +#include "SDL_stdinc.h" + +/** + * \brief The SDL keyboard scancode representation. + * + * Values of this type are used to represent keyboard keys, among other places + * in the \link SDL_Keysym::scancode key.keysym.scancode \endlink field of the + * SDL_Event structure. + * + * The values in this enumeration are based on the USB usage page standard: + * http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf + */ +typedef enum +{ + SDL_SCANCODE_UNKNOWN = 0, + + /** + * \name Usage page 0x07 + * + * These values are from usage page 0x07 (USB keyboard page). + */ + /* @{ */ + + SDL_SCANCODE_A = 4, + SDL_SCANCODE_B = 5, + SDL_SCANCODE_C = 6, + SDL_SCANCODE_D = 7, + SDL_SCANCODE_E = 8, + SDL_SCANCODE_F = 9, + SDL_SCANCODE_G = 10, + SDL_SCANCODE_H = 11, + SDL_SCANCODE_I = 12, + SDL_SCANCODE_J = 13, + SDL_SCANCODE_K = 14, + SDL_SCANCODE_L = 15, + SDL_SCANCODE_M = 16, + SDL_SCANCODE_N = 17, + SDL_SCANCODE_O = 18, + SDL_SCANCODE_P = 19, + SDL_SCANCODE_Q = 20, + SDL_SCANCODE_R = 21, + SDL_SCANCODE_S = 22, + SDL_SCANCODE_T = 23, + SDL_SCANCODE_U = 24, + SDL_SCANCODE_V = 25, + SDL_SCANCODE_W = 26, + SDL_SCANCODE_X = 27, + SDL_SCANCODE_Y = 28, + SDL_SCANCODE_Z = 29, + + SDL_SCANCODE_1 = 30, + SDL_SCANCODE_2 = 31, + SDL_SCANCODE_3 = 32, + SDL_SCANCODE_4 = 33, + SDL_SCANCODE_5 = 34, + SDL_SCANCODE_6 = 35, + SDL_SCANCODE_7 = 36, + SDL_SCANCODE_8 = 37, + SDL_SCANCODE_9 = 38, + SDL_SCANCODE_0 = 39, + + SDL_SCANCODE_RETURN = 40, + SDL_SCANCODE_ESCAPE = 41, + SDL_SCANCODE_BACKSPACE = 42, + SDL_SCANCODE_TAB = 43, + SDL_SCANCODE_SPACE = 44, + + SDL_SCANCODE_MINUS = 45, + SDL_SCANCODE_EQUALS = 46, + SDL_SCANCODE_LEFTBRACKET = 47, + SDL_SCANCODE_RIGHTBRACKET = 48, + SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return + * key on ISO keyboards and at the right end + * of the QWERTY row on ANSI keyboards. + * Produces REVERSE SOLIDUS (backslash) and + * VERTICAL LINE in a US layout, REVERSE + * SOLIDUS and VERTICAL LINE in a UK Mac + * layout, NUMBER SIGN and TILDE in a UK + * Windows layout, DOLLAR SIGN and POUND SIGN + * in a Swiss German layout, NUMBER SIGN and + * APOSTROPHE in a German layout, GRAVE + * ACCENT and POUND SIGN in a French Mac + * layout, and ASTERISK and MICRO SIGN in a + * French Windows layout. + */ + SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code + * instead of 49 for the same key, but all + * OSes I've seen treat the two codes + * identically. So, as an implementor, unless + * your keyboard generates both of those + * codes and your OS treats them differently, + * you should generate SDL_SCANCODE_BACKSLASH + * instead of this code. As a user, you + * should not rely on this code because SDL + * will never generate it with most (all?) + * keyboards. + */ + SDL_SCANCODE_SEMICOLON = 51, + SDL_SCANCODE_APOSTROPHE = 52, + SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI + * and ISO keyboards). Produces GRAVE ACCENT and + * TILDE in a US Windows layout and in US and UK + * Mac layouts on ANSI keyboards, GRAVE ACCENT + * and NOT SIGN in a UK Windows layout, SECTION + * SIGN and PLUS-MINUS SIGN in US and UK Mac + * layouts on ISO keyboards, SECTION SIGN and + * DEGREE SIGN in a Swiss German layout (Mac: + * only on ISO keyboards), CIRCUMFLEX ACCENT and + * DEGREE SIGN in a German layout (Mac: only on + * ISO keyboards), SUPERSCRIPT TWO and TILDE in a + * French Windows layout, COMMERCIAL AT and + * NUMBER SIGN in a French Mac layout on ISO + * keyboards, and LESS-THAN SIGN and GREATER-THAN + * SIGN in a Swiss German, German, or French Mac + * layout on ANSI keyboards. + */ + SDL_SCANCODE_COMMA = 54, + SDL_SCANCODE_PERIOD = 55, + SDL_SCANCODE_SLASH = 56, + + SDL_SCANCODE_CAPSLOCK = 57, + + SDL_SCANCODE_F1 = 58, + SDL_SCANCODE_F2 = 59, + SDL_SCANCODE_F3 = 60, + SDL_SCANCODE_F4 = 61, + SDL_SCANCODE_F5 = 62, + SDL_SCANCODE_F6 = 63, + SDL_SCANCODE_F7 = 64, + SDL_SCANCODE_F8 = 65, + SDL_SCANCODE_F9 = 66, + SDL_SCANCODE_F10 = 67, + SDL_SCANCODE_F11 = 68, + SDL_SCANCODE_F12 = 69, + + SDL_SCANCODE_PRINTSCREEN = 70, + SDL_SCANCODE_SCROLLLOCK = 71, + SDL_SCANCODE_PAUSE = 72, + SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but + does send code 73, not 117) */ + SDL_SCANCODE_HOME = 74, + SDL_SCANCODE_PAGEUP = 75, + SDL_SCANCODE_DELETE = 76, + SDL_SCANCODE_END = 77, + SDL_SCANCODE_PAGEDOWN = 78, + SDL_SCANCODE_RIGHT = 79, + SDL_SCANCODE_LEFT = 80, + SDL_SCANCODE_DOWN = 81, + SDL_SCANCODE_UP = 82, + + SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards + */ + SDL_SCANCODE_KP_DIVIDE = 84, + SDL_SCANCODE_KP_MULTIPLY = 85, + SDL_SCANCODE_KP_MINUS = 86, + SDL_SCANCODE_KP_PLUS = 87, + SDL_SCANCODE_KP_ENTER = 88, + SDL_SCANCODE_KP_1 = 89, + SDL_SCANCODE_KP_2 = 90, + SDL_SCANCODE_KP_3 = 91, + SDL_SCANCODE_KP_4 = 92, + SDL_SCANCODE_KP_5 = 93, + SDL_SCANCODE_KP_6 = 94, + SDL_SCANCODE_KP_7 = 95, + SDL_SCANCODE_KP_8 = 96, + SDL_SCANCODE_KP_9 = 97, + SDL_SCANCODE_KP_0 = 98, + SDL_SCANCODE_KP_PERIOD = 99, + + SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO + * keyboards have over ANSI ones, + * located between left shift and Y. + * Produces GRAVE ACCENT and TILDE in a + * US or UK Mac layout, REVERSE SOLIDUS + * (backslash) and VERTICAL LINE in a + * US or UK Windows layout, and + * LESS-THAN SIGN and GREATER-THAN SIGN + * in a Swiss German, German, or French + * layout. */ + SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */ + SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag, + * not a physical key - but some Mac keyboards + * do have a power key. */ + SDL_SCANCODE_KP_EQUALS = 103, + SDL_SCANCODE_F13 = 104, + SDL_SCANCODE_F14 = 105, + SDL_SCANCODE_F15 = 106, + SDL_SCANCODE_F16 = 107, + SDL_SCANCODE_F17 = 108, + SDL_SCANCODE_F18 = 109, + SDL_SCANCODE_F19 = 110, + SDL_SCANCODE_F20 = 111, + SDL_SCANCODE_F21 = 112, + SDL_SCANCODE_F22 = 113, + SDL_SCANCODE_F23 = 114, + SDL_SCANCODE_F24 = 115, + SDL_SCANCODE_EXECUTE = 116, + SDL_SCANCODE_HELP = 117, + SDL_SCANCODE_MENU = 118, + SDL_SCANCODE_SELECT = 119, + SDL_SCANCODE_STOP = 120, + SDL_SCANCODE_AGAIN = 121, /**< redo */ + SDL_SCANCODE_UNDO = 122, + SDL_SCANCODE_CUT = 123, + SDL_SCANCODE_COPY = 124, + SDL_SCANCODE_PASTE = 125, + SDL_SCANCODE_FIND = 126, + SDL_SCANCODE_MUTE = 127, + SDL_SCANCODE_VOLUMEUP = 128, + SDL_SCANCODE_VOLUMEDOWN = 129, +/* not sure whether there's a reason to enable these */ +/* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */ +/* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */ +/* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */ + SDL_SCANCODE_KP_COMMA = 133, + SDL_SCANCODE_KP_EQUALSAS400 = 134, + + SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see + footnotes in USB doc */ + SDL_SCANCODE_INTERNATIONAL2 = 136, + SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */ + SDL_SCANCODE_INTERNATIONAL4 = 138, + SDL_SCANCODE_INTERNATIONAL5 = 139, + SDL_SCANCODE_INTERNATIONAL6 = 140, + SDL_SCANCODE_INTERNATIONAL7 = 141, + SDL_SCANCODE_INTERNATIONAL8 = 142, + SDL_SCANCODE_INTERNATIONAL9 = 143, + SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */ + SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */ + SDL_SCANCODE_LANG3 = 146, /**< Katakana */ + SDL_SCANCODE_LANG4 = 147, /**< Hiragana */ + SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */ + SDL_SCANCODE_LANG6 = 149, /**< reserved */ + SDL_SCANCODE_LANG7 = 150, /**< reserved */ + SDL_SCANCODE_LANG8 = 151, /**< reserved */ + SDL_SCANCODE_LANG9 = 152, /**< reserved */ + + SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */ + SDL_SCANCODE_SYSREQ = 154, + SDL_SCANCODE_CANCEL = 155, + SDL_SCANCODE_CLEAR = 156, + SDL_SCANCODE_PRIOR = 157, + SDL_SCANCODE_RETURN2 = 158, + SDL_SCANCODE_SEPARATOR = 159, + SDL_SCANCODE_OUT = 160, + SDL_SCANCODE_OPER = 161, + SDL_SCANCODE_CLEARAGAIN = 162, + SDL_SCANCODE_CRSEL = 163, + SDL_SCANCODE_EXSEL = 164, + + SDL_SCANCODE_KP_00 = 176, + SDL_SCANCODE_KP_000 = 177, + SDL_SCANCODE_THOUSANDSSEPARATOR = 178, + SDL_SCANCODE_DECIMALSEPARATOR = 179, + SDL_SCANCODE_CURRENCYUNIT = 180, + SDL_SCANCODE_CURRENCYSUBUNIT = 181, + SDL_SCANCODE_KP_LEFTPAREN = 182, + SDL_SCANCODE_KP_RIGHTPAREN = 183, + SDL_SCANCODE_KP_LEFTBRACE = 184, + SDL_SCANCODE_KP_RIGHTBRACE = 185, + SDL_SCANCODE_KP_TAB = 186, + SDL_SCANCODE_KP_BACKSPACE = 187, + SDL_SCANCODE_KP_A = 188, + SDL_SCANCODE_KP_B = 189, + SDL_SCANCODE_KP_C = 190, + SDL_SCANCODE_KP_D = 191, + SDL_SCANCODE_KP_E = 192, + SDL_SCANCODE_KP_F = 193, + SDL_SCANCODE_KP_XOR = 194, + SDL_SCANCODE_KP_POWER = 195, + SDL_SCANCODE_KP_PERCENT = 196, + SDL_SCANCODE_KP_LESS = 197, + SDL_SCANCODE_KP_GREATER = 198, + SDL_SCANCODE_KP_AMPERSAND = 199, + SDL_SCANCODE_KP_DBLAMPERSAND = 200, + SDL_SCANCODE_KP_VERTICALBAR = 201, + SDL_SCANCODE_KP_DBLVERTICALBAR = 202, + SDL_SCANCODE_KP_COLON = 203, + SDL_SCANCODE_KP_HASH = 204, + SDL_SCANCODE_KP_SPACE = 205, + SDL_SCANCODE_KP_AT = 206, + SDL_SCANCODE_KP_EXCLAM = 207, + SDL_SCANCODE_KP_MEMSTORE = 208, + SDL_SCANCODE_KP_MEMRECALL = 209, + SDL_SCANCODE_KP_MEMCLEAR = 210, + SDL_SCANCODE_KP_MEMADD = 211, + SDL_SCANCODE_KP_MEMSUBTRACT = 212, + SDL_SCANCODE_KP_MEMMULTIPLY = 213, + SDL_SCANCODE_KP_MEMDIVIDE = 214, + SDL_SCANCODE_KP_PLUSMINUS = 215, + SDL_SCANCODE_KP_CLEAR = 216, + SDL_SCANCODE_KP_CLEARENTRY = 217, + SDL_SCANCODE_KP_BINARY = 218, + SDL_SCANCODE_KP_OCTAL = 219, + SDL_SCANCODE_KP_DECIMAL = 220, + SDL_SCANCODE_KP_HEXADECIMAL = 221, + + SDL_SCANCODE_LCTRL = 224, + SDL_SCANCODE_LSHIFT = 225, + SDL_SCANCODE_LALT = 226, /**< alt, option */ + SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */ + SDL_SCANCODE_RCTRL = 228, + SDL_SCANCODE_RSHIFT = 229, + SDL_SCANCODE_RALT = 230, /**< alt gr, option */ + SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */ + + SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered + * by any of the above, but since there's a + * special KMOD_MODE for it I'm adding it here + */ + + /* @} *//* Usage page 0x07 */ + + /** + * \name Usage page 0x0C + * + * These values are mapped from usage page 0x0C (USB consumer page). + */ + /* @{ */ + + SDL_SCANCODE_AUDIONEXT = 258, + SDL_SCANCODE_AUDIOPREV = 259, + SDL_SCANCODE_AUDIOSTOP = 260, + SDL_SCANCODE_AUDIOPLAY = 261, + SDL_SCANCODE_AUDIOMUTE = 262, + SDL_SCANCODE_MEDIASELECT = 263, + SDL_SCANCODE_WWW = 264, + SDL_SCANCODE_MAIL = 265, + SDL_SCANCODE_CALCULATOR = 266, + SDL_SCANCODE_COMPUTER = 267, + SDL_SCANCODE_AC_SEARCH = 268, + SDL_SCANCODE_AC_HOME = 269, + SDL_SCANCODE_AC_BACK = 270, + SDL_SCANCODE_AC_FORWARD = 271, + SDL_SCANCODE_AC_STOP = 272, + SDL_SCANCODE_AC_REFRESH = 273, + SDL_SCANCODE_AC_BOOKMARKS = 274, + + /* @} *//* Usage page 0x0C */ + + /** + * \name Walther keys + * + * These are values that Christian Walther added (for mac keyboard?). + */ + /* @{ */ + + SDL_SCANCODE_BRIGHTNESSDOWN = 275, + SDL_SCANCODE_BRIGHTNESSUP = 276, + SDL_SCANCODE_DISPLAYSWITCH = 277, /**< display mirroring/dual display + switch, video mode switch */ + SDL_SCANCODE_KBDILLUMTOGGLE = 278, + SDL_SCANCODE_KBDILLUMDOWN = 279, + SDL_SCANCODE_KBDILLUMUP = 280, + SDL_SCANCODE_EJECT = 281, + SDL_SCANCODE_SLEEP = 282, + + SDL_SCANCODE_APP1 = 283, + SDL_SCANCODE_APP2 = 284, + + /* @} *//* Walther keys */ + + /* Add any other keys here. */ + + SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes + for array bounds */ +} SDL_Scancode; + +#endif /* _SDL_scancode_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_shape.h b/code/SDL2/include/SDL_shape.h new file mode 100644 index 00000000..53029306 --- /dev/null +++ b/code/SDL2/include/SDL_shape.h @@ -0,0 +1,143 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_shape_h +#define _SDL_shape_h + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_surface.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** \file SDL_shape.h + * + * Header file for the shaped window API. + */ + +#define SDL_NONSHAPEABLE_WINDOW -1 +#define SDL_INVALID_SHAPE_ARGUMENT -2 +#define SDL_WINDOW_LACKS_SHAPE -3 + +/** + * \brief Create a window that can be shaped with the specified position, dimensions, and flags. + * + * \param title The title of the window, in UTF-8 encoding. + * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param w The width of the window. + * \param h The height of the window. + * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: + * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, + * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_RESIZABLE, + * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, + * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. + * + * \return The window created, or NULL if window creation failed. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); + +/** + * \brief Return whether the given window is a shaped window. + * + * \param window The window to query for being shaped. + * + * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL. + * \sa SDL_CreateShapedWindow + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); + +/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ +typedef enum { + /** \brief The default mode, a binarized alpha cutoff of 1. */ + ShapeModeDefault, + /** \brief A binarized alpha cutoff with a given integer value. */ + ShapeModeBinarizeAlpha, + /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ + ShapeModeReverseBinarizeAlpha, + /** \brief A color key is applied. */ + ShapeModeColorKey +} WindowShapeMode; + +#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) + +/** \brief A union containing parameters for shaped windows. */ +typedef union { + /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ + Uint8 binarizationCutoff; + SDL_Color colorKey; +} SDL_WindowShapeParams; + +/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ +typedef struct SDL_WindowShapeMode { + /** \brief The mode of these window-shape parameters. */ + WindowShapeMode mode; + /** \brief Window-shape parameters. */ + SDL_WindowShapeParams parameters; +} SDL_WindowShapeMode; + +/** + * \brief Set the shape and parameters of a shaped window. + * + * \param window The shaped window whose parameters should be set. + * \param shape A surface encoding the desired shape for the window. + * \param shape_mode The parameters to set for the shaped window. + * + * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW + * if the SDL_Window* given does not reference a valid shaped window. + * + * \sa SDL_WindowShapeMode + * \sa SDL_GetShapedWindowMode. + */ +extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); + +/** + * \brief Get the shape parameters of a shaped window. + * + * \param window The shaped window whose parameters should be retrieved. + * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. + * + * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode + * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if + * the SDL_Window* given is a shapeable window currently lacking a shape. + * + * \sa SDL_WindowShapeMode + * \sa SDL_SetWindowShape + */ +extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_shape_h */ diff --git a/code/SDL2/include/SDL_stdinc.h b/code/SDL2/include/SDL_stdinc.h new file mode 100644 index 00000000..31b343d3 --- /dev/null +++ b/code/SDL2/include/SDL_stdinc.h @@ -0,0 +1,405 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_stdinc.h + * + * This is a general header that includes C language support. + */ + +#ifndef _SDL_stdinc_h +#define _SDL_stdinc_h + +#include "SDL_config.h" + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#if defined(STDC_HEADERS) +# include +# include +# include +#else +# if defined(HAVE_STDLIB_H) +# include +# elif defined(HAVE_MALLOC_H) +# include +# endif +# if defined(HAVE_STDDEF_H) +# include +# endif +# if defined(HAVE_STDARG_H) +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#if defined(HAVE_INTTYPES_H) +# include +#elif defined(HAVE_STDINT_H) +# include +#endif +#ifdef HAVE_CTYPE_H +# include +#endif +#ifdef HAVE_MATH_H +# if defined(__WINRT__) +/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on + WinRT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx + for more information. +*/ +# define _USE_MATH_DEFINES +# endif +# include +#endif +#ifdef HAVE_FLOAT_H +# include +#endif +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +# include +#endif + +/** + * The number of elements in an array. + */ +#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) +#define SDL_TABLESIZE(table) SDL_arraysize(table) + +/** + * \name Cast operators + * + * Use proper C++ casts when compiled as C++ to be compatible with the option + * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). + */ +/* @{ */ +#ifdef __cplusplus +#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) +#define SDL_static_cast(type, expression) static_cast(expression) +#define SDL_const_cast(type, expression) const_cast(expression) +#else +#define SDL_reinterpret_cast(type, expression) ((type)(expression)) +#define SDL_static_cast(type, expression) ((type)(expression)) +#define SDL_const_cast(type, expression) ((type)(expression)) +#endif +/* @} *//* Cast operators */ + +/* Define a four character code as a Uint32 */ +#define SDL_FOURCC(A, B, C, D) \ + ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24)) + +/** + * \name Basic data types + */ +/* @{ */ + +typedef enum +{ + SDL_FALSE = 0, + SDL_TRUE = 1 +} SDL_bool; + +/** + * \brief A signed 8-bit integer type. + */ +typedef int8_t Sint8; +/** + * \brief An unsigned 8-bit integer type. + */ +typedef uint8_t Uint8; +/** + * \brief A signed 16-bit integer type. + */ +typedef int16_t Sint16; +/** + * \brief An unsigned 16-bit integer type. + */ +typedef uint16_t Uint16; +/** + * \brief A signed 32-bit integer type. + */ +typedef int32_t Sint32; +/** + * \brief An unsigned 32-bit integer type. + */ +typedef uint32_t Uint32; + +/** + * \brief A signed 64-bit integer type. + */ +typedef int64_t Sint64; +/** + * \brief An unsigned 64-bit integer type. + */ +typedef uint64_t Uint64; + +/* @} *//* Basic data types */ + + +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_dummy_ ## name[(x) * 2 - 1] +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +/* Check to make sure enums are the size of ints, for structure packing. + For both Watcom C/C++ and Borland C/C++ the compiler option that makes + enums having the size of an int must be enabled. + This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). +*/ + +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +#if !defined(__ANDROID__) + /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ +typedef enum +{ + DUMMY_ENUM_VALUE +} SDL_DUMMY_ENUM; + +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); +#endif +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(HAVE_ALLOCA) && !defined(alloca) +# if defined(HAVE_ALLOCA_H) +# include +# elif defined(__GNUC__) +# define alloca __builtin_alloca +# elif defined(_MSC_VER) +# include +# define alloca _alloca +# elif defined(__WATCOMC__) +# include +# elif defined(__BORLANDC__) +# include +# elif defined(__DMC__) +# include +# elif defined(__AIX__) +#pragma alloca +# elif defined(__MRC__) +void *alloca(unsigned); +# else +char *alloca(); +# endif +#endif +#ifdef HAVE_ALLOCA +#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) +#define SDL_stack_free(data) +#else +#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) +#define SDL_stack_free(data) SDL_free(data) +#endif + +extern DECLSPEC void *SDLCALL SDL_malloc(size_t size); +extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size); +extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size); +extern DECLSPEC void SDLCALL SDL_free(void *mem); + +extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); +extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite); + +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)); + +extern DECLSPEC int SDLCALL SDL_abs(int x); + +/* !!! FIXME: these have side effects. You probably shouldn't use them. */ +/* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */ +#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) +#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) + +extern DECLSPEC int SDLCALL SDL_isdigit(int x); +extern DECLSPEC int SDLCALL SDL_isspace(int x); +extern DECLSPEC int SDLCALL SDL_toupper(int x); +extern DECLSPEC int SDLCALL SDL_tolower(int x); + +extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len); + +#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) +#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) + +/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */ +SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords) +{ +#if defined(__GNUC__) && defined(i386) + int u0, u1, u2; + __asm__ __volatile__ ( + "cld \n\t" + "rep ; stosl \n\t" + : "=&D" (u0), "=&a" (u1), "=&c" (u2) + : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords)) + : "memory" + ); +#else + size_t _n = (dwords + 3) / 4; + Uint32 *_p = SDL_static_cast(Uint32 *, dst); + Uint32 _val = (val); + if (dwords == 0) + return; + switch (dwords % 4) + { + case 0: do { *_p++ = _val; + case 3: *_p++ = _val; + case 2: *_p++ = _val; + case 1: *_p++ = _val; + } while ( --_n ); + } +#endif +} + + +extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); + +SDL_FORCE_INLINE void *SDL_memcpy4(void *dst, const void *src, size_t dwords) +{ + return SDL_memcpy(dst, src, dwords * 4); +} + +extern DECLSPEC void *SDLCALL SDL_memmove(void *dst, const void *src, size_t len); +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); + +extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr); +extern DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen); +extern DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen); + +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str); +extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen); +extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes); +extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen); +extern DECLSPEC char *SDLCALL SDL_strdup(const char *str); +extern DECLSPEC char *SDLCALL SDL_strrev(char *str); +extern DECLSPEC char *SDLCALL SDL_strupr(char *str); +extern DECLSPEC char *SDLCALL SDL_strlwr(char *str); +extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c); +extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c); +extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle); + +extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix); + +extern DECLSPEC int SDLCALL SDL_atoi(const char *str); +extern DECLSPEC double SDLCALL SDL_atof(const char *str); +extern DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base); +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base); +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base); +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base); +extern DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp); + +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len); + +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); +extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap); +extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); +extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); + +#ifndef HAVE_M_PI +#ifndef M_PI +#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#endif +#endif + +extern DECLSPEC double SDLCALL SDL_acos(double x); +extern DECLSPEC double SDLCALL SDL_asin(double x); +extern DECLSPEC double SDLCALL SDL_atan(double x); +extern DECLSPEC double SDLCALL SDL_atan2(double x, double y); +extern DECLSPEC double SDLCALL SDL_ceil(double x); +extern DECLSPEC double SDLCALL SDL_copysign(double x, double y); +extern DECLSPEC double SDLCALL SDL_cos(double x); +extern DECLSPEC float SDLCALL SDL_cosf(float x); +extern DECLSPEC double SDLCALL SDL_fabs(double x); +extern DECLSPEC double SDLCALL SDL_floor(double x); +extern DECLSPEC double SDLCALL SDL_log(double x); +extern DECLSPEC double SDLCALL SDL_pow(double x, double y); +extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); +extern DECLSPEC double SDLCALL SDL_sin(double x); +extern DECLSPEC float SDLCALL SDL_sinf(float x); +extern DECLSPEC double SDLCALL SDL_sqrt(double x); + +/* The SDL implementation of iconv() returns these error codes */ +#define SDL_ICONV_ERROR (size_t)-1 +#define SDL_ICONV_E2BIG (size_t)-2 +#define SDL_ICONV_EILSEQ (size_t)-3 +#define SDL_ICONV_EINVAL (size_t)-4 + +/* SDL_iconv_* are now always real symbols/types, not macros or inlined. */ +typedef struct _SDL_iconv_t *SDL_iconv_t; +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, + const char *fromcode); +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, + size_t * inbytesleft, char **outbuf, + size_t * outbytesleft); +/** + * This function converts a string between encodings in one pass, returning a + * string that must be freed with SDL_free() or NULL on error. + */ +extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, + const char *fromcode, + const char *inbuf, + size_t inbytesleft); +#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_stdinc_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_surface.h b/code/SDL2/include/SDL_surface.h new file mode 100644 index 00000000..aa8d8217 --- /dev/null +++ b/code/SDL2/include/SDL_surface.h @@ -0,0 +1,503 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_surface.h + * + * Header file for ::SDL_Surface definition and management functions. + */ + +#ifndef _SDL_surface_h +#define _SDL_surface_h + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_blendmode.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Surface flags + * + * These are the currently supported flags for the ::SDL_Surface. + * + * \internal + * Used internally (read-only). + */ +/* @{ */ +#define SDL_SWSURFACE 0 /**< Just here for compatibility */ +#define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ +#define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ +#define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ +/* @} *//* Surface flags */ + +/** + * Evaluates to true if the surface needs to be locked before access. + */ +#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) + +/** + * \brief A collection of pixels used in software blitting. + * + * \note This structure should be treated as read-only, except for \c pixels, + * which, if not NULL, contains the raw pixel data for the surface. + */ +typedef struct SDL_Surface +{ + Uint32 flags; /**< Read-only */ + SDL_PixelFormat *format; /**< Read-only */ + int w, h; /**< Read-only */ + int pitch; /**< Read-only */ + void *pixels; /**< Read-write */ + + /** Application data associated with the surface */ + void *userdata; /**< Read-write */ + + /** information needed for surfaces requiring locks */ + int locked; /**< Read-only */ + void *lock_data; /**< Read-only */ + + /** clipping information */ + SDL_Rect clip_rect; /**< Read-only */ + + /** info for fast blit mapping to other surfaces */ + struct SDL_BlitMap *map; /**< Private */ + + /** Reference count -- used when freeing surface */ + int refcount; /**< Read-mostly */ +} SDL_Surface; + +/** + * \brief The type of function used for surface blitting functions. + */ +typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect, + struct SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * Allocate and free an RGB surface. + * + * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. + * If the depth is greater than 8 bits, the pixel format is set using the + * flags '[RGB]mask'. + * + * If the function runs out of memory, it will return NULL. + * + * \param flags The \c flags are obsolete and should be set to 0. + * \param width The width in pixels of the surface to create. + * \param height The height in pixels of the surface to create. + * \param depth The depth in bits of the surface to create. + * \param Rmask The red mask of the surface to create. + * \param Gmask The green mask of the surface to create. + * \param Bmask The blue mask of the surface to create. + * \param Amask The alpha mask of the surface to create. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, + int width, + int height, + int depth, + int pitch, + Uint32 Rmask, + Uint32 Gmask, + Uint32 Bmask, + Uint32 Amask); +extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface); + +/** + * \brief Set the palette used by a surface. + * + * \return 0, or -1 if the surface format doesn't use a palette. + * + * \note A single palette can be shared with many surfaces. + */ +extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface, + SDL_Palette * palette); + +/** + * \brief Sets up a surface for directly accessing the pixels. + * + * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write + * to and read from \c surface->pixels, using the pixel format stored in + * \c surface->format. Once you are done accessing the surface, you should + * use SDL_UnlockSurface() to release it. + * + * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates + * to 0, then you can read and write to the surface at any time, and the + * pixel format of the surface will not change. + * + * No operating system or library calls should be made between lock/unlock + * pairs, as critical system locks may be held during this time. + * + * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. + * + * \sa SDL_UnlockSurface() + */ +extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface); +/** \sa SDL_LockSurface() */ +extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface); + +/** + * Load a surface from a seekable SDL data stream (memory or file). + * + * If \c freesrc is non-zero, the stream will be closed after being read. + * + * The new surface should be freed with SDL_FreeSurface(). + * + * \return the new surface, or NULL if there was an error. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, + int freesrc); + +/** + * Load a surface from a file. + * + * Convenience macro. + */ +#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) + +/** + * Save a surface to a seekable SDL data stream (memory or file). + * + * If \c freedst is non-zero, the stream will be closed after being written. + * + * \return 0 if successful or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SaveBMP_RW + (SDL_Surface * surface, SDL_RWops * dst, int freedst); + +/** + * Save a surface to a file. + * + * Convenience macro. + */ +#define SDL_SaveBMP(surface, file) \ + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + +/** + * \brief Sets the RLE acceleration hint for a surface. + * + * \return 0 on success, or -1 if the surface is not valid + * + * \note If RLE is enabled, colorkey and alpha blending blits are much faster, + * but the surface must be locked before directly accessing the pixels. + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface, + int flag); + +/** + * \brief Sets the color key (transparent pixel) in a blittable surface. + * + * \param surface The surface to update + * \param flag Non-zero to enable colorkey and 0 to disable colorkey + * \param key The transparent pixel in the native surface format + * + * \return 0 on success, or -1 if the surface is not valid + * + * You can pass SDL_RLEACCEL to enable RLE accelerated blits. + */ +extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface, + int flag, Uint32 key); + +/** + * \brief Gets the color key (transparent pixel) in a blittable surface. + * + * \param surface The surface to update + * \param key A pointer filled in with the transparent pixel in the native + * surface format + * + * \return 0 on success, or -1 if the surface is not valid or colorkey is not + * enabled. + */ +extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, + Uint32 * key); + +/** + * \brief Set an additional color value used in blit operations. + * + * \param surface The surface to update. + * \param r The red color value multiplied into blit operations. + * \param g The green color value multiplied into blit operations. + * \param b The blue color value multiplied into blit operations. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_GetSurfaceColorMod() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface, + Uint8 r, Uint8 g, Uint8 b); + + +/** + * \brief Get the additional color value used in blit operations. + * + * \param surface The surface to query. + * \param r A pointer filled in with the current red color value. + * \param g A pointer filled in with the current green color value. + * \param b A pointer filled in with the current blue color value. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceColorMod() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface, + Uint8 * r, Uint8 * g, + Uint8 * b); + +/** + * \brief Set an additional alpha value used in blit operations. + * + * \param surface The surface to update. + * \param alpha The alpha value multiplied into blit operations. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_GetSurfaceAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface, + Uint8 alpha); + +/** + * \brief Get the additional alpha value used in blit operations. + * + * \param surface The surface to query. + * \param alpha A pointer filled in with the current alpha value. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface, + Uint8 * alpha); + +/** + * \brief Set the blend mode used for blit operations. + * + * \param surface The surface to update. + * \param blendMode ::SDL_BlendMode to use for blit blending. + * + * \return 0 on success, or -1 if the parameters are not valid. + * + * \sa SDL_GetSurfaceBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for blit operations. + * + * \param surface The surface to query. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, + SDL_BlendMode *blendMode); + +/** + * Sets the clipping rectangle for the destination surface in a blit. + * + * If the clip rectangle is NULL, clipping will be disabled. + * + * If the clip rectangle doesn't intersect the surface, the function will + * return SDL_FALSE and blits will be completely clipped. Otherwise the + * function returns SDL_TRUE and blits to the surface will be clipped to + * the intersection of the surface area and the clipping rectangle. + * + * Note that blits are automatically clipped to the edges of the source + * and destination surfaces. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface, + const SDL_Rect * rect); + +/** + * Gets the clipping rectangle for the destination surface in a blit. + * + * \c rect must be a pointer to a valid rectangle which will be filled + * with the correct values. + */ +extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, + SDL_Rect * rect); + +/** + * Creates a new surface of the specified format, and then copies and maps + * the given surface to it so the blit of the converted surface will be as + * fast as possible. If this function fails, it returns NULL. + * + * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those + * semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and + * SDL will try to RLE accelerate colorkey and alpha blits in the resulting + * surface. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface + (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); +extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat + (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); + +/** + * \brief Copy a block of pixels of one format to another format + * + * \return 0 on success, or -1 if there was an error + */ +extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, + Uint32 src_format, + const void * src, int src_pitch, + Uint32 dst_format, + void * dst, int dst_pitch); + +/** + * Performs a fast fill of the given rectangle with \c color. + * + * If \c rect is NULL, the whole surface will be filled with \c color. + * + * The color should be a pixel of the format used by the surface, and + * can be generated by the SDL_MapRGB() function. + * + * \return 0 on success, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_FillRect + (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); +extern DECLSPEC int SDLCALL SDL_FillRects + (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); + +/** + * Performs a fast blit from the source surface to the destination surface. + * + * This assumes that the source and destination rectangles are + * the same size. If either \c srcrect or \c dstrect are NULL, the entire + * surface (\c src or \c dst) is copied. The final blit rectangles are saved + * in \c srcrect and \c dstrect after all clipping is performed. + * + * \return If the blit is successful, it returns 0, otherwise it returns -1. + * + * The blit function should not be called on a locked surface. + * + * The blit semantics for surfaces with and without blending and colorkey + * are defined as follows: + * \verbatim + RGBA->RGB: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source alpha-channel and per-surface alpha) + SDL_SRCCOLORKEY ignored. + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB. + if SDL_SRCCOLORKEY set, only copy the pixels matching the + RGB values of the source color key, ignoring alpha in the + comparison. + + RGB->RGBA: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source per-surface alpha) + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB, set destination alpha to source per-surface alpha value. + both: + if SDL_SRCCOLORKEY set, only copy the pixels matching the + source color key. + + RGBA->RGBA: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source alpha-channel and per-surface alpha) + SDL_SRCCOLORKEY ignored. + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy all of RGBA to the destination. + if SDL_SRCCOLORKEY set, only copy the pixels matching the + RGB values of the source color key, ignoring alpha in the + comparison. + + RGB->RGB: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source per-surface alpha) + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB. + both: + if SDL_SRCCOLORKEY set, only copy the pixels matching the + source color key. + \endverbatim + * + * You should call SDL_BlitSurface() unless you know exactly how SDL + * blitting works internally and how to use the other blit functions. + */ +#define SDL_BlitSurface SDL_UpperBlit + +/** + * This is the public blit function, SDL_BlitSurface(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlit() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlit + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * This is a semi-private blit function and it performs low-level surface + * blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlit + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * \brief Perform a fast, low quality, stretch blit between two surfaces of the + * same pixel format. + * + * \note This function uses a static buffer, and is not thread-safe. + */ +extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, + const SDL_Rect * srcrect, + SDL_Surface * dst, + const SDL_Rect * dstrect); + +#define SDL_BlitScaled SDL_UpperBlitScaled + +/** + * This is the public scaled blit function, SDL_BlitScaled(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlitScaled() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlitScaled + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * This is a semi-private blit function and it performs low-level surface + * scaled blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlitScaled + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_surface_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_system.h b/code/SDL2/include/SDL_system.h new file mode 100644 index 00000000..fd929f7f --- /dev/null +++ b/code/SDL2/include/SDL_system.h @@ -0,0 +1,191 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_system.h + * + * Include file for platform specific SDL API functions + */ + +#ifndef _SDL_system_h +#define _SDL_system_h + +#include "SDL_stdinc.h" +#include "SDL_keyboard.h" +#include "SDL_render.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* Platform specific functions for Windows */ +#ifdef __WIN32__ + +/* Returns the D3D9 adapter index that matches the specified display index. + This adapter index can be passed to IDirect3D9::CreateDevice and controls + on which monitor a full screen application will appear. +*/ +extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); + +/* Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. + Once you are done using the device, you should release it to avoid a resource leak. + */ +typedef struct IDirect3DDevice9 IDirect3DDevice9; +extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer); + +/* Returns the DXGI Adapter and Output indices for the specified display index. + These can be passed to EnumAdapters and EnumOutputs respectively to get the objects + required to create a DX10 or DX11 device and swap chain. + */ +extern DECLSPEC void SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex ); + +#endif /* __WIN32__ */ + + +/* Platform specific functions for iOS */ +#if defined(__IPHONEOS__) && __IPHONEOS__ + +extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam); +extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); + +#endif /* __IPHONEOS__ */ + + +/* Platform specific functions for Android */ +#if defined(__ANDROID__) && __ANDROID__ + +/* Get the JNI environment for the current thread + This returns JNIEnv*, but the prototype is void* so we don't need jni.h + */ +extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(); + +/* Get the SDL Activity object for the application + This returns jobject, but the prototype is void* so we don't need jni.h + The jobject returned by SDL_AndroidGetActivity is a local reference. + It is the caller's responsibility to properly release it + (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef) + */ +extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(); + +/* See the official Android developer guide for more information: + http://developer.android.com/guide/topics/data/data-storage.html +*/ +#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01 +#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 + +/* Get the path used for internal storage for this application. + This path is unique to your application and cannot be written to + by other applications. + */ +extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath(); + +/* Get the current state of external storage, a bitmask of these values: + SDL_ANDROID_EXTERNAL_STORAGE_READ + SDL_ANDROID_EXTERNAL_STORAGE_WRITE + If external storage is currently unavailable, this will return 0. +*/ +extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(); + +/* Get the path used for external storage for this application. + This path is unique to your application, but is public and can be + written to by other applications. + */ +extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(); + +#endif /* __ANDROID__ */ + +/* Platform specific functions for WinRT */ +#if defined(__WINRT__) && __WINRT__ + +/** + * \brief WinRT / Windows Phone path types + */ +typedef enum +{ + /** \brief The installed app's root directory. + Files here are likely to be read-only. */ + SDL_WINRT_PATH_INSTALLED_LOCATION, + + /** \brief The app's local data store. Files may be written here */ + SDL_WINRT_PATH_LOCAL_FOLDER, + + /** \brief The app's roaming data store. Unsupported on Windows Phone. + Files written here may be copied to other machines via a network + connection. + */ + SDL_WINRT_PATH_ROAMING_FOLDER, + + /** \brief The app's temporary data store. Unsupported on Windows Phone. + Files written here may be deleted at any time. */ + SDL_WINRT_PATH_TEMP_FOLDER +} SDL_WinRT_Path; + + +/** + * \brief Retrieves a WinRT defined path on the local file system + * + * \note Documentation on most app-specific path types on WinRT + * can be found on MSDN, at the URL: + * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * + * \param pathType The type of path to retrieve. + * \ret A UCS-2 string (16-bit, wide-char) containing the path, or NULL + * if the path is not available for any reason. Not all paths are + * available on all versions of Windows. This is especially true on + * Windows Phone. Check the documentation for the given + * SDL_WinRT_Path for more information on which path types are + * supported where. + */ +extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType); + +/** + * \brief Retrieves a WinRT defined path on the local file system + * + * \note Documentation on most app-specific path types on WinRT + * can be found on MSDN, at the URL: + * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * + * \param pathType The type of path to retrieve. + * \ret A UTF-8 string (8-bit, multi-byte) containing the path, or NULL + * if the path is not available for any reason. Not all paths are + * available on all versions of Windows. This is especially true on + * Windows Phone. Check the documentation for the given + * SDL_WinRT_Path for more information on which path types are + * supported where. + */ +extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType); + +#endif /* __WINRT__ */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_system_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_syswm.h b/code/SDL2/include/SDL_syswm.h new file mode 100644 index 00000000..a3fe7386 --- /dev/null +++ b/code/SDL2/include/SDL_syswm.h @@ -0,0 +1,272 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_syswm.h + * + * Include file for SDL custom system window manager hooks. + */ + +#ifndef _SDL_syswm_h +#define _SDL_syswm_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_syswm.h + * + * Your application has access to a special type of event ::SDL_SYSWMEVENT, + * which contains window-manager specific information and arrives whenever + * an unhandled window event occurs. This event is ignored by default, but + * you can enable it with SDL_EventState(). + */ +#ifdef SDL_PROTOTYPES_ONLY +struct SDL_SysWMinfo; +#else + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) +#define WIN32_LEAN_AND_MEAN +#include +#endif + +#if defined(SDL_VIDEO_DRIVER_WINRT) +#include +#endif + +/* This is the structure for custom window manager events */ +#if defined(SDL_VIDEO_DRIVER_X11) +#if defined(__APPLE__) && defined(__MACH__) +/* conflicts with Quickdraw.h */ +#define Cursor X11Cursor +#endif + +#include +#include + +#if defined(__APPLE__) && defined(__MACH__) +/* matches the re-define above */ +#undef Cursor +#endif + +#endif /* defined(SDL_VIDEO_DRIVER_X11) */ + +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) +#include +#endif + +#if defined(SDL_VIDEO_DRIVER_COCOA) +#ifdef __OBJC__ +#include +#else +typedef struct _NSWindow NSWindow; +#endif +#endif + +#if defined(SDL_VIDEO_DRIVER_UIKIT) +#ifdef __OBJC__ +#include +#else +typedef struct _UIWindow UIWindow; +typedef struct _UIViewController UIViewController; +#endif +#endif + +#if defined(SDL_VIDEO_DRIVER_MIR) +#include +#endif + + +/** + * These are the various supported windowing subsystems + */ +typedef enum +{ + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, + SDL_SYSWM_WINRT, +} SDL_SYSWM_TYPE; + +/** + * The custom event structure. + */ +struct SDL_SysWMmsg +{ + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union + { +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + struct { + HWND hwnd; /**< The window for the message */ + UINT msg; /**< The type of message */ + WPARAM wParam; /**< WORD message parameter */ + LPARAM lParam; /**< LONG message parameter */ + } win; +#endif +#if defined(SDL_VIDEO_DRIVER_X11) + struct { + XEvent event; + } x11; +#endif +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) + struct { + DFBEvent event; + } dfb; +#endif +#if defined(SDL_VIDEO_DRIVER_COCOA) + struct + { + /* No Cocoa window events yet */ + } cocoa; +#endif +#if defined(SDL_VIDEO_DRIVER_UIKIT) + struct + { + /* No UIKit window events yet */ + } uikit; +#endif + /* Can't have an empty union */ + int dummy; + } msg; +}; + +/** + * The custom window manager information structure. + * + * When this structure is returned, it holds information about which + * low level system it is using, and will be one of SDL_SYSWM_TYPE. + */ +struct SDL_SysWMinfo +{ + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union + { +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + struct + { + HWND window; /**< The window handle */ + } win; +#endif +#if defined(SDL_VIDEO_DRIVER_WINRT) + struct + { + IInspectable * window; /**< The WinRT CoreWindow */ + } winrt; +#endif +#if defined(SDL_VIDEO_DRIVER_X11) + struct + { + Display *display; /**< The X11 display */ + Window window; /**< The X11 window */ + } x11; +#endif +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) + struct + { + IDirectFB *dfb; /**< The directfb main interface */ + IDirectFBWindow *window; /**< The directfb window handle */ + IDirectFBSurface *surface; /**< The directfb client surface */ + } dfb; +#endif +#if defined(SDL_VIDEO_DRIVER_COCOA) + struct + { + NSWindow *window; /* The Cocoa window */ + } cocoa; +#endif +#if defined(SDL_VIDEO_DRIVER_UIKIT) + struct + { + UIWindow *window; /* The UIKit window */ + } uikit; +#endif +#if defined(SDL_VIDEO_DRIVER_WAYLAND) + struct + { + struct wl_display *display; /**< Wayland display */ + struct wl_surface *surface; /**< Wayland surface */ + struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ + } wl; +#endif +#if defined(SDL_VIDEO_DRIVER_MIR) + struct + { + MirConnection *connection; /**< Mir display server connection */ + MirSurface *surface; /**< Mir surface */ + } mir; +#endif + + /* Can't have an empty union */ + int dummy; + } info; +}; + +#endif /* SDL_PROTOTYPES_ONLY */ + +typedef struct SDL_SysWMinfo SDL_SysWMinfo; + +/* Function prototypes */ +/** + * \brief This function allows access to driver-dependent window information. + * + * \param window The window about which information is being requested + * \param info This structure must be initialized with the SDL version, and is + * then filled in with information about the given window. + * + * \return SDL_TRUE if the function is implemented and the version member of + * the \c info struct is valid, SDL_FALSE otherwise. + * + * You typically use this function like this: + * \code + * SDL_SysWMinfo info; + * SDL_VERSION(&info.version); + * if ( SDL_GetWindowWMInfo(window, &info) ) { ... } + * \endcode + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, + SDL_SysWMinfo * info); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_syswm_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test.h b/code/SDL2/include/SDL_test.h new file mode 100644 index 00000000..ae649a42 --- /dev/null +++ b/code/SDL2/include/SDL_test.h @@ -0,0 +1,68 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +#ifndef _SDL_test_h +#define _SDL_test_h + +#include "SDL.h" +#include "SDL_test_common.h" +#include "SDL_test_font.h" +#include "SDL_test_random.h" +#include "SDL_test_fuzzer.h" +#include "SDL_test_crc32.h" +#include "SDL_test_md5.h" +#include "SDL_test_log.h" +#include "SDL_test_assert.h" +#include "SDL_test_harness.h" +#include "SDL_test_images.h" +#include "SDL_test_compare.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Global definitions */ + +/* + * Note: Maximum size of SDLTest log message is less than SDLs limit + * to ensure we can fit additional information such as the timestamp. + */ +#define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_assert.h b/code/SDL2/include/SDL_test_assert.h new file mode 100644 index 00000000..79c84d60 --- /dev/null +++ b/code/SDL2/include/SDL_test_assert.h @@ -0,0 +1,105 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_assert.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + * + * Assert API for test code and test cases + * + */ + +#ifndef _SDL_test_assert_h +#define _SDL_test_assert_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Fails the assert. + */ +#define ASSERT_FAIL 0 + +/** + * \brief Passes the assert. + */ +#define ASSERT_PASS 1 + +/** + * \brief Assert that logs and break execution flow on failures. + * + * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). + * \param assertDescription Message to log with the assert describing it. + */ +void SDLTest_Assert(int assertCondition, const char *assertDescription, ...); + +/** + * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. + * + * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). + * \param assertDescription Message to log with the assert describing it. + * + * \returns Returns the assertCondition so it can be used to externally to break execution flow if desired. + */ +int SDLTest_AssertCheck(int assertCondition, const char *assertDescription, ...); + +/** + * \brief Explicitely pass without checking an assertion condition. Updates assertion counter. + * + * \param assertDescription Message to log with the assert describing it. + */ +void SDLTest_AssertPass(const char *assertDescription, ...); + +/** + * \brief Resets the assert summary counters to zero. + */ +void SDLTest_ResetAssertSummary(); + +/** + * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. + */ +void SDLTest_LogAssertSummary(); + + +/** + * \brief Converts the current assert summary state to a test result. + * + * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT + */ +int SDLTest_AssertSummaryToTestResult(); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_assert_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_common.h b/code/SDL2/include/SDL_test_common.h new file mode 100644 index 00000000..45c9edaf --- /dev/null +++ b/code/SDL2/include/SDL_test_common.h @@ -0,0 +1,188 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_common.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* Ported from original test\common.h file. */ + +#ifndef _SDL_test_common_h +#define _SDL_test_common_h + +#include "SDL.h" + +#if defined(__PSP__) +#define DEFAULT_WINDOW_WIDTH 480 +#define DEFAULT_WINDOW_HEIGHT 272 +#else +#define DEFAULT_WINDOW_WIDTH 640 +#define DEFAULT_WINDOW_HEIGHT 480 +#endif + +#define VERBOSE_VIDEO 0x00000001 +#define VERBOSE_MODES 0x00000002 +#define VERBOSE_RENDER 0x00000004 +#define VERBOSE_EVENT 0x00000008 +#define VERBOSE_AUDIO 0x00000010 + +typedef struct +{ + /* SDL init flags */ + char **argv; + Uint32 flags; + Uint32 verbose; + + /* Video info */ + const char *videodriver; + int display; + const char *window_title; + const char *window_icon; + Uint32 window_flags; + int window_x; + int window_y; + int window_w; + int window_h; + int window_minW; + int window_minH; + int window_maxW; + int window_maxH; + int logical_w; + int logical_h; + float scale; + int depth; + int refresh_rate; + int num_windows; + SDL_Window **windows; + + /* Renderer info */ + const char *renderdriver; + Uint32 render_flags; + SDL_bool skip_renderer; + SDL_Renderer **renderers; + SDL_Texture **targets; + + /* Audio info */ + const char *audiodriver; + SDL_AudioSpec audiospec; + + /* GL settings */ + int gl_red_size; + int gl_green_size; + int gl_blue_size; + int gl_alpha_size; + int gl_buffer_size; + int gl_depth_size; + int gl_stencil_size; + int gl_double_buffer; + int gl_accum_red_size; + int gl_accum_green_size; + int gl_accum_blue_size; + int gl_accum_alpha_size; + int gl_stereo; + int gl_multisamplebuffers; + int gl_multisamplesamples; + int gl_retained_backing; + int gl_accelerated; + int gl_major_version; + int gl_minor_version; + int gl_debug; + int gl_profile_mask; +} SDLTest_CommonState; + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * \brief Parse command line parameters and create common state. + * + * \param argv Array of command line parameters + * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO) + * + * \returns Returns a newly allocated common state object. + */ +SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); + +/** + * \brief Process one common argument. + * + * \param state The common state describing the test window to create. + * \param index The index of the argument to process in argv[]. + * + * \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error. + */ +int SDLTest_CommonArg(SDLTest_CommonState * state, int index); + +/** + * \brief Returns common usage information + * + * \param state The common state describing the test window to create. + * + * \returns String with usage information + */ +const char *SDLTest_CommonUsage(SDLTest_CommonState * state); + +/** + * \brief Open test window. + * + * \param state The common state describing the test window to create. + * + * \returns True if initialization succeeded, false otherwise + */ +SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); + +/** + * \brief Common event handler for test windows. + * + * \param state The common state used to create test window. + * \param event The event to handle. + * \param done Flag indicating we are done. + * + */ +void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done); + +/** + * \brief Close test window. + * + * \param state The common state used to create test window. + * + */ +void SDLTest_CommonQuit(SDLTest_CommonState * state); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_common_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_compare.h b/code/SDL2/include/SDL_test_compare.h new file mode 100644 index 00000000..f1353a8d --- /dev/null +++ b/code/SDL2/include/SDL_test_compare.h @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_compare.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Defines comparison functions (i.e. for surfaces). + +*/ + +#ifndef _SDL_test_compare_h +#define _SDL_test_compare_h + +#include "SDL.h" + +#include "SDL_test_images.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Compares a surface and with reference image data for equality + * + * \param surface Surface used in comparison + * \param referenceSurface Test Surface used in comparison + * \param allowable_error Allowable difference (squared) in blending accuracy. + * + * \returns 0 if comparison succeeded, >0 (=number of pixels where comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. + */ +int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_compare_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_crc32.h b/code/SDL2/include/SDL_test_crc32.h new file mode 100644 index 00000000..a180fe3b --- /dev/null +++ b/code/SDL2/include/SDL_test_crc32.h @@ -0,0 +1,124 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_crc32.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Implements CRC32 calculations (default output is Perl String::CRC32 compatible). + +*/ + +#ifndef _SDL_test_crc32_h +#define _SDL_test_crc32_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* ------------ Definitions --------- */ + +/* Definition shared by all CRC routines */ + +#ifndef CrcUint32 + #define CrcUint32 unsigned int +#endif +#ifndef CrcUint8 + #define CrcUint8 unsigned char +#endif + +#ifdef ORIGINAL_METHOD + #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ +#else + #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ +#endif + +/** + * Data structure for CRC32 (checksum) computation + */ + typedef struct { + CrcUint32 crc32_table[256]; /* CRC table */ + } SDLTest_Crc32Context; + +/* ---------- Function Prototypes ------------- */ + +/** + * /brief Initialize the CRC context + * + * Note: The function initializes the crc table required for all crc calculations. + * + * /param crcContext pointer to context variable + * + * /returns 0 for OK, -1 on error + * + */ + int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext); + + +/** + * /brief calculate a crc32 from a data block + * + * /param crcContext pointer to context variable + * /param inBuf input buffer to checksum + * /param inLen length of input buffer + * /param crc32 pointer to Uint32 to store the final CRC into + * + * /returns 0 for OK, -1 on error + * + */ +int SDLTest_crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); + +/* Same routine broken down into three steps */ +int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); +int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); +int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); + + +/** + * /brief clean up CRC context + * + * /param crcContext pointer to context variable + * + * /returns 0 for OK, -1 on error + * +*/ + +int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_crc32_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_font.h b/code/SDL2/include/SDL_test_font.h new file mode 100644 index 00000000..8d51d4a9 --- /dev/null +++ b/code/SDL2/include/SDL_test_font.h @@ -0,0 +1,76 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_font.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +#ifndef _SDL_test_font_h +#define _SDL_test_font_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +#define FONT_CHARACTER_SIZE 8 + +/** + * \brief Draw a string in the currently set font. + * + * \param renderer The renderer to draw on. + * \param x The X coordinate of the upper left corner of the character. + * \param y The Y coordinate of the upper left corner of the character. + * \param c The character to draw. + * + * \returns Returns 0 on success, -1 on failure. + */ +int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c ); + +/** + * \brief Draw a string in the currently set font. + * + * \param renderer The renderer to draw on. + * \param x The X coordinate of the upper left corner of the string. + * \param y The Y coordinate of the upper left corner of the string. + * \param s The string to draw. + * + * \returns Returns 0 on success, -1 on failure. + */ +int SDLTest_DrawString( SDL_Renderer * renderer, int x, int y, const char *s ); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_font_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_fuzzer.h b/code/SDL2/include/SDL_test_fuzzer.h new file mode 100644 index 00000000..64018039 --- /dev/null +++ b/code/SDL2/include/SDL_test_fuzzer.h @@ -0,0 +1,384 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_fuzzer.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Data generators for fuzzing test data in a reproducible way. + +*/ + +#ifndef _SDL_test_fuzzer_h +#define _SDL_test_fuzzer_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* + Based on GSOC code by Markus Kauppila +*/ + + +/** + * \file + * Note: The fuzzer implementation uses a static instance of random context + * internally which makes it thread-UNsafe. + */ + +/** + * Initializes the fuzzer for a test + * + * /param execKey Execution "Key" that initializes the random number generator uniquely for the test. + * + */ +void SDLTest_FuzzerInit(Uint64 execKey); + + +/** + * Returns a random Uint8 + * + * \returns Generated integer + */ +Uint8 SDLTest_RandomUint8(); + +/** + * Returns a random Sint8 + * + * \returns Generated signed integer + */ +Sint8 SDLTest_RandomSint8(); + + +/** + * Returns a random Uint16 + * + * \returns Generated integer + */ +Uint16 SDLTest_RandomUint16(); + +/** + * Returns a random Sint16 + * + * \returns Generated signed integer + */ +Sint16 SDLTest_RandomSint16(); + + +/** + * Returns a random integer + * + * \returns Generated integer + */ +Sint32 SDLTest_RandomSint32(); + + +/** + * Returns a random positive integer + * + * \returns Generated integer + */ +Uint32 SDLTest_RandomUint32(); + +/** + * Returns random Uint64. + * + * \returns Generated integer + */ +Uint64 SDLTest_RandomUint64(); + + +/** + * Returns random Sint64. + * + * \returns Generated signed integer + */ +Sint64 SDLTest_RandomSint64(); + +/** + * \returns random float in range [0.0 - 1.0[ + */ +float SDLTest_RandomUnitFloat(); + +/** + * \returns random double in range [0.0 - 1.0[ + */ +double SDLTest_RandomUnitDouble(); + +/** + * \returns random float. + * + */ +float SDLTest_RandomFloat(); + +/** + * \returns random double. + * + */ +double SDLTest_RandomDouble(); + +/** + * Returns a random boundary value for Uint8 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint8BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint8BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint8BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint8BoundaryValue(0, 255, SDL_FALSE) returns 0 (error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint16 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint16BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint16BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint16BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint16BoundaryValue(0, 0xFFFF, SDL_FALSE) returns 0 (error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint32 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint32BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint32BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint32BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint32BoundaryValue(0, 0xFFFFFFFF, SDL_FALSE) returns 0 (with error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint64 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint64BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint64BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint64BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, SDL_FALSE) returns 0 (with error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint8 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint8BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint8BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint8BoundaryValue(SINT8_MIN, 99, SDL_FALSE) returns 100 + * RandomSint8BoundaryValue(SINT8_MIN, SINT8_MAX, SDL_FALSE) returns SINT8_MIN (== error value) with error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT8_MIN with error set + */ +Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain); + + +/** + * Returns a random boundary value for Sint16 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint16BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint16BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint16BoundaryValue(SINT16_MIN, 99, SDL_FALSE) returns 100 + * RandomSint16BoundaryValue(SINT16_MIN, SINT16_MAX, SDL_FALSE) returns SINT16_MIN (== error value) with error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT16_MIN with error set + */ +Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint32 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint32BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint32BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint32BoundaryValue(SINT32_MIN, 99, SDL_FALSE) returns 100 + * RandomSint32BoundaryValue(SINT32_MIN, SINT32_MAX, SDL_FALSE) returns SINT32_MIN (== error value) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT32_MIN with error set + */ +Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint64 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint64BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint64BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint64BoundaryValue(SINT64_MIN, 99, SDL_FALSE) returns 100 + * RandomSint64BoundaryValue(SINT64_MIN, SINT64_MAX, SDL_FALSE) returns SINT64_MIN (== error value) and error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT64_MIN with error set + */ +Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain); + + +/** + * Returns integer in range [min, max] (inclusive). + * Min and max values can be negative values. + * If Max in smaller tham min, then the values are swapped. + * Min and max are the same value, that value will be returned. + * + * \param min Minimum inclusive value of returned random number + * \param max Maximum inclusive value of returned random number + * + * \returns Generated random integer in range + */ +Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max); + + +/** + * Generates random null-terminated string. The minimum length for + * the string is 1 character, maximum length for the string is 255 + * characters and it can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \returns Newly allocated random string; or NULL if length was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiString(); + + +/** + * Generates random null-terminated string. The maximum length for + * the string is defined by the maxLength parameter. + * String can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \param maxLength The maximum length of the generated string. + * + * \returns Newly allocated random string; or NULL if maxLength was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength); + + +/** + * Generates random null-terminated string. The length for + * the string is defined by the size parameter. + * String can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \param size The length of the generated string + * + * \returns Newly allocated random string; or NULL if size was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiStringOfSize(int size); + +/** + * Returns the invocation count for the fuzzer since last ...FuzzerInit. + */ +int SDLTest_GetFuzzerInvocationCount(); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_fuzzer_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_harness.h b/code/SDL2/include/SDL_test_harness.h new file mode 100644 index 00000000..2c1e2ade --- /dev/null +++ b/code/SDL2/include/SDL_test_harness.h @@ -0,0 +1,123 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_harness.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + Defines types for test case definitions and the test execution harness API. + + Based on original GSOC code by Markus Kauppila +*/ + +#ifndef _SDL_test_harness_h +#define _SDL_test_harness_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* ! Definitions for test case structures */ +#define TEST_ENABLED 1 +#define TEST_DISABLED 0 + +/* ! Definition of all the possible test return values of the test case method */ +#define TEST_ABORTED -1 +#define TEST_STARTED 0 +#define TEST_COMPLETED 1 +#define TEST_SKIPPED 2 + +/* ! Definition of all the possible test results for the harness */ +#define TEST_RESULT_PASSED 0 +#define TEST_RESULT_FAILED 1 +#define TEST_RESULT_NO_ASSERT 2 +#define TEST_RESULT_SKIPPED 3 +#define TEST_RESULT_SETUP_FAILURE 4 + +/* !< Function pointer to a test case setup function (run before every test) */ +typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); + +/* !< Function pointer to a test case function */ +typedef int (*SDLTest_TestCaseFp)(void *arg); + +/* !< Function pointer to a test case teardown function (run after every test) */ +typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); + +/** + * Holds information about a single test case. + */ +typedef struct SDLTest_TestCaseReference { + /* !< Func2Stress */ + SDLTest_TestCaseFp testCase; + /* !< Short name (or function name) "Func2Stress" */ + char *name; + /* !< Long name or full description "This test pushes func2() to the limit." */ + char *description; + /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ + int enabled; +} SDLTest_TestCaseReference; + +/** + * Holds information about a test suite (multiple test cases). + */ +typedef struct SDLTest_TestSuiteReference { + /* !< "PlatformSuite" */ + char *name; + /* !< The function that is run before each test. NULL skips. */ + SDLTest_TestCaseSetUpFp testSetUp; + /* !< The test cases that are run as part of the suite. Last item should be NULL. */ + const SDLTest_TestCaseReference **testCases; + /* !< The function that is run after each test. NULL skips. */ + SDLTest_TestCaseTearDownFp testTearDown; +} SDLTest_TestSuiteReference; + + +/** + * \brief Execute a test suite using the given run seed and execution key. + * + * \param testSuites Suites containing the test case. + * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. + * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. + * \param filter Filter specification. NULL disables. Case sensitive. + * \param testIterations Number of iterations to run each test case. + * + * \returns Test run result; 0 when all tests passed, 1 if any tests failed. + */ +int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_harness_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_images.h b/code/SDL2/include/SDL_test_images.h new file mode 100644 index 00000000..05627996 --- /dev/null +++ b/code/SDL2/include/SDL_test_images.h @@ -0,0 +1,78 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_images.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Defines some images for tests. + +*/ + +#ifndef _SDL_test_images_h +#define _SDL_test_images_h + +#include "SDL.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + *Type for test images. + */ +typedef struct SDLTest_SurfaceImage_s { + int width; + int height; + unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ + const char *pixel_data; +} SDLTest_SurfaceImage_t; + +/* Test images */ +SDL_Surface *SDLTest_ImageBlit(); +SDL_Surface *SDLTest_ImageBlitColor(); +SDL_Surface *SDLTest_ImageBlitAlpha(); +SDL_Surface *SDLTest_ImageBlitBlendAdd(); +SDL_Surface *SDLTest_ImageBlitBlend(); +SDL_Surface *SDLTest_ImageBlitBlendMod(); +SDL_Surface *SDLTest_ImageBlitBlendNone(); +SDL_Surface *SDLTest_ImageBlitBlendAll(); +SDL_Surface *SDLTest_ImageFace(); +SDL_Surface *SDLTest_ImagePrimitives(); +SDL_Surface *SDLTest_ImagePrimitivesBlend(); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_images_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_log.h b/code/SDL2/include/SDL_test_log.h new file mode 100644 index 00000000..76ce1058 --- /dev/null +++ b/code/SDL2/include/SDL_test_log.h @@ -0,0 +1,67 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_log.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + * + * Wrapper to log in the TEST category + * + */ + +#ifndef _SDL_test_log_h +#define _SDL_test_log_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Prints given message with a timestamp in the TEST category and INFO priority. + * + * \param fmt Message to be logged + */ +void SDLTest_Log(const char *fmt, ...); + +/** + * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. + * + * \param fmt Message to be logged + */ +void SDLTest_LogError(const char *fmt, ...); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_log_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_md5.h b/code/SDL2/include/SDL_test_md5.h new file mode 100644 index 00000000..029e164b --- /dev/null +++ b/code/SDL2/include/SDL_test_md5.h @@ -0,0 +1,129 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_md5.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + *********************************************************************** + ** Header file for implementation of MD5 ** + ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** + ** Revised (for MD5): RLR 4/27/91 ** + ** -- G modified to have y&~z instead of y&z ** + ** -- FF, GG, HH modified to add in last register done ** + ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** + ** -- distinct additive constant for each step ** + ** -- round 4 added, working mod 7 ** + *********************************************************************** +*/ + +/* + *********************************************************************** + ** Message-digest routines: ** + ** To form the message digest for a message M ** + ** (1) Initialize a context buffer mdContext using MD5Init ** + ** (2) Call MD5Update on mdContext and M ** + ** (3) Call MD5Final on mdContext ** + ** The message digest is now in mdContext->digest[0...15] ** + *********************************************************************** +*/ + +#ifndef _SDL_test_md5_h +#define _SDL_test_md5_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------ Definitions --------- */ + +/* typedef a 32-bit type */ + typedef unsigned long int MD5UINT4; + +/* Data structure for MD5 (Message-Digest) computation */ + typedef struct { + MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ + MD5UINT4 buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after Md5Final call */ + } SDLTest_Md5Context; + +/* ---------- Function Prototypes ------------- */ + +/** + * /brief initialize the context + * + * /param mdContext pointer to context variable + * + * Note: The function initializes the message-digest context + * mdContext. Call before each new use of the context - + * all fields are set to zero. + */ + void SDLTest_Md5Init(SDLTest_Md5Context * mdContext); + + +/** + * /brief update digest from variable length data + * + * /param mdContext pointer to context variable + * /param inBuf pointer to data array/string + * /param inLen length of data array/string + * + * Note: The function updates the message-digest context to account + * for the presence of each of the characters inBuf[0..inLen-1] + * in the message whose digest is being computed. +*/ + + void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, + unsigned int inLen); + + +/* + * /brief complete digest computation + * + * /param mdContext pointer to context variable + * + * Note: The function terminates the message-digest computation and + * ends with the desired message digest in mdContext.digest[0..15]. + * Always call before using the digest[] variable. +*/ + + void SDLTest_Md5Final(SDLTest_Md5Context * mdContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_md5_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_test_random.h b/code/SDL2/include/SDL_test_random.h new file mode 100644 index 00000000..6c5660d8 --- /dev/null +++ b/code/SDL2/include/SDL_test_random.h @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_random.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + A "32-bit Multiply with carry random number generator. Very fast. + Includes a list of recommended multipliers. + + multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. + period: (a*2^31)-1 + +*/ + +#ifndef _SDL_test_random_h +#define _SDL_test_random_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* --- Definitions */ + +/* + * Macros that return a random number in a specific format. + */ +#define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) + +/* + * Context structure for the random number generator state. + */ + typedef struct { + unsigned int a; + unsigned int x; + unsigned int c; + unsigned int ah; + unsigned int al; + } SDLTest_RandomContext; + + +/* --- Function prototypes */ + +/** + * \brief Initialize random number generator with two integers. + * + * Note: The random sequence of numbers returned by ...Random() is the + * same for the same two integers and has a period of 2^31. + * + * \param rndContext pointer to context structure + * \param xi integer that defines the random sequence + * \param ci integer that defines the random sequence + * + */ + void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, + unsigned int ci); + +/** + * \brief Initialize random number generator based on current system time. + * + * \param rndContext pointer to context structure + * + */ + void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext); + + +/** + * \brief Initialize random number generator based on current system time. + * + * Note: ...RandomInit() or ...RandomInitTime() must have been called + * before using this function. + * + * \param rndContext pointer to context structure + * + * \returns A random number (32bit unsigned integer) + * + */ + unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_random_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_thread.h b/code/SDL2/include/SDL_thread.h new file mode 100644 index 00000000..4e48cc34 --- /dev/null +++ b/code/SDL2/include/SDL_thread.h @@ -0,0 +1,287 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_thread_h +#define _SDL_thread_h + +/** + * \file SDL_thread.h + * + * Header for the SDL thread management routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/* Thread synchronization primitives */ +#include "SDL_atomic.h" +#include "SDL_mutex.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The SDL thread structure, defined in SDL_thread.c */ +struct SDL_Thread; +typedef struct SDL_Thread SDL_Thread; + +/* The SDL thread ID */ +typedef unsigned long SDL_threadID; + +/* Thread local storage ID, 0 is the invalid ID */ +typedef unsigned int SDL_TLSID; + +/** + * The SDL thread priority. + * + * \note On many systems you require special privileges to set high priority. + */ +typedef enum { + SDL_THREAD_PRIORITY_LOW, + SDL_THREAD_PRIORITY_NORMAL, + SDL_THREAD_PRIORITY_HIGH +} SDL_ThreadPriority; + +/** + * The function passed to SDL_CreateThread(). + * It is passed a void* user context parameter and returns an int. + */ +typedef int (SDLCALL * SDL_ThreadFunction) (void *data); + +#if defined(__WIN32__) && !defined(HAVE_LIBC) +/** + * \file SDL_thread.h + * + * We compile SDL into a DLL. This means, that it's the DLL which + * creates a new thread for the calling process with the SDL_CreateThread() + * API. There is a problem with this, that only the RTL of the SDL.DLL will + * be initialized for those threads, and not the RTL of the calling + * application! + * + * To solve this, we make a little hack here. + * + * We'll always use the caller's _beginthread() and _endthread() APIs to + * start a new thread. This way, if it's the SDL.DLL which uses this API, + * then the RTL of SDL.DLL will be used to create the new thread, and if it's + * the application, then the RTL of the application will be used. + * + * So, in short: + * Always use the _beginthread() and _endthread() of the calling runtime + * library! + */ +#define SDL_PASSED_BEGINTHREAD_ENDTHREAD +#include /* This has _beginthread() and _endthread() defined! */ + +typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall * + func) (void + *), + void *arg, unsigned, + unsigned *threadID); +typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); + +/** + * Create a thread. + */ +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread); + +/** + * Create a thread. + */ +#if defined(SDL_CreateThread) && SDL_DYNAMIC_API +#undef SDL_CreateThread +#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex) +#else +#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex) +#endif + +#else + +/** + * Create a thread. + * + * Thread naming is a little complicated: Most systems have very small + * limits for the string length (Haiku has 32 bytes, Linux currently has 16, + * Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll + * have to see what happens with your system's debugger. The name should be + * UTF-8 (but using the naming limits of C identifiers is a better bet). + * There are no requirements for thread naming conventions, so long as the + * string is null-terminated UTF-8, but these guidelines are helpful in + * choosing a name: + * + * http://stackoverflow.com/questions/149932/naming-conventions-for-threads + * + * If a system imposes requirements, SDL will try to munge the string for + * it (truncate, etc), but the original string contents will be available + * from SDL_GetThreadName(). + */ +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data); + +#endif + +/** + * Get the thread name, as it was specified in SDL_CreateThread(). + * This function returns a pointer to a UTF-8 string that names the + * specified thread, or NULL if it doesn't have a name. This is internal + * memory, not to be free()'d by the caller, and remains valid until the + * specified thread is cleaned up by SDL_WaitThread(). + */ +extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread); + +/** + * Get the thread identifier for the current thread. + */ +extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void); + +/** + * Get the thread identifier for the specified thread. + * + * Equivalent to SDL_ThreadID() if the specified thread is NULL. + */ +extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread); + +/** + * Set the priority for the current thread + */ +extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); + +/** + * Wait for a thread to finish. Threads that haven't been detached will + * remain (as a "zombie") until this function cleans them up. Not doing so + * is a resource leak. + * + * Once a thread has been cleaned up through this function, the SDL_Thread + * that references it becomes invalid and should not be referenced again. + * As such, only one thread may call SDL_WaitThread() on another. + * + * The return code for the thread function is placed in the area + * pointed to by \c status, if \c status is not NULL. + * + * You may not wait on a thread that has been used in a call to + * SDL_DetachThread(). Use either that function or this one, but not + * both, or behavior is undefined. + * + * It is safe to pass NULL to this function; it is a no-op. + */ +extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status); + +/** + * A thread may be "detached" to signify that it should not remain until + * another thread has called SDL_WaitThread() on it. Detaching a thread + * is useful for long-running threads that nothing needs to synchronize + * with or further manage. When a detached thread is done, it simply + * goes away. + * + * There is no way to recover the return code of a detached thread. If you + * need this, don't detach the thread and instead use SDL_WaitThread(). + * + * Once a thread is detached, you should usually assume the SDL_Thread isn't + * safe to reference again, as it will become invalid immediately upon + * the detached thread's exit, instead of remaining until someone has called + * SDL_WaitThread() to finally clean it up. As such, don't detach the same + * thread more than once. + * + * If a thread has already exited when passed to SDL_DetachThread(), it will + * stop waiting for a call to SDL_WaitThread() and clean up immediately. + * It is not safe to detach a thread that might be used with SDL_WaitThread(). + * + * You may not call SDL_WaitThread() on a thread that has been detached. + * Use either that function or this one, but not both, or behavior is + * undefined. + * + * It is safe to pass NULL to this function; it is a no-op. + */ +extern DECLSPEC void SDLCALL SDL_DetachThread(SDL_Thread * thread); + +/** + * \brief Create an identifier that is globally visible to all threads but refers to data that is thread-specific. + * + * \return The newly created thread local storage identifier, or 0 on error + * + * \code + * static SDL_SpinLock tls_lock; + * static SDL_TLSID thread_local_storage; + * + * void SetMyThreadData(void *value) + * { + * if (!thread_local_storage) { + * SDL_AtomicLock(&tls_lock); + * if (!thread_local_storage) { + * thread_local_storage = SDL_TLSCreate(); + * } + * SDL_AtomicUnLock(&tls_lock); + * } + * SDL_TLSSet(thread_local_storage, value); + * } + * + * void *GetMyThreadData(void) + * { + * return SDL_TLSGet(thread_local_storage); + * } + * \endcode + * + * \sa SDL_TLSGet() + * \sa SDL_TLSSet() + */ +extern DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate(void); + +/** + * \brief Get the value associated with a thread local storage ID for the current thread. + * + * \param id The thread local storage ID + * + * \return The value associated with the ID for the current thread, or NULL if no value has been set. + * + * \sa SDL_TLSCreate() + * \sa SDL_TLSSet() + */ +extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id); + +/** + * \brief Set the value associated with a thread local storage ID for the current thread. + * + * \param id The thread local storage ID + * \param value The value to associate with the ID for the current thread + * \param destructor A function called when the thread exits, to free the value. + * + * \return 0 on success, -1 on error + * + * \sa SDL_TLSCreate() + * \sa SDL_TLSGet() + */ +extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (*destructor)(void*)); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_thread_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_timer.h b/code/SDL2/include/SDL_timer.h new file mode 100644 index 00000000..a48e0466 --- /dev/null +++ b/code/SDL2/include/SDL_timer.h @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_timer_h +#define _SDL_timer_h + +/** + * \file SDL_timer.h + * + * Header for the SDL time management routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Get the number of milliseconds since the SDL library initialization. + * + * \note This value wraps if the program runs for more than ~49 days. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); + +/** + * \brief Compare SDL ticks values, and return true if A has passed B + * + * e.g. if you want to wait 100 ms, you could do this: + * Uint32 timeout = SDL_GetTicks() + 100; + * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { + * ... do work until timeout has elapsed + * } + */ +#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) + +/** + * \brief Get the current value of the high resolution counter + */ +extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); + +/** + * \brief Get the count per second of the high resolution counter + */ +extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); + +/** + * \brief Wait a specified number of milliseconds before returning. + */ +extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); + +/** + * Function prototype for the timer callback function. + * + * The callback function is passed the current timer interval and returns + * the next timer interval. If the returned value is the same as the one + * passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is cancelled. + */ +typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); + +/** + * Definition of the timer ID type. + */ +typedef int SDL_TimerID; + +/** + * \brief Add a new timer to the pool of timers already running. + * + * \return A timer ID, or NULL when an error occurs. + */ +extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, + SDL_TimerCallback callback, + void *param); + +/** + * \brief Remove a timer knowing its ID. + * + * \return A boolean value indicating success or failure. + * + * \warning It is not safe to remove a timer multiple times. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_timer_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_touch.h b/code/SDL2/include/SDL_touch.h new file mode 100644 index 00000000..017deb28 --- /dev/null +++ b/code/SDL2/include/SDL_touch.h @@ -0,0 +1,86 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_touch.h + * + * Include file for SDL touch event handling. + */ + +#ifndef _SDL_touch_h +#define _SDL_touch_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef Sint64 SDL_TouchID; +typedef Sint64 SDL_FingerID; + +typedef struct SDL_Finger +{ + SDL_FingerID id; + float x; + float y; + float pressure; +} SDL_Finger; + +/* Used as the device ID for mouse events simulated with touch input */ +#define SDL_TOUCH_MOUSEID ((Uint32)-1) + + +/* Function prototypes */ + +/** + * \brief Get the number of registered touch devices. + */ +extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); + +/** + * \brief Get the touch ID with the given index, or 0 if the index is invalid. + */ +extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); + +/** + * \brief Get the number of active fingers for a given touch device. + */ +extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); + +/** + * \brief Get the finger object of the given touch, with the given index. + */ +extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_touch_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_types.h b/code/SDL2/include/SDL_types.h new file mode 100644 index 00000000..cd3ba33c --- /dev/null +++ b/code/SDL2/include/SDL_types.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_types.h + * + * \deprecated + */ + +/* DEPRECATED */ +#include "SDL_stdinc.h" diff --git a/code/SDL2/include/SDL_version.h b/code/SDL2/include/SDL_version.h new file mode 100644 index 00000000..d02898bb --- /dev/null +++ b/code/SDL2/include/SDL_version.h @@ -0,0 +1,162 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_version.h + * + * This header defines the current SDL version. + */ + +#ifndef _SDL_version_h +#define _SDL_version_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Information the version of SDL in use. + * + * Represents the library's version as three levels: major revision + * (increments with massive changes, additions, and enhancements), + * minor revision (increments with backwards-compatible changes to the + * major revision), and patchlevel (increments with fixes to the minor + * revision). + * + * \sa SDL_VERSION + * \sa SDL_GetVersion + */ +typedef struct SDL_version +{ + Uint8 major; /**< major version */ + Uint8 minor; /**< minor version */ + Uint8 patch; /**< update version */ +} SDL_version; + +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL +*/ +#define SDL_MAJOR_VERSION 2 +#define SDL_MINOR_VERSION 0 +#define SDL_PATCHLEVEL 3 + +/** + * \brief Macro to determine SDL version program was compiled against. + * + * This macro fills in a SDL_version structure with the version of the + * library you compiled against. This is determined by what header the + * compiler uses. Note that if you dynamically linked the library, you might + * have a slightly newer or older version at runtime. That version can be + * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), + * is not a macro. + * + * \param x A pointer to a SDL_version struct to initialize. + * + * \sa SDL_version + * \sa SDL_GetVersion + */ +#define SDL_VERSION(x) \ +{ \ + (x)->major = SDL_MAJOR_VERSION; \ + (x)->minor = SDL_MINOR_VERSION; \ + (x)->patch = SDL_PATCHLEVEL; \ +} + +/** + * This macro turns the version numbers into a numeric value: + * \verbatim + (1,2,3) -> (1203) + \endverbatim + * + * This assumes that there will never be more than 100 patchlevels. + */ +#define SDL_VERSIONNUM(X, Y, Z) \ + ((X)*1000 + (Y)*100 + (Z)) + +/** + * This is the version number macro for the current SDL version. + */ +#define SDL_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +/** + * This macro will evaluate to true if compiled with SDL at least X.Y.Z. + */ +#define SDL_VERSION_ATLEAST(X, Y, Z) \ + (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/** + * \brief Get the version of SDL that is linked against your program. + * + * If you are linking to SDL dynamically, then it is possible that the + * current version will be different than the version you compiled against. + * This function returns the current version, while SDL_VERSION() is a + * macro that tells you what version you compiled with. + * + * \code + * SDL_version compiled; + * SDL_version linked; + * + * SDL_VERSION(&compiled); + * SDL_GetVersion(&linked); + * printf("We compiled against SDL version %d.%d.%d ...\n", + * compiled.major, compiled.minor, compiled.patch); + * printf("But we linked against SDL version %d.%d.%d.\n", + * linked.major, linked.minor, linked.patch); + * \endcode + * + * This function may be called safely at any time, even before SDL_Init(). + * + * \sa SDL_VERSION + */ +extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); + +/** + * \brief Get the code revision of SDL that is linked against your program. + * + * Returns an arbitrary string (a hash value) uniquely identifying the + * exact revision of the SDL library in use, and is only useful in comparing + * against other revisions. It is NOT an incrementing number. + */ +extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); + +/** + * \brief Get the revision number of SDL that is linked against your program. + * + * Returns a number uniquely identifying the exact revision of the SDL + * library in use. It is an incrementing number based on commits to + * hg.libsdl.org. + */ +extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_version_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/SDL_video.h b/code/SDL2/include/SDL_video.h new file mode 100644 index 00000000..49ea37ad --- /dev/null +++ b/code/SDL2/include/SDL_video.h @@ -0,0 +1,979 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_video.h + * + * Header file for SDL video functions. + */ + +#ifndef _SDL_video_h +#define _SDL_video_h + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_surface.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The structure that defines a display mode + * + * \sa SDL_GetNumDisplayModes() + * \sa SDL_GetDisplayMode() + * \sa SDL_GetDesktopDisplayMode() + * \sa SDL_GetCurrentDisplayMode() + * \sa SDL_GetClosestDisplayMode() + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_GetWindowDisplayMode() + */ +typedef struct +{ + Uint32 format; /**< pixel format */ + int w; /**< width */ + int h; /**< height */ + int refresh_rate; /**< refresh rate (or zero for unspecified) */ + void *driverdata; /**< driver-specific data, initialize to 0 */ +} SDL_DisplayMode; + +/** + * \brief The type used to identify a window + * + * \sa SDL_CreateWindow() + * \sa SDL_CreateWindowFrom() + * \sa SDL_DestroyWindow() + * \sa SDL_GetWindowData() + * \sa SDL_GetWindowFlags() + * \sa SDL_GetWindowGrab() + * \sa SDL_GetWindowPosition() + * \sa SDL_GetWindowSize() + * \sa SDL_GetWindowTitle() + * \sa SDL_HideWindow() + * \sa SDL_MaximizeWindow() + * \sa SDL_MinimizeWindow() + * \sa SDL_RaiseWindow() + * \sa SDL_RestoreWindow() + * \sa SDL_SetWindowData() + * \sa SDL_SetWindowFullscreen() + * \sa SDL_SetWindowGrab() + * \sa SDL_SetWindowIcon() + * \sa SDL_SetWindowPosition() + * \sa SDL_SetWindowSize() + * \sa SDL_SetWindowBordered() + * \sa SDL_SetWindowTitle() + * \sa SDL_ShowWindow() + */ +typedef struct SDL_Window SDL_Window; + +/** + * \brief The flags on a window + * + * \sa SDL_GetWindowFlags() + */ +typedef enum +{ + SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */ + SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */ + SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */ + SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */ + SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */ + SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ + SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */ + SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */ + SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */ + SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ + SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ + SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), + SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */ + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000 /**< window should be created in high-DPI mode if supported */ +} SDL_WindowFlags; + +/** + * \brief Used to indicate that you don't care what the window position is. + */ +#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000 +#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) +#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) +#define SDL_WINDOWPOS_ISUNDEFINED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) + +/** + * \brief Used to indicate that the window position should be centered. + */ +#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000 +#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) +#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) +#define SDL_WINDOWPOS_ISCENTERED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) + +/** + * \brief Event subtype for window events + */ +typedef enum +{ + SDL_WINDOWEVENT_NONE, /**< Never used */ + SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */ + SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */ + SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be + redrawn */ + SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2 + */ + SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */ + SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as a result of an API call or through the system or user changing the window size. */ + SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */ + SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */ + SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size + and position */ + SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */ + SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */ + SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */ + SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */ + SDL_WINDOWEVENT_CLOSE /**< The window manager requests that the + window be closed */ +} SDL_WindowEventID; + +/** + * \brief An opaque handle to an OpenGL context. + */ +typedef void *SDL_GLContext; + +/** + * \brief OpenGL configuration attributes + */ +typedef enum +{ + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION, + SDL_GL_CONTEXT_EGL, + SDL_GL_CONTEXT_FLAGS, + SDL_GL_CONTEXT_PROFILE_MASK, + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE +} SDL_GLattr; + +typedef enum +{ + SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, + SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, + SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /* GLX_CONTEXT_ES2_PROFILE_BIT_EXT */ +} SDL_GLprofile; + +typedef enum +{ + SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, + SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, + SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004, + SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008 +} SDL_GLcontextFlag; + + +/* Function prototypes */ + +/** + * \brief Get the number of video drivers compiled into SDL + * + * \sa SDL_GetVideoDriver() + */ +extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); + +/** + * \brief Get the name of a built in video driver. + * + * \note The video drivers are presented in the order in which they are + * normally checked during initialization. + * + * \sa SDL_GetNumVideoDrivers() + */ +extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); + +/** + * \brief Initialize the video subsystem, optionally specifying a video driver. + * + * \param driver_name Initialize a specific driver by name, or NULL for the + * default video driver. + * + * \return 0 on success, -1 on error + * + * This function initializes the video subsystem; setting up a connection + * to the window manager, etc, and determines the available display modes + * and pixel formats, but does not initialize a window or graphics mode. + * + * \sa SDL_VideoQuit() + */ +extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name); + +/** + * \brief Shuts down the video subsystem. + * + * This function closes all windows, and restores the original video mode. + * + * \sa SDL_VideoInit() + */ +extern DECLSPEC void SDLCALL SDL_VideoQuit(void); + +/** + * \brief Returns the name of the currently initialized video driver. + * + * \return The name of the current video driver or NULL if no driver + * has been initialized + * + * \sa SDL_GetNumVideoDrivers() + * \sa SDL_GetVideoDriver() + */ +extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); + +/** + * \brief Returns the number of available video displays. + * + * \sa SDL_GetDisplayBounds() + */ +extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); + +/** + * \brief Get the name of a display in UTF-8 encoding + * + * \return The name of a display, or NULL for an invalid display index. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex); + +/** + * \brief Get the desktop area represented by a display, with the primary + * display located at 0,0 + * + * \return 0 on success, or -1 if the index is out of range. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect); + +/** + * \brief Returns the number of available display modes. + * + * \sa SDL_GetDisplayMode() + */ +extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex); + +/** + * \brief Fill in information about a specific display mode. + * + * \note The display modes are sorted in this priority: + * \li bits per pixel -> more colors to fewer colors + * \li width -> largest to smallest + * \li height -> largest to smallest + * \li refresh rate -> highest to lowest + * + * \sa SDL_GetNumDisplayModes() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, + SDL_DisplayMode * mode); + +/** + * \brief Fill in information about the desktop display mode. + */ +extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode); + +/** + * \brief Fill in information about the current display mode. + */ +extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode); + + +/** + * \brief Get the closest match to the requested display mode. + * + * \param displayIndex The index of display from which mode should be queried. + * \param mode The desired display mode + * \param closest A pointer to a display mode to be filled in with the closest + * match of the available display modes. + * + * \return The passed in value \c closest, or NULL if no matching video mode + * was available. + * + * The available display modes are scanned, and \c closest is filled in with the + * closest mode matching the requested mode and returned. The mode format and + * refresh_rate default to the desktop mode if they are 0. The modes are + * scanned with size being first priority, format being second priority, and + * finally checking the refresh_rate. If all the available modes are too + * small, then NULL is returned. + * + * \sa SDL_GetNumDisplayModes() + * \sa SDL_GetDisplayMode() + */ +extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); + +/** + * \brief Get the display index associated with a window. + * + * \return the display index of the display containing the center of the + * window, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window); + +/** + * \brief Set the display mode used when a fullscreen window is visible. + * + * By default the window's dimensions and the desktop format and refresh rate + * are used. + * + * \param window The window for which the display mode should be set. + * \param mode The mode to use, or NULL for the default mode. + * + * \return 0 on success, or -1 if setting the display mode failed. + * + * \sa SDL_GetWindowDisplayMode() + * \sa SDL_SetWindowFullscreen() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, + const SDL_DisplayMode + * mode); + +/** + * \brief Fill in information about the display mode used when a fullscreen + * window is visible. + * + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_SetWindowFullscreen() + */ +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, + SDL_DisplayMode * mode); + +/** + * \brief Get the pixel format associated with the window. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); + +/** + * \brief Create a window with the specified position, dimensions, and flags. + * + * \param title The title of the window, in UTF-8 encoding. + * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param w The width of the window. + * \param h The height of the window. + * \param flags The flags for the window, a mask of any of the following: + * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, + * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS, + * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, + * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED, + * ::SDL_WINDOW_ALLOW_HIGHDPI. + * + * \return The id of the window created, or zero if window creation failed. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, + int x, int y, int w, + int h, Uint32 flags); + +/** + * \brief Create an SDL window from an existing native window. + * + * \param data A pointer to driver-dependent window creation data + * + * \return The id of the window created, or zero if window creation failed. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data); + +/** + * \brief Get the numeric ID of a window, for logging purposes. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window); + +/** + * \brief Get a window from a stored ID, or NULL if it doesn't exist. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id); + +/** + * \brief Get the window flags. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window); + +/** + * \brief Set the title of a window, in UTF-8 format. + * + * \sa SDL_GetWindowTitle() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, + const char *title); + +/** + * \brief Get the title of a window, in UTF-8 format. + * + * \sa SDL_SetWindowTitle() + */ +extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window); + +/** + * \brief Set the icon for a window. + * + * \param window The window for which the icon should be set. + * \param icon The icon for the window. + */ +extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, + SDL_Surface * icon); + +/** + * \brief Associate an arbitrary named pointer with a window. + * + * \param window The window to associate with the pointer. + * \param name The name of the pointer. + * \param userdata The associated pointer. + * + * \return The previous value associated with 'name' + * + * \note The name is case-sensitive. + * + * \sa SDL_GetWindowData() + */ +extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, + const char *name, + void *userdata); + +/** + * \brief Retrieve the data pointer associated with a window. + * + * \param window The window to query. + * \param name The name of the pointer. + * + * \return The value associated with 'name' + * + * \sa SDL_SetWindowData() + */ +extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, + const char *name); + +/** + * \brief Set the position of a window. + * + * \param window The window to reposition. + * \param x The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or + ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or + ::SDL_WINDOWPOS_UNDEFINED. + * + * \note The window coordinate origin is the upper left of the display. + * + * \sa SDL_GetWindowPosition() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, + int x, int y); + +/** + * \brief Get the position of a window. + * + * \param window The window to query. + * \param x Pointer to variable for storing the x position, may be NULL + * \param y Pointer to variable for storing the y position, may be NULL + * + * \sa SDL_SetWindowPosition() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, + int *x, int *y); + +/** + * \brief Set the size of a window's client area. + * + * \param window The window to resize. + * \param w The width of the window, must be >0 + * \param h The height of the window, must be >0 + * + * \note You can't change the size of a fullscreen window, it automatically + * matches the size of the display mode. + * + * \sa SDL_GetWindowSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, + int h); + +/** + * \brief Get the size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the width, may be NULL + * \param h Pointer to variable for storing the height, may be NULL + * + * \sa SDL_SetWindowSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, + int *h); + +/** + * \brief Set the minimum size of a window's client area. + * + * \param window The window to set a new minimum size. + * \param min_w The minimum width of the window, must be >0 + * \param min_h The minimum height of the window, must be >0 + * + * \note You can't change the minimum size of a fullscreen window, it + * automatically matches the size of the display mode. + * + * \sa SDL_GetWindowMinimumSize() + * \sa SDL_SetWindowMaximumSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window, + int min_w, int min_h); + +/** + * \brief Get the minimum size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the minimum width, may be NULL + * \param h Pointer to variable for storing the minimum height, may be NULL + * + * \sa SDL_GetWindowMaximumSize() + * \sa SDL_SetWindowMinimumSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window, + int *w, int *h); + +/** + * \brief Set the maximum size of a window's client area. + * + * \param window The window to set a new maximum size. + * \param max_w The maximum width of the window, must be >0 + * \param max_h The maximum height of the window, must be >0 + * + * \note You can't change the maximum size of a fullscreen window, it + * automatically matches the size of the display mode. + * + * \sa SDL_GetWindowMaximumSize() + * \sa SDL_SetWindowMinimumSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window, + int max_w, int max_h); + +/** + * \brief Get the maximum size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the maximum width, may be NULL + * \param h Pointer to variable for storing the maximum height, may be NULL + * + * \sa SDL_GetWindowMinimumSize() + * \sa SDL_SetWindowMaximumSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window, + int *w, int *h); + +/** + * \brief Set the border state of a window. + * + * This will add or remove the window's SDL_WINDOW_BORDERLESS flag and + * add or remove the border from the actual window. This is a no-op if the + * window's border already matches the requested state. + * + * \param window The window of which to change the border state. + * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border. + * + * \note You can't change the border state of a fullscreen window. + * + * \sa SDL_GetWindowFlags() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, + SDL_bool bordered); + +/** + * \brief Show a window. + * + * \sa SDL_HideWindow() + */ +extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window); + +/** + * \brief Hide a window. + * + * \sa SDL_ShowWindow() + */ +extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window); + +/** + * \brief Raise a window above other windows and set the input focus. + */ +extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window); + +/** + * \brief Make a window as large as possible. + * + * \sa SDL_RestoreWindow() + */ +extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window); + +/** + * \brief Minimize a window to an iconic representation. + * + * \sa SDL_RestoreWindow() + */ +extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window); + +/** + * \brief Restore the size and position of a minimized or maximized window. + * + * \sa SDL_MaximizeWindow() + * \sa SDL_MinimizeWindow() + */ +extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); + +/** + * \brief Set a window's fullscreen state. + * + * \return 0 on success, or -1 if setting the display mode failed. + * + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_GetWindowDisplayMode() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, + Uint32 flags); + +/** + * \brief Get the SDL surface associated with the window. + * + * \return The window's framebuffer surface, or NULL on error. + * + * A new surface will be created with the optimal format for the window, + * if necessary. This surface will be freed when the window is destroyed. + * + * \note You may not combine this with 3D or the rendering API on this window. + * + * \sa SDL_UpdateWindowSurface() + * \sa SDL_UpdateWindowSurfaceRects() + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window); + +/** + * \brief Copy the window surface to the screen. + * + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetWindowSurface() + * \sa SDL_UpdateWindowSurfaceRects() + */ +extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window); + +/** + * \brief Copy a number of rectangles on the window surface to the screen. + * + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetWindowSurface() + * \sa SDL_UpdateWindowSurfaceRect() + */ +extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, + const SDL_Rect * rects, + int numrects); + +/** + * \brief Set a window's input grab mode. + * + * \param window The window for which the input grab mode should be set. + * \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input. + * + * \sa SDL_GetWindowGrab() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, + SDL_bool grabbed); + +/** + * \brief Get a window's input grab mode. + * + * \return This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise. + * + * \sa SDL_SetWindowGrab() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window); + +/** + * \brief Set the brightness (gamma correction) for a window. + * + * \return 0 on success, or -1 if setting the brightness isn't supported. + * + * \sa SDL_GetWindowBrightness() + * \sa SDL_SetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness); + +/** + * \brief Get the brightness (gamma correction) for a window. + * + * \return The last brightness value passed to SDL_SetWindowBrightness() + * + * \sa SDL_SetWindowBrightness() + */ +extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window); + +/** + * \brief Set the gamma ramp for a window. + * + * \param window The window for which the gamma ramp should be set. + * \param red The translation table for the red channel, or NULL. + * \param green The translation table for the green channel, or NULL. + * \param blue The translation table for the blue channel, or NULL. + * + * \return 0 on success, or -1 if gamma ramps are unsupported. + * + * Set the gamma translation table for the red, green, and blue channels + * of the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. + * The input is the index into the array, and the output is the 16-bit + * gamma value at that index, scaled to the output color precision. + * + * \sa SDL_GetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, + const Uint16 * red, + const Uint16 * green, + const Uint16 * blue); + +/** + * \brief Get the gamma ramp for a window. + * + * \param window The window from which the gamma ramp should be queried. + * \param red A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the red channel, or NULL. + * \param green A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the green channel, or NULL. + * \param blue A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the blue channel, or NULL. + * + * \return 0 on success, or -1 if gamma ramps are unsupported. + * + * \sa SDL_SetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, + Uint16 * red, + Uint16 * green, + Uint16 * blue); + +/** + * \brief Destroy a window. + */ +extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window); + + +/** + * \brief Returns whether the screensaver is currently enabled (default on). + * + * \sa SDL_EnableScreenSaver() + * \sa SDL_DisableScreenSaver() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void); + +/** + * \brief Allow the screen to be blanked by a screensaver + * + * \sa SDL_IsScreenSaverEnabled() + * \sa SDL_DisableScreenSaver() + */ +extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void); + +/** + * \brief Prevent the screen from being blanked by a screensaver + * + * \sa SDL_IsScreenSaverEnabled() + * \sa SDL_EnableScreenSaver() + */ +extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); + + +/** + * \name OpenGL support functions + */ +/* @{ */ + +/** + * \brief Dynamically load an OpenGL library. + * + * \param path The platform dependent OpenGL library name, or NULL to open the + * default OpenGL library. + * + * \return 0 on success, or -1 if the library couldn't be loaded. + * + * This should be done after initializing the video driver, but before + * creating any OpenGL windows. If no OpenGL library is loaded, the default + * library will be loaded upon creation of the first OpenGL window. + * + * \note If you do this, you need to retrieve all of the GL functions used in + * your program from the dynamic library using SDL_GL_GetProcAddress(). + * + * \sa SDL_GL_GetProcAddress() + * \sa SDL_GL_UnloadLibrary() + */ +extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); + +/** + * \brief Get the address of an OpenGL function. + */ +extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc); + +/** + * \brief Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). + * + * \sa SDL_GL_LoadLibrary() + */ +extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); + +/** + * \brief Return true if an OpenGL extension is supported for the current + * context. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char + *extension); + +/** + * \brief Reset all previously set OpenGL context attributes to their default values + */ +extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); + +/** + * \brief Set an OpenGL window attribute before window creation. + */ +extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); + +/** + * \brief Get the actual value for an attribute from the current context. + */ +extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value); + +/** + * \brief Create an OpenGL context for use with an OpenGL window, and make it + * current. + * + * \sa SDL_GL_DeleteContext() + */ +extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * + window); + +/** + * \brief Set up an OpenGL context for rendering into an OpenGL window. + * + * \note The context must have been created with a compatible window. + */ +extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, + SDL_GLContext context); + +/** + * \brief Get the currently active OpenGL window. + */ +extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void); + +/** + * \brief Get the currently active OpenGL context. + */ +extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); + +/** + * \brief Get the size of a window's underlying drawable (for use with glViewport). + * + * \param window Window from which the drawable size should be queried + * \param w Pointer to variable for storing the width, may be NULL + * \param h Pointer to variable for storing the height, may be NULL + * + * This may differ from SDL_GetWindowSize if we're rendering to a high-DPI + * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a + * platform with high-DPI support (Apple calls this "Retina"), and not disabled + * by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. + * + * \sa SDL_GetWindowSize() + * \sa SDL_CreateWindow() + */ +extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, + int *h); + +/** + * \brief Set the swap interval for the current OpenGL context. + * + * \param interval 0 for immediate updates, 1 for updates synchronized with the + * vertical retrace. If the system supports it, you may + * specify -1 to allow late swaps to happen immediately + * instead of waiting for the next retrace. + * + * \return 0 on success, or -1 if setting the swap interval is not supported. + * + * \sa SDL_GL_GetSwapInterval() + */ +extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval); + +/** + * \brief Get the swap interval for the current OpenGL context. + * + * \return 0 if there is no vertical retrace synchronization, 1 if the buffer + * swap is synchronized with the vertical retrace, and -1 if late + * swaps happen immediately instead of waiting for the next retrace. + * If the system can't determine the swap interval, or there isn't a + * valid current context, this will return 0 as a safe default. + * + * \sa SDL_GL_SetSwapInterval() + */ +extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void); + +/** + * \brief Swap the OpenGL buffers for a window, if double-buffering is + * supported. + */ +extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); + +/** + * \brief Delete an OpenGL context. + * + * \sa SDL_GL_CreateContext() + */ +extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); + +/* @} *//* OpenGL support functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/code/SDL2/include/begin_code.h b/code/SDL2/include/begin_code.h new file mode 100644 index 00000000..f37ee369 --- /dev/null +++ b/code/SDL2/include/begin_code.h @@ -0,0 +1,140 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file begin_code.h + * + * This file sets things up for C dynamic library function definitions, + * static inlined functions, and structures aligned at 4-byte alignment. + * If you don't like ugly C preprocessor code, don't look at this file. :) + */ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +#ifndef SDL_DEPRECATED +# if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ +# define SDL_DEPRECATED __attribute__((deprecated)) +# else +# define SDL_DEPRECATED +# endif +#endif + +/* Some compilers use a special export keyword */ +#ifndef DECLSPEC +# if defined(__WIN32__) || defined(__WINRT__) +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && __GNUC__ >= 4 +# define DECLSPEC __attribute__ ((visibility("default"))) +# elif defined(__GNUC__) && __GNUC__ >= 2 +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC +# endif +# endif +#endif + +/* By default SDL uses the C calling convention */ +#ifndef SDLCALL +#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) +#define SDLCALL __cdecl +#else +#define SDLCALL +#endif +#endif /* SDLCALL */ + +/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ +#ifdef __SYMBIAN32__ +#undef DECLSPEC +#define DECLSPEC +#endif /* __SYMBIAN32__ */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#ifdef _M_X64 +/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ +#pragma pack(push,8) +#else +#pragma pack(push,4) +#endif +#endif /* Compiler needs structure packing set */ + +#ifndef SDL_INLINE +#if defined(__GNUC__) +#define SDL_INLINE __inline__ +#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) +#define SDL_INLINE __inline +#ifndef __inline__ +#define __inline__ __inline +#endif +#else +#define SDL_INLINE inline +#ifndef __inline__ +#define __inline__ inline +#endif +#endif +#endif /* SDL_INLINE not defined */ + +#ifndef SDL_FORCE_INLINE +#if defined(_MSC_VER) +#define SDL_FORCE_INLINE __forceinline +#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ +#else +#define SDL_FORCE_INLINE static SDL_INLINE +#endif +#endif /* SDL_FORCE_INLINE not defined */ + +/* Apparently this is needed by several Windows compilers */ +#if !defined(__MACH__) +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ +#endif /* ! Mac OS X - breaks precompiled headers */ diff --git a/code/SDL2/include/close_code.h b/code/SDL2/include/close_code.h new file mode 100644 index 00000000..9826f147 --- /dev/null +++ b/code/SDL2/include/close_code.h @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + 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. +*/ + +/** + * \file close_code.h + * + * This file reverses the effects of begin_code.h and should be included + * after you finish any function and structure declarations in your headers + */ + +#undef _begin_code_h + +/* Reset structure packing at previous byte alignment */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#pragma pack(pop) +#endif /* Compiler needs structure packing set */ diff --git a/code/SDL2/include/doxyfile b/code/SDL2/include/doxyfile new file mode 100644 index 00000000..495dbc19 --- /dev/null +++ b/code/SDL2/include/doxyfile @@ -0,0 +1,1555 @@ +# Doxyfile 1.5.9 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = SDL + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 2.0.0 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = . + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = YES + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = YES + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = "defined=\"\def\"" \ + "discussion=\"\par Discussion:\n\"" + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. Note that for custom extensions you also need to set +# FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = YES + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = YES + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = YES + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = ./doxygen_warn.txt + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = . + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.vhd \ + *.vhdl \ + *.h.in \ + *.h.default + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = ../doxy \ + ../test \ + ../Xcode \ + ../VisualC \ + ../VisualCE \ + ../Xcode-iOS + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = YES + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = SDL_ \ + SDL + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = YES + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "SDL 2.0 Doxygen" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.libsdl.sdl20 + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = ./sdl20.chm + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = YES + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 1 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to FRAME, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values +# for this tag are: HIERARCHIES, which will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list; +# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which +# disables this behavior completely. For backwards compatibility with previous +# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE +# respectively. + +GENERATE_TREEVIEW = ALL + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = DOXYGEN_SHOULD_IGNORE_THIS=1 \ + DECLSPEC= \ + SDLCALL= \ + _WIN32=1 + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = ./SDL.tag + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = c:\Perl\bin\perl.exe + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 2 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = YES + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Options related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/code/asm/ftola.s b/code/asm/ftola.s new file mode 100644 index 00000000..7e9c523e --- /dev/null +++ b/code/asm/ftola.s @@ -0,0 +1,160 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +// +// qftol -- fast floating point to long conversion. +// + +// 23/09/05 Ported to gas by intel2gas, best supporting actor Tim Angus +// + +#include "qasm.h" + +#if id386 + +.data + +temp: .single 0.0 +fpucw: .long 0 + +// Precision Control Field , 2 bits / 0x0300 +// PC24 0x0000 Single precision (24 bits). +// PC53 0x0200 Double precision (53 bits). +// PC64 0x0300 Extended precision (64 bits). + +// Rounding Control Field, 2 bits / 0x0C00 +// RCN 0x0000 Rounding to nearest (even). +// RCD 0x0400 Rounding down (directed, minus). +// RCU 0x0800 Rounding up (directed plus). +// RC0 0x0C00 Rounding towards zero (chop mode). + + +// rounding towards nearest (even) +cw027F: .long 0x027F +cw037F: .long 0x037F + +// rounding towards zero (chop mode) +cw0E7F: .long 0x0E7F +cw0F7F: .long 0x0F7F + + +.text + +// +// int qftol( void ) - default control word +// + +.globl C(qftol) + +C(qftol): + fistpl temp + movl temp,%eax + ret + + +// +// int qftol027F( void ) - DirectX FPU +// + +.globl C(qftol027F) + +C(qftol027F): + fnstcw fpucw + fldcw cw027F + fistpl temp + fldcw fpucw + movl temp,%eax + ret + +// +// int qftol037F( void ) - Linux FPU +// + +.globl C(qftol037F) + +C(qftol037F): + fnstcw fpucw + fldcw cw037F + fistpl temp + fldcw fpucw + movl temp,%eax + ret + + +// +// int qftol0F7F( void ) - ANSI +// + +.globl C(qftol0F7F) + +C(qftol0F7F): + fnstcw fpucw + fldcw cw0F7F + fistpl temp + fldcw fpucw + movl temp,%eax + ret + +// +// int qftol0E7F( void ) +// + +.globl C(qftol0E7F) + +C(qftol0E7F): + fnstcw fpucw + fldcw cw0E7F + fistpl temp + fldcw fpucw + movl temp,%eax + ret + + + +// +// long Q_ftol( float q ) +// + +.globl C(Q_ftol) + +C(Q_ftol): + flds 4(%esp) + fistpl temp + movl temp,%eax + ret + + +// +// long qftol0F7F( float q ) - Linux FPU +// + +.globl C(Q_ftol0F7F) + +C(Q_ftol0F7F): + fnstcw fpucw + flds 4(%esp) + fldcw cw0F7F + fistpl temp + fldcw fpucw + movl temp,%eax + ret +#endif diff --git a/code/asm/matha.s b/code/asm/matha.s new file mode 100644 index 00000000..3bc22204 --- /dev/null +++ b/code/asm/matha.s @@ -0,0 +1,424 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ +// +// math.s +// x86 assembly-language math routines. + +#include "qasm.h" + + +#if id386 + + .data + + .align 4 +Ljmptab: .long Lcase0, Lcase1, Lcase2, Lcase3 + .long Lcase4, Lcase5, Lcase6, Lcase7 + + .text + +// TODO: rounding needed? +// stack parameter offset +#define val 4 + +.globl C(Invert24To16) +C(Invert24To16): + + movl val(%esp),%ecx + movl $0x100,%edx // 0x10000000000 as dividend + cmpl %edx,%ecx + jle LOutOfRange + + subl %eax,%eax + divl %ecx + + ret + +LOutOfRange: + movl $0xFFFFFFFF,%eax + ret + +#if 0 + +#define in 4 +#define out 8 + + .align 2 +.globl C(TransformVector) +C(TransformVector): + movl in(%esp),%eax + movl out(%esp),%edx + + flds (%eax) // in[0] + fmuls C(vright) // in[0]*vright[0] + flds (%eax) // in[0] | in[0]*vright[0] + fmuls C(vup) // in[0]*vup[0] | in[0]*vright[0] + flds (%eax) // in[0] | in[0]*vup[0] | in[0]*vright[0] + fmuls C(vpn) // in[0]*vpn[0] | in[0]*vup[0] | in[0]*vright[0] + + flds 4(%eax) // in[1] | ... + fmuls C(vright)+4 // in[1]*vright[1] | ... + flds 4(%eax) // in[1] | in[1]*vright[1] | ... + fmuls C(vup)+4 // in[1]*vup[1] | in[1]*vright[1] | ... + flds 4(%eax) // in[1] | in[1]*vup[1] | in[1]*vright[1] | ... + fmuls C(vpn)+4 // in[1]*vpn[1] | in[1]*vup[1] | in[1]*vright[1] | ... + fxch %st(2) // in[1]*vright[1] | in[1]*vup[1] | in[1]*vpn[1] | ... + + faddp %st(0),%st(5) // in[1]*vup[1] | in[1]*vpn[1] | ... + faddp %st(0),%st(3) // in[1]*vpn[1] | ... + faddp %st(0),%st(1) // vpn_accum | vup_accum | vright_accum + + flds 8(%eax) // in[2] | ... + fmuls C(vright)+8 // in[2]*vright[2] | ... + flds 8(%eax) // in[2] | in[2]*vright[2] | ... + fmuls C(vup)+8 // in[2]*vup[2] | in[2]*vright[2] | ... + flds 8(%eax) // in[2] | in[2]*vup[2] | in[2]*vright[2] | ... + fmuls C(vpn)+8 // in[2]*vpn[2] | in[2]*vup[2] | in[2]*vright[2] | ... + fxch %st(2) // in[2]*vright[2] | in[2]*vup[2] | in[2]*vpn[2] | ... + + faddp %st(0),%st(5) // in[2]*vup[2] | in[2]*vpn[2] | ... + faddp %st(0),%st(3) // in[2]*vpn[2] | ... + faddp %st(0),%st(1) // vpn_accum | vup_accum | vright_accum + + fstps 8(%edx) // out[2] + fstps 4(%edx) // out[1] + fstps (%edx) // out[0] + + ret + +#endif + +#define EMINS 4+4 +#define EMAXS 4+8 +#define P 4+12 + + .align 2 +.globl C(BoxOnPlaneSide) +C(BoxOnPlaneSide): + pushl %ebx + + movl P(%esp),%edx + movl EMINS(%esp),%ecx + xorl %eax,%eax + movl EMAXS(%esp),%ebx + movb pl_signbits(%edx),%al + cmpb $8,%al + jge Lerror + flds pl_normal(%edx) // p->normal[0] + fld %st(0) // p->normal[0] | p->normal[0] + // bk000422 - warning: missing prefix `*' in absolute indirect address, maybe misassembled! + // bk001129 - fix from Andrew Henderson, was: Ljmptab(,%eax,4) + jmp *Ljmptab(,%eax,4) + + +//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; +//dist2= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; +Lcase0: + fmuls (%ebx) // p->normal[0]*emaxs[0] | p->normal[0] + flds pl_normal+4(%edx) // p->normal[1] | p->normal[0]*emaxs[0] | + // p->normal[0] + fxch %st(2) // p->normal[0] | p->normal[0]*emaxs[0] | + // p->normal[1] + fmuls (%ecx) // p->normal[0]*emins[0] | + // p->normal[0]*emaxs[0] | p->normal[1] + fxch %st(2) // p->normal[1] | p->normal[0]*emaxs[0] | + // p->normal[0]*emins[0] + fld %st(0) // p->normal[1] | p->normal[1] | + // p->normal[0]*emaxs[0] | + // p->normal[0]*emins[0] + fmuls 4(%ebx) // p->normal[1]*emaxs[1] | p->normal[1] | + // p->normal[0]*emaxs[0] | + // p->normal[0]*emins[0] + flds pl_normal+8(%edx) // p->normal[2] | p->normal[1]*emaxs[1] | + // p->normal[1] | p->normal[0]*emaxs[0] | + // p->normal[0]*emins[0] + fxch %st(2) // p->normal[1] | p->normal[1]*emaxs[1] | + // p->normal[2] | p->normal[0]*emaxs[0] | + // p->normal[0]*emins[0] + fmuls 4(%ecx) // p->normal[1]*emins[1] | + // p->normal[1]*emaxs[1] | + // p->normal[2] | p->normal[0]*emaxs[0] | + // p->normal[0]*emins[0] + fxch %st(2) // p->normal[2] | p->normal[1]*emaxs[1] | + // p->normal[1]*emins[1] | + // p->normal[0]*emaxs[0] | + // p->normal[0]*emins[0] + fld %st(0) // p->normal[2] | p->normal[2] | + // p->normal[1]*emaxs[1] | + // p->normal[1]*emins[1] | + // p->normal[0]*emaxs[0] | + // p->normal[0]*emins[0] + fmuls 8(%ebx) // p->normal[2]*emaxs[2] | + // p->normal[2] | + // p->normal[1]*emaxs[1] | + // p->normal[1]*emins[1] | + // p->normal[0]*emaxs[0] | + // p->normal[0]*emins[0] + fxch %st(5) // p->normal[0]*emins[0] | + // p->normal[2] | + // p->normal[1]*emaxs[1] | + // p->normal[1]*emins[1] | + // p->normal[0]*emaxs[0] | + // p->normal[2]*emaxs[2] + faddp %st(0),%st(3) //p->normal[2] | + // p->normal[1]*emaxs[1] | + // p->normal[1]*emins[1]+p->normal[0]*emins[0]| + // p->normal[0]*emaxs[0] | + // p->normal[2]*emaxs[2] + fmuls 8(%ecx) //p->normal[2]*emins[2] | + // p->normal[1]*emaxs[1] | + // p->normal[1]*emins[1]+p->normal[0]*emins[0]| + // p->normal[0]*emaxs[0] | + // p->normal[2]*emaxs[2] + fxch %st(1) //p->normal[1]*emaxs[1] | + // p->normal[2]*emins[2] | + // p->normal[1]*emins[1]+p->normal[0]*emins[0]| + // p->normal[0]*emaxs[0] | + // p->normal[2]*emaxs[2] + faddp %st(0),%st(3) //p->normal[2]*emins[2] | + // p->normal[1]*emins[1]+p->normal[0]*emins[0]| + // p->normal[0]*emaxs[0]+p->normal[1]*emaxs[1]| + // p->normal[2]*emaxs[2] + fxch %st(3) //p->normal[2]*emaxs[2] + + // p->normal[1]*emins[1]+p->normal[0]*emins[0]| + // p->normal[0]*emaxs[0]+p->normal[1]*emaxs[1]| + // p->normal[2]*emins[2] + faddp %st(0),%st(2) //p->normal[1]*emins[1]+p->normal[0]*emins[0]| + // dist1 | p->normal[2]*emins[2] + + jmp LSetSides + +//dist1= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; +//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; +Lcase1: + fmuls (%ecx) // emins[0] + flds pl_normal+4(%edx) + fxch %st(2) + fmuls (%ebx) // emaxs[0] + fxch %st(2) + fld %st(0) + fmuls 4(%ebx) // emaxs[1] + flds pl_normal+8(%edx) + fxch %st(2) + fmuls 4(%ecx) // emins[1] + fxch %st(2) + fld %st(0) + fmuls 8(%ebx) // emaxs[2] + fxch %st(5) + faddp %st(0),%st(3) + fmuls 8(%ecx) // emins[2] + fxch %st(1) + faddp %st(0),%st(3) + fxch %st(3) + faddp %st(0),%st(2) + + jmp LSetSides + +//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; +//dist2= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; +Lcase2: + fmuls (%ebx) // emaxs[0] + flds pl_normal+4(%edx) + fxch %st(2) + fmuls (%ecx) // emins[0] + fxch %st(2) + fld %st(0) + fmuls 4(%ecx) // emins[1] + flds pl_normal+8(%edx) + fxch %st(2) + fmuls 4(%ebx) // emaxs[1] + fxch %st(2) + fld %st(0) + fmuls 8(%ebx) // emaxs[2] + fxch %st(5) + faddp %st(0),%st(3) + fmuls 8(%ecx) // emins[2] + fxch %st(1) + faddp %st(0),%st(3) + fxch %st(3) + faddp %st(0),%st(2) + + jmp LSetSides + +//dist1= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; +//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; +Lcase3: + fmuls (%ecx) // emins[0] + flds pl_normal+4(%edx) + fxch %st(2) + fmuls (%ebx) // emaxs[0] + fxch %st(2) + fld %st(0) + fmuls 4(%ecx) // emins[1] + flds pl_normal+8(%edx) + fxch %st(2) + fmuls 4(%ebx) // emaxs[1] + fxch %st(2) + fld %st(0) + fmuls 8(%ebx) // emaxs[2] + fxch %st(5) + faddp %st(0),%st(3) + fmuls 8(%ecx) // emins[2] + fxch %st(1) + faddp %st(0),%st(3) + fxch %st(3) + faddp %st(0),%st(2) + + jmp LSetSides + +//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; +//dist2= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; +Lcase4: + fmuls (%ebx) // emaxs[0] + flds pl_normal+4(%edx) + fxch %st(2) + fmuls (%ecx) // emins[0] + fxch %st(2) + fld %st(0) + fmuls 4(%ebx) // emaxs[1] + flds pl_normal+8(%edx) + fxch %st(2) + fmuls 4(%ecx) // emins[1] + fxch %st(2) + fld %st(0) + fmuls 8(%ecx) // emins[2] + fxch %st(5) + faddp %st(0),%st(3) + fmuls 8(%ebx) // emaxs[2] + fxch %st(1) + faddp %st(0),%st(3) + fxch %st(3) + faddp %st(0),%st(2) + + jmp LSetSides + +//dist1= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; +//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; +Lcase5: + fmuls (%ecx) // emins[0] + flds pl_normal+4(%edx) + fxch %st(2) + fmuls (%ebx) // emaxs[0] + fxch %st(2) + fld %st(0) + fmuls 4(%ebx) // emaxs[1] + flds pl_normal+8(%edx) + fxch %st(2) + fmuls 4(%ecx) // emins[1] + fxch %st(2) + fld %st(0) + fmuls 8(%ecx) // emins[2] + fxch %st(5) + faddp %st(0),%st(3) + fmuls 8(%ebx) // emaxs[2] + fxch %st(1) + faddp %st(0),%st(3) + fxch %st(3) + faddp %st(0),%st(2) + + jmp LSetSides + +//dist1= p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; +//dist2= p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; +Lcase6: + fmuls (%ebx) // emaxs[0] + flds pl_normal+4(%edx) + fxch %st(2) + fmuls (%ecx) // emins[0] + fxch %st(2) + fld %st(0) + fmuls 4(%ecx) // emins[1] + flds pl_normal+8(%edx) + fxch %st(2) + fmuls 4(%ebx) // emaxs[1] + fxch %st(2) + fld %st(0) + fmuls 8(%ecx) // emins[2] + fxch %st(5) + faddp %st(0),%st(3) + fmuls 8(%ebx) // emaxs[2] + fxch %st(1) + faddp %st(0),%st(3) + fxch %st(3) + faddp %st(0),%st(2) + + jmp LSetSides + +//dist1= p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; +//dist2= p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; +Lcase7: + fmuls (%ecx) // emins[0] + flds pl_normal+4(%edx) + fxch %st(2) + fmuls (%ebx) // emaxs[0] + fxch %st(2) + fld %st(0) + fmuls 4(%ecx) // emins[1] + flds pl_normal+8(%edx) + fxch %st(2) + fmuls 4(%ebx) // emaxs[1] + fxch %st(2) + fld %st(0) + fmuls 8(%ecx) // emins[2] + fxch %st(5) + faddp %st(0),%st(3) + fmuls 8(%ebx) // emaxs[2] + fxch %st(1) + faddp %st(0),%st(3) + fxch %st(3) + faddp %st(0),%st(2) + +LSetSides: + +// sides = 0; +// if (dist1 >= p->dist) +// sides = 1; +// if (dist2 < p->dist) +// sides |= 2; + + faddp %st(0),%st(2) // dist1 | dist2 + fcomps pl_dist(%edx) + xorl %ecx,%ecx + fnstsw %ax + fcomps pl_dist(%edx) + andb $1,%ah + xorb $1,%ah + addb %ah,%cl + + fnstsw %ax + andb $1,%ah + addb %ah,%ah + addb %ah,%cl + +// return sides; + + popl %ebx + movl %ecx,%eax // return status + + ret + + +Lerror: + movl 1, %eax + ret + +#endif // id386 diff --git a/code/asm/qasm.h b/code/asm/qasm.h new file mode 100644 index 00000000..b02a60a2 --- /dev/null +++ b/code/asm/qasm.h @@ -0,0 +1,46 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#ifndef __ASM_I386__ +#define __ASM_I386__ + +#include "../qcommon/q_platform.h" + +#ifdef __ELF__ +.section .note.GNU-stack,"",@progbits +#endif + +#ifdef __ELF__ +#define C(label) label +#else +#define C(label) _##label +#endif + +// plane_t structure +// !!! if this is changed, it must be changed in q_shared.h too !!! +#define pl_normal 0 +#define pl_dist 12 +#define pl_type 16 +#define pl_signbits 17 +#define pl_pad 18 +#define pl_size 20 + +#endif diff --git a/code/asm/snapvectora.s b/code/asm/snapvectora.s new file mode 100644 index 00000000..11294a05 --- /dev/null +++ b/code/asm/snapvectora.s @@ -0,0 +1,103 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +// +// Sys_SnapVector NASM code (Andrew Henderson) +// See win32/win_shared.c for the Win32 equivalent +// This code is provided to ensure that the +// rounding behavior (and, if necessary, the +// precision) of DLL and QVM code are identical +// e.g. for network-visible operations. +// See ftol.nasm for operations on a single float, +// as used in compiled VM and DLL code that does +// not use this system trap. +// + +// 23/09/05 Ported to gas by intel2gas, best supporting actor Tim Angus +// + +#include "qasm.h" + +#if id386 +.data + +fpucw: .long 0 +cw037F: .long 0x037F + +.text + +// void Sys_SnapVector( float *v ) +.globl C(Sys_SnapVector) +C(Sys_SnapVector): + pushl %eax + pushl %ebp + movl %esp,%ebp + + fnstcw fpucw + movl 12(%ebp),%eax + fldcw cw037F + flds (%eax) + fistpl (%eax) + fildl (%eax) + fstps (%eax) + flds 4(%eax) + fistpl 4(%eax) + fildl 4(%eax) + fstps 4(%eax) + flds 8(%eax) + fistpl 8(%eax) + fildl 8(%eax) + fstps 8(%eax) + fldcw fpucw + + popl %ebp + popl %eax + ret + +// void Sys_SnapVectorCW( float *v, unsigned short int cw ) +.globl C(Sys_SnapVectorCW) +C(Sys_SnapVectorCW): + pushl %eax + pushl %ebp + movl %esp,%ebp + + fnstcw fpucw + movl 12(%ebp),%eax + fldcw 16(%ebp) + flds (%eax) + fistpl (%eax) + fildl (%eax) + fstps (%eax) + flds 4(%eax) + fistpl 4(%eax) + fildl 4(%eax) + fstps 4(%eax) + flds 8(%eax) + fistpl 8(%eax) + fildl 8(%eax) + fstps 8(%eax) + fldcw fpucw + + popl %ebp + popl %eax + ret +#endif diff --git a/code/asm/snd_mixa.s b/code/asm/snd_mixa.s new file mode 100644 index 00000000..4c6be5b7 --- /dev/null +++ b/code/asm/snd_mixa.s @@ -0,0 +1,217 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ +// +// snd_mixa.s +// x86 assembly-language sound code +// + +#include "qasm.h" + +#if id386 + + .text + +#if 0 +//---------------------------------------------------------------------- +// 8-bit sound-mixing code +//---------------------------------------------------------------------- + +#define ch 4+16 +#define sc 8+16 +#define count 12+16 + +.globl C(S_PaintChannelFrom8) +C(S_PaintChannelFrom8): + pushl %esi // preserve register variables + pushl %edi + pushl %ebx + pushl %ebp + +// int data; +// short *lscale, *rscale; +// unsigned char *sfx; +// int i; + + movl ch(%esp),%ebx + movl sc(%esp),%esi + +// if (ch->leftvol > 255) +// ch->leftvol = 255; +// if (ch->rightvol > 255) +// ch->rightvol = 255; + movl ch_leftvol(%ebx),%eax + movl ch_rightvol(%ebx),%edx + cmpl $255,%eax + jna LLeftSet + movl $255,%eax +LLeftSet: + cmpl $255,%edx + jna LRightSet + movl $255,%edx +LRightSet: + +// lscale = snd_scaletable[ch->leftvol >> 3]; +// rscale = snd_scaletable[ch->rightvol >> 3]; +// sfx = (signed char *)sc->data + ch->pos; +// ch->pos += count; + andl $0xF8,%eax + addl $20,%esi + movl (%esi),%esi + andl $0xF8,%edx + movl ch_pos(%ebx),%edi + movl count(%esp),%ecx + addl %edi,%esi + shll $7,%eax + addl %ecx,%edi + shll $7,%edx + movl %edi,ch_pos(%ebx) + addl $(C(snd_scaletable)),%eax + addl $(C(snd_scaletable)),%edx + subl %ebx,%ebx + movb -1(%esi,%ecx,1),%bl + + testl $1,%ecx + jz LMix8Loop + + movl (%eax,%ebx,4),%edi + movl (%edx,%ebx,4),%ebp + addl C(paintbuffer)+psp_left-psp_size(,%ecx,psp_size),%edi + addl C(paintbuffer)+psp_right-psp_size(,%ecx,psp_size),%ebp + movl %edi,C(paintbuffer)+psp_left-psp_size(,%ecx,psp_size) + movl %ebp,C(paintbuffer)+psp_right-psp_size(,%ecx,psp_size) + movb -2(%esi,%ecx,1),%bl + + decl %ecx + jz LDone + +// for (i=0 ; i>8; +// if (val > 0x7fff) +// snd_out[i] = 0x7fff; +// else if (val < (short)0x8000) +// snd_out[i] = (short)0x8000; +// else +// snd_out[i] = val; + movl -8(%ebx,%ecx,4),%eax + sarl $8,%eax + cmpl $0x7FFF,%eax + jg LClampHigh + cmpl $0xFFFF8000,%eax + jnl LClampDone + movl $0xFFFF8000,%eax + jmp LClampDone +LClampHigh: + movl $0x7FFF,%eax +LClampDone: + +// val = (snd_p[i+1]*snd_vol)>>8; +// if (val > 0x7fff) +// snd_out[i+1] = 0x7fff; +// else if (val < (short)0x8000) +// snd_out[i+1] = (short)0x8000; +// else +// snd_out[i+1] = val; + movl -4(%ebx,%ecx,4),%edx + sarl $8,%edx + cmpl $0x7FFF,%edx + jg LClampHigh2 + cmpl $0xFFFF8000,%edx + jnl LClampDone2 + movl $0xFFFF8000,%edx + jmp LClampDone2 +LClampHigh2: + movl $0x7FFF,%edx +LClampDone2: + shll $16,%edx + andl $0xFFFF,%eax + orl %eax,%edx + movl %edx,-4(%edi,%ecx,2) + +// } + subl $2,%ecx + jnz LWLBLoopTop + +// snd_p += snd_linear_count; + + popl %ebx + popl %edi + + ret + +#endif // id386 + diff --git a/code/botlib/aasfile.h b/code/botlib/aasfile.h new file mode 100644 index 00000000..8f2fbf62 --- /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 Quake III Arena source code; 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.h b/code/botlib/be_aas.h new file mode 100644 index 00000000..bc70c7bb --- /dev/null +++ b/code/botlib/be_aas.h @@ -0,0 +1,213 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_aas.h + * + * desc: Area Awareness System, stuff exported to the AI + * + * $Archive: /source/code/botlib/be_aas.h $ + * + *****************************************************************************/ + +#ifndef MAX_STRINGFIELD +#define MAX_STRINGFIELD 80 +#endif + +//travel flags +#define TFL_INVALID 0x00000001 //traveling temporary not possible +#define TFL_WALK 0x00000002 //walking +#define TFL_CROUCH 0x00000004 //crouching +#define TFL_BARRIERJUMP 0x00000008 //jumping onto a barrier +#define TFL_JUMP 0x00000010 //jumping +#define TFL_LADDER 0x00000020 //climbing a ladder +#define TFL_WALKOFFLEDGE 0x00000080 //walking of a ledge +#define TFL_SWIM 0x00000100 //swimming +#define TFL_WATERJUMP 0x00000200 //jumping out of the water +#define TFL_TELEPORT 0x00000400 //teleporting +#define TFL_ELEVATOR 0x00000800 //elevator +#define TFL_ROCKETJUMP 0x00001000 //rocket jumping +#define TFL_BFGJUMP 0x00002000 //bfg jumping +#define TFL_GRAPPLEHOOK 0x00004000 //grappling hook +#define TFL_DOUBLEJUMP 0x00008000 //double jump +#define TFL_RAMPJUMP 0x00010000 //ramp jump +#define TFL_STRAFEJUMP 0x00020000 //strafe jump +#define TFL_JUMPPAD 0x00040000 //jump pad +#define TFL_AIR 0x00080000 //travel through air +#define TFL_WATER 0x00100000 //travel through water +#define TFL_SLIME 0x00200000 //travel through slime +#define TFL_LAVA 0x00400000 //travel through lava +#define TFL_DONOTENTER 0x00800000 //travel through donotenter area +#define TFL_FUNCBOB 0x01000000 //func bobbing +#define TFL_FLIGHT 0x02000000 //flight +#define TFL_BRIDGE 0x04000000 //move over a bridge +// +#define TFL_NOTTEAM1 0x08000000 //not team 1 +#define TFL_NOTTEAM2 0x10000000 //not team 2 + +//default travel flags +#define TFL_DEFAULT TFL_WALK|TFL_CROUCH|TFL_BARRIERJUMP|\ + TFL_JUMP|TFL_LADDER|\ + TFL_WALKOFFLEDGE|TFL_SWIM|TFL_WATERJUMP|\ + TFL_TELEPORT|TFL_ELEVATOR|\ + TFL_AIR|TFL_WATER|TFL_JUMPPAD|TFL_FUNCBOB + +//a trace is returned when a box is swept through the AAS world +typedef struct aas_trace_s +{ + qboolean startsolid; // if true, the initial point was in a solid area + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + int ent; // entity blocking the trace + int lastarea; // last area the trace was in (zero if none) + int area; // area blocking the trace (zero if none) + int planenum; // number of the plane that was hit +} aas_trace_t; + +/* Defined in botlib.h + +//bsp_trace_t hit surface +typedef struct bsp_surface_s +{ + char name[16]; + int flags; + int value; +} bsp_surface_t; + +//a trace is returned when a box is swept through the BSP world +typedef struct bsp_trace_s +{ + qboolean allsolid; // if true, plane is not valid + qboolean startsolid; // if true, the initial point was in a solid area + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + cplane_t plane; // surface normal at impact + float exp_dist; // expanded plane distance + int sidenum; // number of the brush side hit + bsp_surface_t surface; // hit surface + int contents; // contents on other side of surface hit + int ent; // number of entity hit +} bsp_trace_t; +// +*/ + +//entity info +typedef struct aas_entityinfo_s +{ + int valid; // true if updated this frame + int type; // entity type + int flags; // entity flags + float ltime; // local time + float update_time; // time between last and current update + int number; // number of the entity + vec3_t origin; // origin of the entity + vec3_t angles; // angles of the model + vec3_t old_origin; // for lerping + vec3_t lastvisorigin; // last visible origin + vec3_t mins; // bounding box minimums + vec3_t maxs; // bounding box maximums + int groundent; // ground entity + int solid; // solid type + int modelindex; // model used + int modelindex2; // weapons, CTF flags, etc + int frame; // model frame number + int event; // impulse events -- muzzle flashes, footsteps, etc + int eventParm; // even parameter + int powerups; // bit flags + int weapon; // determines weapon and flash model, etc + int legsAnim; // mask off ANIM_TOGGLEBIT + int torsoAnim; // mask off ANIM_TOGGLEBIT +} aas_entityinfo_t; + +// area info +typedef struct aas_areainfo_s +{ + int contents; + int flags; + int presencetype; + int cluster; + vec3_t mins; + vec3_t maxs; + vec3_t center; +} aas_areainfo_t; + +// client movement prediction stop events, stop as soon as: +#define SE_NONE 0 +#define SE_HITGROUND 1 // the ground is hit +#define SE_LEAVEGROUND 2 // there's no ground +#define SE_ENTERWATER 4 // water is entered +#define SE_ENTERSLIME 8 // slime is entered +#define SE_ENTERLAVA 16 // lava is entered +#define SE_HITGROUNDDAMAGE 32 // the ground is hit with damage +#define SE_GAP 64 // there's a gap +#define SE_TOUCHJUMPPAD 128 // touching a jump pad area +#define SE_TOUCHTELEPORTER 256 // touching teleporter +#define SE_ENTERAREA 512 // the given stoparea is entered +#define SE_HITGROUNDAREA 1024 // a ground face in the area is hit +#define SE_HITBOUNDINGBOX 2048 // hit the specified bounding box +#define SE_TOUCHCLUSTERPORTAL 4096 // touching a cluster portal + +typedef struct aas_clientmove_s +{ + vec3_t endpos; //position at the end of movement prediction + int endarea; //area at end of movement prediction + vec3_t velocity; //velocity at the end of movement prediction + aas_trace_t trace; //last trace + int presencetype; //presence type at end of movement prediction + int stopevent; //event that made the prediction stop + int endcontents; //contents at the end of movement prediction + float time; //time predicted ahead + int frames; //number of frames predicted ahead +} aas_clientmove_t; + +// alternate route goals +#define ALTROUTEGOAL_ALL 1 +#define ALTROUTEGOAL_CLUSTERPORTALS 2 +#define ALTROUTEGOAL_VIEWPORTALS 4 + +typedef struct aas_altroutegoal_s +{ + vec3_t origin; + int areanum; + unsigned short starttraveltime; + unsigned short goaltraveltime; + unsigned short extratraveltime; +} aas_altroutegoal_t; + +// route prediction stop events +#define RSE_NONE 0 +#define RSE_NOROUTE 1 //no route to goal +#define RSE_USETRAVELTYPE 2 //stop as soon as on of the given travel types is used +#define RSE_ENTERCONTENTS 4 //stop when entering the given contents +#define RSE_ENTERAREA 8 //stop when entering the given area + +typedef struct aas_predictroute_s +{ + vec3_t endpos; //position at the end of movement prediction + int endarea; //area at end of movement prediction + int stopevent; //event that made the prediction stop + int endcontents; //contents at the end of movement prediction + int endtravelflags; //end travel flags + int numareas; //number of areas predicted ahead + int time; //time predicted ahead (in hundreth of a sec) +} aas_predictroute_t; diff --git a/code/botlib/be_aas_bsp.h b/code/botlib/be_aas_bsp.h new file mode 100644 index 00000000..932874a1 --- /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 Quake III Arena source code; 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 00000000..9bfc824f --- /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 Quake III Arena source code; 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 "../qcommon/q_shared.h" +#include "l_memory.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "aasfile.h" +#include "botlib.h" +#include "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 00000000..c4909cf7 --- /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 Quake III Arena source code; 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 "../qcommon/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 "botlib.h" +#include "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) + { + AAScriptError("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) + { + AAScriptError("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) + { + AAScriptError("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 + // + AAScriptError("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) + { + AAScriptError("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) + { + AAScriptError("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) + { + AAScriptError("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; + AAScriptError("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 00000000..e36697d1 --- /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 Quake III Arena source code; 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 00000000..ab44bc0b --- /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 Quake III Arena source code; 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 "../qcommon/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 "botlib.h" +#include "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 00000000..008eeba6 --- /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 Quake III Arena source code; 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 00000000..fdb96816 --- /dev/null +++ b/code/botlib/be_aas_def.h @@ -0,0 +1,304 @@ +/* +=========================================================================== +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 Quake III Arena source code; 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_CONFIGSTRINGS 2736 + +#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 00000000..02699bde --- /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 Quake III Arena source code; 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 "../qcommon/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 "botlib.h" +#include "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 00000000..01ec54c3 --- /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 Quake III Arena source code; 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 00000000..d06bf6c2 --- /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 Quake III Arena source code; 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 "../qcommon/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 "botlib.h" +#include "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)) + { + AAScriptError("can't seek to aas lump\n"); + AAS_DumpAASData(); + botimport.FS_FCloseFile(fp); + return NULL; + } //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) + { + AAScriptError("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) + { + AAScriptError("%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) + { + AAScriptError("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) + { + AAScriptError("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 00000000..c2271fcf --- /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 Quake III Arena source code; 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 00000000..87c7636f --- /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 Quake III Arena source code; 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 00000000..e1dad7c5 --- /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 Quake III Arena source code; 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 "../qcommon/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 "botlib.h" +#include "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 AAScriptError(char *fmt, ...) +{ + char str[1024]; + va_list arglist; + + va_start(arglist, fmt); + vsprintf(str, fmt, arglist); + va_end(arglist); + botimport.Print(PRT_FATAL, "%s", str); +} //end of the function AAScriptError +//=========================================================================== +// +// 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 00000000..de6f00f2 --- /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 Quake III Arena source code; 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 AAScriptError(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 00000000..fded262d --- /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 Quake III Arena source code; 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 "../qcommon/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 "botlib.h" +#include "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 00000000..b00e41ab --- /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 Quake III Arena source code; 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 00000000..ea0d2da6 --- /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 Quake III Arena source code; 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 "../qcommon/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 "botlib.h" +#include "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 00000000..799c28a3 --- /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 Quake III Arena source code; 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 00000000..ec9f7f89 --- /dev/null +++ b/code/botlib/be_aas_reach.c @@ -0,0 +1,4538 @@ +/* +=========================================================================== +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 Quake III Arena source code; 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 "../qcommon/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 "botlib.h" +#include "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) AAScriptError("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) + { + AAScriptError("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: - +//=========================================================================== +int AAS_Reachability_EqualFloorHeight(int area1num, int area2num) +{ + int i, j, edgenum, edgenum1, edgenum2, foundreach, side; + float height, bestheight, length, bestlength; + vec3_t dir, start, end, normal, invgravity, gravitydirection = {0, 0, -1}; + vec3_t edgevec; + aas_area_t *area1, *area2; + aas_face_t *face1, *face2; + aas_edge_t *edge; + aas_plane_t *plane2; + aas_lreachability_t lr, *lreach; + + if (!AAS_AreaGrounded(area1num) || !AAS_AreaGrounded(area2num)) return qfalse; + + area1 = &aasworld.areas[area1num]; + area2 = &aasworld.areas[area2num]; + //if the areas are not near anough in the x-y direction + for (i = 0; i < 2; i++) + { + if (area1->mins[i] > area2->maxs[i] + 10) return qfalse; + if (area1->maxs[i] < area2->mins[i] - 10) return qfalse; + } //end for + //if area 2 is too high above area 1 + if (area2->mins[2] > area1->maxs[2]) return qfalse; + // + VectorCopy(gravitydirection, invgravity); + VectorInverse(invgravity); + // + bestheight = 99999; + bestlength = 0; + foundreach = qfalse; + Com_Memset(&lr, 0, sizeof(aas_lreachability_t)); //make the compiler happy + // + //check if the areas have ground faces with a common edge + //if existing use the lowest common edge for a reachability link + for (i = 0; i < area1->numfaces; i++) + { + face1 = &aasworld.faces[abs(aasworld.faceindex[area1->firstface + i])]; + if (!(face1->faceflags & FACE_GROUND)) continue; + // + for (j = 0; j < area2->numfaces; j++) + { + face2 = &aasworld.faces[abs(aasworld.faceindex[area2->firstface + j])]; + if (!(face2->faceflags & FACE_GROUND)) continue; + //if there is a common edge + for (edgenum1 = 0; edgenum1 < face1->numedges; edgenum1++) + { + for (edgenum2 = 0; edgenum2 < face2->numedges; edgenum2++) + { + if (abs(aasworld.edgeindex[face1->firstedge + edgenum1]) != + abs(aasworld.edgeindex[face2->firstedge + edgenum2])) + continue; + edgenum = aasworld.edgeindex[face1->firstedge + edgenum1]; + side = edgenum < 0; + edge = &aasworld.edges[abs(edgenum)]; + //get the length of the edge + VectorSubtract(aasworld.vertexes[edge->v[1]], + aasworld.vertexes[edge->v[0]], dir); + length = VectorLength(dir); + //get the start point + VectorAdd(aasworld.vertexes[edge->v[0]], + aasworld.vertexes[edge->v[1]], start); + VectorScale(start, 0.5, start); + VectorCopy(start, end); + //get the end point several units inside area2 + //and the start point several units inside area1 + //NOTE: normal is pointing into area2 because the + //face edges are stored counter clockwise + VectorSubtract(aasworld.vertexes[edge->v[side]], + aasworld.vertexes[edge->v[!side]], edgevec); + plane2 = &aasworld.planes[face2->planenum]; + CrossProduct(edgevec, plane2->normal, normal); + VectorNormalize(normal); + // + //VectorMA(start, -1, normal, start); + VectorMA(end, INSIDEUNITS_WALKEND, normal, end); + VectorMA(start, INSIDEUNITS_WALKSTART, normal, start); + end[2] += 0.125; + // + height = DotProduct(invgravity, start); + //NOTE: if there's nearby solid or a gap area after this area + //disabled this crap + //if (AAS_NearbySolidOrGap(start, end)) height += 200; + //NOTE: disabled because it disables reachabilities to very small areas + //if (AAS_PointAreaNum(end) != area2num) continue; + //get the longest lowest edge + if (height < bestheight || + (height < bestheight + 1 && length > bestlength)) + { + bestheight = height; + bestlength = length; + //create a new reachability link + lr.areanum = area2num; + lr.facenum = 0; + lr.edgenum = edgenum; + VectorCopy(start, lr.start); + VectorCopy(end, lr.end); + lr.traveltype = TRAVEL_WALK; + lr.traveltime = 1; + foundreach = qtrue; + } //end if + } //end for + } //end for + } //end for + } //end for + if (foundreach) + { + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = lr.areanum; + lreach->facenum = lr.facenum; + lreach->edgenum = lr.edgenum; + VectorCopy(lr.start, lreach->start); + VectorCopy(lr.end, lreach->end); + lreach->traveltype = lr.traveltype; + lreach->traveltime = lr.traveltime; + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + //if going into a crouch area + if (!AAS_AreaCrouch(area1num) && AAS_AreaCrouch(area2num)) + { + lreach->traveltime += aassettings.rs_startcrouch; + } //end if + /* + //NOTE: if there's nearby solid or a gap area after this area + if (!AAS_NearbySolidOrGap(lreach->start, lreach->end)) + { + lreach->traveltime += 100; + } //end if + */ + //avoid rather small areas + //if (AAS_AreaGroundFaceArea(lreach->areanum) < 500) lreach->traveltime += 100; + // + reach_equalfloor++; + return qtrue; + } //end if + return qfalse; +} //end of the function AAS_Reachability_EqualFloorHeight +//=========================================================================== +// searches step, barrier, waterjump and walk off ledge reachabilities +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, int area2num) +{ + int i, j, k, l, edge1num, edge2num, areas[10], numareas; + int ground_bestarea2groundedgenum, ground_foundreach; + int water_bestarea2groundedgenum, water_foundreach; + int side1, area1swim, faceside1, groundface1num; + float dist, dist1, dist2, diff, invgravitydot, ortdot; + float x1, x2, x3, x4, y1, y2, y3, y4, tmp, y; + float length, ground_bestlength, water_bestlength, ground_bestdist, water_bestdist; + vec3_t v1, v2, v3, v4, tmpv, p1area1, p1area2, p2area1, p2area2; + vec3_t normal, ort, edgevec, start, end, dir; + vec3_t ground_beststart = {0, 0, 0}, ground_bestend = {0, 0, 0}, ground_bestnormal = {0, 0, 0}; + vec3_t water_beststart = {0, 0, 0}, water_bestend = {0, 0, 0}, water_bestnormal = {0, 0, 0}; + vec3_t invgravity = {0, 0, 1}; + vec3_t testpoint; + aas_plane_t *plane; + aas_area_t *area1, *area2; + aas_face_t *groundface1, *groundface2, *ground_bestface1, *water_bestface1; + aas_edge_t *edge1, *edge2; + aas_lreachability_t *lreach; + aas_trace_t trace; + + //must be able to walk or swim in the first area + if (!AAS_AreaGrounded(area1num) && !AAS_AreaSwim(area1num)) return qfalse; + // + if (!AAS_AreaGrounded(area2num) && !AAS_AreaSwim(area2num)) return qfalse; + // + area1 = &aasworld.areas[area1num]; + area2 = &aasworld.areas[area2num]; + //if the first area contains a liquid + area1swim = AAS_AreaSwim(area1num); + //if the areas are not near anough in the x-y direction + for (i = 0; i < 2; i++) + { + if (area1->mins[i] > area2->maxs[i] + 10) return qfalse; + if (area1->maxs[i] < area2->mins[i] - 10) return qfalse; + } //end for + // + ground_foundreach = qfalse; + ground_bestdist = 99999; + ground_bestlength = 0; + ground_bestarea2groundedgenum = 0; + // + water_foundreach = qfalse; + water_bestdist = 99999; + water_bestlength = 0; + water_bestarea2groundedgenum = 0; + // + for (i = 0; i < area1->numfaces; i++) + { + groundface1num = aasworld.faceindex[area1->firstface + i]; + faceside1 = groundface1num < 0; + groundface1 = &aasworld.faces[abs(groundface1num)]; + //if this isn't a ground face + if (!(groundface1->faceflags & FACE_GROUND)) + { + //if we can swim in the first area + if (area1swim) + { + //face plane must be more or less horizontal + plane = &aasworld.planes[groundface1->planenum ^ (!faceside1)]; + if (DotProduct(plane->normal, invgravity) < 0.7) continue; + } //end if + else + { + //if we can't swim in the area it must be a ground face + continue; + } //end else + } //end if + // + for (k = 0; k < groundface1->numedges; k++) + { + edge1num = aasworld.edgeindex[groundface1->firstedge + k]; + side1 = (edge1num < 0); + //NOTE: for water faces we must take the side area 1 is + // on into account because the face is shared and doesn't + // have to be oriented correctly + if (!(groundface1->faceflags & FACE_GROUND)) side1 = (side1 == faceside1); + edge1num = abs(edge1num); + edge1 = &aasworld.edges[edge1num]; + //vertexes of the edge + VectorCopy(aasworld.vertexes[edge1->v[!side1]], v1); + VectorCopy(aasworld.vertexes[edge1->v[side1]], v2); + //get a vertical plane through the edge + //NOTE: normal is pointing into area 2 because the + //face edges are stored counter clockwise + VectorSubtract(v2, v1, edgevec); + CrossProduct(edgevec, invgravity, normal); + VectorNormalize(normal); + dist = DotProduct(normal, v1); + //check the faces from the second area + for (j = 0; j < area2->numfaces; j++) + { + groundface2 = &aasworld.faces[abs(aasworld.faceindex[area2->firstface + j])]; + //must be a ground face + if (!(groundface2->faceflags & FACE_GROUND)) continue; + //check the edges of this ground face + for (l = 0; l < groundface2->numedges; l++) + { + edge2num = abs(aasworld.edgeindex[groundface2->firstedge + l]); + edge2 = &aasworld.edges[edge2num]; + //vertexes of the edge + VectorCopy(aasworld.vertexes[edge2->v[0]], v3); + VectorCopy(aasworld.vertexes[edge2->v[1]], v4); + //check the distance between the two points and the vertical plane + //through the edge of area1 + diff = DotProduct(normal, v3) - dist; + if (diff < -0.1 || diff > 0.1) continue; + diff = DotProduct(normal, v4) - dist; + if (diff < -0.1 || diff > 0.1) continue; + // + //project the two ground edges into the step side plane + //and calculate the shortest distance between the two + //edges if they overlap in the direction orthogonal to + //the gravity direction + CrossProduct(invgravity, normal, ort); + invgravitydot = DotProduct(invgravity, invgravity); + ortdot = DotProduct(ort, ort); + //projection into the step plane + //NOTE: since gravity is vertical this is just the z coordinate + y1 = v1[2];//DotProduct(v1, invgravity) / invgravitydot; + y2 = v2[2];//DotProduct(v2, invgravity) / invgravitydot; + y3 = v3[2];//DotProduct(v3, invgravity) / invgravitydot; + y4 = v4[2];//DotProduct(v4, invgravity) / invgravitydot; + // + x1 = DotProduct(v1, ort) / ortdot; + x2 = DotProduct(v2, ort) / ortdot; + x3 = DotProduct(v3, ort) / ortdot; + x4 = DotProduct(v4, ort) / ortdot; + // + if (x1 > x2) + { + tmp = x1; x1 = x2; x2 = tmp; + tmp = y1; y1 = y2; y2 = tmp; + VectorCopy(v1, tmpv); VectorCopy(v2, v1); VectorCopy(tmpv, v2); + } //end if + if (x3 > x4) + { + tmp = x3; x3 = x4; x4 = tmp; + tmp = y3; y3 = y4; y4 = tmp; + VectorCopy(v3, tmpv); VectorCopy(v4, v3); VectorCopy(tmpv, v4); + } //end if + //if the two projected edge lines have no overlap + if (x2 <= x3 || x4 <= x1) + { +// Log_Write("lines no overlap: from area %d to %d\r\n", area1num, area2num); + continue; + } //end if + //if the two lines fully overlap + if ((x1 - 0.5 < x3 && x4 < x2 + 0.5) && + (x3 - 0.5 < x1 && x2 < x4 + 0.5)) + { + dist1 = y3 - y1; + dist2 = y4 - y2; + VectorCopy(v1, p1area1); + VectorCopy(v2, p2area1); + VectorCopy(v3, p1area2); + VectorCopy(v4, p2area2); + } //end if + else + { + //if the points are equal + if (x1 > x3 - 0.1 && x1 < x3 + 0.1) + { + dist1 = y3 - y1; + VectorCopy(v1, p1area1); + VectorCopy(v3, p1area2); + } //end if + else if (x1 < x3) + { + y = y1 + (x3 - x1) * (y2 - y1) / (x2 - x1); + dist1 = y3 - y; + VectorCopy(v3, p1area1); + p1area1[2] = y; + VectorCopy(v3, p1area2); + } //end if + else + { + y = y3 + (x1 - x3) * (y4 - y3) / (x4 - x3); + dist1 = y - y1; + VectorCopy(v1, p1area1); + VectorCopy(v1, p1area2); + p1area2[2] = y; + } //end if + //if the points are equal + if (x2 > x4 - 0.1 && x2 < x4 + 0.1) + { + dist2 = y4 - y2; + VectorCopy(v2, p2area1); + VectorCopy(v4, p2area2); + } //end if + else if (x2 < x4) + { + y = y3 + (x2 - x3) * (y4 - y3) / (x4 - x3); + dist2 = y - y2; + VectorCopy(v2, p2area1); + VectorCopy(v2, p2area2); + p2area2[2] = y; + } //end if + else + { + y = y1 + (x4 - x1) * (y2 - y1) / (x2 - x1); + dist2 = y4 - y; + VectorCopy(v4, p2area1); + p2area1[2] = y; + VectorCopy(v4, p2area2); + } //end else + } //end else + //if both distances are pretty much equal + //then we take the middle of the points + if (dist1 > dist2 - 1 && dist1 < dist2 + 1) + { + dist = dist1; + VectorAdd(p1area1, p2area1, start); + VectorScale(start, 0.5, start); + VectorAdd(p1area2, p2area2, end); + VectorScale(end, 0.5, end); + } //end if + else if (dist1 < dist2) + { + dist = dist1; + VectorCopy(p1area1, start); + VectorCopy(p1area2, end); + } //end else if + else + { + dist = dist2; + VectorCopy(p2area1, start); + VectorCopy(p2area2, end); + } //end else + //get the length of the overlapping part of the edges of the two areas + VectorSubtract(p2area2, p1area2, dir); + length = VectorLength(dir); + // + if (groundface1->faceflags & FACE_GROUND) + { + //if the vertical distance is smaller + if (dist < ground_bestdist || + //or the vertical distance is pretty much the same + //but the overlapping part of the edges is longer + (dist < ground_bestdist + 1 && length > ground_bestlength)) + { + ground_bestdist = dist; + ground_bestlength = length; + ground_foundreach = qtrue; + ground_bestarea2groundedgenum = edge1num; + ground_bestface1 = groundface1; + //best point towards area1 + VectorCopy(start, ground_beststart); + //normal is pointing into area2 + VectorCopy(normal, ground_bestnormal); + //best point towards area2 + VectorCopy(end, ground_bestend); + } //end if + } //end if + else + { + //if the vertical distance is smaller + if (dist < water_bestdist || + //or the vertical distance is pretty much the same + //but the overlapping part of the edges is longer + (dist < water_bestdist + 1 && length > water_bestlength)) + { + water_bestdist = dist; + water_bestlength = length; + water_foundreach = qtrue; + water_bestarea2groundedgenum = edge1num; + water_bestface1 = groundface1; + //best point towards area1 + VectorCopy(start, water_beststart); + //normal is pointing into area2 + VectorCopy(normal, water_bestnormal); + //best point towards area2 + VectorCopy(end, water_bestend); + } //end if + } //end else + } //end for + } //end for + } //end for + } //end for + // + // NOTE: swim reachabilities are already filtered out + // + // Steps + // + // --------- + // | step height -> TRAVEL_WALK + //--------| + // + // --------- + //~~~~~~~~| step height and low water -> TRAVEL_WALK + //--------| + // + //~~~~~~~~~~~~~~~~~~ + // --------- + // | step height and low water up to the step -> TRAVEL_WALK + //--------| + // + //check for a step reachability + if (ground_foundreach) + { + //if area2 is higher but lower than the maximum step height + //NOTE: ground_bestdist >= 0 also catches equal floor reachabilities + if (ground_bestdist >= 0 && ground_bestdist < aassettings.phys_maxstep) + { + //create walk reachability from area1 to area2 + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area2num; + lreach->facenum = 0; + lreach->edgenum = ground_bestarea2groundedgenum; + VectorMA(ground_beststart, INSIDEUNITS_WALKSTART, ground_bestnormal, lreach->start); + VectorMA(ground_bestend, INSIDEUNITS_WALKEND, ground_bestnormal, lreach->end); + lreach->traveltype = TRAVEL_WALK; + lreach->traveltime = 0;//1; + //if going into a crouch area + if (!AAS_AreaCrouch(area1num) && AAS_AreaCrouch(area2num)) + { + lreach->traveltime += aassettings.rs_startcrouch; + } //end if + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + //NOTE: if there's nearby solid or a gap area after this area + /* + if (!AAS_NearbySolidOrGap(lreach->start, lreach->end)) + { + lreach->traveltime += 100; + } //end if + */ + //avoid rather small areas + //if (AAS_AreaGroundFaceArea(lreach->areanum) < 500) lreach->traveltime += 100; + // + reach_step++; + return qtrue; + } //end if + } //end if + // + // Water Jumps + // + // --------- + // | + //~~~~~~~~| + // | + // | higher than step height and water up to waterjump height -> TRAVEL_WATERJUMP + //--------| + // + //~~~~~~~~~~~~~~~~~~ + // --------- + // | + // | + // | + // | higher than step height and low water up to the step -> TRAVEL_WATERJUMP + //--------| + // + //check for a waterjump reachability + if (water_foundreach) + { + //get a test point a little bit towards area1 + VectorMA(water_bestend, -INSIDEUNITS, water_bestnormal, testpoint); + //go down the maximum waterjump height + testpoint[2] -= aassettings.phys_maxwaterjump; + //if there IS water the sv_maxwaterjump height below the bestend point + if (aasworld.areasettings[AAS_PointAreaNum(testpoint)].areaflags & AREA_LIQUID) + { + //don't create rediculous water jump reachabilities from areas very far below + //the water surface + if (water_bestdist < aassettings.phys_maxwaterjump + 24) + { + //waterjumping from or towards a crouch only area is not possible in Quake2 + if ((aasworld.areasettings[area1num].presencetype & PRESENCE_NORMAL) && + (aasworld.areasettings[area2num].presencetype & PRESENCE_NORMAL)) + { + //create water jump reachability from area1 to area2 + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area2num; + lreach->facenum = 0; + lreach->edgenum = water_bestarea2groundedgenum; + VectorCopy(water_beststart, lreach->start); + VectorMA(water_bestend, INSIDEUNITS_WATERJUMP, water_bestnormal, lreach->end); + lreach->traveltype = TRAVEL_WATERJUMP; + lreach->traveltime = aassettings.rs_waterjump; + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + //we've got another waterjump reachability + reach_waterjump++; + return qtrue; + } //end if + } //end if + } //end if + } //end if + // + // Barrier Jumps + // + // --------- + // | + // | + // | + // | higher than step height lower than barrier height -> TRAVEL_BARRIERJUMP + //--------| + // + // --------- + // | + // | + // | + //~~~~~~~~| higher than step height lower than barrier height + //--------| and a thin layer of water in the area to jump from -> TRAVEL_BARRIERJUMP + // + //check for a barrier jump reachability + if (ground_foundreach) + { + //if area2 is higher but lower than the maximum barrier jump height + if (ground_bestdist > 0 && ground_bestdist < aassettings.phys_maxbarrier) + { + //if no water in area1 or a very thin layer of water on the ground + if (!water_foundreach || (ground_bestdist - water_bestdist < 16)) + { + //cannot perform a barrier jump towards or from a crouch area in Quake2 + if (!AAS_AreaCrouch(area1num) && !AAS_AreaCrouch(area2num)) + { + //create barrier jump reachability from area1 to area2 + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area2num; + lreach->facenum = 0; + lreach->edgenum = ground_bestarea2groundedgenum; + VectorMA(ground_beststart, INSIDEUNITS_WALKSTART, ground_bestnormal, lreach->start); + VectorMA(ground_bestend, INSIDEUNITS_WALKEND, ground_bestnormal, lreach->end); + lreach->traveltype = TRAVEL_BARRIERJUMP; + lreach->traveltime = aassettings.rs_barrierjump;//AAS_BarrierJumpTravelTime(); + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + //we've got another barrierjump reachability + reach_barrier++; + return qtrue; + } //end if + } //end if + } //end if + } //end if + // + // Walk and Walk Off Ledge + // + //--------| + // | can walk or step back -> TRAVEL_WALK + // --------- + // + //--------| + // | + // | + // | + // | cannot walk/step back -> TRAVEL_WALKOFFLEDGE + // --------- + // + //--------| + // | + // |~~~~~~~~ + // | + // | cannot step back but can waterjump back -> TRAVEL_WALKOFFLEDGE + // --------- FIXME: create TRAVEL_WALK reach?? + // + //check for a walk or walk off ledge reachability + if (ground_foundreach) + { + if (ground_bestdist < 0) + { + if (ground_bestdist > -aassettings.phys_maxstep) + { + //create walk reachability from area1 to area2 + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area2num; + lreach->facenum = 0; + lreach->edgenum = ground_bestarea2groundedgenum; + VectorMA(ground_beststart, INSIDEUNITS_WALKSTART, ground_bestnormal, lreach->start); + VectorMA(ground_bestend, INSIDEUNITS_WALKEND, ground_bestnormal, lreach->end); + lreach->traveltype = TRAVEL_WALK; + lreach->traveltime = 1; + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + //we've got another walk reachability + reach_walk++; + return qtrue; + } //end if + // if no maximum fall height set or less than the max + if (!aassettings.rs_maxfallheight || fabs(ground_bestdist) < aassettings.rs_maxfallheight) { + //trace a bounding box vertically to check for solids + VectorMA(ground_bestend, INSIDEUNITS, ground_bestnormal, ground_bestend); + VectorCopy(ground_bestend, start); + start[2] = ground_beststart[2]; + VectorCopy(ground_bestend, end); + end[2] += 4; + trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1); + //if no solids were found + if (!trace.startsolid && trace.fraction >= 1.0) + { + //the trace end point must be in the goal area + trace.endpos[2] += 1; + if (AAS_PointAreaNum(trace.endpos) == area2num) + { + //if not going through a cluster portal + numareas = AAS_TraceAreas(start, end, areas, NULL, sizeof(areas) / sizeof(int)); + for (i = 0; i < numareas; i++) + if (AAS_AreaClusterPortal(areas[i])) + break; + if (i >= numareas) + { + //create a walk off ledge reachability from area1 to area2 + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area2num; + lreach->facenum = 0; + lreach->edgenum = ground_bestarea2groundedgenum; + VectorCopy(ground_beststart, lreach->start); + VectorCopy(ground_bestend, lreach->end); + lreach->traveltype = TRAVEL_WALKOFFLEDGE; + lreach->traveltime = aassettings.rs_startwalkoffledge + fabs(ground_bestdist) * 50 / aassettings.phys_gravity; + //if falling from too high and not falling into water + if (!AAS_AreaSwim(area2num) && !AAS_AreaJumpPad(area2num)) + { + if (AAS_FallDelta(ground_bestdist) > aassettings.phys_falldelta5) + { + lreach->traveltime += aassettings.rs_falldamage5; + } //end if + if (AAS_FallDelta(ground_bestdist) > aassettings.phys_falldelta10) + { + lreach->traveltime += aassettings.rs_falldamage10; + } //end if + } //end if + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + // + reach_walkoffledge++; + //NOTE: don't create a weapon (rl, bfg) jump reachability here + //because it interferes with other reachabilities + //like the ladder reachability + return qtrue; + } //end if + } //end if + } //end if + } //end if + } //end else + } //end if + return qfalse; +} //end of the function AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge +//=========================================================================== +// returns the distance between the two vectors +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float VectorDistance(vec3_t v1, vec3_t v2) +{ + vec3_t dir; + + VectorSubtract(v2, v1, dir); + return VectorLength(dir); +} //end of the function VectorDistance +//=========================================================================== +// returns true if the first vector is between the last two vectors +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int VectorBetweenVectors(vec3_t v, vec3_t v1, vec3_t v2) +{ + vec3_t dir1, dir2; + + VectorSubtract(v, v1, dir1); + VectorSubtract(v, v2, dir2); + return (DotProduct(dir1, dir2) <= 0); +} //end of the function VectorBetweenVectors +//=========================================================================== +// returns the mid point between the two vectors +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void VectorMiddle(vec3_t v1, vec3_t v2, vec3_t middle) +{ + VectorAdd(v1, v2, middle); + VectorScale(middle, 0.5, middle); +} //end of the function VectorMiddle +//=========================================================================== +// calculate a range of points closest to each other on both edges +// +// Parameter: beststart1 start of the range of points on edge v1-v2 +// beststart2 end of the range of points on edge v1-v2 +// bestend1 start of the range of points on edge v3-v4 +// bestend2 end of the range of points on edge v3-v4 +// bestdist best distance so far +// Returns: - +// Changes Globals: - +//=========================================================================== +/* +float AAS_ClosestEdgePoints(vec3_t v1, vec3_t v2, vec3_t v3, vec3_t v4, + aas_plane_t *plane1, aas_plane_t *plane2, + vec3_t beststart, vec3_t bestend, float bestdist) +{ + vec3_t dir1, dir2, p1, p2, p3, p4; + float a1, a2, b1, b2, dist; + int founddist; + + //edge vectors + VectorSubtract(v2, v1, dir1); + VectorSubtract(v4, v3, dir2); + //get the horizontal directions + dir1[2] = 0; + dir2[2] = 0; + // + // p1 = point on an edge vector of area2 closest to v1 + // p2 = point on an edge vector of area2 closest to v2 + // p3 = point on an edge vector of area1 closest to v3 + // p4 = point on an edge vector of area1 closest to v4 + // + if (dir2[0]) + { + a2 = dir2[1] / dir2[0]; + b2 = v3[1] - a2 * v3[0]; + //point on the edge vector of area2 closest to v1 + p1[0] = (DotProduct(v1, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0]; + p1[1] = a2 * p1[0] + b2; + //point on the edge vector of area2 closest to v2 + p2[0] = (DotProduct(v2, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0]; + p2[1] = a2 * p2[0] + b2; + } //end if + else + { + //point on the edge vector of area2 closest to v1 + p1[0] = v3[0]; + p1[1] = v1[1]; + //point on the edge vector of area2 closest to v2 + p2[0] = v3[0]; + p2[1] = v2[1]; + } //end else + // + if (dir1[0]) + { + // + a1 = dir1[1] / dir1[0]; + b1 = v1[1] - a1 * v1[0]; + //point on the edge vector of area1 closest to v3 + p3[0] = (DotProduct(v3, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0]; + p3[1] = a1 * p3[0] + b1; + //point on the edge vector of area1 closest to v4 + p4[0] = (DotProduct(v4, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0]; + p4[1] = a1 * p4[0] + b1; + } //end if + else + { + //point on the edge vector of area1 closest to v3 + p3[0] = v1[0]; + p3[1] = v3[1]; + //point on the edge vector of area1 closest to v4 + p4[0] = v1[0]; + p4[1] = v4[1]; + } //end else + //start with zero z-coordinates + p1[2] = 0; + p2[2] = 0; + p3[2] = 0; + p4[2] = 0; + //calculate the z-coordinates from the ground planes + p1[2] = (plane2->dist - DotProduct(plane2->normal, p1)) / plane2->normal[2]; + p2[2] = (plane2->dist - DotProduct(plane2->normal, p2)) / plane2->normal[2]; + p3[2] = (plane1->dist - DotProduct(plane1->normal, p3)) / plane1->normal[2]; + p4[2] = (plane1->dist - DotProduct(plane1->normal, p4)) / plane1->normal[2]; + // + founddist = qfalse; + // + if (VectorBetweenVectors(p1, v3, v4)) + { + dist = VectorDistance(v1, p1); + if (dist > bestdist - 0.5 && dist < bestdist + 0.5) + { + VectorMiddle(beststart, v1, beststart); + VectorMiddle(bestend, p1, bestend); + } //end if + else if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v1, beststart); + VectorCopy(p1, bestend); + } //end if + founddist = qtrue; + } //end if + if (VectorBetweenVectors(p2, v3, v4)) + { + dist = VectorDistance(v2, p2); + if (dist > bestdist - 0.5 && dist < bestdist + 0.5) + { + VectorMiddle(beststart, v2, beststart); + VectorMiddle(bestend, p2, bestend); + } //end if + else if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v2, beststart); + VectorCopy(p2, bestend); + } //end if + founddist = qtrue; + } //end else if + if (VectorBetweenVectors(p3, v1, v2)) + { + dist = VectorDistance(v3, p3); + if (dist > bestdist - 0.5 && dist < bestdist + 0.5) + { + VectorMiddle(beststart, p3, beststart); + VectorMiddle(bestend, v3, bestend); + } //end if + else if (dist < bestdist) + { + bestdist = dist; + VectorCopy(p3, beststart); + VectorCopy(v3, bestend); + } //end if + founddist = qtrue; + } //end else if + if (VectorBetweenVectors(p4, v1, v2)) + { + dist = VectorDistance(v4, p4); + if (dist > bestdist - 0.5 && dist < bestdist + 0.5) + { + VectorMiddle(beststart, p4, beststart); + VectorMiddle(bestend, v4, bestend); + } //end if + else if (dist < bestdist) + { + bestdist = dist; + VectorCopy(p4, beststart); + VectorCopy(v4, bestend); + } //end if + founddist = qtrue; + } //end else if + //if no shortest distance was found the shortest distance + //is between one of the vertexes of edge1 and one of edge2 + if (!founddist) + { + dist = VectorDistance(v1, v3); + if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v1, beststart); + VectorCopy(v3, bestend); + } //end if + dist = VectorDistance(v1, v4); + if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v1, beststart); + VectorCopy(v4, bestend); + } //end if + dist = VectorDistance(v2, v3); + if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v2, beststart); + VectorCopy(v3, bestend); + } //end if + dist = VectorDistance(v2, v4); + if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v2, beststart); + VectorCopy(v4, bestend); + } //end if + } //end if + return bestdist; +} //end of the function AAS_ClosestEdgePoints*/ + +float AAS_ClosestEdgePoints(vec3_t v1, vec3_t v2, vec3_t v3, vec3_t v4, + aas_plane_t *plane1, aas_plane_t *plane2, + vec3_t beststart1, vec3_t bestend1, + vec3_t beststart2, vec3_t bestend2, float bestdist) +{ + vec3_t dir1, dir2, p1, p2, p3, p4; + float a1, a2, b1, b2, dist, dist1, dist2; + int founddist; + + //edge vectors + VectorSubtract(v2, v1, dir1); + VectorSubtract(v4, v3, dir2); + //get the horizontal directions + dir1[2] = 0; + dir2[2] = 0; + // + // p1 = point on an edge vector of area2 closest to v1 + // p2 = point on an edge vector of area2 closest to v2 + // p3 = point on an edge vector of area1 closest to v3 + // p4 = point on an edge vector of area1 closest to v4 + // + if (dir2[0]) + { + a2 = dir2[1] / dir2[0]; + b2 = v3[1] - a2 * v3[0]; + //point on the edge vector of area2 closest to v1 + p1[0] = (DotProduct(v1, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0]; + p1[1] = a2 * p1[0] + b2; + //point on the edge vector of area2 closest to v2 + p2[0] = (DotProduct(v2, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0]; + p2[1] = a2 * p2[0] + b2; + } //end if + else + { + //point on the edge vector of area2 closest to v1 + p1[0] = v3[0]; + p1[1] = v1[1]; + //point on the edge vector of area2 closest to v2 + p2[0] = v3[0]; + p2[1] = v2[1]; + } //end else + // + if (dir1[0]) + { + // + a1 = dir1[1] / dir1[0]; + b1 = v1[1] - a1 * v1[0]; + //point on the edge vector of area1 closest to v3 + p3[0] = (DotProduct(v3, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0]; + p3[1] = a1 * p3[0] + b1; + //point on the edge vector of area1 closest to v4 + p4[0] = (DotProduct(v4, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0]; + p4[1] = a1 * p4[0] + b1; + } //end if + else + { + //point on the edge vector of area1 closest to v3 + p3[0] = v1[0]; + p3[1] = v3[1]; + //point on the edge vector of area1 closest to v4 + p4[0] = v1[0]; + p4[1] = v4[1]; + } //end else + //start with zero z-coordinates + p1[2] = 0; + p2[2] = 0; + p3[2] = 0; + p4[2] = 0; + //calculate the z-coordinates from the ground planes + p1[2] = (plane2->dist - DotProduct(plane2->normal, p1)) / plane2->normal[2]; + p2[2] = (plane2->dist - DotProduct(plane2->normal, p2)) / plane2->normal[2]; + p3[2] = (plane1->dist - DotProduct(plane1->normal, p3)) / plane1->normal[2]; + p4[2] = (plane1->dist - DotProduct(plane1->normal, p4)) / plane1->normal[2]; + // + founddist = qfalse; + // + if (VectorBetweenVectors(p1, v3, v4)) + { + dist = VectorDistance(v1, p1); + if (dist > bestdist - 0.5 && dist < bestdist + 0.5) + { + dist1 = VectorDistance(beststart1, v1); + dist2 = VectorDistance(beststart2, v1); + if (dist1 > dist2) + { + if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(v1, beststart2); + } //end if + else + { + if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(v1, beststart1); + } //end else + dist1 = VectorDistance(bestend1, p1); + dist2 = VectorDistance(bestend2, p1); + if (dist1 > dist2) + { + if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(p1, bestend2); + } //end if + else + { + if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(p1, bestend1); + } //end else + } //end if + else if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v1, beststart1); + VectorCopy(v1, beststart2); + VectorCopy(p1, bestend1); + VectorCopy(p1, bestend2); + } //end if + founddist = qtrue; + } //end if + if (VectorBetweenVectors(p2, v3, v4)) + { + dist = VectorDistance(v2, p2); + if (dist > bestdist - 0.5 && dist < bestdist + 0.5) + { + dist1 = VectorDistance(beststart1, v2); + dist2 = VectorDistance(beststart2, v2); + if (dist1 > dist2) + { + if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(v2, beststart2); + } //end if + else + { + if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(v2, beststart1); + } //end else + dist1 = VectorDistance(bestend1, p2); + dist2 = VectorDistance(bestend2, p2); + if (dist1 > dist2) + { + if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(p2, bestend2); + } //end if + else + { + if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(p2, bestend1); + } //end else + } //end if + else if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v2, beststart1); + VectorCopy(v2, beststart2); + VectorCopy(p2, bestend1); + VectorCopy(p2, bestend2); + } //end if + founddist = qtrue; + } //end else if + if (VectorBetweenVectors(p3, v1, v2)) + { + dist = VectorDistance(v3, p3); + if (dist > bestdist - 0.5 && dist < bestdist + 0.5) + { + dist1 = VectorDistance(beststart1, p3); + dist2 = VectorDistance(beststart2, p3); + if (dist1 > dist2) + { + if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(p3, beststart2); + } //end if + else + { + if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(p3, beststart1); + } //end else + dist1 = VectorDistance(bestend1, v3); + dist2 = VectorDistance(bestend2, v3); + if (dist1 > dist2) + { + if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(v3, bestend2); + } //end if + else + { + if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(v3, bestend1); + } //end else + } //end if + else if (dist < bestdist) + { + bestdist = dist; + VectorCopy(p3, beststart1); + VectorCopy(p3, beststart2); + VectorCopy(v3, bestend1); + VectorCopy(v3, bestend2); + } //end if + founddist = qtrue; + } //end else if + if (VectorBetweenVectors(p4, v1, v2)) + { + dist = VectorDistance(v4, p4); + if (dist > bestdist - 0.5 && dist < bestdist + 0.5) + { + dist1 = VectorDistance(beststart1, p4); + dist2 = VectorDistance(beststart2, p4); + if (dist1 > dist2) + { + if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(p4, beststart2); + } //end if + else + { + if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(p4, beststart1); + } //end else + dist1 = VectorDistance(bestend1, v4); + dist2 = VectorDistance(bestend2, v4); + if (dist1 > dist2) + { + if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(v4, bestend2); + } //end if + else + { + if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(v4, bestend1); + } //end else + } //end if + else if (dist < bestdist) + { + bestdist = dist; + VectorCopy(p4, beststart1); + VectorCopy(p4, beststart2); + VectorCopy(v4, bestend1); + VectorCopy(v4, bestend2); + } //end if + founddist = qtrue; + } //end else if + //if no shortest distance was found the shortest distance + //is between one of the vertexes of edge1 and one of edge2 + if (!founddist) + { + dist = VectorDistance(v1, v3); + if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v1, beststart1); + VectorCopy(v1, beststart2); + VectorCopy(v3, bestend1); + VectorCopy(v3, bestend2); + } //end if + dist = VectorDistance(v1, v4); + if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v1, beststart1); + VectorCopy(v1, beststart2); + VectorCopy(v4, bestend1); + VectorCopy(v4, bestend2); + } //end if + dist = VectorDistance(v2, v3); + if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v2, beststart1); + VectorCopy(v2, beststart2); + VectorCopy(v3, bestend1); + VectorCopy(v3, bestend2); + } //end if + dist = VectorDistance(v2, v4); + if (dist < bestdist) + { + bestdist = dist; + VectorCopy(v2, beststart1); + VectorCopy(v2, beststart2); + VectorCopy(v4, bestend1); + VectorCopy(v4, bestend2); + } //end if + } //end if + return bestdist; +} //end of the function AAS_ClosestEdgePoints +//=========================================================================== +// creates possible jump reachabilities between the areas +// +// The two closest points on the ground of the areas are calculated +// One of the points will be on an edge of a ground face of area1 and +// one on an edge of a ground face of area2. +// If there is a range of closest points the point in the middle of this range +// is selected. +// Between these two points there must be one or more gaps. +// If the gaps exist a potential jump is predicted. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_Reachability_Jump(int area1num, int area2num) +{ + int i, j, k, l, face1num, face2num, edge1num, edge2num, traveltype; + int stopevent, areas[10], numareas; + float phys_jumpvel, maxjumpdistance, maxjumpheight, height, bestdist, speed; + vec_t *v1, *v2, *v3, *v4; + vec3_t beststart, beststart2, bestend, bestend2; + vec3_t teststart, testend, dir, velocity, cmdmove, up = {0, 0, 1}, sidewards; + aas_area_t *area1, *area2; + aas_face_t *face1, *face2; + aas_edge_t *edge1, *edge2; + aas_plane_t *plane1, *plane2, *plane; + aas_trace_t trace; + aas_clientmove_t move; + aas_lreachability_t *lreach; + + if (!AAS_AreaGrounded(area1num) || !AAS_AreaGrounded(area2num)) return qfalse; + //cannot jump from or to a crouch area + if (AAS_AreaCrouch(area1num) || AAS_AreaCrouch(area2num)) return qfalse; + // + area1 = &aasworld.areas[area1num]; + area2 = &aasworld.areas[area2num]; + // + phys_jumpvel = aassettings.phys_jumpvel; + //maximum distance a player can jump + maxjumpdistance = 2 * AAS_MaxJumpDistance(phys_jumpvel); + //maximum height a player can jump with the given initial z velocity + maxjumpheight = AAS_MaxJumpHeight(phys_jumpvel); + + //if the areas are not near anough in the x-y direction + for (i = 0; i < 2; i++) + { + if (area1->mins[i] > area2->maxs[i] + maxjumpdistance) return qfalse; + if (area1->maxs[i] < area2->mins[i] - maxjumpdistance) return qfalse; + } //end for + //if area2 is way to high to jump up to + if (area2->mins[2] > area1->maxs[2] + maxjumpheight) return qfalse; + // + bestdist = 999999; + // + for (i = 0; i < area1->numfaces; i++) + { + face1num = aasworld.faceindex[area1->firstface + i]; + face1 = &aasworld.faces[abs(face1num)]; + //if not a ground face + if (!(face1->faceflags & FACE_GROUND)) continue; + // + for (j = 0; j < area2->numfaces; j++) + { + face2num = aasworld.faceindex[area2->firstface + j]; + face2 = &aasworld.faces[abs(face2num)]; + //if not a ground face + if (!(face2->faceflags & FACE_GROUND)) continue; + // + for (k = 0; k < face1->numedges; k++) + { + edge1num = abs(aasworld.edgeindex[face1->firstedge + k]); + edge1 = &aasworld.edges[edge1num]; + for (l = 0; l < face2->numedges; l++) + { + edge2num = abs(aasworld.edgeindex[face2->firstedge + l]); + edge2 = &aasworld.edges[edge2num]; + //calculate the minimum distance between the two edges + v1 = aasworld.vertexes[edge1->v[0]]; + v2 = aasworld.vertexes[edge1->v[1]]; + v3 = aasworld.vertexes[edge2->v[0]]; + v4 = aasworld.vertexes[edge2->v[1]]; + //get the ground planes + plane1 = &aasworld.planes[face1->planenum]; + plane2 = &aasworld.planes[face2->planenum]; + // + bestdist = AAS_ClosestEdgePoints(v1, v2, v3, v4, plane1, plane2, + beststart, bestend, + beststart2, bestend2, bestdist); + } //end for + } //end for + } //end for + } //end for + VectorMiddle(beststart, beststart2, beststart); + VectorMiddle(bestend, bestend2, bestend); + if (bestdist > 4 && bestdist < maxjumpdistance) + { +// Log_Write("shortest distance between %d and %d is %f\r\n", area1num, area2num, bestdist); + // if very close and almost no height difference then the bot can walk + if (bestdist <= 48 && fabs(beststart[2] - bestend[2]) < 8) + { + speed = 400; + traveltype = TRAVEL_WALKOFFLEDGE; + } //end if + else if (AAS_HorizontalVelocityForJump(0, beststart, bestend, &speed)) + { + //FIXME: why multiply with 1.2??? + speed *= 1.2f; + traveltype = TRAVEL_WALKOFFLEDGE; + } //end else if + else + { + //get the horizontal speed for the jump, if it isn't possible to calculate this + //speed (the jump is not possible) then there's no jump reachability created + if (!AAS_HorizontalVelocityForJump(phys_jumpvel, beststart, bestend, &speed)) + return qfalse; + speed *= 1.05f; + traveltype = TRAVEL_JUMP; + // + //NOTE: test if the horizontal distance isn't too small + VectorSubtract(bestend, beststart, dir); + dir[2] = 0; + if (VectorLength(dir) < 10) + return qfalse; + } //end if + // + VectorSubtract(bestend, beststart, dir); + VectorNormalize(dir); + VectorMA(beststart, 1, dir, teststart); + // + VectorCopy(teststart, testend); + testend[2] -= 100; + trace = AAS_TraceClientBBox(teststart, testend, PRESENCE_NORMAL, -1); + // + if (trace.startsolid) + return qfalse; + if (trace.fraction < 1) + { + plane = &aasworld.planes[trace.planenum]; + // if the bot can stand on the surface + if (DotProduct(plane->normal, up) >= 0.7) + { + // if no lava or slime below + if (!(AAS_PointContents(trace.endpos) & (CONTENTS_LAVA|CONTENTS_SLIME))) + { + if (teststart[2] - trace.endpos[2] <= aassettings.phys_maxbarrier) + return qfalse; + } //end if + } //end if + } //end if + // + VectorMA(bestend, -1, dir, teststart); + // + VectorCopy(teststart, testend); + testend[2] -= 100; + trace = AAS_TraceClientBBox(teststart, testend, PRESENCE_NORMAL, -1); + // + if (trace.startsolid) + return qfalse; + if (trace.fraction < 1) + { + plane = &aasworld.planes[trace.planenum]; + // if the bot can stand on the surface + if (DotProduct(plane->normal, up) >= 0.7) + { + // if no lava or slime below + if (!(AAS_PointContents(trace.endpos) & (CONTENTS_LAVA|CONTENTS_SLIME))) + { + if (teststart[2] - trace.endpos[2] <= aassettings.phys_maxbarrier) + return qfalse; + } //end if + } //end if + } //end if + // + // get command movement + VectorClear(cmdmove); + if ((traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP) + cmdmove[2] = aassettings.phys_jumpvel; + else + cmdmove[2] = 0; + // + VectorSubtract(bestend, beststart, dir); + dir[2] = 0; + VectorNormalize(dir); + CrossProduct(dir, up, sidewards); + // + stopevent = SE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE; + if (!AAS_AreaClusterPortal(area1num) && !AAS_AreaClusterPortal(area2num)) + stopevent |= SE_TOUCHCLUSTERPORTAL; + // + for (i = 0; i < 3; i++) + { + // + if (i == 1) + VectorAdd(testend, sidewards, testend); + else if (i == 2) + VectorSubtract(bestend, sidewards, testend); + else + VectorCopy(bestend, testend); + VectorSubtract(testend, beststart, dir); + dir[2] = 0; + VectorNormalize(dir); + VectorScale(dir, speed, velocity); + // + AAS_PredictClientMovement(&move, -1, beststart, PRESENCE_NORMAL, qtrue, + velocity, cmdmove, 3, 30, 0.1f, + stopevent, 0, qfalse); + // if prediction time wasn't enough to fully predict the movement + if (move.frames >= 30) + return qfalse; + // don't enter slime or lava and don't fall from too high + if (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA)) + return qfalse; + // never jump or fall through a cluster portal + if (move.stopevent & SE_TOUCHCLUSTERPORTAL) + return qfalse; + //the end position should be in area2, also test a little bit back + //because the predicted jump could have rushed through the area + VectorMA(move.endpos, -64, dir, teststart); + teststart[2] += 1; + numareas = AAS_TraceAreas(move.endpos, teststart, areas, NULL, sizeof(areas) / sizeof(int)); + for (j = 0; j < numareas; j++) + { + if (areas[j] == area2num) + break; + } //end for + if (j < numareas) + break; + } + if (i >= 3) + return qfalse; + // +#ifdef REACH_DEBUG + //create the reachability + Log_Write("jump reachability between %d and %d\r\n", area1num, area2num); +#endif //REACH_DEBUG + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area2num; + lreach->facenum = 0; + lreach->edgenum = 0; + VectorCopy(beststart, lreach->start); + VectorCopy(bestend, lreach->end); + lreach->traveltype = traveltype; + + VectorSubtract(bestend, beststart, dir); + height = dir[2]; + dir[2] = 0; + if ((traveltype & TRAVELTYPE_MASK) == TRAVEL_WALKOFFLEDGE && height > VectorLength(dir)) + { + lreach->traveltime = aassettings.rs_startwalkoffledge + height * 50 / aassettings.phys_gravity; + } + else + { + lreach->traveltime = aassettings.rs_startjump + VectorDistance(bestend, beststart) * 240 / aassettings.phys_maxwalkvelocity; + } //end if + // + if (!AAS_AreaJumpPad(area2num)) + { + if (AAS_FallDelta(beststart[2] - bestend[2]) > aassettings.phys_falldelta5) + { + lreach->traveltime += aassettings.rs_falldamage5; + } //end if + else if (AAS_FallDelta(beststart[2] - bestend[2]) > aassettings.phys_falldelta10) + { + lreach->traveltime += aassettings.rs_falldamage10; + } //end if + } //end if + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + // + if ((traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP) + reach_jump++; + else + reach_walkoffledge++; + } //end if + return qfalse; +} //end of the function AAS_Reachability_Jump +//=========================================================================== +// create a possible ladder reachability from area1 to area2 +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_Reachability_Ladder(int area1num, int area2num) +{ + int i, j, k, l, edge1num, edge2num, sharededgenum = 0, lowestedgenum = 0; + int face1num, face2num, ladderface1num = 0, ladderface2num = 0; + int ladderface1vertical, ladderface2vertical, firstv; + float face1area, face2area, bestface1area = -9999, bestface2area = -9999; + float phys_jumpvel, maxjumpheight; + vec3_t area1point, area2point, v1, v2, up = {0, 0, 1}; + vec3_t mid, lowestpoint = {0, 0}, start, end, sharededgevec, dir; + aas_area_t *area1, *area2; + aas_face_t *face1, *face2, *ladderface1 = NULL, *ladderface2 = NULL; + aas_plane_t *plane1, *plane2; + aas_edge_t *sharededge, *edge1; + aas_lreachability_t *lreach; + aas_trace_t trace; + + if (!AAS_AreaLadder(area1num) || !AAS_AreaLadder(area2num)) return qfalse; + // + phys_jumpvel = aassettings.phys_jumpvel; + //maximum height a player can jump with the given initial z velocity + maxjumpheight = AAS_MaxJumpHeight(phys_jumpvel); + + area1 = &aasworld.areas[area1num]; + area2 = &aasworld.areas[area2num]; + + for (i = 0; i < area1->numfaces; i++) + { + face1num = aasworld.faceindex[area1->firstface + i]; + face1 = &aasworld.faces[abs(face1num)]; + //if not a ladder face + if (!(face1->faceflags & FACE_LADDER)) continue; + // + for (j = 0; j < area2->numfaces; j++) + { + face2num = aasworld.faceindex[area2->firstface + j]; + face2 = &aasworld.faces[abs(face2num)]; + //if not a ladder face + if (!(face2->faceflags & FACE_LADDER)) continue; + //check if the faces share an edge + for (k = 0; k < face1->numedges; k++) + { + edge1num = aasworld.edgeindex[face1->firstedge + k]; + for (l = 0; l < face2->numedges; l++) + { + edge2num = aasworld.edgeindex[face2->firstedge + l]; + if (abs(edge1num) == abs(edge2num)) + { + //get the face with the largest area + face1area = AAS_FaceArea(face1); + face2area = AAS_FaceArea(face2); + if (face1area > bestface1area && face2area > bestface2area) + { + bestface1area = face1area; + bestface2area = face2area; + ladderface1 = face1; + ladderface2 = face2; + ladderface1num = face1num; + ladderface2num = face2num; + sharededgenum = edge1num; + } //end if + break; + } //end if + } //end for + if (l != face2->numedges) break; + } //end for + } //end for + } //end for + // + if (ladderface1 && ladderface2) + { + //get the middle of the shared edge + sharededge = &aasworld.edges[abs(sharededgenum)]; + firstv = sharededgenum < 0; + // + VectorCopy(aasworld.vertexes[sharededge->v[firstv]], v1); + VectorCopy(aasworld.vertexes[sharededge->v[!firstv]], v2); + VectorAdd(v1, v2, area1point); + VectorScale(area1point, 0.5, area1point); + VectorCopy(area1point, area2point); + // + //if the face plane in area 1 is pretty much vertical + plane1 = &aasworld.planes[ladderface1->planenum ^ (ladderface1num < 0)]; + plane2 = &aasworld.planes[ladderface2->planenum ^ (ladderface2num < 0)]; + // + //get the points really into the areas + VectorSubtract(v2, v1, sharededgevec); + CrossProduct(plane1->normal, sharededgevec, dir); + VectorNormalize(dir); + //NOTE: 32 because that's larger than 16 (bot bbox x,y) + VectorMA(area1point, -32, dir, area1point); + VectorMA(area2point, 32, dir, area2point); + // + ladderface1vertical = abs(DotProduct(plane1->normal, up)) < 0.1; + ladderface2vertical = abs(DotProduct(plane2->normal, up)) < 0.1; + //there's only reachability between vertical ladder faces + if (!ladderface1vertical && !ladderface2vertical) return qfalse; + //if both vertical ladder faces + if (ladderface1vertical && ladderface2vertical + //and the ladder faces do not make a sharp corner + && DotProduct(plane1->normal, plane2->normal) > 0.7 + //and the shared edge is not too vertical + && abs(DotProduct(sharededgevec, up)) < 0.7) + { + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area2num; + lreach->facenum = ladderface1num; + lreach->edgenum = abs(sharededgenum); + VectorCopy(area1point, lreach->start); + //VectorCopy(area2point, lreach->end); + VectorMA(area2point, -3, plane1->normal, lreach->end); + lreach->traveltype = TRAVEL_LADDER; + lreach->traveltime = 10; + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + // + reach_ladder++; + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area1num; + lreach->facenum = ladderface2num; + lreach->edgenum = abs(sharededgenum); + VectorCopy(area2point, lreach->start); + //VectorCopy(area1point, lreach->end); + VectorMA(area1point, -3, plane1->normal, lreach->end); + lreach->traveltype = TRAVEL_LADDER; + lreach->traveltime = 10; + lreach->next = areareachability[area2num]; + areareachability[area2num] = lreach; + // + reach_ladder++; + // + return qtrue; + } //end if + //if the second ladder face is also a ground face + //create ladder end (just ladder) reachability and + //walk off a ladder (ledge) reachability + if (ladderface1vertical && (ladderface2->faceflags & FACE_GROUND)) + { + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area2num; + lreach->facenum = ladderface1num; + lreach->edgenum = abs(sharededgenum); + VectorCopy(area1point, lreach->start); + VectorCopy(area2point, lreach->end); + lreach->end[2] += 16; + VectorMA(lreach->end, -15, plane1->normal, lreach->end); + lreach->traveltype = TRAVEL_LADDER; + lreach->traveltime = 10; + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + // + reach_ladder++; + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area1num; + lreach->facenum = ladderface2num; + lreach->edgenum = abs(sharededgenum); + VectorCopy(area2point, lreach->start); + VectorCopy(area1point, lreach->end); + lreach->traveltype = TRAVEL_WALKOFFLEDGE; + lreach->traveltime = 10; + lreach->next = areareachability[area2num]; + areareachability[area2num] = lreach; + // + reach_walkoffledge++; + // + return qtrue; + } //end if + // + if (ladderface1vertical) + { + //find lowest edge of the ladder face + lowestpoint[2] = 99999; + for (i = 0; i < ladderface1->numedges; i++) + { + edge1num = abs(aasworld.edgeindex[ladderface1->firstedge + i]); + edge1 = &aasworld.edges[edge1num]; + // + VectorCopy(aasworld.vertexes[edge1->v[0]], v1); + VectorCopy(aasworld.vertexes[edge1->v[1]], v2); + // + VectorAdd(v1, v2, mid); + VectorScale(mid, 0.5, mid); + // + if (mid[2] < lowestpoint[2]) + { + VectorCopy(mid, lowestpoint); + lowestedgenum = edge1num; + } //end if + } //end for + // + plane1 = &aasworld.planes[ladderface1->planenum]; + //trace down in the middle of this edge + VectorMA(lowestpoint, 5, plane1->normal, start); + VectorCopy(start, end); + start[2] += 5; + end[2] -= 100; + //trace without entity collision + trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1); + // + // +#ifdef REACH_DEBUG + if (trace.startsolid) + { + Log_Write("trace from area %d started in solid\r\n", area1num); + } //end if +#endif //REACH_DEBUG + // + trace.endpos[2] += 1; + area2num = AAS_PointAreaNum(trace.endpos); + // + area2 = &aasworld.areas[area2num]; + for (i = 0; i < area2->numfaces; i++) + { + face2num = aasworld.faceindex[area2->firstface + i]; + face2 = &aasworld.faces[abs(face2num)]; + // + if (face2->faceflags & FACE_LADDER) + { + plane2 = &aasworld.planes[face2->planenum]; + if (abs(DotProduct(plane2->normal, up)) < 0.1) break; + } //end if + } //end for + //if from another area without vertical ladder faces + if (i >= area2->numfaces && area2num != area1num && + //the reachabilities shouldn't exist already + !AAS_ReachabilityExists(area1num, area2num) && + !AAS_ReachabilityExists(area2num, area1num)) + { + //if the height is jumpable + if (start[2] - trace.endpos[2] < maxjumpheight) + { + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area2num; + lreach->facenum = ladderface1num; + lreach->edgenum = lowestedgenum; + VectorCopy(lowestpoint, lreach->start); + VectorCopy(trace.endpos, lreach->end); + lreach->traveltype = TRAVEL_LADDER; + lreach->traveltime = 10; + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + // + reach_ladder++; + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area1num; + lreach->facenum = ladderface1num; + lreach->edgenum = lowestedgenum; + VectorCopy(trace.endpos, lreach->start); + //get the end point a little bit into the ladder + VectorMA(lowestpoint, -5, plane1->normal, lreach->end); + //get the end point a little higher + lreach->end[2] += 10; + lreach->traveltype = TRAVEL_JUMP; + lreach->traveltime = 10; + lreach->next = areareachability[area2num]; + areareachability[area2num] = lreach; + // + reach_jump++; + // + return qtrue; +#ifdef REACH_DEBUG + Log_Write("jump up to ladder reach between %d and %d\r\n", area2num, area1num); +#endif //REACH_DEBUG + } //end if +#ifdef REACH_DEBUG + else Log_Write("jump too high between area %d and %d\r\n", area2num, area1num); +#endif //REACH_DEBUG + } //end if + /*//if slime or lava below the ladder + //try jump reachability from far towards the ladder + if (aasworld.areasettings[area2num].contents & (AREACONTENTS_SLIME + | AREACONTENTS_LAVA)) + { + for (i = 20; i <= 120; i += 20) + { + //trace down in the middle of this edge + VectorMA(lowestpoint, i, plane1->normal, start); + VectorCopy(start, end); + start[2] += 5; + end[2] -= 100; + //trace without entity collision + trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1); + // + if (trace.startsolid) break; + trace.endpos[2] += 1; + area2num = AAS_PointAreaNum(trace.endpos); + if (area2num == area1num) continue; + // + if (start[2] - trace.endpos[2] > maxjumpheight) continue; + if (aasworld.areasettings[area2num].contents & (AREACONTENTS_SLIME + | AREACONTENTS_LAVA)) continue; + // + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area1num; + lreach->facenum = ladderface1num; + lreach->edgenum = lowestedgenum; + VectorCopy(trace.endpos, lreach->start); + VectorCopy(lowestpoint, lreach->end); + lreach->end[2] += 5; + lreach->traveltype = TRAVEL_JUMP; + lreach->traveltime = 10; + lreach->next = areareachability[area2num]; + areareachability[area2num] = lreach; + // + reach_jump++; + // + Log_Write("jump far to ladder reach between %d and %d\r\n", area2num, area1num); + // + break; + } //end for + } //end if*/ + } //end if + } //end if + return qfalse; +} //end of the function AAS_Reachability_Ladder +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_TravelFlagsForTeam(int ent) +{ + int notteam; + + if (!AAS_IntForBSPEpairKey(ent, "bot_notteam", ¬team)) + return 0; + if (notteam == 1) + return TRAVELFLAG_NOTTEAM1; + if (notteam == 2) + return TRAVELFLAG_NOTTEAM2; + return 0; +} //end of the function AAS_TravelFlagsForTeam +//=========================================================================== +// create possible teleporter reachabilities +// this is very game dependent.... :( +// +// classname = trigger_multiple or trigger_teleport +// target = "t1" +// +// classname = target_teleporter +// targetname = "t1" +// target = "t2" +// +// classname = misc_teleporter_dest +// targetname = "t2" +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_Reachability_Teleport(void) +{ + int area1num, area2num; + char target[MAX_EPAIRKEY], targetname[MAX_EPAIRKEY]; + char classname[MAX_EPAIRKEY], model[MAX_EPAIRKEY]; + int ent, dest; + float angle; + vec3_t origin, destorigin, mins, maxs, end, angles; + vec3_t mid, velocity, cmdmove; + aas_lreachability_t *lreach; + aas_clientmove_t move; + aas_trace_t trace; + aas_link_t *areas, *link; + + for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) + { + if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; + if (!strcmp(classname, "trigger_multiple")) + { + AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY); +//#ifdef REACH_DEBUG + botimport.Print(PRT_MESSAGE, "trigger_multiple model = \"%s\"\n", model); +//#endif REACH_DEBUG + VectorClear(angles); + AAS_BSPModelMinsMaxsOrigin(atoi(model+1), angles, mins, maxs, origin); + // + if (!AAS_ValueForBSPEpairKey(ent, "target", target, MAX_EPAIRKEY)) + { + botimport.Print(PRT_ERROR, "trigger_multiple at %1.0f %1.0f %1.0f without target\n", + origin[0], origin[1], origin[2]); + continue; + } //end if + for (dest = AAS_NextBSPEntity(0); dest; dest = AAS_NextBSPEntity(dest)) + { + if (!AAS_ValueForBSPEpairKey(dest, "classname", classname, MAX_EPAIRKEY)) continue; + if (!strcmp(classname, "target_teleporter")) + { + if (!AAS_ValueForBSPEpairKey(dest, "targetname", targetname, MAX_EPAIRKEY)) continue; + if (!strcmp(targetname, target)) + { + break; + } //end if + } //end if + } //end for + if (!dest) + { + continue; + } //end if + if (!AAS_ValueForBSPEpairKey(dest, "target", target, MAX_EPAIRKEY)) + { + botimport.Print(PRT_ERROR, "target_teleporter without target\n"); + continue; + } //end if + } //end else + else if (!strcmp(classname, "trigger_teleport")) + { + AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY); +//#ifdef REACH_DEBUG + botimport.Print(PRT_MESSAGE, "trigger_teleport model = \"%s\"\n", model); +//#endif REACH_DEBUG + VectorClear(angles); + AAS_BSPModelMinsMaxsOrigin(atoi(model+1), angles, mins, maxs, origin); + // + if (!AAS_ValueForBSPEpairKey(ent, "target", target, MAX_EPAIRKEY)) + { + botimport.Print(PRT_ERROR, "trigger_teleport at %1.0f %1.0f %1.0f without target\n", + origin[0], origin[1], origin[2]); + continue; + } //end if + } //end if + else + { + continue; + } //end else + // + for (dest = AAS_NextBSPEntity(0); dest; dest = AAS_NextBSPEntity(dest)) + { + //classname should be misc_teleporter_dest + //but I've also seen target_position and actually any + //entity could be used... burp + if (AAS_ValueForBSPEpairKey(dest, "targetname", targetname, MAX_EPAIRKEY)) + { + if (!strcmp(targetname, target)) + { + break; + } //end if + } //end if + } //end for + if (!dest) + { + botimport.Print(PRT_ERROR, "teleporter without misc_teleporter_dest (%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 + // + area2num = AAS_PointAreaNum(destorigin); + //if not teleported into a teleporter or into a jumppad + if (!AAS_AreaTeleporter(area2num) && !AAS_AreaJumpPad(area2num)) + { + VectorCopy(destorigin, end); + end[2] -= 64; + 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 + area2num = AAS_PointAreaNum(trace.endpos); + // + /* + if (!AAS_AreaTeleporter(area2num) && + !AAS_AreaJumpPad(area2num) && + !AAS_AreaGrounded(area2num)) + { + VectorCopy(trace.endpos, destorigin); + } + else*/ + { + //predict where you'll end up + AAS_FloatForBSPEpairKey(dest, "angle", &angle); + if (angle) + { + VectorSet(angles, 0, angle, 0); + AngleVectors(angles, velocity, NULL, NULL); + VectorScale(velocity, 400, velocity); + } //end if + else + { + VectorClear(velocity); + } //end else + VectorClear(cmdmove); + AAS_PredictClientMovement(&move, -1, destorigin, PRESENCE_NORMAL, qfalse, + velocity, cmdmove, 0, 30, 0.1f, + SE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME| + SE_ENTERLAVA|SE_HITGROUNDDAMAGE|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER, 0, qfalse); //qtrue); + area2num = AAS_PointAreaNum(move.endpos); + if (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA)) + { + botimport.Print(PRT_WARNING, "teleported into slime or lava at dest %s\n", target); + } //end if + VectorCopy(move.endpos, destorigin); + } //end else + } //end if + // + //botimport.Print(PRT_MESSAGE, "teleporter brush origin at %f %f %f\n", origin[0], origin[1], origin[2]); + //botimport.Print(PRT_MESSAGE, "teleporter brush mins = %f %f %f\n", mins[0], mins[1], mins[2]); + //botimport.Print(PRT_MESSAGE, "teleporter brush maxs = %f %f %f\n", maxs[0], maxs[1], maxs[2]); + VectorAdd(origin, mins, mins); + VectorAdd(origin, maxs, maxs); + // + VectorAdd(mins, maxs, mid); + VectorScale(mid, 0.5, mid); + //link an invalid (-1) entity + areas = AAS_LinkEntityClientBBox(mins, maxs, -1, PRESENCE_CROUCH); + if (!areas) botimport.Print(PRT_MESSAGE, "trigger_multiple not in any area\n"); + // + for (link = areas; link; link = link->next_area) + { + //if (!AAS_AreaGrounded(link->areanum)) continue; + if (!AAS_AreaTeleporter(link->areanum)) continue; + // + area1num = link->areanum; + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) break; + lreach->areanum = area2num; + lreach->facenum = 0; + lreach->edgenum = 0; + VectorCopy(mid, lreach->start); + VectorCopy(destorigin, lreach->end); + lreach->traveltype = TRAVEL_TELEPORT; + lreach->traveltype |= AAS_TravelFlagsForTeam(ent); + lreach->traveltime = aassettings.rs_teleport; + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + // + reach_teleport++; + } //end for + //unlink the invalid entity + AAS_UnlinkFromAreas(areas); + } //end for +} //end of the function AAS_Reachability_Teleport +//=========================================================================== +// create possible elevator (func_plat) reachabilities +// this is very game dependent.... :( +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_Reachability_Elevator(void) +{ + int area1num, area2num, modelnum, i, j, k, l, n, p; + float lip, height, speed; + char model[MAX_EPAIRKEY], classname[MAX_EPAIRKEY]; + int ent; + vec3_t mins, maxs, origin, angles = {0, 0, 0}; + vec3_t pos1, pos2, mids, platbottom, plattop; + vec3_t bottomorg, toporg, start, end, dir; + vec_t xvals[8], yvals[8], xvals_top[8], yvals_top[8]; + aas_lreachability_t *lreach; + aas_trace_t trace; + +#ifdef REACH_DEBUG + Log_Write("AAS_Reachability_Elevator\r\n"); +#endif //REACH_DEBUG + for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) + { + if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; + if (!strcmp(classname, "func_plat")) + { +#ifdef REACH_DEBUG + Log_Write("found func plat\r\n"); +#endif //REACH_DEBUG + if (!AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY)) + { + botimport.Print(PRT_ERROR, "func_plat without model\n"); + continue; + } //end if + //get the model number, and skip the leading * + modelnum = atoi(model+1); + if (modelnum <= 0) + { + botimport.Print(PRT_ERROR, "func_plat with invalid model number\n"); + continue; + } //end if + //get the mins, maxs and origin of the model + //NOTE: the origin is usually (0,0,0) and the mins and maxs + // are the absolute mins and maxs + AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin); + // + AAS_VectorForBSPEpairKey(ent, "origin", origin); + //pos1 is the top position, pos2 is the bottom + VectorCopy(origin, pos1); + VectorCopy(origin, pos2); + //get the lip of the plat + AAS_FloatForBSPEpairKey(ent, "lip", &lip); + if (!lip) lip = 8; + //get the movement height of the plat + AAS_FloatForBSPEpairKey(ent, "height", &height); + if (!height) height = (maxs[2] - mins[2]) - lip; + //get the speed of the plat + AAS_FloatForBSPEpairKey(ent, "speed", &speed); + if (!speed) speed = 200; + //get bottom position below pos1 + pos2[2] -= height; + // + //get a point just above the plat in the bottom position + VectorAdd(mins, maxs, mids); + VectorMA(pos2, 0.5, mids, platbottom); + platbottom[2] = maxs[2] - (pos1[2] - pos2[2]) + 2; + //get a point just above the plat in the top position + VectorAdd(mins, maxs, mids); + VectorMA(pos2, 0.5, mids, plattop); + plattop[2] = maxs[2] + 2; + // + /*if (!area1num) + { + Log_Write("no grounded area near plat bottom\r\n"); + continue; + } //end if*/ + //get the mins and maxs a little larger + for (i = 0; i < 3; i++) + { + mins[i] -= 1; + maxs[i] += 1; + } //end for + // + //botimport.Print(PRT_MESSAGE, "platbottom[2] = %1.1f plattop[2] = %1.1f\n", platbottom[2], plattop[2]); + // + VectorAdd(mins, maxs, mids); + VectorScale(mids, 0.5, mids); + // + xvals[0] = mins[0]; xvals[1] = mids[0]; xvals[2] = maxs[0]; xvals[3] = mids[0]; + yvals[0] = mids[1]; yvals[1] = maxs[1]; yvals[2] = mids[1]; yvals[3] = mins[1]; + // + xvals[4] = mins[0]; xvals[5] = maxs[0]; xvals[6] = maxs[0]; xvals[7] = mins[0]; + yvals[4] = maxs[1]; yvals[5] = maxs[1]; yvals[6] = mins[1]; yvals[7] = mins[1]; + //find adjacent areas around the bottom of the plat + for (i = 0; i < 9; i++) + { + if (i < 8) //check at the sides of the plat + { + bottomorg[0] = origin[0] + xvals[i]; + bottomorg[1] = origin[1] + yvals[i]; + bottomorg[2] = platbottom[2] + 16; + //get a grounded or swim area near the plat in the bottom position + area1num = AAS_PointAreaNum(bottomorg); + for (k = 0; k < 16; k++) + { + if (area1num) + { + if (AAS_AreaGrounded(area1num) || AAS_AreaSwim(area1num)) break; + } //end if + bottomorg[2] += 4; + area1num = AAS_PointAreaNum(bottomorg); + } //end if + //if in solid + if (k >= 16) + { + continue; + } //end if + } //end if + else //at the middle of the plat + { + VectorCopy(plattop, bottomorg); + bottomorg[2] += 24; + area1num = AAS_PointAreaNum(bottomorg); + if (!area1num) continue; + VectorCopy(platbottom, bottomorg); + bottomorg[2] += 24; + } //end else + //look at adjacent areas around the top of the plat + //make larger steps to outside the plat everytime + for (n = 0; n < 3; n++) + { + for (k = 0; k < 3; k++) + { + mins[k] -= 4; + maxs[k] += 4; + } //end for + xvals_top[0] = mins[0]; xvals_top[1] = mids[0]; xvals_top[2] = maxs[0]; xvals_top[3] = mids[0]; + yvals_top[0] = mids[1]; yvals_top[1] = maxs[1]; yvals_top[2] = mids[1]; yvals_top[3] = mins[1]; + // + xvals_top[4] = mins[0]; xvals_top[5] = maxs[0]; xvals_top[6] = maxs[0]; xvals_top[7] = mins[0]; + yvals_top[4] = maxs[1]; yvals_top[5] = maxs[1]; yvals_top[6] = mins[1]; yvals_top[7] = mins[1]; + // + for (j = 0; j < 8; j++) + { + toporg[0] = origin[0] + xvals_top[j]; + toporg[1] = origin[1] + yvals_top[j]; + toporg[2] = plattop[2] + 16; + //get a grounded or swim area near the plat in the top position + area2num = AAS_PointAreaNum(toporg); + for (l = 0; l < 16; l++) + { + if (area2num) + { + if (AAS_AreaGrounded(area2num) || AAS_AreaSwim(area2num)) + { + VectorCopy(plattop, start); + start[2] += 32; + VectorCopy(toporg, end); + end[2] += 1; + trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1); + if (trace.fraction >= 1) break; + } //end if + } //end if + toporg[2] += 4; + area2num = AAS_PointAreaNum(toporg); + } //end if + //if in solid + if (l >= 16) continue; + //never create a reachability in the same area + if (area2num == area1num) continue; + //if the area isn't grounded + if (!AAS_AreaGrounded(area2num)) continue; + //if there already exists reachability between the areas + if (AAS_ReachabilityExists(area1num, area2num)) continue; + //if the reachability start is within the elevator bounding box + VectorSubtract(bottomorg, platbottom, dir); + VectorNormalize(dir); + dir[0] = bottomorg[0] + 24 * dir[0]; + dir[1] = bottomorg[1] + 24 * dir[1]; + dir[2] = bottomorg[2]; + // + for (p = 0; p < 3; p++) + if (dir[p] < origin[p] + mins[p] || dir[p] > origin[p] + maxs[p]) break; + if (p >= 3) continue; + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) continue; + lreach->areanum = area2num; + //the facenum is the model number + lreach->facenum = modelnum; + //the edgenum is the height + lreach->edgenum = (int) height; + // + VectorCopy(dir, lreach->start); + VectorCopy(toporg, lreach->end); + lreach->traveltype = TRAVEL_ELEVATOR; + lreach->traveltype |= AAS_TravelFlagsForTeam(ent); + lreach->traveltime = aassettings.rs_startelevator + height * 100 / speed; + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + //don't go any further to the outside + n = 9999; + // +#ifdef REACH_DEBUG + Log_Write("elevator reach from %d to %d\r\n", area1num, area2num); +#endif //REACH_DEBUG + // + reach_elevator++; + } //end for + } //end for + } //end for + } //end if + } //end for +} //end of the function AAS_Reachability_Elevator +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_lreachability_t *AAS_FindFaceReachabilities(vec3_t *facepoints, int numpoints, aas_plane_t *plane, int towardsface) +{ + int i, j, k, l; + int facenum, edgenum, bestfacenum; + float *v1, *v2, *v3, *v4; + float bestdist, speed, hordist, dist; + vec3_t beststart, beststart2, bestend, bestend2, tmp, hordir, testpoint; + aas_lreachability_t *lreach, *lreachabilities; + aas_area_t *area; + aas_face_t *face; + aas_edge_t *edge; + aas_plane_t *faceplane, *bestfaceplane; + + // + lreachabilities = NULL; + bestfacenum = 0; + bestfaceplane = NULL; + // + for (i = 1; i < aasworld.numareas; i++) + { + area = &aasworld.areas[i]; + // get the shortest distance between one of the func_bob start edges and + // one of the face edges of area1 + bestdist = 999999; + for (j = 0; j < area->numfaces; j++) + { + facenum = aasworld.faceindex[area->firstface + j]; + face = &aasworld.faces[abs(facenum)]; + //if not a ground face + if (!(face->faceflags & FACE_GROUND)) continue; + //get the ground planes + faceplane = &aasworld.planes[face->planenum]; + // + for (k = 0; k < face->numedges; k++) + { + edgenum = abs(aasworld.edgeindex[face->firstedge + k]); + edge = &aasworld.edges[edgenum]; + //calculate the minimum distance between the two edges + v1 = aasworld.vertexes[edge->v[0]]; + v2 = aasworld.vertexes[edge->v[1]]; + // + for (l = 0; l < numpoints; l++) + { + v3 = facepoints[l]; + v4 = facepoints[(l+1) % numpoints]; + dist = AAS_ClosestEdgePoints(v1, v2, v3, v4, faceplane, plane, + beststart, bestend, + beststart2, bestend2, bestdist); + if (dist < bestdist) + { + bestfacenum = facenum; + bestfaceplane = faceplane; + bestdist = dist; + } //end if + } //end for + } //end for + } //end for + // + if (bestdist > 192) continue; + // + VectorMiddle(beststart, beststart2, beststart); + VectorMiddle(bestend, bestend2, bestend); + // + if (!towardsface) + { + VectorCopy(beststart, tmp); + VectorCopy(bestend, beststart); + VectorCopy(tmp, bestend); + } //end if + // + VectorSubtract(bestend, beststart, hordir); + hordir[2] = 0; + hordist = VectorLength(hordir); + // + if (hordist > 2 * AAS_MaxJumpDistance(aassettings.phys_jumpvel)) continue; + //the end point should not be significantly higher than the start point + if (bestend[2] - 32 > beststart[2]) continue; + //don't fall down too far + if (bestend[2] < beststart[2] - 128) continue; + //the distance should not be too far + if (hordist > 32) + { + //check for walk off ledge + if (!AAS_HorizontalVelocityForJump(0, beststart, bestend, &speed)) continue; + } //end if + // + beststart[2] += 1; + bestend[2] += 1; + // + if (towardsface) VectorCopy(bestend, testpoint); + else VectorCopy(beststart, testpoint); + testpoint[2] = 0; + testpoint[2] = (bestfaceplane->dist - DotProduct(bestfaceplane->normal, testpoint)) / bestfaceplane->normal[2]; + // + if (!AAS_PointInsideFace(bestfacenum, testpoint, 0.1f)) + { + //if the faces are not overlapping then only go down + if (bestend[2] - 16 > beststart[2]) continue; + } //end if + lreach = AAS_AllocReachability(); + if (!lreach) return lreachabilities; + lreach->areanum = i; + lreach->facenum = 0; + lreach->edgenum = 0; + VectorCopy(beststart, lreach->start); + VectorCopy(bestend, lreach->end); + lreach->traveltype = 0; + lreach->traveltime = 0; + lreach->next = lreachabilities; + lreachabilities = lreach; +#ifndef BSPC + if (towardsface) AAS_PermanentLine(lreach->start, lreach->end, 1); + else AAS_PermanentLine(lreach->start, lreach->end, 2); +#endif + } //end for + return lreachabilities; +} //end of the function AAS_FindFaceReachabilities +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_Reachability_FuncBobbing(void) +{ + int ent, spawnflags, modelnum, axis; + int i, numareas, areas[10]; + char classname[MAX_EPAIRKEY], model[MAX_EPAIRKEY]; + vec3_t origin, move_end, move_start, move_start_top, move_end_top; + vec3_t mins, maxs, angles = {0, 0, 0}; + vec3_t start_edgeverts[4], end_edgeverts[4], mid; + vec3_t org, start, end, dir, points[10]; + float height; + aas_plane_t start_plane, end_plane; + aas_lreachability_t *startreach, *endreach, *nextstartreach, *nextendreach, *lreach; + aas_lreachability_t *firststartreach, *firstendreach; + + for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) + { + if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; + if (strcmp(classname, "func_bobbing")) continue; + AAS_FloatForBSPEpairKey(ent, "height", &height); + if (!height) height = 32; + // + if (!AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY)) + { + botimport.Print(PRT_ERROR, "func_bobbing without model\n"); + continue; + } //end if + //get the model number, and skip the leading * + modelnum = atoi(model+1); + if (modelnum <= 0) + { + botimport.Print(PRT_ERROR, "func_bobbing with invalid model number\n"); + continue; + } //end if + //if the entity has an origin set then use it + if (!AAS_VectorForBSPEpairKey(ent, "origin", origin)) + VectorSet(origin, 0, 0, 0); + // + AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL); + // + VectorAdd(mins, origin, mins); + VectorAdd(maxs, origin, maxs); + // + VectorAdd(mins, maxs, mid); + VectorScale(mid, 0.5, mid); + VectorCopy(mid, origin); + // + VectorCopy(origin, move_end); + VectorCopy(origin, move_start); + // + AAS_IntForBSPEpairKey(ent, "spawnflags", &spawnflags); + // set the axis of bobbing + if (spawnflags & 1) axis = 0; + else if (spawnflags & 2) axis = 1; + else axis = 2; + // + move_start[axis] -= height; + move_end[axis] += height; + // + Log_Write("funcbob model %d, start = {%1.1f, %1.1f, %1.1f} end = {%1.1f, %1.1f, %1.1f}\n", + modelnum, move_start[0], move_start[1], move_start[2], move_end[0], move_end[1], move_end[2]); + // +#ifndef BSPC + /* + AAS_DrawPermanentCross(move_start, 4, 1); + AAS_DrawPermanentCross(move_end, 4, 2); + */ +#endif + // + for (i = 0; i < 4; i++) + { + VectorCopy(move_start, start_edgeverts[i]); + start_edgeverts[i][2] += maxs[2] - mid[2]; //+ bbox maxs z + start_edgeverts[i][2] += 24; //+ player origin to ground dist + } //end for + start_edgeverts[0][0] += maxs[0] - mid[0]; + start_edgeverts[0][1] += maxs[1] - mid[1]; + start_edgeverts[1][0] += maxs[0] - mid[0]; + start_edgeverts[1][1] += mins[1] - mid[1]; + start_edgeverts[2][0] += mins[0] - mid[0]; + start_edgeverts[2][1] += mins[1] - mid[1]; + start_edgeverts[3][0] += mins[0] - mid[0]; + start_edgeverts[3][1] += maxs[1] - mid[1]; + // + start_plane.dist = start_edgeverts[0][2]; + VectorSet(start_plane.normal, 0, 0, 1); + // + for (i = 0; i < 4; i++) + { + VectorCopy(move_end, end_edgeverts[i]); + end_edgeverts[i][2] += maxs[2] - mid[2]; //+ bbox maxs z + end_edgeverts[i][2] += 24; //+ player origin to ground dist + } //end for + end_edgeverts[0][0] += maxs[0] - mid[0]; + end_edgeverts[0][1] += maxs[1] - mid[1]; + end_edgeverts[1][0] += maxs[0] - mid[0]; + end_edgeverts[1][1] += mins[1] - mid[1]; + end_edgeverts[2][0] += mins[0] - mid[0]; + end_edgeverts[2][1] += mins[1] - mid[1]; + end_edgeverts[3][0] += mins[0] - mid[0]; + end_edgeverts[3][1] += maxs[1] - mid[1]; + // + end_plane.dist = end_edgeverts[0][2]; + VectorSet(end_plane.normal, 0, 0, 1); + // +#ifndef BSPC +#if 0 + for (i = 0; i < 4; i++) + { + AAS_PermanentLine(start_edgeverts[i], start_edgeverts[(i+1)%4], 1); + AAS_PermanentLine(end_edgeverts[i], end_edgeverts[(i+1)%4], 1); + } //end for +#endif +#endif + VectorCopy(move_start, move_start_top); + move_start_top[2] += maxs[2] - mid[2] + 24; //+ bbox maxs z + VectorCopy(move_end, move_end_top); + move_end_top[2] += maxs[2] - mid[2] + 24; //+ bbox maxs z + // + if (!AAS_PointAreaNum(move_start_top)) continue; + if (!AAS_PointAreaNum(move_end_top)) continue; + // + for (i = 0; i < 2; i++) + { + firststartreach = firstendreach = NULL; + // + if (i == 0) + { + firststartreach = AAS_FindFaceReachabilities(start_edgeverts, 4, &start_plane, qtrue); + firstendreach = AAS_FindFaceReachabilities(end_edgeverts, 4, &end_plane, qfalse); + } //end if + else + { + firststartreach = AAS_FindFaceReachabilities(end_edgeverts, 4, &end_plane, qtrue); + firstendreach = AAS_FindFaceReachabilities(start_edgeverts, 4, &start_plane, qfalse); + } //end else + // + //create reachabilities from start to end + for (startreach = firststartreach; startreach; startreach = nextstartreach) + { + nextstartreach = startreach->next; + // + //trace = AAS_TraceClientBBox(startreach->start, move_start_top, PRESENCE_NORMAL, -1); + //if (trace.fraction < 1) continue; + // + for (endreach = firstendreach; endreach; endreach = nextendreach) + { + nextendreach = endreach->next; + // + //trace = AAS_TraceClientBBox(endreach->end, move_end_top, PRESENCE_NORMAL, -1); + //if (trace.fraction < 1) continue; + // + Log_Write("funcbob reach from area %d to %d\n", startreach->areanum, endreach->areanum); + // + // + if (i == 0) VectorCopy(move_start_top, org); + else VectorCopy(move_end_top, org); + VectorSubtract(startreach->start, org, dir); + dir[2] = 0; + VectorNormalize(dir); + VectorCopy(startreach->start, start); + VectorMA(startreach->start, 1, dir, start); + start[2] += 1; + VectorMA(startreach->start, 16, dir, end); + end[2] += 1; + // + numareas = AAS_TraceAreas(start, end, areas, points, 10); + if (numareas <= 0) continue; + if (numareas > 1) VectorCopy(points[1], startreach->start); + else VectorCopy(end, startreach->start); + // + if (!AAS_PointAreaNum(startreach->start)) continue; + if (!AAS_PointAreaNum(endreach->end)) continue; + // + lreach = AAS_AllocReachability(); + lreach->areanum = endreach->areanum; + if (i == 0) lreach->edgenum = ((int)move_start[axis] << 16) | ((int) move_end[axis] & 0x0000ffff); + else lreach->edgenum = ((int)move_end[axis] << 16) | ((int) move_start[axis] & 0x0000ffff); + lreach->facenum = (spawnflags << 16) | modelnum; + VectorCopy(startreach->start, lreach->start); + VectorCopy(endreach->end, lreach->end); +#ifndef BSPC +// AAS_DrawArrow(lreach->start, lreach->end, LINECOLOR_BLUE, LINECOLOR_YELLOW); +// AAS_PermanentLine(lreach->start, lreach->end, 1); +#endif + lreach->traveltype = TRAVEL_FUNCBOB; + lreach->traveltype |= AAS_TravelFlagsForTeam(ent); + lreach->traveltime = aassettings.rs_funcbob; + reach_funcbob++; + lreach->next = areareachability[startreach->areanum]; + areareachability[startreach->areanum] = lreach; + // + } //end for + } //end for + for (startreach = firststartreach; startreach; startreach = nextstartreach) + { + nextstartreach = startreach->next; + AAS_FreeReachability(startreach); + } //end for + for (endreach = firstendreach; endreach; endreach = nextendreach) + { + nextendreach = endreach->next; + AAS_FreeReachability(endreach); + } //end for + //only go up with func_bobbing entities that go up and down + if (!(spawnflags & 1) && !(spawnflags & 2)) break; + } //end for + } //end for +} //end of the function AAS_Reachability_FuncBobbing +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_Reachability_JumpPad(void) +{ + int face2num, i, ret, area2num, visualize, ent, bot_visualizejumppads; + //int modelnum, ent2; + //float dist, time, height, gravity, forward; + float speed, zvel, hordist; + aas_face_t *face2; + aas_area_t *area2; + aas_lreachability_t *lreach; + vec3_t areastart, facecenter, dir, cmdmove; + vec3_t velocity, absmins, absmaxs; + //vec3_t origin, ent2origin, angles, teststart; + aas_clientmove_t move; + //aas_trace_t trace; + aas_link_t *areas, *link; + //char target[MAX_EPAIRKEY], targetname[MAX_EPAIRKEY], model[MAX_EPAIRKEY]; + char classname[MAX_EPAIRKEY]; + +#ifdef BSPC + bot_visualizejumppads = 0; +#else + bot_visualizejumppads = LibVarValue("bot_visualizejumppads", "0"); +#endif + 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; + /* + // + AAS_FloatForBSPEpairKey(ent, "speed", &speed); + if (!speed) speed = 1000; +// AAS_VectorForBSPEpairKey(ent, "angles", angles); +// AAS_SetMovedir(angles, velocity); +// VectorScale(velocity, speed, velocity); + 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); + // +#ifdef REACH_DEBUG + botimport.Print(PRT_MESSAGE, "absmins = %f %f %f\n", absmins[0], absmins[1], absmins[2]); + botimport.Print(PRT_MESSAGE, "absmaxs = %f %f %f\n", absmaxs[0], absmaxs[1], absmaxs[2]); +#endif REACH_DEBUG + 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); + continue; + } //end if + AAS_VectorForBSPEpairKey(ent2, "origin", ent2origin); + // + height = ent2origin[2] - origin[2]; + gravity = aassettings.sv_gravity; + time = sqrt( height / ( 0.5 * gravity ) ); + if (!time) + { + botimport.Print(PRT_MESSAGE, "trigger_push without time\n"); + continue; + } //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.1; + VectorScale(velocity, forward, velocity); + velocity[2] = time * gravity; + */ + //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 (link->areanum == 563) + { + ret = qfalse; + } + } + */ + 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]); + //if there is a horizontal velocity check for a reachability without air control + if (velocity[0] || velocity[1]) + { + VectorSet(cmdmove, 0, 0, 0); + //VectorCopy(velocity, cmdmove); + //cmdmove[2] = 0; + Com_Memset(&move, 0, sizeof(aas_clientmove_t)); + area2num = 0; + for (i = 0; i < 20; i++) + { + AAS_PredictClientMovement(&move, -1, areastart, PRESENCE_NORMAL, qfalse, + velocity, cmdmove, 0, 30, 0.1f, + SE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME| + SE_ENTERLAVA|SE_HITGROUNDDAMAGE|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER, 0, bot_visualizejumppads); + area2num = move.endarea; + for (link = areas; link; link = link->next_area) + { + if (!AAS_AreaJumpPad(link->areanum)) continue; + if (link->areanum == area2num) break; + } //end if + if (!link) break; + VectorCopy(move.endpos, areastart); + VectorCopy(move.velocity, velocity); + } //end for + if (area2num && i < 20) + { + for (link = areas; link; link = link->next_area) + { + if (!AAS_AreaJumpPad(link->areanum)) continue; + if (AAS_ReachabilityExists(link->areanum, area2num)) continue; + //create a rocket or bfg jump reachability from area1 to area2 + lreach = AAS_AllocReachability(); + if (!lreach) + { + AAS_UnlinkFromAreas(areas); + return; + } //end if + lreach->areanum = area2num; + //NOTE: the facenum is the Z velocity + lreach->facenum = velocity[2]; + //NOTE: the edgenum is the horizontal velocity + lreach->edgenum = sqrt(velocity[0] * velocity[0] + velocity[1] * velocity[1]); + VectorCopy(areastart, lreach->start); + VectorCopy(move.endpos, lreach->end); + lreach->traveltype = TRAVEL_JUMPPAD; + lreach->traveltype |= AAS_TravelFlagsForTeam(ent); + lreach->traveltime = aassettings.rs_jumppad; + lreach->next = areareachability[link->areanum]; + areareachability[link->areanum] = lreach; + // + reach_jumppad++; + } //end for + } //end if + } //end if + // + if (fabs(velocity[0]) > 100 || fabs(velocity[1]) > 100) continue; + //check for areas we can reach with air control + for (area2num = 1; area2num < aasworld.numareas; area2num++) + { + visualize = qfalse; + /* + if (area2num == 3568) + { + for (link = areas; link; link = link->next_area) + { + if (link->areanum == 3380) + { + visualize = qtrue; + botimport.Print(PRT_MESSAGE, "bah\n"); + } //end if + } //end for + } //end if*/ + //never try to go back to one of the original jumppad areas + //and don't create reachabilities if they already exist + for (link = areas; link; link = link->next_area) + { + if (AAS_ReachabilityExists(link->areanum, area2num)) break; + if (AAS_AreaJumpPad(link->areanum)) + { + if (link->areanum == area2num) break; + } //end if + } //end if + if (link) continue; + // + area2 = &aasworld.areas[area2num]; + for (i = 0; i < area2->numfaces; i++) + { + face2num = aasworld.faceindex[area2->firstface + i]; + face2 = &aasworld.faces[abs(face2num)]; + //if it is not a ground face + if (!(face2->faceflags & FACE_GROUND)) continue; + //get the center of the face + AAS_FaceCenter(face2num, facecenter); + //only go higher up + if (facecenter[2] < areastart[2]) continue; + //get the jumppad jump z velocity + zvel = velocity[2]; + //get the horizontal speed for the jump, if it isn't possible to calculate this + //speed + ret = AAS_HorizontalVelocityForJump(zvel, areastart, facecenter, &speed); + if (ret && speed < 150) + { + //direction towards the face center + VectorSubtract(facecenter, areastart, dir); + dir[2] = 0; + hordist = VectorNormalize(dir); + //if (hordist < 1.6 * facecenter[2] - areastart[2]) + { + //get command movement + VectorScale(dir, speed, cmdmove); + // + AAS_PredictClientMovement(&move, -1, areastart, PRESENCE_NORMAL, qfalse, + velocity, cmdmove, 30, 30, 0.1f, + SE_ENTERWATER|SE_ENTERSLIME| + SE_ENTERLAVA|SE_HITGROUNDDAMAGE| + SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER|SE_HITGROUNDAREA, area2num, visualize); + //if prediction time wasn't enough to fully predict the movement + //don't enter slime or lava and don't fall from too high + if (move.frames < 30 && + !(move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE)) + && (move.stopevent & (SE_HITGROUNDAREA|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER))) + { + //never go back to the same jumppad + for (link = areas; link; link = link->next_area) + { + if (link->areanum == move.endarea) break; + } + if (!link) + { + for (link = areas; link; link = link->next_area) + { + if (!AAS_AreaJumpPad(link->areanum)) continue; + if (AAS_ReachabilityExists(link->areanum, area2num)) continue; + //create a jumppad reachability from area1 to area2 + lreach = AAS_AllocReachability(); + if (!lreach) + { + AAS_UnlinkFromAreas(areas); + return; + } //end if + lreach->areanum = move.endarea; + //NOTE: the facenum is the Z velocity + lreach->facenum = velocity[2]; + //NOTE: the edgenum is the horizontal velocity + lreach->edgenum = sqrt(cmdmove[0] * cmdmove[0] + cmdmove[1] * cmdmove[1]); + VectorCopy(areastart, lreach->start); + VectorCopy(facecenter, lreach->end); + lreach->traveltype = TRAVEL_JUMPPAD; + lreach->traveltype |= AAS_TravelFlagsForTeam(ent); + lreach->traveltime = aassettings.rs_aircontrolledjumppad; + lreach->next = areareachability[link->areanum]; + areareachability[link->areanum] = lreach; + // + reach_jumppad++; + } //end for + } + } //end if + } //end if + } //end for + } //end for + } //end for + AAS_UnlinkFromAreas(areas); + } //end for +} //end of the function AAS_Reachability_JumpPad +//=========================================================================== +// never point at ground faces +// always a higher and pretty far area +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_Reachability_Grapple(int area1num, int area2num) +{ + int face2num, i, j, areanum, numareas, areas[20]; + float mingrappleangle, z, hordist; + bsp_trace_t bsptrace; + aas_trace_t trace; + aas_face_t *face2; + aas_area_t *area1, *area2; + aas_lreachability_t *lreach; + vec3_t areastart, facecenter, start, end, dir, down = {0, 0, -1}; + vec_t *v; + + //only grapple when on the ground or swimming + if (!AAS_AreaGrounded(area1num) && !AAS_AreaSwim(area1num)) return qfalse; + //don't grapple from a crouch area + if (!(AAS_AreaPresenceType(area1num) & PRESENCE_NORMAL)) return qfalse; + //NOTE: disabled area swim it doesn't work right + if (AAS_AreaSwim(area1num)) return qfalse; + // + area1 = &aasworld.areas[area1num]; + area2 = &aasworld.areas[area2num]; + //don't grapple towards way lower areas + if (area2->maxs[2] < area1->mins[2]) return qfalse; + // + VectorCopy(aasworld.areas[area1num].center, start); + //if not a swim area + if (!AAS_AreaSwim(area1num)) + { + if (!AAS_PointAreaNum(start)) Log_Write("area %d center %f %f %f in solid?\r\n", area1num, + start[0], start[1], start[2]); + VectorCopy(start, end); + end[2] -= 1000; + trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1); + if (trace.startsolid) return qfalse; + VectorCopy(trace.endpos, areastart); + } //end if + else + { + if (!(AAS_PointContents(start) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER))) return qfalse; + } //end else + // + //start is now the start point + // + for (i = 0; i < area2->numfaces; i++) + { + face2num = aasworld.faceindex[area2->firstface + i]; + face2 = &aasworld.faces[abs(face2num)]; + //if it is not a solid face + if (!(face2->faceflags & FACE_SOLID)) continue; + //direction towards the first vertex of the face + v = aasworld.vertexes[aasworld.edges[abs(aasworld.edgeindex[face2->firstedge])].v[0]]; + VectorSubtract(v, areastart, dir); + //if the face plane is facing away + if (DotProduct(aasworld.planes[face2->planenum].normal, dir) > 0) continue; + //get the center of the face + AAS_FaceCenter(face2num, facecenter); + //only go higher up with the grapple + if (facecenter[2] < areastart[2] + 64) continue; + //only use vertical faces or downward facing faces + if (DotProduct(aasworld.planes[face2->planenum].normal, down) < 0) continue; + //direction towards the face center + VectorSubtract(facecenter, areastart, dir); + // + z = dir[2]; + dir[2] = 0; + hordist = VectorLength(dir); + if (!hordist) continue; + //if too far + if (hordist > 2000) continue; + //check the minimal angle of the movement + mingrappleangle = 15; //15 degrees + if (z / hordist < tan(2 * M_PI * mingrappleangle / 360)) continue; + // + VectorCopy(facecenter, start); + VectorMA(facecenter, -500, aasworld.planes[face2->planenum].normal, end); + // + bsptrace = AAS_Trace(start, NULL, NULL, end, 0, CONTENTS_SOLID); + //the grapple won't stick to the sky and the grapple point should be near the AAS wall + if ((bsptrace.surface.flags & SURF_SKY) || (bsptrace.fraction * 500 > 32)) continue; + //trace a full bounding box from the area center on the ground to + //the center of the face + VectorSubtract(facecenter, areastart, dir); + VectorNormalize(dir); + VectorMA(areastart, 4, dir, start); + VectorCopy(bsptrace.endpos, end); + trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1); + VectorSubtract(trace.endpos, facecenter, dir); + if (VectorLength(dir) > 24) continue; + // + VectorCopy(trace.endpos, start); + VectorCopy(trace.endpos, end); + end[2] -= AAS_FallDamageDistance(); + trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1); + if (trace.fraction >= 1) continue; + //area to end in + areanum = AAS_PointAreaNum(trace.endpos); + //if not in lava or slime + if (aasworld.areasettings[areanum].contents & (AREACONTENTS_SLIME|AREACONTENTS_LAVA)) + { + continue; + } //end if + //do not go the the source area + if (areanum == area1num) continue; + //don't create reachabilities if they already exist + if (AAS_ReachabilityExists(area1num, areanum)) continue; + //only end in areas we can stand + if (!AAS_AreaGrounded(areanum)) continue; + //never go through cluster portals!! + numareas = AAS_TraceAreas(areastart, bsptrace.endpos, areas, NULL, 20); + if (numareas >= 20) continue; + for (j = 0; j < numareas; j++) + { + if (aasworld.areasettings[areas[j]].contents & AREACONTENTS_CLUSTERPORTAL) break; + } //end for + if (j < numareas) continue; + //create a new reachability link + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = areanum; + lreach->facenum = face2num; + lreach->edgenum = 0; + VectorCopy(areastart, lreach->start); + //VectorCopy(facecenter, lreach->end); + VectorCopy(bsptrace.endpos, lreach->end); + lreach->traveltype = TRAVEL_GRAPPLEHOOK; + VectorSubtract(lreach->end, lreach->start, dir); + lreach->traveltime = aassettings.rs_startgrapple + VectorLength(dir) * 0.25; + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + // + reach_grapple++; + } //end for + // + return qfalse; +} //end of the function AAS_Reachability_Grapple +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_SetWeaponJumpAreaFlags(void) +{ + int ent, i; + vec3_t mins = {-15, -15, -15}, maxs = {15, 15, 15}; + vec3_t origin; + int areanum, weaponjumpareas, spawnflags; + char classname[MAX_EPAIRKEY]; + + weaponjumpareas = 0; + for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) + { + if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; + if ( + !strcmp(classname, "item_armor_body") || + !strcmp(classname, "item_armor_combat") || + !strcmp(classname, "item_health_mega") || + !strcmp(classname, "weapon_grenadelauncher") || + !strcmp(classname, "weapon_rocketlauncher") || + !strcmp(classname, "weapon_lightning") || + !strcmp(classname, "weapon_plasmagun") || + !strcmp(classname, "weapon_railgun") || + !strcmp(classname, "weapon_bfg") || + !strcmp(classname, "item_quad") || + !strcmp(classname, "item_regen") || + !strcmp(classname, "item_invulnerability")) + { + if (AAS_VectorForBSPEpairKey(ent, "origin", origin)) + { + spawnflags = 0; + AAS_IntForBSPEpairKey(ent, "spawnflags", &spawnflags); + //if not a stationary item + if (!(spawnflags & 1)) + { + if (!AAS_DropToFloor(origin, mins, maxs)) + { + botimport.Print(PRT_MESSAGE, "%s in solid at (%1.1f %1.1f %1.1f)\n", + classname, origin[0], origin[1], origin[2]); + } //end if + } //end if + //areanum = AAS_PointAreaNum(origin); + areanum = AAS_BestReachableArea(origin, mins, maxs, origin); + //the bot may rocket jump towards this area + aasworld.areasettings[areanum].areaflags |= AREA_WEAPONJUMP; + // + //if (!AAS_AreaGrounded(areanum)) + // botimport.Print(PRT_MESSAGE, "area not grounded\n"); + // + weaponjumpareas++; + } //end if + } //end if + } //end for + for (i = 1; i < aasworld.numareas; i++) + { + if (aasworld.areasettings[i].contents & AREACONTENTS_JUMPPAD) + { + aasworld.areasettings[i].areaflags |= AREA_WEAPONJUMP; + weaponjumpareas++; + } //end if + } //end for + botimport.Print(PRT_MESSAGE, "%d weapon jump areas\n", weaponjumpareas); +} //end of the function AAS_SetWeaponJumpAreaFlags +//=========================================================================== +// create a possible weapon jump reachability from area1 to area2 +// +// check if there's a cool item in the second area +// check if area1 is lower than area2 +// check if the bot can rocketjump from area1 to area2 +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_Reachability_WeaponJump(int area1num, int area2num) +{ + int face2num, i, n, ret, visualize; + float speed, zvel, hordist; + aas_face_t *face2; + aas_area_t *area1, *area2; + aas_lreachability_t *lreach; + vec3_t areastart, facecenter, start, end, dir, cmdmove;// teststart; + vec3_t velocity; + aas_clientmove_t move; + aas_trace_t trace; + + visualize = qfalse; +// if (area1num == 4436 && area2num == 4318) +// { +// visualize = qtrue; +// } + if (!AAS_AreaGrounded(area1num) || AAS_AreaSwim(area1num)) return qfalse; + if (!AAS_AreaGrounded(area2num)) return qfalse; + //NOTE: only weapon jump towards areas with an interesting item in it?? + if (!(aasworld.areasettings[area2num].areaflags & AREA_WEAPONJUMP)) return qfalse; + // + area1 = &aasworld.areas[area1num]; + area2 = &aasworld.areas[area2num]; + //don't weapon jump towards way lower areas + if (area2->maxs[2] < area1->mins[2]) return qfalse; + // + VectorCopy(aasworld.areas[area1num].center, start); + //if not a swim area + if (!AAS_PointAreaNum(start)) Log_Write("area %d center %f %f %f in solid?\r\n", area1num, + start[0], start[1], start[2]); + VectorCopy(start, end); + end[2] -= 1000; + trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1); + if (trace.startsolid) return qfalse; + VectorCopy(trace.endpos, areastart); + // + //areastart is now the start point + // + for (i = 0; i < area2->numfaces; i++) + { + face2num = aasworld.faceindex[area2->firstface + i]; + face2 = &aasworld.faces[abs(face2num)]; + //if it is not a solid face + if (!(face2->faceflags & FACE_GROUND)) continue; + //get the center of the face + AAS_FaceCenter(face2num, facecenter); + //only go higher up with weapon jumps + if (facecenter[2] < areastart[2] + 64) continue; + //NOTE: set to 2 to allow bfg jump reachabilities + for (n = 0; n < 1/*2*/; n++) + { + //get the rocket jump z velocity + if (n) zvel = AAS_BFGJumpZVelocity(areastart); + else zvel = AAS_RocketJumpZVelocity(areastart); + //get the horizontal speed for the jump, if it isn't possible to calculate this + //speed (the jump is not possible) then there's no jump reachability created + ret = AAS_HorizontalVelocityForJump(zvel, areastart, facecenter, &speed); + if (ret && speed < 300) + { + //direction towards the face center + VectorSubtract(facecenter, areastart, dir); + dir[2] = 0; + hordist = VectorNormalize(dir); + //if (hordist < 1.6 * (facecenter[2] - areastart[2])) + { + //get command movement + VectorScale(dir, speed, cmdmove); + VectorSet(velocity, 0, 0, zvel); + /* + //get command movement + VectorScale(dir, speed, velocity); + velocity[2] = zvel; + VectorSet(cmdmove, 0, 0, 0); + */ + // + AAS_PredictClientMovement(&move, -1, areastart, PRESENCE_NORMAL, qtrue, + velocity, cmdmove, 30, 30, 0.1f, + SE_ENTERWATER|SE_ENTERSLIME| + SE_ENTERLAVA|SE_HITGROUNDDAMAGE| + SE_TOUCHJUMPPAD|SE_HITGROUND|SE_HITGROUNDAREA, area2num, visualize); + //if prediction time wasn't enough to fully predict the movement + //don't enter slime or lava and don't fall from too high + if (move.frames < 30 && + !(move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE)) + && (move.stopevent & (SE_HITGROUNDAREA|SE_TOUCHJUMPPAD))) + { + //create a rocket or bfg jump reachability from area1 to area2 + lreach = AAS_AllocReachability(); + if (!lreach) return qfalse; + lreach->areanum = area2num; + lreach->facenum = 0; + lreach->edgenum = 0; + VectorCopy(areastart, lreach->start); + VectorCopy(facecenter, lreach->end); + if (n) + { + lreach->traveltype = TRAVEL_BFGJUMP; + lreach->traveltime = aassettings.rs_bfgjump; + } //end if + else + { + lreach->traveltype = TRAVEL_ROCKETJUMP; + lreach->traveltime = aassettings.rs_rocketjump; + } //end else + lreach->next = areareachability[area1num]; + areareachability[area1num] = lreach; + // + reach_rocketjump++; + return qtrue; + } //end if + } //end if + } //end if + } //end for + } //end for + // + return qfalse; +} //end of the function AAS_Reachability_WeaponJump +//=========================================================================== +// calculates additional walk off ledge reachabilities for the given area +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_Reachability_WalkOffLedge(int areanum) +{ + int i, j, k, l, m, n, p, areas[10], numareas; + int face1num, face2num, face3num, edge1num, edge2num, edge3num; + int otherareanum, gap, reachareanum, side; + aas_area_t *area, *area2; + aas_face_t *face1, *face2, *face3; + aas_edge_t *edge; + aas_plane_t *plane; + vec_t *v1, *v2; + vec3_t sharededgevec, mid, dir, testend; + aas_lreachability_t *lreach; + aas_trace_t trace; + + if (!AAS_AreaGrounded(areanum) || AAS_AreaSwim(areanum)) return; + // + area = &aasworld.areas[areanum]; + // + for (i = 0; i < area->numfaces; i++) + { + face1num = aasworld.faceindex[area->firstface + i]; + face1 = &aasworld.faces[abs(face1num)]; + //face 1 must be a ground face + if (!(face1->faceflags & FACE_GROUND)) continue; + //go through all the edges of this ground face + for (k = 0; k < face1->numedges; k++) + { + edge1num = aasworld.edgeindex[face1->firstedge + k]; + //find another not ground face using this same edge + for (j = 0; j < area->numfaces; j++) + { + face2num = aasworld.faceindex[area->firstface + j]; + face2 = &aasworld.faces[abs(face2num)]; + //face 2 may not be a ground face + if (face2->faceflags & FACE_GROUND) continue; + //compare all the edges + for (l = 0; l < face2->numedges; l++) + { + edge2num = aasworld.edgeindex[face2->firstedge + l]; + if (abs(edge1num) == abs(edge2num)) + { + //get the area at the other side of the face + if (face2->frontarea == areanum) otherareanum = face2->backarea; + else otherareanum = face2->frontarea; + // + area2 = &aasworld.areas[otherareanum]; + //if the other area is grounded! + if (aasworld.areasettings[otherareanum].areaflags & AREA_GROUNDED) + { + //check for a possible gap + gap = qfalse; + for (n = 0; n < area2->numfaces; n++) + { + face3num = aasworld.faceindex[area2->firstface + n]; + //may not be the shared face of the two areas + if (abs(face3num) == abs(face2num)) continue; + // + face3 = &aasworld.faces[abs(face3num)]; + //find an edge shared by all three faces + for (m = 0; m < face3->numedges; m++) + { + edge3num = aasworld.edgeindex[face3->firstedge + m]; + //but the edge should be shared by all three faces + if (abs(edge3num) == abs(edge1num)) + { + if (!(face3->faceflags & FACE_SOLID)) + { + gap = qtrue; + break; + } //end if + // + if (face3->faceflags & FACE_GROUND) + { + gap = qfalse; + break; + } //end if + //FIXME: there are more situations to be handled + gap = qtrue; + break; + } //end if + } //end for + if (m < face3->numedges) break; + } //end for + if (!gap) break; + } //end if + //check for a walk off ledge reachability + edge = &aasworld.edges[abs(edge1num)]; + side = edge1num < 0; + // + v1 = aasworld.vertexes[edge->v[side]]; + v2 = aasworld.vertexes[edge->v[!side]]; + // + plane = &aasworld.planes[face1->planenum]; + //get the points really into the areas + VectorSubtract(v2, v1, sharededgevec); + CrossProduct(plane->normal, sharededgevec, dir); + VectorNormalize(dir); + // + VectorAdd(v1, v2, mid); + VectorScale(mid, 0.5, mid); + VectorMA(mid, 8, dir, mid); + // + VectorCopy(mid, testend); + testend[2] -= 1000; + trace = AAS_TraceClientBBox(mid, testend, PRESENCE_CROUCH, -1); + // + if (trace.startsolid) + { + //Log_Write("area %d: trace.startsolid\r\n", areanum); + break; + } //end if + reachareanum = AAS_PointAreaNum(trace.endpos); + if (reachareanum == areanum) + { + //Log_Write("area %d: same area\r\n", areanum); + break; + } //end if + if (AAS_ReachabilityExists(areanum, reachareanum)) + { + //Log_Write("area %d: reachability already exists\r\n", areanum); + break; + } //end if + if (!AAS_AreaGrounded(reachareanum) && !AAS_AreaSwim(reachareanum)) + { + //Log_Write("area %d, reach area %d: not grounded and not swim\r\n", areanum, reachareanum); + break; + } //end if + // + if (aasworld.areasettings[reachareanum].contents & (AREACONTENTS_SLIME + | AREACONTENTS_LAVA)) + { + //Log_Write("area %d, reach area %d: lava or slime\r\n", areanum, reachareanum); + break; + } //end if + //if not going through a cluster portal + numareas = AAS_TraceAreas(mid, testend, areas, NULL, sizeof(areas) / sizeof(int)); + for (p = 0; p < numareas; p++) + if (AAS_AreaClusterPortal(areas[p])) + break; + if (p < numareas) + break; + // if a maximum fall height is set and the bot would fall down further + if (aassettings.rs_maxfallheight && fabs(mid[2] - trace.endpos[2]) > aassettings.rs_maxfallheight) + break; + // + lreach = AAS_AllocReachability(); + if (!lreach) break; + lreach->areanum = reachareanum; + lreach->facenum = 0; + lreach->edgenum = edge1num; + VectorCopy(mid, lreach->start); + VectorCopy(trace.endpos, lreach->end); + lreach->traveltype = TRAVEL_WALKOFFLEDGE; + lreach->traveltime = aassettings.rs_startwalkoffledge + fabs(mid[2] - trace.endpos[2]) * 50 / aassettings.phys_gravity; + if (!AAS_AreaSwim(reachareanum) && !AAS_AreaJumpPad(reachareanum)) + { + if (AAS_FallDelta(mid[2] - trace.endpos[2]) > aassettings.phys_falldelta5) + { + lreach->traveltime += aassettings.rs_falldamage5; + } //end if + else if (AAS_FallDelta(mid[2] - trace.endpos[2]) > aassettings.phys_falldelta10) + { + lreach->traveltime += aassettings.rs_falldamage10; + } //end if + } //end if + lreach->next = areareachability[areanum]; + areareachability[areanum] = lreach; + //we've got another walk off ledge reachability + reach_walkoffledge++; + } //end if + } //end for + } //end for + } //end for + } //end for +} //end of the function AAS_Reachability_WalkOffLedge +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_StoreReachability(void) +{ + int i; + aas_areasettings_t *areasettings; + aas_lreachability_t *lreach; + aas_reachability_t *reach; + + if (aasworld.reachability) FreeMemory(aasworld.reachability); + aasworld.reachability = (aas_reachability_t *) GetClearedMemory((numlreachabilities + 10) * sizeof(aas_reachability_t)); + aasworld.reachabilitysize = 1; + for (i = 0; i < aasworld.numareas; i++) + { + areasettings = &aasworld.areasettings[i]; + areasettings->firstreachablearea = aasworld.reachabilitysize; + areasettings->numreachableareas = 0; + for (lreach = areareachability[i]; lreach; lreach = lreach->next) + { + reach = &aasworld.reachability[areasettings->firstreachablearea + + areasettings->numreachableareas]; + reach->areanum = lreach->areanum; + reach->facenum = lreach->facenum; + reach->edgenum = lreach->edgenum; + VectorCopy(lreach->start, reach->start); + VectorCopy(lreach->end, reach->end); + reach->traveltype = lreach->traveltype; + reach->traveltime = lreach->traveltime; + // + areasettings->numreachableareas++; + } //end for + aasworld.reachabilitysize += areasettings->numreachableareas; + } //end for +} //end of the function AAS_StoreReachability +//=========================================================================== +// +// TRAVEL_WALK 100% equal floor height + steps +// TRAVEL_CROUCH 100% +// TRAVEL_BARRIERJUMP 100% +// TRAVEL_JUMP 80% +// TRAVEL_LADDER 100% + fall down from ladder + jump up to ladder +// TRAVEL_WALKOFFLEDGE 90% walk off very steep walls? +// TRAVEL_SWIM 100% +// TRAVEL_WATERJUMP 100% +// TRAVEL_TELEPORT 100% +// TRAVEL_ELEVATOR 100% +// TRAVEL_GRAPPLEHOOK 100% +// TRAVEL_DOUBLEJUMP 0% +// TRAVEL_RAMPJUMP 0% +// TRAVEL_STRAFEJUMP 0% +// TRAVEL_ROCKETJUMP 100% (currently limited towards areas with items) +// TRAVEL_BFGJUMP 0% (currently disabled) +// TRAVEL_JUMPPAD 100% +// TRAVEL_FUNCBOB 100% +// +// Parameter: - +// Returns: true if NOT finished +// Changes Globals: - +//=========================================================================== +int AAS_ContinueInitReachability(float time) +{ + int i, j, todo, start_time; + static float framereachability, reachability_delay; + static int lastpercentage; + + if (!aasworld.loaded) return qfalse; + //if reachability is calculated for all areas + if (aasworld.numreachabilityareas >= aasworld.numareas + 2) return qfalse; + //if starting with area 1 (area 0 is a dummy) + if (aasworld.numreachabilityareas == 1) + { + botimport.Print(PRT_MESSAGE, "calculating reachability...\n"); + lastpercentage = 0; + framereachability = 2000; + reachability_delay = 1000; + } //end if + //number of areas to calculate reachability for this cycle + todo = aasworld.numreachabilityareas + (int) framereachability; + start_time = Sys_MilliSeconds(); + //loop over the areas + for (i = aasworld.numreachabilityareas; i < aasworld.numareas && i < todo; i++) + { + aasworld.numreachabilityareas++; + //only create jumppad reachabilities from jumppad areas + if (aasworld.areasettings[i].contents & AREACONTENTS_JUMPPAD) + { + continue; + } //end if + //loop over the areas + for (j = 1; j < aasworld.numareas; j++) + { + if (i == j) continue; + //never create reachabilities from teleporter or jumppad areas to regular areas + if (aasworld.areasettings[i].contents & (AREACONTENTS_TELEPORTER|AREACONTENTS_JUMPPAD)) + { + if (!(aasworld.areasettings[j].contents & (AREACONTENTS_TELEPORTER|AREACONTENTS_JUMPPAD))) + { + continue; + } //end if + } //end if + //if there already is a reachability link from area i to j + if (AAS_ReachabilityExists(i, j)) continue; + //check for a swim reachability + if (AAS_Reachability_Swim(i, j)) continue; + //check for a simple walk on equal floor height reachability + if (AAS_Reachability_EqualFloorHeight(i, j)) continue; + //check for step, barrier, waterjump and walk off ledge reachabilities + if (AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(i, j)) continue; + //check for ladder reachabilities + if (AAS_Reachability_Ladder(i, j)) continue; + //check for a jump reachability + if (AAS_Reachability_Jump(i, j)) continue; + } //end for + //never create these reachabilities from teleporter or jumppad areas + if (aasworld.areasettings[i].contents & (AREACONTENTS_TELEPORTER|AREACONTENTS_JUMPPAD)) + { + continue; + } //end if + //loop over the areas + for (j = 1; j < aasworld.numareas; j++) + { + if (i == j) continue; + // + if (AAS_ReachabilityExists(i, j)) continue; + //check for a grapple hook reachability + if (calcgrapplereach) AAS_Reachability_Grapple(i, j); + //check for a weapon jump reachability + AAS_Reachability_WeaponJump(i, j); + } //end for + //if the calculation took more time than the max reachability delay + if (Sys_MilliSeconds() - start_time > (int) reachability_delay) break; + // + if (aasworld.numreachabilityareas * 1000 / aasworld.numareas > lastpercentage) break; + } //end for + // + if (aasworld.numreachabilityareas == aasworld.numareas) + { + botimport.Print(PRT_MESSAGE, "\r%6.1f%%", (float) 100.0); + botimport.Print(PRT_MESSAGE, "\nplease wait while storing reachability...\n"); + aasworld.numreachabilityareas++; + } //end if + //if this is the last step in the reachability calculations + else if (aasworld.numreachabilityareas == aasworld.numareas + 1) + { + //create additional walk off ledge reachabilities for every area + for (i = 1; i < aasworld.numareas; i++) + { + //only create jumppad reachabilities from jumppad areas + if (aasworld.areasettings[i].contents & AREACONTENTS_JUMPPAD) + { + continue; + } //end if + AAS_Reachability_WalkOffLedge(i); + } //end for + //create jump pad reachabilities + AAS_Reachability_JumpPad(); + //create teleporter reachabilities + AAS_Reachability_Teleport(); + //create elevator (func_plat) reachabilities + AAS_Reachability_Elevator(); + //create func_bobbing reachabilities + AAS_Reachability_FuncBobbing(); + // +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "%6d reach swim\n", reach_swim); + botimport.Print(PRT_MESSAGE, "%6d reach equal floor\n", reach_equalfloor); + botimport.Print(PRT_MESSAGE, "%6d reach step\n", reach_step); + botimport.Print(PRT_MESSAGE, "%6d reach barrier\n", reach_barrier); + botimport.Print(PRT_MESSAGE, "%6d reach waterjump\n", reach_waterjump); + botimport.Print(PRT_MESSAGE, "%6d reach walkoffledge\n", reach_walkoffledge); + botimport.Print(PRT_MESSAGE, "%6d reach jump\n", reach_jump); + botimport.Print(PRT_MESSAGE, "%6d reach ladder\n", reach_ladder); + botimport.Print(PRT_MESSAGE, "%6d reach walk\n", reach_walk); + botimport.Print(PRT_MESSAGE, "%6d reach teleport\n", reach_teleport); + botimport.Print(PRT_MESSAGE, "%6d reach funcbob\n", reach_funcbob); + botimport.Print(PRT_MESSAGE, "%6d reach elevator\n", reach_elevator); + botimport.Print(PRT_MESSAGE, "%6d reach grapple\n", reach_grapple); + botimport.Print(PRT_MESSAGE, "%6d reach rocketjump\n", reach_rocketjump); + botimport.Print(PRT_MESSAGE, "%6d reach jumppad\n", reach_jumppad); +#endif + //*/ + //store all the reachabilities + AAS_StoreReachability(); + //free the reachability link heap + AAS_ShutDownReachabilityHeap(); + // + FreeMemory(areareachability); + // + aasworld.numreachabilityareas++; + // + botimport.Print(PRT_MESSAGE, "calculating clusters...\n"); + } //end if + else + { + lastpercentage = aasworld.numreachabilityareas * 1000 / aasworld.numareas; + botimport.Print(PRT_MESSAGE, "\r%6.1f%%", (float) lastpercentage / 10); + } //end else + //not yet finished + return qtrue; +} //end of the function AAS_ContinueInitReachability +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitReachability(void) +{ + if (!aasworld.loaded) return; + + if (aasworld.reachabilitysize) + { +#ifndef BSPC + if (!((int)LibVarGetValue("forcereachability"))) + { + aasworld.numreachabilityareas = aasworld.numareas + 2; + return; + } //end if +#else + aasworld.numreachabilityareas = aasworld.numareas + 2; + return; +#endif //BSPC + } //end if +#ifndef BSPC + calcgrapplereach = LibVarGetValue("grapplereach"); +#endif + aasworld.savefile = qtrue; + //start with area 1 because area zero is a dummy + aasworld.numreachabilityareas = 1; + ////aasworld.numreachabilityareas = aasworld.numareas + 1; //only calculate entity reachabilities + //setup the heap with reachability links + AAS_SetupReachabilityHeap(); + //allocate area reachability link array + areareachability = (aas_lreachability_t **) GetClearedMemory( + aasworld.numareas * sizeof(aas_lreachability_t *)); + // + AAS_SetWeaponJumpAreaFlags(); +} //end of the function AAS_InitReachable diff --git a/code/botlib/be_aas_reach.h b/code/botlib/be_aas_reach.h new file mode 100644 index 00000000..0ab8740b --- /dev/null +++ b/code/botlib/be_aas_reach.h @@ -0,0 +1,68 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_aas_reach.h + * + * desc: AAS + * + * $Archive: /source/code/botlib/be_aas_reach.h $ + * + *****************************************************************************/ + +#ifdef AASINTERN +//initialize calculating the reachabilities +void AAS_InitReachability(void); +//continue calculating the reachabilities +int AAS_ContinueInitReachability(float time); +// +int AAS_BestReachableLinkArea(aas_link_t *areas); +#endif //AASINTERN + +//returns true if the are has reachabilities to other areas +int AAS_AreaReachability(int areanum); +//returns the best reachable area and goal origin for a bounding box at the given origin +int AAS_BestReachableArea(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t goalorigin); +//returns the best jumppad area from which the bbox at origin is reachable +int AAS_BestReachableFromJumpPadArea(vec3_t origin, vec3_t mins, vec3_t maxs); +//returns the next reachability using the given model +int AAS_NextModelReachability(int num, int modelnum); +//returns the total area of the ground faces of the given area +float AAS_AreaGroundFaceArea(int areanum); +//returns true if the area is crouch only +int AAS_AreaCrouch(int areanum); +//returns true if a player can swim in this area +int AAS_AreaSwim(int areanum); +//returns true if the area is filled with a liquid +int AAS_AreaLiquid(int areanum); +//returns true if the area contains lava +int AAS_AreaLava(int areanum); +//returns true if the area contains slime +int AAS_AreaSlime(int areanum); +//returns true if the area has one or more ground faces +int AAS_AreaGrounded(int areanum); +//returns true if the area has one or more ladder faces +int AAS_AreaLadder(int areanum); +//returns true if the area is a jump pad +int AAS_AreaJumpPad(int areanum); +//returns true if the area is donotenter +int AAS_AreaDoNotEnter(int areanum); diff --git a/code/botlib/be_aas_route.c b/code/botlib/be_aas_route.c new file mode 100644 index 00000000..3d2f0191 --- /dev/null +++ b/code/botlib/be_aas_route.c @@ -0,0 +1,2210 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_aas_route.c + * + * desc: AAS + * + * $Archive: /MissionPack/code/botlib/be_aas_route.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_utils.h" +#include "l_memory.h" +#include "l_log.h" +#include "l_crc.h" +#include "l_libvar.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "aasfile.h" +#include "botlib.h" +#include "be_aas.h" +#include "be_aas_funcs.h" +#include "be_interface.h" +#include "be_aas_def.h" + +#define ROUTING_DEBUG + +//travel time in hundreths of a second = distance * 100 / speed +#define DISTANCEFACTOR_CROUCH 1.3f //crouch speed = 100 +#define DISTANCEFACTOR_SWIM 1 //should be 0.66, swim speed = 150 +#define DISTANCEFACTOR_WALK 0.33f //walk speed = 300 + +//cache refresh time +#define CACHE_REFRESHTIME 15.0f //15 seconds refresh time + +//maximum number of routing updates each frame +#define MAX_FRAMEROUTINGUPDATES 10 + + +/* + + area routing cache: + stores the distances within one cluster to a specific goal area + this goal area is in this same cluster and could be a cluster portal + for every cluster there's a list with routing cache for every area + in that cluster (including the portals of that cluster) + area cache stores aasworld.clusters[?].numreachabilityareas travel times + + portal routing cache: + stores the distances of all portals to a specific goal area + this goal area could be in any cluster and could also be a cluster portal + for every area (aasworld.numareas) the portal cache stores + aasworld.numportals travel times + +*/ + +#ifdef ROUTING_DEBUG +int numareacacheupdates; +int numportalcacheupdates; +#endif //ROUTING_DEBUG + +int routingcachesize; +int max_routingcachesize; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef ROUTING_DEBUG +void AAS_RoutingInfo(void) +{ + botimport.Print(PRT_MESSAGE, "%d area cache updates\n", numareacacheupdates); + botimport.Print(PRT_MESSAGE, "%d portal cache updates\n", numportalcacheupdates); + botimport.Print(PRT_MESSAGE, "%d bytes routing cache\n", routingcachesize); +} //end of the function AAS_RoutingInfo +#endif //ROUTING_DEBUG +//=========================================================================== +// returns the number of the area in the cluster +// assumes the given area is in the given cluster or a portal of the cluster +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +ID_INLINE int AAS_ClusterAreaNum(int cluster, int areanum) +{ + int side, areacluster; + + areacluster = aasworld.areasettings[areanum].cluster; + if (areacluster > 0) return aasworld.areasettings[areanum].clusterareanum; + else + { +/*#ifdef ROUTING_DEBUG + if (aasworld.portals[-areacluster].frontcluster != cluster && + aasworld.portals[-areacluster].backcluster != cluster) + { + botimport.Print(PRT_ERROR, "portal %d: does not belong to cluster %d\n" + , -areacluster, cluster); + } //end if +#endif //ROUTING_DEBUG*/ + side = aasworld.portals[-areacluster].frontcluster != cluster; + return aasworld.portals[-areacluster].clusterareanum[side]; + } //end else +} //end of the function AAS_ClusterAreaNum +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitTravelFlagFromType(void) +{ + int i; + + for (i = 0; i < MAX_TRAVELTYPES; i++) + { + aasworld.travelflagfortype[i] = TFL_INVALID; + } //end for + aasworld.travelflagfortype[TRAVEL_INVALID] = TFL_INVALID; + aasworld.travelflagfortype[TRAVEL_WALK] = TFL_WALK; + aasworld.travelflagfortype[TRAVEL_CROUCH] = TFL_CROUCH; + aasworld.travelflagfortype[TRAVEL_BARRIERJUMP] = TFL_BARRIERJUMP; + aasworld.travelflagfortype[TRAVEL_JUMP] = TFL_JUMP; + aasworld.travelflagfortype[TRAVEL_LADDER] = TFL_LADDER; + aasworld.travelflagfortype[TRAVEL_WALKOFFLEDGE] = TFL_WALKOFFLEDGE; + aasworld.travelflagfortype[TRAVEL_SWIM] = TFL_SWIM; + aasworld.travelflagfortype[TRAVEL_WATERJUMP] = TFL_WATERJUMP; + aasworld.travelflagfortype[TRAVEL_TELEPORT] = TFL_TELEPORT; + aasworld.travelflagfortype[TRAVEL_ELEVATOR] = TFL_ELEVATOR; + aasworld.travelflagfortype[TRAVEL_ROCKETJUMP] = TFL_ROCKETJUMP; + aasworld.travelflagfortype[TRAVEL_BFGJUMP] = TFL_BFGJUMP; + aasworld.travelflagfortype[TRAVEL_GRAPPLEHOOK] = TFL_GRAPPLEHOOK; + aasworld.travelflagfortype[TRAVEL_DOUBLEJUMP] = TFL_DOUBLEJUMP; + aasworld.travelflagfortype[TRAVEL_RAMPJUMP] = TFL_RAMPJUMP; + aasworld.travelflagfortype[TRAVEL_STRAFEJUMP] = TFL_STRAFEJUMP; + aasworld.travelflagfortype[TRAVEL_JUMPPAD] = TFL_JUMPPAD; + aasworld.travelflagfortype[TRAVEL_FUNCBOB] = TFL_FUNCBOB; +} //end of the function AAS_InitTravelFlagFromType +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +ID_INLINE int AAS_TravelFlagForType_inline(int traveltype) +{ + int tfl; + + tfl = 0; + if (tfl & TRAVELFLAG_NOTTEAM1) + tfl |= TFL_NOTTEAM1; + if (tfl & TRAVELFLAG_NOTTEAM2) + tfl |= TFL_NOTTEAM2; + traveltype &= TRAVELTYPE_MASK; + if (traveltype < 0 || traveltype >= MAX_TRAVELTYPES) + return TFL_INVALID; + tfl |= aasworld.travelflagfortype[traveltype]; + return tfl; +} //end of the function AAS_TravelFlagForType_inline +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_TravelFlagForType(int traveltype) +{ + return AAS_TravelFlagForType_inline(traveltype); +} //end of the function AAS_TravelFlagForType_inline +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_UnlinkCache(aas_routingcache_t *cache) +{ + if (cache->time_next) cache->time_next->time_prev = cache->time_prev; + else aasworld.newestcache = cache->time_prev; + if (cache->time_prev) cache->time_prev->time_next = cache->time_next; + else aasworld.oldestcache = cache->time_next; + cache->time_next = NULL; + cache->time_prev = NULL; +} //end of the function AAS_UnlinkCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_LinkCache(aas_routingcache_t *cache) +{ + if (aasworld.newestcache) + { + aasworld.newestcache->time_next = cache; + cache->time_prev = aasworld.newestcache; + } //end if + else + { + aasworld.oldestcache = cache; + cache->time_prev = NULL; + } //end else + cache->time_next = NULL; + aasworld.newestcache = cache; +} //end of the function AAS_LinkCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeRoutingCache(aas_routingcache_t *cache) +{ + AAS_UnlinkCache(cache); + routingcachesize -= cache->size; + FreeMemory(cache); +} //end of the function AAS_FreeRoutingCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_RemoveRoutingCacheInCluster( int clusternum ) +{ + int i; + aas_routingcache_t *cache, *nextcache; + aas_cluster_t *cluster; + + if (!aasworld.clusterareacache) + return; + cluster = &aasworld.clusters[clusternum]; + for (i = 0; i < cluster->numareas; i++) + { + for (cache = aasworld.clusterareacache[clusternum][i]; cache; cache = nextcache) + { + nextcache = cache->next; + AAS_FreeRoutingCache(cache); + } //end for + aasworld.clusterareacache[clusternum][i] = NULL; + } //end for +} //end of the function AAS_RemoveRoutingCacheInCluster +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_RemoveRoutingCacheUsingArea( int areanum ) +{ + int i, clusternum; + aas_routingcache_t *cache, *nextcache; + + clusternum = aasworld.areasettings[areanum].cluster; + if (clusternum > 0) + { + //remove all the cache in the cluster the area is in + AAS_RemoveRoutingCacheInCluster( clusternum ); + } //end if + else + { + // if this is a portal remove all cache in both the front and back cluster + AAS_RemoveRoutingCacheInCluster( aasworld.portals[-clusternum].frontcluster ); + AAS_RemoveRoutingCacheInCluster( aasworld.portals[-clusternum].backcluster ); + } //end else + // remove all portal cache + for (i = 0; i < aasworld.numareas; i++) + { + //refresh portal cache + for (cache = aasworld.portalcache[i]; cache; cache = nextcache) + { + nextcache = cache->next; + AAS_FreeRoutingCache(cache); + } //end for + aasworld.portalcache[i] = NULL; + } //end for +} //end of the function AAS_RemoveRoutingCacheUsingArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_EnableRoutingArea(int areanum, int enable) +{ + int flags; + + if (areanum <= 0 || areanum >= aasworld.numareas) + { + if (bot_developer) + { + botimport.Print(PRT_ERROR, "AAS_EnableRoutingArea: areanum %d out of range\n", areanum); + } //end if + return 0; + } //end if + flags = aasworld.areasettings[areanum].areaflags & AREA_DISABLED; + if (enable < 0) + return !flags; + + if (enable) + aasworld.areasettings[areanum].areaflags &= ~AREA_DISABLED; + else + aasworld.areasettings[areanum].areaflags |= AREA_DISABLED; + // if the status of the area changed + if ( (flags & AREA_DISABLED) != (aasworld.areasettings[areanum].areaflags & AREA_DISABLED) ) + { + //remove all routing cache involving this area + AAS_RemoveRoutingCacheUsingArea( areanum ); + } //end if + return !flags; +} //end of the function AAS_EnableRoutingArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +ID_INLINE float AAS_RoutingTime(void) +{ + return AAS_Time(); +} //end of the function AAS_RoutingTime +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_GetAreaContentsTravelFlags(int areanum) +{ + int contents, tfl; + + contents = aasworld.areasettings[areanum].contents; + tfl = 0; + if (contents & AREACONTENTS_WATER) + tfl |= TFL_WATER; + else if (contents & AREACONTENTS_SLIME) + tfl |= TFL_SLIME; + else if (contents & AREACONTENTS_LAVA) + tfl |= TFL_LAVA; + else + tfl |= TFL_AIR; + if (contents & AREACONTENTS_DONOTENTER) + tfl |= TFL_DONOTENTER; + if (contents & AREACONTENTS_NOTTEAM1) + tfl |= TFL_NOTTEAM1; + if (contents & AREACONTENTS_NOTTEAM2) + tfl |= TFL_NOTTEAM2; + if (aasworld.areasettings[areanum].areaflags & AREA_BRIDGE) + tfl |= TFL_BRIDGE; + return tfl; +} //end of the function AAS_GetAreaContentsTravelFlags +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +ID_INLINE int AAS_AreaContentsTravelFlags_inline(int areanum) +{ + return aasworld.areacontentstravelflags[areanum]; +} //end of the function AAS_AreaContentsTravelFlags +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_AreaContentsTravelFlags(int areanum) +{ + return aasworld.areacontentstravelflags[areanum]; +} //end of the function AAS_AreaContentsTravelFlags +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitAreaContentsTravelFlags(void) +{ + int i; + + if (aasworld.areacontentstravelflags) FreeMemory(aasworld.areacontentstravelflags); + aasworld.areacontentstravelflags = (int *) GetClearedMemory(aasworld.numareas * sizeof(int)); + // + for (i = 0; i < aasworld.numareas; i++) { + aasworld.areacontentstravelflags[i] = AAS_GetAreaContentsTravelFlags(i); + } +} //end of the function AAS_InitAreaContentsTravelFlags +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CreateReversedReachability(void) +{ + int i, n; + aas_reversedlink_t *revlink; + aas_reachability_t *reach; + aas_areasettings_t *settings; + char *ptr; +#ifdef DEBUG + int starttime; + + starttime = Sys_MilliSeconds(); +#endif + //free reversed links that have already been created + if (aasworld.reversedreachability) FreeMemory(aasworld.reversedreachability); + //allocate memory for the reversed reachability links + ptr = (char *) GetClearedMemory(aasworld.numareas * sizeof(aas_reversedreachability_t) + + aasworld.reachabilitysize * sizeof(aas_reversedlink_t)); + // + aasworld.reversedreachability = (aas_reversedreachability_t *) ptr; + //pointer to the memory for the reversed links + ptr += aasworld.numareas * sizeof(aas_reversedreachability_t); + //check all reachabilities of all areas + for (i = 1; i < aasworld.numareas; i++) + { + //settings of the area + settings = &aasworld.areasettings[i]; + // + if (settings->numreachableareas >= 128) + botimport.Print(PRT_WARNING, "area %d has more than 128 reachabilities\n", i); + //create reversed links for the reachabilities + for (n = 0; n < settings->numreachableareas && n < 128; n++) + { + //reachability link + reach = &aasworld.reachability[settings->firstreachablearea + n]; + // + revlink = (aas_reversedlink_t *) ptr; + ptr += sizeof(aas_reversedlink_t); + // + revlink->areanum = i; + revlink->linknum = settings->firstreachablearea + n; + revlink->next = aasworld.reversedreachability[reach->areanum].first; + aasworld.reversedreachability[reach->areanum].first = revlink; + aasworld.reversedreachability[reach->areanum].numlinks++; + } //end for + } //end for +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "reversed reachability %d msec\n", Sys_MilliSeconds() - starttime); +#endif +} //end of the function AAS_CreateReversedReachability +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +unsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end) +{ + int intdist; + float dist; + vec3_t dir; + + VectorSubtract(start, end, dir); + dist = VectorLength(dir); + //if crouch only area + if (AAS_AreaCrouch(areanum)) dist *= DISTANCEFACTOR_CROUCH; + //if swim area + else if (AAS_AreaSwim(areanum)) dist *= DISTANCEFACTOR_SWIM; + //normal walk area + else dist *= DISTANCEFACTOR_WALK; + // + intdist = (int) dist; + //make sure the distance isn't zero + if (intdist <= 0) intdist = 1; + return intdist; +} //end of the function AAS_AreaTravelTime +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CalculateAreaTravelTimes(void) +{ + int i, l, n, size; + char *ptr; + vec3_t end; + aas_reversedreachability_t *revreach; + aas_reversedlink_t *revlink; + aas_reachability_t *reach; + aas_areasettings_t *settings; + int starttime; + + starttime = Sys_MilliSeconds(); + //if there are still area travel times, free the memory + if (aasworld.areatraveltimes) FreeMemory(aasworld.areatraveltimes); + //get the total size of all the area travel times + size = aasworld.numareas * sizeof(unsigned short **); + for (i = 0; i < aasworld.numareas; i++) + { + revreach = &aasworld.reversedreachability[i]; + //settings of the area + settings = &aasworld.areasettings[i]; + // + size += settings->numreachableareas * sizeof(unsigned short *); + // + size += settings->numreachableareas * + PAD(revreach->numlinks, sizeof(long)) * sizeof(unsigned short); + } //end for + //allocate memory for the area travel times + ptr = (char *) GetClearedMemory(size); + aasworld.areatraveltimes = (unsigned short ***) ptr; + ptr += aasworld.numareas * sizeof(unsigned short **); + //calcluate the travel times for all the areas + for (i = 0; i < aasworld.numareas; i++) + { + //reversed reachabilities of this area + revreach = &aasworld.reversedreachability[i]; + //settings of the area + settings = &aasworld.areasettings[i]; + // + aasworld.areatraveltimes[i] = (unsigned short **) ptr; + ptr += settings->numreachableareas * sizeof(unsigned short *); + // + for (l = 0; l < settings->numreachableareas; l++) + { + aasworld.areatraveltimes[i][l] = (unsigned short *) ptr; + ptr += PAD(revreach->numlinks, sizeof(long)) * sizeof(unsigned short); + //reachability link + reach = &aasworld.reachability[settings->firstreachablearea + l]; + // + for (n = 0, revlink = revreach->first; revlink; revlink = revlink->next, n++) + { + VectorCopy(aasworld.reachability[revlink->linknum].end, end); + // + aasworld.areatraveltimes[i][l][n] = AAS_AreaTravelTime(i, end, reach->start); + } //end for + } //end for + } //end for +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "area travel times %d msec\n", Sys_MilliSeconds() - starttime); +#endif +} //end of the function AAS_CalculateAreaTravelTimes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_PortalMaxTravelTime(int portalnum) +{ + int l, n, t, maxt; + aas_portal_t *portal; + aas_reversedreachability_t *revreach; + aas_reversedlink_t *revlink; + aas_areasettings_t *settings; + + portal = &aasworld.portals[portalnum]; + //reversed reachabilities of this portal area + revreach = &aasworld.reversedreachability[portal->areanum]; + //settings of the portal area + settings = &aasworld.areasettings[portal->areanum]; + // + maxt = 0; + for (l = 0; l < settings->numreachableareas; l++) + { + for (n = 0, revlink = revreach->first; revlink; revlink = revlink->next, n++) + { + t = aasworld.areatraveltimes[portal->areanum][l][n]; + if (t > maxt) + { + maxt = t; + } //end if + } //end for + } //end for + return maxt; +} //end of the function AAS_PortalMaxTravelTime +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitPortalMaxTravelTimes(void) +{ + int i; + + if (aasworld.portalmaxtraveltimes) FreeMemory(aasworld.portalmaxtraveltimes); + + aasworld.portalmaxtraveltimes = (int *) GetClearedMemory(aasworld.numportals * sizeof(int)); + + for (i = 0; i < aasworld.numportals; i++) + { + aasworld.portalmaxtraveltimes[i] = AAS_PortalMaxTravelTime(i); + //botimport.Print(PRT_MESSAGE, "portal %d max tt = %d\n", i, aasworld.portalmaxtraveltimes[i]); + } //end for +} //end of the function AAS_InitPortalMaxTravelTimes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +/* +int AAS_FreeOldestCache(void) +{ + int i, j, bestcluster, bestarea, freed; + float besttime; + aas_routingcache_t *cache, *bestcache; + + freed = qfalse; + besttime = 999999999; + bestcache = NULL; + bestcluster = 0; + bestarea = 0; + //refresh cluster cache + for (i = 0; i < aasworld.numclusters; i++) + { + for (j = 0; j < aasworld.clusters[i].numareas; j++) + { + for (cache = aasworld.clusterareacache[i][j]; cache; cache = cache->next) + { + //never remove cache leading towards a portal + if (aasworld.areasettings[cache->areanum].cluster < 0) continue; + //if this cache is older than the cache we found so far + if (cache->time < besttime) + { + bestcache = cache; + bestcluster = i; + bestarea = j; + besttime = cache->time; + } //end if + } //end for + } //end for + } //end for + if (bestcache) + { + cache = bestcache; + if (cache->prev) cache->prev->next = cache->next; + else aasworld.clusterareacache[bestcluster][bestarea] = cache->next; + if (cache->next) cache->next->prev = cache->prev; + AAS_FreeRoutingCache(cache); + freed = qtrue; + } //end if + besttime = 999999999; + bestcache = NULL; + bestarea = 0; + for (i = 0; i < aasworld.numareas; i++) + { + //refresh portal cache + for (cache = aasworld.portalcache[i]; cache; cache = cache->next) + { + if (cache->time < besttime) + { + bestcache = cache; + bestarea = i; + besttime = cache->time; + } //end if + } //end for + } //end for + if (bestcache) + { + cache = bestcache; + if (cache->prev) cache->prev->next = cache->next; + else aasworld.portalcache[bestarea] = cache->next; + if (cache->next) cache->next->prev = cache->prev; + AAS_FreeRoutingCache(cache); + freed = qtrue; + } //end if + return freed; +} //end of the function AAS_FreeOldestCache +*/ +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_FreeOldestCache(void) +{ + int clusterareanum; + aas_routingcache_t *cache; + + for (cache = aasworld.oldestcache; cache; cache = cache->time_next) { + // never free area cache leading towards a portal + if (cache->type == CACHETYPE_AREA && aasworld.areasettings[cache->areanum].cluster < 0) { + continue; + } + break; + } + if (cache) { + // unlink the cache + if (cache->type == CACHETYPE_AREA) { + //number of the area in the cluster + clusterareanum = AAS_ClusterAreaNum(cache->cluster, cache->areanum); + // unlink from cluster area cache + if (cache->prev) cache->prev->next = cache->next; + else aasworld.clusterareacache[cache->cluster][clusterareanum] = cache->next; + if (cache->next) cache->next->prev = cache->prev; + } + else { + // unlink from portal cache + if (cache->prev) cache->prev->next = cache->next; + else aasworld.portalcache[cache->areanum] = cache->next; + if (cache->next) cache->next->prev = cache->prev; + } + AAS_FreeRoutingCache(cache); + return qtrue; + } + return qfalse; +} //end of the function AAS_FreeOldestCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_routingcache_t *AAS_AllocRoutingCache(int numtraveltimes) +{ + aas_routingcache_t *cache; + int size; + + // + size = sizeof(aas_routingcache_t) + + numtraveltimes * sizeof(unsigned short int) + + numtraveltimes * sizeof(unsigned char); + // + routingcachesize += size; + // + cache = (aas_routingcache_t *) GetClearedMemory(size); + cache->reachabilities = (unsigned char *) cache + sizeof(aas_routingcache_t) + + numtraveltimes * sizeof(unsigned short int); + cache->size = size; + return cache; +} //end of the function AAS_AllocRoutingCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeAllClusterAreaCache(void) +{ + int i, j; + aas_routingcache_t *cache, *nextcache; + aas_cluster_t *cluster; + + //free all cluster cache if existing + if (!aasworld.clusterareacache) return; + //free caches + for (i = 0; i < aasworld.numclusters; i++) + { + cluster = &aasworld.clusters[i]; + for (j = 0; j < cluster->numareas; j++) + { + for (cache = aasworld.clusterareacache[i][j]; cache; cache = nextcache) + { + nextcache = cache->next; + AAS_FreeRoutingCache(cache); + } //end for + aasworld.clusterareacache[i][j] = NULL; + } //end for + } //end for + //free the cluster cache array + FreeMemory(aasworld.clusterareacache); + aasworld.clusterareacache = NULL; +} //end of the function AAS_FreeAllClusterAreaCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitClusterAreaCache(void) +{ + int i, size; + char *ptr; + + // + for (size = 0, i = 0; i < aasworld.numclusters; i++) + { + size += aasworld.clusters[i].numareas; + } //end for + //two dimensional array with pointers for every cluster to routing cache + //for every area in that cluster + ptr = (char *) GetClearedMemory( + aasworld.numclusters * sizeof(aas_routingcache_t **) + + size * sizeof(aas_routingcache_t *)); + aasworld.clusterareacache = (aas_routingcache_t ***) ptr; + ptr += aasworld.numclusters * sizeof(aas_routingcache_t **); + for (i = 0; i < aasworld.numclusters; i++) + { + aasworld.clusterareacache[i] = (aas_routingcache_t **) ptr; + ptr += aasworld.clusters[i].numareas * sizeof(aas_routingcache_t *); + } //end for +} //end of the function AAS_InitClusterAreaCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeAllPortalCache(void) +{ + int i; + aas_routingcache_t *cache, *nextcache; + + //free all portal cache if existing + if (!aasworld.portalcache) return; + //free portal caches + for (i = 0; i < aasworld.numareas; i++) + { + for (cache = aasworld.portalcache[i]; cache; cache = nextcache) + { + nextcache = cache->next; + AAS_FreeRoutingCache(cache); + } //end for + aasworld.portalcache[i] = NULL; + } //end for + FreeMemory(aasworld.portalcache); + aasworld.portalcache = NULL; +} //end of the function AAS_FreeAllPortalCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitPortalCache(void) +{ + // + aasworld.portalcache = (aas_routingcache_t **) GetClearedMemory( + aasworld.numareas * sizeof(aas_routingcache_t *)); +} //end of the function AAS_InitPortalCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitRoutingUpdate(void) +{ + int i, maxreachabilityareas; + + //free routing update fields if already existing + if (aasworld.areaupdate) FreeMemory(aasworld.areaupdate); + // + maxreachabilityareas = 0; + for (i = 0; i < aasworld.numclusters; i++) + { + if (aasworld.clusters[i].numreachabilityareas > maxreachabilityareas) + { + maxreachabilityareas = aasworld.clusters[i].numreachabilityareas; + } //end if + } //end for + //allocate memory for the routing update fields + aasworld.areaupdate = (aas_routingupdate_t *) GetClearedMemory( + maxreachabilityareas * sizeof(aas_routingupdate_t)); + // + if (aasworld.portalupdate) FreeMemory(aasworld.portalupdate); + //allocate memory for the portal update fields + aasworld.portalupdate = (aas_routingupdate_t *) GetClearedMemory( + (aasworld.numportals+1) * sizeof(aas_routingupdate_t)); +} //end of the function AAS_InitRoutingUpdate +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CreateAllRoutingCache(void) +{ + int i, j, t; + + aasworld.initialized = qtrue; + botimport.Print(PRT_MESSAGE, "AAS_CreateAllRoutingCache\n"); + for (i = 1; i < aasworld.numareas; i++) + { + if (!AAS_AreaReachability(i)) continue; + for (j = 1; j < aasworld.numareas; j++) + { + if (i == j) continue; + if (!AAS_AreaReachability(j)) continue; + t = AAS_AreaTravelTimeToGoalArea(i, aasworld.areas[i].center, j, TFL_DEFAULT); + //Log_Write("traveltime from %d to %d is %d", i, j, t); + } //end for + } //end for + aasworld.initialized = qfalse; +} //end of the function AAS_CreateAllRoutingCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== + +//the route cache header +//this header is followed by numportalcache + numareacache aas_routingcache_t +//structures that store routing cache +typedef struct routecacheheader_s +{ + int ident; + int version; + int numareas; + int numclusters; + int areacrc; + int clustercrc; + int numportalcache; + int numareacache; +} routecacheheader_t; + +#define RCID (('C'<<24)+('R'<<16)+('E'<<8)+'M') +#define RCVERSION 2 + +//void AAS_DecompressVis(byte *in, int numareas, byte *decompressed); +//int AAS_CompressVis(byte *vis, int numareas, byte *dest); + +void AAS_WriteRouteCache(void) +{ + int i, j, numportalcache, numareacache, totalsize; + aas_routingcache_t *cache; + aas_cluster_t *cluster; + fileHandle_t fp; + char filename[MAX_QPATH]; + routecacheheader_t routecacheheader; + + numportalcache = 0; + for (i = 0; i < aasworld.numareas; i++) + { + for (cache = aasworld.portalcache[i]; cache; cache = cache->next) + { + numportalcache++; + } //end for + } //end for + numareacache = 0; + for (i = 0; i < aasworld.numclusters; i++) + { + cluster = &aasworld.clusters[i]; + for (j = 0; j < cluster->numareas; j++) + { + for (cache = aasworld.clusterareacache[i][j]; cache; cache = cache->next) + { + numareacache++; + } //end for + } //end for + } //end for + // open the file for writing + Com_sprintf(filename, MAX_QPATH, "maps/%s.rcd", aasworld.mapname); + botimport.FS_FOpenFile( filename, &fp, FS_WRITE ); + if (!fp) + { + AAScriptError("Unable to open file: %s\n", filename); + return; + } //end if + //create the header + routecacheheader.ident = RCID; + routecacheheader.version = RCVERSION; + routecacheheader.numareas = aasworld.numareas; + routecacheheader.numclusters = aasworld.numclusters; + routecacheheader.areacrc = CRC_ProcessString( (unsigned char *)aasworld.areas, sizeof(aas_area_t) * aasworld.numareas ); + routecacheheader.clustercrc = CRC_ProcessString( (unsigned char *)aasworld.clusters, sizeof(aas_cluster_t) * aasworld.numclusters ); + routecacheheader.numportalcache = numportalcache; + routecacheheader.numareacache = numareacache; + //write the header + botimport.FS_Write(&routecacheheader, sizeof(routecacheheader_t), fp); + // + totalsize = 0; + //write all the cache + for (i = 0; i < aasworld.numareas; i++) + { + for (cache = aasworld.portalcache[i]; cache; cache = cache->next) + { + botimport.FS_Write(cache, cache->size, fp); + totalsize += cache->size; + } //end for + } //end for + for (i = 0; i < aasworld.numclusters; i++) + { + cluster = &aasworld.clusters[i]; + for (j = 0; j < cluster->numareas; j++) + { + for (cache = aasworld.clusterareacache[i][j]; cache; cache = cache->next) + { + botimport.FS_Write(cache, cache->size, fp); + totalsize += cache->size; + } //end for + } //end for + } //end for + // write the visareas + /* + for (i = 0; i < aasworld.numareas; i++) + { + if (!aasworld.areavisibility[i]) { + size = 0; + botimport.FS_Write(&size, sizeof(int), fp); + continue; + } + AAS_DecompressVis( aasworld.areavisibility[i], aasworld.numareas, aasworld.decompressedvis ); + size = AAS_CompressVis( aasworld.decompressedvis, aasworld.numareas, aasworld.decompressedvis ); + botimport.FS_Write(&size, sizeof(int), fp); + botimport.FS_Write(aasworld.decompressedvis, size, fp); + } + */ + // + botimport.FS_FCloseFile(fp); + botimport.Print(PRT_MESSAGE, "\nroute cache written to %s\n", filename); + botimport.Print(PRT_MESSAGE, "written %d bytes of routing cache\n", totalsize); +} //end of the function AAS_WriteRouteCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_routingcache_t *AAS_ReadCache(fileHandle_t fp) +{ + int size; + aas_routingcache_t *cache; + + botimport.FS_Read(&size, sizeof(size), fp); + cache = (aas_routingcache_t *) GetMemory(size); + cache->size = size; + botimport.FS_Read((unsigned char *)cache + sizeof(size), size - sizeof(size), fp); + cache->reachabilities = (unsigned char *) cache + sizeof(aas_routingcache_t) - sizeof(unsigned short) + + (size - sizeof(aas_routingcache_t) + sizeof(unsigned short)) / 3 * 2; + return cache; +} //end of the function AAS_ReadCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_ReadRouteCache(void) +{ + int i, clusterareanum;//, size; + fileHandle_t fp; + char filename[MAX_QPATH]; + routecacheheader_t routecacheheader; + aas_routingcache_t *cache; + + Com_sprintf(filename, MAX_QPATH, "maps/%s.rcd", aasworld.mapname); + botimport.FS_FOpenFile( filename, &fp, FS_READ ); + if (!fp) + { + return qfalse; + } //end if + botimport.FS_Read(&routecacheheader, sizeof(routecacheheader_t), fp ); + if (routecacheheader.ident != RCID) + { + AAScriptError("%s is not a route cache dump\n"); + return qfalse; + } //end if + if (routecacheheader.version != RCVERSION) + { + AAScriptError("route cache dump has wrong version %d, should be %d", routecacheheader.version, RCVERSION); + return qfalse; + } //end if + if (routecacheheader.numareas != aasworld.numareas) + { + //AAScriptError("route cache dump has wrong number of areas\n"); + return qfalse; + } //end if + if (routecacheheader.numclusters != aasworld.numclusters) + { + //AAScriptError("route cache dump has wrong number of clusters\n"); + return qfalse; + } //end if + if (routecacheheader.areacrc != + CRC_ProcessString( (unsigned char *)aasworld.areas, sizeof(aas_area_t) * aasworld.numareas )) + { + //AAScriptError("route cache dump area CRC incorrect\n"); + return qfalse; + } //end if + if (routecacheheader.clustercrc != + CRC_ProcessString( (unsigned char *)aasworld.clusters, sizeof(aas_cluster_t) * aasworld.numclusters )) + { + //AAScriptError("route cache dump cluster CRC incorrect\n"); + return qfalse; + } //end if + //read all the portal cache + for (i = 0; i < routecacheheader.numportalcache; i++) + { + cache = AAS_ReadCache(fp); + cache->next = aasworld.portalcache[cache->areanum]; + cache->prev = NULL; + if (aasworld.portalcache[cache->areanum]) + aasworld.portalcache[cache->areanum]->prev = cache; + aasworld.portalcache[cache->areanum] = cache; + } //end for + //read all the cluster area cache + for (i = 0; i < routecacheheader.numareacache; i++) + { + cache = AAS_ReadCache(fp); + clusterareanum = AAS_ClusterAreaNum(cache->cluster, cache->areanum); + cache->next = aasworld.clusterareacache[cache->cluster][clusterareanum]; + cache->prev = NULL; + if (aasworld.clusterareacache[cache->cluster][clusterareanum]) + aasworld.clusterareacache[cache->cluster][clusterareanum]->prev = cache; + aasworld.clusterareacache[cache->cluster][clusterareanum] = cache; + } //end for + // read the visareas + /* + aasworld.areavisibility = (byte **) GetClearedMemory(aasworld.numareas * sizeof(byte *)); + aasworld.decompressedvis = (byte *) GetClearedMemory(aasworld.numareas * sizeof(byte)); + for (i = 0; i < aasworld.numareas; i++) + { + botimport.FS_Read(&size, sizeof(size), fp ); + if (size) { + aasworld.areavisibility[i] = (byte *) GetMemory(size); + botimport.FS_Read(aasworld.areavisibility[i], size, fp ); + } + } + */ + // + botimport.FS_FCloseFile(fp); + return qtrue; +} //end of the function AAS_ReadRouteCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#define MAX_REACHABILITYPASSAREAS 32 + +void AAS_InitReachabilityAreas(void) +{ + int i, j, numareas, areas[MAX_REACHABILITYPASSAREAS]; + int numreachareas; + aas_reachability_t *reach; + vec3_t start, end; + + if (aasworld.reachabilityareas) + FreeMemory(aasworld.reachabilityareas); + if (aasworld.reachabilityareaindex) + FreeMemory(aasworld.reachabilityareaindex); + + aasworld.reachabilityareas = (aas_reachabilityareas_t *) + GetClearedMemory(aasworld.reachabilitysize * sizeof(aas_reachabilityareas_t)); + aasworld.reachabilityareaindex = (int *) + GetClearedMemory(aasworld.reachabilitysize * MAX_REACHABILITYPASSAREAS * sizeof(int)); + numreachareas = 0; + for (i = 0; i < aasworld.reachabilitysize; i++) + { + reach = &aasworld.reachability[i]; + numareas = 0; + switch(reach->traveltype & TRAVELTYPE_MASK) + { + //trace areas from start to end + case TRAVEL_BARRIERJUMP: + case TRAVEL_WATERJUMP: + VectorCopy(reach->start, end); + end[2] = reach->end[2]; + numareas = AAS_TraceAreas(reach->start, end, areas, NULL, MAX_REACHABILITYPASSAREAS); + break; + case TRAVEL_WALKOFFLEDGE: + VectorCopy(reach->end, start); + start[2] = reach->start[2]; + numareas = AAS_TraceAreas(start, reach->end, areas, NULL, MAX_REACHABILITYPASSAREAS); + break; + case TRAVEL_GRAPPLEHOOK: + numareas = AAS_TraceAreas(reach->start, reach->end, areas, NULL, MAX_REACHABILITYPASSAREAS); + break; + + //trace arch + case TRAVEL_JUMP: break; + case TRAVEL_ROCKETJUMP: break; + case TRAVEL_BFGJUMP: break; + case TRAVEL_JUMPPAD: break; + + //trace from reach->start to entity center, along entity movement + //and from entity center to reach->end + case TRAVEL_ELEVATOR: break; + case TRAVEL_FUNCBOB: break; + + //no areas in between + case TRAVEL_WALK: break; + case TRAVEL_CROUCH: break; + case TRAVEL_LADDER: break; + case TRAVEL_SWIM: break; + case TRAVEL_TELEPORT: break; + default: break; + } //end switch + aasworld.reachabilityareas[i].firstarea = numreachareas; + aasworld.reachabilityareas[i].numareas = numareas; + for (j = 0; j < numareas; j++) + { + aasworld.reachabilityareaindex[numreachareas++] = areas[j]; + } //end for + } //end for +} //end of the function AAS_InitReachabilityAreas +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitRouting(void) +{ + AAS_InitTravelFlagFromType(); + // + AAS_InitAreaContentsTravelFlags(); + //initialize the routing update fields + AAS_InitRoutingUpdate(); + //create reversed reachability links used by the routing update algorithm + AAS_CreateReversedReachability(); + //initialize the cluster cache + AAS_InitClusterAreaCache(); + //initialize portal cache + AAS_InitPortalCache(); + //initialize the area travel times + AAS_CalculateAreaTravelTimes(); + //calculate the maximum travel times through portals + AAS_InitPortalMaxTravelTimes(); + //get the areas reachabilities go through + AAS_InitReachabilityAreas(); + // +#ifdef ROUTING_DEBUG + numareacacheupdates = 0; + numportalcacheupdates = 0; +#endif //ROUTING_DEBUG + // + routingcachesize = 0; + max_routingcachesize = 1024 * (int) LibVarValue("max_routingcache", "4096"); + // read any routing cache if available + AAS_ReadRouteCache(); +} //end of the function AAS_InitRouting +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeRoutingCaches(void) +{ + // free all the existing cluster area cache + AAS_FreeAllClusterAreaCache(); + // free all the existing portal cache + AAS_FreeAllPortalCache(); + // free cached travel times within areas + if (aasworld.areatraveltimes) FreeMemory(aasworld.areatraveltimes); + aasworld.areatraveltimes = NULL; + // free cached maximum travel time through cluster portals + if (aasworld.portalmaxtraveltimes) FreeMemory(aasworld.portalmaxtraveltimes); + aasworld.portalmaxtraveltimes = NULL; + // free reversed reachability links + if (aasworld.reversedreachability) FreeMemory(aasworld.reversedreachability); + aasworld.reversedreachability = NULL; + // free routing algorithm memory + if (aasworld.areaupdate) FreeMemory(aasworld.areaupdate); + aasworld.areaupdate = NULL; + if (aasworld.portalupdate) FreeMemory(aasworld.portalupdate); + aasworld.portalupdate = NULL; + // free lists with areas the reachabilities go through + if (aasworld.reachabilityareas) FreeMemory(aasworld.reachabilityareas); + aasworld.reachabilityareas = NULL; + // free the reachability area index + if (aasworld.reachabilityareaindex) FreeMemory(aasworld.reachabilityareaindex); + aasworld.reachabilityareaindex = NULL; + // free area contents travel flags look up table + if (aasworld.areacontentstravelflags) FreeMemory(aasworld.areacontentstravelflags); + aasworld.areacontentstravelflags = NULL; +} //end of the function AAS_FreeRoutingCaches +//=========================================================================== +// update the given routing cache +// +// Parameter: areacache : routing cache to update +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_UpdateAreaRoutingCache(aas_routingcache_t *areacache) +{ + int i, nextareanum, cluster, badtravelflags, clusterareanum, linknum; + int numreachabilityareas; + unsigned short int t, startareatraveltimes[128]; //NOTE: not more than 128 reachabilities per area allowed + aas_routingupdate_t *updateliststart, *updatelistend, *curupdate, *nextupdate; + aas_reachability_t *reach; + aas_reversedreachability_t *revreach; + aas_reversedlink_t *revlink; + +#ifdef ROUTING_DEBUG + numareacacheupdates++; +#endif //ROUTING_DEBUG + //number of reachability areas within this cluster + numreachabilityareas = aasworld.clusters[areacache->cluster].numreachabilityareas; + // + aasworld.frameroutingupdates++; + //clear the routing update fields +// Com_Memset(aasworld.areaupdate, 0, aasworld.numareas * sizeof(aas_routingupdate_t)); + // + badtravelflags = ~areacache->travelflags; + // + clusterareanum = AAS_ClusterAreaNum(areacache->cluster, areacache->areanum); + if (clusterareanum >= numreachabilityareas) return; + // + Com_Memset(startareatraveltimes, 0, sizeof(startareatraveltimes)); + // + curupdate = &aasworld.areaupdate[clusterareanum]; + curupdate->areanum = areacache->areanum; + //VectorCopy(areacache->origin, curupdate->start); + curupdate->areatraveltimes = startareatraveltimes; + curupdate->tmptraveltime = areacache->starttraveltime; + // + areacache->traveltimes[clusterareanum] = areacache->starttraveltime; + //put the area to start with in the current read list + curupdate->next = NULL; + curupdate->prev = NULL; + updateliststart = curupdate; + updatelistend = curupdate; + //while there are updates in the current list + while (updateliststart) + { + curupdate = updateliststart; + // + if (curupdate->next) curupdate->next->prev = NULL; + else updatelistend = NULL; + updateliststart = curupdate->next; + // + curupdate->inlist = qfalse; + //check all reversed reachability links + revreach = &aasworld.reversedreachability[curupdate->areanum]; + // + for (i = 0, revlink = revreach->first; revlink; revlink = revlink->next, i++) + { + linknum = revlink->linknum; + reach = &aasworld.reachability[linknum]; + //if there is used an undesired travel type + if (AAS_TravelFlagForType_inline(reach->traveltype) & badtravelflags) continue; + //if not allowed to enter the next area + if (aasworld.areasettings[reach->areanum].areaflags & AREA_DISABLED) continue; + //if the next area has a not allowed travel flag + if (AAS_AreaContentsTravelFlags_inline(reach->areanum) & badtravelflags) continue; + //number of the area the reversed reachability leads to + nextareanum = revlink->areanum; + //get the cluster number of the area + cluster = aasworld.areasettings[nextareanum].cluster; + //don't leave the cluster + if (cluster > 0 && cluster != areacache->cluster) continue; + //get the number of the area in the cluster + clusterareanum = AAS_ClusterAreaNum(areacache->cluster, nextareanum); + if (clusterareanum >= numreachabilityareas) continue; + //time already travelled plus the traveltime through + //the current area plus the travel time from the reachability + t = curupdate->tmptraveltime + + //AAS_AreaTravelTime(curupdate->areanum, curupdate->start, reach->end) + + curupdate->areatraveltimes[i] + + reach->traveltime; + // + if (!areacache->traveltimes[clusterareanum] || + areacache->traveltimes[clusterareanum] > t) + { + areacache->traveltimes[clusterareanum] = t; + areacache->reachabilities[clusterareanum] = linknum - aasworld.areasettings[nextareanum].firstreachablearea; + nextupdate = &aasworld.areaupdate[clusterareanum]; + nextupdate->areanum = nextareanum; + nextupdate->tmptraveltime = t; + //VectorCopy(reach->start, nextupdate->start); + nextupdate->areatraveltimes = aasworld.areatraveltimes[nextareanum][linknum - + aasworld.areasettings[nextareanum].firstreachablearea]; + if (!nextupdate->inlist) + { + // we add the update to the end of the list + // we could also use a B+ tree to have a real sorted list + // on travel time which makes for faster routing updates + nextupdate->next = NULL; + nextupdate->prev = updatelistend; + if (updatelistend) updatelistend->next = nextupdate; + else updateliststart = nextupdate; + updatelistend = nextupdate; + nextupdate->inlist = qtrue; + } //end if + } //end if + } //end for + } //end while +} //end of the function AAS_UpdateAreaRoutingCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_routingcache_t *AAS_GetAreaRoutingCache(int clusternum, int areanum, int travelflags) +{ + int clusterareanum; + aas_routingcache_t *cache, *clustercache; + + //number of the area in the cluster + clusterareanum = AAS_ClusterAreaNum(clusternum, areanum); + //pointer to the cache for the area in the cluster + clustercache = aasworld.clusterareacache[clusternum][clusterareanum]; + //find the cache without undesired travel flags + for (cache = clustercache; cache; cache = cache->next) + { + //if there aren't used any undesired travel types for the cache + if (cache->travelflags == travelflags) break; + } //end for + //if there was no cache + if (!cache) + { + cache = AAS_AllocRoutingCache(aasworld.clusters[clusternum].numreachabilityareas); + cache->cluster = clusternum; + cache->areanum = areanum; + VectorCopy(aasworld.areas[areanum].center, cache->origin); + cache->starttraveltime = 1; + cache->travelflags = travelflags; + cache->prev = NULL; + cache->next = clustercache; + if (clustercache) clustercache->prev = cache; + aasworld.clusterareacache[clusternum][clusterareanum] = cache; + AAS_UpdateAreaRoutingCache(cache); + } //end if + else + { + AAS_UnlinkCache(cache); + } //end else + //the cache has been accessed + cache->time = AAS_RoutingTime(); + cache->type = CACHETYPE_AREA; + AAS_LinkCache(cache); + return cache; +} //end of the function AAS_GetAreaRoutingCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_UpdatePortalRoutingCache(aas_routingcache_t *portalcache) +{ + int i, portalnum, clusterareanum, clusternum; + unsigned short int t; + aas_portal_t *portal; + aas_cluster_t *cluster; + aas_routingcache_t *cache; + aas_routingupdate_t *updateliststart, *updatelistend, *curupdate, *nextupdate; + +#ifdef ROUTING_DEBUG + numportalcacheupdates++; +#endif //ROUTING_DEBUG + //clear the routing update fields +// Com_Memset(aasworld.portalupdate, 0, (aasworld.numportals+1) * sizeof(aas_routingupdate_t)); + // + curupdate = &aasworld.portalupdate[aasworld.numportals]; + curupdate->cluster = portalcache->cluster; + curupdate->areanum = portalcache->areanum; + curupdate->tmptraveltime = portalcache->starttraveltime; + //if the start area is a cluster portal, store the travel time for that portal + clusternum = aasworld.areasettings[portalcache->areanum].cluster; + if (clusternum < 0) + { + portalcache->traveltimes[-clusternum] = portalcache->starttraveltime; + } //end if + //put the area to start with in the current read list + curupdate->next = NULL; + curupdate->prev = NULL; + updateliststart = curupdate; + updatelistend = curupdate; + //while there are updates in the current list + while (updateliststart) + { + curupdate = updateliststart; + //remove the current update from the list + if (curupdate->next) curupdate->next->prev = NULL; + else updatelistend = NULL; + updateliststart = curupdate->next; + //current update is removed from the list + curupdate->inlist = qfalse; + // + cluster = &aasworld.clusters[curupdate->cluster]; + // + cache = AAS_GetAreaRoutingCache(curupdate->cluster, + curupdate->areanum, portalcache->travelflags); + //take all portals of the cluster + for (i = 0; i < cluster->numportals; i++) + { + portalnum = aasworld.portalindex[cluster->firstportal + i]; + portal = &aasworld.portals[portalnum]; + //if this is the portal of the current update continue + if (portal->areanum == curupdate->areanum) continue; + // + clusterareanum = AAS_ClusterAreaNum(curupdate->cluster, portal->areanum); + if (clusterareanum >= cluster->numreachabilityareas) continue; + // + t = cache->traveltimes[clusterareanum]; + if (!t) continue; + t += curupdate->tmptraveltime; + // + if (!portalcache->traveltimes[portalnum] || + portalcache->traveltimes[portalnum] > t) + { + portalcache->traveltimes[portalnum] = t; + nextupdate = &aasworld.portalupdate[portalnum]; + if (portal->frontcluster == curupdate->cluster) + { + nextupdate->cluster = portal->backcluster; + } //end if + else + { + nextupdate->cluster = portal->frontcluster; + } //end else + nextupdate->areanum = portal->areanum; + //add travel time through the actual portal area for the next update + nextupdate->tmptraveltime = t + aasworld.portalmaxtraveltimes[portalnum]; + if (!nextupdate->inlist) + { + // we add the update to the end of the list + // we could also use a B+ tree to have a real sorted list + // on travel time which makes for faster routing updates + nextupdate->next = NULL; + nextupdate->prev = updatelistend; + if (updatelistend) updatelistend->next = nextupdate; + else updateliststart = nextupdate; + updatelistend = nextupdate; + nextupdate->inlist = qtrue; + } //end if + } //end if + } //end for + } //end while +} //end of the function AAS_UpdatePortalRoutingCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_routingcache_t *AAS_GetPortalRoutingCache(int clusternum, int areanum, int travelflags) +{ + aas_routingcache_t *cache; + + //find the cached portal routing if existing + for (cache = aasworld.portalcache[areanum]; cache; cache = cache->next) + { + if (cache->travelflags == travelflags) break; + } //end for + //if the portal routing isn't cached + if (!cache) + { + cache = AAS_AllocRoutingCache(aasworld.numportals); + cache->cluster = clusternum; + cache->areanum = areanum; + VectorCopy(aasworld.areas[areanum].center, cache->origin); + cache->starttraveltime = 1; + cache->travelflags = travelflags; + //add the cache to the cache list + cache->prev = NULL; + cache->next = aasworld.portalcache[areanum]; + if (aasworld.portalcache[areanum]) aasworld.portalcache[areanum]->prev = cache; + aasworld.portalcache[areanum] = cache; + //update the cache + AAS_UpdatePortalRoutingCache(cache); + } //end if + else + { + AAS_UnlinkCache(cache); + } //end else + //the cache has been accessed + cache->time = AAS_RoutingTime(); + cache->type = CACHETYPE_PORTAL; + AAS_LinkCache(cache); + return cache; +} //end of the function AAS_GetPortalRoutingCache +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_AreaRouteToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags, int *traveltime, int *reachnum) +{ + int clusternum, goalclusternum, portalnum, i, clusterareanum, bestreachnum; + unsigned short int t, besttime; + aas_portal_t *portal; + aas_cluster_t *cluster; + aas_routingcache_t *areacache, *portalcache; + aas_reachability_t *reach; + + if (!aasworld.initialized) return qfalse; + + if (areanum == goalareanum) + { + *traveltime = 1; + *reachnum = 0; + return qtrue; + } + // + if (areanum <= 0 || areanum >= aasworld.numareas) + { + if (bot_developer) + { + botimport.Print(PRT_ERROR, "AAS_AreaTravelTimeToGoalArea: areanum %d out of range\n", areanum); + } //end if + return qfalse; + } //end if + if (goalareanum <= 0 || goalareanum >= aasworld.numareas) + { + if (bot_developer) + { + botimport.Print(PRT_ERROR, "AAS_AreaTravelTimeToGoalArea: goalareanum %d out of range\n", goalareanum); + } //end if + return qfalse; + } //end if + // make sure the routing cache doesn't grow to large + while(AvailableMemory() < 1 * 1024 * 1024) { + if (!AAS_FreeOldestCache()) break; + } + // + if (AAS_AreaDoNotEnter(areanum) || AAS_AreaDoNotEnter(goalareanum)) + { + travelflags |= TFL_DONOTENTER; + } //end if + //NOTE: the number of routing updates is limited per frame + /* + if (aasworld.frameroutingupdates > MAX_FRAMEROUTINGUPDATES) + { +#ifdef DEBUG + //Log_Write("WARNING: AAS_AreaTravelTimeToGoalArea: frame routing updates overflowed"); +#endif + return 0; + } //end if + */ + // + clusternum = aasworld.areasettings[areanum].cluster; + goalclusternum = aasworld.areasettings[goalareanum].cluster; + //check if the area is a portal of the goal area cluster + if (clusternum < 0 && goalclusternum > 0) + { + portal = &aasworld.portals[-clusternum]; + if (portal->frontcluster == goalclusternum || + portal->backcluster == goalclusternum) + { + clusternum = goalclusternum; + } //end if + } //end if + //check if the goalarea is a portal of the area cluster + else if (clusternum > 0 && goalclusternum < 0) + { + portal = &aasworld.portals[-goalclusternum]; + if (portal->frontcluster == clusternum || + portal->backcluster == clusternum) + { + goalclusternum = clusternum; + } //end if + } //end if + //if both areas are in the same cluster + //NOTE: there might be a shorter route via another cluster!!! but we don't care + if (clusternum > 0 && goalclusternum > 0 && clusternum == goalclusternum) + { + // + areacache = AAS_GetAreaRoutingCache(clusternum, goalareanum, travelflags); + //the number of the area in the cluster + clusterareanum = AAS_ClusterAreaNum(clusternum, areanum); + //the cluster the area is in + cluster = &aasworld.clusters[clusternum]; + //if the area is NOT a reachability area + if (clusterareanum >= cluster->numreachabilityareas) return 0; + //if it is possible to travel to the goal area through this cluster + if (areacache->traveltimes[clusterareanum] != 0) + { + *reachnum = aasworld.areasettings[areanum].firstreachablearea + + areacache->reachabilities[clusterareanum]; + if (!origin) { + *traveltime = areacache->traveltimes[clusterareanum]; + return qtrue; + } + reach = &aasworld.reachability[*reachnum]; + *traveltime = areacache->traveltimes[clusterareanum] + + AAS_AreaTravelTime(areanum, origin, reach->start); + // + return qtrue; + } //end if + } //end if + // + clusternum = aasworld.areasettings[areanum].cluster; + goalclusternum = aasworld.areasettings[goalareanum].cluster; + //if the goal area is a portal + if (goalclusternum < 0) + { + //just assume the goal area is part of the front cluster + portal = &aasworld.portals[-goalclusternum]; + goalclusternum = portal->frontcluster; + } //end if + //get the portal routing cache + portalcache = AAS_GetPortalRoutingCache(goalclusternum, goalareanum, travelflags); + //if the area is a cluster portal, read directly from the portal cache + if (clusternum < 0) + { + *traveltime = portalcache->traveltimes[-clusternum]; + *reachnum = aasworld.areasettings[areanum].firstreachablearea + + portalcache->reachabilities[-clusternum]; + return qtrue; + } //end if + // + besttime = 0; + bestreachnum = -1; + //the cluster the area is in + cluster = &aasworld.clusters[clusternum]; + //find the portal of the area cluster leading towards the goal area + for (i = 0; i < cluster->numportals; i++) + { + portalnum = aasworld.portalindex[cluster->firstportal + i]; + //if the goal area isn't reachable from the portal + if (!portalcache->traveltimes[portalnum]) continue; + // + portal = &aasworld.portals[portalnum]; + //get the cache of the portal area + areacache = AAS_GetAreaRoutingCache(clusternum, portal->areanum, travelflags); + //current area inside the current cluster + clusterareanum = AAS_ClusterAreaNum(clusternum, areanum); + //if the area is NOT a reachability area + if (clusterareanum >= cluster->numreachabilityareas) continue; + //if the portal is NOT reachable from this area + if (!areacache->traveltimes[clusterareanum]) continue; + //total travel time is the travel time the portal area is from + //the goal area plus the travel time towards the portal area + t = portalcache->traveltimes[portalnum] + areacache->traveltimes[clusterareanum]; + //FIXME: add the exact travel time through the actual portal area + //NOTE: for now we just add the largest travel time through the portal area + // because we can't directly calculate the exact travel time + // to be more specific we don't know which reachability was used to travel + // into the portal area + t += aasworld.portalmaxtraveltimes[portalnum]; + // + if (origin) + { + *reachnum = aasworld.areasettings[areanum].firstreachablearea + + areacache->reachabilities[clusterareanum]; + reach = aasworld.reachability + *reachnum; + t += AAS_AreaTravelTime(areanum, origin, reach->start); + } //end if + //if the time is better than the one already found + if (!besttime || t < besttime) + { + bestreachnum = *reachnum; + besttime = t; + } //end if + } //end for + if (bestreachnum < 0) { + return qfalse; + } + *reachnum = bestreachnum; + *traveltime = besttime; + return qtrue; +} //end of the function AAS_AreaRouteToGoalArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags) +{ + int traveltime, reachnum; + + if (AAS_AreaRouteToGoalArea(areanum, origin, goalareanum, travelflags, &traveltime, &reachnum)) + { + return traveltime; + } + return 0; +} //end of the function AAS_AreaTravelTimeToGoalArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_AreaReachabilityToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags) +{ + int traveltime, reachnum; + + if (AAS_AreaRouteToGoalArea(areanum, origin, goalareanum, travelflags, &traveltime, &reachnum)) + { + return reachnum; + } + return 0; +} //end of the function AAS_AreaReachabilityToGoalArea +//=========================================================================== +// predict the route and stop on one of the stop events +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_PredictRoute(struct aas_predictroute_s *route, int areanum, vec3_t origin, + int goalareanum, int travelflags, int maxareas, int maxtime, + int stopevent, int stopcontents, int stoptfl, int stopareanum) +{ + int curareanum, reachnum, i, j, testareanum; + vec3_t curorigin; + aas_reachability_t *reach; + aas_reachabilityareas_t *reachareas; + + //init output + route->stopevent = RSE_NONE; + route->endarea = goalareanum; + route->endcontents = 0; + route->endtravelflags = 0; + VectorCopy(origin, route->endpos); + route->time = 0; + + curareanum = areanum; + VectorCopy(origin, curorigin); + + for (i = 0; curareanum != goalareanum && (!maxareas || i < maxareas) && i < aasworld.numareas; i++) + { + reachnum = AAS_AreaReachabilityToGoalArea(curareanum, curorigin, goalareanum, travelflags); + if (!reachnum) + { + route->stopevent = RSE_NOROUTE; + return qfalse; + } //end if + reach = &aasworld.reachability[reachnum]; + // + if (stopevent & RSE_USETRAVELTYPE) + { + if (AAS_TravelFlagForType_inline(reach->traveltype) & stoptfl) + { + route->stopevent = RSE_USETRAVELTYPE; + route->endarea = curareanum; + route->endcontents = aasworld.areasettings[curareanum].contents; + route->endtravelflags = AAS_TravelFlagForType_inline(reach->traveltype); + VectorCopy(reach->start, route->endpos); + return qtrue; + } //end if + if (AAS_AreaContentsTravelFlags_inline(reach->areanum) & stoptfl) + { + route->stopevent = RSE_USETRAVELTYPE; + route->endarea = reach->areanum; + route->endcontents = aasworld.areasettings[reach->areanum].contents; + route->endtravelflags = AAS_AreaContentsTravelFlags_inline(reach->areanum); + VectorCopy(reach->end, route->endpos); + route->time += AAS_AreaTravelTime(areanum, origin, reach->start); + route->time += reach->traveltime; + return qtrue; + } //end if + } //end if + reachareas = &aasworld.reachabilityareas[reachnum]; + for (j = 0; j < reachareas->numareas + 1; j++) + { + if (j >= reachareas->numareas) + testareanum = reach->areanum; + else + testareanum = aasworld.reachabilityareaindex[reachareas->firstarea + j]; + if (stopevent & RSE_ENTERCONTENTS) + { + if (aasworld.areasettings[testareanum].contents & stopcontents) + { + route->stopevent = RSE_ENTERCONTENTS; + route->endarea = testareanum; + route->endcontents = aasworld.areasettings[testareanum].contents; + VectorCopy(reach->end, route->endpos); + route->time += AAS_AreaTravelTime(areanum, origin, reach->start); + route->time += reach->traveltime; + return qtrue; + } //end if + } //end if + if (stopevent & RSE_ENTERAREA) + { + if (testareanum == stopareanum) + { + route->stopevent = RSE_ENTERAREA; + route->endarea = testareanum; + route->endcontents = aasworld.areasettings[testareanum].contents; + VectorCopy(reach->start, route->endpos); + return qtrue; + } //end if + } //end if + } //end for + + route->time += AAS_AreaTravelTime(areanum, origin, reach->start); + route->time += reach->traveltime; + route->endarea = reach->areanum; + route->endcontents = aasworld.areasettings[reach->areanum].contents; + route->endtravelflags = AAS_TravelFlagForType_inline(reach->traveltype); + VectorCopy(reach->end, route->endpos); + // + curareanum = reach->areanum; + VectorCopy(reach->end, curorigin); + // + if (maxtime && route->time > maxtime) + break; + } //end while + if (curareanum != goalareanum) + return qfalse; + return qtrue; +} //end of the function AAS_PredictRoute +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_BridgeWalkable(int areanum) +{ + return qfalse; +} //end of the function AAS_BridgeWalkable +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_ReachabilityFromNum(int num, struct aas_reachability_s *reach) +{ + if (!aasworld.initialized) + { + Com_Memset(reach, 0, sizeof(aas_reachability_t)); + return; + } //end if + if (num < 0 || num >= aasworld.reachabilitysize) + { + Com_Memset(reach, 0, sizeof(aas_reachability_t)); + return; + } //end if + Com_Memcpy(reach, &aasworld.reachability[num], sizeof(aas_reachability_t));; +} //end of the function AAS_ReachabilityFromNum +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_NextAreaReachability(int areanum, int reachnum) +{ + aas_areasettings_t *settings; + + if (!aasworld.initialized) return 0; + + if (areanum <= 0 || areanum >= aasworld.numareas) + { + botimport.Print(PRT_ERROR, "AAS_NextAreaReachability: areanum %d out of range\n", areanum); + return 0; + } //end if + + settings = &aasworld.areasettings[areanum]; + if (!reachnum) + { + return settings->firstreachablearea; + } //end if + if (reachnum < settings->firstreachablearea) + { + botimport.Print(PRT_FATAL, "AAS_NextAreaReachability: reachnum < settings->firstreachableara"); + return 0; + } //end if + reachnum++; + if (reachnum >= settings->firstreachablearea + settings->numreachableareas) + { + return 0; + } //end if + return reachnum; +} //end of the function AAS_NextAreaReachability +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_NextModelReachability(int num, int modelnum) +{ + int i; + + if (num <= 0) num = 1; + else if (num >= aasworld.reachabilitysize) return 0; + else num++; + // + for (i = num; i < aasworld.reachabilitysize; i++) + { + if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR) + { + if (aasworld.reachability[i].facenum == modelnum) return i; + } //end if + else if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_FUNCBOB) + { + if ((aasworld.reachability[i].facenum & 0x0000FFFF) == modelnum) return i; + } //end if + } //end for + return 0; +} //end of the function AAS_NextModelReachability +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_RandomGoalArea(int areanum, int travelflags, int *goalareanum, vec3_t goalorigin) +{ + int i, n, t; + vec3_t start, end; + aas_trace_t trace; + + //if the area has no reachabilities + if (!AAS_AreaReachability(areanum)) return qfalse; + // + n = aasworld.numareas * random(); + for (i = 0; i < aasworld.numareas; i++) + { + if (n <= 0) n = 1; + if (n >= aasworld.numareas) n = 1; + if (AAS_AreaReachability(n)) + { + t = AAS_AreaTravelTimeToGoalArea(areanum, aasworld.areas[areanum].center, n, travelflags); + //if the goal is reachable + if (t > 0) + { + if (AAS_AreaSwim(n)) + { + *goalareanum = n; + VectorCopy(aasworld.areas[n].center, goalorigin); + //botimport.Print(PRT_MESSAGE, "found random goal area %d\n", *goalareanum); + return qtrue; + } //end if + VectorCopy(aasworld.areas[n].center, start); + if (!AAS_PointAreaNum(start)) + Log_Write("area %d center %f %f %f in solid?", n, start[0], start[1], start[2]); + VectorCopy(start, end); + end[2] -= 300; + trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1); + if (!trace.startsolid && trace.fraction < 1 && AAS_PointAreaNum(trace.endpos) == n) + { + if (AAS_AreaGroundFaceArea(n) > 300) + { + *goalareanum = n; + VectorCopy(trace.endpos, goalorigin); + //botimport.Print(PRT_MESSAGE, "found random goal area %d\n", *goalareanum); + return qtrue; + } //end if + } //end if + } //end if + } //end if + n++; + } //end for + return qfalse; +} //end of the function AAS_RandomGoalArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_AreaVisible(int srcarea, int destarea) +{ + return qfalse; +} //end of the function AAS_AreaVisible +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float DistancePointToLine(vec3_t v1, vec3_t v2, vec3_t point) +{ + vec3_t vec, p2; + + AAS_ProjectPointOntoVector(point, v1, v2, p2); + VectorSubtract(point, p2, vec); + return VectorLength(vec); +} //end of the function DistancePointToLine +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_NearestHideArea(int srcnum, vec3_t origin, int areanum, int enemynum, vec3_t enemyorigin, int enemyareanum, int travelflags) +{ + int i, j, nextareanum, badtravelflags, numreach, bestarea; + unsigned short int t, besttraveltime; + static unsigned short int *hidetraveltimes; + aas_routingupdate_t *updateliststart, *updatelistend, *curupdate, *nextupdate; + aas_reachability_t *reach; + float dist1, dist2; + vec3_t v1, v2, p; + qboolean startVisible; + + // + if (!hidetraveltimes) + { + hidetraveltimes = (unsigned short int *) GetClearedMemory(aasworld.numareas * sizeof(unsigned short int)); + } //end if + else + { + Com_Memset(hidetraveltimes, 0, aasworld.numareas * sizeof(unsigned short int)); + } //end else + besttraveltime = 0; + bestarea = 0; + //assume visible + startVisible = qtrue; + // + badtravelflags = ~travelflags; + // + curupdate = &aasworld.areaupdate[areanum]; + curupdate->areanum = areanum; + VectorCopy(origin, curupdate->start); + curupdate->areatraveltimes = aasworld.areatraveltimes[areanum][0]; + curupdate->tmptraveltime = 0; + //put the area to start with in the current read list + curupdate->next = NULL; + curupdate->prev = NULL; + updateliststart = curupdate; + updatelistend = curupdate; + //while there are updates in the list + while (updateliststart) + { + curupdate = updateliststart; + // + if (curupdate->next) curupdate->next->prev = NULL; + else updatelistend = NULL; + updateliststart = curupdate->next; + // + curupdate->inlist = qfalse; + //check all reversed reachability links + numreach = aasworld.areasettings[curupdate->areanum].numreachableareas; + reach = &aasworld.reachability[aasworld.areasettings[curupdate->areanum].firstreachablearea]; + // + for (i = 0; i < numreach; i++, reach++) + { + //if an undesired travel type is used + if (AAS_TravelFlagForType_inline(reach->traveltype) & badtravelflags) continue; + // + if (AAS_AreaContentsTravelFlags_inline(reach->areanum) & badtravelflags) continue; + //number of the area the reachability leads to + nextareanum = reach->areanum; + // if this moves us into the enemies area, skip it + if (nextareanum == enemyareanum) continue; + //time already travelled plus the traveltime through + //the current area plus the travel time from the reachability + t = curupdate->tmptraveltime + + AAS_AreaTravelTime(curupdate->areanum, curupdate->start, reach->start) + + reach->traveltime; + + //avoid going near the enemy + AAS_ProjectPointOntoVector(enemyorigin, curupdate->start, reach->end, p); + for (j = 0; j < 3; j++) + if ((p[j] > curupdate->start[j] && p[j] > reach->end[j]) || + (p[j] < curupdate->start[j] && p[j] < reach->end[j])) + break; + if (j < 3) + { + VectorSubtract(enemyorigin, reach->end, v2); + } //end if + else + { + VectorSubtract(enemyorigin, p, v2); + } //end else + dist2 = VectorLength(v2); + //never go through the enemy + if (dist2 < 40) continue; + // + VectorSubtract(enemyorigin, curupdate->start, v1); + dist1 = VectorLength(v1); + // + if (dist2 < dist1) + { + t += (dist1 - dist2) * 10; + } + // if we weren't visible when starting, make sure we don't move into their view + if (!startVisible && AAS_AreaVisible(enemyareanum, nextareanum)) { + continue; + } + // + if (besttraveltime && t >= besttraveltime) continue; + // + if (!hidetraveltimes[nextareanum] || + hidetraveltimes[nextareanum] > t) + { + //if the nextarea is not visible from the enemy area + if (!AAS_AreaVisible(enemyareanum, nextareanum)) + { + besttraveltime = t; + bestarea = nextareanum; + } //end if + hidetraveltimes[nextareanum] = t; + nextupdate = &aasworld.areaupdate[nextareanum]; + nextupdate->areanum = nextareanum; + nextupdate->tmptraveltime = t; + //remember where we entered this area + VectorCopy(reach->end, nextupdate->start); + //if this update is not in the list yet + if (!nextupdate->inlist) + { + //add the new update to the end of the list + nextupdate->next = NULL; + nextupdate->prev = updatelistend; + if (updatelistend) updatelistend->next = nextupdate; + else updateliststart = nextupdate; + updatelistend = nextupdate; + nextupdate->inlist = qtrue; + } //end if + } //end if + } //end for + } //end while + return bestarea; +} //end of the function AAS_NearestHideArea diff --git a/code/botlib/be_aas_route.h b/code/botlib/be_aas_route.h new file mode 100644 index 00000000..8805c66f --- /dev/null +++ b/code/botlib/be_aas_route.h @@ -0,0 +1,67 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_aas_route.h + * + * desc: AAS + * + * $Archive: /source/code/botlib/be_aas_route.h $ + * + *****************************************************************************/ + +#ifdef AASINTERN +//initialize the AAS routing +void AAS_InitRouting(void); +//free the AAS routing caches +void AAS_FreeRoutingCaches(void); +//returns the travel time from start to end in the given area +unsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end); +// +void AAS_CreateAllRoutingCache(void); +void AAS_WriteRouteCache(void); +// +void AAS_RoutingInfo(void); +#endif //AASINTERN + +//returns the travel flag for the given travel type +int AAS_TravelFlagForType(int traveltype); +//return the travel flag(s) for traveling through this area +int AAS_AreaContentsTravelFlags(int areanum); +//returns the index of the next reachability for the given area +int AAS_NextAreaReachability(int areanum, int reachnum); +//returns the reachability with the given index +void AAS_ReachabilityFromNum(int num, struct aas_reachability_s *reach); +//returns a random goal area and goal origin +int AAS_RandomGoalArea(int areanum, int travelflags, int *goalareanum, vec3_t goalorigin); +//enable or disable an area for routing +int AAS_EnableRoutingArea(int areanum, int enable); +//returns the travel time within the given area from start to end +unsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end); +//returns the travel time from the area to the goal area using the given travel flags +int AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags); +//predict a route up to a stop event +int AAS_PredictRoute(struct aas_predictroute_s *route, int areanum, vec3_t origin, + int goalareanum, int travelflags, int maxareas, int maxtime, + int stopevent, int stopcontents, int stoptfl, int stopareanum); + + diff --git a/code/botlib/be_aas_routealt.c b/code/botlib/be_aas_routealt.c new file mode 100644 index 00000000..e4f79eec --- /dev/null +++ b/code/botlib/be_aas_routealt.c @@ -0,0 +1,240 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_aas_routealt.c + * + * desc: AAS + * + * $Archive: /MissionPack/code/botlib/be_aas_routealt.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_utils.h" +#include "l_memory.h" +#include "l_log.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "aasfile.h" +#include "botlib.h" +#include "be_aas.h" +#include "be_aas_funcs.h" +#include "be_interface.h" +#include "be_aas_def.h" + +#define ENABLE_ALTROUTING +//#define ALTROUTE_DEBUG + +typedef struct midrangearea_s +{ + int valid; + unsigned short starttime; + unsigned short goaltime; +} midrangearea_t; + +midrangearea_t *midrangeareas; +int *clusterareas; +int numclusterareas; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_AltRoutingFloodCluster_r(int areanum) +{ + int i, otherareanum; + aas_area_t *area; + aas_face_t *face; + + //add the current area to the areas of the current cluster + clusterareas[numclusterareas] = areanum; + numclusterareas++; + //remove the area from the mid range areas + midrangeareas[areanum].valid = qfalse; + //flood to other areas through the faces of this area + area = &aasworld.areas[areanum]; + for (i = 0; i < area->numfaces; i++) + { + face = &aasworld.faces[abs(aasworld.faceindex[area->firstface + i])]; + //get the area at the other side of the face + if (face->frontarea == areanum) otherareanum = face->backarea; + else otherareanum = face->frontarea; + //if there is an area at the other side of this face + if (!otherareanum) continue; + //if the other area is not a midrange area + if (!midrangeareas[otherareanum].valid) continue; + // + AAS_AltRoutingFloodCluster_r(otherareanum); + } //end for +} //end of the function AAS_AltRoutingFloodCluster_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags, + aas_altroutegoal_t *altroutegoals, int maxaltroutegoals, + int type) +{ +#ifndef ENABLE_ALTROUTING + return 0; +#else + int i, j, bestareanum; + int numaltroutegoals, nummidrangeareas; + int starttime, goaltime, goaltraveltime; + float dist, bestdist; + vec3_t mid, dir; +#ifdef ALTROUTE_DEBUG + int startmillisecs; + + startmillisecs = Sys_MilliSeconds(); +#endif + + if (!startareanum || !goalareanum) + return 0; + //travel time towards the goal area + goaltraveltime = AAS_AreaTravelTimeToGoalArea(startareanum, start, goalareanum, travelflags); + //clear the midrange areas + Com_Memset(midrangeareas, 0, aasworld.numareas * sizeof(midrangearea_t)); + numaltroutegoals = 0; + // + nummidrangeareas = 0; + // + for (i = 1; i < aasworld.numareas; i++) + { + // + if (!(type & ALTROUTEGOAL_ALL)) + { + if (!(type & ALTROUTEGOAL_CLUSTERPORTALS && (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL))) + { + if (!(type & ALTROUTEGOAL_VIEWPORTALS && (aasworld.areasettings[i].contents & AREACONTENTS_VIEWPORTAL))) + { + continue; + } //end if + } //end if + } //end if + //if the area has no reachabilities + if (!AAS_AreaReachability(i)) continue; + //tavel time from the area to the start area + starttime = AAS_AreaTravelTimeToGoalArea(startareanum, start, i, travelflags); + if (!starttime) continue; + //if the travel time from the start to the area is greater than the shortest goal travel time + if (starttime > (float) 1.1 * goaltraveltime) continue; + //travel time from the area to the goal area + goaltime = AAS_AreaTravelTimeToGoalArea(i, NULL, goalareanum, travelflags); + if (!goaltime) continue; + //if the travel time from the area to the goal is greater than the shortest goal travel time + if (goaltime > (float) 0.8 * goaltraveltime) continue; + //this is a mid range area + midrangeareas[i].valid = qtrue; + midrangeareas[i].starttime = starttime; + midrangeareas[i].goaltime = goaltime; + Log_Write("%d midrange area %d", nummidrangeareas, i); + nummidrangeareas++; + } //end for + // + for (i = 1; i < aasworld.numareas; i++) + { + if (!midrangeareas[i].valid) continue; + //get the areas in one cluster + numclusterareas = 0; + AAS_AltRoutingFloodCluster_r(i); + //now we've got a cluster with areas through which an alternative route could go + //get the 'center' of the cluster + VectorClear(mid); + for (j = 0; j < numclusterareas; j++) + { + VectorAdd(mid, aasworld.areas[clusterareas[j]].center, mid); + } //end for + VectorScale(mid, 1.0 / numclusterareas, mid); + //get the area closest to the center of the cluster + bestdist = 999999; + bestareanum = 0; + for (j = 0; j < numclusterareas; j++) + { + VectorSubtract(mid, aasworld.areas[clusterareas[j]].center, dir); + dist = VectorLength(dir); + if (dist < bestdist) + { + bestdist = dist; + bestareanum = clusterareas[j]; + } //end if + } //end for + //now we've got an area for an alternative route + //FIXME: add alternative goal origin + VectorCopy(aasworld.areas[bestareanum].center, altroutegoals[numaltroutegoals].origin); + altroutegoals[numaltroutegoals].areanum = bestareanum; + altroutegoals[numaltroutegoals].starttraveltime = midrangeareas[bestareanum].starttime; + altroutegoals[numaltroutegoals].goaltraveltime = midrangeareas[bestareanum].goaltime; + altroutegoals[numaltroutegoals].extratraveltime = + (midrangeareas[bestareanum].starttime + midrangeareas[bestareanum].goaltime) - + goaltraveltime; + numaltroutegoals++; + // +#ifdef ALTROUTE_DEBUG + AAS_ShowAreaPolygons(bestareanum, 1, qtrue); +#endif + //don't return more than the maximum alternative route goals + if (numaltroutegoals >= maxaltroutegoals) break; + } //end for +#ifdef ALTROUTE_DEBUG + botimport.Print(PRT_MESSAGE, "alternative route goals in %d msec\n", Sys_MilliSeconds() - startmillisecs); +#endif + return numaltroutegoals; +#endif +} //end of the function AAS_AlternativeRouteGoals +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitAlternativeRouting(void) +{ +#ifdef ENABLE_ALTROUTING + if (midrangeareas) FreeMemory(midrangeareas); + midrangeareas = (midrangearea_t *) GetMemory(aasworld.numareas * sizeof(midrangearea_t)); + if (clusterareas) FreeMemory(clusterareas); + clusterareas = (int *) GetMemory(aasworld.numareas * sizeof(int)); +#endif +} //end of the function AAS_InitAlternativeRouting +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_ShutdownAlternativeRouting(void) +{ +#ifdef ENABLE_ALTROUTING + if (midrangeareas) FreeMemory(midrangeareas); + midrangeareas = NULL; + if (clusterareas) FreeMemory(clusterareas); + clusterareas = NULL; + numclusterareas = 0; +#endif +} //end of the function AAS_ShutdownAlternativeRouting diff --git a/code/botlib/be_aas_routealt.h b/code/botlib/be_aas_routealt.h new file mode 100644 index 00000000..160966a9 --- /dev/null +++ b/code/botlib/be_aas_routealt.h @@ -0,0 +1,40 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_aas_routealt.h + * + * desc: AAS + * + * $Archive: /source/code/botlib/be_aas_routealt.h $ + * + *****************************************************************************/ + +#ifdef AASINTERN +void AAS_InitAlternativeRouting(void); +void AAS_ShutdownAlternativeRouting(void); +#endif //AASINTERN + + +int AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags, + aas_altroutegoal_t *altroutegoals, int maxaltroutegoals, + int type); diff --git a/code/botlib/be_aas_sample.c b/code/botlib/be_aas_sample.c new file mode 100644 index 00000000..92b75174 --- /dev/null +++ b/code/botlib/be_aas_sample.c @@ -0,0 +1,1394 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_aas_sample.c + * + * desc: AAS environment sampling + * + * $Archive: /MissionPack/code/botlib/be_aas_sample.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_memory.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#ifndef BSPC +#include "l_libvar.h" +#endif +#include "aasfile.h" +#include "botlib.h" +#include "be_aas.h" +#include "be_interface.h" +#include "be_aas_funcs.h" +#include "be_aas_def.h" + +extern botlib_import_t botimport; + +//#define AAS_SAMPLE_DEBUG + +#define BBOX_NORMAL_EPSILON 0.001 + +#define ON_EPSILON 0 //0.0005 + +#define TRACEPLANE_EPSILON 0.125 + +typedef struct aas_tracestack_s +{ + vec3_t start; //start point of the piece of line to trace + vec3_t end; //end point of the piece of line to trace + int planenum; //last plane used as splitter + int nodenum; //node found after splitting with planenum +} aas_tracestack_t; + +int numaaslinks; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs) +{ + int index; + //bounding box size for each presence type + vec3_t boxmins[3] = {{0, 0, 0}, {-15, -15, -24}, {-15, -15, -24}}; + vec3_t boxmaxs[3] = {{0, 0, 0}, { 15, 15, 32}, { 15, 15, 8}}; + + if (presencetype == PRESENCE_NORMAL) index = 1; + else if (presencetype == PRESENCE_CROUCH) index = 2; + else + { + botimport.Print(PRT_FATAL, "AAS_PresenceTypeBoundingBox: unknown presence type\n"); + index = 2; + } //end if + VectorCopy(boxmins[index], mins); + VectorCopy(boxmaxs[index], maxs); +} //end of the function AAS_PresenceTypeBoundingBox +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitAASLinkHeap(void) +{ + int i, max_aaslinks; + + max_aaslinks = aasworld.linkheapsize; + //if there's no link heap present + if (!aasworld.linkheap) + { +#ifdef BSPC + max_aaslinks = 6144; +#else + max_aaslinks = (int) LibVarValue("max_aaslinks", "6144"); +#endif + if (max_aaslinks < 0) max_aaslinks = 0; + aasworld.linkheapsize = max_aaslinks; + aasworld.linkheap = (aas_link_t *) GetHunkMemory(max_aaslinks * sizeof(aas_link_t)); + } //end if + //link the links on the heap + aasworld.linkheap[0].prev_ent = NULL; + aasworld.linkheap[0].next_ent = &aasworld.linkheap[1]; + for (i = 1; i < max_aaslinks-1; i++) + { + aasworld.linkheap[i].prev_ent = &aasworld.linkheap[i - 1]; + aasworld.linkheap[i].next_ent = &aasworld.linkheap[i + 1]; + } //end for + aasworld.linkheap[max_aaslinks-1].prev_ent = &aasworld.linkheap[max_aaslinks-2]; + aasworld.linkheap[max_aaslinks-1].next_ent = NULL; + //pointer to the first free link + aasworld.freelinks = &aasworld.linkheap[0]; + // + numaaslinks = max_aaslinks; +} //end of the function AAS_InitAASLinkHeap +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeAASLinkHeap(void) +{ + if (aasworld.linkheap) FreeMemory(aasworld.linkheap); + aasworld.linkheap = NULL; + aasworld.linkheapsize = 0; +} //end of the function AAS_FreeAASLinkHeap +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_link_t *AAS_AllocAASLink(void) +{ + aas_link_t *link; + + link = aasworld.freelinks; + if (!link) + { +#ifndef BSPC + if (bot_developer) +#endif + { + botimport.Print(PRT_FATAL, "empty aas link heap\n"); + } //end if + return NULL; + } //end if + if (aasworld.freelinks) aasworld.freelinks = aasworld.freelinks->next_ent; + if (aasworld.freelinks) aasworld.freelinks->prev_ent = NULL; + numaaslinks--; + return link; +} //end of the function AAS_AllocAASLink +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_DeAllocAASLink(aas_link_t *link) +{ + if (aasworld.freelinks) aasworld.freelinks->prev_ent = link; + link->prev_ent = NULL; + link->next_ent = aasworld.freelinks; + link->prev_area = NULL; + link->next_area = NULL; + aasworld.freelinks = link; + numaaslinks++; +} //end of the function AAS_DeAllocAASLink +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitAASLinkedEntities(void) +{ + if (!aasworld.loaded) return; + if (aasworld.arealinkedentities) FreeMemory(aasworld.arealinkedentities); + aasworld.arealinkedentities = (aas_link_t **) GetClearedHunkMemory( + aasworld.numareas * sizeof(aas_link_t *)); +} //end of the function AAS_InitAASLinkedEntities +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeAASLinkedEntities(void) +{ + if (aasworld.arealinkedentities) FreeMemory(aasworld.arealinkedentities); + aasworld.arealinkedentities = NULL; +} //end of the function AAS_InitAASLinkedEntities +//=========================================================================== +// returns the AAS area the point is in +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_PointAreaNum(vec3_t point) +{ + int nodenum; + vec_t dist; + aas_node_t *node; + aas_plane_t *plane; + + if (!aasworld.loaded) + { + botimport.Print(PRT_ERROR, "AAS_PointAreaNum: aas not loaded\n"); + return 0; + } //end if + + //start with node 1 because node zero is a dummy used for solid leafs + nodenum = 1; + while (nodenum > 0) + { +// botimport.Print(PRT_MESSAGE, "[%d]", nodenum); +#ifdef AAS_SAMPLE_DEBUG + if (nodenum >= aasworld.numnodes) + { + botimport.Print(PRT_ERROR, "nodenum = %d >= aasworld.numnodes = %d\n", nodenum, aasworld.numnodes); + return 0; + } //end if +#endif //AAS_SAMPLE_DEBUG + node = &aasworld.nodes[nodenum]; +#ifdef AAS_SAMPLE_DEBUG + if (node->planenum < 0 || node->planenum >= aasworld.numplanes) + { + botimport.Print(PRT_ERROR, "node->planenum = %d >= aasworld.numplanes = %d\n", node->planenum, aasworld.numplanes); + return 0; + } //end if +#endif //AAS_SAMPLE_DEBUG + plane = &aasworld.planes[node->planenum]; + dist = DotProduct(point, plane->normal) - plane->dist; + if (dist > 0) nodenum = node->children[0]; + else nodenum = node->children[1]; + } //end while + if (!nodenum) + { +#ifdef AAS_SAMPLE_DEBUG + botimport.Print(PRT_MESSAGE, "in solid\n"); +#endif //AAS_SAMPLE_DEBUG + return 0; + } //end if + return -nodenum; +} //end of the function AAS_PointAreaNum +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_PointReachabilityAreaIndex( vec3_t origin ) +{ + int areanum, cluster, i, index; + + if (!aasworld.initialized) + return 0; + + if ( !origin ) + { + index = 0; + for (i = 0; i < aasworld.numclusters; i++) + { + index += aasworld.clusters[i].numreachabilityareas; + } //end for + return index; + } //end if + + areanum = AAS_PointAreaNum( origin ); + if ( !areanum || !AAS_AreaReachability(areanum) ) + return 0; + cluster = aasworld.areasettings[areanum].cluster; + areanum = aasworld.areasettings[areanum].clusterareanum; + if (cluster < 0) + { + cluster = aasworld.portals[-cluster].frontcluster; + areanum = aasworld.portals[-cluster].clusterareanum[0]; + } //end if + + index = 0; + for (i = 0; i < cluster; i++) + { + index += aasworld.clusters[i].numreachabilityareas; + } //end for + index += areanum; + return index; +} //end of the function AAS_PointReachabilityAreaIndex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_AreaCluster(int areanum) +{ + if (areanum <= 0 || areanum >= aasworld.numareas) + { + botimport.Print(PRT_ERROR, "AAS_AreaCluster: invalid area number\n"); + return 0; + } //end if + return aasworld.areasettings[areanum].cluster; +} //end of the function AAS_AreaCluster +//=========================================================================== +// returns the presence types of the given area +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_AreaPresenceType(int areanum) +{ + if (!aasworld.loaded) return 0; + if (areanum <= 0 || areanum >= aasworld.numareas) + { + botimport.Print(PRT_ERROR, "AAS_AreaPresenceType: invalid area number\n"); + return 0; + } //end if + return aasworld.areasettings[areanum].presencetype; +} //end of the function AAS_AreaPresenceType +//=========================================================================== +// returns the presence type at the given point +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_PointPresenceType(vec3_t point) +{ + int areanum; + + if (!aasworld.loaded) return 0; + + areanum = AAS_PointAreaNum(point); + if (!areanum) return PRESENCE_NONE; + return aasworld.areasettings[areanum].presencetype; +} //end of the function AAS_PointPresenceType +//=========================================================================== +// calculates the minimum distance between the origin of the box and the +// given plane when both will collide on the given side of the plane +// +// normal = normal vector of plane to calculate distance from +// mins = minimums of box relative to origin +// maxs = maximums of box relative to origin +// side = side of the plane we want to calculate the distance from +// 0 normal vector side +// 1 not normal vector side +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +vec_t AAS_BoxOriginDistanceFromPlane(vec3_t normal, vec3_t mins, vec3_t maxs, int side) +{ + vec3_t v1, v2; + int i; + + //swap maxs and mins when on the other side of the plane + if (side) + { + //get a point of the box that would be one of the first + //to collide with the plane + for (i = 0; i < 3; i++) + { + if (normal[i] > BBOX_NORMAL_EPSILON) v1[i] = maxs[i]; + else if (normal[i] < -BBOX_NORMAL_EPSILON) v1[i] = mins[i]; + else v1[i] = 0; + } //end for + } //end if + else + { + //get a point of the box that would be one of the first + //to collide with the plane + for (i = 0; i < 3; i++) + { + if (normal[i] > BBOX_NORMAL_EPSILON) v1[i] = mins[i]; + else if (normal[i] < -BBOX_NORMAL_EPSILON) v1[i] = maxs[i]; + else v1[i] = 0; + } //end for + } //end else + // + VectorCopy(normal, v2); + VectorInverse(v2); +// VectorNegate(normal, v2); + return DotProduct(v1, v2); +} //end of the function AAS_BoxOriginDistanceFromPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean AAS_AreaEntityCollision(int areanum, vec3_t start, vec3_t end, + int presencetype, int passent, aas_trace_t *trace) +{ + int collision; + vec3_t boxmins, boxmaxs; + aas_link_t *link; + bsp_trace_t bsptrace; + + AAS_PresenceTypeBoundingBox(presencetype, boxmins, boxmaxs); + + Com_Memset(&bsptrace, 0, sizeof(bsp_trace_t)); //make compiler happy + //assume no collision + bsptrace.fraction = 1; + collision = qfalse; + for (link = aasworld.arealinkedentities[areanum]; link; link = link->next_ent) + { + //ignore the pass entity + if (link->entnum == passent) continue; + // + if (AAS_EntityCollision(link->entnum, start, boxmins, boxmaxs, end, + CONTENTS_SOLID|CONTENTS_PLAYERCLIP, &bsptrace)) + { + collision = qtrue; + } //end if + } //end for + if (collision) + { + trace->startsolid = bsptrace.startsolid; + trace->ent = bsptrace.ent; + VectorCopy(bsptrace.endpos, trace->endpos); + trace->area = 0; + trace->planenum = 0; + return qtrue; + } //end if + return qfalse; +} //end of the function AAS_AreaEntityCollision +//=========================================================================== +// recursive subdivision of the line by the BSP tree. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_trace_t AAS_TraceClientBBox(vec3_t start, vec3_t end, int presencetype, + int passent) +{ + int side, nodenum, tmpplanenum; + float front, back, frac; + vec3_t cur_start, cur_end, cur_mid, v1, v2; + aas_tracestack_t tracestack[127]; + aas_tracestack_t *tstack_p; + aas_node_t *aasnode; + aas_plane_t *plane; + aas_trace_t trace; + + //clear the trace structure + Com_Memset(&trace, 0, sizeof(aas_trace_t)); + + if (!aasworld.loaded) return trace; + + tstack_p = tracestack; + //we start with the whole line on the stack + VectorCopy(start, tstack_p->start); + VectorCopy(end, tstack_p->end); + tstack_p->planenum = 0; + //start with node 1 because node zero is a dummy for a solid leaf + tstack_p->nodenum = 1; //starting at the root of the tree + tstack_p++; + + while (1) + { + //pop up the stack + tstack_p--; + //if the trace stack is empty (ended up with a piece of the + //line to be traced in an area) + if (tstack_p < tracestack) + { + tstack_p++; + //nothing was hit + trace.startsolid = qfalse; + trace.fraction = 1.0; + //endpos is the end of the line + VectorCopy(end, trace.endpos); + //nothing hit + trace.ent = 0; + trace.area = 0; + trace.planenum = 0; + return trace; + } //end if + //number of the current node to test the line against + nodenum = tstack_p->nodenum; + //if it is an area + if (nodenum < 0) + { +#ifdef AAS_SAMPLE_DEBUG + if (-nodenum > aasworld.numareasettings) + { + botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: -nodenum out of range\n"); + return trace; + } //end if +#endif //AAS_SAMPLE_DEBUG + //botimport.Print(PRT_MESSAGE, "areanum = %d, must be %d\n", -nodenum, AAS_PointAreaNum(start)); + //if can't enter the area because it hasn't got the right presence type + if (!(aasworld.areasettings[-nodenum].presencetype & presencetype)) + { + //if the start point is still the initial start point + //NOTE: no need for epsilons because the points will be + //exactly the same when they're both the start point + if (tstack_p->start[0] == start[0] && + tstack_p->start[1] == start[1] && + tstack_p->start[2] == start[2]) + { + trace.startsolid = qtrue; + trace.fraction = 0.0; + VectorClear(v1); + } //end if + else + { + trace.startsolid = qfalse; + VectorSubtract(end, start, v1); + VectorSubtract(tstack_p->start, start, v2); + trace.fraction = VectorLength(v2) / VectorNormalize(v1); + VectorMA(tstack_p->start, -0.125, v1, tstack_p->start); + } //end else + VectorCopy(tstack_p->start, trace.endpos); + trace.ent = 0; + trace.area = -nodenum; +// VectorSubtract(end, start, v1); + trace.planenum = tstack_p->planenum; + //always take the plane with normal facing towards the trace start + plane = &aasworld.planes[trace.planenum]; + if (DotProduct(v1, plane->normal) > 0) trace.planenum ^= 1; + return trace; + } //end if + else + { + if (passent >= 0) + { + if (AAS_AreaEntityCollision(-nodenum, tstack_p->start, + tstack_p->end, presencetype, passent, + &trace)) + { + if (!trace.startsolid) + { + VectorSubtract(end, start, v1); + VectorSubtract(trace.endpos, start, v2); + trace.fraction = VectorLength(v2) / VectorLength(v1); + } //end if + return trace; + } //end if + } //end if + } //end else + trace.lastarea = -nodenum; + continue; + } //end if + //if it is a solid leaf + if (!nodenum) + { + //if the start point is still the initial start point + //NOTE: no need for epsilons because the points will be + //exactly the same when they're both the start point + if (tstack_p->start[0] == start[0] && + tstack_p->start[1] == start[1] && + tstack_p->start[2] == start[2]) + { + trace.startsolid = qtrue; + trace.fraction = 0.0; + VectorClear(v1); + } //end if + else + { + trace.startsolid = qfalse; + VectorSubtract(end, start, v1); + VectorSubtract(tstack_p->start, start, v2); + trace.fraction = VectorLength(v2) / VectorNormalize(v1); + VectorMA(tstack_p->start, -0.125, v1, tstack_p->start); + } //end else + VectorCopy(tstack_p->start, trace.endpos); + trace.ent = 0; + trace.area = 0; //hit solid leaf +// VectorSubtract(end, start, v1); + trace.planenum = tstack_p->planenum; + //always take the plane with normal facing towards the trace start + plane = &aasworld.planes[trace.planenum]; + if (DotProduct(v1, plane->normal) > 0) trace.planenum ^= 1; + return trace; + } //end if +#ifdef AAS_SAMPLE_DEBUG + if (nodenum > aasworld.numnodes) + { + botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: nodenum out of range\n"); + return trace; + } //end if +#endif //AAS_SAMPLE_DEBUG + //the node to test against + aasnode = &aasworld.nodes[nodenum]; + //start point of current line to test against node + VectorCopy(tstack_p->start, cur_start); + //end point of the current line to test against node + VectorCopy(tstack_p->end, cur_end); + //the current node plane + plane = &aasworld.planes[aasnode->planenum]; + + switch(plane->type) + {/*FIXME: wtf doesn't this work? obviously the axial node planes aren't always facing positive!!! + //check for axial planes + case PLANE_X: + { + front = cur_start[0] - plane->dist; + back = cur_end[0] - plane->dist; + break; + } //end case + case PLANE_Y: + { + front = cur_start[1] - plane->dist; + back = cur_end[1] - plane->dist; + break; + } //end case + case PLANE_Z: + { + front = cur_start[2] - plane->dist; + back = cur_end[2] - plane->dist; + break; + } //end case*/ + default: //gee it's not an axial plane + { + front = DotProduct(cur_start, plane->normal) - plane->dist; + back = DotProduct(cur_end, plane->normal) - plane->dist; + break; + } //end default + } //end switch + // bk010221 - old location of FPE hack and divide by zero expression + //if the whole to be traced line is totally at the front of this node + //only go down the tree with the front child + if ((front >= -ON_EPSILON && back >= -ON_EPSILON)) + { + //keep the current start and end point on the stack + //and go down the tree with the front child + tstack_p->nodenum = aasnode->children[0]; + tstack_p++; + if (tstack_p >= &tracestack[127]) + { + botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: stack overflow\n"); + return trace; + } //end if + } //end if + //if the whole to be traced line is totally at the back of this node + //only go down the tree with the back child + else if ((front < ON_EPSILON && back < ON_EPSILON)) + { + //keep the current start and end point on the stack + //and go down the tree with the back child + tstack_p->nodenum = aasnode->children[1]; + tstack_p++; + if (tstack_p >= &tracestack[127]) + { + botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: stack overflow\n"); + return trace; + } //end if + } //end if + //go down the tree both at the front and back of the node + else + { + tmpplanenum = tstack_p->planenum; + // bk010221 - new location of divide by zero (see above) + if ( front == back ) front -= 0.001f; // bk0101022 - hack/FPE + //calculate the hitpoint with the node (split point of the line) + //put the crosspoint TRACEPLANE_EPSILON pixels on the near side + if (front < 0) frac = (front + TRACEPLANE_EPSILON)/(front-back); + else frac = (front - TRACEPLANE_EPSILON)/(front-back); // bk010221 + // + if (frac < 0) + frac = 0.001f; //0 + else if (frac > 1) + frac = 0.999f; //1 + //frac = front / (front-back); + // + cur_mid[0] = cur_start[0] + (cur_end[0] - cur_start[0]) * frac; + cur_mid[1] = cur_start[1] + (cur_end[1] - cur_start[1]) * frac; + cur_mid[2] = cur_start[2] + (cur_end[2] - cur_start[2]) * frac; + +// AAS_DrawPlaneCross(cur_mid, plane->normal, plane->dist, plane->type, LINECOLOR_RED); + //side the front part of the line is on + side = front < 0; + //first put the end part of the line on the stack (back side) + VectorCopy(cur_mid, tstack_p->start); + //not necesary to store because still on stack + //VectorCopy(cur_end, tstack_p->end); + tstack_p->planenum = aasnode->planenum; + tstack_p->nodenum = aasnode->children[!side]; + tstack_p++; + if (tstack_p >= &tracestack[127]) + { + botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: stack overflow\n"); + return trace; + } //end if + //now put the part near the start of the line on the stack so we will + //continue with thats part first. This way we'll find the first + //hit of the bbox + VectorCopy(cur_start, tstack_p->start); + VectorCopy(cur_mid, tstack_p->end); + tstack_p->planenum = tmpplanenum; + tstack_p->nodenum = aasnode->children[side]; + tstack_p++; + if (tstack_p >= &tracestack[127]) + { + botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: stack overflow\n"); + return trace; + } //end if + } //end else + } //end while +// return trace; +} //end of the function AAS_TraceClientBBox +//=========================================================================== +// recursive subdivision of the line by the BSP tree. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas) +{ + int side, nodenum, tmpplanenum; + int numareas; + float front, back, frac; + vec3_t cur_start, cur_end, cur_mid; + aas_tracestack_t tracestack[127]; + aas_tracestack_t *tstack_p; + aas_node_t *aasnode; + aas_plane_t *plane; + + numareas = 0; + areas[0] = 0; + if (!aasworld.loaded) return numareas; + + tstack_p = tracestack; + //we start with the whole line on the stack + VectorCopy(start, tstack_p->start); + VectorCopy(end, tstack_p->end); + tstack_p->planenum = 0; + //start with node 1 because node zero is a dummy for a solid leaf + tstack_p->nodenum = 1; //starting at the root of the tree + tstack_p++; + + while (1) + { + //pop up the stack + tstack_p--; + //if the trace stack is empty (ended up with a piece of the + //line to be traced in an area) + if (tstack_p < tracestack) + { + return numareas; + } //end if + //number of the current node to test the line against + nodenum = tstack_p->nodenum; + //if it is an area + if (nodenum < 0) + { +#ifdef AAS_SAMPLE_DEBUG + if (-nodenum > aasworld.numareasettings) + { + botimport.Print(PRT_ERROR, "AAS_TraceAreas: -nodenum = %d out of range\n", -nodenum); + return numareas; + } //end if +#endif //AAS_SAMPLE_DEBUG + //botimport.Print(PRT_MESSAGE, "areanum = %d, must be %d\n", -nodenum, AAS_PointAreaNum(start)); + areas[numareas] = -nodenum; + if (points) VectorCopy(tstack_p->start, points[numareas]); + numareas++; + if (numareas >= maxareas) return numareas; + continue; + } //end if + //if it is a solid leaf + if (!nodenum) + { + continue; + } //end if +#ifdef AAS_SAMPLE_DEBUG + if (nodenum > aasworld.numnodes) + { + botimport.Print(PRT_ERROR, "AAS_TraceAreas: nodenum out of range\n"); + return numareas; + } //end if +#endif //AAS_SAMPLE_DEBUG + //the node to test against + aasnode = &aasworld.nodes[nodenum]; + //start point of current line to test against node + VectorCopy(tstack_p->start, cur_start); + //end point of the current line to test against node + VectorCopy(tstack_p->end, cur_end); + //the current node plane + plane = &aasworld.planes[aasnode->planenum]; + + switch(plane->type) + {/*FIXME: wtf doesn't this work? obviously the node planes aren't always facing positive!!! + //check for axial planes + case PLANE_X: + { + front = cur_start[0] - plane->dist; + back = cur_end[0] - plane->dist; + break; + } //end case + case PLANE_Y: + { + front = cur_start[1] - plane->dist; + back = cur_end[1] - plane->dist; + break; + } //end case + case PLANE_Z: + { + front = cur_start[2] - plane->dist; + back = cur_end[2] - plane->dist; + break; + } //end case*/ + default: //gee it's not an axial plane + { + front = DotProduct(cur_start, plane->normal) - plane->dist; + back = DotProduct(cur_end, plane->normal) - plane->dist; + break; + } //end default + } //end switch + + //if the whole to be traced line is totally at the front of this node + //only go down the tree with the front child + if (front > 0 && back > 0) + { + //keep the current start and end point on the stack + //and go down the tree with the front child + tstack_p->nodenum = aasnode->children[0]; + tstack_p++; + if (tstack_p >= &tracestack[127]) + { + botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n"); + return numareas; + } //end if + } //end if + //if the whole to be traced line is totally at the back of this node + //only go down the tree with the back child + else if (front <= 0 && back <= 0) + { + //keep the current start and end point on the stack + //and go down the tree with the back child + tstack_p->nodenum = aasnode->children[1]; + tstack_p++; + if (tstack_p >= &tracestack[127]) + { + botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n"); + return numareas; + } //end if + } //end if + //go down the tree both at the front and back of the node + else + { + tmpplanenum = tstack_p->planenum; + //calculate the hitpoint with the node (split point of the line) + //put the crosspoint TRACEPLANE_EPSILON pixels on the near side + if (front < 0) frac = (front)/(front-back); + else frac = (front)/(front-back); + if (frac < 0) frac = 0; + else if (frac > 1) frac = 1; + //frac = front / (front-back); + // + cur_mid[0] = cur_start[0] + (cur_end[0] - cur_start[0]) * frac; + cur_mid[1] = cur_start[1] + (cur_end[1] - cur_start[1]) * frac; + cur_mid[2] = cur_start[2] + (cur_end[2] - cur_start[2]) * frac; + +// AAS_DrawPlaneCross(cur_mid, plane->normal, plane->dist, plane->type, LINECOLOR_RED); + //side the front part of the line is on + side = front < 0; + //first put the end part of the line on the stack (back side) + VectorCopy(cur_mid, tstack_p->start); + //not necesary to store because still on stack + //VectorCopy(cur_end, tstack_p->end); + tstack_p->planenum = aasnode->planenum; + tstack_p->nodenum = aasnode->children[!side]; + tstack_p++; + if (tstack_p >= &tracestack[127]) + { + botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n"); + return numareas; + } //end if + //now put the part near the start of the line on the stack so we will + //continue with thats part first. This way we'll find the first + //hit of the bbox + VectorCopy(cur_start, tstack_p->start); + VectorCopy(cur_mid, tstack_p->end); + tstack_p->planenum = tmpplanenum; + tstack_p->nodenum = aasnode->children[side]; + tstack_p++; + if (tstack_p >= &tracestack[127]) + { + botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n"); + return numareas; + } //end if + } //end else + } //end while +// return numareas; +} //end of the function AAS_TraceAreas +//=========================================================================== +// a simple cross product +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +// void AAS_OrthogonalToVectors(vec3_t v1, vec3_t v2, vec3_t res) +#define AAS_OrthogonalToVectors(v1, v2, res) \ + (res)[0] = ((v1)[1] * (v2)[2]) - ((v1)[2] * (v2)[1]);\ + (res)[1] = ((v1)[2] * (v2)[0]) - ((v1)[0] * (v2)[2]);\ + (res)[2] = ((v1)[0] * (v2)[1]) - ((v1)[1] * (v2)[0]); +//=========================================================================== +// tests if the given point is within the face boundaries +// +// Parameter: face : face to test if the point is in it +// pnormal : normal of the plane to use for the face +// point : point to test if inside face boundaries +// Returns: qtrue if the point is within the face boundaries +// Changes Globals: - +//=========================================================================== +qboolean AAS_InsideFace(aas_face_t *face, vec3_t pnormal, vec3_t point, float epsilon) +{ + int i, firstvertex, edgenum; + vec3_t v0; + vec3_t edgevec, pointvec, sepnormal; + aas_edge_t *edge; +#ifdef AAS_SAMPLE_DEBUG + int lastvertex = 0; +#endif //AAS_SAMPLE_DEBUG + + if (!aasworld.loaded) return qfalse; + + for (i = 0; i < face->numedges; i++) + { + edgenum = aasworld.edgeindex[face->firstedge + i]; + edge = &aasworld.edges[abs(edgenum)]; + //get the first vertex of the edge + firstvertex = edgenum < 0; + VectorCopy(aasworld.vertexes[edge->v[firstvertex]], v0); + //edge vector + VectorSubtract(aasworld.vertexes[edge->v[!firstvertex]], v0, edgevec); + // +#ifdef AAS_SAMPLE_DEBUG + if (lastvertex && lastvertex != edge->v[firstvertex]) + { + botimport.Print(PRT_MESSAGE, "winding not counter clockwise\n"); + } //end if + lastvertex = edge->v[!firstvertex]; +#endif //AAS_SAMPLE_DEBUG + //vector from first edge point to point possible in face + VectorSubtract(point, v0, pointvec); + //get a vector pointing inside the face orthogonal to both the + //edge vector and the normal vector of the plane the face is in + //this vector defines a plane through the origin (first vertex of + //edge) and through both the edge vector and the normal vector + //of the plane + AAS_OrthogonalToVectors(edgevec, pnormal, sepnormal); + //check on wich side of the above plane the point is + //this is done by checking the sign of the dot product of the + //vector orthogonal vector from above and the vector from the + //origin (first vertex of edge) to the point + //if the dotproduct is smaller than zero the point is outside the face + if (DotProduct(pointvec, sepnormal) < -epsilon) return qfalse; + } //end for + return qtrue; +} //end of the function AAS_InsideFace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean AAS_PointInsideFace(int facenum, vec3_t point, float epsilon) +{ + int i, firstvertex, edgenum; + vec_t *v1, *v2; + vec3_t edgevec, pointvec, sepnormal; + aas_edge_t *edge; + aas_plane_t *plane; + aas_face_t *face; + + if (!aasworld.loaded) return qfalse; + + face = &aasworld.faces[facenum]; + plane = &aasworld.planes[face->planenum]; + // + for (i = 0; i < face->numedges; i++) + { + edgenum = aasworld.edgeindex[face->firstedge + i]; + edge = &aasworld.edges[abs(edgenum)]; + //get the first vertex of the edge + firstvertex = edgenum < 0; + v1 = aasworld.vertexes[edge->v[firstvertex]]; + v2 = aasworld.vertexes[edge->v[!firstvertex]]; + //edge vector + VectorSubtract(v2, v1, edgevec); + //vector from first edge point to point possible in face + VectorSubtract(point, v1, pointvec); + // + CrossProduct(edgevec, plane->normal, sepnormal); + // + if (DotProduct(pointvec, sepnormal) < -epsilon) return qfalse; + } //end for + return qtrue; +} //end of the function AAS_PointInsideFace +//=========================================================================== +// returns the ground face the given point is above in the given area +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_face_t *AAS_AreaGroundFace(int areanum, vec3_t point) +{ + int i, facenum; + vec3_t up = {0, 0, 1}; + vec3_t normal; + aas_area_t *area; + aas_face_t *face; + + if (!aasworld.loaded) return NULL; + + area = &aasworld.areas[areanum]; + for (i = 0; i < area->numfaces; i++) + { + facenum = aasworld.faceindex[area->firstface + i]; + face = &aasworld.faces[abs(facenum)]; + //if this is a ground face + if (face->faceflags & FACE_GROUND) + { + //get the up or down normal + if (aasworld.planes[face->planenum].normal[2] < 0) VectorNegate(up, normal); + else VectorCopy(up, normal); + //check if the point is in the face + if (AAS_InsideFace(face, normal, point, 0.01f)) return face; + } //end if + } //end for + return NULL; +} //end of the function AAS_AreaGroundFace +//=========================================================================== +// returns the face the trace end position is situated in +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FacePlane(int facenum, vec3_t normal, float *dist) +{ + aas_plane_t *plane; + + plane = &aasworld.planes[aasworld.faces[facenum].planenum]; + VectorCopy(plane->normal, normal); + *dist = plane->dist; +} //end of the function AAS_FacePlane +//=========================================================================== +// returns the face the trace end position is situated in +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_face_t *AAS_TraceEndFace(aas_trace_t *trace) +{ + int i, facenum; + aas_area_t *area; + aas_face_t *face, *firstface = NULL; + + if (!aasworld.loaded) return NULL; + + //if started in solid no face was hit + if (trace->startsolid) return NULL; + //trace->lastarea is the last area the trace was in + area = &aasworld.areas[trace->lastarea]; + //check which face the trace.endpos was in + for (i = 0; i < area->numfaces; i++) + { + facenum = aasworld.faceindex[area->firstface + i]; + face = &aasworld.faces[abs(facenum)]; + //if the face is in the same plane as the trace end point + if ((face->planenum & ~1) == (trace->planenum & ~1)) + { + //firstface is used for optimization, if theres only one + //face in the plane then it has to be the good one + //if there are more faces in the same plane then always + //check the one with the fewest edges first +/* if (firstface) + { + if (firstface->numedges < face->numedges) + { + if (AAS_InsideFace(firstface, + aasworld.planes[face->planenum].normal, trace->endpos)) + { + return firstface; + } //end if + firstface = face; + } //end if + else + { + if (AAS_InsideFace(face, + aasworld.planes[face->planenum].normal, trace->endpos)) + { + return face; + } //end if + } //end else + } //end if + else + { + firstface = face; + } //end else*/ + if (AAS_InsideFace(face, + aasworld.planes[face->planenum].normal, trace->endpos, 0.01f)) return face; + } //end if + } //end for + return firstface; +} //end of the function AAS_TraceEndFace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_BoxOnPlaneSide2(vec3_t absmins, vec3_t absmaxs, aas_plane_t *p) +{ + int i, sides; + float dist1, dist2; + vec3_t corners[2]; + + for (i = 0; i < 3; i++) + { + if (p->normal[i] < 0) + { + corners[0][i] = absmins[i]; + corners[1][i] = absmaxs[i]; + } //end if + else + { + corners[1][i] = absmins[i]; + corners[0][i] = absmaxs[i]; + } //end else + } //end for + dist1 = DotProduct(p->normal, corners[0]) - p->dist; + dist2 = DotProduct(p->normal, corners[1]) - p->dist; + sides = 0; + if (dist1 >= 0) sides = 1; + if (dist2 < 0) sides |= 2; + + return sides; +} //end of the function AAS_BoxOnPlaneSide2 +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +//int AAS_BoxOnPlaneSide(vec3_t absmins, vec3_t absmaxs, aas_plane_t *p) +#define AAS_BoxOnPlaneSide(absmins, absmaxs, p) (\ + ( (p)->type < 3) ?\ + (\ + ( (p)->dist <= (absmins)[(p)->type]) ?\ + (\ + 1\ + )\ + :\ + (\ + ( (p)->dist >= (absmaxs)[(p)->type]) ?\ + (\ + 2\ + )\ + :\ + (\ + 3\ + )\ + )\ + )\ + :\ + (\ + AAS_BoxOnPlaneSide2((absmins), (absmaxs), (p))\ + )\ +) //end of the function AAS_BoxOnPlaneSide +//=========================================================================== +// remove the links to this entity from all areas +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_UnlinkFromAreas(aas_link_t *areas) +{ + aas_link_t *link, *nextlink; + + for (link = areas; link; link = nextlink) + { + //next area the entity is linked in + nextlink = link->next_area; + //remove the entity from the linked list of this area + if (link->prev_ent) link->prev_ent->next_ent = link->next_ent; + else aasworld.arealinkedentities[link->areanum] = link->next_ent; + if (link->next_ent) link->next_ent->prev_ent = link->prev_ent; + //deallocate the link structure + AAS_DeAllocAASLink(link); + } //end for +} //end of the function AAS_UnlinkFromAreas +//=========================================================================== +// link the entity to the areas the bounding box is totally or partly +// situated in. This is done with recursion down the tree using the +// bounding box to test for plane sides +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== + +typedef struct +{ + int nodenum; //node found after splitting +} aas_linkstack_t; + +aas_link_t *AAS_AASLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum) +{ + int side, nodenum; + aas_linkstack_t linkstack[128]; + aas_linkstack_t *lstack_p; + aas_node_t *aasnode; + aas_plane_t *plane; + aas_link_t *link, *areas; + + if (!aasworld.loaded) + { + botimport.Print(PRT_ERROR, "AAS_LinkEntity: aas not loaded\n"); + return NULL; + } //end if + + areas = NULL; + // + lstack_p = linkstack; + //we start with the whole line on the stack + //start with node 1 because node zero is a dummy used for solid leafs + lstack_p->nodenum = 1; //starting at the root of the tree + lstack_p++; + + while (1) + { + //pop up the stack + lstack_p--; + //if the trace stack is empty (ended up with a piece of the + //line to be traced in an area) + if (lstack_p < linkstack) break; + //number of the current node to test the line against + nodenum = lstack_p->nodenum; + //if it is an area + if (nodenum < 0) + { + //NOTE: the entity might have already been linked into this area + // because several node children can point to the same area + for (link = aasworld.arealinkedentities[-nodenum]; link; link = link->next_ent) + { + if (link->entnum == entnum) break; + } //end for + if (link) continue; + // + link = AAS_AllocAASLink(); + if (!link) return areas; + link->entnum = entnum; + link->areanum = -nodenum; + //put the link into the double linked area list of the entity + link->prev_area = NULL; + link->next_area = areas; + if (areas) areas->prev_area = link; + areas = link; + //put the link into the double linked entity list of the area + link->prev_ent = NULL; + link->next_ent = aasworld.arealinkedentities[-nodenum]; + if (aasworld.arealinkedentities[-nodenum]) + aasworld.arealinkedentities[-nodenum]->prev_ent = link; + aasworld.arealinkedentities[-nodenum] = link; + // + continue; + } //end if + //if solid leaf + if (!nodenum) continue; + //the node to test against + aasnode = &aasworld.nodes[nodenum]; + //the current node plane + plane = &aasworld.planes[aasnode->planenum]; + //get the side(s) the box is situated relative to the plane + side = AAS_BoxOnPlaneSide2(absmins, absmaxs, plane); + //if on the front side of the node + if (side & 1) + { + lstack_p->nodenum = aasnode->children[0]; + lstack_p++; + } //end if + if (lstack_p >= &linkstack[127]) + { + botimport.Print(PRT_ERROR, "AAS_LinkEntity: stack overflow\n"); + break; + } //end if + //if on the back side of the node + if (side & 2) + { + lstack_p->nodenum = aasnode->children[1]; + lstack_p++; + } //end if + if (lstack_p >= &linkstack[127]) + { + botimport.Print(PRT_ERROR, "AAS_LinkEntity: stack overflow\n"); + break; + } //end if + } //end while + return areas; +} //end of the function AAS_AASLinkEntity +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_link_t *AAS_LinkEntityClientBBox(vec3_t absmins, vec3_t absmaxs, int entnum, int presencetype) +{ + vec3_t mins, maxs; + vec3_t newabsmins, newabsmaxs; + + AAS_PresenceTypeBoundingBox(presencetype, mins, maxs); + VectorSubtract(absmins, maxs, newabsmins); + VectorSubtract(absmaxs, mins, newabsmaxs); + //relink the entity + return AAS_AASLinkEntity(newabsmins, newabsmaxs, entnum); +} //end of the function AAS_LinkEntityClientBBox +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas) +{ + aas_link_t *linkedareas, *link; + int num; + + linkedareas = AAS_AASLinkEntity(absmins, absmaxs, -1); + num = 0; + for (link = linkedareas; link; link = link->next_area) + { + areas[num] = link->areanum; + num++; + if (num >= maxareas) + break; + } //end for + AAS_UnlinkFromAreas(linkedareas); + return num; +} //end of the function AAS_BBoxAreas +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_AreaInfo( int areanum, aas_areainfo_t *info ) +{ + aas_areasettings_t *settings; + if (!info) + return 0; + if (areanum <= 0 || areanum >= aasworld.numareas) + { + botimport.Print(PRT_ERROR, "AAS_AreaInfo: areanum %d out of range\n", areanum); + return 0; + } //end if + settings = &aasworld.areasettings[areanum]; + info->cluster = settings->cluster; + info->contents = settings->contents; + info->flags = settings->areaflags; + info->presencetype = settings->presencetype; + VectorCopy(aasworld.areas[areanum].mins, info->mins); + VectorCopy(aasworld.areas[areanum].maxs, info->maxs); + VectorCopy(aasworld.areas[areanum].center, info->center); + return sizeof(aas_areainfo_t); +} //end of the function AAS_AreaInfo +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +aas_plane_t *AAS_PlaneFromNum(int planenum) +{ + if (!aasworld.loaded) return NULL; + + return &aasworld.planes[planenum]; +} //end of the function AAS_PlaneFromNum diff --git a/code/botlib/be_aas_sample.h b/code/botlib/be_aas_sample.h new file mode 100644 index 00000000..ed6c2371 --- /dev/null +++ b/code/botlib/be_aas_sample.h @@ -0,0 +1,69 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_aas_sample.h + * + * desc: AAS + * + * $Archive: /source/code/botlib/be_aas_sample.h $ + * + *****************************************************************************/ + +#ifdef AASINTERN +void AAS_InitAASLinkHeap(void); +void AAS_InitAASLinkedEntities(void); +void AAS_FreeAASLinkHeap(void); +void AAS_FreeAASLinkedEntities(void); +aas_face_t *AAS_AreaGroundFace(int areanum, vec3_t point); +aas_face_t *AAS_TraceEndFace(aas_trace_t *trace); +aas_plane_t *AAS_PlaneFromNum(int planenum); +aas_link_t *AAS_AASLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum); +aas_link_t *AAS_LinkEntityClientBBox(vec3_t absmins, vec3_t absmaxs, int entnum, int presencetype); +qboolean AAS_PointInsideFace(int facenum, vec3_t point, float epsilon); +qboolean AAS_InsideFace(aas_face_t *face, vec3_t pnormal, vec3_t point, float epsilon); +void AAS_UnlinkFromAreas(aas_link_t *areas); +#endif //AASINTERN + +//returns the mins and maxs of the bounding box for the given presence type +void AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs); +//returns the cluster the area is in (negative portal number if the area is a portal) +int AAS_AreaCluster(int areanum); +//returns the presence type(s) of the area +int AAS_AreaPresenceType(int areanum); +//returns the presence type(s) at the given point +int AAS_PointPresenceType(vec3_t point); +//returns the result of the trace of a client bbox +aas_trace_t AAS_TraceClientBBox(vec3_t start, vec3_t end, int presencetype, int passent); +//stores the areas the trace went through and returns the number of passed areas +int AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas); +//returns the areas the bounding box is in +int AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas); +//return area information +int AAS_AreaInfo( int areanum, aas_areainfo_t *info ); +//returns the area the point is in +int AAS_PointAreaNum(vec3_t point); +// +int AAS_PointReachabilityAreaIndex( vec3_t point ); +//returns the plane the given face is in +void AAS_FacePlane(int facenum, vec3_t normal, float *dist); + diff --git a/code/botlib/be_ai_char.c b/code/botlib/be_ai_char.c new file mode 100644 index 00000000..51520f71 --- /dev/null +++ b/code/botlib/be_ai_char.c @@ -0,0 +1,790 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_ai_char.c + * + * desc: bot characters + * + * $Archive: /MissionPack/code/botlib/be_ai_char.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_log.h" +#include "l_memory.h" +#include "l_utils.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "l_libvar.h" +#include "aasfile.h" +#include "botlib.h" +#include "be_aas.h" +#include "be_aas_funcs.h" +#include "be_interface.h" +#include "be_ai_char.h" + +#define MAX_CHARACTERISTICS 80 + +#define CT_INTEGER 1 +#define CT_FLOAT 2 +#define CT_STRING 3 + +#define DEFAULT_CHARACTER "bots/default_c.c" + +//characteristic value +union cvalue +{ + int integer; + float _float; + char *string; +}; +//a characteristic +typedef struct bot_characteristic_s +{ + char type; //characteristic type + union cvalue value; //characteristic value +} bot_characteristic_t; + +//a bot character +typedef struct bot_character_s +{ + char filename[MAX_QPATH]; + float skill; + bot_characteristic_t c[1]; //variable sized +} bot_character_t; + +bot_character_t *botcharacters[MAX_CLIENTS + 1]; + +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +bot_character_t *BotCharacterFromHandle(int handle) +{ + if (handle <= 0 || handle > MAX_CLIENTS) + { + botimport.Print(PRT_FATAL, "character handle %d out of range\n", handle); + return NULL; + } //end if + if (!botcharacters[handle]) + { + botimport.Print(PRT_FATAL, "invalid character %d\n", handle); + return NULL; + } //end if + return botcharacters[handle]; +} //end of the function BotCharacterFromHandle +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotDumpCharacter(bot_character_t *ch) +{ + int i; + + Log_Write("%s", ch->filename); + Log_Write("skill %d\n", ch->skill); + Log_Write("{\n"); + for (i = 0; i < MAX_CHARACTERISTICS; i++) + { + switch(ch->c[i].type) + { + case CT_INTEGER: Log_Write(" %4d %d\n", i, ch->c[i].value.integer); break; + case CT_FLOAT: Log_Write(" %4d %f\n", i, ch->c[i].value._float); break; + case CT_STRING: Log_Write(" %4d %s\n", i, ch->c[i].value.string); break; + } //end case + } //end for + Log_Write("}\n"); +} //end of the function BotDumpCharacter +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +void BotFreeCharacterStrings(bot_character_t *ch) +{ + int i; + + for (i = 0; i < MAX_CHARACTERISTICS; i++) + { + if (ch->c[i].type == CT_STRING) + { + FreeMemory(ch->c[i].value.string); + } //end if + } //end for +} //end of the function BotFreeCharacterStrings +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +void BotFreeCharacter2(int handle) +{ + if (handle <= 0 || handle > MAX_CLIENTS) + { + botimport.Print(PRT_FATAL, "character handle %d out of range\n", handle); + return; + } //end if + if (!botcharacters[handle]) + { + botimport.Print(PRT_FATAL, "invalid character %d\n", handle); + return; + } //end if + BotFreeCharacterStrings(botcharacters[handle]); + FreeMemory(botcharacters[handle]); + botcharacters[handle] = NULL; +} //end of the function BotFreeCharacter2 +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +void BotFreeCharacter(int handle) +{ + if (!LibVarGetValue("bot_reloadcharacters")) return; + BotFreeCharacter2(handle); +} //end of the function BotFreeCharacter +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotDefaultCharacteristics(bot_character_t *ch, bot_character_t *defaultch) +{ + int i; + + for (i = 0; i < MAX_CHARACTERISTICS; i++) + { + if (ch->c[i].type) continue; + // + if (defaultch->c[i].type == CT_FLOAT) + { + ch->c[i].type = CT_FLOAT; + ch->c[i].value._float = defaultch->c[i].value._float; + } //end if + else if (defaultch->c[i].type == CT_INTEGER) + { + ch->c[i].type = CT_INTEGER; + ch->c[i].value.integer = defaultch->c[i].value.integer; + } //end else if + else if (defaultch->c[i].type == CT_STRING) + { + ch->c[i].type = CT_STRING; + ch->c[i].value.string = (char *) GetMemory(strlen(defaultch->c[i].value.string)+1); + strcpy(ch->c[i].value.string, defaultch->c[i].value.string); + } //end else if + } //end for +} //end of the function BotDefaultCharacteristics +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_character_t *BotLoadCharacterFromFile(char *charfile, int skill) +{ + int indent, index, foundcharacter; + bot_character_t *ch; + source_t *source; + token_t token; + + foundcharacter = qfalse; + //a bot character is parsed in two phases + PC_SetBaseFolder(BOTFILESBASEFOLDER); + source = LoadSourceFile(charfile); + if (!source) + { + botimport.Print(PRT_ERROR, "counldn't load %s\n", charfile); + return NULL; + } //end if + ch = (bot_character_t *) GetClearedMemory(sizeof(bot_character_t) + + MAX_CHARACTERISTICS * sizeof(bot_characteristic_t)); + strcpy(ch->filename, charfile); + while(PC_ReadToken(source, &token)) + { + if (!strcmp(token.string, "skill")) + { + if (!PC_ExpectTokenType(source, TT_NUMBER, 0, &token)) + { + FreeSource(source); + BotFreeCharacterStrings(ch); + FreeMemory(ch); + return NULL; + } //end if + if (!PC_ExpectTokenString(source, "{")) + { + FreeSource(source); + BotFreeCharacterStrings(ch); + FreeMemory(ch); + return NULL; + } //end if + //if it's the correct skill + if (skill < 0 || token.intvalue == skill) + { + foundcharacter = qtrue; + ch->skill = token.intvalue; + while(PC_ExpectAnyToken(source, &token)) + { + if (!strcmp(token.string, "}")) break; + if (token.type != TT_NUMBER || !(token.subtype & TT_INTEGER)) + { + SourceError(source, "expected integer index, found %s\n", token.string); + FreeSource(source); + BotFreeCharacterStrings(ch); + FreeMemory(ch); + return NULL; + } //end if + index = token.intvalue; + if (index < 0 || index > MAX_CHARACTERISTICS) + { + SourceError(source, "characteristic index out of range [0, %d]\n", MAX_CHARACTERISTICS); + FreeSource(source); + BotFreeCharacterStrings(ch); + FreeMemory(ch); + return NULL; + } //end if + if (ch->c[index].type) + { + SourceError(source, "characteristic %d already initialized\n", index); + FreeSource(source); + BotFreeCharacterStrings(ch); + FreeMemory(ch); + return NULL; + } //end if + if (!PC_ExpectAnyToken(source, &token)) + { + FreeSource(source); + BotFreeCharacterStrings(ch); + FreeMemory(ch); + return NULL; + } //end if + if (token.type == TT_NUMBER) + { + if (token.subtype & TT_FLOAT) + { + ch->c[index].value._float = token.floatvalue; + ch->c[index].type = CT_FLOAT; + } //end if + else + { + ch->c[index].value.integer = token.intvalue; + ch->c[index].type = CT_INTEGER; + } //end else + } //end if + else if (token.type == TT_STRING) + { + StripDoubleQuotes(token.string); + ch->c[index].value.string = GetMemory(strlen(token.string)+1); + strcpy(ch->c[index].value.string, token.string); + ch->c[index].type = CT_STRING; + } //end else if + else + { + SourceError(source, "expected integer, float or string, found %s\n", token.string); + FreeSource(source); + BotFreeCharacterStrings(ch); + FreeMemory(ch); + return NULL; + } //end else + } //end if + break; + } //end if + else + { + indent = 1; + while(indent) + { + if (!PC_ExpectAnyToken(source, &token)) + { + FreeSource(source); + BotFreeCharacterStrings(ch); + FreeMemory(ch); + return NULL; + } //end if + if (!strcmp(token.string, "{")) indent++; + else if (!strcmp(token.string, "}")) indent--; + } //end while + } //end else + } //end if + else + { + SourceError(source, "unknown definition %s\n", token.string); + FreeSource(source); + BotFreeCharacterStrings(ch); + FreeMemory(ch); + return NULL; + } //end else + } //end while + FreeSource(source); + // + if (!foundcharacter) + { + BotFreeCharacterStrings(ch); + FreeMemory(ch); + return NULL; + } //end if + return ch; +} //end of the function BotLoadCharacterFromFile +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotFindCachedCharacter(char *charfile, float skill) +{ + int handle; + + for (handle = 1; handle <= MAX_CLIENTS; handle++) + { + if ( !botcharacters[handle] ) continue; + if ( strcmp( botcharacters[handle]->filename, charfile ) == 0 && + (skill < 0 || fabs(botcharacters[handle]->skill - skill) < 0.01) ) + { + return handle; + } //end if + } //end for + return 0; +} //end of the function BotFindCachedCharacter +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotLoadCachedCharacter(char *charfile, float skill, int reload) +{ + int handle, cachedhandle, intskill; + bot_character_t *ch = NULL; +#ifdef DEBUG + int starttime; + + starttime = Sys_MilliSeconds(); +#endif //DEBUG + + //find a free spot for a character + for (handle = 1; handle <= MAX_CLIENTS; handle++) + { + if (!botcharacters[handle]) break; + } //end for + if (handle > MAX_CLIENTS) return 0; + //try to load a cached character with the given skill + if (!reload) + { + cachedhandle = BotFindCachedCharacter(charfile, skill); + if (cachedhandle) + { + botimport.Print(PRT_MESSAGE, "loaded cached skill %f from %s\n", skill, charfile); + return cachedhandle; + } //end if + } //end else + // + intskill = (int) (skill + 0.5); + //try to load the character with the given skill + ch = BotLoadCharacterFromFile(charfile, intskill); + if (ch) + { + botcharacters[handle] = ch; + // + botimport.Print(PRT_MESSAGE, "loaded skill %d from %s\n", intskill, charfile); +#ifdef DEBUG + if (bot_developer) + { + botimport.Print(PRT_MESSAGE, "skill %d loaded in %d msec from %s\n", intskill, Sys_MilliSeconds() - starttime, charfile); + } //end if +#endif //DEBUG + return handle; + } //end if + // + botimport.Print(PRT_WARNING, "couldn't find skill %d in %s\n", intskill, charfile); + // + if (!reload) + { + //try to load a cached default character with the given skill + cachedhandle = BotFindCachedCharacter(DEFAULT_CHARACTER, skill); + if (cachedhandle) + { + botimport.Print(PRT_MESSAGE, "loaded cached default skill %d from %s\n", intskill, charfile); + return cachedhandle; + } //end if + } //end if + //try to load the default character with the given skill + ch = BotLoadCharacterFromFile(DEFAULT_CHARACTER, intskill); + if (ch) + { + botcharacters[handle] = ch; + botimport.Print(PRT_MESSAGE, "loaded default skill %d from %s\n", intskill, charfile); + return handle; + } //end if + // + if (!reload) + { + //try to load a cached character with any skill + cachedhandle = BotFindCachedCharacter(charfile, -1); + if (cachedhandle) + { + botimport.Print(PRT_MESSAGE, "loaded cached skill %f from %s\n", botcharacters[cachedhandle]->skill, charfile); + return cachedhandle; + } //end if + } //end if + //try to load a character with any skill + ch = BotLoadCharacterFromFile(charfile, -1); + if (ch) + { + botcharacters[handle] = ch; + botimport.Print(PRT_MESSAGE, "loaded skill %f from %s\n", ch->skill, charfile); + return handle; + } //end if + // + if (!reload) + { + //try to load a cached character with any skill + cachedhandle = BotFindCachedCharacter(DEFAULT_CHARACTER, -1); + if (cachedhandle) + { + botimport.Print(PRT_MESSAGE, "loaded cached default skill %f from %s\n", botcharacters[cachedhandle]->skill, charfile); + return cachedhandle; + } //end if + } //end if + //try to load a character with any skill + ch = BotLoadCharacterFromFile(DEFAULT_CHARACTER, -1); + if (ch) + { + botcharacters[handle] = ch; + botimport.Print(PRT_MESSAGE, "loaded default skill %f from %s\n", ch->skill, charfile); + return handle; + } //end if + // + botimport.Print(PRT_WARNING, "couldn't load any skill from %s\n", charfile); + //couldn't load any character + return 0; +} //end of the function BotLoadCachedCharacter +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotLoadCharacterSkill(char *charfile, float skill) +{ + int ch, defaultch; + + defaultch = BotLoadCachedCharacter(DEFAULT_CHARACTER, skill, qfalse); + ch = BotLoadCachedCharacter(charfile, skill, LibVarGetValue("bot_reloadcharacters")); + + if (defaultch && ch) + { + BotDefaultCharacteristics(botcharacters[ch], botcharacters[defaultch]); + } //end if + + return ch; +} //end of the function BotLoadCharacterSkill +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotInterpolateCharacters(int handle1, int handle2, float desiredskill) +{ + bot_character_t *ch1, *ch2, *out; + int i, handle; + float scale; + + ch1 = BotCharacterFromHandle(handle1); + ch2 = BotCharacterFromHandle(handle2); + if (!ch1 || !ch2) + return 0; + //find a free spot for a character + for (handle = 1; handle <= MAX_CLIENTS; handle++) + { + if (!botcharacters[handle]) break; + } //end for + if (handle > MAX_CLIENTS) return 0; + out = (bot_character_t *) GetClearedMemory(sizeof(bot_character_t) + + MAX_CHARACTERISTICS * sizeof(bot_characteristic_t)); + out->skill = desiredskill; + strcpy(out->filename, ch1->filename); + botcharacters[handle] = out; + + scale = (float) (desiredskill - ch1->skill) / (ch2->skill - ch1->skill); + for (i = 0; i < MAX_CHARACTERISTICS; i++) + { + // + if (ch1->c[i].type == CT_FLOAT && ch2->c[i].type == CT_FLOAT) + { + out->c[i].type = CT_FLOAT; + out->c[i].value._float = ch1->c[i].value._float + + (ch2->c[i].value._float - ch1->c[i].value._float) * scale; + } //end if + else if (ch1->c[i].type == CT_INTEGER) + { + out->c[i].type = CT_INTEGER; + out->c[i].value.integer = ch1->c[i].value.integer; + } //end else if + else if (ch1->c[i].type == CT_STRING) + { + out->c[i].type = CT_STRING; + out->c[i].value.string = (char *) GetMemory(strlen(ch1->c[i].value.string)+1); + strcpy(out->c[i].value.string, ch1->c[i].value.string); + } //end else if + } //end for + return handle; +} //end of the function BotInterpolateCharacters +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotLoadCharacter(char *charfile, float skill) +{ + int firstskill, secondskill, handle; + + //make sure the skill is in the valid range + if (skill < 1.0) skill = 1.0; + else if (skill > 5.0) skill = 5.0; + //skill 1, 4 and 5 should be available in the character files + if (skill == 1.0 || skill == 4.0 || skill == 5.0) + { + return BotLoadCharacterSkill(charfile, skill); + } //end if + //check if there's a cached skill + handle = BotFindCachedCharacter(charfile, skill); + if (handle) + { + botimport.Print(PRT_MESSAGE, "loaded cached skill %f from %s\n", skill, charfile); + return handle; + } //end if + if (skill < 4.0) + { + //load skill 1 and 4 + firstskill = BotLoadCharacterSkill(charfile, 1); + if (!firstskill) return 0; + secondskill = BotLoadCharacterSkill(charfile, 4); + if (!secondskill) return firstskill; + } //end if + else + { + //load skill 4 and 5 + firstskill = BotLoadCharacterSkill(charfile, 4); + if (!firstskill) return 0; + secondskill = BotLoadCharacterSkill(charfile, 5); + if (!secondskill) return firstskill; + } //end else + //interpolate between the two skills + handle = BotInterpolateCharacters(firstskill, secondskill, skill); + if (!handle) return 0; + //write the character to the log file + BotDumpCharacter(botcharacters[handle]); + // + return handle; +} //end of the function BotLoadCharacter +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int CheckCharacteristicIndex(int character, int index) +{ + bot_character_t *ch; + + ch = BotCharacterFromHandle(character); + if (!ch) return qfalse; + if (index < 0 || index >= MAX_CHARACTERISTICS) + { + botimport.Print(PRT_ERROR, "characteristic %d does not exist\n", index); + return qfalse; + } //end if + if (!ch->c[index].type) + { + botimport.Print(PRT_ERROR, "characteristic %d is not initialized\n", index); + return qfalse; + } //end if + return qtrue; +} //end of the function CheckCharacteristicIndex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float Characteristic_Float(int character, int index) +{ + bot_character_t *ch; + + ch = BotCharacterFromHandle(character); + if (!ch) return 0; + //check if the index is in range + if (!CheckCharacteristicIndex(character, index)) return 0; + //an integer will be converted to a float + if (ch->c[index].type == CT_INTEGER) + { + return (float) ch->c[index].value.integer; + } //end if + //floats are just returned + else if (ch->c[index].type == CT_FLOAT) + { + return ch->c[index].value._float; + } //end else if + //cannot convert a string pointer to a float + else + { + botimport.Print(PRT_ERROR, "characteristic %d is not a float\n", index); + return 0; + } //end else if +// return 0; +} //end of the function Characteristic_Float +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float Characteristic_BFloat(int character, int index, float min, float max) +{ + float value; + bot_character_t *ch; + + ch = BotCharacterFromHandle(character); + if (!ch) return 0; + if (min > max) + { + botimport.Print(PRT_ERROR, "cannot bound characteristic %d between %f and %f\n", index, min, max); + return 0; + } //end if + value = Characteristic_Float(character, index); + if (value < min) return min; + if (value > max) return max; + return value; +} //end of the function Characteristic_BFloat +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Characteristic_Integer(int character, int index) +{ + bot_character_t *ch; + + ch = BotCharacterFromHandle(character); + if (!ch) return 0; + //check if the index is in range + if (!CheckCharacteristicIndex(character, index)) return 0; + //an integer will just be returned + if (ch->c[index].type == CT_INTEGER) + { + return ch->c[index].value.integer; + } //end if + //floats are casted to integers + else if (ch->c[index].type == CT_FLOAT) + { + return (int) ch->c[index].value._float; + } //end else if + else + { + botimport.Print(PRT_ERROR, "characteristic %d is not a integer\n", index); + return 0; + } //end else if +// return 0; +} //end of the function Characteristic_Integer +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Characteristic_BInteger(int character, int index, int min, int max) +{ + int value; + bot_character_t *ch; + + ch = BotCharacterFromHandle(character); + if (!ch) return 0; + if (min > max) + { + botimport.Print(PRT_ERROR, "cannot bound characteristic %d between %d and %d\n", index, min, max); + return 0; + } //end if + value = Characteristic_Integer(character, index); + if (value < min) return min; + if (value > max) return max; + return value; +} //end of the function Characteristic_BInteger +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Characteristic_String(int character, int index, char *buf, int size) +{ + bot_character_t *ch; + + ch = BotCharacterFromHandle(character); + if (!ch) return; + //check if the index is in range + if (!CheckCharacteristicIndex(character, index)) return; + //an integer will be converted to a float + if (ch->c[index].type == CT_STRING) + { + strncpy(buf, ch->c[index].value.string, size-1); + buf[size-1] = '\0'; + return; + } //end if + else + { + botimport.Print(PRT_ERROR, "characteristic %d is not a string\n", index); + return; + } //end else if + return; +} //end of the function Characteristic_String +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotShutdownCharacters(void) +{ + int handle; + + for (handle = 1; handle <= MAX_CLIENTS; handle++) + { + if (botcharacters[handle]) + { + BotFreeCharacter2(handle); + } //end if + } //end for +} //end of the function BotShutdownCharacters + diff --git a/code/botlib/be_ai_char.h b/code/botlib/be_ai_char.h new file mode 100644 index 00000000..719d68f6 --- /dev/null +++ b/code/botlib/be_ai_char.h @@ -0,0 +1,48 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_ai_char.h + * + * desc: bot characters + * + * $Archive: /source/code/botlib/be_ai_char.h $ + * + *****************************************************************************/ + +//loads a bot character from a file +int BotLoadCharacter(char *charfile, float skill); +//frees a bot character +void BotFreeCharacter(int character); +//returns a float characteristic +float Characteristic_Float(int character, int index); +//returns a bounded float characteristic +float Characteristic_BFloat(int character, int index, float min, float max); +//returns an integer characteristic +int Characteristic_Integer(int character, int index); +//returns a bounded integer characteristic +int Characteristic_BInteger(int character, int index, int min, int max); +//returns a string characteristic +void Characteristic_String(int character, int index, char *buf, int size); +//free cached bot characters +void BotShutdownCharacters(void); diff --git a/code/botlib/be_ai_chat.c b/code/botlib/be_ai_chat.c new file mode 100644 index 00000000..6d64cf63 --- /dev/null +++ b/code/botlib/be_ai_chat.c @@ -0,0 +1,3042 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_ai_chat.c + * + * desc: bot chat AI + * + * $Archive: /MissionPack/code/botlib/be_ai_chat.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_memory.h" +#include "l_libvar.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 "botlib.h" +#include "be_aas.h" +#include "be_aas_funcs.h" +#include "be_interface.h" +#include "be_ea.h" +#include "be_ai_chat.h" + + +//escape character +#define ESCAPE_CHAR 0x01 //'_' +// +// "hi ", people, " ", 0, " entered the game" +//becomes: +// "hi _rpeople_ _v0_ entered the game" +// + +//match piece types +#define MT_VARIABLE 1 //variable match piece +#define MT_STRING 2 //string match piece +//reply chat key flags +#define RCKFL_AND 1 //key must be present +#define RCKFL_NOT 2 //key must be absent +#define RCKFL_NAME 4 //name of bot must be present +#define RCKFL_STRING 8 //key is a string +#define RCKFL_VARIABLES 16 //key is a match template +#define RCKFL_BOTNAMES 32 //key is a series of botnames +#define RCKFL_GENDERFEMALE 64 //bot must be female +#define RCKFL_GENDERMALE 128 //bot must be male +#define RCKFL_GENDERLESS 256 //bot must be genderless +//time to ignore a chat message after using it +#define CHATMESSAGE_RECENTTIME 20 + +//the actuall chat messages +typedef struct bot_chatmessage_s +{ + char *chatmessage; //chat message string + float time; //last time used + struct bot_chatmessage_s *next; //next chat message in a list +} bot_chatmessage_t; +//bot chat type with chat lines +typedef struct bot_chattype_s +{ + char name[MAX_CHATTYPE_NAME]; + int numchatmessages; + bot_chatmessage_t *firstchatmessage; + struct bot_chattype_s *next; +} bot_chattype_t; +//bot chat lines +typedef struct bot_chat_s +{ + bot_chattype_t *types; +} bot_chat_t; + +//random string +typedef struct bot_randomstring_s +{ + char *string; + struct bot_randomstring_s *next; +} bot_randomstring_t; +//list with random strings +typedef struct bot_randomlist_s +{ + char *string; + int numstrings; + bot_randomstring_t *firstrandomstring; + struct bot_randomlist_s *next; +} bot_randomlist_t; + +//synonym +typedef struct bot_synonym_s +{ + char *string; + float weight; + struct bot_synonym_s *next; +} bot_synonym_t; +//list with synonyms +typedef struct bot_synonymlist_s +{ + unsigned long int context; + float totalweight; + bot_synonym_t *firstsynonym; + struct bot_synonymlist_s *next; +} bot_synonymlist_t; + +//fixed match string +typedef struct bot_matchstring_s +{ + char *string; + struct bot_matchstring_s *next; +} bot_matchstring_t; + +//piece of a match template +typedef struct bot_matchpiece_s +{ + int type; + bot_matchstring_t *firststring; + int variable; + struct bot_matchpiece_s *next; +} bot_matchpiece_t; +//match template +typedef struct bot_matchtemplate_s +{ + unsigned long int context; + int type; + int subtype; + bot_matchpiece_t *first; + struct bot_matchtemplate_s *next; +} bot_matchtemplate_t; + +//reply chat key +typedef struct bot_replychatkey_s +{ + int flags; + char *string; + bot_matchpiece_t *match; + struct bot_replychatkey_s *next; +} bot_replychatkey_t; +//reply chat +typedef struct bot_replychat_s +{ + bot_replychatkey_t *keys; + float priority; + int numchatmessages; + bot_chatmessage_t *firstchatmessage; + struct bot_replychat_s *next; +} bot_replychat_t; + +//string list +typedef struct bot_stringlist_s +{ + char *string; + struct bot_stringlist_s *next; +} bot_stringlist_t; + +//chat state of a bot +typedef struct bot_chatstate_s +{ + int gender; //0=it, 1=female, 2=male + int client; //client number + char name[32]; //name of the bot + char chatmessage[MAX_MESSAGE_SIZE]; + int handle; + //the console messages visible to the bot + bot_consolemessage_t *firstmessage; //first message is the first typed message + bot_consolemessage_t *lastmessage; //last message is the last typed message, bottom of console + //number of console messages stored in the state + int numconsolemessages; + //the bot chat lines + bot_chat_t *chat; +} bot_chatstate_t; + +typedef struct { + bot_chat_t *chat; + char filename[MAX_QPATH]; + char chatname[MAX_QPATH]; +} bot_ichatdata_t; + +bot_ichatdata_t *ichatdata[MAX_CLIENTS]; + +bot_chatstate_t *botchatstates[MAX_CLIENTS+1]; +//console message heap +bot_consolemessage_t *consolemessageheap = NULL; +bot_consolemessage_t *freeconsolemessages = NULL; +//list with match strings +bot_matchtemplate_t *matchtemplates = NULL; +//list with synonyms +bot_synonymlist_t *synonyms = NULL; +//list with random strings +bot_randomlist_t *randomstrings = NULL; +//reply chats +bot_replychat_t *replychats = NULL; + +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +bot_chatstate_t *BotChatStateFromHandle(int handle) +{ + if (handle <= 0 || handle > MAX_CLIENTS) + { + botimport.Print(PRT_FATAL, "chat state handle %d out of range\n", handle); + return NULL; + } //end if + if (!botchatstates[handle]) + { + botimport.Print(PRT_FATAL, "invalid chat state %d\n", handle); + return NULL; + } //end if + return botchatstates[handle]; +} //end of the function BotChatStateFromHandle +//=========================================================================== +// initialize the heap with unused console messages +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void InitConsoleMessageHeap(void) +{ + int i, max_messages; + + if (consolemessageheap) FreeMemory(consolemessageheap); + // + max_messages = (int) LibVarValue("max_messages", "1024"); + consolemessageheap = (bot_consolemessage_t *) GetClearedHunkMemory(max_messages * + sizeof(bot_consolemessage_t)); + consolemessageheap[0].prev = NULL; + consolemessageheap[0].next = &consolemessageheap[1]; + for (i = 1; i < max_messages-1; i++) + { + consolemessageheap[i].prev = &consolemessageheap[i - 1]; + consolemessageheap[i].next = &consolemessageheap[i + 1]; + } //end for + consolemessageheap[max_messages-1].prev = &consolemessageheap[max_messages-2]; + consolemessageheap[max_messages-1].next = NULL; + //pointer to the free console messages + freeconsolemessages = consolemessageheap; +} //end of the function InitConsoleMessageHeap +//=========================================================================== +// allocate one console message from the heap +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_consolemessage_t *AllocConsoleMessage(void) +{ + bot_consolemessage_t *message; + message = freeconsolemessages; + if (freeconsolemessages) freeconsolemessages = freeconsolemessages->next; + if (freeconsolemessages) freeconsolemessages->prev = NULL; + return message; +} //end of the function AllocConsoleMessage +//=========================================================================== +// deallocate one console message from the heap +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeConsoleMessage(bot_consolemessage_t *message) +{ + if (freeconsolemessages) freeconsolemessages->prev = message; + message->prev = NULL; + message->next = freeconsolemessages; + freeconsolemessages = message; +} //end of the function FreeConsoleMessage +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotRemoveConsoleMessage(int chatstate, int handle) +{ + bot_consolemessage_t *m, *nextm; + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return; + + for (m = cs->firstmessage; m; m = nextm) + { + nextm = m->next; + if (m->handle == handle) + { + if (m->next) m->next->prev = m->prev; + else cs->lastmessage = m->prev; + if (m->prev) m->prev->next = m->next; + else cs->firstmessage = m->next; + + FreeConsoleMessage(m); + cs->numconsolemessages--; + break; + } //end if + } //end for +} //end of the function BotRemoveConsoleMessage +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotQueueConsoleMessage(int chatstate, int type, char *message) +{ + bot_consolemessage_t *m; + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return; + + m = AllocConsoleMessage(); + if (!m) + { + botimport.Print(PRT_ERROR, "empty console message heap\n"); + return; + } //end if + cs->handle++; + if (cs->handle <= 0 || cs->handle > 8192) cs->handle = 1; + m->handle = cs->handle; + m->time = AAS_Time(); + m->type = type; + strncpy(m->message, message, MAX_MESSAGE_SIZE); + m->next = NULL; + if (cs->lastmessage) + { + cs->lastmessage->next = m; + m->prev = cs->lastmessage; + cs->lastmessage = m; + } //end if + else + { + cs->lastmessage = m; + cs->firstmessage = m; + m->prev = NULL; + } //end if + cs->numconsolemessages++; +} //end of the function BotQueueConsoleMessage +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm) +{ + bot_chatstate_t *cs; + bot_consolemessage_t *firstmsg; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return 0; + if ((firstmsg = cs->firstmessage)) + { + cm->handle = firstmsg->handle; + cm->time = firstmsg->time; + cm->type = firstmsg->type; + Q_strncpyz(cm->message, firstmsg->message, + sizeof(cm->message)); + + /* We omit setting the two pointers in cm because pointer + * size in the VM differs between the size in the engine on + * 64 bit machines, which would lead to a buffer overflow if + * this functions is called from the VM. The pointers are + * of no interest to functions calling + * BotNextConsoleMessage anyways. + */ + + return cm->handle; + } //end if + return 0; +} //end of the function BotConsoleMessage +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotNumConsoleMessages(int chatstate) +{ + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return 0; + return cs->numconsolemessages; +} //end of the function BotNumConsoleMessages +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int IsWhiteSpace(char c) +{ + if ((c >= 'a' && c <= 'z') + || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9') + || c == '(' || c == ')' + || c == '?' || c == ':' + || c == '\''|| c == '/' + || c == ',' || c == '.' + || c == '[' || c == ']' + || c == '-' || c == '_' + || c == '+' || c == '=') return qfalse; + return qtrue; +} //end of the function IsWhiteSpace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotRemoveTildes(char *message) +{ + int i; + + //remove all tildes from the chat message + for (i = 0; message[i]; i++) + { + if (message[i] == '~') + { + memmove(&message[i], &message[i+1], strlen(&message[i+1])+1); + } //end if + } //end for +} //end of the function BotRemoveTildes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void UnifyWhiteSpaces(char *string) +{ + char *ptr, *oldptr; + + for (ptr = oldptr = string; *ptr; oldptr = ptr) + { + while(*ptr && IsWhiteSpace(*ptr)) ptr++; + if (ptr > oldptr) + { + //if not at the start and not at the end of the string + //write only one space + if (oldptr > string && *ptr) *oldptr++ = ' '; + //remove all other white spaces + if (ptr > oldptr) memmove(oldptr, ptr, strlen(ptr)+1); + } //end if + while(*ptr && !IsWhiteSpace(*ptr)) ptr++; + } //end while +} //end of the function UnifyWhiteSpaces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int StringContains(char *str1, char *str2, int casesensitive) +{ + int len, i, j, index; + + if (str1 == NULL || str2 == NULL) return -1; + + len = strlen(str1) - strlen(str2); + index = 0; + for (i = 0; i <= len; i++, str1++, index++) + { + for (j = 0; str2[j]; j++) + { + if (casesensitive) + { + if (str1[j] != str2[j]) break; + } //end if + else + { + if (toupper(str1[j]) != toupper(str2[j])) break; + } //end else + } //end for + if (!str2[j]) return index; + } //end for + return -1; +} //end of the function StringContains +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *StringContainsWord(char *str1, char *str2, int casesensitive) +{ + int len, i, j; + + len = strlen(str1) - strlen(str2); + for (i = 0; i <= len; i++, str1++) + { + //if not at the start of the string + if (i) + { + //skip to the start of the next word + while(*str1 && *str1 != ' ' && *str1 != '.' && *str1 != ',' && *str1 != '!') str1++; + if (!*str1) break; + str1++; + } //end for + //compare the word + for (j = 0; str2[j]; j++) + { + if (casesensitive) + { + if (str1[j] != str2[j]) break; + } //end if + else + { + if (toupper(str1[j]) != toupper(str2[j])) break; + } //end else + } //end for + //if there was a word match + if (!str2[j]) + { + //if the first string has an end of word + if (!str1[j] || str1[j] == ' ' || str1[j] == '.' || str1[j] == ',' || str1[j] == '!') return str1; + } //end if + } //end for + return NULL; +} //end of the function StringContainsWord +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void StringReplaceWords(char *string, char *synonym, char *replacement) +{ + char *str, *str2; + + //find the synonym in the string + str = StringContainsWord(string, synonym, qfalse); + //if the synonym occured in the string + while(str) + { + //if the synonym isn't part of the replacement which is already in the string + //usefull for abreviations + str2 = StringContainsWord(string, replacement, qfalse); + while(str2) + { + if (str2 <= str && str < str2 + strlen(replacement)) break; + str2 = StringContainsWord(str2+1, replacement, qfalse); + } //end while + if (!str2) + { + memmove(str + strlen(replacement), str+strlen(synonym), strlen(str+strlen(synonym))+1); + //append the synonum replacement + Com_Memcpy(str, replacement, strlen(replacement)); + } //end if + //find the next synonym in the string + str = StringContainsWord(str+strlen(replacement), synonym, qfalse); + } //end if +} //end of the function StringReplaceWords +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotDumpSynonymList(bot_synonymlist_t *synlist) +{ + FILE *fp; + bot_synonymlist_t *syn; + bot_synonym_t *synonym; + + fp = Log_FilePointer(); + if (!fp) return; + for (syn = synlist; syn; syn = syn->next) + { + fprintf(fp, "%ld : [", syn->context); + for (synonym = syn->firstsynonym; synonym; synonym = synonym->next) + { + fprintf(fp, "(\"%s\", %1.2f)", synonym->string, synonym->weight); + if (synonym->next) fprintf(fp, ", "); + } //end for + fprintf(fp, "]\n"); + } //end for +} //end of the function BotDumpSynonymList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_synonymlist_t *BotLoadSynonyms(char *filename) +{ + int pass, size, contextlevel, numsynonyms; + unsigned long int context, contextstack[32]; + char *ptr = NULL; + source_t *source; + token_t token; + bot_synonymlist_t *synlist, *lastsyn, *syn; + bot_synonym_t *synonym, *lastsynonym; + + size = 0; + synlist = NULL; //make compiler happy + syn = NULL; //make compiler happy + synonym = NULL; //make compiler happy + //the synonyms are parsed in two phases + for (pass = 0; pass < 2; pass++) + { + // + if (pass && size) ptr = (char *) GetClearedHunkMemory(size); + // + PC_SetBaseFolder(BOTFILESBASEFOLDER); + source = LoadSourceFile(filename); + if (!source) + { + botimport.Print(PRT_ERROR, "counldn't load %s\n", filename); + return NULL; + } //end if + // + context = 0; + contextlevel = 0; + synlist = NULL; //list synonyms + lastsyn = NULL; //last synonym in the list + // + while(PC_ReadToken(source, &token)) + { + if (token.type == TT_NUMBER) + { + context |= token.intvalue; + contextstack[contextlevel] = token.intvalue; + contextlevel++; + if (contextlevel >= 32) + { + SourceError(source, "more than 32 context levels"); + FreeSource(source); + return NULL; + } //end if + if (!PC_ExpectTokenString(source, "{")) + { + FreeSource(source); + return NULL; + } //end if + } //end if + else if (token.type == TT_PUNCTUATION) + { + if (!strcmp(token.string, "}")) + { + contextlevel--; + if (contextlevel < 0) + { + SourceError(source, "too many }"); + FreeSource(source); + return NULL; + } //end if + context &= ~contextstack[contextlevel]; + } //end if + else if (!strcmp(token.string, "[")) + { + size += sizeof(bot_synonymlist_t); + if (pass) + { + syn = (bot_synonymlist_t *) ptr; + ptr += sizeof(bot_synonymlist_t); + syn->context = context; + syn->firstsynonym = NULL; + syn->next = NULL; + if (lastsyn) lastsyn->next = syn; + else synlist = syn; + lastsyn = syn; + } //end if + numsynonyms = 0; + lastsynonym = NULL; + while(1) + { + size_t len; + if (!PC_ExpectTokenString(source, "(") || + !PC_ExpectTokenType(source, TT_STRING, 0, &token)) + { + FreeSource(source); + return NULL; + } //end if + StripDoubleQuotes(token.string); + if (strlen(token.string) <= 0) + { + SourceError(source, "empty string", token.string); + FreeSource(source); + return NULL; + } //end if + len = strlen(token.string) + 1; + len = PAD(len, sizeof(long)); + size += sizeof(bot_synonym_t) + len; + if (pass) + { + synonym = (bot_synonym_t *) ptr; + ptr += sizeof(bot_synonym_t); + synonym->string = ptr; + ptr += len; + strcpy(synonym->string, token.string); + // + if (lastsynonym) lastsynonym->next = synonym; + else syn->firstsynonym = synonym; + lastsynonym = synonym; + } //end if + numsynonyms++; + if (!PC_ExpectTokenString(source, ",") || + !PC_ExpectTokenType(source, TT_NUMBER, 0, &token) || + !PC_ExpectTokenString(source, ")")) + { + FreeSource(source); + return NULL; + } //end if + if (pass) + { + synonym->weight = token.floatvalue; + syn->totalweight += synonym->weight; + } //end if + if (PC_CheckTokenString(source, "]")) break; + if (!PC_ExpectTokenString(source, ",")) + { + FreeSource(source); + return NULL; + } //end if + } //end while + if (numsynonyms < 2) + { + SourceError(source, "synonym must have at least two entries\n"); + FreeSource(source); + return NULL; + } //end if + } //end else + else + { + SourceError(source, "unexpected %s", token.string); + FreeSource(source); + return NULL; + } //end if + } //end else if + } //end while + // + FreeSource(source); + // + if (contextlevel > 0) + { + SourceError(source, "missing }"); + return NULL; + } //end if + } //end for + botimport.Print(PRT_MESSAGE, "loaded %s\n", filename); + // + //BotDumpSynonymList(synlist); + // + return synlist; +} //end of the function BotLoadSynonyms +//=========================================================================== +// replace all the synonyms in the string +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotReplaceSynonyms(char *string, unsigned long int context) +{ + bot_synonymlist_t *syn; + bot_synonym_t *synonym; + + for (syn = synonyms; syn; syn = syn->next) + { + if (!(syn->context & context)) continue; + for (synonym = syn->firstsynonym->next; synonym; synonym = synonym->next) + { + StringReplaceWords(string, synonym->string, syn->firstsynonym->string); + } //end for + } //end for +} //end of the function BotReplaceSynonyms +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotReplaceWeightedSynonyms(char *string, unsigned long int context) +{ + bot_synonymlist_t *syn; + bot_synonym_t *synonym, *replacement; + float weight, curweight; + + for (syn = synonyms; syn; syn = syn->next) + { + if (!(syn->context & context)) continue; + //choose a weighted random replacement synonym + weight = random() * syn->totalweight; + if (!weight) continue; + curweight = 0; + for (replacement = syn->firstsynonym; replacement; replacement = replacement->next) + { + curweight += replacement->weight; + if (weight < curweight) break; + } //end for + if (!replacement) continue; + //replace all synonyms with the replacement + for (synonym = syn->firstsynonym; synonym; synonym = synonym->next) + { + if (synonym == replacement) continue; + StringReplaceWords(string, synonym->string, replacement->string); + } //end for + } //end for +} //end of the function BotReplaceWeightedSynonyms +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotReplaceReplySynonyms(char *string, unsigned long int context) +{ + char *str1, *str2, *replacement; + bot_synonymlist_t *syn; + bot_synonym_t *synonym; + + for (str1 = string; *str1; ) + { + //go to the start of the next word + while(*str1 && *str1 <= ' ') str1++; + if (!*str1) break; + // + for (syn = synonyms; syn; syn = syn->next) + { + if (!(syn->context & context)) continue; + for (synonym = syn->firstsynonym->next; synonym; synonym = synonym->next) + { + str2 = synonym->string; + //if the synonym is not at the front of the string continue + str2 = StringContainsWord(str1, synonym->string, qfalse); + if (!str2 || str2 != str1) continue; + // + replacement = syn->firstsynonym->string; + //if the replacement IS in front of the string continue + str2 = StringContainsWord(str1, replacement, qfalse); + if (str2 && str2 == str1) continue; + // + memmove(str1 + strlen(replacement), str1+strlen(synonym->string), + strlen(str1+strlen(synonym->string)) + 1); + //append the synonum replacement + Com_Memcpy(str1, replacement, strlen(replacement)); + // + break; + } //end for + //if a synonym has been replaced + if (synonym) break; + } //end for + //skip over this word + while(*str1 && *str1 > ' ') str1++; + if (!*str1) break; + } //end while +} //end of the function BotReplaceReplySynonyms +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotLoadChatMessage(source_t *source, char *chatmessagestring) +{ + char *ptr; + token_t token; + + ptr = chatmessagestring; + *ptr = 0; + // + while(1) + { + if (!PC_ExpectAnyToken(source, &token)) return qfalse; + //fixed string + if (token.type == TT_STRING) + { + StripDoubleQuotes(token.string); + if (strlen(ptr) + strlen(token.string) + 1 > MAX_MESSAGE_SIZE) + { + SourceError(source, "chat message too long\n"); + return qfalse; + } //end if + strcat(ptr, token.string); + } //end else if + //variable string + else if (token.type == TT_NUMBER && (token.subtype & TT_INTEGER)) + { + if (strlen(ptr) + 7 > MAX_MESSAGE_SIZE) + { + SourceError(source, "chat message too long\n"); + return qfalse; + } //end if + sprintf(&ptr[strlen(ptr)], "%cv%ld%c", ESCAPE_CHAR, token.intvalue, ESCAPE_CHAR); + } //end if + //random string + else if (token.type == TT_NAME) + { + if (strlen(ptr) + 7 > MAX_MESSAGE_SIZE) + { + SourceError(source, "chat message too long\n"); + return qfalse; + } //end if + sprintf(&ptr[strlen(ptr)], "%cr%s%c", ESCAPE_CHAR, token.string, ESCAPE_CHAR); + } //end else if + else + { + SourceError(source, "unknown message component %s\n", token.string); + return qfalse; + } //end else + if (PC_CheckTokenString(source, ";")) break; + if (!PC_ExpectTokenString(source, ",")) return qfalse; + } //end while + // + return qtrue; +} //end of the function BotLoadChatMessage +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotDumpRandomStringList(bot_randomlist_t *randomlist) +{ + FILE *fp; + bot_randomlist_t *random; + bot_randomstring_t *rs; + + fp = Log_FilePointer(); + if (!fp) return; + for (random = randomlist; random; random = random->next) + { + fprintf(fp, "%s = {", random->string); + for (rs = random->firstrandomstring; rs; rs = rs->next) + { + fprintf(fp, "\"%s\"", rs->string); + if (rs->next) fprintf(fp, ", "); + else fprintf(fp, "}\n"); + } //end for + } //end for +} //end of the function BotDumpRandomStringList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_randomlist_t *BotLoadRandomStrings(char *filename) +{ + int pass, size; + char *ptr = NULL, chatmessagestring[MAX_MESSAGE_SIZE]; + source_t *source; + token_t token; + bot_randomlist_t *randomlist, *lastrandom, *random; + bot_randomstring_t *randomstring; + +#ifdef DEBUG + int starttime = Sys_MilliSeconds(); +#endif //DEBUG + + size = 0; + randomlist = NULL; + random = NULL; + //the synonyms are parsed in two phases + for (pass = 0; pass < 2; pass++) + { + // + if (pass && size) ptr = (char *) GetClearedHunkMemory(size); + // + PC_SetBaseFolder(BOTFILESBASEFOLDER); + source = LoadSourceFile(filename); + if (!source) + { + botimport.Print(PRT_ERROR, "counldn't load %s\n", filename); + return NULL; + } //end if + // + randomlist = NULL; //list + lastrandom = NULL; //last + // + while(PC_ReadToken(source, &token)) + { + size_t len; + if (token.type != TT_NAME) + { + SourceError(source, "unknown random %s", token.string); + FreeSource(source); + return NULL; + } //end if + len = strlen(token.string) + 1; + len = PAD(len, sizeof(long)); + size += sizeof(bot_randomlist_t) + len; + if (pass) + { + random = (bot_randomlist_t *) ptr; + ptr += sizeof(bot_randomlist_t); + random->string = ptr; + ptr += len; + strcpy(random->string, token.string); + random->firstrandomstring = NULL; + random->numstrings = 0; + // + if (lastrandom) lastrandom->next = random; + else randomlist = random; + lastrandom = random; + } //end if + if (!PC_ExpectTokenString(source, "=") || + !PC_ExpectTokenString(source, "{")) + { + FreeSource(source); + return NULL; + } //end if + while(!PC_CheckTokenString(source, "}")) + { + size_t len; + if (!BotLoadChatMessage(source, chatmessagestring)) + { + FreeSource(source); + return NULL; + } //end if + len = strlen(chatmessagestring) + 1; + len = PAD(len, sizeof(long)); + size += sizeof(bot_randomstring_t) + len; + if (pass) + { + randomstring = (bot_randomstring_t *) ptr; + ptr += sizeof(bot_randomstring_t); + randomstring->string = ptr; + ptr += len; + strcpy(randomstring->string, chatmessagestring); + // + random->numstrings++; + randomstring->next = random->firstrandomstring; + random->firstrandomstring = randomstring; + } //end if + } //end while + } //end while + //free the source after one pass + FreeSource(source); + } //end for + botimport.Print(PRT_MESSAGE, "loaded %s\n", filename); + // +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "random strings %d msec\n", Sys_MilliSeconds() - starttime); + //BotDumpRandomStringList(randomlist); +#endif //DEBUG + // + return randomlist; +} //end of the function BotLoadRandomStrings +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *RandomString(char *name) +{ + bot_randomlist_t *random; + bot_randomstring_t *rs; + int i; + + for (random = randomstrings; random; random = random->next) + { + if (!strcmp(random->string, name)) + { + i = random() * random->numstrings; + for (rs = random->firstrandomstring; rs; rs = rs->next) + { + if (--i < 0) break; + } //end for + if (rs) + { + return rs->string; + } //end if + } //end for + } //end for + return NULL; +} //end of the function RandomString +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotDumpMatchTemplates(bot_matchtemplate_t *matches) +{ + FILE *fp; + bot_matchtemplate_t *mt; + bot_matchpiece_t *mp; + bot_matchstring_t *ms; + + fp = Log_FilePointer(); + if (!fp) return; + for (mt = matches; mt; mt = mt->next) + { + fprintf(fp, "{ " ); + for (mp = mt->first; mp; mp = mp->next) + { + if (mp->type == MT_STRING) + { + for (ms = mp->firststring; ms; ms = ms->next) + { + fprintf(fp, "\"%s\"", ms->string); + if (ms->next) fprintf(fp, "|"); + } //end for + } //end if + else if (mp->type == MT_VARIABLE) + { + fprintf(fp, "%d", mp->variable); + } //end else if + if (mp->next) fprintf(fp, ", "); + } //end for + fprintf(fp, " = (%d, %d);}\n", mt->type, mt->subtype); + } //end for +} //end of the function BotDumpMatchTemplates +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotFreeMatchPieces(bot_matchpiece_t *matchpieces) +{ + bot_matchpiece_t *mp, *nextmp; + bot_matchstring_t *ms, *nextms; + + for (mp = matchpieces; mp; mp = nextmp) + { + nextmp = mp->next; + if (mp->type == MT_STRING) + { + for (ms = mp->firststring; ms; ms = nextms) + { + nextms = ms->next; + FreeMemory(ms); + } //end for + } //end if + FreeMemory(mp); + } //end for +} //end of the function BotFreeMatchPieces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_matchpiece_t *BotLoadMatchPieces(source_t *source, char *endtoken) +{ + int lastwasvariable, emptystring; + token_t token; + bot_matchpiece_t *matchpiece, *firstpiece, *lastpiece; + bot_matchstring_t *matchstring, *lastmatchstring; + + firstpiece = NULL; + lastpiece = NULL; + // + lastwasvariable = qfalse; + // + while(PC_ReadToken(source, &token)) + { + if (token.type == TT_NUMBER && (token.subtype & TT_INTEGER)) + { + if (token.intvalue < 0 || token.intvalue >= MAX_MATCHVARIABLES) + { + SourceError(source, "can't have more than %d match variables\n", MAX_MATCHVARIABLES); + FreeSource(source); + BotFreeMatchPieces(firstpiece); + return NULL; + } //end if + if (lastwasvariable) + { + SourceError(source, "not allowed to have adjacent variables\n"); + FreeSource(source); + BotFreeMatchPieces(firstpiece); + return NULL; + } //end if + lastwasvariable = qtrue; + // + matchpiece = (bot_matchpiece_t *) GetClearedHunkMemory(sizeof(bot_matchpiece_t)); + matchpiece->type = MT_VARIABLE; + matchpiece->variable = token.intvalue; + matchpiece->next = NULL; + if (lastpiece) lastpiece->next = matchpiece; + else firstpiece = matchpiece; + lastpiece = matchpiece; + } //end if + else if (token.type == TT_STRING) + { + // + matchpiece = (bot_matchpiece_t *) GetClearedHunkMemory(sizeof(bot_matchpiece_t)); + matchpiece->firststring = NULL; + matchpiece->type = MT_STRING; + matchpiece->variable = 0; + matchpiece->next = NULL; + if (lastpiece) lastpiece->next = matchpiece; + else firstpiece = matchpiece; + lastpiece = matchpiece; + // + lastmatchstring = NULL; + emptystring = qfalse; + // + do + { + if (matchpiece->firststring) + { + if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) + { + FreeSource(source); + BotFreeMatchPieces(firstpiece); + return NULL; + } //end if + } //end if + StripDoubleQuotes(token.string); + matchstring = (bot_matchstring_t *) GetClearedHunkMemory(sizeof(bot_matchstring_t) + strlen(token.string) + 1); + matchstring->string = (char *) matchstring + sizeof(bot_matchstring_t); + strcpy(matchstring->string, token.string); + if (!strlen(token.string)) emptystring = qtrue; + matchstring->next = NULL; + if (lastmatchstring) lastmatchstring->next = matchstring; + else matchpiece->firststring = matchstring; + lastmatchstring = matchstring; + } while(PC_CheckTokenString(source, "|")); + //if there was no empty string found + if (!emptystring) lastwasvariable = qfalse; + } //end if + else + { + SourceError(source, "invalid token %s\n", token.string); + FreeSource(source); + BotFreeMatchPieces(firstpiece); + return NULL; + } //end else + if (PC_CheckTokenString(source, endtoken)) break; + if (!PC_ExpectTokenString(source, ",")) + { + FreeSource(source); + BotFreeMatchPieces(firstpiece); + return NULL; + } //end if + } //end while + return firstpiece; +} //end of the function BotLoadMatchPieces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotFreeMatchTemplates(bot_matchtemplate_t *mt) +{ + bot_matchtemplate_t *nextmt; + + for (; mt; mt = nextmt) + { + nextmt = mt->next; + BotFreeMatchPieces(mt->first); + FreeMemory(mt); + } //end for +} //end of the function BotFreeMatchTemplates +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_matchtemplate_t *BotLoadMatchTemplates(char *matchfile) +{ + source_t *source; + token_t token; + bot_matchtemplate_t *matchtemplate, *matches, *lastmatch; + unsigned long int context; + + PC_SetBaseFolder(BOTFILESBASEFOLDER); + source = LoadSourceFile(matchfile); + if (!source) + { + botimport.Print(PRT_ERROR, "counldn't load %s\n", matchfile); + return NULL; + } //end if + // + matches = NULL; //list with matches + lastmatch = NULL; //last match in the list + + while(PC_ReadToken(source, &token)) + { + if (token.type != TT_NUMBER || !(token.subtype & TT_INTEGER)) + { + SourceError(source, "expected integer, found %s\n", token.string); + BotFreeMatchTemplates(matches); + FreeSource(source); + return NULL; + } //end if + //the context + context = token.intvalue; + // + if (!PC_ExpectTokenString(source, "{")) + { + BotFreeMatchTemplates(matches); + FreeSource(source); + return NULL; + } //end if + // + while(PC_ReadToken(source, &token)) + { + if (!strcmp(token.string, "}")) break; + // + PC_UnreadLastToken(source); + // + matchtemplate = (bot_matchtemplate_t *) GetClearedHunkMemory(sizeof(bot_matchtemplate_t)); + matchtemplate->context = context; + matchtemplate->next = NULL; + //add the match template to the list + if (lastmatch) lastmatch->next = matchtemplate; + else matches = matchtemplate; + lastmatch = matchtemplate; + //load the match template + matchtemplate->first = BotLoadMatchPieces(source, "="); + if (!matchtemplate->first) + { + BotFreeMatchTemplates(matches); + return NULL; + } //end if + //read the match type + if (!PC_ExpectTokenString(source, "(") || + !PC_ExpectTokenType(source, TT_NUMBER, TT_INTEGER, &token)) + { + BotFreeMatchTemplates(matches); + FreeSource(source); + return NULL; + } //end if + matchtemplate->type = token.intvalue; + //read the match subtype + if (!PC_ExpectTokenString(source, ",") || + !PC_ExpectTokenType(source, TT_NUMBER, TT_INTEGER, &token)) + { + BotFreeMatchTemplates(matches); + FreeSource(source); + return NULL; + } //end if + matchtemplate->subtype = token.intvalue; + //read trailing punctuations + if (!PC_ExpectTokenString(source, ")") || + !PC_ExpectTokenString(source, ";")) + { + BotFreeMatchTemplates(matches); + FreeSource(source); + return NULL; + } //end if + } //end while + } //end while + //free the source + FreeSource(source); + botimport.Print(PRT_MESSAGE, "loaded %s\n", matchfile); + // + //BotDumpMatchTemplates(matches); + // + return matches; +} //end of the function BotLoadMatchTemplates +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int StringsMatch(bot_matchpiece_t *pieces, bot_match_t *match) +{ + int lastvariable, index; + char *strptr, *newstrptr; + bot_matchpiece_t *mp; + bot_matchstring_t *ms; + + //no last variable + lastvariable = -1; + //pointer to the string to compare the match string with + strptr = match->string; + //Log_Write("match: %s", strptr); + //compare the string with the current match string + for (mp = pieces; mp; mp = mp->next) + { + //if it is a piece of string + if (mp->type == MT_STRING) + { + newstrptr = NULL; + for (ms = mp->firststring; ms; ms = ms->next) + { + if (!strlen(ms->string)) + { + newstrptr = strptr; + break; + } //end if + //Log_Write("MT_STRING: %s", mp->string); + index = StringContains(strptr, ms->string, qfalse); + if (index >= 0) + { + newstrptr = strptr + index; + if (lastvariable >= 0) + { + match->variables[lastvariable].length = + (newstrptr - match->string) - match->variables[lastvariable].offset; + //newstrptr - match->variables[lastvariable].ptr; + lastvariable = -1; + break; + } //end if + else if (index == 0) + { + break; + } //end else + newstrptr = NULL; + } //end if + } //end for + if (!newstrptr) return qfalse; + strptr = newstrptr + strlen(ms->string); + } //end if + //if it is a variable piece of string + else if (mp->type == MT_VARIABLE) + { + //Log_Write("MT_VARIABLE"); + match->variables[mp->variable].offset = strptr - match->string; + lastvariable = mp->variable; + } //end else if + } //end for + //if a match was found + if (!mp && (lastvariable >= 0 || !strlen(strptr))) + { + //if the last piece was a variable string + if (lastvariable >= 0) + { + assert( match->variables[lastvariable].offset >= 0 ); + match->variables[lastvariable].length = + strlen(&match->string[ (int) match->variables[lastvariable].offset]); + } //end if + return qtrue; + } //end if + return qfalse; +} //end of the function StringsMatch +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotFindMatch(char *str, bot_match_t *match, unsigned long int context) +{ + int i; + bot_matchtemplate_t *ms; + + strncpy(match->string, str, MAX_MESSAGE_SIZE); + //remove any trailing enters + while(strlen(match->string) && + match->string[strlen(match->string)-1] == '\n') + { + match->string[strlen(match->string)-1] = '\0'; + } //end while + //compare the string with all the match strings + for (ms = matchtemplates; ms; ms = ms->next) + { + if (!(ms->context & context)) continue; + //reset the match variable offsets + for (i = 0; i < MAX_MATCHVARIABLES; i++) match->variables[i].offset = -1; + // + if (StringsMatch(ms->first, match)) + { + match->type = ms->type; + match->subtype = ms->subtype; + return qtrue; + } //end if + } //end for + return qfalse; +} //end of the function BotFindMatch +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size) +{ + if (variable < 0 || variable >= MAX_MATCHVARIABLES) + { + botimport.Print(PRT_FATAL, "BotMatchVariable: variable out of range\n"); + strcpy(buf, ""); + return; + } //end if + + if (match->variables[variable].offset >= 0) + { + if (match->variables[variable].length < size) + size = match->variables[variable].length+1; + assert( match->variables[variable].offset >= 0 ); + strncpy(buf, &match->string[ (int) match->variables[variable].offset], size-1); + buf[size-1] = '\0'; + } //end if + else + { + strcpy(buf, ""); + } //end else + return; +} //end of the function BotMatchVariable +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_stringlist_t *BotFindStringInList(bot_stringlist_t *list, char *string) +{ + bot_stringlist_t *s; + + for (s = list; s; s = s->next) + { + if (!strcmp(s->string, string)) return s; + } //end for + return NULL; +} //end of the function BotFindStringInList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_stringlist_t *BotCheckChatMessageIntegrety(char *message, bot_stringlist_t *stringlist) +{ + int i; + char *msgptr; + char temp[MAX_MESSAGE_SIZE]; + bot_stringlist_t *s; + + msgptr = message; + // + while(*msgptr) + { + if (*msgptr == ESCAPE_CHAR) + { + msgptr++; + switch(*msgptr) + { + case 'v': //variable + { + //step over the 'v' + msgptr++; + while(*msgptr && *msgptr != ESCAPE_CHAR) msgptr++; + //step over the trailing escape char + if (*msgptr) msgptr++; + break; + } //end case + case 'r': //random + { + //step over the 'r' + msgptr++; + for (i = 0; (*msgptr && *msgptr != ESCAPE_CHAR); i++) + { + temp[i] = *msgptr++; + } //end while + temp[i] = '\0'; + //step over the trailing escape char + if (*msgptr) msgptr++; + //find the random keyword + if (!RandomString(temp)) + { + if (!BotFindStringInList(stringlist, temp)) + { + Log_Write("%s = {\"%s\"} //MISSING RANDOM\r\n", temp, temp); + s = GetClearedMemory(sizeof(bot_stringlist_t) + strlen(temp) + 1); + s->string = (char *) s + sizeof(bot_stringlist_t); + strcpy(s->string, temp); + s->next = stringlist; + stringlist = s; + } //end if + } //end if + break; + } //end case + default: + { + botimport.Print(PRT_FATAL, "BotCheckChatMessageIntegrety: message \"%s\" invalid escape char\n", message); + break; + } //end default + } //end switch + } //end if + else + { + msgptr++; + } //end else + } //end while + return stringlist; +} //end of the function BotCheckChatMessageIntegrety +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotCheckInitialChatIntegrety(bot_chat_t *chat) +{ + bot_chattype_t *t; + bot_chatmessage_t *cm; + bot_stringlist_t *stringlist, *s, *nexts; + + stringlist = NULL; + for (t = chat->types; t; t = t->next) + { + for (cm = t->firstchatmessage; cm; cm = cm->next) + { + stringlist = BotCheckChatMessageIntegrety(cm->chatmessage, stringlist); + } //end for + } //end for + for (s = stringlist; s; s = nexts) + { + nexts = s->next; + FreeMemory(s); + } //end for +} //end of the function BotCheckInitialChatIntegrety +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotCheckReplyChatIntegrety(bot_replychat_t *replychat) +{ + bot_replychat_t *rp; + bot_chatmessage_t *cm; + bot_stringlist_t *stringlist, *s, *nexts; + + stringlist = NULL; + for (rp = replychat; rp; rp = rp->next) + { + for (cm = rp->firstchatmessage; cm; cm = cm->next) + { + stringlist = BotCheckChatMessageIntegrety(cm->chatmessage, stringlist); + } //end for + } //end for + for (s = stringlist; s; s = nexts) + { + nexts = s->next; + FreeMemory(s); + } //end for +} //end of the function BotCheckReplyChatIntegrety +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotDumpReplyChat(bot_replychat_t *replychat) +{ + FILE *fp; + bot_replychat_t *rp; + bot_replychatkey_t *key; + bot_chatmessage_t *cm; + bot_matchpiece_t *mp; + + fp = Log_FilePointer(); + if (!fp) return; + fprintf(fp, "BotDumpReplyChat:\n"); + for (rp = replychat; rp; rp = rp->next) + { + fprintf(fp, "["); + for (key = rp->keys; key; key = key->next) + { + if (key->flags & RCKFL_AND) fprintf(fp, "&"); + else if (key->flags & RCKFL_NOT) fprintf(fp, "!"); + // + if (key->flags & RCKFL_NAME) fprintf(fp, "name"); + else if (key->flags & RCKFL_GENDERFEMALE) fprintf(fp, "female"); + else if (key->flags & RCKFL_GENDERMALE) fprintf(fp, "male"); + else if (key->flags & RCKFL_GENDERLESS) fprintf(fp, "it"); + else if (key->flags & RCKFL_VARIABLES) + { + fprintf(fp, "("); + for (mp = key->match; mp; mp = mp->next) + { + if (mp->type == MT_STRING) fprintf(fp, "\"%s\"", mp->firststring->string); + else fprintf(fp, "%d", mp->variable); + if (mp->next) fprintf(fp, ", "); + } //end for + fprintf(fp, ")"); + } //end if + else if (key->flags & RCKFL_STRING) + { + fprintf(fp, "\"%s\"", key->string); + } //end if + if (key->next) fprintf(fp, ", "); + else fprintf(fp, "] = %1.0f\n", rp->priority); + } //end for + fprintf(fp, "{\n"); + for (cm = rp->firstchatmessage; cm; cm = cm->next) + { + fprintf(fp, "\t\"%s\";\n", cm->chatmessage); + } //end for + fprintf(fp, "}\n"); + } //end for +} //end of the function BotDumpReplyChat +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotFreeReplyChat(bot_replychat_t *replychat) +{ + bot_replychat_t *rp, *nextrp; + bot_replychatkey_t *key, *nextkey; + bot_chatmessage_t *cm, *nextcm; + + for (rp = replychat; rp; rp = nextrp) + { + nextrp = rp->next; + for (key = rp->keys; key; key = nextkey) + { + nextkey = key->next; + if (key->match) BotFreeMatchPieces(key->match); + if (key->string) FreeMemory(key->string); + FreeMemory(key); + } //end for + for (cm = rp->firstchatmessage; cm; cm = nextcm) + { + nextcm = cm->next; + FreeMemory(cm); + } //end for + FreeMemory(rp); + } //end for +} //end of the function BotFreeReplyChat +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotCheckValidReplyChatKeySet(source_t *source, bot_replychatkey_t *keys) +{ + int allprefixed, hasvariableskey, hasstringkey; + bot_matchpiece_t *m; + bot_matchstring_t *ms; + bot_replychatkey_t *key, *key2; + + // + allprefixed = qtrue; + hasvariableskey = hasstringkey = qfalse; + for (key = keys; key; key = key->next) + { + if (!(key->flags & (RCKFL_AND|RCKFL_NOT))) + { + allprefixed = qfalse; + if (key->flags & RCKFL_VARIABLES) + { + for (m = key->match; m; m = m->next) + { + if (m->type == MT_VARIABLE) hasvariableskey = qtrue; + } //end for + } //end if + else if (key->flags & RCKFL_STRING) + { + hasstringkey = qtrue; + } //end else if + } //end if + else if ((key->flags & RCKFL_AND) && (key->flags & RCKFL_STRING)) + { + for (key2 = keys; key2; key2 = key2->next) + { + if (key2 == key) continue; + if (key2->flags & RCKFL_NOT) continue; + if (key2->flags & RCKFL_VARIABLES) + { + for (m = key2->match; m; m = m->next) + { + if (m->type == MT_STRING) + { + for (ms = m->firststring; ms; ms = ms->next) + { + if (StringContains(ms->string, key->string, qfalse) != -1) + { + break; + } //end if + } //end for + if (ms) break; + } //end if + else if (m->type == MT_VARIABLE) + { + break; + } //end if + } //end for + if (!m) + { + SourceWarning(source, "one of the match templates does not " + "leave space for the key %s with the & prefix", key->string); + } //end if + } //end if + } //end for + } //end else + if ((key->flags & RCKFL_NOT) && (key->flags & RCKFL_STRING)) + { + for (key2 = keys; key2; key2 = key2->next) + { + if (key2 == key) continue; + if (key2->flags & RCKFL_NOT) continue; + if (key2->flags & RCKFL_STRING) + { + if (StringContains(key2->string, key->string, qfalse) != -1) + { + SourceWarning(source, "the key %s with prefix ! is inside the key %s", key->string, key2->string); + } //end if + } //end if + else if (key2->flags & RCKFL_VARIABLES) + { + for (m = key2->match; m; m = m->next) + { + if (m->type == MT_STRING) + { + for (ms = m->firststring; ms; ms = ms->next) + { + if (StringContains(ms->string, key->string, qfalse) != -1) + { + SourceWarning(source, "the key %s with prefix ! is inside " + "the match template string %s", key->string, ms->string); + } //end if + } //end for + } //end if + } //end for + } //end else if + } //end for + } //end if + } //end for + if (allprefixed) SourceWarning(source, "all keys have a & or ! prefix"); + if (hasvariableskey && hasstringkey) + { + SourceWarning(source, "variables from the match template(s) could be " + "invalid when outputting one of the chat messages"); + } //end if +} //end of the function BotCheckValidReplyChatKeySet +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_replychat_t *BotLoadReplyChat(char *filename) +{ + char chatmessagestring[MAX_MESSAGE_SIZE]; + char namebuffer[MAX_MESSAGE_SIZE]; + source_t *source; + token_t token; + bot_chatmessage_t *chatmessage = NULL; + bot_replychat_t *replychat, *replychatlist; + bot_replychatkey_t *key; + + PC_SetBaseFolder(BOTFILESBASEFOLDER); + source = LoadSourceFile(filename); + if (!source) + { + botimport.Print(PRT_ERROR, "counldn't load %s\n", filename); + return NULL; + } //end if + // + replychatlist = NULL; + // + while(PC_ReadToken(source, &token)) + { + if (strcmp(token.string, "[")) + { + SourceError(source, "expected [, found %s", token.string); + BotFreeReplyChat(replychatlist); + FreeSource(source); + return NULL; + } //end if + // + replychat = GetClearedHunkMemory(sizeof(bot_replychat_t)); + replychat->keys = NULL; + replychat->next = replychatlist; + replychatlist = replychat; + //read the keys, there must be at least one key + do + { + //allocate a key + key = (bot_replychatkey_t *) GetClearedHunkMemory(sizeof(bot_replychatkey_t)); + key->flags = 0; + key->string = NULL; + key->match = NULL; + key->next = replychat->keys; + replychat->keys = key; + //check for MUST BE PRESENT and MUST BE ABSENT keys + if (PC_CheckTokenString(source, "&")) key->flags |= RCKFL_AND; + else if (PC_CheckTokenString(source, "!")) key->flags |= RCKFL_NOT; + //special keys + if (PC_CheckTokenString(source, "name")) key->flags |= RCKFL_NAME; + else if (PC_CheckTokenString(source, "female")) key->flags |= RCKFL_GENDERFEMALE; + else if (PC_CheckTokenString(source, "male")) key->flags |= RCKFL_GENDERMALE; + else if (PC_CheckTokenString(source, "it")) key->flags |= RCKFL_GENDERLESS; + else if (PC_CheckTokenString(source, "(")) //match key + { + key->flags |= RCKFL_VARIABLES; + key->match = BotLoadMatchPieces(source, ")"); + if (!key->match) + { + BotFreeReplyChat(replychatlist); + return NULL; + } //end if + } //end else if + else if (PC_CheckTokenString(source, "<")) //bot names + { + key->flags |= RCKFL_BOTNAMES; + strcpy(namebuffer, ""); + do + { + if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) + { + BotFreeReplyChat(replychatlist); + FreeSource(source); + return NULL; + } //end if + StripDoubleQuotes(token.string); + if (strlen(namebuffer)) strcat(namebuffer, "\\"); + strcat(namebuffer, token.string); + } while(PC_CheckTokenString(source, ",")); + if (!PC_ExpectTokenString(source, ">")) + { + BotFreeReplyChat(replychatlist); + FreeSource(source); + return NULL; + } //end if + key->string = (char *) GetClearedHunkMemory(strlen(namebuffer) + 1); + strcpy(key->string, namebuffer); + } //end else if + else //normal string key + { + key->flags |= RCKFL_STRING; + if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) + { + BotFreeReplyChat(replychatlist); + FreeSource(source); + return NULL; + } //end if + StripDoubleQuotes(token.string); + key->string = (char *) GetClearedHunkMemory(strlen(token.string) + 1); + strcpy(key->string, token.string); + } //end else + // + PC_CheckTokenString(source, ","); + } while(!PC_CheckTokenString(source, "]")); + // + BotCheckValidReplyChatKeySet(source, replychat->keys); + //read the = sign and the priority + if (!PC_ExpectTokenString(source, "=") || + !PC_ExpectTokenType(source, TT_NUMBER, 0, &token)) + { + BotFreeReplyChat(replychatlist); + FreeSource(source); + return NULL; + } //end if + replychat->priority = token.floatvalue; + //read the leading { + if (!PC_ExpectTokenString(source, "{")) + { + BotFreeReplyChat(replychatlist); + FreeSource(source); + return NULL; + } //end if + replychat->numchatmessages = 0; + //while the trailing } is not found + while(!PC_CheckTokenString(source, "}")) + { + if (!BotLoadChatMessage(source, chatmessagestring)) + { + BotFreeReplyChat(replychatlist); + FreeSource(source); + return NULL; + } //end if + chatmessage = (bot_chatmessage_t *) GetClearedHunkMemory(sizeof(bot_chatmessage_t) + strlen(chatmessagestring) + 1); + chatmessage->chatmessage = (char *) chatmessage + sizeof(bot_chatmessage_t); + strcpy(chatmessage->chatmessage, chatmessagestring); + chatmessage->time = -2*CHATMESSAGE_RECENTTIME; + chatmessage->next = replychat->firstchatmessage; + //add the chat message to the reply chat + replychat->firstchatmessage = chatmessage; + replychat->numchatmessages++; + } //end while + } //end while + FreeSource(source); + botimport.Print(PRT_MESSAGE, "loaded %s\n", filename); + // + //BotDumpReplyChat(replychatlist); + if (bot_developer) + { + BotCheckReplyChatIntegrety(replychatlist); + } //end if + // + if (!replychatlist) botimport.Print(PRT_MESSAGE, "no rchats\n"); + // + return replychatlist; +} //end of the function BotLoadReplyChat +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotDumpInitialChat(bot_chat_t *chat) +{ + bot_chattype_t *t; + bot_chatmessage_t *m; + + Log_Write("{"); + for (t = chat->types; t; t = t->next) + { + Log_Write(" type \"%s\"", t->name); + Log_Write(" {"); + Log_Write(" numchatmessages = %d", t->numchatmessages); + for (m = t->firstchatmessage; m; m = m->next) + { + Log_Write(" \"%s\"", m->chatmessage); + } //end for + Log_Write(" }"); + } //end for + Log_Write("}"); +} //end of the function BotDumpInitialChat +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname) +{ + int pass, foundchat, indent, size; + char *ptr = NULL; + char chatmessagestring[MAX_MESSAGE_SIZE]; + source_t *source; + token_t token; + bot_chat_t *chat = NULL; + bot_chattype_t *chattype = NULL; + bot_chatmessage_t *chatmessage = NULL; +#ifdef DEBUG + int starttime; + + starttime = Sys_MilliSeconds(); +#endif //DEBUG + // + size = 0; + foundchat = qfalse; + //a bot chat is parsed in two phases + for (pass = 0; pass < 2; pass++) + { + //allocate memory + if (pass && size) ptr = (char *) GetClearedMemory(size); + //load the source file + PC_SetBaseFolder(BOTFILESBASEFOLDER); + source = LoadSourceFile(chatfile); + if (!source) + { + botimport.Print(PRT_ERROR, "counldn't load %s\n", chatfile); + return NULL; + } //end if + //chat structure + if (pass) + { + chat = (bot_chat_t *) ptr; + ptr += sizeof(bot_chat_t); + } //end if + size = sizeof(bot_chat_t); + // + while(PC_ReadToken(source, &token)) + { + if (!strcmp(token.string, "chat")) + { + if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) + { + FreeSource(source); + return NULL; + } //end if + StripDoubleQuotes(token.string); + //after the chat name we expect a opening brace + if (!PC_ExpectTokenString(source, "{")) + { + FreeSource(source); + return NULL; + } //end if + //if the chat name is found + if (!Q_stricmp(token.string, chatname)) + { + foundchat = qtrue; + //read the chat types + while(1) + { + if (!PC_ExpectAnyToken(source, &token)) + { + FreeSource(source); + return NULL; + } //end if + if (!strcmp(token.string, "}")) break; + if (strcmp(token.string, "type")) + { + SourceError(source, "expected type found %s\n", token.string); + FreeSource(source); + return NULL; + } //end if + //expect the chat type name + if (!PC_ExpectTokenType(source, TT_STRING, 0, &token) || + !PC_ExpectTokenString(source, "{")) + { + FreeSource(source); + return NULL; + } //end if + StripDoubleQuotes(token.string); + if (pass) + { + chattype = (bot_chattype_t *) ptr; + strncpy(chattype->name, token.string, MAX_CHATTYPE_NAME); + chattype->firstchatmessage = NULL; + //add the chat type to the chat + chattype->next = chat->types; + chat->types = chattype; + // + ptr += sizeof(bot_chattype_t); + } //end if + size += sizeof(bot_chattype_t); + //read the chat messages + while(!PC_CheckTokenString(source, "}")) + { + size_t len; + if (!BotLoadChatMessage(source, chatmessagestring)) + { + FreeSource(source); + return NULL; + } //end if + len = strlen(chatmessagestring) + 1; + len = PAD(len, sizeof(long)); + if (pass) + { + chatmessage = (bot_chatmessage_t *) ptr; + chatmessage->time = -2*CHATMESSAGE_RECENTTIME; + //put the chat message in the list + chatmessage->next = chattype->firstchatmessage; + chattype->firstchatmessage = chatmessage; + //store the chat message + ptr += sizeof(bot_chatmessage_t); + chatmessage->chatmessage = ptr; + strcpy(chatmessage->chatmessage, chatmessagestring); + ptr += len; + //the number of chat messages increased + chattype->numchatmessages++; + } //end if + size += sizeof(bot_chatmessage_t) + len; + } //end if + } //end while + } //end if + else //skip the bot chat + { + indent = 1; + while(indent) + { + if (!PC_ExpectAnyToken(source, &token)) + { + FreeSource(source); + return NULL; + } //end if + if (!strcmp(token.string, "{")) indent++; + else if (!strcmp(token.string, "}")) indent--; + } //end while + } //end else + } //end if + else + { + SourceError(source, "unknown definition %s\n", token.string); + FreeSource(source); + return NULL; + } //end else + } //end while + //free the source + FreeSource(source); + //if the requested character is not found + if (!foundchat) + { + botimport.Print(PRT_ERROR, "couldn't find chat %s in %s\n", chatname, chatfile); + return NULL; + } //end if + } //end for + // + botimport.Print(PRT_MESSAGE, "loaded %s from %s\n", chatname, chatfile); + // + //BotDumpInitialChat(chat); + if (bot_developer) + { + BotCheckInitialChatIntegrety(chat); + } //end if +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "initial chats loaded in %d msec\n", Sys_MilliSeconds() - starttime); +#endif //DEBUG + //character was read succesfully + return chat; +} //end of the function BotLoadInitialChat +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotFreeChatFile(int chatstate) +{ + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return; + if (cs->chat) FreeMemory(cs->chat); + cs->chat = NULL; +} //end of the function BotFreeChatFile +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotLoadChatFile(int chatstate, char *chatfile, char *chatname) +{ + bot_chatstate_t *cs; + int n, avail = 0; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return BLERR_CANNOTLOADICHAT; + BotFreeChatFile(chatstate); + + if (!LibVarGetValue("bot_reloadcharacters")) + { + avail = -1; + for( n = 0; n < MAX_CLIENTS; n++ ) { + if( !ichatdata[n] ) { + if( avail == -1 ) { + avail = n; + } + continue; + } + if( strcmp( chatfile, ichatdata[n]->filename ) != 0 ) { + continue; + } + if( strcmp( chatname, ichatdata[n]->chatname ) != 0 ) { + continue; + } + cs->chat = ichatdata[n]->chat; + // botimport.Print( PRT_MESSAGE, "retained %s from %s\n", chatname, chatfile ); + return BLERR_NOERROR; + } + + if( avail == -1 ) { + botimport.Print(PRT_FATAL, "ichatdata table full; couldn't load chat %s from %s\n", chatname, chatfile); + return BLERR_CANNOTLOADICHAT; + } + } + + cs->chat = BotLoadInitialChat(chatfile, chatname); + if (!cs->chat) + { + botimport.Print(PRT_FATAL, "couldn't load chat %s from %s\n", chatname, chatfile); + return BLERR_CANNOTLOADICHAT; + } //end if + if (!LibVarGetValue("bot_reloadcharacters")) + { + ichatdata[avail] = GetClearedMemory( sizeof(bot_ichatdata_t) ); + ichatdata[avail]->chat = cs->chat; + Q_strncpyz( ichatdata[avail]->chatname, chatname, sizeof(ichatdata[avail]->chatname) ); + Q_strncpyz( ichatdata[avail]->filename, chatfile, sizeof(ichatdata[avail]->filename) ); + } //end if + + return BLERR_NOERROR; +} //end of the function BotLoadChatFile +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotExpandChatMessage(char *outmessage, char *message, unsigned long mcontext, + bot_match_t *match, unsigned long vcontext, int reply) +{ + int num, len, i, expansion; + char *outputbuf, *ptr, *msgptr; + char temp[MAX_MESSAGE_SIZE]; + + expansion = qfalse; + msgptr = message; + outputbuf = outmessage; + len = 0; + // + while(*msgptr) + { + if (*msgptr == ESCAPE_CHAR) + { + msgptr++; + switch(*msgptr) + { + case 'v': //variable + { + msgptr++; + num = 0; + while(*msgptr && *msgptr != ESCAPE_CHAR) + { + num = num * 10 + (*msgptr++) - '0'; + } //end while + //step over the trailing escape char + if (*msgptr) msgptr++; + if (num > MAX_MATCHVARIABLES) + { + botimport.Print(PRT_ERROR, "BotConstructChat: message %s variable %d out of range\n", message, num); + return qfalse; + } //end if + if (match->variables[num].offset >= 0) + { + assert( match->variables[num].offset >= 0 ); + ptr = &match->string[ (int) match->variables[num].offset]; + for (i = 0; i < match->variables[num].length; i++) + { + temp[i] = ptr[i]; + } //end for + temp[i] = 0; + //if it's a reply message + if (reply) + { + //replace the reply synonyms in the variables + BotReplaceReplySynonyms(temp, vcontext); + } //end if + else + { + //replace synonyms in the variable context + BotReplaceSynonyms(temp, vcontext); + } //end else + // + if (len + strlen(temp) >= MAX_MESSAGE_SIZE) + { + botimport.Print(PRT_ERROR, "BotConstructChat: message %s too long\n", message); + return qfalse; + } //end if + strcpy(&outputbuf[len], temp); + len += strlen(temp); + } //end if + break; + } //end case + case 'r': //random + { + msgptr++; + for (i = 0; (*msgptr && *msgptr != ESCAPE_CHAR); i++) + { + temp[i] = *msgptr++; + } //end while + temp[i] = '\0'; + //step over the trailing escape char + if (*msgptr) msgptr++; + //find the random keyword + ptr = RandomString(temp); + if (!ptr) + { + botimport.Print(PRT_ERROR, "BotConstructChat: unknown random string %s\n", temp); + return qfalse; + } //end if + if (len + strlen(ptr) >= MAX_MESSAGE_SIZE) + { + botimport.Print(PRT_ERROR, "BotConstructChat: message \"%s\" too long\n", message); + return qfalse; + } //end if + strcpy(&outputbuf[len], ptr); + len += strlen(ptr); + expansion = qtrue; + break; + } //end case + default: + { + botimport.Print(PRT_FATAL, "BotConstructChat: message \"%s\" invalid escape char\n", message); + break; + } //end default + } //end switch + } //end if + else + { + outputbuf[len++] = *msgptr++; + if (len >= MAX_MESSAGE_SIZE) + { + botimport.Print(PRT_ERROR, "BotConstructChat: message \"%s\" too long\n", message); + break; + } //end if + } //end else + } //end while + outputbuf[len] = '\0'; + //replace synonyms weighted in the message context + BotReplaceWeightedSynonyms(outputbuf, mcontext); + //return true if a random was expanded + return expansion; +} //end of the function BotExpandChatMessage +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotConstructChatMessage(bot_chatstate_t *chatstate, char *message, unsigned long mcontext, + bot_match_t *match, unsigned long vcontext, int reply) +{ + int i; + char srcmessage[MAX_MESSAGE_SIZE]; + + strcpy(srcmessage, message); + for (i = 0; i < 10; i++) + { + if (!BotExpandChatMessage(chatstate->chatmessage, srcmessage, mcontext, match, vcontext, reply)) + { + break; + } //end if + strcpy(srcmessage, chatstate->chatmessage); + } //end for + if (i >= 10) + { + botimport.Print(PRT_WARNING, "too many expansions in chat message\n"); + botimport.Print(PRT_WARNING, "%s\n", chatstate->chatmessage); + } //end if +} //end of the function BotConstructChatMessage +//=========================================================================== +// randomly chooses one of the chat message of the given type +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *BotChooseInitialChatMessage(bot_chatstate_t *cs, char *type) +{ + int n, numchatmessages; + float besttime; + bot_chattype_t *t; + bot_chatmessage_t *m, *bestchatmessage; + bot_chat_t *chat; + + chat = cs->chat; + for (t = chat->types; t; t = t->next) + { + if (!Q_stricmp(t->name, type)) + { + numchatmessages = 0; + for (m = t->firstchatmessage; m; m = m->next) + { + if (m->time > AAS_Time()) continue; + numchatmessages++; + } //end if + //if all chat messages have been used recently + if (numchatmessages <= 0) + { + besttime = 0; + bestchatmessage = NULL; + for (m = t->firstchatmessage; m; m = m->next) + { + if (!besttime || m->time < besttime) + { + bestchatmessage = m; + besttime = m->time; + } //end if + } //end for + if (bestchatmessage) return bestchatmessage->chatmessage; + } //end if + else //choose a chat message randomly + { + n = random() * numchatmessages; + for (m = t->firstchatmessage; m; m = m->next) + { + if (m->time > AAS_Time()) continue; + if (--n < 0) + { + m->time = AAS_Time() + CHATMESSAGE_RECENTTIME; + return m->chatmessage; + } //end if + } //end for + } //end else + return NULL; + } //end if + } //end for + return NULL; +} //end of the function BotChooseInitialChatMessage +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotNumInitialChats(int chatstate, char *type) +{ + bot_chatstate_t *cs; + bot_chattype_t *t; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return 0; + + for (t = cs->chat->types; t; t = t->next) + { + if (!Q_stricmp(t->name, type)) + { + if (LibVarGetValue("bot_testichat")) { + botimport.Print(PRT_MESSAGE, "%s has %d chat lines\n", type, t->numchatmessages); + botimport.Print(PRT_MESSAGE, "-------------------\n"); + } + return t->numchatmessages; + } //end if + } //end for + return 0; +} //end of the function BotNumInitialChats +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7) +{ + char *message; + int index; + bot_match_t match; + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return; + //if no chat file is loaded + if (!cs->chat) return; + //choose a chat message randomly of the given type + message = BotChooseInitialChatMessage(cs, type); + //if there's no message of the given type + if (!message) + { +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "no chat messages of type %s\n", type); +#endif //DEBUG + return; + } //end if + // + Com_Memset(&match, 0, sizeof(match)); + index = 0; + if( var0 ) { + strcat(match.string, var0); + match.variables[0].offset = index; + match.variables[0].length = strlen(var0); + index += strlen(var0); + } + if( var1 ) { + strcat(match.string, var1); + match.variables[1].offset = index; + match.variables[1].length = strlen(var1); + index += strlen(var1); + } + if( var2 ) { + strcat(match.string, var2); + match.variables[2].offset = index; + match.variables[2].length = strlen(var2); + index += strlen(var2); + } + if( var3 ) { + strcat(match.string, var3); + match.variables[3].offset = index; + match.variables[3].length = strlen(var3); + index += strlen(var3); + } + if( var4 ) { + strcat(match.string, var4); + match.variables[4].offset = index; + match.variables[4].length = strlen(var4); + index += strlen(var4); + } + if( var5 ) { + strcat(match.string, var5); + match.variables[5].offset = index; + match.variables[5].length = strlen(var5); + index += strlen(var5); + } + if( var6 ) { + strcat(match.string, var6); + match.variables[6].offset = index; + match.variables[6].length = strlen(var6); + index += strlen(var6); + } + if( var7 ) { + strcat(match.string, var7); + match.variables[7].offset = index; + match.variables[7].length = strlen(var7); + index += strlen(var7); + } + // + BotConstructChatMessage(cs, message, mcontext, &match, 0, qfalse); +} //end of the function BotInitialChat +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotPrintReplyChatKeys(bot_replychat_t *replychat) +{ + bot_replychatkey_t *key; + bot_matchpiece_t *mp; + + botimport.Print(PRT_MESSAGE, "["); + for (key = replychat->keys; key; key = key->next) + { + if (key->flags & RCKFL_AND) botimport.Print(PRT_MESSAGE, "&"); + else if (key->flags & RCKFL_NOT) botimport.Print(PRT_MESSAGE, "!"); + // + if (key->flags & RCKFL_NAME) botimport.Print(PRT_MESSAGE, "name"); + else if (key->flags & RCKFL_GENDERFEMALE) botimport.Print(PRT_MESSAGE, "female"); + else if (key->flags & RCKFL_GENDERMALE) botimport.Print(PRT_MESSAGE, "male"); + else if (key->flags & RCKFL_GENDERLESS) botimport.Print(PRT_MESSAGE, "it"); + else if (key->flags & RCKFL_VARIABLES) + { + botimport.Print(PRT_MESSAGE, "("); + for (mp = key->match; mp; mp = mp->next) + { + if (mp->type == MT_STRING) botimport.Print(PRT_MESSAGE, "\"%s\"", mp->firststring->string); + else botimport.Print(PRT_MESSAGE, "%d", mp->variable); + if (mp->next) botimport.Print(PRT_MESSAGE, ", "); + } //end for + botimport.Print(PRT_MESSAGE, ")"); + } //end if + else if (key->flags & RCKFL_STRING) + { + botimport.Print(PRT_MESSAGE, "\"%s\"", key->string); + } //end if + if (key->next) botimport.Print(PRT_MESSAGE, ", "); + else botimport.Print(PRT_MESSAGE, "] = %1.0f\n", replychat->priority); + } //end for + botimport.Print(PRT_MESSAGE, "{\n"); +} //end of the function BotPrintReplyChatKeys +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7) +{ + bot_replychat_t *rchat, *bestrchat; + bot_replychatkey_t *key; + bot_chatmessage_t *m, *bestchatmessage; + bot_match_t match, bestmatch; + int bestpriority, num, found, res, numchatmessages, index; + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return qfalse; + Com_Memset(&match, 0, sizeof(bot_match_t)); + strcpy(match.string, message); + bestpriority = -1; + bestchatmessage = NULL; + bestrchat = NULL; + //go through all the reply chats + for (rchat = replychats; rchat; rchat = rchat->next) + { + found = qfalse; + for (key = rchat->keys; key; key = key->next) + { + res = qfalse; + //get the match result + if (key->flags & RCKFL_NAME) res = (StringContains(message, cs->name, qfalse) != -1); + else if (key->flags & RCKFL_BOTNAMES) res = (StringContains(key->string, cs->name, qfalse) != -1); + else if (key->flags & RCKFL_GENDERFEMALE) res = (cs->gender == CHAT_GENDERFEMALE); + else if (key->flags & RCKFL_GENDERMALE) res = (cs->gender == CHAT_GENDERMALE); + else if (key->flags & RCKFL_GENDERLESS) res = (cs->gender == CHAT_GENDERLESS); + else if (key->flags & RCKFL_VARIABLES) res = StringsMatch(key->match, &match); + else if (key->flags & RCKFL_STRING) res = (StringContainsWord(message, key->string, qfalse) != NULL); + //if the key must be present + if (key->flags & RCKFL_AND) + { + if (!res) + { + found = qfalse; + break; + } //end if + } //end else if + //if the key must be absent + else if (key->flags & RCKFL_NOT) + { + if (res) + { + found = qfalse; + break; + } //end if + } //end if + else if (res) + { + found = qtrue; + } //end else + } //end for + // + if (found) + { + if (rchat->priority > bestpriority) + { + numchatmessages = 0; + for (m = rchat->firstchatmessage; m; m = m->next) + { + if (m->time > AAS_Time()) continue; + numchatmessages++; + } //end if + num = random() * numchatmessages; + for (m = rchat->firstchatmessage; m; m = m->next) + { + if (--num < 0) break; + if (m->time > AAS_Time()) continue; + } //end for + //if the reply chat has a message + if (m) + { + Com_Memcpy(&bestmatch, &match, sizeof(bot_match_t)); + bestchatmessage = m; + bestrchat = rchat; + bestpriority = rchat->priority; + } //end if + } //end if + } //end if + } //end for + if (bestchatmessage) + { + index = strlen(bestmatch.string); + if( var0 ) { + strcat(bestmatch.string, var0); + bestmatch.variables[0].offset = index; + bestmatch.variables[0].length = strlen(var0); + index += strlen(var0); + } + if( var1 ) { + strcat(bestmatch.string, var1); + bestmatch.variables[1].offset = index; + bestmatch.variables[1].length = strlen(var1); + index += strlen(var1); + } + if( var2 ) { + strcat(bestmatch.string, var2); + bestmatch.variables[2].offset = index; + bestmatch.variables[2].length = strlen(var2); + index += strlen(var2); + } + if( var3 ) { + strcat(bestmatch.string, var3); + bestmatch.variables[3].offset = index; + bestmatch.variables[3].length = strlen(var3); + index += strlen(var3); + } + if( var4 ) { + strcat(bestmatch.string, var4); + bestmatch.variables[4].offset = index; + bestmatch.variables[4].length = strlen(var4); + index += strlen(var4); + } + if( var5 ) { + strcat(bestmatch.string, var5); + bestmatch.variables[5].offset = index; + bestmatch.variables[5].length = strlen(var5); + index += strlen(var5); + } + if( var6 ) { + strcat(bestmatch.string, var6); + bestmatch.variables[6].offset = index; + bestmatch.variables[6].length = strlen(var6); + index += strlen(var6); + } + if( var7 ) { + strcat(bestmatch.string, var7); + bestmatch.variables[7].offset = index; + bestmatch.variables[7].length = strlen(var7); + index += strlen(var7); + } + if (LibVarGetValue("bot_testrchat")) + { + for (m = bestrchat->firstchatmessage; m; m = m->next) + { + BotConstructChatMessage(cs, m->chatmessage, mcontext, &bestmatch, vcontext, qtrue); + BotRemoveTildes(cs->chatmessage); + botimport.Print(PRT_MESSAGE, "%s\n", cs->chatmessage); + } //end if + } //end if + else + { + bestchatmessage->time = AAS_Time() + CHATMESSAGE_RECENTTIME; + BotConstructChatMessage(cs, bestchatmessage->chatmessage, mcontext, &bestmatch, vcontext, qtrue); + } //end else + return qtrue; + } //end if + return qfalse; +} //end of the function BotReplyChat +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotChatLength(int chatstate) +{ + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return 0; + return strlen(cs->chatmessage); +} //end of the function BotChatLength +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotEnterChat(int chatstate, int clientto, int sendto) +{ + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return; + + if (strlen(cs->chatmessage)) + { + BotRemoveTildes(cs->chatmessage); + if (LibVarGetValue("bot_testichat")) { + botimport.Print(PRT_MESSAGE, "%s\n", cs->chatmessage); + } + else { + switch(sendto) { + case CHAT_TEAM: + EA_Command(cs->client, va("say_team %s", cs->chatmessage)); + break; + case CHAT_TELL: + EA_Command(cs->client, va("tell %d %s", clientto, cs->chatmessage)); + break; + default: //CHAT_ALL + EA_Command(cs->client, va("say %s", cs->chatmessage)); + break; + } + } + //clear the chat message from the state + strcpy(cs->chatmessage, ""); + } //end if +} //end of the function BotEnterChat +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotGetChatMessage(int chatstate, char *buf, int size) +{ + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return; + + BotRemoveTildes(cs->chatmessage); + strncpy(buf, cs->chatmessage, size-1); + buf[size-1] = '\0'; + //clear the chat message from the state + strcpy(cs->chatmessage, ""); +} //end of the function BotGetChatMessage +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotSetChatGender(int chatstate, int gender) +{ + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return; + switch(gender) + { + case CHAT_GENDERFEMALE: cs->gender = CHAT_GENDERFEMALE; break; + case CHAT_GENDERMALE: cs->gender = CHAT_GENDERMALE; break; + default: cs->gender = CHAT_GENDERLESS; break; + } //end switch +} //end of the function BotSetChatGender +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotSetChatName(int chatstate, char *name, int client) +{ + bot_chatstate_t *cs; + + cs = BotChatStateFromHandle(chatstate); + if (!cs) return; + cs->client = client; + Com_Memset(cs->name, 0, sizeof(cs->name)); + strncpy(cs->name, name, sizeof(cs->name)); + cs->name[sizeof(cs->name)-1] = '\0'; +} //end of the function BotSetChatName +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotResetChatAI(void) +{ + bot_replychat_t *rchat; + bot_chatmessage_t *m; + + for (rchat = replychats; rchat; rchat = rchat->next) + { + for (m = rchat->firstchatmessage; m; m = m->next) + { + m->time = 0; + } //end for + } //end for +} //end of the function BotResetChatAI +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +int BotAllocChatState(void) +{ + int i; + + for (i = 1; i <= MAX_CLIENTS; i++) + { + if (!botchatstates[i]) + { + botchatstates[i] = GetClearedMemory(sizeof(bot_chatstate_t)); + return i; + } //end if + } //end for + return 0; +} //end of the function BotAllocChatState +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +void BotFreeChatState(int handle) +{ + bot_chatstate_t *cs; + bot_consolemessage_t m; + int h; + + if (handle <= 0 || handle > MAX_CLIENTS) + { + botimport.Print(PRT_FATAL, "chat state handle %d out of range\n", handle); + return; + } //end if + if (!botchatstates[handle]) + { + botimport.Print(PRT_FATAL, "invalid chat state %d\n", handle); + return; + } //end if + cs = botchatstates[handle]; + if (LibVarGetValue("bot_reloadcharacters")) + { + BotFreeChatFile(handle); + } //end if + //free all the console messages left in the chat state + for (h = BotNextConsoleMessage(handle, &m); h; h = BotNextConsoleMessage(handle, &m)) + { + //remove the console message + BotRemoveConsoleMessage(handle, h); + } //end for + FreeMemory(botchatstates[handle]); + botchatstates[handle] = NULL; +} //end of the function BotFreeChatState +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotSetupChatAI(void) +{ + char *file; + +#ifdef DEBUG + int starttime = Sys_MilliSeconds(); +#endif //DEBUG + + file = LibVarString("synfile", "syn.c"); + synonyms = BotLoadSynonyms(file); + file = LibVarString("rndfile", "rnd.c"); + randomstrings = BotLoadRandomStrings(file); + file = LibVarString("matchfile", "match.c"); + matchtemplates = BotLoadMatchTemplates(file); + // + if (!LibVarValue("nochat", "0")) + { + file = LibVarString("rchatfile", "rchat.c"); + replychats = BotLoadReplyChat(file); + } //end if + + InitConsoleMessageHeap(); + +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "setup chat AI %d msec\n", Sys_MilliSeconds() - starttime); +#endif //DEBUG + return BLERR_NOERROR; +} //end of the function BotSetupChatAI +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotShutdownChatAI(void) +{ + int i; + + //free all remaining chat states + for(i = 0; i < MAX_CLIENTS; i++) + { + if (botchatstates[i]) + { + BotFreeChatState(i); + } //end if + } //end for + //free all cached chats + for(i = 0; i < MAX_CLIENTS; i++) + { + if (ichatdata[i]) + { + FreeMemory(ichatdata[i]->chat); + FreeMemory(ichatdata[i]); + ichatdata[i] = NULL; + } //end if + } //end for + if (consolemessageheap) FreeMemory(consolemessageheap); + consolemessageheap = NULL; + if (matchtemplates) BotFreeMatchTemplates(matchtemplates); + matchtemplates = NULL; + if (randomstrings) FreeMemory(randomstrings); + randomstrings = NULL; + if (synonyms) FreeMemory(synonyms); + synonyms = NULL; + if (replychats) BotFreeReplyChat(replychats); + replychats = NULL; +} //end of the function BotShutdownChatAI diff --git a/code/botlib/be_ai_chat.h b/code/botlib/be_ai_chat.h new file mode 100644 index 00000000..53a56d7b --- /dev/null +++ b/code/botlib/be_ai_chat.h @@ -0,0 +1,113 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +/***************************************************************************** + * name: be_ai_chat.h + * + * desc: char AI + * + * $Archive: /source/code/botlib/be_ai_chat.h $ + * + *****************************************************************************/ + +#define MAX_MESSAGE_SIZE 256 +#define MAX_CHATTYPE_NAME 32 +#define MAX_MATCHVARIABLES 8 + +#define CHAT_GENDERLESS 0 +#define CHAT_GENDERFEMALE 1 +#define CHAT_GENDERMALE 2 + +#define CHAT_ALL 0 +#define CHAT_TEAM 1 +#define CHAT_TELL 2 + +//a console message +typedef struct bot_consolemessage_s +{ + int handle; + float time; //message time + int type; //message type + char message[MAX_MESSAGE_SIZE]; //message + struct bot_consolemessage_s *prev, *next; //prev and next in list +} bot_consolemessage_t; + +//match variable +typedef struct bot_matchvariable_s +{ + char offset; + int length; +} bot_matchvariable_t; +//returned to AI when a match is found +typedef struct bot_match_s +{ + char string[MAX_MESSAGE_SIZE]; + int type; + int subtype; + bot_matchvariable_t variables[MAX_MATCHVARIABLES]; +} bot_match_t; + +//setup the chat AI +int BotSetupChatAI(void); +//shutdown the chat AI +void BotShutdownChatAI(void); +//returns the handle to a newly allocated chat state +int BotAllocChatState(void); +//frees the chatstate +void BotFreeChatState(int handle); +//adds a console message to the chat state +void BotQueueConsoleMessage(int chatstate, int type, char *message); +//removes the console message from the chat state +void BotRemoveConsoleMessage(int chatstate, int handle); +//returns the next console message from the state +int BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm); +//returns the number of console messages currently stored in the state +int BotNumConsoleMessages(int chatstate); +//selects a chat message of the given type +void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); +//returns the number of initial chat messages of the given type +int BotNumInitialChats(int chatstate, char *type); +//find and select a reply for the given message +int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); +//returns the length of the currently selected chat message +int BotChatLength(int chatstate); +//enters the selected chat message +void BotEnterChat(int chatstate, int clientto, int sendto); +//get the chat message ready to be output +void BotGetChatMessage(int chatstate, char *buf, int size); +//checks if the first string contains the second one, returns index into first string or -1 if not found +int StringContains(char *str1, char *str2, int casesensitive); +//finds a match for the given string using the match templates +int BotFindMatch(char *str, bot_match_t *match, unsigned long int context); +//returns a variable from a match +void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size); +//unify all the white spaces in the string +void UnifyWhiteSpaces(char *string); +//replace all the context related synonyms in the string +void BotReplaceSynonyms(char *string, unsigned long int context); +//loads a chat file for the chat state +int BotLoadChatFile(int chatstate, char *chatfile, char *chatname); +//store the gender of the bot in the chat state +void BotSetChatGender(int chatstate, int gender); +//store the bot name in the chat state +void BotSetChatName(int chatstate, char *name, int client); + diff --git a/code/botlib/be_ai_gen.c b/code/botlib/be_ai_gen.c new file mode 100644 index 00000000..d7bb2214 --- /dev/null +++ b/code/botlib/be_ai_gen.c @@ -0,0 +1,134 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_ai_gen.c + * + * desc: genetic selection + * + * $Archive: /MissionPack/code/botlib/be_ai_gen.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_memory.h" +#include "l_log.h" +#include "l_utils.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "aasfile.h" +#include "botlib.h" +#include "be_aas.h" +#include "be_aas_funcs.h" +#include "be_interface.h" +#include "be_ai_gen.h" + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int GeneticSelection(int numranks, float *rankings) +{ + float sum, select; + int i, index; + + sum = 0; + for (i = 0; i < numranks; i++) + { + if (rankings[i] < 0) continue; + sum += rankings[i]; + } //end for + if (sum > 0) + { + //select a bot where the ones with the higest rankings have + //the highest chance of being selected + select = random() * sum; + for (i = 0; i < numranks; i++) + { + if (rankings[i] < 0) continue; + sum -= rankings[i]; + if (sum <= 0) return i; + } //end for + } //end if + //select a bot randomly + index = random() * numranks; + for (i = 0; i < numranks; i++) + { + if (rankings[index] >= 0) return index; + index = (index + 1) % numranks; + } //end for + return 0; +} //end of the function GeneticSelection +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child) +{ + float rankings[256], max; + int i; + + if (numranks > 256) + { + botimport.Print(PRT_WARNING, "GeneticParentsAndChildSelection: too many bots\n"); + *parent1 = *parent2 = *child = 0; + return qfalse; + } //end if + for (max = 0, i = 0; i < numranks; i++) + { + if (ranks[i] < 0) continue; + max++; + } //end for + if (max < 3) + { + botimport.Print(PRT_WARNING, "GeneticParentsAndChildSelection: too few valid bots\n"); + *parent1 = *parent2 = *child = 0; + return qfalse; + } //end if + Com_Memcpy(rankings, ranks, sizeof(float) * numranks); + //select first parent + *parent1 = GeneticSelection(numranks, rankings); + rankings[*parent1] = -1; + //select second parent + *parent2 = GeneticSelection(numranks, rankings); + rankings[*parent2] = -1; + //reverse the rankings + max = 0; + for (i = 0; i < numranks; i++) + { + if (rankings[i] < 0) continue; + if (rankings[i] > max) max = rankings[i]; + } //end for + for (i = 0; i < numranks; i++) + { + if (rankings[i] < 0) continue; + rankings[i] = max - rankings[i]; + } //end for + //select child + *child = GeneticSelection(numranks, rankings); + return qtrue; +} //end of the function GeneticParentsAndChildSelection diff --git a/code/botlib/be_ai_gen.h b/code/botlib/be_ai_gen.h new file mode 100644 index 00000000..ce9ba92f --- /dev/null +++ b/code/botlib/be_ai_gen.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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_ai_gen.h + * + * desc: genetic selection + * + * $Archive: /source/code/botlib/be_ai_gen.h $ + * + *****************************************************************************/ + +int GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child); diff --git a/code/botlib/be_ai_goal.c b/code/botlib/be_ai_goal.c new file mode 100644 index 00000000..fbcc20fd --- /dev/null +++ b/code/botlib/be_ai_goal.c @@ -0,0 +1,1821 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_ai_goal.c + * + * desc: goal AI + * + * $Archive: /MissionPack/code/botlib/be_ai_goal.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_utils.h" +#include "l_libvar.h" +#include "l_memory.h" +#include "l_log.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "aasfile.h" +#include "botlib.h" +#include "be_aas.h" +#include "be_aas_funcs.h" +#include "be_interface.h" +#include "be_ai_weight.h" +#include "be_ai_goal.h" +#include "be_ai_move.h" + +//#define DEBUG_AI_GOAL +#ifdef RANDOMIZE +#define UNDECIDEDFUZZY +#endif //RANDOMIZE +#define DROPPEDWEIGHT +//minimum avoid goal time +#define AVOID_MINIMUM_TIME 10 +//default avoid goal time +#define AVOID_DEFAULT_TIME 30 +//avoid dropped goal time +#define AVOID_DROPPED_TIME 10 +// +#define TRAVELTIME_SCALE 0.01 +//item flags +#define IFL_NOTFREE 1 //not in free for all +#define IFL_NOTTEAM 2 //not in team play +#define IFL_NOTSINGLE 4 //not in single player +#define IFL_NOTBOT 8 //bot should never go for this +#define IFL_ROAM 16 //bot roam goal + +//location in the map "target_location" +typedef struct maplocation_s +{ + vec3_t origin; + int areanum; + char name[MAX_EPAIRKEY]; + struct maplocation_s *next; +} maplocation_t; + +//camp spots "info_camp" +typedef struct campspot_s +{ + vec3_t origin; + int areanum; + char name[MAX_EPAIRKEY]; + float range; + float weight; + float wait; + float random; + struct campspot_s *next; +} campspot_t; + +//FIXME: these are game specific +typedef enum { + GT_FFA, // free for all + GT_TOURNAMENT, // one on one tournament + GT_SINGLE_PLAYER, // single player tournament + + //-- team games go after this -- + + GT_TEAM, // team deathmatch + GT_CTF, // capture the flag +#ifdef MISSIONPACK + GT_1FCTF, + GT_OBELISK, + GT_HARVESTER, +#endif + GT_MAX_GAME_TYPE +} gametype_t; + +typedef struct levelitem_s +{ + int number; //number of the level item + int iteminfo; //index into the item info + int flags; //item flags + float weight; //fixed roam weight + vec3_t origin; //origin of the item + int goalareanum; //area the item is in + vec3_t goalorigin; //goal origin within the area + int entitynum; //entity number + float timeout; //item is removed after this time + struct levelitem_s *prev, *next; +} levelitem_t; + +typedef struct iteminfo_s +{ + char classname[32]; //classname of the item + char name[MAX_STRINGFIELD]; //name of the item + char model[MAX_STRINGFIELD]; //model of the item + int modelindex; //model index + int type; //item type + int index; //index in the inventory + float respawntime; //respawn time + vec3_t mins; //mins of the item + vec3_t maxs; //maxs of the item + int number; //number of the item info +} iteminfo_t; + +#define ITEMINFO_OFS(x) (size_t)&(((iteminfo_t *)0)->x) + +fielddef_t iteminfo_fields[] = +{ +{"name", ITEMINFO_OFS(name), FT_STRING}, +{"model", ITEMINFO_OFS(model), FT_STRING}, +{"modelindex", ITEMINFO_OFS(modelindex), FT_INT}, +{"type", ITEMINFO_OFS(type), FT_INT}, +{"index", ITEMINFO_OFS(index), FT_INT}, +{"respawntime", ITEMINFO_OFS(respawntime), FT_FLOAT}, +{"mins", ITEMINFO_OFS(mins), FT_FLOAT|FT_ARRAY, 3}, +{"maxs", ITEMINFO_OFS(maxs), FT_FLOAT|FT_ARRAY, 3}, +{NULL, 0, 0} +}; + +structdef_t iteminfo_struct = +{ + sizeof(iteminfo_t), iteminfo_fields +}; + +typedef struct itemconfig_s +{ + int numiteminfo; + iteminfo_t *iteminfo; +} itemconfig_t; + +//goal state +typedef struct bot_goalstate_s +{ + struct weightconfig_s *itemweightconfig; //weight config + int *itemweightindex; //index from item to weight + // + int client; //client using this goal state + int lastreachabilityarea; //last area with reachabilities the bot was in + // + bot_goal_t goalstack[MAX_GOALSTACK]; //goal stack + int goalstacktop; //the top of the goal stack + // + int avoidgoals[MAX_AVOIDGOALS]; //goals to avoid + float avoidgoaltimes[MAX_AVOIDGOALS]; //times to avoid the goals +} bot_goalstate_t; + +bot_goalstate_t *botgoalstates[MAX_CLIENTS + 1]; // FIXME: init? +//item configuration +itemconfig_t *itemconfig = NULL; +//level items +levelitem_t *levelitemheap = NULL; +levelitem_t *freelevelitems = NULL; +levelitem_t *levelitems = NULL; +int numlevelitems = 0; +//map locations +maplocation_t *maplocations = NULL; +//camp spots +campspot_t *campspots = NULL; +//the game type +int g_gametype = 0; +//additional dropped item weight +libvar_t *droppedweight = NULL; + +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +bot_goalstate_t *BotGoalStateFromHandle(int handle) +{ + if (handle <= 0 || handle > MAX_CLIENTS) + { + botimport.Print(PRT_FATAL, "goal state handle %d out of range\n", handle); + return NULL; + } //end if + if (!botgoalstates[handle]) + { + botimport.Print(PRT_FATAL, "invalid goal state %d\n", handle); + return NULL; + } //end if + return botgoalstates[handle]; +} //end of the function BotGoalStateFromHandle +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child) +{ + bot_goalstate_t *p1, *p2, *c; + + p1 = BotGoalStateFromHandle(parent1); + p2 = BotGoalStateFromHandle(parent2); + c = BotGoalStateFromHandle(child); + + InterbreedWeightConfigs(p1->itemweightconfig, p2->itemweightconfig, + c->itemweightconfig); +} //end of the function BotInterbreedingGoalFuzzyLogic +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotSaveGoalFuzzyLogic(int goalstate, char *filename) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + + //WriteWeightConfig(filename, gs->itemweightconfig); +} //end of the function BotSaveGoalFuzzyLogic +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotMutateGoalFuzzyLogic(int goalstate, float range) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + + EvolveWeightConfig(gs->itemweightconfig); +} //end of the function BotMutateGoalFuzzyLogic +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +itemconfig_t *LoadItemConfig(char *filename) +{ + int max_iteminfo; + token_t token; + char path[MAX_PATH]; + source_t *source; + itemconfig_t *ic; + iteminfo_t *ii; + + max_iteminfo = (int) LibVarValue("max_iteminfo", "256"); + if (max_iteminfo < 0) + { + botimport.Print(PRT_ERROR, "max_iteminfo = %d\n", max_iteminfo); + max_iteminfo = 256; + LibVarSet( "max_iteminfo", "256" ); + } + + strncpy( path, filename, MAX_PATH ); + PC_SetBaseFolder(BOTFILESBASEFOLDER); + source = LoadSourceFile( path ); + if( !source ) { + botimport.Print( PRT_ERROR, "counldn't load %s\n", path ); + return NULL; + } //end if + //initialize item config + ic = (itemconfig_t *) GetClearedHunkMemory(sizeof(itemconfig_t) + + max_iteminfo * sizeof(iteminfo_t)); + ic->iteminfo = (iteminfo_t *) ((char *) ic + sizeof(itemconfig_t)); + ic->numiteminfo = 0; + //parse the item config file + while(PC_ReadToken(source, &token)) + { + if (!strcmp(token.string, "iteminfo")) + { + if (ic->numiteminfo >= max_iteminfo) + { + SourceError(source, "more than %d item info defined\n", max_iteminfo); + FreeMemory(ic); + FreeSource(source); + return NULL; + } //end if + ii = &ic->iteminfo[ic->numiteminfo]; + Com_Memset(ii, 0, sizeof(iteminfo_t)); + if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) + { + FreeMemory(ic); + FreeMemory(source); + return NULL; + } //end if + StripDoubleQuotes(token.string); + strncpy(ii->classname, token.string, sizeof(ii->classname)-1); + if (!ReadStructure(source, &iteminfo_struct, (char *) ii)) + { + FreeMemory(ic); + FreeSource(source); + return NULL; + } //end if + ii->number = ic->numiteminfo; + ic->numiteminfo++; + } //end if + else + { + SourceError(source, "unknown definition %s\n", token.string); + FreeMemory(ic); + FreeSource(source); + return NULL; + } //end else + } //end while + FreeSource(source); + // + if (!ic->numiteminfo) botimport.Print(PRT_WARNING, "no item info loaded\n"); + botimport.Print(PRT_MESSAGE, "loaded %s\n", path); + return ic; +} //end of the function LoadItemConfig +//=========================================================================== +// index to find the weight function of an iteminfo +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int *ItemWeightIndex(weightconfig_t *iwc, itemconfig_t *ic) +{ + int *index, i; + + //initialize item weight index + index = (int *) GetClearedMemory(sizeof(int) * ic->numiteminfo); + + for (i = 0; i < ic->numiteminfo; i++) + { + index[i] = FindFuzzyWeight(iwc, ic->iteminfo[i].classname); + if (index[i] < 0) + { + Log_Write("item info %d \"%s\" has no fuzzy weight\r\n", i, ic->iteminfo[i].classname); + } //end if + } //end for + return index; +} //end of the function ItemWeightIndex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void InitLevelItemHeap(void) +{ + int i, max_levelitems; + + if (levelitemheap) FreeMemory(levelitemheap); + + max_levelitems = (int) LibVarValue("max_levelitems", "256"); + levelitemheap = (levelitem_t *) GetClearedMemory(max_levelitems * sizeof(levelitem_t)); + + for (i = 0; i < max_levelitems-1; i++) + { + levelitemheap[i].next = &levelitemheap[i + 1]; + } //end for + levelitemheap[max_levelitems-1].next = NULL; + // + freelevelitems = levelitemheap; +} //end of the function InitLevelItemHeap +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +levelitem_t *AllocLevelItem(void) +{ + levelitem_t *li; + + li = freelevelitems; + if (!li) + { + botimport.Print(PRT_FATAL, "out of level items\n"); + return NULL; + } //end if + // + freelevelitems = freelevelitems->next; + Com_Memset(li, 0, sizeof(levelitem_t)); + return li; +} //end of the function AllocLevelItem +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeLevelItem(levelitem_t *li) +{ + li->next = freelevelitems; + freelevelitems = li; +} //end of the function FreeLevelItem +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AddLevelItemToList(levelitem_t *li) +{ + if (levelitems) levelitems->prev = li; + li->prev = NULL; + li->next = levelitems; + levelitems = li; +} //end of the function AddLevelItemToList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RemoveLevelItemFromList(levelitem_t *li) +{ + if (li->prev) li->prev->next = li->next; + else levelitems = li->next; + if (li->next) li->next->prev = li->prev; +} //end of the function RemoveLevelItemFromList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotFreeInfoEntities(void) +{ + maplocation_t *ml, *nextml; + campspot_t *cs, *nextcs; + + for (ml = maplocations; ml; ml = nextml) + { + nextml = ml->next; + FreeMemory(ml); + } //end for + maplocations = NULL; + for (cs = campspots; cs; cs = nextcs) + { + nextcs = cs->next; + FreeMemory(cs); + } //end for + campspots = NULL; +} //end of the function BotFreeInfoEntities +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotInitInfoEntities(void) +{ + char classname[MAX_EPAIRKEY]; + maplocation_t *ml; + campspot_t *cs; + int ent, numlocations, numcampspots; + + BotFreeInfoEntities(); + // + numlocations = 0; + numcampspots = 0; + for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) + { + if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; + + //map locations + if (!strcmp(classname, "target_location")) + { + ml = (maplocation_t *) GetClearedMemory(sizeof(maplocation_t)); + AAS_VectorForBSPEpairKey(ent, "origin", ml->origin); + AAS_ValueForBSPEpairKey(ent, "message", ml->name, sizeof(ml->name)); + ml->areanum = AAS_PointAreaNum(ml->origin); + ml->next = maplocations; + maplocations = ml; + numlocations++; + } //end if + //camp spots + else if (!strcmp(classname, "info_camp")) + { + cs = (campspot_t *) GetClearedMemory(sizeof(campspot_t)); + AAS_VectorForBSPEpairKey(ent, "origin", cs->origin); + //cs->origin[2] += 16; + AAS_ValueForBSPEpairKey(ent, "message", cs->name, sizeof(cs->name)); + AAS_FloatForBSPEpairKey(ent, "range", &cs->range); + AAS_FloatForBSPEpairKey(ent, "weight", &cs->weight); + AAS_FloatForBSPEpairKey(ent, "wait", &cs->wait); + AAS_FloatForBSPEpairKey(ent, "random", &cs->random); + cs->areanum = AAS_PointAreaNum(cs->origin); + if (!cs->areanum) + { + botimport.Print(PRT_MESSAGE, "camp spot at %1.1f %1.1f %1.1f in solid\n", cs->origin[0], cs->origin[1], cs->origin[2]); + FreeMemory(cs); + continue; + } //end if + cs->next = campspots; + campspots = cs; + //AAS_DrawPermanentCross(cs->origin, 4, LINECOLOR_YELLOW); + numcampspots++; + } //end else if + } //end for + if (bot_developer) + { + botimport.Print(PRT_MESSAGE, "%d map locations\n", numlocations); + botimport.Print(PRT_MESSAGE, "%d camp spots\n", numcampspots); + } //end if +} //end of the function BotInitInfoEntities +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotInitLevelItems(void) +{ + int i, spawnflags, value; + char classname[MAX_EPAIRKEY]; + vec3_t origin, end; + int ent, goalareanum; + itemconfig_t *ic; + levelitem_t *li; + bsp_trace_t trace; + + //initialize the map locations and camp spots + BotInitInfoEntities(); + + //initialize the level item heap + InitLevelItemHeap(); + levelitems = NULL; + numlevelitems = 0; + // + ic = itemconfig; + if (!ic) return; + + //if there's no AAS file loaded + if (!AAS_Loaded()) return; + + //update the modelindexes of the item info + for (i = 0; i < ic->numiteminfo; i++) + { + //ic->iteminfo[i].modelindex = AAS_IndexFromModel(ic->iteminfo[i].model); + if (!ic->iteminfo[i].modelindex) + { + Log_Write("item %s has modelindex 0", ic->iteminfo[i].classname); + } //end if + } //end for + + for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) + { + if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; + // + spawnflags = 0; + AAS_IntForBSPEpairKey(ent, "spawnflags", &spawnflags); + // + for (i = 0; i < ic->numiteminfo; i++) + { + if (!strcmp(classname, ic->iteminfo[i].classname)) break; + } //end for + if (i >= ic->numiteminfo) + { + Log_Write("entity %s unknown item\r\n", classname); + continue; + } //end if + //get the origin of the item + if (!AAS_VectorForBSPEpairKey(ent, "origin", origin)) + { + botimport.Print(PRT_ERROR, "item %s without origin\n", classname); + continue; + } //end else + // + goalareanum = 0; + //if it is a floating item + if (spawnflags & 1) + { + //if the item is not floating in water + if (!(AAS_PointContents(origin) & CONTENTS_WATER)) + { + VectorCopy(origin, end); + end[2] -= 32; + trace = AAS_Trace(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs, end, -1, CONTENTS_SOLID|CONTENTS_PLAYERCLIP); + //if the item not near the ground + if (trace.fraction >= 1) + { + //if the item is not reachable from a jumppad + goalareanum = AAS_BestReachableFromJumpPadArea(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs); + Log_Write("item %s reachable from jumppad area %d\r\n", ic->iteminfo[i].classname, goalareanum); + //botimport.Print(PRT_MESSAGE, "item %s reachable from jumppad area %d\r\n", ic->iteminfo[i].classname, goalareanum); + if (!goalareanum) continue; + } //end if + } //end if + } //end if + + li = AllocLevelItem(); + if (!li) return; + // + li->number = ++numlevelitems; + li->timeout = 0; + li->entitynum = 0; + // + li->flags = 0; + AAS_IntForBSPEpairKey(ent, "notfree", &value); + if (value) li->flags |= IFL_NOTFREE; + AAS_IntForBSPEpairKey(ent, "notteam", &value); + if (value) li->flags |= IFL_NOTTEAM; + AAS_IntForBSPEpairKey(ent, "notsingle", &value); + if (value) li->flags |= IFL_NOTSINGLE; + AAS_IntForBSPEpairKey(ent, "notbot", &value); + if (value) li->flags |= IFL_NOTBOT; + if (!strcmp(classname, "item_botroam")) + { + li->flags |= IFL_ROAM; + AAS_FloatForBSPEpairKey(ent, "weight", &li->weight); + } //end if + //if not a stationary item + if (!(spawnflags & 1)) + { + if (!AAS_DropToFloor(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs)) + { + botimport.Print(PRT_MESSAGE, "%s in solid at (%1.1f %1.1f %1.1f)\n", + classname, origin[0], origin[1], origin[2]); + } //end if + } //end if + //item info of the level item + li->iteminfo = i; + //origin of the item + VectorCopy(origin, li->origin); + // + if (goalareanum) + { + li->goalareanum = goalareanum; + VectorCopy(origin, li->goalorigin); + } //end if + else + { + //get the item goal area and goal origin + li->goalareanum = AAS_BestReachableArea(origin, + ic->iteminfo[i].mins, ic->iteminfo[i].maxs, + li->goalorigin); + if (!li->goalareanum) + { + botimport.Print(PRT_MESSAGE, "%s not reachable for bots at (%1.1f %1.1f %1.1f)\n", + classname, origin[0], origin[1], origin[2]); + } //end if + } //end else + // + AddLevelItemToList(li); + } //end for + botimport.Print(PRT_MESSAGE, "found %d level items\n", numlevelitems); +} //end of the function BotInitLevelItems +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotGoalName(int number, char *name, int size) +{ + levelitem_t *li; + + if (!itemconfig) return; + // + for (li = levelitems; li; li = li->next) + { + if (li->number == number) + { + strncpy(name, itemconfig->iteminfo[li->iteminfo].name, size-1); + name[size-1] = '\0'; + return; + } //end for + } //end for + strcpy(name, ""); + return; +} //end of the function BotGoalName +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotResetAvoidGoals(int goalstate) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return; + Com_Memset(gs->avoidgoals, 0, MAX_AVOIDGOALS * sizeof(int)); + Com_Memset(gs->avoidgoaltimes, 0, MAX_AVOIDGOALS * sizeof(float)); +} //end of the function BotResetAvoidGoals +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotDumpAvoidGoals(int goalstate) +{ + int i; + bot_goalstate_t *gs; + char name[32]; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return; + for (i = 0; i < MAX_AVOIDGOALS; i++) + { + if (gs->avoidgoaltimes[i] >= AAS_Time()) + { + BotGoalName(gs->avoidgoals[i], name, 32); + Log_Write("avoid goal %s, number %d for %f seconds", name, + gs->avoidgoals[i], gs->avoidgoaltimes[i] - AAS_Time()); + } //end if + } //end for +} //end of the function BotDumpAvoidGoals +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotAddToAvoidGoals(bot_goalstate_t *gs, int number, float avoidtime) +{ + int i; + + for (i = 0; i < MAX_AVOIDGOALS; i++) + { + //if the avoid goal is already stored + if (gs->avoidgoals[i] == number) + { + gs->avoidgoals[i] = number; + gs->avoidgoaltimes[i] = AAS_Time() + avoidtime; + return; + } //end if + } //end for + + for (i = 0; i < MAX_AVOIDGOALS; i++) + { + //if this avoid goal has expired + if (gs->avoidgoaltimes[i] < AAS_Time()) + { + gs->avoidgoals[i] = number; + gs->avoidgoaltimes[i] = AAS_Time() + avoidtime; + return; + } //end if + } //end for +} //end of the function BotAddToAvoidGoals +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotRemoveFromAvoidGoals(int goalstate, int number) +{ + int i; + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return; + //don't use the goals the bot wants to avoid + for (i = 0; i < MAX_AVOIDGOALS; i++) + { + if (gs->avoidgoals[i] == number && gs->avoidgoaltimes[i] >= AAS_Time()) + { + gs->avoidgoaltimes[i] = 0; + return; + } //end if + } //end for +} //end of the function BotRemoveFromAvoidGoals +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float BotAvoidGoalTime(int goalstate, int number) +{ + int i; + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return 0; + //don't use the goals the bot wants to avoid + for (i = 0; i < MAX_AVOIDGOALS; i++) + { + if (gs->avoidgoals[i] == number && gs->avoidgoaltimes[i] >= AAS_Time()) + { + return gs->avoidgoaltimes[i] - AAS_Time(); + } //end if + } //end for + return 0; +} //end of the function BotAvoidGoalTime +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotSetAvoidGoalTime(int goalstate, int number, float avoidtime) +{ + bot_goalstate_t *gs; + levelitem_t *li; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) + return; + if (avoidtime < 0) + { + if (!itemconfig) + return; + // + for (li = levelitems; li; li = li->next) + { + if (li->number == number) + { + avoidtime = itemconfig->iteminfo[li->iteminfo].respawntime; + if (!avoidtime) + avoidtime = AVOID_DEFAULT_TIME; + if (avoidtime < AVOID_MINIMUM_TIME) + avoidtime = AVOID_MINIMUM_TIME; + BotAddToAvoidGoals(gs, number, avoidtime); + return; + } //end for + } //end for + return; + } //end if + else + { + BotAddToAvoidGoals(gs, number, avoidtime); + } //end else +} //end of the function BotSetAvoidGoalTime +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotGetLevelItemGoal(int index, char *name, bot_goal_t *goal) +{ + levelitem_t *li; + + if (!itemconfig) return -1; + li = levelitems; + if (index >= 0) + { + for (; li; li = li->next) + { + if (li->number == index) + { + li = li->next; + break; + } //end if + } //end for + } //end for + for (; li; li = li->next) + { + // + if (g_gametype == GT_SINGLE_PLAYER) { + if (li->flags & IFL_NOTSINGLE) continue; + } + else if (g_gametype >= GT_TEAM) { + if (li->flags & IFL_NOTTEAM) continue; + } + else { + if (li->flags & IFL_NOTFREE) continue; + } + if (li->flags & IFL_NOTBOT) continue; + // + if (!Q_stricmp(name, itemconfig->iteminfo[li->iteminfo].name)) + { + goal->areanum = li->goalareanum; + VectorCopy(li->goalorigin, goal->origin); + goal->entitynum = li->entitynum; + VectorCopy(itemconfig->iteminfo[li->iteminfo].mins, goal->mins); + VectorCopy(itemconfig->iteminfo[li->iteminfo].maxs, goal->maxs); + goal->number = li->number; + goal->flags = GFL_ITEM; + if (li->timeout) goal->flags |= GFL_DROPPED; + //botimport.Print(PRT_MESSAGE, "found li %s\n", itemconfig->iteminfo[li->iteminfo].name); + return li->number; + } //end if + } //end for + return -1; +} //end of the function BotGetLevelItemGoal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotGetMapLocationGoal(char *name, bot_goal_t *goal) +{ + maplocation_t *ml; + vec3_t mins = {-8, -8, -8}, maxs = {8, 8, 8}; + + for (ml = maplocations; ml; ml = ml->next) + { + if (!Q_stricmp(ml->name, name)) + { + goal->areanum = ml->areanum; + VectorCopy(ml->origin, goal->origin); + goal->entitynum = 0; + VectorCopy(mins, goal->mins); + VectorCopy(maxs, goal->maxs); + return qtrue; + } //end if + } //end for + return qfalse; +} //end of the function BotGetMapLocationGoal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotGetNextCampSpotGoal(int num, bot_goal_t *goal) +{ + int i; + campspot_t *cs; + vec3_t mins = {-8, -8, -8}, maxs = {8, 8, 8}; + + if (num < 0) num = 0; + i = num; + for (cs = campspots; cs; cs = cs->next) + { + if (--i < 0) + { + goal->areanum = cs->areanum; + VectorCopy(cs->origin, goal->origin); + goal->entitynum = 0; + VectorCopy(mins, goal->mins); + VectorCopy(maxs, goal->maxs); + return num+1; + } //end if + } //end for + return 0; +} //end of the function BotGetNextCampSpotGoal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotFindEntityForLevelItem(levelitem_t *li) +{ + int ent, modelindex; + itemconfig_t *ic; + aas_entityinfo_t entinfo; + vec3_t dir; + + ic = itemconfig; + if (!itemconfig) return; + for (ent = AAS_NextEntity(0); ent; ent = AAS_NextEntity(ent)) + { + //get the model index of the entity + modelindex = AAS_EntityModelindex(ent); + // + if (!modelindex) continue; + //get info about the entity + AAS_EntityInfo(ent, &entinfo); + //if the entity is still moving + if (entinfo.origin[0] != entinfo.lastvisorigin[0] || + entinfo.origin[1] != entinfo.lastvisorigin[1] || + entinfo.origin[2] != entinfo.lastvisorigin[2]) continue; + // + if (ic->iteminfo[li->iteminfo].modelindex == modelindex) + { + //check if the entity is very close + VectorSubtract(li->origin, entinfo.origin, dir); + if (VectorLength(dir) < 30) + { + //found an entity for this level item + li->entitynum = ent; + } //end if + } //end if + } //end for +} //end of the function BotFindEntityForLevelItem +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== + +//NOTE: enum entityType_t in bg_public.h +#define ET_ITEM 2 + +void BotUpdateEntityItems(void) +{ + int ent, i, modelindex; + vec3_t dir; + levelitem_t *li, *nextli; + aas_entityinfo_t entinfo; + itemconfig_t *ic; + + //timeout current entity items if necessary + for (li = levelitems; li; li = nextli) + { + nextli = li->next; + //if it is a item that will time out + if (li->timeout) + { + //timeout the item + if (li->timeout < AAS_Time()) + { + RemoveLevelItemFromList(li); + FreeLevelItem(li); + } //end if + } //end if + } //end for + //find new entity items + ic = itemconfig; + if (!itemconfig) return; + // + for (ent = AAS_NextEntity(0); ent; ent = AAS_NextEntity(ent)) + { + if (AAS_EntityType(ent) != ET_ITEM) continue; + //get the model index of the entity + modelindex = AAS_EntityModelindex(ent); + // + if (!modelindex) continue; + //get info about the entity + AAS_EntityInfo(ent, &entinfo); + //FIXME: don't do this + //skip all floating items for now + //if (entinfo.groundent != ENTITYNUM_WORLD) continue; + //if the entity is still moving + if (entinfo.origin[0] != entinfo.lastvisorigin[0] || + entinfo.origin[1] != entinfo.lastvisorigin[1] || + entinfo.origin[2] != entinfo.lastvisorigin[2]) continue; + //check if the entity is already stored as a level item + for (li = levelitems; li; li = li->next) + { + //if the level item is linked to an entity + if (li->entitynum && li->entitynum == ent) + { + //the entity is re-used if the models are different + if (ic->iteminfo[li->iteminfo].modelindex != modelindex) + { + //remove this level item + RemoveLevelItemFromList(li); + FreeLevelItem(li); + li = NULL; + break; + } //end if + else + { + if (entinfo.origin[0] != li->origin[0] || + entinfo.origin[1] != li->origin[1] || + entinfo.origin[2] != li->origin[2]) + { + VectorCopy(entinfo.origin, li->origin); + //also update the goal area number + li->goalareanum = AAS_BestReachableArea(li->origin, + ic->iteminfo[li->iteminfo].mins, ic->iteminfo[li->iteminfo].maxs, + li->goalorigin); + } //end if + break; + } //end else + } //end if + } //end for + if (li) continue; + //try to link the entity to a level item + for (li = levelitems; li; li = li->next) + { + //if this level item is already linked + if (li->entitynum) continue; + // + if (g_gametype == GT_SINGLE_PLAYER) { + if (li->flags & IFL_NOTSINGLE) continue; + } + else if (g_gametype >= GT_TEAM) { + if (li->flags & IFL_NOTTEAM) continue; + } + else { + if (li->flags & IFL_NOTFREE) continue; + } + //if the model of the level item and the entity are the same + if (ic->iteminfo[li->iteminfo].modelindex == modelindex) + { + //check if the entity is very close + VectorSubtract(li->origin, entinfo.origin, dir); + if (VectorLength(dir) < 30) + { + //found an entity for this level item + li->entitynum = ent; + //if the origin is different + if (entinfo.origin[0] != li->origin[0] || + entinfo.origin[1] != li->origin[1] || + entinfo.origin[2] != li->origin[2]) + { + //update the level item origin + VectorCopy(entinfo.origin, li->origin); + //also update the goal area number + li->goalareanum = AAS_BestReachableArea(li->origin, + ic->iteminfo[li->iteminfo].mins, ic->iteminfo[li->iteminfo].maxs, + li->goalorigin); + } //end if +#ifdef DEBUG + Log_Write("linked item %s to an entity", ic->iteminfo[li->iteminfo].classname); +#endif //DEBUG + break; + } //end if + } //end else + } //end for + if (li) continue; + //check if the model is from a known item + for (i = 0; i < ic->numiteminfo; i++) + { + if (ic->iteminfo[i].modelindex == modelindex) + { + break; + } //end if + } //end for + //if the model is not from a known item + if (i >= ic->numiteminfo) continue; + //allocate a new level item + li = AllocLevelItem(); + // + if (!li) continue; + //entity number of the level item + li->entitynum = ent; + //number for the level item + li->number = numlevelitems + ent; + //set the item info index for the level item + li->iteminfo = i; + //origin of the item + VectorCopy(entinfo.origin, li->origin); + //get the item goal area and goal origin + li->goalareanum = AAS_BestReachableArea(li->origin, + ic->iteminfo[i].mins, ic->iteminfo[i].maxs, + li->goalorigin); + //never go for items dropped into jumppads + if (AAS_AreaJumpPad(li->goalareanum)) + { + FreeLevelItem(li); + continue; + } //end if + //time this item out after 30 seconds + //dropped items disappear after 30 seconds + li->timeout = AAS_Time() + 30; + //add the level item to the list + AddLevelItemToList(li); + //botimport.Print(PRT_MESSAGE, "found new level item %s\n", ic->iteminfo[i].classname); + } //end for + /* + for (li = levelitems; li; li = li->next) + { + if (!li->entitynum) + { + BotFindEntityForLevelItem(li); + } //end if + } //end for*/ +} //end of the function BotUpdateEntityItems +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotDumpGoalStack(int goalstate) +{ + int i; + bot_goalstate_t *gs; + char name[32]; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return; + for (i = 1; i <= gs->goalstacktop; i++) + { + BotGoalName(gs->goalstack[i].number, name, 32); + Log_Write("%d: %s", i, name); + } //end for +} //end of the function BotDumpGoalStack +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotPushGoal(int goalstate, bot_goal_t *goal) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return; + if (gs->goalstacktop >= MAX_GOALSTACK-1) + { + botimport.Print(PRT_ERROR, "goal heap overflow\n"); + BotDumpGoalStack(goalstate); + return; + } //end if + gs->goalstacktop++; + Com_Memcpy(&gs->goalstack[gs->goalstacktop], goal, sizeof(bot_goal_t)); +} //end of the function BotPushGoal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotPopGoal(int goalstate) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return; + if (gs->goalstacktop > 0) gs->goalstacktop--; +} //end of the function BotPopGoal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotEmptyGoalStack(int goalstate) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return; + gs->goalstacktop = 0; +} //end of the function BotEmptyGoalStack +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotGetTopGoal(int goalstate, bot_goal_t *goal) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return qfalse; + if (!gs->goalstacktop) return qfalse; + Com_Memcpy(goal, &gs->goalstack[gs->goalstacktop], sizeof(bot_goal_t)); + return qtrue; +} //end of the function BotGetTopGoal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotGetSecondGoal(int goalstate, bot_goal_t *goal) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return qfalse; + if (gs->goalstacktop <= 1) return qfalse; + Com_Memcpy(goal, &gs->goalstack[gs->goalstacktop-1], sizeof(bot_goal_t)); + return qtrue; +} //end of the function BotGetSecondGoal +//=========================================================================== +// pops a new long term goal on the goal stack in the goalstate +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags) +{ + int areanum, t, weightnum; + float weight, bestweight, avoidtime; + iteminfo_t *iteminfo; + itemconfig_t *ic; + levelitem_t *li, *bestitem; + bot_goal_t goal; + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) + return qfalse; + if (!gs->itemweightconfig) + return qfalse; + //get the area the bot is in + areanum = BotReachabilityArea(origin, gs->client); + //if the bot is in solid or if the area the bot is in has no reachability links + if (!areanum || !AAS_AreaReachability(areanum)) + { + //use the last valid area the bot was in + areanum = gs->lastreachabilityarea; + } //end if + //remember the last area with reachabilities the bot was in + gs->lastreachabilityarea = areanum; + //if still in solid + if (!areanum) + return qfalse; + //the item configuration + ic = itemconfig; + if (!itemconfig) + return qfalse; + //best weight and item so far + bestweight = 0; + bestitem = NULL; + Com_Memset(&goal, 0, sizeof(bot_goal_t)); + //go through the items in the level + for (li = levelitems; li; li = li->next) + { + if (g_gametype == GT_SINGLE_PLAYER) { + if (li->flags & IFL_NOTSINGLE) + continue; + } + else if (g_gametype >= GT_TEAM) { + if (li->flags & IFL_NOTTEAM) + continue; + } + else { + if (li->flags & IFL_NOTFREE) + continue; + } + if (li->flags & IFL_NOTBOT) + continue; + //if the item is not in a possible goal area + if (!li->goalareanum) + continue; + //FIXME: is this a good thing? added this for items that never spawned into the game (f.i. CTF flags in obelisk) + if (!li->entitynum && !(li->flags & IFL_ROAM)) + continue; + //get the fuzzy weight function for this item + iteminfo = &ic->iteminfo[li->iteminfo]; + weightnum = gs->itemweightindex[iteminfo->number]; + if (weightnum < 0) + continue; + +#ifdef UNDECIDEDFUZZY + weight = FuzzyWeightUndecided(inventory, gs->itemweightconfig, weightnum); +#else + weight = FuzzyWeight(inventory, gs->itemweightconfig, weightnum); +#endif //UNDECIDEDFUZZY +#ifdef DROPPEDWEIGHT + //HACK: to make dropped items more attractive + if (li->timeout) + weight += droppedweight->value; +#endif //DROPPEDWEIGHT + //use weight scale for item_botroam + if (li->flags & IFL_ROAM) weight *= li->weight; + // + if (weight > 0) + { + //get the travel time towards the goal area + t = AAS_AreaTravelTimeToGoalArea(areanum, origin, li->goalareanum, travelflags); + //if the goal is reachable + if (t > 0) + { + //if this item won't respawn before we get there + avoidtime = BotAvoidGoalTime(goalstate, li->number); + if (avoidtime - t * 0.009 > 0) + continue; + // + weight /= (float) t * TRAVELTIME_SCALE; + // + if (weight > bestweight) + { + bestweight = weight; + bestitem = li; + } //end if + } //end if + } //end if + } //end for + //if no goal item found + if (!bestitem) + { + /* + //if not in lava or slime + if (!AAS_AreaLava(areanum) && !AAS_AreaSlime(areanum)) + { + if (AAS_RandomGoalArea(areanum, travelflags, &goal.areanum, goal.origin)) + { + VectorSet(goal.mins, -15, -15, -15); + VectorSet(goal.maxs, 15, 15, 15); + goal.entitynum = 0; + goal.number = 0; + goal.flags = GFL_ROAM; + goal.iteminfo = 0; + //push the goal on the stack + BotPushGoal(goalstate, &goal); + // +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "chosen roam goal area %d\n", goal.areanum); +#endif //DEBUG + return qtrue; + } //end if + } //end if + */ + return qfalse; + } //end if + //create a bot goal for this item + iteminfo = &ic->iteminfo[bestitem->iteminfo]; + VectorCopy(bestitem->goalorigin, goal.origin); + VectorCopy(iteminfo->mins, goal.mins); + VectorCopy(iteminfo->maxs, goal.maxs); + goal.areanum = bestitem->goalareanum; + goal.entitynum = bestitem->entitynum; + goal.number = bestitem->number; + goal.flags = GFL_ITEM; + if (bestitem->timeout) + goal.flags |= GFL_DROPPED; + if (bestitem->flags & IFL_ROAM) + goal.flags |= GFL_ROAM; + goal.iteminfo = bestitem->iteminfo; + //if it's a dropped item + if (bestitem->timeout) + { + avoidtime = AVOID_DROPPED_TIME; + } //end if + else + { + avoidtime = iteminfo->respawntime; + if (!avoidtime) + avoidtime = AVOID_DEFAULT_TIME; + if (avoidtime < AVOID_MINIMUM_TIME) + avoidtime = AVOID_MINIMUM_TIME; + } //end else + //add the chosen goal to the goals to avoid for a while + BotAddToAvoidGoals(gs, bestitem->number, avoidtime); + //push the goal on the stack + BotPushGoal(goalstate, &goal); + // + return qtrue; +} //end of the function BotChooseLTGItem +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, + bot_goal_t *ltg, float maxtime) +{ + int areanum, t, weightnum, ltg_time; + float weight, bestweight, avoidtime; + iteminfo_t *iteminfo; + itemconfig_t *ic; + levelitem_t *li, *bestitem; + bot_goal_t goal; + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) + return qfalse; + if (!gs->itemweightconfig) + return qfalse; + //get the area the bot is in + areanum = BotReachabilityArea(origin, gs->client); + //if the bot is in solid or if the area the bot is in has no reachability links + if (!areanum || !AAS_AreaReachability(areanum)) + { + //use the last valid area the bot was in + areanum = gs->lastreachabilityarea; + } //end if + //remember the last area with reachabilities the bot was in + gs->lastreachabilityarea = areanum; + //if still in solid + if (!areanum) + return qfalse; + // + if (ltg) ltg_time = AAS_AreaTravelTimeToGoalArea(areanum, origin, ltg->areanum, travelflags); + else ltg_time = 99999; + //the item configuration + ic = itemconfig; + if (!itemconfig) + return qfalse; + //best weight and item so far + bestweight = 0; + bestitem = NULL; + Com_Memset(&goal, 0, sizeof(bot_goal_t)); + //go through the items in the level + for (li = levelitems; li; li = li->next) + { + if (g_gametype == GT_SINGLE_PLAYER) { + if (li->flags & IFL_NOTSINGLE) + continue; + } + else if (g_gametype >= GT_TEAM) { + if (li->flags & IFL_NOTTEAM) + continue; + } + else { + if (li->flags & IFL_NOTFREE) + continue; + } + if (li->flags & IFL_NOTBOT) + continue; + //if the item is in a possible goal area + if (!li->goalareanum) + continue; + //FIXME: is this a good thing? added this for items that never spawned into the game (f.i. CTF flags in obelisk) + if (!li->entitynum && !(li->flags & IFL_ROAM)) + continue; + //get the fuzzy weight function for this item + iteminfo = &ic->iteminfo[li->iteminfo]; + weightnum = gs->itemweightindex[iteminfo->number]; + if (weightnum < 0) + continue; + // +#ifdef UNDECIDEDFUZZY + weight = FuzzyWeightUndecided(inventory, gs->itemweightconfig, weightnum); +#else + weight = FuzzyWeight(inventory, gs->itemweightconfig, weightnum); +#endif //UNDECIDEDFUZZY +#ifdef DROPPEDWEIGHT + //HACK: to make dropped items more attractive + if (li->timeout) + weight += droppedweight->value; +#endif //DROPPEDWEIGHT + //use weight scale for item_botroam + if (li->flags & IFL_ROAM) weight *= li->weight; + // + if (weight > 0) + { + //get the travel time towards the goal area + t = AAS_AreaTravelTimeToGoalArea(areanum, origin, li->goalareanum, travelflags); + //if the goal is reachable + if (t > 0 && t < maxtime) + { + //if this item won't respawn before we get there + avoidtime = BotAvoidGoalTime(goalstate, li->number); + if (avoidtime - t * 0.009 > 0) + continue; + // + weight /= (float) t * TRAVELTIME_SCALE; + // + if (weight > bestweight) + { + t = 0; + if (ltg && !li->timeout) + { + //get the travel time from the goal to the long term goal + t = AAS_AreaTravelTimeToGoalArea(li->goalareanum, li->goalorigin, ltg->areanum, travelflags); + } //end if + //if the travel back is possible and doesn't take too long + if (t <= ltg_time) + { + bestweight = weight; + bestitem = li; + } //end if + } //end if + } //end if + } //end if + } //end for + //if no goal item found + if (!bestitem) + return qfalse; + //create a bot goal for this item + iteminfo = &ic->iteminfo[bestitem->iteminfo]; + VectorCopy(bestitem->goalorigin, goal.origin); + VectorCopy(iteminfo->mins, goal.mins); + VectorCopy(iteminfo->maxs, goal.maxs); + goal.areanum = bestitem->goalareanum; + goal.entitynum = bestitem->entitynum; + goal.number = bestitem->number; + goal.flags = GFL_ITEM; + if (bestitem->timeout) + goal.flags |= GFL_DROPPED; + if (bestitem->flags & IFL_ROAM) + goal.flags |= GFL_ROAM; + goal.iteminfo = bestitem->iteminfo; + //if it's a dropped item + if (bestitem->timeout) + { + avoidtime = AVOID_DROPPED_TIME; + } //end if + else + { + avoidtime = iteminfo->respawntime; + if (!avoidtime) + avoidtime = AVOID_DEFAULT_TIME; + if (avoidtime < AVOID_MINIMUM_TIME) + avoidtime = AVOID_MINIMUM_TIME; + } //end else + //add the chosen goal to the goals to avoid for a while + BotAddToAvoidGoals(gs, bestitem->number, avoidtime); + //push the goal on the stack + BotPushGoal(goalstate, &goal); + // + return qtrue; +} //end of the function BotChooseNBGItem +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotTouchingGoal(vec3_t origin, bot_goal_t *goal) +{ + int i; + vec3_t boxmins, boxmaxs; + vec3_t absmins, absmaxs; + vec3_t safety_maxs = {0, 0, 0}; //{4, 4, 10}; + vec3_t safety_mins = {0, 0, 0}; //{-4, -4, 0}; + + AAS_PresenceTypeBoundingBox(PRESENCE_NORMAL, boxmins, boxmaxs); + VectorSubtract(goal->mins, boxmaxs, absmins); + VectorSubtract(goal->maxs, boxmins, absmaxs); + VectorAdd(absmins, goal->origin, absmins); + VectorAdd(absmaxs, goal->origin, absmaxs); + //make the box a little smaller for safety + VectorSubtract(absmaxs, safety_maxs, absmaxs); + VectorSubtract(absmins, safety_mins, absmins); + + for (i = 0; i < 3; i++) + { + if (origin[i] < absmins[i] || origin[i] > absmaxs[i]) return qfalse; + } //end for + return qtrue; +} //end of the function BotTouchingGoal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal) +{ + aas_entityinfo_t entinfo; + bsp_trace_t trace; + vec3_t middle; + + if (!(goal->flags & GFL_ITEM)) return qfalse; + // + VectorAdd(goal->mins, goal->mins, middle); + VectorScale(middle, 0.5, middle); + VectorAdd(goal->origin, middle, middle); + // + trace = AAS_Trace(eye, NULL, NULL, middle, viewer, CONTENTS_SOLID); + //if the goal middle point is visible + if (trace.fraction >= 1) + { + //the goal entity number doesn't have to be valid + //just assume it's valid + if (goal->entitynum <= 0) + return qfalse; + // + //if the entity data isn't valid + AAS_EntityInfo(goal->entitynum, &entinfo); + //NOTE: for some wacko reason entities are sometimes + // not updated + //if (!entinfo.valid) return qtrue; + if (entinfo.ltime < AAS_Time() - 0.5) + return qtrue; + } //end if + return qfalse; +} //end of the function BotItemGoalInVisButNotVisible +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotResetGoalState(int goalstate) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return; + Com_Memset(gs->goalstack, 0, MAX_GOALSTACK * sizeof(bot_goal_t)); + gs->goalstacktop = 0; + BotResetAvoidGoals(goalstate); +} //end of the function BotResetGoalState +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotLoadItemWeights(int goalstate, char *filename) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return BLERR_CANNOTLOADITEMWEIGHTS; + //load the weight configuration + gs->itemweightconfig = ReadWeightConfig(filename); + if (!gs->itemweightconfig) + { + botimport.Print(PRT_FATAL, "couldn't load weights\n"); + return BLERR_CANNOTLOADITEMWEIGHTS; + } //end if + //if there's no item configuration + if (!itemconfig) return BLERR_CANNOTLOADITEMWEIGHTS; + //create the item weight index + gs->itemweightindex = ItemWeightIndex(gs->itemweightconfig, itemconfig); + //everything went ok + return BLERR_NOERROR; +} //end of the function BotLoadItemWeights +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotFreeItemWeights(int goalstate) +{ + bot_goalstate_t *gs; + + gs = BotGoalStateFromHandle(goalstate); + if (!gs) return; + if (gs->itemweightconfig) FreeWeightConfig(gs->itemweightconfig); + if (gs->itemweightindex) FreeMemory(gs->itemweightindex); +} //end of the function BotFreeItemWeights +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotAllocGoalState(int client) +{ + int i; + + for (i = 1; i <= MAX_CLIENTS; i++) + { + if (!botgoalstates[i]) + { + botgoalstates[i] = GetClearedMemory(sizeof(bot_goalstate_t)); + botgoalstates[i]->client = client; + return i; + } //end if + } //end for + return 0; +} //end of the function BotAllocGoalState +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +void BotFreeGoalState(int handle) +{ + if (handle <= 0 || handle > MAX_CLIENTS) + { + botimport.Print(PRT_FATAL, "goal state handle %d out of range\n", handle); + return; + } //end if + if (!botgoalstates[handle]) + { + botimport.Print(PRT_FATAL, "invalid goal state handle %d\n", handle); + return; + } //end if + BotFreeItemWeights(handle); + FreeMemory(botgoalstates[handle]); + botgoalstates[handle] = NULL; +} //end of the function BotFreeGoalState +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotSetupGoalAI(void) +{ + char *filename; + + //check if teamplay is on + g_gametype = LibVarValue("g_gametype", "0"); + //item configuration file + filename = LibVarString("itemconfig", "items.c"); + //load the item configuration + itemconfig = LoadItemConfig(filename); + if (!itemconfig) + { + botimport.Print(PRT_FATAL, "couldn't load item config\n"); + return BLERR_CANNOTLOADITEMCONFIG; + } //end if + // + droppedweight = LibVar("droppedweight", "1000"); + //everything went ok + return BLERR_NOERROR; +} //end of the function BotSetupGoalAI +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotShutdownGoalAI(void) +{ + int i; + + if (itemconfig) FreeMemory(itemconfig); + itemconfig = NULL; + if (levelitemheap) FreeMemory(levelitemheap); + levelitemheap = NULL; + freelevelitems = NULL; + levelitems = NULL; + numlevelitems = 0; + + BotFreeInfoEntities(); + + for (i = 1; i <= MAX_CLIENTS; i++) + { + if (botgoalstates[i]) + { + BotFreeGoalState(i); + } //end if + } //end for +} //end of the function BotShutdownGoalAI diff --git a/code/botlib/be_ai_goal.h b/code/botlib/be_ai_goal.h new file mode 100644 index 00000000..80dad08d --- /dev/null +++ b/code/botlib/be_ai_goal.h @@ -0,0 +1,118 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +/***************************************************************************** + * name: be_ai_goal.h + * + * desc: goal AI + * + * $Archive: /source/code/botlib/be_ai_goal.h $ + * + *****************************************************************************/ + +#define MAX_AVOIDGOALS 256 +#define MAX_GOALSTACK 8 + +#define GFL_NONE 0 +#define GFL_ITEM 1 +#define GFL_ROAM 2 +#define GFL_DROPPED 4 + +//a bot goal +typedef struct bot_goal_s +{ + vec3_t origin; //origin of the goal + int areanum; //area number of the goal + vec3_t mins, maxs; //mins and maxs of the goal + int entitynum; //number of the goal entity + int number; //goal number + int flags; //goal flags + int iteminfo; //item information +} bot_goal_t; + +//reset the whole goal state, but keep the item weights +void BotResetGoalState(int goalstate); +//reset avoid goals +void BotResetAvoidGoals(int goalstate); +//remove the goal with the given number from the avoid goals +void BotRemoveFromAvoidGoals(int goalstate, int number); +//push a goal onto the goal stack +void BotPushGoal(int goalstate, bot_goal_t *goal); +//pop a goal from the goal stack +void BotPopGoal(int goalstate); +//empty the bot's goal stack +void BotEmptyGoalStack(int goalstate); +//dump the avoid goals +void BotDumpAvoidGoals(int goalstate); +//dump the goal stack +void BotDumpGoalStack(int goalstate); +//get the name name of the goal with the given number +void BotGoalName(int number, char *name, int size); +//get the top goal from the stack +int BotGetTopGoal(int goalstate, bot_goal_t *goal); +//get the second goal on the stack +int BotGetSecondGoal(int goalstate, bot_goal_t *goal); +//choose the best long term goal item for the bot +int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags); +//choose the best nearby goal item for the bot +//the item may not be further away from the current bot position than maxtime +//also the travel time from the nearby goal towards the long term goal may not +//be larger than the travel time towards the long term goal from the current bot position +int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, + bot_goal_t *ltg, float maxtime); +//returns true if the bot touches the goal +int BotTouchingGoal(vec3_t origin, bot_goal_t *goal); +//returns true if the goal should be visible but isn't +int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal); +//search for a goal for the given classname, the index can be used +//as a start point for the search when multiple goals are available with that same classname +int BotGetLevelItemGoal(int index, char *classname, bot_goal_t *goal); +//get the next camp spot in the map +int BotGetNextCampSpotGoal(int num, bot_goal_t *goal); +//get the map location with the given name +int BotGetMapLocationGoal(char *name, bot_goal_t *goal); +//returns the avoid goal time +float BotAvoidGoalTime(int goalstate, int number); +//set the avoid goal time +void BotSetAvoidGoalTime(int goalstate, int number, float avoidtime); +//initializes the items in the level +void BotInitLevelItems(void); +//regularly update dynamic entity items (dropped weapons, flags etc.) +void BotUpdateEntityItems(void); +//interbreed the goal fuzzy logic +void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child); +//save the goal fuzzy logic to disk +void BotSaveGoalFuzzyLogic(int goalstate, char *filename); +//mutate the goal fuzzy logic +void BotMutateGoalFuzzyLogic(int goalstate, float range); +//loads item weights for the bot +int BotLoadItemWeights(int goalstate, char *filename); +//frees the item weights of the bot +void BotFreeItemWeights(int goalstate); +//returns the handle of a newly allocated goal state +int BotAllocGoalState(int client); +//free the given goal state +void BotFreeGoalState(int handle); +//setup the goal AI +int BotSetupGoalAI(void); +//shut down the goal AI +void BotShutdownGoalAI(void); diff --git a/code/botlib/be_ai_move.c b/code/botlib/be_ai_move.c new file mode 100644 index 00000000..27a855a5 --- /dev/null +++ b/code/botlib/be_ai_move.c @@ -0,0 +1,3570 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_ai_move.c + * + * desc: bot movement AI + * + * $Archive: /MissionPack/code/botlib/be_ai_move.c $ + * + *****************************************************************************/ + +#include "../qcommon/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 "aasfile.h" +#include "botlib.h" +#include "be_aas.h" +#include "be_aas_funcs.h" +#include "be_interface.h" + +#include "be_ea.h" +#include "be_ai_goal.h" +#include "be_ai_move.h" + + +//#define DEBUG_AI_MOVE +//#define DEBUG_ELEVATOR +//#define DEBUG_GRAPPLE + +//movement state +//NOTE: the moveflags MFL_ONGROUND, MFL_TELEPORTED, MFL_WATERJUMP and +// MFL_GRAPPLEPULL must be set outside the movement code +typedef struct bot_movestate_s +{ + //input vars (all set outside the movement code) + vec3_t origin; //origin of the bot + vec3_t velocity; //velocity of the bot + vec3_t viewoffset; //view offset + int entitynum; //entity number of the bot + int client; //client number of the bot + float thinktime; //time the bot thinks + int presencetype; //presencetype of the bot + vec3_t viewangles; //view angles of the bot + //state vars + int areanum; //area the bot is in + int lastareanum; //last area the bot was in + int lastgoalareanum; //last goal area number + int lastreachnum; //last reachability number + vec3_t lastorigin; //origin previous cycle + int reachareanum; //area number of the reachabilty + int moveflags; //movement flags + int jumpreach; //set when jumped + float grapplevisible_time; //last time the grapple was visible + float lastgrappledist; //last distance to the grapple end + float reachability_time; //time to use current reachability + int avoidreach[MAX_AVOIDREACH]; //reachabilities to avoid + float avoidreachtimes[MAX_AVOIDREACH]; //times to avoid the reachabilities + int avoidreachtries[MAX_AVOIDREACH]; //number of tries before avoiding + // + bot_avoidspot_t avoidspots[MAX_AVOIDSPOTS]; //spots to avoid + int numavoidspots; +} bot_movestate_t; + +//used to avoid reachability links for some time after being used +#define AVOIDREACH +#define AVOIDREACH_TIME 6 //avoid links for 6 seconds after use +#define AVOIDREACH_TRIES 4 +//prediction times +#define PREDICTIONTIME_JUMP 3 //in seconds +#define PREDICTIONTIME_MOVE 2 //in seconds +//weapon indexes for weapon jumping +#define WEAPONINDEX_ROCKET_LAUNCHER 5 +#define WEAPONINDEX_BFG 9 + +#define MODELTYPE_FUNC_PLAT 1 +#define MODELTYPE_FUNC_BOB 2 +#define MODELTYPE_FUNC_DOOR 3 +#define MODELTYPE_FUNC_STATIC 4 + +libvar_t *sv_maxstep; +libvar_t *sv_maxbarrier; +libvar_t *sv_gravity; +libvar_t *weapindex_rocketlauncher; +libvar_t *weapindex_bfg10k; +libvar_t *weapindex_grapple; +libvar_t *entitytypemissile; +libvar_t *offhandgrapple; +libvar_t *cmd_grappleoff; +libvar_t *cmd_grappleon; +//type of model, func_plat or func_bobbing +int modeltypes[MAX_MODELS]; + +bot_movestate_t *botmovestates[MAX_CLIENTS+1]; + +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +int BotAllocMoveState(void) +{ + int i; + + for (i = 1; i <= MAX_CLIENTS; i++) + { + if (!botmovestates[i]) + { + botmovestates[i] = GetClearedMemory(sizeof(bot_movestate_t)); + return i; + } //end if + } //end for + return 0; +} //end of the function BotAllocMoveState +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +void BotFreeMoveState(int handle) +{ + if (handle <= 0 || handle > MAX_CLIENTS) + { + botimport.Print(PRT_FATAL, "move state handle %d out of range\n", handle); + return; + } //end if + if (!botmovestates[handle]) + { + botimport.Print(PRT_FATAL, "invalid move state %d\n", handle); + return; + } //end if + FreeMemory(botmovestates[handle]); + botmovestates[handle] = NULL; +} //end of the function BotFreeMoveState +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +bot_movestate_t *BotMoveStateFromHandle(int handle) +{ + if (handle <= 0 || handle > MAX_CLIENTS) + { + botimport.Print(PRT_FATAL, "move state handle %d out of range\n", handle); + return NULL; + } //end if + if (!botmovestates[handle]) + { + botimport.Print(PRT_FATAL, "invalid move state %d\n", handle); + return NULL; + } //end if + return botmovestates[handle]; +} //end of the function BotMoveStateFromHandle +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +void BotInitMoveState(int handle, bot_initmove_t *initmove) +{ + bot_movestate_t *ms; + + ms = BotMoveStateFromHandle(handle); + if (!ms) return; + VectorCopy(initmove->origin, ms->origin); + VectorCopy(initmove->velocity, ms->velocity); + VectorCopy(initmove->viewoffset, ms->viewoffset); + ms->entitynum = initmove->entitynum; + ms->client = initmove->client; + ms->thinktime = initmove->thinktime; + ms->presencetype = initmove->presencetype; + VectorCopy(initmove->viewangles, ms->viewangles); + // + ms->moveflags &= ~MFL_ONGROUND; + if (initmove->or_moveflags & MFL_ONGROUND) ms->moveflags |= MFL_ONGROUND; + ms->moveflags &= ~MFL_TELEPORTED; + if (initmove->or_moveflags & MFL_TELEPORTED) ms->moveflags |= MFL_TELEPORTED; + ms->moveflags &= ~MFL_WATERJUMP; + if (initmove->or_moveflags & MFL_WATERJUMP) ms->moveflags |= MFL_WATERJUMP; + ms->moveflags &= ~MFL_WALK; + if (initmove->or_moveflags & MFL_WALK) ms->moveflags |= MFL_WALK; + ms->moveflags &= ~MFL_GRAPPLEPULL; + if (initmove->or_moveflags & MFL_GRAPPLEPULL) ms->moveflags |= MFL_GRAPPLEPULL; +} //end of the function BotInitMoveState +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +float AngleDiff(float ang1, float ang2) +{ + float diff; + + diff = ang1 - ang2; + if (ang1 > ang2) + { + if (diff > 180.0) diff -= 360.0; + } //end if + else + { + if (diff < -180.0) diff += 360.0; + } //end else + return diff; +} //end of the function AngleDiff +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotFuzzyPointReachabilityArea(vec3_t origin) +{ + int firstareanum, j, x, y, z; + int areas[10], numareas, areanum, bestareanum; + float dist, bestdist; + vec3_t points[10], v, end; + + firstareanum = 0; + areanum = AAS_PointAreaNum(origin); + if (areanum) + { + firstareanum = areanum; + if (AAS_AreaReachability(areanum)) return areanum; + } //end if + VectorCopy(origin, end); + end[2] += 4; + numareas = AAS_TraceAreas(origin, end, areas, points, 10); + for (j = 0; j < numareas; j++) + { + if (AAS_AreaReachability(areas[j])) return areas[j]; + } //end for + bestdist = 999999; + bestareanum = 0; + for (z = 1; z >= -1; z -= 1) + { + for (x = 1; x >= -1; x -= 1) + { + for (y = 1; y >= -1; y -= 1) + { + VectorCopy(origin, end); + end[0] += x * 8; + end[1] += y * 8; + end[2] += z * 12; + numareas = AAS_TraceAreas(origin, end, areas, points, 10); + for (j = 0; j < numareas; j++) + { + if (AAS_AreaReachability(areas[j])) + { + VectorSubtract(points[j], origin, v); + dist = VectorLength(v); + if (dist < bestdist) + { + bestareanum = areas[j]; + bestdist = dist; + } //end if + } //end if + if (!firstareanum) firstareanum = areas[j]; + } //end for + } //end for + } //end for + if (bestareanum) return bestareanum; + } //end for + return firstareanum; +} //end of the function BotFuzzyPointReachabilityArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotReachabilityArea(vec3_t origin, int client) +{ + int modelnum, modeltype, reachnum, areanum; + aas_reachability_t reach; + vec3_t org, end, mins, maxs, up = {0, 0, 1}; + bsp_trace_t bsptrace; + aas_trace_t trace; + + //check if the bot is standing on something + AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, mins, maxs); + VectorMA(origin, -3, up, end); + bsptrace = AAS_Trace(origin, mins, maxs, end, client, CONTENTS_SOLID|CONTENTS_PLAYERCLIP); + if (!bsptrace.startsolid && bsptrace.fraction < 1 && bsptrace.ent != ENTITYNUM_NONE) + { + //if standing on the world the bot should be in a valid area + if (bsptrace.ent == ENTITYNUM_WORLD) + { + return BotFuzzyPointReachabilityArea(origin); + } //end if + + modelnum = AAS_EntityModelindex(bsptrace.ent); + modeltype = modeltypes[modelnum]; + + //if standing on a func_plat or func_bobbing then the bot is assumed to be + //in the area the reachability points to + if (modeltype == MODELTYPE_FUNC_PLAT || modeltype == MODELTYPE_FUNC_BOB) + { + reachnum = AAS_NextModelReachability(0, modelnum); + if (reachnum) + { + AAS_ReachabilityFromNum(reachnum, &reach); + return reach.areanum; + } //end if + } //end else if + + //if the bot is swimming the bot should be in a valid area + if (AAS_Swimming(origin)) + { + return BotFuzzyPointReachabilityArea(origin); + } //end if + // + areanum = BotFuzzyPointReachabilityArea(origin); + //if the bot is in an area with reachabilities + if (areanum && AAS_AreaReachability(areanum)) return areanum; + //trace down till the ground is hit because the bot is standing on some other entity + VectorCopy(origin, org); + VectorCopy(org, end); + end[2] -= 800; + trace = AAS_TraceClientBBox(org, end, PRESENCE_CROUCH, -1); + if (!trace.startsolid) + { + VectorCopy(trace.endpos, org); + } //end if + // + return BotFuzzyPointReachabilityArea(org); + } //end if + // + return BotFuzzyPointReachabilityArea(origin); +} //end of the function BotReachabilityArea +//=========================================================================== +// returns the reachability area the bot is in +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +/* +int BotReachabilityArea(vec3_t origin, int testground) +{ + int firstareanum, i, j, x, y, z; + int areas[10], numareas, areanum, bestareanum; + float dist, bestdist; + vec3_t org, end, points[10], v; + aas_trace_t trace; + + firstareanum = 0; + for (i = 0; i < 2; i++) + { + VectorCopy(origin, org); + //if test at the ground (used when bot is standing on an entity) + if (i > 0) + { + VectorCopy(origin, end); + end[2] -= 800; + trace = AAS_TraceClientBBox(origin, end, PRESENCE_CROUCH, -1); + if (!trace.startsolid) + { + VectorCopy(trace.endpos, org); + } //end if + } //end if + + firstareanum = 0; + areanum = AAS_PointAreaNum(org); + if (areanum) + { + firstareanum = areanum; + if (AAS_AreaReachability(areanum)) return areanum; + } //end if + bestdist = 999999; + bestareanum = 0; + for (z = 1; z >= -1; z -= 1) + { + for (x = 1; x >= -1; x -= 1) + { + for (y = 1; y >= -1; y -= 1) + { + VectorCopy(org, end); + end[0] += x * 8; + end[1] += y * 8; + end[2] += z * 12; + numareas = AAS_TraceAreas(org, end, areas, points, 10); + for (j = 0; j < numareas; j++) + { + if (AAS_AreaReachability(areas[j])) + { + VectorSubtract(points[j], org, v); + dist = VectorLength(v); + if (dist < bestdist) + { + bestareanum = areas[j]; + bestdist = dist; + } //end if + } //end if + } //end for + } //end for + } //end for + if (bestareanum) return bestareanum; + } //end for + if (!testground) break; + } //end for +//#ifdef DEBUG + //botimport.Print(PRT_MESSAGE, "no reachability area\n"); +//#endif //DEBUG + return firstareanum; +} //end of the function BotReachabilityArea*/ +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotOnMover(vec3_t origin, int entnum, aas_reachability_t *reach) +{ + int i, modelnum; + vec3_t mins, maxs, modelorigin, org, end; + vec3_t angles = {0, 0, 0}; + vec3_t boxmins = {-16, -16, -8}, boxmaxs = {16, 16, 8}; + bsp_trace_t trace; + + modelnum = reach->facenum & 0x0000FFFF; + //get some bsp model info + AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL); + // + if (!AAS_OriginOfMoverWithModelNum(modelnum, modelorigin)) + { + botimport.Print(PRT_MESSAGE, "no entity with model %d\n", modelnum); + return qfalse; + } //end if + // + for (i = 0; i < 2; i++) + { + if (origin[i] > modelorigin[i] + maxs[i] + 16) return qfalse; + if (origin[i] < modelorigin[i] + mins[i] - 16) return qfalse; + } //end for + // + VectorCopy(origin, org); + org[2] += 24; + VectorCopy(origin, end); + end[2] -= 48; + // + trace = AAS_Trace(org, boxmins, boxmaxs, end, entnum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP); + if (!trace.startsolid && !trace.allsolid) + { + //NOTE: the reachability face number is the model number of the elevator + if (trace.ent != ENTITYNUM_NONE && AAS_EntityModelNum(trace.ent) == modelnum) + { + return qtrue; + } //end if + } //end if + return qfalse; +} //end of the function BotOnMover +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int MoverDown(aas_reachability_t *reach) +{ + int modelnum; + vec3_t mins, maxs, origin; + vec3_t angles = {0, 0, 0}; + + modelnum = reach->facenum & 0x0000FFFF; + //get some bsp model info + AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin); + // + if (!AAS_OriginOfMoverWithModelNum(modelnum, origin)) + { + botimport.Print(PRT_MESSAGE, "no entity with model %d\n", modelnum); + return qfalse; + } //end if + //if the top of the plat is below the reachability start point + if (origin[2] + maxs[2] < reach->start[2]) return qtrue; + return qfalse; +} //end of the function MoverDown +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +void BotSetBrushModelTypes(void) +{ + int ent, modelnum; + char classname[MAX_EPAIRKEY], model[MAX_EPAIRKEY]; + + Com_Memset(modeltypes, 0, MAX_MODELS * sizeof(int)); + // + for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) + { + if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; + if (!AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY)) continue; + if (model[0]) modelnum = atoi(model+1); + else modelnum = 0; + + if (modelnum < 0 || modelnum > MAX_MODELS) + { + botimport.Print(PRT_MESSAGE, "entity %s model number out of range\n", classname); + continue; + } //end if + + if (!Q_stricmp(classname, "func_bobbing")) + modeltypes[modelnum] = MODELTYPE_FUNC_BOB; + else if (!Q_stricmp(classname, "func_plat")) + modeltypes[modelnum] = MODELTYPE_FUNC_PLAT; + else if (!Q_stricmp(classname, "func_door")) + modeltypes[modelnum] = MODELTYPE_FUNC_DOOR; + else if (!Q_stricmp(classname, "func_static")) + modeltypes[modelnum] = MODELTYPE_FUNC_STATIC; + } //end for +} //end of the function BotSetBrushModelTypes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotOnTopOfEntity(bot_movestate_t *ms) +{ + vec3_t mins, maxs, end, up = {0, 0, 1}; + bsp_trace_t trace; + + AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs); + VectorMA(ms->origin, -3, up, end); + trace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP); + if (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) ) + { + return trace.ent; + } //end if + return -1; +} //end of the function BotOnTopOfEntity +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotValidTravel(vec3_t origin, aas_reachability_t *reach, int travelflags) +{ + //if the reachability uses an unwanted travel type + if (AAS_TravelFlagForType(reach->traveltype) & ~travelflags) return qfalse; + //don't go into areas with bad travel types + if (AAS_AreaContentsTravelFlags(reach->areanum) & ~travelflags) return qfalse; + return qtrue; +} //end of the function BotValidTravel +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotAddToAvoidReach(bot_movestate_t *ms, int number, float avoidtime) +{ + int i; + + for (i = 0; i < MAX_AVOIDREACH; i++) + { + if (ms->avoidreach[i] == number) + { + if (ms->avoidreachtimes[i] > AAS_Time()) ms->avoidreachtries[i]++; + else ms->avoidreachtries[i] = 1; + ms->avoidreachtimes[i] = AAS_Time() + avoidtime; + return; + } //end if + } //end for + //add the reachability to the reachabilities to avoid for a while + for (i = 0; i < MAX_AVOIDREACH; i++) + { + if (ms->avoidreachtimes[i] < AAS_Time()) + { + ms->avoidreach[i] = number; + ms->avoidreachtimes[i] = AAS_Time() + avoidtime; + ms->avoidreachtries[i] = 1; + return; + } //end if + } //end for +} //end of the function BotAddToAvoidReach +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float DistanceFromLineSquared(vec3_t p, vec3_t lp1, vec3_t lp2) +{ + vec3_t proj, dir; + int j; + + AAS_ProjectPointOntoVector(p, lp1, lp2, proj); + for (j = 0; j < 3; j++) + if ((proj[j] > lp1[j] && proj[j] > lp2[j]) || + (proj[j] < lp1[j] && proj[j] < lp2[j])) + break; + if (j < 3) { + if (fabs(proj[j] - lp1[j]) < fabs(proj[j] - lp2[j])) + VectorSubtract(p, lp1, dir); + else + VectorSubtract(p, lp2, dir); + return VectorLengthSquared(dir); + } + VectorSubtract(p, proj, dir); + return VectorLengthSquared(dir); +} //end of the function DistanceFromLineSquared +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float VectorDistanceSquared(vec3_t p1, vec3_t p2) +{ + vec3_t dir; + VectorSubtract(p2, p1, dir); + return VectorLengthSquared(dir); +} //end of the function VectorDistanceSquared +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotAvoidSpots(vec3_t origin, aas_reachability_t *reach, bot_avoidspot_t *avoidspots, int numavoidspots) +{ + int checkbetween, i, type; + float squareddist, squaredradius; + + switch(reach->traveltype & TRAVELTYPE_MASK) + { + case TRAVEL_WALK: checkbetween = qtrue; break; + case TRAVEL_CROUCH: checkbetween = qtrue; break; + case TRAVEL_BARRIERJUMP: checkbetween = qtrue; break; + case TRAVEL_LADDER: checkbetween = qtrue; break; + case TRAVEL_WALKOFFLEDGE: checkbetween = qfalse; break; + case TRAVEL_JUMP: checkbetween = qfalse; break; + case TRAVEL_SWIM: checkbetween = qtrue; break; + case TRAVEL_WATERJUMP: checkbetween = qtrue; break; + case TRAVEL_TELEPORT: checkbetween = qfalse; break; + case TRAVEL_ELEVATOR: checkbetween = qfalse; break; + case TRAVEL_GRAPPLEHOOK: checkbetween = qfalse; break; + case TRAVEL_ROCKETJUMP: checkbetween = qfalse; break; + case TRAVEL_BFGJUMP: checkbetween = qfalse; break; + case TRAVEL_JUMPPAD: checkbetween = qfalse; break; + case TRAVEL_FUNCBOB: checkbetween = qfalse; break; + default: checkbetween = qtrue; break; + } //end switch + + type = AVOID_CLEAR; + for (i = 0; i < numavoidspots; i++) + { + squaredradius = Square(avoidspots[i].radius); + squareddist = DistanceFromLineSquared(avoidspots[i].origin, origin, reach->start); + // if moving towards the avoid spot + if (squareddist < squaredradius && + VectorDistanceSquared(avoidspots[i].origin, origin) > squareddist) + { + type = avoidspots[i].type; + } //end if + else if (checkbetween) { + squareddist = DistanceFromLineSquared(avoidspots[i].origin, reach->start, reach->end); + // if moving towards the avoid spot + if (squareddist < squaredradius && + VectorDistanceSquared(avoidspots[i].origin, reach->start) > squareddist) + { + type = avoidspots[i].type; + } //end if + } //end if + else + { + VectorDistanceSquared(avoidspots[i].origin, reach->end); + // if the reachability leads closer to the avoid spot + if (squareddist < squaredradius && + VectorDistanceSquared(avoidspots[i].origin, reach->start) > squareddist) + { + type = avoidspots[i].type; + } //end if + } //end else + if (type == AVOID_ALWAYS) + return type; + } //end for + return type; +} //end of the function BotAvoidSpots +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type) +{ + bot_movestate_t *ms; + + ms = BotMoveStateFromHandle(movestate); + if (!ms) return; + if (type == AVOID_CLEAR) + { + ms->numavoidspots = 0; + return; + } //end if + + if (ms->numavoidspots >= MAX_AVOIDSPOTS) + return; + VectorCopy(origin, ms->avoidspots[ms->numavoidspots].origin); + ms->avoidspots[ms->numavoidspots].radius = radius; + ms->avoidspots[ms->numavoidspots].type = type; + ms->numavoidspots++; +} //end of the function BotAddAvoidSpot +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotGetReachabilityToGoal(vec3_t origin, int areanum, + int lastgoalareanum, int lastareanum, + int *avoidreach, float *avoidreachtimes, int *avoidreachtries, + bot_goal_t *goal, int travelflags, int movetravelflags, + struct bot_avoidspot_s *avoidspots, int numavoidspots, int *flags) +{ + int i, t, besttime, bestreachnum, reachnum; + aas_reachability_t reach; + + //if not in a valid area + if (!areanum) return 0; + // + if (AAS_AreaDoNotEnter(areanum) || AAS_AreaDoNotEnter(goal->areanum)) + { + travelflags |= TFL_DONOTENTER; + movetravelflags |= TFL_DONOTENTER; + } //end if + //use the routing to find the next area to go to + besttime = 0; + bestreachnum = 0; + // + for (reachnum = AAS_NextAreaReachability(areanum, 0); reachnum; + reachnum = AAS_NextAreaReachability(areanum, reachnum)) + { +#ifdef AVOIDREACH + //check if it isn't an reachability to avoid + for (i = 0; i < MAX_AVOIDREACH; i++) + { + if (avoidreach[i] == reachnum && avoidreachtimes[i] >= AAS_Time()) break; + } //end for + if (i != MAX_AVOIDREACH && avoidreachtries[i] > AVOIDREACH_TRIES) + { +#ifdef DEBUG + if (bot_developer) + { + botimport.Print(PRT_MESSAGE, "avoiding reachability %d\n", avoidreach[i]); + } //end if +#endif //DEBUG + continue; + } //end if +#endif //AVOIDREACH + //get the reachability from the number + AAS_ReachabilityFromNum(reachnum, &reach); + //NOTE: do not go back to the previous area if the goal didn't change + //NOTE: is this actually avoidance of local routing minima between two areas??? + if (lastgoalareanum == goal->areanum && reach.areanum == lastareanum) continue; + //if (AAS_AreaContentsTravelFlags(reach.areanum) & ~travelflags) continue; + //if the travel isn't valid + if (!BotValidTravel(origin, &reach, movetravelflags)) continue; + //get the travel time + t = AAS_AreaTravelTimeToGoalArea(reach.areanum, reach.end, goal->areanum, travelflags); + //if the goal area isn't reachable from the reachable area + if (!t) continue; + //if the bot should not use this reachability to avoid bad spots + if (BotAvoidSpots(origin, &reach, avoidspots, numavoidspots)) { + if (flags) { + *flags |= MOVERESULT_BLOCKEDBYAVOIDSPOT; + } + continue; + } + //add the travel time towards the area + t += reach.traveltime;// + AAS_AreaTravelTime(areanum, origin, reach.start); + //if the travel time is better than the ones already found + if (!besttime || t < besttime) + { + besttime = t; + bestreachnum = reachnum; + } //end if + } //end for + // + return bestreachnum; +} //end of the function BotGetReachabilityToGoal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotAddToTarget(vec3_t start, vec3_t end, float maxdist, float *dist, vec3_t target) +{ + vec3_t dir; + float curdist; + + VectorSubtract(end, start, dir); + curdist = VectorNormalize(dir); + if (*dist + curdist < maxdist) + { + VectorCopy(end, target); + *dist += curdist; + return qfalse; + } //end if + else + { + VectorMA(start, maxdist - *dist, dir, target); + *dist = maxdist; + return qtrue; + } //end else +} //end of the function BotAddToTarget + +int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target) +{ + aas_reachability_t reach; + int reachnum, lastareanum; + bot_movestate_t *ms; + vec3_t end; + float dist; + + ms = BotMoveStateFromHandle(movestate); + if (!ms) return qfalse; + reachnum = 0; + //if the bot has no goal or no last reachability + if (!ms->lastreachnum || !goal) return qfalse; + + reachnum = ms->lastreachnum; + VectorCopy(ms->origin, end); + lastareanum = ms->lastareanum; + dist = 0; + while(reachnum && dist < lookahead) + { + AAS_ReachabilityFromNum(reachnum, &reach); + if (BotAddToTarget(end, reach.start, lookahead, &dist, target)) return qtrue; + //never look beyond teleporters + if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_TELEPORT) return qtrue; + //never look beyond the weapon jump point + if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_ROCKETJUMP) return qtrue; + if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_BFGJUMP) return qtrue; + //don't add jump pad distances + if ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_JUMPPAD && + (reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_ELEVATOR && + (reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_FUNCBOB) + { + if (BotAddToTarget(reach.start, reach.end, lookahead, &dist, target)) return qtrue; + } //end if + reachnum = BotGetReachabilityToGoal(reach.end, reach.areanum, + ms->lastgoalareanum, lastareanum, + ms->avoidreach, ms->avoidreachtimes, ms->avoidreachtries, + goal, travelflags, travelflags, NULL, 0, NULL); + VectorCopy(reach.end, end); + lastareanum = reach.areanum; + if (lastareanum == goal->areanum) + { + BotAddToTarget(reach.end, goal->origin, lookahead, &dist, target); + return qtrue; + } //end if + } //end while + // + return qfalse; +} //end of the function BotMovementViewTarget +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotVisible(int ent, vec3_t eye, vec3_t target) +{ + bsp_trace_t trace; + + trace = AAS_Trace(eye, NULL, NULL, target, ent, CONTENTS_SOLID|CONTENTS_PLAYERCLIP); + if (trace.fraction >= 1) return qtrue; + return qfalse; +} //end of the function BotVisible +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target) +{ + aas_reachability_t reach; + int reachnum, lastgoalareanum, lastareanum, i; + int avoidreach[MAX_AVOIDREACH]; + float avoidreachtimes[MAX_AVOIDREACH]; + int avoidreachtries[MAX_AVOIDREACH]; + vec3_t end; + + //if the bot has no goal or no last reachability + if (!goal) return qfalse; + //if the areanum is not valid + if (!areanum) return qfalse; + //if the goal areanum is not valid + if (!goal->areanum) return qfalse; + + Com_Memset(avoidreach, 0, MAX_AVOIDREACH * sizeof(int)); + lastgoalareanum = goal->areanum; + lastareanum = areanum; + VectorCopy(origin, end); + //only do 20 hops + for (i = 0; i < 20 && (areanum != goal->areanum); i++) + { + // + reachnum = BotGetReachabilityToGoal(end, areanum, + lastgoalareanum, lastareanum, + avoidreach, avoidreachtimes, avoidreachtries, + goal, travelflags, travelflags, NULL, 0, NULL); + if (!reachnum) return qfalse; + AAS_ReachabilityFromNum(reachnum, &reach); + // + if (BotVisible(goal->entitynum, goal->origin, reach.start)) + { + VectorCopy(reach.start, target); + return qtrue; + } //end if + // + if (BotVisible(goal->entitynum, goal->origin, reach.end)) + { + VectorCopy(reach.end, target); + return qtrue; + } //end if + // + if (reach.areanum == goal->areanum) + { + VectorCopy(reach.end, target); + return qtrue; + } //end if + // + lastareanum = areanum; + areanum = reach.areanum; + VectorCopy(reach.end, end); + // + } //end while + // + return qfalse; +} //end of the function BotPredictVisiblePosition +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void MoverBottomCenter(aas_reachability_t *reach, vec3_t bottomcenter) +{ + int modelnum; + vec3_t mins, maxs, origin, mids; + vec3_t angles = {0, 0, 0}; + + modelnum = reach->facenum & 0x0000FFFF; + //get some bsp model info + AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin); + // + if (!AAS_OriginOfMoverWithModelNum(modelnum, origin)) + { + botimport.Print(PRT_MESSAGE, "no entity with model %d\n", modelnum); + } //end if + //get a point just above the plat in the bottom position + VectorAdd(mins, maxs, mids); + VectorMA(origin, 0.5, mids, bottomcenter); + bottomcenter[2] = reach->start[2]; +} //end of the function MoverBottomCenter +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float BotGapDistance(vec3_t origin, vec3_t hordir, int entnum) +{ + float dist, startz; + vec3_t start, end; + aas_trace_t trace; + + //do gap checking + startz = origin[2]; + //this enables walking down stairs more fluidly + { + VectorCopy(origin, start); + VectorCopy(origin, end); + end[2] -= 60; + trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, entnum); + if (trace.fraction >= 1) return 1; + startz = trace.endpos[2] + 1; + } + // + for (dist = 8; dist <= 100; dist += 8) + { + VectorMA(origin, dist, hordir, start); + start[2] = startz + 24; + VectorCopy(start, end); + end[2] -= 48 + sv_maxbarrier->value; + trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, entnum); + //if solid is found the bot can't walk any further and fall into a gap + if (!trace.startsolid) + { + //if it is a gap + if (trace.endpos[2] < startz - sv_maxstep->value - 8) + { + VectorCopy(trace.endpos, end); + end[2] -= 20; + if (AAS_PointContents(end) & CONTENTS_WATER) break; + //if a gap is found slow down + //botimport.Print(PRT_MESSAGE, "gap at %f\n", dist); + return dist; + } //end if + startz = trace.endpos[2]; + } //end if + } //end for + return 0; +} //end of the function BotGapDistance +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotCheckBarrierJump(bot_movestate_t *ms, vec3_t dir, float speed) +{ + vec3_t start, hordir, end; + aas_trace_t trace; + + VectorCopy(ms->origin, end); + end[2] += sv_maxbarrier->value; + //trace right up + trace = AAS_TraceClientBBox(ms->origin, end, PRESENCE_NORMAL, ms->entitynum); + //this shouldn't happen... but we check anyway + if (trace.startsolid) return qfalse; + //if very low ceiling it isn't possible to jump up to a barrier + if (trace.endpos[2] - ms->origin[2] < sv_maxstep->value) return qfalse; + // + hordir[0] = dir[0]; + hordir[1] = dir[1]; + hordir[2] = 0; + VectorNormalize(hordir); + VectorMA(ms->origin, ms->thinktime * speed * 0.5, hordir, end); + VectorCopy(trace.endpos, start); + end[2] = trace.endpos[2]; + //trace from previous trace end pos horizontally in the move direction + trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, ms->entitynum); + //again this shouldn't happen + if (trace.startsolid) return qfalse; + // + VectorCopy(trace.endpos, start); + VectorCopy(trace.endpos, end); + end[2] = ms->origin[2]; + //trace down from the previous trace end pos + trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, ms->entitynum); + //if solid + if (trace.startsolid) return qfalse; + //if no obstacle at all + if (trace.fraction >= 1.0) return qfalse; + //if less than the maximum step height + if (trace.endpos[2] - ms->origin[2] < sv_maxstep->value) return qfalse; + // + EA_Jump(ms->client); + EA_Move(ms->client, hordir, speed); + ms->moveflags |= MFL_BARRIERJUMP; + //there is a barrier + return qtrue; +} //end of the function BotCheckBarrierJump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotSwimInDirection(bot_movestate_t *ms, vec3_t dir, float speed, int type) +{ + vec3_t normdir; + + VectorCopy(dir, normdir); + VectorNormalize(normdir); + EA_Move(ms->client, normdir, speed); + return qtrue; +} //end of the function BotSwimInDirection +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotWalkInDirection(bot_movestate_t *ms, vec3_t dir, float speed, int type) +{ + vec3_t hordir, cmdmove, velocity, tmpdir, origin; + int presencetype, maxframes, cmdframes, stopevent; + aas_clientmove_t move; + float dist; + + if (AAS_OnGround(ms->origin, ms->presencetype, ms->entitynum)) ms->moveflags |= MFL_ONGROUND; + //if the bot is on the ground + if (ms->moveflags & MFL_ONGROUND) + { + //if there is a barrier the bot can jump on + if (BotCheckBarrierJump(ms, dir, speed)) return qtrue; + //remove barrier jump flag + ms->moveflags &= ~MFL_BARRIERJUMP; + //get the presence type for the movement + if ((type & MOVE_CROUCH) && !(type & MOVE_JUMP)) presencetype = PRESENCE_CROUCH; + else presencetype = PRESENCE_NORMAL; + //horizontal direction + hordir[0] = dir[0]; + hordir[1] = dir[1]; + hordir[2] = 0; + VectorNormalize(hordir); + //if the bot is not supposed to jump + if (!(type & MOVE_JUMP)) + { + //if there is a gap, try to jump over it + if (BotGapDistance(ms->origin, hordir, ms->entitynum) > 0) type |= MOVE_JUMP; + } //end if + //get command movement + VectorScale(hordir, speed, cmdmove); + VectorCopy(ms->velocity, velocity); + // + if (type & MOVE_JUMP) + { + //botimport.Print(PRT_MESSAGE, "trying jump\n"); + cmdmove[2] = 400; + maxframes = PREDICTIONTIME_JUMP / 0.1; + cmdframes = 1; + stopevent = SE_HITGROUND|SE_HITGROUNDDAMAGE| + SE_ENTERWATER|SE_ENTERSLIME|SE_ENTERLAVA; + } //end if + else + { + maxframes = 2; + cmdframes = 2; + stopevent = SE_HITGROUNDDAMAGE| + SE_ENTERWATER|SE_ENTERSLIME|SE_ENTERLAVA; + } //end else + //AAS_ClearShownDebugLines(); + // + VectorCopy(ms->origin, origin); + origin[2] += 0.5; + AAS_PredictClientMovement(&move, ms->entitynum, origin, presencetype, qtrue, + velocity, cmdmove, cmdframes, maxframes, 0.1f, + stopevent, 0, qfalse);//qtrue); + //if prediction time wasn't enough to fully predict the movement + if (move.frames >= maxframes && (type & MOVE_JUMP)) + { + //botimport.Print(PRT_MESSAGE, "client %d: max prediction frames\n", ms->client); + return qfalse; + } //end if + //don't enter slime or lava and don't fall from too high + if (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE)) + { + //botimport.Print(PRT_MESSAGE, "client %d: would be hurt ", ms->client); + //if (move.stopevent & SE_ENTERSLIME) botimport.Print(PRT_MESSAGE, "slime\n"); + //if (move.stopevent & SE_ENTERLAVA) botimport.Print(PRT_MESSAGE, "lava\n"); + //if (move.stopevent & SE_HITGROUNDDAMAGE) botimport.Print(PRT_MESSAGE, "hitground\n"); + return qfalse; + } //end if + //if ground was hit + if (move.stopevent & SE_HITGROUND) + { + //check for nearby gap + VectorNormalize2(move.velocity, tmpdir); + dist = BotGapDistance(move.endpos, tmpdir, ms->entitynum); + if (dist > 0) return qfalse; + // + dist = BotGapDistance(move.endpos, hordir, ms->entitynum); + if (dist > 0) return qfalse; + } //end if + //get horizontal movement + tmpdir[0] = move.endpos[0] - ms->origin[0]; + tmpdir[1] = move.endpos[1] - ms->origin[1]; + tmpdir[2] = 0; + // + //AAS_DrawCross(move.endpos, 4, LINECOLOR_BLUE); + //the bot is blocked by something + if (VectorLength(tmpdir) < speed * ms->thinktime * 0.5) return qfalse; + //perform the movement + if (type & MOVE_JUMP) EA_Jump(ms->client); + if (type & MOVE_CROUCH) EA_Crouch(ms->client); + EA_Move(ms->client, hordir, speed); + //movement was succesfull + return qtrue; + } //end if + else + { + if (ms->moveflags & MFL_BARRIERJUMP) + { + //if near the top or going down + if (ms->velocity[2] < 50) + { + EA_Move(ms->client, dir, speed); + } //end if + } //end if + //FIXME: do air control to avoid hazards + return qtrue; + } //end else +} //end of the function BotWalkInDirection +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotMoveInDirection(int movestate, vec3_t dir, float speed, int type) +{ + bot_movestate_t *ms; + + ms = BotMoveStateFromHandle(movestate); + if (!ms) return qfalse; + //if swimming + if (AAS_Swimming(ms->origin)) + { + return BotSwimInDirection(ms, dir, speed, type); + } //end if + else + { + return BotWalkInDirection(ms, dir, speed, type); + } //end else +} //end of the function BotMoveInDirection +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Intersection(vec2_t p1, vec2_t p2, vec2_t p3, vec2_t p4, vec2_t out) +{ + float x1, dx1, dy1, x2, dx2, dy2, d; + + dx1 = p2[0] - p1[0]; + dy1 = p2[1] - p1[1]; + dx2 = p4[0] - p3[0]; + dy2 = p4[1] - p3[1]; + + d = dy1 * dx2 - dx1 * dy2; + if (d != 0) + { + x1 = p1[1] * dx1 - p1[0] * dy1; + x2 = p3[1] * dx2 - p3[0] * dy2; + out[0] = (int) ((dx1 * x2 - dx2 * x1) / d); + out[1] = (int) ((dy1 * x2 - dy2 * x1) / d); + return qtrue; + } //end if + else + { + return qfalse; + } //end else +} //end of the function Intersection +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotCheckBlocked(bot_movestate_t *ms, vec3_t dir, int checkbottom, bot_moveresult_t *result) +{ + vec3_t mins, maxs, end, up = {0, 0, 1}; + bsp_trace_t trace; + + //test for entities obstructing the bot's path + AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs); + // + if (fabs(DotProduct(dir, up)) < 0.7) + { + mins[2] += sv_maxstep->value; //if the bot can step on + maxs[2] -= 10; //a little lower to avoid low ceiling + } //end if + VectorMA(ms->origin, 3, dir, end); + trace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY); + //if not started in solid and not hitting the world entity + if (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) ) + { + result->blocked = qtrue; + result->blockentity = trace.ent; +#ifdef DEBUG + //botimport.Print(PRT_MESSAGE, "%d: BotCheckBlocked: I'm blocked\n", ms->client); +#endif //DEBUG + } //end if + //if not in an area with reachability + else if (checkbottom && !AAS_AreaReachability(ms->areanum)) + { + //check if the bot is standing on something + AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs); + VectorMA(ms->origin, -3, up, end); + trace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP); + if (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) ) + { + result->blocked = qtrue; + result->blockentity = trace.ent; + result->flags |= MOVERESULT_ONTOPOFOBSTACLE; +#ifdef DEBUG + //botimport.Print(PRT_MESSAGE, "%d: BotCheckBlocked: I'm blocked\n", ms->client); +#endif //DEBUG + } //end if + } //end else +} //end of the function BotCheckBlocked +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_Walk(bot_movestate_t *ms, aas_reachability_t *reach) +{ + float dist, speed; + vec3_t hordir; + bot_moveresult_t_cleared( result ); + + //first walk straight to the reachability start + hordir[0] = reach->start[0] - ms->origin[0]; + hordir[1] = reach->start[1] - ms->origin[1]; + hordir[2] = 0; + dist = VectorNormalize(hordir); + // + BotCheckBlocked(ms, hordir, qtrue, &result); + // + if (dist < 10) + { + //walk straight to the reachability end + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + dist = VectorNormalize(hordir); + } //end if + //if going towards a crouch area + if (!(AAS_AreaPresenceType(reach->areanum) & PRESENCE_NORMAL)) + { + //if pretty close to the reachable area + if (dist < 20) EA_Crouch(ms->client); + } //end if + // + dist = BotGapDistance(ms->origin, hordir, ms->entitynum); + // + if (ms->moveflags & MFL_WALK) + { + if (dist > 0) speed = 200 - (180 - 1 * dist); + else speed = 200; + EA_Walk(ms->client); + } //end if + else + { + if (dist > 0) speed = 400 - (360 - 2 * dist); + else speed = 400; + } //end else + //elemantary action move in direction + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotTravel_Walk +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotFinishTravel_Walk(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t hordir; + float dist, speed; + bot_moveresult_t_cleared( result ); + //if not on the ground and changed areas... don't walk back!! + //(doesn't seem to help) + /* + ms->areanum = BotFuzzyPointReachabilityArea(ms->origin); + if (ms->areanum == reach->areanum) + { +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "BotFinishTravel_Walk: already in reach area\n"); +#endif //DEBUG + return result; + } //end if*/ + //go straight to the reachability end + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + dist = VectorNormalize(hordir); + // + if (dist > 100) dist = 100; + speed = 400 - (400 - 3 * dist); + // + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotFinishTravel_Walk +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_Crouch(bot_movestate_t *ms, aas_reachability_t *reach) +{ + float speed; + vec3_t hordir; + bot_moveresult_t_cleared( result ); + + // + speed = 400; + //walk straight to reachability end + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + VectorNormalize(hordir); + // + BotCheckBlocked(ms, hordir, qtrue, &result); + //elemantary actions + EA_Crouch(ms->client); + EA_Move(ms->client, hordir, speed); + // + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotTravel_Crouch +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_BarrierJump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + float dist, speed; + vec3_t hordir; + bot_moveresult_t_cleared( result ); + + //walk straight to reachability start + hordir[0] = reach->start[0] - ms->origin[0]; + hordir[1] = reach->start[1] - ms->origin[1]; + hordir[2] = 0; + dist = VectorNormalize(hordir); + // + BotCheckBlocked(ms, hordir, qtrue, &result); + //if pretty close to the barrier + if (dist < 9) + { + EA_Jump(ms->client); + } //end if + else + { + if (dist > 60) dist = 60; + speed = 360 - (360 - 6 * dist); + EA_Move(ms->client, hordir, speed); + } //end else + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotTravel_BarrierJump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotFinishTravel_BarrierJump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + float dist; + vec3_t hordir; + bot_moveresult_t_cleared( result ); + + //if near the top or going down + if (ms->velocity[2] < 250) + { + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + dist = VectorNormalize(hordir); + // + BotCheckBlocked(ms, hordir, qtrue, &result); + // + EA_Move(ms->client, hordir, 400); + VectorCopy(hordir, result.movedir); + } //end if + // + return result; +} //end of the function BotFinishTravel_BarrierJump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_Swim(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t dir; + bot_moveresult_t_cleared( result ); + + //swim straight to reachability end + VectorSubtract(reach->start, ms->origin, dir); + VectorNormalize(dir); + // + BotCheckBlocked(ms, dir, qtrue, &result); + //elemantary actions + EA_Move(ms->client, dir, 400); + // + VectorCopy(dir, result.movedir); + Vector2Angles(dir, result.ideal_viewangles); + result.flags |= MOVERESULT_SWIMVIEW; + // + return result; +} //end of the function BotTravel_Swim +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_WaterJump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t dir, hordir; + float dist; + bot_moveresult_t_cleared( result ); + + //swim straight to reachability end + VectorSubtract(reach->end, ms->origin, dir); + VectorCopy(dir, hordir); + hordir[2] = 0; + dir[2] += 15 + crandom() * 40; + //botimport.Print(PRT_MESSAGE, "BotTravel_WaterJump: dir[2] = %f\n", dir[2]); + VectorNormalize(dir); + dist = VectorNormalize(hordir); + //elemantary actions + //EA_Move(ms->client, dir, 400); + EA_MoveForward(ms->client); + //move up if close to the actual out of water jump spot + if (dist < 40) EA_MoveUp(ms->client); + //set the ideal view angles + Vector2Angles(dir, result.ideal_viewangles); + result.flags |= MOVERESULT_MOVEMENTVIEW; + // + VectorCopy(dir, result.movedir); + // + return result; +} //end of the function BotTravel_WaterJump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotFinishTravel_WaterJump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t dir, pnt; + float dist; + bot_moveresult_t_cleared( result ); + + //botimport.Print(PRT_MESSAGE, "BotFinishTravel_WaterJump\n"); + //if waterjumping there's nothing to do + if (ms->moveflags & MFL_WATERJUMP) return result; + //if not touching any water anymore don't do anything + //otherwise the bot sometimes keeps jumping? + VectorCopy(ms->origin, pnt); + pnt[2] -= 32; //extra for q2dm4 near red armor/mega health + if (!(AAS_PointContents(pnt) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER))) return result; + //swim straight to reachability end + VectorSubtract(reach->end, ms->origin, dir); + dir[0] += crandom() * 10; + dir[1] += crandom() * 10; + dir[2] += 70 + crandom() * 10; + dist = VectorNormalize(dir); + //elemantary actions + EA_Move(ms->client, dir, 400); + //set the ideal view angles + Vector2Angles(dir, result.ideal_viewangles); + result.flags |= MOVERESULT_MOVEMENTVIEW; + // + VectorCopy(dir, result.movedir); + // + return result; +} //end of the function BotFinishTravel_WaterJump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_WalkOffLedge(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t hordir, dir; + float dist, speed, reachhordist; + bot_moveresult_t_cleared( result ); + + //check if the bot is blocked by anything + VectorSubtract(reach->start, ms->origin, dir); + VectorNormalize(dir); + BotCheckBlocked(ms, dir, qtrue, &result); + //if the reachability start and end are practially above each other + VectorSubtract(reach->end, reach->start, dir); + dir[2] = 0; + reachhordist = VectorLength(dir); + //walk straight to the reachability start + hordir[0] = reach->start[0] - ms->origin[0]; + hordir[1] = reach->start[1] - ms->origin[1]; + hordir[2] = 0; + dist = VectorNormalize(hordir); + //if pretty close to the start focus on the reachability end + if (dist < 48) + { + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + VectorNormalize(hordir); + // + if (reachhordist < 20) + { + speed = 100; + } //end if + else if (!AAS_HorizontalVelocityForJump(0, reach->start, reach->end, &speed)) + { + speed = 400; + } //end if + } //end if + else + { + if (reachhordist < 20) + { + if (dist > 64) dist = 64; + speed = 400 - (256 - 4 * dist); + } //end if + else + { + speed = 400; + } //end else + } //end else + // + BotCheckBlocked(ms, hordir, qtrue, &result); + //elemantary action + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotTravel_WalkOffLedge +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotAirControl(vec3_t origin, vec3_t velocity, vec3_t goal, vec3_t dir, float *speed) +{ + vec3_t org, vel; + float dist; + int i; + + VectorCopy(origin, org); + VectorScale(velocity, 0.1, vel); + for (i = 0; i < 50; i++) + { + vel[2] -= sv_gravity->value * 0.01; + //if going down and next position would be below the goal + if (vel[2] < 0 && org[2] + vel[2] < goal[2]) + { + VectorScale(vel, (goal[2] - org[2]) / vel[2], vel); + VectorAdd(org, vel, org); + VectorSubtract(goal, org, dir); + dist = VectorNormalize(dir); + if (dist > 32) dist = 32; + *speed = 400 - (400 - 13 * dist); + return qtrue; + } //end if + else + { + VectorAdd(org, vel, org); + } //end else + } //end for + VectorSet(dir, 0, 0, 0); + *speed = 400; + return qfalse; +} //end of the function BotAirControl +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotFinishTravel_WalkOffLedge(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t dir, hordir, end, v; + float dist, speed; + bot_moveresult_t_cleared( result ); + + // + VectorSubtract(reach->end, ms->origin, dir); + BotCheckBlocked(ms, dir, qtrue, &result); + // + VectorSubtract(reach->end, ms->origin, v); + v[2] = 0; + dist = VectorNormalize(v); + if (dist > 16) VectorMA(reach->end, 16, v, end); + else VectorCopy(reach->end, end); + // + if (!BotAirControl(ms->origin, ms->velocity, end, hordir, &speed)) + { + //go straight to the reachability end + VectorCopy(dir, hordir); + hordir[2] = 0; + // + dist = VectorNormalize(hordir); + speed = 400; + } //end if + // + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotFinishTravel_WalkOffLedge +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +/* +bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t hordir; + float dist, gapdist, speed, horspeed, sv_jumpvel; + bot_moveresult_t_cleared( result ); + + // + sv_jumpvel = botlibglobals.sv_jumpvel->value; + //walk straight to the reachability start + hordir[0] = reach->start[0] - ms->origin[0]; + hordir[1] = reach->start[1] - ms->origin[1]; + hordir[2] = 0; + dist = VectorNormalize(hordir); + // + speed = 350; + // + gapdist = BotGapDistance(ms, hordir, ms->entitynum); + //if pretty close to the start focus on the reachability end + if (dist < 50 || (gapdist && gapdist < 50)) + { + //NOTE: using max speed (400) works best + //if (AAS_HorizontalVelocityForJump(sv_jumpvel, ms->origin, reach->end, &horspeed)) + //{ + // speed = horspeed * 400 / botlibglobals.sv_maxwalkvelocity->value; + //} //end if + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + VectorNormalize(hordir); + //elemantary action jump + EA_Jump(ms->client); + // + ms->jumpreach = ms->lastreachnum; + speed = 600; + } //end if + else + { + if (AAS_HorizontalVelocityForJump(sv_jumpvel, reach->start, reach->end, &horspeed)) + { + speed = horspeed * 400 / botlibglobals.sv_maxwalkvelocity->value; + } //end if + } //end else + //elemantary action + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotTravel_Jump*/ +/* +bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t hordir, dir1, dir2, mins, maxs, start, end; + float dist1, dist2, speed; + bot_moveresult_t_cleared( result ); + bsp_trace_t trace; + + // + hordir[0] = reach->start[0] - reach->end[0]; + hordir[1] = reach->start[1] - reach->end[1]; + hordir[2] = 0; + VectorNormalize(hordir); + // + VectorCopy(reach->start, start); + start[2] += 1; + //minus back the bouding box size plus 16 + VectorMA(reach->start, 80, hordir, end); + // + AAS_PresenceTypeBoundingBox(PRESENCE_NORMAL, mins, maxs); + //check for solids + trace = AAS_Trace(start, mins, maxs, end, ms->entitynum, MASK_PLAYERSOLID); + if (trace.startsolid) VectorCopy(start, trace.endpos); + //check for a gap + for (dist1 = 0; dist1 < 80; dist1 += 10) + { + VectorMA(start, dist1+10, hordir, end); + end[2] += 1; + if (AAS_PointAreaNum(end) != ms->reachareanum) break; + } //end for + if (dist1 < 80) VectorMA(reach->start, dist1, hordir, trace.endpos); +// dist1 = BotGapDistance(start, hordir, ms->entitynum); +// if (dist1 && dist1 <= trace.fraction * 80) VectorMA(reach->start, dist1-20, hordir, trace.endpos); + // + VectorSubtract(ms->origin, reach->start, dir1); + dir1[2] = 0; + dist1 = VectorNormalize(dir1); + VectorSubtract(ms->origin, trace.endpos, dir2); + dir2[2] = 0; + dist2 = VectorNormalize(dir2); + //if just before the reachability start + if (DotProduct(dir1, dir2) < -0.8 || dist2 < 5) + { + //botimport.Print(PRT_MESSAGE, "between jump start and run to point\n"); + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + VectorNormalize(hordir); + //elemantary action jump + if (dist1 < 24) EA_Jump(ms->client); + else if (dist1 < 32) EA_DelayedJump(ms->client); + EA_Move(ms->client, hordir, 600); + // + ms->jumpreach = ms->lastreachnum; + } //end if + else + { + //botimport.Print(PRT_MESSAGE, "going towards run to point\n"); + hordir[0] = trace.endpos[0] - ms->origin[0]; + hordir[1] = trace.endpos[1] - ms->origin[1]; + hordir[2] = 0; + VectorNormalize(hordir); + // + if (dist2 > 80) dist2 = 80; + speed = 400 - (400 - 5 * dist2); + EA_Move(ms->client, hordir, speed); + } //end else + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotTravel_Jump*/ +//* +bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t hordir, dir1, dir2, start, end, runstart; +// vec3_t runstart, dir1, dir2, hordir; + float dist1, dist2, speed; + bot_moveresult_t_cleared( result ); + + // + AAS_JumpReachRunStart(reach, runstart); + //* + hordir[0] = runstart[0] - reach->start[0]; + hordir[1] = runstart[1] - reach->start[1]; + hordir[2] = 0; + VectorNormalize(hordir); + // + VectorCopy(reach->start, start); + start[2] += 1; + VectorMA(reach->start, 80, hordir, runstart); + //check for a gap + for (dist1 = 0; dist1 < 80; dist1 += 10) + { + VectorMA(start, dist1+10, hordir, end); + end[2] += 1; + if (AAS_PointAreaNum(end) != ms->reachareanum) break; + } //end for + if (dist1 < 80) VectorMA(reach->start, dist1, hordir, runstart); + // + VectorSubtract(ms->origin, reach->start, dir1); + dir1[2] = 0; + dist1 = VectorNormalize(dir1); + VectorSubtract(ms->origin, runstart, dir2); + dir2[2] = 0; + dist2 = VectorNormalize(dir2); + //if just before the reachability start + if (DotProduct(dir1, dir2) < -0.8 || dist2 < 5) + { +// botimport.Print(PRT_MESSAGE, "between jump start and run start point\n"); + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + VectorNormalize(hordir); + //elemantary action jump + if (dist1 < 24) EA_Jump(ms->client); + else if (dist1 < 32) EA_DelayedJump(ms->client); + EA_Move(ms->client, hordir, 600); + // + ms->jumpreach = ms->lastreachnum; + } //end if + else + { +// botimport.Print(PRT_MESSAGE, "going towards run start point\n"); + hordir[0] = runstart[0] - ms->origin[0]; + hordir[1] = runstart[1] - ms->origin[1]; + hordir[2] = 0; + VectorNormalize(hordir); + // + if (dist2 > 80) dist2 = 80; + speed = 400 - (400 - 5 * dist2); + EA_Move(ms->client, hordir, speed); + } //end else + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotTravel_Jump*/ +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotFinishTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t hordir, hordir2; + float speed, dist; + bot_moveresult_t_cleared( result ); + + //if not jumped yet + if (!ms->jumpreach) return result; + //go straight to the reachability end + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + dist = VectorNormalize(hordir); + // + hordir2[0] = reach->end[0] - reach->start[0]; + hordir2[1] = reach->end[1] - reach->start[1]; + hordir2[2] = 0; + VectorNormalize(hordir2); + // + if (DotProduct(hordir, hordir2) < -0.5 && dist < 24) return result; + //always use max speed when traveling through the air + speed = 800; + // + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotFinishTravel_Jump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_Ladder(bot_movestate_t *ms, aas_reachability_t *reach) +{ + //float dist, speed; + vec3_t dir, viewdir;//, hordir; + vec3_t origin = {0, 0, 0}; +// vec3_t up = {0, 0, 1}; + bot_moveresult_t_cleared( result ); + + // +// if ((ms->moveflags & MFL_AGAINSTLADDER)) + //NOTE: not a good idea for ladders starting in water + // || !(ms->moveflags & MFL_ONGROUND)) + { + //botimport.Print(PRT_MESSAGE, "against ladder or not on ground\n"); + VectorSubtract(reach->end, ms->origin, dir); + VectorNormalize(dir); + //set the ideal view angles, facing the ladder up or down + viewdir[0] = dir[0]; + viewdir[1] = dir[1]; + viewdir[2] = 3 * dir[2]; + Vector2Angles(viewdir, result.ideal_viewangles); + //elemantary action + EA_Move(ms->client, origin, 0); + EA_MoveForward(ms->client); + //set movement view flag so the AI can see the view is focussed + result.flags |= MOVERESULT_MOVEMENTVIEW; + } //end if +/* else + { + //botimport.Print(PRT_MESSAGE, "moving towards ladder\n"); + VectorSubtract(reach->end, ms->origin, dir); + //make sure the horizontal movement is large anough + VectorCopy(dir, hordir); + hordir[2] = 0; + dist = VectorNormalize(hordir); + // + dir[0] = hordir[0]; + dir[1] = hordir[1]; + if (dir[2] > 0) dir[2] = 1; + else dir[2] = -1; + if (dist > 50) dist = 50; + speed = 400 - (200 - 4 * dist); + EA_Move(ms->client, dir, speed); + } //end else*/ + //save the movement direction + VectorCopy(dir, result.movedir); + // + return result; +} //end of the function BotTravel_Ladder +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_Teleport(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t hordir; + float dist; + bot_moveresult_t_cleared( result ); + + //if the bot is being teleported + if (ms->moveflags & MFL_TELEPORTED) return result; + + //walk straight to center of the teleporter + VectorSubtract(reach->start, ms->origin, hordir); + if (!(ms->moveflags & MFL_SWIMMING)) hordir[2] = 0; + dist = VectorNormalize(hordir); + // + BotCheckBlocked(ms, hordir, qtrue, &result); + + if (dist < 30) EA_Move(ms->client, hordir, 200); + else EA_Move(ms->client, hordir, 400); + + if (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW; + + VectorCopy(hordir, result.movedir); + return result; +} //end of the function BotTravel_Teleport +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t dir, dir1, dir2, hordir, bottomcenter; + float dist, dist1, dist2, speed; + bot_moveresult_t_cleared( result ); + + //if standing on the plat + if (BotOnMover(ms->origin, ms->entitynum, reach)) + { +#ifdef DEBUG_ELEVATOR + botimport.Print(PRT_MESSAGE, "bot on elevator\n"); +#endif //DEBUG_ELEVATOR + //if vertically not too far from the end point + if (abs(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value) + { +#ifdef DEBUG_ELEVATOR + botimport.Print(PRT_MESSAGE, "bot moving to end\n"); +#endif //DEBUG_ELEVATOR + //move to the end point + VectorSubtract(reach->end, ms->origin, hordir); + hordir[2] = 0; + VectorNormalize(hordir); + if (!BotCheckBarrierJump(ms, hordir, 100)) + { + EA_Move(ms->client, hordir, 400); + } //end if + VectorCopy(hordir, result.movedir); + } //end else + //if not really close to the center of the elevator + else + { + MoverBottomCenter(reach, bottomcenter); + VectorSubtract(bottomcenter, ms->origin, hordir); + hordir[2] = 0; + dist = VectorNormalize(hordir); + // + if (dist > 10) + { +#ifdef DEBUG_ELEVATOR + botimport.Print(PRT_MESSAGE, "bot moving to center\n"); +#endif //DEBUG_ELEVATOR + //move to the center of the plat + if (dist > 100) dist = 100; + speed = 400 - (400 - 4 * dist); + // + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + } //end if + } //end else + } //end if + else + { +#ifdef DEBUG_ELEVATOR + botimport.Print(PRT_MESSAGE, "bot not on elevator\n"); +#endif //DEBUG_ELEVATOR + //if very near the reachability end + VectorSubtract(reach->end, ms->origin, dir); + dist = VectorLength(dir); + if (dist < 64) + { + if (dist > 60) dist = 60; + speed = 360 - (360 - 6 * dist); + // + if ((ms->moveflags & MFL_SWIMMING) || !BotCheckBarrierJump(ms, dir, 50)) + { + if (speed > 5) EA_Move(ms->client, dir, speed); + } //end if + VectorCopy(dir, result.movedir); + // + if (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW; + //stop using this reachability + ms->reachability_time = 0; + return result; + } //end if + //get direction and distance to reachability start + VectorSubtract(reach->start, ms->origin, dir1); + if (!(ms->moveflags & MFL_SWIMMING)) dir1[2] = 0; + dist1 = VectorNormalize(dir1); + //if the elevator isn't down + if (!MoverDown(reach)) + { +#ifdef DEBUG_ELEVATOR + botimport.Print(PRT_MESSAGE, "elevator not down\n"); +#endif //DEBUG_ELEVATOR + dist = dist1; + VectorCopy(dir1, dir); + // + BotCheckBlocked(ms, dir, qfalse, &result); + // + if (dist > 60) dist = 60; + speed = 360 - (360 - 6 * dist); + // + if (!(ms->moveflags & MFL_SWIMMING) && !BotCheckBarrierJump(ms, dir, 50)) + { + if (speed > 5) EA_Move(ms->client, dir, speed); + } //end if + VectorCopy(dir, result.movedir); + // + if (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW; + //this isn't a failure... just wait till the elevator comes down + result.type = RESULTTYPE_ELEVATORUP; + result.flags |= MOVERESULT_WAITING; + return result; + } //end if + //get direction and distance to elevator bottom center + MoverBottomCenter(reach, bottomcenter); + VectorSubtract(bottomcenter, ms->origin, dir2); + if (!(ms->moveflags & MFL_SWIMMING)) dir2[2] = 0; + dist2 = VectorNormalize(dir2); + //if very close to the reachability start or + //closer to the elevator center or + //between reachability start and elevator center + if (dist1 < 20 || dist2 < dist1 || DotProduct(dir1, dir2) < 0) + { +#ifdef DEBUG_ELEVATOR + botimport.Print(PRT_MESSAGE, "bot moving to center\n"); +#endif //DEBUG_ELEVATOR + dist = dist2; + VectorCopy(dir2, dir); + } //end if + else //closer to the reachability start + { +#ifdef DEBUG_ELEVATOR + botimport.Print(PRT_MESSAGE, "bot moving to start\n"); +#endif //DEBUG_ELEVATOR + dist = dist1; + VectorCopy(dir1, dir); + } //end else + // + BotCheckBlocked(ms, dir, qfalse, &result); + // + if (dist > 60) dist = 60; + speed = 400 - (400 - 6 * dist); + // + if (!(ms->moveflags & MFL_SWIMMING) && !BotCheckBarrierJump(ms, dir, 50)) + { + EA_Move(ms->client, dir, speed); + } //end if + VectorCopy(dir, result.movedir); + // + if (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW; + } //end else + return result; +} //end of the function BotTravel_Elevator +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotFinishTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t bottomcenter, bottomdir, topdir; + bot_moveresult_t_cleared( result ); + + // + MoverBottomCenter(reach, bottomcenter); + VectorSubtract(bottomcenter, ms->origin, bottomdir); + // + VectorSubtract(reach->end, ms->origin, topdir); + // + if (fabs(bottomdir[2]) < fabs(topdir[2])) + { + VectorNormalize(bottomdir); + EA_Move(ms->client, bottomdir, 300); + } //end if + else + { + VectorNormalize(topdir); + EA_Move(ms->client, topdir, 300); + } //end else + return result; +} //end of the function BotFinishTravel_Elevator +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotFuncBobStartEnd(aas_reachability_t *reach, vec3_t start, vec3_t end, vec3_t origin) +{ + int spawnflags, modelnum; + vec3_t mins, maxs, mid, angles = {0, 0, 0}; + int num0, num1; + + modelnum = reach->facenum & 0x0000FFFF; + if (!AAS_OriginOfMoverWithModelNum(modelnum, origin)) + { + botimport.Print(PRT_MESSAGE, "BotFuncBobStartEnd: no entity with model %d\n", modelnum); + VectorSet(start, 0, 0, 0); + VectorSet(end, 0, 0, 0); + return; + } //end if + AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL); + VectorAdd(mins, maxs, mid); + VectorScale(mid, 0.5, mid); + VectorCopy(mid, start); + VectorCopy(mid, end); + spawnflags = reach->facenum >> 16; + num0 = reach->edgenum >> 16; + if (num0 > 0x00007FFF) num0 |= 0xFFFF0000; + num1 = reach->edgenum & 0x0000FFFF; + if (num1 > 0x00007FFF) num1 |= 0xFFFF0000; + if (spawnflags & 1) + { + start[0] = num0; + end[0] = num1; + // + origin[0] += mid[0]; + origin[1] = mid[1]; + origin[2] = mid[2]; + } //end if + else if (spawnflags & 2) + { + start[1] = num0; + end[1] = num1; + // + origin[0] = mid[0]; + origin[1] += mid[1]; + origin[2] = mid[2]; + } //end else if + else + { + start[2] = num0; + end[2] = num1; + // + origin[0] = mid[0]; + origin[1] = mid[1]; + origin[2] += mid[2]; + } //end else +} //end of the function BotFuncBobStartEnd +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t dir, dir1, dir2, hordir, bottomcenter, bob_start, bob_end, bob_origin; + float dist, dist1, dist2, speed; + bot_moveresult_t_cleared( result ); + + // + BotFuncBobStartEnd(reach, bob_start, bob_end, bob_origin); + //if standing ontop of the func_bobbing + if (BotOnMover(ms->origin, ms->entitynum, reach)) + { +#ifdef DEBUG_FUNCBOB + botimport.Print(PRT_MESSAGE, "bot on func_bobbing\n"); +#endif + //if near end point of reachability + VectorSubtract(bob_origin, bob_end, dir); + if (VectorLength(dir) < 24) + { +#ifdef DEBUG_FUNCBOB + botimport.Print(PRT_MESSAGE, "bot moving to reachability end\n"); +#endif + //move to the end point + VectorSubtract(reach->end, ms->origin, hordir); + hordir[2] = 0; + VectorNormalize(hordir); + if (!BotCheckBarrierJump(ms, hordir, 100)) + { + EA_Move(ms->client, hordir, 400); + } //end if + VectorCopy(hordir, result.movedir); + } //end else + //if not really close to the center of the elevator + else + { + MoverBottomCenter(reach, bottomcenter); + VectorSubtract(bottomcenter, ms->origin, hordir); + hordir[2] = 0; + dist = VectorNormalize(hordir); + // + if (dist > 10) + { +#ifdef DEBUG_FUNCBOB + botimport.Print(PRT_MESSAGE, "bot moving to func_bobbing center\n"); +#endif + //move to the center of the plat + if (dist > 100) dist = 100; + speed = 400 - (400 - 4 * dist); + // + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + } //end if + } //end else + } //end if + else + { +#ifdef DEBUG_FUNCBOB + botimport.Print(PRT_MESSAGE, "bot not ontop of func_bobbing\n"); +#endif + //if very near the reachability end + VectorSubtract(reach->end, ms->origin, dir); + dist = VectorLength(dir); + if (dist < 64) + { +#ifdef DEBUG_FUNCBOB + botimport.Print(PRT_MESSAGE, "bot moving to end\n"); +#endif + if (dist > 60) dist = 60; + speed = 360 - (360 - 6 * dist); + //if swimming or no barrier jump + if ((ms->moveflags & MFL_SWIMMING) || !BotCheckBarrierJump(ms, dir, 50)) + { + if (speed > 5) EA_Move(ms->client, dir, speed); + } //end if + VectorCopy(dir, result.movedir); + // + if (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW; + //stop using this reachability + ms->reachability_time = 0; + return result; + } //end if + //get direction and distance to reachability start + VectorSubtract(reach->start, ms->origin, dir1); + if (!(ms->moveflags & MFL_SWIMMING)) dir1[2] = 0; + dist1 = VectorNormalize(dir1); + //if func_bobbing is Not it's start position + VectorSubtract(bob_origin, bob_start, dir); + if (VectorLength(dir) > 16) + { +#ifdef DEBUG_FUNCBOB + botimport.Print(PRT_MESSAGE, "func_bobbing not at start\n"); +#endif + dist = dist1; + VectorCopy(dir1, dir); + // + BotCheckBlocked(ms, dir, qfalse, &result); + // + if (dist > 60) dist = 60; + speed = 360 - (360 - 6 * dist); + // + if (!(ms->moveflags & MFL_SWIMMING) && !BotCheckBarrierJump(ms, dir, 50)) + { + if (speed > 5) EA_Move(ms->client, dir, speed); + } //end if + VectorCopy(dir, result.movedir); + // + if (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW; + //this isn't a failure... just wait till the func_bobbing arrives + result.type = RESULTTYPE_WAITFORFUNCBOBBING; + result.flags |= MOVERESULT_WAITING; + return result; + } //end if + //get direction and distance to func_bob bottom center + MoverBottomCenter(reach, bottomcenter); + VectorSubtract(bottomcenter, ms->origin, dir2); + if (!(ms->moveflags & MFL_SWIMMING)) dir2[2] = 0; + dist2 = VectorNormalize(dir2); + //if very close to the reachability start or + //closer to the elevator center or + //between reachability start and func_bobbing center + if (dist1 < 20 || dist2 < dist1 || DotProduct(dir1, dir2) < 0) + { +#ifdef DEBUG_FUNCBOB + botimport.Print(PRT_MESSAGE, "bot moving to func_bobbing center\n"); +#endif + dist = dist2; + VectorCopy(dir2, dir); + } //end if + else //closer to the reachability start + { +#ifdef DEBUG_FUNCBOB + botimport.Print(PRT_MESSAGE, "bot moving to reachability start\n"); +#endif + dist = dist1; + VectorCopy(dir1, dir); + } //end else + // + BotCheckBlocked(ms, dir, qfalse, &result); + // + if (dist > 60) dist = 60; + speed = 400 - (400 - 6 * dist); + // + if (!(ms->moveflags & MFL_SWIMMING) && !BotCheckBarrierJump(ms, dir, 50)) + { + EA_Move(ms->client, dir, speed); + } //end if + VectorCopy(dir, result.movedir); + // + if (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW; + } //end else + return result; +} //end of the function BotTravel_FuncBobbing +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotFinishTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t bob_origin, bob_start, bob_end, dir, hordir, bottomcenter; + bot_moveresult_t_cleared( result ); + float dist, speed; + + // + BotFuncBobStartEnd(reach, bob_start, bob_end, bob_origin); + // + VectorSubtract(bob_origin, bob_end, dir); + dist = VectorLength(dir); + //if the func_bobbing is near the end + if (dist < 16) + { + VectorSubtract(reach->end, ms->origin, hordir); + if (!(ms->moveflags & MFL_SWIMMING)) hordir[2] = 0; + dist = VectorNormalize(hordir); + // + if (dist > 60) dist = 60; + speed = 360 - (360 - 6 * dist); + // + if (speed > 5) EA_Move(ms->client, dir, speed); + VectorCopy(dir, result.movedir); + // + if (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW; + } //end if + else + { + MoverBottomCenter(reach, bottomcenter); + VectorSubtract(bottomcenter, ms->origin, hordir); + if (!(ms->moveflags & MFL_SWIMMING)) hordir[2] = 0; + dist = VectorNormalize(hordir); + // + if (dist > 5) + { + //move to the center of the plat + if (dist > 100) dist = 100; + speed = 400 - (400 - 4 * dist); + // + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + } //end if + } //end else + return result; +} //end of the function BotFinishTravel_FuncBobbing +//=========================================================================== +// 0 no valid grapple hook visible +// 1 the grapple hook is still flying +// 2 the grapple hooked into a wall +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int GrappleState(bot_movestate_t *ms, aas_reachability_t *reach) +{ + int i; + aas_entityinfo_t entinfo; + + //if the grapple hook is pulling + if (ms->moveflags & MFL_GRAPPLEPULL) + return 2; + //check for a visible grapple missile entity + //or visible grapple entity + for (i = AAS_NextEntity(0); i; i = AAS_NextEntity(i)) + { + if (AAS_EntityType(i) == (int) entitytypemissile->value) + { + AAS_EntityInfo(i, &entinfo); + if (entinfo.weapon == (int) weapindex_grapple->value) + { + return 1; + } //end if + } //end if + } //end for + //no valid grapple at all + return 0; +} //end of the function GrappleState +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotResetGrapple(bot_movestate_t *ms) +{ + aas_reachability_t reach; + + AAS_ReachabilityFromNum(ms->lastreachnum, &reach); + //if not using the grapple hook reachability anymore + if ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_GRAPPLEHOOK) + { + if ((ms->moveflags & MFL_ACTIVEGRAPPLE) || ms->grapplevisible_time) + { + if (offhandgrapple->value) + EA_Command(ms->client, cmd_grappleoff->string); + ms->moveflags &= ~MFL_ACTIVEGRAPPLE; + ms->grapplevisible_time = 0; +#ifdef DEBUG_GRAPPLE + botimport.Print(PRT_MESSAGE, "reset grapple\n"); +#endif //DEBUG_GRAPPLE + } //end if + } //end if +} //end of the function BotResetGrapple +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reach) +{ + bot_moveresult_t_cleared( result ); + float dist, speed; + vec3_t dir, viewdir, org; + int state, areanum; + bsp_trace_t trace; + +#ifdef DEBUG_GRAPPLE + static int debugline; + if (!debugline) debugline = botimport.DebugLineCreate(); + botimport.DebugLineShow(debugline, reach->start, reach->end, LINECOLOR_BLUE); +#endif //DEBUG_GRAPPLE + + // + if (ms->moveflags & MFL_GRAPPLERESET) + { + if (offhandgrapple->value) + EA_Command(ms->client, cmd_grappleoff->string); + ms->moveflags &= ~MFL_ACTIVEGRAPPLE; + return result; + } //end if + // + if (!(int) offhandgrapple->value) + { + result.weapon = weapindex_grapple->value; + result.flags |= MOVERESULT_MOVEMENTWEAPON; + } //end if + // + if (ms->moveflags & MFL_ACTIVEGRAPPLE) + { +#ifdef DEBUG_GRAPPLE + botimport.Print(PRT_MESSAGE, "BotTravel_Grapple: active grapple\n"); +#endif //DEBUG_GRAPPLE + // + state = GrappleState(ms, reach); + // + VectorSubtract(reach->end, ms->origin, dir); + dir[2] = 0; + dist = VectorLength(dir); + //if very close to the grapple end or the grappled is hooked and + //the bot doesn't get any closer + if (state && dist < 48) + { + if (ms->lastgrappledist - dist < 1) + { +#ifdef DEBUG_GRAPPLE + botimport.Print(PRT_ERROR, "grapple normal end\n"); +#endif //DEBUG_GRAPPLE + if (offhandgrapple->value) + EA_Command(ms->client, cmd_grappleoff->string); + ms->moveflags &= ~MFL_ACTIVEGRAPPLE; + ms->moveflags |= MFL_GRAPPLERESET; + ms->reachability_time = 0; //end the reachability + return result; + } //end if + } //end if + //if no valid grapple at all, or the grapple hooked and the bot + //isn't moving anymore + else if (!state || (state == 2 && dist > ms->lastgrappledist - 2)) + { + if (ms->grapplevisible_time < AAS_Time() - 0.4) + { +#ifdef DEBUG_GRAPPLE + botimport.Print(PRT_ERROR, "grapple not visible\n"); +#endif //DEBUG_GRAPPLE + if (offhandgrapple->value) + EA_Command(ms->client, cmd_grappleoff->string); + ms->moveflags &= ~MFL_ACTIVEGRAPPLE; + ms->moveflags |= MFL_GRAPPLERESET; + ms->reachability_time = 0; //end the reachability + return result; + } //end if + } //end if + else + { + ms->grapplevisible_time = AAS_Time(); + } //end else + // + if (!(int) offhandgrapple->value) + { + EA_Attack(ms->client); + } //end if + //remember the current grapple distance + ms->lastgrappledist = dist; + } //end if + else + { +#ifdef DEBUG_GRAPPLE + botimport.Print(PRT_MESSAGE, "BotTravel_Grapple: inactive grapple\n"); +#endif //DEBUG_GRAPPLE + // + ms->grapplevisible_time = AAS_Time(); + // + VectorSubtract(reach->start, ms->origin, dir); + if (!(ms->moveflags & MFL_SWIMMING)) dir[2] = 0; + VectorAdd(ms->origin, ms->viewoffset, org); + VectorSubtract(reach->end, org, viewdir); + // + dist = VectorNormalize(dir); + Vector2Angles(viewdir, result.ideal_viewangles); + result.flags |= MOVERESULT_MOVEMENTVIEW; + // + if (dist < 5 && + fabs(AngleDiff(result.ideal_viewangles[0], ms->viewangles[0])) < 2 && + fabs(AngleDiff(result.ideal_viewangles[1], ms->viewangles[1])) < 2) + { +#ifdef DEBUG_GRAPPLE + botimport.Print(PRT_MESSAGE, "BotTravel_Grapple: activating grapple\n"); +#endif //DEBUG_GRAPPLE + //check if the grapple missile path is clear + VectorAdd(ms->origin, ms->viewoffset, org); + trace = AAS_Trace(org, NULL, NULL, reach->end, ms->entitynum, CONTENTS_SOLID); + VectorSubtract(reach->end, trace.endpos, dir); + if (VectorLength(dir) > 16) + { + result.failure = qtrue; + return result; + } //end if + //activate the grapple + if (offhandgrapple->value) + { + EA_Command(ms->client, cmd_grappleon->string); + } //end if + else + { + EA_Attack(ms->client); + } //end else + ms->moveflags |= MFL_ACTIVEGRAPPLE; + ms->lastgrappledist = 999999; + } //end if + else + { + if (dist < 70) speed = 300 - (300 - 4 * dist); + else speed = 400; + // + BotCheckBlocked(ms, dir, qtrue, &result); + //elemantary action move in direction + EA_Move(ms->client, dir, speed); + VectorCopy(dir, result.movedir); + } //end else + //if in another area before actually grappling + areanum = AAS_PointAreaNum(ms->origin); + if (areanum && areanum != ms->reachareanum) ms->reachability_time = 0; + } //end else + return result; +} //end of the function BotTravel_Grapple +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_RocketJump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t hordir; + float dist, speed; + bot_moveresult_t_cleared( result ); + + //botimport.Print(PRT_MESSAGE, "BotTravel_RocketJump: bah\n"); + // + hordir[0] = reach->start[0] - ms->origin[0]; + hordir[1] = reach->start[1] - ms->origin[1]; + hordir[2] = 0; + // + dist = VectorNormalize(hordir); + //look in the movement direction + Vector2Angles(hordir, result.ideal_viewangles); + //look straight down + result.ideal_viewangles[PITCH] = 90; + // + if (dist < 5 && + fabs(AngleDiff(result.ideal_viewangles[0], ms->viewangles[0])) < 5 && + fabs(AngleDiff(result.ideal_viewangles[1], ms->viewangles[1])) < 5) + { + //botimport.Print(PRT_MESSAGE, "between jump start and run start point\n"); + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + VectorNormalize(hordir); + //elemantary action jump + EA_Jump(ms->client); + EA_Attack(ms->client); + EA_Move(ms->client, hordir, 800); + // + ms->jumpreach = ms->lastreachnum; + } //end if + else + { + if (dist > 80) dist = 80; + speed = 400 - (400 - 5 * dist); + EA_Move(ms->client, hordir, speed); + } //end else + //look in the movement direction + Vector2Angles(hordir, result.ideal_viewangles); + //look straight down + result.ideal_viewangles[PITCH] = 90; + //set the view angles directly + EA_View(ms->client, result.ideal_viewangles); + //view is important for the movment + result.flags |= MOVERESULT_MOVEMENTVIEWSET; + //select the rocket launcher + EA_SelectWeapon(ms->client, (int) weapindex_rocketlauncher->value); + //weapon is used for movement + result.weapon = (int) weapindex_rocketlauncher->value; + result.flags |= MOVERESULT_MOVEMENTWEAPON; + // + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotTravel_RocketJump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_BFGJump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t hordir; + float dist, speed; + bot_moveresult_t_cleared( result ); + + //botimport.Print(PRT_MESSAGE, "BotTravel_BFGJump: bah\n"); + // + hordir[0] = reach->start[0] - ms->origin[0]; + hordir[1] = reach->start[1] - ms->origin[1]; + hordir[2] = 0; + // + dist = VectorNormalize(hordir); + // + if (dist < 5 && + fabs(AngleDiff(result.ideal_viewangles[0], ms->viewangles[0])) < 5 && + fabs(AngleDiff(result.ideal_viewangles[1], ms->viewangles[1])) < 5) + { + //botimport.Print(PRT_MESSAGE, "between jump start and run start point\n"); + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + VectorNormalize(hordir); + //elemantary action jump + EA_Jump(ms->client); + EA_Attack(ms->client); + EA_Move(ms->client, hordir, 800); + // + ms->jumpreach = ms->lastreachnum; + } //end if + else + { + if (dist > 80) dist = 80; + speed = 400 - (400 - 5 * dist); + EA_Move(ms->client, hordir, speed); + } //end else + //look in the movement direction + Vector2Angles(hordir, result.ideal_viewangles); + //look straight down + result.ideal_viewangles[PITCH] = 90; + //set the view angles directly + EA_View(ms->client, result.ideal_viewangles); + //view is important for the movment + result.flags |= MOVERESULT_MOVEMENTVIEWSET; + //select the rocket launcher + EA_SelectWeapon(ms->client, (int) weapindex_bfg10k->value); + //weapon is used for movement + result.weapon = (int) weapindex_bfg10k->value; + result.flags |= MOVERESULT_MOVEMENTWEAPON; + // + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotTravel_BFGJump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotFinishTravel_WeaponJump(bot_movestate_t *ms, aas_reachability_t *reach) +{ + vec3_t hordir; + float speed; + bot_moveresult_t_cleared( result ); + + //if not jumped yet + if (!ms->jumpreach) return result; + /* + //go straight to the reachability end + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + VectorNormalize(hordir); + //always use max speed when traveling through the air + EA_Move(ms->client, hordir, 800); + VectorCopy(hordir, result.movedir); + */ + // + if (!BotAirControl(ms->origin, ms->velocity, reach->end, hordir, &speed)) + { + //go straight to the reachability end + VectorSubtract(reach->end, ms->origin, hordir); + hordir[2] = 0; + VectorNormalize(hordir); + speed = 400; + } //end if + // + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotFinishTravel_WeaponJump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotTravel_JumpPad(bot_movestate_t *ms, aas_reachability_t *reach) +{ + float dist, speed; + vec3_t hordir; + bot_moveresult_t_cleared( result ); + + //first walk straight to the reachability start + hordir[0] = reach->start[0] - ms->origin[0]; + hordir[1] = reach->start[1] - ms->origin[1]; + hordir[2] = 0; + dist = VectorNormalize(hordir); + // + BotCheckBlocked(ms, hordir, qtrue, &result); + speed = 400; + //elemantary action move in direction + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotTravel_JumpPad +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotFinishTravel_JumpPad(bot_movestate_t *ms, aas_reachability_t *reach) +{ + float speed; + vec3_t hordir; + bot_moveresult_t_cleared( result ); + + if (!BotAirControl(ms->origin, ms->velocity, reach->end, hordir, &speed)) + { + hordir[0] = reach->end[0] - ms->origin[0]; + hordir[1] = reach->end[1] - ms->origin[1]; + hordir[2] = 0; + VectorNormalize(hordir); + speed = 400; + } //end if + BotCheckBlocked(ms, hordir, qtrue, &result); + //elemantary action move in direction + EA_Move(ms->client, hordir, speed); + VectorCopy(hordir, result.movedir); + // + return result; +} //end of the function BotFinishTravel_JumpPad +//=========================================================================== +// time before the reachability times out +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotReachabilityTime(aas_reachability_t *reach) +{ + switch(reach->traveltype & TRAVELTYPE_MASK) + { + case TRAVEL_WALK: return 5; + case TRAVEL_CROUCH: return 5; + case TRAVEL_BARRIERJUMP: return 5; + case TRAVEL_LADDER: return 6; + case TRAVEL_WALKOFFLEDGE: return 5; + case TRAVEL_JUMP: return 5; + case TRAVEL_SWIM: return 5; + case TRAVEL_WATERJUMP: return 5; + case TRAVEL_TELEPORT: return 5; + case TRAVEL_ELEVATOR: return 10; + case TRAVEL_GRAPPLEHOOK: return 8; + case TRAVEL_ROCKETJUMP: return 6; + case TRAVEL_BFGJUMP: return 6; + case TRAVEL_JUMPPAD: return 10; + case TRAVEL_FUNCBOB: return 10; + default: + { + botimport.Print(PRT_ERROR, "travel type %d not implemented yet\n", reach->traveltype); + return 8; + } //end case + } //end switch +} //end of the function BotReachabilityTime +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bot_moveresult_t BotMoveInGoalArea(bot_movestate_t *ms, bot_goal_t *goal) +{ + bot_moveresult_t_cleared( result ); + vec3_t dir; + float dist, speed; + +#ifdef DEBUG + //botimport.Print(PRT_MESSAGE, "%s: moving straight to goal\n", ClientName(ms->entitynum-1)); + //AAS_ClearShownDebugLines(); + //AAS_DebugLine(ms->origin, goal->origin, LINECOLOR_RED); +#endif //DEBUG + //walk straight to the goal origin + dir[0] = goal->origin[0] - ms->origin[0]; + dir[1] = goal->origin[1] - ms->origin[1]; + if (ms->moveflags & MFL_SWIMMING) + { + dir[2] = goal->origin[2] - ms->origin[2]; + result.traveltype = TRAVEL_SWIM; + } //end if + else + { + dir[2] = 0; + result.traveltype = TRAVEL_WALK; + } //endif + // + dist = VectorNormalize(dir); + if (dist > 100) dist = 100; + speed = 400 - (400 - 4 * dist); + if (speed < 10) speed = 0; + // + BotCheckBlocked(ms, dir, qtrue, &result); + //elemantary action move in direction + EA_Move(ms->client, dir, speed); + VectorCopy(dir, result.movedir); + // + if (ms->moveflags & MFL_SWIMMING) + { + Vector2Angles(dir, result.ideal_viewangles); + result.flags |= MOVERESULT_SWIMVIEW; + } //end if + //if (!debugline) debugline = botimport.DebugLineCreate(); + //botimport.DebugLineShow(debugline, ms->origin, goal->origin, LINECOLOR_BLUE); + // + ms->lastreachnum = 0; + ms->lastareanum = 0; + ms->lastgoalareanum = goal->areanum; + VectorCopy(ms->origin, ms->lastorigin); + // + return result; +} //end of the function BotMoveInGoalArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags) +{ + int reachnum, lastreachnum, foundjumppad, ent, resultflags; + aas_reachability_t reach, lastreach; + bot_movestate_t *ms; + //vec3_t mins, maxs, up = {0, 0, 1}; + //bsp_trace_t trace; + //static int debugline; + + result->failure = qfalse; + result->type = 0; + result->blocked = qfalse; + result->blockentity = 0; + result->traveltype = 0; + result->flags = 0; + + // + ms = BotMoveStateFromHandle(movestate); + if (!ms) return; + //reset the grapple before testing if the bot has a valid goal + //because the bot could loose all it's goals when stuck to a wall + BotResetGrapple(ms); + // + if (!goal) + { +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "client %d: movetogoal -> no goal\n", ms->client); +#endif //DEBUG + result->failure = qtrue; + return; + } //end if + //botimport.Print(PRT_MESSAGE, "numavoidreach = %d\n", ms->numavoidreach); + //remove some of the move flags + ms->moveflags &= ~(MFL_SWIMMING|MFL_AGAINSTLADDER); + //set some of the move flags + //NOTE: the MFL_ONGROUND flag is also set in the higher AI + if (AAS_OnGround(ms->origin, ms->presencetype, ms->entitynum)) ms->moveflags |= MFL_ONGROUND; + // + if (ms->moveflags & MFL_ONGROUND) + { + int modeltype, modelnum; + + ent = BotOnTopOfEntity(ms); + + if (ent != -1) + { + modelnum = AAS_EntityModelindex(ent); + if (modelnum >= 0 && modelnum < MAX_MODELS) + { + modeltype = modeltypes[modelnum]; + + if (modeltype == MODELTYPE_FUNC_PLAT) + { + AAS_ReachabilityFromNum(ms->lastreachnum, &reach); + //if the bot is Not using the elevator + if ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_ELEVATOR || + //NOTE: the face number is the plat model number + (reach.facenum & 0x0000FFFF) != modelnum) + { + reachnum = AAS_NextModelReachability(0, modelnum); + if (reachnum) + { + //botimport.Print(PRT_MESSAGE, "client %d: accidentally ended up on func_plat\n", ms->client); + AAS_ReachabilityFromNum(reachnum, &reach); + ms->lastreachnum = reachnum; + ms->reachability_time = AAS_Time() + BotReachabilityTime(&reach); + } //end if + else + { + if (bot_developer) + { + botimport.Print(PRT_MESSAGE, "client %d: on func_plat without reachability\n", ms->client); + } //end if + result->blocked = qtrue; + result->blockentity = ent; + result->flags |= MOVERESULT_ONTOPOFOBSTACLE; + return; + } //end else + } //end if + result->flags |= MOVERESULT_ONTOPOF_ELEVATOR; + } //end if + else if (modeltype == MODELTYPE_FUNC_BOB) + { + AAS_ReachabilityFromNum(ms->lastreachnum, &reach); + //if the bot is Not using the func bobbing + if ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_FUNCBOB || + //NOTE: the face number is the func_bobbing model number + (reach.facenum & 0x0000FFFF) != modelnum) + { + reachnum = AAS_NextModelReachability(0, modelnum); + if (reachnum) + { + //botimport.Print(PRT_MESSAGE, "client %d: accidentally ended up on func_bobbing\n", ms->client); + AAS_ReachabilityFromNum(reachnum, &reach); + ms->lastreachnum = reachnum; + ms->reachability_time = AAS_Time() + BotReachabilityTime(&reach); + } //end if + else + { + if (bot_developer) + { + botimport.Print(PRT_MESSAGE, "client %d: on func_bobbing without reachability\n", ms->client); + } //end if + result->blocked = qtrue; + result->blockentity = ent; + result->flags |= MOVERESULT_ONTOPOFOBSTACLE; + return; + } //end else + } //end if + result->flags |= MOVERESULT_ONTOPOF_FUNCBOB; + } //end if + else if (modeltype == MODELTYPE_FUNC_STATIC || modeltype == MODELTYPE_FUNC_DOOR) + { + // check if ontop of a door bridge ? + ms->areanum = BotFuzzyPointReachabilityArea(ms->origin); + // if not in a reachability area + if (!AAS_AreaReachability(ms->areanum)) + { + result->blocked = qtrue; + result->blockentity = ent; + result->flags |= MOVERESULT_ONTOPOFOBSTACLE; + return; + } //end if + } //end else if + else + { + result->blocked = qtrue; + result->blockentity = ent; + result->flags |= MOVERESULT_ONTOPOFOBSTACLE; + return; + } //end else + } //end if + } //end if + } //end if + //if swimming + if (AAS_Swimming(ms->origin)) ms->moveflags |= MFL_SWIMMING; + //if against a ladder + if (AAS_AgainstLadder(ms->origin)) ms->moveflags |= MFL_AGAINSTLADDER; + //if the bot is on the ground, swimming or against a ladder + if (ms->moveflags & (MFL_ONGROUND|MFL_SWIMMING|MFL_AGAINSTLADDER)) + { + //botimport.Print(PRT_MESSAGE, "%s: onground, swimming or against ladder\n", ClientName(ms->entitynum-1)); + // + AAS_ReachabilityFromNum(ms->lastreachnum, &lastreach); + //reachability area the bot is in + //ms->areanum = BotReachabilityArea(ms->origin, ((lastreach.traveltype & TRAVELTYPE_MASK) != TRAVEL_ELEVATOR)); + ms->areanum = BotFuzzyPointReachabilityArea(ms->origin); + // + if ( !ms->areanum ) + { + result->failure = qtrue; + result->blocked = qtrue; + result->blockentity = 0; + result->type = RESULTTYPE_INSOLIDAREA; + return; + } //end if + //if the bot is in the goal area + if (ms->areanum == goal->areanum) + { + *result = BotMoveInGoalArea(ms, goal); + return; + } //end if + //assume we can use the reachability from the last frame + reachnum = ms->lastreachnum; + //if there is a last reachability + if (reachnum) + { + AAS_ReachabilityFromNum(reachnum, &reach); + //check if the reachability is still valid + if (!(AAS_TravelFlagForType(reach.traveltype) & travelflags)) + { + reachnum = 0; + } //end if + //special grapple hook case + else if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_GRAPPLEHOOK) + { + if (ms->reachability_time < AAS_Time() || + (ms->moveflags & MFL_GRAPPLERESET)) + { + reachnum = 0; + } //end if + } //end if + //special elevator case + else if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR || + (reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_FUNCBOB) + { + if ((result->flags & MOVERESULT_ONTOPOF_FUNCBOB) || + (result->flags & MOVERESULT_ONTOPOF_FUNCBOB)) + { + ms->reachability_time = AAS_Time() + 5; + } //end if + //if the bot was going for an elevator and reached the reachability area + if (ms->areanum == reach.areanum || + ms->reachability_time < AAS_Time()) + { + reachnum = 0; + } //end if + } //end if + else + { +#ifdef DEBUG + if (bot_developer) + { + if (ms->reachability_time < AAS_Time()) + { + botimport.Print(PRT_MESSAGE, "client %d: reachability timeout in ", ms->client); + AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK); + botimport.Print(PRT_MESSAGE, "\n"); + } //end if + /* + if (ms->lastareanum != ms->areanum) + { + botimport.Print(PRT_MESSAGE, "changed from area %d to %d\n", ms->lastareanum, ms->areanum); + } //end if*/ + } //end if +#endif //DEBUG + //if the goal area changed or the reachability timed out + //or the area changed + if (ms->lastgoalareanum != goal->areanum || + ms->reachability_time < AAS_Time() || + ms->lastareanum != ms->areanum) + { + reachnum = 0; + //botimport.Print(PRT_MESSAGE, "area change or timeout\n"); + } //end else if + } //end else + } //end if + resultflags = 0; + //if the bot needs a new reachability + if (!reachnum) + { + //if the area has no reachability links + if (!AAS_AreaReachability(ms->areanum)) + { +#ifdef DEBUG + if (bot_developer) + { + botimport.Print(PRT_MESSAGE, "area %d no reachability\n", ms->areanum); + } //end if +#endif //DEBUG + } //end if + //get a new reachability leading towards the goal + reachnum = BotGetReachabilityToGoal(ms->origin, ms->areanum, + ms->lastgoalareanum, ms->lastareanum, + ms->avoidreach, ms->avoidreachtimes, ms->avoidreachtries, + goal, travelflags, travelflags, + ms->avoidspots, ms->numavoidspots, &resultflags); + //the area number the reachability starts in + ms->reachareanum = ms->areanum; + //reset some state variables + ms->jumpreach = 0; //for TRAVEL_JUMP + ms->moveflags &= ~MFL_GRAPPLERESET; //for TRAVEL_GRAPPLEHOOK + //if there is a reachability to the goal + if (reachnum) + { + AAS_ReachabilityFromNum(reachnum, &reach); + //set a timeout for this reachability + ms->reachability_time = AAS_Time() + BotReachabilityTime(&reach); + // +#ifdef AVOIDREACH + //add the reachability to the reachabilities to avoid for a while + BotAddToAvoidReach(ms, reachnum, AVOIDREACH_TIME); +#endif //AVOIDREACH + } //end if +#ifdef DEBUG + + else if (bot_developer) + { + botimport.Print(PRT_MESSAGE, "goal not reachable\n"); + Com_Memset(&reach, 0, sizeof(aas_reachability_t)); //make compiler happy + } //end else + if (bot_developer) + { + //if still going for the same goal + if (ms->lastgoalareanum == goal->areanum) + { + if (ms->lastareanum == reach.areanum) + { + botimport.Print(PRT_MESSAGE, "same goal, going back to previous area\n"); + } //end if + } //end if + } //end if +#endif //DEBUG + } //end else + // + ms->lastreachnum = reachnum; + ms->lastgoalareanum = goal->areanum; + ms->lastareanum = ms->areanum; + //if the bot has a reachability + if (reachnum) + { + //get the reachability from the number + AAS_ReachabilityFromNum(reachnum, &reach); + result->traveltype = reach.traveltype; + // +#ifdef DEBUG_AI_MOVE + AAS_ClearShownDebugLines(); + AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK); + AAS_ShowReachability(&reach); +#endif //DEBUG_AI_MOVE + // +#ifdef DEBUG + //botimport.Print(PRT_MESSAGE, "client %d: ", ms->client); + //AAS_PrintTravelType(reach.traveltype); + //botimport.Print(PRT_MESSAGE, "\n"); +#endif //DEBUG + switch(reach.traveltype & TRAVELTYPE_MASK) + { + case TRAVEL_WALK: *result = BotTravel_Walk(ms, &reach); break; + case TRAVEL_CROUCH: *result = BotTravel_Crouch(ms, &reach); break; + case TRAVEL_BARRIERJUMP: *result = BotTravel_BarrierJump(ms, &reach); break; + case TRAVEL_LADDER: *result = BotTravel_Ladder(ms, &reach); break; + case TRAVEL_WALKOFFLEDGE: *result = BotTravel_WalkOffLedge(ms, &reach); break; + case TRAVEL_JUMP: *result = BotTravel_Jump(ms, &reach); break; + case TRAVEL_SWIM: *result = BotTravel_Swim(ms, &reach); break; + case TRAVEL_WATERJUMP: *result = BotTravel_WaterJump(ms, &reach); break; + case TRAVEL_TELEPORT: *result = BotTravel_Teleport(ms, &reach); break; + case TRAVEL_ELEVATOR: *result = BotTravel_Elevator(ms, &reach); break; + case TRAVEL_GRAPPLEHOOK: *result = BotTravel_Grapple(ms, &reach); break; + case TRAVEL_ROCKETJUMP: *result = BotTravel_RocketJump(ms, &reach); break; + case TRAVEL_BFGJUMP: *result = BotTravel_BFGJump(ms, &reach); break; + case TRAVEL_JUMPPAD: *result = BotTravel_JumpPad(ms, &reach); break; + case TRAVEL_FUNCBOB: *result = BotTravel_FuncBobbing(ms, &reach); break; + default: + { + botimport.Print(PRT_FATAL, "travel type %d not implemented yet\n", (reach.traveltype & TRAVELTYPE_MASK)); + break; + } //end case + } //end switch + result->traveltype = reach.traveltype; + result->flags |= resultflags; + } //end if + else + { + result->failure = qtrue; + result->flags |= resultflags; + Com_Memset(&reach, 0, sizeof(aas_reachability_t)); + } //end else +#ifdef DEBUG + if (bot_developer) + { + if (result->failure) + { + botimport.Print(PRT_MESSAGE, "client %d: movement failure in ", ms->client); + AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK); + botimport.Print(PRT_MESSAGE, "\n"); + } //end if + } //end if +#endif //DEBUG + } //end if + else + { + int i, numareas, areas[16]; + vec3_t end; + + //special handling of jump pads when the bot uses a jump pad without knowing it + foundjumppad = qfalse; + VectorMA(ms->origin, -2 * ms->thinktime, ms->velocity, end); + numareas = AAS_TraceAreas(ms->origin, end, areas, NULL, 16); + for (i = numareas-1; i >= 0; i--) + { + if (AAS_AreaJumpPad(areas[i])) + { + //botimport.Print(PRT_MESSAGE, "client %d used a jumppad without knowing, area %d\n", ms->client, areas[i]); + foundjumppad = qtrue; + lastreachnum = BotGetReachabilityToGoal(end, areas[i], + ms->lastgoalareanum, ms->lastareanum, + ms->avoidreach, ms->avoidreachtimes, ms->avoidreachtries, + goal, travelflags, TFL_JUMPPAD, ms->avoidspots, ms->numavoidspots, NULL); + if (lastreachnum) + { + ms->lastreachnum = lastreachnum; + ms->lastareanum = areas[i]; + //botimport.Print(PRT_MESSAGE, "found jumppad reachability\n"); + break; + } //end if + else + { + for (lastreachnum = AAS_NextAreaReachability(areas[i], 0); lastreachnum; + lastreachnum = AAS_NextAreaReachability(areas[i], lastreachnum)) + { + //get the reachability from the number + AAS_ReachabilityFromNum(lastreachnum, &reach); + if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMPPAD) + { + ms->lastreachnum = lastreachnum; + ms->lastareanum = areas[i]; + //botimport.Print(PRT_MESSAGE, "found jumppad reachability hard!!\n"); + break; + } //end if + } //end for + if (lastreachnum) break; + } //end else + } //end if + } //end for + if (bot_developer) + { + //if a jumppad is found with the trace but no reachability is found + if (foundjumppad && !ms->lastreachnum) + { + botimport.Print(PRT_MESSAGE, "client %d didn't find jumppad reachability\n", ms->client); + } //end if + } //end if + // + if (ms->lastreachnum) + { + //botimport.Print(PRT_MESSAGE, "%s: NOT onground, swimming or against ladder\n", ClientName(ms->entitynum-1)); + AAS_ReachabilityFromNum(ms->lastreachnum, &reach); + result->traveltype = reach.traveltype; +#ifdef DEBUG + //botimport.Print(PRT_MESSAGE, "client %d finish: ", ms->client); + //AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK); + //botimport.Print(PRT_MESSAGE, "\n"); +#endif //DEBUG + // + switch(reach.traveltype & TRAVELTYPE_MASK) + { + case TRAVEL_WALK: *result = BotTravel_Walk(ms, &reach); break;//BotFinishTravel_Walk(ms, &reach); break; + case TRAVEL_CROUCH: /*do nothing*/ break; + case TRAVEL_BARRIERJUMP: *result = BotFinishTravel_BarrierJump(ms, &reach); break; + case TRAVEL_LADDER: *result = BotTravel_Ladder(ms, &reach); break; + case TRAVEL_WALKOFFLEDGE: *result = BotFinishTravel_WalkOffLedge(ms, &reach); break; + case TRAVEL_JUMP: *result = BotFinishTravel_Jump(ms, &reach); break; + case TRAVEL_SWIM: *result = BotTravel_Swim(ms, &reach); break; + case TRAVEL_WATERJUMP: *result = BotFinishTravel_WaterJump(ms, &reach); break; + case TRAVEL_TELEPORT: /*do nothing*/ break; + case TRAVEL_ELEVATOR: *result = BotFinishTravel_Elevator(ms, &reach); break; + case TRAVEL_GRAPPLEHOOK: *result = BotTravel_Grapple(ms, &reach); break; + case TRAVEL_ROCKETJUMP: + case TRAVEL_BFGJUMP: *result = BotFinishTravel_WeaponJump(ms, &reach); break; + case TRAVEL_JUMPPAD: *result = BotFinishTravel_JumpPad(ms, &reach); break; + case TRAVEL_FUNCBOB: *result = BotFinishTravel_FuncBobbing(ms, &reach); break; + default: + { + botimport.Print(PRT_FATAL, "(last) travel type %d not implemented yet\n", (reach.traveltype & TRAVELTYPE_MASK)); + break; + } //end case + } //end switch + result->traveltype = reach.traveltype; +#ifdef DEBUG + if (bot_developer) + { + if (result->failure) + { + botimport.Print(PRT_MESSAGE, "client %d: movement failure in finish ", ms->client); + AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK); + botimport.Print(PRT_MESSAGE, "\n"); + } //end if + } //end if +#endif //DEBUG + } //end if + } //end else + //FIXME: is it right to do this here? + if (result->blocked) ms->reachability_time -= 10 * ms->thinktime; + //copy the last origin + VectorCopy(ms->origin, ms->lastorigin); + //return the movement result + return; +} //end of the function BotMoveToGoal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotResetAvoidReach(int movestate) +{ + bot_movestate_t *ms; + + ms = BotMoveStateFromHandle(movestate); + if (!ms) return; + Com_Memset(ms->avoidreach, 0, MAX_AVOIDREACH * sizeof(int)); + Com_Memset(ms->avoidreachtimes, 0, MAX_AVOIDREACH * sizeof(float)); + Com_Memset(ms->avoidreachtries, 0, MAX_AVOIDREACH * sizeof(int)); +} //end of the function BotResetAvoidReach +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotResetLastAvoidReach(int movestate) +{ + int i, latest; + float latesttime; + bot_movestate_t *ms; + + ms = BotMoveStateFromHandle(movestate); + if (!ms) return; + latesttime = 0; + latest = 0; + for (i = 0; i < MAX_AVOIDREACH; i++) + { + if (ms->avoidreachtimes[i] > latesttime) + { + latesttime = ms->avoidreachtimes[i]; + latest = i; + } //end if + } //end for + if (latesttime) + { + ms->avoidreachtimes[latest] = 0; + if (ms->avoidreachtries[i] > 0) ms->avoidreachtries[latest]--; + } //end if +} //end of the function BotResetLastAvoidReach +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotResetMoveState(int movestate) +{ + bot_movestate_t *ms; + + ms = BotMoveStateFromHandle(movestate); + if (!ms) return; + Com_Memset(ms, 0, sizeof(bot_movestate_t)); +} //end of the function BotResetMoveState +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotSetupMoveAI(void) +{ + BotSetBrushModelTypes(); + sv_maxstep = LibVar("sv_step", "18"); + sv_maxbarrier = LibVar("sv_maxbarrier", "32"); + sv_gravity = LibVar("sv_gravity", "800"); + weapindex_rocketlauncher = LibVar("weapindex_rocketlauncher", "5"); + weapindex_bfg10k = LibVar("weapindex_bfg10k", "9"); + weapindex_grapple = LibVar("weapindex_grapple", "10"); + entitytypemissile = LibVar("entitytypemissile", "3"); + offhandgrapple = LibVar("offhandgrapple", "0"); + cmd_grappleon = LibVar("cmd_grappleon", "grappleon"); + cmd_grappleoff = LibVar("cmd_grappleoff", "grappleoff"); + return BLERR_NOERROR; +} //end of the function BotSetupMoveAI +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotShutdownMoveAI(void) +{ + int i; + + for (i = 1; i <= MAX_CLIENTS; i++) + { + if (botmovestates[i]) + { + FreeMemory(botmovestates[i]); + botmovestates[i] = NULL; + } //end if + } //end for +} //end of the function BotShutdownMoveAI + + diff --git a/code/botlib/be_ai_move.h b/code/botlib/be_ai_move.h new file mode 100644 index 00000000..a32d9397 --- /dev/null +++ b/code/botlib/be_ai_move.h @@ -0,0 +1,142 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_ai_move.h + * + * desc: movement AI + * + * $Archive: /source/code/botlib/be_ai_move.h $ + * + *****************************************************************************/ + +//movement types +#define MOVE_WALK 1 +#define MOVE_CROUCH 2 +#define MOVE_JUMP 4 +#define MOVE_GRAPPLE 8 +#define MOVE_ROCKETJUMP 16 +#define MOVE_BFGJUMP 32 +//move flags +#define MFL_BARRIERJUMP 1 //bot is performing a barrier jump +#define MFL_ONGROUND 2 //bot is in the ground +#define MFL_SWIMMING 4 //bot is swimming +#define MFL_AGAINSTLADDER 8 //bot is against a ladder +#define MFL_WATERJUMP 16 //bot is waterjumping +#define MFL_TELEPORTED 32 //bot is being teleported +#define MFL_GRAPPLEPULL 64 //bot is being pulled by the grapple +#define MFL_ACTIVEGRAPPLE 128 //bot is using the grapple hook +#define MFL_GRAPPLERESET 256 //bot has reset the grapple +#define MFL_WALK 512 //bot should walk slowly +// move result flags +#define MOVERESULT_MOVEMENTVIEW 1 //bot uses view for movement +#define MOVERESULT_SWIMVIEW 2 //bot uses view for swimming +#define MOVERESULT_WAITING 4 //bot is waiting for something +#define MOVERESULT_MOVEMENTVIEWSET 8 //bot has set the view in movement code +#define MOVERESULT_MOVEMENTWEAPON 16 //bot uses weapon for movement +#define MOVERESULT_ONTOPOFOBSTACLE 32 //bot is ontop of obstacle +#define MOVERESULT_ONTOPOF_FUNCBOB 64 //bot is ontop of a func_bobbing +#define MOVERESULT_ONTOPOF_ELEVATOR 128 //bot is ontop of an elevator (func_plat) +#define MOVERESULT_BLOCKEDBYAVOIDSPOT 256 //bot is blocked by an avoid spot +// +#define MAX_AVOIDREACH 1 +#define MAX_AVOIDSPOTS 32 +// avoid spot types +#define AVOID_CLEAR 0 //clear all avoid spots +#define AVOID_ALWAYS 1 //avoid always +#define AVOID_DONTBLOCK 2 //never totally block +// restult types +#define RESULTTYPE_ELEVATORUP 1 //elevator is up +#define RESULTTYPE_WAITFORFUNCBOBBING 2 //waiting for func bobbing to arrive +#define RESULTTYPE_BADGRAPPLEPATH 4 //grapple path is obstructed +#define RESULTTYPE_INSOLIDAREA 8 //stuck in solid area, this is bad + +//structure used to initialize the movement state +//the or_moveflags MFL_ONGROUND, MFL_TELEPORTED and MFL_WATERJUMP come from the playerstate +typedef struct bot_initmove_s +{ + vec3_t origin; //origin of the bot + vec3_t velocity; //velocity of the bot + vec3_t viewoffset; //view offset + int entitynum; //entity number of the bot + int client; //client number of the bot + float thinktime; //time the bot thinks + int presencetype; //presencetype of the bot + vec3_t viewangles; //view angles of the bot + int or_moveflags; //values ored to the movement flags +} bot_initmove_t; + +//NOTE: the ideal_viewangles are only valid if MFL_MOVEMENTVIEW is set +typedef struct bot_moveresult_s +{ + int failure; //true if movement failed all together + int type; //failure or blocked type + int blocked; //true if blocked by an entity + int blockentity; //entity blocking the bot + int traveltype; //last executed travel type + int flags; //result flags + int weapon; //weapon used for movement + vec3_t movedir; //movement direction + vec3_t ideal_viewangles; //ideal viewangles for the movement +} bot_moveresult_t; + +#define bot_moveresult_t_cleared(x) bot_moveresult_t (x) = {0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, {0, 0, 0}} + +typedef struct bot_avoidspot_s +{ + vec3_t origin; + float radius; + int type; +} bot_avoidspot_t; + +//resets the whole move state +void BotResetMoveState(int movestate); +//moves the bot to the given goal +void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags); +//moves the bot in the specified direction using the specified type of movement +int BotMoveInDirection(int movestate, vec3_t dir, float speed, int type); +//reset avoid reachability +void BotResetAvoidReach(int movestate); +//resets the last avoid reachability +void BotResetLastAvoidReach(int movestate); +//returns a reachability area if the origin is in one +int BotReachabilityArea(vec3_t origin, int client); +//view target based on movement +int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target); +//predict the position of a player based on movement towards a goal +int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target); +//returns the handle of a newly allocated movestate +int BotAllocMoveState(void); +//frees the movestate with the given handle +void BotFreeMoveState(int handle); +//initialize movement state before performing any movement +void BotInitMoveState(int handle, bot_initmove_t *initmove); +//add a spot to avoid (if type == AVOID_CLEAR all spots are removed) +void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type); +//must be called every map change +void BotSetBrushModelTypes(void); +//setup movement AI +int BotSetupMoveAI(void); +//shutdown movement AI +void BotShutdownMoveAI(void); + diff --git a/code/botlib/be_ai_weap.c b/code/botlib/be_ai_weap.c new file mode 100644 index 00000000..0aab5e8c --- /dev/null +++ b/code/botlib/be_ai_weap.c @@ -0,0 +1,543 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_ai_weap.c + * + * desc: weapon AI + * + * $Archive: /MissionPack/code/botlib/be_ai_weap.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_libvar.h" +#include "l_log.h" +#include "l_memory.h" +#include "l_utils.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "aasfile.h" +#include "botlib.h" +#include "be_aas.h" +#include "be_aas_funcs.h" +#include "be_interface.h" +#include "be_ai_weight.h" //fuzzy weights +#include "be_ai_weap.h" + +//#define DEBUG_AI_WEAP + +//structure field offsets +#define WEAPON_OFS(x) (size_t)&(((weaponinfo_t *)0)->x) +#define PROJECTILE_OFS(x) (size_t)&(((projectileinfo_t *)0)->x) + +//weapon definition +static fielddef_t weaponinfo_fields[] = +{ +{"number", WEAPON_OFS(number), FT_INT}, //weapon number +{"name", WEAPON_OFS(name), FT_STRING}, //name of the weapon +{"level", WEAPON_OFS(level), FT_INT}, +{"model", WEAPON_OFS(model), FT_STRING}, //model of the weapon +{"weaponindex", WEAPON_OFS(weaponindex), FT_INT}, //index of weapon in inventory +{"flags", WEAPON_OFS(flags), FT_INT}, //special flags +{"projectile", WEAPON_OFS(projectile), FT_STRING}, //projectile used by the weapon +{"numprojectiles", WEAPON_OFS(numprojectiles), FT_INT}, //number of projectiles +{"hspread", WEAPON_OFS(hspread), FT_FLOAT}, //horizontal spread of projectiles (degrees from middle) +{"vspread", WEAPON_OFS(vspread), FT_FLOAT}, //vertical spread of projectiles (degrees from middle) +{"speed", WEAPON_OFS(speed), FT_FLOAT}, //speed of the projectile (0 = instant hit) +{"acceleration", WEAPON_OFS(acceleration), FT_FLOAT}, //"acceleration" * time (in seconds) + "speed" = projectile speed +{"recoil", WEAPON_OFS(recoil), FT_FLOAT|FT_ARRAY, 3}, //amount of recoil the player gets from the weapon +{"offset", WEAPON_OFS(offset), FT_FLOAT|FT_ARRAY, 3}, //projectile start offset relative to eye and view angles +{"angleoffset", WEAPON_OFS(angleoffset), FT_FLOAT|FT_ARRAY, 3},//offset of the shoot angles relative to the view angles +{"extrazvelocity", WEAPON_OFS(extrazvelocity), FT_FLOAT},//extra z velocity the projectile gets +{"ammoamount", WEAPON_OFS(ammoamount), FT_INT}, //ammo amount used per shot +{"ammoindex", WEAPON_OFS(ammoindex), FT_INT}, //index of ammo in inventory +{"activate", WEAPON_OFS(activate), FT_FLOAT}, //time it takes to select the weapon +{"reload", WEAPON_OFS(reload), FT_FLOAT}, //time it takes to reload the weapon +{"spinup", WEAPON_OFS(spinup), FT_FLOAT}, //time it takes before first shot +{"spindown", WEAPON_OFS(spindown), FT_FLOAT}, //time it takes before weapon stops firing +{NULL, 0, 0, 0} +}; + +//projectile definition +static fielddef_t projectileinfo_fields[] = +{ +{"name", PROJECTILE_OFS(name), FT_STRING}, //name of the projectile +{"model", WEAPON_OFS(model), FT_STRING}, //model of the projectile +{"flags", PROJECTILE_OFS(flags), FT_INT}, //special flags +{"gravity", PROJECTILE_OFS(gravity), FT_FLOAT}, //amount of gravity applied to the projectile [0,1] +{"damage", PROJECTILE_OFS(damage), FT_INT}, //damage of the projectile +{"radius", PROJECTILE_OFS(radius), FT_FLOAT}, //radius of damage +{"visdamage", PROJECTILE_OFS(visdamage), FT_INT}, //damage of the projectile to visible entities +{"damagetype", PROJECTILE_OFS(damagetype), FT_INT}, //type of damage (combination of the DAMAGETYPE_? flags) +{"healthinc", PROJECTILE_OFS(healthinc), FT_INT}, //health increase the owner gets +{"push", PROJECTILE_OFS(push), FT_FLOAT}, //amount a player is pushed away from the projectile impact +{"detonation", PROJECTILE_OFS(detonation), FT_FLOAT}, //time before projectile explodes after fire pressed +{"bounce", PROJECTILE_OFS(bounce), FT_FLOAT}, //amount the projectile bounces +{"bouncefric", PROJECTILE_OFS(bouncefric), FT_FLOAT}, //amount the bounce decreases per bounce +{"bouncestop", PROJECTILE_OFS(bouncestop), FT_FLOAT}, //minimum bounce value before bouncing stops +//recurive projectile definition?? +{NULL, 0, 0, 0} +}; + +static structdef_t weaponinfo_struct = +{ + sizeof(weaponinfo_t), weaponinfo_fields +}; +static structdef_t projectileinfo_struct = +{ + sizeof(projectileinfo_t), projectileinfo_fields +}; + +//weapon configuration: set of weapons with projectiles +typedef struct weaponconfig_s +{ + int numweapons; + int numprojectiles; + projectileinfo_t *projectileinfo; + weaponinfo_t *weaponinfo; +} weaponconfig_t; + +//the bot weapon state +typedef struct bot_weaponstate_s +{ + struct weightconfig_s *weaponweightconfig; //weapon weight configuration + int *weaponweightindex; //weapon weight index +} bot_weaponstate_t; + +static bot_weaponstate_t *botweaponstates[MAX_CLIENTS+1]; +static weaponconfig_t *weaponconfig; + +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +int BotValidWeaponNumber(int weaponnum) +{ + if (weaponnum <= 0 || weaponnum > weaponconfig->numweapons) + { + botimport.Print(PRT_ERROR, "weapon number out of range\n"); + return qfalse; + } //end if + return qtrue; +} //end of the function BotValidWeaponNumber +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +bot_weaponstate_t *BotWeaponStateFromHandle(int handle) +{ + if (handle <= 0 || handle > MAX_CLIENTS) + { + botimport.Print(PRT_FATAL, "move state handle %d out of range\n", handle); + return NULL; + } //end if + if (!botweaponstates[handle]) + { + botimport.Print(PRT_FATAL, "invalid move state %d\n", handle); + return NULL; + } //end if + return botweaponstates[handle]; +} //end of the function BotWeaponStateFromHandle +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef DEBUG_AI_WEAP +void DumpWeaponConfig(weaponconfig_t *wc) +{ + FILE *fp; + int i; + + fp = Log_FileStruct(); + if (!fp) return; + for (i = 0; i < wc->numprojectiles; i++) + { + WriteStructure(fp, &projectileinfo_struct, (char *) &wc->projectileinfo[i]); + Log_Flush(); + } //end for + for (i = 0; i < wc->numweapons; i++) + { + WriteStructure(fp, &weaponinfo_struct, (char *) &wc->weaponinfo[i]); + Log_Flush(); + } //end for +} //end of the function DumpWeaponConfig +#endif //DEBUG_AI_WEAP +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +weaponconfig_t *LoadWeaponConfig(char *filename) +{ + int max_weaponinfo, max_projectileinfo; + token_t token; + char path[MAX_PATH]; + int i, j; + source_t *source; + weaponconfig_t *wc; + weaponinfo_t weaponinfo; + + max_weaponinfo = (int) LibVarValue("max_weaponinfo", "32"); + if (max_weaponinfo < 0) + { + botimport.Print(PRT_ERROR, "max_weaponinfo = %d\n", max_weaponinfo); + max_weaponinfo = 32; + LibVarSet("max_weaponinfo", "32"); + } //end if + max_projectileinfo = (int) LibVarValue("max_projectileinfo", "32"); + if (max_projectileinfo < 0) + { + botimport.Print(PRT_ERROR, "max_projectileinfo = %d\n", max_projectileinfo); + max_projectileinfo = 32; + LibVarSet("max_projectileinfo", "32"); + } //end if + strncpy(path, filename, MAX_PATH); + PC_SetBaseFolder(BOTFILESBASEFOLDER); + source = LoadSourceFile(path); + if (!source) + { + botimport.Print(PRT_ERROR, "counldn't load %s\n", path); + return NULL; + } //end if + //initialize weapon config + wc = (weaponconfig_t *) GetClearedHunkMemory(sizeof(weaponconfig_t) + + max_weaponinfo * sizeof(weaponinfo_t) + + max_projectileinfo * sizeof(projectileinfo_t)); + wc->weaponinfo = (weaponinfo_t *) ((char *) wc + sizeof(weaponconfig_t)); + wc->projectileinfo = (projectileinfo_t *) ((char *) wc->weaponinfo + + max_weaponinfo * sizeof(weaponinfo_t)); + wc->numweapons = max_weaponinfo; + wc->numprojectiles = 0; + //parse the source file + while(PC_ReadToken(source, &token)) + { + if (!strcmp(token.string, "weaponinfo")) + { + Com_Memset(&weaponinfo, 0, sizeof(weaponinfo_t)); + if (!ReadStructure(source, &weaponinfo_struct, (char *) &weaponinfo)) + { + FreeMemory(wc); + FreeSource(source); + return NULL; + } //end if + if (weaponinfo.number < 0 || weaponinfo.number >= max_weaponinfo) + { + botimport.Print(PRT_ERROR, "weapon info number %d out of range in %s\n", weaponinfo.number, path); + FreeMemory(wc); + FreeSource(source); + return NULL; + } //end if + Com_Memcpy(&wc->weaponinfo[weaponinfo.number], &weaponinfo, sizeof(weaponinfo_t)); + wc->weaponinfo[weaponinfo.number].valid = qtrue; + } //end if + else if (!strcmp(token.string, "projectileinfo")) + { + if (wc->numprojectiles >= max_projectileinfo) + { + botimport.Print(PRT_ERROR, "more than %d projectiles defined in %s\n", max_projectileinfo, path); + FreeMemory(wc); + FreeSource(source); + return NULL; + } //end if + Com_Memset(&wc->projectileinfo[wc->numprojectiles], 0, sizeof(projectileinfo_t)); + if (!ReadStructure(source, &projectileinfo_struct, (char *) &wc->projectileinfo[wc->numprojectiles])) + { + FreeMemory(wc); + FreeSource(source); + return NULL; + } //end if + wc->numprojectiles++; + } //end if + else + { + botimport.Print(PRT_ERROR, "unknown definition %s in %s\n", token.string, path); + FreeMemory(wc); + FreeSource(source); + return NULL; + } //end else + } //end while + FreeSource(source); + //fix up weapons + for (i = 0; i < wc->numweapons; i++) + { + if (!wc->weaponinfo[i].valid) continue; + if (!wc->weaponinfo[i].name[0]) + { + botimport.Print(PRT_ERROR, "weapon %d has no name in %s\n", i, path); + FreeMemory(wc); + return NULL; + } //end if + if (!wc->weaponinfo[i].projectile[0]) + { + botimport.Print(PRT_ERROR, "weapon %s has no projectile in %s\n", wc->weaponinfo[i].name, path); + FreeMemory(wc); + return NULL; + } //end if + //find the projectile info and copy it to the weapon info + for (j = 0; j < wc->numprojectiles; j++) + { + if (!strcmp(wc->projectileinfo[j].name, wc->weaponinfo[i].projectile)) + { + Com_Memcpy(&wc->weaponinfo[i].proj, &wc->projectileinfo[j], sizeof(projectileinfo_t)); + break; + } //end if + } //end for + if (j == wc->numprojectiles) + { + botimport.Print(PRT_ERROR, "weapon %s uses undefined projectile in %s\n", wc->weaponinfo[i].name, path); + FreeMemory(wc); + return NULL; + } //end if + } //end for + if (!wc->numweapons) botimport.Print(PRT_WARNING, "no weapon info loaded\n"); + botimport.Print(PRT_MESSAGE, "loaded %s\n", path); + return wc; +} //end of the function LoadWeaponConfig +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int *WeaponWeightIndex(weightconfig_t *wwc, weaponconfig_t *wc) +{ + int *index, i; + + //initialize item weight index + index = (int *) GetClearedMemory(sizeof(int) * wc->numweapons); + + for (i = 0; i < wc->numweapons; i++) + { + index[i] = FindFuzzyWeight(wwc, wc->weaponinfo[i].name); + } //end for + return index; +} //end of the function WeaponWeightIndex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotFreeWeaponWeights(int weaponstate) +{ + bot_weaponstate_t *ws; + + ws = BotWeaponStateFromHandle(weaponstate); + if (!ws) return; + if (ws->weaponweightconfig) FreeWeightConfig(ws->weaponweightconfig); + if (ws->weaponweightindex) FreeMemory(ws->weaponweightindex); +} //end of the function BotFreeWeaponWeights +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotLoadWeaponWeights(int weaponstate, char *filename) +{ + bot_weaponstate_t *ws; + + ws = BotWeaponStateFromHandle(weaponstate); + if (!ws) return BLERR_CANNOTLOADWEAPONWEIGHTS; + BotFreeWeaponWeights(weaponstate); + // + ws->weaponweightconfig = ReadWeightConfig(filename); + if (!ws->weaponweightconfig) + { + botimport.Print(PRT_FATAL, "couldn't load weapon config %s\n", filename); + return BLERR_CANNOTLOADWEAPONWEIGHTS; + } //end if + if (!weaponconfig) return BLERR_CANNOTLOADWEAPONCONFIG; + ws->weaponweightindex = WeaponWeightIndex(ws->weaponweightconfig, weaponconfig); + return BLERR_NOERROR; +} //end of the function BotLoadWeaponWeights +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo) +{ + bot_weaponstate_t *ws; + + if (!BotValidWeaponNumber(weapon)) return; + ws = BotWeaponStateFromHandle(weaponstate); + if (!ws) return; + if (!weaponconfig) return; + Com_Memcpy(weaponinfo, &weaponconfig->weaponinfo[weapon], sizeof(weaponinfo_t)); +} //end of the function BotGetWeaponInfo +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotChooseBestFightWeapon(int weaponstate, int *inventory) +{ + int i, index, bestweapon; + float weight, bestweight; + weaponconfig_t *wc; + bot_weaponstate_t *ws; + + ws = BotWeaponStateFromHandle(weaponstate); + if (!ws) return 0; + wc = weaponconfig; + if (!weaponconfig) return 0; + + //if the bot has no weapon weight configuration + if (!ws->weaponweightconfig) return 0; + + bestweight = 0; + bestweapon = 0; + for (i = 0; i < wc->numweapons; i++) + { + if (!wc->weaponinfo[i].valid) continue; + index = ws->weaponweightindex[i]; + if (index < 0) continue; + weight = FuzzyWeight(inventory, ws->weaponweightconfig, index); + if (weight > bestweight) + { + bestweight = weight; + bestweapon = i; + } //end if + } //end for + return bestweapon; +} //end of the function BotChooseBestFightWeapon +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotResetWeaponState(int weaponstate) +{ + struct weightconfig_s *weaponweightconfig; + int *weaponweightindex; + bot_weaponstate_t *ws; + + ws = BotWeaponStateFromHandle(weaponstate); + if (!ws) return; + weaponweightconfig = ws->weaponweightconfig; + weaponweightindex = ws->weaponweightindex; + + //Com_Memset(ws, 0, sizeof(bot_weaponstate_t)); + ws->weaponweightconfig = weaponweightconfig; + ws->weaponweightindex = weaponweightindex; +} //end of the function BotResetWeaponState +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +int BotAllocWeaponState(void) +{ + int i; + + for (i = 1; i <= MAX_CLIENTS; i++) + { + if (!botweaponstates[i]) + { + botweaponstates[i] = GetClearedMemory(sizeof(bot_weaponstate_t)); + return i; + } //end if + } //end for + return 0; +} //end of the function BotAllocWeaponState +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +void BotFreeWeaponState(int handle) +{ + if (handle <= 0 || handle > MAX_CLIENTS) + { + botimport.Print(PRT_FATAL, "move state handle %d out of range\n", handle); + return; + } //end if + if (!botweaponstates[handle]) + { + botimport.Print(PRT_FATAL, "invalid move state %d\n", handle); + return; + } //end if + BotFreeWeaponWeights(handle); + FreeMemory(botweaponstates[handle]); + botweaponstates[handle] = NULL; +} //end of the function BotFreeWeaponState +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotSetupWeaponAI(void) +{ + char *file; + + file = LibVarString("weaponconfig", "weapons.c"); + weaponconfig = LoadWeaponConfig(file); + if (!weaponconfig) + { + botimport.Print(PRT_FATAL, "couldn't load the weapon config\n"); + return BLERR_CANNOTLOADWEAPONCONFIG; + } //end if + +#ifdef DEBUG_AI_WEAP + DumpWeaponConfig(weaponconfig); +#endif //DEBUG_AI_WEAP + // + return BLERR_NOERROR; +} //end of the function BotSetupWeaponAI +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotShutdownWeaponAI(void) +{ + int i; + + if (weaponconfig) FreeMemory(weaponconfig); + weaponconfig = NULL; + + for (i = 1; i <= MAX_CLIENTS; i++) + { + if (botweaponstates[i]) + { + BotFreeWeaponState(i); + } //end if + } //end for +} //end of the function BotShutdownWeaponAI + diff --git a/code/botlib/be_ai_weap.h b/code/botlib/be_ai_weap.h new file mode 100644 index 00000000..59067fb0 --- /dev/null +++ b/code/botlib/be_ai_weap.h @@ -0,0 +1,104 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_ai_weap.h + * + * desc: weapon AI + * + * $Archive: /source/code/botlib/be_ai_weap.h $ + * + *****************************************************************************/ + +//projectile flags +#define PFL_WINDOWDAMAGE 1 //projectile damages through window +#define PFL_RETURN 2 //set when projectile returns to owner +//weapon flags +#define WFL_FIRERELEASED 1 //set when projectile is fired with key-up event +//damage types +#define DAMAGETYPE_IMPACT 1 //damage on impact +#define DAMAGETYPE_RADIAL 2 //radial damage +#define DAMAGETYPE_VISIBLE 4 //damage to all entities visible to the projectile + +typedef struct projectileinfo_s +{ + char name[MAX_STRINGFIELD]; + char model[MAX_STRINGFIELD]; + int flags; + float gravity; + int damage; + float radius; + int visdamage; + int damagetype; + int healthinc; + float push; + float detonation; + float bounce; + float bouncefric; + float bouncestop; +} projectileinfo_t; + +typedef struct weaponinfo_s +{ + int valid; //true if the weapon info is valid + int number; //number of the weapon + char name[MAX_STRINGFIELD]; + char model[MAX_STRINGFIELD]; + int level; + int weaponindex; + int flags; + char projectile[MAX_STRINGFIELD]; + int numprojectiles; + float hspread; + float vspread; + float speed; + float acceleration; + vec3_t recoil; + vec3_t offset; + vec3_t angleoffset; + float extrazvelocity; + int ammoamount; + int ammoindex; + float activate; + float reload; + float spinup; + float spindown; + projectileinfo_t proj; //pointer to the used projectile +} weaponinfo_t; + +//setup the weapon AI +int BotSetupWeaponAI(void); +//shut down the weapon AI +void BotShutdownWeaponAI(void); +//returns the best weapon to fight with +int BotChooseBestFightWeapon(int weaponstate, int *inventory); +//returns the information of the current weapon +void BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo); +//loads the weapon weights +int BotLoadWeaponWeights(int weaponstate, char *filename); +//returns a handle to a newly allocated weapon state +int BotAllocWeaponState(void); +//frees the weapon state +void BotFreeWeaponState(int weaponstate); +//resets the whole weapon state +void BotResetWeaponState(int weaponstate); diff --git a/code/botlib/be_ai_weight.c b/code/botlib/be_ai_weight.c new file mode 100644 index 00000000..8d48ee62 --- /dev/null +++ b/code/botlib/be_ai_weight.c @@ -0,0 +1,918 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_ai_weight.c + * + * desc: fuzzy logic + * + * $Archive: /MissionPack/code/botlib/be_ai_weight.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_memory.h" +#include "l_log.h" +#include "l_utils.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "l_libvar.h" +#include "aasfile.h" +#include "botlib.h" +#include "be_aas.h" +#include "be_aas_funcs.h" +#include "be_interface.h" +#include "be_ai_weight.h" + +#define MAX_INVENTORYVALUE 999999 +#define EVALUATERECURSIVELY + +#define MAX_WEIGHT_FILES 128 +weightconfig_t *weightFileList[MAX_WEIGHT_FILES]; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int ReadValue(source_t *source, float *value) +{ + token_t token; + + if (!PC_ExpectAnyToken(source, &token)) return qfalse; + if (!strcmp(token.string, "-")) + { + SourceWarning(source, "negative value set to zero\n"); + if (!PC_ExpectTokenType(source, TT_NUMBER, 0, &token)) return qfalse; + } //end if + if (token.type != TT_NUMBER) + { + SourceError(source, "invalid return value %s\n", token.string); + return qfalse; + } //end if + *value = token.floatvalue; + return qtrue; +} //end of the function ReadValue +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int ReadFuzzyWeight(source_t *source, fuzzyseperator_t *fs) +{ + if (PC_CheckTokenString(source, "balance")) + { + fs->type = WT_BALANCE; + if (!PC_ExpectTokenString(source, "(")) return qfalse; + if (!ReadValue(source, &fs->weight)) return qfalse; + if (!PC_ExpectTokenString(source, ",")) return qfalse; + if (!ReadValue(source, &fs->minweight)) return qfalse; + if (!PC_ExpectTokenString(source, ",")) return qfalse; + if (!ReadValue(source, &fs->maxweight)) return qfalse; + if (!PC_ExpectTokenString(source, ")")) return qfalse; + } //end if + else + { + fs->type = 0; + if (!ReadValue(source, &fs->weight)) return qfalse; + fs->minweight = fs->weight; + fs->maxweight = fs->weight; + } //end if + if (!PC_ExpectTokenString(source, ";")) return qfalse; + return qtrue; +} //end of the function ReadFuzzyWeight +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeFuzzySeperators_r(fuzzyseperator_t *fs) +{ + if (!fs) return; + if (fs->child) FreeFuzzySeperators_r(fs->child); + if (fs->next) FreeFuzzySeperators_r(fs->next); + FreeMemory(fs); +} //end of the function FreeFuzzySeperators +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeWeightConfig2(weightconfig_t *config) +{ + int i; + + for (i = 0; i < config->numweights; i++) + { + FreeFuzzySeperators_r(config->weights[i].firstseperator); + if (config->weights[i].name) FreeMemory(config->weights[i].name); + } //end for + FreeMemory(config); +} //end of the function FreeWeightConfig2 +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeWeightConfig(weightconfig_t *config) +{ + if (!LibVarGetValue("bot_reloadcharacters")) return; + FreeWeightConfig2(config); +} //end of the function FreeWeightConfig +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source) +{ + int newindent, index, def, founddefault; + token_t token; + fuzzyseperator_t *fs, *lastfs, *firstfs; + + founddefault = qfalse; + firstfs = NULL; + lastfs = NULL; + if (!PC_ExpectTokenString(source, "(")) return NULL; + if (!PC_ExpectTokenType(source, TT_NUMBER, TT_INTEGER, &token)) return NULL; + index = token.intvalue; + if (!PC_ExpectTokenString(source, ")")) return NULL; + if (!PC_ExpectTokenString(source, "{")) return NULL; + if (!PC_ExpectAnyToken(source, &token)) return NULL; + do + { + def = !strcmp(token.string, "default"); + if (def || !strcmp(token.string, "case")) + { + fs = (fuzzyseperator_t *) GetClearedMemory(sizeof(fuzzyseperator_t)); + fs->index = index; + if (lastfs) lastfs->next = fs; + else firstfs = fs; + lastfs = fs; + if (def) + { + if (founddefault) + { + SourceError(source, "switch already has a default\n"); + FreeFuzzySeperators_r(firstfs); + return NULL; + } //end if + fs->value = MAX_INVENTORYVALUE; + founddefault = qtrue; + } //end if + else + { + if (!PC_ExpectTokenType(source, TT_NUMBER, TT_INTEGER, &token)) + { + FreeFuzzySeperators_r(firstfs); + return NULL; + } //end if + fs->value = token.intvalue; + } //end else + if (!PC_ExpectTokenString(source, ":") || !PC_ExpectAnyToken(source, &token)) + { + FreeFuzzySeperators_r(firstfs); + return NULL; + } //end if + newindent = qfalse; + if (!strcmp(token.string, "{")) + { + newindent = qtrue; + if (!PC_ExpectAnyToken(source, &token)) + { + FreeFuzzySeperators_r(firstfs); + return NULL; + } //end if + } //end if + if (!strcmp(token.string, "return")) + { + if (!ReadFuzzyWeight(source, fs)) + { + FreeFuzzySeperators_r(firstfs); + return NULL; + } //end if + } //end if + else if (!strcmp(token.string, "switch")) + { + fs->child = ReadFuzzySeperators_r(source); + if (!fs->child) + { + FreeFuzzySeperators_r(firstfs); + return NULL; + } //end if + } //end else if + else + { + SourceError(source, "invalid name %s\n", token.string); + return NULL; + } //end else + if (newindent) + { + if (!PC_ExpectTokenString(source, "}")) + { + FreeFuzzySeperators_r(firstfs); + return NULL; + } //end if + } //end if + } //end if + else + { + FreeFuzzySeperators_r(firstfs); + SourceError(source, "invalid name %s\n", token.string); + return NULL; + } //end else + if (!PC_ExpectAnyToken(source, &token)) + { + FreeFuzzySeperators_r(firstfs); + return NULL; + } //end if + } while(strcmp(token.string, "}")); + // + if (!founddefault) + { + SourceWarning(source, "switch without default\n"); + fs = (fuzzyseperator_t *) GetClearedMemory(sizeof(fuzzyseperator_t)); + fs->index = index; + fs->value = MAX_INVENTORYVALUE; + fs->weight = 0; + fs->next = NULL; + fs->child = NULL; + if (lastfs) lastfs->next = fs; + else firstfs = fs; + lastfs = fs; + } //end if + // + return firstfs; +} //end of the function ReadFuzzySeperators_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +weightconfig_t *ReadWeightConfig(char *filename) +{ + int newindent, avail = 0, n; + token_t token; + source_t *source; + fuzzyseperator_t *fs; + weightconfig_t *config = NULL; +#ifdef DEBUG + int starttime; + + starttime = Sys_MilliSeconds(); +#endif //DEBUG + + if (!LibVarGetValue("bot_reloadcharacters")) + { + avail = -1; + for( n = 0; n < MAX_WEIGHT_FILES; n++ ) + { + config = weightFileList[n]; + if( !config ) + { + if( avail == -1 ) + { + avail = n; + } //end if + continue; + } //end if + if( strcmp( filename, config->filename ) == 0 ) + { + //botimport.Print( PRT_MESSAGE, "retained %s\n", filename ); + return config; + } //end if + } //end for + + if( avail == -1 ) + { + botimport.Print( PRT_ERROR, "weightFileList was full trying to load %s\n", filename ); + return NULL; + } //end if + } //end if + + PC_SetBaseFolder(BOTFILESBASEFOLDER); + source = LoadSourceFile(filename); + if (!source) + { + botimport.Print(PRT_ERROR, "counldn't load %s\n", filename); + return NULL; + } //end if + // + config = (weightconfig_t *) GetClearedMemory(sizeof(weightconfig_t)); + config->numweights = 0; + Q_strncpyz( config->filename, filename, sizeof(config->filename) ); + //parse the item config file + while(PC_ReadToken(source, &token)) + { + if (!strcmp(token.string, "weight")) + { + if (config->numweights >= MAX_WEIGHTS) + { + SourceWarning(source, "too many fuzzy weights\n"); + break; + } //end if + if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) + { + FreeWeightConfig(config); + FreeSource(source); + return NULL; + } //end if + StripDoubleQuotes(token.string); + config->weights[config->numweights].name = (char *) GetClearedMemory(strlen(token.string) + 1); + strcpy(config->weights[config->numweights].name, token.string); + if (!PC_ExpectAnyToken(source, &token)) + { + FreeWeightConfig(config); + FreeSource(source); + return NULL; + } //end if + newindent = qfalse; + if (!strcmp(token.string, "{")) + { + newindent = qtrue; + if (!PC_ExpectAnyToken(source, &token)) + { + FreeWeightConfig(config); + FreeSource(source); + return NULL; + } //end if + } //end if + if (!strcmp(token.string, "switch")) + { + fs = ReadFuzzySeperators_r(source); + if (!fs) + { + FreeWeightConfig(config); + FreeSource(source); + return NULL; + } //end if + config->weights[config->numweights].firstseperator = fs; + } //end if + else if (!strcmp(token.string, "return")) + { + fs = (fuzzyseperator_t *) GetClearedMemory(sizeof(fuzzyseperator_t)); + fs->index = 0; + fs->value = MAX_INVENTORYVALUE; + fs->next = NULL; + fs->child = NULL; + if (!ReadFuzzyWeight(source, fs)) + { + FreeMemory(fs); + FreeWeightConfig(config); + FreeSource(source); + return NULL; + } //end if + config->weights[config->numweights].firstseperator = fs; + } //end else if + else + { + SourceError(source, "invalid name %s\n", token.string); + FreeWeightConfig(config); + FreeSource(source); + return NULL; + } //end else + if (newindent) + { + if (!PC_ExpectTokenString(source, "}")) + { + FreeWeightConfig(config); + FreeSource(source); + return NULL; + } //end if + } //end if + config->numweights++; + } //end if + else + { + SourceError(source, "invalid name %s\n", token.string); + FreeWeightConfig(config); + FreeSource(source); + return NULL; + } //end else + } //end while + //free the source at the end of a pass + FreeSource(source); + //if the file was located in a pak file + botimport.Print(PRT_MESSAGE, "loaded %s\n", filename); +#ifdef DEBUG + if (bot_developer) + { + botimport.Print(PRT_MESSAGE, "weights loaded in %d msec\n", Sys_MilliSeconds() - starttime); + } //end if +#endif //DEBUG + // + if (!LibVarGetValue("bot_reloadcharacters")) + { + weightFileList[avail] = config; + } //end if + // + return config; +} //end of the function ReadWeightConfig +#if 0 +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean WriteFuzzyWeight(FILE *fp, fuzzyseperator_t *fs) +{ + if (fs->type == WT_BALANCE) + { + if (fprintf(fp, " return balance(") < 0) return qfalse; + if (!WriteFloat(fp, fs->weight)) return qfalse; + if (fprintf(fp, ",") < 0) return qfalse; + if (!WriteFloat(fp, fs->minweight)) return qfalse; + if (fprintf(fp, ",") < 0) return qfalse; + if (!WriteFloat(fp, fs->maxweight)) return qfalse; + if (fprintf(fp, ");\n") < 0) return qfalse; + } //end if + else + { + if (fprintf(fp, " return ") < 0) return qfalse; + if (!WriteFloat(fp, fs->weight)) return qfalse; + if (fprintf(fp, ";\n") < 0) return qfalse; + } //end else + return qtrue; +} //end of the function WriteFuzzyWeight +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean WriteFuzzySeperators_r(FILE *fp, fuzzyseperator_t *fs, int indent) +{ + if (!WriteIndent(fp, indent)) return qfalse; + if (fprintf(fp, "switch(%d)\n", fs->index) < 0) return qfalse; + if (!WriteIndent(fp, indent)) return qfalse; + if (fprintf(fp, "{\n") < 0) return qfalse; + indent++; + do + { + if (!WriteIndent(fp, indent)) return qfalse; + if (fs->next) + { + if (fprintf(fp, "case %d:", fs->value) < 0) return qfalse; + } //end if + else + { + if (fprintf(fp, "default:") < 0) return qfalse; + } //end else + if (fs->child) + { + if (fprintf(fp, "\n") < 0) return qfalse; + if (!WriteIndent(fp, indent)) return qfalse; + if (fprintf(fp, "{\n") < 0) return qfalse; + if (!WriteFuzzySeperators_r(fp, fs->child, indent + 1)) return qfalse; + if (!WriteIndent(fp, indent)) return qfalse; + if (fs->next) + { + if (fprintf(fp, "} //end case\n") < 0) return qfalse; + } //end if + else + { + if (fprintf(fp, "} //end default\n") < 0) return qfalse; + } //end else + } //end if + else + { + if (!WriteFuzzyWeight(fp, fs)) return qfalse; + } //end else + fs = fs->next; + } while(fs); + indent--; + if (!WriteIndent(fp, indent)) return qfalse; + if (fprintf(fp, "} //end switch\n") < 0) return qfalse; + return qtrue; +} //end of the function WriteItemFuzzyWeights_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean WriteWeightConfig(char *filename, weightconfig_t *config) +{ + int i; + FILE *fp; + weight_t *ifw; + + fp = fopen(filename, "wb"); + if (!fp) return qfalse; + + for (i = 0; i < config->numweights; i++) + { + ifw = &config->weights[i]; + if (fprintf(fp, "\nweight \"%s\"\n", ifw->name) < 0) return qfalse; + if (fprintf(fp, "{\n") < 0) return qfalse; + if (ifw->firstseperator->index > 0) + { + if (!WriteFuzzySeperators_r(fp, ifw->firstseperator, 1)) return qfalse; + } //end if + else + { + if (!WriteIndent(fp, 1)) return qfalse; + if (!WriteFuzzyWeight(fp, ifw->firstseperator)) return qfalse; + } //end else + if (fprintf(fp, "} //end weight\n") < 0) return qfalse; + } //end for + fclose(fp); + return qtrue; +} //end of the function WriteWeightConfig +#endif +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int FindFuzzyWeight(weightconfig_t *wc, char *name) +{ + int i; + + for (i = 0; i < wc->numweights; i++) + { + if (!strcmp(wc->weights[i].name, name)) + { + return i; + } //end if + } //end if + return -1; +} //end of the function FindFuzzyWeight +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float FuzzyWeight_r(int *inventory, fuzzyseperator_t *fs) +{ + float scale, w1, w2; + + if (inventory[fs->index] < fs->value) + { + if (fs->child) return FuzzyWeight_r(inventory, fs->child); + else return fs->weight; + } //end if + else if (fs->next) + { + if (inventory[fs->index] < fs->next->value) + { + //first weight + if (fs->child) w1 = FuzzyWeight_r(inventory, fs->child); + else w1 = fs->weight; + //second weight + if (fs->next->child) w2 = FuzzyWeight_r(inventory, fs->next->child); + else w2 = fs->next->weight; + //the scale factor + if(fs->next->value == MAX_INVENTORYVALUE) // is fs->next the default case? + return w2; // can't interpolate, return default weight + else + scale = (float) (inventory[fs->index] - fs->value) / (fs->next->value - fs->value); + //scale between the two weights + return (1 - scale) * w1 + scale * w2; + } //end if + return FuzzyWeight_r(inventory, fs->next); + } //end else if + return fs->weight; +} //end of the function FuzzyWeight_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float FuzzyWeightUndecided_r(int *inventory, fuzzyseperator_t *fs) +{ + float scale, w1, w2; + + if (inventory[fs->index] < fs->value) + { + if (fs->child) return FuzzyWeightUndecided_r(inventory, fs->child); + else return fs->minweight + random() * (fs->maxweight - fs->minweight); + } //end if + else if (fs->next) + { + if (inventory[fs->index] < fs->next->value) + { + //first weight + if (fs->child) w1 = FuzzyWeightUndecided_r(inventory, fs->child); + else w1 = fs->minweight + random() * (fs->maxweight - fs->minweight); + //second weight + if (fs->next->child) w2 = FuzzyWeight_r(inventory, fs->next->child); + else w2 = fs->next->minweight + random() * (fs->next->maxweight - fs->next->minweight); + //the scale factor + if(fs->next->value == MAX_INVENTORYVALUE) // is fs->next the default case? + return w2; // can't interpolate, return default weight + else + scale = (float) (inventory[fs->index] - fs->value) / (fs->next->value - fs->value); + //scale between the two weights + return (1 - scale) * w1 + scale * w2; + } //end if + return FuzzyWeightUndecided_r(inventory, fs->next); + } //end else if + return fs->weight; +} //end of the function FuzzyWeightUndecided_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float FuzzyWeight(int *inventory, weightconfig_t *wc, int weightnum) +{ +#ifdef EVALUATERECURSIVELY + return FuzzyWeight_r(inventory, wc->weights[weightnum].firstseperator); +#else + fuzzyseperator_t *s; + + s = wc->weights[weightnum].firstseperator; + if (!s) return 0; + while(1) + { + if (inventory[s->index] < s->value) + { + if (s->child) s = s->child; + else return s->weight; + } //end if + else + { + if (s->next) s = s->next; + else return s->weight; + } //end else + } //end if + return 0; +#endif +} //end of the function FuzzyWeight +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float FuzzyWeightUndecided(int *inventory, weightconfig_t *wc, int weightnum) +{ +#ifdef EVALUATERECURSIVELY + return FuzzyWeightUndecided_r(inventory, wc->weights[weightnum].firstseperator); +#else + fuzzyseperator_t *s; + + s = wc->weights[weightnum].firstseperator; + if (!s) return 0; + while(1) + { + if (inventory[s->index] < s->value) + { + if (s->child) s = s->child; + else return s->minweight + random() * (s->maxweight - s->minweight); + } //end if + else + { + if (s->next) s = s->next; + else return s->minweight + random() * (s->maxweight - s->minweight); + } //end else + } //end if + return 0; +#endif +} //end of the function FuzzyWeightUndecided +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EvolveFuzzySeperator_r(fuzzyseperator_t *fs) +{ + if (fs->child) + { + EvolveFuzzySeperator_r(fs->child); + } //end if + else if (fs->type == WT_BALANCE) + { + //every once in a while an evolution leap occurs, mutation + if (random() < 0.01) fs->weight += crandom() * (fs->maxweight - fs->minweight); + else fs->weight += crandom() * (fs->maxweight - fs->minweight) * 0.5; + //modify bounds if necesary because of mutation + if (fs->weight < fs->minweight) fs->minweight = fs->weight; + else if (fs->weight > fs->maxweight) fs->maxweight = fs->weight; + } //end else if + if (fs->next) EvolveFuzzySeperator_r(fs->next); +} //end of the function EvolveFuzzySeperator_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EvolveWeightConfig(weightconfig_t *config) +{ + int i; + + for (i = 0; i < config->numweights; i++) + { + EvolveFuzzySeperator_r(config->weights[i].firstseperator); + } //end for +} //end of the function EvolveWeightConfig +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ScaleFuzzySeperator_r(fuzzyseperator_t *fs, float scale) +{ + if (fs->child) + { + ScaleFuzzySeperator_r(fs->child, scale); + } //end if + else if (fs->type == WT_BALANCE) + { + // + fs->weight = (float) (fs->maxweight + fs->minweight) * scale; + //get the weight between bounds + if (fs->weight < fs->minweight) fs->weight = fs->minweight; + else if (fs->weight > fs->maxweight) fs->weight = fs->maxweight; + } //end else if + if (fs->next) ScaleFuzzySeperator_r(fs->next, scale); +} //end of the function ScaleFuzzySeperator_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ScaleWeight(weightconfig_t *config, char *name, float scale) +{ + int i; + + if (scale < 0) scale = 0; + else if (scale > 1) scale = 1; + for (i = 0; i < config->numweights; i++) + { + if (!strcmp(name, config->weights[i].name)) + { + ScaleFuzzySeperator_r(config->weights[i].firstseperator, scale); + break; + } //end if + } //end for +} //end of the function ScaleWeight +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ScaleFuzzySeperatorBalanceRange_r(fuzzyseperator_t *fs, float scale) +{ + if (fs->child) + { + ScaleFuzzySeperatorBalanceRange_r(fs->child, scale); + } //end if + else if (fs->type == WT_BALANCE) + { + float mid = (fs->minweight + fs->maxweight) * 0.5; + //get the weight between bounds + fs->maxweight = mid + (fs->maxweight - mid) * scale; + fs->minweight = mid + (fs->minweight - mid) * scale; + if (fs->maxweight < fs->minweight) + { + fs->maxweight = fs->minweight; + } //end if + } //end else if + if (fs->next) ScaleFuzzySeperatorBalanceRange_r(fs->next, scale); +} //end of the function ScaleFuzzySeperatorBalanceRange_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ScaleFuzzyBalanceRange(weightconfig_t *config, float scale) +{ + int i; + + if (scale < 0) scale = 0; + else if (scale > 100) scale = 100; + for (i = 0; i < config->numweights; i++) + { + ScaleFuzzySeperatorBalanceRange_r(config->weights[i].firstseperator, scale); + } //end for +} //end of the function ScaleFuzzyBalanceRange +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int InterbreedFuzzySeperator_r(fuzzyseperator_t *fs1, fuzzyseperator_t *fs2, + fuzzyseperator_t *fsout) +{ + if (fs1->child) + { + if (!fs2->child || !fsout->child) + { + botimport.Print(PRT_ERROR, "cannot interbreed weight configs, unequal child\n"); + return qfalse; + } //end if + if (!InterbreedFuzzySeperator_r(fs2->child, fs2->child, fsout->child)) + { + return qfalse; + } //end if + } //end if + else if (fs1->type == WT_BALANCE) + { + if (fs2->type != WT_BALANCE || fsout->type != WT_BALANCE) + { + botimport.Print(PRT_ERROR, "cannot interbreed weight configs, unequal balance\n"); + return qfalse; + } //end if + fsout->weight = (fs1->weight + fs2->weight) / 2; + if (fsout->weight > fsout->maxweight) fsout->maxweight = fsout->weight; + if (fsout->weight > fsout->minweight) fsout->minweight = fsout->weight; + } //end else if + if (fs1->next) + { + if (!fs2->next || !fsout->next) + { + botimport.Print(PRT_ERROR, "cannot interbreed weight configs, unequal next\n"); + return qfalse; + } //end if + if (!InterbreedFuzzySeperator_r(fs1->next, fs2->next, fsout->next)) + { + return qfalse; + } //end if + } //end if + return qtrue; +} //end of the function InterbreedFuzzySeperator_r +//=========================================================================== +// config1 and config2 are interbreeded and stored in configout +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void InterbreedWeightConfigs(weightconfig_t *config1, weightconfig_t *config2, + weightconfig_t *configout) +{ + int i; + + if (config1->numweights != config2->numweights || + config1->numweights != configout->numweights) + { + botimport.Print(PRT_ERROR, "cannot interbreed weight configs, unequal numweights\n"); + return; + } //end if + for (i = 0; i < config1->numweights; i++) + { + InterbreedFuzzySeperator_r(config1->weights[i].firstseperator, + config2->weights[i].firstseperator, + configout->weights[i].firstseperator); + } //end for +} //end of the function InterbreedWeightConfigs +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotShutdownWeights(void) +{ + int i; + + for( i = 0; i < MAX_WEIGHT_FILES; i++ ) + { + if (weightFileList[i]) + { + FreeWeightConfig2(weightFileList[i]); + weightFileList[i] = NULL; + } //end if + } //end for +} //end of the function BotShutdownWeights diff --git a/code/botlib/be_ai_weight.h b/code/botlib/be_ai_weight.h new file mode 100644 index 00000000..fb1c8853 --- /dev/null +++ b/code/botlib/be_ai_weight.h @@ -0,0 +1,83 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_ai_weight.h + * + * desc: fuzzy weights + * + * $Archive: /source/code/botlib/be_ai_weight.h $ + * + *****************************************************************************/ + +#define WT_BALANCE 1 +#define MAX_WEIGHTS 128 + +//fuzzy seperator +typedef struct fuzzyseperator_s +{ + int index; + int value; + int type; + float weight; + float minweight; + float maxweight; + struct fuzzyseperator_s *child; + struct fuzzyseperator_s *next; +} fuzzyseperator_t; + +//fuzzy weight +typedef struct weight_s +{ + char *name; + struct fuzzyseperator_s *firstseperator; +} weight_t; + +//weight configuration +typedef struct weightconfig_s +{ + int numweights; + weight_t weights[MAX_WEIGHTS]; + char filename[MAX_QPATH]; +} weightconfig_t; + +//reads a weight configuration +weightconfig_t *ReadWeightConfig(char *filename); +//free a weight configuration +void FreeWeightConfig(weightconfig_t *config); +//writes a weight configuration, returns true if successfull +qboolean WriteWeightConfig(char *filename, weightconfig_t *config); +//find the fuzzy weight with the given name +int FindFuzzyWeight(weightconfig_t *wc, char *name); +//returns the fuzzy weight for the given inventory and weight +float FuzzyWeight(int *inventory, weightconfig_t *wc, int weightnum); +float FuzzyWeightUndecided(int *inventory, weightconfig_t *wc, int weightnum); +//scales the weight with the given name +void ScaleWeight(weightconfig_t *config, char *name, float scale); +//scale the balance range +void ScaleBalanceRange(weightconfig_t *config, float scale); +//evolves the weight configuration +void EvolveWeightConfig(weightconfig_t *config); +//interbreed the weight configurations and stores the interbreeded one in configout +void InterbreedWeightConfigs(weightconfig_t *config1, weightconfig_t *config2, weightconfig_t *configout); +//frees cached weight configurations +void BotShutdownWeights(void); diff --git a/code/botlib/be_ea.c b/code/botlib/be_ea.c new file mode 100644 index 00000000..3e284197 --- /dev/null +++ b/code/botlib/be_ea.c @@ -0,0 +1,508 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_ea.c + * + * desc: elementary actions + * + * $Archive: /MissionPack/code/botlib/be_ea.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_memory.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "botlib.h" +#include "be_interface.h" + +#define MAX_USERMOVE 400 +#define MAX_COMMANDARGUMENTS 10 +#define ACTION_JUMPEDLASTFRAME 128 + +bot_input_t *botinputs; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Say(int client, char *str) +{ + botimport.BotClientCommand(client, va("say %s", str) ); +} //end of the function EA_Say +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_SayTeam(int client, char *str) +{ + botimport.BotClientCommand(client, va("say_team %s", str)); +} //end of the function EA_SayTeam +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Tell(int client, int clientto, char *str) +{ + botimport.BotClientCommand(client, va("tell %d, %s", clientto, str)); +} //end of the function EA_SayTeam +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_UseItem(int client, char *it) +{ + botimport.BotClientCommand(client, va("use %s", it)); +} //end of the function EA_UseItem +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_DropItem(int client, char *it) +{ + botimport.BotClientCommand(client, va("drop %s", it)); +} //end of the function EA_DropItem +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_UseInv(int client, char *inv) +{ + botimport.BotClientCommand(client, va("invuse %s", inv)); +} //end of the function EA_UseInv +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_DropInv(int client, char *inv) +{ + botimport.BotClientCommand(client, va("invdrop %s", inv)); +} //end of the function EA_DropInv +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Gesture(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_GESTURE; +} //end of the function EA_Gesture +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Command(int client, char *command) +{ + botimport.BotClientCommand(client, command); +} //end of the function EA_Command +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_SelectWeapon(int client, int weapon) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->weapon = weapon; +} //end of the function EA_SelectWeapon +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Attack(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_ATTACK; +} //end of the function EA_Attack +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Talk(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_TALK; +} //end of the function EA_Talk +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Use(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_USE; +} //end of the function EA_Use +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Respawn(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_RESPAWN; +} //end of the function EA_Respawn +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Jump(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + if (bi->actionflags & ACTION_JUMPEDLASTFRAME) + { + bi->actionflags &= ~ACTION_JUMP; + } //end if + else + { + bi->actionflags |= ACTION_JUMP; + } //end if +} //end of the function EA_Jump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_DelayedJump(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + if (bi->actionflags & ACTION_JUMPEDLASTFRAME) + { + bi->actionflags &= ~ACTION_DELAYEDJUMP; + } //end if + else + { + bi->actionflags |= ACTION_DELAYEDJUMP; + } //end if +} //end of the function EA_DelayedJump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Crouch(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_CROUCH; +} //end of the function EA_Crouch +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Walk(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_WALK; +} //end of the function EA_Walk +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Action(int client, int action) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= action; +} //end of function EA_Action +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_MoveUp(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_MOVEUP; +} //end of the function EA_MoveUp +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_MoveDown(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_MOVEDOWN; +} //end of the function EA_MoveDown +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_MoveForward(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_MOVEFORWARD; +} //end of the function EA_MoveForward +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_MoveBack(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_MOVEBACK; +} //end of the function EA_MoveBack +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_MoveLeft(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_MOVELEFT; +} //end of the function EA_MoveLeft +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_MoveRight(int client) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + bi->actionflags |= ACTION_MOVERIGHT; +} //end of the function EA_MoveRight +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Move(int client, vec3_t dir, float speed) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + VectorCopy(dir, bi->dir); + //cap speed + if (speed > MAX_USERMOVE) speed = MAX_USERMOVE; + else if (speed < -MAX_USERMOVE) speed = -MAX_USERMOVE; + bi->speed = speed; +} //end of the function EA_Move +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_View(int client, vec3_t viewangles) +{ + bot_input_t *bi; + + bi = &botinputs[client]; + + VectorCopy(viewangles, bi->viewangles); +} //end of the function EA_View +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_EndRegular(int client, float thinktime) +{ +/* + bot_input_t *bi; + int jumped = qfalse; + + bi = &botinputs[client]; + + bi->actionflags &= ~ACTION_JUMPEDLASTFRAME; + + bi->thinktime = thinktime; + botimport.BotInput(client, bi); + + bi->thinktime = 0; + VectorClear(bi->dir); + bi->speed = 0; + jumped = bi->actionflags & ACTION_JUMP; + bi->actionflags = 0; + if (jumped) bi->actionflags |= ACTION_JUMPEDLASTFRAME; +*/ +} //end of the function EA_EndRegular +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_GetInput(int client, float thinktime, bot_input_t *input) +{ + bot_input_t *bi; +// int jumped = qfalse; + + bi = &botinputs[client]; + +// bi->actionflags &= ~ACTION_JUMPEDLASTFRAME; + + bi->thinktime = thinktime; + Com_Memcpy(input, bi, sizeof(bot_input_t)); + + /* + bi->thinktime = 0; + VectorClear(bi->dir); + bi->speed = 0; + jumped = bi->actionflags & ACTION_JUMP; + bi->actionflags = 0; + if (jumped) bi->actionflags |= ACTION_JUMPEDLASTFRAME; + */ +} //end of the function EA_GetInput +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_ResetInput(int client) +{ + bot_input_t *bi; + int jumped = qfalse; + + bi = &botinputs[client]; + bi->actionflags &= ~ACTION_JUMPEDLASTFRAME; + + bi->thinktime = 0; + VectorClear(bi->dir); + bi->speed = 0; + jumped = bi->actionflags & ACTION_JUMP; + bi->actionflags = 0; + if (jumped) bi->actionflags |= ACTION_JUMPEDLASTFRAME; +} //end of the function EA_ResetInput +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int EA_Setup(void) +{ + //initialize the bot inputs + botinputs = (bot_input_t *) GetClearedHunkMemory( + botlibglobals.maxclients * sizeof(bot_input_t)); + return BLERR_NOERROR; +} //end of the function EA_Setup +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void EA_Shutdown(void) +{ + FreeMemory(botinputs); + botinputs = NULL; +} //end of the function EA_Shutdown diff --git a/code/botlib/be_ea.h b/code/botlib/be_ea.h new file mode 100644 index 00000000..4fb37046 --- /dev/null +++ b/code/botlib/be_ea.h @@ -0,0 +1,66 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_ea.h + * + * desc: elementary actions + * + * $Archive: /source/code/botlib/be_ea.h $ + * + *****************************************************************************/ + +//ClientCommand elementary actions +void EA_Say(int client, char *str); +void EA_SayTeam(int client, char *str); +void EA_Command(int client, char *command ); + +void EA_Action(int client, int action); +void EA_Crouch(int client); +void EA_Walk(int client); +void EA_MoveUp(int client); +void EA_MoveDown(int client); +void EA_MoveForward(int client); +void EA_MoveBack(int client); +void EA_MoveLeft(int client); +void EA_MoveRight(int client); +void EA_Attack(int client); +void EA_Respawn(int client); +void EA_Talk(int client); +void EA_Gesture(int client); +void EA_Use(int client); + +//regular elementary actions +void EA_SelectWeapon(int client, int weapon); +void EA_Jump(int client); +void EA_DelayedJump(int client); +void EA_Move(int client, vec3_t dir, float speed); +void EA_View(int client, vec3_t viewangles); + +//send regular input to the server +void EA_EndRegular(int client, float thinktime); +void EA_GetInput(int client, float thinktime, bot_input_t *input); +void EA_ResetInput(int client); +//setup and shutdown routines +int EA_Setup(void); +void EA_Shutdown(void); diff --git a/code/botlib/be_interface.c b/code/botlib/be_interface.c new file mode 100644 index 00000000..5418635b --- /dev/null +++ b/code/botlib/be_interface.c @@ -0,0 +1,895 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_interface.c + * + * desc: bot library interface + * + * $Archive: /MissionPack/code/botlib/be_interface.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_memory.h" +#include "l_log.h" +#include "l_libvar.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "aasfile.h" +#include "botlib.h" +#include "be_aas.h" +#include "be_aas_funcs.h" +#include "be_aas_def.h" +#include "be_interface.h" + +#include "be_ea.h" +#include "be_ai_weight.h" +#include "be_ai_goal.h" +#include "be_ai_move.h" +#include "be_ai_weap.h" +#include "be_ai_chat.h" +#include "be_ai_char.h" +#include "be_ai_gen.h" + +//library globals in a structure +botlib_globals_t botlibglobals; + +botlib_export_t be_botlib_export; +botlib_import_t botimport; +// +int bot_developer; +//qtrue if the library is setup +int botlibsetup = qfalse; + +//=========================================================================== +// +// several functions used by the exported functions +// +//=========================================================================== + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Sys_MilliSeconds(void) +{ + return clock() * 1000 / CLOCKS_PER_SEC; +} //end of the function Sys_MilliSeconds +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean ValidClientNumber(int num, char *str) +{ + if (num < 0 || num > botlibglobals.maxclients) + { + //weird: the disabled stuff results in a crash + botimport.Print(PRT_ERROR, "%s: invalid client number %d, [0, %d]\n", + str, num, botlibglobals.maxclients); + return qfalse; + } //end if + return qtrue; +} //end of the function BotValidateClientNumber +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean ValidEntityNumber(int num, char *str) +{ + if (num < 0 || num > botlibglobals.maxentities) + { + botimport.Print(PRT_ERROR, "%s: invalid entity number %d, [0, %d]\n", + str, num, botlibglobals.maxentities); + return qfalse; + } //end if + return qtrue; +} //end of the function BotValidateClientNumber +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean BotLibSetup(char *str) +{ + if (!botlibglobals.botlibsetup) + { + botimport.Print(PRT_ERROR, "%s: bot library used before being setup\n", str); + return qfalse; + } //end if + return qtrue; +} //end of the function BotLibSetup + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Export_BotLibSetup(void) +{ + int errnum; + char logfilename[MAX_OSPATH]; + char *homedir, *gamedir; + + bot_developer = LibVarGetValue("bot_developer"); + memset( &botlibglobals, 0, sizeof(botlibglobals) ); + //initialize byte swapping (litte endian etc.) +// Swap_Init(); + homedir = LibVarGetString("homedir"); + gamedir = LibVarGetString("gamedir"); + if (homedir[0]) { + if (gamedir[0]) { + Com_sprintf(logfilename, sizeof(logfilename), "%s%c%s%cbotlib.log", homedir, PATH_SEP, gamedir, PATH_SEP); + } + else { + Com_sprintf(logfilename, sizeof(logfilename), "%s%c" BASEGAME "%cbotlib.log", homedir, PATH_SEP, PATH_SEP); + } + } else { + Com_sprintf(logfilename, sizeof(logfilename), "botlib.log"); + } + Log_Open(logfilename); + // + botimport.Print(PRT_MESSAGE, "------- BotLib Initialization -------\n"); + // + botlibglobals.maxclients = (int) LibVarValue("maxclients", "128"); + botlibglobals.maxentities = (int) LibVarValue("maxentities", "1024"); + + errnum = AAS_Setup(); //be_aas_main.c + if (errnum != BLERR_NOERROR) return errnum; + errnum = EA_Setup(); //be_ea.c + if (errnum != BLERR_NOERROR) return errnum; + errnum = BotSetupWeaponAI(); //be_ai_weap.c + if (errnum != BLERR_NOERROR)return errnum; + errnum = BotSetupGoalAI(); //be_ai_goal.c + if (errnum != BLERR_NOERROR) return errnum; + errnum = BotSetupChatAI(); //be_ai_chat.c + if (errnum != BLERR_NOERROR) return errnum; + errnum = BotSetupMoveAI(); //be_ai_move.c + if (errnum != BLERR_NOERROR) return errnum; + + botlibsetup = qtrue; + botlibglobals.botlibsetup = qtrue; + + return BLERR_NOERROR; +} //end of the function Export_BotLibSetup +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Export_BotLibShutdown(void) +{ + if (!BotLibSetup("BotLibShutdown")) return BLERR_LIBRARYNOTSETUP; +#ifndef DEMO + //DumpFileCRCs(); +#endif //DEMO + // + BotShutdownChatAI(); //be_ai_chat.c + BotShutdownMoveAI(); //be_ai_move.c + BotShutdownGoalAI(); //be_ai_goal.c + BotShutdownWeaponAI(); //be_ai_weap.c + BotShutdownWeights(); //be_ai_weight.c + BotShutdownCharacters(); //be_ai_char.c + //shud down aas + AAS_Shutdown(); + //shut down bot elemantary actions + EA_Shutdown(); + //free all libvars + LibVarDeAllocAll(); + //remove all global defines from the pre compiler + PC_RemoveAllGlobalDefines(); + + //dump all allocated memory +// DumpMemory(); +#ifdef DEBUG + PrintMemoryLabels(); +#endif + //shut down library log file + Log_Shutdown(); + // + botlibsetup = qfalse; + botlibglobals.botlibsetup = qfalse; + // print any files still open + PC_CheckOpenSourceHandles(); + // + return BLERR_NOERROR; +} //end of the function Export_BotLibShutdown +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Export_BotLibVarSet(char *var_name, char *value) +{ + LibVarSet(var_name, value); + return BLERR_NOERROR; +} //end of the function Export_BotLibVarSet +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Export_BotLibVarGet(char *var_name, char *value, int size) +{ + char *varvalue; + + varvalue = LibVarGetString(var_name); + strncpy(value, varvalue, size-1); + value[size-1] = '\0'; + return BLERR_NOERROR; +} //end of the function Export_BotLibVarGet +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Export_BotLibStartFrame(float time) +{ + if (!BotLibSetup("BotStartFrame")) return BLERR_LIBRARYNOTSETUP; + return AAS_StartFrame(time); +} //end of the function Export_BotLibStartFrame +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Export_BotLibLoadMap(const char *mapname) +{ +#ifdef DEBUG + int starttime = Sys_MilliSeconds(); +#endif + int errnum; + + if (!BotLibSetup("BotLoadMap")) return BLERR_LIBRARYNOTSETUP; + // + botimport.Print(PRT_MESSAGE, "------------ Map Loading ------------\n"); + //startup AAS for the current map, model and sound index + errnum = AAS_LoadMap(mapname); + if (errnum != BLERR_NOERROR) return errnum; + //initialize the items in the level + BotInitLevelItems(); //be_ai_goal.h + BotSetBrushModelTypes(); //be_ai_move.h + // + botimport.Print(PRT_MESSAGE, "-------------------------------------\n"); +#ifdef DEBUG + botimport.Print(PRT_MESSAGE, "map loaded in %d msec\n", Sys_MilliSeconds() - starttime); +#endif + // + return BLERR_NOERROR; +} //end of the function Export_BotLibLoadMap +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Export_BotLibUpdateEntity(int ent, bot_entitystate_t *state) +{ + if (!BotLibSetup("BotUpdateEntity")) return BLERR_LIBRARYNOTSETUP; + if (!ValidEntityNumber(ent, "BotUpdateEntity")) return BLERR_INVALIDENTITYNUMBER; + + return AAS_UpdateEntity(ent, state); +} //end of the function Export_BotLibUpdateEntity +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_TestMovementPrediction(int entnum, vec3_t origin, vec3_t dir); +void ElevatorBottomCenter(aas_reachability_t *reach, vec3_t bottomcenter); +int BotGetReachabilityToGoal(vec3_t origin, int areanum, + int lastgoalareanum, int lastareanum, + int *avoidreach, float *avoidreachtimes, int *avoidreachtries, + bot_goal_t *goal, int travelflags, int movetravelflags, + struct bot_avoidspot_s *avoidspots, int numavoidspots, int *flags); + +int AAS_PointLight(vec3_t origin, int *red, int *green, int *blue); + +int AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas); + +int AAS_Reachability_WeaponJump(int area1num, int area2num); + +int BotFuzzyPointReachabilityArea(vec3_t origin); + +float BotGapDistance(vec3_t origin, vec3_t hordir, int entnum); + +void AAS_FloodAreas(vec3_t origin); + +int BotExportTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3) +{ + +// return AAS_PointLight(parm2, NULL, NULL, NULL); + +#ifdef DEBUG + static int area = -1; + static int line[2]; + int newarea, i, highlightarea, flood; +// int reachnum; + vec3_t eye, forward, right, end, origin; +// vec3_t bottomcenter; +// aas_trace_t trace; +// aas_face_t *face; +// aas_entity_t *ent; +// bsp_trace_t bsptrace; +// aas_reachability_t reach; +// bot_goal_t goal; + + // clock_t start_time, end_time; + vec3_t mins = {-16, -16, -24}; + vec3_t maxs = {16, 16, 32}; + +// int areas[10], numareas; + + + //return 0; + + if (!aasworld.loaded) return 0; + + /* + if (parm0 & 1) + { + AAS_ClearShownPolygons(); + AAS_FloodAreas(parm2); + } //end if + return 0; + */ + for (i = 0; i < 2; i++) if (!line[i]) line[i] = botimport.DebugLineCreate(); + +// AAS_ClearShownDebugLines(); + + //if (AAS_AgainstLadder(parm2)) botimport.Print(PRT_MESSAGE, "against ladder\n"); + //BotOnGround(parm2, PRESENCE_NORMAL, 1, &newarea, &newarea); + //botimport.Print(PRT_MESSAGE, "%f %f %f\n", parm2[0], parm2[1], parm2[2]); + //* + highlightarea = LibVarGetValue("bot_highlightarea"); + if (highlightarea > 0) + { + newarea = highlightarea; + } //end if + else + { + VectorCopy(parm2, origin); + origin[2] += 0.5; + //newarea = AAS_PointAreaNum(origin); + newarea = BotFuzzyPointReachabilityArea(origin); + } //end else + + botimport.Print(PRT_MESSAGE, "\rtravel time to goal (%d) = %d ", botlibglobals.goalareanum, + AAS_AreaTravelTimeToGoalArea(newarea, origin, botlibglobals.goalareanum, TFL_DEFAULT)); + //newarea = BotReachabilityArea(origin, qtrue); + if (newarea != area) + { + botimport.Print(PRT_MESSAGE, "origin = %f, %f, %f\n", origin[0], origin[1], origin[2]); + area = newarea; + botimport.Print(PRT_MESSAGE, "new area %d, cluster %d, presence type %d\n", + area, AAS_AreaCluster(area), AAS_PointPresenceType(origin)); + botimport.Print(PRT_MESSAGE, "area contents: "); + if (aasworld.areasettings[area].contents & AREACONTENTS_WATER) + { + botimport.Print(PRT_MESSAGE, "water &"); + } //end if + if (aasworld.areasettings[area].contents & AREACONTENTS_LAVA) + { + botimport.Print(PRT_MESSAGE, "lava &"); + } //end if + if (aasworld.areasettings[area].contents & AREACONTENTS_SLIME) + { + botimport.Print(PRT_MESSAGE, "slime &"); + } //end if + if (aasworld.areasettings[area].contents & AREACONTENTS_JUMPPAD) + { + botimport.Print(PRT_MESSAGE, "jump pad &"); + } //end if + if (aasworld.areasettings[area].contents & AREACONTENTS_CLUSTERPORTAL) + { + botimport.Print(PRT_MESSAGE, "cluster portal &"); + } //end if + if (aasworld.areasettings[area].contents & AREACONTENTS_VIEWPORTAL) + { + botimport.Print(PRT_MESSAGE, "view portal &"); + } //end if + if (aasworld.areasettings[area].contents & AREACONTENTS_DONOTENTER) + { + botimport.Print(PRT_MESSAGE, "do not enter &"); + } //end if + if (aasworld.areasettings[area].contents & AREACONTENTS_MOVER) + { + botimport.Print(PRT_MESSAGE, "mover &"); + } //end if + if (!aasworld.areasettings[area].contents) + { + botimport.Print(PRT_MESSAGE, "empty"); + } //end if + botimport.Print(PRT_MESSAGE, "\n"); + botimport.Print(PRT_MESSAGE, "travel time to goal (%d) = %d\n", botlibglobals.goalareanum, + AAS_AreaTravelTimeToGoalArea(newarea, origin, botlibglobals.goalareanum, TFL_DEFAULT|TFL_ROCKETJUMP)); + /* + VectorCopy(origin, end); + end[2] += 5; + numareas = AAS_TraceAreas(origin, end, areas, NULL, 10); + AAS_TraceClientBBox(origin, end, PRESENCE_CROUCH, -1); + botimport.Print(PRT_MESSAGE, "num areas = %d, area = %d\n", numareas, areas[0]); + */ + /* + botlibglobals.goalareanum = newarea; + VectorCopy(parm2, botlibglobals.goalorigin); + botimport.Print(PRT_MESSAGE, "new goal %2.1f %2.1f %2.1f area %d\n", + origin[0], origin[1], origin[2], newarea); + */ + } //end if + //* + flood = LibVarGetValue("bot_flood"); + if (parm0 & 1) + { + if (flood) + { + AAS_ClearShownPolygons(); + AAS_ClearShownDebugLines(); + AAS_FloodAreas(parm2); + } + else + { + botlibglobals.goalareanum = newarea; + VectorCopy(parm2, botlibglobals.goalorigin); + botimport.Print(PRT_MESSAGE, "new goal %2.1f %2.1f %2.1f area %d\n", + origin[0], origin[1], origin[2], newarea); + } + } //end if*/ + if (flood) + return 0; +// if (parm0 & BUTTON_USE) +// { +// botlibglobals.runai = !botlibglobals.runai; +// if (botlibglobals.runai) botimport.Print(PRT_MESSAGE, "started AI\n"); +// else botimport.Print(PRT_MESSAGE, "stopped AI\n"); + //* / + /* + goal.areanum = botlibglobals.goalareanum; + reachnum = BotGetReachabilityToGoal(parm2, newarea, 1, + ms.avoidreach, ms.avoidreachtimes, + &goal, TFL_DEFAULT); + if (!reachnum) + { + botimport.Print(PRT_MESSAGE, "goal not reachable\n"); + } //end if + else + { + AAS_ReachabilityFromNum(reachnum, &reach); + AAS_ClearShownDebugLines(); + AAS_ShowArea(area, qtrue); + AAS_ShowArea(reach.areanum, qtrue); + AAS_DrawCross(reach.start, 6, LINECOLOR_BLUE); + AAS_DrawCross(reach.end, 6, LINECOLOR_RED); + // + if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR) + { + ElevatorBottomCenter(&reach, bottomcenter); + AAS_DrawCross(bottomcenter, 10, LINECOLOR_GREEN); + } //end if + } //end else*/ +// botimport.Print(PRT_MESSAGE, "travel time to goal = %d\n", +// AAS_AreaTravelTimeToGoalArea(area, origin, botlibglobals.goalareanum, TFL_DEFAULT)); +// botimport.Print(PRT_MESSAGE, "test rj from 703 to 716\n"); +// AAS_Reachability_WeaponJump(703, 716); +// } //end if*/ + +/* face = AAS_AreaGroundFace(newarea, parm2); + if (face) + { + AAS_ShowFace(face - aasworld.faces); + } //end if*/ + /* + AAS_ClearShownDebugLines(); + AAS_ShowArea(newarea, parm0 & BUTTON_USE); + AAS_ShowReachableAreas(area); + */ + AAS_ClearShownPolygons(); + AAS_ClearShownDebugLines(); + AAS_ShowAreaPolygons(newarea, 1, parm0 & 4); + if (parm0 & 2) AAS_ShowReachableAreas(area); + else + { + static int lastgoalareanum, lastareanum; + static int avoidreach[MAX_AVOIDREACH]; + static float avoidreachtimes[MAX_AVOIDREACH]; + static int avoidreachtries[MAX_AVOIDREACH]; + int reachnum, resultFlags; + bot_goal_t goal; + aas_reachability_t reach; + + /* + goal.areanum = botlibglobals.goalareanum; + VectorCopy(botlibglobals.goalorigin, goal.origin); + reachnum = BotGetReachabilityToGoal(origin, newarea, + lastgoalareanum, lastareanum, + avoidreach, avoidreachtimes, avoidreachtries, + &goal, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, + NULL, 0, &resultFlags); + AAS_ReachabilityFromNum(reachnum, &reach); + AAS_ShowReachability(&reach); + */ + int curarea; + vec3_t curorigin; + + goal.areanum = botlibglobals.goalareanum; + VectorCopy(botlibglobals.goalorigin, goal.origin); + VectorCopy(origin, curorigin); + curarea = newarea; + for ( i = 0; i < 100; i++ ) { + if ( curarea == goal.areanum ) { + break; + } + reachnum = BotGetReachabilityToGoal(curorigin, curarea, + lastgoalareanum, lastareanum, + avoidreach, avoidreachtimes, avoidreachtries, + &goal, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, + NULL, 0, &resultFlags); + AAS_ReachabilityFromNum(reachnum, &reach); + AAS_ShowReachability(&reach); + VectorCopy(reach.end, origin); + lastareanum = curarea; + curarea = reach.areanum; + } + } //end else + VectorClear(forward); + //BotGapDistance(origin, forward, 0); + /* + if (parm0 & BUTTON_USE) + { + botimport.Print(PRT_MESSAGE, "test rj from 703 to 716\n"); + AAS_Reachability_WeaponJump(703, 716); + } //end if*/ + + AngleVectors(parm3, forward, right, NULL); + //get the eye 16 units to the right of the origin + VectorMA(parm2, 8, right, eye); + //get the eye 24 units up + eye[2] += 24; + //get the end point for the line to be traced + VectorMA(eye, 800, forward, end); + +// AAS_TestMovementPrediction(1, parm2, forward); +/* + //trace the line to find the hit point + trace = AAS_TraceClientBBox(eye, end, PRESENCE_NORMAL, 1); + if (!line[0]) line[0] = botimport.DebugLineCreate(); + botimport.DebugLineShow(line[0], eye, trace.endpos, LINECOLOR_BLUE); + // + AAS_ClearShownDebugLines(); + if (trace.ent) + { + ent = &aasworld.entities[trace.ent]; + AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs); + } //end if +*/ + +/* + start_time = clock(); + for (i = 0; i < 2000; i++) + { + AAS_Trace2(eye, mins, maxs, end, 1, MASK_PLAYERSOLID); +// AAS_TraceClientBBox(eye, end, PRESENCE_NORMAL, 1); + } //end for + end_time = clock(); + botimport.Print(PRT_MESSAGE, "me %lu clocks, %lu CLOCKS_PER_SEC\n", end_time - start_time, CLOCKS_PER_SEC); + start_time = clock(); + for (i = 0; i < 2000; i++) + { + AAS_Trace(eye, mins, maxs, end, 1, MASK_PLAYERSOLID); + } //end for + end_time = clock(); + botimport.Print(PRT_MESSAGE, "id %lu clocks, %lu CLOCKS_PER_SEC\n", end_time - start_time, CLOCKS_PER_SEC); +*/ + + // TTimo: nested comments are BAD for gcc -Werror, use #if 0 instead.. +#if 0 + AAS_ClearShownDebugLines(); + //bsptrace = AAS_Trace(eye, NULL, NULL, end, 1, MASK_PLAYERSOLID); + bsptrace = AAS_Trace(eye, mins, maxs, end, 1, MASK_PLAYERSOLID); + if (!line[0]) line[0] = botimport.DebugLineCreate(); + botimport.DebugLineShow(line[0], eye, bsptrace.endpos, LINECOLOR_YELLOW); + if (bsptrace.fraction < 1.0) + { + face = AAS_TraceEndFace(&trace); + if (face) + { + AAS_ShowFace(face - aasworld.faces); + } //end if + + AAS_DrawPlaneCross(bsptrace.endpos, + bsptrace.plane.normal, + bsptrace.plane.dist + bsptrace.exp_dist, + bsptrace.plane.type, LINECOLOR_GREEN); + if (trace.ent) + { + ent = &aasworld.entities[trace.ent]; + AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs); + } //end if + } //end if + //bsptrace = AAS_Trace2(eye, NULL, NULL, end, 1, MASK_PLAYERSOLID); + bsptrace = AAS_Trace2(eye, mins, maxs, end, 1, MASK_PLAYERSOLID); + botimport.DebugLineShow(line[1], eye, bsptrace.endpos, LINECOLOR_BLUE); + if (bsptrace.fraction < 1.0) + { + AAS_DrawPlaneCross(bsptrace.endpos, + bsptrace.plane.normal, + bsptrace.plane.dist,// + bsptrace.exp_dist, + bsptrace.plane.type, LINECOLOR_RED); + if (bsptrace.ent) + { + ent = &aasworld.entities[bsptrace.ent]; + AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs); + } //end if + } //end if +#endif +#endif + return 0; +} //end of the function BotExportTest + + +/* +============ +Init_AAS_Export +============ +*/ +static void Init_AAS_Export( aas_export_t *aas ) { + //-------------------------------------------- + // be_aas_entity.c + //-------------------------------------------- + aas->AAS_EntityInfo = AAS_EntityInfo; + //-------------------------------------------- + // be_aas_main.c + //-------------------------------------------- + aas->AAS_Initialized = AAS_Initialized; + aas->AAS_PresenceTypeBoundingBox = AAS_PresenceTypeBoundingBox; + aas->AAS_Time = AAS_Time; + //-------------------------------------------- + // be_aas_sample.c + //-------------------------------------------- + aas->AAS_PointAreaNum = AAS_PointAreaNum; + aas->AAS_PointReachabilityAreaIndex = AAS_PointReachabilityAreaIndex; + aas->AAS_TraceAreas = AAS_TraceAreas; + aas->AAS_BBoxAreas = AAS_BBoxAreas; + aas->AAS_AreaInfo = AAS_AreaInfo; + //-------------------------------------------- + // be_aas_bspq3.c + //-------------------------------------------- + aas->AAS_PointContents = AAS_PointContents; + aas->AAS_NextBSPEntity = AAS_NextBSPEntity; + aas->AAS_ValueForBSPEpairKey = AAS_ValueForBSPEpairKey; + aas->AAS_VectorForBSPEpairKey = AAS_VectorForBSPEpairKey; + aas->AAS_FloatForBSPEpairKey = AAS_FloatForBSPEpairKey; + aas->AAS_IntForBSPEpairKey = AAS_IntForBSPEpairKey; + //-------------------------------------------- + // be_aas_reach.c + //-------------------------------------------- + aas->AAS_AreaReachability = AAS_AreaReachability; + //-------------------------------------------- + // be_aas_route.c + //-------------------------------------------- + aas->AAS_AreaTravelTimeToGoalArea = AAS_AreaTravelTimeToGoalArea; + aas->AAS_EnableRoutingArea = AAS_EnableRoutingArea; + aas->AAS_PredictRoute = AAS_PredictRoute; + //-------------------------------------------- + // be_aas_altroute.c + //-------------------------------------------- + aas->AAS_AlternativeRouteGoals = AAS_AlternativeRouteGoals; + //-------------------------------------------- + // be_aas_move.c + //-------------------------------------------- + aas->AAS_Swimming = AAS_Swimming; + aas->AAS_PredictClientMovement = AAS_PredictClientMovement; +} + + +/* +============ +Init_EA_Export +============ +*/ +static void Init_EA_Export( ea_export_t *ea ) { + //ClientCommand elementary actions + ea->EA_Command = EA_Command; + ea->EA_Say = EA_Say; + ea->EA_SayTeam = EA_SayTeam; + + ea->EA_Action = EA_Action; + ea->EA_Gesture = EA_Gesture; + ea->EA_Talk = EA_Talk; + ea->EA_Attack = EA_Attack; + ea->EA_Use = EA_Use; + ea->EA_Respawn = EA_Respawn; + ea->EA_Crouch = EA_Crouch; + ea->EA_MoveUp = EA_MoveUp; + ea->EA_MoveDown = EA_MoveDown; + ea->EA_MoveForward = EA_MoveForward; + ea->EA_MoveBack = EA_MoveBack; + ea->EA_MoveLeft = EA_MoveLeft; + ea->EA_MoveRight = EA_MoveRight; + + ea->EA_SelectWeapon = EA_SelectWeapon; + ea->EA_Jump = EA_Jump; + ea->EA_DelayedJump = EA_DelayedJump; + ea->EA_Move = EA_Move; + ea->EA_View = EA_View; + ea->EA_GetInput = EA_GetInput; + ea->EA_EndRegular = EA_EndRegular; + ea->EA_ResetInput = EA_ResetInput; +} + + +/* +============ +Init_AI_Export +============ +*/ +static void Init_AI_Export( ai_export_t *ai ) { + //----------------------------------- + // be_ai_char.h + //----------------------------------- + ai->BotLoadCharacter = BotLoadCharacter; + ai->BotFreeCharacter = BotFreeCharacter; + ai->Characteristic_Float = Characteristic_Float; + ai->Characteristic_BFloat = Characteristic_BFloat; + ai->Characteristic_Integer = Characteristic_Integer; + ai->Characteristic_BInteger = Characteristic_BInteger; + ai->Characteristic_String = Characteristic_String; + //----------------------------------- + // be_ai_chat.h + //----------------------------------- + ai->BotAllocChatState = BotAllocChatState; + ai->BotFreeChatState = BotFreeChatState; + ai->BotQueueConsoleMessage = BotQueueConsoleMessage; + ai->BotRemoveConsoleMessage = BotRemoveConsoleMessage; + ai->BotNextConsoleMessage = BotNextConsoleMessage; + ai->BotNumConsoleMessages = BotNumConsoleMessages; + ai->BotInitialChat = BotInitialChat; + ai->BotNumInitialChats = BotNumInitialChats; + ai->BotReplyChat = BotReplyChat; + ai->BotChatLength = BotChatLength; + ai->BotEnterChat = BotEnterChat; + ai->BotGetChatMessage = BotGetChatMessage; + ai->StringContains = StringContains; + ai->BotFindMatch = BotFindMatch; + ai->BotMatchVariable = BotMatchVariable; + ai->UnifyWhiteSpaces = UnifyWhiteSpaces; + ai->BotReplaceSynonyms = BotReplaceSynonyms; + ai->BotLoadChatFile = BotLoadChatFile; + ai->BotSetChatGender = BotSetChatGender; + ai->BotSetChatName = BotSetChatName; + //----------------------------------- + // be_ai_goal.h + //----------------------------------- + ai->BotResetGoalState = BotResetGoalState; + ai->BotResetAvoidGoals = BotResetAvoidGoals; + ai->BotRemoveFromAvoidGoals = BotRemoveFromAvoidGoals; + ai->BotPushGoal = BotPushGoal; + ai->BotPopGoal = BotPopGoal; + ai->BotEmptyGoalStack = BotEmptyGoalStack; + ai->BotDumpAvoidGoals = BotDumpAvoidGoals; + ai->BotDumpGoalStack = BotDumpGoalStack; + ai->BotGoalName = BotGoalName; + ai->BotGetTopGoal = BotGetTopGoal; + ai->BotGetSecondGoal = BotGetSecondGoal; + ai->BotChooseLTGItem = BotChooseLTGItem; + ai->BotChooseNBGItem = BotChooseNBGItem; + ai->BotTouchingGoal = BotTouchingGoal; + ai->BotItemGoalInVisButNotVisible = BotItemGoalInVisButNotVisible; + ai->BotGetLevelItemGoal = BotGetLevelItemGoal; + ai->BotGetNextCampSpotGoal = BotGetNextCampSpotGoal; + ai->BotGetMapLocationGoal = BotGetMapLocationGoal; + ai->BotAvoidGoalTime = BotAvoidGoalTime; + ai->BotSetAvoidGoalTime = BotSetAvoidGoalTime; + ai->BotInitLevelItems = BotInitLevelItems; + ai->BotUpdateEntityItems = BotUpdateEntityItems; + ai->BotLoadItemWeights = BotLoadItemWeights; + ai->BotFreeItemWeights = BotFreeItemWeights; + ai->BotInterbreedGoalFuzzyLogic = BotInterbreedGoalFuzzyLogic; + ai->BotSaveGoalFuzzyLogic = BotSaveGoalFuzzyLogic; + ai->BotMutateGoalFuzzyLogic = BotMutateGoalFuzzyLogic; + ai->BotAllocGoalState = BotAllocGoalState; + ai->BotFreeGoalState = BotFreeGoalState; + //----------------------------------- + // be_ai_move.h + //----------------------------------- + ai->BotResetMoveState = BotResetMoveState; + ai->BotMoveToGoal = BotMoveToGoal; + ai->BotMoveInDirection = BotMoveInDirection; + ai->BotResetAvoidReach = BotResetAvoidReach; + ai->BotResetLastAvoidReach = BotResetLastAvoidReach; + ai->BotReachabilityArea = BotReachabilityArea; + ai->BotMovementViewTarget = BotMovementViewTarget; + ai->BotPredictVisiblePosition = BotPredictVisiblePosition; + ai->BotAllocMoveState = BotAllocMoveState; + ai->BotFreeMoveState = BotFreeMoveState; + ai->BotInitMoveState = BotInitMoveState; + ai->BotAddAvoidSpot = BotAddAvoidSpot; + //----------------------------------- + // be_ai_weap.h + //----------------------------------- + ai->BotChooseBestFightWeapon = BotChooseBestFightWeapon; + ai->BotGetWeaponInfo = BotGetWeaponInfo; + ai->BotLoadWeaponWeights = BotLoadWeaponWeights; + ai->BotAllocWeaponState = BotAllocWeaponState; + ai->BotFreeWeaponState = BotFreeWeaponState; + ai->BotResetWeaponState = BotResetWeaponState; + //----------------------------------- + // be_ai_gen.h + //----------------------------------- + ai->GeneticParentsAndChildSelection = GeneticParentsAndChildSelection; +} + + +/* +============ +GetBotLibAPI +============ +*/ +botlib_export_t *GetBotLibAPI(int apiVersion, botlib_import_t *import) { + assert(import); + botimport = *import; + assert(botimport.Print); + + Com_Memset( &be_botlib_export, 0, sizeof( be_botlib_export ) ); + + if ( apiVersion != BOTLIB_API_VERSION ) { + botimport.Print( PRT_ERROR, "Mismatched BOTLIB_API_VERSION: expected %i, got %i\n", BOTLIB_API_VERSION, apiVersion ); + return NULL; + } + + Init_AAS_Export(&be_botlib_export.aas); + Init_EA_Export(&be_botlib_export.ea); + Init_AI_Export(&be_botlib_export.ai); + + be_botlib_export.BotLibSetup = Export_BotLibSetup; + be_botlib_export.BotLibShutdown = Export_BotLibShutdown; + be_botlib_export.BotLibVarSet = Export_BotLibVarSet; + be_botlib_export.BotLibVarGet = Export_BotLibVarGet; + + be_botlib_export.PC_AddGlobalDefine = PC_AddGlobalDefine; + be_botlib_export.PC_LoadSourceHandle = PC_LoadSourceHandle; + be_botlib_export.PC_FreeSourceHandle = PC_FreeSourceHandle; + be_botlib_export.PC_ReadTokenHandle = PC_ReadTokenHandle; + be_botlib_export.PC_SourceFileAndLine = PC_SourceFileAndLine; + + be_botlib_export.BotLibStartFrame = Export_BotLibStartFrame; + be_botlib_export.BotLibLoadMap = Export_BotLibLoadMap; + be_botlib_export.BotLibUpdateEntity = Export_BotLibUpdateEntity; + be_botlib_export.Test = BotExportTest; + + return &be_botlib_export; +} diff --git a/code/botlib/be_interface.h b/code/botlib/be_interface.h new file mode 100644 index 00000000..956530b3 --- /dev/null +++ b/code/botlib/be_interface.h @@ -0,0 +1,57 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: be_interface.h + * + * desc: botlib interface + * + * $Archive: /source/code/botlib/be_interface.h $ + * + *****************************************************************************/ + +//#define DEBUG //debug code +#define RANDOMIZE //randomize bot behaviour + +//FIXME: get rid of this global structure +typedef struct botlib_globals_s +{ + int botlibsetup; //true when the bot library has been setup + int maxentities; //maximum number of entities + int maxclients; //maximum number of clients + float time; //the global time +#ifdef DEBUG + qboolean debug; //true if debug is on + int goalareanum; + vec3_t goalorigin; + int runai; +#endif +} botlib_globals_t; + + +extern botlib_globals_t botlibglobals; +extern botlib_import_t botimport; +extern int bot_developer; //true if developer is on + +// +int Sys_MilliSeconds(void); + diff --git a/code/botlib/botlib.h b/code/botlib/botlib.h new file mode 100644 index 00000000..f079264b --- /dev/null +++ b/code/botlib/botlib.h @@ -0,0 +1,516 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +/***************************************************************************** + * name: botlib.h + * + * desc: bot AI library + * + * $Archive: /source/code/game/botai.h $ + * + *****************************************************************************/ + +#define BOTLIB_API_VERSION 2 + +struct aas_clientmove_s; +struct aas_entityinfo_s; +struct aas_areainfo_s; +struct aas_altroutegoal_s; +struct aas_predictroute_s; +struct bot_consolemessage_s; +struct bot_match_s; +struct bot_goal_s; +struct bot_moveresult_s; +struct bot_initmove_s; +struct weaponinfo_s; + +#define BOTFILESBASEFOLDER "botfiles" +//debug line colors +#define LINECOLOR_NONE -1 +#define LINECOLOR_RED 1//0xf2f2f0f0L +#define LINECOLOR_GREEN 2//0xd0d1d2d3L +#define LINECOLOR_BLUE 3//0xf3f3f1f1L +#define LINECOLOR_YELLOW 4//0xdcdddedfL +#define LINECOLOR_ORANGE 5//0xe0e1e2e3L + +//Print types +#define PRT_MESSAGE 1 +#define PRT_WARNING 2 +#define PRT_ERROR 3 +#define PRT_FATAL 4 +#define PRT_EXIT 5 + +//console message types +#define CMS_NORMAL 0 +#define CMS_CHAT 1 + +//botlib error codes +#define BLERR_NOERROR 0 //no error +#define BLERR_LIBRARYNOTSETUP 1 //library not setup +#define BLERR_INVALIDENTITYNUMBER 2 //invalid entity number +#define BLERR_NOAASFILE 3 //no AAS file available +#define BLERR_CANNOTOPENAASFILE 4 //cannot open AAS file +#define BLERR_WRONGAASFILEID 5 //incorrect AAS file id +#define BLERR_WRONGAASFILEVERSION 6 //incorrect AAS file version +#define BLERR_CANNOTREADAASLUMP 7 //cannot read AAS file lump +#define BLERR_CANNOTLOADICHAT 8 //cannot load initial chats +#define BLERR_CANNOTLOADITEMWEIGHTS 9 //cannot load item weights +#define BLERR_CANNOTLOADITEMCONFIG 10 //cannot load item config +#define BLERR_CANNOTLOADWEAPONWEIGHTS 11 //cannot load weapon weights +#define BLERR_CANNOTLOADWEAPONCONFIG 12 //cannot load weapon config + +//action flags +#define ACTION_ATTACK 0x0000001 +#define ACTION_USE 0x0000002 +#define ACTION_RESPAWN 0x0000008 +#define ACTION_JUMP 0x0000010 +#define ACTION_MOVEUP 0x0000020 +#define ACTION_CROUCH 0x0000080 +#define ACTION_MOVEDOWN 0x0000100 +#define ACTION_MOVEFORWARD 0x0000200 +#define ACTION_MOVEBACK 0x0000800 +#define ACTION_MOVELEFT 0x0001000 +#define ACTION_MOVERIGHT 0x0002000 +#define ACTION_DELAYEDJUMP 0x0008000 +#define ACTION_TALK 0x0010000 +#define ACTION_GESTURE 0x0020000 +#define ACTION_WALK 0x0080000 +#define ACTION_AFFIRMATIVE 0x0100000 +#define ACTION_NEGATIVE 0x0200000 +#define ACTION_GETFLAG 0x0800000 +#define ACTION_GUARDBASE 0x1000000 +#define ACTION_PATROL 0x2000000 +#define ACTION_FOLLOWME 0x8000000 + +//the bot input, will be converted to an usercmd_t +typedef struct bot_input_s +{ + float thinktime; //time since last output (in seconds) + vec3_t dir; //movement direction + float speed; //speed in the range [0, 400] + vec3_t viewangles; //the view angles + int actionflags; //one of the ACTION_? flags + int weapon; //weapon to use +} bot_input_t; + +#ifndef BSPTRACE + +#define BSPTRACE + +//bsp_trace_t hit surface +typedef struct bsp_surface_s +{ + char name[16]; + int flags; + int value; +} bsp_surface_t; + +//remove the bsp_trace_s structure definition l8r on +//a trace is returned when a box is swept through the world +typedef struct bsp_trace_s +{ + qboolean allsolid; // if true, plane is not valid + qboolean startsolid; // if true, the initial point was in a solid area + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + cplane_t plane; // surface normal at impact + float exp_dist; // expanded plane distance + int sidenum; // number of the brush side hit + bsp_surface_t surface; // the hit point surface + int contents; // contents on other side of surface hit + int ent; // number of entity hit +} bsp_trace_t; + +#endif // BSPTRACE + +//entity state +typedef struct bot_entitystate_s +{ + int type; // entity type + int flags; // entity flags + vec3_t origin; // origin of the entity + vec3_t angles; // angles of the model + vec3_t old_origin; // for lerping + vec3_t mins; // bounding box minimums + vec3_t maxs; // bounding box maximums + int groundent; // ground entity + int solid; // solid type + int modelindex; // model used + int modelindex2; // weapons, CTF flags, etc + int frame; // model frame number + int event; // impulse events -- muzzle flashes, footsteps, etc + int eventParm; // even parameter + int powerups; // bit flags + int weapon; // determines weapon and flash model, etc + int legsAnim; // mask off ANIM_TOGGLEBIT + int torsoAnim; // mask off ANIM_TOGGLEBIT +} bot_entitystate_t; + +//bot AI library exported functions +typedef struct botlib_import_s +{ + //print messages from the bot library + void (QDECL *Print)(int type, char *fmt, ...); + //trace a bbox through the world + void (*Trace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask); + //trace a bbox against a specific entity + void (*EntityTrace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int entnum, int contentmask); + //retrieve the contents at the given point + int (*PointContents)(vec3_t point); + //check if the point is in potential visible sight + int (*inPVS)(vec3_t p1, vec3_t p2); + //retrieve the BSP entity data lump + char *(*BSPEntityData)(void); + // + void (*BSPModelMinsMaxsOrigin)(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin); + //send a bot client command + void (*BotClientCommand)(int client, char *command); + //memory allocation + void *(*GetMemory)(int size); // allocate from Zone + void (*FreeMemory)(void *ptr); // free memory from Zone + int (*AvailableMemory)(void); // available Zone memory + void *(*HunkAlloc)(int size); // allocate from hunk + //file system access + int (*FS_FOpenFile)( const char *qpath, fileHandle_t *file, fsMode_t mode ); + int (*FS_Read)( void *buffer, int len, fileHandle_t f ); + int (*FS_Write)( const void *buffer, int len, fileHandle_t f ); + void (*FS_FCloseFile)( fileHandle_t f ); + int (*FS_Seek)( fileHandle_t f, long offset, fsOrigin_t origin ); + //debug visualisation stuff + int (*DebugLineCreate)(void); + void (*DebugLineDelete)(int line); + void (*DebugLineShow)(int line, vec3_t start, vec3_t end, int color); + // + int (*DebugPolygonCreate)(int color, int numPoints, vec3_t *points); + void (*DebugPolygonDelete)(int id); +} botlib_import_t; + +typedef struct aas_export_s +{ + //----------------------------------- + // be_aas_entity.h + //----------------------------------- + void (*AAS_EntityInfo)(int entnum, struct aas_entityinfo_s *info); + //----------------------------------- + // be_aas_main.h + //----------------------------------- + int (*AAS_Initialized)(void); + void (*AAS_PresenceTypeBoundingBox)(int presencetype, vec3_t mins, vec3_t maxs); + float (*AAS_Time)(void); + //-------------------------------------------- + // be_aas_sample.c + //-------------------------------------------- + int (*AAS_PointAreaNum)(vec3_t point); + int (*AAS_PointReachabilityAreaIndex)( vec3_t point ); + int (*AAS_TraceAreas)(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas); + int (*AAS_BBoxAreas)(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas); + int (*AAS_AreaInfo)( int areanum, struct aas_areainfo_s *info ); + //-------------------------------------------- + // be_aas_bspq3.c + //-------------------------------------------- + int (*AAS_PointContents)(vec3_t point); + int (*AAS_NextBSPEntity)(int ent); + int (*AAS_ValueForBSPEpairKey)(int ent, char *key, char *value, int size); + int (*AAS_VectorForBSPEpairKey)(int ent, char *key, vec3_t v); + int (*AAS_FloatForBSPEpairKey)(int ent, char *key, float *value); + int (*AAS_IntForBSPEpairKey)(int ent, char *key, int *value); + //-------------------------------------------- + // be_aas_reach.c + //-------------------------------------------- + int (*AAS_AreaReachability)(int areanum); + //-------------------------------------------- + // be_aas_route.c + //-------------------------------------------- + int (*AAS_AreaTravelTimeToGoalArea)(int areanum, vec3_t origin, int goalareanum, int travelflags); + int (*AAS_EnableRoutingArea)(int areanum, int enable); + int (*AAS_PredictRoute)(struct aas_predictroute_s *route, int areanum, vec3_t origin, + int goalareanum, int travelflags, int maxareas, int maxtime, + int stopevent, int stopcontents, int stoptfl, int stopareanum); + //-------------------------------------------- + // be_aas_altroute.c + //-------------------------------------------- + int (*AAS_AlternativeRouteGoals)(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags, + struct aas_altroutegoal_s *altroutegoals, int maxaltroutegoals, + int type); + //-------------------------------------------- + // be_aas_move.c + //-------------------------------------------- + int (*AAS_Swimming)(vec3_t origin); + 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); +} aas_export_t; + +typedef struct ea_export_s +{ + //ClientCommand elementary actions + void (*EA_Command)(int client, char *command ); + void (*EA_Say)(int client, char *str); + void (*EA_SayTeam)(int client, char *str); + // + void (*EA_Action)(int client, int action); + void (*EA_Gesture)(int client); + void (*EA_Talk)(int client); + void (*EA_Attack)(int client); + void (*EA_Use)(int client); + void (*EA_Respawn)(int client); + void (*EA_MoveUp)(int client); + void (*EA_MoveDown)(int client); + void (*EA_MoveForward)(int client); + void (*EA_MoveBack)(int client); + void (*EA_MoveLeft)(int client); + void (*EA_MoveRight)(int client); + void (*EA_Crouch)(int client); + + void (*EA_SelectWeapon)(int client, int weapon); + void (*EA_Jump)(int client); + void (*EA_DelayedJump)(int client); + void (*EA_Move)(int client, vec3_t dir, float speed); + void (*EA_View)(int client, vec3_t viewangles); + //send regular input to the server + void (*EA_EndRegular)(int client, float thinktime); + void (*EA_GetInput)(int client, float thinktime, bot_input_t *input); + void (*EA_ResetInput)(int client); +} ea_export_t; + +typedef struct ai_export_s +{ + //----------------------------------- + // be_ai_char.h + //----------------------------------- + int (*BotLoadCharacter)(char *charfile, float skill); + void (*BotFreeCharacter)(int character); + float (*Characteristic_Float)(int character, int index); + float (*Characteristic_BFloat)(int character, int index, float min, float max); + int (*Characteristic_Integer)(int character, int index); + int (*Characteristic_BInteger)(int character, int index, int min, int max); + void (*Characteristic_String)(int character, int index, char *buf, int size); + //----------------------------------- + // be_ai_chat.h + //----------------------------------- + int (*BotAllocChatState)(void); + void (*BotFreeChatState)(int handle); + void (*BotQueueConsoleMessage)(int chatstate, int type, char *message); + void (*BotRemoveConsoleMessage)(int chatstate, int handle); + int (*BotNextConsoleMessage)(int chatstate, struct bot_consolemessage_s *cm); + int (*BotNumConsoleMessages)(int chatstate); + void (*BotInitialChat)(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); + int (*BotNumInitialChats)(int chatstate, char *type); + int (*BotReplyChat)(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); + int (*BotChatLength)(int chatstate); + void (*BotEnterChat)(int chatstate, int client, int sendto); + void (*BotGetChatMessage)(int chatstate, char *buf, int size); + int (*StringContains)(char *str1, char *str2, int casesensitive); + int (*BotFindMatch)(char *str, struct bot_match_s *match, unsigned long int context); + void (*BotMatchVariable)(struct bot_match_s *match, int variable, char *buf, int size); + void (*UnifyWhiteSpaces)(char *string); + void (*BotReplaceSynonyms)(char *string, unsigned long int context); + int (*BotLoadChatFile)(int chatstate, char *chatfile, char *chatname); + void (*BotSetChatGender)(int chatstate, int gender); + void (*BotSetChatName)(int chatstate, char *name, int client); + //----------------------------------- + // be_ai_goal.h + //----------------------------------- + void (*BotResetGoalState)(int goalstate); + void (*BotResetAvoidGoals)(int goalstate); + void (*BotRemoveFromAvoidGoals)(int goalstate, int number); + void (*BotPushGoal)(int goalstate, struct bot_goal_s *goal); + void (*BotPopGoal)(int goalstate); + void (*BotEmptyGoalStack)(int goalstate); + void (*BotDumpAvoidGoals)(int goalstate); + void (*BotDumpGoalStack)(int goalstate); + void (*BotGoalName)(int number, char *name, int size); + int (*BotGetTopGoal)(int goalstate, struct bot_goal_s *goal); + int (*BotGetSecondGoal)(int goalstate, struct bot_goal_s *goal); + int (*BotChooseLTGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags); + int (*BotChooseNBGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags, + struct bot_goal_s *ltg, float maxtime); + int (*BotTouchingGoal)(vec3_t origin, struct bot_goal_s *goal); + int (*BotItemGoalInVisButNotVisible)(int viewer, vec3_t eye, vec3_t viewangles, struct bot_goal_s *goal); + int (*BotGetLevelItemGoal)(int index, char *classname, struct bot_goal_s *goal); + int (*BotGetNextCampSpotGoal)(int num, struct bot_goal_s *goal); + int (*BotGetMapLocationGoal)(char *name, struct bot_goal_s *goal); + float (*BotAvoidGoalTime)(int goalstate, int number); + void (*BotSetAvoidGoalTime)(int goalstate, int number, float avoidtime); + void (*BotInitLevelItems)(void); + void (*BotUpdateEntityItems)(void); + int (*BotLoadItemWeights)(int goalstate, char *filename); + void (*BotFreeItemWeights)(int goalstate); + void (*BotInterbreedGoalFuzzyLogic)(int parent1, int parent2, int child); + void (*BotSaveGoalFuzzyLogic)(int goalstate, char *filename); + void (*BotMutateGoalFuzzyLogic)(int goalstate, float range); + int (*BotAllocGoalState)(int client); + void (*BotFreeGoalState)(int handle); + //----------------------------------- + // be_ai_move.h + //----------------------------------- + void (*BotResetMoveState)(int movestate); + void (*BotMoveToGoal)(struct bot_moveresult_s *result, int movestate, struct bot_goal_s *goal, int travelflags); + int (*BotMoveInDirection)(int movestate, vec3_t dir, float speed, int type); + void (*BotResetAvoidReach)(int movestate); + void (*BotResetLastAvoidReach)(int movestate); + int (*BotReachabilityArea)(vec3_t origin, int testground); + int (*BotMovementViewTarget)(int movestate, struct bot_goal_s *goal, int travelflags, float lookahead, vec3_t target); + int (*BotPredictVisiblePosition)(vec3_t origin, int areanum, struct bot_goal_s *goal, int travelflags, vec3_t target); + int (*BotAllocMoveState)(void); + void (*BotFreeMoveState)(int handle); + void (*BotInitMoveState)(int handle, struct bot_initmove_s *initmove); + void (*BotAddAvoidSpot)(int movestate, vec3_t origin, float radius, int type); + //----------------------------------- + // be_ai_weap.h + //----------------------------------- + int (*BotChooseBestFightWeapon)(int weaponstate, int *inventory); + void (*BotGetWeaponInfo)(int weaponstate, int weapon, struct weaponinfo_s *weaponinfo); + int (*BotLoadWeaponWeights)(int weaponstate, char *filename); + int (*BotAllocWeaponState)(void); + void (*BotFreeWeaponState)(int weaponstate); + void (*BotResetWeaponState)(int weaponstate); + //----------------------------------- + // be_ai_gen.h + //----------------------------------- + int (*GeneticParentsAndChildSelection)(int numranks, float *ranks, int *parent1, int *parent2, int *child); +} ai_export_t; + +//bot AI library imported functions +typedef struct botlib_export_s +{ + //Area Awareness System functions + aas_export_t aas; + //Elementary Action functions + ea_export_t ea; + //AI functions + ai_export_t ai; + //setup the bot library, returns BLERR_ + int (*BotLibSetup)(void); + //shutdown the bot library, returns BLERR_ + int (*BotLibShutdown)(void); + //sets a library variable returns BLERR_ + int (*BotLibVarSet)(char *var_name, char *value); + //gets a library variable returns BLERR_ + int (*BotLibVarGet)(char *var_name, char *value, int size); + + //sets a C-like define returns BLERR_ + int (*PC_AddGlobalDefine)(char *string); + int (*PC_LoadSourceHandle)(const char *filename); + int (*PC_FreeSourceHandle)(int handle); + int (*PC_ReadTokenHandle)(int handle, pc_token_t *pc_token); + int (*PC_SourceFileAndLine)(int handle, char *filename, int *line); + + //start a frame in the bot library + int (*BotLibStartFrame)(float time); + //load a new map in the bot library + int (*BotLibLoadMap)(const char *mapname); + //entity updates + int (*BotLibUpdateEntity)(int ent, bot_entitystate_t *state); + //just for testing + int (*Test)(int parm0, char *parm1, vec3_t parm2, vec3_t parm3); +} botlib_export_t; + +//linking of bot library +botlib_export_t *GetBotLibAPI( int apiVersion, botlib_import_t *import ); + +/* Library variables: + +name: default: module(s): description: + +"basedir" "" l_utils.c base directory +"gamedir" "" l_utils.c game directory +"cddir" "" l_utils.c CD directory + +"log" "0" l_log.c enable/disable creating a log file +"maxclients" "4" be_interface.c maximum number of clients +"maxentities" "1024" be_interface.c maximum number of entities +"bot_developer" "0" be_interface.c bot developer mode + +"phys_friction" "6" be_aas_move.c ground friction +"phys_stopspeed" "100" be_aas_move.c stop speed +"phys_gravity" "800" be_aas_move.c gravity value +"phys_waterfriction" "1" be_aas_move.c water friction +"phys_watergravity" "400" be_aas_move.c gravity in water +"phys_maxvelocity" "320" be_aas_move.c maximum velocity +"phys_maxwalkvelocity" "320" be_aas_move.c maximum walk velocity +"phys_maxcrouchvelocity" "100" be_aas_move.c maximum crouch velocity +"phys_maxswimvelocity" "150" be_aas_move.c maximum swim velocity +"phys_walkaccelerate" "10" be_aas_move.c walk acceleration +"phys_airaccelerate" "1" be_aas_move.c air acceleration +"phys_swimaccelerate" "4" be_aas_move.c swim acceleration +"phys_maxstep" "18" be_aas_move.c maximum step height +"phys_maxsteepness" "0.7" be_aas_move.c maximum floor steepness +"phys_maxbarrier" "32" be_aas_move.c maximum barrier height +"phys_maxwaterjump" "19" be_aas_move.c maximum waterjump height +"phys_jumpvel" "270" be_aas_move.c jump z velocity +"phys_falldelta5" "40" be_aas_move.c +"phys_falldelta10" "60" be_aas_move.c +"rs_waterjump" "400" be_aas_move.c +"rs_teleport" "50" be_aas_move.c +"rs_barrierjump" "100" be_aas_move.c +"rs_startcrouch" "300" be_aas_move.c +"rs_startgrapple" "500" be_aas_move.c +"rs_startwalkoffledge" "70" be_aas_move.c +"rs_startjump" "300" be_aas_move.c +"rs_rocketjump" "500" be_aas_move.c +"rs_bfgjump" "500" be_aas_move.c +"rs_jumppad" "250" be_aas_move.c +"rs_aircontrolledjumppad" "300" be_aas_move.c +"rs_funcbob" "300" be_aas_move.c +"rs_startelevator" "50" be_aas_move.c +"rs_falldamage5" "300" be_aas_move.c +"rs_falldamage10" "500" be_aas_move.c +"rs_maxjumpfallheight" "450" be_aas_move.c + +"max_aaslinks" "4096" be_aas_sample.c maximum links in the AAS +"max_routingcache" "4096" be_aas_route.c maximum routing cache size in KB +"forceclustering" "0" be_aas_main.c force recalculation of clusters +"forcereachability" "0" be_aas_main.c force recalculation of reachabilities +"forcewrite" "0" be_aas_main.c force writing of aas file +"aasoptimize" "0" be_aas_main.c enable aas optimization +"sv_mapChecksum" "0" be_aas_main.c BSP file checksum +"bot_visualizejumppads" "0" be_aas_reach.c visualize jump pads + +"bot_reloadcharacters" "0" - reload bot character files +"ai_gametype" "0" be_ai_goal.c game type +"droppedweight" "1000" be_ai_goal.c additional dropped item weight +"weapindex_rocketlauncher" "5" be_ai_move.c rl weapon index for rocket jumping +"weapindex_bfg10k" "9" be_ai_move.c bfg weapon index for bfg jumping +"weapindex_grapple" "10" be_ai_move.c grapple weapon index for grappling +"entitytypemissile" "3" be_ai_move.c ET_MISSILE +"offhandgrapple" "0" be_ai_move.c enable off hand grapple hook +"cmd_grappleon" "grappleon" be_ai_move.c command to activate off hand grapple +"cmd_grappleoff" "grappleoff" be_ai_move.c command to deactivate off hand grapple +"itemconfig" "items.c" be_ai_goal.c item configuration file +"weaponconfig" "weapons.c" be_ai_weap.c weapon configuration file +"synfile" "syn.c" be_ai_chat.c file with synonyms +"rndfile" "rnd.c" be_ai_chat.c file with random strings +"matchfile" "match.c" be_ai_chat.c file with match strings +"nochat" "0" be_ai_chat.c disable chats +"max_messages" "1024" be_ai_chat.c console message heap size +"max_weaponinfo" "32" be_ai_weap.c maximum number of weapon info +"max_projectileinfo" "32" be_ai_weap.c maximum number of projectile info +"max_iteminfo" "256" be_ai_goal.c maximum number of item info +"max_levelitems" "256" be_ai_goal.c maximum number of level items + +*/ + diff --git a/code/botlib/l_crc.c b/code/botlib/l_crc.c new file mode 100644 index 00000000..e27b146e --- /dev/null +++ b/code/botlib/l_crc.c @@ -0,0 +1,151 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_crc.c + * + * desc: CRC calculation + * + * $Archive: /MissionPack/CODE/botlib/l_crc.c $ + * + *****************************************************************************/ + +#include +#include +#include + +#include "../qcommon/q_shared.h" +#include "botlib.h" +#include "be_interface.h" //for botimport.Print + + +// FIXME: byte swap? + +// this is a 16 bit, non-reflected CRC using the polynomial 0x1021 +// and the initial and final xor values shown below... in other words, the +// CCITT standard CRC used by XMODEM + +#define CRC_INIT_VALUE 0xffff +#define CRC_XOR_VALUE 0x0000 + +unsigned short crctable[257] = +{ + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, + 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, + 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, + 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, + 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, + 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, + 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, + 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, + 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, + 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, + 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, + 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, + 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, + 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, + 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, + 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, + 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, + 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, + 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, + 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, + 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, + 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, + 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 +}; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void CRC_Init(unsigned short *crcvalue) +{ + *crcvalue = CRC_INIT_VALUE; +} //end of the function CRC_Init +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void CRC_ProcessByte(unsigned short *crcvalue, byte data) +{ + *crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data]; +} //end of the function CRC_ProcessByte +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +unsigned short CRC_Value(unsigned short crcvalue) +{ + return crcvalue ^ CRC_XOR_VALUE; +} //end of the function CRC_Value +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +unsigned short CRC_ProcessString(unsigned char *data, int length) +{ + unsigned short crcvalue; + int i, ind; + + CRC_Init(&crcvalue); + + for (i = 0; i < length; i++) + { + ind = (crcvalue >> 8) ^ data[i]; + if (ind < 0 || ind > 256) ind = 0; + crcvalue = (crcvalue << 8) ^ crctable[ind]; + } //end for + return CRC_Value(crcvalue); +} //end of the function CRC_ProcessString +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void CRC_ContinueProcessString(unsigned short *crc, char *data, int length) +{ + int i; + + for (i = 0; i < length; i++) + { + *crc = (*crc << 8) ^ crctable[(*crc >> 8) ^ data[i]]; + } //end for +} //end of the function CRC_ProcessString diff --git a/code/botlib/l_crc.h b/code/botlib/l_crc.h new file mode 100644 index 00000000..f9c7e379 --- /dev/null +++ b/code/botlib/l_crc.h @@ -0,0 +1,29 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +typedef unsigned short crc_t; + +void CRC_Init(unsigned short *crcvalue); +void CRC_ProcessByte(unsigned short *crcvalue, byte data); +unsigned short CRC_Value(unsigned short crcvalue); +unsigned short CRC_ProcessString(unsigned char *data, int length); +void CRC_ContinueProcessString(unsigned short *crc, char *data, int length); diff --git a/code/botlib/l_libvar.c b/code/botlib/l_libvar.c new file mode 100644 index 00000000..0270781f --- /dev/null +++ b/code/botlib/l_libvar.c @@ -0,0 +1,295 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_libvar.c + * + * desc: bot library variables + * + * $Archive: /MissionPack/code/botlib/l_libvar.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "l_memory.h" +#include "l_libvar.h" + +//list with library variables +libvar_t *libvarlist = NULL; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float LibVarStringValue(char *string) +{ + int dotfound = 0; + float value = 0; + + while(*string) + { + if (*string < '0' || *string > '9') + { + if (dotfound || *string != '.') + { + return 0; + } //end if + else + { + dotfound = 10; + string++; + } //end if + } //end if + if (dotfound) + { + value = value + (float) (*string - '0') / (float) dotfound; + dotfound *= 10; + } //end if + else + { + value = value * 10.0 + (float) (*string - '0'); + } //end else + string++; + } //end while + return value; +} //end of the function LibVarStringValue +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +libvar_t *LibVarAlloc(char *var_name) +{ + libvar_t *v; + + v = (libvar_t *) GetMemory(sizeof(libvar_t)); + Com_Memset(v, 0, sizeof(libvar_t)); + v->name = (char *) GetMemory(strlen(var_name)+1); + strcpy(v->name, var_name); + //add the variable in the list + v->next = libvarlist; + libvarlist = v; + return v; +} //end of the function LibVarAlloc +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void LibVarDeAlloc(libvar_t *v) +{ + if (v->string) FreeMemory(v->string); + FreeMemory(v->name); + FreeMemory(v); +} //end of the function LibVarDeAlloc +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void LibVarDeAllocAll(void) +{ + libvar_t *v; + + for (v = libvarlist; v; v = libvarlist) + { + libvarlist = libvarlist->next; + LibVarDeAlloc(v); + } //end for + libvarlist = NULL; +} //end of the function LibVarDeAllocAll +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +libvar_t *LibVarGet(char *var_name) +{ + libvar_t *v; + + for (v = libvarlist; v; v = v->next) + { + if (!Q_stricmp(v->name, var_name)) + { + return v; + } //end if + } //end for + return NULL; +} //end of the function LibVarGet +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *LibVarGetString(char *var_name) +{ + libvar_t *v; + + v = LibVarGet(var_name); + if (v) + { + return v->string; + } //end if + else + { + return ""; + } //end else +} //end of the function LibVarGetString +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float LibVarGetValue(char *var_name) +{ + libvar_t *v; + + v = LibVarGet(var_name); + if (v) + { + return v->value; + } //end if + else + { + return 0; + } //end else +} //end of the function LibVarGetValue +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +libvar_t *LibVar(char *var_name, char *value) +{ + libvar_t *v; + v = LibVarGet(var_name); + if (v) return v; + //create new variable + v = LibVarAlloc(var_name); + //variable string + v->string = (char *) GetMemory(strlen(value) + 1); + strcpy(v->string, value); + //the value + v->value = LibVarStringValue(v->string); + //variable is modified + v->modified = qtrue; + // + return v; +} //end of the function LibVar +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *LibVarString(char *var_name, char *value) +{ + libvar_t *v; + + v = LibVar(var_name, value); + return v->string; +} //end of the function LibVarString +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float LibVarValue(char *var_name, char *value) +{ + libvar_t *v; + + v = LibVar(var_name, value); + return v->value; +} //end of the function LibVarValue +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void LibVarSet(char *var_name, char *value) +{ + libvar_t *v; + + v = LibVarGet(var_name); + if (v) + { + FreeMemory(v->string); + } //end if + else + { + v = LibVarAlloc(var_name); + } //end else + //variable string + v->string = (char *) GetMemory(strlen(value) + 1); + strcpy(v->string, value); + //the value + v->value = LibVarStringValue(v->string); + //variable is modified + v->modified = qtrue; +} //end of the function LibVarSet +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean LibVarChanged(char *var_name) +{ + libvar_t *v; + + v = LibVarGet(var_name); + if (v) + { + return v->modified; + } //end if + else + { + return qfalse; + } //end else +} //end of the function LibVarChanged +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void LibVarSetNotModified(char *var_name) +{ + libvar_t *v; + + v = LibVarGet(var_name); + if (v) + { + v->modified = qfalse; + } //end if +} //end of the function LibVarSetNotModified diff --git a/code/botlib/l_libvar.h b/code/botlib/l_libvar.h new file mode 100644 index 00000000..d96685f4 --- /dev/null +++ b/code/botlib/l_libvar.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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_libvar.h + * + * desc: botlib vars + * + * $Archive: /source/code/botlib/l_libvar.h $ + * + *****************************************************************************/ + +//library variable +typedef struct libvar_s +{ + char *name; + char *string; + int flags; + qboolean modified; // set each time the cvar is changed + float value; + struct libvar_s *next; +} libvar_t; + +//removes all library variables +void LibVarDeAllocAll(void); +//gets the library variable with the given name +libvar_t *LibVarGet(char *var_name); +//gets the string of the library variable with the given name +char *LibVarGetString(char *var_name); +//gets the value of the library variable with the given name +float LibVarGetValue(char *var_name); +//creates the library variable if not existing already and returns it +libvar_t *LibVar(char *var_name, char *value); +//creates the library variable if not existing already and returns the value +float LibVarValue(char *var_name, char *value); +//creates the library variable if not existing already and returns the value string +char *LibVarString(char *var_name, char *value); +//sets the library variable +void LibVarSet(char *var_name, char *value); +//returns true if the library variable has been modified +qboolean LibVarChanged(char *var_name); +//sets the library variable to unmodified +void LibVarSetNotModified(char *var_name); + diff --git a/code/botlib/l_log.c b/code/botlib/l_log.c new file mode 100644 index 00000000..1b41b500 --- /dev/null +++ b/code/botlib/l_log.c @@ -0,0 +1,169 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_log.c + * + * desc: log file + * + * $Archive: /MissionPack/CODE/botlib/l_log.c $ + * + *****************************************************************************/ + +#include +#include +#include + +#include "../qcommon/q_shared.h" +#include "botlib.h" +#include "be_interface.h" //for botimport.Print +#include "l_libvar.h" + +#define MAX_LOGFILENAMESIZE 1024 + +typedef struct logfile_s +{ + char filename[MAX_LOGFILENAMESIZE]; + FILE *fp; + int numwrites; +} logfile_t; + +static logfile_t logfile; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_Open(char *filename) +{ + if (!LibVarValue("log", "0")) return; + if (!filename || !strlen(filename)) + { + botimport.Print(PRT_MESSAGE, "openlog \n"); + return; + } //end if + if (logfile.fp) + { + botimport.Print(PRT_ERROR, "log file %s is already opened\n", logfile.filename); + return; + } //end if + logfile.fp = fopen(filename, "wb"); + if (!logfile.fp) + { + botimport.Print(PRT_ERROR, "can't open the log file %s\n", filename); + return; + } //end if + strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE); + botimport.Print(PRT_MESSAGE, "Opened log %s\n", logfile.filename); +} //end of the function Log_Create +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_Close(void) +{ + if (!logfile.fp) return; + if (fclose(logfile.fp)) + { + botimport.Print(PRT_ERROR, "can't close log file %s\n", logfile.filename); + return; + } //end if + logfile.fp = NULL; + botimport.Print(PRT_MESSAGE, "Closed log %s\n", logfile.filename); +} //end of the function Log_Close +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_Shutdown(void) +{ + if (logfile.fp) Log_Close(); +} //end of the function Log_Shutdown +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void QDECL Log_Write(char *fmt, ...) +{ + va_list ap; + + if (!logfile.fp) return; + va_start(ap, fmt); + vfprintf(logfile.fp, fmt, ap); + va_end(ap); + //fprintf(logfile.fp, "\r\n"); + fflush(logfile.fp); +} //end of the function Log_Write +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void QDECL Log_WriteTimeStamped(char *fmt, ...) +{ + va_list ap; + + if (!logfile.fp) return; + fprintf(logfile.fp, "%d %02d:%02d:%02d:%02d ", + logfile.numwrites, + (int) (botlibglobals.time / 60 / 60), + (int) (botlibglobals.time / 60), + (int) (botlibglobals.time), + (int) ((int) (botlibglobals.time * 100)) - + ((int) botlibglobals.time) * 100); + va_start(ap, fmt); + vfprintf(logfile.fp, fmt, ap); + va_end(ap); + fprintf(logfile.fp, "\r\n"); + logfile.numwrites++; + fflush(logfile.fp); +} //end of the function Log_Write +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +FILE *Log_FilePointer(void) +{ + return logfile.fp; +} //end of the function Log_FilePointer +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_Flush(void) +{ + if (logfile.fp) fflush(logfile.fp); +} //end of the function Log_Flush + diff --git a/code/botlib/l_log.h b/code/botlib/l_log.h new file mode 100644 index 00000000..3ddb4641 --- /dev/null +++ b/code/botlib/l_log.h @@ -0,0 +1,46 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_log.h + * + * desc: log file + * + * $Archive: /source/code/botlib/l_log.h $ + * + *****************************************************************************/ + +//open a log file +void Log_Open(char *filename); +//close the current log file +void Log_Close(void); +//close log file if present +void Log_Shutdown(void); +//write to the current opened log file +void QDECL Log_Write(char *fmt, ...); +//write to the current opened log file with a time stamp +void QDECL Log_WriteTimeStamped(char *fmt, ...); +//returns a pointer to the log file +FILE *Log_FilePointer(void); +//flush log file +void Log_Flush(void); + diff --git a/code/botlib/l_memory.c b/code/botlib/l_memory.c new file mode 100644 index 00000000..da063ab0 --- /dev/null +++ b/code/botlib/l_memory.c @@ -0,0 +1,463 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_memory.c + * + * desc: memory allocation + * + * $Archive: /MissionPack/code/botlib/l_memory.c $ + * + *****************************************************************************/ + +#include "../qcommon/q_shared.h" +#include "botlib.h" +#include "l_log.h" +#include "be_interface.h" + +//#define MEMDEBUG +//#define MEMORYMANEGER + +#define MEM_ID 0x12345678l +#define HUNK_ID 0x87654321l + +int allocatedmemory; +int totalmemorysize; +int numblocks; + +#ifdef MEMORYMANEGER + +typedef struct memoryblock_s +{ + unsigned long int id; + void *ptr; + int size; +#ifdef MEMDEBUG + char *label; + char *file; + int line; +#endif //MEMDEBUG + struct memoryblock_s *prev, *next; +} memoryblock_t; + +memoryblock_t *memory; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void LinkMemoryBlock(memoryblock_t *block) +{ + block->prev = NULL; + block->next = memory; + if (memory) memory->prev = block; + memory = block; +} //end of the function LinkMemoryBlock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void UnlinkMemoryBlock(memoryblock_t *block) +{ + if (block->prev) block->prev->next = block->next; + else memory = block->next; + if (block->next) block->next->prev = block->prev; +} //end of the function UnlinkMemoryBlock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef MEMDEBUG +void *GetMemoryDebug(unsigned long size, char *label, char *file, int line) +#else +void *GetMemory(unsigned long size) +#endif //MEMDEBUG +{ + void *ptr; + memoryblock_t *block; + assert(botimport.GetMemory); + ptr = botimport.GetMemory(size + sizeof(memoryblock_t)); + block = (memoryblock_t *) ptr; + block->id = MEM_ID; + block->ptr = (char *) ptr + sizeof(memoryblock_t); + block->size = size + sizeof(memoryblock_t); +#ifdef MEMDEBUG + block->label = label; + block->file = file; + block->line = line; +#endif //MEMDEBUG + LinkMemoryBlock(block); + allocatedmemory += block->size; + totalmemorysize += block->size + sizeof(memoryblock_t); + numblocks++; + return block->ptr; +} //end of the function GetMemoryDebug +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef MEMDEBUG +void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line) +#else +void *GetClearedMemory(unsigned long size) +#endif //MEMDEBUG +{ + void *ptr; +#ifdef MEMDEBUG + ptr = GetMemoryDebug(size, label, file, line); +#else + ptr = GetMemory(size); +#endif //MEMDEBUG + Com_Memset(ptr, 0, size); + return ptr; +} //end of the function GetClearedMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef MEMDEBUG +void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line) +#else +void *GetHunkMemory(unsigned long size) +#endif //MEMDEBUG +{ + void *ptr; + memoryblock_t *block; + + ptr = botimport.HunkAlloc(size + sizeof(memoryblock_t)); + block = (memoryblock_t *) ptr; + block->id = HUNK_ID; + block->ptr = (char *) ptr + sizeof(memoryblock_t); + block->size = size + sizeof(memoryblock_t); +#ifdef MEMDEBUG + block->label = label; + block->file = file; + block->line = line; +#endif //MEMDEBUG + LinkMemoryBlock(block); + allocatedmemory += block->size; + totalmemorysize += block->size + sizeof(memoryblock_t); + numblocks++; + return block->ptr; +} //end of the function GetHunkMemoryDebug +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef MEMDEBUG +void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line) +#else +void *GetClearedHunkMemory(unsigned long size) +#endif //MEMDEBUG +{ + void *ptr; +#ifdef MEMDEBUG + ptr = GetHunkMemoryDebug(size, label, file, line); +#else + ptr = GetHunkMemory(size); +#endif //MEMDEBUG + Com_Memset(ptr, 0, size); + return ptr; +} //end of the function GetClearedHunkMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +memoryblock_t *BlockFromPointer(void *ptr, char *str) +{ + memoryblock_t *block; + + if (!ptr) + { +#ifdef MEMDEBUG + //char *crash = (char *) NULL; + //crash[0] = 1; + botimport.Print(PRT_FATAL, "%s: NULL pointer\n", str); +#endif // MEMDEBUG + return NULL; + } //end if + block = (memoryblock_t *) ((char *) ptr - sizeof(memoryblock_t)); + if (block->id != MEM_ID && block->id != HUNK_ID) + { + botimport.Print(PRT_FATAL, "%s: invalid memory block\n", str); + return NULL; + } //end if + if (block->ptr != ptr) + { + botimport.Print(PRT_FATAL, "%s: memory block pointer invalid\n", str); + return NULL; + } //end if + return block; +} //end of the function BlockFromPointer +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeMemory(void *ptr) +{ + memoryblock_t *block; + + block = BlockFromPointer(ptr, "FreeMemory"); + if (!block) return; + UnlinkMemoryBlock(block); + allocatedmemory -= block->size; + totalmemorysize -= block->size + sizeof(memoryblock_t); + numblocks--; + // + if (block->id == MEM_ID) + { + botimport.FreeMemory(block); + } //end if +} //end of the function FreeMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AvailableMemory(void) +{ + return botimport.AvailableMemory(); +} //end of the function AvailableMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int MemoryByteSize(void *ptr) +{ + memoryblock_t *block; + + block = BlockFromPointer(ptr, "MemoryByteSize"); + if (!block) return 0; + return block->size; +} //end of the function MemoryByteSize +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintUsedMemorySize(void) +{ + botimport.Print(PRT_MESSAGE, "total allocated memory: %d KB\n", allocatedmemory >> 10); + botimport.Print(PRT_MESSAGE, "total botlib memory: %d KB\n", totalmemorysize >> 10); + botimport.Print(PRT_MESSAGE, "total memory blocks: %d\n", numblocks); +} //end of the function PrintUsedMemorySize +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintMemoryLabels(void) +{ + memoryblock_t *block; + int i; + + PrintUsedMemorySize(); + i = 0; + Log_Write("============= Botlib memory log ==============\r\n"); + Log_Write("\r\n"); + for (block = memory; block; block = block->next) + { +#ifdef MEMDEBUG + if (block->id == HUNK_ID) + { + Log_Write("%6d, hunk %p, %8d: %24s line %6d: %s\r\n", i, block->ptr, block->size, block->file, block->line, block->label); + } //end if + else + { + Log_Write("%6d, %p, %8d: %24s line %6d: %s\r\n", i, block->ptr, block->size, block->file, block->line, block->label); + } //end else +#endif //MEMDEBUG + i++; + } //end for +} //end of the function PrintMemoryLabels +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void DumpMemory(void) +{ + memoryblock_t *block; + + for (block = memory; block; block = memory) + { + FreeMemory(block->ptr); + } //end for + totalmemorysize = 0; + allocatedmemory = 0; +} //end of the function DumpMemory + +#else + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef MEMDEBUG +void *GetMemoryDebug(unsigned long size, char *label, char *file, int line) +#else +void *GetMemory(unsigned long size) +#endif //MEMDEBUG +{ + void *ptr; + unsigned long int *memid; + + ptr = botimport.GetMemory(size + sizeof(unsigned long int)); + if (!ptr) return NULL; + memid = (unsigned long int *) ptr; + *memid = MEM_ID; + return (unsigned long int *) ((char *) ptr + sizeof(unsigned long int)); +} //end of the function GetMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef MEMDEBUG +void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line) +#else +void *GetClearedMemory(unsigned long size) +#endif //MEMDEBUG +{ + void *ptr; +#ifdef MEMDEBUG + ptr = GetMemoryDebug(size, label, file, line); +#else + ptr = GetMemory(size); +#endif //MEMDEBUG + Com_Memset(ptr, 0, size); + return ptr; +} //end of the function GetClearedMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef MEMDEBUG +void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line) +#else +void *GetHunkMemory(unsigned long size) +#endif //MEMDEBUG +{ + void *ptr; + unsigned long int *memid; + + ptr = botimport.HunkAlloc(size + sizeof(unsigned long int)); + if (!ptr) return NULL; + memid = (unsigned long int *) ptr; + *memid = HUNK_ID; + return (unsigned long int *) ((char *) ptr + sizeof(unsigned long int)); +} //end of the function GetHunkMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef MEMDEBUG +void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line) +#else +void *GetClearedHunkMemory(unsigned long size) +#endif //MEMDEBUG +{ + void *ptr; +#ifdef MEMDEBUG + ptr = GetHunkMemoryDebug(size, label, file, line); +#else + ptr = GetHunkMemory(size); +#endif //MEMDEBUG + Com_Memset(ptr, 0, size); + return ptr; +} //end of the function GetClearedHunkMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeMemory(void *ptr) +{ + unsigned long int *memid; + + memid = (unsigned long int *) ((char *) ptr - sizeof(unsigned long int)); + + if (*memid == MEM_ID) + { + botimport.FreeMemory(memid); + } //end if +} //end of the function FreeMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AvailableMemory(void) +{ + return botimport.AvailableMemory(); +} //end of the function AvailableMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintUsedMemorySize(void) +{ +} //end of the function PrintUsedMemorySize +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintMemoryLabels(void) +{ +} //end of the function PrintMemoryLabels + +#endif diff --git a/code/botlib/l_memory.h b/code/botlib/l_memory.h new file mode 100644 index 00000000..17c89d5b --- /dev/null +++ b/code/botlib/l_memory.h @@ -0,0 +1,76 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_memory.h + * + * desc: memory management + * + * $Archive: /source/code/botlib/l_memory.h $ + * + *****************************************************************************/ + +//#define MEMDEBUG + +#ifdef MEMDEBUG +#define GetMemory(size) GetMemoryDebug(size, #size, __FILE__, __LINE__); +#define GetClearedMemory(size) GetClearedMemoryDebug(size, #size, __FILE__, __LINE__); +//allocate a memory block of the given size +void *GetMemoryDebug(unsigned long size, char *label, char *file, int line); +//allocate a memory block of the given size and clear it +void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line); +// +#define GetHunkMemory(size) GetHunkMemoryDebug(size, #size, __FILE__, __LINE__); +#define GetClearedHunkMemory(size) GetClearedHunkMemoryDebug(size, #size, __FILE__, __LINE__); +//allocate a memory block of the given size +void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line); +//allocate a memory block of the given size and clear it +void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line); +#else +//allocate a memory block of the given size +void *GetMemory(unsigned long size); +//allocate a memory block of the given size and clear it +void *GetClearedMemory(unsigned long size); +// +#ifdef BSPC +#define GetHunkMemory GetMemory +#define GetClearedHunkMemory GetClearedMemory +#else +//allocate a memory block of the given size +void *GetHunkMemory(unsigned long size); +//allocate a memory block of the given size and clear it +void *GetClearedHunkMemory(unsigned long size); +#endif +#endif + +//free the given memory block +void FreeMemory(void *ptr); +//returns the amount available memory +int AvailableMemory(void); +//prints the total used memory size +void PrintUsedMemorySize(void); +//print all memory blocks with label +void PrintMemoryLabels(void); +//returns the size of the memory block in bytes +int MemoryByteSize(void *ptr); +//free all allocated memory +void DumpMemory(void); diff --git a/code/botlib/l_precomp.c b/code/botlib/l_precomp.c new file mode 100644 index 00000000..866a6012 --- /dev/null +++ b/code/botlib/l_precomp.c @@ -0,0 +1,3230 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: l_precomp.c + * + * desc: pre compiler + * + * $Archive: /MissionPack/code/botlib/l_precomp.c $ + * + *****************************************************************************/ + +//Notes: fix: PC_StringizeTokens + +//#define SCREWUP +//#define BOTLIB +//#define QUAKE +//#define QUAKEC +//#define MEQCC + +#ifdef SCREWUP +#include +#include +#include +#include +#include +#include +#include "l_memory.h" +#include "l_script.h" +#include "l_precomp.h" + +typedef enum {qfalse, qtrue} qboolean; +#endif //SCREWUP + +#ifdef BOTLIB +#include "../qcommon/q_shared.h" +#include "botlib.h" +#include "be_interface.h" +#include "l_memory.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_log.h" +#endif //BOTLIB + +#ifdef MEQCC +#include "qcc.h" +#include "time.h" //time & ctime +#include "math.h" //fabs +#include "l_memory.h" +#include "l_script.h" +#include "l_precomp.h" +#include "l_log.h" + +#define qtrue true +#define qfalse false +#endif //MEQCC + +#ifdef BSPC +//include files for usage in the BSP Converter +#include "../bspc/qbsp.h" +#include "../bspc/l_log.h" +#include "../bspc/l_mem.h" +#include "l_precomp.h" + +#define qtrue true +#define qfalse false +#define Q_stricmp stricmp + +#endif //BSPC + +#if defined(QUAKE) && !defined(BSPC) +#include "l_utils.h" +#endif //QUAKE + +//#define DEBUG_EVAL + +#define MAX_DEFINEPARMS 128 + +#define DEFINEHASHING 1 + +//directive name with parse function +typedef struct directive_s +{ + char *name; + int (*func)(source_t *source); +} directive_t; + +#define DEFINEHASHSIZE 1024 + +#define TOKEN_HEAP_SIZE 4096 + +int numtokens; +/* +int tokenheapinitialized; //true when the token heap is initialized +token_t token_heap[TOKEN_HEAP_SIZE]; //heap with tokens +token_t *freetokens; //free tokens from the heap +*/ + +//list with global defines added to every source loaded +define_t *globaldefines; + +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void QDECL SourceError(source_t *source, char *str, ...) +{ + char text[1024]; + va_list ap; + + va_start(ap, str); + vsprintf(text, str, ap); + va_end(ap); +#ifdef BOTLIB + botimport.Print(PRT_ERROR, "file %s, line %d: %s\n", source->scriptstack->filename, source->scriptstack->line, text); +#endif //BOTLIB +#ifdef MEQCC + printf("error: file %s, line %d: %s\n", source->scriptstack->filename, source->scriptstack->line, text); +#endif //MEQCC +#ifdef BSPC + Log_Print("error: file %s, line %d: %s\n", source->scriptstack->filename, source->scriptstack->line, text); +#endif //BSPC +} //end of the function SourceError +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void QDECL SourceWarning(source_t *source, char *str, ...) +{ + char text[1024]; + va_list ap; + + va_start(ap, str); + vsprintf(text, str, ap); + va_end(ap); +#ifdef BOTLIB + botimport.Print(PRT_WARNING, "file %s, line %d: %s\n", source->scriptstack->filename, source->scriptstack->line, text); +#endif //BOTLIB +#ifdef MEQCC + printf("warning: file %s, line %d: %s\n", source->scriptstack->filename, source->scriptstack->line, text); +#endif //MEQCC +#ifdef BSPC + Log_Print("warning: file %s, line %d: %s\n", source->scriptstack->filename, source->scriptstack->line, text); +#endif //BSPC +} //end of the function ScriptWarning +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_PushIndent(source_t *source, int type, int skip) +{ + indent_t *indent; + + indent = (indent_t *) GetMemory(sizeof(indent_t)); + indent->type = type; + indent->script = source->scriptstack; + indent->skip = (skip != 0); + source->skip += indent->skip; + indent->next = source->indentstack; + source->indentstack = indent; +} //end of the function PC_PushIndent +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_PopIndent(source_t *source, int *type, int *skip) +{ + indent_t *indent; + + *type = 0; + *skip = 0; + + indent = source->indentstack; + if (!indent) return; + + //must be an indent from the current script + if (source->indentstack->script != source->scriptstack) return; + + *type = indent->type; + *skip = indent->skip; + source->indentstack = source->indentstack->next; + source->skip -= indent->skip; + FreeMemory(indent); +} //end of the function PC_PopIndent +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_PushScript(source_t *source, script_t *script) +{ + script_t *s; + + for (s = source->scriptstack; s; s = s->next) + { + if (!Q_stricmp(s->filename, script->filename)) + { + SourceError(source, "%s recursively included", script->filename); + return; + } //end if + } //end for + //push the script on the script stack + script->next = source->scriptstack; + source->scriptstack = script; +} //end of the function PC_PushScript +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_InitTokenHeap(void) +{ + /* + int i; + + if (tokenheapinitialized) return; + freetokens = NULL; + for (i = 0; i < TOKEN_HEAP_SIZE; i++) + { + token_heap[i].next = freetokens; + freetokens = &token_heap[i]; + } //end for + tokenheapinitialized = qtrue; + */ +} //end of the function PC_InitTokenHeap +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +token_t *PC_CopyToken(token_t *token) +{ + token_t *t; + +// t = (token_t *) malloc(sizeof(token_t)); + t = (token_t *) GetMemory(sizeof(token_t)); +// t = freetokens; + if (!t) + { +#ifdef BSPC + Error("out of token space\n"); +#else + Com_Error(ERR_FATAL, "out of token space\n"); +#endif + return NULL; + } //end if +// freetokens = freetokens->next; + Com_Memcpy(t, token, sizeof(token_t)); + t->next = NULL; + numtokens++; + return t; +} //end of the function PC_CopyToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_FreeToken(token_t *token) +{ + //free(token); + FreeMemory(token); +// token->next = freetokens; +// freetokens = token; + numtokens--; +} //end of the function PC_FreeToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ReadSourceToken(source_t *source, token_t *token) +{ + token_t *t; + script_t *script; + int type, skip; + + //if there's no token already available + while(!source->tokens) + { + //if there's a token to read from the script + if (PS_ReadToken(source->scriptstack, token)) return qtrue; + //if at the end of the script + if (EndOfScript(source->scriptstack)) + { + //remove all indents of the script + while(source->indentstack && + source->indentstack->script == source->scriptstack) + { + SourceWarning(source, "missing #endif"); + PC_PopIndent(source, &type, &skip); + } //end if + } //end if + //if this was the initial script + if (!source->scriptstack->next) return qfalse; + //remove the script and return to the last one + script = source->scriptstack; + source->scriptstack = source->scriptstack->next; + FreeScript(script); + } //end while + //copy the already available token + Com_Memcpy(token, source->tokens, sizeof(token_t)); + //free the read token + t = source->tokens; + source->tokens = source->tokens->next; + PC_FreeToken(t); + return qtrue; +} //end of the function PC_ReadSourceToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_UnreadSourceToken(source_t *source, token_t *token) +{ + token_t *t; + + t = PC_CopyToken(token); + t->next = source->tokens; + source->tokens = t; + return qtrue; +} //end of the function PC_UnreadSourceToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ReadDefineParms(source_t *source, define_t *define, token_t **parms, int maxparms) +{ + token_t token, *t, *last; + int i, done, lastcomma, numparms, indent; + + if (!PC_ReadSourceToken(source, &token)) + { + SourceError(source, "define %s missing parms", define->name); + return qfalse; + } //end if + // + if (define->numparms > maxparms) + { + SourceError(source, "define with more than %d parameters", maxparms); + return qfalse; + } //end if + // + for (i = 0; i < define->numparms; i++) parms[i] = NULL; + //if no leading "(" + if (strcmp(token.string, "(")) + { + PC_UnreadSourceToken(source, &token); + SourceError(source, "define %s missing parms", define->name); + return qfalse; + } //end if + //read the define parameters + for (done = 0, numparms = 0, indent = 0; !done;) + { + if (numparms >= maxparms) + { + SourceError(source, "define %s with too many parms", define->name); + return qfalse; + } //end if + if (numparms >= define->numparms) + { + SourceWarning(source, "define %s has too many parms", define->name); + return qfalse; + } //end if + parms[numparms] = NULL; + lastcomma = 1; + last = NULL; + while(!done) + { + // + if (!PC_ReadSourceToken(source, &token)) + { + SourceError(source, "define %s incomplete", define->name); + return qfalse; + } //end if + // + if (!strcmp(token.string, ",")) + { + if (indent <= 0) + { + if (lastcomma) SourceWarning(source, "too many comma's"); + lastcomma = 1; + break; + } //end if + } //end if + lastcomma = 0; + // + if (!strcmp(token.string, "(")) + { + indent++; + continue; + } //end if + else if (!strcmp(token.string, ")")) + { + if (--indent <= 0) + { + if (!parms[define->numparms-1]) + { + SourceWarning(source, "too few define parms"); + } //end if + done = 1; + break; + } //end if + } //end if + // + if (numparms < define->numparms) + { + // + t = PC_CopyToken(&token); + t->next = NULL; + if (last) last->next = t; + else parms[numparms] = t; + last = t; + } //end if + } //end while + numparms++; + } //end for + return qtrue; +} //end of the function PC_ReadDefineParms +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_StringizeTokens(token_t *tokens, token_t *token) +{ + token_t *t; + + token->type = TT_STRING; + token->whitespace_p = NULL; + token->endwhitespace_p = NULL; + token->string[0] = '\0'; + strcat(token->string, "\""); + for (t = tokens; t; t = t->next) + { + strncat(token->string, t->string, MAX_TOKEN - strlen(token->string) - 1); + } //end for + strncat(token->string, "\"", MAX_TOKEN - strlen(token->string) - 1); + return qtrue; +} //end of the function PC_StringizeTokens +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_MergeTokens(token_t *t1, token_t *t2) +{ + //merging of a name with a name or number + if (t1->type == TT_NAME && (t2->type == TT_NAME || t2->type == TT_NUMBER)) + { + strcat(t1->string, t2->string); + return qtrue; + } //end if + //merging of two strings + if (t1->type == TT_STRING && t2->type == TT_STRING) + { + //remove trailing double quote + t1->string[strlen(t1->string)-1] = '\0'; + //concat without leading double quote + strcat(t1->string, &t2->string[1]); + return qtrue; + } //end if + //FIXME: merging of two number of the same sub type + return qfalse; +} //end of the function PC_MergeTokens +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +/* +void PC_PrintDefine(define_t *define) +{ + printf("define->name = %s\n", define->name); + printf("define->flags = %d\n", define->flags); + printf("define->builtin = %d\n", define->builtin); + printf("define->numparms = %d\n", define->numparms); +// token_t *parms; //define parameters +// token_t *tokens; //macro tokens (possibly containing parm tokens) +// struct define_s *next; //next defined macro in a list +} //end of the function PC_PrintDefine*/ +#if DEFINEHASHING +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_PrintDefineHashTable(define_t **definehash) +{ + int i; + define_t *d; + + for (i = 0; i < DEFINEHASHSIZE; i++) + { + Log_Write("%4d:", i); + for (d = definehash[i]; d; d = d->hashnext) + { + Log_Write(" %s", d->name); + } //end for + Log_Write("\n"); + } //end for +} //end of the function PC_PrintDefineHashTable +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +//char primes[16] = {1, 3, 5, 7, 11, 13, 17, 19, 23, 27, 29, 31, 37, 41, 43, 47}; + +int PC_NameHash(char *name) +{ + int register hash, i; + + hash = 0; + for (i = 0; name[i] != '\0'; i++) + { + hash += name[i] * (119 + i); + //hash += (name[i] << 7) + i; + //hash += (name[i] << (i&15)); + } //end while + hash = (hash ^ (hash >> 10) ^ (hash >> 20)) & (DEFINEHASHSIZE-1); + return hash; +} //end of the function PC_NameHash +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_AddDefineToHash(define_t *define, define_t **definehash) +{ + int hash; + + hash = PC_NameHash(define->name); + define->hashnext = definehash[hash]; + definehash[hash] = define; +} //end of the function PC_AddDefineToHash +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +define_t *PC_FindHashedDefine(define_t **definehash, char *name) +{ + define_t *d; + int hash; + + hash = PC_NameHash(name); + for (d = definehash[hash]; d; d = d->hashnext) + { + if (!strcmp(d->name, name)) return d; + } //end for + return NULL; +} //end of the function PC_FindHashedDefine +#endif //DEFINEHASHING +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +define_t *PC_FindDefine(define_t *defines, char *name) +{ + define_t *d; + + for (d = defines; d; d = d->next) + { + if (!strcmp(d->name, name)) return d; + } //end for + return NULL; +} //end of the function PC_FindDefine +//============================================================================ +// +// Parameter: - +// Returns: number of the parm +// if no parm found with the given name -1 is returned +// Changes Globals: - +//============================================================================ +int PC_FindDefineParm(define_t *define, char *name) +{ + token_t *p; + int i; + + i = 0; + for (p = define->parms; p; p = p->next) + { + if (!strcmp(p->string, name)) return i; + i++; + } //end for + return -1; +} //end of the function PC_FindDefineParm +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_FreeDefine(define_t *define) +{ + token_t *t, *next; + + //free the define parameters + for (t = define->parms; t; t = next) + { + next = t->next; + PC_FreeToken(t); + } //end for + //free the define tokens + for (t = define->tokens; t; t = next) + { + next = t->next; + PC_FreeToken(t); + } //end for + //free the define + FreeMemory(define->name); + FreeMemory(define); +} //end of the function PC_FreeDefine +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_AddBuiltinDefines(source_t *source) +{ + int i; + define_t *define; + struct builtin + { + char *string; + int builtin; + } builtin[] = { + { "__LINE__", BUILTIN_LINE }, + { "__FILE__", BUILTIN_FILE }, + { "__DATE__", BUILTIN_DATE }, + { "__TIME__", BUILTIN_TIME }, +// { "__STDC__", BUILTIN_STDC }, + { NULL, 0 } + }; + + for (i = 0; builtin[i].string; i++) + { + define = (define_t *) GetMemory(sizeof(define_t)); + Com_Memset(define, 0, sizeof(define_t)); + define->name = (char *) GetMemory(strlen(builtin[i].string) + 1); + strcpy(define->name, builtin[i].string); + define->flags |= DEFINE_FIXED; + define->builtin = builtin[i].builtin; + //add the define to the source +#if DEFINEHASHING + PC_AddDefineToHash(define, source->definehash); +#else + define->next = source->defines; + source->defines = define; +#endif //DEFINEHASHING + } //end for +} //end of the function PC_AddBuiltinDefines +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define, + token_t **firsttoken, token_t **lasttoken) +{ + token_t *token; + time_t t; + + char *curtime; + + token = PC_CopyToken(deftoken); + switch(define->builtin) + { + case BUILTIN_LINE: + { + sprintf(token->string, "%d", deftoken->line); +#ifdef NUMBERVALUE + token->intvalue = deftoken->line; + token->floatvalue = deftoken->line; +#endif //NUMBERVALUE + token->type = TT_NUMBER; + token->subtype = TT_DECIMAL | TT_INTEGER; + *firsttoken = token; + *lasttoken = token; + break; + } //end case + case BUILTIN_FILE: + { + strcpy(token->string, source->scriptstack->filename); + token->type = TT_NAME; + token->subtype = strlen(token->string); + *firsttoken = token; + *lasttoken = token; + break; + } //end case + case BUILTIN_DATE: + { + t = time(NULL); + curtime = ctime(&t); + strcpy(token->string, "\""); + strncat(token->string, curtime+4, 7); + strncat(token->string+7, curtime+20, 4); + strcat(token->string, "\""); + free(curtime); + token->type = TT_NAME; + token->subtype = strlen(token->string); + *firsttoken = token; + *lasttoken = token; + break; + } //end case + case BUILTIN_TIME: + { + t = time(NULL); + curtime = ctime(&t); + strcpy(token->string, "\""); + strncat(token->string, curtime+11, 8); + strcat(token->string, "\""); + free(curtime); + token->type = TT_NAME; + token->subtype = strlen(token->string); + *firsttoken = token; + *lasttoken = token; + break; + } //end case + case BUILTIN_STDC: + default: + { + *firsttoken = NULL; + *lasttoken = NULL; + break; + } //end case + } //end switch + return qtrue; +} //end of the function PC_ExpandBuiltinDefine +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ExpandDefine(source_t *source, token_t *deftoken, define_t *define, + token_t **firsttoken, token_t **lasttoken) +{ + token_t *parms[MAX_DEFINEPARMS], *dt, *pt, *t; + token_t *t1, *t2, *first, *last, *nextpt, token; + int parmnum, i; + + //if it is a builtin define + if (define->builtin) + { + return PC_ExpandBuiltinDefine(source, deftoken, define, firsttoken, lasttoken); + } //end if + //if the define has parameters + if (define->numparms) + { + if (!PC_ReadDefineParms(source, define, parms, MAX_DEFINEPARMS)) return qfalse; +#ifdef DEBUG_EVAL + for (i = 0; i < define->numparms; i++) + { + Log_Write("define parms %d:", i); + for (pt = parms[i]; pt; pt = pt->next) + { + Log_Write("%s", pt->string); + } //end for + } //end for +#endif //DEBUG_EVAL + } //end if + //empty list at first + first = NULL; + last = NULL; + //create a list with tokens of the expanded define + for (dt = define->tokens; dt; dt = dt->next) + { + parmnum = -1; + //if the token is a name, it could be a define parameter + if (dt->type == TT_NAME) + { + parmnum = PC_FindDefineParm(define, dt->string); + } //end if + //if it is a define parameter + if (parmnum >= 0) + { + for (pt = parms[parmnum]; pt; pt = pt->next) + { + t = PC_CopyToken(pt); + //add the token to the list + t->next = NULL; + if (last) last->next = t; + else first = t; + last = t; + } //end for + } //end if + else + { + //if stringizing operator + if (dt->string[0] == '#' && dt->string[1] == '\0') + { + //the stringizing operator must be followed by a define parameter + if (dt->next) parmnum = PC_FindDefineParm(define, dt->next->string); + else parmnum = -1; + // + if (parmnum >= 0) + { + //step over the stringizing operator + dt = dt->next; + //stringize the define parameter tokens + if (!PC_StringizeTokens(parms[parmnum], &token)) + { + SourceError(source, "can't stringize tokens"); + return qfalse; + } //end if + t = PC_CopyToken(&token); + } //end if + else + { + SourceWarning(source, "stringizing operator without define parameter"); + continue; + } //end if + } //end if + else + { + t = PC_CopyToken(dt); + } //end else + //add the token to the list + t->next = NULL; + if (last) last->next = t; + else first = t; + last = t; + } //end else + } //end for + //check for the merging operator + for (t = first; t; ) + { + if (t->next) + { + //if the merging operator + if (t->next->string[0] == '#' && t->next->string[1] == '#') + { + t1 = t; + t2 = t->next->next; + if (t2) + { + if (!PC_MergeTokens(t1, t2)) + { + SourceError(source, "can't merge %s with %s", t1->string, t2->string); + return qfalse; + } //end if + PC_FreeToken(t1->next); + t1->next = t2->next; + if (t2 == last) last = t1; + PC_FreeToken(t2); + continue; + } //end if + } //end if + } //end if + t = t->next; + } //end for + //store the first and last token of the list + *firsttoken = first; + *lasttoken = last; + //free all the parameter tokens + for (i = 0; i < define->numparms; i++) + { + for (pt = parms[i]; pt; pt = nextpt) + { + nextpt = pt->next; + PC_FreeToken(pt); + } //end for + } //end for + // + return qtrue; +} //end of the function PC_ExpandDefine +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ExpandDefineIntoSource(source_t *source, token_t *deftoken, define_t *define) +{ + token_t *firsttoken, *lasttoken; + + if (!PC_ExpandDefine(source, deftoken, define, &firsttoken, &lasttoken)) return qfalse; + + if (firsttoken && lasttoken) + { + lasttoken->next = source->tokens; + source->tokens = firsttoken; + return qtrue; + } //end if + return qfalse; +} //end of the function PC_ExpandDefineIntoSource +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_ConvertPath(char *path) +{ + char *ptr; + + //remove double path seperators + for (ptr = path; *ptr;) + { + if ((*ptr == '\\' || *ptr == '/') && + (*(ptr+1) == '\\' || *(ptr+1) == '/')) + { + strcpy(ptr, ptr+1); + } //end if + else + { + ptr++; + } //end else + } //end while + //set OS dependent path seperators + for (ptr = path; *ptr;) + { + if (*ptr == '/' || *ptr == '\\') *ptr = PATHSEPERATOR_CHAR; + ptr++; + } //end while +} //end of the function PC_ConvertPath +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_include(source_t *source) +{ + script_t *script; + token_t token; + char path[MAX_PATH]; +#ifdef QUAKE + foundfile_t file; +#endif //QUAKE + + if (source->skip > 0) return qtrue; + // + if (!PC_ReadSourceToken(source, &token)) + { + SourceError(source, "#include without file name"); + return qfalse; + } //end if + if (token.linescrossed > 0) + { + SourceError(source, "#include without file name"); + return qfalse; + } //end if + if (token.type == TT_STRING) + { + StripDoubleQuotes(token.string); + PC_ConvertPath(token.string); + script = LoadScriptFile(token.string); + if (!script) + { + strcpy(path, source->includepath); + strcat(path, token.string); + script = LoadScriptFile(path); + } //end if + } //end if + else if (token.type == TT_PUNCTUATION && *token.string == '<') + { + strcpy(path, source->includepath); + while(PC_ReadSourceToken(source, &token)) + { + if (token.linescrossed > 0) + { + PC_UnreadSourceToken(source, &token); + break; + } //end if + if (token.type == TT_PUNCTUATION && *token.string == '>') break; + strncat(path, token.string, MAX_PATH - 1); + } //end while + if (*token.string != '>') + { + SourceWarning(source, "#include missing trailing >"); + } //end if + if (!strlen(path)) + { + SourceError(source, "#include without file name between < >"); + return qfalse; + } //end if + PC_ConvertPath(path); + script = LoadScriptFile(path); + } //end if + else + { + SourceError(source, "#include without file name"); + return qfalse; + } //end else +#ifdef QUAKE + if (!script) + { + Com_Memset(&file, 0, sizeof(foundfile_t)); + script = LoadScriptFile(path); + if (script) strncpy(script->filename, path, MAX_PATH); + } //end if +#endif //QUAKE + if (!script) + { +#ifdef SCREWUP + SourceWarning(source, "file %s not found", path); + return qtrue; +#else + SourceError(source, "file %s not found", path); + return qfalse; +#endif //SCREWUP + } //end if + PC_PushScript(source, script); + return qtrue; +} //end of the function PC_Directive_include +//============================================================================ +// reads a token from the current line, continues reading on the next +// line only if a backslash '\' is encountered. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ReadLine(source_t *source, token_t *token) +{ + int crossline; + + crossline = 0; + do + { + if (!PC_ReadSourceToken(source, token)) return qfalse; + + if (token->linescrossed > crossline) + { + PC_UnreadSourceToken(source, token); + return qfalse; + } //end if + crossline = 1; + } while(!strcmp(token->string, "\\")); + return qtrue; +} //end of the function PC_ReadLine +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_WhiteSpaceBeforeToken(token_t *token) +{ + return token->endwhitespace_p - token->whitespace_p > 0; +} //end of the function PC_WhiteSpaceBeforeToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_ClearTokenWhiteSpace(token_t *token) +{ + token->whitespace_p = NULL; + token->endwhitespace_p = NULL; + token->linescrossed = 0; +} //end of the function PC_ClearTokenWhiteSpace +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_undef(source_t *source) +{ + token_t token; + define_t *define, *lastdefine; + int hash; + + if (source->skip > 0) return qtrue; + // + if (!PC_ReadLine(source, &token)) + { + SourceError(source, "undef without name"); + return qfalse; + } //end if + if (token.type != TT_NAME) + { + PC_UnreadSourceToken(source, &token); + SourceError(source, "expected name, found %s", token.string); + return qfalse; + } //end if +#if DEFINEHASHING + + hash = PC_NameHash(token.string); + for (lastdefine = NULL, define = source->definehash[hash]; define; define = define->hashnext) + { + if (!strcmp(define->name, token.string)) + { + if (define->flags & DEFINE_FIXED) + { + SourceWarning(source, "can't undef %s", token.string); + } //end if + else + { + if (lastdefine) lastdefine->hashnext = define->hashnext; + else source->definehash[hash] = define->hashnext; + PC_FreeDefine(define); + } //end else + break; + } //end if + lastdefine = define; + } //end for +#else //DEFINEHASHING + for (lastdefine = NULL, define = source->defines; define; define = define->next) + { + if (!strcmp(define->name, token.string)) + { + if (define->flags & DEFINE_FIXED) + { + SourceWarning(source, "can't undef %s", token.string); + } //end if + else + { + if (lastdefine) lastdefine->next = define->next; + else source->defines = define->next; + PC_FreeDefine(define); + } //end else + break; + } //end if + lastdefine = define; + } //end for +#endif //DEFINEHASHING + return qtrue; +} //end of the function PC_Directive_undef +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_define(source_t *source) +{ + token_t token, *t, *last; + define_t *define; + + if (source->skip > 0) return qtrue; + // + if (!PC_ReadLine(source, &token)) + { + SourceError(source, "#define without name"); + return qfalse; + } //end if + if (token.type != TT_NAME) + { + PC_UnreadSourceToken(source, &token); + SourceError(source, "expected name after #define, found %s", token.string); + return qfalse; + } //end if + //check if the define already exists +#if DEFINEHASHING + define = PC_FindHashedDefine(source->definehash, token.string); +#else + define = PC_FindDefine(source->defines, token.string); +#endif //DEFINEHASHING + if (define) + { + if (define->flags & DEFINE_FIXED) + { + SourceError(source, "can't redefine %s", token.string); + return qfalse; + } //end if + SourceWarning(source, "redefinition of %s", token.string); + //unread the define name before executing the #undef directive + PC_UnreadSourceToken(source, &token); + if (!PC_Directive_undef(source)) return qfalse; + //if the define was not removed (define->flags & DEFINE_FIXED) +#if DEFINEHASHING + define = PC_FindHashedDefine(source->definehash, token.string); +#else + define = PC_FindDefine(source->defines, token.string); +#endif //DEFINEHASHING + } //end if + //allocate define + define = (define_t *) GetMemory(sizeof(define_t)); + Com_Memset(define, 0, sizeof(define_t)); + define->name = (char *) GetMemory(strlen(token.string) + 1); + strcpy(define->name, token.string); + //add the define to the source +#if DEFINEHASHING + PC_AddDefineToHash(define, source->definehash); +#else //DEFINEHASHING + define->next = source->defines; + source->defines = define; +#endif //DEFINEHASHING + //if nothing is defined, just return + if (!PC_ReadLine(source, &token)) return qtrue; + //if it is a define with parameters + if (!PC_WhiteSpaceBeforeToken(&token) && !strcmp(token.string, "(")) + { + //read the define parameters + last = NULL; + if (!PC_CheckTokenString(source, ")")) + { + while(1) + { + if (!PC_ReadLine(source, &token)) + { + SourceError(source, "expected define parameter"); + return qfalse; + } //end if + //if it isn't a name + if (token.type != TT_NAME) + { + SourceError(source, "invalid define parameter"); + return qfalse; + } //end if + // + if (PC_FindDefineParm(define, token.string) >= 0) + { + SourceError(source, "two the same define parameters"); + return qfalse; + } //end if + //add the define parm + t = PC_CopyToken(&token); + PC_ClearTokenWhiteSpace(t); + t->next = NULL; + if (last) last->next = t; + else define->parms = t; + last = t; + define->numparms++; + //read next token + if (!PC_ReadLine(source, &token)) + { + SourceError(source, "define parameters not terminated"); + return qfalse; + } //end if + // + if (!strcmp(token.string, ")")) break; + //then it must be a comma + if (strcmp(token.string, ",")) + { + SourceError(source, "define not terminated"); + return qfalse; + } //end if + } //end while + } //end if + if (!PC_ReadLine(source, &token)) return qtrue; + } //end if + //read the defined stuff + last = NULL; + do + { + t = PC_CopyToken(&token); + if (t->type == TT_NAME && !strcmp(t->string, define->name)) + { + SourceError(source, "recursive define (removed recursion)"); + continue; + } //end if + PC_ClearTokenWhiteSpace(t); + t->next = NULL; + if (last) last->next = t; + else define->tokens = t; + last = t; + } while(PC_ReadLine(source, &token)); + // + if (last) + { + //check for merge operators at the beginning or end + if (!strcmp(define->tokens->string, "##") || + !strcmp(last->string, "##")) + { + SourceError(source, "define with misplaced ##"); + return qfalse; + } //end if + } //end if + return qtrue; +} //end of the function PC_Directive_define +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +define_t *PC_DefineFromString(char *string) +{ + script_t *script; + source_t src; + token_t *t; + int res, i; + define_t *def; + + PC_InitTokenHeap(); + + script = LoadScriptMemory(string, strlen(string), "*extern"); + //create a new source + Com_Memset(&src, 0, sizeof(source_t)); + strncpy(src.filename, "*extern", MAX_PATH); + src.scriptstack = script; +#if DEFINEHASHING + src.definehash = GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *)); +#endif //DEFINEHASHING + //create a define from the source + res = PC_Directive_define(&src); + //free any tokens if left + for (t = src.tokens; t; t = src.tokens) + { + src.tokens = src.tokens->next; + PC_FreeToken(t); + } //end for +#ifdef DEFINEHASHING + def = NULL; + for (i = 0; i < DEFINEHASHSIZE; i++) + { + if (src.definehash[i]) + { + def = src.definehash[i]; + break; + } //end if + } //end for +#else + def = src.defines; +#endif //DEFINEHASHING + // +#if DEFINEHASHING + FreeMemory(src.definehash); +#endif //DEFINEHASHING + // + FreeScript(script); + //if the define was created succesfully + if (res > 0) return def; + //free the define is created + if (src.defines) PC_FreeDefine(def); + // + return NULL; +} //end of the function PC_DefineFromString +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_AddDefine(source_t *source, char *string) +{ + define_t *define; + + define = PC_DefineFromString(string); + if (!define) return qfalse; +#if DEFINEHASHING + PC_AddDefineToHash(define, source->definehash); +#else //DEFINEHASHING + define->next = source->defines; + source->defines = define; +#endif //DEFINEHASHING + return qtrue; +} //end of the function PC_AddDefine +//============================================================================ +// add a globals define that will be added to all opened sources +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_AddGlobalDefine(char *string) +{ + define_t *define; + + define = PC_DefineFromString(string); + if (!define) return qfalse; + define->next = globaldefines; + globaldefines = define; + return qtrue; +} //end of the function PC_AddGlobalDefine +//============================================================================ +// remove the given global define +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_RemoveGlobalDefine(char *name) +{ + define_t *define; + + define = PC_FindDefine(globaldefines, name); + if (define) + { + PC_FreeDefine(define); + return qtrue; + } //end if + return qfalse; +} //end of the function PC_RemoveGlobalDefine +//============================================================================ +// remove all globals defines +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_RemoveAllGlobalDefines(void) +{ + define_t *define; + + for (define = globaldefines; define; define = globaldefines) + { + globaldefines = globaldefines->next; + PC_FreeDefine(define); + } //end for +} //end of the function PC_RemoveAllGlobalDefines +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +define_t *PC_CopyDefine(source_t *source, define_t *define) +{ + define_t *newdefine; + token_t *token, *newtoken, *lasttoken; + + newdefine = (define_t *) GetMemory(sizeof(define_t)); + //copy the define name + newdefine->name = (char *) GetMemory(strlen(define->name) + 1); + strcpy(newdefine->name, define->name); + newdefine->flags = define->flags; + newdefine->builtin = define->builtin; + newdefine->numparms = define->numparms; + //the define is not linked + newdefine->next = NULL; + newdefine->hashnext = NULL; + //copy the define tokens + newdefine->tokens = NULL; + for (lasttoken = NULL, token = define->tokens; token; token = token->next) + { + newtoken = PC_CopyToken(token); + newtoken->next = NULL; + if (lasttoken) lasttoken->next = newtoken; + else newdefine->tokens = newtoken; + lasttoken = newtoken; + } //end for + //copy the define parameters + newdefine->parms = NULL; + for (lasttoken = NULL, token = define->parms; token; token = token->next) + { + newtoken = PC_CopyToken(token); + newtoken->next = NULL; + if (lasttoken) lasttoken->next = newtoken; + else newdefine->parms = newtoken; + lasttoken = newtoken; + } //end for + return newdefine; +} //end of the function PC_CopyDefine +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_AddGlobalDefinesToSource(source_t *source) +{ + define_t *define, *newdefine; + + for (define = globaldefines; define; define = define->next) + { + newdefine = PC_CopyDefine(source, define); +#if DEFINEHASHING + PC_AddDefineToHash(newdefine, source->definehash); +#else //DEFINEHASHING + newdefine->next = source->defines; + source->defines = newdefine; +#endif //DEFINEHASHING + } //end for +} //end of the function PC_AddGlobalDefinesToSource +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_if_def(source_t *source, int type) +{ + token_t token; + define_t *d; + int skip; + + if (!PC_ReadLine(source, &token)) + { + SourceError(source, "#ifdef without name"); + return qfalse; + } //end if + if (token.type != TT_NAME) + { + PC_UnreadSourceToken(source, &token); + SourceError(source, "expected name after #ifdef, found %s", token.string); + return qfalse; + } //end if +#if DEFINEHASHING + d = PC_FindHashedDefine(source->definehash, token.string); +#else + d = PC_FindDefine(source->defines, token.string); +#endif //DEFINEHASHING + skip = (type == INDENT_IFDEF) == (d == NULL); + PC_PushIndent(source, type, skip); + return qtrue; +} //end of the function PC_Directiveif_def +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_ifdef(source_t *source) +{ + return PC_Directive_if_def(source, INDENT_IFDEF); +} //end of the function PC_Directive_ifdef +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_ifndef(source_t *source) +{ + return PC_Directive_if_def(source, INDENT_IFNDEF); +} //end of the function PC_Directive_ifndef +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_else(source_t *source) +{ + int type, skip; + + PC_PopIndent(source, &type, &skip); + if (!type) + { + SourceError(source, "misplaced #else"); + return qfalse; + } //end if + if (type == INDENT_ELSE) + { + SourceError(source, "#else after #else"); + return qfalse; + } //end if + PC_PushIndent(source, INDENT_ELSE, !skip); + return qtrue; +} //end of the function PC_Directive_else +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_endif(source_t *source) +{ + int type, skip; + + PC_PopIndent(source, &type, &skip); + if (!type) + { + SourceError(source, "misplaced #endif"); + return qfalse; + } //end if + return qtrue; +} //end of the function PC_Directive_endif +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +typedef struct operator_s +{ + int operator; + int priority; + int parentheses; + struct operator_s *prev, *next; +} operator_t; + +typedef struct value_s +{ + signed long int intvalue; + double floatvalue; + int parentheses; + struct value_s *prev, *next; +} value_t; + +int PC_OperatorPriority(int op) +{ + switch(op) + { + case P_MUL: return 15; + case P_DIV: return 15; + case P_MOD: return 15; + case P_ADD: return 14; + case P_SUB: return 14; + + case P_LOGIC_AND: return 7; + case P_LOGIC_OR: return 6; + case P_LOGIC_GEQ: return 12; + case P_LOGIC_LEQ: return 12; + case P_LOGIC_EQ: return 11; + case P_LOGIC_UNEQ: return 11; + + case P_LOGIC_NOT: return 16; + case P_LOGIC_GREATER: return 12; + case P_LOGIC_LESS: return 12; + + case P_RSHIFT: return 13; + case P_LSHIFT: return 13; + + case P_BIN_AND: return 10; + case P_BIN_OR: return 8; + case P_BIN_XOR: return 9; + case P_BIN_NOT: return 16; + + case P_COLON: return 5; + case P_QUESTIONMARK: return 5; + } //end switch + return qfalse; +} //end of the function PC_OperatorPriority + +//#define AllocValue() GetClearedMemory(sizeof(value_t)); +//#define FreeValue(val) FreeMemory(val) +//#define AllocOperator(op) op = (operator_t *) GetClearedMemory(sizeof(operator_t)); +//#define FreeOperator(op) FreeMemory(op); + +#define MAX_VALUES 64 +#define MAX_OPERATORS 64 +#define AllocValue(val) \ + if (numvalues >= MAX_VALUES) { \ + SourceError(source, "out of value space\n"); \ + error = 1; \ + break; \ + } \ + else \ + val = &value_heap[numvalues++]; +#define FreeValue(val) +// +#define AllocOperator(op) \ + if (numoperators >= MAX_OPERATORS) { \ + SourceError(source, "out of operator space\n"); \ + error = 1; \ + break; \ + } \ + else \ + op = &operator_heap[numoperators++]; +#define FreeOperator(op) + +int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intvalue, + double *floatvalue, int integer) +{ + operator_t *o, *firstoperator, *lastoperator; + value_t *v, *firstvalue, *lastvalue, *v1, *v2; + token_t *t; + int brace = 0; + int parentheses = 0; + int error = 0; + int lastwasvalue = 0; + int negativevalue = 0; + int questmarkintvalue = 0; + double questmarkfloatvalue = 0; + int gotquestmarkvalue = qfalse; + int lastoperatortype = 0; + // + operator_t operator_heap[MAX_OPERATORS]; + int numoperators = 0; + value_t value_heap[MAX_VALUES]; + int numvalues = 0; + + firstoperator = lastoperator = NULL; + firstvalue = lastvalue = NULL; + if (intvalue) *intvalue = 0; + if (floatvalue) *floatvalue = 0; + for (t = tokens; t; t = t->next) + { + switch(t->type) + { + case TT_NAME: + { + if (lastwasvalue || negativevalue) + { + SourceError(source, "syntax error in #if/#elif"); + error = 1; + break; + } //end if + if (strcmp(t->string, "defined")) + { + SourceError(source, "undefined name %s in #if/#elif", t->string); + error = 1; + break; + } //end if + t = t->next; + if (!strcmp(t->string, "(")) + { + brace = qtrue; + t = t->next; + } //end if + if (!t || t->type != TT_NAME) + { + SourceError(source, "defined without name in #if/#elif"); + error = 1; + break; + } //end if + //v = (value_t *) GetClearedMemory(sizeof(value_t)); + AllocValue(v); +#if DEFINEHASHING + if (PC_FindHashedDefine(source->definehash, t->string)) +#else + if (PC_FindDefine(source->defines, t->string)) +#endif //DEFINEHASHING + { + v->intvalue = 1; + v->floatvalue = 1; + } //end if + else + { + v->intvalue = 0; + v->floatvalue = 0; + } //end else + v->parentheses = parentheses; + v->next = NULL; + v->prev = lastvalue; + if (lastvalue) lastvalue->next = v; + else firstvalue = v; + lastvalue = v; + if (brace) + { + t = t->next; + if (!t || strcmp(t->string, ")")) + { + SourceError(source, "defined without ) in #if/#elif"); + error = 1; + break; + } //end if + } //end if + brace = qfalse; + // defined() creates a value + lastwasvalue = 1; + break; + } //end case + case TT_NUMBER: + { + if (lastwasvalue) + { + SourceError(source, "syntax error in #if/#elif"); + error = 1; + break; + } //end if + //v = (value_t *) GetClearedMemory(sizeof(value_t)); + AllocValue(v); + if (negativevalue) + { + v->intvalue = - (signed int) t->intvalue; + v->floatvalue = - t->floatvalue; + } //end if + else + { + v->intvalue = t->intvalue; + v->floatvalue = t->floatvalue; + } //end else + v->parentheses = parentheses; + v->next = NULL; + v->prev = lastvalue; + if (lastvalue) lastvalue->next = v; + else firstvalue = v; + lastvalue = v; + //last token was a value + lastwasvalue = 1; + // + negativevalue = 0; + break; + } //end case + case TT_PUNCTUATION: + { + if (negativevalue) + { + SourceError(source, "misplaced minus sign in #if/#elif"); + error = 1; + break; + } //end if + if (t->subtype == P_PARENTHESESOPEN) + { + parentheses++; + break; + } //end if + else if (t->subtype == P_PARENTHESESCLOSE) + { + parentheses--; + if (parentheses < 0) + { + SourceError(source, "too many ) in #if/#elsif"); + error = 1; + } //end if + break; + } //end else if + //check for invalid operators on floating point values + if (!integer) + { + if (t->subtype == P_BIN_NOT || t->subtype == P_MOD || + t->subtype == P_RSHIFT || t->subtype == P_LSHIFT || + t->subtype == P_BIN_AND || t->subtype == P_BIN_OR || + t->subtype == P_BIN_XOR) + { + SourceError(source, "illigal operator %s on floating point operands\n", t->string); + error = 1; + break; + } //end if + } //end if + switch(t->subtype) + { + case P_LOGIC_NOT: + case P_BIN_NOT: + { + if (lastwasvalue) + { + SourceError(source, "! or ~ after value in #if/#elif"); + error = 1; + break; + } //end if + break; + } //end case + case P_INC: + case P_DEC: + { + SourceError(source, "++ or -- used in #if/#elif"); + break; + } //end case + case P_SUB: + { + if (!lastwasvalue) + { + negativevalue = 1; + break; + } //end if + } //end case + + case P_MUL: + case P_DIV: + case P_MOD: + case P_ADD: + + case P_LOGIC_AND: + case P_LOGIC_OR: + case P_LOGIC_GEQ: + case P_LOGIC_LEQ: + case P_LOGIC_EQ: + case P_LOGIC_UNEQ: + + case P_LOGIC_GREATER: + case P_LOGIC_LESS: + + case P_RSHIFT: + case P_LSHIFT: + + case P_BIN_AND: + case P_BIN_OR: + case P_BIN_XOR: + + case P_COLON: + case P_QUESTIONMARK: + { + if (!lastwasvalue) + { + SourceError(source, "operator %s after operator in #if/#elif", t->string); + error = 1; + break; + } //end if + break; + } //end case + default: + { + SourceError(source, "invalid operator %s in #if/#elif", t->string); + error = 1; + break; + } //end default + } //end switch + if (!error && !negativevalue) + { + //o = (operator_t *) GetClearedMemory(sizeof(operator_t)); + AllocOperator(o); + o->operator = t->subtype; + o->priority = PC_OperatorPriority(t->subtype); + o->parentheses = parentheses; + o->next = NULL; + o->prev = lastoperator; + if (lastoperator) lastoperator->next = o; + else firstoperator = o; + lastoperator = o; + lastwasvalue = 0; + } //end if + break; + } //end case + default: + { + SourceError(source, "unknown %s in #if/#elif", t->string); + error = 1; + break; + } //end default + } //end switch + if (error) break; + } //end for + if (!error) + { + if (!lastwasvalue) + { + SourceError(source, "trailing operator in #if/#elif"); + error = 1; + } //end if + else if (parentheses) + { + SourceError(source, "too many ( in #if/#elif"); + error = 1; + } //end else if + } //end if + // + gotquestmarkvalue = qfalse; + questmarkintvalue = 0; + questmarkfloatvalue = 0; + //while there are operators + while(!error && firstoperator) + { + v = firstvalue; + for (o = firstoperator; o->next; o = o->next) + { + //if the current operator is nested deeper in parentheses + //than the next operator + if (o->parentheses > o->next->parentheses) break; + //if the current and next operator are nested equally deep in parentheses + if (o->parentheses == o->next->parentheses) + { + //if the priority of the current operator is equal or higher + //than the priority of the next operator + if (o->priority >= o->next->priority) break; + } //end if + //if the arity of the operator isn't equal to 1 + if (o->operator != P_LOGIC_NOT + && o->operator != P_BIN_NOT) v = v->next; + //if there's no value or no next value + if (!v) + { + SourceError(source, "mising values in #if/#elif"); + error = 1; + break; + } //end if + } //end for + if (error) break; + v1 = v; + v2 = v->next; +#ifdef DEBUG_EVAL + if (integer) + { + Log_Write("operator %s, value1 = %d", PunctuationFromNum(source->scriptstack, o->operator), v1->intvalue); + if (v2) Log_Write("value2 = %d", v2->intvalue); + } //end if + else + { + Log_Write("operator %s, value1 = %f", PunctuationFromNum(source->scriptstack, o->operator), v1->floatvalue); + if (v2) Log_Write("value2 = %f", v2->floatvalue); + } //end else +#endif //DEBUG_EVAL + switch(o->operator) + { + case P_LOGIC_NOT: v1->intvalue = !v1->intvalue; + v1->floatvalue = !v1->floatvalue; break; + case P_BIN_NOT: v1->intvalue = ~v1->intvalue; + break; + case P_MUL: v1->intvalue *= v2->intvalue; + v1->floatvalue *= v2->floatvalue; break; + case P_DIV: if (!v2->intvalue || !v2->floatvalue) + { + SourceError(source, "divide by zero in #if/#elif\n"); + error = 1; + break; + } + v1->intvalue /= v2->intvalue; + v1->floatvalue /= v2->floatvalue; break; + case P_MOD: if (!v2->intvalue) + { + SourceError(source, "divide by zero in #if/#elif\n"); + error = 1; + break; + } + v1->intvalue %= v2->intvalue; break; + case P_ADD: v1->intvalue += v2->intvalue; + v1->floatvalue += v2->floatvalue; break; + case P_SUB: v1->intvalue -= v2->intvalue; + v1->floatvalue -= v2->floatvalue; break; + case P_LOGIC_AND: v1->intvalue = v1->intvalue && v2->intvalue; + v1->floatvalue = v1->floatvalue && v2->floatvalue; break; + case P_LOGIC_OR: v1->intvalue = v1->intvalue || v2->intvalue; + v1->floatvalue = v1->floatvalue || v2->floatvalue; break; + case P_LOGIC_GEQ: v1->intvalue = v1->intvalue >= v2->intvalue; + v1->floatvalue = v1->floatvalue >= v2->floatvalue; break; + case P_LOGIC_LEQ: v1->intvalue = v1->intvalue <= v2->intvalue; + v1->floatvalue = v1->floatvalue <= v2->floatvalue; break; + case P_LOGIC_EQ: v1->intvalue = v1->intvalue == v2->intvalue; + v1->floatvalue = v1->floatvalue == v2->floatvalue; break; + case P_LOGIC_UNEQ: v1->intvalue = v1->intvalue != v2->intvalue; + v1->floatvalue = v1->floatvalue != v2->floatvalue; break; + case P_LOGIC_GREATER: v1->intvalue = v1->intvalue > v2->intvalue; + v1->floatvalue = v1->floatvalue > v2->floatvalue; break; + case P_LOGIC_LESS: v1->intvalue = v1->intvalue < v2->intvalue; + v1->floatvalue = v1->floatvalue < v2->floatvalue; break; + case P_RSHIFT: v1->intvalue >>= v2->intvalue; + break; + case P_LSHIFT: v1->intvalue <<= v2->intvalue; + break; + case P_BIN_AND: v1->intvalue &= v2->intvalue; + break; + case P_BIN_OR: v1->intvalue |= v2->intvalue; + break; + case P_BIN_XOR: v1->intvalue ^= v2->intvalue; + break; + case P_COLON: + { + if (!gotquestmarkvalue) + { + SourceError(source, ": without ? in #if/#elif"); + error = 1; + break; + } //end if + if (integer) + { + if (!questmarkintvalue) v1->intvalue = v2->intvalue; + } //end if + else + { + if (!questmarkfloatvalue) v1->floatvalue = v2->floatvalue; + } //end else + gotquestmarkvalue = qfalse; + break; + } //end case + case P_QUESTIONMARK: + { + if (gotquestmarkvalue) + { + SourceError(source, "? after ? in #if/#elif"); + error = 1; + break; + } //end if + questmarkintvalue = v1->intvalue; + questmarkfloatvalue = v1->floatvalue; + gotquestmarkvalue = qtrue; + break; + } //end if + } //end switch +#ifdef DEBUG_EVAL + if (integer) Log_Write("result value = %d", v1->intvalue); + else Log_Write("result value = %f", v1->floatvalue); +#endif //DEBUG_EVAL + if (error) break; + lastoperatortype = o->operator; + //if not an operator with arity 1 + if (o->operator != P_LOGIC_NOT + && o->operator != P_BIN_NOT) + { + //remove the second value if not question mark operator + if (o->operator != P_QUESTIONMARK) v = v->next; + // + if (v->prev) v->prev->next = v->next; + else firstvalue = v->next; + if (v->next) v->next->prev = v->prev; + else lastvalue = v->prev; + //FreeMemory(v); + FreeValue(v); + } //end if + //remove the operator + if (o->prev) o->prev->next = o->next; + else firstoperator = o->next; + if (o->next) o->next->prev = o->prev; + else lastoperator = o->prev; + //FreeMemory(o); + FreeOperator(o); + } //end while + if (firstvalue) + { + if (intvalue) *intvalue = firstvalue->intvalue; + if (floatvalue) *floatvalue = firstvalue->floatvalue; + } //end if + for (o = firstoperator; o; o = lastoperator) + { + lastoperator = o->next; + //FreeMemory(o); + FreeOperator(o); + } //end for + for (v = firstvalue; v; v = lastvalue) + { + lastvalue = v->next; + //FreeMemory(v); + FreeValue(v); + } //end for + if (!error) return qtrue; + if (intvalue) *intvalue = 0; + if (floatvalue) *floatvalue = 0; + return qfalse; +} //end of the function PC_EvaluateTokens +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Evaluate(source_t *source, signed long int *intvalue, + double *floatvalue, int integer) +{ + token_t token, *firsttoken, *lasttoken; + token_t *t, *nexttoken; + define_t *define; + int defined = qfalse; + + if (intvalue) *intvalue = 0; + if (floatvalue) *floatvalue = 0; + // + if (!PC_ReadLine(source, &token)) + { + SourceError(source, "no value after #if/#elif"); + return qfalse; + } //end if + firsttoken = NULL; + lasttoken = NULL; + do + { + //if the token is a name + if (token.type == TT_NAME) + { + if (defined) + { + defined = qfalse; + t = PC_CopyToken(&token); + t->next = NULL; + if (lasttoken) lasttoken->next = t; + else firsttoken = t; + lasttoken = t; + } //end if + else if (!strcmp(token.string, "defined")) + { + defined = qtrue; + t = PC_CopyToken(&token); + t->next = NULL; + if (lasttoken) lasttoken->next = t; + else firsttoken = t; + lasttoken = t; + } //end if + else + { + //then it must be a define +#if DEFINEHASHING + define = PC_FindHashedDefine(source->definehash, token.string); +#else + define = PC_FindDefine(source->defines, token.string); +#endif //DEFINEHASHING + if (!define) + { + SourceError(source, "can't evaluate %s, not defined", token.string); + return qfalse; + } //end if + if (!PC_ExpandDefineIntoSource(source, &token, define)) return qfalse; + } //end else + } //end if + //if the token is a number or a punctuation + else if (token.type == TT_NUMBER || token.type == TT_PUNCTUATION) + { + t = PC_CopyToken(&token); + t->next = NULL; + if (lasttoken) lasttoken->next = t; + else firsttoken = t; + lasttoken = t; + } //end else + else //can't evaluate the token + { + SourceError(source, "can't evaluate %s", token.string); + return qfalse; + } //end else + } while(PC_ReadLine(source, &token)); + // + if (!PC_EvaluateTokens(source, firsttoken, intvalue, floatvalue, integer)) return qfalse; + // +#ifdef DEBUG_EVAL + Log_Write("eval:"); +#endif //DEBUG_EVAL + for (t = firsttoken; t; t = nexttoken) + { +#ifdef DEBUG_EVAL + Log_Write(" %s", t->string); +#endif //DEBUG_EVAL + nexttoken = t->next; + PC_FreeToken(t); + } //end for +#ifdef DEBUG_EVAL + if (integer) Log_Write("eval result: %d", *intvalue); + else Log_Write("eval result: %f", *floatvalue); +#endif //DEBUG_EVAL + // + return qtrue; +} //end of the function PC_Evaluate +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_DollarEvaluate(source_t *source, signed long int *intvalue, + double *floatvalue, int integer) +{ + int indent, defined = qfalse; + token_t token, *firsttoken, *lasttoken; + token_t *t, *nexttoken; + define_t *define; + + if (intvalue) *intvalue = 0; + if (floatvalue) *floatvalue = 0; + // + if (!PC_ReadSourceToken(source, &token)) + { + SourceError(source, "no leading ( after $evalint/$evalfloat"); + return qfalse; + } //end if + if (!PC_ReadSourceToken(source, &token)) + { + SourceError(source, "nothing to evaluate"); + return qfalse; + } //end if + indent = 1; + firsttoken = NULL; + lasttoken = NULL; + do + { + //if the token is a name + if (token.type == TT_NAME) + { + if (defined) + { + defined = qfalse; + t = PC_CopyToken(&token); + t->next = NULL; + if (lasttoken) lasttoken->next = t; + else firsttoken = t; + lasttoken = t; + } //end if + else if (!strcmp(token.string, "defined")) + { + defined = qtrue; + t = PC_CopyToken(&token); + t->next = NULL; + if (lasttoken) lasttoken->next = t; + else firsttoken = t; + lasttoken = t; + } //end if + else + { + //then it must be a define +#if DEFINEHASHING + define = PC_FindHashedDefine(source->definehash, token.string); +#else + define = PC_FindDefine(source->defines, token.string); +#endif //DEFINEHASHING + if (!define) + { + SourceError(source, "can't evaluate %s, not defined", token.string); + return qfalse; + } //end if + if (!PC_ExpandDefineIntoSource(source, &token, define)) return qfalse; + } //end else + } //end if + //if the token is a number or a punctuation + else if (token.type == TT_NUMBER || token.type == TT_PUNCTUATION) + { + if (*token.string == '(') indent++; + else if (*token.string == ')') indent--; + if (indent <= 0) break; + t = PC_CopyToken(&token); + t->next = NULL; + if (lasttoken) lasttoken->next = t; + else firsttoken = t; + lasttoken = t; + } //end else + else //can't evaluate the token + { + SourceError(source, "can't evaluate %s", token.string); + return qfalse; + } //end else + } while(PC_ReadSourceToken(source, &token)); + // + if (!PC_EvaluateTokens(source, firsttoken, intvalue, floatvalue, integer)) return qfalse; + // +#ifdef DEBUG_EVAL + Log_Write("$eval:"); +#endif //DEBUG_EVAL + for (t = firsttoken; t; t = nexttoken) + { +#ifdef DEBUG_EVAL + Log_Write(" %s", t->string); +#endif //DEBUG_EVAL + nexttoken = t->next; + PC_FreeToken(t); + } //end for +#ifdef DEBUG_EVAL + if (integer) Log_Write("$eval result: %d", *intvalue); + else Log_Write("$eval result: %f", *floatvalue); +#endif //DEBUG_EVAL + // + return qtrue; +} //end of the function PC_DollarEvaluate +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_elif(source_t *source) +{ + signed long int value; + int type, skip; + + PC_PopIndent(source, &type, &skip); + if (!type || type == INDENT_ELSE) + { + SourceError(source, "misplaced #elif"); + return qfalse; + } //end if + if (!PC_Evaluate(source, &value, NULL, qtrue)) return qfalse; + skip = (value == 0); + PC_PushIndent(source, INDENT_ELIF, skip); + return qtrue; +} //end of the function PC_Directive_elif +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_if(source_t *source) +{ + signed long int value; + int skip; + + if (!PC_Evaluate(source, &value, NULL, qtrue)) return qfalse; + skip = (value == 0); + PC_PushIndent(source, INDENT_IF, skip); + return qtrue; +} //end of the function PC_Directive +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_line(source_t *source) +{ + SourceError(source, "#line directive not supported"); + return qfalse; +} //end of the function PC_Directive_line +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_error(source_t *source) +{ + token_t token; + + strcpy(token.string, ""); + PC_ReadSourceToken(source, &token); + SourceError(source, "#error directive: %s", token.string); + return qfalse; +} //end of the function PC_Directive_error +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_pragma(source_t *source) +{ + token_t token; + + SourceWarning(source, "#pragma directive not supported"); + while(PC_ReadLine(source, &token)) ; + return qtrue; +} //end of the function PC_Directive_pragma +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void UnreadSignToken(source_t *source) +{ + token_t token; + + token.line = source->scriptstack->line; + token.whitespace_p = source->scriptstack->script_p; + token.endwhitespace_p = source->scriptstack->script_p; + token.linescrossed = 0; + strcpy(token.string, "-"); + token.type = TT_PUNCTUATION; + token.subtype = P_SUB; + PC_UnreadSourceToken(source, &token); +} //end of the function UnreadSignToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_eval(source_t *source) +{ + signed long int value; + token_t token; + + if (!PC_Evaluate(source, &value, NULL, qtrue)) return qfalse; + // + token.line = source->scriptstack->line; + token.whitespace_p = source->scriptstack->script_p; + token.endwhitespace_p = source->scriptstack->script_p; + token.linescrossed = 0; + sprintf(token.string, "%d", abs(value)); + token.type = TT_NUMBER; + token.subtype = TT_INTEGER|TT_LONG|TT_DECIMAL; + PC_UnreadSourceToken(source, &token); + if (value < 0) UnreadSignToken(source); + return qtrue; +} //end of the function PC_Directive_eval +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_Directive_evalfloat(source_t *source) +{ + double value; + token_t token; + + if (!PC_Evaluate(source, NULL, &value, qfalse)) return qfalse; + token.line = source->scriptstack->line; + token.whitespace_p = source->scriptstack->script_p; + token.endwhitespace_p = source->scriptstack->script_p; + token.linescrossed = 0; + sprintf(token.string, "%1.2f", fabs(value)); + token.type = TT_NUMBER; + token.subtype = TT_FLOAT|TT_LONG|TT_DECIMAL; + PC_UnreadSourceToken(source, &token); + if (value < 0) UnreadSignToken(source); + return qtrue; +} //end of the function PC_Directive_evalfloat +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +directive_t directives[20] = +{ + {"if", PC_Directive_if}, + {"ifdef", PC_Directive_ifdef}, + {"ifndef", PC_Directive_ifndef}, + {"elif", PC_Directive_elif}, + {"else", PC_Directive_else}, + {"endif", PC_Directive_endif}, + {"include", PC_Directive_include}, + {"define", PC_Directive_define}, + {"undef", PC_Directive_undef}, + {"line", PC_Directive_line}, + {"error", PC_Directive_error}, + {"pragma", PC_Directive_pragma}, + {"eval", PC_Directive_eval}, + {"evalfloat", PC_Directive_evalfloat}, + {NULL, NULL} +}; + +int PC_ReadDirective(source_t *source) +{ + token_t token; + int i; + + //read the directive name + if (!PC_ReadSourceToken(source, &token)) + { + SourceError(source, "found # without name"); + return qfalse; + } //end if + //directive name must be on the same line + if (token.linescrossed > 0) + { + PC_UnreadSourceToken(source, &token); + SourceError(source, "found # at end of line"); + return qfalse; + } //end if + //if if is a name + if (token.type == TT_NAME) + { + //find the precompiler directive + for (i = 0; directives[i].name; i++) + { + if (!strcmp(directives[i].name, token.string)) + { + return directives[i].func(source); + } //end if + } //end for + } //end if + SourceError(source, "unknown precompiler directive %s", token.string); + return qfalse; +} //end of the function PC_ReadDirective +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_DollarDirective_evalint(source_t *source) +{ + signed long int value; + token_t token; + + if (!PC_DollarEvaluate(source, &value, NULL, qtrue)) return qfalse; + // + token.line = source->scriptstack->line; + token.whitespace_p = source->scriptstack->script_p; + token.endwhitespace_p = source->scriptstack->script_p; + token.linescrossed = 0; + sprintf(token.string, "%d", abs(value)); + token.type = TT_NUMBER; + token.subtype = TT_INTEGER|TT_LONG|TT_DECIMAL; +#ifdef NUMBERVALUE + token.intvalue = value; + token.floatvalue = value; +#endif //NUMBERVALUE + PC_UnreadSourceToken(source, &token); + if (value < 0) UnreadSignToken(source); + return qtrue; +} //end of the function PC_DollarDirective_evalint +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_DollarDirective_evalfloat(source_t *source) +{ + double value; + token_t token; + + if (!PC_DollarEvaluate(source, NULL, &value, qfalse)) return qfalse; + token.line = source->scriptstack->line; + token.whitespace_p = source->scriptstack->script_p; + token.endwhitespace_p = source->scriptstack->script_p; + token.linescrossed = 0; + sprintf(token.string, "%1.2f", fabs(value)); + token.type = TT_NUMBER; + token.subtype = TT_FLOAT|TT_LONG|TT_DECIMAL; +#ifdef NUMBERVALUE + token.intvalue = (unsigned long) value; + token.floatvalue = value; +#endif //NUMBERVALUE + PC_UnreadSourceToken(source, &token); + if (value < 0) UnreadSignToken(source); + return qtrue; +} //end of the function PC_DollarDirective_evalfloat +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +directive_t dollardirectives[20] = +{ + {"evalint", PC_DollarDirective_evalint}, + {"evalfloat", PC_DollarDirective_evalfloat}, + {NULL, NULL} +}; + +int PC_ReadDollarDirective(source_t *source) +{ + token_t token; + int i; + + //read the directive name + if (!PC_ReadSourceToken(source, &token)) + { + SourceError(source, "found $ without name"); + return qfalse; + } //end if + //directive name must be on the same line + if (token.linescrossed > 0) + { + PC_UnreadSourceToken(source, &token); + SourceError(source, "found $ at end of line"); + return qfalse; + } //end if + //if if is a name + if (token.type == TT_NAME) + { + //find the precompiler directive + for (i = 0; dollardirectives[i].name; i++) + { + if (!strcmp(dollardirectives[i].name, token.string)) + { + return dollardirectives[i].func(source); + } //end if + } //end for + } //end if + PC_UnreadSourceToken(source, &token); + SourceError(source, "unknown precompiler directive %s", token.string); + return qfalse; +} //end of the function PC_ReadDirective + +#ifdef QUAKEC +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int BuiltinFunction(source_t *source) +{ + token_t token; + + if (!PC_ReadSourceToken(source, &token)) return qfalse; + if (token.type == TT_NUMBER) + { + PC_UnreadSourceToken(source, &token); + return qtrue; + } //end if + else + { + PC_UnreadSourceToken(source, &token); + return qfalse; + } //end else +} //end of the function BuiltinFunction +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int QuakeCMacro(source_t *source) +{ + int i; + token_t token; + + if (!PC_ReadSourceToken(source, &token)) return qtrue; + if (token.type != TT_NAME) + { + PC_UnreadSourceToken(source, &token); + return qtrue; + } //end if + //find the precompiler directive + for (i = 0; dollardirectives[i].name; i++) + { + if (!strcmp(dollardirectives[i].name, token.string)) + { + PC_UnreadSourceToken(source, &token); + return qfalse; + } //end if + } //end for + PC_UnreadSourceToken(source, &token); + return qtrue; +} //end of the function QuakeCMacro +#endif //QUAKEC +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ReadToken(source_t *source, token_t *token) +{ + define_t *define; + + while(1) + { + if (!PC_ReadSourceToken(source, token)) return qfalse; + //check for precompiler directives + if (token->type == TT_PUNCTUATION && *token->string == '#') + { +#ifdef QUAKEC + if (!BuiltinFunction(source)) +#endif //QUAKC + { + //read the precompiler directive + if (!PC_ReadDirective(source)) return qfalse; + continue; + } //end if + } //end if + if (token->type == TT_PUNCTUATION && *token->string == '$') + { +#ifdef QUAKEC + if (!QuakeCMacro(source)) +#endif //QUAKEC + { + //read the precompiler directive + if (!PC_ReadDollarDirective(source)) return qfalse; + continue; + } //end if + } //end if + // recursively concatenate strings that are behind each other still resolving defines + if (token->type == TT_STRING) + { + token_t newtoken; + if (PC_ReadToken(source, &newtoken)) + { + if (newtoken.type == TT_STRING) + { + token->string[strlen(token->string)-1] = '\0'; + if (strlen(token->string) + strlen(newtoken.string+1) + 1 >= MAX_TOKEN) + { + SourceError(source, "string longer than MAX_TOKEN %d\n", MAX_TOKEN); + return qfalse; + } + strcat(token->string, newtoken.string+1); + } + else + { + PC_UnreadToken(source, &newtoken); + } + } + } //end if + //if skipping source because of conditional compilation + if (source->skip) continue; + //if the token is a name + if (token->type == TT_NAME) + { + //check if the name is a define macro +#if DEFINEHASHING + define = PC_FindHashedDefine(source->definehash, token->string); +#else + define = PC_FindDefine(source->defines, token->string); +#endif //DEFINEHASHING + //if it is a define macro + if (define) + { + //expand the defined macro + if (!PC_ExpandDefineIntoSource(source, token, define)) return qfalse; + continue; + } //end if + } //end if + //copy token for unreading + Com_Memcpy(&source->token, token, sizeof(token_t)); + //found a token + return qtrue; + } //end while +} //end of the function PC_ReadToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ExpectTokenString(source_t *source, char *string) +{ + token_t token; + + if (!PC_ReadToken(source, &token)) + { + SourceError(source, "couldn't find expected %s", string); + return qfalse; + } //end if + + if (strcmp(token.string, string)) + { + SourceError(source, "expected %s, found %s", string, token.string); + return qfalse; + } //end if + return qtrue; +} //end of the function PC_ExpectTokenString +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ExpectTokenType(source_t *source, int type, int subtype, token_t *token) +{ + char str[MAX_TOKEN]; + + if (!PC_ReadToken(source, token)) + { + SourceError(source, "couldn't read expected token"); + return qfalse; + } //end if + + if (token->type != type) + { + strcpy(str, ""); + if (type == TT_STRING) strcpy(str, "string"); + if (type == TT_LITERAL) strcpy(str, "literal"); + if (type == TT_NUMBER) strcpy(str, "number"); + if (type == TT_NAME) strcpy(str, "name"); + if (type == TT_PUNCTUATION) strcpy(str, "punctuation"); + SourceError(source, "expected a %s, found %s", str, token->string); + return qfalse; + } //end if + if (token->type == TT_NUMBER) + { + if ((token->subtype & subtype) != subtype) + { + if (subtype & TT_DECIMAL) strcpy(str, "decimal"); + if (subtype & TT_HEX) strcpy(str, "hex"); + if (subtype & TT_OCTAL) strcpy(str, "octal"); + if (subtype & TT_BINARY) strcpy(str, "binary"); + if (subtype & TT_LONG) strcat(str, " long"); + if (subtype & TT_UNSIGNED) strcat(str, " unsigned"); + if (subtype & TT_FLOAT) strcat(str, " float"); + if (subtype & TT_INTEGER) strcat(str, " integer"); + SourceError(source, "expected %s, found %s", str, token->string); + return qfalse; + } //end if + } //end if + else if (token->type == TT_PUNCTUATION) + { + if (token->subtype != subtype) + { + SourceError(source, "found %s", token->string); + return qfalse; + } //end if + } //end else if + return qtrue; +} //end of the function PC_ExpectTokenType +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ExpectAnyToken(source_t *source, token_t *token) +{ + if (!PC_ReadToken(source, token)) + { + SourceError(source, "couldn't read expected token"); + return qfalse; + } //end if + else + { + return qtrue; + } //end else +} //end of the function PC_ExpectAnyToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_CheckTokenString(source_t *source, char *string) +{ + token_t tok; + + if (!PC_ReadToken(source, &tok)) return qfalse; + //if the token is available + if (!strcmp(tok.string, string)) return qtrue; + // + PC_UnreadSourceToken(source, &tok); + return qfalse; +} //end of the function PC_CheckTokenString +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_CheckTokenType(source_t *source, int type, int subtype, token_t *token) +{ + token_t tok; + + if (!PC_ReadToken(source, &tok)) return qfalse; + //if the type matches + if (tok.type == type && + (tok.subtype & subtype) == subtype) + { + Com_Memcpy(token, &tok, sizeof(token_t)); + return qtrue; + } //end if + // + PC_UnreadSourceToken(source, &tok); + return qfalse; +} //end of the function PC_CheckTokenType +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_SkipUntilString(source_t *source, char *string) +{ + token_t token; + + while(PC_ReadToken(source, &token)) + { + if (!strcmp(token.string, string)) return qtrue; + } //end while + return qfalse; +} //end of the function PC_SkipUntilString +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_UnreadLastToken(source_t *source) +{ + PC_UnreadSourceToken(source, &source->token); +} //end of the function PC_UnreadLastToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_UnreadToken(source_t *source, token_t *token) +{ + PC_UnreadSourceToken(source, token); +} //end of the function PC_UnreadToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_SetIncludePath(source_t *source, char *path) +{ + strncpy(source->includepath, path, MAX_PATH); + //add trailing path seperator + if (source->includepath[strlen(source->includepath)-1] != '\\' && + source->includepath[strlen(source->includepath)-1] != '/') + { + strcat(source->includepath, PATHSEPERATOR_STR); + } //end if +} //end of the function PC_SetIncludePath +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_SetPunctuations(source_t *source, punctuation_t *p) +{ + source->punctuations = p; +} //end of the function PC_SetPunctuations +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +source_t *LoadSourceFile(const char *filename) +{ + source_t *source; + script_t *script; + + PC_InitTokenHeap(); + + script = LoadScriptFile(filename); + if (!script) return NULL; + + script->next = NULL; + + source = (source_t *) GetMemory(sizeof(source_t)); + Com_Memset(source, 0, sizeof(source_t)); + + strncpy(source->filename, filename, MAX_PATH); + source->scriptstack = script; + source->tokens = NULL; + source->defines = NULL; + source->indentstack = NULL; + source->skip = 0; + +#if DEFINEHASHING + source->definehash = GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *)); +#endif //DEFINEHASHING + PC_AddGlobalDefinesToSource(source); + return source; +} //end of the function LoadSourceFile +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +source_t *LoadSourceMemory(char *ptr, int length, char *name) +{ + source_t *source; + script_t *script; + + PC_InitTokenHeap(); + + script = LoadScriptMemory(ptr, length, name); + if (!script) return NULL; + script->next = NULL; + + source = (source_t *) GetMemory(sizeof(source_t)); + Com_Memset(source, 0, sizeof(source_t)); + + strncpy(source->filename, name, MAX_PATH); + source->scriptstack = script; + source->tokens = NULL; + source->defines = NULL; + source->indentstack = NULL; + source->skip = 0; + +#if DEFINEHASHING + source->definehash = GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *)); +#endif //DEFINEHASHING + PC_AddGlobalDefinesToSource(source); + return source; +} //end of the function LoadSourceMemory +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void FreeSource(source_t *source) +{ + script_t *script; + token_t *token; + define_t *define; + indent_t *indent; + int i; + + //PC_PrintDefineHashTable(source->definehash); + //free all the scripts + while(source->scriptstack) + { + script = source->scriptstack; + source->scriptstack = source->scriptstack->next; + FreeScript(script); + } //end for + //free all the tokens + while(source->tokens) + { + token = source->tokens; + source->tokens = source->tokens->next; + PC_FreeToken(token); + } //end for +#if DEFINEHASHING + for (i = 0; i < DEFINEHASHSIZE; i++) + { + while(source->definehash[i]) + { + define = source->definehash[i]; + source->definehash[i] = source->definehash[i]->hashnext; + PC_FreeDefine(define); + } //end while + } //end for +#else //DEFINEHASHING + //free all defines + while(source->defines) + { + define = source->defines; + source->defines = source->defines->next; + PC_FreeDefine(define); + } //end for +#endif //DEFINEHASHING + //free all indents + while(source->indentstack) + { + indent = source->indentstack; + source->indentstack = source->indentstack->next; + FreeMemory(indent); + } //end for +#if DEFINEHASHING + // + if (source->definehash) FreeMemory(source->definehash); +#endif //DEFINEHASHING + //free the source itself + FreeMemory(source); +} //end of the function FreeSource +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ + +#define MAX_SOURCEFILES 64 + +source_t *sourceFiles[MAX_SOURCEFILES]; + +int PC_LoadSourceHandle(const char *filename) +{ + source_t *source; + int i; + + for (i = 1; i < MAX_SOURCEFILES; i++) + { + if (!sourceFiles[i]) + break; + } //end for + if (i >= MAX_SOURCEFILES) + return 0; + PS_SetBaseFolder(""); + source = LoadSourceFile(filename); + if (!source) + return 0; + sourceFiles[i] = source; + return i; +} //end of the function PC_LoadSourceHandle +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_FreeSourceHandle(int handle) +{ + if (handle < 1 || handle >= MAX_SOURCEFILES) + return qfalse; + if (!sourceFiles[handle]) + return qfalse; + + FreeSource(sourceFiles[handle]); + sourceFiles[handle] = NULL; + return qtrue; +} //end of the function PC_FreeSourceHandle +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_ReadTokenHandle(int handle, pc_token_t *pc_token) +{ + token_t token; + int ret; + + if (handle < 1 || handle >= MAX_SOURCEFILES) + return 0; + if (!sourceFiles[handle]) + return 0; + + ret = PC_ReadToken(sourceFiles[handle], &token); + strcpy(pc_token->string, token.string); + pc_token->type = token.type; + pc_token->subtype = token.subtype; + pc_token->intvalue = token.intvalue; + pc_token->floatvalue = token.floatvalue; + if (pc_token->type == TT_STRING) + StripDoubleQuotes(pc_token->string); + return ret; +} //end of the function PC_ReadTokenHandle +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PC_SourceFileAndLine(int handle, char *filename, int *line) +{ + if (handle < 1 || handle >= MAX_SOURCEFILES) + return qfalse; + if (!sourceFiles[handle]) + return qfalse; + + strcpy(filename, sourceFiles[handle]->filename); + if (sourceFiles[handle]->scriptstack) + *line = sourceFiles[handle]->scriptstack->line; + else + *line = 0; + return qtrue; +} //end of the function PC_SourceFileAndLine +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_SetBaseFolder(char *path) +{ + PS_SetBaseFolder(path); +} //end of the function PC_SetBaseFolder +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PC_CheckOpenSourceHandles(void) +{ + int i; + + for (i = 1; i < MAX_SOURCEFILES; i++) + { + if (sourceFiles[i]) + { +#ifdef BOTLIB + botimport.Print(PRT_ERROR, "file %s still open in precompiler\n", sourceFiles[i]->scriptstack->filename); +#endif //BOTLIB + } //end if + } //end for +} //end of the function PC_CheckOpenSourceHandles + diff --git a/code/botlib/l_precomp.h b/code/botlib/l_precomp.h new file mode 100644 index 00000000..fcc0e8a3 --- /dev/null +++ b/code/botlib/l_precomp.h @@ -0,0 +1,180 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_precomp.h + * + * desc: pre compiler + * + * $Archive: /source/code/botlib/l_precomp.h $ + * + *****************************************************************************/ + +#ifndef MAX_PATH + #define MAX_PATH MAX_QPATH +#endif + +#ifndef PATH_SEPERATORSTR + #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__) + #define PATHSEPERATOR_STR "\\" + #else + #define PATHSEPERATOR_STR "/" + #endif +#endif +#ifndef PATH_SEPERATORCHAR + #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__) + #define PATHSEPERATOR_CHAR '\\' + #else + #define PATHSEPERATOR_CHAR '/' + #endif +#endif + +#if defined(BSPC) && !defined(QDECL) +#define QDECL +#endif + + +#define DEFINE_FIXED 0x0001 + +#define BUILTIN_LINE 1 +#define BUILTIN_FILE 2 +#define BUILTIN_DATE 3 +#define BUILTIN_TIME 4 +#define BUILTIN_STDC 5 + +#define INDENT_IF 0x0001 +#define INDENT_ELSE 0x0002 +#define INDENT_ELIF 0x0004 +#define INDENT_IFDEF 0x0008 +#define INDENT_IFNDEF 0x0010 + +//macro definitions +typedef struct define_s +{ + char *name; //define name + int flags; //define flags + int builtin; // > 0 if builtin define + int numparms; //number of define parameters + token_t *parms; //define parameters + token_t *tokens; //macro tokens (possibly containing parm tokens) + struct define_s *next; //next defined macro in a list + struct define_s *hashnext; //next define in the hash chain +} define_t; + +//indents +//used for conditional compilation directives: +//#if, #else, #elif, #ifdef, #ifndef +typedef struct indent_s +{ + int type; //indent type + int skip; //true if skipping current indent + script_t *script; //script the indent was in + struct indent_s *next; //next indent on the indent stack +} indent_t; + +//source file +typedef struct source_s +{ + char filename[1024]; //file name of the script + char includepath[1024]; //path to include files + punctuation_t *punctuations; //punctuations to use + script_t *scriptstack; //stack with scripts of the source + token_t *tokens; //tokens to read first + define_t *defines; //list with macro definitions + define_t **definehash; //hash chain with defines + indent_t *indentstack; //stack with indents + int skip; // > 0 if skipping conditional code + token_t token; //last read token +} source_t; + + +//read a token from the source +int PC_ReadToken(source_t *source, token_t *token); +//expect a certain token +int PC_ExpectTokenString(source_t *source, char *string); +//expect a certain token type +int PC_ExpectTokenType(source_t *source, int type, int subtype, token_t *token); +//expect a token +int PC_ExpectAnyToken(source_t *source, token_t *token); +//returns true when the token is available +int PC_CheckTokenString(source_t *source, char *string); +//returns true an reads the token when a token with the given type is available +int PC_CheckTokenType(source_t *source, int type, int subtype, token_t *token); +//skip tokens until the given token string is read +int PC_SkipUntilString(source_t *source, char *string); +//unread the last token read from the script +void PC_UnreadLastToken(source_t *source); +//unread the given token +void PC_UnreadToken(source_t *source, token_t *token); +//read a token only if on the same line, lines are concatenated with a slash +int PC_ReadLine(source_t *source, token_t *token); +//returns true if there was a white space in front of the token +int PC_WhiteSpaceBeforeToken(token_t *token); +//add a define to the source +int PC_AddDefine(source_t *source, char *string); +//add a globals define that will be added to all opened sources +int PC_AddGlobalDefine(char *string); +//remove the given global define +int PC_RemoveGlobalDefine(char *name); +//remove all globals defines +void PC_RemoveAllGlobalDefines(void); +//add builtin defines +void PC_AddBuiltinDefines(source_t *source); +//set the source include path +void PC_SetIncludePath(source_t *source, char *path); +//set the punction set +void PC_SetPunctuations(source_t *source, punctuation_t *p); +//set the base folder to load files from +void PC_SetBaseFolder(char *path); +//load a source file +source_t *LoadSourceFile(const char *filename); +//load a source from memory +source_t *LoadSourceMemory(char *ptr, int length, char *name); +//free the given source +void FreeSource(source_t *source); +//print a source error +void QDECL SourceError(source_t *source, char *str, ...); +//print a source warning +void QDECL SourceWarning(source_t *source, char *str, ...); + +#ifdef BSPC +// some of BSPC source does include game/q_shared.h and some does not +// we define pc_token_s pc_token_t if needed (yes, it's ugly) +#ifndef __Q_SHARED_H +#define MAX_TOKENLENGTH 1024 +typedef struct pc_token_s +{ + int type; + int subtype; + int intvalue; + float floatvalue; + char string[MAX_TOKENLENGTH]; +} pc_token_t; +#endif //!_Q_SHARED_H +#endif //BSPC + +// +int PC_LoadSourceHandle(const char *filename); +int PC_FreeSourceHandle(int handle); +int PC_ReadTokenHandle(int handle, pc_token_t *pc_token); +int PC_SourceFileAndLine(int handle, char *filename, int *line); +void PC_CheckOpenSourceHandles(void); diff --git a/code/botlib/l_script.c b/code/botlib/l_script.c new file mode 100644 index 00000000..0dc849ff --- /dev/null +++ b/code/botlib/l_script.c @@ -0,0 +1,1433 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_script.c + * + * desc: lexicographical parser + * + * $Archive: /MissionPack/code/botlib/l_script.c $ + * + *****************************************************************************/ + +//#define SCREWUP +//#define BOTLIB +//#define MEQCC +//#define BSPC + +#ifdef SCREWUP +#include +#include +#include +#include +#include +#include "l_memory.h" +#include "l_script.h" + +typedef enum {qfalse, qtrue} qboolean; + +#endif //SCREWUP + +#ifdef BOTLIB +//include files for usage in the bot library +#include "../qcommon/q_shared.h" +#include "botlib.h" +#include "be_interface.h" +#include "l_script.h" +#include "l_memory.h" +#include "l_log.h" +#include "l_libvar.h" +#endif //BOTLIB + +#ifdef MEQCC +//include files for usage in MrElusive's QuakeC Compiler +#include "qcc.h" +#include "l_script.h" +#include "l_memory.h" +#include "l_log.h" + +#define qtrue true +#define qfalse false +#endif //MEQCC + +#ifdef BSPC +//include files for usage in the BSP Converter +#include "../bspc/qbsp.h" +#include "../bspc/l_log.h" +#include "../bspc/l_mem.h" + +#define qtrue true +#define qfalse false +#endif //BSPC + + +#define PUNCTABLE + +//longer punctuations first +punctuation_t default_punctuations[] = +{ + //binary operators + {">>=",P_RSHIFT_ASSIGN, NULL}, + {"<<=",P_LSHIFT_ASSIGN, NULL}, + // + {"...",P_PARMS, NULL}, + //define merge operator + {"##",P_PRECOMPMERGE, NULL}, + //logic operators + {"&&",P_LOGIC_AND, NULL}, + {"||",P_LOGIC_OR, NULL}, + {">=",P_LOGIC_GEQ, NULL}, + {"<=",P_LOGIC_LEQ, NULL}, + {"==",P_LOGIC_EQ, NULL}, + {"!=",P_LOGIC_UNEQ, NULL}, + //arithmatic operators + {"*=",P_MUL_ASSIGN, NULL}, + {"/=",P_DIV_ASSIGN, NULL}, + {"%=",P_MOD_ASSIGN, NULL}, + {"+=",P_ADD_ASSIGN, NULL}, + {"-=",P_SUB_ASSIGN, NULL}, + {"++",P_INC, NULL}, + {"--",P_DEC, NULL}, + //binary operators + {"&=",P_BIN_AND_ASSIGN, NULL}, + {"|=",P_BIN_OR_ASSIGN, NULL}, + {"^=",P_BIN_XOR_ASSIGN, NULL}, + {">>",P_RSHIFT, NULL}, + {"<<",P_LSHIFT, NULL}, + //reference operators + {"->",P_POINTERREF, NULL}, + //C++ + {"::",P_CPP1, NULL}, + {".*",P_CPP2, NULL}, + //arithmatic operators + {"*",P_MUL, NULL}, + {"/",P_DIV, NULL}, + {"%",P_MOD, NULL}, + {"+",P_ADD, NULL}, + {"-",P_SUB, NULL}, + {"=",P_ASSIGN, NULL}, + //binary operators + {"&",P_BIN_AND, NULL}, + {"|",P_BIN_OR, NULL}, + {"^",P_BIN_XOR, NULL}, + {"~",P_BIN_NOT, NULL}, + //logic operators + {"!",P_LOGIC_NOT, NULL}, + {">",P_LOGIC_GREATER, NULL}, + {"<",P_LOGIC_LESS, NULL}, + //reference operator + {".",P_REF, NULL}, + //seperators + {",",P_COMMA, NULL}, + {";",P_SEMICOLON, NULL}, + //label indication + {":",P_COLON, NULL}, + //if statement + {"?",P_QUESTIONMARK, NULL}, + //embracements + {"(",P_PARENTHESESOPEN, NULL}, + {")",P_PARENTHESESCLOSE, NULL}, + {"{",P_BRACEOPEN, NULL}, + {"}",P_BRACECLOSE, NULL}, + {"[",P_SQBRACKETOPEN, NULL}, + {"]",P_SQBRACKETCLOSE, NULL}, + // + {"\\",P_BACKSLASH, NULL}, + //precompiler operator + {"#",P_PRECOMP, NULL}, +#ifdef DOLLAR + {"$",P_DOLLAR, NULL}, +#endif //DOLLAR + {NULL, 0} +}; + +#ifdef BSPC +char basefolder[MAX_PATH]; +#else +char basefolder[MAX_QPATH]; +#endif + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PS_CreatePunctuationTable(script_t *script, punctuation_t *punctuations) +{ + int i; + punctuation_t *p, *lastp, *newp; + + //get memory for the table + if (!script->punctuationtable) script->punctuationtable = (punctuation_t **) + GetMemory(256 * sizeof(punctuation_t *)); + Com_Memset(script->punctuationtable, 0, 256 * sizeof(punctuation_t *)); + //add the punctuations in the list to the punctuation table + for (i = 0; punctuations[i].p; i++) + { + newp = &punctuations[i]; + lastp = NULL; + //sort the punctuations in this table entry on length (longer punctuations first) + for (p = script->punctuationtable[(unsigned int) newp->p[0]]; p; p = p->next) + { + if (strlen(p->p) < strlen(newp->p)) + { + newp->next = p; + if (lastp) lastp->next = newp; + else script->punctuationtable[(unsigned int) newp->p[0]] = newp; + break; + } //end if + lastp = p; + } //end for + if (!p) + { + newp->next = NULL; + if (lastp) lastp->next = newp; + else script->punctuationtable[(unsigned int) newp->p[0]] = newp; + } //end if + } //end for +} //end of the function PS_CreatePunctuationTable +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *PunctuationFromNum(script_t *script, int num) +{ + int i; + + for (i = 0; script->punctuations[i].p; i++) + { + if (script->punctuations[i].n == num) return script->punctuations[i].p; + } //end for + return "unkown punctuation"; +} //end of the function PunctuationFromNum +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void QDECL ScriptError(script_t *script, char *str, ...) +{ + char text[1024]; + va_list ap; + + if (script->flags & SCFL_NOERRORS) return; + + va_start(ap, str); + vsprintf(text, str, ap); + va_end(ap); +#ifdef BOTLIB + botimport.Print(PRT_ERROR, "file %s, line %d: %s\n", script->filename, script->line, text); +#endif //BOTLIB +#ifdef MEQCC + printf("error: file %s, line %d: %s\n", script->filename, script->line, text); +#endif //MEQCC +#ifdef BSPC + Log_Print("error: file %s, line %d: %s\n", script->filename, script->line, text); +#endif //BSPC +} //end of the function ScriptError +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void QDECL ScriptWarning(script_t *script, char *str, ...) +{ + char text[1024]; + va_list ap; + + if (script->flags & SCFL_NOWARNINGS) return; + + va_start(ap, str); + vsprintf(text, str, ap); + va_end(ap); +#ifdef BOTLIB + botimport.Print(PRT_WARNING, "file %s, line %d: %s\n", script->filename, script->line, text); +#endif //BOTLIB +#ifdef MEQCC + printf("warning: file %s, line %d: %s\n", script->filename, script->line, text); +#endif //MEQCC +#ifdef BSPC + Log_Print("warning: file %s, line %d: %s\n", script->filename, script->line, text); +#endif //BSPC +} //end of the function ScriptWarning +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void SetScriptPunctuations(script_t *script, punctuation_t *p) +{ +#ifdef PUNCTABLE + if (p) PS_CreatePunctuationTable(script, p); + else PS_CreatePunctuationTable(script, default_punctuations); +#endif //PUNCTABLE + if (p) script->punctuations = p; + else script->punctuations = default_punctuations; +} //end of the function SetScriptPunctuations +//============================================================================ +// Reads spaces, tabs, C-like comments etc. +// When a newline character is found the scripts line counter is increased. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ReadWhiteSpace(script_t *script) +{ + while(1) + { + //skip white space + while(*script->script_p <= ' ') + { + if (!*script->script_p) return 0; + if (*script->script_p == '\n') script->line++; + script->script_p++; + } //end while + //skip comments + if (*script->script_p == '/') + { + //comments // + if (*(script->script_p+1) == '/') + { + script->script_p++; + do + { + script->script_p++; + if (!*script->script_p) return 0; + } //end do + while(*script->script_p != '\n'); + script->line++; + script->script_p++; + if (!*script->script_p) return 0; + continue; + } //end if + //comments /* */ + else if (*(script->script_p+1) == '*') + { + script->script_p++; + do + { + script->script_p++; + if (!*script->script_p) return 0; + if (*script->script_p == '\n') script->line++; + } //end do + while(!(*script->script_p == '*' && *(script->script_p+1) == '/')); + script->script_p++; + if (!*script->script_p) return 0; + script->script_p++; + if (!*script->script_p) return 0; + continue; + } //end if + } //end if + break; + } //end while + return 1; +} //end of the function PS_ReadWhiteSpace +//============================================================================ +// Reads an escape character. +// +// Parameter: script : script to read from +// ch : place to store the read escape character +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ReadEscapeCharacter(script_t *script, char *ch) +{ + int c, val, i; + + //step over the leading '\\' + script->script_p++; + //determine the escape character + switch(*script->script_p) + { + case '\\': c = '\\'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'a': c = '\a'; break; + case '\'': c = '\''; break; + case '\"': c = '\"'; break; + case '\?': c = '\?'; break; + case 'x': + { + script->script_p++; + for (i = 0, val = 0; ; i++, script->script_p++) + { + c = *script->script_p; + if (c >= '0' && c <= '9') c = c - '0'; + else if (c >= 'A' && c <= 'Z') c = c - 'A' + 10; + else if (c >= 'a' && c <= 'z') c = c - 'a' + 10; + else break; + val = (val << 4) + c; + } //end for + script->script_p--; + if (val > 0xFF) + { + ScriptWarning(script, "too large value in escape character"); + val = 0xFF; + } //end if + c = val; + break; + } //end case + default: //NOTE: decimal ASCII code, NOT octal + { + if (*script->script_p < '0' || *script->script_p > '9') ScriptError(script, "unknown escape char"); + for (i = 0, val = 0; ; i++, script->script_p++) + { + c = *script->script_p; + if (c >= '0' && c <= '9') c = c - '0'; + else break; + val = val * 10 + c; + } //end for + script->script_p--; + if (val > 0xFF) + { + ScriptWarning(script, "too large value in escape character"); + val = 0xFF; + } //end if + c = val; + break; + } //end default + } //end switch + //step over the escape character or the last digit of the number + script->script_p++; + //store the escape character + *ch = c; + //succesfully read escape character + return 1; +} //end of the function PS_ReadEscapeCharacter +//============================================================================ +// Reads C-like string. Escape characters are interpretted. +// Quotes are included with the string. +// Reads two strings with a white space between them as one string. +// +// Parameter: script : script to read from +// token : buffer to store the string +// Returns: qtrue when a string was read succesfully +// Changes Globals: - +//============================================================================ +int PS_ReadString(script_t *script, token_t *token, int quote) +{ + int len, tmpline; + char *tmpscript_p; + + if (quote == '\"') token->type = TT_STRING; + else token->type = TT_LITERAL; + + len = 0; + //leading quote + token->string[len++] = *script->script_p++; + // + while(1) + { + //minus 2 because trailing double quote and zero have to be appended + if (len >= MAX_TOKEN - 2) + { + ScriptError(script, "string longer than MAX_TOKEN = %d", MAX_TOKEN); + return 0; + } //end if + //if there is an escape character and + //if escape characters inside a string are allowed + if (*script->script_p == '\\' && !(script->flags & SCFL_NOSTRINGESCAPECHARS)) + { + if (!PS_ReadEscapeCharacter(script, &token->string[len])) + { + token->string[len] = 0; + return 0; + } //end if + len++; + } //end if + //if a trailing quote + else if (*script->script_p == quote) + { + //step over the double quote + script->script_p++; + //if white spaces in a string are not allowed + if (script->flags & SCFL_NOSTRINGWHITESPACES) break; + // + tmpscript_p = script->script_p; + tmpline = script->line; + //read unusefull stuff between possible two following strings + if (!PS_ReadWhiteSpace(script)) + { + script->script_p = tmpscript_p; + script->line = tmpline; + break; + } //end if + //if there's no leading double qoute + if (*script->script_p != quote) + { + script->script_p = tmpscript_p; + script->line = tmpline; + break; + } //end if + //step over the new leading double quote + script->script_p++; + } //end if + else + { + if (*script->script_p == '\0') + { + token->string[len] = 0; + ScriptError(script, "missing trailing quote"); + return 0; + } //end if + if (*script->script_p == '\n') + { + token->string[len] = 0; + ScriptError(script, "newline inside string %s", token->string); + return 0; + } //end if + token->string[len++] = *script->script_p++; + } //end else + } //end while + //trailing quote + token->string[len++] = quote; + //end string with a zero + token->string[len] = '\0'; + //the sub type is the length of the string + token->subtype = len; + return 1; +} //end of the function PS_ReadString +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ReadName(script_t *script, token_t *token) +{ + int len = 0; + char c; + + token->type = TT_NAME; + do + { + token->string[len++] = *script->script_p++; + if (len >= MAX_TOKEN) + { + ScriptError(script, "name longer than MAX_TOKEN = %d", MAX_TOKEN); + return 0; + } //end if + c = *script->script_p; + } while ((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + c == '_'); + token->string[len] = '\0'; + //the sub type is the length of the name + token->subtype = len; + return 1; +} //end of the function PS_ReadName +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void NumberValue(char *string, int subtype, unsigned long int *intvalue, + double *floatvalue) +{ + unsigned long int dotfound = 0; + + *intvalue = 0; + *floatvalue = 0; + //floating point number + if (subtype & TT_FLOAT) + { + while(*string) + { + if (*string == '.') + { + if (dotfound) return; + dotfound = 10; + string++; + } //end if + if (dotfound) + { + *floatvalue = *floatvalue + (double) (*string - '0') / + (double) dotfound; + dotfound *= 10; + } //end if + else + { + *floatvalue = *floatvalue * 10.0 + (double) (*string - '0'); + } //end else + string++; + } //end while + *intvalue = (unsigned long) *floatvalue; + } //end if + else if (subtype & TT_DECIMAL) + { + while(*string) *intvalue = *intvalue * 10 + (*string++ - '0'); + *floatvalue = *intvalue; + } //end else if + else if (subtype & TT_HEX) + { + //step over the leading 0x or 0X + string += 2; + while(*string) + { + *intvalue <<= 4; + if (*string >= 'a' && *string <= 'f') *intvalue += *string - 'a' + 10; + else if (*string >= 'A' && *string <= 'F') *intvalue += *string - 'A' + 10; + else *intvalue += *string - '0'; + string++; + } //end while + *floatvalue = *intvalue; + } //end else if + else if (subtype & TT_OCTAL) + { + //step over the first zero + string += 1; + while(*string) *intvalue = (*intvalue << 3) + (*string++ - '0'); + *floatvalue = *intvalue; + } //end else if + else if (subtype & TT_BINARY) + { + //step over the leading 0b or 0B + string += 2; + while(*string) *intvalue = (*intvalue << 1) + (*string++ - '0'); + *floatvalue = *intvalue; + } //end else if +} //end of the function NumberValue +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ReadNumber(script_t *script, token_t *token) +{ + int len = 0, i; + int octal, dot; + char c; +// unsigned long int intvalue = 0; +// double floatvalue = 0; + + token->type = TT_NUMBER; + //check for a hexadecimal number + if (*script->script_p == '0' && + (*(script->script_p + 1) == 'x' || + *(script->script_p + 1) == 'X')) + { + token->string[len++] = *script->script_p++; + token->string[len++] = *script->script_p++; + c = *script->script_p; + //hexadecimal + while((c >= '0' && c <= '9') || + (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'A')) + { + token->string[len++] = *script->script_p++; + if (len >= MAX_TOKEN) + { + ScriptError(script, "hexadecimal number longer than MAX_TOKEN = %d", MAX_TOKEN); + return 0; + } //end if + c = *script->script_p; + } //end while + token->subtype |= TT_HEX; + } //end if +#ifdef BINARYNUMBERS + //check for a binary number + else if (*script->script_p == '0' && + (*(script->script_p + 1) == 'b' || + *(script->script_p + 1) == 'B')) + { + token->string[len++] = *script->script_p++; + token->string[len++] = *script->script_p++; + c = *script->script_p; + //binary + while(c == '0' || c == '1') + { + token->string[len++] = *script->script_p++; + if (len >= MAX_TOKEN) + { + ScriptError(script, "binary number longer than MAX_TOKEN = %d", MAX_TOKEN); + return 0; + } //end if + c = *script->script_p; + } //end while + token->subtype |= TT_BINARY; + } //end if +#endif //BINARYNUMBERS + else //decimal or octal integer or floating point number + { + octal = qfalse; + dot = qfalse; + if (*script->script_p == '0') octal = qtrue; + while(1) + { + c = *script->script_p; + if (c == '.') dot = qtrue; + else if (c == '8' || c == '9') octal = qfalse; + else if (c < '0' || c > '9') break; + token->string[len++] = *script->script_p++; + if (len >= MAX_TOKEN - 1) + { + ScriptError(script, "number longer than MAX_TOKEN = %d", MAX_TOKEN); + return 0; + } //end if + } //end while + if (octal) token->subtype |= TT_OCTAL; + else token->subtype |= TT_DECIMAL; + if (dot) token->subtype |= TT_FLOAT; + } //end else + for (i = 0; i < 2; i++) + { + c = *script->script_p; + //check for a LONG number + if ( (c == 'l' || c == 'L') + && !(token->subtype & TT_LONG)) + { + script->script_p++; + token->subtype |= TT_LONG; + } //end if + //check for an UNSIGNED number + else if ( (c == 'u' || c == 'U') + && !(token->subtype & (TT_UNSIGNED | TT_FLOAT))) + { + script->script_p++; + token->subtype |= TT_UNSIGNED; + } //end if + } //end for + token->string[len] = '\0'; +#ifdef NUMBERVALUE + NumberValue(token->string, token->subtype, &token->intvalue, &token->floatvalue); +#endif //NUMBERVALUE + if (!(token->subtype & TT_FLOAT)) token->subtype |= TT_INTEGER; + return 1; +} //end of the function PS_ReadNumber +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ReadLiteral(script_t *script, token_t *token) +{ + token->type = TT_LITERAL; + //first quote + token->string[0] = *script->script_p++; + //check for end of file + if (!*script->script_p) + { + ScriptError(script, "end of file before trailing \'"); + return 0; + } //end if + //if it is an escape character + if (*script->script_p == '\\') + { + if (!PS_ReadEscapeCharacter(script, &token->string[1])) return 0; + } //end if + else + { + token->string[1] = *script->script_p++; + } //end else + //check for trailing quote + if (*script->script_p != '\'') + { + ScriptWarning(script, "too many characters in literal, ignored"); + while(*script->script_p && + *script->script_p != '\'' && + *script->script_p != '\n') + { + script->script_p++; + } //end while + if (*script->script_p == '\'') script->script_p++; + } //end if + //store the trailing quote + token->string[2] = *script->script_p++; + //store trailing zero to end the string + token->string[3] = '\0'; + //the sub type is the integer literal value + token->subtype = token->string[1]; + // + return 1; +} //end of the function PS_ReadLiteral +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ReadPunctuation(script_t *script, token_t *token) +{ + int len; + char *p; + punctuation_t *punc; + +#ifdef PUNCTABLE + for (punc = script->punctuationtable[(unsigned int)*script->script_p]; punc; punc = punc->next) + { +#else + int i; + + for (i = 0; script->punctuations[i].p; i++) + { + punc = &script->punctuations[i]; +#endif //PUNCTABLE + p = punc->p; + len = strlen(p); + //if the script contains at least as much characters as the punctuation + if (script->script_p + len <= script->end_p) + { + //if the script contains the punctuation + if (!strncmp(script->script_p, p, len)) + { + strncpy(token->string, p, MAX_TOKEN); + script->script_p += len; + token->type = TT_PUNCTUATION; + //sub type is the number of the punctuation + token->subtype = punc->n; + return 1; + } //end if + } //end if + } //end for + return 0; +} //end of the function PS_ReadPunctuation +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ReadPrimitive(script_t *script, token_t *token) +{ + int len; + + len = 0; + while(*script->script_p > ' ' && *script->script_p != ';') + { + if (len >= MAX_TOKEN) + { + ScriptError(script, "primitive token longer than MAX_TOKEN = %d", MAX_TOKEN); + return 0; + } //end if + token->string[len++] = *script->script_p++; + } //end while + token->string[len] = 0; + //copy the token into the script structure + Com_Memcpy(&script->token, token, sizeof(token_t)); + //primitive reading successfull + return 1; +} //end of the function PS_ReadPrimitive +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ReadToken(script_t *script, token_t *token) +{ + //if there is a token available (from UnreadToken) + if (script->tokenavailable) + { + script->tokenavailable = 0; + Com_Memcpy(token, &script->token, sizeof(token_t)); + return 1; + } //end if + //save script pointer + script->lastscript_p = script->script_p; + //save line counter + script->lastline = script->line; + //clear the token stuff + Com_Memset(token, 0, sizeof(token_t)); + //start of the white space + script->whitespace_p = script->script_p; + token->whitespace_p = script->script_p; + //read unusefull stuff + if (!PS_ReadWhiteSpace(script)) return 0; + //end of the white space + script->endwhitespace_p = script->script_p; + token->endwhitespace_p = script->script_p; + //line the token is on + token->line = script->line; + //number of lines crossed before token + token->linescrossed = script->line - script->lastline; + //if there is a leading double quote + if (*script->script_p == '\"') + { + if (!PS_ReadString(script, token, '\"')) return 0; + } //end if + //if an literal + else if (*script->script_p == '\'') + { + //if (!PS_ReadLiteral(script, token)) return 0; + if (!PS_ReadString(script, token, '\'')) return 0; + } //end if + //if there is a number + else if ((*script->script_p >= '0' && *script->script_p <= '9') || + (*script->script_p == '.' && + (*(script->script_p + 1) >= '0' && *(script->script_p + 1) <= '9'))) + { + if (!PS_ReadNumber(script, token)) return 0; + } //end if + //if this is a primitive script + else if (script->flags & SCFL_PRIMITIVE) + { + return PS_ReadPrimitive(script, token); + } //end else if + //if there is a name + else if ((*script->script_p >= 'a' && *script->script_p <= 'z') || + (*script->script_p >= 'A' && *script->script_p <= 'Z') || + *script->script_p == '_') + { + if (!PS_ReadName(script, token)) return 0; + } //end if + //check for punctuations + else if (!PS_ReadPunctuation(script, token)) + { + ScriptError(script, "can't read token"); + return 0; + } //end if + //copy the token into the script structure + Com_Memcpy(&script->token, token, sizeof(token_t)); + //succesfully read a token + return 1; +} //end of the function PS_ReadToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ExpectTokenString(script_t *script, char *string) +{ + token_t token; + + if (!PS_ReadToken(script, &token)) + { + ScriptError(script, "couldn't find expected %s", string); + return 0; + } //end if + + if (strcmp(token.string, string)) + { + ScriptError(script, "expected %s, found %s", string, token.string); + return 0; + } //end if + return 1; +} //end of the function PS_ExpectToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ExpectTokenType(script_t *script, int type, int subtype, token_t *token) +{ + char str[MAX_TOKEN]; + + if (!PS_ReadToken(script, token)) + { + ScriptError(script, "couldn't read expected token"); + return 0; + } //end if + + if (token->type != type) + { + if (type == TT_STRING) strcpy(str, "string"); + if (type == TT_LITERAL) strcpy(str, "literal"); + if (type == TT_NUMBER) strcpy(str, "number"); + if (type == TT_NAME) strcpy(str, "name"); + if (type == TT_PUNCTUATION) strcpy(str, "punctuation"); + ScriptError(script, "expected a %s, found %s", str, token->string); + return 0; + } //end if + if (token->type == TT_NUMBER) + { + if ((token->subtype & subtype) != subtype) + { + if (subtype & TT_DECIMAL) strcpy(str, "decimal"); + if (subtype & TT_HEX) strcpy(str, "hex"); + if (subtype & TT_OCTAL) strcpy(str, "octal"); + if (subtype & TT_BINARY) strcpy(str, "binary"); + if (subtype & TT_LONG) strcat(str, " long"); + if (subtype & TT_UNSIGNED) strcat(str, " unsigned"); + if (subtype & TT_FLOAT) strcat(str, " float"); + if (subtype & TT_INTEGER) strcat(str, " integer"); + ScriptError(script, "expected %s, found %s", str, token->string); + return 0; + } //end if + } //end if + else if (token->type == TT_PUNCTUATION) + { + if (subtype < 0) + { + ScriptError(script, "BUG: wrong punctuation subtype"); + return 0; + } //end if + if (token->subtype != subtype) + { + ScriptError(script, "expected %s, found %s", + script->punctuations[subtype], token->string); + return 0; + } //end if + } //end else if + return 1; +} //end of the function PS_ExpectTokenType +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_ExpectAnyToken(script_t *script, token_t *token) +{ + if (!PS_ReadToken(script, token)) + { + ScriptError(script, "couldn't read expected token"); + return 0; + } //end if + else + { + return 1; + } //end else +} //end of the function PS_ExpectAnyToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_CheckTokenString(script_t *script, char *string) +{ + token_t tok; + + if (!PS_ReadToken(script, &tok)) return 0; + //if the token is available + if (!strcmp(tok.string, string)) return 1; + //token not available + script->script_p = script->lastscript_p; + return 0; +} //end of the function PS_CheckTokenString +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_CheckTokenType(script_t *script, int type, int subtype, token_t *token) +{ + token_t tok; + + if (!PS_ReadToken(script, &tok)) return 0; + //if the type matches + if (tok.type == type && + (tok.subtype & subtype) == subtype) + { + Com_Memcpy(token, &tok, sizeof(token_t)); + return 1; + } //end if + //token is not available + script->script_p = script->lastscript_p; + return 0; +} //end of the function PS_CheckTokenType +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int PS_SkipUntilString(script_t *script, char *string) +{ + token_t token; + + while(PS_ReadToken(script, &token)) + { + if (!strcmp(token.string, string)) return 1; + } //end while + return 0; +} //end of the function PS_SkipUntilString +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PS_UnreadLastToken(script_t *script) +{ + script->tokenavailable = 1; +} //end of the function UnreadLastToken +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PS_UnreadToken(script_t *script, token_t *token) +{ + Com_Memcpy(&script->token, token, sizeof(token_t)); + script->tokenavailable = 1; +} //end of the function UnreadToken +//============================================================================ +// returns the next character of the read white space, returns NULL if none +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +char PS_NextWhiteSpaceChar(script_t *script) +{ + if (script->whitespace_p != script->endwhitespace_p) + { + return *script->whitespace_p++; + } //end if + else + { + return 0; + } //end else +} //end of the function PS_NextWhiteSpaceChar +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void StripDoubleQuotes(char *string) +{ + if (*string == '\"') + { + strcpy(string, string+1); + } //end if + if (string[strlen(string)-1] == '\"') + { + string[strlen(string)-1] = '\0'; + } //end if +} //end of the function StripDoubleQuotes +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void StripSingleQuotes(char *string) +{ + if (*string == '\'') + { + strcpy(string, string+1); + } //end if + if (string[strlen(string)-1] == '\'') + { + string[strlen(string)-1] = '\0'; + } //end if +} //end of the function StripSingleQuotes +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +double ReadSignedFloat(script_t *script) +{ + token_t token; + double sign = 1.0; + + PS_ExpectAnyToken(script, &token); + if (!strcmp(token.string, "-")) + { + sign = -1.0; + PS_ExpectTokenType(script, TT_NUMBER, 0, &token); + } //end if + else if (token.type != TT_NUMBER) + { + ScriptError(script, "expected float value, found %s\n", token.string); + } //end else if + return sign * token.floatvalue; +} //end of the function ReadSignedFloat +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +signed long int ReadSignedInt(script_t *script) +{ + token_t token; + signed long int sign = 1; + + PS_ExpectAnyToken(script, &token); + if (!strcmp(token.string, "-")) + { + sign = -1; + PS_ExpectTokenType(script, TT_NUMBER, TT_INTEGER, &token); + } //end if + else if (token.type != TT_NUMBER || token.subtype == TT_FLOAT) + { + ScriptError(script, "expected integer value, found %s\n", token.string); + } //end else if + return sign * token.intvalue; +} //end of the function ReadSignedInt +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void SetScriptFlags(script_t *script, int flags) +{ + script->flags = flags; +} //end of the function SetScriptFlags +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int GetScriptFlags(script_t *script) +{ + return script->flags; +} //end of the function GetScriptFlags +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void ResetScript(script_t *script) +{ + //pointer in script buffer + script->script_p = script->buffer; + //pointer in script buffer before reading token + script->lastscript_p = script->buffer; + //begin of white space + script->whitespace_p = NULL; + //end of white space + script->endwhitespace_p = NULL; + //set if there's a token available in script->token + script->tokenavailable = 0; + // + script->line = 1; + script->lastline = 1; + //clear the saved token + Com_Memset(&script->token, 0, sizeof(token_t)); +} //end of the function ResetScript +//============================================================================ +// returns true if at the end of the script +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int EndOfScript(script_t *script) +{ + return script->script_p >= script->end_p; +} //end of the function EndOfScript +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int NumLinesCrossed(script_t *script) +{ + return script->line - script->lastline; +} //end of the function NumLinesCrossed +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int ScriptSkipTo(script_t *script, char *value) +{ + int len; + char firstchar; + + firstchar = *value; + len = strlen(value); + do + { + if (!PS_ReadWhiteSpace(script)) return 0; + if (*script->script_p == firstchar) + { + if (!strncmp(script->script_p, value, len)) + { + return 1; + } //end if + } //end if + script->script_p++; + } while(1); +} //end of the function ScriptSkipTo +#ifndef BOTLIB +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +int FileLength(FILE *fp) +{ + int pos; + int end; + + pos = ftell(fp); + fseek(fp, 0, SEEK_END); + end = ftell(fp); + fseek(fp, pos, SEEK_SET); + + return end; +} //end of the function FileLength +#endif +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +script_t *LoadScriptFile(const char *filename) +{ +#ifdef BOTLIB + fileHandle_t fp; + char pathname[MAX_QPATH]; +#else + FILE *fp; +#endif + int length; + void *buffer; + script_t *script; + +#ifdef BOTLIB + if (strlen(basefolder)) + Com_sprintf(pathname, sizeof(pathname), "%s/%s", basefolder, filename); + else + Com_sprintf(pathname, sizeof(pathname), "%s", filename); + length = botimport.FS_FOpenFile( pathname, &fp, FS_READ ); + if (!fp) return NULL; +#else + fp = fopen(filename, "rb"); + if (!fp) return NULL; + + length = FileLength(fp); +#endif + + buffer = GetClearedMemory(sizeof(script_t) + length + 1); + script = (script_t *) buffer; + Com_Memset(script, 0, sizeof(script_t)); + strcpy(script->filename, filename); + script->buffer = (char *) buffer + sizeof(script_t); + script->buffer[length] = 0; + script->length = length; + //pointer in script buffer + script->script_p = script->buffer; + //pointer in script buffer before reading token + script->lastscript_p = script->buffer; + //pointer to end of script buffer + script->end_p = &script->buffer[length]; + //set if there's a token available in script->token + script->tokenavailable = 0; + // + script->line = 1; + script->lastline = 1; + // + SetScriptPunctuations(script, NULL); + // +#ifdef BOTLIB + botimport.FS_Read(script->buffer, length, fp); + botimport.FS_FCloseFile(fp); +#else + if (fread(script->buffer, length, 1, fp) != 1) + { + FreeMemory(buffer); + script = NULL; + } //end if + fclose(fp); +#endif + // + script->length = COM_Compress(script->buffer); + + return script; +} //end of the function LoadScriptFile +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +script_t *LoadScriptMemory(char *ptr, int length, char *name) +{ + void *buffer; + script_t *script; + + buffer = GetClearedMemory(sizeof(script_t) + length + 1); + script = (script_t *) buffer; + Com_Memset(script, 0, sizeof(script_t)); + strcpy(script->filename, name); + script->buffer = (char *) buffer + sizeof(script_t); + script->buffer[length] = 0; + script->length = length; + //pointer in script buffer + script->script_p = script->buffer; + //pointer in script buffer before reading token + script->lastscript_p = script->buffer; + //pointer to end of script buffer + script->end_p = &script->buffer[length]; + //set if there's a token available in script->token + script->tokenavailable = 0; + // + script->line = 1; + script->lastline = 1; + // + SetScriptPunctuations(script, NULL); + // + Com_Memcpy(script->buffer, ptr, length); + // + return script; +} //end of the function LoadScriptMemory +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void FreeScript(script_t *script) +{ +#ifdef PUNCTABLE + if (script->punctuationtable) FreeMemory(script->punctuationtable); +#endif //PUNCTABLE + FreeMemory(script); +} //end of the function FreeScript +//============================================================================ +// +// Parameter: - +// Returns: - +// Changes Globals: - +//============================================================================ +void PS_SetBaseFolder(char *path) +{ +#ifdef BSPC + sprintf(basefolder, path); +#else + Com_sprintf(basefolder, sizeof(basefolder), "%s", path); +#endif +} //end of the function PS_SetBaseFolder diff --git a/code/botlib/l_script.h b/code/botlib/l_script.h new file mode 100644 index 00000000..7fe4ac96 --- /dev/null +++ b/code/botlib/l_script.h @@ -0,0 +1,247 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_script.h + * + * desc: lexicographical parser + * + * $Archive: /source/code/botlib/l_script.h $ + * + *****************************************************************************/ + +//undef if binary numbers of the form 0b... or 0B... are not allowed +#define BINARYNUMBERS +//undef if not using the token.intvalue and token.floatvalue +#define NUMBERVALUE +//use dollar sign also as punctuation +#define DOLLAR + +//maximum token length +#define MAX_TOKEN 1024 + +#if defined(BSPC) && !defined(QDECL) +#define QDECL +#endif + + +//script flags +#define SCFL_NOERRORS 0x0001 +#define SCFL_NOWARNINGS 0x0002 +#define SCFL_NOSTRINGWHITESPACES 0x0004 +#define SCFL_NOSTRINGESCAPECHARS 0x0008 +#define SCFL_PRIMITIVE 0x0010 +#define SCFL_NOBINARYNUMBERS 0x0020 +#define SCFL_NONUMBERVALUES 0x0040 + +//token types +#define TT_STRING 1 // string +#define TT_LITERAL 2 // literal +#define TT_NUMBER 3 // number +#define TT_NAME 4 // name +#define TT_PUNCTUATION 5 // punctuation + +//string sub type +//--------------- +// the length of the string +//literal sub type +//---------------- +// the ASCII code of the literal +//number sub type +//--------------- +#define TT_DECIMAL 0x0008 // decimal number +#define TT_HEX 0x0100 // hexadecimal number +#define TT_OCTAL 0x0200 // octal number +#ifdef BINARYNUMBERS +#define TT_BINARY 0x0400 // binary number +#endif //BINARYNUMBERS +#define TT_FLOAT 0x0800 // floating point number +#define TT_INTEGER 0x1000 // integer number +#define TT_LONG 0x2000 // long number +#define TT_UNSIGNED 0x4000 // unsigned number +//punctuation sub type +//-------------------- +#define P_RSHIFT_ASSIGN 1 +#define P_LSHIFT_ASSIGN 2 +#define P_PARMS 3 +#define P_PRECOMPMERGE 4 + +#define P_LOGIC_AND 5 +#define P_LOGIC_OR 6 +#define P_LOGIC_GEQ 7 +#define P_LOGIC_LEQ 8 +#define P_LOGIC_EQ 9 +#define P_LOGIC_UNEQ 10 + +#define P_MUL_ASSIGN 11 +#define P_DIV_ASSIGN 12 +#define P_MOD_ASSIGN 13 +#define P_ADD_ASSIGN 14 +#define P_SUB_ASSIGN 15 +#define P_INC 16 +#define P_DEC 17 + +#define P_BIN_AND_ASSIGN 18 +#define P_BIN_OR_ASSIGN 19 +#define P_BIN_XOR_ASSIGN 20 +#define P_RSHIFT 21 +#define P_LSHIFT 22 + +#define P_POINTERREF 23 +#define P_CPP1 24 +#define P_CPP2 25 +#define P_MUL 26 +#define P_DIV 27 +#define P_MOD 28 +#define P_ADD 29 +#define P_SUB 30 +#define P_ASSIGN 31 + +#define P_BIN_AND 32 +#define P_BIN_OR 33 +#define P_BIN_XOR 34 +#define P_BIN_NOT 35 + +#define P_LOGIC_NOT 36 +#define P_LOGIC_GREATER 37 +#define P_LOGIC_LESS 38 + +#define P_REF 39 +#define P_COMMA 40 +#define P_SEMICOLON 41 +#define P_COLON 42 +#define P_QUESTIONMARK 43 + +#define P_PARENTHESESOPEN 44 +#define P_PARENTHESESCLOSE 45 +#define P_BRACEOPEN 46 +#define P_BRACECLOSE 47 +#define P_SQBRACKETOPEN 48 +#define P_SQBRACKETCLOSE 49 +#define P_BACKSLASH 50 + +#define P_PRECOMP 51 +#define P_DOLLAR 52 +//name sub type +//------------- +// the length of the name + +//punctuation +typedef struct punctuation_s +{ + char *p; //punctuation character(s) + int n; //punctuation indication + struct punctuation_s *next; //next punctuation +} punctuation_t; + +//token +typedef struct token_s +{ + char string[MAX_TOKEN]; //available token + int type; //last read token type + int subtype; //last read token sub type +#ifdef NUMBERVALUE + unsigned long int intvalue; //integer value + double floatvalue; //floating point value +#endif //NUMBERVALUE + char *whitespace_p; //start of white space before token + char *endwhitespace_p; //start of white space before token + int line; //line the token was on + int linescrossed; //lines crossed in white space + struct token_s *next; //next token in chain +} token_t; + +//script file +typedef struct script_s +{ + char filename[1024]; //file name of the script + char *buffer; //buffer containing the script + char *script_p; //current pointer in the script + char *end_p; //pointer to the end of the script + char *lastscript_p; //script pointer before reading token + char *whitespace_p; //begin of the white space + char *endwhitespace_p; //end of the white space + int length; //length of the script in bytes + int line; //current line in script + int lastline; //line before reading token + int tokenavailable; //set by UnreadLastToken + int flags; //several script flags + punctuation_t *punctuations; //the punctuations used in the script + punctuation_t **punctuationtable; + token_t token; //available token + struct script_s *next; //next script in a chain +} script_t; + +//read a token from the script +int PS_ReadToken(script_t *script, token_t *token); +//expect a certain token +int PS_ExpectTokenString(script_t *script, char *string); +//expect a certain token type +int PS_ExpectTokenType(script_t *script, int type, int subtype, token_t *token); +//expect a token +int PS_ExpectAnyToken(script_t *script, token_t *token); +//returns true when the token is available +int PS_CheckTokenString(script_t *script, char *string); +//returns true an reads the token when a token with the given type is available +int PS_CheckTokenType(script_t *script, int type, int subtype, token_t *token); +//skip tokens until the given token string is read +int PS_SkipUntilString(script_t *script, char *string); +//unread the last token read from the script +void PS_UnreadLastToken(script_t *script); +//unread the given token +void PS_UnreadToken(script_t *script, token_t *token); +//returns the next character of the read white space, returns NULL if none +char PS_NextWhiteSpaceChar(script_t *script); +//remove any leading and trailing double quotes from the token +void StripDoubleQuotes(char *string); +//remove any leading and trailing single quotes from the token +void StripSingleQuotes(char *string); +//read a possible signed integer +signed long int ReadSignedInt(script_t *script); +//read a possible signed floating point number +double ReadSignedFloat(script_t *script); +//set an array with punctuations, NULL restores default C/C++ set +void SetScriptPunctuations(script_t *script, punctuation_t *p); +//set script flags +void SetScriptFlags(script_t *script, int flags); +//get script flags +int GetScriptFlags(script_t *script); +//reset a script +void ResetScript(script_t *script); +//returns true if at the end of the script +int EndOfScript(script_t *script); +//returns a pointer to the punctuation with the given number +char *PunctuationFromNum(script_t *script, int num); +//load a script from the given file at the given offset with the given length +script_t *LoadScriptFile(const char *filename); +//load a script from the given memory with the given length +script_t *LoadScriptMemory(char *ptr, int length, char *name); +//free a script +void FreeScript(script_t *script); +//set the base folder to load files from +void PS_SetBaseFolder(char *path); +//print a script error with filename and line number +void QDECL ScriptError(script_t *script, char *str, ...); +//print a script warning with filename and line number +void QDECL ScriptWarning(script_t *script, char *str, ...); + + diff --git a/code/botlib/l_struct.c b/code/botlib/l_struct.c new file mode 100644 index 00000000..303ecaa8 --- /dev/null +++ b/code/botlib/l_struct.c @@ -0,0 +1,462 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_struct.c + * + * desc: structure reading / writing + * + * $Archive: /MissionPack/CODE/botlib/l_struct.c $ + * + *****************************************************************************/ + +#ifdef BOTLIB +#include "../qcommon/q_shared.h" +#include "botlib.h" //for the include of be_interface.h +#include "l_script.h" +#include "l_precomp.h" +#include "l_struct.h" +#include "l_utils.h" +#include "be_interface.h" +#endif //BOTLIB + +#ifdef BSPC +//include files for usage in the BSP Converter +#include "../bspc/qbsp.h" +#include "../bspc/l_log.h" +#include "../bspc/l_mem.h" +#include "l_precomp.h" +#include "l_struct.h" + +#define qtrue true +#define qfalse false +#endif //BSPC + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +fielddef_t *FindField(fielddef_t *defs, char *name) +{ + int i; + + for (i = 0; defs[i].name; i++) + { + if (!strcmp(defs[i].name, name)) return &defs[i]; + } //end for + return NULL; +} //end of the function FindField +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p) +{ + token_t token; + int negative = qfalse; + long int intval, intmin = 0, intmax = 0; + double floatval; + + if (!PC_ExpectAnyToken(source, &token)) return 0; + + //check for minus sign + if (token.type == TT_PUNCTUATION) + { + if (fd->type & FT_UNSIGNED) + { + SourceError(source, "expected unsigned value, found %s", token.string); + return 0; + } //end if + //if not a minus sign + if (strcmp(token.string, "-")) + { + SourceError(source, "unexpected punctuation %s", token.string); + return 0; + } //end if + negative = qtrue; + //read the number + if (!PC_ExpectAnyToken(source, &token)) return 0; + } //end if + //check if it is a number + if (token.type != TT_NUMBER) + { + SourceError(source, "expected number, found %s", token.string); + return 0; + } //end if + //check for a float value + if (token.subtype & TT_FLOAT) + { + if ((fd->type & FT_TYPE) != FT_FLOAT) + { + SourceError(source, "unexpected float"); + return 0; + } //end if + floatval = token.floatvalue; + if (negative) floatval = -floatval; + if (fd->type & FT_BOUNDED) + { + if (floatval < fd->floatmin || floatval > fd->floatmax) + { + SourceError(source, "float out of range [%f, %f]", fd->floatmin, fd->floatmax); + return 0; + } //end if + } //end if + *(float *) p = (float) floatval; + return 1; + } //end if + // + intval = token.intvalue; + if (negative) intval = -intval; + //check bounds + if ((fd->type & FT_TYPE) == FT_CHAR) + { + if (fd->type & FT_UNSIGNED) {intmin = 0; intmax = 255;} + else {intmin = -128; intmax = 127;} + } //end if + if ((fd->type & FT_TYPE) == FT_INT) + { + if (fd->type & FT_UNSIGNED) {intmin = 0; intmax = 65535;} + else {intmin = -32768; intmax = 32767;} + } //end else if + if ((fd->type & FT_TYPE) == FT_CHAR || (fd->type & FT_TYPE) == FT_INT) + { + if (fd->type & FT_BOUNDED) + { + intmin = Maximum(intmin, fd->floatmin); + intmax = Minimum(intmax, fd->floatmax); + } //end if + if (intval < intmin || intval > intmax) + { + SourceError(source, "value %d out of range [%d, %d]", intval, intmin, intmax); + return 0; + } //end if + } //end if + else if ((fd->type & FT_TYPE) == FT_FLOAT) + { + if (fd->type & FT_BOUNDED) + { + if (intval < fd->floatmin || intval > fd->floatmax) + { + SourceError(source, "value %d out of range [%f, %f]", intval, fd->floatmin, fd->floatmax); + return 0; + } //end if + } //end if + } //end else if + //store the value + if ((fd->type & FT_TYPE) == FT_CHAR) + { + if (fd->type & FT_UNSIGNED) *(unsigned char *) p = (unsigned char) intval; + else *(char *) p = (char) intval; + } //end if + else if ((fd->type & FT_TYPE) == FT_INT) + { + if (fd->type & FT_UNSIGNED) *(unsigned int *) p = (unsigned int) intval; + else *(int *) p = (int) intval; + } //end else + else if ((fd->type & FT_TYPE) == FT_FLOAT) + { + *(float *) p = (float) intval; + } //end else + return 1; +} //end of the function ReadNumber +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean ReadChar(source_t *source, fielddef_t *fd, void *p) +{ + token_t token; + + if (!PC_ExpectAnyToken(source, &token)) return 0; + + //take literals into account + if (token.type == TT_LITERAL) + { + StripSingleQuotes(token.string); + *(char *) p = token.string[0]; + } //end if + else + { + PC_UnreadLastToken(source); + if (!ReadNumber(source, fd, p)) return 0; + } //end if + return 1; +} //end of the function ReadChar +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int ReadString(source_t *source, fielddef_t *fd, void *p) +{ + token_t token; + + if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) return 0; + //remove the double quotes + StripDoubleQuotes(token.string); + //copy the string + strncpy((char *) p, token.string, MAX_STRINGFIELD); + //make sure the string is closed with a zero + ((char *)p)[MAX_STRINGFIELD-1] = '\0'; + // + return 1; +} //end of the function ReadString +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int ReadStructure(source_t *source, structdef_t *def, char *structure) +{ + token_t token; + fielddef_t *fd; + void *p; + int num; + + if (!PC_ExpectTokenString(source, "{")) return 0; + while(1) + { + if (!PC_ExpectAnyToken(source, &token)) return qfalse; + //if end of structure + if (!strcmp(token.string, "}")) break; + //find the field with the name + fd = FindField(def->fields, token.string); + if (!fd) + { + SourceError(source, "unknown structure field %s", token.string); + return qfalse; + } //end if + if (fd->type & FT_ARRAY) + { + num = fd->maxarray; + if (!PC_ExpectTokenString(source, "{")) return qfalse; + } //end if + else + { + num = 1; + } //end else + p = (void *)(structure + fd->offset); + while (num-- > 0) + { + if (fd->type & FT_ARRAY) + { + if (PC_CheckTokenString(source, "}")) break; + } //end if + switch(fd->type & FT_TYPE) + { + case FT_CHAR: + { + if (!ReadChar(source, fd, p)) return qfalse; + p = (char *) p + sizeof(char); + break; + } //end case + case FT_INT: + { + if (!ReadNumber(source, fd, p)) return qfalse; + p = (char *) p + sizeof(int); + break; + } //end case + case FT_FLOAT: + { + if (!ReadNumber(source, fd, p)) return qfalse; + p = (char *) p + sizeof(float); + break; + } //end case + case FT_STRING: + { + if (!ReadString(source, fd, p)) return qfalse; + p = (char *) p + MAX_STRINGFIELD; + break; + } //end case + case FT_STRUCT: + { + if (!fd->substruct) + { + SourceError(source, "BUG: no sub structure defined"); + return qfalse; + } //end if + ReadStructure(source, fd->substruct, (char *) p); + p = (char *) p + fd->substruct->size; + break; + } //end case + } //end switch + if (fd->type & FT_ARRAY) + { + if (!PC_ExpectAnyToken(source, &token)) return qfalse; + if (!strcmp(token.string, "}")) break; + if (strcmp(token.string, ",")) + { + SourceError(source, "expected a comma, found %s", token.string); + return qfalse; + } //end if + } //end if + } //end while + } //end while + return qtrue; +} //end of the function ReadStructure +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int WriteIndent(FILE *fp, int indent) +{ + while(indent-- > 0) + { + if (fprintf(fp, "\t") < 0) return qfalse; + } //end while + return qtrue; +} //end of the function WriteIndent +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int WriteFloat(FILE *fp, float value) +{ + char buf[128]; + int l; + + sprintf(buf, "%f", value); + l = strlen(buf); + //strip any trailing zeros + while(l-- > 1) + { + if (buf[l] != '0' && buf[l] != '.') break; + if (buf[l] == '.') + { + buf[l] = 0; + break; + } //end if + buf[l] = 0; + } //end while + //write the float to file + if (fprintf(fp, "%s", buf) < 0) return 0; + return 1; +} //end of the function WriteFloat +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int WriteStructWithIndent(FILE *fp, structdef_t *def, char *structure, int indent) +{ + int i, num; + void *p; + fielddef_t *fd; + + if (!WriteIndent(fp, indent)) return qfalse; + if (fprintf(fp, "{\r\n") < 0) return qfalse; + + indent++; + for (i = 0; def->fields[i].name; i++) + { + fd = &def->fields[i]; + if (!WriteIndent(fp, indent)) return qfalse; + if (fprintf(fp, "%s\t", fd->name) < 0) return qfalse; + p = (void *)(structure + fd->offset); + if (fd->type & FT_ARRAY) + { + num = fd->maxarray; + if (fprintf(fp, "{") < 0) return qfalse; + } //end if + else + { + num = 1; + } //end else + while(num-- > 0) + { + switch(fd->type & FT_TYPE) + { + case FT_CHAR: + { + if (fprintf(fp, "%d", *(char *) p) < 0) return qfalse; + p = (char *) p + sizeof(char); + break; + } //end case + case FT_INT: + { + if (fprintf(fp, "%d", *(int *) p) < 0) return qfalse; + p = (char *) p + sizeof(int); + break; + } //end case + case FT_FLOAT: + { + if (!WriteFloat(fp, *(float *)p)) return qfalse; + p = (char *) p + sizeof(float); + break; + } //end case + case FT_STRING: + { + if (fprintf(fp, "\"%s\"", (char *) p) < 0) return qfalse; + p = (char *) p + MAX_STRINGFIELD; + break; + } //end case + case FT_STRUCT: + { + if (!WriteStructWithIndent(fp, fd->substruct, structure, indent)) return qfalse; + p = (char *) p + fd->substruct->size; + break; + } //end case + } //end switch + if (fd->type & FT_ARRAY) + { + if (num > 0) + { + if (fprintf(fp, ",") < 0) return qfalse; + } //end if + else + { + if (fprintf(fp, "}") < 0) return qfalse; + } //end else + } //end if + } //end while + if (fprintf(fp, "\r\n") < 0) return qfalse; + } //end for + indent--; + + if (!WriteIndent(fp, indent)) return qfalse; + if (fprintf(fp, "}\r\n") < 0) return qfalse; + return qtrue; +} //end of the function WriteStructWithIndent +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int WriteStructure(FILE *fp, structdef_t *def, char *structure) +{ + return WriteStructWithIndent(fp, def, structure, 0); +} //end of the function WriteStructure + diff --git a/code/botlib/l_struct.h b/code/botlib/l_struct.h new file mode 100644 index 00000000..e2c6b032 --- /dev/null +++ b/code/botlib/l_struct.h @@ -0,0 +1,75 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_struct.h + * + * desc: structure reading/writing + * + * $Archive: /source/code/botlib/l_struct.h $ + * + *****************************************************************************/ + + +#define MAX_STRINGFIELD 80 +//field types +#define FT_CHAR 1 // char +#define FT_INT 2 // int +#define FT_FLOAT 3 // float +#define FT_STRING 4 // char [MAX_STRINGFIELD] +#define FT_STRUCT 6 // struct (sub structure) +//type only mask +#define FT_TYPE 0x00FF // only type, clear subtype +//sub types +#define FT_ARRAY 0x0100 // array of type +#define FT_BOUNDED 0x0200 // bounded value +#define FT_UNSIGNED 0x0400 + +//structure field definition +typedef struct fielddef_s +{ + char *name; //name of the field + int offset; //offset in the structure + int type; //type of the field + //type specific fields + int maxarray; //maximum array size + float floatmin, floatmax; //float min and max + struct structdef_s *substruct; //sub structure +} fielddef_t; + +//structure definition +typedef struct structdef_s +{ + int size; + fielddef_t *fields; +} structdef_t; + +//read a structure from a script +int ReadStructure(source_t *source, structdef_t *def, char *structure); +//write a structure to a file +int WriteStructure(FILE *fp, structdef_t *def, char *structure); +//writes indents +int WriteIndent(FILE *fp, int indent); +//writes a float without traling zeros +int WriteFloat(FILE *fp, float value); + + diff --git a/code/botlib/l_utils.h b/code/botlib/l_utils.h new file mode 100644 index 00000000..6944d06f --- /dev/null +++ b/code/botlib/l_utils.h @@ -0,0 +1,37 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: l_util.h + * + * desc: utils + * + * $Archive: /source/code/botlib/l_util.h $ + * + *****************************************************************************/ + +#define Vector2Angles(v,a) vectoangles(v,a) +#ifndef MAX_PATH +#define MAX_PATH MAX_QPATH +#endif +#define Maximum(x,y) (x > y ? x : y) +#define Minimum(x,y) (x < y ? x : y) diff --git a/code/botlib/lcc.mak b/code/botlib/lcc.mak new file mode 100644 index 00000000..f5567c3a --- /dev/null +++ b/code/botlib/lcc.mak @@ -0,0 +1,55 @@ +# +# Makefile for Gladiator Bot library: gladiator.dll +# Intended for LCC-Win32 +# + +CC=lcc +CFLAGS=-DC_ONLY -o +OBJS= be_aas_bspq2.obj \ + be_aas_bsphl.obj \ + be_aas_cluster.obj \ + be_aas_debug.obj \ + be_aas_entity.obj \ + be_aas_file.obj \ + be_aas_light.obj \ + be_aas_main.obj \ + be_aas_move.obj \ + be_aas_optimize.obj \ + be_aas_reach.obj \ + be_aas_route.obj \ + be_aas_routealt.obj \ + be_aas_sample.obj \ + be_aas_sound.obj \ + be_ai2_dm.obj \ + be_ai2_dmnet.obj \ + be_ai2_main.obj \ + be_ai_char.obj \ + be_ai_chat.obj \ + be_ai_goal.obj \ + be_ai_load.obj \ + be_ai_move.obj \ + be_ai_weap.obj \ + be_ai_weight.obj \ + be_ea.obj \ + be_interface.obj \ + l_crc.obj \ + l_libvar.obj \ + l_log.obj \ + l_memory.obj \ + l_precomp.obj \ + l_script.obj \ + l_struct.obj \ + l_utils.obj \ + q_shared.obj + +all: gladiator.dll + +gladiator.dll: $(OBJS) + lcclnk -dll -entry GetBotAPI *.obj botlib.def -o gladiator.dll + +clean: + del *.obj gladiator.dll + +%.obj: %.c + $(CC) $(CFLAGS) $< + diff --git a/code/botlib/linux-i386.mak b/code/botlib/linux-i386.mak new file mode 100644 index 00000000..c9607a7b --- /dev/null +++ b/code/botlib/linux-i386.mak @@ -0,0 +1,92 @@ +# +# Makefile for Gladiator Bot library: gladiator.so +# Intended for gcc/Linux +# + +ARCH=i386 +CC=gcc +BASE_CFLAGS=-Dstricmp=strcasecmp + +#use these cflags to optimize it +CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \ + -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \ + -malign-jumps=2 -malign-functions=2 +#use these when debugging +#CFLAGS=$(BASE_CFLAGS) -g + +LDFLAGS=-ldl -lm +SHLIBEXT=so +SHLIBCFLAGS=-fPIC +SHLIBLDFLAGS=-shared + +DO_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< + +############################################################################# +# SETUP AND BUILD +# GLADIATOR BOT +############################################################################# + +.c.o: + $(DO_CC) + +GAME_OBJS = \ + be_aas_bsphl.o\ + be_aas_bspq2.o\ + be_aas_cluster.o\ + be_aas_debug.o\ + be_aas_entity.o\ + be_aas_file.o\ + be_aas_light.o\ + be_aas_main.o\ + be_aas_move.o\ + be_aas_optimize.o\ + be_aas_reach.o\ + be_aas_route.o\ + be_aas_routealt.o\ + be_aas_sample.o\ + be_aas_sound.o\ + be_ai2_dmq2.o\ + be_ai2_dmhl.o\ + be_ai2_dmnet.o\ + be_ai2_main.o\ + be_ai_char.o\ + be_ai_chat.o\ + be_ai_goal.o\ + be_ai_load.o\ + be_ai_move.o\ + be_ai_weap.o\ + be_ai_weight.o\ + be_ea.o\ + be_interface.o\ + l_crc.o\ + l_libvar.o\ + l_log.o\ + l_memory.o\ + l_precomp.o\ + l_script.o\ + l_struct.o\ + l_utils.o\ + q_shared.o + +glad$(ARCH).$(SHLIBEXT) : $(GAME_OBJS) + $(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(GAME_OBJS) + + +############################################################################# +# MISC +############################################################################# + +clean: + -rm -f $(GAME_OBJS) + +depend: + gcc -MM $(GAME_OBJS:.o=.c) + + +install: + cp gladiator.so .. + +# +# From "make depend" +# + diff --git a/code/bspc/Conscript b/code/bspc/Conscript new file mode 100644 index 00000000..264e7c7c --- /dev/null +++ b/code/bspc/Conscript @@ -0,0 +1,75 @@ +# bspc compile + +Import qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK ); + +@BSPC_FILES = qw( + aas_areamerging.c + aas_cfg.c + aas_create.c + aas_edgemelting.c + aas_facemerging.c + aas_file.c + aas_gsubdiv.c + aas_map.c + aas_prunenodes.c + aas_store.c + be_aas_bspc.c + ../botlib/be_aas_bspq3.c + ../botlib/be_aas_cluster.c + ../botlib/be_aas_move.c + ../botlib/be_aas_optimize.c + ../botlib/be_aas_reach.c + ../botlib/be_aas_sample.c + brushbsp.c + bspc.c + ../qcommon/cm_load.c + ../qcommon/cm_patch.c + ../qcommon/cm_test.c + ../qcommon/cm_trace.c + csg.c + glfile.c + l_bsp_ent.c + l_bsp_hl.c + l_bsp_q1.c + l_bsp_q2.c + l_bsp_q3.c + l_bsp_sin.c + l_cmd.c + ../botlib/l_libvar.c + l_log.c + l_math.c + l_mem.c + l_poly.c + ../botlib/l_precomp.c + l_qfiles.c + ../botlib/l_script.c + ../botlib/l_struct.c + l_threads.c + l_utils.c + leakfile.c + map.c + map_hl.c + map_q1.c + map_q2.c + map_q3.c + map_sin.c + ../qcommon/md4.c + nodraw.c + portals.c + textures.c + tree.c + ../qcommon/unzip.c + ); +$BSPC_REF = \@BSPC_FILES; + +$env = new cons( + CC => $CC, + CXX => $CXX, + LINK => $LINK, + CFLAGS => $BSPC_BASE_CFLAGS, + LIBS => '-ldl -lm -lpthread' +); + +Program $env 'bspc', @$BSPC_REF; +# this should install to Q3 or something? +Install $env $INSTALL_DIR, 'bspc'; diff --git a/code/bspc/Makefile b/code/bspc/Makefile new file mode 100644 index 00000000..b6d3b944 --- /dev/null +++ b/code/bspc/Makefile @@ -0,0 +1,114 @@ +# +# Makefile for the BSPC tool for the Gladiator Bot +# Intended for gcc/Linux +# +# TTimo 5/15/2001 +# some cleanup .. only used on i386 for GtkRadiant setups AFAIK .. removing the i386 tag +# TODO: the intermediate object files should go into their own directory +# specially for ../botlib and ../qcommon, the compilation flags on those might not be what you expect + +#ARCH=i386 +CC=gcc +BASE_CFLAGS=-Dstricmp=strcasecmp + +#use these cflags to optimize it +CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \ + -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \ + -malign-jumps=2 -malign-functions=2 -DLINUX -DBSPC +#use these when debugging +#CFLAGS=$(BASE_CFLAGS) -g + +LDFLAGS=-ldl -lm -lpthread + +DO_CC=$(CC) $(CFLAGS) -o $@ -c $< + +############################################################################# +# SETUP AND BUILD BSPC +############################################################################# + +.c.o: + $(DO_CC) + +GAME_OBJS = \ + _files.o\ + aas_areamerging.o\ + aas_cfg.o\ + aas_create.o\ + aas_edgemelting.o\ + aas_facemerging.o\ + aas_file.o\ + aas_gsubdiv.o\ + aas_map.o\ + aas_prunenodes.o\ + aas_store.o\ + be_aas_bspc.o\ + ../botlib/be_aas_bspq3.o\ + ../botlib/be_aas_cluster.o\ + ../botlib/be_aas_move.o\ + ../botlib/be_aas_optimize.o\ + ../botlib/be_aas_reach.o\ + ../botlib/be_aas_sample.o\ + brushbsp.o\ + bspc.o\ + ../qcommon/cm_load.o\ + ../qcommon/cm_patch.o\ + ../qcommon/cm_test.o\ + ../qcommon/cm_trace.o\ + csg.o\ + glfile.o\ + l_bsp_ent.o\ + l_bsp_hl.o\ + l_bsp_q1.o\ + l_bsp_q2.o\ + l_bsp_q3.o\ + l_bsp_sin.o\ + l_cmd.o\ + ../botlib/l_libvar.o\ + l_log.o\ + l_math.o\ + l_mem.o\ + l_poly.o\ + ../botlib/l_precomp.o\ + l_qfiles.o\ + ../botlib/l_script.o\ + ../botlib/l_struct.o\ + l_threads.o\ + l_utils.o\ + leakfile.o\ + map.o\ + map_hl.o\ + map_q1.o\ + map_q2.o\ + map_q3.o\ + map_sin.o\ + ../qcommon/md4.o\ + nodraw.o\ + portals.o\ + textures.o\ + tree.o\ + ../qcommon/unzip.o + + #tetrahedron.o + +bspc : $(GAME_OBJS) + $(CC) $(CFLAGS) -o $@ $(GAME_OBJS) $(LDFLAGS) + strip $@ + + +############################################################################# +# MISC +############################################################################# + +clean: + -rm -f $(GAME_OBJS) + +depend: + gcc -MM $(GAME_OBJS:.o=.c) + +#install: +# cp bspci386 .. + +# +# From "make depend" +# + diff --git a/code/bspc/_files.c b/code/bspc/_files.c new file mode 100644 index 00000000..8f4fcffc --- /dev/null +++ b/code/bspc/_files.c @@ -0,0 +1,63 @@ +//=========================================================================== +// +// Name: _files.c +// Function: +// Programmer: Mr Elusive +// Last update: 1999-12-02 +// Tab Size: 4 +//=========================================================================== + +/* + +aas_areamerging.c //AAS area merging +aas_cfg.c //AAS configuration for different games +aas_create.c //AAS creating +aas_edgemelting.c //AAS edge melting +aas_facemerging.c //AAS face merging +aas_file.c //AAS file writing +aas_gsubdiv.c //AAS gravitational and ladder subdivision +aas_map.c //AAS map brush creation +aas_prunenodes.c //AAS node pruning +aas_store.c //AAS file storing + +map.c //map file loading and writing +map_hl.c //Half-Life map loading +map_q1.c //Quake1 map loading +map_q2.c //Quake2 map loading +map_q3.c //Quake3 map loading +map_sin.c //Sin map loading +tree.c //BSP tree management + node pruning (*) +brushbsp.c //brush bsp creation (*) +portals.c //BSP portal creation and leaf filling (*) +csg.c //Constructive Solid Geometry brush chopping (*) +leakfile.c //leak file writing (*) +textures.c //Quake2 BSP textures (*) + +l_bsp_ent.c //BSP entity parsing +l_bsp_hl.c //Half-Life BSP loading and writing +l_bsp_q1.c //Quake1 BSP loading and writing +l_bsp_q2.c //Quake2 BSP loading and writing +l_bsp_q3.c //Quake2 BSP loading and writing +l_bsp_sin.c //Sin BSP loading and writing +l_cmd.c //cmd library +l_log.c //log file library +l_math.c //math library +l_mem.c //memory management library +l_poly.c //polygon (winding) library +l_script.c //script file parsing library +l_threads.c //multi-threading library +l_utils.c //utility library +l_qfiles.c //loading of quake files + +gldraw.c //GL drawing (*) +glfile.c //GL file writing (*) +nodraw.c //no draw module (*) + +bspc.c //BSPC Win32 console version +winbspc.c //WinBSPC Win32 GUI version +win32_terminal.c //Win32 terminal output +win32_qfiles.c //Win32 game file management (also .pak .sin) +win32_font.c //Win32 fonts +win32_folder.c //Win32 folder dialogs + +*/ diff --git a/code/bspc/aas_areamerging.c b/code/bspc/aas_areamerging.c new file mode 100644 index 00000000..f9de65ff --- /dev/null +++ b/code/bspc/aas_areamerging.c @@ -0,0 +1,390 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "../botlib/aasfile.h" +#include "aas_create.h" +#include "aas_store.h" + +#define CONVEX_EPSILON 0.3 + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_node_t *AAS_RefreshMergedTree_r(tmp_node_t *tmpnode) +{ + tmp_area_t *tmparea; + + //if this is a solid leaf + if (!tmpnode) return NULL; + //if this is an area leaf + if (tmpnode->tmparea) + { + tmparea = tmpnode->tmparea; + while(tmparea->mergedarea) tmparea = tmparea->mergedarea; + tmpnode->tmparea = tmparea; + return tmpnode; + } //end if + //do the children recursively + tmpnode->children[0] = AAS_RefreshMergedTree_r(tmpnode->children[0]); + tmpnode->children[1] = AAS_RefreshMergedTree_r(tmpnode->children[1]); + return tmpnode; +} //end of the function AAS_RefreshMergedTree_r +//=========================================================================== +// returns true if the two given faces would create a non-convex area at +// the given sides, otherwise false is returned +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int NonConvex(tmp_face_t *face1, tmp_face_t *face2, int side1, int side2) +{ + int i; + winding_t *w1, *w2; + plane_t *plane1, *plane2; + + w1 = face1->winding; + w2 = face2->winding; + + plane1 = &mapplanes[face1->planenum ^ side1]; + plane2 = &mapplanes[face2->planenum ^ side2]; + + //check if one of the points of face1 is at the back of the plane of face2 + for (i = 0; i < w1->numpoints; i++) + { + if (DotProduct(plane2->normal, w1->p[i]) - plane2->dist < -CONVEX_EPSILON) return true; + } //end for + //check if one of the points of face2 is at the back of the plane of face1 + for (i = 0; i < w2->numpoints; i++) + { + if (DotProduct(plane1->normal, w2->p[i]) - plane1->dist < -CONVEX_EPSILON) return true; + } //end for + + return false; +} //end of the function NonConvex +//=========================================================================== +// try to merge the areas at both sides of the given face +// +// Parameter: seperatingface : face that seperates two areas +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_TryMergeFaceAreas(tmp_face_t *seperatingface) +{ + int side1, side2, area1faceflags, area2faceflags; + tmp_area_t *tmparea1, *tmparea2, *newarea; + tmp_face_t *face1, *face2, *nextface1, *nextface2; + + tmparea1 = seperatingface->frontarea; + tmparea2 = seperatingface->backarea; + + //areas must have the same presence type + if (tmparea1->presencetype != tmparea2->presencetype) return false; + //areas must have the same area contents + if (tmparea1->contents != tmparea2->contents) return false; + //areas must have the same bsp model inside (or both none) + if (tmparea1->modelnum != tmparea2->modelnum) return false; + + area1faceflags = 0; + area2faceflags = 0; + for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side1]) + { + side1 = (face1->frontarea != tmparea1); + //debug: check if the area belongs to the area + if (face1->frontarea != tmparea1 && + face1->backarea != tmparea1) Error("face does not belong to area1"); + //just continue if the face is seperating the two areas + //NOTE: a result of this is that ground and gap areas can + // be merged if the seperating face is the gap + if ((face1->frontarea == tmparea1 && + face1->backarea == tmparea2) || + (face1->frontarea == tmparea2 && + face1->backarea == tmparea1)) continue; + //get area1 face flags + area1faceflags |= face1->faceflags; + if (AAS_GapFace(face1, side1)) area1faceflags |= FACE_GAP; + // + for (face2 = tmparea2->tmpfaces; face2; face2 = face2->next[side2]) + { + side2 = (face2->frontarea != tmparea2); + //debug: check if the area belongs to the area + if (face2->frontarea != tmparea2 && + face2->backarea != tmparea2) Error("face does not belong to area2"); + //just continue if the face is seperating the two areas + //NOTE: a result of this is that ground and gap areas can + // be merged if the seperating face is the gap + if ((face2->frontarea == tmparea1 && + face2->backarea == tmparea2) || + (face2->frontarea == tmparea2 && + face2->backarea == tmparea1)) continue; + //get area2 face flags + area2faceflags |= face2->faceflags; + if (AAS_GapFace(face2, side2)) area2faceflags |= FACE_GAP; + //if the two faces would create a non-convex area + if (NonConvex(face1, face2, side1, side2)) return false; + } //end for + } //end for + //if one area has gap faces (that aren't seperating the two areas) + //and the other has ground faces (that aren't seperating the two areas), + //the areas can't be merged + if (((area1faceflags & FACE_GROUND) && (area2faceflags & FACE_GAP)) || + ((area2faceflags & FACE_GROUND) && (area1faceflags & FACE_GAP))) + { +// Log_Print(" can't merge: ground/gap\n"); + return false; + } //end if + +// Log_Print("merged area %d & %d to %d with %d faces\n", tmparea1->areanum, tmparea2->areanum, newarea->areanum, numfaces); +// return false; + // + //AAS_CheckArea(tmparea1); + //AAS_CheckArea(tmparea2); + //create the new area + newarea = AAS_AllocTmpArea(); + newarea->presencetype = tmparea1->presencetype; + newarea->contents = tmparea1->contents; + newarea->modelnum = tmparea1->modelnum; + newarea->tmpfaces = NULL; + + //add all the faces (except the seperating ones) from the first area + //to the new area + for (face1 = tmparea1->tmpfaces; face1; face1 = nextface1) + { + side1 = (face1->frontarea != tmparea1); + nextface1 = face1->next[side1]; + //don't add seperating faces + if ((face1->frontarea == tmparea1 && + face1->backarea == tmparea2) || + (face1->frontarea == tmparea2 && + face1->backarea == tmparea1)) + { + continue; + } //end if + // + AAS_RemoveFaceFromArea(face1, tmparea1); + AAS_AddFaceSideToArea(face1, side1, newarea); + } //end for + //add all the faces (except the seperating ones) from the second area + //to the new area + for (face2 = tmparea2->tmpfaces; face2; face2 = nextface2) + { + side2 = (face2->frontarea != tmparea2); + nextface2 = face2->next[side2]; + //don't add seperating faces + if ((face2->frontarea == tmparea1 && + face2->backarea == tmparea2) || + (face2->frontarea == tmparea2 && + face2->backarea == tmparea1)) + { + continue; + } //end if + // + AAS_RemoveFaceFromArea(face2, tmparea2); + AAS_AddFaceSideToArea(face2, side2, newarea); + } //end for + //free all shared faces + for (face1 = tmparea1->tmpfaces; face1; face1 = nextface1) + { + side1 = (face1->frontarea != tmparea1); + nextface1 = face1->next[side1]; + // + AAS_RemoveFaceFromArea(face1, face1->frontarea); + AAS_RemoveFaceFromArea(face1, face1->backarea); + AAS_FreeTmpFace(face1); + } //end for + // + tmparea1->mergedarea = newarea; + tmparea1->invalid = true; + tmparea2->mergedarea = newarea; + tmparea2->invalid = true; + // + AAS_CheckArea(newarea); + AAS_FlipAreaFaces(newarea); +// Log_Print("merged area %d & %d to %d with %d faces\n", tmparea1->areanum, tmparea2->areanum, newarea->areanum); + return true; +} //end of the function AAS_TryMergeFaceAreas +//=========================================================================== +// try to merge areas +// merged areas are added to the end of the convex area list so merging +// will be tried for those areas as well +// +// Parameter: - +// Returns: - +// Changes Globals: tmpaasworld +//=========================================================================== +/* +void AAS_MergeAreas(void) +{ + int side, nummerges; + tmp_area_t *tmparea, *othertmparea; + tmp_face_t *face; + + nummerges = 0; + Log_Write("AAS_MergeAreas\r\n"); + qprintf("%6d areas merged", 1); + //first merge grounded areas only + //NOTE: this is useless because the area settings aren't available yet + for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) + { +// Log_Print("checking area %d\n", i); + //if the area is invalid + if (tmparea->invalid) + { +// Log_Print(" area invalid\n"); + continue; + } //end if + // +// if (!(tmparea->settings->areaflags & AREA_GROUNDED)) continue; + // + for (face = tmparea->tmpfaces; face; face = face->next[side]) + { + side = (face->frontarea != tmparea); + //if the face has both a front and back area + if (face->frontarea && face->backarea) + { + // + if (face->frontarea == tmparea) othertmparea = face->backarea; + else othertmparea = face->frontarea; +// if (!(othertmparea->settings->areaflags & AREA_GROUNDED)) continue; +// Log_Print(" checking area %d with %d\n", face->frontarea, face->backarea); + if (AAS_TryMergeFaceAreas(face)) + { + qprintf("\r%6d", ++nummerges); + break; + } //end if + } //end if + } //end for + } //end for + //merge all areas + for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) + { +// Log_Print("checking area %d\n", i); + //if the area is invalid + if (tmparea->invalid) + { +// Log_Print(" area invalid\n"); + continue; + } //end if + // + for (face = tmparea->tmpfaces; face; face = face->next[side]) + { + side = (face->frontarea != tmparea); + //if the face has both a front and back area + if (face->frontarea && face->backarea) + { +// Log_Print(" checking area %d with %d\n", face->frontarea, face->backarea); + if (AAS_TryMergeFaceAreas(face)) + { + qprintf("\r%6d", ++nummerges); + break; + } //end if + } //end if + } //end for + } //end for + Log_Print("\r%6d areas merged\n", nummerges); + //refresh the merged tree + AAS_RefreshMergedTree_r(tmpaasworld.nodes); +} //end of the function AAS_MergeAreas*/ + +int AAS_GroundArea(tmp_area_t *tmparea) +{ + tmp_face_t *face; + int side; + + for (face = tmparea->tmpfaces; face; face = face->next[side]) + { + side = (face->frontarea != tmparea); + if (face->faceflags & FACE_GROUND) return true; + } //end for + return false; +} //end of the function AAS_GroundArea + +void AAS_MergeAreas(void) +{ + int side, nummerges, merges, groundfirst; + tmp_area_t *tmparea, *othertmparea; + tmp_face_t *face; + + nummerges = 0; + Log_Write("AAS_MergeAreas\r\n"); + qprintf("%6d areas merged", 1); + // + groundfirst = true; + //for (i = 0; i < 4 || merges; i++) + while(1) + { + //if (i < 2) groundfirst = true; + //else groundfirst = false; + // + merges = 0; + //first merge grounded areas only + for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) + { + //if the area is invalid + if (tmparea->invalid) + { + continue; + } //end if + // + if (groundfirst) + { + if (!AAS_GroundArea(tmparea)) continue; + } //end if + // + for (face = tmparea->tmpfaces; face; face = face->next[side]) + { + side = (face->frontarea != tmparea); + //if the face has both a front and back area + if (face->frontarea && face->backarea) + { + // + if (face->frontarea == tmparea) othertmparea = face->backarea; + else othertmparea = face->frontarea; + // + if (groundfirst) + { + if (!AAS_GroundArea(othertmparea)) continue; + } //end if + if (AAS_TryMergeFaceAreas(face)) + { + qprintf("\r%6d", ++nummerges); + merges++; + break; + } //end if + } //end if + } //end for + } //end for + if (!merges) + { + if (groundfirst) groundfirst = false; + else break; + } //end if + } //end for + qprintf("\n"); + Log_Write("%6d areas merged\r\n", nummerges); + //refresh the merged tree + AAS_RefreshMergedTree_r(tmpaasworld.nodes); +} //end of the function AAS_MergeAreas diff --git a/code/bspc/aas_areamerging.h b/code/bspc/aas_areamerging.h new file mode 100644 index 00000000..14cb8eda --- /dev/null +++ b/code/bspc/aas_areamerging.h @@ -0,0 +1,24 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +void AAS_MergeAreas(void); + diff --git a/code/bspc/aas_cfg.c b/code/bspc/aas_cfg.c new file mode 100644 index 00000000..983bda90 --- /dev/null +++ b/code/bspc/aas_cfg.c @@ -0,0 +1,256 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "../botlib/aasfile.h" +#include "aas_store.h" +#include "aas_cfg.h" +#include "../botlib/l_precomp.h" +#include "../botlib/l_struct.h" +#include "../botlib/l_libvar.h" + +// su44: this is from float.h +#ifndef FLT_MAX +#define FLT_MAX 3.402823466e+38F /* max value */ +#endif // FLT_MAX + +//structure field offsets +#define BBOX_OFS(x) (int)&(((aas_bbox_t *)0)->x) +#define CFG_OFS(x) (int)&(((cfg_t *)0)->x) + +//bounding box definition +fielddef_t bbox_fields[] = +{ + {"presencetype", BBOX_OFS(presencetype), FT_INT}, + {"flags", BBOX_OFS(flags), FT_INT}, + {"mins", BBOX_OFS(mins), FT_FLOAT|FT_ARRAY, 3}, + {"maxs", BBOX_OFS(maxs), FT_FLOAT|FT_ARRAY, 3}, + {NULL, 0, 0, 0} +}; + +fielddef_t cfg_fields[] = +{ + {"phys_gravitydirection", CFG_OFS(phys_gravitydirection), FT_FLOAT|FT_ARRAY, 3}, + {"phys_friction", CFG_OFS(phys_friction), FT_FLOAT}, + {"phys_stopspeed", CFG_OFS(phys_stopspeed), FT_FLOAT}, + {"phys_gravity", CFG_OFS(phys_gravity), FT_FLOAT}, + {"phys_waterfriction", CFG_OFS(phys_waterfriction), FT_FLOAT}, + {"phys_watergravity", CFG_OFS(phys_watergravity), FT_FLOAT}, + {"phys_maxvelocity", CFG_OFS(phys_maxvelocity), FT_FLOAT}, + {"phys_maxwalkvelocity", CFG_OFS(phys_maxwalkvelocity), FT_FLOAT}, + {"phys_maxcrouchvelocity", CFG_OFS(phys_maxcrouchvelocity), FT_FLOAT}, + {"phys_maxswimvelocity", CFG_OFS(phys_maxswimvelocity), FT_FLOAT}, + {"phys_walkaccelerate", CFG_OFS(phys_walkaccelerate), FT_FLOAT}, + {"phys_airaccelerate", CFG_OFS(phys_airaccelerate), FT_FLOAT}, + {"phys_swimaccelerate", CFG_OFS(phys_swimaccelerate), FT_FLOAT}, + {"phys_maxstep", CFG_OFS(phys_maxstep), FT_FLOAT}, + {"phys_maxsteepness", CFG_OFS(phys_maxsteepness), FT_FLOAT}, + {"phys_maxwaterjump", CFG_OFS(phys_maxwaterjump), FT_FLOAT}, + {"phys_maxbarrier", CFG_OFS(phys_maxbarrier), FT_FLOAT}, + {"phys_jumpvel", CFG_OFS(phys_jumpvel), FT_FLOAT}, + {"phys_falldelta5", CFG_OFS(phys_falldelta5), FT_FLOAT}, + {"phys_falldelta10", CFG_OFS(phys_falldelta10), FT_FLOAT}, + {"rs_waterjump", CFG_OFS(rs_waterjump), FT_FLOAT}, + {"rs_teleport", CFG_OFS(rs_teleport), FT_FLOAT}, + {"rs_barrierjump", CFG_OFS(rs_barrierjump), FT_FLOAT}, + {"rs_startcrouch", CFG_OFS(rs_startcrouch), FT_FLOAT}, + {"rs_startgrapple", CFG_OFS(rs_startgrapple), FT_FLOAT}, + {"rs_startwalkoffledge", CFG_OFS(rs_startwalkoffledge), FT_FLOAT}, + {"rs_startjump", CFG_OFS(rs_startjump), FT_FLOAT}, + {"rs_rocketjump", CFG_OFS(rs_rocketjump), FT_FLOAT}, + {"rs_bfgjump", CFG_OFS(rs_bfgjump), FT_FLOAT}, + {"rs_jumppad", CFG_OFS(rs_jumppad), FT_FLOAT}, + {"rs_aircontrolledjumppad", CFG_OFS(rs_aircontrolledjumppad), FT_FLOAT}, + {"rs_funcbob", CFG_OFS(rs_funcbob), FT_FLOAT}, + {"rs_startelevator", CFG_OFS(rs_startelevator), FT_FLOAT}, + {"rs_falldamage5", CFG_OFS(rs_falldamage5), FT_FLOAT}, + {"rs_falldamage10", CFG_OFS(rs_falldamage10), FT_FLOAT}, + {"rs_maxjumpfallheight", CFG_OFS(rs_maxjumpfallheight), FT_FLOAT}, + {NULL, 0, 0, 0} +}; + +structdef_t bbox_struct = +{ + sizeof(aas_bbox_t), bbox_fields +}; +structdef_t cfg_struct = +{ + sizeof(cfg_t), cfg_fields +}; + +//global cfg +cfg_t cfg; + +//=========================================================================== +// the default Q3A configuration +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void DefaultCfg(void) +{ + int i; + + // default all float values to infinite + for (i = 0; cfg_fields[i].name; i++) + { + if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT) + *(float *)( ((char*)&cfg) + cfg_fields[i].offset ) = FLT_MAX; + } //end for + // + cfg.numbboxes = 2; + //bbox 0 + cfg.bboxes[0].presencetype = PRESENCE_NORMAL; + cfg.bboxes[0].flags = 0; + cfg.bboxes[0].mins[0] = -15; + cfg.bboxes[0].mins[1] = -15; + cfg.bboxes[0].mins[2] = 0; + cfg.bboxes[0].maxs[0] = 15; + cfg.bboxes[0].maxs[1] = 15; + cfg.bboxes[0].maxs[2] = 94; + //bbox 1 + cfg.bboxes[1].presencetype = PRESENCE_CROUCH; + cfg.bboxes[1].flags = 1; + cfg.bboxes[1].mins[0] = -15; + cfg.bboxes[1].mins[1] = -15; + cfg.bboxes[1].mins[2] = 0; + cfg.bboxes[1].maxs[0] = 15; + cfg.bboxes[1].maxs[1] = 15; + cfg.bboxes[1].maxs[2] = 54; + // + cfg.allpresencetypes = PRESENCE_NORMAL|PRESENCE_CROUCH; + cfg.phys_gravitydirection[0] = 0; + cfg.phys_gravitydirection[1] = 0; + cfg.phys_gravitydirection[2] = -1; + cfg.phys_maxsteepness = 0.7; +} //end of the function DefaultCfg +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char * QDECL va( char *format, ... ) +{ + va_list argptr; + static char string[2][32000]; // in case va is called by nested functions + static int index = 0; + char *buf; + + buf = string[index & 1]; + index++; + + va_start (argptr, format); + vsprintf (buf, format,argptr); + va_end (argptr); + + return buf; +} //end of the function va +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void SetCfgLibVars(void) +{ + int i; + float value; + + for (i = 0; cfg_fields[i].name; i++) + { + if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT) + { + value = *(float *)(((char*)&cfg) + cfg_fields[i].offset); + if (value != FLT_MAX) + { + LibVarSet(cfg_fields[i].name, va("%f", value)); + } //end if + } //end if + } //end for +} //end of the function SetCfgLibVars +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int LoadCfgFile(char *filename) +{ + source_t *source; + token_t token; + int settingsdefined; + + source = LoadSourceFile(filename); + if (!source) + { + Log_Print("couldn't open cfg file %s\n", filename); + return false; + } //end if + + settingsdefined = false; + memset(&cfg, 0, sizeof(cfg_t)); + + while(PC_ReadToken(source, &token)) + { + if (!stricmp(token.string, "bbox")) + { + if (cfg.numbboxes >= AAS_MAX_BBOXES) + { + SourceError(source, "too many bounding box volumes defined"); + } //end if + if (!ReadStructure(source, &bbox_struct, (char *) &cfg.bboxes[cfg.numbboxes])) + { + FreeSource(source); + return false; + } //end if + cfg.allpresencetypes |= cfg.bboxes[cfg.numbboxes].presencetype; + cfg.numbboxes++; + } //end if + else if (!stricmp(token.string, "settings")) + { + if (settingsdefined) + { + SourceWarning(source, "settings already defined\n"); + } //end if + settingsdefined = true; + if (!ReadStructure(source, &cfg_struct, (char *) &cfg)) + { + FreeSource(source); + return false; + } //end if + } //end else if + } //end while + if (VectorLength(cfg.phys_gravitydirection) < 0.9 || VectorLength(cfg.phys_gravitydirection) > 1.1) + { + SourceError(source, "invalid gravity direction specified"); + } //end if + if (cfg.numbboxes <= 0) + { + SourceError(source, "no bounding volumes specified"); + } //end if + FreeSource(source); + SetCfgLibVars(); + Log_Print("using cfg file %s\n", filename); + return true; +} //end of the function LoadCfgFile diff --git a/code/bspc/aas_cfg.h b/code/bspc/aas_cfg.h new file mode 100644 index 00000000..a5db5a86 --- /dev/null +++ b/code/bspc/aas_cfg.h @@ -0,0 +1,73 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#define BBOXFL_GROUNDED 1 //bounding box only valid when on ground +#define BBOXFL_NOTGROUNDED 2 //bounding box only valid when NOT on ground + +typedef struct cfg_s +{ + int numbboxes; //number of bounding boxes + aas_bbox_t bboxes[AAS_MAX_BBOXES]; //all the bounding boxes + int allpresencetypes; //or of all presence types + // aas settings + vec3_t phys_gravitydirection; + float phys_friction; + float phys_stopspeed; + float phys_gravity; + float phys_waterfriction; + float phys_watergravity; + float phys_maxvelocity; + float phys_maxwalkvelocity; + float phys_maxcrouchvelocity; + float phys_maxswimvelocity; + float phys_walkaccelerate; + float phys_airaccelerate; + float phys_swimaccelerate; + float phys_maxstep; + float phys_maxsteepness; + float phys_maxwaterjump; + float phys_maxbarrier; + float phys_jumpvel; + float phys_falldelta5; + float phys_falldelta10; + float rs_waterjump; + float rs_teleport; + float rs_barrierjump; + float rs_startcrouch; + float rs_startgrapple; + float rs_startwalkoffledge; + float rs_startjump; + float rs_rocketjump; + float rs_bfgjump; + float rs_jumppad; + float rs_aircontrolledjumppad; + float rs_funcbob; + float rs_startelevator; + float rs_falldamage5; + float rs_falldamage10; + float rs_maxjumpfallheight; +} cfg_t; + +extern cfg_t cfg; + +void DefaultCfg(void); +int LoadCfgFile(char *filename); diff --git a/code/bspc/aas_create.c b/code/bspc/aas_create.c new file mode 100644 index 00000000..49299bc3 --- /dev/null +++ b/code/bspc/aas_create.c @@ -0,0 +1,1150 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "../botlib/aasfile.h" +#include "aas_create.h" +#include "aas_store.h" +#include "aas_gsubdiv.h" +#include "aas_facemerging.h" +#include "aas_areamerging.h" +#include "aas_edgemelting.h" +#include "aas_prunenodes.h" +#include "aas_cfg.h" +#include "../qcommon/surfaceflags.h" + +//#define AW_DEBUG +//#define L_DEBUG + +#define AREAONFACESIDE(face, area) (face->frontarea != area) + +tmp_aas_t tmpaasworld; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitTmpAAS(void) +{ + //tmp faces + tmpaasworld.numfaces = 0; + tmpaasworld.facenum = 0; + tmpaasworld.faces = NULL; + //tmp convex areas + tmpaasworld.numareas = 0; + tmpaasworld.areanum = 0; + tmpaasworld.areas = NULL; + //tmp nodes + tmpaasworld.numnodes = 0; + tmpaasworld.nodes = NULL; + // + tmpaasworld.nodebuffer = NULL; +} //end of the function AAS_InitTmpAAS +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeTmpAAS(void) +{ + tmp_face_t *f, *nextf; + tmp_area_t *a, *nexta; + tmp_nodebuf_t *nb, *nextnb; + + //free all the faces + for (f = tmpaasworld.faces; f; f = nextf) + { + nextf = f->l_next; + if (f->winding) FreeWinding(f->winding); + FreeMemory(f); + } //end if + //free all tmp areas + for (a = tmpaasworld.areas; a; a = nexta) + { + nexta = a->l_next; + if (a->settings) FreeMemory(a->settings); + FreeMemory(a); + } //end for + //free all the tmp nodes + for (nb = tmpaasworld.nodebuffer; nb; nb = nextnb) + { + nextnb = nb->next; + FreeMemory(nb); + } //end for +} //end of the function AAS_FreeTmpAAS +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_face_t *AAS_AllocTmpFace(void) +{ + tmp_face_t *tmpface; + + tmpface = (tmp_face_t *) GetClearedMemory(sizeof(tmp_face_t)); + tmpface->num = tmpaasworld.facenum++; + tmpface->l_prev = NULL; + tmpface->l_next = tmpaasworld.faces; + if (tmpaasworld.faces) tmpaasworld.faces->l_prev = tmpface; + tmpaasworld.faces = tmpface; + tmpaasworld.numfaces++; + return tmpface; +} //end of the function AAS_AllocTmpFace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeTmpFace(tmp_face_t *tmpface) +{ + if (tmpface->l_next) tmpface->l_next->l_prev = tmpface->l_prev; + if (tmpface->l_prev) tmpface->l_prev->l_next = tmpface->l_next; + else tmpaasworld.faces = tmpface->l_next; + //free the winding + if (tmpface->winding) FreeWinding(tmpface->winding); + //free the face + FreeMemory(tmpface); + tmpaasworld.numfaces--; +} //end of the function AAS_FreeTmpFace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_area_t *AAS_AllocTmpArea(void) +{ + tmp_area_t *tmparea; + + tmparea = (tmp_area_t *) GetClearedMemory(sizeof(tmp_area_t)); + tmparea->areanum = tmpaasworld.areanum++; + tmparea->l_prev = NULL; + tmparea->l_next = tmpaasworld.areas; + if (tmpaasworld.areas) tmpaasworld.areas->l_prev = tmparea; + tmpaasworld.areas = tmparea; + tmpaasworld.numareas++; + return tmparea; +} //end of the function AAS_AllocTmpArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeTmpArea(tmp_area_t *tmparea) +{ + if (tmparea->l_next) tmparea->l_next->l_prev = tmparea->l_prev; + if (tmparea->l_prev) tmparea->l_prev->l_next = tmparea->l_next; + else tmpaasworld.areas = tmparea->l_next; + if (tmparea->settings) FreeMemory(tmparea->settings); + FreeMemory(tmparea); + tmpaasworld.numareas--; +} //end of the function AAS_FreeTmpArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_node_t *AAS_AllocTmpNode(void) +{ + tmp_nodebuf_t *nodebuf; + + if (!tmpaasworld.nodebuffer || + tmpaasworld.nodebuffer->numnodes >= NODEBUF_SIZE) + { + nodebuf = (tmp_nodebuf_t *) GetClearedMemory(sizeof(tmp_nodebuf_t)); + nodebuf->next = tmpaasworld.nodebuffer; + nodebuf->numnodes = 0; + tmpaasworld.nodebuffer = nodebuf; + } //end if + tmpaasworld.numnodes++; + return &tmpaasworld.nodebuffer->nodes[tmpaasworld.nodebuffer->numnodes++]; +} //end of the function AAS_AllocTmpNode +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeTmpNode(tmp_node_t *tmpnode) +{ + tmpaasworld.numnodes--; +} //end of the function AAS_FreeTmpNode +//=========================================================================== +// returns true if the face is a gap from the given side +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_GapFace(tmp_face_t *tmpface, int side) +{ + vec3_t invgravity; + + //if the face is a solid or ground face it can't be a gap + if (tmpface->faceflags & (FACE_GROUND | FACE_SOLID)) return 0; + + VectorCopy(cfg.phys_gravitydirection, invgravity); + VectorInverse(invgravity); + + return (DotProduct(invgravity, mapplanes[tmpface->planenum ^ side].normal) > cfg.phys_maxsteepness); +} //end of the function AAS_GapFace +//=========================================================================== +// returns true if the face is a ground face +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_GroundFace(tmp_face_t *tmpface) +{ + vec3_t invgravity; + + //must be a solid face + if (!(tmpface->faceflags & FACE_SOLID)) return 0; + + VectorCopy(cfg.phys_gravitydirection, invgravity); + VectorInverse(invgravity); + + return (DotProduct(invgravity, mapplanes[tmpface->planenum].normal) > cfg.phys_maxsteepness); +} //end of the function AAS_GroundFace +//=========================================================================== +// adds the side of a face to an area +// +// side : 0 = front side +// 1 = back side +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_AddFaceSideToArea(tmp_face_t *tmpface, int side, tmp_area_t *tmparea) +{ + int tmpfaceside; + + if (side) + { + if (tmpface->backarea) Error("AAS_AddFaceSideToArea: already a back area\n"); + } //end if + else + { + if (tmpface->frontarea) Error("AAS_AddFaceSideToArea: already a front area\n"); + } //end else + + if (side) tmpface->backarea = tmparea; + else tmpface->frontarea = tmparea; + + if (tmparea->tmpfaces) + { + tmpfaceside = tmparea->tmpfaces->frontarea != tmparea; + tmparea->tmpfaces->prev[tmpfaceside] = tmpface; + } //end if + tmpface->next[side] = tmparea->tmpfaces; + tmpface->prev[side] = NULL; + tmparea->tmpfaces = tmpface; +} //end of the function AAS_AddFaceSideToArea +//=========================================================================== +// remove (a side of) a face from an area +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_RemoveFaceFromArea(tmp_face_t *tmpface, tmp_area_t *tmparea) +{ + int side, prevside, nextside; + + if (tmpface->frontarea != tmparea && + tmpface->backarea != tmparea) + { + Error("AAS_RemoveFaceFromArea: face not part of the area"); + } //end if + side = tmpface->frontarea != tmparea; + if (tmpface->prev[side]) + { + prevside = tmpface->prev[side]->frontarea != tmparea; + tmpface->prev[side]->next[prevside] = tmpface->next[side]; + } //end if + else + { + tmparea->tmpfaces = tmpface->next[side]; + } //end else + if (tmpface->next[side]) + { + nextside = tmpface->next[side]->frontarea != tmparea; + tmpface->next[side]->prev[nextside] = tmpface->prev[side]; + } //end if + //remove the area number from the face depending on the side + if (side) tmpface->backarea = NULL; + else tmpface->frontarea = NULL; + tmpface->prev[side] = NULL; + tmpface->next[side] = NULL; +} //end of the function AAS_RemoveFaceFromArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CheckArea(tmp_area_t *tmparea) +{ + int side; + tmp_face_t *face; + plane_t *plane; + vec3_t wcenter, acenter = {0, 0, 0}; + vec3_t normal; + float n, dist; + + if (tmparea->invalid) Log_Print("AAS_CheckArea: invalid area\n"); + for (n = 0, face = tmparea->tmpfaces; face; face = face->next[side]) + { + //side of the face the area is on + side = face->frontarea != tmparea; + WindingCenter(face->winding, wcenter); + VectorAdd(acenter, wcenter, acenter); + n++; + } //end for + n = 1 / n; + VectorScale(acenter, n, acenter); + for (face = tmparea->tmpfaces; face; face = face->next[side]) + { + //side of the face the area is on + side = face->frontarea != tmparea; + +#ifdef L_DEBUG + if (WindingError(face->winding)) + { + Log_Write("AAS_CheckArea: area %d face %d: %s\r\n", tmparea->areanum, + face->num, WindingErrorString()); + } //end if +#endif L_DEBUG + + plane = &mapplanes[face->planenum ^ side]; + + if (DotProduct(plane->normal, acenter) - plane->dist < 0) + { + Log_Print("AAS_CheckArea: area %d face %d is flipped\n", tmparea->areanum, face->num); + Log_Print("AAS_CheckArea: area %d center is %f %f %f\n", tmparea->areanum, acenter[0], acenter[1], acenter[2]); + } //end if + //check if the winding plane is the same as the face plane + WindingPlane(face->winding, normal, &dist); + plane = &mapplanes[face->planenum]; +#ifdef L_DEBUG + if (fabs(dist - plane->dist) > 0.4 || + fabs(normal[0] - plane->normal[0]) > 0.0001 || + fabs(normal[1] - plane->normal[1]) > 0.0001 || + fabs(normal[2] - plane->normal[2]) > 0.0001) + { + Log_Write("AAS_CheckArea: area %d face %d winding plane unequal to face plane\r\n", + tmparea->areanum, face->num); + } //end if +#endif L_DEBUG + } //end for +} //end of the function AAS_CheckArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CheckFaceWindingPlane(tmp_face_t *face) +{ + float dist, sign1, sign2; + vec3_t normal; + plane_t *plane; + winding_t *w; + + //check if the winding plane is the same as the face plane + WindingPlane(face->winding, normal, &dist); + plane = &mapplanes[face->planenum]; + // + sign1 = DotProduct(plane->normal, normal); + // + if (fabs(dist - plane->dist) > 0.4 || + fabs(normal[0] - plane->normal[0]) > 0.0001 || + fabs(normal[1] - plane->normal[1]) > 0.0001 || + fabs(normal[2] - plane->normal[2]) > 0.0001) + { + VectorInverse(normal); + dist = -dist; + if (fabs(dist - plane->dist) > 0.4 || + fabs(normal[0] - plane->normal[0]) > 0.0001 || + fabs(normal[1] - plane->normal[1]) > 0.0001 || + fabs(normal[2] - plane->normal[2]) > 0.0001) + { + Log_Write("AAS_CheckFaceWindingPlane: face %d winding plane unequal to face plane\r\n", + face->num); + // + sign2 = DotProduct(plane->normal, normal); + if ((sign1 < 0 && sign2 > 0) || + (sign1 > 0 && sign2 < 0)) + { + Log_Write("AAS_CheckFaceWindingPlane: face %d winding reversed\r\n", + face->num); + w = face->winding; + face->winding = ReverseWinding(w); + FreeWinding(w); + } //end if + } //end if + else + { + Log_Write("AAS_CheckFaceWindingPlane: face %d winding reversed\r\n", + face->num); + w = face->winding; + face->winding = ReverseWinding(w); + FreeWinding(w); + } //end else + } //end if +} //end of the function AAS_CheckFaceWindingPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CheckAreaWindingPlanes(void) +{ + int side; + tmp_area_t *tmparea; + tmp_face_t *face; + + Log_Write("AAS_CheckAreaWindingPlanes:\r\n"); + for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) + { + if (tmparea->invalid) continue; + for (face = tmparea->tmpfaces; face; face = face->next[side]) + { + side = face->frontarea != tmparea; + AAS_CheckFaceWindingPlane(face); + } //end for + } //end for +} //end of the function AAS_CheckAreaWindingPlanes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FlipAreaFaces(tmp_area_t *tmparea) +{ + int side; + tmp_face_t *face; + plane_t *plane; + vec3_t wcenter, acenter = {0, 0, 0}; + //winding_t *w; + float n; + + for (n = 0, face = tmparea->tmpfaces; face; face = face->next[side]) + { + if (!face->frontarea) Error("face %d has no front area\n", face->num); + //side of the face the area is on + side = face->frontarea != tmparea; + WindingCenter(face->winding, wcenter); + VectorAdd(acenter, wcenter, acenter); + n++; + } //end for + n = 1 / n; + VectorScale(acenter, n, acenter); + for (face = tmparea->tmpfaces; face; face = face->next[side]) + { + //side of the face the area is on + side = face->frontarea != tmparea; + + plane = &mapplanes[face->planenum ^ side]; + + if (DotProduct(plane->normal, acenter) - plane->dist < 0) + { + Log_Print("area %d face %d flipped: front area %d, back area %d\n", tmparea->areanum, face->num, + face->frontarea ? face->frontarea->areanum : 0, + face->backarea ? face->backarea->areanum : 0); + /* + face->planenum = face->planenum ^ 1; + w = face->winding; + face->winding = ReverseWinding(w); + FreeWinding(w); + */ + } //end if +#ifdef L_DEBUG + { + float dist; + vec3_t normal; + + //check if the winding plane is the same as the face plane + WindingPlane(face->winding, normal, &dist); + plane = &mapplanes[face->planenum]; + if (fabs(dist - plane->dist) > 0.4 || + fabs(normal[0] - plane->normal[0]) > 0.0001 || + fabs(normal[1] - plane->normal[1]) > 0.0001 || + fabs(normal[2] - plane->normal[2]) > 0.0001) + { + Log_Write("area %d face %d winding plane unequal to face plane\r\n", + tmparea->areanum, face->num); + } //end if + } +#endif + } //end for +} //end of the function AAS_FlipAreaFaces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_RemoveAreaFaceColinearPoints(void) +{ + int side; + tmp_face_t *face; + tmp_area_t *tmparea; + + //FIXME: loop over the faces instead of area->faces + for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) + { + for (face = tmparea->tmpfaces; face; face = face->next[side]) + { + side = face->frontarea != tmparea; + RemoveColinearPoints(face->winding); +// RemoveEqualPoints(face->winding, 0.1); + } //end for + } //end for +} //end of the function AAS_RemoveAreaFaceColinearPoints +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_RemoveTinyFaces(void) +{ + int side, num; + tmp_face_t *face, *nextface; + tmp_area_t *tmparea; + + //FIXME: loop over the faces instead of area->faces + Log_Write("AAS_RemoveTinyFaces\r\n"); + num = 0; + for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) + { + for (face = tmparea->tmpfaces; face; face = nextface) + { + side = face->frontarea != tmparea; + nextface = face->next[side]; + // + if (WindingArea(face->winding) < 1) + { + if (face->frontarea) AAS_RemoveFaceFromArea(face, face->frontarea); + if (face->backarea) AAS_RemoveFaceFromArea(face, face->backarea); + AAS_FreeTmpFace(face); + //Log_Write("area %d face %d is tiny\r\n", tmparea->areanum, face->num); + num++; + } //end if + } //end for + } //end for + Log_Write("%d tiny faces removed\r\n", num); +} //end of the function AAS_RemoveTinyFaces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CreateAreaSettings(void) +{ + int i, flags, side, numgrounded, numladderareas, numliquidareas; + tmp_face_t *face; + tmp_area_t *tmparea; + + numgrounded = 0; + numladderareas = 0; + numliquidareas = 0; + Log_Write("AAS_CreateAreaSettings\r\n"); + i = 0; + qprintf("%6d areas provided with settings", i); + for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) + { + //if the area is invalid there no need to create settings for it + if (tmparea->invalid) continue; + + tmparea->settings = (tmp_areasettings_t *) GetClearedMemory(sizeof(tmp_areasettings_t)); + tmparea->settings->contents = tmparea->contents; + tmparea->settings->modelnum = tmparea->modelnum; + flags = 0; + for (face = tmparea->tmpfaces; face; face = face->next[side]) + { + side = face->frontarea != tmparea; + flags |= face->faceflags; + } //end for + tmparea->settings->areaflags = 0; + if (flags & FACE_GROUND) + { + tmparea->settings->areaflags |= AREA_GROUNDED; + numgrounded++; + } //end if + if (flags & FACE_LADDER) + { + tmparea->settings->areaflags |= AREA_LADDER; + numladderareas++; + } //end if + if (tmparea->contents & (AREACONTENTS_WATER | + AREACONTENTS_SLIME | + AREACONTENTS_LAVA)) + { + tmparea->settings->areaflags |= AREA_LIQUID; + numliquidareas++; + } //end if + //presence type of the area + tmparea->settings->presencetype = tmparea->presencetype; + // + qprintf("\r%6d", ++i); + } //end for + qprintf("\n"); +#ifdef AASINFO + Log_Print("%6d grounded areas\n", numgrounded); + Log_Print("%6d ladder areas\n", numladderareas); + Log_Print("%6d liquid areas\n", numliquidareas); +#endif //AASINFO +} //end of the function AAS_CreateAreaSettings +//=========================================================================== +// create a tmp AAS area from a leaf node +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_node_t *AAS_CreateArea(node_t *node) +{ + int pside; + int areafaceflags; + portal_t *p; + tmp_face_t *tmpface; + tmp_area_t *tmparea; + tmp_node_t *tmpnode; + vec3_t up = {0, 0, 1}; + + //create an area from this leaf + tmparea = AAS_AllocTmpArea(); + tmparea->tmpfaces = NULL; + //clear the area face flags + areafaceflags = 0; + //make aas faces from the portals + for (p = node->portals; p; p = p->next[pside]) + { + pside = (p->nodes[1] == node); + //don't create faces from very small portals +// if (WindingArea(p->winding) < 1) continue; + //if there's already a face created for this portal + if (p->tmpface) + { + //add the back side of the face to the area + AAS_AddFaceSideToArea(p->tmpface, 1, tmparea); + } //end if + else + { + tmpface = AAS_AllocTmpFace(); + //set the face pointer at the portal so we can see from + //the portal there's a face created for it + p->tmpface = tmpface; + //FIXME: test this change + //tmpface->planenum = (p->planenum & ~1) | pside; + tmpface->planenum = p->planenum ^ pside; + if (pside) tmpface->winding = ReverseWinding(p->winding); + else tmpface->winding = CopyWinding(p->winding); +#ifdef L_DEBUG + // + AAS_CheckFaceWindingPlane(tmpface); +#endif //L_DEBUG + //if there's solid at the other side of the portal + if (p->nodes[!pside]->contents & (CONTENTS_SOLID | CONTENTS_PLAYERCLIP)) + { + tmpface->faceflags |= FACE_SOLID; + } //end if + //else there is no solid at the other side and if there + //is a liquid at this side + else if (node->contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA)) + { + tmpface->faceflags |= FACE_LIQUID; + //if there's no liquid at the other side + if (!(p->nodes[!pside]->contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA))) + { + tmpface->faceflags |= FACE_LIQUIDSURFACE; + } //end if + } //end else + //if there's ladder contents at other side of the portal +#ifdef CONTENTS_LADDER + if ((p->nodes[pside]->contents & CONTENTS_LADDER) || + (p->nodes[!pside]->contents & CONTENTS_LADDER)) + { + + //NOTE: doesn't have to be solid at the other side because + // when standing one can use a crouch area (which is not solid) + // as a ladder + // imagine a ladder one can walk underthrough, + // under the ladder against the ladder is a crouch area + // the (vertical) sides of this crouch area area also used as + // ladder sides when standing (not crouched) + tmpface->faceflags |= FACE_LADDER; + } //end if +#endif // CONTENTS_LADDER + //if it is possible to stand on the face + if (AAS_GroundFace(tmpface)) + { + tmpface->faceflags |= FACE_GROUND; + } //end if + // + areafaceflags |= tmpface->faceflags; + //no aas face number yet (zero is a dummy in the aasworld faces) + tmpface->aasfacenum = 0; + //add the front side of the face to the area + AAS_AddFaceSideToArea(tmpface, 0, tmparea); + } //end else + } //end for + qprintf("\r%6d", tmparea->areanum); + //presence type in the area + tmparea->presencetype = ~node->expansionbboxes & cfg.allpresencetypes; + // + tmparea->contents = 0; +#ifdef CONTENTS_CLUSTERPORTAL + if (node->contents & CONTENTS_CLUSTERPORTAL) tmparea->contents |= AREACONTENTS_CLUSTERPORTAL; +#endif // CONTENTS_CLUSTERPORTAL + if (node->contents & CONTENTS_MOVER) tmparea->contents |= AREACONTENTS_MOVER; +#ifdef CONTENTS_TELEPORTER + if (node->contents & CONTENTS_TELEPORTER) tmparea->contents |= AREACONTENTS_TELEPORTER; +#endif // CONTENTS_TELEPORTER +#ifdef CONTENTS_JUMPPAD + if (node->contents & CONTENTS_JUMPPAD) tmparea->contents |= AREACONTENTS_JUMPPAD; +#endif // CONTENTS_JUMPPAD + if (node->contents & CONTENTS_DONOTENTER) tmparea->contents |= AREACONTENTS_DONOTENTER; + if (node->contents & CONTENTS_WATER) tmparea->contents |= AREACONTENTS_WATER; + if (node->contents & CONTENTS_LAVA) tmparea->contents |= AREACONTENTS_LAVA; + if (node->contents & CONTENTS_SLIME) tmparea->contents |= AREACONTENTS_SLIME; + if (node->contents & CONTENTS_NOTTEAM1) tmparea->contents |= AREACONTENTS_NOTTEAM1; + if (node->contents & CONTENTS_NOTTEAM2) tmparea->contents |= AREACONTENTS_NOTTEAM2; + + //store the bsp model that's inside this node + tmparea->modelnum = node->modelnum; + //sorta check for flipped area faces (remove??) + AAS_FlipAreaFaces(tmparea); + //check if the area is ok (remove??) + AAS_CheckArea(tmparea); + // + tmpnode = AAS_AllocTmpNode(); + tmpnode->planenum = 0; + tmpnode->children[0] = 0; + tmpnode->children[1] = 0; + tmpnode->tmparea = tmparea; + // + return tmpnode; +} //end of the function AAS_CreateArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_node_t *AAS_CreateAreas_r(node_t *node) +{ + tmp_node_t *tmpnode; + + //recurse down to leafs + if (node->planenum != PLANENUM_LEAF) + { + //the first tmp node is a dummy + tmpnode = AAS_AllocTmpNode(); + tmpnode->planenum = node->planenum; + tmpnode->children[0] = AAS_CreateAreas_r(node->children[0]); + tmpnode->children[1] = AAS_CreateAreas_r(node->children[1]); + return tmpnode; + } //end if + //areas won't be created for solid leafs + if (node->contents & CONTENTS_SOLID) + { + //just return zero for a solid leaf (in tmp AAS NULL is a solid leaf) + return NULL; + } //end if + + return AAS_CreateArea(node); +} //end of the function AAS_CreateAreas_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CreateAreas(node_t *node) +{ + Log_Write("AAS_CreateAreas\r\n"); + qprintf("%6d areas created", 0); + tmpaasworld.nodes = AAS_CreateAreas_r(node); + qprintf("\n"); + Log_Write("%6d areas created\r\n", tmpaasworld.numareas); +} //end of the function AAS_CreateAreas +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_PrintNumGroundFaces(void) +{ + tmp_face_t *tmpface; + int numgroundfaces = 0; + + for (tmpface = tmpaasworld.faces; tmpface; tmpface = tmpface->l_next) + { + if (tmpface->faceflags & FACE_GROUND) + { + numgroundfaces++; + } //end if + } //end for + qprintf("%6d ground faces\n", numgroundfaces); +} //end of the function AAS_PrintNumGroundFaces +//=========================================================================== +// checks the number of shared faces between the given two areas +// since areas are convex they should only have ONE shared face +// however due to crappy face merging there are sometimes several +// shared faces +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CheckAreaSharedFaces(tmp_area_t *tmparea1, tmp_area_t *tmparea2) +{ + int numsharedfaces, side; + tmp_face_t *face1, *sharedface; + + if (tmparea1->invalid || tmparea2->invalid) return; + + sharedface = NULL; + numsharedfaces = 0; + for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side]) + { + side = face1->frontarea != tmparea1; + if (face1->backarea == tmparea2 || face1->frontarea == tmparea2) + { + sharedface = face1; + numsharedfaces++; + } //end if + } //end if + if (!sharedface) return; + //the areas should only have one shared face + if (numsharedfaces > 1) + { + Log_Write("---- tmp area %d and %d have %d shared faces\r\n", + tmparea1->areanum, tmparea2->areanum, numsharedfaces); + for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side]) + { + side = face1->frontarea != tmparea1; + if (face1->backarea == tmparea2 || face1->frontarea == tmparea2) + { + Log_Write("face %d, planenum = %d, face->frontarea = %d face->backarea = %d\r\n", + face1->num, face1->planenum, face1->frontarea->areanum, face1->backarea->areanum); + } //end if + } //end if + } //end if +} //end of the function AAS_CheckAreaSharedFaces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CheckSharedFaces(void) +{ + tmp_area_t *tmparea1, *tmparea2; + + for (tmparea1 = tmpaasworld.areas; tmparea1; tmparea1 = tmparea1->l_next) + { + for (tmparea2 = tmpaasworld.areas; tmparea2; tmparea2 = tmparea2->l_next) + { + if (tmparea1 == tmparea2) continue; + AAS_CheckAreaSharedFaces(tmparea1, tmparea2); + } //end for + } //end for +} //end of the function AAS_CheckSharedFaces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FlipFace(tmp_face_t *face) +{ + tmp_area_t *frontarea, *backarea; + winding_t *w; + + frontarea = face->frontarea; + backarea = face->backarea; + //must have an area at both sides before flipping is allowed + if (!frontarea || !backarea) return; + //flip the face winding + w = face->winding; + face->winding = ReverseWinding(w); + FreeWinding(w); + //flip the face plane + face->planenum ^= 1; + //flip the face areas + AAS_RemoveFaceFromArea(face, frontarea); + AAS_RemoveFaceFromArea(face, backarea); + AAS_AddFaceSideToArea(face, 1, frontarea); + AAS_AddFaceSideToArea(face, 0, backarea); +} //end of the function AAS_FlipFace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +/* +void AAS_FlipAreaSharedFaces(tmp_area_t *tmparea1, tmp_area_t *tmparea2) +{ + int numsharedfaces, side, area1facing, area2facing; + tmp_face_t *face1, *sharedface; + + if (tmparea1->invalid || tmparea2->invalid) return; + + sharedface = NULL; + numsharedfaces = 0; + area1facing = 0; //number of shared faces facing towards area 1 + area2facing = 0; //number of shared faces facing towards area 2 + for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side]) + { + side = face1->frontarea != tmparea1; + if (face1->backarea == tmparea2 || face1->frontarea == tmparea2) + { + sharedface = face1; + numsharedfaces++; + if (face1->frontarea == tmparea1) area1facing++; + else area2facing++; + } //end if + } //end if + if (!sharedface) return; + //if there's only one shared face + if (numsharedfaces <= 1) return; + //if all the shared faces are facing to the same area + if (numsharedfaces == area1facing || numsharedfaces == area2facing) return; + // + do + { + for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side]) + { + side = face1->frontarea != tmparea1; + if (face1->backarea == tmparea2 || face1->frontarea == tmparea2) + { + if (face1->frontarea != tmparea1) + { + AAS_FlipFace(face1); + break; + } //end if + } //end if + } //end for + } while(face1); +} //end of the function AAS_FlipAreaSharedFaces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FlipSharedFaces(void) +{ + int i; + tmp_area_t *tmparea1, *tmparea2; + + i = 0; + qprintf("%6d areas checked for shared face flipping", i); + for (tmparea1 = tmpaasworld.areas; tmparea1; tmparea1 = tmparea1->l_next) + { + if (tmparea1->invalid) continue; + for (tmparea2 = tmpaasworld.areas; tmparea2; tmparea2 = tmparea2->l_next) + { + if (tmparea2->invalid) continue; + if (tmparea1 == tmparea2) continue; + AAS_FlipAreaSharedFaces(tmparea1, tmparea2); + } //end for + qprintf("\r%6d", ++i); + } //end for + Log_Print("\r%6d areas checked for shared face flipping\n", i); +} //end of the function AAS_FlipSharedFaces +*/ +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FlipSharedFaces(void) +{ + int i, side1, side2; + tmp_area_t *tmparea1; + tmp_face_t *face1, *face2; + + i = 0; + qprintf("%6d areas checked for shared face flipping", i); + for (tmparea1 = tmpaasworld.areas; tmparea1; tmparea1 = tmparea1->l_next) + { + if (tmparea1->invalid) continue; + for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side1]) + { + side1 = face1->frontarea != tmparea1; + if (!face1->frontarea || !face1->backarea) continue; + // + for (face2 = face1->next[side1]; face2; face2 = face2->next[side2]) + { + side2 = face2->frontarea != tmparea1; + if (!face2->frontarea || !face2->backarea) continue; + // + if (face1->frontarea == face2->backarea && + face1->backarea == face2->frontarea) + { + AAS_FlipFace(face2); + } //end if + //recheck side + side2 = face2->frontarea != tmparea1; + } //end for + } //end for + qprintf("\r%6d", ++i); + } //end for + qprintf("\n"); + Log_Write("%6d areas checked for shared face flipping\r\n", i); +} //end of the function AAS_FlipSharedFaces +//=========================================================================== +// creates an .AAS file with the given name +// a MAP should be loaded before calling this +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_Create(char *aasfile) +{ + entity_t *e; + tree_t *tree; + double start_time; + + //for a possible leak file + strcpy(source, aasfile); + StripExtension(source); + //the time started + start_time = I_FloatTime(); + //set the default number of threads (depends on number of processors) + ThreadSetDefault(); + //set the global entity number to the world model + entity_num = 0; + //the world entity + e = &entities[entity_num]; + //process the whole world + tree = ProcessWorldBrushes(e->firstbrush, e->firstbrush + e->numbrushes); + //if the conversion is cancelled + if (cancelconversion) + { + Tree_Free(tree); + return; + } //end if + //display BSP tree creation time + Log_Print("BSP tree created in %5.0f seconds\n", I_FloatTime() - start_time); + //prune the bsp tree + Tree_PruneNodes(tree->headnode); + //if the conversion is cancelled + if (cancelconversion) + { + Tree_Free(tree); + return; + } //end if + //create the tree portals + MakeTreePortals(tree); + //if the conversion is cancelled + if (cancelconversion) + { + Tree_Free(tree); + return; + } //end if + //Marks all nodes that can be reached by entites + if (FloodEntities(tree)) + { + //fill out nodes that can't be reached + FillOutside(tree->headnode); + } //end if + else + { + LeakFile(tree); + Error("**** leaked ****\n"); + return; + } //end else + //create AAS from the BSP tree + //========================================== + //initialize tmp aas + AAS_InitTmpAAS(); + //create the convex areas from the leaves + AAS_CreateAreas(tree->headnode); + //free the BSP tree because it isn't used anymore + if (freetree) Tree_Free(tree); + //try to merge area faces + AAS_MergeAreaFaces(); + //do gravitational subdivision + AAS_GravitationalSubdivision(); + //merge faces if possible + AAS_MergeAreaFaces(); + AAS_RemoveAreaFaceColinearPoints(); + //merge areas if possible + AAS_MergeAreas(); + //NOTE: prune nodes directly after area merging + AAS_PruneNodes(); + //flip shared faces so they are all facing to the same area + AAS_FlipSharedFaces(); + AAS_RemoveAreaFaceColinearPoints(); + //merge faces if possible + AAS_MergeAreaFaces(); + //merge area faces in the same plane + AAS_MergeAreaPlaneFaces(); + //do ladder subdivision + AAS_LadderSubdivision(); + //FIXME: melting is buggy + AAS_MeltAreaFaceWindings(); + //remove tiny faces + AAS_RemoveTinyFaces(); + //create area settings + AAS_CreateAreaSettings(); + //check if the winding plane is equal to the face plane + //AAS_CheckAreaWindingPlanes(); + // + //AAS_CheckSharedFaces(); + //========================================== + //if the conversion is cancelled + if (cancelconversion) + { + Tree_Free(tree); + AAS_FreeTmpAAS(); + return; + } //end if + //store the created AAS stuff in the AAS file format and write the file + AAS_StoreFile(aasfile); + //free the temporary AAS memory + AAS_FreeTmpAAS(); + //display creation time + Log_Print("\nAAS created in %5.0f seconds\n", I_FloatTime() - start_time); +} //end of the function AAS_Create diff --git a/code/bspc/aas_create.h b/code/bspc/aas_create.h new file mode 100644 index 00000000..7f41f02d --- /dev/null +++ b/code/bspc/aas_create.h @@ -0,0 +1,136 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#define AREA_PORTAL 1 + +//temporary AAS face +typedef struct tmp_face_s +{ + int num; //face number + int planenum; //number of the plane the face is in + winding_t *winding; //winding of the face + struct tmp_area_s *frontarea; //area at the front of the face + struct tmp_area_s *backarea; //area at the back of the face + int faceflags; //flags of this face + int aasfacenum; //the number of the aas face used for this face + //double link list pointers for front and back area + struct tmp_face_s *prev[2], *next[2]; + //links in the list with faces + struct tmp_face_s *l_prev, *l_next; +} tmp_face_t; + +//temporary AAS area settings +typedef struct tmp_areasettings_s +{ + //could also add all kind of statistic fields + int contents; //contents of the area + int modelnum; //bsp model inside this area + int areaflags; //area flags + int presencetype; //how a bot can be present in this area + int numreachableareas; //number of reachable areas from this one + int firstreachablearea; //first reachable area in the reachable area index +} tmp_areasettings_t; + +//temporary AAS area +typedef struct tmp_area_s +{ + int areanum; //number of the area + struct tmp_face_s *tmpfaces; //the faces of the area + int presencetype; //presence type of the area + int contents; //area contents + int modelnum; //bsp model inside this area + int invalid; //true if the area is invalid + tmp_areasettings_t *settings; //area settings + struct tmp_area_s *mergedarea; //points to the new area after merging + //when mergedarea != 0 the area has only the + //seperating face of the merged areas + int aasareanum; //number of the aas area created for this tmp area + //links in the list with areas + struct tmp_area_s *l_prev, *l_next; +} tmp_area_t; + +//temporary AAS node +typedef struct tmp_node_s +{ + int planenum; //node plane number + struct tmp_area_s *tmparea; //points to an area if this node is an area + struct tmp_node_s *children[2]; //child nodes of this node +} tmp_node_t; + +#define NODEBUF_SIZE 128 +//node buffer +typedef struct tmp_nodebuf_s +{ + int numnodes; + struct tmp_nodebuf_s *next; + tmp_node_t nodes[NODEBUF_SIZE]; +} tmp_nodebuf_t; + +//the whole temorary AAS +typedef struct tmp_aas_s +{ + //faces + int numfaces; + int facenum; + tmp_face_t *faces; + //areas + int numareas; + int areanum; + tmp_area_t *areas; + //area settings + int numareasettings; + tmp_areasettings_t *areasettings; + //nodes + int numnodes; + tmp_node_t *nodes; + //node buffer + tmp_nodebuf_t *nodebuffer; +} tmp_aas_t; + +extern tmp_aas_t tmpaasworld; + +//creates a .AAS file with the given name from an already loaded map +void AAS_Create(char *aasfile); +//adds a face side to an area +void AAS_AddFaceSideToArea(tmp_face_t *tmpface, int side, tmp_area_t *tmparea); +//remvoes a face from an area +void AAS_RemoveFaceFromArea(tmp_face_t *tmpface, tmp_area_t *tmparea); +//allocate a tmp face +tmp_face_t *AAS_AllocTmpFace(void); +//free the tmp face +void AAS_FreeTmpFace(tmp_face_t *tmpface); +//allocate a tmp area +tmp_area_t *AAS_AllocTmpArea(void); +//free a tmp area +void AAS_FreeTmpArea(tmp_area_t *tmparea); +//allocate a tmp node +tmp_node_t *AAS_AllocTmpNode(void); +//free a tmp node +void AAS_FreeTmpNode(tmp_node_t *node); +//checks if an area is ok +void AAS_CheckArea(tmp_area_t *tmparea); +//flips the area faces where needed +void AAS_FlipAreaFaces(tmp_area_t *tmparea); +//returns true if the face is a gap seen from the given side +int AAS_GapFace(tmp_face_t *tmpface, int side); +//returns true if the face is a ground face +int AAS_GroundFace(tmp_face_t *tmpface); diff --git a/code/bspc/aas_edgemelting.c b/code/bspc/aas_edgemelting.c new file mode 100644 index 00000000..e59f4f92 --- /dev/null +++ b/code/bspc/aas_edgemelting.c @@ -0,0 +1,108 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "../botlib/aasfile.h" +#include "aas_create.h" + +//=========================================================================== +// try to melt the windings of the two faces +// FIXME: this is buggy +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_MeltFaceWinding(tmp_face_t *face1, tmp_face_t *face2) +{ + int i, n; + int splits = 0; + winding_t *w2, *neww; + plane_t *plane1; + +#ifdef DEBUG + if (!face1->winding) Error("face1 %d without winding", face1->num); + if (!face2->winding) Error("face2 %d without winding", face2->num); +#endif //DEBUG + w2 = face2->winding; + plane1 = &mapplanes[face1->planenum]; + for (i = 0; i < w2->numpoints; i++) + { + if (PointOnWinding(face1->winding, plane1->normal, plane1->dist, w2->p[i], &n)) + { + neww = AddWindingPoint(face1->winding, w2->p[i], n); + FreeWinding(face1->winding); + face1->winding = neww; + + splits++; + } //end if + } //end for + return splits; +} //end of the function AAS_MeltFaceWinding +//=========================================================================== +// melt the windings of the area faces +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_MeltFaceWindingsOfArea(tmp_area_t *tmparea) +{ + int side1, side2, num_windingsplits = 0; + tmp_face_t *face1, *face2; + + for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) + { + side1 = face1->frontarea != tmparea; + for (face2 = tmparea->tmpfaces; face2; face2 = face2->next[side2]) + { + side2 = face2->frontarea != tmparea; + if (face1 == face2) continue; + num_windingsplits += AAS_MeltFaceWinding(face1, face2); + } //end for + } //end for + return num_windingsplits; +} //end of the function AAS_MeltFaceWindingsOfArea +//=========================================================================== +// melt the windings of the faces of all areas +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_MeltAreaFaceWindings(void) +{ + tmp_area_t *tmparea; + int num_windingsplits = 0; + + Log_Write("AAS_MeltAreaFaceWindings\r\n"); + qprintf("%6d edges melted", num_windingsplits); + //NOTE: first convex area (zero) is a dummy + for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) + { + num_windingsplits += AAS_MeltFaceWindingsOfArea(tmparea); + qprintf("\r%6d", num_windingsplits); + } //end for + qprintf("\n"); + Log_Write("%6d edges melted\r\n", num_windingsplits); +} //end of the function AAS_MeltAreaFaceWindings + diff --git a/code/bspc/aas_edgemelting.h b/code/bspc/aas_edgemelting.h new file mode 100644 index 00000000..a296cb6d --- /dev/null +++ b/code/bspc/aas_edgemelting.h @@ -0,0 +1,24 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +void AAS_MeltAreaFaceWindings(void); + diff --git a/code/bspc/aas_facemerging.c b/code/bspc/aas_facemerging.c new file mode 100644 index 00000000..2fb29039 --- /dev/null +++ b/code/bspc/aas_facemerging.c @@ -0,0 +1,282 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "../botlib/aasfile.h" +#include "aas_create.h" + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_TryMergeFaces(tmp_face_t *face1, tmp_face_t *face2) +{ + winding_t *neww; + +#ifdef DEBUG + if (!face1->winding) Error("face1 %d without winding", face1->num); + if (!face2->winding) Error("face2 %d without winding", face2->num); +#endif //DEBUG + // + if (face1->faceflags != face2->faceflags) return false; + //NOTE: if the front or back area is zero this doesn't mean there's + //a real area. It means there's solid at that side of the face + //if both faces have the same front area + if (face1->frontarea == face2->frontarea) + { + //if both faces have the same back area + if (face1->backarea == face2->backarea) + { + //if the faces are in the same plane + if (face1->planenum == face2->planenum) + { + //if they have both a front and a back area (no solid on either side) + if (face1->frontarea && face1->backarea) + { + neww = MergeWindings(face1->winding, face2->winding, + mapplanes[face1->planenum].normal); + } //end if + else + { + //this function is to be found in l_poly.c + neww = TryMergeWinding(face1->winding, face2->winding, + mapplanes[face1->planenum].normal); + } //end else + if (neww) + { + FreeWinding(face1->winding); + face1->winding = neww; + if (face2->frontarea) AAS_RemoveFaceFromArea(face2, face2->frontarea); + if (face2->backarea) AAS_RemoveFaceFromArea(face2, face2->backarea); + AAS_FreeTmpFace(face2); + return true; + } //end if + } //end if + else if ((face1->planenum & ~1) == (face2->planenum & ~1)) + { + Log_Write("face %d and %d, same front and back area but flipped planes\r\n", + face1->num, face2->num); + } //end if + } //end if + } //end if + return false; +} //end of the function AAS_TryMergeFaces +/* +int AAS_TryMergeFaces(tmp_face_t *face1, tmp_face_t *face2) +{ + winding_t *neww; + +#ifdef DEBUG + if (!face1->winding) Error("face1 %d without winding", face1->num); + if (!face2->winding) Error("face2 %d without winding", face2->num); +#endif //DEBUG + //if the faces are in the same plane + if ((face1->planenum & ~1) != (face2->planenum & ~1)) return false; +// if (face1->planenum != face2->planenum) return false; + //NOTE: if the front or back area is zero this doesn't mean there's + //a real area. It means there's solid at that side of the face + //if both faces have the same front area + if (face1->frontarea != face2->frontarea || + face1->backarea != face2->backarea) + { + if (!face1->frontarea || !face1->backarea || + !face2->frontarea || !face2->backarea) return false; + else if (face1->frontarea != face2->backarea || + face1->backarea != face2->frontarea) return false; +// return false; + } //end if + //this function is to be found in l_poly.c + neww = TryMergeWinding(face1->winding, face2->winding, + mapplanes[face1->planenum].normal); + if (!neww) return false; + // + FreeWinding(face1->winding); + face1->winding = neww; + //remove face2 + if (face2->frontarea) + AAS_RemoveFaceFromArea(face2, &tmpaasworld.areas[face2->frontarea]); + if (face2->backarea) + AAS_RemoveFaceFromArea(face2, &tmpaasworld.areas[face2->backarea]); + return true; +} //end of the function AAS_TryMergeFaces*/ +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_MergeAreaFaces(void) +{ + int num_facemerges = 0; + int side1, side2, restart; + tmp_area_t *tmparea, *lasttmparea; + tmp_face_t *face1, *face2; + + Log_Write("AAS_MergeAreaFaces\r\n"); + qprintf("%6d face merges", num_facemerges); + //NOTE: first convex area is a dummy + lasttmparea = tmpaasworld.areas; + for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) + { + restart = false; + // + if (tmparea->invalid) continue; + // + for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) + { + side1 = face1->frontarea != tmparea; + for (face2 = face1->next[side1]; face2; face2 = face2->next[side2]) + { + side2 = face2->frontarea != tmparea; + //if succesfully merged + if (AAS_TryMergeFaces(face1, face2)) + { + //start over again after merging two faces + restart = true; + num_facemerges++; + qprintf("\r%6d", num_facemerges); + AAS_CheckArea(tmparea); + break; + } //end if + } //end for + if (restart) + { + tmparea = lasttmparea; + break; + } //end if + } //end for + lasttmparea = tmparea; + } //end for + qprintf("\n"); + Log_Write("%6d face merges\r\n", num_facemerges); +} //end of the function AAS_MergeAreaFaces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_MergePlaneFaces(tmp_area_t *tmparea, int planenum) +{ + tmp_face_t *face1, *face2, *nextface2; + winding_t *neww; + int side1, side2; + + for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) + { + side1 = face1->frontarea != tmparea; + if (face1->planenum != planenum) continue; + // + for (face2 = face1->next[side1]; face2; face2 = nextface2) + { + side2 = face2->frontarea != tmparea; + nextface2 = face2->next[side2]; + // + if ((face2->planenum & ~1) != (planenum & ~1)) continue; + // + neww = MergeWindings(face1->winding, face2->winding, + mapplanes[face1->planenum].normal); + FreeWinding(face1->winding); + face1->winding = neww; + if (face2->frontarea) AAS_RemoveFaceFromArea(face2, face2->frontarea); + if (face2->backarea) AAS_RemoveFaceFromArea(face2, face2->backarea); + AAS_FreeTmpFace(face2); + // + nextface2 = face1->next[side1]; + } //end for + } //end for +} //end of the function AAS_MergePlaneFaces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_CanMergePlaneFaces(tmp_area_t *tmparea, int planenum) +{ + tmp_area_t *frontarea, *backarea; + tmp_face_t *face1; + int side1, merge, faceflags; + + frontarea = backarea = NULL; + merge = false; + for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) + { + side1 = face1->frontarea != tmparea; + if ((face1->planenum & ~1) != (planenum & ~1)) continue; + if (!frontarea && !backarea) + { + frontarea = face1->frontarea; + backarea = face1->backarea; + faceflags = face1->faceflags; + } //end if + else + { + if (frontarea != face1->frontarea) return false; + if (backarea != face1->backarea) return false; + if (faceflags != face1->faceflags) return false; + merge = true; + } //end else + } //end for + return merge; +} //end of the function AAS_CanMergePlaneFaces +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_MergeAreaPlaneFaces(void) +{ + int num_facemerges = 0; + int side1; + tmp_area_t *tmparea, *nexttmparea; + tmp_face_t *face1; + + Log_Write("AAS_MergePlaneFaces\r\n"); + qprintf("%6d plane face merges", num_facemerges); + //NOTE: first convex area is a dummy + for (tmparea = tmpaasworld.areas; tmparea; tmparea = nexttmparea) + { + nexttmparea = tmparea->l_next; + // + if (tmparea->invalid) continue; + // + for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) + { + side1 = face1->frontarea != tmparea; + // + if (AAS_CanMergePlaneFaces(tmparea, face1->planenum)) + { + AAS_MergePlaneFaces(tmparea, face1->planenum); + nexttmparea = tmparea; + num_facemerges++; + qprintf("\r%6d", num_facemerges); + break; + } //end if + } //end for + } //end for + qprintf("\n"); + Log_Write("%6d plane face merges\r\n", num_facemerges); +} //end of the function AAS_MergeAreaPlaneFaces diff --git a/code/bspc/aas_facemerging.h b/code/bspc/aas_facemerging.h new file mode 100644 index 00000000..b2e02e53 --- /dev/null +++ b/code/bspc/aas_facemerging.h @@ -0,0 +1,24 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +void AAS_MergeAreaFaces(void); +void AAS_MergeAreaPlaneFaces(void); diff --git a/code/bspc/aas_file.c b/code/bspc/aas_file.c new file mode 100644 index 00000000..9dc6b12a --- /dev/null +++ b/code/bspc/aas_file.c @@ -0,0 +1,549 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "../botlib/aasfile.h" +#include "aas_file.h" +#include "aas_store.h" +#include "aas_create.h" + +#define AAS_Error Error + +//=========================================================================== +// +// 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].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) +{ + /* + if (aasworld.vertexes) FreeMemory(aasworld.vertexes); + aasworld.vertexes = NULL; + if (aasworld.planes) FreeMemory(aasworld.planes); + aasworld.planes = NULL; + if (aasworld.edges) FreeMemory(aasworld.edges); + aasworld.edges = NULL; + if (aasworld.edgeindex) FreeMemory(aasworld.edgeindex); + aasworld.edgeindex = NULL; + if (aasworld.faces) FreeMemory(aasworld.faces); + aasworld.faces = NULL; + if (aasworld.faceindex) FreeMemory(aasworld.faceindex); + aasworld.faceindex = NULL; + if (aasworld.areas) FreeMemory(aasworld.areas); + aasworld.areas = NULL; + if (aasworld.areasettings) FreeMemory(aasworld.areasettings); + aasworld.areasettings = NULL; + if (aasworld.reachability) FreeMemory(aasworld.reachability); + aasworld.reachability = NULL; + */ + aasworld.loaded = false; +} //end of the function AAS_DumpAASData +//=========================================================================== +// allocate memory and read a lump of a AAS file +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *AAS_LoadAASLump(FILE *fp, int offset, int length, void *buf) +{ + if (!length) + { + printf("lump size 0\n"); + return buf; + } //end if + //seek to the data + if (fseek(fp, offset, SEEK_SET)) + { + AAS_Error("can't seek to lump\n"); + AAS_DumpAASData(); + fclose(fp); + return 0; + } //end if + //allocate memory + if (!buf) buf = (void *) GetClearedMemory(length); + //read the data + if (fread((char *) buf, 1, length, fp) != length) + { + AAS_Error("can't read lump\n"); + FreeMemory(buf); + AAS_DumpAASData(); + fclose(fp); + return NULL; + } //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: - +//=========================================================================== +qboolean AAS_LoadAASFile(char *filename, int fpoffset, int fplength) +{ + FILE *fp; + aas_header_t header; + int offset, length; + + //dump current loaded aas file + AAS_DumpAASData(); + //open the file + fp = fopen(filename, "rb"); + if (!fp) + { + AAS_Error("can't open %s\n", filename); + return false; + } //end if + //seek to the correct position (in the pak file) + if (fseek(fp, fpoffset, SEEK_SET)) + { + AAS_Error("can't seek to file %s\n"); + fclose(fp); + return false; + } //end if + //read the header + if (fread(&header, sizeof(aas_header_t), 1, fp) != 1) + { + AAS_Error("can't read header of file %s\n", filename); + fclose(fp); + return false; + } //end if + //check header identification + header.ident = LittleLong(header.ident); + if (header.ident != AASID) + { + AAS_Error("%s is not an AAS file\n", filename); + fclose(fp); + return false; + } //end if + //check the version + header.version = LittleLong(header.version); + if (header.version != AASVERSION_OLD && header.version != AASVERSION) + { + AAS_Error("%s is version %i, not %i\n", filename, header.version, AASVERSION); + fclose(fp); + return false; + } //end if + // + if (header.version == AASVERSION) + { + AAS_DData((unsigned char *) &header + 8, sizeof(aas_header_t) - 8); + } //end if + aasworld.bspchecksum = LittleLong(header.bspchecksum); + //load the lumps: + //bounding boxes + offset = fpoffset + LittleLong(header.lumps[AASLUMP_BBOXES].fileofs); + length = LittleLong(header.lumps[AASLUMP_BBOXES].filelen); + aasworld.bboxes = (aas_bbox_t *) AAS_LoadAASLump(fp, offset, length, aasworld.bboxes); + if (!aasworld.bboxes) return false; + aasworld.numbboxes = length / sizeof(aas_bbox_t); + //vertexes + offset = fpoffset + LittleLong(header.lumps[AASLUMP_VERTEXES].fileofs); + length = LittleLong(header.lumps[AASLUMP_VERTEXES].filelen); + aasworld.vertexes = (aas_vertex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.vertexes); + if (!aasworld.vertexes) return false; + aasworld.numvertexes = length / sizeof(aas_vertex_t); + //planes + offset = fpoffset + LittleLong(header.lumps[AASLUMP_PLANES].fileofs); + length = LittleLong(header.lumps[AASLUMP_PLANES].filelen); + aasworld.planes = (aas_plane_t *) AAS_LoadAASLump(fp, offset, length, aasworld.planes); + if (!aasworld.planes) return false; + aasworld.numplanes = length / sizeof(aas_plane_t); + //edges + offset = fpoffset + LittleLong(header.lumps[AASLUMP_EDGES].fileofs); + length = LittleLong(header.lumps[AASLUMP_EDGES].filelen); + aasworld.edges = (aas_edge_t *) AAS_LoadAASLump(fp, offset, length, aasworld.edges); + if (!aasworld.edges) return false; + aasworld.numedges = length / sizeof(aas_edge_t); + //edgeindex + offset = fpoffset + LittleLong(header.lumps[AASLUMP_EDGEINDEX].fileofs); + length = LittleLong(header.lumps[AASLUMP_EDGEINDEX].filelen); + aasworld.edgeindex = (aas_edgeindex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.edgeindex); + if (!aasworld.edgeindex) return false; + aasworld.edgeindexsize = length / sizeof(aas_edgeindex_t); + //faces + offset = fpoffset + LittleLong(header.lumps[AASLUMP_FACES].fileofs); + length = LittleLong(header.lumps[AASLUMP_FACES].filelen); + aasworld.faces = (aas_face_t *) AAS_LoadAASLump(fp, offset, length, aasworld.faces); + if (!aasworld.faces) return false; + aasworld.numfaces = length / sizeof(aas_face_t); + //faceindex + offset = fpoffset + LittleLong(header.lumps[AASLUMP_FACEINDEX].fileofs); + length = LittleLong(header.lumps[AASLUMP_FACEINDEX].filelen); + aasworld.faceindex = (aas_faceindex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.faceindex); + if (!aasworld.faceindex) return false; + aasworld.faceindexsize = length / sizeof(int); + //convex areas + offset = fpoffset + LittleLong(header.lumps[AASLUMP_AREAS].fileofs); + length = LittleLong(header.lumps[AASLUMP_AREAS].filelen); + aasworld.areas = (aas_area_t *) AAS_LoadAASLump(fp, offset, length, aasworld.areas); + if (!aasworld.areas) return false; + aasworld.numareas = length / sizeof(aas_area_t); + //area settings + offset = fpoffset + LittleLong(header.lumps[AASLUMP_AREASETTINGS].fileofs); + length = LittleLong(header.lumps[AASLUMP_AREASETTINGS].filelen); + aasworld.areasettings = (aas_areasettings_t *) AAS_LoadAASLump(fp, offset, length, aasworld.areasettings); + if (!aasworld.areasettings) return false; + aasworld.numareasettings = length / sizeof(aas_areasettings_t); + //reachability list + offset = fpoffset + LittleLong(header.lumps[AASLUMP_REACHABILITY].fileofs); + length = LittleLong(header.lumps[AASLUMP_REACHABILITY].filelen); + aasworld.reachability = (aas_reachability_t *) AAS_LoadAASLump(fp, offset, length, aasworld.reachability); + if (length && !aasworld.reachability) return false; + aasworld.reachabilitysize = length / sizeof(aas_reachability_t); + //nodes + offset = fpoffset + LittleLong(header.lumps[AASLUMP_NODES].fileofs); + length = LittleLong(header.lumps[AASLUMP_NODES].filelen); + aasworld.nodes = (aas_node_t *) AAS_LoadAASLump(fp, offset, length, aasworld.nodes); + if (!aasworld.nodes) return false; + aasworld.numnodes = length / sizeof(aas_node_t); + //cluster portals + offset = fpoffset + LittleLong(header.lumps[AASLUMP_PORTALS].fileofs); + length = LittleLong(header.lumps[AASLUMP_PORTALS].filelen); + aasworld.portals = (aas_portal_t *) AAS_LoadAASLump(fp, offset, length, aasworld.portals); + if (length && !aasworld.portals) return false; + aasworld.numportals = length / sizeof(aas_portal_t); + //cluster portal index + offset = fpoffset + LittleLong(header.lumps[AASLUMP_PORTALINDEX].fileofs); + length = LittleLong(header.lumps[AASLUMP_PORTALINDEX].filelen); + aasworld.portalindex = (aas_portalindex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.portalindex); + if (length && !aasworld.portalindex) return false; + aasworld.portalindexsize = length / sizeof(aas_portalindex_t); + //clusters + offset = fpoffset + LittleLong(header.lumps[AASLUMP_CLUSTERS].fileofs); + length = LittleLong(header.lumps[AASLUMP_CLUSTERS].filelen); + aasworld.clusters = (aas_cluster_t *) AAS_LoadAASLump(fp, offset, length, aasworld.clusters); + if (length && !aasworld.clusters) return false; + aasworld.numclusters = length / sizeof(aas_cluster_t); + //swap everything + AAS_SwapAASData(); + //aas file is loaded + aasworld.loaded = true; + //close the file + fclose(fp); + return true; +} //end of the function AAS_LoadAASFile +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_WriteAASLump(FILE *fp, aas_header_t *h, int lumpnum, void *data, int length) +{ + aas_lump_t *lump; + + lump = &h->lumps[lumpnum]; + + lump->fileofs = LittleLong(ftell(fp)); + lump->filelen = LittleLong(length); + + if (length > 0) + { + if (fwrite(data, length, 1, fp) < 1) + { + Log_Print("error writing lump %s\n", lumpnum); + fclose(fp); + return false; + } //end if + } //end if + return true; +} //end of the function AAS_WriteAASLump +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_ShowNumReachabilities(int tt, char *name) +{ + int i, num; + + num = 0; + for (i = 0; i < aasworld.reachabilitysize; i++) + { + if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == tt) + num++; + } //end for + Log_Print("%6d %s\n", num, name); +} //end of the function AAS_ShowNumReachabilities +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_ShowTotals(void) +{ + Log_Print("numvertexes = %d\r\n", aasworld.numvertexes); + Log_Print("numplanes = %d\r\n", aasworld.numplanes); + Log_Print("numedges = %d\r\n", aasworld.numedges); + Log_Print("edgeindexsize = %d\r\n", aasworld.edgeindexsize); + Log_Print("numfaces = %d\r\n", aasworld.numfaces); + Log_Print("faceindexsize = %d\r\n", aasworld.faceindexsize); + Log_Print("numareas = %d\r\n", aasworld.numareas); + Log_Print("numareasettings = %d\r\n", aasworld.numareasettings); + Log_Print("reachabilitysize = %d\r\n", aasworld.reachabilitysize); + Log_Print("numnodes = %d\r\n", aasworld.numnodes); + Log_Print("numportals = %d\r\n", aasworld.numportals); + Log_Print("portalindexsize = %d\r\n", aasworld.portalindexsize); + Log_Print("numclusters = %d\r\n", aasworld.numclusters); + AAS_ShowNumReachabilities(TRAVEL_WALK, "walk"); + AAS_ShowNumReachabilities(TRAVEL_CROUCH, "crouch"); + AAS_ShowNumReachabilities(TRAVEL_BARRIERJUMP, "barrier jump"); + AAS_ShowNumReachabilities(TRAVEL_JUMP, "jump"); + AAS_ShowNumReachabilities(TRAVEL_LADDER, "ladder"); + AAS_ShowNumReachabilities(TRAVEL_WALKOFFLEDGE, "walk off ledge"); + AAS_ShowNumReachabilities(TRAVEL_SWIM, "swim"); + AAS_ShowNumReachabilities(TRAVEL_WATERJUMP, "water jump"); + AAS_ShowNumReachabilities(TRAVEL_TELEPORT, "teleport"); + AAS_ShowNumReachabilities(TRAVEL_ELEVATOR, "elevator"); + AAS_ShowNumReachabilities(TRAVEL_ROCKETJUMP, "rocket jump"); + AAS_ShowNumReachabilities(TRAVEL_BFGJUMP, "bfg jump"); + AAS_ShowNumReachabilities(TRAVEL_GRAPPLEHOOK, "grapple hook"); + AAS_ShowNumReachabilities(TRAVEL_DOUBLEJUMP, "double jump"); + AAS_ShowNumReachabilities(TRAVEL_RAMPJUMP, "ramp jump"); + AAS_ShowNumReachabilities(TRAVEL_STRAFEJUMP, "strafe jump"); + AAS_ShowNumReachabilities(TRAVEL_JUMPPAD, "jump pad"); + AAS_ShowNumReachabilities(TRAVEL_FUNCBOB, "func bob"); +} //end of the function AAS_ShowTotals +//=========================================================================== +// 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; + FILE *fp; + + Log_Print("writing %s\n", filename); + AAS_ShowTotals(); + //swap the aas data + AAS_SwapAASData(); + //initialize the file header + memset(&header, 0, sizeof(aas_header_t)); + header.ident = LittleLong(AASID); + header.version = LittleLong(AASVERSION); + header.bspchecksum = LittleLong(aasworld.bspchecksum); + //open a new file + fp = fopen(filename, "wb"); + if (!fp) + { + Log_Print("error opening %s\n", filename); + return false; + } //end if + //write the header + if (fwrite(&header, sizeof(aas_header_t), 1, fp) < 1) + { + fclose(fp); + return false; + } //end if + //add the data lumps to the file + if (!AAS_WriteAASLump(fp, &header, AASLUMP_BBOXES, aasworld.bboxes, + aasworld.numbboxes * sizeof(aas_bbox_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_VERTEXES, aasworld.vertexes, + aasworld.numvertexes * sizeof(aas_vertex_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_PLANES, aasworld.planes, + aasworld.numplanes * sizeof(aas_plane_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_EDGES, aasworld.edges, + aasworld.numedges * sizeof(aas_edge_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_EDGEINDEX, aasworld.edgeindex, + aasworld.edgeindexsize * sizeof(aas_edgeindex_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_FACES, aasworld.faces, + aasworld.numfaces * sizeof(aas_face_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_FACEINDEX, aasworld.faceindex, + aasworld.faceindexsize * sizeof(aas_faceindex_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_AREAS, aasworld.areas, + aasworld.numareas * sizeof(aas_area_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_AREASETTINGS, aasworld.areasettings, + aasworld.numareasettings * sizeof(aas_areasettings_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_REACHABILITY, aasworld.reachability, + aasworld.reachabilitysize * sizeof(aas_reachability_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_NODES, aasworld.nodes, + aasworld.numnodes * sizeof(aas_node_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_PORTALS, aasworld.portals, + aasworld.numportals * sizeof(aas_portal_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_PORTALINDEX, aasworld.portalindex, + aasworld.portalindexsize * sizeof(aas_portalindex_t))) return false; + if (!AAS_WriteAASLump(fp, &header, AASLUMP_CLUSTERS, aasworld.clusters, + aasworld.numclusters * sizeof(aas_cluster_t))) return false; + //rewrite the header with the added lumps + fseek(fp, 0, SEEK_SET); + AAS_DData((unsigned char *) &header + 8, sizeof(aas_header_t) - 8); + if (fwrite(&header, sizeof(aas_header_t), 1, fp) < 1) + { + fclose(fp); + return false; + } //end if + //close the file + fclose(fp); + return true; +} //end of the function AAS_WriteAASFile + diff --git a/code/bspc/aas_file.h b/code/bspc/aas_file.h new file mode 100644 index 00000000..d3e15c27 --- /dev/null +++ b/code/bspc/aas_file.h @@ -0,0 +1,25 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +qboolean AAS_WriteAASFile(char *filename); +qboolean AAS_LoadAASFile(char *filename, int fpoffset, int fplength); + diff --git a/code/bspc/aas_gsubdiv.c b/code/bspc/aas_gsubdiv.c new file mode 100644 index 00000000..4cfb1941 --- /dev/null +++ b/code/bspc/aas_gsubdiv.c @@ -0,0 +1,656 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "../botlib/aasfile.h" +#include "aas_create.h" +#include "aas_store.h" +#include "aas_cfg.h" + +#define FACECLIP_EPSILON 0.2 +#define FACE_EPSILON 1.0 + +int numgravitationalsubdivisions = 0; +int numladdersubdivisions = 0; + +//NOTE: only do gravitational subdivision BEFORE area merging!!!!!!! +// because the bsp tree isn't refreshes like with ladder subdivision + +//=========================================================================== +// NOTE: the original face is invalid after splitting +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_SplitFace(tmp_face_t *face, vec3_t normal, float dist, + tmp_face_t **frontface, tmp_face_t **backface) +{ + winding_t *frontw, *backw; + + // + *frontface = *backface = NULL; + + ClipWindingEpsilon(face->winding, normal, dist, FACECLIP_EPSILON, &frontw, &backw); + +#ifdef DEBUG + // + if (frontw) + { + if (WindingIsTiny(frontw)) + { + Log_Write("AAS_SplitFace: tiny back face\r\n"); + FreeWinding(frontw); + frontw = NULL; + } //end if + } //end if + if (backw) + { + if (WindingIsTiny(backw)) + { + Log_Write("AAS_SplitFace: tiny back face\r\n"); + FreeWinding(backw); + backw = NULL; + } //end if + } //end if +#endif //DEBUG + //if the winding was split + if (frontw) + { + //check bounds + (*frontface) = AAS_AllocTmpFace(); + (*frontface)->planenum = face->planenum; + (*frontface)->winding = frontw; + (*frontface)->faceflags = face->faceflags; + } //end if + if (backw) + { + //check bounds + (*backface) = AAS_AllocTmpFace(); + (*backface)->planenum = face->planenum; + (*backface)->winding = backw; + (*backface)->faceflags = face->faceflags; + } //end if +} //end of the function AAS_SplitFace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +winding_t *AAS_SplitWinding(tmp_area_t *tmparea, int planenum) +{ + tmp_face_t *face; + plane_t *plane; + int side; + winding_t *splitwinding; + + // + plane = &mapplanes[planenum]; + //create a split winding, first base winding for plane + splitwinding = BaseWindingForPlane(plane->normal, plane->dist); + //chop with all the faces of the area + for (face = tmparea->tmpfaces; face && splitwinding; face = face->next[side]) + { + //side of the face the original area was on + side = face->frontarea != tmparea; + plane = &mapplanes[face->planenum ^ side]; + ChopWindingInPlace(&splitwinding, plane->normal, plane->dist, 0); // PLANESIDE_EPSILON); + } //end for + return splitwinding; +} //end of the function AAS_SplitWinding +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_TestSplitPlane(tmp_area_t *tmparea, vec3_t normal, float dist, + int *facesplits, int *groundsplits, int *epsilonfaces) +{ + int j, side, front, back, planenum; + float d, d_front, d_back; + tmp_face_t *face; + winding_t *w; + + *facesplits = *groundsplits = *epsilonfaces = 0; + + planenum = FindFloatPlane(normal, dist); + + w = AAS_SplitWinding(tmparea, planenum); + if (!w) return false; + FreeWinding(w); + // + for (face = tmparea->tmpfaces; face; face = face->next[side]) + { + //side of the face the area is on + side = face->frontarea != tmparea; + + if ((face->planenum & ~1) == (planenum & ~1)) + { + Log_Print("AAS_TestSplitPlane: tried face plane as splitter\n"); + return false; + } //end if + w = face->winding; + //reset distance at front and back side of plane + d_front = d_back = 0; + //reset front and back flags + front = back = 0; + for (j = 0; j < w->numpoints; j++) + { + d = DotProduct(w->p[j], normal) - dist; + if (d > d_front) d_front = d; + if (d < d_back) d_back = d; + + if (d > 0.4) // PLANESIDE_EPSILON) + front = 1; + if (d < -0.4) // PLANESIDE_EPSILON) + back = 1; + } //end for + //check for an epsilon face + if ( (d_front > FACECLIP_EPSILON && d_front < FACE_EPSILON) + || (d_back < -FACECLIP_EPSILON && d_back > -FACE_EPSILON) ) + { + (*epsilonfaces)++; + } //end if + //if the face has points at both sides of the plane + if (front && back) + { + (*facesplits)++; + if (face->faceflags & FACE_GROUND) + { + (*groundsplits)++; + } //end if + } //end if + } //end for + return true; +} //end of the function AAS_TestSplitPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_SplitArea(tmp_area_t *tmparea, int planenum, tmp_area_t **frontarea, tmp_area_t **backarea) +{ + int side; + tmp_area_t *facefrontarea, *facebackarea, *faceotherarea; + tmp_face_t *face, *frontface, *backface, *splitface, *nextface; + winding_t *splitwinding; + plane_t *splitplane; + +/* +#ifdef AW_DEBUG + int facesplits, groundsplits, epsilonface; + Log_Print("\n----------------------\n"); + Log_Print("splitting area %d\n", areanum); + Log_Print("with normal = \'%f %f %f\', dist = %f\n", normal[0], normal[1], normal[2], dist); + AAS_TestSplitPlane(areanum, normal, dist, + &facesplits, &groundsplits, &epsilonface); + Log_Print("face splits = %d\nground splits = %d\n", facesplits, groundsplits); + if (epsilonface) Log_Print("aaahh epsilon face\n"); +#endif //AW_DEBUG*/ + //the original area + + AAS_FlipAreaFaces(tmparea); + AAS_CheckArea(tmparea); + // + splitplane = &mapplanes[planenum]; +/* //create a split winding, first base winding for plane + splitwinding = BaseWindingForPlane(splitplane->normal, splitplane->dist); + //chop with all the faces of the area + for (face = tmparea->tmpfaces; face && splitwinding; face = face->next[side]) + { + //side of the face the original area was on + side = face->frontarea != tmparea->areanum; + plane = &mapplanes[face->planenum ^ side]; + ChopWindingInPlace(&splitwinding, plane->normal, plane->dist, 0); // PLANESIDE_EPSILON); + } //end for*/ + splitwinding = AAS_SplitWinding(tmparea, planenum); + if (!splitwinding) + { +/* +#ifdef DEBUG + AAS_TestSplitPlane(areanum, normal, dist, + &facesplits, &groundsplits, &epsilonface); + Log_Print("\nface splits = %d\nground splits = %d\n", facesplits, groundsplits); + if (epsilonface) Log_Print("aaahh epsilon face\n"); +#endif //DEBUG*/ + Error("AAS_SplitArea: no split winding when splitting area %d\n", tmparea->areanum); + } //end if + //create a split face + splitface = AAS_AllocTmpFace(); + //get the map plane + splitface->planenum = planenum; + //store the split winding + splitface->winding = splitwinding; + //the new front area + (*frontarea) = AAS_AllocTmpArea(); + (*frontarea)->presencetype = tmparea->presencetype; + (*frontarea)->contents = tmparea->contents; + (*frontarea)->modelnum = tmparea->modelnum; + (*frontarea)->tmpfaces = NULL; + //the new back area + (*backarea) = AAS_AllocTmpArea(); + (*backarea)->presencetype = tmparea->presencetype; + (*backarea)->contents = tmparea->contents; + (*backarea)->modelnum = tmparea->modelnum; + (*backarea)->tmpfaces = NULL; + //add the split face to the new areas + AAS_AddFaceSideToArea(splitface, 0, (*frontarea)); + AAS_AddFaceSideToArea(splitface, 1, (*backarea)); + + //split all the faces of the original area + for (face = tmparea->tmpfaces; face; face = nextface) + { + //side of the face the original area was on + side = face->frontarea != tmparea; + //next face of the original area + nextface = face->next[side]; + //front area of the face + facefrontarea = face->frontarea; + //back area of the face + facebackarea = face->backarea; + //remove the face from both the front and back areas + if (facefrontarea) AAS_RemoveFaceFromArea(face, facefrontarea); + if (facebackarea) AAS_RemoveFaceFromArea(face, facebackarea); + //split the face + AAS_SplitFace(face, splitplane->normal, splitplane->dist, &frontface, &backface); + //free the original face + AAS_FreeTmpFace(face); + //get the number of the area at the other side of the face + if (side) faceotherarea = facefrontarea; + else faceotherarea = facebackarea; + //if there is an area at the other side of the original face + if (faceotherarea) + { + if (frontface) AAS_AddFaceSideToArea(frontface, !side, faceotherarea); + if (backface) AAS_AddFaceSideToArea(backface, !side, faceotherarea); + } //end if + //add the front and back part left after splitting the original face to the new areas + if (frontface) AAS_AddFaceSideToArea(frontface, side, (*frontarea)); + if (backface) AAS_AddFaceSideToArea(backface, side, (*backarea)); + } //end for + + if (!(*frontarea)->tmpfaces) Log_Print("AAS_SplitArea: front area without faces\n"); + if (!(*backarea)->tmpfaces) Log_Print("AAS_SplitArea: back area without faces\n"); + + tmparea->invalid = true; +/* +#ifdef AW_DEBUG + for (i = 0, face = frontarea->tmpfaces; face; face = face->next[side]) + { + side = face->frontarea != frontarea->areanum; + i++; + } //end for + Log_Print("created front area %d with %d faces\n", frontarea->areanum, i); + + for (i = 0, face = backarea->tmpfaces; face; face = face->next[side]) + { + side = face->frontarea != backarea->areanum; + i++; + } //end for + Log_Print("created back area %d with %d faces\n", backarea->areanum, i); +#endif //AW_DEBUG*/ + + AAS_FlipAreaFaces((*frontarea)); + AAS_FlipAreaFaces((*backarea)); + // + AAS_CheckArea((*frontarea)); + AAS_CheckArea((*backarea)); +} //end of the function AAS_SplitArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_FindBestAreaSplitPlane(tmp_area_t *tmparea, vec3_t normal, float *dist) +{ + int side1, side2; + int foundsplitter, facesplits, groundsplits, epsilonfaces, bestepsilonfaces; + float bestvalue, value; + tmp_face_t *face1, *face2; + vec3_t tmpnormal, invgravity; + float tmpdist; + + //get inverse of gravity direction + VectorCopy(cfg.phys_gravitydirection, invgravity); + VectorInverse(invgravity); + + foundsplitter = false; + bestvalue = -999999; + bestepsilonfaces = 0; + // +#ifdef AW_DEBUG + Log_Print("finding split plane for area %d\n", tmparea->areanum); +#endif //AW_DEBUG + for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) + { + //side of the face the area is on + side1 = face1->frontarea != tmparea; + // + if (WindingIsTiny(face1->winding)) + { + Log_Write("gsubdiv: area %d has a tiny winding\r\n", tmparea->areanum); + continue; + } //end if + //if the face isn't a gap or ground there's no split edge + if (!(face1->faceflags & FACE_GROUND) && !AAS_GapFace(face1, side1)) continue; + // + for (face2 = face1->next[side1]; face2; face2 = face2->next[side2]) + { + //side of the face the area is on + side2 = face2->frontarea != tmparea; + // + if (WindingIsTiny(face1->winding)) + { + Log_Write("gsubdiv: area %d has a tiny winding\r\n", tmparea->areanum); + continue; + } //end if + //if the face isn't a gap or ground there's no split edge + if (!(face2->faceflags & FACE_GROUND) && !AAS_GapFace(face2, side2)) continue; + //only split between gaps and ground + if (!(((face1->faceflags & FACE_GROUND) && AAS_GapFace(face2, side2)) || + ((face2->faceflags & FACE_GROUND) && AAS_GapFace(face1, side1)))) continue; + //find a plane seperating the windings of the faces + if (!FindPlaneSeperatingWindings(face1->winding, face2->winding, invgravity, + tmpnormal, &tmpdist)) continue; +#ifdef AW_DEBUG + Log_Print("normal = \'%f %f %f\', dist = %f\n", + tmpnormal[0], tmpnormal[1], tmpnormal[2], tmpdist); +#endif //AW_DEBUG + //get metrics for this vertical plane + if (!AAS_TestSplitPlane(tmparea, tmpnormal, tmpdist, + &facesplits, &groundsplits, &epsilonfaces)) + { + continue; + } //end if +#ifdef AW_DEBUG + Log_Print("face splits = %d\nground splits = %d\n", + facesplits, groundsplits); +#endif //AW_DEBUG + value = 100 - facesplits - 2 * groundsplits; + //avoid epsilon faces + value += epsilonfaces * -1000; + if (value > bestvalue) + { + VectorCopy(tmpnormal, normal); + *dist = tmpdist; + bestvalue = value; + bestepsilonfaces = epsilonfaces; + foundsplitter = true; + } //end if + } //end for + } //end for + if (bestepsilonfaces) + { + Log_Write("found %d epsilon faces trying to split area %d\r\n", + epsilonfaces, tmparea->areanum); + } //end else + return foundsplitter; +} //end of the function AAS_FindBestAreaSplitPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_node_t *AAS_SubdivideArea_r(tmp_node_t *tmpnode) +{ + int planenum; + tmp_area_t *frontarea, *backarea; + tmp_node_t *tmpnode1, *tmpnode2; + vec3_t normal; + float dist; + + if (AAS_FindBestAreaSplitPlane(tmpnode->tmparea, normal, &dist)) + { + qprintf("\r%6d", ++numgravitationalsubdivisions); + // + planenum = FindFloatPlane(normal, dist); + //split the area + AAS_SplitArea(tmpnode->tmparea, planenum, &frontarea, &backarea); + // + tmpnode->tmparea = NULL; + tmpnode->planenum = FindFloatPlane(normal, dist); + // + tmpnode1 = AAS_AllocTmpNode(); + tmpnode1->planenum = 0; + tmpnode1->tmparea = frontarea; + // + tmpnode2 = AAS_AllocTmpNode(); + tmpnode2->planenum = 0; + tmpnode2->tmparea = backarea; + //subdivide the areas created by splitting recursively + tmpnode->children[0] = AAS_SubdivideArea_r(tmpnode1); + tmpnode->children[1] = AAS_SubdivideArea_r(tmpnode2); + } //end if + return tmpnode; +} //end of the function AAS_SubdivideArea_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_node_t *AAS_GravitationalSubdivision_r(tmp_node_t *tmpnode) +{ + //if this is a solid leaf + if (!tmpnode) return NULL; + //negative so it's an area + if (tmpnode->tmparea) return AAS_SubdivideArea_r(tmpnode); + //do the children recursively + tmpnode->children[0] = AAS_GravitationalSubdivision_r(tmpnode->children[0]); + tmpnode->children[1] = AAS_GravitationalSubdivision_r(tmpnode->children[1]); + return tmpnode; +} //end of the function AAS_GravitationalSubdivision_r +//=========================================================================== +// NOTE: merge faces and melt edges first +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_GravitationalSubdivision(void) +{ + Log_Write("AAS_GravitationalSubdivision\r\n"); + numgravitationalsubdivisions = 0; + qprintf("%6i gravitational subdivisions", numgravitationalsubdivisions); + //start with the head node + AAS_GravitationalSubdivision_r(tmpaasworld.nodes); + qprintf("\n"); + Log_Write("%6i gravitational subdivisions\r\n", numgravitationalsubdivisions); +} //end of the function AAS_GravitationalSubdivision +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_node_t *AAS_RefreshLadderSubdividedTree_r(tmp_node_t *tmpnode, tmp_area_t *tmparea, + tmp_node_t *tmpnode1, tmp_node_t *tmpnode2, int planenum) +{ + //if this is a solid leaf + if (!tmpnode) return NULL; + //negative so it's an area + if (tmpnode->tmparea) + { + if (tmpnode->tmparea == tmparea) + { + tmpnode->tmparea = NULL; + tmpnode->planenum = planenum; + tmpnode->children[0] = tmpnode1; + tmpnode->children[1] = tmpnode2; + } //end if + return tmpnode; + } //end if + //do the children recursively + tmpnode->children[0] = AAS_RefreshLadderSubdividedTree_r(tmpnode->children[0], + tmparea, tmpnode1, tmpnode2, planenum); + tmpnode->children[1] = AAS_RefreshLadderSubdividedTree_r(tmpnode->children[1], + tmparea, tmpnode1, tmpnode2, planenum); + return tmpnode; +} //end of the function AAS_RefreshLadderSubdividedTree_r +//=========================================================================== +// find an area with ladder faces and ground faces that are not connected +// split the area with a horizontal plane at the lowest vertex of all +// ladder faces in the area +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_node_t *AAS_LadderSubdivideArea_r(tmp_node_t *tmpnode) +{ + int side1, i, planenum; + int foundladderface, foundgroundface; + float dist; + tmp_area_t *tmparea, *frontarea, *backarea; + tmp_face_t *face1; + tmp_node_t *tmpnode1, *tmpnode2; + vec3_t lowestpoint, normal = {0, 0, 1}; + plane_t *plane; + winding_t *w; + + tmparea = tmpnode->tmparea; + //skip areas with a liquid + if (tmparea->contents & (AREACONTENTS_WATER + | AREACONTENTS_LAVA + | AREACONTENTS_SLIME)) return tmpnode; + //must be possible to stand in the area + if (!(tmparea->presencetype & PRESENCE_NORMAL)) return tmpnode; + // + foundladderface = false; + foundgroundface = false; + lowestpoint[2] = 99999; + // + for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) + { + //side of the face the area is on + side1 = face1->frontarea != tmparea; + //if the face is a ladder face + if (face1->faceflags & FACE_LADDER) + { + plane = &mapplanes[face1->planenum]; + //the ladder face plane should be pretty much vertical + if (DotProduct(plane->normal, normal) > -0.1) + { + foundladderface = true; + //find lowest point + for (i = 0; i < face1->winding->numpoints; i++) + { + if (face1->winding->p[i][2] < lowestpoint[2]) + { + VectorCopy(face1->winding->p[i], lowestpoint); + } //end if + } //end for + } //end if + } //end if + else if (face1->faceflags & FACE_GROUND) + { + foundgroundface = true; + } //end else if + } //end for + // + if ((!foundladderface) || (!foundgroundface)) return tmpnode; + // + for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) + { + //side of the face the area is on + side1 = face1->frontarea != tmparea; + //if the face isn't a ground face + if (!(face1->faceflags & FACE_GROUND)) continue; + //the ground plane + plane = &mapplanes[face1->planenum]; + //get the difference between the ground plane and the lowest point + dist = DotProduct(plane->normal, lowestpoint) - plane->dist; + //if the lowest point is very near one of the ground planes + if (dist > -1 && dist < 1) + { + return tmpnode; + } //end if + } //end for + // + dist = DotProduct(normal, lowestpoint); + planenum = FindFloatPlane(normal, dist); + // + w = AAS_SplitWinding(tmparea, planenum); + if (!w) return tmpnode; + FreeWinding(w); + //split the area with a horizontal plane through the lowest point + qprintf("\r%6d", ++numladdersubdivisions); + // + AAS_SplitArea(tmparea, planenum, &frontarea, &backarea); + // + tmpnode->tmparea = NULL; + tmpnode->planenum = planenum; + // + tmpnode1 = AAS_AllocTmpNode(); + tmpnode1->planenum = 0; + tmpnode1->tmparea = frontarea; + // + tmpnode2 = AAS_AllocTmpNode(); + tmpnode2->planenum = 0; + tmpnode2->tmparea = backarea; + //subdivide the areas created by splitting recursively + tmpnode->children[0] = AAS_LadderSubdivideArea_r(tmpnode1); + tmpnode->children[1] = AAS_LadderSubdivideArea_r(tmpnode2); + //refresh the tree + AAS_RefreshLadderSubdividedTree_r(tmpaasworld.nodes, tmparea, tmpnode1, tmpnode2, planenum); + // + return tmpnode; +} //end of the function AAS_LadderSubdivideArea_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_node_t *AAS_LadderSubdivision_r(tmp_node_t *tmpnode) +{ + //if this is a solid leaf + if (!tmpnode) return 0; + //negative so it's an area + if (tmpnode->tmparea) return AAS_LadderSubdivideArea_r(tmpnode); + //do the children recursively + tmpnode->children[0] = AAS_LadderSubdivision_r(tmpnode->children[0]); + tmpnode->children[1] = AAS_LadderSubdivision_r(tmpnode->children[1]); + return tmpnode; +} //end of the function AAS_LadderSubdivision_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_LadderSubdivision(void) +{ + Log_Write("AAS_LadderSubdivision\r\n"); + numladdersubdivisions = 0; + qprintf("%6i ladder subdivisions", numladdersubdivisions); + //start with the head node + AAS_LadderSubdivision_r(tmpaasworld.nodes); + // + qprintf("\n"); + Log_Write("%6i ladder subdivisions\r\n", numladdersubdivisions); +} //end of the function AAS_LadderSubdivision diff --git a/code/bspc/aas_gsubdiv.h b/code/bspc/aas_gsubdiv.h new file mode 100644 index 00000000..bb2b0950 --- /dev/null +++ b/code/bspc/aas_gsubdiv.h @@ -0,0 +1,25 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +//works with the global tmpaasworld +void AAS_GravitationalSubdivision(void); +void AAS_LadderSubdivision(void); diff --git a/code/bspc/aas_map.c b/code/bspc/aas_map.c new file mode 100644 index 00000000..a5e69040 --- /dev/null +++ b/code/bspc/aas_map.c @@ -0,0 +1,893 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "l_mem.h" +#include "../botlib/aasfile.h" //aas_bbox_t +#include "aas_store.h" //AAS_MAX_BBOXES +#include "aas_cfg.h" +#include "../qcommon/surfaceflags.h" + +#define SPAWNFLAG_NOT_EASY 0x00000100 +#define SPAWNFLAG_NOT_MEDIUM 0x00000200 +#define SPAWNFLAG_NOT_HARD 0x00000400 +#define SPAWNFLAG_NOT_DEATHMATCH 0x00000800 +#define SPAWNFLAG_NOT_COOP 0x00001000 + +#define STATE_TOP 0 +#define STATE_BOTTOM 1 +#define STATE_UP 2 +#define STATE_DOWN 3 + +#define DOOR_START_OPEN 1 +#define DOOR_REVERSE 2 +#define DOOR_CRUSHER 4 +#define DOOR_NOMONSTER 8 +#define DOOR_TOGGLE 32 +#define DOOR_X_AXIS 64 +#define DOOR_Y_AXIS 128 + +#define BBOX_NORMAL_EPSILON 0.0001 + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +vec_t BoxOriginDistanceFromPlane(vec3_t normal, vec3_t mins, vec3_t maxs, int side) +{ + vec3_t v1, v2; + int i; + + if (side) + { + for (i = 0; i < 3; i++) + { + if (normal[i] > BBOX_NORMAL_EPSILON) v1[i] = maxs[i]; + else if (normal[i] < -BBOX_NORMAL_EPSILON) v1[i] = mins[i]; + else v1[i] = 0; + } //end for + } //end if + else + { + for (i = 0; i < 3; i++) + { + if (normal[i] > BBOX_NORMAL_EPSILON) v1[i] = mins[i]; + else if (normal[i] < -BBOX_NORMAL_EPSILON) v1[i] = maxs[i]; + else v1[i] = 0; + } //end for + } //end else + VectorCopy(normal, v2); + VectorInverse(v2); + return DotProduct(v1, v2); +} //end of the function BoxOriginDistanceFromPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +vec_t CapsuleOriginDistanceFromPlane(vec3_t normal, vec3_t mins, vec3_t maxs) +{ + float offset_up, offset_down, width, radius; + + width = maxs[0] - mins[0]; + // if the box is less high then it is wide + if (maxs[2] - mins[2] < width) { + width = maxs[2] - mins[2]; + } + radius = width * 0.5; + // offset to upper and lower sphere + offset_up = maxs[2] - radius; + offset_down = -mins[2] - radius; + + // if normal points upward + if ( normal[2] > 0 ) { + // touches lower sphere first + return normal[2] * offset_down + radius; + } + else { + // touched upper sphere first + return -normal[2] * offset_up + radius; + } +} +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_ExpandMapBrush(mapbrush_t *brush, vec3_t mins, vec3_t maxs) +{ + int sn; + float dist; + side_t *s; + plane_t *plane; + + for (sn = 0; sn < brush->numsides; sn++) + { + s = brush->original_sides + sn; + plane = &mapplanes[s->planenum]; + dist = plane->dist; + if (capsule_collision) { + dist += CapsuleOriginDistanceFromPlane(plane->normal, mins, maxs); + } + else { + dist += BoxOriginDistanceFromPlane(plane->normal, mins, maxs, 0); + } + s->planenum = FindFloatPlane(plane->normal, dist); + //the side isn't a bevel after expanding + s->flags &= ~SFL_BEVEL; + //don't skip the surface +#ifdef SURF_SKIP + s->surf &= ~SURF_SKIP; +#endif + //make sure the texinfo is not TEXINFO_NODE + //when player clip contents brushes are read from the bsp tree + //they have the texinfo field set to TEXINFO_NODE + //s->texinfo = 0; + } //end for +} //end of the function AAS_ExpandMapBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_SetTexinfo(mapbrush_t *brush) +{ + int n; + side_t *side; + + if (brush->contents & ( +#ifdef CONTENTS_LADDER + CONTENTS_LADDER + | +#endif + CONTENTS_AREAPORTAL +#ifdef CONTENTS_CLUSTERPORTAL + | CONTENTS_CLUSTERPORTAL +#endif // CONTENTS_CLUSTERPORTAL +#ifdef CONTENTS_TELEPORTER + | CONTENTS_TELEPORTER +#endif // CONTENTS_TELEPORTER +#ifdef CONTENTS_JUMPPAD + | CONTENTS_JUMPPAD +#endif // CONTENTS_JUMPPAD + | CONTENTS_DONOTENTER + | CONTENTS_WATER + | CONTENTS_LAVA + | CONTENTS_SLIME +#ifdef CONTENTS_WINDOW + | CONTENTS_WINDOW +#endif + | CONTENTS_PLAYERCLIP)) + { + //we just set texinfo to 0 because these brush sides MUST be used as + //bsp splitters textured or not textured + for (n = 0; n < brush->numsides; n++) + { + side = brush->original_sides + n; + //side->flags |= SFL_TEXTURED|SFL_VISIBLE; + side->texinfo = 0; + } //end for + } //end if + else + { + //only use brush sides as splitters if they are textured + //texinfo of non-textured sides will be set to TEXINFO_NODE + for (n = 0; n < brush->numsides; n++) + { + side = brush->original_sides + n; + //don't use side as splitter (set texinfo to TEXINFO_NODE) if not textured + if (side->flags & (SFL_TEXTURED|SFL_BEVEL)) side->texinfo = 0; + else side->texinfo = TEXINFO_NODE; + } //end for + } //end else +} //end of the function AAS_SetTexinfo +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeBrushWindings(mapbrush_t *brush) +{ + int n; + side_t *side; + // + for (n = 0; n < brush->numsides; n++) + { + side = brush->original_sides + n; + // + if (side->winding) FreeWinding(side->winding); + } //end for +} //end of the function FreeBrushWindings +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_AddMapBrushSide(mapbrush_t *brush, int planenum) +{ + side_t *side; + // + if (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES) + Error ("MAX_MAPFILE_BRUSHSIDES"); + // + side = brush->original_sides + brush->numsides; + side->original = NULL; + side->winding = NULL; + side->contents = brush->contents; + side->flags &= ~(SFL_BEVEL|SFL_VISIBLE); + side->surf = 0; + side->planenum = planenum; + side->texinfo = 0; + // + nummapbrushsides++; + brush->numsides++; +} //end of the function AAS_AddMapBrushSide +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FixMapBrush(mapbrush_t *brush) +{ + int i, j, planenum; + float dist; + winding_t *w; + plane_t *plane, *plane1, *plane2; + side_t *side; + vec3_t normal; + + //calculate the brush bounds + ClearBounds(brush->mins, brush->maxs); + for (i = 0; i < brush->numsides; i++) + { + plane = &mapplanes[brush->original_sides[i].planenum]; + w = BaseWindingForPlane(plane->normal, plane->dist); + for (j = 0; j < brush->numsides && w; j++) + { + if (i == j) continue; + //there are no brush bevels marked but who cares :) + if (brush->original_sides[j].flags & SFL_BEVEL) continue; + plane = &mapplanes[brush->original_sides[j].planenum^1]; + ChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON); + } //end for + + side = &brush->original_sides[i]; + side->winding = w; + if (w) + { + for (j = 0; j < w->numpoints; j++) + { + AddPointToBounds(w->p[j], brush->mins, brush->maxs); + } //end for + } //end if + } //end for + // + for (i = 0; i < brush->numsides; i++) + { + for (j = 0; j < brush->numsides; j++) + { + if (i == j) continue; + plane1 = &mapplanes[brush->original_sides[i].planenum]; + plane2 = &mapplanes[brush->original_sides[j].planenum]; + if (WindingsNonConvex(brush->original_sides[i].winding, + brush->original_sides[j].winding, + plane1->normal, plane2->normal, + plane1->dist, plane2->dist)) + { + Log_Print("non convex brush"); + } //end if + } //end for + } //end for + + //NOW close the fucking brush!! + for (i = 0; i < 3; i++) + { + if (brush->mins[i] < -MAX_MAP_BOUNDS) + { + VectorClear(normal); + normal[i] = -1; + dist = MAX_MAP_BOUNDS - 10; + planenum = FindFloatPlane(normal, dist); + // + Log_Print("mins out of range: added extra brush side\n"); + AAS_AddMapBrushSide(brush, planenum); + } //end if + if (brush->maxs[i] > MAX_MAP_BOUNDS) + { + VectorClear(normal); + normal[i] = 1; + dist = MAX_MAP_BOUNDS - 10; + planenum = FindFloatPlane(normal, dist); + // + Log_Print("maxs out of range: added extra brush side\n"); + AAS_AddMapBrushSide(brush, planenum); + } //end if + if (brush->mins[i] > MAX_MAP_BOUNDS || brush->maxs[i] < -MAX_MAP_BOUNDS) + { + Log_Print("entity %i, brush %i: no visible sides on brush\n", brush->entitynum, brush->brushnum); + } //end if + } //end for + //free all the windings + FreeBrushWindings(brush); +} //end of the function AAS_FixMapBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean AAS_MakeBrushWindings(mapbrush_t *ob) +{ + int i, j; + winding_t *w; + side_t *side; + plane_t *plane, *plane1, *plane2; + + ClearBounds (ob->mins, ob->maxs); + + for (i = 0; i < ob->numsides; i++) + { + plane = &mapplanes[ob->original_sides[i].planenum]; + w = BaseWindingForPlane(plane->normal, plane->dist); + for (j = 0; j numsides && w; j++) + { + if (i == j) continue; + if (ob->original_sides[j].flags & SFL_BEVEL) continue; + plane = &mapplanes[ob->original_sides[j].planenum^1]; + ChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON); + } + + side = &ob->original_sides[i]; + side->winding = w; + if (w) + { + side->flags |= SFL_VISIBLE; + for (j = 0; j < w->numpoints; j++) + AddPointToBounds (w->p[j], ob->mins, ob->maxs); + } + } + //check if the brush is convex + for (i = 0; i < ob->numsides; i++) + { + for (j = 0; j < ob->numsides; j++) + { + if (i == j) continue; + plane1 = &mapplanes[ob->original_sides[i].planenum]; + plane2 = &mapplanes[ob->original_sides[j].planenum]; + if (WindingsNonConvex(ob->original_sides[i].winding, + ob->original_sides[j].winding, + plane1->normal, plane2->normal, + plane1->dist, plane2->dist)) + { + Log_Print("non convex brush"); + } //end if + } //end for + } //end for + //check for out of bound brushes + for (i = 0; i < 3; i++) + { + //IDBUG: all the indexes into the mins and maxs were zero (not using i) + if (ob->mins[i] < -MAX_MAP_BOUNDS || ob->maxs[i] > MAX_MAP_BOUNDS) + { + Log_Print("entity %i, brush %i: bounds out of range\n", ob->entitynum, ob->brushnum); + Log_Print("ob->mins[%d] = %f, ob->maxs[%d] = %f\n", i, ob->mins[i], i, ob->maxs[i]); + ob->numsides = 0; //remove the brush + break; + } //end if + if (ob->mins[i] > MAX_MAP_BOUNDS || ob->maxs[i] < -MAX_MAP_BOUNDS) + { + Log_Print("entity %i, brush %i: no visible sides on brush\n", ob->entitynum, ob->brushnum); + Log_Print("ob->mins[%d] = %f, ob->maxs[%d] = %f\n", i, ob->mins[i], i, ob->maxs[i]); + ob->numsides = 0; //remove the brush + break; + } //end if + } //end for + return true; +} //end of the function AAS_MakeBrushWindings +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +mapbrush_t *AAS_CopyMapBrush(mapbrush_t *brush, entity_t *mapent) +{ + int n; + mapbrush_t *newbrush; + side_t *side, *newside; + + if (nummapbrushes >= MAX_MAPFILE_BRUSHES) + Error ("MAX_MAPFILE_BRUSHES"); + + newbrush = &mapbrushes[nummapbrushes]; + newbrush->original_sides = &brushsides[nummapbrushsides]; + newbrush->entitynum = brush->entitynum; + newbrush->brushnum = nummapbrushes - mapent->firstbrush; + newbrush->numsides = brush->numsides; + newbrush->contents = brush->contents; + + //copy the sides + for (n = 0; n < brush->numsides; n++) + { + if (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES) + Error ("MAX_MAPFILE_BRUSHSIDES"); + side = brush->original_sides + n; + + newside = newbrush->original_sides + n; + newside->original = NULL; + newside->winding = NULL; + newside->contents = side->contents; + newside->flags = side->flags; + newside->surf = side->surf; + newside->planenum = side->planenum; + newside->texinfo = side->texinfo; + nummapbrushsides++; + } //end for + // + nummapbrushes++; + mapent->numbrushes++; + return newbrush; +} //end of the function AAS_CopyMapBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int mark_entities[MAX_MAP_ENTITIES]; + +int AAS_AlwaysTriggered_r(char *targetname) +{ + int i; + + if (!strlen(targetname)) { + return false; + } + // + for (i = 0; i < num_entities; i++) { + // if the entity will activate the given targetname + if ( !strcmp(targetname, ValueForKey(&entities[i], "target")) ) { + // if this activator is present in deathmatch + if (!(atoi(ValueForKey(&entities[i], "spawnflags")) & SPAWNFLAG_NOT_DEATHMATCH)) { + // if it is a trigger_always entity + if (!strcmp("trigger_always", ValueForKey(&entities[i], "classname"))) { + return true; + } + // check for possible trigger_always entities activating this entity + if ( mark_entities[i] ) { + Warning( "entity %d, classname %s has recursive targetname %s\n", i, + ValueForKey(&entities[i], "classname"), targetname ); + return false; + } + mark_entities[i] = true; + if ( AAS_AlwaysTriggered_r(ValueForKey(&entities[i], "targetname")) ) { + return true; + } + } + } + } + return false; +} + +int AAS_AlwaysTriggered(char *targetname) { + memset( mark_entities, 0, sizeof(mark_entities) ); + return AAS_AlwaysTriggered_r( targetname ); +} +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_ValidEntity(entity_t *mapent) +{ + int i; + char target[1024]; + + //all world brushes are used for AAS + if (mapent == &entities[0]) + { + return true; + } //end if + //some of the func_wall brushes are also used for AAS + else if (!strcmp("func_wall", ValueForKey(mapent, "classname"))) + { + //Log_Print("found func_wall entity %d\n", mapent - entities); + //if the func wall is used in deathmatch + if (!(atoi(ValueForKey(mapent, "spawnflags")) & SPAWNFLAG_NOT_DEATHMATCH)) + { + //Log_Print("func_wall USED in deathmatch mode %d\n", atoi(ValueForKey(mapent, "spawnflags"))); + return true; + } //end if + } //end else if + else if (!strcmp("func_door_rotating", ValueForKey(mapent, "classname"))) + { + //if the func_door_rotating is present in deathmatch + if (!(atoi(ValueForKey(mapent, "spawnflags")) & SPAWNFLAG_NOT_DEATHMATCH)) + { + //if the func_door_rotating is always activated in deathmatch + if (AAS_AlwaysTriggered(ValueForKey(mapent, "targetname"))) + { + //Log_Print("found func_door_rotating in deathmatch\ntargetname %s\n", ValueForKey(mapent, "targetname")); + return true; + } //end if + } //end if + } //end else if + else if (!strcmp("trigger_hurt", ValueForKey(mapent, "classname"))) + { + //"dmg" is the damage, for instance: "dmg" "666" + return true; + } //end else if + else if (!strcmp("trigger_push", ValueForKey(mapent, "classname"))) + { + return true; + } //end else if + else if (!strcmp("trigger_multiple", ValueForKey(mapent, "classname"))) + { + //find out if the trigger_multiple is pointing to a target_teleporter + strcpy(target, ValueForKey(mapent, "target")); + for (i = 0; i < num_entities; i++) + { + //if the entity will activate the given targetname + if (!strcmp(target, ValueForKey(&entities[i], "targetname"))) + { + if (!strcmp("target_teleporter", ValueForKey(&entities[i], "classname"))) + { + return true; + } //end if + } //end if + } //end for + } //end else if + else if (!strcmp("trigger_teleport", ValueForKey(mapent, "classname"))) + { + return true; + } //end else if + else if (!strcmp("func_static", ValueForKey(mapent, "classname"))) + { + //FIXME: easy/medium/hard/deathmatch specific? + return true; + } //end else if + else if (!strcmp("func_door", ValueForKey(mapent, "classname"))) + { + return true; + } //end else if + return false; +} //end of the function AAS_ValidEntity +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_TransformPlane(int planenum, vec3_t origin, vec3_t angles) +{ + float newdist, matrix[3][3]; + vec3_t normal; + + //rotate the node plane + VectorCopy(mapplanes[planenum].normal, normal); + CreateRotationMatrix(angles, matrix); + RotatePoint(normal, matrix); + newdist = mapplanes[planenum].dist + DotProduct(normal, origin); + return FindFloatPlane(normal, newdist); +} //end of the function AAS_TransformPlane +//=========================================================================== +// this function sets the func_rotating_door in it's final position +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_PositionFuncRotatingBrush(entity_t *mapent, mapbrush_t *brush) +{ + int spawnflags, i; + float distance; + vec3_t movedir, angles, pos1, pos2; + side_t *s; + + spawnflags = FloatForKey(mapent, "spawnflags"); + VectorClear(movedir); + if (spawnflags & DOOR_X_AXIS) + movedir[2] = 1.0; //roll + else if (spawnflags & DOOR_Y_AXIS) + movedir[0] = 1.0; //pitch + else // Z_AXIS + movedir[1] = 1.0; //yaw + + // check for reverse rotation + if (spawnflags & DOOR_REVERSE) + VectorInverse(movedir); + + distance = FloatForKey(mapent, "distance"); + if (!distance) distance = 90; + + GetVectorForKey(mapent, "angles", angles); + VectorCopy(angles, pos1); + VectorMA(angles, -distance, movedir, pos2); + // if it starts open, switch the positions + if (spawnflags & DOOR_START_OPEN) + { + VectorCopy(pos2, angles); + VectorCopy(pos1, pos2); + VectorCopy(angles, pos1); + VectorInverse(movedir); + } //end if + // + for (i = 0; i < brush->numsides; i++) + { + s = &brush->original_sides[i]; + s->planenum = AAS_TransformPlane(s->planenum, mapent->origin, pos2); + } //end for + // + FreeBrushWindings(brush); + AAS_MakeBrushWindings(brush); + AddBrushBevels(brush); + FreeBrushWindings(brush); +} //end of the function AAS_PositionFuncRotatingBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_PositionBrush(entity_t *mapent, mapbrush_t *brush) +{ + side_t *s; + float newdist; + int i, notteam; + char *model; + + if (!strcmp(ValueForKey(mapent, "classname"), "func_door_rotating")) + { + AAS_PositionFuncRotatingBrush(mapent, brush); + } //end if + else + { + if (mapent->origin[0] || mapent->origin[1] || mapent->origin[2]) + { + for (i = 0; i < brush->numsides; i++) + { + s = &brush->original_sides[i]; + newdist = mapplanes[s->planenum].dist + + DotProduct(mapplanes[s->planenum].normal, mapent->origin); + s->planenum = FindFloatPlane(mapplanes[s->planenum].normal, newdist); + } //end for + } //end if + //if it's a trigger hurt + if (!strcmp("trigger_hurt", ValueForKey(mapent, "classname"))) + { + notteam = FloatForKey(mapent, "bot_notteam"); + if ( notteam == 1 ) { + brush->contents |= CONTENTS_NOTTEAM1; + } + else if ( notteam == 2 ) { + brush->contents |= CONTENTS_NOTTEAM2; + } + else { + // always avoid so set lava contents + brush->contents |= CONTENTS_LAVA; + } + } //end if + // +#ifdef CONTENTS_JUMPPAD + else if (!strcmp("trigger_push", ValueForKey(mapent, "classname"))) + { + //set the jumppad contents + brush->contents = CONTENTS_JUMPPAD; + //Log_Print("found trigger_push brush\n"); + } //end if +#endif // CONTENTS_JUMPPAD + // +#ifdef CONTENTS_TELEPORTER + else if (!strcmp("trigger_multiple", ValueForKey(mapent, "classname"))) + { + //set teleporter contents + brush->contents = CONTENTS_TELEPORTER; + //Log_Print("found trigger_multiple teleporter brush\n"); + } //end if +#endif // CONTENTS_TELEPORTER + // +#ifdef CONTENTS_TELEPORTER + else if (!strcmp("trigger_teleport", ValueForKey(mapent, "classname"))) + { + //set teleporter contents + brush->contents = CONTENTS_TELEPORTER; + //Log_Print("found trigger_teleport teleporter brush\n"); + } //end if +#endif // CONTENTS_TELEPORTER + else if (!strcmp("func_door", ValueForKey(mapent, "classname"))) + { + //set mover contents + brush->contents = CONTENTS_MOVER; + //get the model number + model = ValueForKey(mapent, "model"); + brush->modelnum = atoi(model+1); + } //end if + } //end else +} //end of the function AAS_PositionBrush +//=========================================================================== +// uses the global cfg_t cfg +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CreateMapBrushes(mapbrush_t *brush, entity_t *mapent, int addbevels) +{ + int i; + //side_t *s; + mapbrush_t *bboxbrushes[16]; + + //if the brushes are not from an entity used for AAS + if (!AAS_ValidEntity(mapent)) + { + nummapbrushsides -= brush->numsides; + brush->numsides = 0; + return; + } //end if + // + AAS_PositionBrush(mapent, brush); + //from all normal solid brushes only the textured brush sides will + //be used as bsp splitters, so set the right texinfo reference here + AAS_SetTexinfo(brush); + //remove contents detail flag, otherwise player clip contents won't be + //bsped correctly for AAS! + brush->contents &= ~CONTENTS_DETAIL; + //if the brush has contents area portal it should be the only contents + if (brush->contents & (CONTENTS_AREAPORTAL|CONTENTS_CLUSTERPORTAL)) + { + brush->contents = CONTENTS_CLUSTERPORTAL; + brush->leafnum = -1; + } //end if + //window and playerclip are used for player clipping, make them solid +#ifdef CONTENTS_WINDOW + if (brush->contents & (CONTENTS_WINDOW | CONTENTS_PLAYERCLIP)) + { + // + brush->contents &= ~(CONTENTS_WINDOW | CONTENTS_PLAYERCLIP); + brush->contents |= CONTENTS_SOLID; + brush->leafnum = -1; + } //end if +#else + if (brush->contents & (CONTENTS_PLAYERCLIP)) + { + // + brush->contents &= ~(CONTENTS_PLAYERCLIP); + brush->contents |= CONTENTS_SOLID; + brush->leafnum = -1; + } //end if +#endif + // + if (brush->contents & CONTENTS_BOTCLIP) + { + brush->contents = CONTENTS_SOLID; + brush->leafnum = -1; + } //end if + // + //Log_Write("brush %d contents = ", brush->brushnum); + //PrintContents(brush->contents); + //Log_Write("\r\n"); + //if not one of the following brushes then the brush is NOT used for AAS + if (!(brush->contents & (CONTENTS_SOLID +#ifdef CONTENTS_LADDER + | CONTENTS_LADDER +#endif // CONTENTS_LADDER + | CONTENTS_CLUSTERPORTAL + | CONTENTS_DONOTENTER +#ifdef CONTENTS_TELEPORTER + | CONTENTS_TELEPORTER +#endif // CONTENTS_TELEPORTER +#ifdef CONTENTS_JUMPPAD + | CONTENTS_JUMPPAD +#endif // CONTENTS_JUMPPAD + | CONTENTS_WATER + | CONTENTS_LAVA + | CONTENTS_SLIME + | CONTENTS_MOVER + ))) + { + nummapbrushsides -= brush->numsides; + brush->numsides = 0; + return; + } //end if + //fix the map brush + //AAS_FixMapBrush(brush); + //if brush bevels should be added (for real map brushes, not bsp map brushes) + if (addbevels) + { + //NOTE: we first have to get the mins and maxs of the brush before + // creating the brush bevels... the mins and maxs are used to + // create them. so we call MakeBrushWindings to get the mins + // and maxs and then after creating the bevels we free the + // windings because they are created for all sides (including + // bevels) a little later + AAS_MakeBrushWindings(brush); + AddBrushBevels(brush); + FreeBrushWindings(brush); + } //end if + //NOTE: add the brush to the WORLD entity!!! + mapent = &entities[0]; + //there's at least one new brush for now + nummapbrushes++; + mapent->numbrushes++; + //liquid brushes are expanded for the maximum possible bounding box + if (brush->contents & (CONTENTS_WATER + | CONTENTS_LAVA + | CONTENTS_SLIME +#ifdef CONTENTS_TELEPORTER + | CONTENTS_TELEPORTER +#endif // CONTENTS_TELEPORTER +#ifdef CONTENTS_JUMPPAD + | CONTENTS_JUMPPAD +#endif // CONTENTS_JUMPPAD + | CONTENTS_DONOTENTER + | CONTENTS_MOVER + )) + { + brush->expansionbbox = 0; + //NOTE: the first bounding box is the max + //FIXME: use max bounding box created from all bboxes + AAS_ExpandMapBrush(brush, cfg.bboxes[0].mins, cfg.bboxes[0].maxs); + AAS_MakeBrushWindings(brush); + } //end if + //area portal brushes are NOT expanded +#ifdef CONTENTS_CLUSTERPORTAL + else if (brush->contents & CONTENTS_CLUSTERPORTAL) + { + brush->expansionbbox = 0; + //NOTE: the first bounding box is the max + //FIXME: use max bounding box created from all bboxes + AAS_ExpandMapBrush(brush, cfg.bboxes[0].mins, cfg.bboxes[0].maxs); + AAS_MakeBrushWindings(brush); + } //end if +#endif // CONTENTS_CLUSTERPORTAL + //all solid brushes are expanded for all bounding boxes + else if (brush->contents & (CONTENTS_SOLID +#ifdef CONTENTS_LADDER + | CONTENTS_LADDER +#endif + )) + { + //brush for the first bounding box + bboxbrushes[0] = brush; + //make a copy for the other bounding boxes + for (i = 1; i < cfg.numbboxes; i++) + { + bboxbrushes[i] = AAS_CopyMapBrush(brush, mapent); + } //end for + //expand every brush for it's bounding box and create windings + for (i = 0; i < cfg.numbboxes; i++) + { + AAS_ExpandMapBrush(bboxbrushes[i], cfg.bboxes[i].mins, cfg.bboxes[i].maxs); + bboxbrushes[i]->expansionbbox = cfg.bboxes[i].presencetype; + AAS_MakeBrushWindings(bboxbrushes[i]); + } //end for + } //end else +} //end of the function AAS_CreateMapBrushes diff --git a/code/bspc/aas_map.h b/code/bspc/aas_map.h new file mode 100644 index 00000000..181f7119 --- /dev/null +++ b/code/bspc/aas_map.h @@ -0,0 +1,23 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +void AAS_CreateMapBrushes(mapbrush_t *brush, entity_t *mapent, int addbevels); diff --git a/code/bspc/aas_prunenodes.c b/code/bspc/aas_prunenodes.c new file mode 100644 index 00000000..1ba292ad --- /dev/null +++ b/code/bspc/aas_prunenodes.c @@ -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 +=========================================================================== +*/ + +#include "qbsp.h" +#include "../botlib/aasfile.h" +#include "aas_create.h" + +int c_numprunes; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tmp_node_t *AAS_PruneNodes_r(tmp_node_t *tmpnode) +{ + tmp_area_t *tmparea1, *tmparea2; + + //if it is a solid leaf + if (!tmpnode) return NULL; + // + if (tmpnode->tmparea) return tmpnode; + //process the children first + tmpnode->children[0] = AAS_PruneNodes_r(tmpnode->children[0]); + tmpnode->children[1] = AAS_PruneNodes_r(tmpnode->children[1]); + //if both children are areas + if (tmpnode->children[0] && tmpnode->children[1] && + tmpnode->children[0]->tmparea && tmpnode->children[1]->tmparea) + { + tmparea1 = tmpnode->children[0]->tmparea; + while(tmparea1->mergedarea) tmparea1 = tmparea1->mergedarea; + + tmparea2 = tmpnode->children[1]->tmparea; + while(tmparea2->mergedarea) tmparea2 = tmparea2->mergedarea; + + if (tmparea1 == tmparea2) + { + c_numprunes++; + tmpnode->tmparea = tmparea1; + tmpnode->planenum = 0; + AAS_FreeTmpNode(tmpnode->children[0]); + AAS_FreeTmpNode(tmpnode->children[1]); + tmpnode->children[0] = NULL; + tmpnode->children[1] = NULL; + return tmpnode; + } //end if + } //end if + //if both solid leafs + if (!tmpnode->children[0] && !tmpnode->children[1]) + { + c_numprunes++; + AAS_FreeTmpNode(tmpnode); + return NULL; + } //end if + // + return tmpnode; +} //end of the function AAS_PruneNodes_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_PruneNodes(void) +{ + Log_Write("AAS_PruneNodes\r\n"); + AAS_PruneNodes_r(tmpaasworld.nodes); + Log_Print("%6d nodes pruned\r\n", c_numprunes); +} //end of the function AAS_PruneNodes diff --git a/code/bspc/aas_prunenodes.h b/code/bspc/aas_prunenodes.h new file mode 100644 index 00000000..9433864f --- /dev/null +++ b/code/bspc/aas_prunenodes.h @@ -0,0 +1,24 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +void AAS_PruneNodes(void); + diff --git a/code/bspc/aas_store.c b/code/bspc/aas_store.c new file mode 100644 index 00000000..02cb78ff --- /dev/null +++ b/code/bspc/aas_store.c @@ -0,0 +1,1082 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "../botlib/aasfile.h" +#include "aas_file.h" +#include "aas_store.h" +#include "aas_create.h" +#include "aas_cfg.h" + + +//#define NOTHREEVERTEXFACES + +#define STOREPLANESDOUBLE + +#define VERTEX_EPSILON 0.1 //NOTE: changed from 0.5 +#define DIST_EPSILON 0.05 //NOTE: changed from 0.9 +#define NORMAL_EPSILON 0.0001 //NOTE: changed from 0.005 +#define INTEGRAL_EPSILON 0.01 + +#define VERTEX_HASHING +#define VERTEX_HASH_SHIFT 7 +#define VERTEX_HASH_SIZE ((MAX_MAP_BOUNDS>>(VERTEX_HASH_SHIFT-1))+1) //was 64 +// +#define PLANE_HASHING +#define PLANE_HASH_SIZE 1024 //must be power of 2 +// +#define EDGE_HASHING +#define EDGE_HASH_SIZE 1024 //must be power of 2 + +aas_t aasworld; + +//vertex hash +int *aas_vertexchain; // the next vertex in a hash chain +int aas_hashverts[VERTEX_HASH_SIZE*VERTEX_HASH_SIZE]; // a vertex number, or 0 for no verts +//plane hash +int *aas_planechain; +int aas_hashplanes[PLANE_HASH_SIZE]; +//edge hash +int *aas_edgechain; +int aas_hashedges[EDGE_HASH_SIZE]; + +int allocatedaasmem = 0; + +int groundfacesonly = false;//true; +// +typedef struct max_aas_s +{ + int max_bboxes; + int max_vertexes; + int max_planes; + int max_edges; + int max_edgeindexsize; + int max_faces; + int max_faceindexsize; + int max_areas; + int max_areasettings; + int max_reachabilitysize; + int max_nodes; + int max_portals; + int max_portalindexsize; + int max_clusters; +} max_aas_t; +//maximums of everything +max_aas_t max_aas; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_CountTmpNodes(tmp_node_t *tmpnode) +{ + if (!tmpnode) return 0; + return AAS_CountTmpNodes(tmpnode->children[0]) + + AAS_CountTmpNodes(tmpnode->children[1]) + 1; +} //end of the function AAS_CountTmpNodes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitMaxAAS(void) +{ + int numfaces, numpoints, numareas; + tmp_face_t *f; + tmp_area_t *a; + + numpoints = 0; + numfaces = 0; + for (f = tmpaasworld.faces; f; f = f->l_next) + { + numfaces++; + if (f->winding) numpoints += f->winding->numpoints; + } //end for + // + numareas = 0; + for (a = tmpaasworld.areas; a; a = a->l_next) + { + numareas++; + } //end for + max_aas.max_bboxes = AAS_MAX_BBOXES; + max_aas.max_vertexes = numpoints + 1; + max_aas.max_planes = nummapplanes; + max_aas.max_edges = numpoints + 1; + max_aas.max_edgeindexsize = (numpoints + 1) * 3; + max_aas.max_faces = numfaces + 10; + max_aas.max_faceindexsize = (numfaces + 10) * 2; + max_aas.max_areas = numareas + 10; + max_aas.max_areasettings = numareas + 10; + max_aas.max_reachabilitysize = 0; + max_aas.max_nodes = AAS_CountTmpNodes(tmpaasworld.nodes) + 10; + max_aas.max_portals = 0; + max_aas.max_portalindexsize = 0; + max_aas.max_clusters = 0; +} //end of the function AAS_InitMaxAAS +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_AllocMaxAAS(void) +{ + int i; + + AAS_InitMaxAAS(); + //bounding boxes + aasworld.numbboxes = 0; + aasworld.bboxes = (aas_bbox_t *) GetClearedMemory(max_aas.max_bboxes * sizeof(aas_bbox_t)); + allocatedaasmem += max_aas.max_bboxes * sizeof(aas_bbox_t); + //vertexes + aasworld.numvertexes = 0; + aasworld.vertexes = (aas_vertex_t *) GetClearedMemory(max_aas.max_vertexes * sizeof(aas_vertex_t)); + allocatedaasmem += max_aas.max_vertexes * sizeof(aas_vertex_t); + //planes + aasworld.numplanes = 0; + aasworld.planes = (aas_plane_t *) GetClearedMemory(max_aas.max_planes * sizeof(aas_plane_t)); + allocatedaasmem += max_aas.max_planes * sizeof(aas_plane_t); + //edges + aasworld.numedges = 0; + aasworld.edges = (aas_edge_t *) GetClearedMemory(max_aas.max_edges * sizeof(aas_edge_t)); + allocatedaasmem += max_aas.max_edges * sizeof(aas_edge_t); + //edge index + aasworld.edgeindexsize = 0; + aasworld.edgeindex = (aas_edgeindex_t *) GetClearedMemory(max_aas.max_edgeindexsize * sizeof(aas_edgeindex_t)); + allocatedaasmem += max_aas.max_edgeindexsize * sizeof(aas_edgeindex_t); + //faces + aasworld.numfaces = 0; + aasworld.faces = (aas_face_t *) GetClearedMemory(max_aas.max_faces * sizeof(aas_face_t)); + allocatedaasmem += max_aas.max_faces * sizeof(aas_face_t); + //face index + aasworld.faceindexsize = 0; + aasworld.faceindex = (aas_faceindex_t *) GetClearedMemory(max_aas.max_faceindexsize * sizeof(aas_faceindex_t)); + allocatedaasmem += max_aas.max_faceindexsize * sizeof(aas_faceindex_t); + //convex areas + aasworld.numareas = 0; + aasworld.areas = (aas_area_t *) GetClearedMemory(max_aas.max_areas * sizeof(aas_area_t)); + allocatedaasmem += max_aas.max_areas * sizeof(aas_area_t); + //convex area settings + aasworld.numareasettings = 0; + aasworld.areasettings = (aas_areasettings_t *) GetClearedMemory(max_aas.max_areasettings * sizeof(aas_areasettings_t)); + allocatedaasmem += max_aas.max_areasettings * sizeof(aas_areasettings_t); + //reachablity list + aasworld.reachabilitysize = 0; + aasworld.reachability = (aas_reachability_t *) GetClearedMemory(max_aas.max_reachabilitysize * sizeof(aas_reachability_t)); + allocatedaasmem += max_aas.max_reachabilitysize * sizeof(aas_reachability_t); + //nodes of the bsp tree + aasworld.numnodes = 0; + aasworld.nodes = (aas_node_t *) GetClearedMemory(max_aas.max_nodes * sizeof(aas_node_t)); + allocatedaasmem += max_aas.max_nodes * sizeof(aas_node_t); + //cluster portals + aasworld.numportals = 0; + aasworld.portals = (aas_portal_t *) GetClearedMemory(max_aas.max_portals * sizeof(aas_portal_t)); + allocatedaasmem += max_aas.max_portals * sizeof(aas_portal_t); + //cluster portal index + aasworld.portalindexsize = 0; + aasworld.portalindex = (aas_portalindex_t *) GetClearedMemory(max_aas.max_portalindexsize * sizeof(aas_portalindex_t)); + allocatedaasmem += max_aas.max_portalindexsize * sizeof(aas_portalindex_t); + //cluster + aasworld.numclusters = 0; + aasworld.clusters = (aas_cluster_t *) GetClearedMemory(max_aas.max_clusters * sizeof(aas_cluster_t)); + allocatedaasmem += max_aas.max_clusters * sizeof(aas_cluster_t); + // + Log_Print("allocated "); + PrintMemorySize(allocatedaasmem); + Log_Print(" of AAS memory\n"); + //reset the has stuff + aas_vertexchain = (int *) GetClearedMemory(max_aas.max_vertexes * sizeof(int)); + aas_planechain = (int *) GetClearedMemory(max_aas.max_planes * sizeof(int)); + aas_edgechain = (int *) GetClearedMemory(max_aas.max_edges * sizeof(int)); + // + for (i = 0; i < max_aas.max_vertexes; i++) aas_vertexchain[i] = -1; + for (i = 0; i < VERTEX_HASH_SIZE * VERTEX_HASH_SIZE; i++) aas_hashverts[i] = -1; + // + for (i = 0; i < max_aas.max_planes; i++) aas_planechain[i] = -1; + for (i = 0; i < PLANE_HASH_SIZE; i++) aas_hashplanes[i] = -1; + // + for (i = 0; i < max_aas.max_edges; i++) aas_edgechain[i] = -1; + for (i = 0; i < EDGE_HASH_SIZE; i++) aas_hashedges[i] = -1; +} //end of the function AAS_AllocMaxAAS +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_FreeMaxAAS(void) +{ + //bounding boxes + if (aasworld.bboxes) FreeMemory(aasworld.bboxes); + aasworld.bboxes = NULL; + aasworld.numbboxes = 0; + //vertexes + if (aasworld.vertexes) FreeMemory(aasworld.vertexes); + aasworld.vertexes = NULL; + aasworld.numvertexes = 0; + //planes + if (aasworld.planes) FreeMemory(aasworld.planes); + aasworld.planes = NULL; + aasworld.numplanes = 0; + //edges + if (aasworld.edges) FreeMemory(aasworld.edges); + aasworld.edges = NULL; + aasworld.numedges = 0; + //edge index + if (aasworld.edgeindex) FreeMemory(aasworld.edgeindex); + aasworld.edgeindex = NULL; + aasworld.edgeindexsize = 0; + //faces + if (aasworld.faces) FreeMemory(aasworld.faces); + aasworld.faces = NULL; + aasworld.numfaces = 0; + //face index + if (aasworld.faceindex) FreeMemory(aasworld.faceindex); + aasworld.faceindex = NULL; + aasworld.faceindexsize = 0; + //convex areas + if (aasworld.areas) FreeMemory(aasworld.areas); + aasworld.areas = NULL; + aasworld.numareas = 0; + //convex area settings + if (aasworld.areasettings) FreeMemory(aasworld.areasettings); + aasworld.areasettings = NULL; + aasworld.numareasettings = 0; + //reachablity list + if (aasworld.reachability) FreeMemory(aasworld.reachability); + aasworld.reachability = NULL; + aasworld.reachabilitysize = 0; + //nodes of the bsp tree + if (aasworld.nodes) FreeMemory(aasworld.nodes); + aasworld.nodes = NULL; + aasworld.numnodes = 0; + //cluster portals + if (aasworld.portals) FreeMemory(aasworld.portals); + aasworld.portals = NULL; + aasworld.numportals = 0; + //cluster portal index + if (aasworld.portalindex) FreeMemory(aasworld.portalindex); + aasworld.portalindex = NULL; + aasworld.portalindexsize = 0; + //clusters + if (aasworld.clusters) FreeMemory(aasworld.clusters); + aasworld.clusters = NULL; + aasworld.numclusters = 0; + + Log_Print("freed "); + PrintMemorySize(allocatedaasmem); + Log_Print(" of AAS memory\n"); + allocatedaasmem = 0; + // + if (aas_vertexchain) FreeMemory(aas_vertexchain); + aas_vertexchain = NULL; + if (aas_planechain) FreeMemory(aas_planechain); + aas_planechain = NULL; + if (aas_edgechain) FreeMemory(aas_edgechain); + aas_edgechain = NULL; +} //end of the function AAS_FreeMaxAAS +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +unsigned AAS_HashVec(vec3_t vec) +{ + int x, y; + + x = (MAX_MAP_BOUNDS + (int)(vec[0]+0.5)) >> VERTEX_HASH_SHIFT; + y = (MAX_MAP_BOUNDS + (int)(vec[1]+0.5)) >> VERTEX_HASH_SHIFT; + + if (x < 0 || x >= VERTEX_HASH_SIZE || y < 0 || y >= VERTEX_HASH_SIZE) + { + Log_Print("WARNING! HashVec: point %f %f %f outside valid range\n", vec[0], vec[1], vec[2]); + Log_Print("This should never happen!\n"); + return -1; + } //end if + + return y*VERTEX_HASH_SIZE + x; +} //end of the function AAS_HashVec +//=========================================================================== +// returns true if the vertex was found in the list +// stores the vertex number in *vnum +// stores a new vertex if not stored already +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean AAS_GetVertex(vec3_t v, int *vnum) +{ + int i; +#ifndef VERTEX_HASHING + float diff; +#endif //VERTEX_HASHING + +#ifdef VERTEX_HASHING + int h, vn; + vec3_t vert; + + for (i = 0; i < 3; i++) + { + if ( fabs(v[i] - Q_rint(v[i])) < INTEGRAL_EPSILON) + vert[i] = Q_rint(v[i]); + else + vert[i] = v[i]; + } //end for + + h = AAS_HashVec(vert); + //if the vertex was outside the valid range + if (h == -1) + { + *vnum = -1; + return true; + } //end if + + for (vn = aas_hashverts[h]; vn >= 0; vn = aas_vertexchain[vn]) + { + if (fabs(aasworld.vertexes[vn][0] - vert[0]) < VERTEX_EPSILON + && fabs(aasworld.vertexes[vn][1] - vert[1]) < VERTEX_EPSILON + && fabs(aasworld.vertexes[vn][2] - vert[2]) < VERTEX_EPSILON) + { + *vnum = vn; + return true; + } //end if + } //end for +#else //VERTEX_HASHING + //check if the vertex is already stored + //stupid linear search + for (i = 0; i < aasworld.numvertexes; i++) + { + diff = vert[0] - aasworld.vertexes[i][0]; + if (diff < VERTEX_EPSILON && diff > -VERTEX_EPSILON) + { + diff = vert[1] - aasworld.vertexes[i][1]; + if (diff < VERTEX_EPSILON && diff > -VERTEX_EPSILON) + { + diff = vert[2] - aasworld.vertexes[i][2]; + if (diff < VERTEX_EPSILON && diff > -VERTEX_EPSILON) + { + *vnum = i; + return true; + } //end if + } //end if + } //end if + } //end for +#endif //VERTEX_HASHING + + if (aasworld.numvertexes >= max_aas.max_vertexes) + { + Error("AAS_MAX_VERTEXES = %d", max_aas.max_vertexes); + } //end if + VectorCopy(vert, aasworld.vertexes[aasworld.numvertexes]); + *vnum = aasworld.numvertexes; + +#ifdef VERTEX_HASHING + aas_vertexchain[aasworld.numvertexes] = aas_hashverts[h]; + aas_hashverts[h] = aasworld.numvertexes; +#endif //VERTEX_HASHING + + aasworld.numvertexes++; + return false; +} //end of the function AAS_GetVertex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +unsigned AAS_HashEdge(int v1, int v2) +{ + int vnum1, vnum2; + // + if (v1 < v2) + { + vnum1 = v1; + vnum2 = v2; + } //end if + else + { + vnum1 = v2; + vnum2 = v1; + } //end else + return (vnum1 + vnum2) & (EDGE_HASH_SIZE-1); +} //end of the function AAS_HashVec +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_AddEdgeToHash(int edgenum) +{ + int hash; + aas_edge_t *edge; + + edge = &aasworld.edges[edgenum]; + + hash = AAS_HashEdge(edge->v[0], edge->v[1]); + + aas_edgechain[edgenum] = aas_hashedges[hash]; + aas_hashedges[hash] = edgenum; +} //end of the function AAS_AddEdgeToHash +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean AAS_FindHashedEdge(int v1num, int v2num, int *edgenum) +{ + int e, hash; + aas_edge_t *edge; + + hash = AAS_HashEdge(v1num, v2num); + for (e = aas_hashedges[hash]; e >= 0; e = aas_edgechain[e]) + { + edge = &aasworld.edges[e]; + if (edge->v[0] == v1num) + { + if (edge->v[1] == v2num) + { + *edgenum = e; + return true; + } //end if + } //end if + else if (edge->v[1] == v1num) + { + if (edge->v[0] == v2num) + { + //negative for a reversed edge + *edgenum = -e; + return true; + } //end if + } //end else + } //end for + return false; +} //end of the function AAS_FindHashedPlane +//=========================================================================== +// returns true if the edge was found +// stores the edge number in *edgenum (negative if reversed edge) +// stores new edge if not stored already +// returns zero when the edge is degenerate +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean AAS_GetEdge(vec3_t v1, vec3_t v2, int *edgenum) +{ + int v1num, v2num; + qboolean found; + + //the first edge is a dummy + if (aasworld.numedges == 0) aasworld.numedges = 1; + + found = AAS_GetVertex(v1, &v1num); + found &= AAS_GetVertex(v2, &v2num); + //if one of the vertexes was outside the valid range + if (v1num == -1 || v2num == -1) + { + *edgenum = 0; + return true; + } //end if + //if both vertexes are the same or snapped onto each other + if (v1num == v2num) + { + *edgenum = 0; + return true; + } //end if + //if both vertexes where already stored + if (found) + { +#ifdef EDGE_HASHING + if (AAS_FindHashedEdge(v1num, v2num, edgenum)) return true; +#else + int i; + for (i = 1; i < aasworld.numedges; i++) + { + if (aasworld.edges[i].v[0] == v1num) + { + if (aasworld.edges[i].v[1] == v2num) + { + *edgenum = i; + return true; + } //end if + } //end if + else if (aasworld.edges[i].v[1] == v1num) + { + if (aasworld.edges[i].v[0] == v2num) + { + //negative for a reversed edge + *edgenum = -i; + return true; + } //end if + } //end else + } //end for +#endif //EDGE_HASHING + } //end if + if (aasworld.numedges >= max_aas.max_edges) + { + Error("AAS_MAX_EDGES = %d", max_aas.max_edges); + } //end if + aasworld.edges[aasworld.numedges].v[0] = v1num; + aasworld.edges[aasworld.numedges].v[1] = v2num; + *edgenum = aasworld.numedges; +#ifdef EDGE_HASHING + AAS_AddEdgeToHash(*edgenum); +#endif //EDGE_HASHING + aasworld.numedges++; + return false; +} //end of the function AAS_GetEdge +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +//int AAS_PlaneTypeForNormal(vec3_t normal) +//{ +// vec_t ax, ay, az; +// +// //NOTE: epsilon used +// if ( (normal[0] >= 1.0 -NORMAL_EPSILON) || +// (normal[0] <= -1.0 + NORMAL_EPSILON)) return PLANE_X; +// if ( (normal[1] >= 1.0 -NORMAL_EPSILON) || +// (normal[1] <= -1.0 + NORMAL_EPSILON)) return PLANE_Y; +// if ( (normal[2] >= 1.0 -NORMAL_EPSILON) || +// (normal[2] <= -1.0 + NORMAL_EPSILON)) return PLANE_Z; +// +// ax = fabs(normal[0]); +// ay = fabs(normal[1]); +// az = fabs(normal[2]); +// +// if (ax >= ay && ax >= az) return PLANE_ANYX; +// if (ay >= ax && ay >= az) return PLANE_ANYY; +// return PLANE_ANYZ; +//} //end of the function AAS_PlaneTypeForNormal +////=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_AddPlaneToHash(int planenum) +{ + int hash; + aas_plane_t *plane; + + plane = &aasworld.planes[planenum]; + + hash = (int)fabs(plane->dist) / 8; + hash &= (PLANE_HASH_SIZE-1); + + aas_planechain[planenum] = aas_hashplanes[hash]; + aas_hashplanes[hash] = planenum; +} //end of the function AAS_AddPlaneToHash +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_PlaneEqual(vec3_t normal, float dist, int planenum) +{ + float diff; + + diff = dist - aasworld.planes[planenum].dist; + if (diff > -DIST_EPSILON && diff < DIST_EPSILON) + { + diff = normal[0] - aasworld.planes[planenum].normal[0]; + if (diff > -NORMAL_EPSILON && diff < NORMAL_EPSILON) + { + diff = normal[1] - aasworld.planes[planenum].normal[1]; + if (diff > -NORMAL_EPSILON && diff < NORMAL_EPSILON) + { + diff = normal[2] - aasworld.planes[planenum].normal[2]; + if (diff > -NORMAL_EPSILON && diff < NORMAL_EPSILON) + { + return true; + } //end if + } //end if + } //end if + } //end if + return false; +} //end of the function AAS_PlaneEqual +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean AAS_FindPlane(vec3_t normal, float dist, int *planenum) +{ + int i; + + for (i = 0; i < aasworld.numplanes; i++) + { + if (AAS_PlaneEqual(normal, dist, i)) + { + *planenum = i; + return true; + } //end if + } //end for + return false; +} //end of the function AAS_FindPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean AAS_FindHashedPlane(vec3_t normal, float dist, int *planenum) +{ + int i, p; + aas_plane_t *plane; + int hash, h; + + hash = (int)fabs(dist) / 8; + hash &= (PLANE_HASH_SIZE-1); + + //search the border bins as well + for (i = -1; i <= 1; i++) + { + h = (hash+i)&(PLANE_HASH_SIZE-1); + for (p = aas_hashplanes[h]; p >= 0; p = aas_planechain[p]) + { + plane = &aasworld.planes[p]; + if (AAS_PlaneEqual(normal, dist, p)) + { + *planenum = p; + return true; + } //end if + } //end for + } //end for + return false; +} //end of the function AAS_FindHashedPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean AAS_GetPlane(vec3_t normal, vec_t dist, int *planenum) +{ + aas_plane_t *plane, temp; + + //if (AAS_FindPlane(normal, dist, planenum)) return true; + if (AAS_FindHashedPlane(normal, dist, planenum)) return true; + + if (aasworld.numplanes >= max_aas.max_planes-1) + { + Error("AAS_MAX_PLANES = %d", max_aas.max_planes); + } //end if + +#ifdef STOREPLANESDOUBLE + plane = &aasworld.planes[aasworld.numplanes]; + VectorCopy(normal, plane->normal); + plane->dist = dist; + plane->type = (plane+1)->type = PlaneTypeForNormal(plane->normal); + + VectorCopy(normal, (plane+1)->normal); + VectorNegate((plane+1)->normal, (plane+1)->normal); + (plane+1)->dist = -dist; + + aasworld.numplanes += 2; + + //allways put axial planes facing positive first + if (plane->type < 3) + { + if (plane->normal[0] < 0 || plane->normal[1] < 0 || plane->normal[2] < 0) + { + // flip order + temp = *plane; + *plane = *(plane+1); + *(plane+1) = temp; + *planenum = aasworld.numplanes - 1; + return false; + } //end if + } //end if + *planenum = aasworld.numplanes - 2; + //add the planes to the hash + AAS_AddPlaneToHash(aasworld.numplanes - 1); + AAS_AddPlaneToHash(aasworld.numplanes - 2); + return false; +#else + plane = &aasworld.planes[aasworld.numplanes]; + VectorCopy(normal, plane->normal); + plane->dist = dist; + plane->type = AAS_PlaneTypeForNormal(normal); + + *planenum = aasworld.numplanes; + aasworld.numplanes++; + //add the plane to the hash + AAS_AddPlaneToHash(aasworld.numplanes - 1); + return false; +#endif //STOREPLANESDOUBLE +} //end of the function AAS_GetPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean AAS_GetFace(winding_t *w, plane_t *p, int side, int *facenum) +{ + int edgenum, i, j; + aas_face_t *face; + + //face zero is a dummy, because of the face index with negative numbers + if (aasworld.numfaces == 0) aasworld.numfaces = 1; + + if (aasworld.numfaces >= max_aas.max_faces) + { + Error("AAS_MAX_FACES = %d", max_aas.max_faces); + } //end if + face = &aasworld.faces[aasworld.numfaces]; + AAS_GetPlane(p->normal, p->dist, &face->planenum); + face->faceflags = 0; + face->firstedge = aasworld.edgeindexsize; + face->frontarea = 0; + face->backarea = 0; + face->numedges = 0; + for (i = 0; i < w->numpoints; i++) + { + if (aasworld.edgeindexsize >= max_aas.max_edgeindexsize) + { + Error("AAS_MAX_EDGEINDEXSIZE = %d", max_aas.max_edgeindexsize); + } //end if + j = (i+1) % w->numpoints; + AAS_GetEdge(w->p[i], w->p[j], &edgenum); + //if the edge wasn't degenerate + if (edgenum) + { + aasworld.edgeindex[aasworld.edgeindexsize++] = edgenum; + face->numedges++; + } //end if + else if (verbose) + { + Log_Write("AAS_GetFace: face %d had degenerate edge %d-%d\r\n", + aasworld.numfaces, i, j); + } //end else + } //end for + if (face->numedges < 1 +#ifdef NOTHREEVERTEXFACES + || face->numedges < 3 +#endif //NOTHREEVERTEXFACES + ) + { + memset(&aasworld.faces[aasworld.numfaces], 0, sizeof(aas_face_t)); + Log_Write("AAS_GetFace: face %d was tiny\r\n", aasworld.numfaces); + return false; + } //end if + *facenum = aasworld.numfaces; + aasworld.numfaces++; + return true; +} //end of the function AAS_GetFace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +/* +qboolean AAS_GetFace(winding_t *w, plane_t *p, int side, int *facenum) +{ + aas_edgeindex_t edges[1024]; + int planenum, numedges, i; + int j, edgenum; + qboolean foundplane, foundedges; + aas_face_t *face; + + //face zero is a dummy, because of the face index with negative numbers + if (aasworld.numfaces == 0) aasworld.numfaces = 1; + + foundplane = AAS_GetPlane(p->normal, p->dist, &planenum); + + foundedges = true; + numedges = w->numpoints; + for (i = 0; i < w->numpoints; i++) + { + if (i >= 1024) Error("AAS_GetFace: more than %d edges\n", 1024); + foundedges &= AAS_GetEdge(w->p[i], w->p[(i+1 >= w->numpoints ? 0 : i+1)], &edges[i]); + } //end for + + //FIXME: use portal number instead of a search + //if the plane and all edges already existed + if (foundplane && foundedges) + { + for (i = 0; i < aasworld.numfaces; i++) + { + face = &aasworld.faces[i]; + if (planenum == face->planenum) + { + if (numedges == face->numedges) + { + for (j = 0; j < numedges; j++) + { + edgenum = abs(aasworld.edgeindex[face->firstedge + j]); + if (abs(edges[i]) != edgenum) break; + } //end for + if (j == numedges) + { + //jippy found the face + *facenum = -i; + return true; + } //end if + } //end if + } //end if + } //end for + } //end if + if (aasworld.numfaces >= max_aas.max_faces) + { + Error("AAS_MAX_FACES = %d", max_aas.max_faces); + } //end if + face = &aasworld.faces[aasworld.numfaces]; + face->planenum = planenum; + face->faceflags = 0; + face->numedges = numedges; + face->firstedge = aasworld.edgeindexsize; + face->frontarea = 0; + face->backarea = 0; + for (i = 0; i < numedges; i++) + { + if (aasworld.edgeindexsize >= max_aas.max_edgeindexsize) + { + Error("AAS_MAX_EDGEINDEXSIZE = %d", max_aas.max_edgeindexsize); + } //end if + aasworld.edgeindex[aasworld.edgeindexsize++] = edges[i]; + } //end for + *facenum = aasworld.numfaces; + aasworld.numfaces++; + return false; +} //end of the function AAS_GetFace*/ +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_StoreAreaSettings(tmp_areasettings_t *tmpareasettings) +{ + aas_areasettings_t *areasettings; + + if (aasworld.numareasettings == 0) aasworld.numareasettings = 1; + areasettings = &aasworld.areasettings[aasworld.numareasettings++]; + areasettings->areaflags = tmpareasettings->areaflags; + areasettings->presencetype = tmpareasettings->presencetype; + areasettings->contents = tmpareasettings->contents; + if (tmpareasettings->modelnum > AREACONTENTS_MAXMODELNUM) + Log_Print("WARNING: more than %d mover models\n", AREACONTENTS_MAXMODELNUM); + areasettings->contents |= (tmpareasettings->modelnum & AREACONTENTS_MAXMODELNUM) << AREACONTENTS_MODELNUMSHIFT; +} //end of the function AAS_StoreAreaSettings +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_StoreArea(tmp_area_t *tmparea) +{ + int side, edgenum, i; + plane_t *plane; + tmp_face_t *tmpface; + aas_area_t *aasarea; + aas_edge_t *edge; + aas_face_t *aasface; + aas_faceindex_t aasfacenum; + vec3_t facecenter; + winding_t *w; + + //when the area is merged go to the merged area + //FIXME: this isn't necessary anymore because the tree + // is refreshed after area merging + while(tmparea->mergedarea) tmparea = tmparea->mergedarea; + // + if (tmparea->invalid) Error("AAS_StoreArea: tried to store invalid area"); + //if there is an aas area already stored for this tmp area + if (tmparea->aasareanum) return -tmparea->aasareanum; + // + if (aasworld.numareas >= max_aas.max_areas) + { + Error("AAS_MAX_AREAS = %d", max_aas.max_areas); + } //end if + //area zero is a dummy + if (aasworld.numareas == 0) aasworld.numareas = 1; + //create an area from this leaf + aasarea = &aasworld.areas[aasworld.numareas]; + aasarea->areanum = aasworld.numareas; + aasarea->numfaces = 0; + aasarea->firstface = aasworld.faceindexsize; + ClearBounds(aasarea->mins, aasarea->maxs); + VectorClear(aasarea->center); + // +// Log_Write("tmparea %d became aasarea %d\r\n", tmparea->areanum, aasarea->areanum); + //store the aas area number at the tmp area + tmparea->aasareanum = aasarea->areanum; + // + for (tmpface = tmparea->tmpfaces; tmpface; tmpface = tmpface->next[side]) + { + side = tmpface->frontarea != tmparea; + //if there's an aas face created for the tmp face already + if (tmpface->aasfacenum) + { + //we're at the back of the face so use a negative index + aasfacenum = -tmpface->aasfacenum; +#ifdef DEBUG + if (tmpface->aasfacenum < 0 || tmpface->aasfacenum > max_aas.max_faces) + { + Error("AAS_CreateTree_r: face number out of range"); + } //end if +#endif //DEBUG + aasface = &aasworld.faces[tmpface->aasfacenum]; + aasface->backarea = aasarea->areanum; + } //end if + else + { + plane = &mapplanes[tmpface->planenum ^ side]; + if (side) + { + w = tmpface->winding; + tmpface->winding = ReverseWinding(tmpface->winding); + } //end if + if (!AAS_GetFace(tmpface->winding, plane, 0, &aasfacenum)) continue; + if (side) + { + FreeWinding(tmpface->winding); + tmpface->winding = w; + } //end if + aasface = &aasworld.faces[aasfacenum]; + aasface->frontarea = aasarea->areanum; + aasface->backarea = 0; + aasface->faceflags = tmpface->faceflags; + //set the face number at the tmp face + tmpface->aasfacenum = aasfacenum; + } //end else + //add face points to the area bounds and + //calculate the face 'center' + VectorClear(facecenter); + for (edgenum = 0; edgenum < aasface->numedges; edgenum++) + { + edge = &aasworld.edges[abs(aasworld.edgeindex[aasface->firstedge + edgenum])]; + for (i = 0; i < 2; i++) + { + AddPointToBounds(aasworld.vertexes[edge->v[i]], aasarea->mins, aasarea->maxs); + VectorAdd(aasworld.vertexes[edge->v[i]], facecenter, facecenter); + } //end for + } //end for + VectorScale(facecenter, 1.0 / (aasface->numedges * 2.0), facecenter); + //add the face 'center' to the area 'center' + VectorAdd(aasarea->center, facecenter, aasarea->center); + // + if (aasworld.faceindexsize >= max_aas.max_faceindexsize) + { + Error("AAS_MAX_FACEINDEXSIZE = %d", max_aas.max_faceindexsize); + } //end if + aasworld.faceindex[aasworld.faceindexsize++] = aasfacenum; + aasarea->numfaces++; + } //end for + //if the area has no faces at all (return 0, = solid leaf) + if (!aasarea->numfaces) return 0; + // + VectorScale(aasarea->center, 1.0 / aasarea->numfaces, aasarea->center); + //Log_Write("area %d center %f %f %f\r\n", aasworld.numareas, + // aasarea->center[0], aasarea->center[1], aasarea->center[2]); + //store the area settings + AAS_StoreAreaSettings(tmparea->settings); + // + //Log_Write("tmp area %d became aas area %d\r\n", tmpareanum, aasarea->areanum); + qprintf("\r%6d", aasarea->areanum); + // + aasworld.numareas++; + return -(aasworld.numareas - 1); +} //end of the function AAS_StoreArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int AAS_StoreTree_r(tmp_node_t *tmpnode) +{ + int aasnodenum; + plane_t *plane; + aas_node_t *aasnode; + + //if it is a solid leaf + if (!tmpnode) return 0; + //negative so it's an area + if (tmpnode->tmparea) return AAS_StoreArea(tmpnode->tmparea); + //it's another node + //the first node is a dummy + if (aasworld.numnodes == 0) aasworld.numnodes = 1; + if (aasworld.numnodes >= max_aas.max_nodes) + { + Error("AAS_MAX_NODES = %d", max_aas.max_nodes); + } //end if + aasnodenum = aasworld.numnodes; + aasnode = &aasworld.nodes[aasworld.numnodes++]; + plane = &mapplanes[tmpnode->planenum]; + AAS_GetPlane(plane->normal, plane->dist, &aasnode->planenum); + aasnode->children[0] = AAS_StoreTree_r(tmpnode->children[0]); + aasnode->children[1] = AAS_StoreTree_r(tmpnode->children[1]); + return aasnodenum; +} //end of the function AAS_StoreTree_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_StoreBoundingBoxes(void) +{ + if (cfg.numbboxes > max_aas.max_bboxes) + { + Error("more than %d bounding boxes", max_aas.max_bboxes); + } //end if + aasworld.numbboxes = cfg.numbboxes; + memcpy(aasworld.bboxes, cfg.bboxes, cfg.numbboxes * sizeof(aas_bbox_t)); +} //end of the function AAS_StoreBoundingBoxes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_StoreFile(char *filename) +{ + AAS_AllocMaxAAS(); + + Log_Write("AAS_StoreFile\r\n"); + // + AAS_StoreBoundingBoxes(); + // + qprintf("%6d areas stored", 0); + //start with node 1 because node zero is a dummy + AAS_StoreTree_r(tmpaasworld.nodes); + qprintf("\n"); + Log_Write("%6d areas stored\r\n", aasworld.numareas); + aasworld.loaded = true; +} //end of the function AAS_StoreFile diff --git a/code/bspc/aas_store.h b/code/bspc/aas_store.h new file mode 100644 index 00000000..58ea1c15 --- /dev/null +++ b/code/bspc/aas_store.h @@ -0,0 +1,107 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#define AAS_MAX_BBOXES 5 +#define AAS_MAX_VERTEXES 512000 +#define AAS_MAX_PLANES 65536 +#define AAS_MAX_EDGES 512000 +#define AAS_MAX_EDGEINDEXSIZE 512000 +#define AAS_MAX_FACES 512000 +#define AAS_MAX_FACEINDEXSIZE 512000 +#define AAS_MAX_AREAS 65536 +#define AAS_MAX_AREASETTINGS 65536 +#define AAS_MAX_REACHABILITYSIZE 65536 +#define AAS_MAX_NODES 256000 +#define AAS_MAX_PORTALS 65536 +#define AAS_MAX_PORTALINDEXSIZE 65536 +#define AAS_MAX_CLUSTERS 65536 + +#define BSPCINCLUDE +#include "../botlib/be_aas.h" +#include "../botlib/be_aas_def.h" + +/* +typedef struct bspc_aas_s +{ + int loaded; + int initialized; //true when AAS has been initialized + int savefile; //set true when file should be saved + //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; +} bspc_aas_t; + +extern bspc_aas_t aasworld; +//*/ + +extern aas_t aasworld; + +//stores the AAS file from the temporary AAS +void AAS_StoreFile(char *filename); +//returns a number of the given plane +qboolean AAS_FindPlane(vec3_t normal, float dist, int *planenum); +//allocates the maximum AAS memory for storage +void AAS_AllocMaxAAS(void); +//frees the maximum AAS memory for storage +void AAS_FreeMaxAAS(void); diff --git a/code/bspc/aasfile.h b/code/bspc/aasfile.h new file mode 100644 index 00000000..fc3dc778 --- /dev/null +++ b/code/bspc/aasfile.h @@ -0,0 +1,252 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + + +//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 + +//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 +#define FACE_LIQUIDSURFACE 32 + +//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 + +//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 + +//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 convex area + int areaflags; //several area flags + int presencetype; //how a bot can be present in this convex 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 a convex area, often it will also seperate two convex 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; //convex area at the front of this face + int backarea; //convex 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; + +//convex 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 convex area + int firstface; //first face in the face index used for the boundary of the convex area + vec3_t mins; //mins of the convex area + vec3_t maxs; //maxs of the convex area + vec3_t center; //'center' of the convex 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 convex 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 convex 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 + cluster number zero +- edge zero is a dummy +- face zero is a dummy +- area zero is a dummy +- node zero is a dummy +*/ diff --git a/code/bspc/be_aas_bspc.c b/code/bspc/be_aas_bspc.c new file mode 100644 index 00000000..bcdae2a5 --- /dev/null +++ b/code/bspc/be_aas_bspc.c @@ -0,0 +1,292 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "../qcommon/q_shared.h" +#include "../bspc/l_log.h" +#include "../bspc/l_qfiles.h" +#include "../botlib/l_memory.h" +#include "../botlib/l_script.h" +#include "../botlib/l_precomp.h" +#include "../botlib/l_struct.h" +#include "../botlib/aasfile.h" +#include "../botlib/botlib.h" +#include "../botlib/be_aas.h" +#include "../botlib/be_aas_def.h" +#include "../qcommon/cm_public.h" + +//#define BSPC + +extern botlib_import_t botimport; +extern qboolean capsule_collision; + +botlib_import_t botimport; +clipHandle_t worldmodel; + +void Error (char *error, ...); + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_Error(char *fmt, ...) +{ + va_list argptr; + char text[1024]; + + va_start(argptr, fmt); + vsprintf(text, fmt, argptr); + va_end(argptr); + + Error(text); +} //end of the function AAS_Error +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Sys_MilliSeconds(void) +{ + return clock() * 1000 / CLOCKS_PER_SEC; +} //end of the function Sys_MilliSeconds +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_DebugLine(vec3_t start, vec3_t end, int color) +{ +} //end of the function AAS_DebugLine +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_ClearShownDebugLines(void) +{ +} //end of the function AAS_ClearShownDebugLines +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *BotImport_BSPEntityData(void) +{ + return CM_EntityString(); +} //end of the function AAS_GetEntityData +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotImport_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask) +{ + trace_t result; + + CM_BoxTrace(&result, start, end, mins, maxs, worldmodel, contentmask, capsule_collision); + + bsptrace->allsolid = result.allsolid; + bsptrace->contents = result.contents; + VectorCopy(result.endpos, bsptrace->endpos); + bsptrace->ent = result.entityNum; + bsptrace->fraction = result.fraction; + bsptrace->exp_dist = 0; + bsptrace->plane.dist = result.plane.dist; + VectorCopy(result.plane.normal, bsptrace->plane.normal); + bsptrace->plane.signbits = result.plane.signbits; + bsptrace->plane.type = result.plane.type; + bsptrace->sidenum = 0; + bsptrace->startsolid = result.startsolid; + bsptrace->surface.flags = result.surfaceFlags; +} //end of the function BotImport_Trace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BotImport_PointContents(vec3_t p) +{ + return CM_PointContents(p, worldmodel); +} //end of the function BotImport_PointContents +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void *BotImport_GetMemory(int size) +{ + return GetMemory(size); +} //end of the function BotImport_GetMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotImport_Print(int type, char *fmt, ...) +{ + va_list argptr; + char buf[1024]; + + va_start(argptr, fmt); + vsprintf(buf, fmt, argptr); + printf(buf); + if (buf[0] != '\r') Log_Write(buf); + va_end(argptr); +} //end of the function BotImport_Print +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmins, vec3_t outmaxs, vec3_t origin) +{ + clipHandle_t h; + vec3_t mins, maxs; + float max; + int i; + + h = CM_InlineModel(modelnum); + CM_ModelBounds(h, mins, maxs); + //if the model is rotated + if ((angles[0] || angles[1] || angles[2])) + { // expand for rotation + + max = RadiusFromBounds(mins, maxs); + for (i = 0; i < 3; i++) + { + mins[i] = (mins[i] + maxs[i]) * 0.5 - max; + maxs[i] = (mins[i] + maxs[i]) * 0.5 + max; + } //end for + } //end if + if (outmins) VectorCopy(mins, outmins); + if (outmaxs) VectorCopy(maxs, outmaxs); + if (origin) VectorClear(origin); +} //end of the function BotImport_BSPModelMinsMaxsOrigin +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Com_DPrintf(char *fmt, ...) +{ + va_list argptr; + char buf[1024]; + + va_start(argptr, fmt); + vsprintf(buf, fmt, argptr); + printf(buf); + if (buf[0] != '\r') Log_Write(buf); + va_end(argptr); +} //end of the function Com_DPrintf +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int COM_Compress( char *data_p ) { + return strlen(data_p); +} +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +//void Com_Memset (void* dest, const int val, const size_t count) { +// memset(dest, val, count); +//} +////=========================================================================== +//// +//// Parameter: - +//// Returns: - +//// Changes Globals: - +////=========================================================================== +//void Com_Memcpy (void* dest, const void* src, const size_t count) { +// memcpy(dest, src, count); +//} +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_InitBotImport(void) +{ + botimport.BSPEntityData = BotImport_BSPEntityData; + botimport.GetMemory = BotImport_GetMemory; + botimport.FreeMemory = FreeMemory; + botimport.Trace = BotImport_Trace; + botimport.PointContents = BotImport_PointContents; + botimport.Print = BotImport_Print; + botimport.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin; +} //end of the function AAS_InitBotImport +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_CalcReachAndClusters(struct quakefile_s *qf) +{ + float time; + + Log_Print("loading collision map...\n"); + // + if (!qf->pakfile[0]) strcpy(qf->pakfile, qf->filename); + //load the map + CM_LoadMap((char *) qf, qfalse, &aasworld.bspchecksum); + //get a handle to the world model + worldmodel = CM_InlineModel(0); // 0 = world, 1 + are bmodels + //initialize bot import structure + AAS_InitBotImport(); + //load the BSP entity string + AAS_LoadBSPFile(); + //init physics settings + AAS_InitSettings(); + //initialize AAS link heap + AAS_InitAASLinkHeap(); + //initialize the AAS linked entities for the new map + AAS_InitAASLinkedEntities(); + //reset all reachabilities and clusters + aasworld.reachabilitysize = 0; + aasworld.numclusters = 0; + //set all view portals as cluster portals in case we re-calculate the reachabilities and clusters (with -reach) + AAS_SetViewPortalsAsClusterPortals(); + //calculate reachabilities + AAS_InitReachability(); + time = 0; + while(AAS_ContinueInitReachability(time)) time++; + //calculate clusters + AAS_InitClustering(); +} //end of the function AAS_CalcReachAndClusters diff --git a/code/bspc/be_aas_bspc.h b/code/bspc/be_aas_bspc.h new file mode 100644 index 00000000..97e2921b --- /dev/null +++ b/code/bspc/be_aas_bspc.h @@ -0,0 +1,23 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +void AAS_CalcReachAndClusters(struct quakefile_s *qf); diff --git a/code/bspc/brushbsp.c b/code/bspc/brushbsp.c new file mode 100644 index 00000000..48adb1cd --- /dev/null +++ b/code/bspc/brushbsp.c @@ -0,0 +1,1887 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "l_mem.h" +#include "../botlib/aasfile.h" +#include "aas_store.h" +#include "aas_cfg.h" + +#include + +/* +each side has a count of the other sides it splits + +the best split will be the one that minimizes the total split counts +of all remaining sides + +precalc side on plane table + +evaluate split side +{ +cost = 0 +for all sides + for all sides + get + if side splits side and splitside is on same child + cost++; +} +*/ + +int c_nodes; +int c_nonvis; +int c_active_brushes; +int c_solidleafnodes; +int c_totalsides; +int c_brushmemory; +int c_peak_brushmemory; +int c_nodememory; +int c_peak_totalbspmemory; + +// if a brush just barely pokes onto the other side, +// let it slide by without chopping +#define PLANESIDE_EPSILON 0.001 +//0.1 + +//#ifdef DEBUG +typedef struct cname_s +{ + int value; + char *name; +} cname_t; + +cname_t contentnames[] = +{ + {CONTENTS_SOLID,"CONTENTS_SOLID"}, +#ifdef CONTENTS_WINDOW + {CONTENTS_WINDOW,"CONTENTS_WINDOW"}, +#endif +#ifdef CONTENTS_AUX + {CONTENTS_AUX,"CONTENTS_AUX"}, +#endif + {CONTENTS_LAVA,"CONTENTS_LAVA"}, + {CONTENTS_SLIME,"CONTENTS_SLIME"}, + {CONTENTS_WATER,"CONTENTS_WATER"}, +#ifdef CONTENTS_MIST + {CONTENTS_MIST,"CONTENTS_MIST"}, +#endif + {LAST_VISIBLE_CONTENTS,"LAST_VISIBLE_CONTENTS"}, + + {CONTENTS_AREAPORTAL,"CONTENTS_AREAPORTAL"}, + {CONTENTS_PLAYERCLIP,"CONTENTS_PLAYERCLIP"}, + {CONTENTS_MONSTERCLIP,"CONTENTS_MONSTERCLIP"}, +#ifdef CONTENTS_CURRENT_0 + {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"}, +#endif + {CONTENTS_ORIGIN,"CONTENTS_ORIGIN"}, +#ifdef CONTENTS_MONSTER + {CONTENTS_MONSTER,"CONTENTS_MONSTER"}, +#endif +#ifdef CONTENTS_DEADMONSTER + {CONTENTS_DEADMONSTER,"CONTENTS_DEADMONSTER"}, +#endif + {CONTENTS_DETAIL,"CONTENTS_DETAIL"}, +// {CONTENTS_Q2TRANSLUCENT,"CONTENTS_TRANSLUCENT"}, +#ifdef CONTENTS_LADDER + {CONTENTS_LADDER,"CONTENTS_LADDER"}, +#endif + {0, 0} +}; + +void PrintContents(int contents) +{ + int i; + + for (i = 0; contentnames[i].value; i++) + { + if (contents & contentnames[i].value) + { + Log_Write("%s,", contentnames[i].name); + } //end if + } //end for +} //end of the function PrintContents + +//#endif DEBUG + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ResetBrushBSP(void) +{ + c_nodes = 0; + c_nonvis = 0; + c_active_brushes = 0; + c_solidleafnodes = 0; + c_totalsides = 0; + c_brushmemory = 0; + c_peak_brushmemory = 0; + c_nodememory = 0; + c_peak_totalbspmemory = 0; +} //end of the function ResetBrushBSP +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FindBrushInTree (node_t *node, int brushnum) +{ + bspbrush_t *b; + + if (node->planenum == PLANENUM_LEAF) + { + for (b=node->brushlist ; b ; b=b->next) + if (b->original->brushnum == brushnum) + Log_Print ("here\n"); + return; + } + FindBrushInTree(node->children[0], brushnum); + FindBrushInTree(node->children[1], brushnum); +} //end of the function FindBrushInTree +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void DrawBrushList (bspbrush_t *brush, node_t *node) +{ + int i; + side_t *s; + + GLS_BeginScene (); + for ( ; brush ; brush=brush->next) + { + for (i=0 ; inumsides ; i++) + { + s = &brush->sides[i]; + if (!s->winding) + continue; + if (s->texinfo == TEXINFO_NODE) + GLS_Winding (s->winding, 1); + else if (!(s->flags & SFL_VISIBLE)) + GLS_Winding (s->winding, 2); + else + GLS_Winding (s->winding, 0); + } + } + GLS_EndScene (); +} //end of the function DrawBrushList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void WriteBrushList (char *name, bspbrush_t *brush, qboolean onlyvis) +{ + int i; + side_t *s; + FILE *f; + + qprintf ("writing %s\n", name); + f = SafeOpenWrite (name); + + for ( ; brush ; brush=brush->next) + { + for (i=0 ; inumsides ; i++) + { + s = &brush->sides[i]; + if (!s->winding) + continue; + if (onlyvis && !(s->flags & SFL_VISIBLE)) + continue; + OutputWinding (brush->sides[i].winding, f); + } + } + + fclose (f); +} //end of the function WriteBrushList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintBrush (bspbrush_t *brush) +{ + int i; + + printf ("brush: %p\n", brush); + for (i=0;inumsides ; i++) + { + pw(brush->sides[i].winding); + printf ("\n"); + } //end for +} //end of the function PrintBrush +//=========================================================================== +// Sets the mins/maxs based on the windings +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BoundBrush (bspbrush_t *brush) +{ + int i, j; + winding_t *w; + + ClearBounds (brush->mins, brush->maxs); + for (i=0 ; inumsides ; i++) + { + w = brush->sides[i].winding; + if (!w) + continue; + for (j=0 ; jnumpoints ; j++) + AddPointToBounds (w->p[j], brush->mins, brush->maxs); + } +} //end of the function BoundBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void CreateBrushWindings (bspbrush_t *brush) +{ + int i, j; + winding_t *w; + side_t *side; + plane_t *plane; + + for (i=0 ; inumsides ; i++) + { + side = &brush->sides[i]; + plane = &mapplanes[side->planenum]; + w = BaseWindingForPlane (plane->normal, plane->dist); + for (j=0 ; jnumsides && w; j++) + { + if (i == j) + continue; + if (brush->sides[j].flags & SFL_BEVEL) + continue; + plane = &mapplanes[brush->sides[j].planenum^1]; + ChopWindingInPlace (&w, plane->normal, plane->dist, 0); //CLIP_EPSILON); + } + + side->winding = w; + } + + BoundBrush (brush); +} //end of the function CreateBrushWindings +//=========================================================================== +// Creates a new axial brush +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *BrushFromBounds (vec3_t mins, vec3_t maxs) +{ + bspbrush_t *b; + int i; + vec3_t normal; + vec_t dist; + + b = AllocBrush (6); + b->numsides = 6; + for (i=0 ; i<3 ; i++) + { + VectorClear (normal); + normal[i] = 1; + dist = maxs[i]; + b->sides[i].planenum = FindFloatPlane (normal, dist); + + normal[i] = -1; + dist = -mins[i]; + b->sides[3+i].planenum = FindFloatPlane (normal, dist); + } + + CreateBrushWindings (b); + + return b; +} //end of the function BrushFromBounds +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BrushOutOfBounds(bspbrush_t *brush, vec3_t mins, vec3_t maxs, float epsilon) +{ + int i, j, n; + winding_t *w; + side_t *side; + + for (i = 0; i < brush->numsides; i++) + { + side = &brush->sides[i]; + w = side->winding; + for (j = 0; j < w->numpoints; j++) + { + for (n = 0; n < 3; n++) + { + if (w->p[j][n] < (mins[n] + epsilon) || w->p[j][n] > (maxs[n] - epsilon)) return true; + } //end for + } //end for + } //end for + return false; +} //end of the function BrushOutOfBounds +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +vec_t BrushVolume (bspbrush_t *brush) +{ + int i; + winding_t *w; + vec3_t corner; + vec_t d, area, volume; + plane_t *plane; + + if (!brush) return 0; + + // grab the first valid point as the corner + w = NULL; + for (i = 0; i < brush->numsides; i++) + { + w = brush->sides[i].winding; + if (w) break; + } //end for + if (!w) return 0; + VectorCopy (w->p[0], corner); + + // make tetrahedrons to all other faces + volume = 0; + for ( ; i < brush->numsides; i++) + { + w = brush->sides[i].winding; + if (!w) continue; + plane = &mapplanes[brush->sides[i].planenum]; + d = -(DotProduct (corner, plane->normal) - plane->dist); + area = WindingArea(w); + volume += d * area; + } //end for + + volume /= 3; + return volume; +} //end of the function BrushVolume +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int CountBrushList (bspbrush_t *brushes) +{ + int c; + + c = 0; + for ( ; brushes; brushes = brushes->next) c++; + return c; +} //end of the function CountBrushList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +node_t *AllocNode (void) +{ + node_t *node; + + node = GetMemory(sizeof(*node)); + memset (node, 0, sizeof(*node)); + if (numthreads == 1) + { + c_nodememory += MemorySize(node); + } //end if + return node; +} //end of the function AllocNode +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *AllocBrush (int numsides) +{ + bspbrush_t *bb; + int c; + + c = (int)&(((bspbrush_t *)0)->sides[numsides]); + bb = GetMemory(c); + memset (bb, 0, c); + if (numthreads == 1) + { + c_active_brushes++; + c_brushmemory += MemorySize(bb); + if (c_brushmemory > c_peak_brushmemory) + c_peak_brushmemory = c_brushmemory; + } //end if + return bb; +} //end of the function AllocBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeBrush (bspbrush_t *brushes) +{ + int i; + + for (i=0 ; inumsides ; i++) + if (brushes->sides[i].winding) + FreeWinding(brushes->sides[i].winding); + if (numthreads == 1) + { + c_active_brushes--; + c_brushmemory -= MemorySize(brushes); + if (c_brushmemory < 0) c_brushmemory = 0; + } //end if + FreeMemory(brushes); +} //end of the function FreeBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeBrushList (bspbrush_t *brushes) +{ + bspbrush_t *next; + + for ( ; brushes; brushes = next) + { + next = brushes->next; + + FreeBrush(brushes); + } //end for +} //end of the function FreeBrushList +//=========================================================================== +// Duplicates the brush, the sides, and the windings +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *CopyBrush (bspbrush_t *brush) +{ + bspbrush_t *newbrush; + int size; + int i; + + size = (int)&(((bspbrush_t *)0)->sides[brush->numsides]); + + newbrush = AllocBrush (brush->numsides); + memcpy (newbrush, brush, size); + + for (i=0 ; inumsides ; i++) + { + if (brush->sides[i].winding) + newbrush->sides[i].winding = CopyWinding (brush->sides[i].winding); + } + + return newbrush; +} //end of the function CopyBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +node_t *PointInLeaf (node_t *node, vec3_t point) +{ + vec_t d; + plane_t *plane; + + while (node->planenum != PLANENUM_LEAF) + { + plane = &mapplanes[node->planenum]; + d = DotProduct (point, plane->normal) - plane->dist; + if (d > 0) + node = node->children[0]; + else + node = node->children[1]; + } + + return node; +} //end of the function PointInLeaf +//=========================================================================== +// Returns PSIDE_FRONT, PSIDE_BACK, or PSIDE_BOTH +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#if 0 +int BoxOnPlaneSide (vec3_t mins, vec3_t maxs, plane_t *plane) +{ + int side; + int i; + vec3_t corners[2]; + vec_t dist1, dist2; + + // axial planes are easy + if (plane->type < 3) + { + side = 0; + if (maxs[plane->type] > plane->dist+PLANESIDE_EPSILON) + side |= PSIDE_FRONT; + if (mins[plane->type] < plane->dist-PLANESIDE_EPSILON) + side |= PSIDE_BACK; + return side; + } + + // create the proper leading and trailing verts for the box + + for (i=0 ; i<3 ; i++) + { + if (plane->normal[i] < 0) + { + corners[0][i] = mins[i]; + corners[1][i] = maxs[i]; + } + else + { + corners[1][i] = mins[i]; + corners[0][i] = maxs[i]; + } + } + + dist1 = DotProduct (plane->normal, corners[0]) - plane->dist; + dist2 = DotProduct (plane->normal, corners[1]) - plane->dist; + side = 0; + if (dist1 >= PLANESIDE_EPSILON) + side = PSIDE_FRONT; + if (dist2 < PLANESIDE_EPSILON) + side |= PSIDE_BACK; + + return side; +} +#else +int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, plane_t *p) +{ + float dist1, dist2; + int sides; + + // axial planes are easy + if (p->type < 3) + { + sides = 0; + if (emaxs[p->type] > p->dist+PLANESIDE_EPSILON) sides |= PSIDE_FRONT; + if (emins[p->type] < p->dist-PLANESIDE_EPSILON) sides |= PSIDE_BACK; + return sides; + } //end if + +// general case + switch (p->signbits) + { + case 0: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + break; + case 1: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + break; + case 2: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + break; + case 3: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + break; + case 4: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + break; + case 5: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + break; + case 6: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + break; + case 7: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + break; + default: + dist1 = dist2 = 0; // shut up compiler +// assert( 0 ); + break; + } + + sides = 0; + if (dist1 - p->dist >= PLANESIDE_EPSILON) sides = PSIDE_FRONT; + if (dist2 - p->dist < PLANESIDE_EPSILON) sides |= PSIDE_BACK; + +// assert(sides != 0); + + return sides; +} +#endif +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int QuickTestBrushToPlanenum (bspbrush_t *brush, int planenum, int *numsplits) +{ + int i, num; + plane_t *plane; + int s; + + *numsplits = 0; + + plane = &mapplanes[planenum]; + +#ifdef ME + //fast axial cases + if (plane->type < 3) + { + if (plane->dist + PLANESIDE_EPSILON < brush->mins[plane->type]) + return PSIDE_FRONT; + if (plane->dist - PLANESIDE_EPSILON > brush->maxs[plane->type]) + return PSIDE_BACK; + } //end if +#endif //ME*/ + + // if the brush actually uses the planenum, + // we can tell the side for sure + for (i = 0; i < brush->numsides; i++) + { + num = brush->sides[i].planenum; + if (num >= MAX_MAPFILE_PLANES) + Error ("bad planenum"); + if (num == planenum) + return PSIDE_BACK|PSIDE_FACING; + if (num == (planenum ^ 1) ) + return PSIDE_FRONT|PSIDE_FACING; + + } + + // box on plane side + s = BoxOnPlaneSide (brush->mins, brush->maxs, plane); + + // if both sides, count the visible faces split + if (s == PSIDE_BOTH) + { + *numsplits += 3; + } + + return s; +} //end of the function QuickTestBrushToPlanenum +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TestBrushToPlanenum (bspbrush_t *brush, int planenum, + int *numsplits, qboolean *hintsplit, int *epsilonbrush) +{ + int i, j, num; + plane_t *plane; + int s = 0; + winding_t *w; + vec_t d, d_front, d_back; + int front, back; + int type; + float dist; + + *numsplits = 0; + *hintsplit = false; + + plane = &mapplanes[planenum]; + +#ifdef ME + //fast axial cases + type = plane->type; + if (type < 3) + { + dist = plane->dist; + if (dist + PLANESIDE_EPSILON < brush->mins[type]) return PSIDE_FRONT; + if (dist - PLANESIDE_EPSILON > brush->maxs[type]) return PSIDE_BACK; + if (brush->mins[type] < dist - PLANESIDE_EPSILON && + brush->maxs[type] > dist + PLANESIDE_EPSILON) s = PSIDE_BOTH; + } //end if + + if (s != PSIDE_BOTH) +#endif //ME + { + // if the brush actually uses the planenum, + // we can tell the side for sure + for (i = 0; i < brush->numsides; i++) + { + num = brush->sides[i].planenum; + if (num >= MAX_MAPFILE_PLANES) Error ("bad planenum"); + if (num == planenum) + { + //we don't need to test this side plane again + brush->sides[i].flags |= SFL_TESTED; + return PSIDE_BACK|PSIDE_FACING; + } //end if + if (num == (planenum ^ 1) ) + { + //we don't need to test this side plane again + brush->sides[i].flags |= SFL_TESTED; + return PSIDE_FRONT|PSIDE_FACING; + } //end if + } //end for + + // box on plane side + s = BoxOnPlaneSide (brush->mins, brush->maxs, plane); + + if (s != PSIDE_BOTH) return s; + } //end if + + // if both sides, count the visible faces split + d_front = d_back = 0; + + for (i = 0; i < brush->numsides; i++) + { + if (brush->sides[i].texinfo == TEXINFO_NODE) + continue; // on node, don't worry about splits + if (!(brush->sides[i].flags & SFL_VISIBLE)) + continue; // we don't care about non-visible + w = brush->sides[i].winding; + if (!w) continue; + front = back = 0; + for (j = 0; j < w->numpoints; j++) + { + d = DotProduct(w->p[j], plane->normal) - plane->dist; + if (d > d_front) d_front = d; + if (d < d_back) d_back = d; + if (d > 0.1) // PLANESIDE_EPSILON) + front = 1; + if (d < -0.1) // PLANESIDE_EPSILON) + back = 1; + } //end for + if (front && back) + { +#ifdef SURF_SKIP + if ( !(brush->sides[i].surf & SURF_SKIP) ) +#endif + { + (*numsplits)++; + if (brush->sides[i].surf & SURF_HINT) + { + *hintsplit = true; + } //end if + } //end if + } //end if + } //end for + + if ( (d_front > 0.0 && d_front < 1.0) + || (d_back < 0.0 && d_back > -1.0) ) + (*epsilonbrush)++; + +#if 0 + if (*numsplits == 0) + { // didn't really need to be split + if (front) s = PSIDE_FRONT; + else if (back) s = PSIDE_BACK; + else s = 0; + } +#endif + + return s; +} //end of the function TestBrushToPlanenum +//=========================================================================== +// Returns true if the winding would be crunched out of +// existance by the vertex snapping. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#define EDGE_LENGTH 0.2 +qboolean WindingIsTiny (winding_t *w) +{ +#if 0 + if (WindingArea (w) < 1) + return true; + return false; +#else + int i, j; + vec_t len; + vec3_t delta; + int edges; + + edges = 0; + for (i=0 ; inumpoints ; i++) + { + j = i == w->numpoints - 1 ? 0 : i+1; + VectorSubtract (w->p[j], w->p[i], delta); + len = VectorLength (delta); + if (len > EDGE_LENGTH) + { + if (++edges == 3) + return false; + } + } + return true; +#endif +} //end of the function WindingIsTiny +//=========================================================================== +// Returns true if the winding still has one of the points +// from basewinding for plane +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean WindingIsHuge (winding_t *w) +{ + int i, j; + + for (i=0 ; inumpoints ; i++) + { + for (j=0 ; j<3 ; j++) + if (w->p[i][j] < -BOGUS_RANGE+1 || w->p[i][j] > BOGUS_RANGE-1) + return true; + } + return false; +} //end of the function WindingIsHuge +//=========================================================================== +// creates a leaf out of the given nodes with the given brushes +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void LeafNode(node_t *node, bspbrush_t *brushes) +{ + bspbrush_t *b; + int i; + + node->side = NULL; + node->planenum = PLANENUM_LEAF; + node->contents = 0; + + for (b = brushes; b; b = b->next) + { + // if the brush is solid and all of its sides are on nodes, + // it eats everything + if (b->original->contents & CONTENTS_SOLID) + { + for (i=0 ; inumsides ; i++) + if (b->sides[i].texinfo != TEXINFO_NODE) + break; + if (i == b->numsides) + { + node->contents = CONTENTS_SOLID; + break; + } //end if + } //end if + node->contents |= b->original->contents; + } //end for + + if (create_aas) + { + node->expansionbboxes = 0; + node->contents = 0; + for (b = brushes; b; b = b->next) + { + node->expansionbboxes |= b->original->expansionbbox; + node->contents |= b->original->contents; + if (b->original->modelnum) + node->modelnum = b->original->modelnum; + } //end for + if (node->contents & CONTENTS_SOLID) + { + if (node->expansionbboxes != cfg.allpresencetypes) + { + node->contents &= ~CONTENTS_SOLID; + } //end if + } //end if + } //end if + + node->brushlist = brushes; +} //end of the function LeafNode +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void CheckPlaneAgainstParents (int pnum, node_t *node) +{ + node_t *p; + + for (p = node->parent; p; p = p->parent) + { + if (p->planenum == pnum) Error("Tried parent"); + } //end for +} //end of the function CheckPlaneAgainstParants +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean CheckPlaneAgainstVolume (int pnum, node_t *node) +{ + bspbrush_t *front, *back; + qboolean good; + + SplitBrush (node->volume, pnum, &front, &back); + + good = (front && back); + + if (front) FreeBrush (front); + if (back) FreeBrush (back); + + return good; +} //end of the function CheckPlaneAgaintsVolume +//=========================================================================== +// Using a hueristic, choses one of the sides out of the brushlist +// to partition the brushes with. +// Returns NULL if there are no valid planes to split with.. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +side_t *SelectSplitSide (bspbrush_t *brushes, node_t *node) +{ + int value, bestvalue; + bspbrush_t *brush, *test; + side_t *side, *bestside; + int i, pass, numpasses; + int pnum; + int s; + int front, back, both, facing, splits; + int bsplits; + int bestsplits; + int epsilonbrush; + qboolean hintsplit = false; + + bestside = NULL; + bestvalue = -99999; + bestsplits = 0; + + // the search order goes: visible-structural, visible-detail, + // nonvisible-structural, nonvisible-detail. + // If any valid plane is available in a pass, no further + // passes will be tried. + numpasses = 2; + for (pass = 0; pass < numpasses; pass++) + { + for (brush = brushes; brush; brush = brush->next) + { + // only check detail the second pass +// if ( (pass & 1) && !(brush->original->contents & CONTENTS_DETAIL) ) +// continue; +// if ( !(pass & 1) && (brush->original->contents & CONTENTS_DETAIL) ) +// continue; + for (i = 0; i < brush->numsides; i++) + { + side = brush->sides + i; +// if (side->flags & SFL_BEVEL) +// continue; // never use a bevel as a spliter + if (!side->winding) + continue; // nothing visible, so it can't split + if (side->texinfo == TEXINFO_NODE) + continue; // allready a node splitter + if (side->flags & SFL_TESTED) + continue; // we allready have metrics for this plane +// if (side->surf & SURF_SKIP) +// continue; // skip surfaces are never chosen + +// if (!(side->flags & SFL_VISIBLE) && (pass < 2)) +// continue; // only check visible faces on first pass + + if ((side->flags & SFL_CURVE) && (pass < 1)) + continue; // only check curves the second pass + + pnum = side->planenum; + pnum &= ~1; // allways use positive facing plane + + CheckPlaneAgainstParents (pnum, node); + + if (!CheckPlaneAgainstVolume (pnum, node)) + continue; // would produce a tiny volume + + front = 0; + back = 0; + both = 0; + facing = 0; + splits = 0; + epsilonbrush = 0; + + //inner loop: optimize + for (test = brushes; test; test = test->next) + { + s = TestBrushToPlanenum (test, pnum, &bsplits, &hintsplit, &epsilonbrush); + + splits += bsplits; +// if (bsplits && (s&PSIDE_FACING) ) +// Error ("PSIDE_FACING with splits"); + + test->testside = s; + // + if (s & PSIDE_FACING) facing++; + if (s & PSIDE_FRONT) front++; + if (s & PSIDE_BACK) back++; + if (s == PSIDE_BOTH) both++; + } //end for + + // give a value estimate for using this plane + value = 5*facing - 5*splits - abs(front-back); +// value = -5*splits; +// value = 5*facing - 5*splits; + if (mapplanes[pnum].type < 3) + value+=5; // axial is better + + value -= epsilonbrush * 1000; // avoid! + + // never split a hint side except with another hint + if (hintsplit && !(side->surf & SURF_HINT) ) + value = -9999999; + + // save off the side test so we don't need + // to recalculate it when we actually seperate + // the brushes + if (value > bestvalue) + { + bestvalue = value; + bestside = side; + bestsplits = splits; + for (test = brushes; test ; test = test->next) + test->side = test->testside; + } //end if + } //end for + } //end for (brush = brushes; + + // if we found a good plane, don't bother trying any + // other passes + if (bestside) + { + if (pass > 1) + { + if (numthreads == 1) c_nonvis++; + } + if (pass > 0) node->detail_seperator = true; // not needed for vis + break; + } //end if + } //end for (pass = 0; + + // + // clear all the tested flags we set + // + for (brush = brushes ; brush ; brush=brush->next) + { + for (i = 0; i < brush->numsides; i++) + { + brush->sides[i].flags &= ~SFL_TESTED; + } //end for + } //end for + + return bestside; +} //end of the function SelectSplitSide +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BrushMostlyOnSide (bspbrush_t *brush, plane_t *plane) +{ + int i, j; + winding_t *w; + vec_t d, max; + int side; + + max = 0; + side = PSIDE_FRONT; + for (i=0 ; inumsides ; i++) + { + w = brush->sides[i].winding; + if (!w) + continue; + for (j=0 ; jnumpoints ; j++) + { + d = DotProduct (w->p[j], plane->normal) - plane->dist; + if (d > max) + { + max = d; + side = PSIDE_FRONT; + } + if (-d > max) + { + max = -d; + side = PSIDE_BACK; + } + } + } + return side; +} //end of the function BrushMostlyOnSide +//=========================================================================== +// Generates two new brushes, leaving the original +// unchanged +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void SplitBrush (bspbrush_t *brush, int planenum, + bspbrush_t **front, bspbrush_t **back) +{ + bspbrush_t *b[2]; + int i, j; + winding_t *w, *cw[2], *midwinding; + plane_t *plane, *plane2; + side_t *s, *cs; + float d, d_front, d_back; + + *front = *back = NULL; + plane = &mapplanes[planenum]; + + // check all points + d_front = d_back = 0; + for (i=0 ; inumsides ; i++) + { + w = brush->sides[i].winding; + if (!w) + continue; + for (j=0 ; jnumpoints ; j++) + { + d = DotProduct (w->p[j], plane->normal) - plane->dist; + if (d > 0 && d > d_front) + d_front = d; + if (d < 0 && d < d_back) + d_back = d; + } + } + + if (d_front < 0.2) // PLANESIDE_EPSILON) + { // only on back + *back = CopyBrush (brush); + return; + } + if (d_back > -0.2) // PLANESIDE_EPSILON) + { // only on front + *front = CopyBrush (brush); + return; + } + + // create a new winding from the split plane + + w = BaseWindingForPlane (plane->normal, plane->dist); + for (i=0 ; inumsides && w ; i++) + { + plane2 = &mapplanes[brush->sides[i].planenum ^ 1]; + ChopWindingInPlace (&w, plane2->normal, plane2->dist, 0); // PLANESIDE_EPSILON); + } + + if (!w || WindingIsTiny(w)) + { // the brush isn't really split + int side; + + side = BrushMostlyOnSide (brush, plane); + if (side == PSIDE_FRONT) + *front = CopyBrush (brush); + if (side == PSIDE_BACK) + *back = CopyBrush (brush); + //free a possible winding + if (w) FreeWinding(w); + return; + } + + if (WindingIsHuge (w)) + { + Log_Write("WARNING: huge winding\n"); + } + + midwinding = w; + + // split it for real + + for (i=0 ; i<2 ; i++) + { + b[i] = AllocBrush (brush->numsides+1); + b[i]->original = brush->original; + } + + // split all the current windings + + for (i=0 ; inumsides ; i++) + { + s = &brush->sides[i]; + w = s->winding; + if (!w) + continue; + ClipWindingEpsilon (w, plane->normal, plane->dist, + 0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1]); + for (j=0 ; j<2 ; j++) + { + if (!cw[j]) + continue; +#if 0 + if (WindingIsTiny (cw[j])) + { + FreeWinding (cw[j]); + continue; + } +#endif + cs = &b[j]->sides[b[j]->numsides]; + b[j]->numsides++; + *cs = *s; +// cs->planenum = s->planenum; +// cs->texinfo = s->texinfo; +// cs->original = s->original; + cs->winding = cw[j]; + cs->flags &= ~SFL_TESTED; + } + } + + + // see if we have valid polygons on both sides + + for (i=0 ; i<2 ; i++) + { + BoundBrush (b[i]); + for (j=0 ; j<3 ; j++) + { + if (b[i]->mins[j] < -MAX_MAP_BOUNDS || b[i]->maxs[j] > MAX_MAP_BOUNDS) + { + Log_Write("bogus brush after clip"); + break; + } + } + + if (b[i]->numsides < 3 || j < 3) + { + FreeBrush (b[i]); + b[i] = NULL; + } + } + + if ( !(b[0] && b[1]) ) + { + if (!b[0] && !b[1]) + Log_Write("split removed brush\r\n"); + else + Log_Write("split not on both sides\r\n"); + if (b[0]) + { + FreeBrush (b[0]); + *front = CopyBrush (brush); + } + if (b[1]) + { + FreeBrush (b[1]); + *back = CopyBrush (brush); + } + return; + } + + // add the midwinding to both sides + for (i=0 ; i<2 ; i++) + { + cs = &b[i]->sides[b[i]->numsides]; + b[i]->numsides++; + + cs->planenum = planenum^i^1; + cs->texinfo = TEXINFO_NODE; //never use these sides as splitters + cs->flags &= ~SFL_VISIBLE; + cs->flags &= ~SFL_TESTED; + if (i==0) + cs->winding = CopyWinding (midwinding); + else + cs->winding = midwinding; + } + +{ + vec_t v1; + int i; + + for (i = 0; i < 2; i++) + { + v1 = BrushVolume (b[i]); + if (v1 < 1.0) + { + FreeBrush(b[i]); + b[i] = NULL; + //Log_Write("tiny volume after clip"); + } + } + if (!b[0] && !b[1]) + { + Log_Write("two tiny brushes\r\n"); + } //end if +} + + *front = b[0]; + *back = b[1]; +} //end of the function SplitBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void SplitBrushList (bspbrush_t *brushes, + node_t *node, bspbrush_t **front, bspbrush_t **back) +{ + bspbrush_t *brush, *newbrush, *newbrush2; + side_t *side; + int sides; + int i; + + *front = *back = NULL; + + for (brush = brushes; brush; brush = brush->next) + { + sides = brush->side; + + if (sides == PSIDE_BOTH) + { // split into two brushes + SplitBrush (brush, node->planenum, &newbrush, &newbrush2); + if (newbrush) + { + newbrush->next = *front; + *front = newbrush; + } //end if + if (newbrush2) + { + newbrush2->next = *back; + *back = newbrush2; + } //end if + continue; + } //end if + + newbrush = CopyBrush (brush); + + // if the planenum is actualy a part of the brush + // find the plane and flag it as used so it won't be tried + // as a splitter again + if (sides & PSIDE_FACING) + { + for (i=0 ; inumsides ; i++) + { + side = newbrush->sides + i; + if ( (side->planenum& ~1) == node->planenum) + side->texinfo = TEXINFO_NODE; + } //end for + } //end if + if (sides & PSIDE_FRONT) + { + newbrush->next = *front; + *front = newbrush; + continue; + } //end if + if (sides & PSIDE_BACK) + { + newbrush->next = *back; + *back = newbrush; + continue; + } //end if + } //end for +} //end of the function SplitBrushList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void CheckBrushLists(bspbrush_t *brushlist1, bspbrush_t *brushlist2) +{ + bspbrush_t *brush1, *brush2; + + for (brush1 = brushlist1; brush1; brush1 = brush1->next) + { + for (brush2 = brushlist2; brush2; brush2 = brush2->next) + { + assert(brush1 != brush2); + } //end for + } //end for +} //end of the function CheckBrushLists +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int numrecurse = 0; + +node_t *BuildTree_r (node_t *node, bspbrush_t *brushes) +{ + node_t *newnode; + side_t *bestside; + int i, totalmem; + bspbrush_t *children[2]; + + qprintf("\r%6d", numrecurse); + numrecurse++; + + if (numthreads == 1) + { + totalmem = WindingMemory() + c_nodememory + c_brushmemory; + if (totalmem > c_peak_totalbspmemory) + c_peak_totalbspmemory = totalmem; + c_nodes++; + } //endif + + if (drawflag) + DrawBrushList(brushes, node); + + // find the best plane to use as a splitter + bestside = SelectSplitSide (brushes, node); + if (!bestside) + { + // leaf node + node->side = NULL; + node->planenum = -1; + LeafNode(node, brushes); + if (node->contents & CONTENTS_SOLID) c_solidleafnodes++; + if (create_aas) + { + //free up memory!!! + FreeBrushList(node->brushlist); + node->brushlist = NULL; + //free the node volume brush + if (node->volume) + { + FreeBrush(node->volume); + node->volume = NULL; + } //end if + } //end if + return node; + } //end if + + // this is a splitplane node + node->side = bestside; + node->planenum = bestside->planenum & ~1; // always use front facing + + //split the brush list in two for both children + SplitBrushList (brushes, node, &children[0], &children[1]); + //free the old brush list + FreeBrushList (brushes); + + // allocate children before recursing + for (i = 0; i < 2; i++) + { + newnode = AllocNode (); + newnode->parent = node; + node->children[i] = newnode; + } //end for + + //split the volume brush of the node for the children + SplitBrush (node->volume, node->planenum, &node->children[0]->volume, + &node->children[1]->volume); + + if (create_aas) + { + //free the volume brush + if (node->volume) + { + FreeBrush(node->volume); + node->volume = NULL; + } //end if + } //end if + // recursively process children + for (i = 0; i < 2; i++) + { + node->children[i] = BuildTree_r(node->children[i], children[i]); + } //end for + + return node; +} //end of the function BuildTree_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +node_t *firstnode; //first node in the list +node_t *lastnode; //last node in the list +int nodelistsize; //number of nodes in the list +int use_nodequeue = 0; //use nodequeue, otherwise a node stack is used +int numwaiting = 0; + +void (*AddNodeToList)(node_t *node); + +//add the node to the front of the node list +//(effectively using a node stack) +void AddNodeToStack(node_t *node) +{ + ThreadLock(); + + node->next = firstnode; + firstnode = node; + if (!lastnode) lastnode = node; + nodelistsize++; + + ThreadUnlock(); + // + ThreadSemaphoreIncrease(1); +} //end of the function AddNodeToStack +//add the node to the end of the node list +//(effectively using a node queue) +void AddNodeToQueue(node_t *node) +{ + ThreadLock(); + + node->next = NULL; + if (lastnode) lastnode->next = node; + else firstnode = node; + lastnode = node; + nodelistsize++; + + ThreadUnlock(); + // + ThreadSemaphoreIncrease(1); +} //end of the function AddNodeToQueue +//get the first node from the front of the node list +node_t *NextNodeFromList(void) +{ + node_t *node; + + ThreadLock(); + numwaiting++; + if (!firstnode) + { + if (numwaiting >= GetNumThreads()) ThreadSemaphoreIncrease(GetNumThreads()); + } //end if + ThreadUnlock(); + + ThreadSemaphoreWait(); + + ThreadLock(); + + numwaiting--; + + node = firstnode; + if (firstnode) + { + firstnode = firstnode->next; + nodelistsize--; + } //end if + if (!firstnode) lastnode = NULL; + + ThreadUnlock(); + + return node; +} //end of the function NextNodeFromList +//returns the size of the node list +int NodeListSize(void) +{ + int size; + + ThreadLock(); + size = nodelistsize; + ThreadUnlock(); + + return size; +} //end of the function NodeListSize +// +void IncreaseNodeCounter(void) +{ + ThreadLock(); + //if (verbose) printf("\r%6d", numrecurse++); + qprintf("\r%6d", numrecurse++); + //qprintf("\r%6d %d, %5d ", numrecurse++, GetNumThreads(), nodelistsize); + ThreadUnlock(); +} //end of the function IncreaseNodeCounter +//thread function, gets nodes from the nodelist and processes them +void BuildTreeThread(int threadid) +{ + node_t *newnode, *node; + side_t *bestside; + int i, totalmem; + bspbrush_t *brushes; + + for (node = NextNodeFromList(); node; ) + { + //if the nodelist isn't empty try to add another thread + //if (NodeListSize() > 10) AddThread(BuildTreeThread); + //display the number of nodes processed so far + if (numthreads == 1) + IncreaseNodeCounter(); + + brushes = node->brushlist; + + if (numthreads == 1) + { + totalmem = WindingMemory() + c_nodememory + c_brushmemory; + if (totalmem > c_peak_totalbspmemory) + { + c_peak_totalbspmemory = totalmem; + } //end if + c_nodes++; + } //endif + + if (drawflag) + { + DrawBrushList(brushes, node); + } //end if + + if (cancelconversion) + { + bestside = NULL; + } //end if + else + { + // find the best plane to use as a splitter + bestside = SelectSplitSide(brushes, node); + } //end else + //if there's no split side left + if (!bestside) + { + //create a leaf out of the node + LeafNode(node, brushes); + if (node->contents & CONTENTS_SOLID) c_solidleafnodes++; + if (create_aas) + { + //free up memory!!! + FreeBrushList(node->brushlist); + node->brushlist = NULL; + } //end if + //free the node volume brush (it is not used anymore) + if (node->volume) + { + FreeBrush(node->volume); + node->volume = NULL; + } //end if + node = NextNodeFromList(); + continue; + } //end if + + // this is a splitplane node + node->side = bestside; + node->planenum = bestside->planenum & ~1; //always use front facing + + //allocate children + for (i = 0; i < 2; i++) + { + newnode = AllocNode(); + newnode->parent = node; + node->children[i] = newnode; + } //end for + + //split the brush list in two for both children + SplitBrushList(brushes, node, &node->children[0]->brushlist, &node->children[1]->brushlist); + + CheckBrushLists(node->children[0]->brushlist, node->children[1]->brushlist); + //free the old brush list + FreeBrushList(brushes); + node->brushlist = NULL; + + //split the volume brush of the node for the children + SplitBrush(node->volume, node->planenum, &node->children[0]->volume, + &node->children[1]->volume); + + if (!node->children[0]->volume || !node->children[1]->volume) + { + Error("child without volume brush"); + } //end if + + //free the volume brush + if (node->volume) + { + FreeBrush(node->volume); + node->volume = NULL; + } //end if + //add both children to the node list + //AddNodeToList(node->children[0]); + AddNodeToList(node->children[1]); + node = node->children[0]; + } //end while + RemoveThread(threadid); +} //end of the function BuildTreeThread +//=========================================================================== +// build the bsp tree using a node list +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BuildTree(tree_t *tree) +{ + int i; + + firstnode = NULL; + lastnode = NULL; + //use a node queue or node stack + if (use_nodequeue) AddNodeToList = AddNodeToQueue; + else AddNodeToList = AddNodeToStack; + //setup thread locking + ThreadSetupLock(); + ThreadSetupSemaphore(); + numwaiting = 0; + // + Log_Print("%6d threads max\n", numthreads); + if (use_nodequeue) Log_Print("breadth first bsp building\n"); + else Log_Print("depth first bsp building\n"); + qprintf("%6d splits", 0); + //add the first node to the list + AddNodeToList(tree->headnode); + //start the threads + for (i = 0; i < numthreads; i++) + AddThread(BuildTreeThread); + //wait for all added threads to be finished + WaitForAllThreadsFinished(); + //shutdown the thread locking + ThreadShutdownLock(); + ThreadShutdownSemaphore(); +} //end of the function BuildTree +//=========================================================================== +// The incoming brush list will be freed before exiting +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tree_t *BrushBSP(bspbrush_t *brushlist, vec3_t mins, vec3_t maxs) +{ + int i, c_faces, c_nonvisfaces, c_brushes; + bspbrush_t *b; + node_t *node; + tree_t *tree; + vec_t volume; +// vec3_t point; + + Log_Print("-------- Brush BSP ---------\n"); + + tree = Tree_Alloc(); + + c_faces = 0; + c_nonvisfaces = 0; + c_brushes = 0; + c_totalsides = 0; + for (b = brushlist; b; b = b->next) + { + c_brushes++; + + volume = BrushVolume(b); + if (volume < microvolume) + { + Log_Print("WARNING: entity %i, brush %i: microbrush\n", + b->original->entitynum, b->original->brushnum); + } //end if + + for (i=0 ; inumsides ; i++) + { + if (b->sides[i].flags & SFL_BEVEL) + continue; + if (!b->sides[i].winding) + continue; + if (b->sides[i].texinfo == TEXINFO_NODE) + continue; + if (b->sides[i].flags & SFL_VISIBLE) + { + c_faces++; + } //end if + else + { + c_nonvisfaces++; + //if (create_aas) b->sides[i].texinfo = TEXINFO_NODE; + } //end if + } //end for + c_totalsides += b->numsides; + + AddPointToBounds (b->mins, tree->mins, tree->maxs); + AddPointToBounds (b->maxs, tree->mins, tree->maxs); + } //end for + + Log_Print("%6i brushes\n", c_brushes); + Log_Print("%6i visible faces\n", c_faces); + Log_Print("%6i nonvisible faces\n", c_nonvisfaces); + Log_Print("%6i total sides\n", c_totalsides); + + c_active_brushes = c_brushes; + c_nodememory = 0; + c_brushmemory = 0; + c_peak_brushmemory = 0; + + c_nodes = 0; + c_nonvis = 0; + node = AllocNode (); + + //volume of first node (head node) + node->volume = BrushFromBounds (mins, maxs); + // + tree->headnode = node; + //just get some statistics and the mins/maxs of the node + numrecurse = 0; +// qprintf("%6d splits", numrecurse); + + tree->headnode->brushlist = brushlist; + BuildTree(tree); + + //build the bsp tree with the start node from the brushlist +// node = BuildTree_r(node, brushlist); + + //if the conversion is cancelled + if (cancelconversion) return tree; + + qprintf("\n"); + Log_Write("%6d splits\r\n", numrecurse); +// Log_Print("%6i visible nodes\n", c_nodes/2 - c_nonvis); +// Log_Print("%6i nonvis nodes\n", c_nonvis); +// Log_Print("%6i leaves\n", (c_nodes+1)/2); +// Log_Print("%6i solid leaf nodes\n", c_solidleafnodes); +// Log_Print("%6i active brushes\n", c_active_brushes); + if (numthreads == 1) + { +// Log_Print("%6i KB of node memory\n", c_nodememory >> 10); +// Log_Print("%6i KB of brush memory\n", c_brushmemory >> 10); +// Log_Print("%6i KB of peak brush memory\n", c_peak_brushmemory >> 10); +// Log_Print("%6i KB of winding memory\n", WindingMemory() >> 10); +// Log_Print("%6i KB of peak winding memory\n", WindingPeakMemory() >> 10); + Log_Print("%6i KB of peak total bsp memory\n", c_peak_totalbspmemory >> 10); + } //end if + + /* + point[0] = 1485; + point[1] = 956.125; + point[2] = 352.125; + node = PointInLeaf(tree->headnode, point); + if (node->planenum != PLANENUM_LEAF) + { + Log_Print("node not a leaf\n"); + } //end if + Log_Print("at %f %f %f:\n", point[0], point[1], point[2]); + PrintContents(node->contents); + Log_Print("node->expansionbboxes = %d\n", node->expansionbboxes); + //*/ + return tree; +} //end of the function BrushBSP + diff --git a/code/bspc/bspc.c b/code/bspc/bspc.c new file mode 100644 index 00000000..e19076ea --- /dev/null +++ b/code/bspc/bspc.c @@ -0,0 +1,991 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +#if defined(WIN32) || defined(_WIN32) +#include +#include +#include +#include +#else +#include +#include +#include +#include +#endif +#include "qbsp.h" +#include "l_mem.h" +#include "../botlib/aasfile.h" +#include "../botlib/be_aas_cluster.h" +#include "../botlib/be_aas_optimize.h" +#include "aas_create.h" +#include "aas_store.h" +#include "aas_file.h" +#include "aas_cfg.h" +#include "be_aas_bspc.h" + +extern int use_nodequeue; //brushbsp.c +extern int calcgrapplereach; //be_aas_reach.c + +float subdivide_size = 240; +char source[1024]; +char name[1024]; +vec_t microvolume = 1.0; +char outbase[32]; +int entity_num; +aas_settings_t aassettings; + +qboolean noprune; //don't prune nodes (bspc.c) +qboolean glview; //create a gl view +qboolean nodetail; //don't use detail brushes (map.c) +qboolean fulldetail; //use but don't mark detail brushes (map.c) +qboolean onlyents; //only process the entities (bspc.c) +qboolean nomerge; //don't merge bsp node faces (faces.c) +qboolean nowater; //don't use the water brushes (map.c) +qboolean nocsg; //don't carve intersecting brushes (bspc.c) +qboolean noweld; //use unique face vertexes (faces.c) +qboolean noshare; //don't share bsp edges (faces.c) +qboolean nosubdiv; //don't subdivide bsp node faces (faces.c) +qboolean notjunc; //don't create tjunctions (edge melting) (faces.c) +qboolean optimize; //enable optimisation +qboolean leaktest; //perform a leak test +qboolean verboseentities; +qboolean freetree; //free the bsp tree when not needed anymore +qboolean create_aas; //create an .AAS file +qboolean nobrushmerge; //don't merge brushes +qboolean lessbrushes; //create less brushes instead of correct texture placement +qboolean cancelconversion; //true if the conversion is being cancelled +qboolean noliquids; //no liquids when writing map file +qboolean forcesidesvisible; //force all brush sides to be visible when loaded from bsp +qboolean capsule_collision = 0; + +/* +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ProcessWorldModel (void) +{ + entity_t *e; + tree_t *tree; + qboolean leaked; + int brush_start, brush_end; + + e = &entities[entity_num]; + + brush_start = e->firstbrush; + brush_end = brush_start + e->numbrushes; + leaked = false; + + //process the whole world in one time + tree = ProcessWorldBrushes(brush_start, brush_end); + //create the bsp tree portals + MakeTreePortals(tree); + //mark all leafs that can be reached by entities + if (FloodEntities(tree)) + { + FillOutside(tree->headnode); + } //end if + else + { + Log_Print("**** leaked ****\n"); + leaked = true; + LeakFile(tree); + if (leaktest) + { + Log_Print("--- MAP LEAKED ---\n"); + exit(0); + } //end if + } //end else + + MarkVisibleSides (tree, brush_start, brush_end); + + FloodAreas (tree); + +#ifndef ME + if (glview) WriteGLView(tree, source); +#endif + MakeFaces(tree->headnode); + FixTjuncs(tree->headnode); + + //NOTE: Never prune the nodes because the portals + // are screwed when prunning is done and as + // a result portal writing will crash + //if (!noprune) PruneNodes(tree->headnode); + + WriteBSP(tree->headnode); + + if (!leaked) WritePortalFile(tree); + + Tree_Free(tree); +} //end of the function ProcessWorldModel +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ProcessSubModel (void) +{ + entity_t *e; + int start, end; + tree_t *tree; + bspbrush_t *list; + vec3_t mins, maxs; + + e = &entities[entity_num]; + + start = e->firstbrush; + end = start + e->numbrushes; + + mins[0] = mins[1] = mins[2] = -4096; + maxs[0] = maxs[1] = maxs[2] = 4096; + list = MakeBspBrushList(start, end, mins, maxs); + if (!nocsg) list = ChopBrushes (list); + tree = BrushBSP (list, mins, maxs); + MakeTreePortals (tree); + MarkVisibleSides (tree, start, end); + MakeFaces (tree->headnode); + FixTjuncs (tree->headnode); + WriteBSP (tree->headnode); + Tree_Free(tree); +} //end of the function ProcessSubModel +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ProcessModels (void) +{ + BeginBSPFile(); + + for (entity_num = 0; entity_num < num_entities; entity_num++) + { + if (!entities[entity_num].numbrushes) + continue; + + Log_Print("############### model %i ###############\n", nummodels); + BeginModel(); + if (entity_num == 0) ProcessWorldModel(); + else ProcessSubModel(); + EndModel(); + + if (!verboseentities) + verbose = false; // don't bother printing submodels + } //end for + EndBSPFile(); +} //end of the function ProcessModels +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Win_Map2Bsp(char *bspfilename) +{ + double start, end; + char path[1024]; + + start = I_FloatTime(); + + ThreadSetDefault(); + //yeah sure Carmack + //numthreads = 1; // multiple threads aren't helping... + + strcpy(source, ExpandArg(bspfilename)); + StripExtension(source); + + //delete portal and line files + sprintf(path, "%s.prt", source); + remove(path); + sprintf(path, "%s.lin", source); + remove(path); + + strcpy(name, ExpandArg(bspfilename)); + DefaultExtension(name, ".map"); // might be .reg + + Q2_AllocMaxBSP(); + // + SetModelNumbers(); + SetLightStyles(); + ProcessModels(); + //write the BSP + Q2_WriteBSPFile(bspfilename); + + Q2_FreeMaxBSP(); + + end = I_FloatTime(); + Log_Print("%5.0f seconds elapsed\n", end-start); +} //end of the function Win_Map2Bsp +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Map2Bsp(char *mapfilename, char *outputfilename) +{ + double start, end; + char path[1024]; + + start = I_FloatTime (); + + ThreadSetDefault (); + //yeah sure Carmack + //numthreads = 1; //multiple threads aren't helping... + //SetQdirFromPath(bspfilename); + + strcpy(source, ExpandArg(mapfilename)); + StripExtension(source); + + // delete portal and line files + sprintf(path, "%s.prt", source); + remove(path); + sprintf(path, "%s.lin", source); + remove(path); + + strcpy(name, ExpandArg(mapfilename)); + DefaultExtension(name, ".map"); // might be .reg + + // + // if onlyents, just grab the entites and resave + // + if (onlyents) + { + char out[1024]; + + Q2_AllocMaxBSP(); + sprintf (out, "%s.bsp", source); + Q2_LoadBSPFile(out, 0, 0); + num_entities = 0; + + Q2_LoadMapFile(name); + SetModelNumbers(); + SetLightStyles(); + + Q2_UnparseEntities(); + + Q2_WriteBSPFile(out); + // + Q2_FreeMaxBSP(); + } //end if + else + { + // + // start from scratch + // + Q2_AllocMaxBSP(); + //load the map + Q2_LoadMapFile(name); + //create the .bsp file + SetModelNumbers(); + SetLightStyles(); + ProcessModels(); + //write the BSP + Q2_WriteBSPFile(outputfilename); + // + Q2_FreeMaxBSP(); + } //end else + + end = I_FloatTime(); + Log_Print("%5.0f seconds elapsed\n", end-start); +} //end of the function Map2Bsp +*/ +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AASOuputFile(quakefile_t *qf, char *outputpath, char *filename) +{ + char ext[MAX_PATH]; + + // + if (strlen(outputpath)) + { + strcpy(filename, outputpath); + //append the bsp file base + AppendPathSeperator(filename, MAX_PATH); + ExtractFileBase(qf->origname, &filename[strlen(filename)]); + //append .aas + strcat(filename, ".aas"); + return; + } //end if + // + ExtractFileExtension(qf->filename, ext); + if (!stricmp(ext, "pk3") || !stricmp(ext, "pak") || !stricmp(ext, "sin")) + { + strcpy(filename, qf->filename); + while(strlen(filename) && + filename[strlen(filename)-1] != '\\' && + filename[strlen(filename)-1] != '/') + { + filename[strlen(filename)-1] = '\0'; + } //end while + strcat(filename, "maps"); + if (access(filename, 0x04)) CreatePath(filename); + //append the bsp file base + AppendPathSeperator(filename, MAX_PATH); + ExtractFileBase(qf->origname, &filename[strlen(filename)]); + //append .aas + strcat(filename, ".aas"); + } //end if + else + { + strcpy(filename, qf->filename); + while(strlen(filename) && + filename[strlen(filename)-1] != '.') + { + filename[strlen(filename)-1] = '\0'; + } //end while + strcat(filename, "aas"); + } //end else +} //end of the function AASOutputFile +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void CreateAASFilesForAllBSPFiles(char *quakepath) +{ +#if defined(WIN32)|defined(_WIN32) + WIN32_FIND_DATA filedata; + HWND handle; + struct _stat statbuf; +#else + glob_t globbuf; + struct stat statbuf; + int j; +#endif + int done; + char filter[_MAX_PATH], bspfilter[_MAX_PATH], aasfilter[_MAX_PATH]; + char aasfile[_MAX_PATH], buf[_MAX_PATH], foldername[_MAX_PATH]; + quakefile_t *qf, *qf2, *files, *bspfiles, *aasfiles; + + strcpy(filter, quakepath); + AppendPathSeperator(filter, sizeof(filter)); + strcat(filter, "*"); + +#if defined(WIN32)|defined(_WIN32) + handle = FindFirstFile(filter, &filedata); + done = (handle == INVALID_HANDLE_VALUE); + while(!done) + { + _splitpath(filter, foldername, NULL, NULL, NULL); + _splitpath(filter, NULL, &foldername[strlen(foldername)], NULL, NULL); + AppendPathSeperator(foldername, _MAX_PATH); + strcat(foldername, filedata.cFileName); + _stat(foldername, &statbuf); +#else + glob(filter, 0, NULL, &globbuf); + for (j = 0; j < globbuf.gl_pathc; j++) + { + strcpy(foldername, globbuf.gl_pathv[j]); + stat(foldername, &statbuf); +#endif + //if it is a folder + if (statbuf.st_mode & S_IFDIR) + { + // + AppendPathSeperator(foldername, sizeof(foldername)); + //get all the bsp files + strcpy(bspfilter, foldername); + strcat(bspfilter, "maps/*.bsp"); + files = FindQuakeFiles(bspfilter); + strcpy(bspfilter, foldername); + strcat(bspfilter, "*.pk3/maps/*.bsp"); + bspfiles = FindQuakeFiles(bspfilter); + for (qf = bspfiles; qf; qf = qf->next) if (!qf->next) break; + if (qf) qf->next = files; + else bspfiles = files; + //get all the aas files + strcpy(aasfilter, foldername); + strcat(aasfilter, "maps/*.aas"); + files = FindQuakeFiles(aasfilter); + strcpy(aasfilter, foldername); + strcat(aasfilter, "*.pk3/maps/*.aas"); + aasfiles = FindQuakeFiles(aasfilter); + for (qf = aasfiles; qf; qf = qf->next) if (!qf->next) break; + if (qf) qf->next = files; + else aasfiles = files; + // + for (qf = bspfiles; qf; qf = qf->next) + { + sprintf(aasfile, "%s/%s", qf->pakfile, qf->origname); + Log_Print("found %s\n", aasfile); + strcpy(&aasfile[strlen(aasfile)-strlen(".bsp")], ".aas"); + for (qf2 = aasfiles; qf2; qf2 = qf2->next) + { + sprintf(buf, "%s/%s", qf2->pakfile, qf2->origname); + if (!stricmp(aasfile, buf)) + { + Log_Print("found %s\n", buf); + break; + } //end if + } //end for + } //end for + } //end if +#if defined(WIN32)|defined(_WIN32) + //find the next file + done = !FindNextFile(handle, &filedata); + } //end while +#else + } //end for + globfree(&globbuf); +#endif +} //end of the function CreateAASFilesForAllBSPFiles +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +quakefile_t *GetArgumentFiles(int argc, char *argv[], int *i, char *ext) +{ + quakefile_t *qfiles, *lastqf, *qf; + int j; + char buf[1024]; + + qfiles = NULL; + lastqf = NULL; + for (; (*i)+1 < argc && argv[(*i)+1][0] != '-'; (*i)++) + { + strcpy(buf, argv[(*i)+1]); + for (j = strlen(buf)-1; j >= strlen(buf)-4; j--) + if (buf[j] == '.') break; + if (j >= strlen(buf)-4) + strcpy(&buf[j+1], ext); + qf = FindQuakeFiles(buf); + if (!qf) continue; + if (lastqf) lastqf->next = qf; + else qfiles = qf; + lastqf = qf; + while(lastqf->next) lastqf = lastqf->next; + } //end for + return qfiles; +} //end of the function GetArgumentFiles +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== + +#define COMP_BSP2MAP 1 +#define COMP_BSP2AAS 2 +#define COMP_REACH 3 +#define COMP_CLUSTER 4 +#define COMP_AASOPTIMIZE 5 +#define COMP_AASINFO 6 + +int main (int argc, char **argv) +{ + int i, comp = 0; + char outputpath[MAX_PATH] = ""; + char filename[MAX_PATH] = "unknown"; + quakefile_t *qfiles, *qf; + double start_time; + + myargc = argc; + myargv = argv; + + start_time = I_FloatTime(); + + Log_Open("bspc.log"); //open a log file + Log_Print("BSPC version "BSPC_VERSION", %s %s\n", __DATE__, __TIME__); + + DefaultCfg(); + for (i = 1; i < argc; i++) + { + if (!stricmp(argv[i],"-threads")) + { + if (i + 1 >= argc) {i = 0; break;} + numthreads = atoi(argv[++i]); + Log_Print("threads = %d\n", numthreads); + } //end if + else if (!stricmp(argv[i], "-noverbose")) + { + Log_Print("verbose = false\n"); + verbose = false; + } //end else if + else if (!stricmp(argv[i], "-nocsg")) + { + Log_Print("nocsg = true\n"); + nocsg = true; + } //end else if + else if (!stricmp(argv[i], "-optimize")) + { + Log_Print("optimize = true\n"); + optimize = true; + } //end else if + /* + else if (!stricmp(argv[i],"-glview")) + { + glview = true; + } //end else if + else if (!stricmp(argv[i], "-draw")) + { + Log_Print("drawflag = true\n"); + drawflag = true; + } //end else if + else if (!stricmp(argv[i], "-noweld")) + { + Log_Print("noweld = true\n"); + noweld = true; + } //end else if + else if (!stricmp(argv[i], "-noshare")) + { + Log_Print("noshare = true\n"); + noshare = true; + } //end else if + else if (!stricmp(argv[i], "-notjunc")) + { + Log_Print("notjunc = true\n"); + notjunc = true; + } //end else if + else if (!stricmp(argv[i], "-nowater")) + { + Log_Print("nowater = true\n"); + nowater = true; + } //end else if + else if (!stricmp(argv[i], "-noprune")) + { + Log_Print("noprune = true\n"); + noprune = true; + } //end else if + else if (!stricmp(argv[i], "-nomerge")) + { + Log_Print("nomerge = true\n"); + nomerge = true; + } //end else if + else if (!stricmp(argv[i], "-nosubdiv")) + { + Log_Print("nosubdiv = true\n"); + nosubdiv = true; + } //end else if + else if (!stricmp(argv[i], "-nodetail")) + { + Log_Print("nodetail = true\n"); + nodetail = true; + } //end else if + else if (!stricmp(argv[i], "-fulldetail")) + { + Log_Print("fulldetail = true\n"); + fulldetail = true; + } //end else if + else if (!stricmp(argv[i], "-onlyents")) + { + Log_Print("onlyents = true\n"); + onlyents = true; + } //end else if + else if (!stricmp(argv[i], "-micro")) + { + if (i + 1 >= argc) {i = 0; break;} + microvolume = atof(argv[++i]); + Log_Print("microvolume = %f\n", microvolume); + } //end else if + else if (!stricmp(argv[i], "-leaktest")) + { + Log_Print("leaktest = true\n"); + leaktest = true; + } //end else if + else if (!stricmp(argv[i], "-verboseentities")) + { + Log_Print("verboseentities = true\n"); + verboseentities = true; + } //end else if + else if (!stricmp(argv[i], "-chop")) + { + if (i + 1 >= argc) {i = 0; break;} + subdivide_size = atof(argv[++i]); + Log_Print("subdivide_size = %f\n", subdivide_size); + } //end else if + else if (!stricmp (argv[i], "-tmpout")) + { + strcpy (outbase, "/tmp"); + Log_Print("temp output\n"); + } //end else if + */ +#ifdef ME + else if (!stricmp(argv[i], "-freetree")) + { + freetree = true; + Log_Print("freetree = true\n"); + } //end else if + else if (!stricmp(argv[i], "-grapplereach")) + { + calcgrapplereach = true; + Log_Print("grapplereach = true\n"); + } //end else if + else if (!stricmp(argv[i], "-nobrushmerge")) + { + nobrushmerge = true; + Log_Print("nobrushmerge = true\n"); + } //end else if + else if (!stricmp(argv[i], "-noliquids")) + { + noliquids = true; + Log_Print("noliquids = true\n"); + } //end else if + else if (!stricmp(argv[i], "-forcesidesvisible")) + { + forcesidesvisible = true; + Log_Print("forcesidesvisible = true\n"); + } //end else if + else if (!stricmp(argv[i], "-output")) + { + if (i + 1 >= argc) {i = 0; break;} + if (access(argv[i+1], 0x04)) Warning("the folder %s does not exist", argv[i+1]); + strcpy(outputpath, argv[++i]); + } //end else if + else if (!stricmp(argv[i], "-breadthfirst")) + { + use_nodequeue = true; + Log_Print("breadthfirst = true\n"); + } //end else if + else if (!stricmp(argv[i], "-capsule")) + { + capsule_collision = true; + Log_Print("capsule_collision = true\n"); + } //end else if + else if (!stricmp(argv[i], "-cfg")) + { + if (i + 1 >= argc) {i = 0; break;} + if (!LoadCfgFile(argv[++i])) + exit(0); + } //end else if + else if (!stricmp(argv[i], "-bsp2map")) + { + if (i + 1 >= argc) {i = 0; break;} + comp = COMP_BSP2MAP; + qfiles = GetArgumentFiles(argc, argv, &i, "bsp"); + } //end else if + else if (!stricmp(argv[i], "-bsp2aas")) + { + if (i + 1 >= argc) {i = 0; break;} + comp = COMP_BSP2AAS; + qfiles = GetArgumentFiles(argc, argv, &i, "bsp"); + } //end else if + else if (!stricmp(argv[i], "-aasall")) + { + if (i + 1 >= argc) {i = 0; break;} + CreateAASFilesForAllBSPFiles(argv[++i]); + } //end else if + else if (!stricmp(argv[i], "-reach")) + { + if (i + 1 >= argc) {i = 0; break;} + comp = COMP_REACH; + qfiles = GetArgumentFiles(argc, argv, &i, "bsp"); + } //end else if + else if (!stricmp(argv[i], "-cluster")) + { + if (i + 1 >= argc) {i = 0; break;} + comp = COMP_CLUSTER; + qfiles = GetArgumentFiles(argc, argv, &i, "bsp"); + } //end else if + else if (!stricmp(argv[i], "-aasinfo")) + { + if (i + 1 >= argc) {i = 0; break;} + comp = COMP_AASINFO; + qfiles = GetArgumentFiles(argc, argv, &i, "aas"); + } //end else if + else if (!stricmp(argv[i], "-aasopt")) + { + if (i + 1 >= argc) {i = 0; break;} + comp = COMP_AASOPTIMIZE; + qfiles = GetArgumentFiles(argc, argv, &i, "aas"); + } //end else if +#endif //ME + else + { + Log_Print("unknown parameter %s\n", argv[i]); + break; + } //end else + } //end for + + //if there are parameters and there's no mismatch in one of the parameters + if (argc > 1 && i == argc) + { + switch(comp) + { + case COMP_BSP2MAP: + { + if (!qfiles) Log_Print("no files found\n"); + for (qf = qfiles; qf; qf = qf->next) + { + //copy the output path + strcpy(filename, outputpath); + //append the bsp file base + AppendPathSeperator(filename, MAX_PATH); + ExtractFileBase(qf->origname, &filename[strlen(filename)]); + //append .map + strcat(filename, ".map"); + // + Log_Print("bsp2map: %s to %s\n", qf->origname, filename); + if (qf->type != QFILETYPE_BSP) Warning("%s is probably not a BSP file\n", qf->origname); + // + LoadMapFromBSP(qf); + //write the map file + WriteMapFile(filename); + } //end for + break; + } //end case + case COMP_BSP2AAS: + { + if (!qfiles) Log_Print("no files found\n"); + for (qf = qfiles; qf; qf = qf->next) + { + AASOuputFile(qf, outputpath, filename); + // + Log_Print("bsp2aas: %s to %s\n", qf->origname, filename); + if (qf->type != QFILETYPE_BSP) Warning("%s is probably not a BSP file\n", qf->origname); + //set before map loading + create_aas = 1; + LoadMapFromBSP(qf); + //create the AAS file + AAS_Create(filename); + //if it's a Quake3 map calculate the reachabilities and clusters + if (loadedmaptype == MAPTYPE_QUAKE3) AAS_CalcReachAndClusters(qf); + // + if (optimize) AAS_Optimize(); + // + //write out the stored AAS file + if (!AAS_WriteAASFile(filename)) + { + Error("error writing %s\n", filename); + } //end if + //deallocate memory + AAS_FreeMaxAAS(); + } //end for + break; + } //end case + case COMP_REACH: + { + if (!qfiles) Log_Print("no files found\n"); + for (qf = qfiles; qf; qf = qf->next) + { + AASOuputFile(qf, outputpath, filename); + // + Log_Print("reach: %s to %s\n", qf->origname, filename); + if (qf->type != QFILETYPE_BSP) Warning("%s is probably not a BSP file\n", qf->origname); + //if the AAS file exists in the output directory + if (!access(filename, 0x04)) + { + if (!AAS_LoadAASFile(filename, 0, 0)) + { + Error("error loading aas file %s\n", filename); + } //end if + //assume it's a Quake3 BSP file + loadedmaptype = MAPTYPE_QUAKE3; + } //end if + else + { + Warning("AAS file %s not found in output folder\n", filename); + Log_Print("creating %s...\n", filename); + //set before map loading + create_aas = 1; + LoadMapFromBSP(qf); + //create the AAS file + AAS_Create(filename); + } //end else + //if it's a Quake3 map calculate the reachabilities and clusters + if (loadedmaptype == MAPTYPE_QUAKE3) + { + AAS_CalcReachAndClusters(qf); + } //end if + // + if (optimize) AAS_Optimize(); + //write out the stored AAS file + if (!AAS_WriteAASFile(filename)) + { + Error("error writing %s\n", filename); + } //end if + //deallocate memory + AAS_FreeMaxAAS(); + } //end for + break; + } //end case + case COMP_CLUSTER: + { + if (!qfiles) Log_Print("no files found\n"); + for (qf = qfiles; qf; qf = qf->next) + { + AASOuputFile(qf, outputpath, filename); + // + Log_Print("cluster: %s to %s\n", qf->origname, filename); + if (qf->type != QFILETYPE_BSP) Warning("%s is probably not a BSP file\n", qf->origname); + //if the AAS file exists in the output directory + if (!access(filename, 0x04)) + { + if (!AAS_LoadAASFile(filename, 0, 0)) + { + Error("error loading aas file %s\n", filename); + } //end if + //assume it's a Quake3 BSP file + loadedmaptype = MAPTYPE_QUAKE3; + //if it's a Quake3 map calculate the clusters + if (loadedmaptype == MAPTYPE_QUAKE3) + { + aasworld.numclusters = 0; + AAS_InitBotImport(); + AAS_InitClustering(); + } //end if + } //end if + else + { + Warning("AAS file %s not found in output folder\n", filename); + Log_Print("creating %s...\n", filename); + //set before map loading + create_aas = 1; + LoadMapFromBSP(qf); + //create the AAS file + AAS_Create(filename); + //if it's a Quake3 map calculate the reachabilities and clusters + if (loadedmaptype == MAPTYPE_QUAKE3) AAS_CalcReachAndClusters(qf); + } //end else + // + if (optimize) AAS_Optimize(); + //write out the stored AAS file + if (!AAS_WriteAASFile(filename)) + { + Error("error writing %s\n", filename); + } //end if + //deallocate memory + AAS_FreeMaxAAS(); + } //end for + break; + } //end case + case COMP_AASOPTIMIZE: + { + if (!qfiles) Log_Print("no files found\n"); + for (qf = qfiles; qf; qf = qf->next) + { + AASOuputFile(qf, outputpath, filename); + // + Log_Print("optimizing: %s to %s\n", qf->origname, filename); + if (qf->type != QFILETYPE_AAS) Warning("%s is probably not a AAS file\n", qf->origname); + // + AAS_InitBotImport(); + // + if (!AAS_LoadAASFile(qf->filename, qf->offset, qf->length)) + { + Error("error loading aas file %s\n", qf->filename); + } //end if + AAS_Optimize(); + //write out the stored AAS file + if (!AAS_WriteAASFile(filename)) + { + Error("error writing %s\n", filename); + } //end if + //deallocate memory + AAS_FreeMaxAAS(); + } //end for + break; + } //end case + case COMP_AASINFO: + { + if (!qfiles) Log_Print("no files found\n"); + for (qf = qfiles; qf; qf = qf->next) + { + AASOuputFile(qf, outputpath, filename); + // + Log_Print("aas info for: %s\n", filename); + if (qf->type != QFILETYPE_AAS) Warning("%s is probably not a AAS file\n", qf->origname); + // + AAS_InitBotImport(); + // + if (!AAS_LoadAASFile(qf->filename, qf->offset, qf->length)) + { + Error("error loading aas file %s\n", qf->filename); + } //end if + AAS_ShowTotals(); + } //end for + } //end case + default: + { + Log_Print("don't know what to do\n"); + break; + } //end default + } //end switch + } //end if + else + { + Log_Print("Usage: bspc [- [- ...]]\n" +#if defined(WIN32) || defined(_WIN32) + "Example 1: bspc -bsp2aas d:\\quake3\\baseq3\\maps\\mymap?.bsp\n" + "Example 2: bspc -bsp2aas d:\\quake3\\baseq3\\pak0.pk3\\maps/q3dm*.bsp\n" +#else + "Example 1: bspc -bsp2aas /quake3/baseq3/maps/mymap?.bsp\n" + "Example 2: bspc -bsp2aas /quake3/baseq3/pak0.pk3/maps/q3dm*.bsp\n" +#endif + "\n" + "Switches:\n" + //" bsp2map <[pakfilter/]filter.bsp> = convert BSP to MAP\n" + //" aasall = create AAS files for all BSPs\n" + " bsp2aas <[pakfilter/]filter.bsp> = convert BSP to AAS\n" + " reach = compute reachability & clusters\n" + " cluster = compute clusters\n" + " aasopt = optimize aas file\n" + " aasinfo = show AAS file info\n" + " output = set output path\n" + " threads = set number of threads to X\n" + " cfg = use this cfg file\n" + " optimize = enable optimization\n" + " noverbose = disable verbose output\n" + " breadthfirst = breadth first bsp building\n" + " nobrushmerge = don't merge brushes\n" + " noliquids = don't write liquids to map\n" + " freetree = free the bsp tree\n" + " nocsg = disables brush chopping\n" + " forcesidesvisible = force all sides to be visible\n" + " grapplereach = calculate grapple reachabilities\n" + +/* " glview = output a GL view\n" + " draw = enables drawing\n" + " noweld = disables weld\n" + " noshare = disables sharing\n" + " notjunc = disables juncs\n" + " nowater = disables water brushes\n" + " noprune = disables node prunes\n" + " nomerge = disables face merging\n" + " nosubdiv = disables subdeviding\n" + " nodetail = disables detail brushes\n" + " fulldetail = enables full detail\n" + " onlyents = only compile entities with bsp\n" + " micro \n" + " = sets the micro volume to the given float\n" + " leaktest = perform a leak test\n" + " verboseentities\n" + " = enable entity verbose mode\n" + " chop \n" + " = sets the subdivide size to the given float\n"*/ + "\n"); + } //end else + Log_Print("BSPC run time is %5.0f seconds\n", I_FloatTime() - start_time); + Log_Close(); //close the log file + return 0; +} //end of the function main + diff --git a/code/bspc/bspc.vcproj b/code/bspc/bspc.vcproj new file mode 100644 index 00000000..4d2ad474 --- /dev/null +++ b/code/bspc/bspc.vcproj @@ -0,0 +1,1777 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/bspc/cfgq3.c b/code/bspc/cfgq3.c new file mode 100644 index 00000000..c0598ae8 --- /dev/null +++ b/code/bspc/cfgq3.c @@ -0,0 +1,84 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ +//=========================================================================== +// BSPC configuration file +// Quake3 +//=========================================================================== + +#define PRESENCE_NONE 1 +#define PRESENCE_NORMAL 2 +#define PRESENCE_CROUCH 4 + +bbox //30x30x56 +{ + presencetype PRESENCE_NORMAL + flags 0x0000 + mins {-15, -15, -24} + maxs {15, 15, 32} +} //end bbox + +bbox //30x30x40 +{ + presencetype PRESENCE_CROUCH + flags 0x0001 + mins {-15, -15, -24} + maxs {15, 15, 16} +} //end bbox + +settings +{ + phys_gravitydirection {0, 0, -1} + phys_friction 6 + phys_stopspeed 100 + phys_gravity 800 + phys_waterfriction 1 + phys_watergravity 400 + phys_maxvelocity 320 + phys_maxwalkvelocity 320 + phys_maxcrouchvelocity 100 + phys_maxswimvelocity 150 + phys_maxacceleration 2200 + phys_airaccelerate 0 + phys_maxstep 18 + phys_maxsteepness 0.7 + phys_maxwaterjump 19 + phys_maxbarrier 33 + phys_jumpvel 270 + phys_falldelta5 40 + phys_falldelta10 60 + rs_waterjump 400 + rs_teleport 50 + rs_barrierjump 100 + rs_startcrouch 300 + rs_startgrapple 500 + rs_startwalkoffledge 70 + rs_startjump 300 + rs_rocketjump 500 + rs_bfgjump 500 + rs_jumppad 250 + rs_aircontrolledjumppad 300 + rs_funcbob 300 + rs_startelevator 50 + rs_falldamage5 300 + rs_falldamage10 500 + rs_maxjumpfallheight 450 +} //end settings diff --git a/code/bspc/csg.c b/code/bspc/csg.c new file mode 100644 index 00000000..5223cadf --- /dev/null +++ b/code/bspc/csg.c @@ -0,0 +1,1007 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" + +/* + +tag all brushes with original contents +brushes may contain multiple contents +there will be no brush overlap after csg phase + +*/ + +int minplanenums[3]; +int maxplanenums[3]; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void CheckBSPBrush(bspbrush_t *brush) +{ + int i, j; + plane_t *plane1, *plane2; + + //check if the brush is convex... flipped planes make a brush non-convex + for (i = 0; i < brush->numsides; i++) + { + for (j = 0; j < brush->numsides; j++) + { + if (i == j) continue; + plane1 = &mapplanes[brush->sides[i].planenum]; + plane2 = &mapplanes[brush->sides[j].planenum]; + // + if (WindingsNonConvex(brush->sides[i].winding, + brush->sides[j].winding, + plane1->normal, plane2->normal, + plane1->dist, plane2->dist)) + { + Log_Print("non convex brush"); + break; + } //end if + } //end for + } //end for + BoundBrush(brush); + //check for out of bound brushes + for (i = 0; i < 3; i++) + { + if (brush->mins[i] < -MAX_MAP_BOUNDS || brush->maxs[i] > MAX_MAP_BOUNDS) + { + Log_Print("brush: bounds out of range\n"); + Log_Print("ob->mins[%d] = %f, ob->maxs[%d] = %f\n", i, brush->mins[i], i, brush->maxs[i]); + break; + } //end if + if (brush->mins[i] > MAX_MAP_BOUNDS || brush->maxs[i] < -MAX_MAP_BOUNDS) + { + Log_Print("brush: no visible sides on brush\n"); + Log_Print("ob->mins[%d] = %f, ob->maxs[%d] = %f\n", i, brush->mins[i], i, brush->maxs[i]); + break; + } //end if + } //end for +} //end of the function CheckBSPBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void BSPBrushWindings(bspbrush_t *brush) +{ + int i, j; + winding_t *w; + plane_t *plane; + + for (i = 0; i < brush->numsides; i++) + { + plane = &mapplanes[brush->sides[i].planenum]; + w = BaseWindingForPlane(plane->normal, plane->dist); + for (j = 0; j < brush->numsides && w; j++) + { + if (i == j) continue; + plane = &mapplanes[brush->sides[j].planenum^1]; + ChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON); + } //end for + brush->sides[i].winding = w; + } //end for +} //end of the function BSPBrushWindings +//=========================================================================== +// NOTE: can't keep brush->original intact +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *TryMergeBrushes(bspbrush_t *brush1, bspbrush_t *brush2) +{ + int i, j, k, n, shared; + side_t *side1, *side2, *cs; + plane_t *plane1, *plane2; + bspbrush_t *newbrush; + + //check for bounding box overlapp + for (i = 0; i < 3; i++) + { + if (brush1->mins[i] > brush2->maxs[i] + 2 + || brush1->maxs[i] < brush2->mins[i] - 2) + { + return NULL; + } //end if + } //end for + // + shared = 0; + //check if the brush is convex... flipped planes make a brush non-convex + for (i = 0; i < brush1->numsides; i++) + { + side1 = &brush1->sides[i]; + //don't check the "shared" sides + for (k = 0; k < brush2->numsides; k++) + { + side2 = &brush2->sides[k]; + if (side1->planenum == (side2->planenum^1)) + { + shared++; + //there may only be ONE shared side + if (shared > 1) return NULL; + break; + } //end if + } //end for + if (k < brush2->numsides) continue; + // + for (j = 0; j < brush2->numsides; j++) + { + side2 = &brush2->sides[j]; + //don't check the "shared" sides + for (n = 0; n < brush1->numsides; n++) + { + side1 = &brush1->sides[n]; + if (side1->planenum == (side2->planenum^1)) break; + } //end for + if (n < brush1->numsides) continue; + // + side1 = &brush1->sides[i]; + //if the side is in the same plane + //* + if (side1->planenum == side2->planenum) + { + if (side1->texinfo != TEXINFO_NODE && + side2->texinfo != TEXINFO_NODE && + side1->texinfo != side2->texinfo) return NULL; + continue; + } //end if + // + plane1 = &mapplanes[side1->planenum]; + plane2 = &mapplanes[side2->planenum]; + // + if (WindingsNonConvex(side1->winding, side2->winding, + plane1->normal, plane2->normal, + plane1->dist, plane2->dist)) + { + return NULL; + } //end if + } //end for + } //end for + newbrush = AllocBrush(brush1->numsides + brush2->numsides); + newbrush->original = brush1->original; + newbrush->numsides = 0; + //newbrush->side = brush1->side; //brush contents + //fix texinfos for sides lying in the same plane + for (i = 0; i < brush1->numsides; i++) + { + side1 = &brush1->sides[i]; + // + for (n = 0; n < brush2->numsides; n++) + { + side2 = &brush2->sides[n]; + //if both sides are in the same plane get the texinfo right + if (side1->planenum == side2->planenum) + { + if (side1->texinfo == TEXINFO_NODE) side1->texinfo = side2->texinfo; + if (side2->texinfo == TEXINFO_NODE) side2->texinfo = side1->texinfo; + } //end if + } //end for + } //end for + // + for (i = 0; i < brush1->numsides; i++) + { + side1 = &brush1->sides[i]; + //don't add the "shared" sides + for (n = 0; n < brush2->numsides; n++) + { + side2 = &brush2->sides[n]; + if (side1->planenum == (side2->planenum ^ 1)) break; + } //end for + if (n < brush2->numsides) continue; + // + for (n = 0; n < newbrush->numsides; n++) + { + cs = &newbrush->sides[n]; + if (cs->planenum == side1->planenum) + { + Log_Print("brush duplicate plane\n"); + break; + } //end if + } //end if + if (n < newbrush->numsides) continue; + //add this side + cs = &newbrush->sides[newbrush->numsides]; + newbrush->numsides++; + *cs = *side1; + } //end for + for (j = 0; j < brush2->numsides; j++) + { + side2 = &brush2->sides[j]; + for (n = 0; n < brush1->numsides; n++) + { + side1 = &brush1->sides[n]; + //if the side is in the same plane + if (side2->planenum == side1->planenum) break; + //don't add the "shared" sides + if (side2->planenum == (side1->planenum ^ 1)) break; + } //end for + if (n < brush1->numsides) continue; + // + for (n = 0; n < newbrush->numsides; n++) + { + cs = &newbrush->sides[n]; + if (cs->planenum == side2->planenum) + { + Log_Print("brush duplicate plane\n"); + break; + } //end if + } //end if + if (n < newbrush->numsides) continue; + //add this side + cs = &newbrush->sides[newbrush->numsides]; + newbrush->numsides++; + *cs = *side2; + } //end for + BSPBrushWindings(newbrush); + BoundBrush(newbrush); + CheckBSPBrush(newbrush); + return newbrush; +} //end of the function TryMergeBrushes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *MergeBrushes(bspbrush_t *brushlist) +{ + int nummerges, merged; + bspbrush_t *b1, *b2, *tail, *newbrush, *newbrushlist; + bspbrush_t *lastb2; + + if (!brushlist) return NULL; + + qprintf("%5d brushes merged", nummerges = 0); + do + { + for (tail = brushlist; tail; tail = tail->next) + { + if (!tail->next) break; + } //end for + merged = 0; + newbrushlist = NULL; + for (b1 = brushlist; b1; b1 = brushlist) + { + lastb2 = b1; + for (b2 = b1->next; b2; b2 = b2->next) + { + //if the brushes don't have the same contents + if (b1->original->contents != b2->original->contents || + b1->original->expansionbbox != b2->original->expansionbbox) newbrush = NULL; + else newbrush = TryMergeBrushes(b1, b2); + if (newbrush) + { + tail->next = newbrush; + lastb2->next = b2->next; + brushlist = brushlist->next; + FreeBrush(b1); + FreeBrush(b2); + for (tail = brushlist; tail; tail = tail->next) + { + if (!tail->next) break; + } //end for + merged++; + qprintf("\r%5d", nummerges++); + break; + } //end if + lastb2 = b2; + } //end for + //if b1 can't be merged with any of the other brushes + if (!b2) + { + brushlist = brushlist->next; + //keep b1 + b1->next = newbrushlist; + newbrushlist = b1; + } //end else + } //end for + brushlist = newbrushlist; + } while(merged); + qprintf("\n"); + return newbrushlist; +} //end of the function MergeBrushes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void SplitBrush2 (bspbrush_t *brush, int planenum, + bspbrush_t **front, bspbrush_t **back) +{ + SplitBrush (brush, planenum, front, back); +#if 0 + if (*front && (*front)->sides[(*front)->numsides-1].texinfo == -1) + (*front)->sides[(*front)->numsides-1].texinfo = (*front)->sides[0].texinfo; // not -1 + if (*back && (*back)->sides[(*back)->numsides-1].texinfo == -1) + (*back)->sides[(*back)->numsides-1].texinfo = (*back)->sides[0].texinfo; // not -1 +#endif +} //end of the function SplitBrush2 +//=========================================================================== +// Returns a list of brushes that remain after B is subtracted from A. +// May by empty if A is contained inside B. +// The originals are undisturbed. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *SubtractBrush (bspbrush_t *a, bspbrush_t *b) +{ // a - b = out (list) + int i; + bspbrush_t *front, *back; + bspbrush_t *out, *in; + + in = a; + out = NULL; + for (i = 0; i < b->numsides && in; i++) + { + SplitBrush2(in, b->sides[i].planenum, &front, &back); + if (in != a) FreeBrush(in); + if (front) + { // add to list + front->next = out; + out = front; + } //end if + in = back; + } //end for + if (in) + { + FreeBrush (in); + } //end if + else + { // didn't really intersect + FreeBrushList (out); + return a; + } //end else + return out; +} //end of the function SubtractBrush +//=========================================================================== +// Returns a single brush made up by the intersection of the +// two provided brushes, or NULL if they are disjoint. +// +// The originals are undisturbed. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *IntersectBrush (bspbrush_t *a, bspbrush_t *b) +{ + int i; + bspbrush_t *front, *back; + bspbrush_t *in; + + in = a; + for (i=0 ; inumsides && in ; i++) + { + SplitBrush2(in, b->sides[i].planenum, &front, &back); + if (in != a) FreeBrush(in); + if (front) FreeBrush(front); + in = back; + } //end for + + if (in == a) return NULL; + + in->next = NULL; + return in; +} //end of the function IntersectBrush +//=========================================================================== +// Returns true if the two brushes definately do not intersect. +// There will be false negatives for some non-axial combinations. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean BrushesDisjoint (bspbrush_t *a, bspbrush_t *b) +{ + int i, j; + + // check bounding boxes + for (i=0 ; i<3 ; i++) + if (a->mins[i] >= b->maxs[i] + || a->maxs[i] <= b->mins[i]) + return true; // bounding boxes don't overlap + + // check for opposing planes + for (i=0 ; inumsides ; i++) + { + for (j=0 ; jnumsides ; j++) + { + if (a->sides[i].planenum == + (b->sides[j].planenum^1) ) + return true; // opposite planes, so not touching + } + } + + return false; // might intersect +} //end of the function BrushesDisjoint +//=========================================================================== +// Returns a content word for the intersection of two brushes. +// Some combinations will generate a combination (water + clip), +// but most will be the stronger of the two contents. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int IntersectionContents (int c1, int c2) +{ + int out; + + out = c1 | c2; + + if (out & CONTENTS_SOLID) out = CONTENTS_SOLID; + + return out; +} //end of the function IntersectionContents +//=========================================================================== +// Any planes shared with the box edge will be set to no texinfo +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *ClipBrushToBox(bspbrush_t *brush, vec3_t clipmins, vec3_t clipmaxs) +{ + int i, j; + bspbrush_t *front, *back; + int p; + + for (j=0 ; j<2 ; j++) + { + if (brush->maxs[j] > clipmaxs[j]) + { + SplitBrush (brush, maxplanenums[j], &front, &back); + if (front) + FreeBrush (front); + brush = back; + if (!brush) + return NULL; + } + if (brush->mins[j] < clipmins[j]) + { + SplitBrush (brush, minplanenums[j], &front, &back); + if (back) + FreeBrush (back); + brush = front; + if (!brush) + return NULL; + } + } + + // remove any colinear faces + + for (i=0 ; inumsides ; i++) + { + p = brush->sides[i].planenum & ~1; + if (p == maxplanenums[0] || p == maxplanenums[1] + || p == minplanenums[0] || p == minplanenums[1]) + { + brush->sides[i].texinfo = TEXINFO_NODE; + brush->sides[i].flags &= ~SFL_VISIBLE; + } + } + return brush; +} //end of the function ClipBrushToBox +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *MakeBspBrushList(int startbrush, int endbrush, + vec3_t clipmins, vec3_t clipmaxs) +{ + mapbrush_t *mb; + bspbrush_t *brushlist, *newbrush; + int i, j; + int c_faces; + int c_brushes; + int numsides; + int vis; + vec3_t normal; + float dist; + + for (i=0 ; i<2 ; i++) + { + VectorClear (normal); + normal[i] = 1; + dist = clipmaxs[i]; + maxplanenums[i] = FindFloatPlane(normal, dist); + dist = clipmins[i]; + minplanenums[i] = FindFloatPlane(normal, dist); + } + + brushlist = NULL; + c_faces = 0; + c_brushes = 0; + + for (i=startbrush ; inumsides; + if (!numsides) + continue; + + // make sure the brush has at least one face showing + vis = 0; + for (j=0 ; joriginal_sides[j].flags & SFL_VISIBLE) && mb->original_sides[j].winding) + vis++; +#if 0 + if (!vis) + continue; // no faces at all +#endif + // if the brush is outside the clip area, skip it + for (j=0 ; j<3 ; j++) + if (mb->mins[j] >= clipmaxs[j] + || mb->maxs[j] <= clipmins[j]) + break; + if (j != 3) + continue; + + // + // make a copy of the brush + // + newbrush = AllocBrush (mb->numsides); + newbrush->original = mb; + newbrush->numsides = mb->numsides; + memcpy (newbrush->sides, mb->original_sides, numsides*sizeof(side_t)); + for (j=0 ; jsides[j].winding) + newbrush->sides[j].winding = CopyWinding (newbrush->sides[j].winding); + if (newbrush->sides[j].surf & SURF_HINT) + newbrush->sides[j].flags |= SFL_VISIBLE; // hints are always visible + } + VectorCopy (mb->mins, newbrush->mins); + VectorCopy (mb->maxs, newbrush->maxs); + + // + // carve off anything outside the clip box + // + newbrush = ClipBrushToBox (newbrush, clipmins, clipmaxs); + if (!newbrush) + continue; + + c_faces += vis; + c_brushes++; + + newbrush->next = brushlist; + brushlist = newbrush; + } + + return brushlist; +} //end of the function MakeBspBrushList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *AddBrushListToTail (bspbrush_t *list, bspbrush_t *tail) +{ + bspbrush_t *walk, *next; + + for (walk=list ; walk ; walk=next) + { // add to end of list + next = walk->next; + walk->next = NULL; + tail->next = walk; + tail = walk; + } //end for + return tail; +} //end of the function AddBrushListToTail +//=========================================================================== +// Builds a new list that doesn't hold the given brush +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *CullList(bspbrush_t *list, bspbrush_t *skip1) +{ + bspbrush_t *newlist; + bspbrush_t *next; + + newlist = NULL; + + for ( ; list ; list = next) + { + next = list->next; + if (list == skip1) + { + FreeBrush (list); + continue; + } + list->next = newlist; + newlist = list; + } + return newlist; +} //end of the function CullList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +/* +void WriteBrushMap(char *name, bspbrush_t *list) +{ + FILE *f; + side_t *s; + int i; + winding_t *w; + + Log_Print("writing %s\n", name); + f = fopen (name, "wb"); + if (!f) + Error ("Can't write %s\b", name); + + fprintf (f, "{\n\"classname\" \"worldspawn\"\n"); + + for ( ; list ; list=list->next ) + { + fprintf (f, "{\n"); + for (i=0,s=list->sides ; inumsides ; i++,s++) + { + w = BaseWindingForPlane (mapplanes[s->planenum].normal, mapplanes[s->planenum].dist); + + fprintf (f,"( %i %i %i ) ", (int)w->p[0][0], (int)w->p[0][1], (int)w->p[0][2]); + fprintf (f,"( %i %i %i ) ", (int)w->p[1][0], (int)w->p[1][1], (int)w->p[1][2]); + fprintf (f,"( %i %i %i ) ", (int)w->p[2][0], (int)w->p[2][1], (int)w->p[2][2]); + + fprintf (f, "%s 0 0 0 1 1\n", texinfo[s->texinfo].texture); + FreeWinding (w); + } + fprintf (f, "}\n"); + } + fprintf (f, "}\n"); + + fclose (f); +} //end of the function WriteBrushMap +*/ +//=========================================================================== +// Returns true if b1 is allowed to bite b2 +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean BrushGE (bspbrush_t *b1, bspbrush_t *b2) +{ +#ifdef ME + if (create_aas) + { + if (b1->original->expansionbbox != b2->original->expansionbbox) + { + return false; + } //end if + //never have something else bite a ladder brush + //never have a ladder brush bite something else +#ifdef CONTENTS_LADDER + if ( (b1->original->contents & CONTENTS_LADDER) + && !(b2->original->contents & CONTENTS_LADDER)) + { + return false; + } //end if +#endif + } //end if +#endif //ME + // detail brushes never bite structural brushes + if ( (b1->original->contents & CONTENTS_DETAIL) + && !(b2->original->contents & CONTENTS_DETAIL) ) + { + return false; + } //end if + if (b1->original->contents & CONTENTS_SOLID) + { + return true; + } //end if + return false; +} //end of the function BrushGE +//=========================================================================== +// Carves any intersecting solid brushes into the minimum number +// of non-intersecting brushes. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *ChopBrushes (bspbrush_t *head) +{ + bspbrush_t *b1, *b2, *next; + bspbrush_t *tail; + bspbrush_t *keep; + bspbrush_t *sub, *sub2; + int c1, c2; + int num_csg_iterations; + + Log_Print("-------- Brush CSG ---------\n"); + Log_Print("%6d original brushes\n", CountBrushList (head)); + + num_csg_iterations = 0; + qprintf("%6d output brushes", num_csg_iterations); + +#if 0 + if (startbrush == 0) + WriteBrushList ("before.gl", head, false); +#endif + keep = NULL; + +newlist: + // find tail + if (!head) return NULL; + + for (tail = head; tail->next; tail = tail->next) + ; + + for (b1=head ; b1 ; b1=next) + { + next = b1->next; + + //if the conversion is cancelled + if (cancelconversion) + { + b1->next = keep; + keep = b1; + continue; + } //end if + + for (b2 = b1->next; b2; b2 = b2->next) + { + if (BrushesDisjoint (b1, b2)) + continue; + + sub = NULL; + sub2 = NULL; + c1 = 999999; + c2 = 999999; + + if (BrushGE (b2, b1)) + { + sub = SubtractBrush (b1, b2); + if (sub == b1) + { + continue; // didn't really intersect + } //end if + if (!sub) + { // b1 is swallowed by b2 + head = CullList (b1, b1); + goto newlist; + } + c1 = CountBrushList (sub); + } + + if ( BrushGE (b1, b2) ) + { + sub2 = SubtractBrush (b2, b1); + if (sub2 == b2) + continue; // didn't really intersect + if (!sub2) + { // b2 is swallowed by b1 + FreeBrushList (sub); + head = CullList (b1, b2); + goto newlist; + } + c2 = CountBrushList (sub2); + } + + if (!sub && !sub2) + continue; // neither one can bite + + // only accept if it didn't fragment + // (commenting this out allows full fragmentation) + if (c1 > 1 && c2 > 1) + { + if (sub2) + FreeBrushList (sub2); + if (sub) + FreeBrushList (sub); + continue; + } + + if (c1 < c2) + { + if (sub2) FreeBrushList (sub2); + tail = AddBrushListToTail (sub, tail); + head = CullList (b1, b1); + goto newlist; + } //end if + else + { + if (sub) FreeBrushList (sub); + tail = AddBrushListToTail (sub2, tail); + head = CullList (b1, b2); + goto newlist; + } //end else + } //end for + + if (!b2) + { // b1 is no longer intersecting anything, so keep it + b1->next = keep; + keep = b1; + } //end if + num_csg_iterations++; + qprintf("\r%6d", num_csg_iterations); + } //end for + + if (cancelconversion) return keep; + // + qprintf("\n"); + Log_Write("%6d output brushes\r\n", num_csg_iterations); + +#if 0 + { + WriteBrushList ("after.gl", keep, false); + WriteBrushMap ("after.map", keep); + } +#endif + + return keep; +} //end of the function ChopBrushes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *InitialBrushList (bspbrush_t *list) +{ + bspbrush_t *b; + bspbrush_t *out, *newb; + int i; + + // only return brushes that have visible faces + out = NULL; + for (b=list ; b ; b=b->next) + { +#if 0 + for (i=0 ; inumsides ; i++) + if (b->sides[i].flags & SFL_VISIBLE) + break; + if (i == b->numsides) + continue; +#endif + newb = CopyBrush (b); + newb->next = out; + out = newb; + + // clear visible, so it must be set by MarkVisibleFaces_r + // to be used in the optimized list + for (i=0 ; inumsides ; i++) + { + newb->sides[i].original = &b->sides[i]; +// newb->sides[i].visible = true; + b->sides[i].flags &= ~SFL_VISIBLE; + } + } + + return out; +} //end of the function InitialBrushList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *OptimizedBrushList (bspbrush_t *list) +{ + bspbrush_t *b; + bspbrush_t *out, *newb; + int i; + + // only return brushes that have visible faces + out = NULL; + for (b=list ; b ; b=b->next) + { + for (i=0 ; inumsides ; i++) + if (b->sides[i].flags & SFL_VISIBLE) + break; + if (i == b->numsides) + continue; + newb = CopyBrush (b); + newb->next = out; + out = newb; + } //end for + +// WriteBrushList ("vis.gl", out, true); + return out; +} //end of the function OptimizeBrushList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tree_t *ProcessWorldBrushes(int brush_start, int brush_end) +{ + bspbrush_t *brushes; + tree_t *tree; + node_t *node; + vec3_t mins, maxs; + + //take the whole world + mins[0] = map_mins[0] - 8; + mins[1] = map_mins[1] - 8; + mins[2] = map_mins[2] - 8; + + maxs[0] = map_maxs[0] + 8; + maxs[1] = map_maxs[1] + 8; + maxs[2] = map_maxs[2] + 8; + + //reset the brush bsp + ResetBrushBSP(); + + // the makelist and chopbrushes could be cached between the passes... + + //create a list with brushes that are within the given mins/maxs + //some brushes will be cut and only the part that falls within the + //mins/maxs will be in the bush list + brushes = MakeBspBrushList(brush_start, brush_end, mins, maxs); + // + + if (!brushes) + { + node = AllocNode (); + node->planenum = PLANENUM_LEAF; + node->contents = CONTENTS_SOLID; + + tree = Tree_Alloc(); + tree->headnode = node; + VectorCopy(mins, tree->mins); + VectorCopy(maxs, tree->maxs); + } //end if + else + { + //Carves any intersecting solid brushes into the minimum number + //of non-intersecting brushes. + if (!nocsg) + { + brushes = ChopBrushes(brushes); + /* + if (create_aas) + { + brushes = MergeBrushes(brushes); + } //end if*/ + } //end if + //if the conversion is cancelled + if (cancelconversion) + { + FreeBrushList(brushes); + return NULL; + } //end if + //create the actual bsp tree + tree = BrushBSP(brushes, mins, maxs); + } //end else + //return the tree + return tree; +} //end of the function ProcessWorldBrushes diff --git a/code/bspc/faces.c b/code/bspc/faces.c new file mode 100644 index 00000000..f05f5ae9 --- /dev/null +++ b/code/bspc/faces.c @@ -0,0 +1,978 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ +// faces.c + +#include "qbsp.h" +#include "l_mem.h" + +/* + + some faces will be removed before saving, but still form nodes: + + the insides of sky volumes + meeting planes of different water current volumes + +*/ + +// undefine for dumb linear searches +#define USE_HASHING + +#define INTEGRAL_EPSILON 0.01 +#define POINT_EPSILON 0.5 +#define OFF_EPSILON 0.5 + +int c_merge; +int c_subdivide; + +int c_totalverts; +int c_uniqueverts; +int c_degenerate; +int c_tjunctions; +int c_faceoverflows; +int c_facecollapse; +int c_badstartverts; + +#define MAX_SUPERVERTS 512 +int superverts[MAX_SUPERVERTS]; +int numsuperverts; + +face_t *edgefaces[MAX_MAP_EDGES][2]; +int firstmodeledge = 1; +int firstmodelface; + +int c_tryedges; + +vec3_t edge_dir; +vec3_t edge_start; +vec_t edge_len; + +int num_edge_verts; +int edge_verts[MAX_MAP_VERTS]; + +face_t *NewFaceFromFace (face_t *f); + +//=========================================================================== + +typedef struct hashvert_s +{ + struct hashvert_s *next; + int num; +} hashvert_t; + + +#define HASH_SIZE 64 + + +int vertexchain[MAX_MAP_VERTS]; // the next vertex in a hash chain +int hashverts[HASH_SIZE*HASH_SIZE]; // a vertex number, or 0 for no verts + +face_t *edgefaces[MAX_MAP_EDGES][2]; + +//============================================================================ + + +unsigned HashVec (vec3_t vec) +{ + int x, y; + + x = (4096 + (int)(vec[0]+0.5)) >> 7; + y = (4096 + (int)(vec[1]+0.5)) >> 7; + + if ( x < 0 || x >= HASH_SIZE || y < 0 || y >= HASH_SIZE ) + Error ("HashVec: point outside valid range"); + + return y*HASH_SIZE + x; +} + +#ifdef USE_HASHING +/* +============= +GetVertex + +Uses hashing +============= +*/ +int GetVertexnum (vec3_t in) +{ + int h; + int i; + float *p; + vec3_t vert; + int vnum; + + c_totalverts++; + + for (i=0 ; i<3 ; i++) + { + if ( fabs(in[i] - Q_rint(in[i])) < INTEGRAL_EPSILON) + vert[i] = Q_rint(in[i]); + else + vert[i] = in[i]; + } + + h = HashVec (vert); + + for (vnum=hashverts[h] ; vnum ; vnum=vertexchain[vnum]) + { + p = dvertexes[vnum].point; + if ( fabs(p[0]-vert[0]) 4096) + Error ("GetVertexnum: outside +/- 4096"); + } + + // search for an existing vertex match + for (i=0, dv=dvertexes ; ipoint[j]; + if ( d > POINT_EPSILON || d < -POINT_EPSILON) + break; + } + if (j == 3) + return i; // a match + } + + // new point + if (numvertexes == MAX_MAP_VERTS) + Error ("MAX_MAP_VERTS"); + VectorCopy (v, dv->point); + numvertexes++; + c_uniqueverts++; + + return numvertexes-1; +} +#endif + + +/* +================== +FaceFromSuperverts + +The faces vertexes have been added to the superverts[] array, +and there may be more there than can be held in a face (MAXEDGES). + +If less, the faces vertexnums[] will be filled in, otherwise +face will reference a tree of split[] faces until all of the +vertexnums can be added. + +superverts[base] will become face->vertexnums[0], and the others +will be circularly filled in. +================== +*/ +void FaceFromSuperverts (node_t *node, face_t *f, int base) +{ + face_t *newf; + int remaining; + int i; + + remaining = numsuperverts; + while (remaining > MAXEDGES) + { // must split into two faces, because of vertex overload + c_faceoverflows++; + + newf = f->split[0] = NewFaceFromFace (f); + newf = f->split[0]; + newf->next = node->faces; + node->faces = newf; + + newf->numpoints = MAXEDGES; + for (i=0 ; ivertexnums[i] = superverts[(i+base)%numsuperverts]; + + f->split[1] = NewFaceFromFace (f); + f = f->split[1]; + f->next = node->faces; + node->faces = f; + + remaining -= (MAXEDGES-2); + base = (base+MAXEDGES-1)%numsuperverts; + } + + // copy the vertexes back to the face + f->numpoints = remaining; + for (i=0 ; ivertexnums[i] = superverts[(i+base)%numsuperverts]; +} + + +/* +================== +EmitFaceVertexes +================== +*/ +void EmitFaceVertexes (node_t *node, face_t *f) +{ + winding_t *w; + int i; + + if (f->merged || f->split[0] || f->split[1]) + return; + + w = f->w; + for (i=0 ; inumpoints ; i++) + { + if (noweld) + { // make every point unique + if (numvertexes == MAX_MAP_VERTS) + Error ("MAX_MAP_VERTS"); + superverts[i] = numvertexes; + VectorCopy (w->p[i], dvertexes[numvertexes].point); + numvertexes++; + c_uniqueverts++; + c_totalverts++; + } + else + superverts[i] = GetVertexnum (w->p[i]); + } + numsuperverts = w->numpoints; + + // this may fragment the face if > MAXEDGES + FaceFromSuperverts (node, f, 0); +} + +/* +================== +EmitVertexes_r +================== +*/ +void EmitVertexes_r (node_t *node) +{ + int i; + face_t *f; + + if (node->planenum == PLANENUM_LEAF) + return; + + for (f=node->faces ; f ; f=f->next) + { + EmitFaceVertexes (node, f); + } + + for (i=0 ; i<2 ; i++) + EmitVertexes_r (node->children[i]); +} + + +#ifdef USE_HASHING +/* +========== +FindEdgeVerts + +Uses the hash tables to cut down to a small number +========== +*/ +void FindEdgeVerts (vec3_t v1, vec3_t v2) +{ + int x1, x2, y1, y2, t; + int x, y; + int vnum; + +#if 0 +{ + int i; + num_edge_verts = numvertexes-1; + for (i=0 ; i> 7; + y1 = (4096 + (int)(v1[1]+0.5)) >> 7; + x2 = (4096 + (int)(v2[0]+0.5)) >> 7; + y2 = (4096 + (int)(v2[1]+0.5)) >> 7; + + if (x1 > x2) + { + t = x1; + x1 = x2; + x2 = t; + } + if (y1 > y2) + { + t = y1; + y1 = y2; + y2 = t; + } +#if 0 + x1--; + x2++; + y1--; + y2++; + if (x1 < 0) + x1 = 0; + if (x2 >= HASH_SIZE) + x2 = HASH_SIZE; + if (y1 < 0) + y1 = 0; + if (y2 >= HASH_SIZE) + y2 = HASH_SIZE; +#endif + num_edge_verts = 0; + for (x=x1 ; x <= x2 ; x++) + { + for (y=y1 ; y <= y2 ; y++) + { + for (vnum=hashverts[y*HASH_SIZE+x] ; vnum ; vnum=vertexchain[vnum]) + { + edge_verts[num_edge_verts++] = vnum; + } + } + } +} + +#else +/* +========== +FindEdgeVerts + +Forced a dumb check of everything +========== +*/ +void FindEdgeVerts (vec3_t v1, vec3_t v2) +{ + int i; + + num_edge_verts = numvertexes-1; + for (i=0 ; i= end) + continue; // off an end + VectorMA (edge_start, dist, edge_dir, exact); + VectorSubtract (p, exact, off); + error = VectorLength (off); + + if (fabs(error) > OFF_EPSILON) + continue; // not on the edge + + // break the edge + c_tjunctions++; + TestEdge (start, dist, p1, j, k+1); + TestEdge (dist, end, j, p2, k+1); + return; + } + + // the edge p1 to p2 is now free of tjunctions + if (numsuperverts >= MAX_SUPERVERTS) + Error ("MAX_SUPERVERTS"); + superverts[numsuperverts] = p1; + numsuperverts++; +} + +/* +================== +FixFaceEdges + +================== +*/ +void FixFaceEdges (node_t *node, face_t *f) +{ + int p1, p2; + int i; + vec3_t e2; + vec_t len; + int count[MAX_SUPERVERTS], start[MAX_SUPERVERTS]; + int base; + + if (f->merged || f->split[0] || f->split[1]) + return; + + numsuperverts = 0; + + for (i=0 ; inumpoints ; i++) + { + p1 = f->vertexnums[i]; + p2 = f->vertexnums[(i+1)%f->numpoints]; + + VectorCopy (dvertexes[p1].point, edge_start); + VectorCopy (dvertexes[p2].point, e2); + + FindEdgeVerts (edge_start, e2); + + VectorSubtract (e2, edge_start, edge_dir); + len = VectorNormalize(edge_dir); + + start[i] = numsuperverts; + TestEdge (0, len, p1, p2, 0); + + count[i] = numsuperverts - start[i]; + } + + if (numsuperverts < 3) + { // entire face collapsed + f->numpoints = 0; + c_facecollapse++; + return; + } + + // we want to pick a vertex that doesn't have tjunctions + // on either side, which can cause artifacts on trifans, + // especially underwater + for (i=0 ; inumpoints ; i++) + { + if (count[i] == 1 && count[(i+f->numpoints-1)%f->numpoints] == 1) + break; + } + if (i == f->numpoints) + { + f->badstartvert = true; + c_badstartverts++; + base = 0; + } + else + { // rotate the vertex order + base = start[i]; + } + + // this may fragment the face if > MAXEDGES + FaceFromSuperverts (node, f, base); +} + +/* +================== +FixEdges_r +================== +*/ +void FixEdges_r (node_t *node) +{ + int i; + face_t *f; + + if (node->planenum == PLANENUM_LEAF) + return; + + for (f=node->faces ; f ; f=f->next) + FixFaceEdges (node, f); + + for (i=0 ; i<2 ; i++) + FixEdges_r (node->children[i]); +} + +/* +=========== +FixTjuncs + +=========== +*/ +void FixTjuncs (node_t *headnode) +{ + // snap and merge all vertexes + qprintf ("---- snap verts ----\n"); + memset (hashverts, 0, sizeof(hashverts)); + c_totalverts = 0; + c_uniqueverts = 0; + c_faceoverflows = 0; + EmitVertexes_r (headnode); + qprintf ("%i unique from %i\n", c_uniqueverts, c_totalverts); + + // break edges on tjunctions + qprintf ("---- tjunc ----\n"); + c_tryedges = 0; + c_degenerate = 0; + c_facecollapse = 0; + c_tjunctions = 0; + if (!notjunc) + FixEdges_r (headnode); + qprintf ("%5i edges degenerated\n", c_degenerate); + qprintf ("%5i faces degenerated\n", c_facecollapse); + qprintf ("%5i edges added by tjunctions\n", c_tjunctions); + qprintf ("%5i faces added by tjunctions\n", c_faceoverflows); + qprintf ("%5i bad start verts\n", c_badstartverts); +} + + +//======================================================== + +int c_faces; + +face_t *AllocFace (void) +{ + face_t *f; + + f = GetMemory(sizeof(*f)); + memset (f, 0, sizeof(*f)); + c_faces++; + + return f; +} + +face_t *NewFaceFromFace (face_t *f) +{ + face_t *newf; + + newf = AllocFace (); + *newf = *f; + newf->merged = NULL; + newf->split[0] = newf->split[1] = NULL; + newf->w = NULL; + return newf; +} + +void FreeFace (face_t *f) +{ + if (f->w) + FreeWinding (f->w); + FreeMemory(f); + c_faces--; +} + +//======================================================== + +/* +================== +GetEdge + +Called by writebsp. +Don't allow four way edges +================== +*/ +int GetEdge2 (int v1, int v2, face_t *f) +{ + dedge_t *edge; + int i; + + c_tryedges++; + + if (!noshare) + { + for (i=firstmodeledge ; i < numedges ; i++) + { + edge = &dedges[i]; + if (v1 == edge->v[1] && v2 == edge->v[0] + && edgefaces[i][0]->contents == f->contents) + { + if (edgefaces[i][1]) + // printf ("WARNING: multiple backward edge\n"); + continue; + edgefaces[i][1] = f; + return -i; + } + #if 0 + if (v1 == edge->v[0] && v2 == edge->v[1]) + { + printf ("WARNING: multiple forward edge\n"); + return i; + } + #endif + } + } + +// emit an edge + if (numedges >= MAX_MAP_EDGES) + Error ("numedges == MAX_MAP_EDGES"); + edge = &dedges[numedges]; + numedges++; + edge->v[0] = v1; + edge->v[1] = v2; + edgefaces[numedges-1][0] = f; + + return numedges-1; +} + +/* +=========================================================================== + +FACE MERGING + +=========================================================================== +*/ + +/* +============= +TryMerge + +If two polygons share a common edge and the edges that meet at the +common points are both inside the other polygons, merge them + +Returns NULL if the faces couldn't be merged, or the new face. +The originals will NOT be freed. +============= +*/ +face_t *TryMerge (face_t *f1, face_t *f2, vec3_t planenormal) +{ + face_t *newf; + winding_t *nw; + + if (!f1->w || !f2->w) + return NULL; + if (f1->texinfo != f2->texinfo) + return NULL; + if (f1->planenum != f2->planenum) // on front and back sides + return NULL; + if (f1->contents != f2->contents) + return NULL; + + + nw = TryMergeWinding (f1->w, f2->w, planenormal); + if (!nw) + return NULL; + + c_merge++; + newf = NewFaceFromFace (f1); + newf->w = nw; + + f1->merged = newf; + f2->merged = newf; + + return newf; +} + +/* +=============== +MergeNodeFaces +=============== +*/ +void MergeNodeFaces (node_t *node) +{ + face_t *f1, *f2, *end; + face_t *merged; + plane_t *plane; + + plane = &mapplanes[node->planenum]; + merged = NULL; + + for (f1 = node->faces ; f1 ; f1 = f1->next) + { + if (f1->merged || f1->split[0] || f1->split[1]) + continue; + + for (f2 = node->faces ; f2 != f1 ; f2=f2->next) + { + if (f2->merged || f2->split[0] || f2->split[1]) + continue; + + //IDBUG: always passes the face's node's normal to TryMerge() + //regardless of which side the face is on. Approximately 50% of + //the time the face will be on the other side of node, and thus + //the result of the convex/concave test in TryMergeWinding(), + //which depends on the normal, is flipped. This causes faces + //that shouldn't be merged to be merged and faces that + //should be merged to not be merged. + //the following added line fixes this bug + //thanks to: Alexander Malmberg + plane = &mapplanes[f1->planenum]; + // + merged = TryMerge (f1, f2, plane->normal); + if (!merged) + continue; + + // add merged to the end of the node face list + // so it will be checked against all the faces again + for (end = node->faces ; end->next ; end = end->next) + ; + merged->next = NULL; + end->next = merged; + break; + } + } +} + +//===================================================================== + +/* +=============== +SubdivideFace + +Chop up faces that are larger than we want in the surface cache +=============== +*/ +void SubdivideFace (node_t *node, face_t *f) +{ + float mins, maxs; + vec_t v; + int axis, i; + texinfo_t *tex; + vec3_t temp; + vec_t dist; + winding_t *w, *frontw, *backw; + + if (f->merged) + return; + +// special (non-surface cached) faces don't need subdivision + tex = &texinfo[f->texinfo]; + + if ( tex->flags & (SURF_WARP|SURF_SKY) ) + { + return; + } + + for (axis = 0 ; axis < 2 ; axis++) + { + while (1) + { + mins = 999999; + maxs = -999999; + + VectorCopy (tex->vecs[axis], temp); + w = f->w; + for (i=0 ; inumpoints ; i++) + { + v = DotProduct (w->p[i], temp); + if (v < mins) + mins = v; + if (v > maxs) + maxs = v; + } +#if 0 + if (maxs - mins <= 0) + Error ("zero extents"); +#endif + if (axis == 2) + { // allow double high walls + if (maxs - mins <= subdivide_size/* *2 */) + break; + } + else if (maxs - mins <= subdivide_size) + break; + + // split it + c_subdivide++; + + v = VectorNormalize (temp); + + dist = (mins + subdivide_size - 16)/v; + + ClipWindingEpsilon (w, temp, dist, ON_EPSILON, &frontw, &backw); + if (!frontw || !backw) + Error ("SubdivideFace: didn't split the polygon"); + + f->split[0] = NewFaceFromFace (f); + f->split[0]->w = frontw; + f->split[0]->next = node->faces; + node->faces = f->split[0]; + + f->split[1] = NewFaceFromFace (f); + f->split[1]->w = backw; + f->split[1]->next = node->faces; + node->faces = f->split[1]; + + SubdivideFace (node, f->split[0]); + SubdivideFace (node, f->split[1]); + return; + } + } +} + +void SubdivideNodeFaces (node_t *node) +{ + face_t *f; + + for (f = node->faces ; f ; f=f->next) + { + SubdivideFace (node, f); + } +} + +//=========================================================================== + +int c_nodefaces; + + +/* +============ +FaceFromPortal + +============ +*/ +face_t *FaceFromPortal (portal_t *p, int pside) +{ + face_t *f; + side_t *side; + + side = p->side; + if (!side) + return NULL; // portal does not bridge different visible contents + + f = AllocFace (); + + f->texinfo = side->texinfo; + f->planenum = (side->planenum & ~1) | pside; + f->portal = p; + + if ( (p->nodes[pside]->contents & CONTENTS_WINDOW) + && VisibleContents(p->nodes[!pside]->contents^p->nodes[pside]->contents) == CONTENTS_WINDOW ) + return NULL; // don't show insides of windows + + if (pside) + { + f->w = ReverseWinding(p->winding); + f->contents = p->nodes[1]->contents; + } + else + { + f->w = CopyWinding(p->winding); + f->contents = p->nodes[0]->contents; + } + return f; +} + + +/* +=============== +MakeFaces_r + +If a portal will make a visible face, +mark the side that originally created it + + solid / empty : solid + solid / water : solid + water / empty : water + water / water : none +=============== +*/ +void MakeFaces_r (node_t *node) +{ + portal_t *p; + int s; + + // recurse down to leafs + if (node->planenum != PLANENUM_LEAF) + { + MakeFaces_r (node->children[0]); + MakeFaces_r (node->children[1]); + + // merge together all visible faces on the node + if (!nomerge) + MergeNodeFaces (node); + if (!nosubdiv) + SubdivideNodeFaces (node); + + return; + } + + // solid leafs never have visible faces + if (node->contents & CONTENTS_SOLID) + return; + + // see which portals are valid + for (p=node->portals ; p ; p = p->next[s]) + { + s = (p->nodes[1] == node); + + p->face[s] = FaceFromPortal (p, s); + if (p->face[s]) + { + c_nodefaces++; + p->face[s]->next = p->onnode->faces; + p->onnode->faces = p->face[s]; + } + } +} + +/* +============ +MakeFaces +============ +*/ +void MakeFaces (node_t *node) +{ + qprintf ("--- MakeFaces ---\n"); + c_merge = 0; + c_subdivide = 0; + c_nodefaces = 0; + + MakeFaces_r (node); + + qprintf ("%5i makefaces\n", c_nodefaces); + qprintf ("%5i merged\n", c_merge); + qprintf ("%5i subdivided\n", c_subdivide); +} diff --git a/code/bspc/gldraw.c b/code/bspc/gldraw.c new file mode 100644 index 00000000..18ed2c86 --- /dev/null +++ b/code/bspc/gldraw.c @@ -0,0 +1,232 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include +#include +#include +#include + +#include "qbsp.h" + +// can't use the glvertex3fv functions, because the vec3_t fields +// could be either floats or doubles, depending on DOUBLEVEC_T + +qboolean drawflag; +vec3_t draw_mins, draw_maxs; + + +#define WIN_SIZE 512 + +void InitWindow (void) +{ + auxInitDisplayMode (AUX_SINGLE | AUX_RGB); + auxInitPosition (0, 0, WIN_SIZE, WIN_SIZE); + auxInitWindow ("qcsg"); +} + +void Draw_ClearWindow (void) +{ + static int init; + int w, h, g; + vec_t mx, my; + + if (!drawflag) + return; + + if (!init) + { + init = true; + InitWindow (); + } + + glClearColor (1,0.8,0.8,0); + glClear (GL_COLOR_BUFFER_BIT); + + w = (draw_maxs[0] - draw_mins[0]); + h = (draw_maxs[1] - draw_mins[1]); + + mx = draw_mins[0] + w/2; + my = draw_mins[1] + h/2; + + g = w > h ? w : h; + + glLoadIdentity (); + gluPerspective (90, 1, 2, 16384); + gluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0); + + glColor3f (0,0,0); +// glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); + glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); + glDisable (GL_DEPTH_TEST); + glEnable (GL_BLEND); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + +#if 0 + glColor4f (1,0,0,0.5); + glBegin (GL_POLYGON); + + glVertex3f (0, 500, 0); + glVertex3f (0, 900, 0); + glVertex3f (0, 900, 100); + glVertex3f (0, 500, 100); + + glEnd (); +#endif + + glFlush (); + +} + +void Draw_SetRed (void) +{ + if (!drawflag) + return; + + glColor3f (1,0,0); +} + +void Draw_SetGrey (void) +{ + if (!drawflag) + return; + + glColor3f (0.5,0.5,0.5); +} + +void Draw_SetBlack (void) +{ + if (!drawflag) + return; + + glColor3f (0,0,0); +} + +void DrawWinding (winding_t *w) +{ + int i; + + if (!drawflag) + return; + + glColor4f (0,0,0,0.5); + glBegin (GL_LINE_LOOP); + for (i=0 ; inumpoints ; i++) + glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] ); + glEnd (); + + glColor4f (0,1,0,0.3); + glBegin (GL_POLYGON); + for (i=0 ; inumpoints ; i++) + glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] ); + glEnd (); + + glFlush (); +} + +void DrawAuxWinding (winding_t *w) +{ + int i; + + if (!drawflag) + return; + + glColor4f (0,0,0,0.5); + glBegin (GL_LINE_LOOP); + for (i=0 ; inumpoints ; i++) + glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] ); + glEnd (); + + glColor4f (1,0,0,0.3); + glBegin (GL_POLYGON); + for (i=0 ; inumpoints ; i++) + glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] ); + glEnd (); + + glFlush (); +} + +//============================================================ + +#define GLSERV_PORT 25001 + +qboolean wins_init; +int draw_socket; + +void GLS_BeginScene (void) +{ + WSADATA winsockdata; + WORD wVersionRequested; + struct sockaddr_in address; + int r; + + if (!wins_init) + { + wins_init = true; + + wVersionRequested = MAKEWORD(1, 1); + + r = WSAStartup (MAKEWORD(1, 1), &winsockdata); + + if (r) + Error ("Winsock initialization failed."); + + } + + // connect a socket to the server + + draw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); + if (draw_socket == -1) + Error ("draw_socket failed"); + + address.sin_family = AF_INET; + address.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + address.sin_port = GLSERV_PORT; + r = connect (draw_socket, (struct sockaddr *)&address, sizeof(address)); + if (r == -1) + { + closesocket (draw_socket); + draw_socket = 0; + } +} + +void GLS_Winding (winding_t *w, int code) +{ + byte buf[1024]; + int i, j; + + if (!draw_socket) + return; + + ((int *)buf)[0] = w->numpoints; + ((int *)buf)[1] = code; + for (i=0 ; inumpoints ; i++) + for (j=0 ; j<3 ; j++) + ((float *)buf)[2+i*3+j] = w->p[i][j]; + + send (draw_socket, buf, w->numpoints*12+8, 0); +} + +void GLS_EndScene (void) +{ + closesocket (draw_socket); + draw_socket = 0; +} diff --git a/code/bspc/glfile.c b/code/bspc/glfile.c new file mode 100644 index 00000000..e32821b7 --- /dev/null +++ b/code/bspc/glfile.c @@ -0,0 +1,149 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" + +int c_glfaces; + +int PortalVisibleSides (portal_t *p) +{ + int fcon, bcon; + + if (!p->onnode) + return 0; // outside + + fcon = p->nodes[0]->contents; + bcon = p->nodes[1]->contents; + + // same contents never create a face + if (fcon == bcon) + return 0; + + // FIXME: is this correct now? + if (!fcon) + return 1; + if (!bcon) + return 2; + return 0; +} + +void OutputWinding (winding_t *w, FILE *glview) +{ + static int level = 128; + vec_t light; + int i; + + fprintf (glview, "%i\n", w->numpoints); + level+=28; + light = (level&255)/255.0; + for (i=0 ; inumpoints ; i++) + { + fprintf (glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n", + w->p[i][0], + w->p[i][1], + w->p[i][2], + light, + light, + light); + } + fprintf (glview, "\n"); +} + +/* +============= +OutputPortal +============= +*/ +void OutputPortal (portal_t *p, FILE *glview) +{ + winding_t *w; + int sides; + + sides = PortalVisibleSides (p); + if (!sides) + return; + + c_glfaces++; + + w = p->winding; + + if (sides == 2) // back side + w = ReverseWinding (w); + + OutputWinding (w, glview); + + if (sides == 2) + FreeWinding(w); +} + +/* +============= +WriteGLView_r +============= +*/ +void WriteGLView_r (node_t *node, FILE *glview) +{ + portal_t *p, *nextp; + + if (node->planenum != PLANENUM_LEAF) + { + WriteGLView_r (node->children[0], glview); + WriteGLView_r (node->children[1], glview); + return; + } + + // write all the portals + for (p=node->portals ; p ; p=nextp) + { + if (p->nodes[0] == node) + { + OutputPortal (p, glview); + nextp = p->next[0]; + } + else + nextp = p->next[1]; + } +} + +/* +============= +WriteGLView +============= +*/ +void WriteGLView (tree_t *tree, char *source) +{ + char name[1024]; + FILE *glview; + + c_glfaces = 0; + sprintf (name, "%s%s.gl",outbase, source); + printf ("Writing %s\n", name); + + glview = fopen (name, "w"); + if (!glview) + Error ("Couldn't open %s", name); + WriteGLView_r (tree->headnode, glview); + fclose (glview); + + printf ("%5i c_glfaces\n", c_glfaces); +} + diff --git a/code/bspc/l_bsp_ent.c b/code/bspc/l_bsp_ent.c new file mode 100644 index 00000000..0cc8f8e2 --- /dev/null +++ b/code/bspc/l_bsp_ent.c @@ -0,0 +1,180 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "l_cmd.h" +#include "l_math.h" +#include "l_mem.h" +#include "l_log.h" +#include "../botlib/l_script.h" +#include "l_bsp_ent.h" + +#define MAX_KEY 32 +#define MAX_VALUE 1024 + +int num_entities; +entity_t entities[MAX_MAP_ENTITIES]; + +void StripTrailing(char *e) +{ + char *s; + + s = e + strlen(e)-1; + while (s >= e && *s <= 32) + { + *s = 0; + s--; + } +} + +/* +================= +ParseEpair +================= +*/ +epair_t *ParseEpair(script_t *script) +{ + epair_t *e; + token_t token; + + e = GetMemory(sizeof(epair_t)); + memset (e, 0, sizeof(epair_t)); + + PS_ExpectAnyToken(script, &token); + StripDoubleQuotes(token.string); + if (strlen(token.string) >= MAX_KEY-1) + Error ("ParseEpair: token %s too long", token.string); + e->key = copystring(token.string); + PS_ExpectAnyToken(script, &token); + StripDoubleQuotes(token.string); + if (strlen(token.string) >= MAX_VALUE-1) + Error ("ParseEpair: token %s too long", token.string); + e->value = copystring(token.string); + + // strip trailing spaces + StripTrailing(e->key); + StripTrailing(e->value); + + return e; +} //end of the function ParseEpair + + +/* +================ +ParseEntity +================ +*/ +qboolean ParseEntity(script_t *script) +{ + epair_t *e; + entity_t *mapent; + token_t token; + + if (!PS_ReadToken(script, &token)) + return false; + + if (strcmp(token.string, "{")) + Error ("ParseEntity: { not found"); + + if (num_entities == MAX_MAP_ENTITIES) + Error ("num_entities == MAX_MAP_ENTITIES"); + + mapent = &entities[num_entities]; + num_entities++; + + do + { + if (!PS_ReadToken(script, &token)) + Error ("ParseEntity: EOF without closing brace"); + if (!strcmp(token.string, "}") ) + break; + PS_UnreadLastToken(script); + e = ParseEpair(script); + e->next = mapent->epairs; + mapent->epairs = e; + } while (1); + + return true; +} //end of the function ParseEntity + +void PrintEntity (entity_t *ent) +{ + epair_t *ep; + + printf ("------- entity %p -------\n", ent); + for (ep=ent->epairs ; ep ; ep=ep->next) + { + printf ("%s = %s\n", ep->key, ep->value); + } + +} + +void SetKeyValue (entity_t *ent, char *key, char *value) +{ + epair_t *ep; + + for (ep=ent->epairs ; ep ; ep=ep->next) + if (!strcmp (ep->key, key) ) + { + FreeMemory(ep->value); + ep->value = copystring(value); + return; + } + ep = GetMemory(sizeof(*ep)); + ep->next = ent->epairs; + ent->epairs = ep; + ep->key = copystring(key); + ep->value = copystring(value); +} + +char *ValueForKey (entity_t *ent, char *key) +{ + epair_t *ep; + + for (ep=ent->epairs ; ep ; ep=ep->next) + if (!strcmp (ep->key, key) ) + return ep->value; + return ""; +} + +vec_t FloatForKey (entity_t *ent, char *key) +{ + char *k; + + k = ValueForKey (ent, key); + return atof(k); +} + +void GetVectorForKey (entity_t *ent, char *key, vec3_t vec) +{ + char *k; + double v1, v2, v3; + + k = ValueForKey (ent, key); +// scanf into doubles, then assign, so it is vec_t size independent + v1 = v2 = v3 = 0; + sscanf (k, "%lf %lf %lf", &v1, &v2, &v3); + vec[0] = v1; + vec[1] = v2; + vec[2] = v3; +} + + diff --git a/code/bspc/l_bsp_ent.h b/code/bspc/l_bsp_ent.h new file mode 100644 index 00000000..461b91c7 --- /dev/null +++ b/code/bspc/l_bsp_ent.h @@ -0,0 +1,58 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +#ifndef MAX_MAP_ENTITIES +#define MAX_MAP_ENTITIES 2048 +#endif + +typedef struct epair_s +{ + struct epair_s *next; + char *key; + char *value; +} epair_t; + +typedef struct +{ + vec3_t origin; + int firstbrush; + int numbrushes; + epair_t *epairs; + // only valid for func_areaportals + int areaportalnum; + int portalareas[2]; + int modelnum; //for bsp 2 map conversion + qboolean wasdetail; //for SIN +} entity_t; + +extern int num_entities; +extern entity_t entities[MAX_MAP_ENTITIES]; + +void StripTrailing(char *e); +void SetKeyValue(entity_t *ent, char *key, char *value); +char *ValueForKey(entity_t *ent, char *key); // will return "" if not present +vec_t FloatForKey(entity_t *ent, char *key); +void GetVectorForKey(entity_t *ent, char *key, vec3_t vec); +qboolean ParseEntity(script_t *script); +epair_t *ParseEpair(script_t *script); +void PrintEntity(entity_t *ent); + diff --git a/code/bspc/l_bsp_hl.c b/code/bspc/l_bsp_hl.c new file mode 100644 index 00000000..48cb7e8e --- /dev/null +++ b/code/bspc/l_bsp_hl.c @@ -0,0 +1,888 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#include "l_cmd.h" +#include "l_math.h" +#include "l_mem.h" +#include "l_log.h" +#include "../botlib/l_script.h" +#include "l_bsp_hl.h" +#include "l_bsp_ent.h" + +//============================================================================= + +int hl_nummodels; +hl_dmodel_t *hl_dmodels;//[HL_MAX_MAP_MODELS]; +int hl_dmodels_checksum; + +int hl_visdatasize; +byte *hl_dvisdata;//[HL_MAX_MAP_VISIBILITY]; +int hl_dvisdata_checksum; + +int hl_lightdatasize; +byte *hl_dlightdata;//[HL_MAX_MAP_LIGHTING]; +int hl_dlightdata_checksum; + +int hl_texdatasize; +byte *hl_dtexdata;//[HL_MAX_MAP_MIPTEX]; // (dmiptexlump_t) +int hl_dtexdata_checksum; + +int hl_entdatasize; +char *hl_dentdata;//[HL_MAX_MAP_ENTSTRING]; +int hl_dentdata_checksum; + +int hl_numleafs; +hl_dleaf_t *hl_dleafs;//[HL_MAX_MAP_LEAFS]; +int hl_dleafs_checksum; + +int hl_numplanes; +hl_dplane_t *hl_dplanes;//[HL_MAX_MAP_PLANES]; +int hl_dplanes_checksum; + +int hl_numvertexes; +hl_dvertex_t *hl_dvertexes;//[HL_MAX_MAP_VERTS]; +int hl_dvertexes_checksum; + +int hl_numnodes; +hl_dnode_t *hl_dnodes;//[HL_MAX_MAP_NODES]; +int hl_dnodes_checksum; + +int hl_numtexinfo; +hl_texinfo_t *hl_texinfo;//[HL_MAX_MAP_TEXINFO]; +int hl_texinfo_checksum; + +int hl_numfaces; +hl_dface_t *hl_dfaces;//[HL_MAX_MAP_FACES]; +int hl_dfaces_checksum; + +int hl_numclipnodes; +hl_dclipnode_t *hl_dclipnodes;//[HL_MAX_MAP_CLIPNODES]; +int hl_dclipnodes_checksum; + +int hl_numedges; +hl_dedge_t *hl_dedges;//[HL_MAX_MAP_EDGES]; +int hl_dedges_checksum; + +int hl_nummarksurfaces; +unsigned short *hl_dmarksurfaces;//[HL_MAX_MAP_MARKSURFACES]; +int hl_dmarksurfaces_checksum; + +int hl_numsurfedges; +int *hl_dsurfedges;//[HL_MAX_MAP_SURFEDGES]; +int hl_dsurfedges_checksum; + +//int num_entities; +//entity_t entities[HL_MAX_MAP_ENTITIES]; + + +//#ifdef //ME + +int hl_bspallocated = false; +int hl_allocatedbspmem = 0; + +void HL_AllocMaxBSP(void) +{ + //models + hl_nummodels = 0; + hl_dmodels = (hl_dmodel_t *) GetMemory(HL_MAX_MAP_MODELS * sizeof(hl_dmodel_t)); + hl_allocatedbspmem = HL_MAX_MAP_MODELS * sizeof(hl_dmodel_t); + //visibility + hl_visdatasize = 0; + hl_dvisdata = (byte *) GetMemory(HL_MAX_MAP_VISIBILITY * sizeof(byte)); + hl_allocatedbspmem += HL_MAX_MAP_VISIBILITY * sizeof(byte); + //light data + hl_lightdatasize = 0; + hl_dlightdata = (byte *) GetMemory(HL_MAX_MAP_LIGHTING * sizeof(byte)); + hl_allocatedbspmem += HL_MAX_MAP_LIGHTING * sizeof(byte); + //texture data + hl_texdatasize = 0; + hl_dtexdata = (byte *) GetMemory(HL_MAX_MAP_MIPTEX * sizeof(byte)); // (dmiptexlump_t) + hl_allocatedbspmem += HL_MAX_MAP_MIPTEX * sizeof(byte); + //entities + hl_entdatasize = 0; + hl_dentdata = (char *) GetMemory(HL_MAX_MAP_ENTSTRING * sizeof(char)); + hl_allocatedbspmem += HL_MAX_MAP_ENTSTRING * sizeof(char); + //leaves + hl_numleafs = 0; + hl_dleafs = (hl_dleaf_t *) GetMemory(HL_MAX_MAP_LEAFS * sizeof(hl_dleaf_t)); + hl_allocatedbspmem += HL_MAX_MAP_LEAFS * sizeof(hl_dleaf_t); + //planes + hl_numplanes = 0; + hl_dplanes = (hl_dplane_t *) GetMemory(HL_MAX_MAP_PLANES * sizeof(hl_dplane_t)); + hl_allocatedbspmem += HL_MAX_MAP_PLANES * sizeof(hl_dplane_t); + //vertexes + hl_numvertexes = 0; + hl_dvertexes = (hl_dvertex_t *) GetMemory(HL_MAX_MAP_VERTS * sizeof(hl_dvertex_t)); + hl_allocatedbspmem += HL_MAX_MAP_VERTS * sizeof(hl_dvertex_t); + //nodes + hl_numnodes = 0; + hl_dnodes = (hl_dnode_t *) GetMemory(HL_MAX_MAP_NODES * sizeof(hl_dnode_t)); + hl_allocatedbspmem += HL_MAX_MAP_NODES * sizeof(hl_dnode_t); + //texture info + hl_numtexinfo = 0; + hl_texinfo = (hl_texinfo_t *) GetMemory(HL_MAX_MAP_TEXINFO * sizeof(hl_texinfo_t)); + hl_allocatedbspmem += HL_MAX_MAP_TEXINFO * sizeof(hl_texinfo_t); + //faces + hl_numfaces = 0; + hl_dfaces = (hl_dface_t *) GetMemory(HL_MAX_MAP_FACES * sizeof(hl_dface_t)); + hl_allocatedbspmem += HL_MAX_MAP_FACES * sizeof(hl_dface_t); + //clip nodes + hl_numclipnodes = 0; + hl_dclipnodes = (hl_dclipnode_t *) GetMemory(HL_MAX_MAP_CLIPNODES * sizeof(hl_dclipnode_t)); + hl_allocatedbspmem += HL_MAX_MAP_CLIPNODES * sizeof(hl_dclipnode_t); + //edges + hl_numedges = 0; + hl_dedges = (hl_dedge_t *) GetMemory(HL_MAX_MAP_EDGES * sizeof(hl_dedge_t)); + hl_allocatedbspmem += HL_MAX_MAP_EDGES, sizeof(hl_dedge_t); + //mark surfaces + hl_nummarksurfaces = 0; + hl_dmarksurfaces = (unsigned short *) GetMemory(HL_MAX_MAP_MARKSURFACES * sizeof(unsigned short)); + hl_allocatedbspmem += HL_MAX_MAP_MARKSURFACES * sizeof(unsigned short); + //surface edges + hl_numsurfedges = 0; + hl_dsurfedges = (int *) GetMemory(HL_MAX_MAP_SURFEDGES * sizeof(int)); + hl_allocatedbspmem += HL_MAX_MAP_SURFEDGES * sizeof(int); + //print allocated memory + Log_Print("allocated "); + PrintMemorySize(hl_allocatedbspmem); + Log_Print(" of BSP memory\n"); +} //end of the function HL_AllocMaxBSP + +void HL_FreeMaxBSP(void) +{ + //models + hl_nummodels = 0; + FreeMemory(hl_dmodels); + hl_dmodels = NULL; + //visibility + hl_visdatasize = 0; + FreeMemory(hl_dvisdata); + hl_dvisdata = NULL; + //light data + hl_lightdatasize = 0; + FreeMemory(hl_dlightdata); + hl_dlightdata = NULL; + //texture data + hl_texdatasize = 0; + FreeMemory(hl_dtexdata); + hl_dtexdata = NULL; + //entities + hl_entdatasize = 0; + FreeMemory(hl_dentdata); + hl_dentdata = NULL; + //leaves + hl_numleafs = 0; + FreeMemory(hl_dleafs); + hl_dleafs = NULL; + //planes + hl_numplanes = 0; + FreeMemory(hl_dplanes); + hl_dplanes = NULL; + //vertexes + hl_numvertexes = 0; + FreeMemory(hl_dvertexes); + hl_dvertexes = NULL; + //nodes + hl_numnodes = 0; + FreeMemory(hl_dnodes); + hl_dnodes = NULL; + //texture info + hl_numtexinfo = 0; + FreeMemory(hl_texinfo); + hl_texinfo = NULL; + //faces + hl_numfaces = 0; + FreeMemory(hl_dfaces); + hl_dfaces = NULL; + //clip nodes + hl_numclipnodes = 0; + FreeMemory(hl_dclipnodes); + hl_dclipnodes = NULL; + //edges + hl_numedges = 0; + FreeMemory(hl_dedges); + hl_dedges = NULL; + //mark surfaces + hl_nummarksurfaces = 0; + FreeMemory(hl_dmarksurfaces); + hl_dmarksurfaces = NULL; + //surface edges + hl_numsurfedges = 0; + FreeMemory(hl_dsurfedges); + hl_dsurfedges = NULL; + // + Log_Print("freed "); + PrintMemorySize(hl_allocatedbspmem); + Log_Print(" of BSP memory\n"); + hl_allocatedbspmem = 0; +} //end of the function HL_FreeMaxBSP +//#endif //ME + +/* +=============== +FastChecksum +=============== +*/ + +int FastChecksum(void *buffer, int bytes) +{ + int checksum = 0; + + while( bytes-- ) + checksum = (checksum << 4) ^ *((char *)buffer)++; + + return checksum; +} + +/* +=============== +HL_CompressVis +=============== +*/ +int HL_CompressVis(byte *vis, byte *dest) +{ + int j; + int rep; + int visrow; + byte *dest_p; + + dest_p = dest; + visrow = (hl_numleafs + 7)>>3; + + for (j=0 ; j>3; + out = decompressed; + + do + { + if (*in) + { + *out++ = *in++; + continue; + } + + c = in[1]; + in += 2; + while (c) + { + *out++ = 0; + c--; + } + } while (out - decompressed < row); +} + +//============================================================================= + +/* +============= +HL_SwapBSPFile + +Byte swaps all data in a bsp file. +============= +*/ +void HL_SwapBSPFile (qboolean todisk) +{ + int i, j, c; + hl_dmodel_t *d; + hl_dmiptexlump_t *mtl; + + +// models + for (i = 0; i < hl_nummodels; i++) + { + d = &hl_dmodels[i]; + + for (j = 0; j < HL_MAX_MAP_HULLS; j++) + d->headnode[j] = LittleLong(d->headnode[j]); + + d->visleafs = LittleLong(d->visleafs); + d->firstface = LittleLong(d->firstface); + d->numfaces = LittleLong(d->numfaces); + + for (j = 0; j < 3; j++) + { + d->mins[j] = LittleFloat(d->mins[j]); + d->maxs[j] = LittleFloat(d->maxs[j]); + d->origin[j] = LittleFloat(d->origin[j]); + } + } + +// +// vertexes +// + for (i = 0; i < hl_numvertexes; i++) + { + for (j = 0; j < 3; j++) + hl_dvertexes[i].point[j] = LittleFloat (hl_dvertexes[i].point[j]); + } + +// +// planes +// + for (i=0 ; inummiptex; + else + c = LittleLong(mtl->nummiptex); + mtl->nummiptex = LittleLong (mtl->nummiptex); + for (i=0 ; idataofs[i] = LittleLong(mtl->dataofs[i]); + } + +// +// marksurfaces +// + for (i=0 ; ilumps[lump].filelen; + ofs = hl_header->lumps[lump].fileofs; + + if (length % size) { + Error ("LoadBSPFile: odd lump size"); + } + // somehow things got out of range + if ((length/size) > maxsize) { + printf("WARNING: exceeded max size for lump %d size %d > maxsize %d\n", lump, (length/size), maxsize); + length = maxsize * size; + } + if ( ofs + length > hl_fileLength ) { + printf("WARNING: exceeded file length for lump %d\n", lump); + length = hl_fileLength - ofs; + if ( length <= 0 ) { + return 0; + } + } + + memcpy (dest, (byte *)hl_header + ofs, length); + + return length / size; +} + +/* +============= +HL_LoadBSPFile +============= +*/ +void HL_LoadBSPFile (char *filename, int offset, int length) +{ + int i; + +// +// load the file header +// + hl_fileLength = LoadFile (filename, (void **)&hl_header, offset, length); + +// swap the header + for (i=0 ; i< sizeof(hl_dheader_t)/4 ; i++) + ((int *)hl_header)[i] = LittleLong ( ((int *)hl_header)[i]); + + if (hl_header->version != HL_BSPVERSION) + Error ("%s is version %i, not %i", filename, hl_header->version, HL_BSPVERSION); + + hl_nummodels = HL_CopyLump (HL_LUMP_MODELS, hl_dmodels, sizeof(hl_dmodel_t), HL_MAX_MAP_MODELS ); + hl_numvertexes = HL_CopyLump (HL_LUMP_VERTEXES, hl_dvertexes, sizeof(hl_dvertex_t), HL_MAX_MAP_VERTS ); + hl_numplanes = HL_CopyLump (HL_LUMP_PLANES, hl_dplanes, sizeof(hl_dplane_t), HL_MAX_MAP_PLANES ); + hl_numleafs = HL_CopyLump (HL_LUMP_LEAFS, hl_dleafs, sizeof(hl_dleaf_t), HL_MAX_MAP_LEAFS ); + hl_numnodes = HL_CopyLump (HL_LUMP_NODES, hl_dnodes, sizeof(hl_dnode_t), HL_MAX_MAP_NODES ); + hl_numtexinfo = HL_CopyLump (HL_LUMP_TEXINFO, hl_texinfo, sizeof(hl_texinfo_t), HL_MAX_MAP_TEXINFO ); + hl_numclipnodes = HL_CopyLump (HL_LUMP_CLIPNODES, hl_dclipnodes, sizeof(hl_dclipnode_t), HL_MAX_MAP_CLIPNODES ); + hl_numfaces = HL_CopyLump (HL_LUMP_FACES, hl_dfaces, sizeof(hl_dface_t), HL_MAX_MAP_FACES ); + hl_nummarksurfaces = HL_CopyLump (HL_LUMP_MARKSURFACES, hl_dmarksurfaces, sizeof(hl_dmarksurfaces[0]), HL_MAX_MAP_MARKSURFACES ); + hl_numsurfedges = HL_CopyLump (HL_LUMP_SURFEDGES, hl_dsurfedges, sizeof(hl_dsurfedges[0]), HL_MAX_MAP_SURFEDGES ); + hl_numedges = HL_CopyLump (HL_LUMP_EDGES, hl_dedges, sizeof(hl_dedge_t), HL_MAX_MAP_EDGES ); + + hl_texdatasize = HL_CopyLump (HL_LUMP_TEXTURES, hl_dtexdata, 1, HL_MAX_MAP_MIPTEX ); + hl_visdatasize = HL_CopyLump (HL_LUMP_VISIBILITY, hl_dvisdata, 1, HL_MAX_MAP_VISIBILITY ); + hl_lightdatasize = HL_CopyLump (HL_LUMP_LIGHTING, hl_dlightdata, 1, HL_MAX_MAP_LIGHTING ); + hl_entdatasize = HL_CopyLump (HL_LUMP_ENTITIES, hl_dentdata, 1, HL_MAX_MAP_ENTSTRING ); + + FreeMemory(hl_header); // everything has been copied out + +// +// swap everything +// + HL_SwapBSPFile (false); + + hl_dmodels_checksum = FastChecksum( hl_dmodels, hl_nummodels*sizeof(hl_dmodels[0]) ); + hl_dvertexes_checksum = FastChecksum( hl_dvertexes, hl_numvertexes*sizeof(hl_dvertexes[0]) ); + hl_dplanes_checksum = FastChecksum( hl_dplanes, hl_numplanes*sizeof(hl_dplanes[0]) ); + hl_dleafs_checksum = FastChecksum( hl_dleafs, hl_numleafs*sizeof(hl_dleafs[0]) ); + hl_dnodes_checksum = FastChecksum( hl_dnodes, hl_numnodes*sizeof(hl_dnodes[0]) ); + hl_texinfo_checksum = FastChecksum( hl_texinfo, hl_numtexinfo*sizeof(hl_texinfo[0]) ); + hl_dclipnodes_checksum = FastChecksum( hl_dclipnodes, hl_numclipnodes*sizeof(hl_dclipnodes[0]) ); + hl_dfaces_checksum = FastChecksum( hl_dfaces, hl_numfaces*sizeof(hl_dfaces[0]) ); + hl_dmarksurfaces_checksum = FastChecksum( hl_dmarksurfaces, hl_nummarksurfaces*sizeof(hl_dmarksurfaces[0]) ); + hl_dsurfedges_checksum = FastChecksum( hl_dsurfedges, hl_numsurfedges*sizeof(hl_dsurfedges[0]) ); + hl_dedges_checksum = FastChecksum( hl_dedges, hl_numedges*sizeof(hl_dedges[0]) ); + hl_dtexdata_checksum = FastChecksum( hl_dtexdata, hl_numedges*sizeof(hl_dtexdata[0]) ); + hl_dvisdata_checksum = FastChecksum( hl_dvisdata, hl_visdatasize*sizeof(hl_dvisdata[0]) ); + hl_dlightdata_checksum = FastChecksum( hl_dlightdata, hl_lightdatasize*sizeof(hl_dlightdata[0]) ); + hl_dentdata_checksum = FastChecksum( hl_dentdata, hl_entdatasize*sizeof(hl_dentdata[0]) ); + +} + +//============================================================================ + +FILE *wadfile; +hl_dheader_t outheader; + +void HL_AddLump (int lumpnum, void *data, int len) +{ + hl_lump_t *lump; + + lump = &hl_header->lumps[lumpnum]; + + lump->fileofs = LittleLong( ftell(wadfile) ); + lump->filelen = LittleLong(len); + SafeWrite (wadfile, data, (len+3)&~3); +} + +/* +============= +HL_WriteBSPFile + +Swaps the bsp file in place, so it should not be referenced again +============= +*/ +void HL_WriteBSPFile (char *filename) +{ + hl_header = &outheader; + memset (hl_header, 0, sizeof(hl_dheader_t)); + + HL_SwapBSPFile (true); + + hl_header->version = LittleLong (HL_BSPVERSION); + + wadfile = SafeOpenWrite (filename); + SafeWrite (wadfile, hl_header, sizeof(hl_dheader_t)); // overwritten later + + HL_AddLump (HL_LUMP_PLANES, hl_dplanes, hl_numplanes*sizeof(hl_dplane_t)); + HL_AddLump (HL_LUMP_LEAFS, hl_dleafs, hl_numleafs*sizeof(hl_dleaf_t)); + HL_AddLump (HL_LUMP_VERTEXES, hl_dvertexes, hl_numvertexes*sizeof(hl_dvertex_t)); + HL_AddLump (HL_LUMP_NODES, hl_dnodes, hl_numnodes*sizeof(hl_dnode_t)); + HL_AddLump (HL_LUMP_TEXINFO, hl_texinfo, hl_numtexinfo*sizeof(hl_texinfo_t)); + HL_AddLump (HL_LUMP_FACES, hl_dfaces, hl_numfaces*sizeof(hl_dface_t)); + HL_AddLump (HL_LUMP_CLIPNODES, hl_dclipnodes, hl_numclipnodes*sizeof(hl_dclipnode_t)); + HL_AddLump (HL_LUMP_MARKSURFACES, hl_dmarksurfaces, hl_nummarksurfaces*sizeof(hl_dmarksurfaces[0])); + HL_AddLump (HL_LUMP_SURFEDGES, hl_dsurfedges, hl_numsurfedges*sizeof(hl_dsurfedges[0])); + HL_AddLump (HL_LUMP_EDGES, hl_dedges, hl_numedges*sizeof(hl_dedge_t)); + HL_AddLump (HL_LUMP_MODELS, hl_dmodels, hl_nummodels*sizeof(hl_dmodel_t)); + + HL_AddLump (HL_LUMP_LIGHTING, hl_dlightdata, hl_lightdatasize); + HL_AddLump (HL_LUMP_VISIBILITY, hl_dvisdata, hl_visdatasize); + HL_AddLump (HL_LUMP_ENTITIES, hl_dentdata, hl_entdatasize); + HL_AddLump (HL_LUMP_TEXTURES, hl_dtexdata, hl_texdatasize); + + fseek (wadfile, 0, SEEK_SET); + SafeWrite (wadfile, hl_header, sizeof(hl_dheader_t)); + fclose (wadfile); +} + +//============================================================================ + +#define ENTRIES(a) (sizeof(a)/sizeof(*(a))) +#define ENTRYSIZE(a) (sizeof(*(a))) + +ArrayUsage( char *szItem, int items, int maxitems, int itemsize ) +{ + float percentage = maxitems ? items * 100.0 / maxitems : 0.0; + + qprintf("%-12s %7i/%-7i %7i/%-7i (%4.1f%%)", + szItem, items, maxitems, items * itemsize, maxitems * itemsize, percentage ); + if ( percentage > 80.0 ) + qprintf( "VERY FULL!\n" ); + else if ( percentage > 95.0 ) + qprintf( "SIZE DANGER!\n" ); + else if ( percentage > 99.9 ) + qprintf( "SIZE OVERFLOW!!!\n" ); + else + qprintf( "\n" ); + return items * itemsize; +} + +GlobUsage( char *szItem, int itemstorage, int maxstorage ) +{ + float percentage = maxstorage ? itemstorage * 100.0 / maxstorage : 0.0; + + qprintf("%-12s [variable] %7i/%-7i (%4.1f%%)", + szItem, itemstorage, maxstorage, percentage ); + if ( percentage > 80.0 ) + qprintf( "VERY FULL!\n" ); + else if ( percentage > 95.0 ) + qprintf( "SIZE DANGER!\n" ); + else if ( percentage > 99.9 ) + qprintf( "SIZE OVERFLOW!!!\n" ); + else + qprintf( "\n" ); + return itemstorage; +} + +/* +============= +HL_PrintBSPFileSizes + +Dumps info about current file +============= +*/ +void HL_PrintBSPFileSizes(void) +{ + int numtextures = hl_texdatasize ? ((hl_dmiptexlump_t*)hl_dtexdata)->nummiptex : 0; + int totalmemory = 0; + + qprintf("\n"); + qprintf("Object names Objects/Maxobjs Memory / Maxmem Fullness\n" ); + qprintf("------------ --------------- --------------- --------\n" ); + + totalmemory += ArrayUsage( "models", hl_nummodels, ENTRIES(hl_dmodels), ENTRYSIZE(hl_dmodels) ); + totalmemory += ArrayUsage( "planes", hl_numplanes, ENTRIES(hl_dplanes), ENTRYSIZE(hl_dplanes) ); + totalmemory += ArrayUsage( "vertexes", hl_numvertexes, ENTRIES(hl_dvertexes), ENTRYSIZE(hl_dvertexes) ); + totalmemory += ArrayUsage( "nodes", hl_numnodes, ENTRIES(hl_dnodes), ENTRYSIZE(hl_dnodes) ); + totalmemory += ArrayUsage( "texinfos", hl_numtexinfo, ENTRIES(hl_texinfo), ENTRYSIZE(hl_texinfo) ); + totalmemory += ArrayUsage( "faces", hl_numfaces, ENTRIES(hl_dfaces), ENTRYSIZE(hl_dfaces) ); + totalmemory += ArrayUsage( "clipnodes", hl_numclipnodes, ENTRIES(hl_dclipnodes), ENTRYSIZE(hl_dclipnodes) ); + totalmemory += ArrayUsage( "leaves", hl_numleafs, ENTRIES(hl_dleafs), ENTRYSIZE(hl_dleafs) ); + totalmemory += ArrayUsage( "marksurfaces",hl_nummarksurfaces,ENTRIES(hl_dmarksurfaces),ENTRYSIZE(hl_dmarksurfaces) ); + totalmemory += ArrayUsage( "surfedges", hl_numsurfedges, ENTRIES(hl_dsurfedges), ENTRYSIZE(hl_dsurfedges) ); + totalmemory += ArrayUsage( "edges", hl_numedges, ENTRIES(hl_dedges), ENTRYSIZE(hl_dedges) ); + + totalmemory += GlobUsage( "texdata", hl_texdatasize, sizeof(hl_dtexdata) ); + totalmemory += GlobUsage( "lightdata", hl_lightdatasize, sizeof(hl_dlightdata) ); + totalmemory += GlobUsage( "visdata", hl_visdatasize, sizeof(hl_dvisdata) ); + totalmemory += GlobUsage( "entdata", hl_entdatasize, sizeof(hl_dentdata) ); + + qprintf( "=== Total BSP file data space used: %d bytes ===\n\n", totalmemory ); +} + + + +/* +================= +ParseEpair +================= +* / +epair_t *ParseEpair (void) +{ + epair_t *e; + + e = malloc (sizeof(epair_t)); + memset (e, 0, sizeof(epair_t)); + + if (strlen(token) >= MAX_KEY-1) + Error ("ParseEpar: token too long"); + e->key = copystring(token); + GetToken (false); + if (strlen(token) >= MAX_VALUE-1) + Error ("ParseEpar: token too long"); + e->value = copystring(token); + + return e; +} //*/ + + +/* +================ +ParseEntity +================ +* / +qboolean ParseEntity (void) +{ + epair_t *e; + entity_t *mapent; + + if (!GetToken (true)) + return false; + + if (strcmp (token, "{") ) + Error ("ParseEntity: { not found"); + + if (num_entities == HL_MAX_MAP_ENTITIES) + Error ("num_entities == HL_MAX_MAP_ENTITIES"); + + mapent = &entities[num_entities]; + num_entities++; + + do + { + if (!GetToken (true)) + Error ("ParseEntity: EOF without closing brace"); + if (!strcmp (token, "}") ) + break; + e = ParseEpair (); + e->next = mapent->epairs; + mapent->epairs = e; + } while (1); + + return true; +} //*/ + +/* +================ +ParseEntities + +Parses the dentdata string into entities +================ +*/ +void HL_ParseEntities (void) +{ + script_t *script; + + num_entities = 0; + script = LoadScriptMemory(hl_dentdata, hl_entdatasize, "*Half-Life bsp file"); + SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES | + SCFL_NOSTRINGESCAPECHARS); + + while(ParseEntity(script)) + { + } //end while + + FreeScript(script); +} //end of the function HL_ParseEntities + + +/* +================ +UnparseEntities + +Generates the dentdata string from all the entities +================ +*/ +void HL_UnparseEntities (void) +{ + char *buf, *end; + epair_t *ep; + char line[2048]; + int i; + + buf = hl_dentdata; + end = buf; + *end = 0; + + for (i=0 ; inext) + { + sprintf (line, "\"%s\" \"%s\"\n", ep->key, ep->value); + strcat (end, line); + end += strlen(line); + } + strcat (end,"}\n"); + end += 2; + + if (end > buf + HL_MAX_MAP_ENTSTRING) + Error ("Entity text too long"); + } + hl_entdatasize = end - buf + 1; +} //end of the function HL_UnparseEntities + + +/* +void SetKeyValue (entity_t *ent, char *key, char *value) +{ + epair_t *ep; + + for (ep=ent->epairs ; ep ; ep=ep->next) + if (!strcmp (ep->key, key) ) + { + free (ep->value); + ep->value = copystring(value); + return; + } + ep = malloc (sizeof(*ep)); + ep->next = ent->epairs; + ent->epairs = ep; + ep->key = copystring(key); + ep->value = copystring(value); +} + +char *ValueForKey (entity_t *ent, char *key) +{ + epair_t *ep; + + for (ep=ent->epairs ; ep ; ep=ep->next) + if (!strcmp (ep->key, key) ) + return ep->value; + return ""; +} + +vec_t FloatForKey (entity_t *ent, char *key) +{ + char *k; + + k = ValueForKey (ent, key); + return atof(k); +} + +void GetVectorForKey (entity_t *ent, char *key, vec3_t vec) +{ + char *k; + double v1, v2, v3; + + k = ValueForKey (ent, key); +// scanf into doubles, then assign, so it is vec_t size independent + v1 = v2 = v3 = 0; + sscanf (k, "%lf %lf %lf", &v1, &v2, &v3); + vec[0] = v1; + vec[1] = v2; + vec[2] = v3; +} //*/ diff --git a/code/bspc/l_bsp_hl.h b/code/bspc/l_bsp_hl.h new file mode 100644 index 00000000..41462020 --- /dev/null +++ b/code/bspc/l_bsp_hl.h @@ -0,0 +1,314 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ +// upper design bounds + +#define HL_MAX_MAP_HULLS 4 + +#define HL_MAX_MAP_MODELS 400 +#define HL_MAX_MAP_BRUSHES 4096 +#define HL_MAX_MAP_ENTITIES 1024 +#define HL_MAX_MAP_ENTSTRING (128*1024) + +#define HL_MAX_MAP_PLANES 32767 +#define HL_MAX_MAP_NODES 32767 // because negative shorts are contents +#define HL_MAX_MAP_CLIPNODES 32767 // +#define HL_MAX_MAP_LEAFS 8192 +#define HL_MAX_MAP_VERTS 65535 +#define HL_MAX_MAP_FACES 65535 +#define HL_MAX_MAP_MARKSURFACES 65535 +#define HL_MAX_MAP_TEXINFO 8192 +#define HL_MAX_MAP_EDGES 256000 +#define HL_MAX_MAP_SURFEDGES 512000 +#define HL_MAX_MAP_TEXTURES 512 +#define HL_MAX_MAP_MIPTEX 0x200000 +#define HL_MAX_MAP_LIGHTING 0x200000 +#define HL_MAX_MAP_VISIBILITY 0x200000 + +#define HL_MAX_MAP_PORTALS 65536 + +// key / value pair sizes + +#define MAX_KEY 32 +#define MAX_VALUE 1024 + +//============================================================================= + + +#define HL_BSPVERSION 30 +#define HL_TOOLVERSION 2 + + +typedef struct +{ + int fileofs, filelen; +} hl_lump_t; + +#define HL_LUMP_ENTITIES 0 +#define HL_LUMP_PLANES 1 +#define HL_LUMP_TEXTURES 2 +#define HL_LUMP_VERTEXES 3 +#define HL_LUMP_VISIBILITY 4 +#define HL_LUMP_NODES 5 +#define HL_LUMP_TEXINFO 6 +#define HL_LUMP_FACES 7 +#define HL_LUMP_LIGHTING 8 +#define HL_LUMP_CLIPNODES 9 +#define HL_LUMP_LEAFS 10 +#define HL_LUMP_MARKSURFACES 11 +#define HL_LUMP_EDGES 12 +#define HL_LUMP_SURFEDGES 13 +#define HL_LUMP_MODELS 14 + +#define HL_HEADER_LUMPS 15 + +typedef struct +{ + float mins[3], maxs[3]; + float origin[3]; + int headnode[HL_MAX_MAP_HULLS]; + int visleafs; // not including the solid leaf 0 + int firstface, numfaces; +} hl_dmodel_t; + +typedef struct +{ + int version; + hl_lump_t lumps[HL_HEADER_LUMPS]; +} hl_dheader_t; + +typedef struct +{ + int nummiptex; + int dataofs[4]; // [nummiptex] +} hl_dmiptexlump_t; + +#define MIPLEVELS 4 +typedef struct hl_miptex_s +{ + char name[16]; + unsigned width, height; + unsigned offsets[MIPLEVELS]; // four mip maps stored +} hl_miptex_t; + + +typedef struct +{ + float point[3]; +} hl_dvertex_t; + + +// 0-2 are axial planes +#define PLANE_X 0 +#define PLANE_Y 1 +#define PLANE_Z 2 + +// 3-5 are non-axial planes snapped to the nearest +#define PLANE_ANYX 3 +#define PLANE_ANYY 4 +#define PLANE_ANYZ 5 + +typedef struct +{ + float normal[3]; + float dist; + int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate +} hl_dplane_t; + + + +#define HL_CONTENTS_EMPTY -1 +#define HL_CONTENTS_SOLID -2 +#define HL_CONTENTS_WATER -3 +#define HL_CONTENTS_SLIME -4 +#define HL_CONTENTS_LAVA -5 +#define HL_CONTENTS_SKY -6 +#define HL_CONTENTS_ORIGIN -7 // removed at csg time +#define HL_CONTENTS_CLIP -8 // changed to contents_solid + +#define HL_CONTENTS_CURRENT_0 -9 +#define HL_CONTENTS_CURRENT_90 -10 +#define HL_CONTENTS_CURRENT_180 -11 +#define HL_CONTENTS_CURRENT_270 -12 +#define HL_CONTENTS_CURRENT_UP -13 +#define HL_CONTENTS_CURRENT_DOWN -14 + +#define HL_CONTENTS_TRANSLUCENT -15 + +// !!! if this is changed, it must be changed in asm_i386.h too !!! +typedef struct +{ + int planenum; + short children[2]; // negative numbers are -(leafs+1), not nodes + short mins[3]; // for sphere culling + short maxs[3]; + unsigned short firstface; + unsigned short numfaces; // counting both sides +} hl_dnode_t; + +typedef struct +{ + int planenum; + short children[2]; // negative numbers are contents +} hl_dclipnode_t; + + +typedef struct hl_texinfo_s +{ + float vecs[2][4]; // [s/t][xyz offset] + int miptex; + int flags; +} hl_texinfo_t; +#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision + +// note that edge 0 is never used, because negative edge nums are used for +// counterclockwise use of the edge in a face +typedef struct +{ + unsigned short v[2]; // vertex numbers +} hl_dedge_t; + +#define MAXLIGHTMAPS 4 +typedef struct +{ + short planenum; + short side; + + int firstedge; // we must support > 64k edges + short numedges; + short texinfo; + +// lighting info + byte styles[MAXLIGHTMAPS]; + int lightofs; // start of [numstyles*surfsize] samples +} hl_dface_t; + + +#define AMBIENT_WATER 0 +#define AMBIENT_SKY 1 +#define AMBIENT_SLIME 2 +#define AMBIENT_LAVA 3 + +#define NUM_AMBIENTS 4 // automatic ambient sounds + +// leaf 0 is the generic HL_CONTENTS_SOLID leaf, used for all solid areas +// all other leafs need visibility info +typedef struct +{ + int contents; + int visofs; // -1 = no visibility info + + short mins[3]; // for frustum culling + short maxs[3]; + + unsigned short firstmarksurface; + unsigned short nummarksurfaces; + + byte ambient_level[NUM_AMBIENTS]; +} hl_dleaf_t; + + +//============================================================================ + +#ifndef QUAKE_GAME + +#define ANGLE_UP -1 +#define ANGLE_DOWN -2 + + +// the utilities get to be lazy and just use large static arrays + +extern int hl_nummodels; +extern hl_dmodel_t *hl_dmodels;//[MAX_MAP_MODELS]; +extern int hl_dmodels_checksum; + +extern int hl_visdatasize; +extern byte *hl_dvisdata;//[MAX_MAP_VISIBILITY]; +extern int hl_dvisdata_checksum; + +extern int hl_lightdatasize; +extern byte *hl_dlightdata;//[MAX_MAP_LIGHTING]; +extern int hl_dlightdata_checksum; + +extern int hl_texdatasize; +extern byte *hl_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t) +extern int hl_dtexdata_checksum; + +extern int hl_entdatasize; +extern char *hl_dentdata;//[MAX_MAP_ENTSTRING]; +extern int hl_dentdata_checksum; + +extern int hl_numleafs; +extern hl_dleaf_t *hl_dleafs;//[MAX_MAP_LEAFS]; +extern int hl_dleafs_checksum; + +extern int hl_numplanes; +extern hl_dplane_t *hl_dplanes;//[MAX_MAP_PLANES]; +extern int hl_dplanes_checksum; + +extern int hl_numvertexes; +extern hl_dvertex_t *hl_dvertexes;//[MAX_MAP_VERTS]; +extern int hl_dvertexes_checksum; + +extern int hl_numnodes; +extern hl_dnode_t *hl_dnodes;//[MAX_MAP_NODES]; +extern int hl_dnodes_checksum; + +extern int hl_numtexinfo; +extern hl_texinfo_t *hl_texinfo;//[MAX_MAP_TEXINFO]; +extern int hl_texinfo_checksum; + +extern int hl_numfaces; +extern hl_dface_t *hl_dfaces;//[MAX_MAP_FACES]; +extern int hl_dfaces_checksum; + +extern int hl_numclipnodes; +extern hl_dclipnode_t *hl_dclipnodes;//[MAX_MAP_CLIPNODES]; +extern int hl_dclipnodes_checksum; + +extern int hl_numedges; +extern hl_dedge_t *hl_dedges;//[MAX_MAP_EDGES]; +extern int hl_dedges_checksum; + +extern int hl_nummarksurfaces; +extern unsigned short *hl_dmarksurfaces;//[MAX_MAP_MARKSURFACES]; +extern int hl_dmarksurfaces_checksum; + +extern int hl_numsurfedges; +extern int *hl_dsurfedges;//[MAX_MAP_SURFEDGES]; +extern int hl_dsurfedges_checksum; + +int FastChecksum(void *buffer, int bytes); + +void HL_AllocMaxBSP(void); +void HL_FreeMaxBSP(void); + +void HL_DecompressVis(byte *in, byte *decompressed); +int HL_CompressVis(byte *vis, byte *dest); + +void HL_LoadBSPFile(char *filename, int offset, int length); +void HL_WriteBSPFile(char *filename); +void HL_PrintBSPFileSizes(void); +void HL_PrintBSPFileSizes(void); +void HL_ParseEntities(void); +void HL_UnparseEntities(void); + +#endif diff --git a/code/bspc/l_bsp_q1.c b/code/bspc/l_bsp_q1.c new file mode 100644 index 00000000..7ac1553c --- /dev/null +++ b/code/bspc/l_bsp_q1.c @@ -0,0 +1,620 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "l_cmd.h" +#include "l_math.h" +#include "l_mem.h" +#include "l_log.h" +#include "../botlib/l_script.h" +#include "l_bsp_q1.h" +#include "l_bsp_ent.h" + +//============================================================================= + +int q1_nummodels; +q1_dmodel_t *q1_dmodels;//[MAX_MAP_MODELS]; + +int q1_visdatasize; +byte *q1_dvisdata;//[MAX_MAP_VISIBILITY]; + +int q1_lightdatasize; +byte *q1_dlightdata;//[MAX_MAP_LIGHTING]; + +int q1_texdatasize; +byte *q1_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t) + +int q1_entdatasize; +char *q1_dentdata;//[MAX_MAP_ENTSTRING]; + +int q1_numleafs; +q1_dleaf_t *q1_dleafs;//[MAX_MAP_LEAFS]; + +int q1_numplanes; +q1_dplane_t *q1_dplanes;//[MAX_MAP_PLANES]; + +int q1_numvertexes; +q1_dvertex_t *q1_dvertexes;//[MAX_MAP_VERTS]; + +int q1_numnodes; +q1_dnode_t *q1_dnodes;//[MAX_MAP_NODES]; + +int q1_numtexinfo; +q1_texinfo_t *q1_texinfo;//[MAX_MAP_TEXINFO]; + +int q1_numfaces; +q1_dface_t *q1_dfaces;//[MAX_MAP_FACES]; + +int q1_numclipnodes; +q1_dclipnode_t *q1_dclipnodes;//[MAX_MAP_CLIPNODES]; + +int q1_numedges; +q1_dedge_t *q1_dedges;//[MAX_MAP_EDGES]; + +int q1_nummarksurfaces; +unsigned short *q1_dmarksurfaces;//[MAX_MAP_MARKSURFACES]; + +int q1_numsurfedges; +int *q1_dsurfedges;//[MAX_MAP_SURFEDGES]; + +//============================================================================= + +int q1_bspallocated = false; +int q1_allocatedbspmem = 0; + +void Q1_AllocMaxBSP(void) +{ + //models + q1_nummodels = 0; + q1_dmodels = (q1_dmodel_t *) GetMemory(Q1_MAX_MAP_MODELS * sizeof(q1_dmodel_t)); + q1_allocatedbspmem = Q1_MAX_MAP_MODELS * sizeof(q1_dmodel_t); + //visibility + q1_visdatasize = 0; + q1_dvisdata = (byte *) GetMemory(Q1_MAX_MAP_VISIBILITY * sizeof(byte)); + q1_allocatedbspmem += Q1_MAX_MAP_VISIBILITY * sizeof(byte); + //light data + q1_lightdatasize = 0; + q1_dlightdata = (byte *) GetMemory(Q1_MAX_MAP_LIGHTING * sizeof(byte)); + q1_allocatedbspmem += Q1_MAX_MAP_LIGHTING * sizeof(byte); + //texture data + q1_texdatasize = 0; + q1_dtexdata = (byte *) GetMemory(Q1_MAX_MAP_MIPTEX * sizeof(byte)); // (dmiptexlump_t) + q1_allocatedbspmem += Q1_MAX_MAP_MIPTEX * sizeof(byte); + //entities + q1_entdatasize = 0; + q1_dentdata = (char *) GetMemory(Q1_MAX_MAP_ENTSTRING * sizeof(char)); + q1_allocatedbspmem += Q1_MAX_MAP_ENTSTRING * sizeof(char); + //leaves + q1_numleafs = 0; + q1_dleafs = (q1_dleaf_t *) GetMemory(Q1_MAX_MAP_LEAFS * sizeof(q1_dleaf_t)); + q1_allocatedbspmem += Q1_MAX_MAP_LEAFS * sizeof(q1_dleaf_t); + //planes + q1_numplanes = 0; + q1_dplanes = (q1_dplane_t *) GetMemory(Q1_MAX_MAP_PLANES * sizeof(q1_dplane_t)); + q1_allocatedbspmem += Q1_MAX_MAP_PLANES * sizeof(q1_dplane_t); + //vertexes + q1_numvertexes = 0; + q1_dvertexes = (q1_dvertex_t *) GetMemory(Q1_MAX_MAP_VERTS * sizeof(q1_dvertex_t)); + q1_allocatedbspmem += Q1_MAX_MAP_VERTS * sizeof(q1_dvertex_t); + //nodes + q1_numnodes = 0; + q1_dnodes = (q1_dnode_t *) GetMemory(Q1_MAX_MAP_NODES * sizeof(q1_dnode_t)); + q1_allocatedbspmem += Q1_MAX_MAP_NODES * sizeof(q1_dnode_t); + //texture info + q1_numtexinfo = 0; + q1_texinfo = (q1_texinfo_t *) GetMemory(Q1_MAX_MAP_TEXINFO * sizeof(q1_texinfo_t)); + q1_allocatedbspmem += Q1_MAX_MAP_TEXINFO * sizeof(q1_texinfo_t); + //faces + q1_numfaces = 0; + q1_dfaces = (q1_dface_t *) GetMemory(Q1_MAX_MAP_FACES * sizeof(q1_dface_t)); + q1_allocatedbspmem += Q1_MAX_MAP_FACES * sizeof(q1_dface_t); + //clip nodes + q1_numclipnodes = 0; + q1_dclipnodes = (q1_dclipnode_t *) GetMemory(Q1_MAX_MAP_CLIPNODES * sizeof(q1_dclipnode_t)); + q1_allocatedbspmem += Q1_MAX_MAP_CLIPNODES * sizeof(q1_dclipnode_t); + //edges + q1_numedges = 0; + q1_dedges = (q1_dedge_t *) GetMemory(Q1_MAX_MAP_EDGES * sizeof(q1_dedge_t)); + q1_allocatedbspmem += Q1_MAX_MAP_EDGES, sizeof(q1_dedge_t); + //mark surfaces + q1_nummarksurfaces = 0; + q1_dmarksurfaces = (unsigned short *) GetMemory(Q1_MAX_MAP_MARKSURFACES * sizeof(unsigned short)); + q1_allocatedbspmem += Q1_MAX_MAP_MARKSURFACES * sizeof(unsigned short); + //surface edges + q1_numsurfedges = 0; + q1_dsurfedges = (int *) GetMemory(Q1_MAX_MAP_SURFEDGES * sizeof(int)); + q1_allocatedbspmem += Q1_MAX_MAP_SURFEDGES * sizeof(int); + //print allocated memory + Log_Print("allocated "); + PrintMemorySize(q1_allocatedbspmem); + Log_Print(" of BSP memory\n"); +} //end of the function Q1_AllocMaxBSP + +void Q1_FreeMaxBSP(void) +{ + //models + q1_nummodels = 0; + FreeMemory(q1_dmodels); + q1_dmodels = NULL; + //visibility + q1_visdatasize = 0; + FreeMemory(q1_dvisdata); + q1_dvisdata = NULL; + //light data + q1_lightdatasize = 0; + FreeMemory(q1_dlightdata); + q1_dlightdata = NULL; + //texture data + q1_texdatasize = 0; + FreeMemory(q1_dtexdata); + q1_dtexdata = NULL; + //entities + q1_entdatasize = 0; + FreeMemory(q1_dentdata); + q1_dentdata = NULL; + //leaves + q1_numleafs = 0; + FreeMemory(q1_dleafs); + q1_dleafs = NULL; + //planes + q1_numplanes = 0; + FreeMemory(q1_dplanes); + q1_dplanes = NULL; + //vertexes + q1_numvertexes = 0; + FreeMemory(q1_dvertexes); + q1_dvertexes = NULL; + //nodes + q1_numnodes = 0; + FreeMemory(q1_dnodes); + q1_dnodes = NULL; + //texture info + q1_numtexinfo = 0; + FreeMemory(q1_texinfo); + q1_texinfo = NULL; + //faces + q1_numfaces = 0; + FreeMemory(q1_dfaces); + q1_dfaces = NULL; + //clip nodes + q1_numclipnodes = 0; + FreeMemory(q1_dclipnodes); + q1_dclipnodes = NULL; + //edges + q1_numedges = 0; + FreeMemory(q1_dedges); + q1_dedges = NULL; + //mark surfaces + q1_nummarksurfaces = 0; + FreeMemory(q1_dmarksurfaces); + q1_dmarksurfaces = NULL; + //surface edges + q1_numsurfedges = 0; + FreeMemory(q1_dsurfedges); + q1_dsurfedges = NULL; + // + Log_Print("freed "); + PrintMemorySize(q1_allocatedbspmem); + Log_Print(" of BSP memory\n"); + q1_allocatedbspmem = 0; +} //end of the function Q1_FreeMaxBSP +//#endif //ME + +/* +============= +Q1_SwapBSPFile + +Byte swaps all data in a bsp file. +============= +*/ +void Q1_SwapBSPFile (qboolean todisk) +{ + int i, j, c; + q1_dmodel_t *d; + q1_dmiptexlump_t *mtl; + + +// models + for (i=0 ; iheadnode[j] = LittleLong (d->headnode[j]); + + d->visleafs = LittleLong (d->visleafs); + d->firstface = LittleLong (d->firstface); + d->numfaces = LittleLong (d->numfaces); + + for (j=0 ; j<3 ; j++) + { + d->mins[j] = LittleFloat(d->mins[j]); + d->maxs[j] = LittleFloat(d->maxs[j]); + d->origin[j] = LittleFloat(d->origin[j]); + } + } + +// +// vertexes +// + for (i=0 ; inummiptex; + else + c = LittleLong(mtl->nummiptex); + mtl->nummiptex = LittleLong (mtl->nummiptex); + for (i=0 ; idataofs[i] = LittleLong(mtl->dataofs[i]); + } + +// +// marksurfaces +// + for (i=0 ; ilumps[lump].filelen; + ofs = q1_header->lumps[lump].fileofs; + + if (length % size) { + Error ("LoadBSPFile: odd lump size"); + } + // somehow things got out of range + if ((length/size) > maxsize) { + printf("WARNING: exceeded max size for lump %d size %d > maxsize %d\n", lump, (length/size), maxsize); + length = maxsize * size; + } + if ( ofs + length > q1_fileLength ) { + printf("WARNING: exceeded file length for lump %d\n", lump); + length = q1_fileLength - ofs; + if ( length <= 0 ) { + return 0; + } + } + + memcpy (dest, (byte *)q1_header + ofs, length); + + return length / size; +} + +/* +============= +Q1_LoadBSPFile +============= +*/ +void Q1_LoadBSPFile(char *filename, int offset, int length) +{ + int i; + +// +// load the file header +// + q1_fileLength = LoadFile(filename, (void **)&q1_header, offset, length); + +// swap the header + for (i=0 ; i< sizeof(q1_dheader_t)/4 ; i++) + ((int *)q1_header)[i] = LittleLong ( ((int *)q1_header)[i]); + + if (q1_header->version != Q1_BSPVERSION) + Error ("%s is version %i, not %i", filename, i, Q1_BSPVERSION); + + q1_nummodels = Q1_CopyLump (Q1_LUMP_MODELS, q1_dmodels, sizeof(q1_dmodel_t), Q1_MAX_MAP_MODELS ); + q1_numvertexes = Q1_CopyLump (Q1_LUMP_VERTEXES, q1_dvertexes, sizeof(q1_dvertex_t), Q1_MAX_MAP_VERTS ); + q1_numplanes = Q1_CopyLump (Q1_LUMP_PLANES, q1_dplanes, sizeof(q1_dplane_t), Q1_MAX_MAP_PLANES ); + q1_numleafs = Q1_CopyLump (Q1_LUMP_LEAFS, q1_dleafs, sizeof(q1_dleaf_t), Q1_MAX_MAP_LEAFS ); + q1_numnodes = Q1_CopyLump (Q1_LUMP_NODES, q1_dnodes, sizeof(q1_dnode_t), Q1_MAX_MAP_NODES ); + q1_numtexinfo = Q1_CopyLump (Q1_LUMP_TEXINFO, q1_texinfo, sizeof(q1_texinfo_t), Q1_MAX_MAP_TEXINFO ); + q1_numclipnodes = Q1_CopyLump (Q1_LUMP_CLIPNODES, q1_dclipnodes, sizeof(q1_dclipnode_t), Q1_MAX_MAP_CLIPNODES ); + q1_numfaces = Q1_CopyLump (Q1_LUMP_FACES, q1_dfaces, sizeof(q1_dface_t), Q1_MAX_MAP_FACES ); + q1_nummarksurfaces = Q1_CopyLump (Q1_LUMP_MARKSURFACES, q1_dmarksurfaces, sizeof(q1_dmarksurfaces[0]), Q1_MAX_MAP_MARKSURFACES ); + q1_numsurfedges = Q1_CopyLump (Q1_LUMP_SURFEDGES, q1_dsurfedges, sizeof(q1_dsurfedges[0]), Q1_MAX_MAP_SURFEDGES ); + q1_numedges = Q1_CopyLump (Q1_LUMP_EDGES, q1_dedges, sizeof(q1_dedge_t), Q1_MAX_MAP_EDGES ); + + q1_texdatasize = Q1_CopyLump (Q1_LUMP_TEXTURES, q1_dtexdata, 1, Q1_MAX_MAP_MIPTEX ); + q1_visdatasize = Q1_CopyLump (Q1_LUMP_VISIBILITY, q1_dvisdata, 1, Q1_MAX_MAP_VISIBILITY ); + q1_lightdatasize = Q1_CopyLump (Q1_LUMP_LIGHTING, q1_dlightdata, 1, Q1_MAX_MAP_LIGHTING ); + q1_entdatasize = Q1_CopyLump (Q1_LUMP_ENTITIES, q1_dentdata, 1, Q1_MAX_MAP_ENTSTRING ); + + FreeMemory(q1_header); // everything has been copied out + +// +// swap everything +// + Q1_SwapBSPFile (false); +} + +//============================================================================ + +FILE *q1_wadfile; +q1_dheader_t q1_outheader; + +void Q1_AddLump (int lumpnum, void *data, int len) +{ + q1_lump_t *lump; + + lump = &q1_header->lumps[lumpnum]; + + lump->fileofs = LittleLong(ftell(q1_wadfile)); + lump->filelen = LittleLong(len); + SafeWrite(q1_wadfile, data, (len+3)&~3); +} + +/* +============= +Q1_WriteBSPFile + +Swaps the bsp file in place, so it should not be referenced again +============= +*/ +void Q1_WriteBSPFile (char *filename) +{ + q1_header = &q1_outheader; + memset (q1_header, 0, sizeof(q1_dheader_t)); + + Q1_SwapBSPFile (true); + + q1_header->version = LittleLong (Q1_BSPVERSION); + + q1_wadfile = SafeOpenWrite (filename); + SafeWrite (q1_wadfile, q1_header, sizeof(q1_dheader_t)); // overwritten later + + Q1_AddLump (Q1_LUMP_PLANES, q1_dplanes, q1_numplanes*sizeof(q1_dplane_t)); + Q1_AddLump (Q1_LUMP_LEAFS, q1_dleafs, q1_numleafs*sizeof(q1_dleaf_t)); + Q1_AddLump (Q1_LUMP_VERTEXES, q1_dvertexes, q1_numvertexes*sizeof(q1_dvertex_t)); + Q1_AddLump (Q1_LUMP_NODES, q1_dnodes, q1_numnodes*sizeof(q1_dnode_t)); + Q1_AddLump (Q1_LUMP_TEXINFO, q1_texinfo, q1_numtexinfo*sizeof(q1_texinfo_t)); + Q1_AddLump (Q1_LUMP_FACES, q1_dfaces, q1_numfaces*sizeof(q1_dface_t)); + Q1_AddLump (Q1_LUMP_CLIPNODES, q1_dclipnodes, q1_numclipnodes*sizeof(q1_dclipnode_t)); + Q1_AddLump (Q1_LUMP_MARKSURFACES, q1_dmarksurfaces, q1_nummarksurfaces*sizeof(q1_dmarksurfaces[0])); + Q1_AddLump (Q1_LUMP_SURFEDGES, q1_dsurfedges, q1_numsurfedges*sizeof(q1_dsurfedges[0])); + Q1_AddLump (Q1_LUMP_EDGES, q1_dedges, q1_numedges*sizeof(q1_dedge_t)); + Q1_AddLump (Q1_LUMP_MODELS, q1_dmodels, q1_nummodels*sizeof(q1_dmodel_t)); + + Q1_AddLump (Q1_LUMP_LIGHTING, q1_dlightdata, q1_lightdatasize); + Q1_AddLump (Q1_LUMP_VISIBILITY, q1_dvisdata, q1_visdatasize); + Q1_AddLump (Q1_LUMP_ENTITIES, q1_dentdata, q1_entdatasize); + Q1_AddLump (Q1_LUMP_TEXTURES, q1_dtexdata, q1_texdatasize); + + fseek (q1_wadfile, 0, SEEK_SET); + SafeWrite (q1_wadfile, q1_header, sizeof(q1_dheader_t)); + fclose (q1_wadfile); +} + +//============================================================================ + +/* +============= +Q1_PrintBSPFileSizes + +Dumps info about current file +============= +*/ +void Q1_PrintBSPFileSizes (void) +{ + printf ("%5i planes %6i\n" + ,q1_numplanes, (int)(q1_numplanes*sizeof(q1_dplane_t))); + printf ("%5i vertexes %6i\n" + ,q1_numvertexes, (int)(q1_numvertexes*sizeof(q1_dvertex_t))); + printf ("%5i nodes %6i\n" + ,q1_numnodes, (int)(q1_numnodes*sizeof(q1_dnode_t))); + printf ("%5i texinfo %6i\n" + ,q1_numtexinfo, (int)(q1_numtexinfo*sizeof(q1_texinfo_t))); + printf ("%5i faces %6i\n" + ,q1_numfaces, (int)(q1_numfaces*sizeof(q1_dface_t))); + printf ("%5i clipnodes %6i\n" + ,q1_numclipnodes, (int)(q1_numclipnodes*sizeof(q1_dclipnode_t))); + printf ("%5i leafs %6i\n" + ,q1_numleafs, (int)(q1_numleafs*sizeof(q1_dleaf_t))); + printf ("%5i marksurfaces %6i\n" + ,q1_nummarksurfaces, (int)(q1_nummarksurfaces*sizeof(q1_dmarksurfaces[0]))); + printf ("%5i surfedges %6i\n" + ,q1_numsurfedges, (int)(q1_numsurfedges*sizeof(q1_dmarksurfaces[0]))); + printf ("%5i edges %6i\n" + ,q1_numedges, (int)(q1_numedges*sizeof(q1_dedge_t))); + if (!q1_texdatasize) + printf (" 0 textures 0\n"); + else + printf ("%5i textures %6i\n",((q1_dmiptexlump_t*)q1_dtexdata)->nummiptex, q1_texdatasize); + printf (" lightdata %6i\n", q1_lightdatasize); + printf (" visdata %6i\n", q1_visdatasize); + printf (" entdata %6i\n", q1_entdatasize); +} //end of the function Q1_PrintBSPFileSizes + + +/* +================ +Q1_ParseEntities + +Parses the dentdata string into entities +================ +*/ +void Q1_ParseEntities (void) +{ + script_t *script; + + num_entities = 0; + script = LoadScriptMemory(q1_dentdata, q1_entdatasize, "*Quake1 bsp file"); + SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES | + SCFL_NOSTRINGESCAPECHARS); + + while(ParseEntity(script)) + { + } //end while + + FreeScript(script); +} //end of the function Q1_ParseEntities + + +/* +================ +Q1_UnparseEntities + +Generates the dentdata string from all the entities +================ +*/ +void Q1_UnparseEntities (void) +{ + char *buf, *end; + epair_t *ep; + char line[2048]; + int i; + + buf = q1_dentdata; + end = buf; + *end = 0; + + for (i=0 ; inext) + { + sprintf (line, "\"%s\" \"%s\"\n", ep->key, ep->value); + strcat (end, line); + end += strlen(line); + } + strcat (end,"}\n"); + end += 2; + + if (end > buf + Q1_MAX_MAP_ENTSTRING) + Error ("Entity text too long"); + } + q1_entdatasize = end - buf + 1; +} //end of the function Q1_UnparseEntities diff --git a/code/bspc/l_bsp_q1.h b/code/bspc/l_bsp_q1.h new file mode 100644 index 00000000..7cf459ce --- /dev/null +++ b/code/bspc/l_bsp_q1.h @@ -0,0 +1,275 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + + +// upper design bounds + +#define Q1_MAX_MAP_HULLS 4 + +#define Q1_MAX_MAP_MODELS 256 +#define Q1_MAX_MAP_BRUSHES 4096 +#define Q1_MAX_MAP_ENTITIES 1024 +#define Q1_MAX_MAP_ENTSTRING 65536 + +#define Q1_MAX_MAP_PLANES 8192 +#define Q1_MAX_MAP_NODES 32767 // because negative shorts are contents +#define Q1_MAX_MAP_CLIPNODES 32767 // +#define Q1_MAX_MAP_LEAFS 32767 // +#define Q1_MAX_MAP_VERTS 65535 +#define Q1_MAX_MAP_FACES 65535 +#define Q1_MAX_MAP_MARKSURFACES 65535 +#define Q1_MAX_MAP_TEXINFO 4096 +#define Q1_MAX_MAP_EDGES 256000 +#define Q1_MAX_MAP_SURFEDGES 512000 +#define Q1_MAX_MAP_MIPTEX 0x200000 +#define Q1_MAX_MAP_LIGHTING 0x100000 +#define Q1_MAX_MAP_VISIBILITY 0x100000 + +// key / value pair sizes + +#define MAX_KEY 32 +#define MAX_VALUE 1024 + +//============================================================================= + + +#define Q1_BSPVERSION 29 + +typedef struct +{ + int fileofs, filelen; +} q1_lump_t; + +#define Q1_LUMP_ENTITIES 0 +#define Q1_LUMP_PLANES 1 +#define Q1_LUMP_TEXTURES 2 +#define Q1_LUMP_VERTEXES 3 +#define Q1_LUMP_VISIBILITY 4 +#define Q1_LUMP_NODES 5 +#define Q1_LUMP_TEXINFO 6 +#define Q1_LUMP_FACES 7 +#define Q1_LUMP_LIGHTING 8 +#define Q1_LUMP_CLIPNODES 9 +#define Q1_LUMP_LEAFS 10 +#define Q1_LUMP_MARKSURFACES 11 +#define Q1_LUMP_EDGES 12 +#define Q1_LUMP_SURFEDGES 13 +#define Q1_LUMP_MODELS 14 + +#define Q1_HEADER_LUMPS 15 + +typedef struct +{ + float mins[3], maxs[3]; + float origin[3]; + int headnode[Q1_MAX_MAP_HULLS]; + int visleafs; // not including the solid leaf 0 + int firstface, numfaces; +} q1_dmodel_t; + +typedef struct +{ + int version; + q1_lump_t lumps[Q1_HEADER_LUMPS]; +} q1_dheader_t; + +typedef struct +{ + int nummiptex; + int dataofs[4]; // [nummiptex] +} q1_dmiptexlump_t; + +#define MIPLEVELS 4 +typedef struct q1_miptex_s +{ + char name[16]; + unsigned width, height; + unsigned offsets[MIPLEVELS]; // four mip maps stored +} q1_miptex_t; + + +typedef struct +{ + float point[3]; +} q1_dvertex_t; + + +// 0-2 are axial planes +#define PLANE_X 0 +#define PLANE_Y 1 +#define PLANE_Z 2 + +// 3-5 are non-axial planes snapped to the nearest +#define PLANE_ANYX 3 +#define PLANE_ANYY 4 +#define PLANE_ANYZ 5 + +typedef struct +{ + float normal[3]; + float dist; + int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate +} q1_dplane_t; + + + +#define Q1_CONTENTS_EMPTY -1 +#define Q1_CONTENTS_SOLID -2 +#define Q1_CONTENTS_WATER -3 +#define Q1_CONTENTS_SLIME -4 +#define Q1_CONTENTS_LAVA -5 +#define Q1_CONTENTS_SKY -6 + +// !!! if this is changed, it must be changed in asm_i386.h too !!! +typedef struct +{ + int planenum; + short children[2]; // negative numbers are -(leafs+1), not nodes + short mins[3]; // for sphere culling + short maxs[3]; + unsigned short firstface; + unsigned short numfaces; // counting both sides +} q1_dnode_t; + +typedef struct +{ + int planenum; + short children[2]; // negative numbers are contents +} q1_dclipnode_t; + + +typedef struct q1_texinfo_s +{ + float vecs[2][4]; // [s/t][xyz offset] + int miptex; + int flags; +} q1_texinfo_t; +#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision + +// note that edge 0 is never used, because negative edge nums are used for +// counterclockwise use of the edge in a face +typedef struct +{ + unsigned short v[2]; // vertex numbers +} q1_dedge_t; + +#define MAXLIGHTMAPS 4 +typedef struct +{ + short planenum; + short side; + + int firstedge; // we must support > 64k edges + short numedges; + short texinfo; + +// lighting info + byte styles[MAXLIGHTMAPS]; + int lightofs; // start of [numstyles*surfsize] samples +} q1_dface_t; + + + +#define AMBIENT_WATER 0 +#define AMBIENT_SKY 1 +#define AMBIENT_SLIME 2 +#define AMBIENT_LAVA 3 + +#define NUM_AMBIENTS 4 // automatic ambient sounds + +// leaf 0 is the generic Q1_CONTENTS_SOLID leaf, used for all solid areas +// all other leafs need visibility info +typedef struct +{ + int contents; + int visofs; // -1 = no visibility info + + short mins[3]; // for frustum culling + short maxs[3]; + + unsigned short firstmarksurface; + unsigned short nummarksurfaces; + + byte ambient_level[NUM_AMBIENTS]; +} q1_dleaf_t; + +//============================================================================ + +#ifndef QUAKE_GAME + +// the utilities get to be lazy and just use large static arrays + +extern int q1_nummodels; +extern q1_dmodel_t *q1_dmodels;//[MAX_MAP_MODELS]; + +extern int q1_visdatasize; +extern byte *q1_dvisdata;//[MAX_MAP_VISIBILITY]; + +extern int q1_lightdatasize; +extern byte *q1_dlightdata;//[MAX_MAP_LIGHTING]; + +extern int q1_texdatasize; +extern byte *q1_dtexdata;//[MAX_MAP_MIPTEX]; // (dmiptexlump_t) + +extern int q1_entdatasize; +extern char *q1_dentdata;//[MAX_MAP_ENTSTRING]; + +extern int q1_numleafs; +extern q1_dleaf_t *q1_dleafs;//[MAX_MAP_LEAFS]; + +extern int q1_numplanes; +extern q1_dplane_t *q1_dplanes;//[MAX_MAP_PLANES]; + +extern int q1_numvertexes; +extern q1_dvertex_t *q1_dvertexes;//[MAX_MAP_VERTS]; + +extern int q1_numnodes; +extern q1_dnode_t *q1_dnodes;//[MAX_MAP_NODES]; + +extern int q1_numtexinfo; +extern q1_texinfo_t *q1_texinfo;//[MAX_MAP_TEXINFO]; + +extern int q1_numfaces; +extern q1_dface_t *q1_dfaces;//[MAX_MAP_FACES]; + +extern int q1_numclipnodes; +extern q1_dclipnode_t *q1_dclipnodes;//[MAX_MAP_CLIPNODES]; + +extern int q1_numedges; +extern q1_dedge_t *q1_dedges;//[MAX_MAP_EDGES]; + +extern int q1_nummarksurfaces; +extern unsigned short *q1_dmarksurfaces;//[MAX_MAP_MARKSURFACES]; + +extern int q1_numsurfedges; +extern int *q1_dsurfedges;//[MAX_MAP_SURFEDGES]; + + +void Q1_AllocMaxBSP(void); +void Q1_FreeMaxBSP(void); +void Q1_LoadBSPFile(char *filename, int offset, int length); +void Q1_WriteBSPFile(char *filename); +void Q1_PrintBSPFileSizes(void); +void Q1_ParseEntities(void); +void Q1_UnparseEntities(void); + +#endif diff --git a/code/bspc/l_bsp_q3.c b/code/bspc/l_bsp_q3.c new file mode 100644 index 00000000..67a84371 --- /dev/null +++ b/code/bspc/l_bsp_q3.c @@ -0,0 +1,824 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "l_cmd.h" +#include "l_math.h" +#include "l_mem.h" +#include "l_log.h" +#include "l_poly.h" +#include "../botlib/l_script.h" +#include "l_qfiles.h" +#include "l_bsp_q3.h" +#include "l_bsp_ent.h" + +void Q3_ParseEntities (void); +void Q3_PrintBSPFileSizes(void); + +void GetLeafNums (void); + +//============================================================================= + +#define WCONVEX_EPSILON 0.5 + + +int q3_nummodels; +dmodel_t *dmodels;//[MAX_MAP_MODELS]; + +int q3_numShaders; +dshader_t *dshaders;//[Q3_MAX_MAP_SHADERS]; + +int q3_entdatasize; +char *dentdata;//[Q3_MAX_MAP_ENTSTRING]; + +int q3_numleafs; +dleaf_t *dleafs;//[Q3_MAX_MAP_LEAFS]; + +int q3_numplanes; +dplane_t *dplanes;//[Q3_MAX_MAP_PLANES]; + +int q3_numnodes; +dnode_t *dnodes;//[Q3_MAX_MAP_NODES]; + +int q3_numleafsurfaces; +int *dleafsurfaces;//[Q3_MAX_MAP_LEAFFACES]; + +int q3_numleafbrushes; +int *dleafbrushes;//[Q3_MAX_MAP_LEAFBRUSHES]; + +int q3_numbrushes; +dbrush_t *dbrushes;//[Q3_MAX_MAP_BRUSHES]; + +int q3_numbrushsides; +dbrushside_t *dbrushsides;//[Q3_MAX_MAP_BRUSHSIDES]; + +int q3_numLightBytes; +byte *q3_lightBytes;//[Q3_MAX_MAP_LIGHTING]; + +int q3_numGridPoints; +byte *q3_gridData;//[Q3_MAX_MAP_LIGHTGRID]; + +int q3_numVisBytes; +byte *q3_visBytes;//[Q3_MAX_MAP_VISIBILITY]; + +int q3_numDrawVerts; +drawVert_t *drawVerts;//[Q3_MAX_MAP_DRAW_VERTS]; + +int q3_numDrawIndexes; +int *drawIndexes;//[Q3_MAX_MAP_DRAW_INDEXES]; + +int q3_numDrawSurfaces; +dsurface_t *drawSurfaces;//[Q3_MAX_MAP_DRAW_SURFS]; + +int q3_numFogs; +dfog_t *dfogs;//[Q3_MAX_MAP_FOGS]; + +char dbrushsidetextured[MAX_MAP_BRUSHSIDES]; + +extern qboolean forcesidesvisible; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q3_FreeMaxBSP(void) +{ + if (dmodels) FreeMemory(dmodels); + dmodels = NULL; + q3_nummodels = 0; + if (dshaders) FreeMemory(dshaders); + dshaders = NULL; + q3_numShaders = 0; + if (dentdata) FreeMemory(dentdata); + dentdata = NULL; + q3_entdatasize = 0; + if (dleafs) FreeMemory(dleafs); + dleafs = NULL; + q3_numleafs = 0; + if (dplanes) FreeMemory(dplanes); + dplanes = NULL; + q3_numplanes = 0; + if (dnodes) FreeMemory(dnodes); + dnodes = NULL; + q3_numnodes = 0; + if (dleafsurfaces) FreeMemory(dleafsurfaces); + dleafsurfaces = NULL; + q3_numleafsurfaces = 0; + if (dleafbrushes) FreeMemory(dleafbrushes); + dleafbrushes = NULL; + q3_numleafbrushes = 0; + if (dbrushes) FreeMemory(dbrushes); + dbrushes = NULL; + q3_numbrushes = 0; + if (dbrushsides) FreeMemory(dbrushsides); + dbrushsides = NULL; + q3_numbrushsides = 0; + if (q3_lightBytes) FreeMemory(q3_lightBytes); + q3_lightBytes = NULL; + q3_numLightBytes = 0; + if (q3_gridData) FreeMemory(q3_gridData); + q3_gridData = NULL; + q3_numGridPoints = 0; + if (q3_visBytes) FreeMemory(q3_visBytes); + q3_visBytes = NULL; + q3_numVisBytes = 0; + if (drawVerts) FreeMemory(drawVerts); + drawVerts = NULL; + q3_numDrawVerts = 0; + if (drawIndexes) FreeMemory(drawIndexes); + drawIndexes = NULL; + q3_numDrawIndexes = 0; + if (drawSurfaces) FreeMemory(drawSurfaces); + drawSurfaces = NULL; + q3_numDrawSurfaces = 0; + if (dfogs) FreeMemory(dfogs); + dfogs = NULL; + q3_numFogs = 0; +} //end of the function Q3_FreeMaxBSP + + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q3_PlaneFromPoints(vec3_t p0, vec3_t p1, vec3_t p2, vec3_t normal, float *dist) +{ + vec3_t t1, t2; + + VectorSubtract(p0, p1, t1); + VectorSubtract(p2, p1, t2); + CrossProduct(t1, t2, normal); + VectorNormalize(normal); + + *dist = DotProduct(p0, normal); +} //end of the function PlaneFromPoints +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q3_SurfacePlane(dsurface_t *surface, vec3_t normal, float *dist) +{ + int i; + float *p0, *p1, *p2; + vec3_t t1, t2; + + p0 = drawVerts[surface->firstVert].xyz; + for (i = 1; i < surface->numVerts-1; i++) + { + p1 = drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz; + p2 = drawVerts[surface->firstVert + ((i+1) % surface->numVerts)].xyz; + VectorSubtract(p0, p1, t1); + VectorSubtract(p2, p1, t2); + CrossProduct(t1, t2, normal); + VectorNormalize(normal); + if (VectorLength(normal)) break; + } //end for*/ +/* + float dot; + for (i = 0; i < surface->numVerts; i++) + { + p0 = drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz; + p1 = drawVerts[surface->firstVert + ((i+1) % surface->numVerts)].xyz; + p2 = drawVerts[surface->firstVert + ((i+2) % surface->numVerts)].xyz; + VectorSubtract(p0, p1, t1); + VectorSubtract(p2, p1, t2); + VectorNormalize(t1); + VectorNormalize(t2); + dot = DotProduct(t1, t2); + if (dot > -0.9 && dot < 0.9 && + VectorLength(t1) > 0.1 && VectorLength(t2) > 0.1) break; + } //end for + CrossProduct(t1, t2, normal); + VectorNormalize(normal); +*/ + if (VectorLength(normal) < 0.9) + { + printf("surface %d bogus normal vector %f %f %f\n", surface - drawSurfaces, normal[0], normal[1], normal[2]); + printf("t1 = %f %f %f, t2 = %f %f %f\n", t1[0], t1[1], t1[2], t2[0], t2[1], t2[2]); + for (i = 0; i < surface->numVerts; i++) + { + p1 = drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz; + Log_Print("p%d = %f %f %f\n", i, p1[0], p1[1], p1[2]); + } //end for + } //end if + *dist = DotProduct(p0, normal); +} //end of the function Q3_SurfacePlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +dplane_t *q3_surfaceplanes; + +void Q3_CreatePlanarSurfacePlanes(void) +{ + int i; + dsurface_t *surface; + + Log_Print("creating planar surface planes...\n"); + q3_surfaceplanes = (dplane_t *) GetClearedMemory(q3_numDrawSurfaces * sizeof(dplane_t)); + + for (i = 0; i < q3_numDrawSurfaces; i++) + { + surface = &drawSurfaces[i]; + if (surface->surfaceType != MST_PLANAR) continue; + Q3_SurfacePlane(surface, q3_surfaceplanes[i].normal, &q3_surfaceplanes[i].dist); + //Log_Print("normal = %f %f %f, dist = %f\n", q3_surfaceplanes[i].normal[0], + // q3_surfaceplanes[i].normal[1], + // q3_surfaceplanes[i].normal[2], q3_surfaceplanes[i].dist); + } //end for +} //end of the function Q3_CreatePlanarSurfacePlanes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +/* +void Q3_SurfacePlane(dsurface_t *surface, vec3_t normal, float *dist) +{ + //take the plane information from the lightmap vector + //VectorCopy(surface->lightmapVecs[2], normal); + //calculate plane dist with first surface vertex + //*dist = DotProduct(drawVerts[surface->firstVert].xyz, normal); + Q3_PlaneFromPoints(drawVerts[surface->firstVert].xyz, + drawVerts[surface->firstVert+1].xyz, + drawVerts[surface->firstVert+2].xyz, normal, dist); +} //end of the function Q3_SurfacePlane*/ +//=========================================================================== +// returns the amount the face and the winding overlap +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float Q3_FaceOnWinding(dsurface_t *surface, winding_t *winding) +{ + int i; + float dist, area; + dplane_t plane; + vec_t *v1, *v2; + vec3_t normal, edgevec; + winding_t *w; + + //copy the winding before chopping + w = CopyWinding(winding); + //retrieve the surface plane + Q3_SurfacePlane(surface, plane.normal, &plane.dist); + //chop the winding with the surface edge planes + for (i = 0; i < surface->numVerts && w; i++) + { + v1 = drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz; + v2 = drawVerts[surface->firstVert + ((i+1) % surface->numVerts)].xyz; + //create a plane through the edge from v1 to v2, orthogonal to the + //surface plane and with the normal vector pointing inward + VectorSubtract(v2, v1, edgevec); + CrossProduct(edgevec, plane.normal, normal); + VectorNormalize(normal); + dist = DotProduct(normal, v1); + // + ChopWindingInPlace(&w, normal, dist, -0.1); //CLIP_EPSILON + } //end for + if (w) + { + area = WindingArea(w); + FreeWinding(w); + return area; + } //end if + return 0; +} //end of the function Q3_FaceOnWinding +//=========================================================================== +// creates a winding for the given brush side on the given brush +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +winding_t *Q3_BrushSideWinding(dbrush_t *brush, dbrushside_t *baseside) +{ + int i; + dplane_t *baseplane, *plane; + winding_t *w; + dbrushside_t *side; + + //create a winding for the brush side with the given planenumber + baseplane = &dplanes[baseside->planeNum]; + w = BaseWindingForPlane(baseplane->normal, baseplane->dist); + for (i = 0; i < brush->numSides && w; i++) + { + side = &dbrushsides[brush->firstSide + i]; + //don't chop with the base plane + if (side->planeNum == baseside->planeNum) continue; + //also don't use planes that are almost equal + plane = &dplanes[side->planeNum]; + if (DotProduct(baseplane->normal, plane->normal) > 0.999 + && fabs(baseplane->dist - plane->dist) < 0.01) continue; + // + plane = &dplanes[side->planeNum^1]; + ChopWindingInPlace(&w, plane->normal, plane->dist, -0.1); //CLIP_EPSILON); + } //end for + return w; +} //end of the function Q3_BrushSideWinding +//=========================================================================== +// fix screwed brush texture references +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean WindingIsTiny(winding_t *w); + +void Q3_FindVisibleBrushSides(void) +{ + int i, j, k, we, numtextured, numsides; + float dot; + dplane_t *plane; + dbrushside_t *brushside; + dbrush_t *brush; + dsurface_t *surface; + winding_t *w; + + memset(dbrushsidetextured, false, MAX_MAP_BRUSHSIDES); + // + numsides = 0; + //create planes for the planar surfaces + Q3_CreatePlanarSurfacePlanes(); + Log_Print("searching visible brush sides...\n"); + Log_Print("%6d brush sides", numsides); + //go over all the brushes + for (i = 0; i < q3_numbrushes; i++) + { + brush = &dbrushes[i]; + //go over all the sides of the brush + for (j = 0; j < brush->numSides; j++) + { + qprintf("\r%6d", numsides++); + brushside = &dbrushsides[brush->firstSide + j]; + // + w = Q3_BrushSideWinding(brush, brushside); + if (!w) + { + dbrushsidetextured[brush->firstSide + j] = true; + continue; + } //end if + else + { + //RemoveEqualPoints(w, 0.2); + if (WindingIsTiny(w)) + { + FreeWinding(w); + dbrushsidetextured[brush->firstSide + j] = true; + continue; + } //end if + else + { + we = WindingError(w); + if (we == WE_NOTENOUGHPOINTS + || we == WE_SMALLAREA + || we == WE_POINTBOGUSRANGE +// || we == WE_NONCONVEX + ) + { + FreeWinding(w); + dbrushsidetextured[brush->firstSide + j] = true; + continue; + } //end if + } //end else + } //end else + if (WindingArea(w) < 20) + { + dbrushsidetextured[brush->firstSide + j] = true; + continue; + } //end if + //find a face for texturing this brush + for (k = 0; k < q3_numDrawSurfaces; k++) + { + surface = &drawSurfaces[k]; + if (surface->surfaceType != MST_PLANAR) continue; + // + //Q3_SurfacePlane(surface, plane.normal, &plane.dist); + plane = &q3_surfaceplanes[k]; + //the surface plane and the brush side plane should be pretty much the same + if (fabs(fabs(plane->dist) - fabs(dplanes[brushside->planeNum].dist)) > 5) continue; + dot = DotProduct(plane->normal, dplanes[brushside->planeNum].normal); + if (dot > -0.9 && dot < 0.9) continue; + //if the face is partly or totally on the brush side + if (Q3_FaceOnWinding(surface, w)) + { + dbrushsidetextured[brush->firstSide + j] = true; + //Log_Write("Q3_FaceOnWinding"); + break; + } //end if + } //end for + FreeWinding(w); + } //end for + } //end for + qprintf("\r%6d brush sides\n", numsides); + numtextured = 0; + for (i = 0; i < q3_numbrushsides; i++) + { + if (forcesidesvisible) dbrushsidetextured[i] = true; + if (dbrushsidetextured[i]) numtextured++; + } //end for + Log_Print("%d brush sides textured out of %d\n", numtextured, q3_numbrushsides); +} //end of the function Q3_FindVisibleBrushSides + +/* +============= +Q3_SwapBlock + +If all values are 32 bits, this can be used to swap everything +============= +*/ +void Q3_SwapBlock( int *block, int sizeOfBlock ) { + int i; + + sizeOfBlock >>= 2; + for ( i = 0 ; i < sizeOfBlock ; i++ ) { + block[i] = LittleLong( block[i] ); + } +} //end of the function Q3_SwapBlock + +/* +============= +Q3_SwapBSPFile + +Byte swaps all data in a bsp file. +============= +*/ +void Q3_SwapBSPFile( void ) { + int i; + + // models + Q3_SwapBlock( (int *)dmodels, q3_nummodels * sizeof( dmodels[0] ) ); + + // shaders (don't swap the name) + for ( i = 0 ; i < q3_numShaders ; i++ ) { + dshaders[i].contentFlags = LittleLong( dshaders[i].contentFlags ); + dshaders[i].surfaceFlags = LittleLong( dshaders[i].surfaceFlags ); + } + + // planes + Q3_SwapBlock( (int *)dplanes, q3_numplanes * sizeof( dplanes[0] ) ); + + // nodes + Q3_SwapBlock( (int *)dnodes, q3_numnodes * sizeof( dnodes[0] ) ); + + // leafs + Q3_SwapBlock( (int *)dleafs, q3_numleafs * sizeof( dleafs[0] ) ); + + // leaffaces + Q3_SwapBlock( (int *)dleafsurfaces, q3_numleafsurfaces * sizeof( dleafsurfaces[0] ) ); + + // leafbrushes + Q3_SwapBlock( (int *)dleafbrushes, q3_numleafbrushes * sizeof( dleafbrushes[0] ) ); + + // brushes + Q3_SwapBlock( (int *)dbrushes, q3_numbrushes * sizeof( dbrushes[0] ) ); + + // brushsides + Q3_SwapBlock( (int *)dbrushsides, q3_numbrushsides * sizeof( dbrushsides[0] ) ); + + // vis + ((int *)&q3_visBytes)[0] = LittleLong( ((int *)&q3_visBytes)[0] ); + ((int *)&q3_visBytes)[1] = LittleLong( ((int *)&q3_visBytes)[1] ); + + // drawverts (don't swap colors ) + for ( i = 0 ; i < q3_numDrawVerts ; i++ ) { + drawVerts[i].lightmap[0] = LittleFloat( drawVerts[i].lightmap[0] ); + drawVerts[i].lightmap[1] = LittleFloat( drawVerts[i].lightmap[1] ); + drawVerts[i].st[0] = LittleFloat( drawVerts[i].st[0] ); + drawVerts[i].st[1] = LittleFloat( drawVerts[i].st[1] ); + drawVerts[i].xyz[0] = LittleFloat( drawVerts[i].xyz[0] ); + drawVerts[i].xyz[1] = LittleFloat( drawVerts[i].xyz[1] ); + drawVerts[i].xyz[2] = LittleFloat( drawVerts[i].xyz[2] ); + drawVerts[i].normal[0] = LittleFloat( drawVerts[i].normal[0] ); + drawVerts[i].normal[1] = LittleFloat( drawVerts[i].normal[1] ); + drawVerts[i].normal[2] = LittleFloat( drawVerts[i].normal[2] ); + } + + // drawindexes + Q3_SwapBlock( (int *)drawIndexes, q3_numDrawIndexes * sizeof( drawIndexes[0] ) ); + + // drawsurfs + Q3_SwapBlock( (int *)drawSurfaces, q3_numDrawSurfaces * sizeof( drawSurfaces[0] ) ); + + // fogs + for ( i = 0 ; i < q3_numFogs ; i++ ) { + dfogs[i].brushNum = LittleLong( dfogs[i].brushNum ); + } +} + + + +/* +============= +Q3_CopyLump +============= +*/ +int Q3_CopyLump( dheader_t *header, int lump, void **dest, int size ) { + int length, ofs; + + length = header->lumps[lump].filelen; + ofs = header->lumps[lump].fileofs; + + if ( length % size ) { + Error ("Q3_LoadBSPFile: odd lump size"); + } + + *dest = GetMemory(length); + + memcpy( *dest, (byte *)header + ofs, length ); + + return length / size; +} + +/* +============= +CountTriangles +============= +*/ +void CountTriangles( void ) { + int i, numTris, numPatchTris; + dsurface_t *surface; + + numTris = numPatchTris = 0; + for ( i = 0; i < q3_numDrawSurfaces; i++ ) { + surface = &drawSurfaces[i]; + + numTris += surface->numIndexes / 3; + + if ( surface->patchWidth ) { + numPatchTris += surface->patchWidth * surface->patchHeight * 2; + } + } + + Log_Print( "%6d triangles\n", numTris ); + Log_Print( "%6d patch tris\n", numPatchTris ); +} + +/* +============= +Q3_LoadBSPFile +============= +*/ +void Q3_LoadBSPFile(struct quakefile_s *qf) +{ + dheader_t *header; + + // load the file header + //LoadFile(filename, (void **)&header, offset, length); + // + LoadQuakeFile(qf, (void **)&header); + + // swap the header + Q3_SwapBlock( (int *)header, sizeof(*header) ); + + if ( header->ident != BSP_IDENT ) { + Error( "%s is not a 2015 file", qf->filename ); + } + if ( header->version != BSP_VERSION ) { + Error( "%s is version %i, not %i", qf->filename, header->version, BSP_VERSION ); + } + + q3_numShaders = Q3_CopyLump( header, LUMP_SHADERS, (void *) &dshaders, sizeof(dshader_t) ); + q3_nummodels = Q3_CopyLump( header, LUMP_MODELS, (void *) &dmodels, sizeof(dmodel_t) ); + q3_numplanes = Q3_CopyLump( header, LUMP_PLANES, (void *) &dplanes, sizeof(dplane_t) ); + q3_numleafs = Q3_CopyLump( header, LUMP_LEAFS, (void *) &dleafs, sizeof(dleaf_t) ); + q3_numnodes = Q3_CopyLump( header, LUMP_NODES, (void *) &dnodes, sizeof(dnode_t) ); + q3_numleafsurfaces = Q3_CopyLump( header, LUMP_LEAFSURFACES, (void *) &dleafsurfaces, sizeof(dleafsurfaces[0]) ); + q3_numleafbrushes = Q3_CopyLump( header, LUMP_LEAFBRUSHES, (void *) &dleafbrushes, sizeof(dleafbrushes[0]) ); + q3_numbrushes = Q3_CopyLump( header, LUMP_BRUSHES, (void *) &dbrushes, sizeof(dbrush_t) ); + q3_numbrushsides = Q3_CopyLump( header, LUMP_BRUSHSIDES, (void *) &dbrushsides, sizeof(dbrushside_t) ); + q3_numDrawVerts = Q3_CopyLump( header, LUMP_DRAWVERTS, (void *) &drawVerts, sizeof(drawVert_t) ); + q3_numDrawSurfaces = Q3_CopyLump( header, LUMP_SURFACES, (void *) &drawSurfaces, sizeof(dsurface_t) ); +// q3_numFogs = Q3_CopyLump( header, LUMP_FOGS, (void *) &dfogs, sizeof(dfog_t) ); + q3_numDrawIndexes = Q3_CopyLump( header, LUMP_DRAWINDEXES, (void *) &drawIndexes, sizeof(drawIndexes[0]) ); + + q3_numVisBytes = Q3_CopyLump( header, LUMP_VISIBILITY, (void *) &q3_visBytes, 1 ); + q3_numLightBytes = Q3_CopyLump( header, LUMP_LIGHTMAPS, (void *) &q3_lightBytes, 1 ); + q3_entdatasize = Q3_CopyLump( header, LUMP_ENTITIES, (void *) &dentdata, 1); + +// q3_numGridPoints = Q3_CopyLump( header, LUMP_LIGHTGRID, (void *) &q3_gridData, 8 ); + + CountTriangles(); + + FreeMemory( header ); // everything has been copied out + + // swap everything + Q3_SwapBSPFile(); + + Q3_FindVisibleBrushSides(); + + //Q3_PrintBSPFileSizes(); +} + + +//============================================================================ + +/* +============= +Q3_AddLump +============= +*/ +void Q3_AddLump( FILE *bspfile, dheader_t *header, int lumpnum, void *data, int len ) { + lump_t *lump; + + lump = &header->lumps[lumpnum]; + + lump->fileofs = LittleLong( ftell(bspfile) ); + lump->filelen = LittleLong( len ); + SafeWrite( bspfile, data, (len+3)&~3 ); +} + +/* +============= +Q3_WriteBSPFile + +Swaps the bsp file in place, so it should not be referenced again +============= +*/ +void Q3_WriteBSPFile( char *filename ) +{ + dheader_t outheader, *header; + FILE *bspfile; + + header = &outheader; + memset( header, 0, sizeof(dheader_t) ); + + Q3_SwapBSPFile(); + + header->ident = LittleLong( BSP_IDENT ); + header->version = LittleLong( BSP_VERSION ); + + bspfile = SafeOpenWrite( filename ); + SafeWrite( bspfile, header, sizeof(dheader_t) ); // overwritten later + + Q3_AddLump( bspfile, header, LUMP_SHADERS, dshaders, q3_numShaders*sizeof(dshader_t) ); + Q3_AddLump( bspfile, header, LUMP_PLANES, dplanes, q3_numplanes*sizeof(dplane_t) ); + Q3_AddLump( bspfile, header, LUMP_LEAFS, dleafs, q3_numleafs*sizeof(dleaf_t) ); + Q3_AddLump( bspfile, header, LUMP_NODES, dnodes, q3_numnodes*sizeof(dnode_t) ); + Q3_AddLump( bspfile, header, LUMP_BRUSHES, dbrushes, q3_numbrushes*sizeof(dbrush_t) ); + Q3_AddLump( bspfile, header, LUMP_BRUSHSIDES, dbrushsides, q3_numbrushsides*sizeof(dbrushside_t) ); + Q3_AddLump( bspfile, header, LUMP_LEAFSURFACES, dleafsurfaces, q3_numleafsurfaces*sizeof(dleafsurfaces[0]) ); + Q3_AddLump( bspfile, header, LUMP_LEAFBRUSHES, dleafbrushes, q3_numleafbrushes*sizeof(dleafbrushes[0]) ); + Q3_AddLump( bspfile, header, LUMP_MODELS, dmodels, q3_nummodels*sizeof(dmodel_t) ); + Q3_AddLump( bspfile, header, LUMP_DRAWVERTS, drawVerts, q3_numDrawVerts*sizeof(drawVert_t) ); + Q3_AddLump( bspfile, header, LUMP_SURFACES, drawSurfaces, q3_numDrawSurfaces*sizeof(dsurface_t) ); + Q3_AddLump( bspfile, header, LUMP_VISIBILITY, q3_visBytes, q3_numVisBytes ); + Q3_AddLump( bspfile, header, LUMP_LIGHTMAPS, q3_lightBytes, q3_numLightBytes ); +// Q3_AddLump( bspfile, header, LUMP_LIGHTGRID, q3_gridData, 8 * q3_numGridPoints ); + Q3_AddLump( bspfile, header, LUMP_ENTITIES, dentdata, q3_entdatasize ); +// Q3_AddLump( bspfile, header, LUMP_FOGS, dfogs, q3_numFogs * sizeof(dfog_t) ); + Q3_AddLump( bspfile, header, LUMP_DRAWINDEXES, drawIndexes, q3_numDrawIndexes * sizeof(drawIndexes[0]) ); + + fseek (bspfile, 0, SEEK_SET); + SafeWrite (bspfile, header, sizeof(dheader_t)); + fclose (bspfile); +} + +//============================================================================ + +/* +============= +Q3_PrintBSPFileSizes + +Dumps info about current file +============= +*/ +void Q3_PrintBSPFileSizes( void ) +{ + if ( !num_entities ) + { + Q3_ParseEntities(); + } + + Log_Print ("%6i models %7i\n" + ,q3_nummodels, (int)(q3_nummodels*sizeof(dmodel_t))); + Log_Print ("%6i shaders %7i\n" + ,q3_numShaders, (int)(q3_numShaders*sizeof(dshader_t))); + Log_Print ("%6i brushes %7i\n" + ,q3_numbrushes, (int)(q3_numbrushes*sizeof(dbrush_t))); + Log_Print ("%6i brushsides %7i\n" + ,q3_numbrushsides, (int)(q3_numbrushsides*sizeof(dbrushside_t))); + Log_Print ("%6i fogs %7i\n" + ,q3_numFogs, (int)(q3_numFogs*sizeof(dfog_t))); + Log_Print ("%6i planes %7i\n" + ,q3_numplanes, (int)(q3_numplanes*sizeof(dplane_t))); + Log_Print ("%6i entdata %7i\n", num_entities, q3_entdatasize); + + Log_Print ("\n"); + + Log_Print ("%6i nodes %7i\n" + ,q3_numnodes, (int)(q3_numnodes*sizeof(dnode_t))); + Log_Print ("%6i leafs %7i\n" + ,q3_numleafs, (int)(q3_numleafs*sizeof(dleaf_t))); + Log_Print ("%6i leafsurfaces %7i\n" + ,q3_numleafsurfaces, (int)(q3_numleafsurfaces*sizeof(dleafsurfaces[0]))); + Log_Print ("%6i leafbrushes %7i\n" + ,q3_numleafbrushes, (int)(q3_numleafbrushes*sizeof(dleafbrushes[0]))); + Log_Print ("%6i drawverts %7i\n" + ,q3_numDrawVerts, (int)(q3_numDrawVerts*sizeof(drawVerts[0]))); + Log_Print ("%6i drawindexes %7i\n" + ,q3_numDrawIndexes, (int)(q3_numDrawIndexes*sizeof(drawIndexes[0]))); + Log_Print ("%6i drawsurfaces %7i\n" + ,q3_numDrawSurfaces, (int)(q3_numDrawSurfaces*sizeof(drawSurfaces[0]))); + + Log_Print ("%6i lightmaps %7i\n" + ,q3_numLightBytes / (LIGHTMAP_WIDTH*LIGHTMAP_HEIGHT*3), q3_numLightBytes ); + Log_Print (" visibility %7i\n" + , q3_numVisBytes ); +} + +/* +================ +Q3_ParseEntities + +Parses the dentdata string into entities +================ +*/ +void Q3_ParseEntities (void) +{ + script_t *script; + + num_entities = 0; + script = LoadScriptMemory(dentdata, q3_entdatasize, "*Quake3 bsp file"); + SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES | + SCFL_NOSTRINGESCAPECHARS); + + while(ParseEntity(script)) + { + } //end while + + FreeScript(script); +} //end of the function Q3_ParseEntities + + +/* +================ +Q3_UnparseEntities + +Generates the dentdata string from all the entities +================ +*/ +void Q3_UnparseEntities (void) +{ + char *buf, *end; + epair_t *ep; + char line[2048]; + int i; + + buf = dentdata; + end = buf; + *end = 0; + + for (i=0 ; inext) + { + sprintf (line, "\"%s\" \"%s\"\n", ep->key, ep->value); + strcat (end, line); + end += strlen(line); + } + strcat (end,"}\n"); + end += 2; + + if (end > buf + MAX_MAP_ENTSTRING) + Error ("Entity text too long"); + } + q3_entdatasize = end - buf + 1; +} //end of the function Q3_UnparseEntities + + diff --git a/code/bspc/l_bsp_q3.h b/code/bspc/l_bsp_q3.h new file mode 100644 index 00000000..887d1e4b --- /dev/null +++ b/code/bspc/l_bsp_q3.h @@ -0,0 +1,81 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "q3files.h" +//#include "surfaceflags.h" + +extern int q3_nummodels; +extern dmodel_t *dmodels;//[MAX_MAP_MODELS]; + +extern int q3_numShaders; +extern dshader_t *dshaders;//[Q3_MAX_MAP_SHADERS]; + +extern int q3_entdatasize; +extern char *dentdata;//[Q3_MAX_MAP_ENTSTRING]; + +extern int q3_numleafs; +extern dleaf_t *dleafs;//[Q3_MAX_MAP_LEAFS]; + +extern int q3_numplanes; +extern dplane_t *dplanes;//[Q3_MAX_MAP_PLANES]; + +extern int q3_numnodes; +extern dnode_t *dnodes;//[Q3_MAX_MAP_NODES]; + +extern int q3_numleafsurfaces; +extern int *dleafsurfaces;//[Q3_MAX_MAP_LEAFFACES]; + +extern int q3_numleafbrushes; +extern int *dleafbrushes;//[Q3_MAX_MAP_LEAFBRUSHES]; + +extern int q3_numbrushes; +extern dbrush_t *dbrushes;//[Q3_MAX_MAP_BRUSHES]; + +extern int q3_numbrushsides; +extern dbrushside_t *dbrushsides;//[Q3_MAX_MAP_BRUSHSIDES]; + +extern int q3_numLightBytes; +extern byte *q3_lightBytes;//[Q3_MAX_MAP_LIGHTING]; + +extern int q3_numGridPoints; +extern byte *q3_gridData;//[Q3_MAX_MAP_LIGHTGRID]; + +extern int q3_numVisBytes; +extern byte *q3_visBytes;//[Q3_MAX_MAP_VISIBILITY]; + +extern int q3_numDrawVerts; +extern drawVert_t *drawVerts;//[Q3_MAX_MAP_DRAW_VERTS]; + +extern int q3_numDrawIndexes; +extern int *drawIndexes;//[Q3_MAX_MAP_DRAW_INDEXES]; + +extern int q3_numDrawSurfaces; +extern dsurface_t *drawSurfaces;//[Q3_MAX_MAP_DRAW_SURFS]; + +extern int q3_numFogs; +extern dfog_t *dfogs;//[Q3_MAX_MAP_FOGS]; + +extern char dbrushsidetextured[MAX_MAP_BRUSHSIDES]; + +void Q3_LoadBSPFile(struct quakefile_s *qf); +void Q3_FreeMaxBSP(void); +void Q3_ParseEntities (void); diff --git a/code/bspc/l_bsp_sin.c b/code/bspc/l_bsp_sin.c new file mode 100644 index 00000000..2c3c223c --- /dev/null +++ b/code/bspc/l_bsp_sin.c @@ -0,0 +1,1186 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "l_cmd.h" +#include "l_math.h" +#include "l_mem.h" +#include "l_log.h" +#include "l_poly.h" +#include "../botlib/l_script.h" +#include "l_bsp_ent.h" +#include "l_bsp_sin.h" + +void GetLeafNums (void); + +//============================================================================= + +int sin_nummodels; +sin_dmodel_t *sin_dmodels;//[SIN_MAX_MAP_MODELS]; + +int sin_visdatasize; +byte *sin_dvisdata;//[SIN_MAX_MAP_VISIBILITY]; +sin_dvis_t *sin_dvis;// = (sin_dvis_t *)sin_sin_dvisdata; + +int sin_lightdatasize; +byte *sin_dlightdata;//[SIN_MAX_MAP_LIGHTING]; + +int sin_entdatasize; +char *sin_dentdata;//[SIN_MAX_MAP_ENTSTRING]; + +int sin_numleafs; +sin_dleaf_t *sin_dleafs;//[SIN_MAX_MAP_LEAFS]; + +int sin_numplanes; +sin_dplane_t *sin_dplanes;//[SIN_MAX_MAP_PLANES]; + +int sin_numvertexes; +sin_dvertex_t *sin_dvertexes;//[SIN_MAX_MAP_VERTS]; + +int sin_numnodes; +sin_dnode_t *sin_dnodes;//[SIN_MAX_MAP_NODES]; + +int sin_numtexinfo; +sin_texinfo_t *sin_texinfo;//[SIN_MAX_MAP_sin_texinfo]; + +int sin_numfaces; +sin_dface_t *sin_dfaces;//[SIN_MAX_MAP_FACES]; + +int sin_numedges; +sin_dedge_t *sin_dedges;//[SIN_MAX_MAP_EDGES]; + +int sin_numleaffaces; +unsigned short *sin_dleaffaces;//[SIN_MAX_MAP_LEAFFACES]; + +int sin_numleafbrushes; +unsigned short *sin_dleafbrushes;//[SIN_MAX_MAP_LEAFBRUSHES]; + +int sin_numsurfedges; +int *sin_dsurfedges;//[SIN_MAX_MAP_SURFEDGES]; + +int sin_numbrushes; +sin_dbrush_t *sin_dbrushes;//[SIN_MAX_MAP_BRUSHES]; + +int sin_numbrushsides; +sin_dbrushside_t *sin_dbrushsides;//[SIN_MAX_MAP_BRUSHSIDES]; + +int sin_numareas; +sin_darea_t *sin_dareas;//[SIN_MAX_MAP_AREAS]; + +int sin_numareaportals; +sin_dareaportal_t *sin_dareaportals;//[SIN_MAX_MAP_AREAPORTALS]; + +int sin_numlightinfo; +sin_lightvalue_t *sin_lightinfo;//[SIN_MAX_MAP_LIGHTINFO]; + +byte sin_dpop[256]; + +char sin_dbrushsidetextured[SIN_MAX_MAP_BRUSHSIDES]; + +int sin_bspallocated = false; +int sin_allocatedbspmem = 0; + +void Sin_AllocMaxBSP(void) +{ + //models + sin_nummodels = 0; + sin_dmodels = (sin_dmodel_t *) GetClearedMemory(SIN_MAX_MAP_MODELS * sizeof(sin_dmodel_t)); + sin_allocatedbspmem += SIN_MAX_MAP_MODELS * sizeof(sin_dmodel_t); + //vis data + sin_visdatasize = 0; + sin_dvisdata = (byte *) GetClearedMemory(SIN_MAX_MAP_VISIBILITY * sizeof(byte)); + sin_dvis = (sin_dvis_t *) sin_dvisdata; + sin_allocatedbspmem += SIN_MAX_MAP_VISIBILITY * sizeof(byte); + //light data + sin_lightdatasize = 0; + sin_dlightdata = (byte *) GetClearedMemory(SIN_MAX_MAP_LIGHTING * sizeof(byte)); + sin_allocatedbspmem += SIN_MAX_MAP_LIGHTING * sizeof(byte); + //entity data + sin_entdatasize = 0; + sin_dentdata = (char *) GetClearedMemory(SIN_MAX_MAP_ENTSTRING * sizeof(char)); + sin_allocatedbspmem += SIN_MAX_MAP_ENTSTRING * sizeof(char); + //leafs + sin_numleafs = 0; + sin_dleafs = (sin_dleaf_t *) GetClearedMemory(SIN_MAX_MAP_LEAFS * sizeof(sin_dleaf_t)); + sin_allocatedbspmem += SIN_MAX_MAP_LEAFS * sizeof(sin_dleaf_t); + //planes + sin_numplanes = 0; + sin_dplanes = (sin_dplane_t *) GetClearedMemory(SIN_MAX_MAP_PLANES * sizeof(sin_dplane_t)); + sin_allocatedbspmem += SIN_MAX_MAP_PLANES * sizeof(sin_dplane_t); + //vertexes + sin_numvertexes = 0; + sin_dvertexes = (sin_dvertex_t *) GetClearedMemory(SIN_MAX_MAP_VERTS * sizeof(sin_dvertex_t)); + sin_allocatedbspmem += SIN_MAX_MAP_VERTS * sizeof(sin_dvertex_t); + //nodes + sin_numnodes = 0; + sin_dnodes = (sin_dnode_t *) GetClearedMemory(SIN_MAX_MAP_NODES * sizeof(sin_dnode_t)); + sin_allocatedbspmem += SIN_MAX_MAP_NODES * sizeof(sin_dnode_t); + //texture info + sin_numtexinfo = 0; + sin_texinfo = (sin_texinfo_t *) GetClearedMemory(SIN_MAX_MAP_TEXINFO * sizeof(sin_texinfo_t)); + sin_allocatedbspmem += SIN_MAX_MAP_TEXINFO * sizeof(sin_texinfo_t); + //faces + sin_numfaces = 0; + sin_dfaces = (sin_dface_t *) GetClearedMemory(SIN_MAX_MAP_FACES * sizeof(sin_dface_t)); + sin_allocatedbspmem += SIN_MAX_MAP_FACES * sizeof(sin_dface_t); + //edges + sin_numedges = 0; + sin_dedges = (sin_dedge_t *) GetClearedMemory(SIN_MAX_MAP_EDGES * sizeof(sin_dedge_t)); + sin_allocatedbspmem += SIN_MAX_MAP_EDGES * sizeof(sin_dedge_t); + //leaf faces + sin_numleaffaces = 0; + sin_dleaffaces = (unsigned short *) GetClearedMemory(SIN_MAX_MAP_LEAFFACES * sizeof(unsigned short)); + sin_allocatedbspmem += SIN_MAX_MAP_LEAFFACES * sizeof(unsigned short); + //leaf brushes + sin_numleafbrushes = 0; + sin_dleafbrushes = (unsigned short *) GetClearedMemory(SIN_MAX_MAP_LEAFBRUSHES * sizeof(unsigned short)); + sin_allocatedbspmem += SIN_MAX_MAP_LEAFBRUSHES * sizeof(unsigned short); + //surface edges + sin_numsurfedges = 0; + sin_dsurfedges = (int *) GetClearedMemory(SIN_MAX_MAP_SURFEDGES * sizeof(int)); + sin_allocatedbspmem += SIN_MAX_MAP_SURFEDGES * sizeof(int); + //brushes + sin_numbrushes = 0; + sin_dbrushes = (sin_dbrush_t *) GetClearedMemory(SIN_MAX_MAP_BRUSHES * sizeof(sin_dbrush_t)); + sin_allocatedbspmem += SIN_MAX_MAP_BRUSHES * sizeof(sin_dbrush_t); + //brushsides + sin_numbrushsides = 0; + sin_dbrushsides = (sin_dbrushside_t *) GetClearedMemory(SIN_MAX_MAP_BRUSHSIDES * sizeof(sin_dbrushside_t)); + sin_allocatedbspmem += SIN_MAX_MAP_BRUSHSIDES * sizeof(sin_dbrushside_t); + //areas + sin_numareas = 0; + sin_dareas = (sin_darea_t *) GetClearedMemory(SIN_MAX_MAP_AREAS * sizeof(sin_darea_t)); + sin_allocatedbspmem += SIN_MAX_MAP_AREAS * sizeof(sin_darea_t); + //area portals + sin_numareaportals = 0; + sin_dareaportals = (sin_dareaportal_t *) GetClearedMemory(SIN_MAX_MAP_AREAPORTALS * sizeof(sin_dareaportal_t)); + sin_allocatedbspmem += SIN_MAX_MAP_AREAPORTALS * sizeof(sin_dareaportal_t); + //light info + sin_numlightinfo = 0; + sin_lightinfo = (sin_lightvalue_t *) GetClearedMemory(SIN_MAX_MAP_LIGHTINFO * sizeof(sin_lightvalue_t)); + sin_allocatedbspmem += SIN_MAX_MAP_LIGHTINFO * sizeof(sin_lightvalue_t); + //print allocated memory + Log_Print("allocated "); + PrintMemorySize(sin_allocatedbspmem); + Log_Print(" of BSP memory\n"); +} //end of the function Sin_AllocMaxBSP + +void Sin_FreeMaxBSP(void) +{ + //models + sin_nummodels = 0; + FreeMemory(sin_dmodels); + sin_dmodels = NULL; + //vis data + sin_visdatasize = 0; + FreeMemory(sin_dvisdata); + sin_dvisdata = NULL; + sin_dvis = NULL; + //light data + sin_lightdatasize = 0; + FreeMemory(sin_dlightdata); + sin_dlightdata = NULL; + //entity data + sin_entdatasize = 0; + FreeMemory(sin_dentdata); + sin_dentdata = NULL; + //leafs + sin_numleafs = 0; + FreeMemory(sin_dleafs); + sin_dleafs = NULL; + //planes + sin_numplanes = 0; + FreeMemory(sin_dplanes); + sin_dplanes = NULL; + //vertexes + sin_numvertexes = 0; + FreeMemory(sin_dvertexes); + sin_dvertexes = NULL; + //nodes + sin_numnodes = 0; + FreeMemory(sin_dnodes); + sin_dnodes = NULL; + //texture info + sin_numtexinfo = 0; + FreeMemory(sin_texinfo); + sin_texinfo = NULL; + //faces + sin_numfaces = 0; + FreeMemory(sin_dfaces); + sin_dfaces = NULL; + //edges + sin_numedges = 0; + FreeMemory(sin_dedges); + sin_dedges = NULL; + //leaf faces + sin_numleaffaces = 0; + FreeMemory(sin_dleaffaces); + sin_dleaffaces = NULL; + //leaf brushes + sin_numleafbrushes = 0; + FreeMemory(sin_dleafbrushes); + sin_dleafbrushes = NULL; + //surface edges + sin_numsurfedges = 0; + FreeMemory(sin_dsurfedges); + sin_dsurfedges = NULL; + //brushes + sin_numbrushes = 0; + FreeMemory(sin_dbrushes); + sin_dbrushes = NULL; + //brushsides + sin_numbrushsides = 0; + FreeMemory(sin_dbrushsides); + sin_dbrushsides = NULL; + //areas + sin_numareas = 0; + FreeMemory(sin_dareas); + sin_dareas = NULL; + //area portals + sin_numareaportals = 0; + FreeMemory(sin_dareaportals); + sin_dareaportals = NULL; + //light info + sin_numlightinfo = 0; + FreeMemory(sin_lightinfo); + sin_lightinfo = NULL; + // + Log_Print("freed "); + PrintMemorySize(sin_allocatedbspmem); + Log_Print(" of BSP memory\n"); + sin_allocatedbspmem = 0; +} //end of the function Sin_FreeMaxBSP + +#define WCONVEX_EPSILON 0.5 + +//=========================================================================== +// returns the amount the face and the winding overlap +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float Sin_FaceOnWinding(sin_dface_t *face, winding_t *winding) +{ + int i, edgenum, side; + float dist, area; + sin_dplane_t plane; + vec_t *v1, *v2; + vec3_t normal, edgevec; + winding_t *w; + + // + w = CopyWinding(winding); + memcpy(&plane, &sin_dplanes[face->planenum], sizeof(sin_dplane_t)); + //check on which side of the plane the face is + if (face->side) + { + VectorNegate(plane.normal, plane.normal); + plane.dist = -plane.dist; + } //end if + for (i = 0; i < face->numedges && w; i++) + { + //get the first and second vertex of the edge + edgenum = sin_dsurfedges[face->firstedge + i]; + side = edgenum > 0; + //if the face plane is flipped + v1 = sin_dvertexes[sin_dedges[abs(edgenum)].v[side]].point; + v2 = sin_dvertexes[sin_dedges[abs(edgenum)].v[!side]].point; + //create a plane through the edge vector, orthogonal to the face plane + //and with the normal vector pointing out of the face + VectorSubtract(v1, v2, edgevec); + CrossProduct(edgevec, plane.normal, normal); + VectorNormalize(normal); + dist = DotProduct(normal, v1); + // + ChopWindingInPlace(&w, normal, dist, 0.9); //CLIP_EPSILON + } //end for + if (w) + { + area = WindingArea(w); + FreeWinding(w); + return area; + } //end if + return 0; +} //end of the function Sin_FaceOnWinding +//=========================================================================== +// creates a winding for the given brush side on the given brush +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +winding_t *Sin_BrushSideWinding(sin_dbrush_t *brush, sin_dbrushside_t *baseside) +{ + int i; + sin_dplane_t *baseplane, *plane; + sin_dbrushside_t *side; + winding_t *w; + + //create a winding for the brush side with the given planenumber + baseplane = &sin_dplanes[baseside->planenum]; + w = BaseWindingForPlane(baseplane->normal, baseplane->dist); + for (i = 0; i < brush->numsides && w; i++) + { + side = &sin_dbrushsides[brush->firstside + i]; + //don't chop with the base plane + if (side->planenum == baseside->planenum) continue; + //also don't use planes that are almost equal + plane = &sin_dplanes[side->planenum]; + if (DotProduct(baseplane->normal, plane->normal) > 0.999 + && fabs(baseplane->dist - plane->dist) < 0.01) continue; + // + plane = &sin_dplanes[side->planenum^1]; + ChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON); + } //end for + return w; +} //end of the function Sin_BrushSideWinding +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Sin_HintSkipBrush(sin_dbrush_t *brush) +{ + int j; + sin_dbrushside_t *brushside; + + for (j = 0; j < brush->numsides; j++) + { + brushside = &sin_dbrushsides[brush->firstside + j]; + if (brushside->texinfo > 0) + { + if (sin_texinfo[brushside->texinfo].flags & (SURF_SKIP|SURF_HINT)) + { + return true; + } //end if + } //end if + } //end for + return false; +} //end of the function Sin_HintSkipBrush +//=========================================================================== +// fix screwed brush texture references +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean WindingIsTiny(winding_t *w); + +void Sin_FixTextureReferences(void) +{ + int i, j, k, we; + sin_dbrushside_t *brushside; + sin_dbrush_t *brush; + sin_dface_t *face; + winding_t *w; + + memset(sin_dbrushsidetextured, false, SIN_MAX_MAP_BRUSHSIDES); + //go over all the brushes + for (i = 0; i < sin_numbrushes; i++) + { + brush = &sin_dbrushes[i]; + //hint brushes are not textured + if (Sin_HintSkipBrush(brush)) continue; + //go over all the sides of the brush + for (j = 0; j < brush->numsides; j++) + { + brushside = &sin_dbrushsides[brush->firstside + j]; + // + w = Sin_BrushSideWinding(brush, brushside); + if (!w) + { + sin_dbrushsidetextured[brush->firstside + j] = true; + continue; + } //end if + else + { + //RemoveEqualPoints(w, 0.2); + if (WindingIsTiny(w)) + { + FreeWinding(w); + sin_dbrushsidetextured[brush->firstside + j] = true; + continue; + } //end if + else + { + we = WindingError(w); + if (we == WE_NOTENOUGHPOINTS + || we == WE_SMALLAREA + || we == WE_POINTBOGUSRANGE +// || we == WE_NONCONVEX + ) + { + FreeWinding(w); + sin_dbrushsidetextured[brush->firstside + j] = true; + continue; + } //end if + } //end else + } //end else + if (WindingArea(w) < 20) + { + sin_dbrushsidetextured[brush->firstside + j] = true; + } //end if + //find a face for texturing this brush + for (k = 0; k < sin_numfaces; k++) + { + face = &sin_dfaces[k]; + //if the face is in the same plane as the brush side + if ((face->planenum&~1) != (brushside->planenum&~1)) continue; + //if the face is partly or totally on the brush side + if (Sin_FaceOnWinding(face, w)) + { + brushside->texinfo = face->texinfo; + sin_dbrushsidetextured[brush->firstside + j] = true; + break; + } //end if + } //end for + FreeWinding(w); + } //end for + } //end for +} //end of the function Sin_FixTextureReferences*/ + +/* +=============== +CompressVis + +=============== +*/ +int Sin_CompressVis (byte *vis, byte *dest) +{ + int j; + int rep; + int visrow; + byte *dest_p; + + dest_p = dest; +// visrow = (r_numvisleafs + 7)>>3; + visrow = (sin_dvis->numclusters + 7)>>3; + + for (j=0 ; j>3; + row = (sin_dvis->numclusters+7)>>3; + out = decompressed; + + do + { + if (*in) + { + *out++ = *in++; + continue; + } + + c = in[1]; + if (!c) + Error ("DecompressVis: 0 repeat"); + in += 2; + while (c) + { + *out++ = 0; + c--; + } + } while (out - decompressed < row); +} //end of the function Sin_DecompressVis + +//============================================================================= + +/* +============= +Sin_SwapBSPFile + +Byte swaps all data in a bsp file. +============= +*/ +void Sin_SwapBSPFile (qboolean todisk) +{ + int i, j; + sin_dmodel_t *d; + + +// models + for (i=0 ; ifirstface = LittleLong (d->firstface); + d->numfaces = LittleLong (d->numfaces); + d->headnode = LittleLong (d->headnode); + + for (j=0 ; j<3 ; j++) + { + d->mins[j] = LittleFloat(d->mins[j]); + d->maxs[j] = LittleFloat(d->maxs[j]); + d->origin[j] = LittleFloat(d->origin[j]); + } + } + +// +// vertexes +// + for (i=0 ; inumclusters; + else + j = LittleLong(sin_dvis->numclusters); + sin_dvis->numclusters = LittleLong (sin_dvis->numclusters); + for (i=0 ; ibitofs[i][0] = LittleLong (sin_dvis->bitofs[i][0]); + sin_dvis->bitofs[i][1] = LittleLong (sin_dvis->bitofs[i][1]); + } +} //end of the function Sin_SwapBSPFile + + +sin_dheader_t *header; +#ifdef SIN +int Sin_CopyLump (int lump, void *dest, int size, int maxsize) +{ + int length, ofs; + + length = header->lumps[lump].filelen; + ofs = header->lumps[lump].fileofs; + + if (length % size) + Error ("Sin_LoadBSPFile: odd lump size"); + + if ((length/size) > maxsize) + Error ("Sin_LoadBSPFile: exceeded max size for lump %d size %d > maxsize %d\n", lump, (length/size), maxsize ); + + memcpy (dest, (byte *)header + ofs, length); + + return length / size; +} +#else +int Sin_CopyLump (int lump, void *dest, int size) +{ + int length, ofs; + + length = header->lumps[lump].filelen; + ofs = header->lumps[lump].fileofs; + + if (length % size) + Error ("Sin_LoadBSPFile: odd lump size"); + + memcpy (dest, (byte *)header + ofs, length); + + return length / size; +} +#endif + +/* +============= +Sin_LoadBSPFile +============= +*/ +void Sin_LoadBSPFile(char *filename, int offset, int length) +{ + int i; + +// +// load the file header +// + LoadFile (filename, (void **)&header, offset, length); + +// swap the header + for (i=0 ; i< sizeof(sin_dheader_t)/4 ; i++) + ((int *)header)[i] = LittleLong ( ((int *)header)[i]); + + if (header->ident != SIN_BSPHEADER && header->ident != SINGAME_BSPHEADER) + Error ("%s is not a IBSP file", filename); + if (header->version != SIN_BSPVERSION && header->version != SINGAME_BSPVERSION) + Error ("%s is version %i, not %i", filename, header->version, SIN_BSPVERSION); + +#ifdef SIN + sin_nummodels = Sin_CopyLump (SIN_LUMP_MODELS, sin_dmodels, sizeof(sin_dmodel_t), SIN_MAX_MAP_MODELS); + sin_numvertexes = Sin_CopyLump (SIN_LUMP_VERTEXES, sin_dvertexes, sizeof(sin_dvertex_t), SIN_MAX_MAP_VERTS); + sin_numplanes = Sin_CopyLump (SIN_LUMP_PLANES, sin_dplanes, sizeof(sin_dplane_t), SIN_MAX_MAP_PLANES); + sin_numleafs = Sin_CopyLump (SIN_LUMP_LEAFS, sin_dleafs, sizeof(sin_dleaf_t), SIN_MAX_MAP_LEAFS); + sin_numnodes = Sin_CopyLump (SIN_LUMP_NODES, sin_dnodes, sizeof(sin_dnode_t), SIN_MAX_MAP_NODES); + sin_numtexinfo = Sin_CopyLump (SIN_LUMP_TEXINFO, sin_texinfo, sizeof(sin_texinfo_t), SIN_MAX_MAP_TEXINFO); + sin_numfaces = Sin_CopyLump (SIN_LUMP_FACES, sin_dfaces, sizeof(sin_dface_t), SIN_MAX_MAP_FACES); + sin_numleaffaces = Sin_CopyLump (SIN_LUMP_LEAFFACES, sin_dleaffaces, sizeof(sin_dleaffaces[0]), SIN_MAX_MAP_LEAFFACES); + sin_numleafbrushes = Sin_CopyLump (SIN_LUMP_LEAFBRUSHES, sin_dleafbrushes, sizeof(sin_dleafbrushes[0]), SIN_MAX_MAP_LEAFBRUSHES); + sin_numsurfedges = Sin_CopyLump (SIN_LUMP_SURFEDGES, sin_dsurfedges, sizeof(sin_dsurfedges[0]), SIN_MAX_MAP_SURFEDGES); + sin_numedges = Sin_CopyLump (SIN_LUMP_EDGES, sin_dedges, sizeof(sin_dedge_t), SIN_MAX_MAP_EDGES); + sin_numbrushes = Sin_CopyLump (SIN_LUMP_BRUSHES, sin_dbrushes, sizeof(sin_dbrush_t), SIN_MAX_MAP_BRUSHES); + sin_numbrushsides = Sin_CopyLump (SIN_LUMP_BRUSHSIDES, sin_dbrushsides, sizeof(sin_dbrushside_t), SIN_MAX_MAP_BRUSHSIDES); + sin_numareas = Sin_CopyLump (SIN_LUMP_AREAS, sin_dareas, sizeof(sin_darea_t), SIN_MAX_MAP_AREAS); + sin_numareaportals = Sin_CopyLump (SIN_LUMP_AREAPORTALS, sin_dareaportals, sizeof(sin_dareaportal_t), SIN_MAX_MAP_AREAPORTALS); + sin_numlightinfo = Sin_CopyLump (SIN_LUMP_LIGHTINFO, sin_lightinfo, sizeof(sin_lightvalue_t), SIN_MAX_MAP_LIGHTINFO); + + sin_visdatasize = Sin_CopyLump (SIN_LUMP_VISIBILITY, sin_dvisdata, 1, SIN_MAX_MAP_VISIBILITY); + sin_lightdatasize = Sin_CopyLump (SIN_LUMP_LIGHTING, sin_dlightdata, 1, SIN_MAX_MAP_LIGHTING); + sin_entdatasize = Sin_CopyLump (SIN_LUMP_ENTITIES, sin_dentdata, 1, SIN_MAX_MAP_ENTSTRING); + + Sin_CopyLump (SIN_LUMP_POP, sin_dpop, 1, sizeof(sin_dpop)); +#else + sin_nummodels = Sin_CopyLump (SIN_LUMP_MODELS, sin_dmodels, sizeof(sin_dmodel_t)); + sin_numvertexes = Sin_CopyLump (SIN_LUMP_VERTEXES, sin_dvertexes, sizeof(sin_dvertex_t)); + sin_numplanes = Sin_CopyLump (SIN_LUMP_PLANES, sin_dplanes, sizeof(sin_dplane_t)); + sin_numleafs = Sin_CopyLump (SIN_LUMP_LEAFS, sin_dleafs, sizeof(sin_dleaf_t)); + sin_numnodes = Sin_CopyLump (SIN_LUMP_NODES, sin_dnodes, sizeof(sin_dnode_t)); + sin_numtexinfo = Sin_CopyLump (SIN_LUMP_TEXINFO, sin_texinfo, sizeof(sin_texinfo_t)); + sin_numfaces = Sin_CopyLump (SIN_LUMP_FACES, sin_dfaces, sizeof(sin_dface_t)); + sin_numleaffaces = Sin_CopyLump (SIN_LUMP_LEAFFACES, sin_dleaffaces, sizeof(sin_dleaffaces[0])); + sin_numleafbrushes = Sin_CopyLump (SIN_LUMP_LEAFBRUSHES, sin_dleafbrushes, sizeof(sin_dleafbrushes[0])); + sin_numsurfedges = Sin_CopyLump (SIN_LUMP_SURFEDGES, sin_dsurfedges, sizeof(sin_dsurfedges[0])); + sin_numedges = Sin_CopyLump (SIN_LUMP_EDGES, sin_dedges, sizeof(sin_dedge_t)); + sin_numbrushes = Sin_CopyLump (SIN_LUMP_BRUSHES, sin_dbrushes, sizeof(sin_dbrush_t)); + sin_numbrushsides = Sin_CopyLump (SIN_LUMP_BRUSHSIDES, sin_dbrushsides, sizeof(sin_dbrushside_t)); + sin_numareas = Sin_CopyLump (SIN_LUMP_AREAS, sin_dareas, sizeof(sin_darea_t)); + sin_numareaportals = Sin_CopyLump (SIN_LUMP_AREAPORTALS, sin_dareaportals, sizeof(sin_dareaportal_t)); + + sin_visdatasize = Sin_CopyLump (SIN_LUMP_VISIBILITY, sin_dvisdata, 1); + sin_lightdatasize = Sin_CopyLump (SIN_LUMP_LIGHTING, sin_dlightdata, 1); + sin_entdatasize = Sin_CopyLump (SIN_LUMP_ENTITIES, sin_dentdata, 1); + + Sin_CopyLump (SIN_LUMP_POP, sin_dpop, 1); +#endif + + FreeMemory(header); // everything has been copied out + +// +// swap everything +// + Sin_SwapBSPFile (false); +} //end of the function Sin_LoadBSPFile + +/* +============= +Sin_LoadBSPFilesTexinfo + +Only loads the sin_texinfo lump, so qdata can scan for textures +============= +*/ +void Sin_LoadBSPFileTexinfo (char *filename) +{ + int i; + FILE *f; + int length, ofs; + + header = GetMemory(sizeof(sin_dheader_t)); + + f = fopen (filename, "rb"); + fread (header, sizeof(sin_dheader_t), 1, f); + +// swap the header + for (i=0 ; i< sizeof(sin_dheader_t)/4 ; i++) + ((int *)header)[i] = LittleLong ( ((int *)header)[i]); + + if (header->ident != SIN_BSPHEADER && header->ident != SINGAME_BSPHEADER) + Error ("%s is not a IBSP file", filename); + if (header->version != SIN_BSPVERSION && header->version != SINGAME_BSPVERSION) + Error ("%s is version %i, not %i", filename, header->version, SIN_BSPVERSION); + + + length = header->lumps[SIN_LUMP_TEXINFO].filelen; + ofs = header->lumps[SIN_LUMP_TEXINFO].fileofs; + + fseek (f, ofs, SEEK_SET); + fread (sin_texinfo, length, 1, f); + fclose (f); + + sin_numtexinfo = length / sizeof(sin_texinfo_t); + + FreeMemory(header); // everything has been copied out + + Sin_SwapBSPFile (false); +} //end of the function Sin_LoadBSPFilesTexinfo + + +//============================================================================ + +FILE *wadfile; +sin_dheader_t outheader; + +#ifdef SIN +void Sin_AddLump (int lumpnum, void *data, int len, int size, int maxsize) +{ + sin_lump_t *lump; + int totallength; + + totallength = len*size; + + if (len > maxsize) + Error ("Sin_WriteBSPFile: exceeded max size for lump %d size %d > maxsize %d\n", lumpnum, len, maxsize ); + + lump = &header->lumps[lumpnum]; + + lump->fileofs = LittleLong( ftell(wadfile) ); + lump->filelen = LittleLong(totallength); + SafeWrite (wadfile, data, (totallength+3)&~3); +} +#else +void Sin_AddLump (int lumpnum, void *data, int len) +{ + sin_lump_t *lump; + + lump = &header->lumps[lumpnum]; + + lump->fileofs = LittleLong( ftell(wadfile) ); + lump->filelen = LittleLong(len); + SafeWrite (wadfile, data, (len+3)&~3); +} +#endif +/* +============= +Sin_WriteBSPFile + +Swaps the bsp file in place, so it should not be referenced again +============= +*/ +void Sin_WriteBSPFile (char *filename) +{ + header = &outheader; + memset (header, 0, sizeof(sin_dheader_t)); + + Sin_SwapBSPFile (true); + + header->ident = LittleLong (SIN_BSPHEADER); + header->version = LittleLong (SIN_BSPVERSION); + + wadfile = SafeOpenWrite (filename); + SafeWrite (wadfile, header, sizeof(sin_dheader_t)); // overwritten later + +#ifdef SIN + Sin_AddLump (SIN_LUMP_PLANES, sin_dplanes, sin_numplanes, sizeof(sin_dplane_t), SIN_MAX_MAP_PLANES); + Sin_AddLump (SIN_LUMP_LEAFS, sin_dleafs, sin_numleafs, sizeof(sin_dleaf_t), SIN_MAX_MAP_LEAFS); + Sin_AddLump (SIN_LUMP_VERTEXES, sin_dvertexes, sin_numvertexes, sizeof(sin_dvertex_t), SIN_MAX_MAP_VERTS); + Sin_AddLump (SIN_LUMP_NODES, sin_dnodes, sin_numnodes, sizeof(sin_dnode_t), SIN_MAX_MAP_NODES); + Sin_AddLump (SIN_LUMP_TEXINFO, sin_texinfo, sin_numtexinfo, sizeof(sin_texinfo_t), SIN_MAX_MAP_TEXINFO); + Sin_AddLump (SIN_LUMP_FACES, sin_dfaces, sin_numfaces, sizeof(sin_dface_t), SIN_MAX_MAP_FACES); + Sin_AddLump (SIN_LUMP_BRUSHES, sin_dbrushes, sin_numbrushes, sizeof(sin_dbrush_t), SIN_MAX_MAP_BRUSHES); + Sin_AddLump (SIN_LUMP_BRUSHSIDES, sin_dbrushsides, sin_numbrushsides, sizeof(sin_dbrushside_t), SIN_MAX_MAP_BRUSHSIDES); + Sin_AddLump (SIN_LUMP_LEAFFACES, sin_dleaffaces, sin_numleaffaces, sizeof(sin_dleaffaces[0]), SIN_MAX_MAP_LEAFFACES); + Sin_AddLump (SIN_LUMP_LEAFBRUSHES, sin_dleafbrushes, sin_numleafbrushes, sizeof(sin_dleafbrushes[0]), SIN_MAX_MAP_LEAFBRUSHES); + Sin_AddLump (SIN_LUMP_SURFEDGES, sin_dsurfedges, sin_numsurfedges, sizeof(sin_dsurfedges[0]), SIN_MAX_MAP_SURFEDGES); + Sin_AddLump (SIN_LUMP_EDGES, sin_dedges, sin_numedges, sizeof(sin_dedge_t), SIN_MAX_MAP_EDGES); + Sin_AddLump (SIN_LUMP_MODELS, sin_dmodels, sin_nummodels, sizeof(sin_dmodel_t), SIN_MAX_MAP_MODELS); + Sin_AddLump (SIN_LUMP_AREAS, sin_dareas, sin_numareas, sizeof(sin_darea_t), SIN_MAX_MAP_AREAS); + Sin_AddLump (SIN_LUMP_AREAPORTALS, sin_dareaportals, sin_numareaportals, sizeof(sin_dareaportal_t), SIN_MAX_MAP_AREAPORTALS); + Sin_AddLump (SIN_LUMP_LIGHTINFO, sin_lightinfo, sin_numlightinfo, sizeof(sin_lightvalue_t), SIN_MAX_MAP_LIGHTINFO); + + Sin_AddLump (SIN_LUMP_LIGHTING, sin_dlightdata, sin_lightdatasize, 1, SIN_MAX_MAP_LIGHTING); + Sin_AddLump (SIN_LUMP_VISIBILITY, sin_dvisdata, sin_visdatasize, 1, SIN_MAX_MAP_VISIBILITY); + Sin_AddLump (SIN_LUMP_ENTITIES, sin_dentdata, sin_entdatasize, 1, SIN_MAX_MAP_ENTSTRING); + Sin_AddLump (SIN_LUMP_POP, sin_dpop, sizeof(sin_dpop), 1, sizeof(sin_dpop)); +#else + Sin_AddLump (SIN_LUMP_PLANES, sin_dplanes, sin_numplanes*sizeof(sin_dplane_t)); + Sin_AddLump (SIN_LUMP_LEAFS, sin_dleafs, sin_numleafs*sizeof(sin_dleaf_t)); + Sin_AddLump (SIN_LUMP_VERTEXES, sin_dvertexes, sin_numvertexes*sizeof(sin_dvertex_t)); + Sin_AddLump (SIN_LUMP_NODES, sin_dnodes, sin_numnodes*sizeof(sin_dnode_t)); + Sin_AddLump (SIN_LUMP_TEXINFO, sin_texinfo, sin_numtexinfo*sizeof(sin_texinfo_t)); + Sin_AddLump (SIN_LUMP_FACES, sin_dfaces, sin_numfaces*sizeof(sin_dface_t)); + Sin_AddLump (SIN_LUMP_BRUSHES, sin_dbrushes, sin_numbrushes*sizeof(sin_dbrush_t)); + Sin_AddLump (SIN_LUMP_BRUSHSIDES, sin_dbrushsides, sin_numbrushsides*sizeof(sin_dbrushside_t)); + Sin_AddLump (SIN_LUMP_LEAFFACES, sin_dleaffaces, sin_numleaffaces*sizeof(sin_dleaffaces[0])); + Sin_AddLump (SIN_LUMP_LEAFBRUSHES, sin_dleafbrushes, sin_numleafbrushes*sizeof(sin_dleafbrushes[0])); + Sin_AddLump (SIN_LUMP_SURFEDGES, sin_dsurfedges, sin_numsurfedges*sizeof(sin_dsurfedges[0])); + Sin_AddLump (SIN_LUMP_EDGES, sin_dedges, sin_numedges*sizeof(sin_dedge_t)); + Sin_AddLump (SIN_LUMP_MODELS, sin_dmodels, sin_nummodels*sizeof(sin_dmodel_t)); + Sin_AddLump (SIN_LUMP_AREAS, sin_dareas, sin_numareas*sizeof(sin_darea_t)); + Sin_AddLump (SIN_LUMP_AREAPORTALS, sin_dareaportals, sin_numareaportals*sizeof(sin_dareaportal_t)); + + Sin_AddLump (SIN_LUMP_LIGHTING, sin_dlightdata, sin_lightdatasize); + Sin_AddLump (SIN_LUMP_VISIBILITY, sin_dvisdata, sin_visdatasize); + Sin_AddLump (SIN_LUMP_ENTITIES, sin_dentdata, sin_entdatasize); + Sin_AddLump (SIN_LUMP_POP, sin_dpop, sizeof(sin_dpop)); +#endif + + fseek (wadfile, 0, SEEK_SET); + SafeWrite (wadfile, header, sizeof(sin_dheader_t)); + fclose (wadfile); +} + +//============================================================================ + + +//============================================ + +/* +================ +ParseEntities + +Parses the sin_dentdata string into entities +================ +*/ +void Sin_ParseEntities (void) +{ + script_t *script; + + num_entities = 0; + script = LoadScriptMemory(sin_dentdata, sin_entdatasize, "*sin bsp file"); + SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES | + SCFL_NOSTRINGESCAPECHARS); + + while(ParseEntity(script)) + { + } //end while + + FreeScript(script); +} //end of the function Sin_ParseEntities + + +/* +================ +UnparseEntities + +Generates the sin_dentdata string from all the entities +================ +*/ +void Sin_UnparseEntities (void) +{ + char *buf, *end; + epair_t *ep; + char line[2048]; + int i; + char key[1024], value[1024]; + + buf = sin_dentdata; + end = buf; + *end = 0; + + for (i=0 ; inext) + { + strcpy (key, ep->key); + StripTrailing (key); + strcpy (value, ep->value); + StripTrailing (value); + + sprintf (line, "\"%s\" \"%s\"\n", key, value); + strcat (end, line); + end += strlen(line); + } + strcat (end,"}\n"); + end += 2; + + if (end > buf + SIN_MAX_MAP_ENTSTRING) + Error ("Entity text too long"); + } + sin_entdatasize = end - buf + 1; +} //end of the function Sin_UnparseEntities + +#ifdef SIN +void FreeValueKeys(entity_t *ent) +{ + epair_t *ep,*next; + + for (ep=ent->epairs ; ep ; ep=next) + { + next = ep->next; + FreeMemory(ep->value); + FreeMemory(ep->key); + FreeMemory(ep); + } + ent->epairs = NULL; +} +#endif + +/* +============= +Sin_PrintBSPFileSizes + +Dumps info about current file +============= +*/ +void Sin_PrintBSPFileSizes (void) +{ + if (!num_entities) + Sin_ParseEntities (); + + Log_Print("%6i models %7i\n" + ,sin_nummodels, (int)(sin_nummodels*sizeof(sin_dmodel_t))); + Log_Print("%6i brushes %7i\n" + ,sin_numbrushes, (int)(sin_numbrushes*sizeof(sin_dbrush_t))); + Log_Print("%6i brushsides %7i\n" + ,sin_numbrushsides, (int)(sin_numbrushsides*sizeof(sin_dbrushside_t))); + Log_Print("%6i planes %7i\n" + ,sin_numplanes, (int)(sin_numplanes*sizeof(sin_dplane_t))); + Log_Print("%6i texinfo %7i\n" + ,sin_numtexinfo, (int)(sin_numtexinfo*sizeof(sin_texinfo_t))); +#ifdef SIN + Log_Print("%6i lightinfo %7i\n" + ,sin_numlightinfo, (int)(sin_numlightinfo*sizeof(sin_lightvalue_t))); +#endif + Log_Print("%6i entdata %7i\n", num_entities, sin_entdatasize); + + Log_Print("\n"); + + Log_Print("%6i vertexes %7i\n" + ,sin_numvertexes, (int)(sin_numvertexes*sizeof(sin_dvertex_t))); + Log_Print("%6i nodes %7i\n" + ,sin_numnodes, (int)(sin_numnodes*sizeof(sin_dnode_t))); + Log_Print("%6i faces %7i\n" + ,sin_numfaces, (int)(sin_numfaces*sizeof(sin_dface_t))); + Log_Print("%6i leafs %7i\n" + ,sin_numleafs, (int)(sin_numleafs*sizeof(sin_dleaf_t))); + Log_Print("%6i leaffaces %7i\n" + ,sin_numleaffaces, (int)(sin_numleaffaces*sizeof(sin_dleaffaces[0]))); + Log_Print("%6i leafbrushes %7i\n" + ,sin_numleafbrushes, (int)(sin_numleafbrushes*sizeof(sin_dleafbrushes[0]))); + Log_Print("%6i surfedges %7i\n" + ,sin_numsurfedges, (int)(sin_numsurfedges*sizeof(sin_dsurfedges[0]))); + Log_Print("%6i edges %7i\n" + ,sin_numedges, (int)(sin_numedges*sizeof(sin_dedge_t))); + Log_Print(" lightdata %7i\n", sin_lightdatasize); + Log_Print(" visdata %7i\n", sin_visdatasize); +} diff --git a/code/bspc/l_bsp_sin.h b/code/bspc/l_bsp_sin.h new file mode 100644 index 00000000..862674b1 --- /dev/null +++ b/code/bspc/l_bsp_sin.h @@ -0,0 +1,106 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "sinfiles.h" + +#define SINGAME_BSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'R') //RBSP +#define SINGAME_BSPVERSION 1 + +#define SIN_BSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I') //IBSP +#define SIN_BSPVERSION 41 + + +extern int sin_nummodels; +extern sin_dmodel_t *sin_dmodels;//[MAX_MAP_MODELS]; + +extern int sin_visdatasize; +extern byte *sin_dvisdata;//[MAX_MAP_VISIBILITY]; +extern sin_dvis_t *sin_dvis;// = (dvis_t *)sin_sin_dvisdata; + +extern int sin_lightdatasize; +extern byte *sin_dlightdata;//[MAX_MAP_LIGHTING]; + +extern int sin_entdatasize; +extern char *sin_dentdata;//[MAX_MAP_ENTSTRING]; + +extern int sin_numleafs; +extern sin_dleaf_t *sin_dleafs;//[MAX_MAP_LEAFS]; + +extern int sin_numplanes; +extern sin_dplane_t *sin_dplanes;//[MAX_MAP_PLANES]; + +extern int sin_numvertexes; +extern sin_dvertex_t *sin_dvertexes;//[MAX_MAP_VERTS]; + +extern int sin_numnodes; +extern sin_dnode_t *sin_dnodes;//[MAX_MAP_NODES]; + +extern int sin_numtexinfo; +extern sin_texinfo_t *sin_texinfo;//[MAX_MAP_sin_texinfo]; + +extern int sin_numfaces; +extern sin_dface_t *sin_dfaces;//[MAX_MAP_FACES]; + +extern int sin_numedges; +extern sin_dedge_t *sin_dedges;//[MAX_MAP_EDGES]; + +extern int sin_numleaffaces; +extern unsigned short *sin_dleaffaces;//[MAX_MAP_LEAFFACES]; + +extern int sin_numleafbrushes; +extern unsigned short *sin_dleafbrushes;//[MAX_MAP_LEAFBRUSHES]; + +extern int sin_numsurfedges; +extern int *sin_dsurfedges;//[MAX_MAP_SURFEDGES]; + +extern int sin_numbrushes; +extern sin_dbrush_t *sin_dbrushes;//[MAX_MAP_BRUSHES]; + +extern int sin_numbrushsides; +extern sin_dbrushside_t *sin_dbrushsides;//[MAX_MAP_BRUSHSIDES]; + +extern int sin_numareas; +extern sin_darea_t *sin_dareas;//[MAX_MAP_AREAS]; + +extern int sin_numareaportals; +extern sin_dareaportal_t *sin_dareaportals;//[MAX_MAP_AREAPORTALS]; + +extern int sin_numlightinfo; +extern sin_lightvalue_t *sin_lightinfo;//[MAX_MAP_LIGHTINFO]; + +extern byte sin_dpop[256]; + +extern char sin_dbrushsidetextured[SIN_MAX_MAP_BRUSHSIDES]; + +void Sin_AllocMaxBSP(void); +void Sin_FreeMaxBSP(void); + +void Sin_DecompressVis(byte *in, byte *decompressed); +int Sin_CompressVis(byte *vis, byte *dest); + +void Sin_LoadBSPFile (char *filename, int offset, int length); +void Sin_LoadBSPFileTexinfo (char *filename); // just for qdata +void Sin_WriteBSPFile (char *filename); +void Sin_PrintBSPFileSizes (void); +void Sin_ParseEntities(void); +void Sin_UnparseEntities(void); + diff --git a/code/bspc/l_cmd.c b/code/bspc/l_cmd.c new file mode 100644 index 00000000..e35104b2 --- /dev/null +++ b/code/bspc/l_cmd.c @@ -0,0 +1,1230 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +// cmdlib.c + +#include "l_cmd.h" +#include "l_log.h" +#include "l_mem.h" +#include +#include + +#ifndef SIN +#define SIN +#endif //SIN + +#if defined(WIN32) || defined(_WIN32) +#include +#else +#include +#endif + +#ifdef NeXT +#include +#endif + +#define BASEDIRNAME "quake2" +#define PATHSEPERATOR '/' + +// set these before calling CheckParm +int myargc; +char **myargv; + +char com_token[1024]; +qboolean com_eof; + +qboolean archive; +char archivedir[1024]; + + +/* +=================== +ExpandWildcards + +Mimic unix command line expansion +=================== +*/ +#define MAX_EX_ARGC 1024 +int ex_argc; +char *ex_argv[MAX_EX_ARGC]; +#ifdef _WIN32 +#include "io.h" +void ExpandWildcards (int *argc, char ***argv) +{ + struct _finddata_t fileinfo; + int handle; + int i; + char filename[1024]; + char filebase[1024]; + char *path; + + ex_argc = 0; + for (i=0 ; i<*argc ; i++) + { + path = (*argv)[i]; + if ( path[0] == '-' + || ( !strstr(path, "*") && !strstr(path, "?") ) ) + { + ex_argv[ex_argc++] = path; + continue; + } + + handle = _findfirst (path, &fileinfo); + if (handle == -1) + return; + + ExtractFilePath (path, filebase); + + do + { + sprintf (filename, "%s%s", filebase, fileinfo.name); + ex_argv[ex_argc++] = copystring (filename); + } while (_findnext( handle, &fileinfo ) != -1); + + _findclose (handle); + } + + *argc = ex_argc; + *argv = ex_argv; +} +#else +void ExpandWildcards (int *argc, char ***argv) +{ +} +#endif + +#ifdef WINBSPC + +#include + +HWND program_hwnd; + +void SetProgramHandle(HWND hwnd) +{ + program_hwnd = hwnd; +} //end of the function SetProgramHandle + +/* +================= +Error + +For abnormal program terminations in windowed apps +================= +*/ +void Error (char *error, ...) +{ + va_list argptr; + char text[1024]; + char text2[1024]; + int err; + + err = GetLastError (); + + va_start(argptr, error); + vsprintf(text, error, argptr); + va_end(argptr); + + sprintf(text2, "%s\nGetLastError() = %i", text, err); + MessageBox(program_hwnd, text2, "Error", 0 /* MB_OK */ ); + + Log_Write(text); + Log_Close(); + + exit(1); +} //end of the function Error + +void Warning(char *szFormat, ...) +{ + char szBuffer[256]; + va_list argptr; + + va_start (argptr, szFormat); + vsprintf(szBuffer, szFormat, argptr); + va_end (argptr); + + MessageBox(program_hwnd, szBuffer, "Warning", MB_OK); + + Log_Write(szBuffer); +} //end of the function Warning + + +#else +/* +================= +Error + +For abnormal program terminations in console apps +================= +*/ +void Error (char *error, ...) +{ + va_list argptr; + char text[1024]; + + va_start(argptr, error); + vsprintf(text, error, argptr); + va_end(argptr); + printf("ERROR: %s\n", text); + + Log_Write(text); + Log_Close(); + + exit (1); +} //end of the function Error + +void Warning(char *warning, ...) +{ + va_list argptr; + char text[1024]; + + va_start(argptr, warning); + vsprintf(text, warning, argptr); + va_end(argptr); + printf("WARNING: %s\n", text); + + Log_Write(text); +} //end of the function Warning + +#endif + +//only printf if in verbose mode +qboolean verbose = true; + +void qprintf(char *format, ...) +{ + va_list argptr; +#ifdef WINBSPC + char buf[2048]; +#endif //WINBSPC + + if (!verbose) + return; + + va_start(argptr,format); +#ifdef WINBSPC + vsprintf(buf, format, argptr); + WinBSPCPrint(buf); +#else + vprintf(format, argptr); +#endif //WINBSPC + va_end(argptr); +} //end of the function qprintf + +void Com_Error(int level, char *error, ...) +{ + va_list argptr; + char text[1024]; + + va_start(argptr, error); + vsprintf(text, error, argptr); + va_end(argptr); + Error(text); +} //end of the funcion Com_Error + +void Com_Printf( const char *fmt, ... ) +{ + va_list argptr; + char text[1024]; + + va_start(argptr, fmt); + vsprintf(text, fmt, argptr); + va_end(argptr); + Log_Print(text); +} //end of the funcion Com_Printf + +/* + +qdir will hold the path up to the quake directory, including the slash + + f:\quake\ + /raid/quake/ + +gamedir will hold qdir + the game directory (id1, id2, etc) + + */ + +char qdir[1024]; +char gamedir[1024]; + +void SetQdirFromPath (char *path) +{ + char temp[1024]; + char *c; + int len; + + if (!(path[0] == '/' || path[0] == '\\' || path[1] == ':')) + { // path is partial + Q_getwd (temp); + strcat (temp, path); + path = temp; + } + + // search for "quake2" in path + + len = strlen(BASEDIRNAME); + for (c=path+strlen(path)-1 ; c != path ; c--) + if (!Q_strncasecmp (c, BASEDIRNAME, len)) + { + strncpy (qdir, path, c+len+1-path); + qprintf ("qdir: %s\n", qdir); + c += len+1; + while (*c) + { + if (*c == '/' || *c == '\\') + { + strncpy (gamedir, path, c+1-path); + qprintf ("gamedir: %s\n", gamedir); + return; + } + c++; + } + Error ("No gamedir in %s", path); + return; + } + Error ("SetQdirFromPath: no '%s' in %s", BASEDIRNAME, path); +} + +char *ExpandArg (char *path) +{ + static char full[1024]; + + if (path[0] != '/' && path[0] != '\\' && path[1] != ':') + { + Q_getwd (full); + strcat (full, path); + } + else + strcpy (full, path); + return full; +} + +char *ExpandPath (char *path) +{ + static char full[1024]; + if (!qdir) + Error ("ExpandPath called without qdir set"); + if (path[0] == '/' || path[0] == '\\' || path[1] == ':') + return path; + sprintf (full, "%s%s", qdir, path); + return full; +} + +char *ExpandPathAndArchive (char *path) +{ + char *expanded; + char archivename[1024]; + + expanded = ExpandPath (path); + + if (archive) + { + sprintf (archivename, "%s/%s", archivedir, path); + QCopyFile (expanded, archivename); + } + return expanded; +} + + +char *copystring(char *s) +{ + char *b; + b = GetMemory(strlen(s)+1); + strcpy (b, s); + return b; +} + + + +/* +================ +I_FloatTime +================ +*/ +double I_FloatTime (void) +{ + time_t t; + + time (&t); + + return t; +#if 0 +// more precise, less portable + struct timeval tp; + struct timezone tzp; + static int secbase; + + gettimeofday(&tp, &tzp); + + if (!secbase) + { + secbase = tp.tv_sec; + return tp.tv_usec/1000000.0; + } + + return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0; +#endif +} + +void Q_getwd (char *out) +{ +#if defined(WIN32) || defined(_WIN32) + getcwd (out, 256); + strcat (out, "\\"); +#else + getwd(out); + strcat(out, "/"); +#endif +} + + +void Q_mkdir (char *path) +{ +#ifdef WIN32 + if (_mkdir (path) != -1) + return; +#else + if (mkdir (path, 0777) != -1) + return; +#endif + if (errno != EEXIST) + Error ("mkdir %s: %s",path, strerror(errno)); +} + +/* +============ +FileTime + +returns -1 if not present +============ +*/ +int FileTime (char *path) +{ + struct stat buf; + + if (stat (path,&buf) == -1) + return -1; + + return buf.st_mtime; +} + + + +/* +============== +COM_Parse + +Parse a token out of a string +============== +*/ +char *COM_Parse (char *data) +{ + int c; + int len; + + len = 0; + com_token[0] = 0; + + if (!data) + return NULL; + +// skip whitespace +skipwhite: + while ( (c = *data) <= ' ') + { + if (c == 0) + { + com_eof = true; + return NULL; // end of file; + } + data++; + } + +// skip // comments + if (c=='/' && data[1] == '/') + { + while (*data && *data != '\n') + data++; + goto skipwhite; + } + + +// handle quoted strings specially + if (c == '\"') + { + data++; + do + { + c = *data++; + if (c=='\"') + { + com_token[len] = 0; + return data; + } + com_token[len] = c; + len++; + } while (1); + } + +// parse single characters + if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':') + { + com_token[len] = c; + len++; + com_token[len] = 0; + return data+1; + } + +// parse a regular word + do + { + com_token[len] = c; + data++; + len++; + c = *data; + if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':') + break; + } while (c>32); + + com_token[len] = 0; + return data; +} + + +int Q_strncasecmp (char *s1, char *s2, int n) +{ + int c1, c2; + + do + { + c1 = *s1++; + c2 = *s2++; + + if (!n--) + return 0; // strings are equal until end point + + if (c1 != c2) + { + if (c1 >= 'a' && c1 <= 'z') + c1 -= ('a' - 'A'); + if (c2 >= 'a' && c2 <= 'z') + c2 -= ('a' - 'A'); + if (c1 != c2) + return -1; // strings not equal + } + } while (c1); + + return 0; // strings are equal +} + +int Q_strcasecmp (char *s1, char *s2) +{ + return Q_strncasecmp (s1, s2, 99999); +} + +int Q_stricmp (char *s1, char *s2) +{ + return Q_strncasecmp (s1, s2, 99999); +} + +void Q_strncpyz( char *dest, const char *src, int destsize ) { + strncpy( dest, src, destsize-1 ); + dest[destsize-1] = 0; +} + +char *strupr (char *start) +{ + char *in; + in = start; + while (*in) + { + *in = toupper(*in); + in++; + } + return start; +} + +char *strlower (char *start) +{ + char *in; + in = start; + while (*in) + { + *in = tolower(*in); + in++; + } + return start; +} + + +/* +============================================================================= + + MISC FUNCTIONS + +============================================================================= +*/ + + +/* +================= +CheckParm + +Checks for the given parameter in the program's command line arguments +Returns the argument number (1 to argc-1) or 0 if not present +================= +*/ +int CheckParm (char *check) +{ + int i; + + for (i = 1;i 0 && path[length] != PATHSEPERATOR) + length--; + path[length] = 0; +} + +void StripExtension (char *path) +{ + int length; + + length = strlen(path)-1; + while (length > 0 && path[length] != '.') + { + length--; + if (path[length] == '/') + return; // no extension + } + if (length) + path[length] = 0; +} + + +/* +==================== +Extract file parts +==================== +*/ +// FIXME: should include the slash, otherwise +// backing to an empty path will be wrong when appending a slash +void ExtractFilePath (char *path, char *dest) +{ + char *src; + + src = path + strlen(path) - 1; + +// +// back up until a \ or the start +// + while (src != path && *(src-1) != '\\' && *(src-1) != '/') + src--; + + memcpy (dest, path, src-path); + dest[src-path] = 0; +} + +void ExtractFileBase (char *path, char *dest) +{ + char *src; + + src = path + strlen(path) - 1; + +// +// back up until a \ or the start +// + while (src != path && *(src-1) != '\\' && *(src-1) != '/') + src--; + + while (*src && *src != '.') + { + *dest++ = *src++; + } + *dest = 0; +} + +void ExtractFileExtension (char *path, char *dest) +{ + char *src; + + src = path + strlen(path) - 1; + +// +// back up until a . or the start +// + while (src != path && *(src-1) != '.') + src--; + if (src == path) + { + *dest = 0; // no extension + return; + } + + strcpy (dest,src); +} + + +/* +============== +ParseNum / ParseHex +============== +*/ +int ParseHex (char *hex) +{ + char *str; + int num; + + num = 0; + str = hex; + + while (*str) + { + num <<= 4; + if (*str >= '0' && *str <= '9') + num += *str-'0'; + else if (*str >= 'a' && *str <= 'f') + num += 10 + *str-'a'; + else if (*str >= 'A' && *str <= 'F') + num += 10 + *str-'A'; + else + Error ("Bad hex number: %s",hex); + str++; + } + + return num; +} + + +int ParseNum (char *str) +{ + if (str[0] == '$') + return ParseHex (str+1); + if (str[0] == '0' && str[1] == 'x') + return ParseHex (str+2); + return atol (str); +} + + + +/* +============================================================================ + + BYTE ORDER FUNCTIONS + +============================================================================ +*/ + +#ifdef _SGI_SOURCE +#define __BIG_ENDIAN__ +#endif + +#ifdef __BIG_ENDIAN__ + +short LittleShort (short l) +{ + byte b1,b2; + + b1 = l&255; + b2 = (l>>8)&255; + + return (b1<<8) + b2; +} + +short BigShort (short l) +{ + return l; +} + + +int LittleLong (int l) +{ + byte b1,b2,b3,b4; + + b1 = l&255; + b2 = (l>>8)&255; + b3 = (l>>16)&255; + b4 = (l>>24)&255; + + return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4; +} + +int BigLong (int l) +{ + return l; +} + + +float LittleFloat (float l) +{ + union {byte b[4]; float f;} in, out; + + in.f = l; + out.b[0] = in.b[3]; + out.b[1] = in.b[2]; + out.b[2] = in.b[1]; + out.b[3] = in.b[0]; + + return out.f; +} + +float BigFloat (float l) +{ + return l; +} + +#ifdef SIN +unsigned short LittleUnsignedShort (unsigned short l) +{ + byte b1,b2; + + b1 = l&255; + b2 = (l>>8)&255; + + return (b1<<8) + b2; +} + +unsigned short BigUnsignedShort (unsigned short l) +{ + return l; +} + +unsigned LittleUnsigned (unsigned l) +{ + byte b1,b2,b3,b4; + + b1 = l&255; + b2 = (l>>8)&255; + b3 = (l>>16)&255; + b4 = (l>>24)&255; + + return ((unsigned)b1<<24) + ((unsigned)b2<<16) + ((unsigned)b3<<8) + b4; +} + +unsigned BigUnsigned (unsigned l) +{ + return l; +} +#endif + + +#else + + +short BigShort (short l) +{ + byte b1,b2; + + b1 = l&255; + b2 = (l>>8)&255; + + return (b1<<8) + b2; +} + +short LittleShort (short l) +{ + return l; +} + + +int BigLong (int l) +{ + byte b1,b2,b3,b4; + + b1 = l&255; + b2 = (l>>8)&255; + b3 = (l>>16)&255; + b4 = (l>>24)&255; + + return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4; +} + +int LittleLong (int l) +{ + return l; +} + +float BigFloat (float l) +{ + union {byte b[4]; float f;} in, out; + + in.f = l; + out.b[0] = in.b[3]; + out.b[1] = in.b[2]; + out.b[2] = in.b[1]; + out.b[3] = in.b[0]; + + return out.f; +} + +float LittleFloat (float l) +{ + return l; +} + +#ifdef SIN +unsigned short BigUnsignedShort (unsigned short l) +{ + byte b1,b2; + + b1 = l&255; + b2 = (l>>8)&255; + + return (b1<<8) + b2; +} + +unsigned short LittleUnsignedShort (unsigned short l) +{ + return l; +} + + +unsigned BigUnsigned (unsigned l) +{ + byte b1,b2,b3,b4; + + b1 = l&255; + b2 = (l>>8)&255; + b3 = (l>>16)&255; + b4 = (l>>24)&255; + + return ((unsigned)b1<<24) + ((unsigned)b2<<16) + ((unsigned)b3<<8) + b4; +} + +unsigned LittleUnsigned (unsigned l) +{ + return l; +} +#endif + + +#endif + + +//======================================================= + + +// FIXME: byte swap? + +// this is a 16 bit, non-reflected CRC using the polynomial 0x1021 +// and the initial and final xor values shown below... in other words, the +// CCITT standard CRC used by XMODEM + +#define CRC_INIT_VALUE 0xffff +#define CRC_XOR_VALUE 0x0000 + +static unsigned short crctable[256] = +{ + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, + 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, + 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, + 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, + 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, + 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, + 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, + 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, + 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, + 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, + 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, + 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, + 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, + 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, + 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, + 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, + 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, + 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, + 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, + 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, + 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, + 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, + 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 +}; + +void CRC_Init(unsigned short *crcvalue) +{ + *crcvalue = CRC_INIT_VALUE; +} + +void CRC_ProcessByte(unsigned short *crcvalue, byte data) +{ + *crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data]; +} + +unsigned short CRC_Value(unsigned short crcvalue) +{ + return crcvalue ^ CRC_XOR_VALUE; +} +//============================================================================= + +/* +============ +CreatePath +============ +*/ +void CreatePath (char *path) +{ + char *ofs, c; + + if (path[1] == ':') + path += 2; + + for (ofs = path+1 ; *ofs ; ofs++) + { + c = *ofs; + if (c == '/' || c == '\\') + { // create the directory + *ofs = 0; + Q_mkdir (path); + *ofs = c; + } + } +} + + +/* +============ +QCopyFile + + Used to archive source files +============ +*/ +void QCopyFile (char *from, char *to) +{ + void *buffer; + int length; + + length = LoadFile (from, &buffer, 0, 0); + CreatePath (to); + SaveFile (to, buffer, length); + FreeMemory(buffer); +} + +void FS_FreeFile(void *buf) +{ + FreeMemory(buf); +} //end of the function FS_FreeFile + +int FS_ReadFileAndCache(const char *qpath, void **buffer) +{ + return LoadFile((char *) qpath, buffer, 0, 0); +} //end of the function FS_ReadFileAndCache + +int FS_FOpenFileRead( const char *filename, FILE **file, qboolean uniqueFILE ) +{ + *file = fopen(filename, "rb"); + return (*file != NULL); +} //end of the function FS_FOpenFileRead diff --git a/code/bspc/l_cmd.h b/code/bspc/l_cmd.h new file mode 100644 index 00000000..613cafaa --- /dev/null +++ b/code/bspc/l_cmd.h @@ -0,0 +1,157 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ +// cmdlib.h + +#ifndef SIN +#define SIN +#endif //SIN + +#ifndef __CMDLIB__ +#define __CMDLIB__ + +#ifdef _WIN32 +#pragma warning(disable : 4244) // MIPS +#pragma warning(disable : 4136) // X86 +#pragma warning(disable : 4051) // ALPHA + +#pragma warning(disable : 4018) // signed/unsigned mismatch +#pragma warning(disable : 4305) // truncate from double to float +#endif + +#include +#include +#include +#include +#include +#include +#include + +#ifndef __BYTEBOOL__ +#define __BYTEBOOL__ +typedef enum {false, true} qboolean; +typedef unsigned char byte; +#endif + +// the dec offsetof macro doesnt work very well... +#define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier) + + +// set these before calling CheckParm +extern int myargc; +extern char **myargv; + +char *strupr (char *in); +char *strlower (char *in); +int Q_strncasecmp (char *s1, char *s2, int n); +int Q_strcasecmp (char *s1, char *s2); +void Q_getwd (char *out); + +int Q_filelength (FILE *f); +int FileTime (char *path); + +void Q_mkdir (char *path); + +extern char qdir[1024]; +extern char gamedir[1024]; +void SetQdirFromPath (char *path); +char *ExpandArg (char *path); // from cmd line +char *ExpandPath (char *path); // from scripts +char *ExpandPathAndArchive (char *path); + + +double I_FloatTime (void); + +void Error(char *error, ...); +void Warning(char *warning, ...); + +int CheckParm (char *check); + +FILE *SafeOpenWrite (char *filename); +FILE *SafeOpenRead (char *filename); +void SafeRead (FILE *f, void *buffer, int count); +void SafeWrite (FILE *f, void *buffer, int count); + +int LoadFile (char *filename, void **bufferptr, int offset, int length); +int TryLoadFile (char *filename, void **bufferptr); +void SaveFile (char *filename, void *buffer, int count); +qboolean FileExists (char *filename); + +void DefaultExtension (char *path, char *extension); +void DefaultPath (char *path, char *basepath); +void StripFilename (char *path); +void StripExtension (char *path); + +void ExtractFilePath (char *path, char *dest); +void ExtractFileBase (char *path, char *dest); +void ExtractFileExtension (char *path, char *dest); + +int ParseNum (char *str); + +short BigShort (short l); +short LittleShort (short l); +int BigLong (int l); +int LittleLong (int l); +float BigFloat (float l); +float LittleFloat (float l); + +#ifdef SIN +unsigned short BigUnsignedShort (unsigned short l); +unsigned short LittleUnsignedShort (unsigned short l); +unsigned BigUnsigned (unsigned l); +unsigned LittleUnsigned (unsigned l); +#endif + + +char *COM_Parse (char *data); + +extern char com_token[1024]; +extern qboolean com_eof; + +char *copystring(char *s); + + +void CRC_Init(unsigned short *crcvalue); +void CRC_ProcessByte(unsigned short *crcvalue, byte data); +unsigned short CRC_Value(unsigned short crcvalue); + +void CreatePath (char *path); +void QCopyFile (char *from, char *to); + +extern qboolean archive; +extern char archivedir[1024]; + + +extern qboolean verbose; +void qprintf (char *format, ...); + +void ExpandWildcards (int *argc, char ***argv); + + +// for compression routines +typedef struct +{ + byte *data; + int count; +} cblock_t; + +#endif + diff --git a/code/bspc/l_log.c b/code/bspc/l_log.c new file mode 100644 index 00000000..6a69c2b6 --- /dev/null +++ b/code/bspc/l_log.c @@ -0,0 +1,215 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include +#include +#include + +#include "qbsp.h" + +#define MAX_LOGFILENAMESIZE 1024 + +typedef struct logfile_s +{ + char filename[MAX_LOGFILENAMESIZE]; + FILE *fp; + int numwrites; +} logfile_t; + +logfile_t logfile; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_Open(char *filename) +{ + if (!filename || !strlen(filename)) + { + printf("openlog \n"); + return; + } //end if + if (logfile.fp) + { + printf("log file %s is already opened\n", logfile.filename); + return; + } //end if + logfile.fp = fopen(filename, "wb"); + if (!logfile.fp) + { + printf("can't open the log file %s\n", filename); + return; + } //end if + strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE); + printf("Opened log %s\n", logfile.filename); +} //end of the function Log_Create +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_Close(void) +{ + if (!logfile.fp) + { + printf("no log file to close\n"); + return; + } //end if + if (fclose(logfile.fp)) + { + printf("can't close log file %s\n", logfile.filename); + return; + } //end if + logfile.fp = NULL; + printf("Closed log %s\n", logfile.filename); +} //end of the function Log_Close +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_Shutdown(void) +{ + if (logfile.fp) Log_Close(); +} //end of the function Log_Shutdown +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_UnifyEndOfLine(char *buf) +{ + int i; + + for (i = 0; buf[i]; i++) + { + if (buf[i] == '\n') + { + if (i <= 0 || buf[i-1] != '\r') + { + memmove(&buf[i+1], &buf[i], strlen(&buf[i])+1); + buf[i] = '\r'; + i++; + } //end if + } //end if + } //end for +} //end of the function Log_UnifyEndOfLine +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_Print(char *fmt, ...) +{ + va_list ap; + char buf[2048]; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + + if (verbose) + { +#ifdef WINBSPC + WinBSPCPrint(buf); +#else + printf("%s", buf); +#endif //WINBSPS + } //end if + + if (logfile.fp) + { + Log_UnifyEndOfLine(buf); + fprintf(logfile.fp, "%s", buf); + fflush(logfile.fp); + } //end if +} //end of the function Log_Print +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_Write(char *fmt, ...) +{ + va_list ap; + char buf[2048]; + + if (!logfile.fp) return; + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + Log_UnifyEndOfLine(buf); + fprintf(logfile.fp, "%s", buf); + fflush(logfile.fp); +} //end of the function Log_Write +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_WriteTimeStamped(char *fmt, ...) +{ + va_list ap; + + if (!logfile.fp) return; +/* fprintf(logfile.fp, "%d %02d:%02d:%02d:%02d ", + logfile.numwrites, + (int) (botlibglobals.time / 60 / 60), + (int) (botlibglobals.time / 60), + (int) (botlibglobals.time), + (int) ((int) (botlibglobals.time * 100)) - + ((int) botlibglobals.time) * 100);*/ + va_start(ap, fmt); + vfprintf(logfile.fp, fmt, ap); + va_end(ap); + logfile.numwrites++; + fflush(logfile.fp); +} //end of the function Log_Write +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +FILE *Log_FileStruct(void) +{ + return logfile.fp; +} //end of the function Log_FileStruct +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Log_Flush(void) +{ + if (logfile.fp) fflush(logfile.fp); +} //end of the function Log_Flush + diff --git a/code/bspc/l_log.h b/code/bspc/l_log.h new file mode 100644 index 00000000..b9f1be46 --- /dev/null +++ b/code/bspc/l_log.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 +=========================================================================== +*/ + +//open a log file +void Log_Open(char *filename); +//close the current log file +void Log_Close(void); +//close log file if present +void Log_Shutdown(void); +//print on stdout and write to the current opened log file +void Log_Print(char *fmt, ...); +//write to the current opened log file +void Log_Write(char *fmt, ...); +//write to the current opened log file with a time stamp +void Log_WriteTimeStamped(char *fmt, ...); +//returns the log file structure +FILE *Log_FileStruct(void); +//flush log file +void Log_Flush(void); + +#ifdef WINBSPC +void WinBSPCPrint(char *str); +#endif //WINBSPC diff --git a/code/bspc/l_math.c b/code/bspc/l_math.c new file mode 100644 index 00000000..8d26a05d --- /dev/null +++ b/code/bspc/l_math.c @@ -0,0 +1,289 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ +// mathlib.c -- math primitives + +#include "l_cmd.h" +#include "l_math.h" + +vec3_t vec3_origin = {0,0,0}; + +void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) +{ + float angle; + static float sr, sp, sy, cr, cp, cy; + // static to help MS compiler fp bugs + + angle = angles[YAW] * (M_PI*2 / 360); + sy = sin(angle); + cy = cos(angle); + angle = angles[PITCH] * (M_PI*2 / 360); + sp = sin(angle); + cp = cos(angle); + angle = angles[ROLL] * (M_PI*2 / 360); + sr = sin(angle); + cr = cos(angle); + + if (forward) + { + forward[0] = cp*cy; + forward[1] = cp*sy; + forward[2] = -sp; + } + if (right) + { + right[0] = (-1*sr*sp*cy+-1*cr*-sy); + right[1] = (-1*sr*sp*sy+-1*cr*cy); + right[2] = -1*sr*cp; + } + if (up) + { + up[0] = (cr*sp*cy+-sr*-sy); + up[1] = (cr*sp*sy+-sr*cy); + up[2] = cr*cp; + } +} + +/* +================= +RadiusFromBounds +================= +*/ +float RadiusFromBounds( const vec3_t mins, const vec3_t maxs ) { + int i; + vec3_t corner; + float a, b; + + for (i=0 ; i<3 ; i++) { + a = fabs( mins[i] ); + b = fabs( maxs[i] ); + corner[i] = a > b ? a : b; + } + + return VectorLength (corner); +} + +/* +================ +R_ConcatRotations +================ +*/ +void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]) +{ + out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + + in1[0][2] * in2[2][0]; + out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + + in1[0][2] * in2[2][1]; + out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + + in1[0][2] * in2[2][2]; + out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + + in1[1][2] * in2[2][0]; + out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + + in1[1][2] * in2[2][1]; + out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + + in1[1][2] * in2[2][2]; + out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + + in1[2][2] * in2[2][0]; + out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + + in1[2][2] * in2[2][1]; + out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + + in1[2][2] * in2[2][2]; +} + +void AxisClear( vec3_t axis[3] ) { + axis[0][0] = 1; + axis[0][1] = 0; + axis[0][2] = 0; + axis[1][0] = 0; + axis[1][1] = 1; + axis[1][2] = 0; + axis[2][0] = 0; + axis[2][1] = 0; + axis[2][2] = 1; +} + +float VectorLengthSquared(vec3_t v) { + return DotProduct(v, v); +} + +double VectorLength(vec3_t v) +{ + int i; + double length; + + length = 0; + for (i=0 ; i< 3 ; i++) + length += v[i]*v[i]; + length = sqrt (length); // FIXME + + return length; +} + +qboolean VectorCompare (vec3_t v1, vec3_t v2) +{ + int i; + + for (i=0 ; i<3 ; i++) + if (fabs(v1[i]-v2[i]) > EQUAL_EPSILON) + return false; + + return true; +} + +vec_t Q_rint (vec_t in) +{ + return floor(in + 0.5); +} + +void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross) +{ + cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; + cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; + cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; +} + +void _VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc) +{ + vc[0] = va[0] + scale*vb[0]; + vc[1] = va[1] + scale*vb[1]; + vc[2] = va[2] + scale*vb[2]; +} + +vec_t _DotProduct (vec3_t v1, vec3_t v2) +{ + return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; +} + +void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out) +{ + out[0] = va[0]-vb[0]; + out[1] = va[1]-vb[1]; + out[2] = va[2]-vb[2]; +} + +void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out) +{ + out[0] = va[0]+vb[0]; + out[1] = va[1]+vb[1]; + out[2] = va[2]+vb[2]; +} + +void _VectorCopy (vec3_t in, vec3_t out) +{ + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; +} + +void _VectorScale (vec3_t v, vec_t scale, vec3_t out) +{ + out[0] = v[0] * scale; + out[1] = v[1] * scale; + out[2] = v[2] * scale; +} + +vec_t VectorNormalize(vec3_t inout) +{ + vec_t length, ilength; + + length = sqrt (inout[0]*inout[0] + inout[1]*inout[1] + inout[2]*inout[2]); + if (length == 0) + { + VectorClear (inout); + return 0; + } + + ilength = 1.0/length; + inout[0] = inout[0]*ilength; + inout[1] = inout[1]*ilength; + inout[2] = inout[2]*ilength; + + return length; +} + +vec_t VectorNormalize2(const vec3_t in, vec3_t out) +{ + vec_t length, ilength; + + length = sqrt (in[0]*in[0] + in[1]*in[1] + in[2]*in[2]); + if (length == 0) + { + VectorClear (out); + return 0; + } + + ilength = 1.0/length; + out[0] = in[0]*ilength; + out[1] = in[1]*ilength; + out[2] = in[2]*ilength; + + return length; +} + +vec_t ColorNormalize (vec3_t in, vec3_t out) +{ + float max, scale; + + max = in[0]; + if (in[1] > max) + max = in[1]; + if (in[2] > max) + max = in[2]; + + if (max == 0) + return 0; + + scale = 1.0 / max; + + VectorScale (in, scale, out); + + return max; +} + + + +void VectorInverse (vec3_t v) +{ + v[0] = -v[0]; + v[1] = -v[1]; + v[2] = -v[2]; +} + +void ClearBounds(vec3_t mins, vec3_t maxs) +{ + mins[0] = mins[1] = mins[2] = 99999; + maxs[0] = maxs[1] = maxs[2] = -99999; +} + +void AddPointToBounds(const vec3_t v, vec3_t mins, vec3_t maxs) +{ + int i; + vec_t val; + + for (i=0 ; i<3 ; i++) + { + val = v[i]; + if (val < mins[i]) + mins[i] = val; + if (val > maxs[i]) + maxs[i] = val; + } +} diff --git a/code/bspc/l_math.h b/code/bspc/l_math.h new file mode 100644 index 00000000..4cd4a6c5 --- /dev/null +++ b/code/bspc/l_math.h @@ -0,0 +1,93 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ +#ifndef __MATHLIB__ +#define __MATHLIB__ + +// mathlib.h + +#include + +#ifdef DOUBLEVEC_T +typedef double vec_t; +#else +typedef float vec_t; +#endif +typedef vec_t vec3_t[3]; +typedef vec_t vec4_t[4]; + +#define SIDE_FRONT 0 +#define SIDE_ON 2 +#define SIDE_BACK 1 +#define SIDE_CROSS -2 + +#define PITCH 0 +#define YAW 1 +#define ROLL 2 + +#define Q_PI 3.14159265358979323846 + +#define DEG2RAD( a ) ( a * M_PI ) / 180.0F + +#ifndef M_PI +#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h +#endif + +extern vec3_t vec3_origin; + +#define EQUAL_EPSILON 0.001 + +qboolean VectorCompare (vec3_t v1, vec3_t v2); + +#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) +#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];} +#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];} +#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];} +#define Vector4Copy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];} +#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s)) +#define VectorClear(x) {x[0] = x[1] = x[2] = 0;} +#define VectorNegate(x, y) {y[0]=-x[0];y[1]=-x[1];y[2]=-x[2];} +#define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s)) + +vec_t Q_rint (vec_t in); +vec_t _DotProduct (vec3_t v1, vec3_t v2); +void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out); +void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out); +void _VectorCopy (vec3_t in, vec3_t out); +void _VectorScale (vec3_t v, vec_t scale, vec3_t out); +void _VectorMA(vec3_t va, double scale, vec3_t vb, vec3_t vc); + +double VectorLength(vec3_t v); +void CrossProduct(const vec3_t v1, const vec3_t v2, vec3_t cross); +vec_t VectorNormalize(vec3_t inout); +vec_t ColorNormalize(vec3_t in, vec3_t out); +vec_t VectorNormalize2(const vec3_t v, vec3_t out); +void VectorInverse (vec3_t v); + +void ClearBounds (vec3_t mins, vec3_t maxs); +void AddPointToBounds (const vec3_t v, vec3_t mins, vec3_t maxs); + +void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); +void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]); +void RotatePoint(vec3_t point, float matrix[3][3]); +void CreateRotationMatrix(vec3_t angles, float matrix[3][3]); + +#endif diff --git a/code/bspc/l_mem.c b/code/bspc/l_mem.c new file mode 100644 index 00000000..31e02b28 --- /dev/null +++ b/code/bspc/l_mem.c @@ -0,0 +1,441 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "l_log.h" + +int allocedmemory; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintMemorySize(unsigned long size) +{ + unsigned long number1, number2, number3; + number1 = size >> 20; + number2 = (size & 0xFFFFF) >> 10; + number3 = (size & 0x3FF); + if (number1) Log_Print("%ld MB", number1); + if (number1 && number2) Log_Print(" and "); + if (number2) Log_Print("%ld KB", number2); + if (number2 && number3) Log_Print(" and "); + if (number3) Log_Print("%ld bytes", number3); +} //end of the function PrintFileSize + +#ifndef MEMDEBUG +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int MemorySize(void *ptr) +{ +#if defined(WIN32) || defined(_WIN32) + #ifdef __WATCOMC__ + //Intel 32 bits memory addressing, 16 bytes aligned + return (_msize(ptr) + 15) >> 4 << 4; + #else + return _msize(ptr); + #endif +#else + return 0; +#endif +} //end of the function MemorySize +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void *GetClearedMemory(int size) +{ + void *ptr; + + ptr = (void *) malloc(size); + if (!ptr) Error("out of memory"); + memset(ptr, 0, size); + allocedmemory += MemorySize(ptr); + return ptr; +} //end of the function GetClearedMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void *GetMemory(unsigned long size) +{ + void *ptr; + ptr = malloc(size); + if (!ptr) Error("out of memory"); + allocedmemory += MemorySize(ptr); + return ptr; +} //end of the function GetMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeMemory(void *ptr) +{ + allocedmemory -= MemorySize(ptr); + free(ptr); +} //end of the function FreeMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TotalAllocatedMemory(void) +{ + return allocedmemory; +} //end of the function TotalAllocatedMemory + +#else + +#define MEM_ID 0x12345678l + +int totalmemorysize; +int numblocks; + +typedef struct memoryblock_s +{ + unsigned long int id; + void *ptr; + int size; +#ifdef MEMDEBUG + char *label; + char *file; + int line; +#endif //MEMDEBUG + struct memoryblock_s *prev, *next; +} memoryblock_t; + +memoryblock_t *memory; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void LinkMemoryBlock(memoryblock_t *block) +{ + block->prev = NULL; + block->next = memory; + if (memory) memory->prev = block; + memory = block; +} //end of the function LinkMemoryBlock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void UnlinkMemoryBlock(memoryblock_t *block) +{ + if (block->prev) block->prev->next = block->next; + else memory = block->next; + if (block->next) block->next->prev = block->prev; +} //end of the function UnlinkMemoryBlock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef MEMDEBUG +void *GetMemoryDebug(unsigned long size, char *label, char *file, int line) +#else +void *GetMemory(unsigned long size) +#endif //MEMDEBUG +{ + void *ptr; + memoryblock_t *block; + + ptr = malloc(size + sizeof(memoryblock_t)); + block = (memoryblock_t *) ptr; + block->id = MEM_ID; + block->ptr = (char *) ptr + sizeof(memoryblock_t); + block->size = size + sizeof(memoryblock_t); +#ifdef MEMDEBUG + block->label = label; + block->file = file; + block->line = line; +#endif //MEMDEBUG + LinkMemoryBlock(block); + totalmemorysize += block->size; + numblocks++; + return block->ptr; +} //end of the function GetMemoryDebug +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef MEMDEBUG +void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line) +#else +void *GetClearedMemory(unsigned long size) +#endif //MEMDEBUG +{ + void *ptr; +#ifdef MEMDEBUG + ptr = GetMemoryDebug(size, label, file, line); +#else + ptr = GetMemory(size); +#endif //MEMDEBUG + memset(ptr, 0, size); + return ptr; +} //end of the function GetClearedMemoryLabelled +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void *GetClearedHunkMemory(unsigned long size) +{ + return GetClearedMemory(size); +} //end of the function GetClearedHunkMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void *GetHunkMemory(unsigned long size) +{ + return GetMemory(size); +} //end of the function GetHunkMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +memoryblock_t *BlockFromPointer(void *ptr, char *str) +{ + memoryblock_t *block; + + if (!ptr) + { +#ifdef MEMDEBUG + //char *crash = (char *) NULL; + //crash[0] = 1; + Error("%s: NULL pointer\n", str); +#endif MEMDEBUG + return NULL; + } //end if + block = (memoryblock_t *) ((char *) ptr - sizeof(memoryblock_t)); + if (block->id != MEM_ID) + { + Error("%s: invalid memory block\n", str); + } //end if + if (block->ptr != ptr) + { + + Error("%s: memory block pointer invalid\n", str); + } //end if + return block; +} //end of the function BlockFromPointer +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreeMemory(void *ptr) +{ + memoryblock_t *block; + + block = BlockFromPointer(ptr, "FreeMemory"); + if (!block) return; + UnlinkMemoryBlock(block); + totalmemorysize -= block->size; + numblocks--; + // + free(block); +} //end of the function FreeMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int MemoryByteSize(void *ptr) +{ + memoryblock_t *block; + + block = BlockFromPointer(ptr, "MemoryByteSize"); + if (!block) return 0; + return block->size; +} //end of the function MemoryByteSize +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int MemorySize(void *ptr) +{ + return MemoryByteSize(ptr); +} //end of the function MemorySize +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintUsedMemorySize(void) +{ + printf("total botlib memory: %d KB\n", totalmemorysize >> 10); + printf("total memory blocks: %d\n", numblocks); +} //end of the function PrintUsedMemorySize +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintMemoryLabels(void) +{ + memoryblock_t *block; + int i; + + PrintUsedMemorySize(); + i = 0; + for (block = memory; block; block = block->next) + { +#ifdef MEMDEBUG + Log_Write("%6d, %p, %8d: %24s line %6d: %s", i, block->ptr, block->size, block->file, block->line, block->label); +#endif //MEMDEBUG + i++; + } //end for +} //end of the function PrintMemoryLabels +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void DumpMemory(void) +{ + memoryblock_t *block; + + for (block = memory; block; block = memory) + { + FreeMemory(block->ptr); + } //end for + totalmemorysize = 0; +} //end of the function DumpMemory +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TotalAllocatedMemory(void) +{ + return totalmemorysize; +} //end of the function TotalAllocatedMemory +#endif + +//=========================================================================== +// Q3 Hunk and Z_ memory management +//=========================================================================== + +typedef struct memhunk_s +{ + void *ptr; + struct memhunk_s *next; +} memhunk_t; + +memhunk_t *memhunk_high; +memhunk_t *memhunk_low; +int memhunk_high_size = 16 * 1024 * 1024; +int memhunk_low_size = 0; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Hunk_ClearHigh(void) +{ + memhunk_t *h, *nexth; + + for (h = memhunk_high; h; h = nexth) + { + nexth = h->next; + FreeMemory(h); + } //end for + memhunk_high = NULL; + memhunk_high_size = 16 * 1024 * 1024; +} //end of the function Hunk_ClearHigh +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void *Hunk_Alloc(int size) +{ + memhunk_t *h; + + if (!size) return (void *) memhunk_high_size; + // + h = GetClearedMemory(size + sizeof(memhunk_t)); + h->ptr = (char *) h + sizeof(memhunk_t); + h->next = memhunk_high; + memhunk_high = h; + memhunk_high_size -= size; + return h->ptr; +} //end of the function Hunk_Alloc +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void *Z_Malloc(int size) +{ + return GetClearedMemory(size); +} //end of the function Z_Malloc +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Z_Free (void *ptr) +{ + FreeMemory(ptr); +} //end of the function Z_Free diff --git a/code/bspc/l_mem.h b/code/bspc/l_mem.h new file mode 100644 index 00000000..ba3b0d38 --- /dev/null +++ b/code/bspc/l_mem.h @@ -0,0 +1,51 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + + +//============================================================================= + +// memory.h +//#define MEMDEBUG +#undef MEMDEBUG + +#ifndef MEMDEBUG + +void *GetClearedMemory(int size); +void *GetMemory(unsigned long size); + +#else + +#define GetMemory(size) GetMemoryDebug(size, #size, __FILE__, __LINE__); +#define GetClearedMemory(size) GetClearedMemoryDebug(size, #size, __FILE__, __LINE__); +//allocate a memory block of the given size +void *GetMemoryDebug(unsigned long size, char *label, char *file, int line); +//allocate a memory block of the given size and clear it +void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line); +// +void PrintMemoryLabels(void); +#endif //MEMDEBUG + +void FreeMemory(void *ptr); +int MemorySize(void *ptr); +void PrintMemorySize(unsigned long size); +int TotalAllocatedMemory(void); + diff --git a/code/bspc/l_poly.c b/code/bspc/l_poly.c new file mode 100644 index 00000000..7627d202 --- /dev/null +++ b/code/bspc/l_poly.c @@ -0,0 +1,1411 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include +#include "l_cmd.h" +#include "l_math.h" +#include "l_poly.h" +#include "l_log.h" +#include "l_mem.h" + +#define BOGUS_RANGE 65535 + +extern int numthreads; + +// counters are only bumped when running single threaded, +// because they are an awefull coherence problem +int c_active_windings; +int c_peak_windings; +int c_winding_allocs; +int c_winding_points; +int c_windingmemory; +int c_peak_windingmemory; + +char windingerror[1024]; + +void pw(winding_t *w) +{ + int i; + for (i=0 ; inumpoints ; i++) + printf ("(%5.3f, %5.3f, %5.3f)\n",w->p[i][0], w->p[i][1],w->p[i][2]); +} + + +void ResetWindings(void) +{ + c_active_windings = 0; + c_peak_windings = 0; + c_winding_allocs = 0; + c_winding_points = 0; + c_windingmemory = 0; + c_peak_windingmemory = 0; + + strcpy(windingerror, ""); +} //end of the function ResetWindings +/* +============= +AllocWinding +============= +*/ +winding_t *AllocWinding (int points) +{ + winding_t *w; + int s; + + s = sizeof(vec_t)*3*points + sizeof(int); + w = GetMemory(s); + memset(w, 0, s); + + if (numthreads == 1) + { + c_winding_allocs++; + c_winding_points += points; + c_active_windings++; + if (c_active_windings > c_peak_windings) + c_peak_windings = c_active_windings; + c_windingmemory += MemorySize(w); + if (c_windingmemory > c_peak_windingmemory) + c_peak_windingmemory = c_windingmemory; + } //end if + return w; +} //end of the function AllocWinding + +void FreeWinding (winding_t *w) +{ + if (*(unsigned *)w == 0xdeaddead) + Error ("FreeWinding: freed a freed winding"); + + if (numthreads == 1) + { + c_active_windings--; + c_windingmemory -= MemorySize(w); + } //end if + + *(unsigned *)w = 0xdeaddead; + + FreeMemory(w); +} //end of the function FreeWinding + +int WindingMemory(void) +{ + return c_windingmemory; +} //end of the function WindingMemory + +int WindingPeakMemory(void) +{ + return c_peak_windingmemory; +} //end of the function WindingPeakMemory + +int ActiveWindings(void) +{ + return c_active_windings; +} //end of the function ActiveWindings +/* +============ +RemoveColinearPoints +============ +*/ +int c_removed; + +void RemoveColinearPoints (winding_t *w) +{ + int i, j, k; + vec3_t v1, v2; + int nump; + vec3_t p[MAX_POINTS_ON_WINDING]; + + nump = 0; + for (i=0 ; inumpoints ; i++) + { + j = (i+1)%w->numpoints; + k = (i+w->numpoints-1)%w->numpoints; + VectorSubtract (w->p[j], w->p[i], v1); + VectorSubtract (w->p[i], w->p[k], v2); + VectorNormalize(v1); + VectorNormalize(v2); + if (DotProduct(v1, v2) < 0.999) + { + if (nump >= MAX_POINTS_ON_WINDING) + Error("RemoveColinearPoints: MAX_POINTS_ON_WINDING"); + VectorCopy (w->p[i], p[nump]); + nump++; + } + } + + if (nump == w->numpoints) + return; + + if (numthreads == 1) + c_removed += w->numpoints - nump; + w->numpoints = nump; + memcpy (w->p, p, nump*sizeof(p[0])); +} + +/* +============ +WindingPlane +============ +*/ +void WindingPlane (winding_t *w, vec3_t normal, vec_t *dist) +{ + vec3_t v1, v2; + int i; + + //find two vectors each longer than 0.5 units + for (i = 0; i < w->numpoints; i++) + { + VectorSubtract(w->p[(i+1) % w->numpoints], w->p[i], v1); + VectorSubtract(w->p[(i+2) % w->numpoints], w->p[i], v2); + if (VectorLength(v1) > 0.5 && VectorLength(v2) > 0.5) break; + } //end for + CrossProduct(v2, v1, normal); + VectorNormalize(normal); + *dist = DotProduct(w->p[0], normal); +} //end of the function WindingPlane + +/* +============= +WindingArea +============= +*/ +vec_t WindingArea (winding_t *w) +{ + int i; + vec3_t d1, d2, cross; + vec_t total; + + total = 0; + for (i=2 ; inumpoints ; i++) + { + VectorSubtract (w->p[i-1], w->p[0], d1); + VectorSubtract (w->p[i], w->p[0], d2); + CrossProduct (d1, d2, cross); + total += 0.5 * VectorLength ( cross ); + } + return total; +} + +void WindingBounds (winding_t *w, vec3_t mins, vec3_t maxs) +{ + vec_t v; + int i,j; + + mins[0] = mins[1] = mins[2] = 99999; + maxs[0] = maxs[1] = maxs[2] = -99999; + + for (i=0 ; inumpoints ; i++) + { + for (j=0 ; j<3 ; j++) + { + v = w->p[i][j]; + if (v < mins[j]) + mins[j] = v; + if (v > maxs[j]) + maxs[j] = v; + } + } +} + +/* +============= +WindingCenter +============= +*/ +void WindingCenter (winding_t *w, vec3_t center) +{ + int i; + float scale; + + VectorCopy (vec3_origin, center); + for (i=0 ; inumpoints ; i++) + VectorAdd (w->p[i], center, center); + + scale = 1.0/w->numpoints; + VectorScale (center, scale, center); +} + +/* +================= +BaseWindingForPlane +================= +*/ +winding_t *BaseWindingForPlane (vec3_t normal, vec_t dist) +{ + int i, x; + vec_t max, v; + vec3_t org, vright, vup; + winding_t *w; + +// find the major axis + + max = -BOGUS_RANGE; + x = -1; + for (i=0 ; i<3; i++) + { + v = fabs(normal[i]); + if (v > max) + { + x = i; + max = v; + } + } + if (x==-1) + Error ("BaseWindingForPlane: no axis found"); + + VectorCopy (vec3_origin, vup); + switch (x) + { + case 0: + case 1: + vup[2] = 1; + break; + case 2: + vup[0] = 1; + break; + } + + v = DotProduct (vup, normal); + VectorMA (vup, -v, normal, vup); + VectorNormalize (vup); + + VectorScale (normal, dist, org); + + CrossProduct (vup, normal, vright); + + VectorScale (vup, BOGUS_RANGE, vup); + VectorScale (vright, BOGUS_RANGE, vright); + +// project a really big axis aligned box onto the plane + w = AllocWinding (4); + + VectorSubtract (org, vright, w->p[0]); + VectorAdd (w->p[0], vup, w->p[0]); + + VectorAdd (org, vright, w->p[1]); + VectorAdd (w->p[1], vup, w->p[1]); + + VectorAdd (org, vright, w->p[2]); + VectorSubtract (w->p[2], vup, w->p[2]); + + VectorSubtract (org, vright, w->p[3]); + VectorSubtract (w->p[3], vup, w->p[3]); + + w->numpoints = 4; + + return w; +} + +/* +================== +CopyWinding +================== +*/ +winding_t *CopyWinding (winding_t *w) +{ + int size; + winding_t *c; + + c = AllocWinding (w->numpoints); + size = (int)((winding_t *)0)->p[w->numpoints]; + memcpy (c, w, size); + return c; +} + +/* +================== +ReverseWinding +================== +*/ +winding_t *ReverseWinding (winding_t *w) +{ + int i; + winding_t *c; + + c = AllocWinding (w->numpoints); + for (i=0 ; inumpoints ; i++) + { + VectorCopy (w->p[w->numpoints-1-i], c->p[i]); + } + c->numpoints = w->numpoints; + return c; +} + + +/* +============= +ClipWindingEpsilon +============= +*/ +void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, + vec_t epsilon, winding_t **front, winding_t **back) +{ + vec_t dists[MAX_POINTS_ON_WINDING+4]; + int sides[MAX_POINTS_ON_WINDING+4]; + int counts[3]; + //MrElusive: DOH can't use statics when unsing multithreading!!! + vec_t dot; // VC 4.2 optimizer bug if not static + int i, j; + vec_t *p1, *p2; + vec3_t mid; + winding_t *f, *b; + int maxpts; + + counts[0] = counts[1] = counts[2] = 0; + +// determine sides for each point + for (i=0 ; inumpoints ; i++) + { + dot = DotProduct (in->p[i], normal); + dot -= dist; + dists[i] = dot; + if (dot > epsilon) + sides[i] = SIDE_FRONT; + else if (dot < -epsilon) + sides[i] = SIDE_BACK; + else + { + sides[i] = SIDE_ON; + } + counts[sides[i]]++; + } + sides[i] = sides[0]; + dists[i] = dists[0]; + + *front = *back = NULL; + + if (!counts[0]) + { + *back = CopyWinding (in); + return; + } + if (!counts[1]) + { + *front = CopyWinding (in); + return; + } + + maxpts = in->numpoints+4; // cant use counts[0]+2 because + // of fp grouping errors + + *front = f = AllocWinding (maxpts); + *back = b = AllocWinding (maxpts); + + for (i=0 ; inumpoints ; i++) + { + p1 = in->p[i]; + + if (sides[i] == SIDE_ON) + { + VectorCopy (p1, f->p[f->numpoints]); + f->numpoints++; + VectorCopy (p1, b->p[b->numpoints]); + b->numpoints++; + continue; + } + + if (sides[i] == SIDE_FRONT) + { + VectorCopy (p1, f->p[f->numpoints]); + f->numpoints++; + } + if (sides[i] == SIDE_BACK) + { + VectorCopy (p1, b->p[b->numpoints]); + b->numpoints++; + } + + if (sides[i+1] == SIDE_ON || sides[i+1] == sides[i]) + continue; + + // generate a split point + p2 = in->p[(i+1)%in->numpoints]; + + dot = dists[i] / (dists[i]-dists[i+1]); + for (j=0 ; j<3 ; j++) + { // avoid round off error when possible + if (normal[j] == 1) + mid[j] = dist; + else if (normal[j] == -1) + mid[j] = -dist; + else + mid[j] = p1[j] + dot*(p2[j]-p1[j]); + } + + VectorCopy (mid, f->p[f->numpoints]); + f->numpoints++; + VectorCopy (mid, b->p[b->numpoints]); + b->numpoints++; + } + + if (f->numpoints > maxpts || b->numpoints > maxpts) + Error ("ClipWinding: points exceeded estimate"); + if (f->numpoints > MAX_POINTS_ON_WINDING || b->numpoints > MAX_POINTS_ON_WINDING) + Error ("ClipWinding: MAX_POINTS_ON_WINDING"); +} + + +/* +============= +ChopWindingInPlace +============= +*/ +void ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t epsilon) +{ + winding_t *in; + vec_t dists[MAX_POINTS_ON_WINDING+4]; + int sides[MAX_POINTS_ON_WINDING+4]; + int counts[3]; + //MrElusive: DOH can't use statics when unsing multithreading!!! + vec_t dot; // VC 4.2 optimizer bug if not static + int i, j; + vec_t *p1, *p2; + vec3_t mid; + winding_t *f; + int maxpts; + + in = *inout; + counts[0] = counts[1] = counts[2] = 0; + +// determine sides for each point + for (i=0 ; inumpoints ; i++) + { + dot = DotProduct (in->p[i], normal); + dot -= dist; + dists[i] = dot; + if (dot > epsilon) + sides[i] = SIDE_FRONT; + else if (dot < -epsilon) + sides[i] = SIDE_BACK; + else + { + sides[i] = SIDE_ON; + } + counts[sides[i]]++; + } + sides[i] = sides[0]; + dists[i] = dists[0]; + + if (!counts[0]) + { + FreeWinding (in); + *inout = NULL; + return; + } + if (!counts[1]) + return; // inout stays the same + + maxpts = in->numpoints+4; // cant use counts[0]+2 because + // of fp grouping errors + + f = AllocWinding (maxpts); + + for (i=0 ; inumpoints ; i++) + { + p1 = in->p[i]; + + if (sides[i] == SIDE_ON) + { + VectorCopy (p1, f->p[f->numpoints]); + f->numpoints++; + continue; + } + + if (sides[i] == SIDE_FRONT) + { + VectorCopy (p1, f->p[f->numpoints]); + f->numpoints++; + } + + if (sides[i+1] == SIDE_ON || sides[i+1] == sides[i]) + continue; + + // generate a split point + p2 = in->p[(i+1)%in->numpoints]; + + dot = dists[i] / (dists[i]-dists[i+1]); + for (j=0 ; j<3 ; j++) + { // avoid round off error when possible + if (normal[j] == 1) + mid[j] = dist; + else if (normal[j] == -1) + mid[j] = -dist; + else + mid[j] = p1[j] + dot*(p2[j]-p1[j]); + } + + VectorCopy (mid, f->p[f->numpoints]); + f->numpoints++; + } + + if (f->numpoints > maxpts) + Error ("ClipWinding: points exceeded estimate"); + if (f->numpoints > MAX_POINTS_ON_WINDING) + Error ("ClipWinding: MAX_POINTS_ON_WINDING"); + + FreeWinding (in); + *inout = f; +} + + +/* +================= +ChopWinding + +Returns the fragment of in that is on the front side +of the cliping plane. The original is freed. +================= +*/ +winding_t *ChopWinding (winding_t *in, vec3_t normal, vec_t dist) +{ + winding_t *f, *b; + + ClipWindingEpsilon (in, normal, dist, ON_EPSILON, &f, &b); + FreeWinding (in); + if (b) + FreeWinding (b); + return f; +} + + +/* +================= +CheckWinding + +================= +*/ +void CheckWinding (winding_t *w) +{ + int i, j; + vec_t *p1, *p2; + vec_t d, edgedist; + vec3_t dir, edgenormal, facenormal; + vec_t area; + vec_t facedist; + + if (w->numpoints < 3) + Error ("CheckWinding: %i points",w->numpoints); + + area = WindingArea(w); + if (area < 1) + Error ("CheckWinding: %f area", area); + + WindingPlane (w, facenormal, &facedist); + + for (i=0 ; inumpoints ; i++) + { + p1 = w->p[i]; + + for (j=0 ; j<3 ; j++) + if (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE) + Error ("CheckWinding: BUGUS_RANGE: %f",p1[j]); + + j = i+1 == w->numpoints ? 0 : i+1; + + // check the point is on the face plane + d = DotProduct (p1, facenormal) - facedist; + if (d < -ON_EPSILON || d > ON_EPSILON) + Error ("CheckWinding: point off plane"); + + // check the edge isnt degenerate + p2 = w->p[j]; + VectorSubtract (p2, p1, dir); + + if (VectorLength (dir) < ON_EPSILON) + Error ("CheckWinding: degenerate edge"); + + CrossProduct (facenormal, dir, edgenormal); + VectorNormalize (edgenormal); + edgedist = DotProduct (p1, edgenormal); + edgedist += ON_EPSILON; + + // all other points must be on front side + for (j=0 ; jnumpoints ; j++) + { + if (j == i) + continue; + d = DotProduct (w->p[j], edgenormal); + if (d > edgedist) + Error ("CheckWinding: non-convex"); + } + } +} + + +/* +============ +WindingOnPlaneSide +============ +*/ +int WindingOnPlaneSide (winding_t *w, vec3_t normal, vec_t dist) +{ + qboolean front, back; + int i; + vec_t d; + + front = false; + back = false; + for (i=0 ; inumpoints ; i++) + { + d = DotProduct (w->p[i], normal) - dist; + if (d < -ON_EPSILON) + { + if (front) + return SIDE_CROSS; + back = true; + continue; + } + if (d > ON_EPSILON) + { + if (back) + return SIDE_CROSS; + front = true; + continue; + } + } + + if (back) + return SIDE_BACK; + if (front) + return SIDE_FRONT; + return SIDE_ON; +} + +//#ifdef ME + #define CONTINUOUS_EPSILON 0.005 +//#else +// #define CONTINUOUS_EPSILON 0.001 +//#endif + +/* +============= +TryMergeWinding + +If two polygons share a common edge and the edges that meet at the +common points are both inside the other polygons, merge them + +Returns NULL if the faces couldn't be merged, or the new face. +The originals will NOT be freed. +============= +*/ + +winding_t *TryMergeWinding (winding_t *f1, winding_t *f2, vec3_t planenormal) +{ + vec_t *p1, *p2, *p3, *p4, *back; + winding_t *newf; + int i, j, k, l; + vec3_t normal, delta; + vec_t dot; + qboolean keep1, keep2; + + + // + // find a common edge + // + p1 = p2 = NULL; // stop compiler warning + j = 0; // + + for (i = 0; i < f1->numpoints; i++) + { + p1 = f1->p[i]; + p2 = f1->p[(i+1) % f1->numpoints]; + for (j = 0; j < f2->numpoints; j++) + { + p3 = f2->p[j]; + p4 = f2->p[(j+1) % f2->numpoints]; + for (k = 0; k < 3; k++) + { + if (fabs(p1[k] - p4[k]) > 0.1)//EQUAL_EPSILON) //ME + break; + if (fabs(p2[k] - p3[k]) > 0.1)//EQUAL_EPSILON) //ME + break; + } //end for + if (k==3) + break; + } //end for + if (j < f2->numpoints) + break; + } //end for + + if (i == f1->numpoints) + return NULL; // no matching edges + + // + // check slope of connected lines + // if the slopes are colinear, the point can be removed + // + back = f1->p[(i+f1->numpoints-1)%f1->numpoints]; + VectorSubtract (p1, back, delta); + CrossProduct (planenormal, delta, normal); + VectorNormalize (normal); + + back = f2->p[(j+2)%f2->numpoints]; + VectorSubtract (back, p1, delta); + dot = DotProduct (delta, normal); + if (dot > CONTINUOUS_EPSILON) + return NULL; // not a convex polygon + keep1 = (qboolean)(dot < -CONTINUOUS_EPSILON); + + back = f1->p[(i+2)%f1->numpoints]; + VectorSubtract (back, p2, delta); + CrossProduct (planenormal, delta, normal); + VectorNormalize (normal); + + back = f2->p[(j+f2->numpoints-1)%f2->numpoints]; + VectorSubtract (back, p2, delta); + dot = DotProduct (delta, normal); + if (dot > CONTINUOUS_EPSILON) + return NULL; // not a convex polygon + keep2 = (qboolean)(dot < -CONTINUOUS_EPSILON); + + // + // build the new polygon + // + newf = AllocWinding (f1->numpoints + f2->numpoints); + + // copy first polygon + for (k=(i+1)%f1->numpoints ; k != i ; k=(k+1)%f1->numpoints) + { + if (k==(i+1)%f1->numpoints && !keep2) + continue; + + VectorCopy (f1->p[k], newf->p[newf->numpoints]); + newf->numpoints++; + } + + // copy second polygon + for (l= (j+1)%f2->numpoints ; l != j ; l=(l+1)%f2->numpoints) + { + if (l==(j+1)%f2->numpoints && !keep1) + continue; + VectorCopy (f2->p[l], newf->p[newf->numpoints]); + newf->numpoints++; + } + + return newf; +} + +//#ifdef ME +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +winding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal) +{ + winding_t *neww; + float dist; + int i, j, n, found, insertafter; + int sides[MAX_POINTS_ON_WINDING+4]; + vec3_t newp[MAX_POINTS_ON_WINDING+4]; + int numpoints; + vec3_t edgevec, sepnormal, v; + + RemoveEqualPoints(w1, 0.2); + numpoints = w1->numpoints; + memcpy(newp, w1->p, w1->numpoints * sizeof(vec3_t)); + // + for (i = 0; i < w2->numpoints; i++) + { + VectorCopy(w2->p[i], v); + for (j = 0; j < numpoints; j++) + { + VectorSubtract(newp[(j+1)%numpoints], + newp[(j)%numpoints], edgevec); + CrossProduct(edgevec, planenormal, sepnormal); + VectorNormalize(sepnormal); + if (VectorLength(sepnormal) < 0.9) + { + //remove the point from the new winding + for (n = j; n < numpoints-1; n++) + { + VectorCopy(newp[n+1], newp[n]); + sides[n] = sides[n+1]; + } //end for + numpoints--; + j--; + Log_Print("MergeWindings: degenerate edge on winding %f %f %f\n", sepnormal[0], + sepnormal[1], + sepnormal[2]); + continue; + } //end if + dist = DotProduct(newp[(j)%numpoints], sepnormal); + if (DotProduct(v, sepnormal) - dist < -0.1) sides[j] = SIDE_BACK; + else sides[j] = SIDE_FRONT; + } //end for + //remove all unnecesary points + for (j = 0; j < numpoints;) + { + if (sides[j] == SIDE_BACK + && sides[(j+1)%numpoints] == SIDE_BACK) + { + //remove the point from the new winding + for (n = (j+1)%numpoints; n < numpoints-1; n++) + { + VectorCopy(newp[n+1], newp[n]); + sides[n] = sides[n+1]; + } //end for + numpoints--; + } //end if + else + { + j++; + } //end else + } //end for + // + found = false; + for (j = 0; j < numpoints; j++) + { + if (sides[j] == SIDE_FRONT + && sides[(j+1)%numpoints] == SIDE_BACK) + { + if (found) Log_Print("Warning: MergeWindings: front to back found twice\n"); + found = true; + } //end if + } //end for + // + for (j = 0; j < numpoints; j++) + { + if (sides[j] == SIDE_FRONT + && sides[(j+1)%numpoints] == SIDE_BACK) + { + insertafter = (j+1)%numpoints; + //insert the new point after j+1 + for (n = numpoints-1; n > insertafter; n--) + { + VectorCopy(newp[n], newp[n+1]); + } //end for + numpoints++; + VectorCopy(v, newp[(insertafter+1)%numpoints]); + break; + } //end if + } //end for + } //end for + neww = AllocWinding(numpoints); + neww->numpoints = numpoints; + memcpy(neww->p, newp, numpoints * sizeof(vec3_t)); + RemoveColinearPoints(neww); + return neww; +} //end of the function MergeWindings +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *WindingErrorString(void) +{ + return windingerror; +} //end of the function WindingErrorString +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int WindingError(winding_t *w) +{ + int i, j; + vec_t *p1, *p2; + vec_t d, edgedist; + vec3_t dir, edgenormal, facenormal; + vec_t area; + vec_t facedist; + + if (w->numpoints < 3) + { + sprintf(windingerror, "winding %i points", w->numpoints); + return WE_NOTENOUGHPOINTS; + } //end if + + area = WindingArea(w); + if (area < 1) + { + sprintf(windingerror, "winding %f area", area); + return WE_SMALLAREA; + } //end if + + WindingPlane (w, facenormal, &facedist); + + for (i=0 ; inumpoints ; i++) + { + p1 = w->p[i]; + + for (j=0 ; j<3 ; j++) + { + if (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE) + { + sprintf(windingerror, "winding point %d BUGUS_RANGE \'%f %f %f\'", j, p1[0], p1[1], p1[2]); + return WE_POINTBOGUSRANGE; + } //end if + } //end for + + j = i+1 == w->numpoints ? 0 : i+1; + + // check the point is on the face plane + d = DotProduct (p1, facenormal) - facedist; + if (d < -ON_EPSILON || d > ON_EPSILON) + { + sprintf(windingerror, "winding point %d off plane", i); + return WE_POINTOFFPLANE; + } //end if + + // check the edge isnt degenerate + p2 = w->p[j]; + VectorSubtract (p2, p1, dir); + + if (VectorLength (dir) < ON_EPSILON) + { + sprintf(windingerror, "winding degenerate edge %d-%d", i, j); + return WE_DEGENERATEEDGE; + } //end if + + CrossProduct (facenormal, dir, edgenormal); + VectorNormalize (edgenormal); + edgedist = DotProduct (p1, edgenormal); + edgedist += ON_EPSILON; + + // all other points must be on front side + for (j=0 ; jnumpoints ; j++) + { + if (j == i) + continue; + d = DotProduct (w->p[j], edgenormal); + if (d > edgedist) + { + sprintf(windingerror, "winding non-convex"); + return WE_NONCONVEX; + } //end if + } //end for + } //end for + return WE_NONE; +} //end of the function WindingError +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RemoveEqualPoints(winding_t *w, float epsilon) +{ + int i, nump; + vec3_t v; + vec3_t p[MAX_POINTS_ON_WINDING]; + + VectorCopy(w->p[0], p[0]); + nump = 1; + for (i = 1; i < w->numpoints; i++) + { + VectorSubtract(w->p[i], p[nump-1], v); + if (VectorLength(v) > epsilon) + { + if (nump >= MAX_POINTS_ON_WINDING) + Error("RemoveColinearPoints: MAX_POINTS_ON_WINDING"); + VectorCopy (w->p[i], p[nump]); + nump++; + } //end if + } //end for + + if (nump == w->numpoints) + return; + + w->numpoints = nump; + memcpy(w->p, p, nump * sizeof(p[0])); +} //end of the function RemoveEqualPoints +//=========================================================================== +// adds the given point to a winding at the given spot +// (for instance when spot is zero then the point is added at position zero) +// the original winding is NOT freed +// +// Parameter: - +// Returns: the new winding with the added point +// Changes Globals: - +//=========================================================================== +winding_t *AddWindingPoint(winding_t *w, vec3_t point, int spot) +{ + int i, j; + winding_t *neww; + + if (spot > w->numpoints) + { + Error("AddWindingPoint: num > w->numpoints"); + } //end if + if (spot < 0) + { + Error("AddWindingPoint: num < 0"); + } //end if + neww = AllocWinding(w->numpoints + 1); + neww->numpoints = w->numpoints + 1; + for (i = 0, j = 0; i < neww->numpoints; i++) + { + if (i == spot) + { + VectorCopy(point, neww->p[i]); + } //end if + else + { + VectorCopy(w->p[j], neww->p[i]); + j++; + } //end else + } //end for + return neww; +} //end of the function AddWindingPoint +//=========================================================================== +// the position where the new point should be added in the winding is +// stored in *spot +// +// Parameter: - +// Returns: true if the point is on the winding +// Changes Globals: - +//=========================================================================== +#define MELT_ON_EPSILON 0.2 + +int PointOnWinding(winding_t *w, vec3_t normal, float dist, vec3_t point, int *spot) +{ + int i, j; + vec3_t v1, v2; + vec3_t edgenormal, edgevec; + float edgedist, dot; + + *spot = 0; + //the point must be on the winding plane + dot = DotProduct(point, normal) - dist; + if (dot < -MELT_ON_EPSILON || dot > MELT_ON_EPSILON) return false; + // + for (i = 0; i < w->numpoints; i++) + { + j = (i+1) % w->numpoints; + //get a plane orthogonal to the winding plane through the edge + VectorSubtract(w->p[j], w->p[i], edgevec); + CrossProduct(normal, edgevec, edgenormal); + VectorNormalize(edgenormal); + edgedist = DotProduct(edgenormal, w->p[i]); + //point must be not too far from the plane + dot = DotProduct(point, edgenormal) - edgedist; + if (dot < -MELT_ON_EPSILON || dot > MELT_ON_EPSILON) continue; + //vector from first point of winding to the point to test + VectorSubtract(point, w->p[i], v1); + //vector from second point of winding to the point to test + VectorSubtract(point, w->p[j], v2); + //if the length of the vector is not larger than 0.5 units then + //the point is assumend to be the same as one of the winding points + if (VectorNormalize(v1) < 0.5) return false; + if (VectorNormalize(v2) < 0.5) return false; + //point must be between the two winding points + //(the two vectors must be directed towards each other, and on the + //same straight line) + if (DotProduct(v1, v2) < -0.99) + { + *spot = i + 1; + return true; + } //end if + } //end for + return false; +} //end of the function PointOnWinding +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir, + vec3_t normal, float *dist) +{ + int i, i2, j, j2, n; + int sides1[3], sides2[3]; + float dist1, dist2, dot, diff; + vec3_t normal1, normal2; + vec3_t v1, v2; + + for (i = 0; i < w1->numpoints; i++) + { + i2 = (i+1) % w1->numpoints; + // + VectorSubtract(w1->p[i2], w1->p[i], v1); + if (VectorLength(v1) < 0.1) + { + //Log_Write("FindPlaneSeperatingWindings: winding1 with degenerate edge\r\n"); + continue; + } //end if + CrossProduct(v1, dir, normal1); + VectorNormalize(normal1); + dist1 = DotProduct(normal1, w1->p[i]); + // + for (j = 0; j < w2->numpoints; j++) + { + j2 = (j+1) % w2->numpoints; + // + VectorSubtract(w2->p[j2], w2->p[j], v2); + if (VectorLength(v2) < 0.1) + { + //Log_Write("FindPlaneSeperatingWindings: winding2 with degenerate edge\r\n"); + continue; + } //end if + CrossProduct(v2, dir, normal2); + VectorNormalize(normal2); + dist2 = DotProduct(normal2, w2->p[j]); + // + diff = dist1 - dist2; + if (diff < -0.1 || diff > 0.1) + { + dist2 = -dist2; + VectorNegate(normal2, normal2); + diff = dist1 - dist2; + if (diff < -0.1 || diff > 0.1) continue; + } //end if + //check if the normal vectors are equal + for (n = 0; n < 3; n++) + { + diff = normal1[n] - normal2[n]; + if (diff < -0.0001 || diff > 0.0001) break; + } //end for + if (n != 3) continue; + //check on which side of the seperating plane the points of + //the first winding are + sides1[0] = sides1[1] = sides1[2] = 0; + for (n = 0; n < w1->numpoints; n++) + { + dot = DotProduct(w1->p[n], normal1) - dist1; + if (dot > 0.1) sides1[0]++; + else if (dot < -0.1) sides1[1]++; + else sides1[2]++; + } //end for + //check on which side of the seperating plane the points of + //the second winding are + sides2[0] = sides2[1] = sides2[2] = 0; + for (n = 0; n < w2->numpoints; n++) + { + //used normal1 and dist1 (they are equal to normal2 and dist2) + dot = DotProduct(w2->p[n], normal1) - dist1; + if (dot > 0.1) sides2[0]++; + else if (dot < -0.1) sides2[1]++; + else sides2[2]++; + } //end for + //if the first winding has points at both sides + if (sides1[0] && sides1[1]) + { + Log_Write("FindPlaneSeperatingWindings: winding1 non-convex\r\n"); + continue; + } //end if + //if the second winding has points at both sides + if (sides2[0] && sides2[1]) + { + Log_Write("FindPlaneSeperatingWindings: winding2 non-convex\r\n"); + continue; + } //end if + // + if ((!sides1[0] && !sides1[1]) || (!sides2[0] && !sides2[1])) + { + //don't use one of the winding planes as the seperating plane + continue; + } //end if + //the windings must be at different sides of the seperating plane + if ((!sides1[0] && !sides2[1]) || (!sides1[1] && !sides2[0])) + { + VectorCopy(normal1, normal); + *dist = dist1; + return true; + } //end if + } //end for + } //end for + return false; +} //end of the function FindPlaneSeperatingWindings +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#define WCONVEX_EPSILON 0.2 + +int WindingsNonConvex(winding_t *w1, winding_t *w2, + vec3_t normal1, vec3_t normal2, + float dist1, float dist2) +{ + int i; + + if (!w1 || !w2) return false; + + //check if one of the points of face1 is at the back of the plane of face2 + for (i = 0; i < w1->numpoints; i++) + { + if (DotProduct(normal2, w1->p[i]) - dist2 > WCONVEX_EPSILON) return true; + } //end for + //check if one of the points of face2 is at the back of the plane of face1 + for (i = 0; i < w2->numpoints; i++) + { + if (DotProduct(normal1, w2->p[i]) - dist1 > WCONVEX_EPSILON) return true; + } //end for + + return false; +} //end of the function WindingsNonConvex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +/* +#define VERTEX_EPSILON 0.5 + +qboolean EqualVertexes(vec3_t v1, vec3_t v2) +{ + float diff; + + diff = v1[0] - v2[0]; + if (diff > -VERTEX_EPSILON && diff < VERTEX_EPSILON) + { + diff = v1[1] - v2[1]; + if (diff > -VERTEX_EPSILON && diff < VERTEX_EPSILON) + { + diff = v1[2] - v2[2]; + if (diff > -VERTEX_EPSILON && diff < VERTEX_EPSILON) + { + return true; + } //end if + } //end if + } //end if + return false; +} //end of the function EqualVertexes + +#define CONTINUOUS_EPSILON 0.001 + +winding_t *AAS_MergeWindings(winding_t *w1, winding_t *w2, vec3_t windingnormal) +{ + int n, i, k; + vec3_t normal, delta; + winding_t *winding, *neww; + float dist, dot; + int p1, p2; + int points[2][64]; + int numpoints[2] = {0, 0}; + int newnumpoints; + int keep[2]; + + if (!FindPlaneSeperatingWindings(w1, w2, windingnormal, normal, &dist)) return NULL; + + //for both windings + for (n = 0; n < 2; n++) + { + if (n == 0) winding = w1; + else winding = w2; + //get the points of the winding which are on the seperating plane + for (i = 0; i < winding->numpoints; i++) + { + dot = DotProduct(winding->p[i], normal) - dist; + if (dot > -ON_EPSILON && dot < ON_EPSILON) + { + //don't allow more than 64 points on the seperating plane + if (numpoints[n] >= 64) Error("AAS_MergeWindings: more than 64 points on seperating plane\n"); + points[n][numpoints[n]++] = i; + } //end if + } //end for + //there must be at least two points of each winding on the seperating plane + if (numpoints[n] < 2) return NULL; + } //end for + + //if the first point of winding1 (which is on the seperating plane) is unequal + //to the last point of winding2 (which is on the seperating plane) + if (!EqualVertexes(w1->p[points[0][0]], w2->p[points[1][numpoints[1]-1]])) + { + return NULL; + } //end if + //if the last point of winding1 (which is on the seperating plane) is unequal + //to the first point of winding2 (which is on the seperating plane) + if (!EqualVertexes(w1->p[points[0][numpoints[0]-1]], w2->p[points[1][0]])) + { + return NULL; + } //end if + // + // check slope of connected lines + // if the slopes are colinear, the point can be removed + // + //first point of winding1 which is on the seperating plane + p1 = points[0][0]; + //point before p1 + p2 = (p1 + w1->numpoints - 1) % w1->numpoints; + VectorSubtract(w1->p[p1], w1->p[p2], delta); + CrossProduct(windingnormal, delta, normal); + VectorNormalize(normal, normal); + + //last point of winding2 which is on the seperating plane + p1 = points[1][numpoints[1]-1]; + //point after p1 + p2 = (p1 + 1) % w2->numpoints; + VectorSubtract(w2->p[p2], w2->p[p1], delta); + dot = DotProduct(delta, normal); + if (dot > CONTINUOUS_EPSILON) return NULL; //merging would create a non-convex polygon + keep[0] = (qboolean)(dot < -CONTINUOUS_EPSILON); + + //first point of winding2 which is on the seperating plane + p1 = points[1][0]; + //point before p1 + p2 = (p1 + w2->numpoints - 1) % w2->numpoints; + VectorSubtract(w2->p[p1], w2->p[p2], delta); + CrossProduct(windingnormal, delta, normal); + VectorNormalize(normal, normal); + + //last point of winding1 which is on the seperating plane + p1 = points[0][numpoints[0]-1]; + //point after p1 + p2 = (p1 + 1) % w1->numpoints; + VectorSubtract(w1->p[p2], w1->p[p1], delta); + dot = DotProduct(delta, normal); + if (dot > CONTINUOUS_EPSILON) return NULL; //merging would create a non-convex polygon + keep[1] = (qboolean)(dot < -CONTINUOUS_EPSILON); + + //number of points on the new winding + newnumpoints = w1->numpoints - numpoints[0] + w2->numpoints - numpoints[1] + 2; + //allocate the winding + neww = AllocWinding(newnumpoints); + neww->numpoints = newnumpoints; + //copy all the points + k = 0; + //for both windings + for (n = 0; n < 2; n++) + { + if (n == 0) winding = w1; + else winding = w2; + //copy the points of the winding starting with the last point on the + //seperating plane and ending before the first point on the seperating plane + for (i = points[n][numpoints[n]-1]; i != points[n][0]; i = (i+1)%winding->numpoints) + { + if (k >= newnumpoints) + { + Log_Print("numpoints[0] = %d\n", numpoints[0]); + Log_Print("numpoints[1] = %d\n", numpoints[1]); + Error("AAS_MergeWindings: k = %d >= newnumpoints = %d\n", k, newnumpoints); + } //end if + VectorCopy(winding->p[i], neww->p[k]); + k++; + } //end for + } //end for + RemoveEqualPoints(neww); + if (!WindingIsOk(neww, 1)) + { + Log_Print("AAS_MergeWindings: winding not ok after merging\n"); + FreeWinding(neww); + return NULL; + } //end if + return neww; +} //end of the function AAS_MergeWindings*/ +//#endif //ME diff --git a/code/bspc/l_poly.h b/code/bspc/l_poly.h new file mode 100644 index 00000000..f3191eb3 --- /dev/null +++ b/code/bspc/l_poly.h @@ -0,0 +1,120 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +//a winding gives the bounding points of a convex polygon +typedef struct +{ + int numpoints; + vec3_t p[4]; //variable sized +} winding_t; + +#define MAX_POINTS_ON_WINDING 96 + +//you can define on_epsilon in the makefile as tighter +#ifndef ON_EPSILON +#define ON_EPSILON 0.1 +#endif +//winding errors +#define WE_NONE 0 +#define WE_NOTENOUGHPOINTS 1 +#define WE_SMALLAREA 2 +#define WE_POINTBOGUSRANGE 3 +#define WE_POINTOFFPLANE 4 +#define WE_DEGENERATEEDGE 5 +#define WE_NONCONVEX 6 + +//allocates a winding +winding_t *AllocWinding (int points); +//returns the area of the winding +vec_t WindingArea (winding_t *w); +//gives the center of the winding +void WindingCenter (winding_t *w, vec3_t center); +//clips the given winding to the given plane and gives the front +//and back part of the clipped winding +void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, + vec_t epsilon, winding_t **front, winding_t **back); +//returns the fragment of the given winding that is on the front +//side of the cliping plane. The original is freed. +winding_t *ChopWinding (winding_t *in, vec3_t normal, vec_t dist); +//returns a copy of the given winding +winding_t *CopyWinding (winding_t *w); +//returns the reversed winding of the given one +winding_t *ReverseWinding (winding_t *w); +//returns a base winding for the given plane +winding_t *BaseWindingForPlane (vec3_t normal, vec_t dist); +//checks the winding for errors +void CheckWinding (winding_t *w); +//returns the plane normal and dist the winding is in +void WindingPlane(winding_t *w, vec3_t normal, vec_t *dist); +//removes colinear points from the winding +void RemoveColinearPoints(winding_t *w); +//returns on which side of the plane the winding is situated +int WindingOnPlaneSide(winding_t *w, vec3_t normal, vec_t dist); +//frees the winding +void FreeWinding(winding_t *w); +//gets the bounds of the winding +void WindingBounds(winding_t *w, vec3_t mins, vec3_t maxs); +//chops the winding with the given plane, the original winding is freed if clipped +void ChopWindingInPlace (winding_t **w, vec3_t normal, vec_t dist, vec_t epsilon); +//prints the winding points on STDOUT +void pw(winding_t *w); +//try to merge the two windings which are in the given plane +//the original windings are undisturbed +//the merged winding is returned when merging was possible +//NULL is returned otherwise +winding_t *TryMergeWinding (winding_t *f1, winding_t *f2, vec3_t planenormal); +//brute force winding merging... creates a convex winding out of +//the two whatsoever +winding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal); + +//#ifdef ME +void ResetWindings(void); +//returns the amount of winding memory +int WindingMemory(void); +int WindingPeakMemory(void); +int ActiveWindings(void); +//returns the winding error string +char *WindingErrorString(void); +//returns one of the WE_ flags when the winding has errors +int WindingError(winding_t *w); +//removes equal points from the winding +void RemoveEqualPoints(winding_t *w, float epsilon); +//returns a winding with a point added at the given spot to the +//given winding, original winding is NOT freed +winding_t *AddWindingPoint(winding_t *w, vec3_t point, int spot); +//returns true if the point is on one of the winding 'edges' +//when the point is on one of the edged the number of the first +//point of the edge is stored in 'spot' +int PointOnWinding(winding_t *w, vec3_t normal, float dist, vec3_t point, int *spot); +//find a plane seperating the two windings +//true is returned when the windings area adjacent +//the seperating plane normal and distance area stored in 'normal' and 'dist' +//this plane will contain both the piece of common edge of the two windings +//and the vector 'dir' +int FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir, + vec3_t normal, float *dist); +// +int WindingsNonConvex(winding_t *w1, winding_t *w2, + vec3_t normal1, vec3_t normal2, + float dist1, float dist2); +//#endif //ME + diff --git a/code/bspc/l_qfiles.c b/code/bspc/l_qfiles.c new file mode 100644 index 00000000..d86c3d60 --- /dev/null +++ b/code/bspc/l_qfiles.c @@ -0,0 +1,568 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +#if defined(WIN32)|defined(_WIN32) +#include +#include +#include +#else +#include +#include +#include +#endif + +#include "qbsp.h" + +//file extensions with their type +typedef struct qfile_exttype_s +{ + char *extension; + int type; +} qfile_exttyp_t; + +qfile_exttyp_t quakefiletypes[] = +{ + {QFILEEXT_UNKNOWN, QFILETYPE_UNKNOWN}, + {QFILEEXT_PAK, QFILETYPE_PAK}, + {QFILEEXT_PK3, QFILETYPE_PK3}, + {QFILEEXT_SIN, QFILETYPE_PAK}, + {QFILEEXT_BSP, QFILETYPE_BSP}, + {QFILEEXT_MAP, QFILETYPE_MAP}, + {QFILEEXT_MDL, QFILETYPE_MDL}, + {QFILEEXT_MD2, QFILETYPE_MD2}, + {QFILEEXT_MD3, QFILETYPE_MD3}, + {QFILEEXT_WAL, QFILETYPE_WAL}, + {QFILEEXT_WAV, QFILETYPE_WAV}, + {QFILEEXT_AAS, QFILETYPE_AAS}, + {NULL, 0} +}; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int QuakeFileExtensionType(char *extension) +{ + int i; + + for (i = 0; quakefiletypes[i].extension; i++) + { + if (!stricmp(extension, quakefiletypes[i].extension)) + { + return quakefiletypes[i].type; + } //end if + } //end for + return QFILETYPE_UNKNOWN; +} //end of the function QuakeFileExtensionType +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *QuakeFileTypeExtension(int type) +{ + int i; + + for (i = 0; quakefiletypes[i].extension; i++) + { + if (quakefiletypes[i].type == type) + { + return quakefiletypes[i].extension; + } //end if + } //end for + return QFILEEXT_UNKNOWN; +} //end of the function QuakeFileExtension +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int QuakeFileType(char *filename) +{ + char ext[_MAX_PATH] = "."; + + ExtractFileExtension(filename, ext+1); + return QuakeFileExtensionType(ext); +} //end of the function QuakeFileTypeFromFileName +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +char *StringContains(char *str1, char *str2, int casesensitive) +{ + int len, i, j; + + len = strlen(str1) - strlen(str2); + for (i = 0; i <= len; i++, str1++) + { + for (j = 0; str2[j]; j++) + { + if (casesensitive) + { + if (str1[j] != str2[j]) break; + } //end if + else + { + if (toupper(str1[j]) != toupper(str2[j])) break; + } //end else + } //end for + if (!str2[j]) return str1; + } //end for + return NULL; +} //end of the function StringContains +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int FileFilter(char *filter, char *filename, int casesensitive) +{ + char buf[1024]; + char *ptr; + int i, found; + + while(*filter) + { + if (*filter == '*') + { + filter++; + for (i = 0; *filter; i++) + { + if (*filter == '*' || *filter == '?') break; + buf[i] = *filter; + filter++; + } //end for + buf[i] = '\0'; + if (strlen(buf)) + { + ptr = StringContains(filename, buf, casesensitive); + if (!ptr) return false; + filename = ptr + strlen(buf); + } //end if + } //end if + else if (*filter == '?') + { + filter++; + filename++; + } //end else if + else if (*filter == '[' && *(filter+1) == '[') + { + filter++; + } //end if + else if (*filter == '[') + { + filter++; + found = false; + while(*filter && !found) + { + if (*filter == ']' && *(filter+1) != ']') break; + if (*(filter+1) == '-' && *(filter+2) && (*(filter+2) != ']' || *(filter+3) == ']')) + { + if (casesensitive) + { + if (*filename >= *filter && *filename <= *(filter+2)) found = true; + } //end if + else + { + if (toupper(*filename) >= toupper(*filter) && + toupper(*filename) <= toupper(*(filter+2))) found = true; + } //end else + filter += 3; + } //end if + else + { + if (casesensitive) + { + if (*filter == *filename) found = true; + } //end if + else + { + if (toupper(*filter) == toupper(*filename)) found = true; + } //end else + filter++; + } //end else + } //end while + if (!found) return false; + while(*filter) + { + if (*filter == ']' && *(filter+1) != ']') break; + filter++; + } //end while + filter++; + filename++; + } //end else if + else + { + if (casesensitive) + { + if (*filter != *filename) return false; + } //end if + else + { + if (toupper(*filter) != toupper(*filename)) return false; + } //end else + filter++; + filename++; + } //end else + } //end while + return true; +} //end of the function FileFilter +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +quakefile_t *FindQuakeFilesInZip(char *zipfile, char *filter) +{ + unzFile uf; + int err; + unz_global_info gi; + char filename_inzip[MAX_PATH]; + unz_file_info file_info; + int i; + quakefile_t *qfiles, *lastqf, *qf; + + uf = unzOpen(zipfile); + err = unzGetGlobalInfo(uf, &gi); + + if (err != UNZ_OK) return NULL; + + unzGoToFirstFile(uf); + + qfiles = NULL; + lastqf = NULL; + for (i = 0; i < gi.number_entry; i++) + { + err = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL,0,NULL,0); + if (err != UNZ_OK) break; + + ConvertPath(filename_inzip); + if (FileFilter(filter, filename_inzip, false)) + { + qf = malloc(sizeof(quakefile_t)); + if (!qf) Error("out of memory"); + memset(qf, 0, sizeof(quakefile_t)); + strcpy(qf->pakfile, zipfile); + strcpy(qf->filename, zipfile); + strcpy(qf->origname, filename_inzip); + qf->zipfile = true; + //memcpy( &buildBuffer[i].zipfileinfo, (unz_s*)uf, sizeof(unz_s)); + memcpy(&qf->zipinfo, (unz_s*)uf, sizeof(unz_s)); + qf->offset = 0; + qf->length = file_info.uncompressed_size; + qf->type = QuakeFileType(filename_inzip); + //add the file ot the list + qf->next = NULL; + if (lastqf) lastqf->next = qf; + else qfiles = qf; + lastqf = qf; + } //end if + unzGoToNextFile(uf); + } //end for + + unzClose(uf); + + return qfiles; +} //end of the function FindQuakeFilesInZip +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +quakefile_t *FindQuakeFilesInPak(char *pakfile, char *filter) +{ + + Warning("can't open pak file %s", pakfile); + return NULL; + +} //end of the function FindQuakeFilesInPak +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +quakefile_t *FindQuakeFilesWithPakFilter(char *pakfilter, char *filter) +{ +#if defined(WIN32)|defined(_WIN32) + WIN32_FIND_DATA filedata; + HWND handle; + struct _stat statbuf; +#else + glob_t globbuf; + struct stat statbuf; + int j; +#endif + quakefile_t *qfiles, *lastqf, *qf; + char pakfile[_MAX_PATH], filename[_MAX_PATH], *str; + int done; + + qfiles = NULL; + lastqf = NULL; + if (pakfilter && strlen(pakfilter)) + { +#if defined(WIN32)|defined(_WIN32) + handle = FindFirstFile(pakfilter, &filedata); + done = (handle == INVALID_HANDLE_VALUE); + while(!done) + { + _splitpath(pakfilter, pakfile, NULL, NULL, NULL); + _splitpath(pakfilter, NULL, &pakfile[strlen(pakfile)], NULL, NULL); + AppendPathSeperator(pakfile, _MAX_PATH); + strcat(pakfile, filedata.cFileName); + _stat(pakfile, &statbuf); +#else + glob(pakfilter, 0, NULL, &globbuf); + for (j = 0; j < globbuf.gl_pathc; j++) + { + strcpy(pakfile, globbuf.gl_pathv[j]); + stat(pakfile, &statbuf); +#endif + //if the file with .pak or .pk3 is a folder + if (statbuf.st_mode & S_IFDIR) + { + strcpy(filename, pakfilter); + AppendPathSeperator(filename, _MAX_PATH); + strcat(filename, filter); + qf = FindQuakeFilesWithPakFilter(NULL, filename); + if (lastqf) lastqf->next = qf; + else qfiles = qf; + lastqf = qf; + while(lastqf->next) lastqf = lastqf->next; + } //end if + else + { +#if defined(WIN32)|defined(_WIN32) + str = StringContains(pakfile, ".pk3", false); +#else + str = StringContains(pakfile, ".pk3", true); +#endif + if (str && str == pakfile + strlen(pakfile) - strlen(".pk3")) + { + qf = FindQuakeFilesInZip(pakfile, filter); + } //end if + else + { + qf = FindQuakeFilesInPak(pakfile, filter); + } //end else + // + if (qf) + { + if (lastqf) lastqf->next = qf; + else qfiles = qf; + lastqf = qf; + while(lastqf->next) lastqf = lastqf->next; + } //end if + } //end else + // +#if defined(WIN32)|defined(_WIN32) + //find the next file + done = !FindNextFile(handle, &filedata); + } //end while +#else + } //end for + globfree(&globbuf); +#endif + } //end if + else + { +#if defined(WIN32)|defined(_WIN32) + handle = FindFirstFile(filter, &filedata); + done = (handle == INVALID_HANDLE_VALUE); + while(!done) + { + _splitpath(filter, filename, NULL, NULL, NULL); + _splitpath(filter, NULL, &filename[strlen(filename)], NULL, NULL); + AppendPathSeperator(filename, _MAX_PATH); + strcat(filename, filedata.cFileName); +#else + glob(filter, 0, NULL, &globbuf); + for (j = 0; j < globbuf.gl_pathc; j++) + { + strcpy(filename, globbuf.gl_pathv[j]); +#endif + // + qf = malloc(sizeof(quakefile_t)); + if (!qf) Error("out of memory"); + memset(qf, 0, sizeof(quakefile_t)); + strcpy(qf->pakfile, ""); + strcpy(qf->filename, filename); + strcpy(qf->origname, filename); + qf->offset = 0; + qf->length = 0; + qf->type = QuakeFileType(filename); + //add the file ot the list + qf->next = NULL; + if (lastqf) lastqf->next = qf; + else qfiles = qf; + lastqf = qf; +#if defined(WIN32)|defined(_WIN32) + //find the next file + done = !FindNextFile(handle, &filedata); + } //end while +#else + } //end for + globfree(&globbuf); +#endif + } //end else + return qfiles; +} //end of the function FindQuakeFilesWithPakFilter +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +quakefile_t *FindQuakeFiles(char *filter) +{ + char *str; + char newfilter[_MAX_PATH]; + char pakfilter[_MAX_PATH]; + char filefilter[_MAX_PATH]; + + strcpy(newfilter, filter); + ConvertPath(newfilter); + strcpy(pakfilter, newfilter); + + str = StringContains(pakfilter, ".pak", false); + if (!str) str = StringContains(pakfilter, ".pk3", false); + + if (str) + { + str += strlen(".pak"); + if (*str) + { + *str++ = '\0'; + while(*str == '\\' || *str == '/') str++; + strcpy(filefilter, str); + return FindQuakeFilesWithPakFilter(pakfilter, filefilter); + } //end if + } //end else + return FindQuakeFilesWithPakFilter(NULL, newfilter); +} //end of the function FindQuakeFiles +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int LoadQuakeFile(quakefile_t *qf, void **bufferptr) +{ + FILE *fp; + void *buffer; + int length; + unzFile zf; + + if (qf->zipfile) + { + //open the zip file + zf = unzOpen(qf->pakfile); + //set the file pointer + qf->zipinfo.file = ((unz_s *) zf)->file; + //open the Quake file in the zip file + unzOpenCurrentFile(&qf->zipinfo); + //allocate memory for the buffer + length = qf->length; + buffer = GetMemory(length+1); + //read the Quake file from the zip file + length = unzReadCurrentFile(&qf->zipinfo, buffer, length); + //close the Quake file in the zip file + unzCloseCurrentFile(&qf->zipinfo); + //close the zip file + unzClose(zf); + + *bufferptr = buffer; + return length; + } //end if + else + { + fp = SafeOpenRead(qf->filename); + if (qf->offset) fseek(fp, qf->offset, SEEK_SET); + length = qf->length; + if (!length) length = Q_filelength(fp); + buffer = GetMemory(length+1); + ((char *)buffer)[length] = 0; + SafeRead(fp, buffer, length); + fclose(fp); + + *bufferptr = buffer; + return length; + } //end else +} //end of the function LoadQuakeFile +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int ReadQuakeFile(quakefile_t *qf, void *buffer, int offset, int length) +{ + FILE *fp; + int read; + unzFile zf; + char tmpbuf[1024]; + + if (qf->zipfile) + { + //open the zip file + zf = unzOpen(qf->pakfile); + //set the file pointer + qf->zipinfo.file = ((unz_s *) zf)->file; + //open the Quake file in the zip file + unzOpenCurrentFile(&qf->zipinfo); + // + while(offset > 0) + { + read = offset; + if (read > sizeof(tmpbuf)) read = sizeof(tmpbuf); + unzReadCurrentFile(&qf->zipinfo, tmpbuf, read); + offset -= read; + } //end while + //read the Quake file from the zip file + length = unzReadCurrentFile(&qf->zipinfo, buffer, length); + //close the Quake file in the zip file + unzCloseCurrentFile(&qf->zipinfo); + //close the zip file + unzClose(zf); + + return length; + } //end if + else + { + fp = SafeOpenRead(qf->filename); + if (qf->offset) fseek(fp, qf->offset, SEEK_SET); + if (offset) fseek(fp, offset, SEEK_CUR); + SafeRead(fp, buffer, length); + fclose(fp); + + return length; + } //end else +} //end of the function ReadQuakeFile diff --git a/code/bspc/l_qfiles.h b/code/bspc/l_qfiles.h new file mode 100644 index 00000000..0f79e7fa --- /dev/null +++ b/code/bspc/l_qfiles.h @@ -0,0 +1,91 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "../qcommon/unzip.h" + +#define QFILETYPE_UNKNOWN 0x8000 +#define QFILETYPE_PAK 0x0001 +#define QFILETYPE_PK3 0x0002 +#define QFILETYPE_BSP 0x0004 +#define QFILETYPE_MAP 0x0008 +#define QFILETYPE_MDL 0x0010 +#define QFILETYPE_MD2 0x0020 +#define QFILETYPE_MD3 0x0040 +#define QFILETYPE_WAL 0x0080 +#define QFILETYPE_WAV 0x0100 +#define QFILETYPE_AAS 0x4000 + +#define QFILEEXT_UNKNOWN "" +#define QFILEEXT_PAK ".PAK" +#define QFILEEXT_PK3 ".PK3" +#define QFILEEXT_SIN ".SIN" +#define QFILEEXT_BSP ".BSP" +#define QFILEEXT_MAP ".MAP" +#define QFILEEXT_MDL ".MDL" +#define QFILEEXT_MD2 ".MD2" +#define QFILEEXT_MD3 ".MD3" +#define QFILEEXT_WAL ".WAL" +#define QFILEEXT_WAV ".WAV" +#define QFILEEXT_AAS ".AAS" + +//maximum path length +#ifndef _MAX_PATH + #define _MAX_PATH 1024 +#endif + +//for Sin packs +#define MAX_PAK_FILENAME_LENGTH 120 +#define SINPAKHEADER (('K'<<24)+('A'<<16)+('P'<<8)+'S') + +typedef struct +{ + char name[MAX_PAK_FILENAME_LENGTH]; + int filepos, filelen; +} dsinpackfile_t; + +typedef struct quakefile_s +{ + char pakfile[_MAX_PATH]; + char filename[_MAX_PATH]; + char origname[_MAX_PATH]; + int zipfile; + int type; + int offset; + int length; + unz_s zipinfo; + struct quakefile_s *next; +} quakefile_t; + +//returns the file extension for the given type +char *QuakeFileTypeExtension(int type); +//returns the file type for the given extension +int QuakeFileExtensionType(char *extension); +//return the Quake file type for the given file +int QuakeFileType(char *filename); +//returns true if the filename complies to the filter +int FileFilter(char *filter, char *filename, int casesensitive); +//find Quake files using the given filter +quakefile_t *FindQuakeFiles(char *filter); +//load the given Quake file, returns the length of the file +int LoadQuakeFile(quakefile_t *qf, void **bufferptr); +//read part of a Quake file into the buffer +int ReadQuakeFile(quakefile_t *qf, void *buffer, int offset, int length); diff --git a/code/bspc/l_threads.c b/code/bspc/l_threads.c new file mode 100644 index 00000000..94e641a8 --- /dev/null +++ b/code/bspc/l_threads.c @@ -0,0 +1,1510 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "l_cmd.h" +#include "l_threads.h" +#include "l_log.h" +#include "l_mem.h" + +#define MAX_THREADS 64 + +//#define THREAD_DEBUG + +int dispatch; +int workcount; +int oldf; +qboolean pacifier; +qboolean threaded; +void (*workfunction) (int); + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int GetThreadWork(void) +{ + int r; + int f; + + ThreadLock(); + + if (dispatch == workcount) + { + ThreadUnlock (); + return -1; + } + + f = 10*dispatch / workcount; + if (f != oldf) + { + oldf = f; + if (pacifier) + printf ("%i...", f); + } //end if + + r = dispatch; + dispatch++; + ThreadUnlock (); + + return r; +} //end of the function GetThreadWork +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadWorkerFunction(int threadnum) +{ + int work; + + while(1) + { + work = GetThreadWork (); + if (work == -1) + break; +//printf ("thread %i, work %i\n", threadnum, work); + workfunction(work); + } //end while +} //end of the function ThreadWorkerFunction +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RunThreadsOnIndividual (int workcnt, qboolean showpacifier, void(*func)(int)) +{ + if (numthreads == -1) + ThreadSetDefault (); + workfunction = func; + RunThreadsOn (workcnt, showpacifier, ThreadWorkerFunction); +} //end of the function RunThreadsOnIndividual + + +//=================================================================== +// +// WIN32 +// +//=================================================================== + +#if defined(WIN32) || defined(_WIN32) + +#define USED + +#include + +typedef struct thread_s +{ + HANDLE handle; + int threadid; + int id; + struct thread_s *next; +} thread_t; + +thread_t *firstthread; +thread_t *lastthread; +int currentnumthreads; +int currentthreadid; + +int numthreads = 1; +CRITICAL_SECTION crit; +HANDLE semaphore; +static int enter; +static int numwaitingthreads = 0; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetDefault(void) +{ + SYSTEM_INFO info; + + if (numthreads == -1) // not set manually + { + GetSystemInfo (&info); + numthreads = info.dwNumberOfProcessors; + if (numthreads < 1 || numthreads > 32) + numthreads = 1; + } //end if + qprintf ("%i threads\n", numthreads); +} //end of the function ThreadSetDefault +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadLock(void) +{ + if (!threaded) + { + Error("ThreadLock: !threaded"); + return; + } //end if + EnterCriticalSection(&crit); + if (enter) + Error("Recursive ThreadLock\n"); + enter = 1; +} //end of the function ThreadLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadUnlock (void) +{ + if (!threaded) + { + Error("ThreadUnlock: !threaded"); + return; + } //end if + if (!enter) + Error("ThreadUnlock without lock\n"); + enter = 0; + LeaveCriticalSection(&crit); +} //end of the function ThreadUnlock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetupLock(void) +{ + Log_Print("Win32 multi-threading\n"); + InitializeCriticalSection(&crit); + threaded = true; //Stupid me... forgot this!!! + currentnumthreads = 0; + currentthreadid = 0; +} //end of the function ThreadInitLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadShutdownLock(void) +{ + DeleteCriticalSection(&crit); + threaded = false; //Stupid me... forgot this!!! +} //end of the function ThreadShutdownLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetupSemaphore(void) +{ + semaphore = CreateSemaphore(NULL, 0, 99999999, "bspc"); +} //end of the function ThreadSetupSemaphore +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadShutdownSemaphore(void) +{ +} //end of the function ThreadShutdownSemaphore +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSemaphoreWait(void) +{ + WaitForSingleObject(semaphore, INFINITE); +} //end of the function ThreadSemaphoreWait +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSemaphoreIncrease(int count) +{ + ReleaseSemaphore(semaphore, count, NULL); +} //end of the function ThreadSemaphoreIncrease +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RunThreadsOn(int workcnt, qboolean showpacifier, void(*func)(int)) +{ + int threadid[MAX_THREADS]; + HANDLE threadhandle[MAX_THREADS]; + int i; + int start, end; + + Log_Print("Win32 multi-threading\n"); + start = I_FloatTime (); + dispatch = 0; + workcount = workcnt; + oldf = -1; + pacifier = showpacifier; + threaded = true; + + if (numthreads == -1) + ThreadSetDefault (); + + if (numthreads < 1 || numthreads > MAX_THREADS) numthreads = 1; + // + // run threads in parallel + // + InitializeCriticalSection (&crit); + + numwaitingthreads = 0; + + if (numthreads == 1) + { // use same thread + func (0); + } //end if + else + { +// printf("starting %d threads\n", numthreads); + for (i = 0; i < numthreads; i++) + { + threadhandle[i] = CreateThread( + NULL, // LPSECURITY_ATTRIBUTES lpsa, + 0, // DWORD cbStack, + (LPTHREAD_START_ROUTINE)func, // LPTHREAD_START_ROUTINE lpStartAddr, + (LPVOID)i, // LPVOID lpvThreadParm, + 0, // DWORD fdwCreate, + &threadid[i]); +// printf("started thread %d\n", i); + } //end for + + for (i = 0; i < numthreads; i++) + WaitForSingleObject (threadhandle[i], INFINITE); + } //end else + DeleteCriticalSection (&crit); + + threaded = false; + end = I_FloatTime (); + if (pacifier) printf (" (%i)\n", end-start); +} //end of the function RunThreadsOn +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AddThread(void (*func)(int)) +{ + thread_t *thread; + + if (numthreads == 1) + { + if (currentnumthreads >= numthreads) return; + currentnumthreads++; + func(-1); + currentnumthreads--; + } //end if + else + { + ThreadLock(); + if (currentnumthreads >= numthreads) + { + ThreadUnlock(); + return; + } //end if + //allocate new thread + thread = GetMemory(sizeof(thread_t)); + if (!thread) Error("can't allocate memory for thread\n"); + + // + thread->threadid = currentthreadid; + thread->handle = CreateThread( + NULL, // LPSECURITY_ATTRIBUTES lpsa, + 0, // DWORD cbStack, + (LPTHREAD_START_ROUTINE)func, // LPTHREAD_START_ROUTINE lpStartAddr, + (LPVOID) thread->threadid, // LPVOID lpvThreadParm, + 0, // DWORD fdwCreate, + &thread->id); + + //add the thread to the end of the list + thread->next = NULL; + if (lastthread) lastthread->next = thread; + else firstthread = thread; + lastthread = thread; + // +#ifdef THREAD_DEBUG + qprintf("added thread with id %d\n", thread->threadid); +#endif //THREAD_DEBUG + // + currentnumthreads++; + currentthreadid++; + // + ThreadUnlock(); + } //end else +} //end of the function AddThread +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RemoveThread(int threadid) +{ + thread_t *thread, *last; + + //if a single thread + if (threadid == -1) return; + // + ThreadLock(); + last = NULL; + for (thread = firstthread; thread; thread = thread->next) + { + if (thread->threadid == threadid) + { + if (last) last->next = thread->next; + else firstthread = thread->next; + if (!thread->next) lastthread = last; + // + FreeMemory(thread); + currentnumthreads--; +#ifdef THREAD_DEBUG + qprintf("removed thread with id %d\n", threadid); +#endif //THREAD_DEBUG + break; + } //end if + last = thread; + } //end if + if (!thread) Error("couldn't find thread with id %d", threadid); + ThreadUnlock(); +} //end of the function RemoveThread +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void WaitForAllThreadsFinished(void) +{ + HANDLE handle; + + ThreadLock(); + while(firstthread) + { + handle = firstthread->handle; + ThreadUnlock(); + + WaitForSingleObject(handle, INFINITE); + + ThreadLock(); + } //end while + ThreadUnlock(); +} //end of the function WaitForAllThreadsFinished +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int GetNumThreads(void) +{ + return currentnumthreads; +} //end of the function GetNumThreads + +#endif + + +//=================================================================== +// +// OSF1 +// +//=================================================================== + +#if defined(__osf__) + +#define USED + +#include + +typedef struct thread_s +{ + pthread_t thread; + int threadid; + int id; + struct thread_s *next; +} thread_t; + +thread_t *firstthread; +thread_t *lastthread; +int currentnumthreads; +int currentthreadid; + +int numthreads = 1; +pthread_mutex_t my_mutex; +pthread_attr_t attrib; +static int enter; +static int numwaitingthreads = 0; + + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetDefault(void) +{ + if (numthreads == -1) // not set manually + { + numthreads = 1; + } //end if + qprintf("%i threads\n", numthreads); +} //end of the function ThreadSetDefault +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadLock(void) +{ + if (!threaded) + { + Error("ThreadLock: !threaded"); + return; + } //end if + if (my_mutex) + { + pthread_mutex_lock(my_mutex); + } //end if + if (enter) + Error("Recursive ThreadLock\n"); + enter = 1; +} //end of the function ThreadLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadUnlock(void) +{ + if (!threaded) + { + Error("ThreadUnlock: !threaded"); + return; + } //end if + if (!enter) + Error("ThreadUnlock without lock\n"); + enter = 0; + if (my_mutex) + { + pthread_mutex_unlock(my_mutex); + } //end if +} //end of the function ThreadUnlock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetupLock(void) +{ + pthread_mutexattr_t mattrib; + + Log_Print("pthread multi-threading\n"); + + if (!my_mutex) + { + my_mutex = GetMemory(sizeof(*my_mutex)); + if (pthread_mutexattr_create (&mattrib) == -1) + Error ("pthread_mutex_attr_create failed"); + if (pthread_mutexattr_setkind_np (&mattrib, MUTEX_FAST_NP) == -1) + Error ("pthread_mutexattr_setkind_np failed"); + if (pthread_mutex_init (my_mutex, mattrib) == -1) + Error ("pthread_mutex_init failed"); + } + + if (pthread_attr_create (&attrib) == -1) + Error ("pthread_attr_create failed"); + if (pthread_attr_setstacksize (&attrib, 0x100000) == -1) + Error ("pthread_attr_setstacksize failed"); + + threaded = true; + currentnumthreads = 0; + currentthreadid = 0; +} //end of the function ThreadInitLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadShutdownLock(void) +{ + threaded = false; +} //end of the function ThreadShutdownLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RunThreadsOn(int workcnt, qboolean showpacifier, void(*func)(int)) +{ + int i; + pthread_t work_threads[MAX_THREADS]; + pthread_addr_t status; + pthread_attr_t attrib; + pthread_mutexattr_t mattrib; + int start, end; + + Log_Print("pthread multi-threading\n"); + + start = I_FloatTime (); + dispatch = 0; + workcount = workcnt; + oldf = -1; + pacifier = showpacifier; + threaded = true; + + if (numthreads < 1 || numthreads > MAX_THREADS) numthreads = 1; + + if (pacifier) + setbuf (stdout, NULL); + + if (!my_mutex) + { + my_mutex = GetMemory(sizeof(*my_mutex)); + if (pthread_mutexattr_create (&mattrib) == -1) + Error ("pthread_mutex_attr_create failed"); + if (pthread_mutexattr_setkind_np (&mattrib, MUTEX_FAST_NP) == -1) + Error ("pthread_mutexattr_setkind_np failed"); + if (pthread_mutex_init (my_mutex, mattrib) == -1) + Error ("pthread_mutex_init failed"); + } + + if (pthread_attr_create (&attrib) == -1) + Error ("pthread_attr_create failed"); + if (pthread_attr_setstacksize (&attrib, 0x100000) == -1) + Error ("pthread_attr_setstacksize failed"); + + for (i=0 ; i= numthreads) return; + currentnumthreads++; + func(-1); + currentnumthreads--; + } //end if + else + { + ThreadLock(); + if (currentnumthreads >= numthreads) + { + ThreadUnlock(); + return; + } //end if + //allocate new thread + thread = GetMemory(sizeof(thread_t)); + if (!thread) Error("can't allocate memory for thread\n"); + // + thread->threadid = currentthreadid; + + if (pthread_create(&thread->thread, attrib, (pthread_startroutine_t)func, (pthread_addr_t)thread->threadid) == -1) + Error ("pthread_create failed"); + + //add the thread to the end of the list + thread->next = NULL; + if (lastthread) lastthread->next = thread; + else firstthread = thread; + lastthread = thread; + // +#ifdef THREAD_DEBUG + qprintf("added thread with id %d\n", thread->threadid); +#endif //THREAD_DEBUG + // + currentnumthreads++; + currentthreadid++; + // + ThreadUnlock(); + } //end else +} //end of the function AddThread +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RemoveThread(int threadid) +{ + thread_t *thread, *last; + + //if a single thread + if (threadid == -1) return; + // + ThreadLock(); + last = NULL; + for (thread = firstthread; thread; thread = thread->next) + { + if (thread->threadid == threadid) + { + if (last) last->next = thread->next; + else firstthread = thread->next; + if (!thread->next) lastthread = last; + // + FreeMemory(thread); + currentnumthreads--; +#ifdef THREAD_DEBUG + qprintf("removed thread with id %d\n", threadid); +#endif //THREAD_DEBUG + break; + } //end if + last = thread; + } //end if + if (!thread) Error("couldn't find thread with id %d", threadid); + ThreadUnlock(); +} //end of the function RemoveThread +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void WaitForAllThreadsFinished(void) +{ + pthread_t *thread; + pthread_addr_t status; + + ThreadLock(); + while(firstthread) + { + thread = &firstthread->thread; + ThreadUnlock(); + + if (pthread_join(*thread, &status) == -1) + Error("pthread_join failed"); + + ThreadLock(); + } //end while + ThreadUnlock(); +} //end of the function WaitForAllThreadsFinished +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int GetNumThreads(void) +{ + return currentnumthreads; +} //end of the function GetNumThreads + +#endif + +//=================================================================== +// +// LINUX +// +//=================================================================== + +#if defined(LINUX) + +#define USED + +#include +#include + +typedef struct thread_s +{ + pthread_t thread; + int threadid; + int id; + struct thread_s *next; +} thread_t; + +thread_t *firstthread; +thread_t *lastthread; +int currentnumthreads; +int currentthreadid; + +int numthreads = 1; +pthread_mutex_t my_mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_attr_t attrib; +sem_t semaphore; +static int enter; +static int numwaitingthreads = 0; + + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetDefault(void) +{ + if (numthreads == -1) // not set manually + { + numthreads = 1; + } //end if + qprintf("%i threads\n", numthreads); +} //end of the function ThreadSetDefault +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadLock(void) +{ + if (!threaded) + { + Error("ThreadLock: !threaded"); + return; + } //end if + pthread_mutex_lock(&my_mutex); + if (enter) + Error("Recursive ThreadLock\n"); + enter = 1; +} //end of the function ThreadLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadUnlock(void) +{ + if (!threaded) + { + Error("ThreadUnlock: !threaded"); + return; + } //end if + if (!enter) + Error("ThreadUnlock without lock\n"); + enter = 0; + pthread_mutex_unlock(&my_mutex); +} //end of the function ThreadUnlock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetupLock(void) +{ + pthread_mutexattr_t mattrib; + + Log_Print("pthread multi-threading\n"); + + threaded = true; + currentnumthreads = 0; + currentthreadid = 0; +} //end of the function ThreadInitLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadShutdownLock(void) +{ + threaded = false; +} //end of the function ThreadShutdownLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetupSemaphore(void) +{ + sem_init(&semaphore, 0, 0); +} //end of the function ThreadSetupSemaphore +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadShutdownSemaphore(void) +{ + sem_destroy(&semaphore); +} //end of the function ThreadShutdownSemaphore +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSemaphoreWait(void) +{ + sem_wait(&semaphore); +} //end of the function ThreadSemaphoreWait +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSemaphoreIncrease(int count) +{ + int i; + + for (i = 0; i < count; i++) + { + sem_post(&semaphore); + } //end for +} //end of the function ThreadSemaphoreIncrease +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RunThreadsOn(int workcnt, qboolean showpacifier, void(*func)(int)) +{ + int i; + pthread_t work_threads[MAX_THREADS]; + void *pthread_return; + pthread_attr_t attrib; + pthread_mutexattr_t mattrib; + int start, end; + + Log_Print("pthread multi-threading\n"); + + start = I_FloatTime (); + dispatch = 0; + workcount = workcnt; + oldf = -1; + pacifier = showpacifier; + threaded = true; + + if (numthreads < 1 || numthreads > MAX_THREADS) numthreads = 1; + + if (pacifier) + setbuf (stdout, NULL); + + for (i=0 ; i= numthreads) return; + currentnumthreads++; + func(-1); + currentnumthreads--; + } //end if + else + { + ThreadLock(); + if (currentnumthreads >= numthreads) + { + ThreadUnlock(); + return; + } //end if + //allocate new thread + thread = GetMemory(sizeof(thread_t)); + if (!thread) Error("can't allocate memory for thread\n"); + // + thread->threadid = currentthreadid; + + if (pthread_create(&thread->thread, NULL, (void *)func, (void *)thread->threadid) == -1) + Error ("pthread_create failed"); + + //add the thread to the end of the list + thread->next = NULL; + if (lastthread) lastthread->next = thread; + else firstthread = thread; + lastthread = thread; + // +#ifdef THREAD_DEBUG + qprintf("added thread with id %d\n", thread->threadid); +#endif //THREAD_DEBUG + // + currentnumthreads++; + currentthreadid++; + // + ThreadUnlock(); + } //end else +} //end of the function AddThread +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RemoveThread(int threadid) +{ + thread_t *thread, *last; + + //if a single thread + if (threadid == -1) return; + // + ThreadLock(); + last = NULL; + for (thread = firstthread; thread; thread = thread->next) + { + if (thread->threadid == threadid) + { + if (last) last->next = thread->next; + else firstthread = thread->next; + if (!thread->next) lastthread = last; + // + FreeMemory(thread); + currentnumthreads--; +#ifdef THREAD_DEBUG + qprintf("removed thread with id %d\n", threadid); +#endif //THREAD_DEBUG + break; + } //end if + last = thread; + } //end if + if (!thread) Error("couldn't find thread with id %d", threadid); + ThreadUnlock(); +} //end of the function RemoveThread +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void WaitForAllThreadsFinished(void) +{ + pthread_t *thread; + void *pthread_return; + + ThreadLock(); + while(firstthread) + { + thread = &firstthread->thread; + ThreadUnlock(); + + if (pthread_join(*thread, &pthread_return) == -1) + Error("pthread_join failed"); + + ThreadLock(); + } //end while + ThreadUnlock(); +} //end of the function WaitForAllThreadsFinished +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int GetNumThreads(void) +{ + return currentnumthreads; +} //end of the function GetNumThreads + +#endif //LINUX + + +//=================================================================== +// +// IRIX +// +//=================================================================== + +#ifdef _MIPS_ISA + +#define USED + +#include +#include +#include +#include + +typedef struct thread_s +{ + int threadid; + int id; + struct thread_s *next; +} thread_t; + +thread_t *firstthread; +thread_t *lastthread; +int currentnumthreads; +int currentthreadid; + +int numthreads = 1; +static int enter; +static int numwaitingthreads = 0; + +abilock_t lck; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetDefault (void) +{ + if (numthreads == -1) + numthreads = prctl(PR_MAXPPROCS); + printf ("%i threads\n", numthreads); +//@@ + usconfig (CONF_INITUSERS, numthreads); +} //end of the function ThreadSetDefault +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadLock (void) +{ + spin_lock (&lck); +} //end of the function ThreadLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadUnlock (void) +{ + release_lock(&lck); +} //end of the function ThreadUnlock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetupLock(void) +{ + init_lock (&lck); + + Log_Print("IRIX multi-threading\n"); + + threaded = true; + currentnumthreads = 0; + currentthreadid = 0; +} //end of the function ThreadInitLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadShutdownLock(void) +{ + threaded = false; +} //end of the function ThreadShutdownLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int)) +{ + int i; + int pid[MAX_THREADS]; + int start, end; + + start = I_FloatTime (); + dispatch = 0; + workcount = workcnt; + oldf = -1; + pacifier = showpacifier; + threaded = true; + + if (numthreads < 1 || numthreads > MAX_THREADS) numthreads = 1; + + if (pacifier) + setbuf (stdout, NULL); + + init_lock (&lck); + + for (i=0 ; i= numthreads) return; + currentnumthreads++; + func(-1); + currentnumthreads--; + } //end if + else + { + ThreadLock(); + if (currentnumthreads >= numthreads) + { + ThreadUnlock(); + return; + } //end if + //allocate new thread + thread = GetMemory(sizeof(thread_t)); + if (!thread) Error("can't allocate memory for thread\n"); + // + thread->threadid = currentthreadid; + + thread->id = sprocsp ( (void (*)(void *, size_t))func, PR_SALL, (void *)thread->threadid, NULL, 0x100000); + if (thread->id == -1) + { + perror ("sproc"); + Error ("sproc failed"); + } + + //add the thread to the end of the list + thread->next = NULL; + if (lastthread) lastthread->next = thread; + else firstthread = thread; + lastthread = thread; + // +#ifdef THREAD_DEBUG + qprintf("added thread with id %d\n", thread->threadid); +#endif //THREAD_DEBUG + // + currentnumthreads++; + currentthreadid++; + // + ThreadUnlock(); + } //end else +} //end of the function AddThread +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RemoveThread(int threadid) +{ + thread_t *thread, *last; + + //if a single thread + if (threadid == -1) return; + // + ThreadLock(); + last = NULL; + for (thread = firstthread; thread; thread = thread->next) + { + if (thread->threadid == threadid) + { + if (last) last->next = thread->next; + else firstthread = thread->next; + if (!thread->next) lastthread = last; + // + FreeMemory(thread); + currentnumthreads--; +#ifdef THREAD_DEBUG + qprintf("removed thread with id %d\n", threadid); +#endif //THREAD_DEBUG + break; + } //end if + last = thread; + } //end if + if (!thread) Error("couldn't find thread with id %d", threadid); + ThreadUnlock(); +} //end of the function RemoveThread +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void WaitForAllThreadsFinished(void) +{ + ThreadLock(); + while(firstthread) + { + ThreadUnlock(); + + //wait (NULL); + + ThreadLock(); + } //end while + ThreadUnlock(); +} //end of the function WaitForAllThreadsFinished +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int GetNumThreads(void) +{ + return currentnumthreads; +} //end of the function GetNumThreads + +#endif //_MIPS_ISA + + +//======================================================================= +// +// SINGLE THREAD +// +//======================================================================= + +#ifndef USED + +int numthreads = 1; +int currentnumthreads = 0; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetDefault(void) +{ + numthreads = 1; +} //end of the function ThreadSetDefault +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadLock(void) +{ +} //end of the function ThreadLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadUnlock(void) +{ +} //end of the function ThreadUnlock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetupLock(void) +{ + Log_Print("no multi-threading\n"); +} //end of the function ThreadInitLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadShutdownLock(void) +{ +} //end of the function ThreadShutdownLock +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSetupSemaphore(void) +{ +} //end of the function ThreadSetupSemaphore +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadShutdownSemaphore(void) +{ +} //end of the function ThreadShutdownSemaphore +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSemaphoreWait(void) +{ +} //end of the function ThreadSemaphoreWait +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ThreadSemaphoreIncrease(int count) +{ +} //end of the function ThreadSemaphoreIncrease +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RunThreadsOn(int workcnt, qboolean showpacifier, void(*func)(int)) +{ + int start, end; + + Log_Print("no multi-threading\n"); + dispatch = 0; + workcount = workcnt; + oldf = -1; + pacifier = showpacifier; + start = I_FloatTime (); +#ifdef NeXT + if (pacifier) + setbuf (stdout, NULL); +#endif + func(0); + + end = I_FloatTime (); + if (pacifier) + printf (" (%i)\n", end-start); +} //end of the function RunThreadsOn +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AddThread(void (*func)(int)) +{ + if (currentnumthreads >= numthreads) return; + currentnumthreads++; + func(-1); + currentnumthreads--; +} //end of the function AddThread +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RemoveThread(int threadid) +{ +} //end of the function RemoveThread +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void WaitForAllThreadsFinished(void) +{ +} //end of the function WaitForAllThreadsFinished +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int GetNumThreads(void) +{ + return currentnumthreads; +} //end of the function GetNumThreads + +#endif //USED diff --git a/code/bspc/l_threads.h b/code/bspc/l_threads.h new file mode 100644 index 00000000..fe4df17e --- /dev/null +++ b/code/bspc/l_threads.h @@ -0,0 +1,45 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +extern int numthreads; + +void ThreadSetDefault (void); +int GetThreadWork (void); +void RunThreadsOnIndividual (int workcnt, qboolean showpacifier, void(*func)(int)); +void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int)); + +//mutex +void ThreadSetupLock(void); +void ThreadShutdownLock(void); +void ThreadLock (void); +void ThreadUnlock (void); +//semaphore +void ThreadSetupSemaphore(void); +void ThreadShutdownSemaphore(void); +void ThreadSemaphoreWait(void); +void ThreadSemaphoreIncrease(int count); +//add/remove threads +void AddThread(void (*func)(int)); +void RemoveThread(int threadid); +void WaitForAllThreadsFinished(void); +int GetNumThreads(void); + diff --git a/code/bspc/l_utils.c b/code/bspc/l_utils.c new file mode 100644 index 00000000..8b229aa4 --- /dev/null +++ b/code/bspc/l_utils.c @@ -0,0 +1,259 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +//#ifndef BOTLIB +//#define BOTLIB +//#endif //BOTLIB + +#ifdef BOTLIB +#include "q_shared.h" +#include "qfiles.h" +#include "botlib.h" +#include "l_log.h" +#include "l_libvar.h" +#include "l_memory.h" +//#include "l_utils.h" +#include "be_interface.h" +#else //BOTLIB +#include "qbsp.h" +#include "l_mem.h" +#endif //BOTLIB + +#ifdef BOTLIB +//======================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//======================================================================== +void Vector2Angles(vec3_t value1, vec3_t angles) +{ + float forward; + float yaw, pitch; + + if (value1[1] == 0 && value1[0] == 0) + { + yaw = 0; + if (value1[2] > 0) pitch = 90; + else pitch = 270; + } //end if + else + { + yaw = (int) (atan2(value1[1], value1[0]) * 180 / M_PI); + if (yaw < 0) yaw += 360; + + forward = sqrt (value1[0]*value1[0] + value1[1]*value1[1]); + pitch = (int) (atan2(value1[2], forward) * 180 / M_PI); + if (pitch < 0) pitch += 360; + } //end else + + angles[PITCH] = -pitch; + angles[YAW] = yaw; + angles[ROLL] = 0; +} //end of the function Vector2Angles +#endif //BOTLIB +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ConvertPath(char *path) +{ + while(*path) + { + if (*path == '/' || *path == '\\') *path = PATHSEPERATOR_CHAR; + path++; + } //end while +} //end of the function ConvertPath +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AppendPathSeperator(char *path, int length) +{ + int pathlen = strlen(path); + + if (strlen(path) && length-pathlen > 1 && path[pathlen-1] != '/' && path[pathlen-1] != '\\') + { + path[pathlen] = PATHSEPERATOR_CHAR; + path[pathlen+1] = '\0'; + } //end if +} //end of the function AppenPathSeperator + +#if 0 +//=========================================================================== +// returns pointer to file handle +// sets offset to and length of 'filename' in the pak file +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean FindFileInPak(char *pakfile, char *filename, foundfile_t *file) +{ + FILE *fp; + dpackheader_t packheader; + dpackfile_t *packfiles; + int numdirs, i; + char path[MAX_PATH]; + + //open the pak file + fp = fopen(pakfile, "rb"); + if (!fp) + { + return false; + } //end if + //read pak header, check for valid pak id and seek to the dir entries + if ((fread(&packheader, 1, sizeof(dpackheader_t), fp) != sizeof(dpackheader_t)) + || (packheader.ident != IDPAKHEADER) + || (fseek(fp, LittleLong(packheader.dirofs), SEEK_SET)) + ) + { + fclose(fp); + return false; + } //end if + //number of dir entries in the pak file + numdirs = LittleLong(packheader.dirlen) / sizeof(dpackfile_t); + packfiles = (dpackfile_t *) GetMemory(numdirs * sizeof(dpackfile_t)); + //read the dir entry + if (fread(packfiles, sizeof(dpackfile_t), numdirs, fp) != numdirs) + { + fclose(fp); + FreeMemory(packfiles); + return false; + } //end if + fclose(fp); + // + strcpy(path, filename); + ConvertPath(path); + //find the dir entry in the pak file + for (i = 0; i < numdirs; i++) + { + //convert the dir entry name + ConvertPath(packfiles[i].name); + //compare the dir entry name with the filename + if (Q_strcasecmp(packfiles[i].name, path) == 0) + { + strcpy(file->filename, pakfile); + file->offset = LittleLong(packfiles[i].filepos); + file->length = LittleLong(packfiles[i].filelen); + FreeMemory(packfiles); + return true; + } //end if + } //end for + FreeMemory(packfiles); + return false; +} //end of the function FindFileInPak +//=========================================================================== +// find a Quake2 file +// returns full path in 'filename' +// sets offset and length of the file +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean FindQuakeFile2(char *basedir, char *gamedir, char *filename, foundfile_t *file) +{ + int dir, i; + //NOTE: 3 is necessary (LCC bug???) + char gamedirs[3][MAX_PATH] = {"","",""}; + char filedir[MAX_PATH] = ""; + + // + if (gamedir) strncpy(gamedirs[0], gamedir, MAX_PATH); + strncpy(gamedirs[1], "baseq2", MAX_PATH); + // + //find the file in the two game directories + for (dir = 0; dir < 2; dir++) + { + //check if the file is in a directory + filedir[0] = 0; + if (basedir && strlen(basedir)) + { + strncpy(filedir, basedir, MAX_PATH); + AppendPathSeperator(filedir, MAX_PATH); + } //end if + if (strlen(gamedirs[dir])) + { + strncat(filedir, gamedirs[dir], MAX_PATH - strlen(filedir)); + AppendPathSeperator(filedir, MAX_PATH); + } //end if + strncat(filedir, filename, MAX_PATH - strlen(filedir)); + ConvertPath(filedir); + Log_Write("accessing %s", filedir); + if (!access(filedir, 0x04)) + { + strcpy(file->filename, filedir); + file->length = 0; + file->offset = 0; + return true; + } //end if + //check if the file is in a pak?.pak + for (i = 0; i < 10; i++) + { + filedir[0] = 0; + if (basedir && strlen(basedir)) + { + strncpy(filedir, basedir, MAX_PATH); + AppendPathSeperator(filedir, MAX_PATH); + } //end if + if (strlen(gamedirs[dir])) + { + strncat(filedir, gamedirs[dir], MAX_PATH - strlen(filedir)); + AppendPathSeperator(filedir, MAX_PATH); + } //end if + sprintf(&filedir[strlen(filedir)], "pak%d.pak\0", i); + if (!access(filedir, 0x04)) + { + Log_Write("searching %s in %s", filename, filedir); + if (FindFileInPak(filedir, filename, file)) return true; + } //end if + } //end for + } //end for + file->offset = 0; + file->length = 0; + return false; +} //end of the function FindQuakeFile2 +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef BOTLIB +qboolean FindQuakeFile(char *filename, foundfile_t *file) +{ + return FindQuakeFile2(LibVarGetString("basedir"), + LibVarGetString("gamedir"), filename, file); +} //end of the function FindQuakeFile +#else //BOTLIB +qboolean FindQuakeFile(char *basedir, char *gamedir, char *filename, foundfile_t *file) +{ + return FindQuakeFile2(basedir, gamedir, filename, file); +} //end of the function FindQuakeFile +#endif //BOTLIB + +#endif diff --git a/code/bspc/l_utils.h b/code/bspc/l_utils.h new file mode 100644 index 00000000..ebd8dbb6 --- /dev/null +++ b/code/bspc/l_utils.h @@ -0,0 +1,79 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +#ifndef MAX_PATH + #define MAX_PATH 64 +#endif + +#ifndef PATH_SEPERATORSTR + #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__) + #define PATHSEPERATOR_STR "\\" + #else + #define PATHSEPERATOR_STR "/" + #endif +#endif +#ifndef PATH_SEPERATORCHAR + #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__) + #define PATHSEPERATOR_CHAR '\\' + #else + #define PATHSEPERATOR_CHAR '/' + #endif +#endif + +//random in the range [0, 1] +#define random() ((rand () & 0x7fff) / ((float)0x7fff)) +//random in the range [-1, 1] +#define crandom() (2.0 * (random() - 0.5)) +//min and max +#define Maximum(x,y) (x > y ? x : y) +#define Minimum(x,y) (x < y ? x : y) +//absolute value +#define FloatAbs(x) (*(float *) &((* (int *) &(x)) & 0x7FFFFFFF)) +#define IntAbs(x) (~(x)) +//coordinates +#define _X 0 +#define _Y 1 +#define _Z 2 + +typedef struct foundfile_s +{ + int offset; + int length; + char filename[MAX_PATH]; //screw LCC, array must be at end of struct +} foundfile_t; + +void Vector2Angles(vec3_t value1, vec3_t angles); +//set the correct path seperators +void ConvertPath(char *path); +//append a path seperator to the given path not exceeding the length +void AppendPathSeperator(char *path, int length); +//find a file in a pak file +qboolean FindFileInPak(char *pakfile, char *filename, foundfile_t *file); +//find a quake file +#ifdef BOTLIB +qboolean FindQuakeFile(char *filename, foundfile_t *file); +#else //BOTLIB +qboolean FindQuakeFile(char *basedir, char *gamedir, char *filename, foundfile_t *file); +#endif //BOTLIB + + + diff --git a/code/bspc/lcc.mak b/code/bspc/lcc.mak new file mode 100644 index 00000000..1b99864d --- /dev/null +++ b/code/bspc/lcc.mak @@ -0,0 +1,61 @@ +# +# Makefile for the BSPC tool for the Gladiator Bot +# Intended for LCC-Win32 +# + +CC=lcc +CFLAGS=-DC_ONLY -o +OBJS= _files.obj\ + aas_areamerging.obj\ + aas_cfg.obj\ + aas_create.obj\ + aas_edgemelting.obj\ + aas_facemerging.obj\ + aas_file.obj\ + aas_gsubdiv.obj\ + aas_map.obj\ + aas_prunenodes.obj\ + aas_store.obj\ + brushbsp.obj\ + bspc.obj\ + csg.obj\ + faces.obj\ + glfile.obj\ + l_bsp_hl.obj\ + l_bsp_q1.obj\ + l_bsp_q2.obj\ + l_bsp_sin.obj\ + l_cmd.obj\ + l_log.obj\ + l_math.obj\ + l_mem.obj\ + l_poly.obj\ + l_qfiles.obj\ + l_script.obj\ + l_threads.obj\ + l_utils.obj\ + leakfile.obj\ + map.obj\ + map_hl.obj\ + map_q1.obj\ + map_q2.obj\ + map_q2_new.obj\ + map_sin.obj\ + nodraw.obj\ + portals.obj\ + prtfile.obj\ + textures.obj\ + tree.obj\ + writebsp.obj + +all: bspc.exe + +bspc.exe: $(OBJS) + lcclnk + +clean: + del *.obj bspc.exe + +%.obj: %.c + $(CC) $(CFLAGS) $< + diff --git a/code/bspc/leakfile.c b/code/bspc/leakfile.c new file mode 100644 index 00000000..924b34d5 --- /dev/null +++ b/code/bspc/leakfile.c @@ -0,0 +1,101 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" + +/* +============================================================================== + +LEAF FILE GENERATION + +Save out name.line for qe3 to read +============================================================================== +*/ + + +/* +============= +LeakFile + +Finds the shortest possible chain of portals +that leads from the outside leaf to a specifically +occupied leaf +============= +*/ +void LeakFile (tree_t *tree) +{ + vec3_t mid; + FILE *linefile; + char filename[1024]; + node_t *node; + int count; + + if (!tree->outside_node.occupied) + return; + + qprintf ("--- LeakFile ---\n"); + + // + // write the points to the file + // + sprintf (filename, "%s.lin", source); + qprintf ("%s\n", filename); + linefile = fopen (filename, "w"); + if (!linefile) + Error ("Couldn't open %s\n", filename); + + count = 0; + node = &tree->outside_node; + while (node->occupied > 1) + { + int next; + portal_t *p, *nextportal; + node_t *nextnode; + int s; + + // find the best portal exit + next = node->occupied; + for (p=node->portals ; p ; p = p->next[!s]) + { + s = (p->nodes[0] == node); + if (p->nodes[s]->occupied + && p->nodes[s]->occupied < next) + { + nextportal = p; + nextnode = p->nodes[s]; + next = nextnode->occupied; + } + } + node = nextnode; + WindingCenter (nextportal->winding, mid); + fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]); + count++; + } + // add the occupant center + GetVectorForKey (node->occupant, "origin", mid); + + fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]); + qprintf ("%5i point linefile\n", count+1); + + fclose (linefile); +} + diff --git a/code/bspc/linux-i386.mak b/code/bspc/linux-i386.mak new file mode 100644 index 00000000..dd9566d3 --- /dev/null +++ b/code/bspc/linux-i386.mak @@ -0,0 +1,109 @@ +# +# Makefile for the BSPC tool for the Gladiator Bot +# Intended for gcc/Linux +# + +ARCH=i386 +CC=gcc +BASE_CFLAGS=-Dstricmp=strcasecmp + +#use these cflags to optimize it +CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \ + -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \ + -malign-jumps=2 -malign-functions=2 -DLINUX -DBSPC +#use these when debugging +#CFLAGS=$(BASE_CFLAGS) -g + +LDFLAGS=-ldl -lm -lpthread + +DO_CC=$(CC) $(CFLAGS) -o $@ -c $< + +############################################################################# +# SETUP AND BUILD BSPC +############################################################################# + +.c.o: + $(DO_CC) + +GAME_OBJS = \ + _files.o\ + aas_areamerging.o\ + aas_cfg.o\ + aas_create.o\ + aas_edgemelting.o\ + aas_facemerging.o\ + aas_file.o\ + aas_gsubdiv.o\ + aas_map.o\ + aas_prunenodes.o\ + aas_store.o\ + be_aas_bspc.o\ + ../botlib/be_aas_bspq3.o\ + ../botlib/be_aas_cluster.o\ + ../botlib/be_aas_move.o\ + ../botlib/be_aas_optimize.o\ + ../botlib/be_aas_reach.o\ + ../botlib/be_aas_sample.o\ + brushbsp.o\ + bspc.o\ + ../qcommon/cm_load.o\ + ../qcommon/cm_patch.o\ + ../qcommon/cm_test.o\ + ../qcommon/cm_trace.o\ + csg.o\ + glfile.o\ + l_bsp_ent.o\ + l_bsp_hl.o\ + l_bsp_q1.o\ + l_bsp_q2.o\ + l_bsp_q3.o\ + l_bsp_sin.o\ + l_cmd.o\ + ../botlib/l_libvar.o\ + l_log.o\ + l_math.o\ + l_mem.o\ + l_poly.o\ + ../botlib/l_precomp.o\ + l_qfiles.o\ + ../botlib/l_script.o\ + ../botlib/l_struct.o\ + l_threads.o\ + l_utils.o\ + leakfile.o\ + map.o\ + map_hl.o\ + map_q1.o\ + map_q2.o\ + map_q3.o\ + map_sin.o\ + ../qcommon/md4.o\ + nodraw.o\ + portals.o\ + tetrahedron.o\ + textures.o\ + tree.o\ + ../qcommon/unzip.o + +bspc$(ARCH) : $(GAME_OBJS) + $(CC) $(CFLAGS) -o $@ $(GAME_OBJS) $(LDFLAGS) + + +############################################################################# +# MISC +############################################################################# + +clean: + -rm -f $(GAME_OBJS) + +depend: + gcc -MM $(GAME_OBJS:.o=.c) + + +install: + cp bspci386 .. + +# +# From "make depend" +# + diff --git a/code/bspc/map.c b/code/bspc/map.c new file mode 100644 index 00000000..a6ac8ef9 --- /dev/null +++ b/code/bspc/map.c @@ -0,0 +1,1260 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "l_bsp_hl.h" +#include "l_bsp_q1.h" +#include "l_bsp_q3.h" +#include "l_bsp_sin.h" +#include "l_mem.h" +#include "../botlib/aasfile.h" //aas_bbox_t +#include "aas_store.h" //AAS_MAX_BBOXES +#include "aas_cfg.h" + +#define Sign(x) (x < 0 ? 1 : 0) + +int nummapbrushes; +mapbrush_t mapbrushes[MAX_MAPFILE_BRUSHES]; + +int nummapbrushsides; +side_t brushsides[MAX_MAPFILE_BRUSHSIDES]; +brush_texture_t side_brushtextures[MAX_MAPFILE_BRUSHSIDES]; + +int nummapplanes; +plane_t mapplanes[MAX_MAPFILE_PLANES]; +int mapplaneusers[MAX_MAPFILE_PLANES]; + +#define PLANE_HASHES 1024 +plane_t *planehash[PLANE_HASHES]; +vec3_t map_mins, map_maxs; + +#ifdef SIN +textureref_t side_newrefs[MAX_MAPFILE_BRUSHSIDES]; +#endif + +map_texinfo_t map_texinfo[MAX_MAPFILE_TEXINFO]; +int map_numtexinfo; +int loadedmaptype; //loaded map type + +// undefine to make plane finding use linear sort +#define USE_HASHING + +int c_boxbevels; +int c_edgebevels; +int c_areaportals; +int c_clipbrushes; +int c_squattbrushes; +int c_writtenbrushes; + +/* +============================================================================= + +PLANE FINDING + +============================================================================= +*/ + + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int PlaneSignBits(vec3_t normal) +{ + int i, signbits; + + signbits = 0; + for (i = 2; i >= 0; i--) + { + signbits = (signbits << 1) + Sign(normal[i]); + } //end for + return signbits; +} //end of the function PlaneSignBits +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int PlaneTypeForNormal(vec3_t normal) +{ + vec_t ax, ay, az; + +// NOTE: should these have an epsilon around 1.0? + if (normal[0] == 1.0 || normal[0] == -1.0) + return PLANE_X; + if (normal[1] == 1.0 || normal[1] == -1.0) + return PLANE_Y; + if (normal[2] == 1.0 || normal[2] == -1.0) + return PLANE_Z; + + ax = fabs(normal[0]); + ay = fabs(normal[1]); + az = fabs(normal[2]); + + if (ax >= ay && ax >= az) + return PLANE_ANYX; + if (ay >= ax && ay >= az) + return PLANE_ANYY; + return PLANE_ANYZ; +} //end of the function PlaneTypeForNormal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +//ME NOTE: changed from 0.00001 +#define NORMAL_EPSILON 0.0001 +//ME NOTE: changed from 0.01 +#define DIST_EPSILON 0.02 +qboolean PlaneEqual(plane_t *p, vec3_t normal, vec_t dist) +{ +#if 1 + if ( + fabs(p->normal[0] - normal[0]) < NORMAL_EPSILON + && fabs(p->normal[1] - normal[1]) < NORMAL_EPSILON + && fabs(p->normal[2] - normal[2]) < NORMAL_EPSILON + && fabs(p->dist - dist) < DIST_EPSILON ) + return true; +#else + if (p->normal[0] == normal[0] + && p->normal[1] == normal[1] + && p->normal[2] == normal[2] + && p->dist == dist) + return true; +#endif + return false; +} //end of the function PlaneEqual +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AddPlaneToHash(plane_t *p) +{ + int hash; + + hash = (int)fabs(p->dist) / 8; + hash &= (PLANE_HASHES-1); + + p->hash_chain = planehash[hash]; + planehash[hash] = p; +} //end of the function AddPlaneToHash +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int CreateNewFloatPlane (vec3_t normal, vec_t dist) +{ + plane_t *p, temp; + + if (VectorLength(normal) < 0.5) + Error ("FloatPlane: bad normal"); + // create a new plane + if (nummapplanes+2 > MAX_MAPFILE_PLANES) + Error ("MAX_MAPFILE_PLANES"); + + p = &mapplanes[nummapplanes]; + VectorCopy (normal, p->normal); + p->dist = dist; + p->type = (p+1)->type = PlaneTypeForNormal (p->normal); + p->signbits = PlaneSignBits(p->normal); + + VectorSubtract (vec3_origin, normal, (p+1)->normal); + (p+1)->dist = -dist; + (p+1)->signbits = PlaneSignBits((p+1)->normal); + + nummapplanes += 2; + + // allways put axial planes facing positive first + if (p->type < 3) + { + if (p->normal[0] < 0 || p->normal[1] < 0 || p->normal[2] < 0) + { + // flip order + temp = *p; + *p = *(p+1); + *(p+1) = temp; + + AddPlaneToHash (p); + AddPlaneToHash (p+1); + return nummapplanes - 1; + } + } + + AddPlaneToHash (p); + AddPlaneToHash (p+1); + return nummapplanes - 2; +} //end of the function CreateNewFloatPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void SnapVector(vec3_t normal) +{ + int i; + + for (i=0 ; i<3 ; i++) + { + if ( fabs(normal[i] - 1) < NORMAL_EPSILON ) + { + VectorClear (normal); + normal[i] = 1; + break; + } + if ( fabs(normal[i] - -1) < NORMAL_EPSILON ) + { + VectorClear (normal); + normal[i] = -1; + break; + } + } +} //end of the function SnapVector +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void SnapPlane(vec3_t normal, vec_t *dist) +{ + SnapVector(normal); + + if (fabs(*dist-Q_rint(*dist)) < DIST_EPSILON) + *dist = Q_rint(*dist); +} //end of the function SnapPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifndef USE_HASHING +int FindFloatPlane(vec3_t normal, vec_t dist) +{ + int i; + plane_t *p; + + SnapPlane(normal, &dist); + for (i = 0, p = mapplanes; i < nummapplanes; i++, p++) + { + if (PlaneEqual (p, normal, dist)) + { + mapplaneusers[i]++; + return i; + } //end if + } //end for + i = CreateNewFloatPlane (normal, dist); + mapplaneusers[i]++; + return i; +} //end of the function FindFloatPlane +#else +int FindFloatPlane (vec3_t normal, vec_t dist) +{ + int i; + plane_t *p; + int hash, h; + + SnapPlane (normal, &dist); + hash = (int)fabs(dist) / 8; + hash &= (PLANE_HASHES-1); + + // search the border bins as well + for (i = -1; i <= 1; i++) + { + h = (hash+i)&(PLANE_HASHES-1); + for (p = planehash[h]; p; p = p->hash_chain) + { + if (PlaneEqual(p, normal, dist)) + { + mapplaneusers[p-mapplanes]++; + return p - mapplanes; + } //end if + } //end for + } //end for + i = CreateNewFloatPlane (normal, dist); + mapplaneusers[i]++; + return i; +} //end of the function FindFloatPlane +#endif +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int PlaneFromPoints (int *p0, int *p1, int *p2) +{ + vec3_t t1, t2, normal; + vec_t dist; + + VectorSubtract (p0, p1, t1); + VectorSubtract (p2, p1, t2); + CrossProduct (t1, t2, normal); + VectorNormalize (normal); + + dist = DotProduct (p0, normal); + + return FindFloatPlane (normal, dist); +} //end of the function PlaneFromPoints +//=========================================================================== +// Adds any additional planes necessary to allow the brush to be expanded +// against axial bounding boxes +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AddBrushBevels (mapbrush_t *b) +{ + int axis, dir; + int i, j, k, l, order; + side_t sidetemp; + brush_texture_t tdtemp; +#ifdef SIN + textureref_t trtemp; +#endif + side_t *s, *s2; + vec3_t normal; + float dist; + winding_t *w, *w2; + vec3_t vec, vec2; + float d; + + // + // add the axial planes + // + order = 0; + for (axis=0 ; axis <3 ; axis++) + { + for (dir=-1 ; dir <= 1 ; dir+=2, order++) + { + // see if the plane is allready present + for (i=0, s=b->original_sides ; inumsides ; i++,s++) + { + if (mapplanes[s->planenum].normal[axis] == dir) + break; + } + + if (i == b->numsides) + { // add a new side + if (nummapbrushsides == MAX_MAP_BRUSHSIDES) + Error ("MAX_MAP_BRUSHSIDES"); + nummapbrushsides++; + b->numsides++; + VectorClear (normal); + normal[axis] = dir; + if (dir == 1) + dist = b->maxs[axis]; + else + dist = -b->mins[axis]; + s->planenum = FindFloatPlane (normal, dist); + s->texinfo = b->original_sides[0].texinfo; +#ifdef SIN + s->lightinfo = b->original_sides[0].lightinfo; +#endif + s->contents = b->original_sides[0].contents; + s->flags |= SFL_BEVEL; + c_boxbevels++; + } + + // if the plane is not in it canonical order, swap it + if (i != order) + { + sidetemp = b->original_sides[order]; + b->original_sides[order] = b->original_sides[i]; + b->original_sides[i] = sidetemp; + + j = b->original_sides - brushsides; + tdtemp = side_brushtextures[j+order]; + side_brushtextures[j+order] = side_brushtextures[j+i]; + side_brushtextures[j+i] = tdtemp; + +#ifdef SIN + trtemp = side_newrefs[j+order]; + side_newrefs[j+order] = side_newrefs[j+i]; + side_newrefs[j+i] = trtemp; +#endif + } + } + } + + // + // add the edge bevels + // + if (b->numsides == 6) + return; // pure axial + + // test the non-axial plane edges + for (i=6 ; inumsides ; i++) + { + s = b->original_sides + i; + w = s->winding; + if (!w) + continue; + for (j=0 ; jnumpoints ; j++) + { + k = (j+1)%w->numpoints; + VectorSubtract (w->p[j], w->p[k], vec); + if (VectorNormalize (vec) < 0.5) + continue; + SnapVector (vec); + for (k=0 ; k<3 ; k++) + if ( vec[k] == -1 || vec[k] == 1) + break; // axial + if (k != 3) + continue; // only test non-axial edges + + // try the six possible slanted axials from this edge + for (axis=0 ; axis <3 ; axis++) + { + for (dir=-1 ; dir <= 1 ; dir+=2) + { + // construct a plane + VectorClear (vec2); + vec2[axis] = dir; + CrossProduct (vec, vec2, normal); + if (VectorNormalize (normal) < 0.5) + continue; + dist = DotProduct (w->p[j], normal); + + // if all the points on all the sides are + // behind this plane, it is a proper edge bevel + for (k=0 ; knumsides ; k++) + { + // if this plane has allready been used, skip it + if (PlaneEqual (&mapplanes[b->original_sides[k].planenum] + , normal, dist) ) + break; + + w2 = b->original_sides[k].winding; + if (!w2) + continue; + for (l=0 ; lnumpoints ; l++) + { + d = DotProduct (w2->p[l], normal) - dist; + if (d > 0.1) + break; // point in front + } + if (l != w2->numpoints) + break; + } + + if (k != b->numsides) + continue; // wasn't part of the outer hull + // add this plane + if (nummapbrushsides == MAX_MAP_BRUSHSIDES) + Error ("MAX_MAP_BRUSHSIDES"); + nummapbrushsides++; + s2 = &b->original_sides[b->numsides]; + s2->planenum = FindFloatPlane (normal, dist); + s2->texinfo = b->original_sides[0].texinfo; +#ifdef SIN + s2->lightinfo = b->original_sides[0].lightinfo; +#endif + s2->contents = b->original_sides[0].contents; + s2->flags |= SFL_BEVEL; + c_edgebevels++; + b->numsides++; + } + } + } + } +} //end of the function AddBrushBevels +//=========================================================================== +// creates windigs for sides and mins / maxs for the brush +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean MakeBrushWindings(mapbrush_t *ob) +{ + int i, j; + winding_t *w; + side_t *side; + plane_t *plane; + + ClearBounds (ob->mins, ob->maxs); + + for (i = 0; i < ob->numsides; i++) + { + plane = &mapplanes[ob->original_sides[i].planenum]; + w = BaseWindingForPlane(plane->normal, plane->dist); + for (j = 0; j numsides && w; j++) + { + if (i == j) continue; + if (ob->original_sides[j].flags & SFL_BEVEL) continue; + plane = &mapplanes[ob->original_sides[j].planenum^1]; + ChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON); + } + + side = &ob->original_sides[i]; + side->winding = w; + if (w) + { + side->flags |= SFL_VISIBLE; + for (j = 0; j < w->numpoints; j++) + AddPointToBounds (w->p[j], ob->mins, ob->maxs); + } + } + + for (i = 0; i < 3; i++) + { + //IDBUG: all the indexes into the mins and maxs were zero (not using i) + if (ob->mins[i] < -MAX_MAP_BOUNDS || ob->maxs[i] > MAX_MAP_BOUNDS) + { + Log_Print("entity %i, brush %i: bounds out of range\n", ob->entitynum, ob->brushnum); + ob->numsides = 0; //remove the brush + break; + } //end if + if (ob->mins[i] > MAX_MAP_BOUNDS || ob->maxs[i] < -MAX_MAP_BOUNDS) + { + Log_Print("entity %i, brush %i: no visible sides on brush\n", ob->entitynum, ob->brushnum); + ob->numsides = 0; //remove the brush + break; + } //end if + } //end for + return true; +} //end of the function MakeBrushWindings +//=========================================================================== +// FIXME: currently doesn't mark all bevels +// NOTE: when one brush bevel is found the remaining sides of the brush +// are bevels as well (when the brush isn't expanded for AAS :)) +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void MarkBrushBevels(mapbrush_t *brush) +{ + int i; + int we; + side_t *s; + + //check all the sides of the brush + for (i = 0; i < brush->numsides; i++) + { + s = brush->original_sides + i; + //if the side has no winding + if (!s->winding) + { + Log_Write("MarkBrushBevels: brush %d no winding", brush->brushnum); + s->flags |= SFL_BEVEL; + } //end if + //if the winding is tiny + else if (WindingIsTiny(s->winding)) + { + s->flags |= SFL_BEVEL; + Log_Write("MarkBrushBevels: brush %d tiny winding", brush->brushnum); + } //end else if + //if the winding has errors + else + { + we = WindingError(s->winding); + if (we == WE_NOTENOUGHPOINTS + || we == WE_SMALLAREA + || we == WE_POINTBOGUSRANGE +// || we == WE_NONCONVEX + ) + { + Log_Write("MarkBrushBevels: brush %d %s", brush->brushnum, WindingErrorString()); + s->flags |= SFL_BEVEL; + } //end else if + } //end else + if (s->flags & SFL_BEVEL) + { + s->flags &= ~SFL_VISIBLE; + //if the side has a valid plane + if (s->planenum > 0 && s->planenum < nummapplanes) + { + //if it is an axial plane + if (mapplanes[s->planenum].type < 3) c_boxbevels++; + else c_edgebevels++; + } //end if + } //end if + } //end for +} //end of the function MarkBrushBevels +//=========================================================================== +// returns true if the map brush already exists +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int BrushExists(mapbrush_t *brush) +{ + int i, s1, s2; + side_t *side1, *side2; + mapbrush_t *brush1, *brush2; + + for (i = 0; i < nummapbrushes; i++) + { + brush1 = brush; + brush2 = &mapbrushes[i]; + //compare the brushes + if (brush1->entitynum != brush2->entitynum) continue; + //if (brush1->contents != brush2->contents) continue; + if (brush1->numsides != brush2->numsides) continue; + for (s1 = 0; s1 < brush1->numsides; s1++) + { + side1 = brush1->original_sides + s1; + // + for (s2 = 0; s2 < brush2->numsides; s2++) + { + side2 = brush2->original_sides + s2; + // + if ((side1->planenum & ~1) == (side2->planenum & ~1) +// && side1->texinfo == side2->texinfo +// && side1->contents == side2->contents +// && side1->surf == side2->surf + ) break; + } //end if + if (s2 >= brush2->numsides) break; + } //end for + if (s1 >= brush1->numsides) return true; + } //end for + return false; +} //end of the function BrushExists +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin) +{ + int sn, rotate, shift[2], sv, tv, planenum, p1, i, j; + float scale[2], originshift[2], ang1, ang2, newdist; + vec3_t vecs[2], axis[2]; + map_texinfo_t *ti; + winding_t *w; + side_t *s; + plane_t *plane; + + if (noliquids) + { + if (brush->contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA)) + { + return true; + } //end if + } //end if + //if the brush has no contents + if (!brush->contents) return true; + //print the leading { + if (fprintf(fp, " { //brush %d\n", brush->brushnum) < 0) return false; + //write brush sides + for (sn = 0; sn < brush->numsides; sn++) + { + s = brush->original_sides + sn; + //don't write out bevels + if (!(s->flags & SFL_BEVEL)) + { + //if the entity has an origin set + if (origin[0] || origin[1] || origin[2]) + { + newdist = mapplanes[s->planenum].dist + + DotProduct(mapplanes[s->planenum].normal, origin); + planenum = FindFloatPlane(mapplanes[s->planenum].normal, newdist); + } //end if + else + { + planenum = s->planenum; + } //end else + //always take the first plane, then flip the points if necesary + plane = &mapplanes[planenum & ~1]; + w = BaseWindingForPlane(plane->normal, plane->dist); + // + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + if (fabs(w->p[i][j]) < 0.2) w->p[i][j] = 0; + else if (fabs((int)w->p[i][j] - w->p[i][j]) < 0.3) w->p[i][j] = (int) w->p[i][j]; + //w->p[i][j] = (int) (w->p[i][j] + 0.2); + } //end for + } //end for + //three non-colinear points to define the plane + if (planenum & 1) p1 = 1; + else p1 = 0; + if (fprintf(fp," ( %5i %5i %5i ) ", (int)w->p[p1][0], (int)w->p[p1][1], (int)w->p[p1][2]) < 0) return false; + if (fprintf(fp,"( %5i %5i %5i ) ", (int)w->p[!p1][0], (int)w->p[!p1][1], (int)w->p[!p1][2]) < 0) return false; + if (fprintf(fp,"( %5i %5i %5i ) ", (int)w->p[2][0], (int)w->p[2][1], (int)w->p[2][2]) < 0) return false; + //free the winding + FreeWinding(w); + // + if (s->texinfo == TEXINFO_NODE) + { + if (brush->contents & CONTENTS_PLAYERCLIP) + { + //player clip + if (loadedmaptype == MAPTYPE_SIN) + { + if (fprintf(fp, "generic/misc/clip 0 0 0 1 1") < 0) return false; + } //end if + else if (loadedmaptype == MAPTYPE_QUAKE2) + { //FIXME: don't always use e1u1 + if (fprintf(fp, "e1u1/clip 0 0 0 1 1") < 0) return false; + } //end else + else if (loadedmaptype == MAPTYPE_QUAKE3) + { + if (fprintf(fp, "e1u1/clip 0 0 0 1 1") < 0) return false; + } //end else if + else + { + if (fprintf(fp, "clip 0 0 0 1 1") < 0) return false; + } //end else + } //end if + else if (brush->contents == CONTENTS_MONSTERCLIP) + { + //monster clip + if (loadedmaptype == MAPTYPE_SIN) + { + if (fprintf(fp, "generic/misc/monster 0 0 0 1 1") < 0) return false; + } //end if + else if (loadedmaptype == MAPTYPE_QUAKE2) + { + if (fprintf(fp, "e1u1/clip_mon 0 0 0 1 1") < 0) return false; + } //end else + else + { + if (fprintf(fp, "clip 0 0 0 1 1") < 0) return false; + } //end else + } //end else + else + { + if (fprintf(fp, "clip 0 0 0 1 1") < 0) return false; + Log_Write("brush->contents = %d\n", brush->contents); + } //end else + } //end if + else if (loadedmaptype == MAPTYPE_SIN && s->texinfo == 0) + { + if (brush->contents & CONTENTS_DUMMYFENCE) + { + if (fprintf(fp, "generic/misc/fence 0 0 0 1 1") < 0) return false; + } //end if +#ifdef CONTENTS_MIST + else if (brush->contents & CONTENTS_MIST) + { + if (fprintf(fp, "generic/misc/volumetric_base 0 0 0 1 1") < 0) return false; + } //end if +#endif // CONTENTS_MIST + else //unknown so far + { + if (fprintf(fp, "generic/misc/red 0 0 0 1 1") < 0) return false; + } //end else + } //end if + else if (loadedmaptype == MAPTYPE_QUAKE3) + { + //always use the same texture + if (fprintf(fp, "e2u3/floor1_2 0 0 0 1 1 1 0 0") < 0) return false; + } //end else if + else + { + //* + ti = &map_texinfo[s->texinfo]; + //the scaling of the texture + scale[0] = 1 / VectorNormalize2(ti->vecs[0], vecs[0]); + scale[1] = 1 / VectorNormalize2(ti->vecs[1], vecs[1]); + // + TextureAxisFromPlane(plane, axis[0], axis[1]); + //calculate texture shift done by entity origin + originshift[0] = DotProduct(origin, axis[0]); + originshift[1] = DotProduct(origin, axis[1]); + //the texture shift without origin shift + shift[0] = ti->vecs[0][3] - originshift[0]; + shift[1] = ti->vecs[1][3] - originshift[1]; + // + if (axis[0][0]) sv = 0; + else if (axis[0][1]) sv = 1; + else sv = 2; + if (axis[1][0]) tv = 0; + else if (axis[1][1]) tv = 1; + else tv = 2; + //calculate rotation of texture + if (vecs[0][tv] == 0) ang1 = vecs[0][sv] > 0 ? 90.0 : -90.0; + else ang1 = atan2(vecs[0][sv], vecs[0][tv]) * 180 / Q_PI; + if (ang1 < 0) ang1 += 360; + if (ang1 >= 360) ang1 -= 360; + if (axis[0][tv] == 0) ang2 = axis[0][sv] > 0 ? 90.0 : -90.0; + else ang2 = atan2(axis[0][sv], axis[0][tv]) * 180 / Q_PI; + if (ang2 < 0) ang2 += 360; + if (ang2 >= 360) ang2 -= 360; + rotate = ang2 - ang1; + if (rotate < 0) rotate += 360; + if (rotate >= 360) rotate -= 360; + //write the texture info + if (fprintf(fp, "%s %d %d %d", ti->texture, shift[0], shift[1], rotate) < 0) return false; + if (fabs(scale[0] - ((int) scale[0])) < 0.001) + { + if (fprintf(fp, " %d", (int) scale[0]) < 0) return false; + } //end if + else + { + if (fprintf(fp, " %4f", scale[0]) < 0) return false; + } //end if + if (fabs(scale[1] - ((int) scale[1])) < 0.001) + { + if (fprintf(fp, " %d", (int) scale[1]) < 0) return false; + } //end if + else + { + if (fprintf(fp, " %4f", scale[1]) < 0) return false; + } //end else + //write the extra brush side info + if (loadedmaptype == MAPTYPE_QUAKE2) + { + if (fprintf(fp, " %ld %ld %ld", s->contents, ti->flags, ti->value) < 0) return false; + } //end if + //*/ + } //end else + if (fprintf(fp, "\n") < 0) return false; + } //end if + } //end if + if (fprintf(fp, " }\n") < 0) return false; + c_writtenbrushes++; + return true; +} //end of the function WriteMapBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean WriteOriginBrush(FILE *fp, vec3_t origin) +{ + vec3_t normal; + float dist; + int i, s; + winding_t *w; + + if (fprintf(fp, " {\n") < 0) return false; + // + for (i = 0; i < 3; i++) + { + for (s = -1; s <= 1; s += 2) + { + // + VectorClear(normal); + normal[i] = s; + dist = origin[i] * s + 16; + // + w = BaseWindingForPlane(normal, dist); + //three non-colinear points to define the plane + if (fprintf(fp," ( %5i %5i %5i ) ", (int)w->p[0][0], (int)w->p[0][1], (int)w->p[0][2]) < 0) return false; + if (fprintf(fp,"( %5i %5i %5i ) ", (int)w->p[1][0], (int)w->p[1][1], (int)w->p[1][2]) < 0) return false; + if (fprintf(fp,"( %5i %5i %5i ) ", (int)w->p[2][0], (int)w->p[2][1], (int)w->p[2][2]) < 0) return false; + //free the winding + FreeWinding(w); + //write origin texture: + // CONTENTS_ORIGIN = 16777216 + // SURF_NODRAW = 128 + if (loadedmaptype == MAPTYPE_SIN) + { + if (fprintf(fp, "generic/misc/origin 0 0 0 1 1") < 0) return false; + } //end if + else if (loadedmaptype == MAPTYPE_HALFLIFE) + { + if (fprintf(fp, "origin 0 0 0 1 1") < 0) return false; + } //end if + else + { + if (fprintf(fp, "e1u1/origin 0 0 0 1 1") < 0) return false; + } //end else + //Quake2 extra brush side info + if (loadedmaptype == MAPTYPE_QUAKE2) + { + //if (fprintf(fp, " 16777216 128 0") < 0) return false; + } //end if + if (fprintf(fp, "\n") < 0) return false; + } //end for + } //end for + if (fprintf(fp, " }\n") < 0) return false; + c_writtenbrushes++; + return true; +} //end of the function WriteOriginBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +mapbrush_t *GetAreaPortalBrush(entity_t *mapent) +{ + int portalnum, bn; + mapbrush_t *brush; + + //the area portal number + portalnum = mapent->areaportalnum; + //find the area portal brush in the world brushes + for (bn = 0; bn < nummapbrushes && portalnum; bn++) + { + brush = &mapbrushes[bn]; + //must be in world entity + if (brush->entitynum == 0) + { + if (brush->contents & CONTENTS_AREAPORTAL) + { + portalnum--; + } //end if + } //end if + } //end for + if (bn < nummapbrushes) + { + return brush; + } //end if + else + { + Log_Print("area portal %d brush not found\n", mapent->areaportalnum); + return NULL; + } //end else +} //end of the function GetAreaPortalBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean WriteMapFileSafe(FILE *fp) +{ + char key[1024], value[1024]; + int i, bn, entitybrushes; + epair_t *ep; + mapbrush_t *brush; + entity_t *mapent; + //vec3_t vec_origin = {0, 0, 0}; + + // + if (fprintf(fp,"//=====================================================\n" + "//\n" + "// map file created with BSPC "BSPC_VERSION"\n" + "//\n" + "// BSPC is designed to decompile material in which you own the copyright\n" + "// or have obtained permission to decompile from the copyright owner. Unless\n" + "// you own the copyright or have permission to decompile from the copyright\n" + "// owner, you may be violating copyright law and be subject to payment of\n" + "// damages and other remedies. If you are uncertain about your rights, contact\n" + "// your legal advisor.\n" + "//\n") < 0) return false; + if (loadedmaptype == MAPTYPE_SIN) + { + if (fprintf(fp, + "// generic/misc/red is used for unknown textures\n") < 0) return false; + } //end if + if (fprintf(fp,"//\n" + "//=====================================================\n") < 0) return false; + //write out all the entities + for (i = 0; i < num_entities; i++) + { + mapent = &entities[i]; + if (!mapent->epairs) + { + continue; + } //end if + if (fprintf(fp, "{\n") < 0) return false; + // + if (loadedmaptype == MAPTYPE_QUAKE3) + { + if (!stricmp(ValueForKey(mapent, "classname"), "light")) + { + SetKeyValue(mapent, "light", "10000"); + } //end if + } //end if + //write epairs + for (ep = mapent->epairs; ep; ep = ep->next) + { + strcpy(key, ep->key); + StripTrailing (key); + strcpy(value, ep->value); + StripTrailing(value); + // + if (loadedmaptype == MAPTYPE_QUAKE2 || + loadedmaptype == MAPTYPE_SIN) + { + //don't write an origin for BSP models + if (mapent->modelnum >= 0 && !strcmp(key, "origin")) continue; + } //end if + //don't write BSP model numbers + if (mapent->modelnum >= 0 && !strcmp(key, "model") && value[0] == '*') continue; + // + if (fprintf(fp, " \"%s\" \"%s\"\n", key, value) < 0) return false; + } //end for + // + if (ValueForKey(mapent, "origin")) GetVectorForKey(mapent, "origin", mapent->origin); + else mapent->origin[0] = mapent->origin[1] = mapent->origin[2] = 0; + //if this is an area portal entity + if (!strcmp("func_areaportal", ValueForKey(mapent, "classname"))) + { + brush = GetAreaPortalBrush(mapent); + if (!brush) return false; + if (!WriteMapBrush(fp, brush, mapent->origin)) return false; + } //end if + else + { + entitybrushes = false; + //write brushes + for (bn = 0; bn < nummapbrushes; bn++) + { + brush = &mapbrushes[bn]; + //if the brush is part of this entity + if (brush->entitynum == i) + { + //don't write out area portal brushes in the world + if (!((brush->contents & CONTENTS_AREAPORTAL) && brush->entitynum == 0)) + { + /* + if (!strcmp("func_door_rotating", ValueForKey(mapent, "classname"))) + { + AAS_PositionFuncRotatingBrush(mapent, brush); + if (!WriteMapBrush(fp, brush, vec_origin)) return false; + } //end if + else //*/ + { + if (!WriteMapBrush(fp, brush, mapent->origin)) return false; + } //end else + entitybrushes = true; + } //end if + } //end if + } //end for + //if the entity had brushes + if (entitybrushes) + { + //if the entity has an origin set + if (mapent->origin[0] || mapent->origin[1] || mapent->origin[2]) + { + if (!WriteOriginBrush(fp, mapent->origin)) return false; + } //end if + } //end if + } //end else + if (fprintf(fp, "}\n") < 0) return false; + } //end for + if (fprintf(fp, "//total of %d brushes\n", c_writtenbrushes) < 0) return false; + return true; +} //end of the function WriteMapFileSafe +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void WriteMapFile(char *filename) +{ + FILE *fp; + double start_time; + + c_writtenbrushes = 0; + //the time started + start_time = I_FloatTime(); + // + Log_Print("writing %s\n", filename); + fp = fopen(filename, "wb"); + if (!fp) + { + Log_Print("can't open %s\n", filename); + return; + } //end if + if (!WriteMapFileSafe(fp)) + { + fclose(fp); + Log_Print("error writing map file %s\n", filename); + return; + } //end if + fclose(fp); + //display creation time + Log_Print("written %d brushes\n", c_writtenbrushes); + Log_Print("map file written in %5.0f seconds\n", I_FloatTime() - start_time); +} //end of the function WriteMapFile +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintMapInfo(void) +{ + Log_Print("\n"); + Log_Print("%6i brushes\n", nummapbrushes); + Log_Print("%6i brush sides\n", nummapbrushsides); +// Log_Print("%6i clipbrushes\n", c_clipbrushes); +// Log_Print("%6i total sides\n", nummapbrushsides); +// Log_Print("%6i boxbevels\n", c_boxbevels); +// Log_Print("%6i edgebevels\n", c_edgebevels); +// Log_Print("%6i entities\n", num_entities); +// Log_Print("%6i planes\n", nummapplanes); +// Log_Print("%6i areaportals\n", c_areaportals); +// Log_Print("%6i squatt brushes\n", c_squattbrushes); +// Log_Print("size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\n", map_mins[0],map_mins[1],map_mins[2], +// map_maxs[0],map_maxs[1],map_maxs[2]); +} //end of the function PrintMapInfo +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void ResetMapLoading(void) +{ + int i; + epair_t *ep, *nextep; + + Q2_ResetMapLoading(); + Sin_ResetMapLoading(); + + //free all map brush side windings + for (i = 0; i < nummapbrushsides; i++) + { + if (brushsides[i].winding) + { + FreeWinding(brushsides[i].winding); + } //end for + } //end for + + //reset regular stuff + nummapbrushes = 0; + memset(mapbrushes, 0, MAX_MAPFILE_BRUSHES * sizeof(mapbrush_t)); + // + nummapbrushsides = 0; + memset(brushsides, 0, MAX_MAPFILE_BRUSHSIDES * sizeof(side_t)); + memset(side_brushtextures, 0, MAX_MAPFILE_BRUSHSIDES * sizeof(brush_texture_t)); + // + nummapplanes = 0; + memset(mapplanes, 0, MAX_MAPFILE_PLANES * sizeof(plane_t)); + // + memset(planehash, 0, PLANE_HASHES * sizeof(plane_t *)); + // + memset(map_texinfo, 0, MAX_MAPFILE_TEXINFO * sizeof(map_texinfo_t)); + map_numtexinfo = 0; + // + VectorClear(map_mins); + VectorClear(map_maxs); + // + c_boxbevels = 0; + c_edgebevels = 0; + c_areaportals = 0; + c_clipbrushes = 0; + c_writtenbrushes = 0; + //clear the entities + for (i = 0; i < num_entities; i++) + { + for (ep = entities[i].epairs; ep; ep = nextep) + { + nextep = ep->next; + FreeMemory(ep->key); + FreeMemory(ep->value); + FreeMemory(ep); + } //end for + } //end for + num_entities = 0; + memset(entities, 0, MAX_MAP_ENTITIES * sizeof(entity_t)); +} //end of the function ResetMapLoading +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifndef Q1_BSPVERSION +#define Q1_BSPVERSION 29 +#endif +#ifndef HL_BSPVERSION +#define HL_BSPVERSION 30 +#endif + +#define Q2_BSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I') //IBSP +#define Q2_BSPVERSION 38 + +#define SINGAME_BSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'R') //RBSP +#define SINGAME_BSPVERSION 1 + +#define SIN_BSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I') //IBSP +#define SIN_BSPVERSION 41 + +typedef struct +{ + int ident; + int version; +} idheader_t; + +int LoadMapFromBSP(struct quakefile_s *qf) +{ + idheader_t idheader; + + if (ReadQuakeFile(qf, &idheader, 0, sizeof(idheader_t)) != sizeof(idheader_t)) + { + return false; + } //end if + + idheader.ident = LittleLong(idheader.ident); + idheader.version = LittleLong(idheader.version); + // MoHAA BSP file + if (idheader.ident == BSP_IDENT && idheader.version == BSP_VERSION) + { + ResetMapLoading(); + Q3_LoadMapFromBSP(qf); + Q3_FreeMaxBSP(); + } //end if + //Sin BSP file + else if ((idheader.ident == SIN_BSPHEADER && idheader.version == SIN_BSPVERSION) || + //the dorks gave the same format another ident and verions + (idheader.ident == SINGAME_BSPHEADER && idheader.version == SINGAME_BSPVERSION)) + { + ResetMapLoading(); + Sin_AllocMaxBSP(); + Sin_LoadMapFromBSP(qf->filename, qf->offset, qf->length); + Sin_FreeMaxBSP(); + } //end if + //the Quake1 bsp files don't have a ident only a version + else if (idheader.ident == Q1_BSPVERSION) + { + ResetMapLoading(); + Q1_AllocMaxBSP(); + Q1_LoadMapFromBSP(qf->filename, qf->offset, qf->length); + Q1_FreeMaxBSP(); + } //end if + //Half-Life also only uses a version number + else if (idheader.ident == HL_BSPVERSION) + { + ResetMapLoading(); + HL_AllocMaxBSP(); + HL_LoadMapFromBSP(qf->filename, qf->offset, qf->length); + HL_FreeMaxBSP(); + } //end if + else + { + Error("unknown BSP format %c%c%c%c, version %d\n", + (idheader.ident & 0xFF), + ((idheader.ident >> 8) & 0xFF), + ((idheader.ident >> 16) & 0xFF), + ((idheader.ident >> 24) & 0xFF), idheader.version); + return false; + } //end if + // + return true; +} //end of the function LoadMapFromBSP diff --git a/code/bspc/map_hl.c b/code/bspc/map_hl.c new file mode 100644 index 00000000..88e4fa79 --- /dev/null +++ b/code/bspc/map_hl.c @@ -0,0 +1,1114 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "l_bsp_hl.h" +#include "aas_map.h" //AAS_CreateMapBrushes + +int hl_numbrushes; +int hl_numclipbrushes; + +//#define HL_PRINT +#define HLCONTENTS + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int HL_TextureContents(char *name) +{ + if (!Q_strncasecmp (name, "sky",3)) + return CONTENTS_SOLID; + + if (!Q_strncasecmp(name+1,"!lava",5)) + return CONTENTS_LAVA; + + if (!Q_strncasecmp(name+1,"!slime",6)) + return CONTENTS_SLIME; + + /* + if (!Q_strncasecmp (name, "!cur_90",7)) + return CONTENTS_CURRENT_90; + if (!Q_strncasecmp (name, "!cur_0",6)) + return CONTENTS_CURRENT_0; + if (!Q_strncasecmp (name, "!cur_270",8)) + return CONTENTS_CURRENT_270; + if (!Q_strncasecmp (name, "!cur_180",8)) + return CONTENTS_CURRENT_180; + if (!Q_strncasecmp (name, "!cur_up",7)) + return CONTENTS_CURRENT_UP; + if (!Q_strncasecmp (name, "!cur_dwn",8)) + return CONTENTS_CURRENT_DOWN; + //*/ + if (name[0] == '!') + return CONTENTS_WATER; + /* + if (!Q_strncasecmp (name, "origin",6)) + return CONTENTS_ORIGIN; + if (!Q_strncasecmp (name, "clip",4)) + return CONTENTS_CLIP; + if( !Q_strncasecmp( name, "translucent", 11 ) ) + return CONTENTS_TRANSLUCENT; + if( name[0] == '@' ) + return CONTENTS_TRANSLUCENT; + //*/ + + return CONTENTS_SOLID; +} //end of the function HL_TextureContents +//=========================================================================== +// Generates two new brushes, leaving the original +// unchanged +// +// modified for Half-Life because there are quite a lot of tiny node leaves +// in the Half-Life bsps +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void HL_SplitBrush(bspbrush_t *brush, int planenum, int nodenum, + bspbrush_t **front, bspbrush_t **back) +{ + bspbrush_t *b[2]; + int i, j; + winding_t *w, *cw[2], *midwinding; + plane_t *plane, *plane2; + side_t *s, *cs; + float d, d_front, d_back; + + *front = *back = NULL; + plane = &mapplanes[planenum]; + + // check all points + d_front = d_back = 0; + for (i=0 ; inumsides ; i++) + { + w = brush->sides[i].winding; + if (!w) + continue; + for (j=0 ; jnumpoints ; j++) + { + d = DotProduct (w->p[j], plane->normal) - plane->dist; + if (d > 0 && d > d_front) + d_front = d; + if (d < 0 && d < d_back) + d_back = d; + } //end for + } //end for + + if (d_front < 0.1) // PLANESIDE_EPSILON) + { // only on back + *back = CopyBrush (brush); + Log_Print("HL_SplitBrush: only on back\n"); + return; + } //end if + if (d_back > -0.1) // PLANESIDE_EPSILON) + { // only on front + *front = CopyBrush (brush); + Log_Print("HL_SplitBrush: only on front\n"); + return; + } //end if + + // create a new winding from the split plane + + w = BaseWindingForPlane (plane->normal, plane->dist); + for (i = 0; i < brush->numsides && w; i++) + { + plane2 = &mapplanes[brush->sides[i].planenum ^ 1]; + ChopWindingInPlace(&w, plane2->normal, plane2->dist, 0); // PLANESIDE_EPSILON); + } //end for + + if (!w || WindingIsTiny(w)) + { // the brush isn't really split + int side; + + Log_Print("HL_SplitBrush: no split winding\n"); + side = BrushMostlyOnSide (brush, plane); + if (side == PSIDE_FRONT) + *front = CopyBrush (brush); + if (side == PSIDE_BACK) + *back = CopyBrush (brush); + return; + } + + if (WindingIsHuge(w)) + { + Log_Print("HL_SplitBrush: WARNING huge split winding\n"); + } //end of + + midwinding = w; + + // split it for real + + for (i = 0; i < 2; i++) + { + b[i] = AllocBrush (brush->numsides+1); + b[i]->original = brush->original; + } //end for + + // split all the current windings + + for (i=0 ; inumsides ; i++) + { + s = &brush->sides[i]; + w = s->winding; + if (!w) + continue; + ClipWindingEpsilon (w, plane->normal, plane->dist, + 0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1]); + for (j=0 ; j<2 ; j++) + { + if (!cw[j]) + continue; +#if 0 + if (WindingIsTiny (cw[j])) + { + FreeWinding (cw[j]); + continue; + } +#endif + cs = &b[j]->sides[b[j]->numsides]; + b[j]->numsides++; + *cs = *s; +// cs->planenum = s->planenum; +// cs->texinfo = s->texinfo; +// cs->visible = s->visible; +// cs->original = s->original; + cs->winding = cw[j]; + cs->flags &= ~SFL_TESTED; + } //end for + } //end for + + + // see if we have valid polygons on both sides + + for (i=0 ; i<2 ; i++) + { + BoundBrush (b[i]); + for (j=0 ; j<3 ; j++) + { + if (b[i]->mins[j] < -4096 || b[i]->maxs[j] > 4096) + { + Log_Print("HL_SplitBrush: bogus brush after clip\n"); + break; + } //end if + } //end for + + if (b[i]->numsides < 3 || j < 3) + { + FreeBrush (b[i]); + b[i] = NULL; + Log_Print("HL_SplitBrush: numsides < 3\n"); + } //end if + } //end for + + if ( !(b[0] && b[1]) ) + { + if (!b[0] && !b[1]) + Log_Print("HL_SplitBrush: split removed brush\n"); + else + Log_Print("HL_SplitBrush: split not on both sides\n"); + if (b[0]) + { + FreeBrush (b[0]); + *front = CopyBrush (brush); + } //end if + if (b[1]) + { + FreeBrush (b[1]); + *back = CopyBrush (brush); + } //end if + return; + } //end if + + // add the midwinding to both sides + for (i = 0; i < 2; i++) + { + cs = &b[i]->sides[b[i]->numsides]; + b[i]->numsides++; + + cs->planenum = planenum^i^1; + cs->texinfo = 0; + //store the node number in the surf to find the texinfo later on + cs->surf = nodenum; + // + cs->flags &= ~SFL_VISIBLE; + cs->flags &= ~SFL_TESTED; + if (i==0) + cs->winding = CopyWinding (midwinding); + else + cs->winding = midwinding; + } //end for + + +{ + vec_t v1; + int i; + + for (i=0 ; i<2 ; i++) + { + v1 = BrushVolume (b[i]); + if (v1 < 1) + { + FreeBrush (b[i]); + b[i] = NULL; + Log_Print("HL_SplitBrush: tiny volume after clip\n"); + } //end if + } //end for +} //*/ + + *front = b[0]; + *back = b[1]; +} //end of the function HL_SplitBrush +//=========================================================================== +// returns true if the tree starting at nodenum has only solid leaves +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int HL_SolidTree_r(int nodenum) +{ + if (nodenum < 0) + { + switch(hl_dleafs[(-nodenum) - 1].contents) + { + case HL_CONTENTS_EMPTY: + { + return false; + } //end case + case HL_CONTENTS_SOLID: +#ifdef HLCONTENTS + case HL_CONTENTS_CLIP: +#endif //HLCONTENTS + case HL_CONTENTS_SKY: +#ifdef HLCONTENTS + case HL_CONTENTS_TRANSLUCENT: +#endif //HLCONTENTS + { + return true; + } //end case + case HL_CONTENTS_WATER: + case HL_CONTENTS_SLIME: + case HL_CONTENTS_LAVA: +#ifdef HLCONTENTS + //these contents should not be found in the BSP + case HL_CONTENTS_ORIGIN: + case HL_CONTENTS_CURRENT_0: + case HL_CONTENTS_CURRENT_90: + case HL_CONTENTS_CURRENT_180: + case HL_CONTENTS_CURRENT_270: + case HL_CONTENTS_CURRENT_UP: + case HL_CONTENTS_CURRENT_DOWN: +#endif //HLCONTENTS + default: + { + return false; + } //end default + } //end switch + return false; + } //end if + if (!HL_SolidTree_r(hl_dnodes[nodenum].children[0])) return false; + if (!HL_SolidTree_r(hl_dnodes[nodenum].children[1])) return false; + return true; +} //end of the function HL_SolidTree_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *HL_CreateBrushes_r(bspbrush_t *brush, int nodenum) +{ + int planenum; + bspbrush_t *front, *back; + hl_dleaf_t *leaf; + + //if it is a leaf + if (nodenum < 0) + { + leaf = &hl_dleafs[(-nodenum) - 1]; + if (leaf->contents != HL_CONTENTS_EMPTY) + { +#ifdef HL_PRINT + qprintf("\r%5i", ++hl_numbrushes); +#endif //HL_PRINT + } //end if + switch(leaf->contents) + { + case HL_CONTENTS_EMPTY: + { + FreeBrush(brush); + return NULL; + } //end case + case HL_CONTENTS_SOLID: +#ifdef HLCONTENTS + case HL_CONTENTS_CLIP: +#endif //HLCONTENTS + case HL_CONTENTS_SKY: +#ifdef HLCONTENTS + case HL_CONTENTS_TRANSLUCENT: +#endif //HLCONTENTS + { + brush->side = CONTENTS_SOLID; + return brush; + } //end case + case HL_CONTENTS_WATER: + { + brush->side = CONTENTS_WATER; + return brush; + } //end case + case HL_CONTENTS_SLIME: + { + brush->side = CONTENTS_SLIME; + return brush; + } //end case + case HL_CONTENTS_LAVA: + { + brush->side = CONTENTS_LAVA; + return brush; + } //end case +#ifdef HLCONTENTS + //these contents should not be found in the BSP + case HL_CONTENTS_ORIGIN: + case HL_CONTENTS_CURRENT_0: + case HL_CONTENTS_CURRENT_90: + case HL_CONTENTS_CURRENT_180: + case HL_CONTENTS_CURRENT_270: + case HL_CONTENTS_CURRENT_UP: + case HL_CONTENTS_CURRENT_DOWN: + { + Error("HL_CreateBrushes_r: found contents %d in Half-Life BSP", leaf->contents); + return NULL; + } //end case +#endif //HLCONTENTS + default: + { + Error("HL_CreateBrushes_r: unknown contents %d in Half-Life BSP", leaf->contents); + return NULL; + } //end default + } //end switch + return NULL; + } //end if + //if the rest of the tree is solid + /*if (HL_SolidTree_r(nodenum)) + { + brush->side = CONTENTS_SOLID; + return brush; + } //end if*/ + // + planenum = hl_dnodes[nodenum].planenum; + planenum = FindFloatPlane(hl_dplanes[planenum].normal, hl_dplanes[planenum].dist); + //split the brush with the node plane + HL_SplitBrush(brush, planenum, nodenum, &front, &back); + //free the original brush + FreeBrush(brush); + //every node must split the brush in two + if (!front || !back) + { + Log_Print("HL_CreateBrushes_r: WARNING node not splitting brush\n"); + //return NULL; + } //end if + //create brushes recursively + if (front) front = HL_CreateBrushes_r(front, hl_dnodes[nodenum].children[0]); + if (back) back = HL_CreateBrushes_r(back, hl_dnodes[nodenum].children[1]); + //link the brushes if possible and return them + if (front) + { + for (brush = front; brush->next; brush = brush->next); + brush->next = back; + return front; + } //end if + else + { + return back; + } //end else +} //end of the function HL_CreateBrushes_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *HL_CreateBrushesFromBSP(int modelnum) +{ + bspbrush_t *brushlist; + bspbrush_t *brush; + hl_dnode_t *headnode; + vec3_t mins, maxs; + int i; + + // + headnode = &hl_dnodes[hl_dmodels[modelnum].headnode[0]]; + //get the mins and maxs of the world + VectorCopy(headnode->mins, mins); + VectorCopy(headnode->maxs, maxs); + //enlarge these mins and maxs + for (i = 0; i < 3; i++) + { + mins[i] -= 8; + maxs[i] += 8; + } //end for + //NOTE: have to add the BSP tree mins and maxs to the MAP mins and maxs + AddPointToBounds(mins, map_mins, map_maxs); + AddPointToBounds(maxs, map_mins, map_maxs); + // + if (!modelnum) + { + Log_Print("brush size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\n", + map_mins[0], map_mins[1], map_mins[2], + map_maxs[0], map_maxs[1], map_maxs[2]); + } //end if + //create one huge brush containing the whole world + brush = BrushFromBounds(mins, maxs); + VectorCopy(mins, brush->mins); + VectorCopy(maxs, brush->maxs); + // +#ifdef HL_PRINT + qprintf("creating Half-Life brushes\n"); + qprintf("%5d brushes", hl_numbrushes = 0); +#endif //HL_PRINT + //create the brushes + brushlist = HL_CreateBrushes_r(brush, hl_dmodels[modelnum].headnode[0]); + // +#ifdef HL_PRINT + qprintf("\n"); +#endif //HL_PRINT + //now we've got a list with brushes! + return brushlist; +} //end of the function HL_CreateBrushesFromBSP +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *HL_MergeBrushes(bspbrush_t *brushlist, int modelnum) +{ + int nummerges, merged; + bspbrush_t *b1, *b2, *tail, *newbrush, *newbrushlist; + bspbrush_t *lastb2; + + if (!brushlist) return NULL; + + if (!modelnum) qprintf("%5d brushes merged", nummerges = 0); + do + { + for (tail = brushlist; tail; tail = tail->next) + { + if (!tail->next) break; + } //end for + merged = 0; + newbrushlist = NULL; + for (b1 = brushlist; b1; b1 = brushlist) + { + lastb2 = b1; + for (b2 = b1->next; b2; b2 = b2->next) + { + //can't merge brushes with different contents + if (b1->side != b2->side) newbrush = NULL; + else newbrush = TryMergeBrushes(b1, b2); + //if a merged brush is created + if (newbrush) + { + //copy the brush contents + newbrush->side = b1->side; + //add the new brush to the end of the list + tail->next = newbrush; + //remove the second brush from the list + lastb2->next = b2->next; + //remove the first brush from the list + brushlist = brushlist->next; + //free the merged brushes + FreeBrush(b1); + FreeBrush(b2); + //get a new tail brush + for (tail = brushlist; tail; tail = tail->next) + { + if (!tail->next) break; + } //end for + merged++; + if (!modelnum) qprintf("\r%5d", nummerges++); + break; + } //end if + lastb2 = b2; + } //end for + //if b1 can't be merged with any of the other brushes + if (!b2) + { + brushlist = brushlist->next; + //keep b1 + b1->next = newbrushlist; + newbrushlist = b1; + } //end else + } //end for + brushlist = newbrushlist; + } while(merged); + if (!modelnum) qprintf("\n"); + return newbrushlist; +} //end of the function HL_MergeBrushes +//=========================================================================== +// returns the amount the face and the winding have overlap +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float HL_FaceOnWinding(hl_dface_t *face, winding_t *winding) +{ + int i, edgenum, side; + float dist, area; + hl_dplane_t plane; + vec_t *v1, *v2; + vec3_t normal, edgevec; + winding_t *w; + + // + w = CopyWinding(winding); + memcpy(&plane, &hl_dplanes[face->planenum], sizeof(hl_dplane_t)); + //check on which side of the plane the face is + if (face->side) + { + VectorNegate(plane.normal, plane.normal); + plane.dist = -plane.dist; + } //end if + for (i = 0; i < face->numedges && w; i++) + { + //get the first and second vertex of the edge + edgenum = hl_dsurfedges[face->firstedge + i]; + side = edgenum > 0; + //if the face plane is flipped + v1 = hl_dvertexes[hl_dedges[abs(edgenum)].v[side]].point; + v2 = hl_dvertexes[hl_dedges[abs(edgenum)].v[!side]].point; + //create a plane through the edge vector, orthogonal to the face plane + //and with the normal vector pointing out of the face + VectorSubtract(v1, v2, edgevec); + CrossProduct(edgevec, plane.normal, normal); + VectorNormalize(normal); + dist = DotProduct(normal, v1); + // + ChopWindingInPlace(&w, normal, dist, 0.9); //CLIP_EPSILON + } //end for + if (w) + { + area = WindingArea(w); + FreeWinding(w); + return area; + } //end if + return 0; +} //end of the function HL_FaceOnWinding +//=========================================================================== +// returns a list with brushes created by splitting the given brush with +// planes that go through the face edges and are orthogonal to the face plane +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *HL_SplitBrushWithFace(bspbrush_t *brush, hl_dface_t *face) +{ + int i, edgenum, side, planenum, splits; + float dist; + hl_dplane_t plane; + vec_t *v1, *v2; + vec3_t normal, edgevec; + bspbrush_t *front, *back, *brushlist; + + memcpy(&plane, &hl_dplanes[face->planenum], sizeof(hl_dplane_t)); + //check on which side of the plane the face is + if (face->side) + { + VectorNegate(plane.normal, plane.normal); + plane.dist = -plane.dist; + } //end if + splits = 0; + brushlist = NULL; + for (i = 0; i < face->numedges; i++) + { + //get the first and second vertex of the edge + edgenum = hl_dsurfedges[face->firstedge + i]; + side = edgenum > 0; + //if the face plane is flipped + v1 = hl_dvertexes[hl_dedges[abs(edgenum)].v[side]].point; + v2 = hl_dvertexes[hl_dedges[abs(edgenum)].v[!side]].point; + //create a plane through the edge vector, orthogonal to the face plane + //and with the normal vector pointing out of the face + VectorSubtract(v1, v2, edgevec); + CrossProduct(edgevec, plane.normal, normal); + VectorNormalize(normal); + dist = DotProduct(normal, v1); + // + planenum = FindFloatPlane(normal, dist); + //split the current brush + SplitBrush(brush, planenum, &front, &back); + //if there is a back brush just put it in the list + if (back) + { + //copy the brush contents + back->side = brush->side; + // + back->next = brushlist; + brushlist = back; + splits++; + } //end if + if (!front) + { + Log_Print("HL_SplitBrushWithFace: no new brush\n"); + FreeBrushList(brushlist); + return NULL; + } //end if + //copy the brush contents + front->side = brush->side; + //continue splitting the front brush + brush = front; + } //end for + if (!splits) + { + FreeBrush(front); + return NULL; + } //end if + front->next = brushlist; + brushlist = front; + return brushlist; +} //end of the function HL_SplitBrushWithFace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *HL_TextureBrushes(bspbrush_t *brushlist, int modelnum) +{ + float area, largestarea; + int i, n, texinfonum, sn, numbrushes, ofs; + int bestfacenum, sidenodenum; + side_t *side; + hl_dmiptexlump_t *miptexlump; + hl_miptex_t *miptex; + bspbrush_t *brush, *nextbrush, *prevbrush, *newbrushes, *brushlistend; + vec_t defaultvec[4] = {1, 0, 0, 0}; + + if (!modelnum) qprintf("texturing brushes\n"); + if (!modelnum) qprintf("%5d brushes", numbrushes = 0); + //get a pointer to the last brush in the list + for (brushlistend = brushlist; brushlistend; brushlistend = brushlistend->next) + { + if (!brushlistend->next) break; + } //end for + //there's no previous brush when at the start of the list + prevbrush = NULL; + //go over the brush list + for (brush = brushlist; brush; brush = nextbrush) + { + nextbrush = brush->next; + //find a texinfo for every brush side + for (sn = 0; sn < brush->numsides; sn++) + { + side = &brush->sides[sn]; + // + if (side->flags & SFL_TEXTURED) continue; + //number of the node that created this brush side + sidenodenum = side->surf; //see midwinding in HL_SplitBrush + //no face found yet + bestfacenum = -1; + //minimum face size + largestarea = 1; + //if optimizing the texture placement and not going for the + //least number of brushes + if (!lessbrushes) + { + for (i = 0; i < hl_numfaces; i++) + { + //the face must be in the same plane as the node plane that created + //this brush side + if (hl_dfaces[i].planenum == hl_dnodes[sidenodenum].planenum) + { + //get the area the face and the brush side overlap + area = HL_FaceOnWinding(&hl_dfaces[i], side->winding); + //if this face overlaps the brush side winding more than previous faces + if (area > largestarea) + { + //if there already was a face for texturing this brush side with + //a different texture + if (bestfacenum >= 0 && + (hl_dfaces[bestfacenum].texinfo != hl_dfaces[i].texinfo)) + { + //split the brush to fit the texture + newbrushes = HL_SplitBrushWithFace(brush, &hl_dfaces[i]); + //if new brushes where created + if (newbrushes) + { + //remove the current brush from the list + if (prevbrush) prevbrush->next = brush->next; + else brushlist = brush->next; + if (brushlistend == brush) + { + brushlistend = prevbrush; + nextbrush = newbrushes; + } //end if + //add the new brushes to the end of the list + if (brushlistend) brushlistend->next = newbrushes; + else brushlist = newbrushes; + //free the current brush + FreeBrush(brush); + //don't forget about the prevbrush pointer at the bottom of + //the outer loop + brush = prevbrush; + //find the end of the list + for (brushlistend = brushlist; brushlistend; brushlistend = brushlistend->next) + { + if (!brushlistend->next) break; + } //end for + break; + } //end if + else + { + Log_Write("brush %d: no real texture split", numbrushes); + } //end else + } //end if + else + { + //best face for texturing this brush side + bestfacenum = i; + } //end else + } //end if + } //end if + } //end for + //if the brush was split the original brush is removed + //and we just continue with the next one in the list + if (i < hl_numfaces) break; + } //end if + else + { + //find the face with the largest overlap with this brush side + //for texturing the brush side + for (i = 0; i < hl_numfaces; i++) + { + //the face must be in the same plane as the node plane that created + //this brush side + if (hl_dfaces[i].planenum == hl_dnodes[sidenodenum].planenum) + { + //get the area the face and the brush side overlap + area = HL_FaceOnWinding(&hl_dfaces[i], side->winding); + //if this face overlaps the brush side winding more than previous faces + if (area > largestarea) + { + largestarea = area; + bestfacenum = i; + } //end if + } //end if + } //end for + } //end else + //if a face was found for texturing this brush side + if (bestfacenum >= 0) + { + //set the MAP texinfo values + texinfonum = hl_dfaces[bestfacenum].texinfo; + for (n = 0; n < 4; n++) + { + map_texinfo[texinfonum].vecs[0][n] = hl_texinfo[texinfonum].vecs[0][n]; + map_texinfo[texinfonum].vecs[1][n] = hl_texinfo[texinfonum].vecs[1][n]; + } //end for + //make sure the two vectors aren't of zero length otherwise use the default + //vector to prevent a divide by zero in the map writing + if (VectorLength(map_texinfo[texinfonum].vecs[0]) < 0.01) + memcpy(map_texinfo[texinfonum].vecs[0], defaultvec, sizeof(defaultvec)); + if (VectorLength(map_texinfo[texinfonum].vecs[1]) < 0.01) + memcpy(map_texinfo[texinfonum].vecs[1], defaultvec, sizeof(defaultvec)); + // + map_texinfo[texinfonum].flags = hl_texinfo[texinfonum].flags; + map_texinfo[texinfonum].value = 0; //HL_ and HL texinfos don't have a value + //the mip texture + miptexlump = (hl_dmiptexlump_t *) hl_dtexdata; + ofs = miptexlump->dataofs[hl_texinfo[texinfonum].miptex]; + if ( ofs > hl_texdatasize ) { + ofs = miptexlump->dataofs[0]; + } + miptex = (hl_miptex_t *)((byte *)miptexlump + ofs ); + //get the mip texture name + strcpy(map_texinfo[texinfonum].texture, miptex->name); + //no animations in Quake1 and Half-Life mip textures + map_texinfo[texinfonum].nexttexinfo = -1; + //store the texinfo number + side->texinfo = texinfonum; + // + if (texinfonum > map_numtexinfo) map_numtexinfo = texinfonum; + //this side is textured + side->flags |= SFL_TEXTURED; + } //end if + else + { + //no texture for this side + side->texinfo = TEXINFO_NODE; + //this side is textured + side->flags |= SFL_TEXTURED; + } //end if + } //end for + // + if (!modelnum && prevbrush != brush) qprintf("\r%5d", ++numbrushes); + //previous brush in the list + prevbrush = brush; + } //end for + if (!modelnum) qprintf("\n"); + //return the new list with brushes + return brushlist; +} //end of the function HL_TextureBrushes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void HL_FixContentsTextures(bspbrush_t *brushlist) +{ + int i, texinfonum; + bspbrush_t *brush; + + for (brush = brushlist; brush; brush = brush->next) + { + //only fix the textures of water, slime and lava brushes + if (brush->side != CONTENTS_WATER && + brush->side != CONTENTS_SLIME && + brush->side != CONTENTS_LAVA) continue; + // + for (i = 0; i < brush->numsides; i++) + { + texinfonum = brush->sides[i].texinfo; + if (HL_TextureContents(map_texinfo[texinfonum].texture) == brush->side) break; + } //end for + //if no specific contents texture was found + if (i >= brush->numsides) + { + texinfonum = -1; + for (i = 0; i < map_numtexinfo; i++) + { + if (HL_TextureContents(map_texinfo[i].texture) == brush->side) + { + texinfonum = i; + break; + } //end if + } //end for + } //end if + // + if (texinfonum >= 0) + { + //give all the brush sides this contents texture + for (i = 0; i < brush->numsides; i++) + { + brush->sides[i].texinfo = texinfonum; + } //end for + } //end if + else Log_Print("brush contents %d with wrong textures\n", brush->side); + // + } //end for + /* + for (brush = brushlist; brush; brush = brush->next) + { + //give all the brush sides this contents texture + for (i = 0; i < brush->numsides; i++) + { + if (HL_TextureContents(map_texinfo[texinfonum].texture) != brush->side) + { + Error("brush contents %d with wrong contents textures %s\n", brush->side, + HL_TextureContents(map_texinfo[texinfonum].texture)); + } //end if + } //end for + } //end for*/ +} //end of the function HL_FixContentsTextures +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void HL_BSPBrushToMapBrush(bspbrush_t *bspbrush, entity_t *mapent) +{ + mapbrush_t *mapbrush; + side_t *side; + int i, besttexinfo; + + if (nummapbrushes >= MAX_MAPFILE_BRUSHES) + Error ("nummapbrushes == MAX_MAPFILE_BRUSHES"); + + mapbrush = &mapbrushes[nummapbrushes]; + mapbrush->original_sides = &brushsides[nummapbrushsides]; + mapbrush->entitynum = mapent - entities; + mapbrush->brushnum = nummapbrushes - mapent->firstbrush; + mapbrush->leafnum = -1; + mapbrush->numsides = 0; + + besttexinfo = TEXINFO_NODE; + for (i = 0; i < bspbrush->numsides; i++) + { + if (!bspbrush->sides[i].winding) continue; + // + if (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES) + Error ("MAX_MAPFILE_BRUSHSIDES"); + side = &brushsides[nummapbrushsides]; + //the contents of the bsp brush is stored in the side variable + side->contents = bspbrush->side; + side->surf = 0; + side->planenum = bspbrush->sides[i].planenum; + side->texinfo = bspbrush->sides[i].texinfo; + if (side->texinfo != TEXINFO_NODE) + { + //this brush side is textured + side->flags |= SFL_TEXTURED; + besttexinfo = side->texinfo; + } //end if + // + nummapbrushsides++; + mapbrush->numsides++; + } //end for + // + if (besttexinfo == TEXINFO_NODE) + { + mapbrush->numsides = 0; + hl_numclipbrushes++; + return; + } //end if + //set the texinfo for all the brush sides without texture + for (i = 0; i < mapbrush->numsides; i++) + { + if (mapbrush->original_sides[i].texinfo == TEXINFO_NODE) + { + mapbrush->original_sides[i].texinfo = besttexinfo; + } //end if + } //end for + //contents of the brush + mapbrush->contents = bspbrush->side; + // + if (create_aas) + { + //create the AAS brushes from this brush, add brush bevels + AAS_CreateMapBrushes(mapbrush, mapent, true); + return; + } //end if + //create windings for sides and bounds for brush + MakeBrushWindings(mapbrush); + //add brush bevels + AddBrushBevels(mapbrush); + //a new brush has been created + nummapbrushes++; + mapent->numbrushes++; +} //end of the function HL_BSPBrushToMapBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void HL_CreateMapBrushes(entity_t *mapent, int modelnum) +{ + bspbrush_t *brushlist, *brush, *nextbrush; + int i; + + //create brushes from the model BSP tree + brushlist = HL_CreateBrushesFromBSP(modelnum); + //texture the brushes and split them when necesary + brushlist = HL_TextureBrushes(brushlist, modelnum); + //fix the contents textures of all brushes + HL_FixContentsTextures(brushlist); + // + if (!nobrushmerge) + { + brushlist = HL_MergeBrushes(brushlist, modelnum); + //brushlist = HL_MergeBrushes(brushlist, modelnum); + } //end if + // + if (!modelnum) qprintf("converting brushes to map brushes\n"); + if (!modelnum) qprintf("%5d brushes", i = 0); + for (brush = brushlist; brush; brush = nextbrush) + { + nextbrush = brush->next; + HL_BSPBrushToMapBrush(brush, mapent); + brush->next = NULL; + FreeBrush(brush); + if (!modelnum) qprintf("\r%5d", ++i); + } //end for + if (!modelnum) qprintf("\n"); +} //end of the function HL_CreateMapBrushes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void HL_ResetMapLoading(void) +{ +} //end of the function HL_ResetMapLoading +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void HL_LoadMapFromBSP(char *filename, int offset, int length) +{ + int i, modelnum; + char *model, *classname; + + Log_Print("-- HL_LoadMapFromBSP --\n"); + //loaded map type + loadedmaptype = MAPTYPE_HALFLIFE; + // + qprintf("loading map from %s at %d\n", filename, offset); + //load the Half-Life BSP file + HL_LoadBSPFile(filename, offset, length); + // + hl_numclipbrushes = 0; + //parse the entities from the BSP + HL_ParseEntities(); + //clear the map mins and maxs + ClearBounds(map_mins, map_maxs); + // + qprintf("creating Half-Life brushes\n"); + if (lessbrushes) qprintf("creating minimum number of brushes\n"); + else qprintf("placing textures correctly\n"); + // + for (i = 0; i < num_entities; i++) + { + entities[i].firstbrush = nummapbrushes; + entities[i].numbrushes = 0; + // + classname = ValueForKey(&entities[i], "classname"); + if (classname && !strcmp(classname, "worldspawn")) + { + modelnum = 0; + } //end if + else + { + // + model = ValueForKey(&entities[i], "model"); + if (!model || *model != '*') continue; + model++; + modelnum = atoi(model); + } //end else + //create map brushes for the entity + HL_CreateMapBrushes(&entities[i], modelnum); + } //end for + // + qprintf("%5d map brushes\n", nummapbrushes); + qprintf("%5d clip brushes\n", hl_numclipbrushes); +} //end of the function HL_LoadMapFromBSP diff --git a/code/bspc/map_q1.c b/code/bspc/map_q1.c new file mode 100644 index 00000000..fa9d1173 --- /dev/null +++ b/code/bspc/map_q1.c @@ -0,0 +1,1174 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "l_bsp_q1.h" +#include "aas_map.h" //AAS_CreateMapBrushes + +int q1_numbrushes; +int q1_numclipbrushes; + +//#define Q1_PRINT + +//=========================================================================== +// water, slime and lava brush textures names always start with a * +// followed by the type: "slime", "lava" or otherwise water +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Q1_TextureContents(char *name) +{ + if (!Q_strcasecmp(name, "clip")) return CONTENTS_SOLID; + if (name[0] == '*') + { + if (!Q_strncasecmp(name+1,"lava",4)) return CONTENTS_LAVA; + else if (!Q_strncasecmp(name+1,"slime",5)) return CONTENTS_SLIME; + else return CONTENTS_WATER; + } //end if + else if (!Q_strncasecmp(name, "sky", 3)) return CONTENTS_SOLID; + else return CONTENTS_SOLID; +} //end of the function Q1_TextureContents +//=========================================================================== +// Generates two new brushes, leaving the original +// unchanged +// +// modified for Half-Life because there are quite a lot of tiny node leaves +// in the Half-Life bsps +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q1_SplitBrush(bspbrush_t *brush, int planenum, int nodenum, + bspbrush_t **front, bspbrush_t **back) +{ + bspbrush_t *b[2]; + int i, j; + winding_t *w, *cw[2], *midwinding; + plane_t *plane, *plane2; + side_t *s, *cs; + float d, d_front, d_back; + + *front = *back = NULL; + plane = &mapplanes[planenum]; + + // check all points + d_front = d_back = 0; + for (i=0 ; inumsides ; i++) + { + w = brush->sides[i].winding; + if (!w) + continue; + for (j=0 ; jnumpoints ; j++) + { + d = DotProduct (w->p[j], plane->normal) - plane->dist; + if (d > 0 && d > d_front) + d_front = d; + if (d < 0 && d < d_back) + d_back = d; + } //end for + } //end for + + if (d_front < 0.1) // PLANESIDE_EPSILON) + { // only on back + *back = CopyBrush (brush); + Log_Print("Q1_SplitBrush: only on back\n"); + return; + } //end if + if (d_back > -0.1) // PLANESIDE_EPSILON) + { // only on front + *front = CopyBrush (brush); + Log_Print("Q1_SplitBrush: only on front\n"); + return; + } //end if + + // create a new winding from the split plane + + w = BaseWindingForPlane (plane->normal, plane->dist); + for (i = 0; i < brush->numsides && w; i++) + { + plane2 = &mapplanes[brush->sides[i].planenum ^ 1]; + ChopWindingInPlace(&w, plane2->normal, plane2->dist, 0); // PLANESIDE_EPSILON); + } //end for + + if (!w || WindingIsTiny(w)) + { // the brush isn't really split + int side; + + Log_Print("Q1_SplitBrush: no split winding\n"); + side = BrushMostlyOnSide (brush, plane); + if (side == PSIDE_FRONT) + *front = CopyBrush (brush); + if (side == PSIDE_BACK) + *back = CopyBrush (brush); + return; + } + + if (WindingIsHuge(w)) + { + Log_Print("Q1_SplitBrush: WARNING huge split winding\n"); + } //end of + + midwinding = w; + + // split it for real + + for (i = 0; i < 2; i++) + { + b[i] = AllocBrush (brush->numsides+1); + b[i]->original = brush->original; + } //end for + + // split all the current windings + + for (i=0 ; inumsides ; i++) + { + s = &brush->sides[i]; + w = s->winding; + if (!w) + continue; + ClipWindingEpsilon (w, plane->normal, plane->dist, + 0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1]); + for (j=0 ; j<2 ; j++) + { + if (!cw[j]) + continue; +#if 0 + if (WindingIsTiny (cw[j])) + { + FreeWinding (cw[j]); + continue; + } +#endif + cs = &b[j]->sides[b[j]->numsides]; + b[j]->numsides++; + *cs = *s; +// cs->planenum = s->planenum; +// cs->texinfo = s->texinfo; +// cs->visible = s->visible; +// cs->original = s->original; + cs->winding = cw[j]; + cs->flags &= ~SFL_TESTED; + } //end for + } //end for + + + // see if we have valid polygons on both sides + + for (i=0 ; i<2 ; i++) + { + BoundBrush (b[i]); + for (j=0 ; j<3 ; j++) + { + if (b[i]->mins[j] < -4096 || b[i]->maxs[j] > 4096) + { + Log_Print("Q1_SplitBrush: bogus brush after clip\n"); + break; + } //end if + } //end for + + if (b[i]->numsides < 3 || j < 3) + { + FreeBrush (b[i]); + b[i] = NULL; + Log_Print("Q1_SplitBrush: numsides < 3\n"); + } //end if + } //end for + + if ( !(b[0] && b[1]) ) + { + if (!b[0] && !b[1]) + Log_Print("Q1_SplitBrush: split removed brush\n"); + else + Log_Print("Q1_SplitBrush: split not on both sides\n"); + if (b[0]) + { + FreeBrush (b[0]); + *front = CopyBrush (brush); + } //end if + if (b[1]) + { + FreeBrush (b[1]); + *back = CopyBrush (brush); + } //end if + return; + } //end if + + // add the midwinding to both sides + for (i = 0; i < 2; i++) + { + cs = &b[i]->sides[b[i]->numsides]; + b[i]->numsides++; + + cs->planenum = planenum^i^1; + cs->texinfo = 0; + //store the node number in the surf to find the texinfo later on + cs->surf = nodenum; + // + cs->flags &= ~SFL_VISIBLE; + cs->flags &= ~SFL_TESTED; + cs->flags &= ~SFL_TEXTURED; + if (i==0) + cs->winding = CopyWinding (midwinding); + else + cs->winding = midwinding; + } //end for + + +{ + vec_t v1; + int i; + + for (i=0 ; i<2 ; i++) + { + v1 = BrushVolume (b[i]); + if (v1 < 1) + { + FreeBrush (b[i]); + b[i] = NULL; + Log_Print("Q1_SplitBrush: tiny volume after clip\n"); + } //end if + } //end for +} //*/ + + *front = b[0]; + *back = b[1]; +} //end of the function Q1_SplitBrush +//=========================================================================== +// returns true if the tree starting at nodenum has only solid leaves +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Q1_SolidTree_r(int nodenum) +{ + if (nodenum < 0) + { + switch(q1_dleafs[(-nodenum) - 1].contents) + { + case Q1_CONTENTS_EMPTY: + { + return false; + } //end case + case Q1_CONTENTS_SOLID: +#ifdef HLCONTENTS + case Q1_CONTENTS_CLIP: +#endif HLCONTENTS + case Q1_CONTENTS_SKY: +#ifdef HLCONTENTS + case Q1_CONTENTS_TRANSLUCENT: +#endif HLCONTENTS + { + return true; + } //end case + case Q1_CONTENTS_WATER: + case Q1_CONTENTS_SLIME: + case Q1_CONTENTS_LAVA: +#ifdef HLCONTENTS + //these contents should not be found in the BSP + case Q1_CONTENTS_ORIGIN: + case Q1_CONTENTS_CURRENT_0: + case Q1_CONTENTS_CURRENT_90: + case Q1_CONTENTS_CURRENT_180: + case Q1_CONTENTS_CURRENT_270: + case Q1_CONTENTS_CURRENT_UP: + case Q1_CONTENTS_CURRENT_DOWN: +#endif HLCONTENTS + default: + { + return false; + } //end default + } //end switch + return false; + } //end if + if (!Q1_SolidTree_r(q1_dnodes[nodenum].children[0])) return false; + if (!Q1_SolidTree_r(q1_dnodes[nodenum].children[1])) return false; + return true; +} //end of the function Q1_SolidTree_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *Q1_CreateBrushes_r(bspbrush_t *brush, int nodenum) +{ + int planenum; + bspbrush_t *front, *back; + q1_dleaf_t *leaf; + + //if it is a leaf + if (nodenum < 0) + { + leaf = &q1_dleafs[(-nodenum) - 1]; + if (leaf->contents != Q1_CONTENTS_EMPTY) + { +#ifdef Q1_PRINT + qprintf("\r%5i", ++q1_numbrushes); +#endif //Q1_PRINT + } //end if + switch(leaf->contents) + { + case Q1_CONTENTS_EMPTY: + { + FreeBrush(brush); + return NULL; + } //end case + case Q1_CONTENTS_SOLID: +#ifdef HLCONTENTS + case Q1_CONTENTS_CLIP: +#endif HLCONTENTS + case Q1_CONTENTS_SKY: +#ifdef HLCONTENTS + case Q1_CONTENTS_TRANSLUCENT: +#endif HLCONTENTS + { + brush->side = CONTENTS_SOLID; + return brush; + } //end case + case Q1_CONTENTS_WATER: + { + brush->side = CONTENTS_WATER; + return brush; + } //end case + case Q1_CONTENTS_SLIME: + { + brush->side = CONTENTS_SLIME; + return brush; + } //end case + case Q1_CONTENTS_LAVA: + { + brush->side = CONTENTS_LAVA; + return brush; + } //end case +#ifdef HLCONTENTS + //these contents should not be found in the BSP + case Q1_CONTENTS_ORIGIN: + case Q1_CONTENTS_CURRENT_0: + case Q1_CONTENTS_CURRENT_90: + case Q1_CONTENTS_CURRENT_180: + case Q1_CONTENTS_CURRENT_270: + case Q1_CONTENTS_CURRENT_UP: + case Q1_CONTENTS_CURRENT_DOWN: + { + Error("Q1_CreateBrushes_r: found contents %d in Half-Life BSP", leaf->contents); + return NULL; + } //end case +#endif HLCONTENTS + default: + { + Error("Q1_CreateBrushes_r: unknown contents %d in Half-Life BSP", leaf->contents); + return NULL; + } //end default + } //end switch + return NULL; + } //end if + //if the rest of the tree is solid + /*if (Q1_SolidTree_r(nodenum)) + { + brush->side = CONTENTS_SOLID; + return brush; + } //end if*/ + // + planenum = q1_dnodes[nodenum].planenum; + planenum = FindFloatPlane(q1_dplanes[planenum].normal, q1_dplanes[planenum].dist); + //split the brush with the node plane + Q1_SplitBrush(brush, planenum, nodenum, &front, &back); + //free the original brush + FreeBrush(brush); + //every node must split the brush in two + if (!front || !back) + { + Log_Print("Q1_CreateBrushes_r: WARNING node not splitting brush\n"); + //return NULL; + } //end if + //create brushes recursively + if (front) front = Q1_CreateBrushes_r(front, q1_dnodes[nodenum].children[0]); + if (back) back = Q1_CreateBrushes_r(back, q1_dnodes[nodenum].children[1]); + //link the brushes if possible and return them + if (front) + { + for (brush = front; brush->next; brush = brush->next); + brush->next = back; + return front; + } //end if + else + { + return back; + } //end else +} //end of the function Q1_CreateBrushes_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *Q1_CreateBrushesFromBSP(int modelnum) +{ + bspbrush_t *brushlist; + bspbrush_t *brush; + q1_dnode_t *headnode; + vec3_t mins, maxs; + int i; + + // + headnode = &q1_dnodes[q1_dmodels[modelnum].headnode[0]]; + //get the mins and maxs of the world + VectorCopy(headnode->mins, mins); + VectorCopy(headnode->maxs, maxs); + //enlarge these mins and maxs + for (i = 0; i < 3; i++) + { + mins[i] -= 8; + maxs[i] += 8; + } //end for + //NOTE: have to add the BSP tree mins and maxs to the MAP mins and maxs + AddPointToBounds(mins, map_mins, map_maxs); + AddPointToBounds(maxs, map_mins, map_maxs); + // + if (!modelnum) + { + Log_Print("brush size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\n", + map_mins[0], map_mins[1], map_mins[2], + map_maxs[0], map_maxs[1], map_maxs[2]); + } //end if + //create one huge brush containing the whole world + brush = BrushFromBounds(mins, maxs); + VectorCopy(mins, brush->mins); + VectorCopy(maxs, brush->maxs); + // +#ifdef Q1_PRINT + qprintf("creating Quake brushes\n"); + qprintf("%5d brushes", q1_numbrushes = 0); +#endif //Q1_PRINT + //create the brushes + brushlist = Q1_CreateBrushes_r(brush, q1_dmodels[modelnum].headnode[0]); + // +#ifdef Q1_PRINT + qprintf("\n"); +#endif //Q1_PRINT + //now we've got a list with brushes! + return brushlist; +} //end of the function Q1_CreateBrushesFromBSP +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +q1_dleaf_t *Q1_PointInLeaf(int startnode, vec3_t point) +{ + int nodenum; + vec_t dist; + q1_dnode_t *node; + q1_dplane_t *plane; + + nodenum = startnode; + while (nodenum >= 0) + { + node = &q1_dnodes[nodenum]; + plane = &q1_dplanes[node->planenum]; + dist = DotProduct(point, plane->normal) - plane->dist; + if (dist > 0) + nodenum = node->children[0]; + else + nodenum = node->children[1]; + } //end while + + return &q1_dleafs[-nodenum - 1]; +} //end of the function Q1_PointInLeaf +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float Q1_FaceArea(q1_dface_t *face) +{ + int i; + float total; + vec_t *v; + vec3_t d1, d2, cross; + q1_dedge_t *edge; + + edge = &q1_dedges[face->firstedge]; + v = q1_dvertexes[edge->v[0]].point; + + total = 0; + for (i = 1; i < face->numedges - 1; i++) + { + edge = &q1_dedges[face->firstedge + i]; + VectorSubtract(q1_dvertexes[edge->v[0]].point, v, d1); + VectorSubtract(q1_dvertexes[edge->v[1]].point, v, d2); + CrossProduct(d1, d2, cross); + total += 0.5 * VectorLength(cross); + } //end for + return total; +} //end of the function AAS_FaceArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q1_FacePlane(q1_dface_t *face, vec3_t normal, float *dist) +{ + vec_t *v1, *v2, *v3; + vec3_t vec1, vec2; + int side, edgenum; + + edgenum = q1_dsurfedges[face->firstedge]; + side = edgenum < 0; + v1 = q1_dvertexes[q1_dedges[abs(edgenum)].v[side]].point; + v2 = q1_dvertexes[q1_dedges[abs(edgenum)].v[!side]].point; + edgenum = q1_dsurfedges[face->firstedge+1]; + side = edgenum < 0; + v3 = q1_dvertexes[q1_dedges[abs(edgenum)].v[!side]].point; + // + VectorSubtract(v2, v1, vec1); + VectorSubtract(v3, v1, vec2); + + CrossProduct(vec1, vec2, normal); + VectorNormalize(normal); + *dist = DotProduct(v1, normal); +} //end of the function Q1_FacePlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *Q1_MergeBrushes(bspbrush_t *brushlist, int modelnum) +{ + int nummerges, merged; + bspbrush_t *b1, *b2, *tail, *newbrush, *newbrushlist; + bspbrush_t *lastb2; + + if (!brushlist) return NULL; + + if (!modelnum) qprintf("%5d brushes merged", nummerges = 0); + do + { + for (tail = brushlist; tail; tail = tail->next) + { + if (!tail->next) break; + } //end for + merged = 0; + newbrushlist = NULL; + for (b1 = brushlist; b1; b1 = brushlist) + { + lastb2 = b1; + for (b2 = b1->next; b2; b2 = b2->next) + { + //can't merge brushes with different contents + if (b1->side != b2->side) newbrush = NULL; + else newbrush = TryMergeBrushes(b1, b2); + //if a merged brush is created + if (newbrush) + { + //copy the brush contents + newbrush->side = b1->side; + //add the new brush to the end of the list + tail->next = newbrush; + //remove the second brush from the list + lastb2->next = b2->next; + //remove the first brush from the list + brushlist = brushlist->next; + //free the merged brushes + FreeBrush(b1); + FreeBrush(b2); + //get a new tail brush + for (tail = brushlist; tail; tail = tail->next) + { + if (!tail->next) break; + } //end for + merged++; + if (!modelnum) qprintf("\r%5d", nummerges++); + break; + } //end if + lastb2 = b2; + } //end for + //if b1 can't be merged with any of the other brushes + if (!b2) + { + brushlist = brushlist->next; + //keep b1 + b1->next = newbrushlist; + newbrushlist = b1; + } //end else + } //end for + brushlist = newbrushlist; + } while(merged); + if (!modelnum) qprintf("\n"); + return newbrushlist; +} //end of the function Q1_MergeBrushes +//=========================================================================== +// returns the amount the face and the winding overlap +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float Q1_FaceOnWinding(q1_dface_t *face, winding_t *winding) +{ + int i, edgenum, side; + float dist, area; + q1_dplane_t plane; + vec_t *v1, *v2; + vec3_t normal, edgevec; + winding_t *w; + + // + w = CopyWinding(winding); + memcpy(&plane, &q1_dplanes[face->planenum], sizeof(q1_dplane_t)); + //check on which side of the plane the face is + if (face->side) + { + VectorNegate(plane.normal, plane.normal); + plane.dist = -plane.dist; + } //end if + for (i = 0; i < face->numedges && w; i++) + { + //get the first and second vertex of the edge + edgenum = q1_dsurfedges[face->firstedge + i]; + side = edgenum > 0; + //if the face plane is flipped + v1 = q1_dvertexes[q1_dedges[abs(edgenum)].v[side]].point; + v2 = q1_dvertexes[q1_dedges[abs(edgenum)].v[!side]].point; + //create a plane through the edge vector, orthogonal to the face plane + //and with the normal vector pointing out of the face + VectorSubtract(v1, v2, edgevec); + CrossProduct(edgevec, plane.normal, normal); + VectorNormalize(normal); + dist = DotProduct(normal, v1); + // + ChopWindingInPlace(&w, normal, dist, 0.9); //CLIP_EPSILON + } //end for + if (w) + { + area = WindingArea(w); + FreeWinding(w); + return area; + } //end if + return 0; +} //end of the function Q1_FaceOnWinding +//=========================================================================== +// returns a list with brushes created by splitting the given brush with +// planes that go through the face edges and are orthogonal to the face plane +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *Q1_SplitBrushWithFace(bspbrush_t *brush, q1_dface_t *face) +{ + int i, edgenum, side, planenum, splits; + float dist; + q1_dplane_t plane; + vec_t *v1, *v2; + vec3_t normal, edgevec; + bspbrush_t *front, *back, *brushlist; + + memcpy(&plane, &q1_dplanes[face->planenum], sizeof(q1_dplane_t)); + //check on which side of the plane the face is + if (face->side) + { + VectorNegate(plane.normal, plane.normal); + plane.dist = -plane.dist; + } //end if + splits = 0; + brushlist = NULL; + for (i = 0; i < face->numedges; i++) + { + //get the first and second vertex of the edge + edgenum = q1_dsurfedges[face->firstedge + i]; + side = edgenum > 0; + //if the face plane is flipped + v1 = q1_dvertexes[q1_dedges[abs(edgenum)].v[side]].point; + v2 = q1_dvertexes[q1_dedges[abs(edgenum)].v[!side]].point; + //create a plane through the edge vector, orthogonal to the face plane + //and with the normal vector pointing out of the face + VectorSubtract(v1, v2, edgevec); + CrossProduct(edgevec, plane.normal, normal); + VectorNormalize(normal); + dist = DotProduct(normal, v1); + // + planenum = FindFloatPlane(normal, dist); + //split the current brush + SplitBrush(brush, planenum, &front, &back); + //if there is a back brush just put it in the list + if (back) + { + //copy the brush contents + back->side = brush->side; + // + back->next = brushlist; + brushlist = back; + splits++; + } //end if + if (!front) + { + Log_Print("Q1_SplitBrushWithFace: no new brush\n"); + FreeBrushList(brushlist); + return NULL; + } //end if + //copy the brush contents + front->side = brush->side; + //continue splitting the front brush + brush = front; + } //end for + if (!splits) + { + FreeBrush(front); + return NULL; + } //end if + front->next = brushlist; + brushlist = front; + return brushlist; +} //end of the function Q1_SplitBrushWithFace +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +bspbrush_t *Q1_TextureBrushes(bspbrush_t *brushlist, int modelnum) +{ + float area, largestarea; + int i, n, texinfonum, sn, numbrushes, ofs; + int bestfacenum, sidenodenum; + side_t *side; + q1_dmiptexlump_t *miptexlump; + q1_miptex_t *miptex; + bspbrush_t *brush, *nextbrush, *prevbrush, *newbrushes, *brushlistend; + vec_t defaultvec[4] = {1, 0, 0, 0}; + + if (!modelnum) qprintf("texturing brushes\n"); + if (!modelnum) qprintf("%5d brushes", numbrushes = 0); + //get a pointer to the last brush in the list + for (brushlistend = brushlist; brushlistend; brushlistend = brushlistend->next) + { + if (!brushlistend->next) break; + } //end for + //there's no previous brush when at the start of the list + prevbrush = NULL; + //go over the brush list + for (brush = brushlist; brush; brush = nextbrush) + { + nextbrush = brush->next; + //find a texinfo for every brush side + for (sn = 0; sn < brush->numsides; sn++) + { + side = &brush->sides[sn]; + // + if (side->flags & SFL_TEXTURED) continue; + //number of the node that created this brush side + sidenodenum = side->surf; //see midwinding in Q1_SplitBrush + //no face found yet + bestfacenum = -1; + //minimum face size + largestarea = 1; + //if optimizing the texture placement and not going for the + //least number of brushes + if (!lessbrushes) + { + for (i = 0; i < q1_numfaces; i++) + { + //the face must be in the same plane as the node plane that created + //this brush side + if (q1_dfaces[i].planenum == q1_dnodes[sidenodenum].planenum) + { + //get the area the face and the brush side overlap + area = Q1_FaceOnWinding(&q1_dfaces[i], side->winding); + //if this face overlaps the brush side winding more than previous faces + if (area > largestarea) + { + //if there already was a face for texturing this brush side with + //a different texture + if (bestfacenum >= 0 && + (q1_dfaces[bestfacenum].texinfo != q1_dfaces[i].texinfo)) + { + //split the brush to fit the texture + newbrushes = Q1_SplitBrushWithFace(brush, &q1_dfaces[i]); + //if new brushes where created + if (newbrushes) + { + //remove the current brush from the list + if (prevbrush) prevbrush->next = brush->next; + else brushlist = brush->next; + if (brushlistend == brush) + { + brushlistend = prevbrush; + nextbrush = newbrushes; + } //end if + //add the new brushes to the end of the list + if (brushlistend) brushlistend->next = newbrushes; + else brushlist = newbrushes; + //free the current brush + FreeBrush(brush); + //don't forget about the prevbrush pointer at the bottom of + //the outer loop + brush = prevbrush; + //find the end of the list + for (brushlistend = brushlist; brushlistend; brushlistend = brushlistend->next) + { + if (!brushlistend->next) break; + } //end for + break; + } //end if + else + { + Log_Write("brush %d: no real texture split", numbrushes); + } //end else + } //end if + else + { + //best face for texturing this brush side + bestfacenum = i; + } //end else + } //end if + } //end if + } //end for + //if the brush was split the original brush is removed + //and we just continue with the next one in the list + if (i < q1_numfaces) break; + } //end if + else + { + //find the face with the largest overlap with this brush side + //for texturing the brush side + for (i = 0; i < q1_numfaces; i++) + { + //the face must be in the same plane as the node plane that created + //this brush side + if (q1_dfaces[i].planenum == q1_dnodes[sidenodenum].planenum) + { + //get the area the face and the brush side overlap + area = Q1_FaceOnWinding(&q1_dfaces[i], side->winding); + //if this face overlaps the brush side winding more than previous faces + if (area > largestarea) + { + largestarea = area; + bestfacenum = i; + } //end if + } //end if + } //end for + } //end else + //if a face was found for texturing this brush side + if (bestfacenum >= 0) + { + //set the MAP texinfo values + texinfonum = q1_dfaces[bestfacenum].texinfo; + for (n = 0; n < 4; n++) + { + map_texinfo[texinfonum].vecs[0][n] = q1_texinfo[texinfonum].vecs[0][n]; + map_texinfo[texinfonum].vecs[1][n] = q1_texinfo[texinfonum].vecs[1][n]; + } //end for + //make sure the two vectors aren't of zero length otherwise use the default + //vector to prevent a divide by zero in the map writing + if (VectorLength(map_texinfo[texinfonum].vecs[0]) < 0.01) + memcpy(map_texinfo[texinfonum].vecs[0], defaultvec, sizeof(defaultvec)); + if (VectorLength(map_texinfo[texinfonum].vecs[1]) < 0.01) + memcpy(map_texinfo[texinfonum].vecs[1], defaultvec, sizeof(defaultvec)); + // + map_texinfo[texinfonum].flags = q1_texinfo[texinfonum].flags; + map_texinfo[texinfonum].value = 0; //Q1 and HL texinfos don't have a value + //the mip texture + miptexlump = (q1_dmiptexlump_t *) q1_dtexdata; + ofs = miptexlump->dataofs[q1_texinfo[texinfonum].miptex]; + if ( ofs > q1_texdatasize ) { + ofs = miptexlump->dataofs[0]; + } + miptex = (q1_miptex_t *)((byte *)miptexlump + ofs); + //get the mip texture name + strcpy(map_texinfo[texinfonum].texture, miptex->name); + //no animations in Quake1 and Half-Life mip textures + map_texinfo[texinfonum].nexttexinfo = -1; + //store the texinfo number + side->texinfo = texinfonum; + // + if (texinfonum > map_numtexinfo) map_numtexinfo = texinfonum; + //this side is textured + side->flags |= SFL_TEXTURED; + } //end if + else + { + //no texture for this side + side->texinfo = TEXINFO_NODE; + //this side is textured + side->flags |= SFL_TEXTURED; + } //end if + } //end for + // + if (!modelnum && prevbrush != brush) qprintf("\r%5d", ++numbrushes); + //previous brush in the list + prevbrush = brush; + } //end for + if (!modelnum) qprintf("\n"); + //return the new list with brushes + return brushlist; +} //end of the function Q1_TextureBrushes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q1_FixContentsTextures(bspbrush_t *brushlist) +{ + int i, texinfonum; + bspbrush_t *brush; + + for (brush = brushlist; brush; brush = brush->next) + { + //only fix the textures of water, slime and lava brushes + if (brush->side != CONTENTS_WATER && + brush->side != CONTENTS_SLIME && + brush->side != CONTENTS_LAVA) continue; + // + for (i = 0; i < brush->numsides; i++) + { + texinfonum = brush->sides[i].texinfo; + if (Q1_TextureContents(map_texinfo[texinfonum].texture) == brush->side) break; + } //end for + //if no specific contents texture was found + if (i >= brush->numsides) + { + texinfonum = -1; + for (i = 0; i < map_numtexinfo; i++) + { + if (Q1_TextureContents(map_texinfo[i].texture) == brush->side) + { + texinfonum = i; + break; + } //end if + } //end for + } //end if + // + if (texinfonum >= 0) + { + //give all the brush sides this contents texture + for (i = 0; i < brush->numsides; i++) + { + brush->sides[i].texinfo = texinfonum; + } //end for + } //end if + else Log_Print("brush contents %d with wrong textures\n", brush->side); + // + } //end for + /* + for (brush = brushlist; brush; brush = brush->next) + { + //give all the brush sides this contents texture + for (i = 0; i < brush->numsides; i++) + { + if (Q1_TextureContents(map_texinfo[texinfonum].texture) != brush->side) + { + Error("brush contents %d with wrong contents textures %s\n", brush->side, + Q1_TextureContents(map_texinfo[texinfonum].texture)); + } //end if + } //end for + } //end for*/ +} //end of the function Q1_FixContentsTextures +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q1_BSPBrushToMapBrush(bspbrush_t *bspbrush, entity_t *mapent) +{ + mapbrush_t *mapbrush; + side_t *side; + int i, besttexinfo; + + CheckBSPBrush(bspbrush); + + if (nummapbrushes >= MAX_MAPFILE_BRUSHES) + Error ("nummapbrushes == MAX_MAPFILE_BRUSHES"); + + mapbrush = &mapbrushes[nummapbrushes]; + mapbrush->original_sides = &brushsides[nummapbrushsides]; + mapbrush->entitynum = mapent - entities; + mapbrush->brushnum = nummapbrushes - mapent->firstbrush; + mapbrush->leafnum = -1; + mapbrush->numsides = 0; + + besttexinfo = TEXINFO_NODE; + for (i = 0; i < bspbrush->numsides; i++) + { + if (!bspbrush->sides[i].winding) continue; + // + if (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES) + Error ("MAX_MAPFILE_BRUSHSIDES"); + side = &brushsides[nummapbrushsides]; + //the contents of the bsp brush is stored in the side variable + side->contents = bspbrush->side; + side->surf = 0; + side->planenum = bspbrush->sides[i].planenum; + side->texinfo = bspbrush->sides[i].texinfo; + if (side->texinfo != TEXINFO_NODE) + { + //this brush side is textured + side->flags |= SFL_TEXTURED; + besttexinfo = side->texinfo; + } //end if + // + nummapbrushsides++; + mapbrush->numsides++; + } //end for + // + if (besttexinfo == TEXINFO_NODE) + { + mapbrush->numsides = 0; + q1_numclipbrushes++; + return; + } //end if + //set the texinfo for all the brush sides without texture + for (i = 0; i < mapbrush->numsides; i++) + { + if (mapbrush->original_sides[i].texinfo == TEXINFO_NODE) + { + mapbrush->original_sides[i].texinfo = besttexinfo; + } //end if + } //end for + //contents of the brush + mapbrush->contents = bspbrush->side; + // + if (create_aas) + { + //create the AAS brushes from this brush, add brush bevels + AAS_CreateMapBrushes(mapbrush, mapent, true); + return; + } //end if + //create windings for sides and bounds for brush + MakeBrushWindings(mapbrush); + //add brush bevels + AddBrushBevels(mapbrush); + //a new brush has been created + nummapbrushes++; + mapent->numbrushes++; +} //end of the function Q1_BSPBrushToMapBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q1_CreateMapBrushes(entity_t *mapent, int modelnum) +{ + bspbrush_t *brushlist, *brush, *nextbrush; + int i; + + //create brushes from the model BSP tree + brushlist = Q1_CreateBrushesFromBSP(modelnum); + //texture the brushes and split them when necesary + brushlist = Q1_TextureBrushes(brushlist, modelnum); + //fix the contents textures of all brushes + Q1_FixContentsTextures(brushlist); + // + if (!nobrushmerge) + { + brushlist = Q1_MergeBrushes(brushlist, modelnum); + //brushlist = Q1_MergeBrushes(brushlist, modelnum); + } //end if + // + if (!modelnum) qprintf("converting brushes to map brushes\n"); + if (!modelnum) qprintf("%5d brushes", i = 0); + for (brush = brushlist; brush; brush = nextbrush) + { + nextbrush = brush->next; + Q1_BSPBrushToMapBrush(brush, mapent); + brush->next = NULL; + FreeBrush(brush); + if (!modelnum) qprintf("\r%5d", ++i); + } //end for + if (!modelnum) qprintf("\n"); +} //end of the function Q1_CreateMapBrushes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q1_ResetMapLoading(void) +{ +} //end of the function Q1_ResetMapLoading +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q1_LoadMapFromBSP(char *filename, int offset, int length) +{ + int i, modelnum; + char *model, *classname; + + Log_Print("-- Q1_LoadMapFromBSP --\n"); + //the loaded map type + loadedmaptype = MAPTYPE_QUAKE1; + // + qprintf("loading map from %s at %d\n", filename, offset); + //load the Half-Life BSP file + Q1_LoadBSPFile(filename, offset, length); + // + q1_numclipbrushes = 0; + //CreatePath(path); + //Q1_CreateQ2WALFiles(path); + //parse the entities from the BSP + Q1_ParseEntities(); + //clear the map mins and maxs + ClearBounds(map_mins, map_maxs); + // + qprintf("creating Quake1 brushes\n"); + if (lessbrushes) qprintf("creating minimum number of brushes\n"); + else qprintf("placing textures correctly\n"); + // + for (i = 0; i < num_entities; i++) + { + entities[i].firstbrush = nummapbrushes; + entities[i].numbrushes = 0; + // + classname = ValueForKey(&entities[i], "classname"); + if (classname && !strcmp(classname, "worldspawn")) + { + modelnum = 0; + } //end if + else + { + // + model = ValueForKey(&entities[i], "model"); + if (!model || *model != '*') continue; + model++; + modelnum = atoi(model); + } //end else + //create map brushes for the entity + Q1_CreateMapBrushes(&entities[i], modelnum); + } //end for + // + qprintf("%5d map brushes\n", nummapbrushes); + qprintf("%5d clip brushes\n", q1_numclipbrushes); +} //end of the function Q1_LoadMapFromBSP diff --git a/code/bspc/map_q2.c b/code/bspc/map_q2.c new file mode 100644 index 00000000..1882cb87 --- /dev/null +++ b/code/bspc/map_q2.c @@ -0,0 +1,445 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +//=========================================================================== +// ANSI, Area Navigational System Interface +// AAS, Area Awareness System +//=========================================================================== + +#include "qbsp.h" +#include "l_mem.h" +#include "../botlib/aasfile.h" //aas_bbox_t +#include "aas_store.h" //AAS_MAX_BBOXES +#include "aas_cfg.h" +#include "aas_map.h" //AAS_CreateMapBrushes + + +#ifdef ME + +#define NODESTACKSIZE 1024 + +int nodestack[NODESTACKSIZE]; +int *nodestackptr; +int nodestacksize = 0; +int brushmodelnumbers[MAX_MAPFILE_BRUSHES]; +int dbrushleafnums[MAX_MAPFILE_BRUSHES]; +int dplanes2mapplanes[MAX_MAPFILE_PLANES]; + +#endif //ME + +//==================================================================== + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q2_CreateMapTexinfo(void) +{ + +} //end of the function Q2_CreateMapTexinfo + +/* +=========== +Q2_BrushContents +=========== +*/ +int Q2_BrushContents (mapbrush_t *b) +{ + + return 0; +} + +#ifdef ME + +#define BBOX_NORMAL_EPSILON 0.0001 + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void MakeAreaPortalBrush(mapbrush_t *brush) +{ + +} //end of the function MakeAreaPortalBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void DPlanes2MapPlanes(void) +{ + +} //end of the function DPlanes2MapPlanes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void MarkVisibleBrushSides(mapbrush_t *brush) +{ + int n, i, planenum; + +} //end of the function MarkVisibleBrushSides + +#endif //ME + +/* +================= +Q2_ParseBrush +================= +*/ +void Q2_ParseBrush (script_t *script, entity_t *mapent) +{ + +} + +/* +================ +Q2_MoveBrushesToWorld + +Takes all of the brushes from the current entity and +adds them to the world's brush list. + +Used by func_group and func_areaportal +================ +*/ +void Q2_MoveBrushesToWorld (entity_t *mapent) +{ + int newbrushes; + int worldbrushes; + mapbrush_t *temp; + int i; + + // this is pretty gross, because the brushes are expected to be + // in linear order for each entity + + newbrushes = mapent->numbrushes; + worldbrushes = entities[0].numbrushes; + + temp = GetMemory(newbrushes*sizeof(mapbrush_t)); + memcpy (temp, mapbrushes + mapent->firstbrush, newbrushes*sizeof(mapbrush_t)); + +#if 0 // let them keep their original brush numbers + for (i=0 ; inumbrushes = 0; +} + +/* +================ +Q2_ParseMapEntity +================ +*/ +qboolean Q2_ParseMapEntity(script_t *script) +{ + entity_t *mapent; + epair_t *e; + side_t *s; + int i, j; + int startbrush, startsides; + vec_t newdist; + mapbrush_t *b; + token_t token; + + if (!PS_ReadToken(script, &token)) return false; + + if (strcmp(token.string, "{") ) + Error ("ParseEntity: { not found"); + + if (num_entities == MAX_MAP_ENTITIES) + Error ("num_entities == MAX_MAP_ENTITIES"); + + startbrush = nummapbrushes; + startsides = nummapbrushsides; + + mapent = &entities[num_entities]; + num_entities++; + memset (mapent, 0, sizeof(*mapent)); + mapent->firstbrush = nummapbrushes; + mapent->numbrushes = 0; +// mapent->portalareas[0] = -1; +// mapent->portalareas[1] = -1; + + do + { + if (!PS_ReadToken(script, &token)) + { + Error("ParseEntity: EOF without closing brace"); + } //end if + if (!strcmp(token.string, "}")) break; + if (!strcmp(token.string, "{")) + { + Q2_ParseBrush(script, mapent); + } //end if + else + { + PS_UnreadLastToken(script); + e = ParseEpair(script); + e->next = mapent->epairs; + mapent->epairs = e; + } //end else + } while(1); + + GetVectorForKey(mapent, "origin", mapent->origin); + + // + // if there was an origin brush, offset all of the planes and texinfo + // + if (mapent->origin[0] || mapent->origin[1] || mapent->origin[2]) + { + for (i=0 ; inumbrushes ; i++) + { + b = &mapbrushes[mapent->firstbrush + i]; + for (j=0 ; jnumsides ; j++) + { + s = &b->original_sides[j]; + newdist = mapplanes[s->planenum].dist - + DotProduct (mapplanes[s->planenum].normal, mapent->origin); + s->planenum = FindFloatPlane (mapplanes[s->planenum].normal, newdist); + s->texinfo = TexinfoForBrushTexture (&mapplanes[s->planenum], + &side_brushtextures[s-brushsides], mapent->origin); + } + MakeBrushWindings (b); + } + } + + // group entities are just for editor convenience + // toss all brushes into the world entity + if (!strcmp ("func_group", ValueForKey (mapent, "classname"))) + { + Q2_MoveBrushesToWorld (mapent); + mapent->numbrushes = 0; + return true; + } + + // areaportal entities move their brushes, but don't eliminate + // the entity + if (!strcmp ("func_areaportal", ValueForKey (mapent, "classname"))) + { + char str[128]; + + if (mapent->numbrushes != 1) + Error ("Entity %i: func_areaportal can only be a single brush", num_entities-1); + + b = &mapbrushes[nummapbrushes-1]; + b->contents = CONTENTS_AREAPORTAL; + c_areaportals++; + mapent->areaportalnum = c_areaportals; + // set the portal number as "style" + sprintf (str, "%i", c_areaportals); + SetKeyValue (mapent, "style", str); + Q2_MoveBrushesToWorld (mapent); + return true; + } + + return true; +} + +//=================================================================== + +/* +================ +LoadMapFile +================ +*/ +void Q2_LoadMapFile(char *filename) +{ + int i; + script_t *script; + + Log_Print("-- Q2_LoadMapFile --\n"); +#ifdef ME + //loaded map type + loadedmaptype = MAPTYPE_QUAKE2; + //reset the map loading + ResetMapLoading(); +#endif //ME + + script = LoadScriptFile(filename); + if (!script) + { + Log_Print("couldn't open %s\n", filename); + return; + } //end if + //white spaces and escape characters inside a string are not allowed + SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES | + SCFL_NOSTRINGESCAPECHARS | + SCFL_PRIMITIVE); + + nummapbrushsides = 0; + num_entities = 0; + + while (Q2_ParseMapEntity(script)) + { + } + + ClearBounds (map_mins, map_maxs); + for (i=0 ; i 4096) + continue; // no valid points + AddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs); + AddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs); + } //end for + + PrintMapInfo(); + + //free the script + FreeScript(script); +// TestExpandBrushes (); + // + Q2_CreateMapTexinfo(); +} //end of the function Q2_LoadMapFile + +#ifdef ME //Begin MAP loading from BSP file +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q2_SetLeafBrushesModelNumbers(int leafnum, int modelnum) +{ + +} //end of the function Q2_SetLeafBrushesModelNumbers +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q2_InitNodeStack(void) +{ + nodestackptr = nodestack; + nodestacksize = 0; +} //end of the function Q2_InitNodeStack +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q2_PushNodeStack(int num) +{ + *nodestackptr = num; + nodestackptr++; + nodestacksize++; + // + if (nodestackptr >= &nodestack[NODESTACKSIZE]) + { + Error("Q2_PushNodeStack: stack overflow\n"); + } //end if +} //end of the function Q2_PushNodeStack +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Q2_PopNodeStack(void) +{ + //if the stack is empty + if (nodestackptr <= nodestack) return -1; + //decrease stack pointer + nodestackptr--; + nodestacksize--; + //return the top value from the stack + return *nodestackptr; +} //end of the function Q2_PopNodeStack +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q2_SetBrushModelNumbers(entity_t *mapent) +{ + +} //end of the function Q2_SetBrushModelNumbers +//=========================================================================== +//=========================================================================== +void Q2_ParseBSPBrushes(entity_t *mapent) +{ + +} //end of the function Q2_ParseBSPBrushes +//=========================================================================== +//=========================================================================== +qboolean Q2_ParseBSPEntity(int entnum) +{ + + return true; +} //end of the function Q2_ParseBSPEntity +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q2_LoadMapFromBSP(char *filename, int offset, int length) +{ + +} //end of the function Q2_LoadMapFromBSP + +void Q2_ResetMapLoading(void) +{ + +} //end of the function Q2_ResetMapLoading + +//End MAP loading from BSP file +#endif //ME + +//==================================================================== + +/* +================ +TestExpandBrushes + +Expands all the brush planes and saves a new map out +================ +*/ +void TestExpandBrushes (void) +{ + +} //end of the function TestExpandBrushes + diff --git a/code/bspc/map_q3.c b/code/bspc/map_q3.c new file mode 100644 index 00000000..24bd6262 --- /dev/null +++ b/code/bspc/map_q3.c @@ -0,0 +1,697 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "l_mem.h" +#include "../botlib/aasfile.h" //aas_bbox_t +#include "aas_store.h" //AAS_MAX_BBOXES +#include "aas_cfg.h" +#include "aas_map.h" //AAS_CreateMapBrushes +#include "l_bsp_q3.h" +#include "../qcommon/cm_patch.h" +#include "../qcommon/surfaceflags.h" + +#define NODESTACKSIZE 1024 + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintContents(int contents); + +int Q3_BrushContents(mapbrush_t *b) +{ + int contents, i, mixed, hint; + side_t *s; + + s = &b->original_sides[0]; + contents = s->contents; + // + mixed = false; + hint = false; + for (i = 1; i < b->numsides; i++) + { + s = &b->original_sides[i]; + if (s->contents != contents) mixed = true; +#ifdef SURF_SKIP + if (s->surf & (SURF_HINT|SURF_SKIP)) hint = true; +#else + if (s->surf & (SURF_HINT)) hint = true; +#endif + contents |= s->contents; + } //end for + // + if (hint) + { + if (contents) + { + Log_Write("WARNING: hint brush with contents: "); + PrintContents(contents); + Log_Write("\r\n"); + // + Log_Write("brush contents is: "); + PrintContents(b->contents); + Log_Write("\r\n"); + } //end if + return 0; + } //end if + //Log_Write("brush %d contents ", nummapbrushes); + //PrintContents(contents); + //Log_Write("\r\n"); + //remove ladder and fog contents +#ifdef CONTENTS_LADDER + contents &= ~(CONTENTS_LADDER|CONTENTS_FOG); +#else + contents &= ~(CONTENTS_FOG); +#endif + // + if (mixed) + { + Log_Write("Entity %i, Brush %i: mixed face contents " + , b->entitynum, b->brushnum); + PrintContents(contents); + Log_Write("\r\n"); + // + Log_Write("brush contents is: "); + PrintContents(b->contents); + Log_Write("\r\n"); + // + if (contents & CONTENTS_DONOTENTER) return CONTENTS_DONOTENTER;//Log_Print("mixed contents with donotenter\n"); + /* + Log_Print("contents:"); PrintContents(contents); + Log_Print("\ncontents:"); PrintContents(s->contents); + Log_Print("\n"); + Log_Print("texture name = %s\n", texinfo[s->texinfo].texture); + */ + //if liquid brush + if (contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)) + { + return (contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)); + } //end if + if (contents & CONTENTS_PLAYERCLIP) return (contents & CONTENTS_PLAYERCLIP); + return (contents & CONTENTS_SOLID); + } //end if + /* + if (contents & CONTENTS_AREAPORTAL) + { + static int num; + Log_Write("Entity %i, Brush %i: area portal %d\r\n", b->entitynum, b->brushnum, num++); + } //end if*/ + if (contents == (contents & CONTENTS_STRUCTURAL)) + { + //Log_Print("brush %i is only structural\n", b->brushnum); + contents = 0; + } //end if + if (contents & CONTENTS_DONOTENTER) + { + Log_Print("brush %i is a donotenter brush, c = %X\n", b->brushnum, contents); + } //end if + return contents; +} //end of the function Q3_BrushContents +#define BBOX_NORMAL_EPSILON 0.0001 +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q3_DPlanes2MapPlanes(void) +{ + int i; + + for (i = 0; i < q3_numplanes; i++) + { + dplanes2mapplanes[i] = FindFloatPlane(dplanes[i].normal, dplanes[i].dist); + } //end for +} //end of the function Q3_DPlanes2MapPlanes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q3_BSPBrushToMapBrush(dbrush_t *bspbrush, entity_t *mapent) +{ + mapbrush_t *b; + int i, k, n; + side_t *side, *s2; + int planenum; + dbrushside_t *bspbrushside; + dplane_t *bspplane; + + if (nummapbrushes >= MAX_MAPFILE_BRUSHES) + Error ("nummapbrushes >= MAX_MAPFILE_BRUSHES"); + + b = &mapbrushes[nummapbrushes]; + b->original_sides = &brushsides[nummapbrushsides]; + b->entitynum = mapent-entities; + b->brushnum = nummapbrushes - mapent->firstbrush; + b->leafnum = dbrushleafnums[bspbrush - dbrushes]; + + for (n = 0; n < bspbrush->numSides; n++) + { + //pointer to the bsp brush side + bspbrushside = &dbrushsides[bspbrush->firstSide + n]; + + if (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES) + { + Error ("MAX_MAPFILE_BRUSHSIDES"); + } //end if + //pointer to the map brush side + side = &brushsides[nummapbrushsides]; + //if the BSP brush side is textured + if (dbrushsidetextured[bspbrush->firstSide + n]) side->flags |= SFL_TEXTURED|SFL_VISIBLE; + else side->flags &= ~SFL_TEXTURED; + //NOTE: all Quake3 sides are assumed textured + //side->flags |= SFL_TEXTURED|SFL_VISIBLE; + // + if (bspbrushside->shaderNum < 0) + { + side->contents = 0; + side->surf = 0; + } //end if + else + { + side->contents = dshaders[bspbrushside->shaderNum].contentFlags; + side->surf = dshaders[bspbrushside->shaderNum].surfaceFlags; + if (strstr(dshaders[bspbrushside->shaderNum].shader, "common/hint")) + { + //Log_Print("found hint side\n"); + side->surf |= SURF_HINT; + } //end if + } //end else + // + if (side->surf & SURF_NODRAW) + { + side->flags |= SFL_TEXTURED|SFL_VISIBLE; + } //end if + /* + if (side->contents & (CONTENTS_TRANSLUCENT|CONTENTS_STRUCTURAL)) + { + side->flags |= SFL_TEXTURED|SFL_VISIBLE; + } //end if*/ + + // hints and skips are never detail, and have no content +#ifdef SURF_SKIP + if (side->surf & (SURF_HINT|SURF_SKIP) ) +#else + if (side->surf & (SURF_HINT) ) +#endif + { + side->contents = 0; + //Log_Print("found hint brush side\n"); + } + /* + if ((side->surf & SURF_NODRAW) && (side->surf & SURF_NOIMPACT)) + { + side->contents = 0; + side->surf &= ~CONTENTS_DETAIL; + Log_Print("probably found hint brush in a BSP without hints being used\n"); + } //end if*/ + + //ME: get a plane for this side + bspplane = &dplanes[bspbrushside->planeNum]; + planenum = FindFloatPlane(bspplane->normal, bspplane->dist); + // + // see if the plane has been used already + // + //ME: this really shouldn't happen!!! + //ME: otherwise the bsp file is corrupted?? + //ME: still it seems to happen, maybe Johny Boy's + //ME: brush bevel adding is crappy ? + for (k = 0; k < b->numsides; k++) + { + s2 = b->original_sides + k; +// if (DotProduct (mapplanes[s2->planenum].normal, mapplanes[planenum].normal) > 0.999 +// && fabs(mapplanes[s2->planenum].dist - mapplanes[planenum].dist) < 0.01 ) + + if (s2->planenum == planenum) + { + Log_Print("Entity %i, Brush %i: duplicate plane\n" + , b->entitynum, b->brushnum); + break; + } + if ( s2->planenum == (planenum^1) ) + { + Log_Print("Entity %i, Brush %i: mirrored plane\n" + , b->entitynum, b->brushnum); + break; + } + } + if (k != b->numsides) + continue; // duplicated + + // + // keep this side + // + //ME: reset pointer to side, why? hell I dunno (pointer is set above already) + side = b->original_sides + b->numsides; + //ME: store the plane number + side->planenum = planenum; + //ME: texinfo is already stored when bsp is loaded + //NOTE: check for TEXINFO_NODE, otherwise crash in Q3_BrushContents + //if (bspbrushside->texinfo < 0) side->texinfo = 0; + //else side->texinfo = bspbrushside->texinfo; + + // save the td off in case there is an origin brush and we + // have to recalculate the texinfo + // ME: don't need to recalculate because it's already done + // (for non-world entities) in the BSP file +// side_brushtextures[nummapbrushsides] = td; + + nummapbrushsides++; + b->numsides++; + } //end for + + // get the content for the entire brush + b->contents = dshaders[bspbrush->shaderNum].contentFlags; + b->contents &= ~( +#ifdef CONTENTS_LADDER + CONTENTS_LADDER| +#endif + CONTENTS_FOG|CONTENTS_STRUCTURAL); +// b->contents = Q3_BrushContents(b); + // + + if (BrushExists(b)) + { + c_squattbrushes++; + b->numsides = 0; + return; + } //end if + + //if we're creating AAS + if (create_aas) + { + //create the AAS brushes from this brush, don't add brush bevels + AAS_CreateMapBrushes(b, mapent, false); + return; + } //end if + + // allow detail brushes to be removed + if (nodetail && (b->contents & CONTENTS_DETAIL) ) + { + b->numsides = 0; + return; + } //end if + + // allow water brushes to be removed + if (nowater && (b->contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)) ) + { + b->numsides = 0; + return; + } //end if + + // create windings for sides and bounds for brush + MakeBrushWindings(b); + + //mark brushes without winding or with a tiny window as bevels + MarkBrushBevels(b); + + // brushes that will not be visible at all will never be + // used as bsp splitters + if (b->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) ) + { + c_clipbrushes++; + for (i = 0; i < b->numsides; i++) + b->original_sides[i].texinfo = TEXINFO_NODE; + } //end for + + // + // origin brushes are removed, but they set + // the rotation origin for the rest of the brushes + // in the entity. After the entire entity is parsed, + // the planenums and texinfos will be adjusted for + // the origin brush + // + //ME: not needed because the entities in the BSP file already + // have an origin set +// if (b->contents & CONTENTS_ORIGIN) +// { +// char string[32]; +// vec3_t origin; +// +// if (num_entities == 1) +// { +// Error ("Entity %i, Brush %i: origin brushes not allowed in world" +// , b->entitynum, b->brushnum); +// return; +// } +// +// VectorAdd (b->mins, b->maxs, origin); +// VectorScale (origin, 0.5, origin); +// +// sprintf (string, "%i %i %i", (int)origin[0], (int)origin[1], (int)origin[2]); +// SetKeyValue (&entities[b->entitynum], "origin", string); +// +// VectorCopy (origin, entities[b->entitynum].origin); +// +// // don't keep this brush +// b->numsides = 0; +// +// return; +// } + + //ME: the bsp brushes already have bevels, so we won't try to + // add them again (especially since Johny Boy's bevel adding might + // be crappy) +// AddBrushBevels(b); + + nummapbrushes++; + mapent->numbrushes++; +} //end of the function Q3_BSPBrushToMapBrush +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q3_ParseBSPBrushes(entity_t *mapent) +{ + int i; + + for (i = 0; i < dmodels[mapent->modelnum].numBrushes; i++) + { + Q3_BSPBrushToMapBrush(&dbrushes[dmodels[mapent->modelnum].firstBrush + i], mapent); + } //end for +} //end of the function Q3_ParseBSPBrushes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean Q3_ParseBSPEntity(int entnum) +{ + entity_t *mapent; + char *model; + int startbrush, startsides; + + startbrush = nummapbrushes; + startsides = nummapbrushsides; + + mapent = &entities[entnum];//num_entities]; + mapent->firstbrush = nummapbrushes; + mapent->numbrushes = 0; + mapent->modelnum = -1; //-1 = no BSP model + + model = ValueForKey(mapent, "model"); + if (model && strlen(model)) + { + if (*model == '*') + { + //get the model number of this entity (skip the leading *) + mapent->modelnum = atoi(&model[1]); + } //end if + } //end if + + GetVectorForKey(mapent, "origin", mapent->origin); + + //if this is the world entity it has model number zero + //the world entity has no model key + if (!strcmp("worldspawn", ValueForKey(mapent, "classname"))) + { + mapent->modelnum = 0; + } //end if + //if the map entity has a BSP model (a modelnum of -1 is used for + //entities that aren't using a BSP model) + if (mapent->modelnum >= 0) + { + //parse the bsp brushes + Q3_ParseBSPBrushes(mapent); + } //end if + // + //the origin of the entity is already taken into account + // + //func_group entities can't be in the bsp file + // + //check out the func_areaportal entities + if (!strcmp ("func_areaportal", ValueForKey (mapent, "classname"))) + { + c_areaportals++; + mapent->areaportalnum = c_areaportals; + return true; + } //end if + return true; +} //end of the function Q3_ParseBSPEntity +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#define MAX_PATCH_VERTS 1024 + +void AAS_CreateCurveBrushes(void) +{ + int i, j, n, planenum, numcurvebrushes = 0; + dsurface_t *surface; + drawVert_t *dv_p; + vec3_t points[MAX_PATCH_VERTS]; + int width, height, c; + patchCollide_t *pc; + facet_t *facet; + mapbrush_t *brush; + side_t *side; + entity_t *mapent; + winding_t *winding; + + qprintf("nummapbrushsides = %d\n", nummapbrushsides); + mapent = &entities[0]; + for (i = 0; i < q3_numDrawSurfaces; i++) + { + surface = &drawSurfaces[i]; + if ( ! surface->patchWidth ) continue; + // if the curve is not solid + if (!(dshaders[surface->shaderNum].contentFlags & (CONTENTS_SOLID|CONTENTS_PLAYERCLIP))) + { + //Log_Print("skipped non-solid curve\n"); + continue; + } //end if + // if this curve should not be used for AAS + if ( dshaders[surface->shaderNum].contentFlags & CONTENTS_NOBOTCLIP ) { + continue; + } + // + width = surface->patchWidth; + height = surface->patchHeight; + c = width * height; + if (c > MAX_PATCH_VERTS) + { + Error("ParseMesh: MAX_PATCH_VERTS"); + } //end if + + dv_p = drawVerts + surface->firstVert; + for ( j = 0 ; j < c ; j++, dv_p++ ) + { + points[j][0] = dv_p->xyz[0]; + points[j][1] = dv_p->xyz[1]; + points[j][2] = dv_p->xyz[2]; + } //end for + // create the internal facet structure + pc = CM_GeneratePatchCollide(width, height, points); + // + for (j = 0; j < pc->numFacets; j++) + { + facet = &pc->facets[j]; + // + brush = &mapbrushes[nummapbrushes]; + brush->original_sides = &brushsides[nummapbrushsides]; + brush->entitynum = 0; + brush->brushnum = nummapbrushes - mapent->firstbrush; + // + brush->numsides = facet->numBorders + 2; + nummapbrushsides += brush->numsides; + brush->contents = CONTENTS_SOLID; + // + //qprintf("\r%6d curve brushes", nummapbrushsides);//++numcurvebrushes); + qprintf("\r%6d curve brushes", ++numcurvebrushes); + // + planenum = FindFloatPlane(pc->planes[facet->surfacePlane].plane, pc->planes[facet->surfacePlane].plane[3]); + // + side = &brush->original_sides[0]; + side->planenum = planenum; + side->contents = CONTENTS_SOLID; + side->flags |= SFL_TEXTURED|SFL_VISIBLE|SFL_CURVE; + side->surf = 0; + // + side = &brush->original_sides[1]; + if (create_aas) + { + //the plane is expanded later so it's not a problem that + //these first two opposite sides are coplanar + side->planenum = planenum ^ 1; + } //end if + else + { + side->planenum = FindFloatPlane(mapplanes[planenum^1].normal, mapplanes[planenum^1].dist + 1); + side->flags |= SFL_TEXTURED|SFL_VISIBLE; + } //end else + side->contents = CONTENTS_SOLID; + side->flags |= SFL_CURVE; + side->surf = 0; + // + winding = BaseWindingForPlane(mapplanes[side->planenum].normal, mapplanes[side->planenum].dist); + for (n = 0; n < facet->numBorders; n++) + { + //never use the surface plane as a border + if (facet->borderPlanes[n] == facet->surfacePlane) continue; + // + side = &brush->original_sides[2 + n]; + side->planenum = FindFloatPlane(pc->planes[facet->borderPlanes[n]].plane, pc->planes[facet->borderPlanes[n]].plane[3]); + if (facet->borderInward[n]) side->planenum ^= 1; + side->contents = CONTENTS_SOLID; + side->flags |= SFL_TEXTURED|SFL_CURVE; + side->surf = 0; + //chop the winding in place + if (winding) ChopWindingInPlace(&winding, mapplanes[side->planenum^1].normal, mapplanes[side->planenum^1].dist, 0.1); //CLIP_EPSILON); + } //end for + //VectorCopy(pc->bounds[0], brush->mins); + //VectorCopy(pc->bounds[1], brush->maxs); + if (!winding) + { + Log_Print("WARNING: AAS_CreateCurveBrushes: no winding\n"); + brush->numsides = 0; + continue; + } //end if + brush->original_sides[0].winding = winding; + WindingBounds(winding, brush->mins, brush->maxs); + for (n = 0; n < 3; n++) + { + //IDBUG: all the indexes into the mins and maxs were zero (not using i) + if (brush->mins[n] < -MAX_MAP_BOUNDS || brush->maxs[n] > MAX_MAP_BOUNDS) + { + Log_Print("entity %i, brush %i: bounds out of range\n", brush->entitynum, brush->brushnum); + Log_Print("brush->mins[%d] = %f, brush->maxs[%d] = %f\n", n, brush->mins[n], n, brush->maxs[n]); + brush->numsides = 0; //remove the brush + break; + } //end if + if (brush->mins[n] > MAX_MAP_BOUNDS || brush->maxs[n] < -MAX_MAP_BOUNDS) + { + Log_Print("entity %i, brush %i: no visible sides on brush\n", brush->entitynum, brush->brushnum); + Log_Print("brush->mins[%d] = %f, brush->maxs[%d] = %f\n", n, brush->mins[n], n, brush->maxs[n]); + brush->numsides = 0; //remove the brush + break; + } //end if + } //end for + if (create_aas) + { + //NOTE: brush bevels now already added + //AddBrushBevels(brush); + AAS_CreateMapBrushes(brush, mapent, false); + } //end if + else + { + // create windings for sides and bounds for brush + MakeBrushWindings(brush); + AddBrushBevels(brush); + nummapbrushes++; + mapent->numbrushes++; + } //end else + } //end for + } //end for + //qprintf("\r%6d curve brushes", nummapbrushsides);//++numcurvebrushes); + qprintf("\r%6d curve brushes\n", numcurvebrushes); +} //end of the function AAS_CreateCurveBrushes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AAS_ExpandMapBrush(mapbrush_t *brush, vec3_t mins, vec3_t maxs); + +void Q3_LoadMapFromBSP(struct quakefile_s *qf) +{ + int i; + vec3_t mins = {-1,-1,-1}, maxs = {1, 1, 1}; + + Log_Print("-- Q3_LoadMapFromBSP --\n"); + //loaded map type + loadedmaptype = MAPTYPE_QUAKE3; + + Log_Print("Loading map from %s...\n", qf->filename); + //load the bsp file + Q3_LoadBSPFile(qf); + + //create an index from bsp planes to map planes + //DPlanes2MapPlanes(); + //clear brush model numbers + for (i = 0; i < MAX_MAPFILE_BRUSHES; i++) + brushmodelnumbers[i] = -1; + + nummapbrushsides = 0; + num_entities = 0; + + Q3_ParseEntities(); + // + for (i = 0; i < num_entities; i++) + { + Q3_ParseBSPEntity(i); + } //end for + + AAS_CreateCurveBrushes(); + //get the map mins and maxs from the world model + ClearBounds(map_mins, map_maxs); + for (i = 0; i < entities[0].numbrushes; i++) + { + if (mapbrushes[i].numsides <= 0) + continue; + AddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs); + AddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs); + } //end for + /*/ + for (i = 0; i < nummapbrushes; i++) + { + //if (!mapbrushes[i].original_sides) continue; + //AddBrushBevels(&mapbrushes[i]); + //AAS_ExpandMapBrush(&mapbrushes[i], mins, maxs); + } //end for*/ + /* + for (i = 0; i < nummapbrushsides; i++) + { + Log_Write("side %d flags = %d", i, brushsides[i].flags); + } //end for + for (i = 0; i < nummapbrushes; i++) + { + Log_Write("brush contents: "); + PrintContents(mapbrushes[i].contents); + Log_Print("\n"); + } //end for*/ +} //end of the function Q3_LoadMapFromBSP +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Q3_ResetMapLoading(void) +{ + //reset for map loading from bsp + memset(nodestack, 0, NODESTACKSIZE * sizeof(int)); + nodestackptr = NULL; + nodestacksize = 0; + memset(brushmodelnumbers, 0, MAX_MAPFILE_BRUSHES * sizeof(int)); +} //end of the function Q3_ResetMapLoading + diff --git a/code/bspc/map_sin.c b/code/bspc/map_sin.c new file mode 100644 index 00000000..7ac377cb --- /dev/null +++ b/code/bspc/map_sin.c @@ -0,0 +1,1211 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ +//----------------------------------------------------------------------------- +// +// $Logfile:: /MissionPack/code/bspc/map_sin.c $ + +#include "qbsp.h" +#include "l_bsp_sin.h" +#include "aas_map.h" //AAS_CreateMapBrushes + + +//==================================================================== + + +/* +=========== +Sin_BrushContents +=========== +*/ + +int Sin_BrushContents(mapbrush_t *b) +{ + int contents; + side_t *s; + int i; +#ifdef SIN + float trans = 0; +#else + int trans; +#endif + + s = &b->original_sides[0]; + contents = s->contents; + +#ifdef SIN + trans = sin_texinfo[s->texinfo].translucence; +#else + trans = texinfo[s->texinfo].flags; +#endif + for (i=1 ; inumsides ; i++, s++) + { + s = &b->original_sides[i]; +#ifdef SIN + trans += sin_texinfo[s->texinfo].translucence; +#else + trans |= texinfo[s->texinfo].flags; +#endif + if (s->contents != contents) + { +#ifdef SIN + if ( + ( s->contents & CONTENTS_DETAIL && !(contents & CONTENTS_DETAIL) ) || + ( !(s->contents & CONTENTS_DETAIL) && contents & CONTENTS_DETAIL ) + ) + { + s->contents |= CONTENTS_DETAIL; + contents |= CONTENTS_DETAIL; + continue; + } +#endif + printf ("Entity %i, Brush %i: mixed face contents\n" + , b->entitynum, b->brushnum); + break; + } + } + + +#ifdef SIN + if (contents & CONTENTS_FENCE) + { +// contents |= CONTENTS_TRANSLUCENT; + contents |= CONTENTS_DETAIL; + contents |= CONTENTS_DUMMYFENCE; + contents &= ~CONTENTS_SOLID; + contents &= ~CONTENTS_FENCE; +// contents |= CONTENTS_WINDOW; + } +#endif + + // if any side is translucent, mark the contents + // and change solid to window +#ifdef SIN + if ( trans > 0 ) +#else + if ( trans & (SURF_TRANS33|SURF_TRANS66) ) +#endif + { +/// contents |= CONTENTS_Q2TRANSLUCENT; + if (contents & CONTENTS_SOLID) + { + contents &= ~CONTENTS_SOLID; +// contents |= CONTENTS_WINDOW; + } + } + + return contents; +} //*/ + + +//============================================================================ + + + +/* +================= +ParseBrush +================= +* / +void ParseBrush (entity_t *mapent) +{ + mapbrush_t *b; + int i,j, k; + int mt; + side_t *side, *s2; + int planenum; + brush_texture_t td; +#ifdef SIN + textureref_t newref; +#endif + int planepts[3][3]; + + if (nummapbrushes == MAX_MAP_BRUSHES) + Error ("nummapbrushes == MAX_MAP_BRUSHES"); + + b = &mapbrushes[nummapbrushes]; + b->original_sides = &brushsides[nummapbrushsides]; + b->entitynum = num_entities-1; + b->brushnum = nummapbrushes - mapent->firstbrush; + + do + { + if (!GetToken (true)) + break; + if (!strcmp (token, "}") ) + break; + + if (nummapbrushsides == MAX_MAP_BRUSHSIDES) + Error ("MAX_MAP_BRUSHSIDES"); + side = &brushsides[nummapbrushsides]; + + // read the three point plane definition + for (i=0 ; i<3 ; i++) + { + if (i != 0) + GetToken (true); + if (strcmp (token, "(") ) + Error ("parsing brush"); + + for (j=0 ; j<3 ; j++) + { + GetToken (false); + planepts[i][j] = atoi(token); + } + + GetToken (false); + if (strcmp (token, ")") ) + Error ("parsing brush"); + + } + + + // + // read the texturedef + // + GetToken (false); + strcpy (td.name, token); + + GetToken (false); + td.shift[0] = atoi(token); + GetToken (false); + td.shift[1] = atoi(token); + GetToken (false); +#ifdef SIN + td.rotate = atof(token); +#else + td.rotate = atoi(token); +#endif + GetToken (false); + td.scale[0] = atof(token); + GetToken (false); + td.scale[1] = atof(token); + + // find default flags and values + mt = FindMiptex (td.name); +#ifdef SIN + // clear out the masks on newref + memset(&newref,0,sizeof(newref)); + // copy over the name + strcpy( newref.name, td.name ); + + ParseSurfaceInfo( &newref ); + MergeRefs( &bsp_textureref[mt], &newref, &td.tref ); + side->contents = td.tref.contents; + side->surf = td.tref.flags; +#else + td.flags = textureref[mt].flags; + td.value = textureref[mt].value; + side->contents = textureref[mt].contents; + side->surf = td.flags = textureref[mt].flags; + + if (TokenAvailable()) + { + GetToken (false); + side->contents = atoi(token); + GetToken (false); + side->surf = td.flags = atoi(token); + GetToken (false); + td.value = atoi(token); + } +#endif + + // translucent objects are automatically classified as detail +#ifdef SIN + if ( td.tref.translucence > 0 ) +#else + if (side->surf & (SURF_TRANS33|SURF_TRANS66) ) +#endif + side->contents |= CONTENTS_DETAIL; + if (side->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) ) + side->contents |= CONTENTS_DETAIL; + if (fulldetail) + side->contents &= ~CONTENTS_DETAIL; + if (!(side->contents & ((LAST_VISIBLE_CONTENTS-1) + | CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP|CONTENTS_MIST) ) ) + side->contents |= CONTENTS_SOLID; + + // hints and skips are never detail, and have no content + if (side->surf & (SURF_HINT|SURF_SKIP) ) + { + side->contents = 0; +#ifndef SIN // I think this is a bug of some kind + side->surf &= ~CONTENTS_DETAIL; +#endif + } + + // + // find the plane number + // + planenum = PlaneFromPoints (planepts[0], planepts[1], planepts[2]); + if (planenum == -1) + { + printf ("Entity %i, Brush %i: plane with no normal\n" + , b->entitynum, b->brushnum); + continue; + } + + // + // see if the plane has been used already + // + for (k=0 ; knumsides ; k++) + { + s2 = b->original_sides + k; + if (s2->planenum == planenum) + { + printf ("Entity %i, Brush %i: duplicate plane\n" + , b->entitynum, b->brushnum); + break; + } + if ( s2->planenum == (planenum^1) ) + { + printf ("Entity %i, Brush %i: mirrored plane\n" + , b->entitynum, b->brushnum); + break; + } + } + if (k != b->numsides) + continue; // duplicated + + // + // keep this side + // + + side = b->original_sides + b->numsides; + side->planenum = planenum; +#ifdef SIN + side->texinfo = TexinfoForBrushTexture (&mapplanes[planenum], + &td, vec3_origin, &newref); + // + // save off lightinfo + // + side->lightinfo = LightinfoForBrushTexture ( &td ); +#else + side->texinfo = TexinfoForBrushTexture (&mapplanes[planenum], + &td, vec3_origin); + +#endif + + // save the td off in case there is an origin brush and we + // have to recalculate the texinfo + side_brushtextures[nummapbrushsides] = td; +#ifdef SIN + // save off the merged tref for animating textures + side_newrefs[nummapbrushsides] = newref; +#endif + + nummapbrushsides++; + b->numsides++; + } while (1); + + // get the content for the entire brush + b->contents = Sin_BrushContents (b); + + // allow detail brushes to be removed + if (nodetail && (b->contents & CONTENTS_DETAIL) ) + { + b->numsides = 0; + return; + } + + // allow water brushes to be removed + if (nowater && (b->contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)) ) + { + b->numsides = 0; + return; + } + + // create windings for sides and bounds for brush + MakeBrushWindings (b); + + // brushes that will not be visible at all will never be + // used as bsp splitters + if (b->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) ) + { + c_clipbrushes++; + for (i=0 ; inumsides ; i++) + b->original_sides[i].texinfo = TEXINFO_NODE; + } + + // + // origin brushes are removed, but they set + // the rotation origin for the rest of the brushes + // in the entity. After the entire entity is parsed, + // the planenums and texinfos will be adjusted for + // the origin brush + // + if (b->contents & CONTENTS_ORIGIN) + { + char string[32]; + vec3_t origin; + + if (num_entities == 1) + { + Error ("Entity %i, Brush %i: origin brushes not allowed in world" + , b->entitynum, b->brushnum); + return; + } + + VectorAdd (b->mins, b->maxs, origin); + VectorScale (origin, 0.5, origin); + + sprintf (string, "%i %i %i", (int)origin[0], (int)origin[1], (int)origin[2]); + SetKeyValue (&entities[b->entitynum], "origin", string); + + VectorCopy (origin, entities[b->entitynum].origin); + + // don't keep this brush + b->numsides = 0; + + return; + } + + AddBrushBevels (b); + + nummapbrushes++; + mapent->numbrushes++; +} //*/ + +/* +================ +MoveBrushesToWorld + +Takes all of the brushes from the current entity and +adds them to the world's brush list. + +Used by func_group and func_areaportal +================ +* / +void MoveBrushesToWorld (entity_t *mapent) +{ + int newbrushes; + int worldbrushes; + mapbrush_t *temp; + int i; + + // this is pretty gross, because the brushes are expected to be + // in linear order for each entity + + newbrushes = mapent->numbrushes; + worldbrushes = entities[0].numbrushes; + + temp = malloc(newbrushes*sizeof(mapbrush_t)); + memcpy (temp, mapbrushes + mapent->firstbrush, newbrushes*sizeof(mapbrush_t)); + +#if 0 // let them keep their original brush numbers + for (i=0 ; inumbrushes = 0; +} //*/ + +/* +================ +ParseMapEntity +================ +* / +qboolean Sin_ParseMapEntity (void) +{ + entity_t *mapent; + epair_t *e; + side_t *s; + int i, j; + int startbrush, startsides; + vec_t newdist; + mapbrush_t *b; + + if (!GetToken (true)) + return false; + + if (strcmp (token, "{") ) + Error ("ParseEntity: { not found"); + + if (num_entities == MAX_MAP_ENTITIES) + Error ("num_entities == MAX_MAP_ENTITIES"); + + startbrush = nummapbrushes; + startsides = nummapbrushsides; + + mapent = &entities[num_entities]; + num_entities++; + memset (mapent, 0, sizeof(*mapent)); + mapent->firstbrush = nummapbrushes; + mapent->numbrushes = 0; +// mapent->portalareas[0] = -1; +// mapent->portalareas[1] = -1; + + do + { + if (!GetToken (true)) + Error ("ParseEntity: EOF without closing brace"); + if (!strcmp (token, "}") ) + break; + if (!strcmp (token, "{") ) + ParseBrush (mapent); + else + { + e = ParseEpair (); +#ifdef SIN + //HACK HACK HACK + // MED Gotta do this here + if ( !stricmp(e->key, "surfacefile") ) + { + if (!surfacefile[0]) + { + strcpy( surfacefile, e->value ); + } + printf ("--- ParseSurfaceFile ---\n"); + printf ("Surface script: %s\n", surfacefile); + if (!ParseSurfaceFile(surfacefile)) + { + Error ("Script file not found: %s\n", surfacefile); + } + } +#endif + e->next = mapent->epairs; + mapent->epairs = e; + } + } while (1); + +#ifdef SIN + if (!(strlen(ValueForKey(mapent, "origin"))) && ((num_entities-1) != 0)) + { + mapbrush_t *brush; + vec3_t origin; + char string[32]; + vec3_t mins, maxs; + int start, end; + // Calculate bounds + + start = mapent->firstbrush; + end = start + mapent->numbrushes; + ClearBounds (mins, maxs); + + for (j=start ; jnumsides) + continue; // not a real brush (origin brush) - shouldn't happen + AddPointToBounds (brush->mins, mins, maxs); + AddPointToBounds (brush->maxs, mins, maxs); + } + + // Set the origin to be the centroid of the entity. + VectorAdd ( mins, maxs, origin); + VectorScale( origin, 0.5f, origin ); + + sprintf (string, "%i %i %i", (int)origin[0], (int)origin[1], (int)origin[2]); + SetKeyValue ( mapent, "origin", string); +// qprintf("Setting origin to %s\n",string); + } +#endif + + GetVectorForKey (mapent, "origin", mapent->origin); + +#ifdef SIN + if ( + (!strcmp ("func_areaportal", ValueForKey (mapent, "classname"))) || + (!strcmp ("func_group", ValueForKey (mapent, "classname"))) || + (!strcmp ("detail", ValueForKey (mapent, "classname")) && !entitydetails) + ) + { + VectorClear( mapent->origin ); + } +#endif + + // + // if there was an origin brush, offset all of the planes and texinfo + // + if (mapent->origin[0] || mapent->origin[1] || mapent->origin[2]) + { + for (i=0 ; inumbrushes ; i++) + { + b = &mapbrushes[mapent->firstbrush + i]; + for (j=0 ; jnumsides ; j++) + { + s = &b->original_sides[j]; + newdist = mapplanes[s->planenum].dist - + DotProduct (mapplanes[s->planenum].normal, mapent->origin); + s->planenum = FindFloatPlane (mapplanes[s->planenum].normal, newdist); +#ifdef SIN + s->texinfo = TexinfoForBrushTexture (&mapplanes[s->planenum], + &side_brushtextures[s-brushsides], mapent->origin, &side_newrefs[s-brushsides]); + // + // save off lightinfo + // + s->lightinfo = LightinfoForBrushTexture ( &side_brushtextures[s-brushsides] ); +#else + s->texinfo = TexinfoForBrushTexture (&mapplanes[s->planenum], + &side_brushtextures[s-brushsides], mapent->origin); +#endif + } + MakeBrushWindings (b); + } + } + + // group entities are just for editor convenience + // toss all brushes into the world entity + if (!strcmp ("func_group", ValueForKey (mapent, "classname"))) + { + MoveBrushesToWorld (mapent); + mapent->numbrushes = 0; + mapent->wasdetail = true; + FreeValueKeys( mapent ); + return true; + } +#ifdef SIN + // detail entities are just for editor convenience + // toss all brushes into the world entity as detail brushes + if (!strcmp ("detail", ValueForKey (mapent, "classname")) && !entitydetails) + { + for (i=0 ; inumbrushes ; i++) + { + int j; + side_t * s; + b = &mapbrushes[mapent->firstbrush + i]; + if (nodetail) + { + b->numsides = 0; + continue; + } + if (!fulldetail) + { + // set the contents for the entire brush + b->contents |= CONTENTS_DETAIL; + // set the contents in the sides as well + for (j=0, s=b->original_sides ; jnumsides ; j++,s++) + { + s->contents |= CONTENTS_DETAIL; + } + } + else + { + // set the contents for the entire brush + b->contents |= CONTENTS_SOLID; + // set the contents in the sides as well + for (j=0, s=b->original_sides ; jnumsides ; j++,s++) + { + s->contents |= CONTENTS_SOLID; + } + } + } + MoveBrushesToWorld (mapent); + mapent->wasdetail = true; + FreeValueKeys( mapent ); + // kill off the entity + // num_entities--; + return true; + } +#endif + + // areaportal entities move their brushes, but don't eliminate + // the entity + if (!strcmp ("func_areaportal", ValueForKey (mapent, "classname"))) + { + char str[128]; + + if (mapent->numbrushes != 1) + Error ("Entity %i: func_areaportal can only be a single brush", num_entities-1); + + b = &mapbrushes[nummapbrushes-1]; + b->contents = CONTENTS_AREAPORTAL; + c_areaportals++; + mapent->areaportalnum = c_areaportals; + // set the portal number as "style" + sprintf (str, "%i", c_areaportals); + SetKeyValue (mapent, "style", str); + MoveBrushesToWorld (mapent); + return true; + } + + return true; +} //end of the function Sin_ParseMapEntity */ + +//=================================================================== + +/* +================ +LoadMapFile +================ +* / +void Sin_LoadMapFile (char *filename) +{ + int i; +#ifdef SIN + int num_detailsides=0; + int num_detailbrushes=0; + int num_worldsides=0; + int num_worldbrushes=0; + int j,k; +#endif + + qprintf ("--- LoadMapFile ---\n"); + + LoadScriptFile (filename); + + nummapbrushsides = 0; + num_entities = 0; + + while (ParseMapEntity ()) + { + } + + ClearBounds (map_mins, map_maxs); + for (i=0 ; i 4096) + continue; // no valid points + AddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs); + AddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs); + } +#ifdef SIN + for (j=0; jnumsides && b->contents & CONTENTS_DETAIL) + num_detailbrushes++; + else if (b->numsides) + num_worldbrushes++; + for (k=0, s=b->original_sides ; knumsides ; k++,s++) + { + if (s->contents & CONTENTS_DETAIL) + num_detailsides++; + else + num_worldsides++; + } + } + } +#endif + + qprintf ("%5i brushes\n", nummapbrushes); + qprintf ("%5i clipbrushes\n", c_clipbrushes); + qprintf ("%5i total sides\n", nummapbrushsides); + qprintf ("%5i boxbevels\n", c_boxbevels); + qprintf ("%5i edgebevels\n", c_edgebevels); + qprintf ("%5i entities\n", num_entities); + qprintf ("%5i planes\n", nummapplanes); + qprintf ("%5i areaportals\n", c_areaportals); + qprintf ("size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\n", map_mins[0],map_mins[1],map_mins[2], + map_maxs[0],map_maxs[1],map_maxs[2]); +#ifdef SIN + qprintf ("%5i detailbrushes\n", num_detailbrushes); + qprintf ("%5i worldbrushes\n", num_worldbrushes); + qprintf ("%5i detailsides\n", num_detailsides); + qprintf ("%5i worldsides\n", num_worldsides); +#endif + +} //end of the function Sin_LoadMap */ + + +#ifdef ME //Begin MAP loading from BSP file +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Sin_CreateMapTexinfo(void) +{ + int i; + vec_t defaultvec[4] = {1, 0, 0, 0}; + + memcpy(map_texinfo[0].vecs[0], defaultvec, sizeof(defaultvec)); + memcpy(map_texinfo[0].vecs[1], defaultvec, sizeof(defaultvec)); + map_texinfo[0].flags = 0; + map_texinfo[0].value = 0; + strcpy(map_texinfo[0].texture, "generic/misc/red"); //no texture + map_texinfo[0].nexttexinfo = -1; + for (i = 1; i < sin_numtexinfo; i++) + { + memcpy(map_texinfo[i].vecs, sin_texinfo[i].vecs, sizeof(float) * 2 * 4); + map_texinfo[i].flags = sin_texinfo[i].flags; + map_texinfo[i].value = 0; + strcpy(map_texinfo[i].texture, sin_texinfo[i].texture); + map_texinfo[i].nexttexinfo = -1; + } //end for +} //end of the function Sin_CreateMapTexinfo +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Sin_SetLeafBrushesModelNumbers(int leafnum, int modelnum) +{ + int i, brushnum; + sin_dleaf_t *leaf; + + leaf = &sin_dleafs[leafnum]; + for (i = 0; i < leaf->numleafbrushes; i++) + { + brushnum = sin_dleafbrushes[leaf->firstleafbrush + i]; + brushmodelnumbers[brushnum] = modelnum; + dbrushleafnums[brushnum] = leafnum; + } //end for +} //end of the function Sin_SetLeafBrushesModelNumbers +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Sin_InitNodeStack(void) +{ + nodestackptr = nodestack; + nodestacksize = 0; +} //end of the function Sin_InitNodeStack +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Sin_PushNodeStack(int num) +{ + *nodestackptr = num; + nodestackptr++; + nodestacksize++; + // + if (nodestackptr >= &nodestack[NODESTACKSIZE]) + { + Error("Sin_PushNodeStack: stack overflow\n"); + } //end if +} //end of the function Sin_PushNodeStack +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int Sin_PopNodeStack(void) +{ + //if the stack is empty + if (nodestackptr <= nodestack) return -1; + //decrease stack pointer + nodestackptr--; + nodestacksize--; + //return the top value from the stack + return *nodestackptr; +} //end of the function Sin_PopNodeStack +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Sin_SetBrushModelNumbers(entity_t *mapent) +{ + int n, pn; + int leafnum; + + // + Sin_InitNodeStack(); + //head node (root) of the bsp tree + n = sin_dmodels[mapent->modelnum].headnode; + pn = 0; + + do + { + //if we are in a leaf (negative node number) + if (n < 0) + { + //number of the leaf + leafnum = (-n) - 1; + //set the brush numbers + Sin_SetLeafBrushesModelNumbers(leafnum, mapent->modelnum); + //walk back into the tree to find a second child to continue with + for (pn = Sin_PopNodeStack(); pn >= 0; n = pn, pn = Sin_PopNodeStack()) + { + //if we took the first child at the parent node + if (sin_dnodes[pn].children[0] == n) break; + } //end for + //if the stack wasn't empty (if not processed whole tree) + if (pn >= 0) + { + //push the parent node again + Sin_PushNodeStack(pn); + //we proceed with the second child of the parent node + n = sin_dnodes[pn].children[1]; + } //end if + } //end if + else + { + //push the current node onto the stack + Sin_PushNodeStack(n); + //walk forward into the tree to the first child + n = sin_dnodes[n].children[0]; + } //end else + } while(pn >= 0); +} //end of the function Sin_SetBrushModelNumbers +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Sin_BSPBrushToMapBrush(sin_dbrush_t *bspbrush, entity_t *mapent) +{ + mapbrush_t *b; + int i, k, n; + side_t *side, *s2; + int planenum; + sin_dbrushside_t *bspbrushside; + sin_dplane_t *bspplane; + + if (nummapbrushes >= MAX_MAPFILE_BRUSHES) + Error ("nummapbrushes >= MAX_MAPFILE_BRUSHES"); + + b = &mapbrushes[nummapbrushes]; + b->original_sides = &brushsides[nummapbrushsides]; + b->entitynum = mapent-entities; + b->brushnum = nummapbrushes - mapent->firstbrush; + b->leafnum = dbrushleafnums[bspbrush - sin_dbrushes]; + + for (n = 0; n < bspbrush->numsides; n++) + { + //pointer to the bsp brush side + bspbrushside = &sin_dbrushsides[bspbrush->firstside + n]; + + if (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES) + { + Error ("MAX_MAPFILE_BRUSHSIDES"); + } //end if + //pointer to the map brush side + side = &brushsides[nummapbrushsides]; + //if the BSP brush side is textured + if (sin_dbrushsidetextured[bspbrush->firstside + n]) side->flags |= SFL_TEXTURED; + else side->flags &= ~SFL_TEXTURED; + //ME: can get side contents and surf directly from BSP file + side->contents = bspbrush->contents; + //if the texinfo is TEXINFO_NODE + if (bspbrushside->texinfo < 0) side->surf = 0; + else side->surf = sin_texinfo[bspbrushside->texinfo].flags; + + // translucent objects are automatically classified as detail +// if (side->surf & (SURF_TRANS33|SURF_TRANS66) ) +// side->contents |= CONTENTS_DETAIL; + if (side->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) ) + side->contents |= CONTENTS_DETAIL; + if (fulldetail) + side->contents &= ~CONTENTS_DETAIL; +// if (!(side->contents & ((LAST_VISIBLE_CONTENTS-1) + // | CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP|CONTENTS_MIST) ) ) + // side->contents |= CONTENTS_SOLID; + + // hints and skips are never detail, and have no content + if (side->surf & (SURF_HINT|SURF_SKIP) ) + { + side->contents = 0; + side->surf &= ~CONTENTS_DETAIL; + } + + //ME: get a plane for this side + bspplane = &sin_dplanes[bspbrushside->planenum]; + planenum = FindFloatPlane(bspplane->normal, bspplane->dist); + // + // see if the plane has been used already + // + //ME: this really shouldn't happen!!! + //ME: otherwise the bsp file is corrupted?? + //ME: still it seems to happen, maybe Johny Boy's + //ME: brush bevel adding is crappy ? + for (k = 0; k < b->numsides; k++) + { + s2 = b->original_sides + k; + if (s2->planenum == planenum) + { + Log_Print("Entity %i, Brush %i: duplicate plane\n" + , b->entitynum, b->brushnum); + break; + } + if ( s2->planenum == (planenum^1) ) + { + Log_Print("Entity %i, Brush %i: mirrored plane\n" + , b->entitynum, b->brushnum); + break; + } + } + if (k != b->numsides) + continue; // duplicated + + // + // keep this side + // + //ME: reset pointer to side, why? hell I dunno (pointer is set above already) + side = b->original_sides + b->numsides; + //ME: store the plane number + side->planenum = planenum; + //ME: texinfo is already stored when bsp is loaded + //NOTE: check for TEXINFO_NODE, otherwise crash in Sin_BrushContents + if (bspbrushside->texinfo < 0) side->texinfo = 0; + else side->texinfo = bspbrushside->texinfo; + + // save the td off in case there is an origin brush and we + // have to recalculate the texinfo + // ME: don't need to recalculate because it's already done + // (for non-world entities) in the BSP file +// side_brushtextures[nummapbrushsides] = td; + + nummapbrushsides++; + b->numsides++; + } //end for + + // get the content for the entire brush + b->contents = bspbrush->contents; + Sin_BrushContents(b); + + if (BrushExists(b)) + { + c_squattbrushes++; + b->numsides = 0; + return; + } //end if + + //if we're creating AAS + if (create_aas) + { + //create the AAS brushes from this brush, don't add brush bevels + AAS_CreateMapBrushes(b, mapent, false); + return; + } //end if + + // allow detail brushes to be removed + if (nodetail && (b->contents & CONTENTS_DETAIL) ) + { + b->numsides = 0; + return; + } //end if + + // allow water brushes to be removed + if (nowater && (b->contents & (CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_WATER)) ) + { + b->numsides = 0; + return; + } //end if + + // create windings for sides and bounds for brush + MakeBrushWindings(b); + + //mark brushes without winding or with a tiny window as bevels + MarkBrushBevels(b); + + // brushes that will not be visible at all will never be + // used as bsp splitters + if (b->contents & (CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP) ) + { + c_clipbrushes++; + for (i = 0; i < b->numsides; i++) + b->original_sides[i].texinfo = TEXINFO_NODE; + } //end for + + // + // origin brushes are removed, but they set + // the rotation origin for the rest of the brushes + // in the entity. After the entire entity is parsed, + // the planenums and texinfos will be adjusted for + // the origin brush + // + //ME: not needed because the entities in the BSP file already + // have an origin set +// if (b->contents & CONTENTS_ORIGIN) +// { +// char string[32]; +// vec3_t origin; +// +// if (num_entities == 1) +// { +// Error ("Entity %i, Brush %i: origin brushes not allowed in world" +// , b->entitynum, b->brushnum); +// return; +// } +// +// VectorAdd (b->mins, b->maxs, origin); +// VectorScale (origin, 0.5, origin); +// +// sprintf (string, "%i %i %i", (int)origin[0], (int)origin[1], (int)origin[2]); +// SetKeyValue (&entities[b->entitynum], "origin", string); +// +// VectorCopy (origin, entities[b->entitynum].origin); +// +// // don't keep this brush +// b->numsides = 0; +// +// return; +// } + + //ME: the bsp brushes already have bevels, so we won't try to + // add them again (especially since Johny Boy's bevel adding might + // be crappy) +// AddBrushBevels(b); + + nummapbrushes++; + mapent->numbrushes++; +} //end of the function Sin_BSPBrushToMapBrush +//=========================================================================== +//=========================================================================== +void Sin_ParseBSPBrushes(entity_t *mapent) +{ + int i, testnum = 0; + + //give all the brushes that belong to this entity the number of the + //BSP model used by this entity + Sin_SetBrushModelNumbers(mapent); + //now parse all the brushes with the correct mapent->modelnum + for (i = 0; i < sin_numbrushes; i++) + { + if (brushmodelnumbers[i] == mapent->modelnum) + { + testnum++; + Sin_BSPBrushToMapBrush(&sin_dbrushes[i], mapent); + } //end if + } //end for +} //end of the function Sin_ParseBSPBrushes +//=========================================================================== +//=========================================================================== +qboolean Sin_ParseBSPEntity(int entnum) +{ + entity_t *mapent; + char *model; + int startbrush, startsides; + + startbrush = nummapbrushes; + startsides = nummapbrushsides; + + mapent = &entities[entnum];//num_entities]; + mapent->firstbrush = nummapbrushes; + mapent->numbrushes = 0; + mapent->modelnum = -1; //-1 = no model + + model = ValueForKey(mapent, "model"); + if (model && *model == '*') + { + mapent->modelnum = atoi(&model[1]); + //Log_Print("model = %s\n", model); + //Log_Print("mapent->modelnum = %d\n", mapent->modelnum); + } //end if + + GetVectorForKey(mapent, "origin", mapent->origin); + + //if this is the world entity it has model number zero + //the world entity has no model key + if (!strcmp("worldspawn", ValueForKey(mapent, "classname"))) + { + mapent->modelnum = 0; + } //end if + //if the map entity has a BSP model (a modelnum of -1 is used for + //entities that aren't using a BSP model) + if (mapent->modelnum >= 0) + { + //parse the bsp brushes + Sin_ParseBSPBrushes(mapent); + } //end if + // + //the origin of the entity is already taken into account + // + //func_group entities can't be in the bsp file + // + //check out the func_areaportal entities + if (!strcmp ("func_areaportal", ValueForKey (mapent, "classname"))) + { + c_areaportals++; + mapent->areaportalnum = c_areaportals; + return true; + } //end if + return true; +} //end of the function Sin_ParseBSPEntity +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Sin_LoadMapFromBSP(char *filename, int offset, int length) +{ + int i; + + Log_Print("-- Sin_LoadMapFromBSP --\n"); + //loaded map type + loadedmaptype = MAPTYPE_SIN; + + Log_Print("Loading map from %s...\n", filename); + //load the bsp file + Sin_LoadBSPFile(filename, offset, length); + + //create an index from bsp planes to map planes + //DPlanes2MapPlanes(); + //clear brush model numbers + for (i = 0; i < MAX_MAPFILE_BRUSHES; i++) + brushmodelnumbers[i] = -1; + + nummapbrushsides = 0; + num_entities = 0; + + Sin_ParseEntities(); + // + for (i = 0; i < num_entities; i++) + { + Sin_ParseBSPEntity(i); + } //end for + + //get the map mins and maxs from the world model + ClearBounds(map_mins, map_maxs); + for (i = 0; i < entities[0].numbrushes; i++) + { + if (mapbrushes[i].mins[0] > 4096) + continue; //no valid points + AddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs); + AddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs); + } //end for + // + Sin_CreateMapTexinfo(); +} //end of the function Sin_LoadMapFromBSP + +void Sin_ResetMapLoading(void) +{ + //reset for map loading from bsp + memset(nodestack, 0, NODESTACKSIZE * sizeof(int)); + nodestackptr = NULL; + nodestacksize = 0; + memset(brushmodelnumbers, 0, MAX_MAPFILE_BRUSHES * sizeof(int)); +} //end of the function Sin_ResetMapLoading + +//End MAP loading from BSP file + +#endif //ME diff --git a/code/bspc/nodraw.c b/code/bspc/nodraw.c new file mode 100644 index 00000000..7503a48d --- /dev/null +++ b/code/bspc/nodraw.c @@ -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 +=========================================================================== +*/ + +#include "qbsp.h" + +vec3_t draw_mins, draw_maxs; +qboolean drawflag; + +void Draw_ClearWindow (void) +{ +} + +//============================================================ + +#define GLSERV_PORT 25001 + + +void GLS_BeginScene (void) +{ +} + +void GLS_Winding (winding_t *w, int code) +{ +} + +void GLS_EndScene (void) +{ +} diff --git a/code/bspc/portals.c b/code/bspc/portals.c new file mode 100644 index 00000000..0b5ce115 --- /dev/null +++ b/code/bspc/portals.c @@ -0,0 +1,1297 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "l_mem.h" + +int c_active_portals; +int c_peak_portals; +int c_boundary; +int c_boundary_sides; +int c_portalmemory; + +//portal_t *portallist = NULL; +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +portal_t *AllocPortal (void) +{ + portal_t *p; + + p = GetMemory(sizeof(portal_t)); + memset (p, 0, sizeof(portal_t)); + + if (numthreads == 1) + { + c_active_portals++; + if (c_active_portals > c_peak_portals) + { + c_peak_portals = c_active_portals; + } //end if + c_portalmemory += MemorySize(p); + } //end if + +// p->nextportal = portallist; +// portallist = p; + + return p; +} //end of the function AllocPortal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FreePortal (portal_t *p) +{ + if (p->winding) FreeWinding(p->winding); + if (numthreads == 1) + { + c_active_portals--; + c_portalmemory -= MemorySize(p); + } //end if + FreeMemory(p); +} //end of the function FreePortal +//=========================================================================== +// Returns the single content bit of the +// strongest visible content present +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int VisibleContents (int contents) +{ + int i; + + for (i=1 ; i<=LAST_VISIBLE_CONTENTS ; i<<=1) + if (contents & i ) + return i; + + return 0; +} //end of the function VisibleContents +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int ClusterContents (node_t *node) +{ + int c1, c2, c; + + if (node->planenum == PLANENUM_LEAF) + return node->contents; + + c1 = ClusterContents(node->children[0]); + c2 = ClusterContents(node->children[1]); + c = c1|c2; + + // a cluster may include some solid detail areas, but + // still be seen into + if ( ! (c1&CONTENTS_SOLID) || ! (c2&CONTENTS_SOLID) ) + c &= ~CONTENTS_SOLID; + return c; +} //end of the function ClusterContents + +//=========================================================================== +// Returns true if the portal is empty or translucent, allowing +// the PVS calculation to see through it. +// The nodes on either side of the portal may actually be clusters, +// not leaves, so all contents should be ored together +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean Portal_VisFlood (portal_t *p) +{ + int c1, c2; + + if (!p->onnode) + return false; // to global outsideleaf + + c1 = ClusterContents(p->nodes[0]); + c2 = ClusterContents(p->nodes[1]); + + if (!VisibleContents (c1^c2)) + return true; + + if (c1 & (CONTENTS_DETAIL)) + c1 = 0; + if (c2 & (CONTENTS_DETAIL)) + c2 = 0; + + if ( (c1|c2) & CONTENTS_SOLID ) + return false; // can't see through solid + + if (! (c1 ^ c2)) + return true; // identical on both sides + + if (!VisibleContents (c1^c2)) + return true; + return false; +} //end of the function Portal_VisFlood +//=========================================================================== +// The entity flood determines which areas are +// "outside" on the map, which are then filled in. +// Flowing from side s to side !s +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean Portal_EntityFlood (portal_t *p, int s) +{ + if (p->nodes[0]->planenum != PLANENUM_LEAF + || p->nodes[1]->planenum != PLANENUM_LEAF) + Error ("Portal_EntityFlood: not a leaf"); + + // can never cross to a solid + if ( (p->nodes[0]->contents & CONTENTS_SOLID) + || (p->nodes[1]->contents & CONTENTS_SOLID) ) + return false; + + // can flood through everything else + return true; +} + + +//============================================================================= + +int c_tinyportals; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void AddPortalToNodes (portal_t *p, node_t *front, node_t *back) +{ + if (p->nodes[0] || p->nodes[1]) + Error ("AddPortalToNode: allready included"); + + p->nodes[0] = front; + p->next[0] = front->portals; + front->portals = p; + + p->nodes[1] = back; + p->next[1] = back->portals; + back->portals = p; +} //end of the function AddPortalToNodes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void RemovePortalFromNode (portal_t *portal, node_t *l) +{ + portal_t **pp, *t; + + int s, i, n; + portal_t *p; + portal_t *portals[4096]; + +// remove reference to the current portal + pp = &l->portals; + while (1) + { + t = *pp; + if (!t) + Error ("RemovePortalFromNode: portal not in leaf"); + + if ( t == portal ) + break; + + if (t->nodes[0] == l) + pp = &t->next[0]; + else if (t->nodes[1] == l) + pp = &t->next[1]; + else + Error ("RemovePortalFromNode: portal not bounding leaf"); + } + + if (portal->nodes[0] == l) + { + *pp = portal->next[0]; + portal->nodes[0] = NULL; + } //end if + else if (portal->nodes[1] == l) + { + *pp = portal->next[1]; + portal->nodes[1] = NULL; + } //end else if + else + { + Error("RemovePortalFromNode: mislinked portal"); + } //end else +//#ifdef ME + n = 0; + for (p = l->portals; p; p = p->next[s]) + { + for (i = 0; i < n; i++) + { + if (p == portals[i]) Error("RemovePortalFromNode: circular linked\n"); + } //end for + if (p->nodes[0] != l && p->nodes[1] != l) + { + Error("RemovePortalFromNodes: portal does not belong to node\n"); + } //end if + portals[n] = p; + s = (p->nodes[1] == l); +// if (++n >= 4096) Error("RemovePortalFromNode: more than 4096 portals\n"); + } //end for +//#endif +} //end of the function RemovePortalFromNode +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void PrintPortal (portal_t *p) +{ + int i; + winding_t *w; + + w = p->winding; + for (i=0 ; inumpoints ; i++) + printf ("(%5.0f,%5.0f,%5.0f)\n",w->p[i][0] + , w->p[i][1], w->p[i][2]); +} //end of the function PrintPortal +//=========================================================================== +// The created portals will face the global outside_node +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#define SIDESPACE 8 + +void MakeHeadnodePortals (tree_t *tree) +{ + vec3_t bounds[2]; + int i, j, n; + portal_t *p, *portals[6]; + plane_t bplanes[6], *pl; + node_t *node; + + node = tree->headnode; + +// pad with some space so there will never be null volume leaves + for (i=0 ; i<3 ; i++) + { + bounds[0][i] = tree->mins[i] - SIDESPACE; + bounds[1][i] = tree->maxs[i] + SIDESPACE; + if ( bounds[0][i] > bounds[1][i] ) { + Error("empty BSP tree"); + } + } + + tree->outside_node.planenum = PLANENUM_LEAF; + tree->outside_node.brushlist = NULL; + tree->outside_node.portals = NULL; + tree->outside_node.contents = 0; + + for (i=0 ; i<3 ; i++) + for (j=0 ; j<2 ; j++) + { + n = j*3 + i; + + p = AllocPortal (); + portals[n] = p; + + pl = &bplanes[n]; + memset (pl, 0, sizeof(*pl)); + if (j) + { + pl->normal[i] = -1; + pl->dist = -bounds[j][i]; + } + else + { + pl->normal[i] = 1; + pl->dist = bounds[j][i]; + } + p->plane = *pl; + p->winding = BaseWindingForPlane (pl->normal, pl->dist); + AddPortalToNodes (p, node, &tree->outside_node); + } + +// clip the basewindings by all the other planes + for (i=0 ; i<6 ; i++) + { + for (j=0 ; j<6 ; j++) + { + if (j == i) continue; + ChopWindingInPlace (&portals[i]->winding, bplanes[j].normal, bplanes[j].dist, ON_EPSILON); + } //end for + } //end for +} //end of the function MakeHeadNodePortals +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#define BASE_WINDING_EPSILON 0.001 +#define SPLIT_WINDING_EPSILON 0.001 + +winding_t *BaseWindingForNode (node_t *node) +{ + winding_t *w; + node_t *n; + plane_t *plane; + vec3_t normal; + vec_t dist; + + w = BaseWindingForPlane (mapplanes[node->planenum].normal + , mapplanes[node->planenum].dist); + + // clip by all the parents + for (n=node->parent ; n && w ; ) + { + plane = &mapplanes[n->planenum]; + + if (n->children[0] == node) + { // take front + ChopWindingInPlace (&w, plane->normal, plane->dist, BASE_WINDING_EPSILON); + } + else + { // take back + VectorSubtract (vec3_origin, plane->normal, normal); + dist = -plane->dist; + ChopWindingInPlace (&w, normal, dist, BASE_WINDING_EPSILON); + } + node = n; + n = n->parent; + } + + return w; +} //end of the function BaseWindingForNode +//=========================================================================== +// create the new portal by taking the full plane winding for the cutting +// plane and clipping it by all of parents of this node +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean WindingIsTiny (winding_t *w); + +void MakeNodePortal (node_t *node) +{ + portal_t *new_portal, *p; + winding_t *w; + vec3_t normal; + float dist; + int side; + + w = BaseWindingForNode (node); + + // clip the portal by all the other portals in the node + for (p = node->portals; p && w; p = p->next[side]) + { + if (p->nodes[0] == node) + { + side = 0; + VectorCopy (p->plane.normal, normal); + dist = p->plane.dist; + } //end if + else if (p->nodes[1] == node) + { + side = 1; + VectorSubtract (vec3_origin, p->plane.normal, normal); + dist = -p->plane.dist; + } //end else if + else + { + Error ("MakeNodePortal: mislinked portal"); + } //end else + ChopWindingInPlace (&w, normal, dist, 0.1); + } //end for + + if (!w) + { + return; + } //end if + + if (WindingIsTiny (w)) + { + c_tinyportals++; + FreeWinding(w); + return; + } //end if + +#ifdef DEBUG +/* //NOTE: don't use this winding ok check + // all the invalid windings only have a degenerate edge + if (WindingError(w)) + { + Log_Print("MakeNodePortal: %s\n", WindingErrorString()); + FreeWinding(w); + return; + } //end if*/ +#endif //DEBUG + + + new_portal = AllocPortal(); + new_portal->plane = mapplanes[node->planenum]; + +#ifdef ME + new_portal->planenum = node->planenum; +#endif //ME + + new_portal->onnode = node; + new_portal->winding = w; + AddPortalToNodes (new_portal, node->children[0], node->children[1]); +} //end of the function MakeNodePortal +//=========================================================================== +// Move or split the portals that bound node so that the node's +// children have portals instead of node. +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void SplitNodePortals (node_t *node) +{ + portal_t *p, *next_portal, *new_portal; + node_t *f, *b, *other_node; + int side; + plane_t *plane; + winding_t *frontwinding, *backwinding; + + plane = &mapplanes[node->planenum]; + f = node->children[0]; + b = node->children[1]; + + for (p = node->portals ; p ; p = next_portal) + { + if (p->nodes[0] == node) side = 0; + else if (p->nodes[1] == node) side = 1; + else Error ("SplitNodePortals: mislinked portal"); + next_portal = p->next[side]; + + other_node = p->nodes[!side]; + RemovePortalFromNode (p, p->nodes[0]); + RemovePortalFromNode (p, p->nodes[1]); + +// +// cut the portal into two portals, one on each side of the cut plane +// + ClipWindingEpsilon (p->winding, plane->normal, plane->dist, + SPLIT_WINDING_EPSILON, &frontwinding, &backwinding); + + if (frontwinding && WindingIsTiny(frontwinding)) + { + FreeWinding (frontwinding); + frontwinding = NULL; + c_tinyportals++; + } //end if + + if (backwinding && WindingIsTiny(backwinding)) + { + FreeWinding (backwinding); + backwinding = NULL; + c_tinyportals++; + } //end if + +#ifdef DEBUG +/* //NOTE: don't use this winding ok check + // all the invalid windings only have a degenerate edge + if (frontwinding && WindingError(frontwinding)) + { + Log_Print("SplitNodePortals: front %s\n", WindingErrorString()); + FreeWinding(frontwinding); + frontwinding = NULL; + } //end if + if (backwinding && WindingError(backwinding)) + { + Log_Print("SplitNodePortals: back %s\n", WindingErrorString()); + FreeWinding(backwinding); + backwinding = NULL; + } //end if*/ +#endif //DEBUG + + if (!frontwinding && !backwinding) + { // tiny windings on both sides + continue; + } + + if (!frontwinding) + { + FreeWinding (backwinding); + if (side == 0) AddPortalToNodes (p, b, other_node); + else AddPortalToNodes (p, other_node, b); + continue; + } + if (!backwinding) + { + FreeWinding (frontwinding); + if (side == 0) AddPortalToNodes (p, f, other_node); + else AddPortalToNodes (p, other_node, f); + continue; + } + + // the winding is split + new_portal = AllocPortal(); + *new_portal = *p; + new_portal->winding = backwinding; + FreeWinding (p->winding); + p->winding = frontwinding; + + if (side == 0) + { + AddPortalToNodes (p, f, other_node); + AddPortalToNodes (new_portal, b, other_node); + } //end if + else + { + AddPortalToNodes (p, other_node, f); + AddPortalToNodes (new_portal, other_node, b); + } //end else + } + + node->portals = NULL; +} //end of the function SplitNodePortals +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void CalcNodeBounds (node_t *node) +{ + portal_t *p; + int s; + int i; + + // calc mins/maxs for both leaves and nodes + ClearBounds (node->mins, node->maxs); + for (p = node->portals ; p ; p = p->next[s]) + { + s = (p->nodes[1] == node); + for (i=0 ; iwinding->numpoints ; i++) + AddPointToBounds (p->winding->p[i], node->mins, node->maxs); + } +} //end of the function CalcNodeBounds +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int c_numportalizednodes; + +void MakeTreePortals_r (node_t *node) +{ + int i; + +#ifdef ME + qprintf("\r%6d", ++c_numportalizednodes); + if (cancelconversion) return; +#endif //ME + + CalcNodeBounds (node); + if (node->mins[0] >= node->maxs[0]) + { + Log_Print("WARNING: node without a volume\n"); + } + + for (i=0 ; i<3 ; i++) + { + if (node->mins[i] < -MAX_MAP_BOUNDS || node->maxs[i] > MAX_MAP_BOUNDS) + { + Log_Print("WARNING: node with unbounded volume\n"); + break; + } + } + if (node->planenum == PLANENUM_LEAF) + return; + + MakeNodePortal (node); + SplitNodePortals (node); + + MakeTreePortals_r (node->children[0]); + MakeTreePortals_r (node->children[1]); +} //end of the function MakeTreePortals_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void MakeTreePortals(tree_t *tree) +{ + +#ifdef ME + Log_Print("---- Node Portalization ----\n"); + c_numportalizednodes = 0; + c_portalmemory = 0; + qprintf("%6d nodes portalized", c_numportalizednodes); +#endif //ME + + MakeHeadnodePortals(tree); + MakeTreePortals_r(tree->headnode); + +#ifdef ME + qprintf("\n"); + Log_Write("%6d nodes portalized\r\n", c_numportalizednodes); + Log_Print("%6d tiny portals\r\n", c_tinyportals); + Log_Print("%6d KB of portal memory\r\n", c_portalmemory >> 10); + Log_Print("%6i KB of winding memory\r\n", WindingMemory() >> 10); +#endif //ME +} //end of the function MakeTreePortals + +/* +========================================================= + +FLOOD ENTITIES + +========================================================= +*/ +//#define P_NODESTACK + +node_t *p_firstnode; +node_t *p_lastnode; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +#ifdef P_NODESTACK +void P_AddNodeToList(node_t *node) +{ + node->next = p_firstnode; + p_firstnode = node; + if (!p_lastnode) p_lastnode = node; +} //end of the function P_AddNodeToList +#else //it's a node queue +//add the node to the end of the node list +void P_AddNodeToList(node_t *node) +{ + node->next = NULL; + if (p_lastnode) p_lastnode->next = node; + else p_firstnode = node; + p_lastnode = node; +} //end of the function P_AddNodeToList +#endif //P_NODESTACK +//=========================================================================== +// get the first node from the front of the node list +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +node_t *P_NextNodeFromList(void) +{ + node_t *node; + + node = p_firstnode; + if (p_firstnode) p_firstnode = p_firstnode->next; + if (!p_firstnode) p_lastnode = NULL; + return node; +} //end of the function P_NextNodeFromList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FloodPortals(node_t *firstnode) +{ + node_t *node; + portal_t *p; + int s; + + firstnode->occupied = 1; + P_AddNodeToList(firstnode); + + for (node = P_NextNodeFromList(); node; node = P_NextNodeFromList()) + { + for (p = node->portals; p; p = p->next[s]) + { + s = (p->nodes[1] == node); + //if the node at the other side of the portal is occupied already + if (p->nodes[!s]->occupied) continue; + //if it isn't possible to flood through this portal + if (!Portal_EntityFlood(p, s)) continue; + // + p->nodes[!s]->occupied = node->occupied + 1; + // + P_AddNodeToList(p->nodes[!s]); + } //end for + } //end for +} //end of the function FloodPortals +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int numrec; + +void FloodPortals_r (node_t *node, int dist) +{ + portal_t *p; + int s; +// int i; + + Log_Print("\r%6d", ++numrec); + + if (node->occupied) Error("FloodPortals_r: node already occupied\n"); + if (!node) + { + Error("FloodPortals_r: NULL node\n"); + } //end if*/ + node->occupied = dist; + + for (p = node->portals; p; p = p->next[s]) + { + s = (p->nodes[1] == node); + //if the node at the other side of the portal is occupied already + if (p->nodes[!s]->occupied) continue; + //if it isn't possible to flood through this portal + if (!Portal_EntityFlood(p, s)) continue; + //flood recursively through the current portal + FloodPortals_r(p->nodes[!s], dist+1); + } //end for + Log_Print("\r%6d", --numrec); +} //end of the function FloodPortals_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean PlaceOccupant (node_t *headnode, vec3_t origin, entity_t *occupant) +{ + node_t *node; + vec_t d; + plane_t *plane; + + //find the leaf to start in + node = headnode; + while(node->planenum != PLANENUM_LEAF) + { + if (node->planenum < 0 || node->planenum > nummapplanes) + { + Error("PlaceOccupant: invalid node->planenum\n"); + } //end if + plane = &mapplanes[node->planenum]; + d = DotProduct(origin, plane->normal) - plane->dist; + if (d >= 0) node = node->children[0]; + else node = node->children[1]; + if (!node) + { + Error("PlaceOccupant: invalid child %d\n", d < 0); + } //end if + } //end while + //don't start in solid +// if (node->contents == CONTENTS_SOLID) + //ME: replaced because in LeafNode in brushbsp.c + // some nodes have contents solid with other contents + if (node->contents & CONTENTS_SOLID) return false; + //if the node is already occupied + if (node->occupied) return false; + + //place the occupant in the first leaf + node->occupant = occupant; + + numrec = 0; +// Log_Print("%6d recurses", numrec); +// FloodPortals_r(node, 1); +// Log_Print("\n"); + FloodPortals(node); + + return true; +} //end of the function PlaceOccupant +//=========================================================================== +// Marks all nodes that can be reached by entites +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean FloodEntities (tree_t *tree) +{ + int i; + int x, y; + vec3_t origin; + char *cl; + qboolean inside; + node_t *headnode; + + headnode = tree->headnode; + Log_Print("------ FloodEntities -------\n"); + inside = false; + tree->outside_node.occupied = 0; + + //start at entity 1 not the world ( = 0) + for (i = 1; i < num_entities; i++) + { + GetVectorForKey(&entities[i], "origin", origin); + if (VectorCompare(origin, vec3_origin)) continue; + + cl = ValueForKey(&entities[i], "classname"); + origin[2] += 1; //so objects on floor are ok + +// Log_Print("flooding from entity %d: %s\n", i, cl); + //nudge playerstart around if needed so clipping hulls allways + //have a valid point + if (!strcmp(cl, "info_player_start")) + { + for (x = -16; x <= 16; x += 16) + { + for (y = -16; y <= 16; y += 16) + { + origin[0] += x; + origin[1] += y; + if (PlaceOccupant(headnode, origin, &entities[i])) + { + inside = true; + x = 999; //stop for this info_player_start + break; + } //end if + origin[0] -= x; + origin[1] -= y; + } //end for + } //end for + } //end if + else + { + if (PlaceOccupant(headnode, origin, &entities[i])) + { + inside = true; + } //end if + } //end else + } //end for + + if (!inside) + { + Log_Print("WARNING: no entities inside\n"); + } //end if + else if (tree->outside_node.occupied) + { + Log_Print("WARNING: entity reached from outside\n"); + } //end else if + + return (qboolean)(inside && !tree->outside_node.occupied); +} //end of the function FloodEntities + +/* +========================================================= + +FILL OUTSIDE + +========================================================= +*/ + +int c_outside; +int c_inside; +int c_solid; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FillOutside_r (node_t *node) +{ + if (node->planenum != PLANENUM_LEAF) + { + FillOutside_r (node->children[0]); + FillOutside_r (node->children[1]); + return; + } //end if + // anything not reachable by an entity + // can be filled away (by setting solid contents) + if (!node->occupied) + { + if (!(node->contents & CONTENTS_SOLID)) + { + c_outside++; + node->contents |= CONTENTS_SOLID; + } //end if + else + { + c_solid++; + } //end else + } //end if + else + { + c_inside++; + } //end else +} //end of the function FillOutside_r +//=========================================================================== +// Fill all nodes that can't be reached by entities +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FillOutside (node_t *headnode) +{ + c_outside = 0; + c_inside = 0; + c_solid = 0; + Log_Print("------- FillOutside --------\n"); + FillOutside_r (headnode); + Log_Print("%5i solid leaves\n", c_solid); + Log_Print("%5i leaves filled\n", c_outside); + Log_Print("%5i inside leaves\n", c_inside); +} //end of the function FillOutside + +/* +========================================================= + +FLOOD AREAS + +========================================================= +*/ + +int c_areas; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FloodAreas_r (node_t *node) +{ + portal_t *p; + int s; + bspbrush_t *b; + entity_t *e; + + if (node->contents == CONTENTS_AREAPORTAL) + { + // this node is part of an area portal + b = node->brushlist; + e = &entities[b->original->entitynum]; + + // if the current area has allready touched this + // portal, we are done + if (e->portalareas[0] == c_areas || e->portalareas[1] == c_areas) + return; + + // note the current area as bounding the portal + if (e->portalareas[1]) + { + Log_Print("WARNING: areaportal entity %i touches > 2 areas\n", b->original->entitynum); + return; + } + if (e->portalareas[0]) + e->portalareas[1] = c_areas; + else + e->portalareas[0] = c_areas; + + return; + } //end if + + if (node->area) + return; // allready got it + node->area = c_areas; + + for (p=node->portals ; p ; p = p->next[s]) + { + s = (p->nodes[1] == node); +#if 0 + if (p->nodes[!s]->occupied) + continue; +#endif + if (!Portal_EntityFlood (p, s)) + continue; + + FloodAreas_r (p->nodes[!s]); + } //end for +} //end of the function FloodAreas_r +//=========================================================================== +// Just decend the tree, and for each node that hasn't had an +// area set, flood fill out from there +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FindAreas_r (node_t *node) +{ + if (node->planenum != PLANENUM_LEAF) + { + FindAreas_r (node->children[0]); + FindAreas_r (node->children[1]); + return; + } + + if (node->area) + return; // allready got it + + if (node->contents & CONTENTS_SOLID) + return; + + if (!node->occupied) + return; // not reachable by entities + + // area portals are allways only flooded into, never + // out of + if (node->contents == CONTENTS_AREAPORTAL) + return; + + c_areas++; + FloodAreas_r (node); +} //end of the function FindAreas_r +//=========================================================================== +// Just decend the tree, and for each node that hasn't had an +// area set, flood fill out from there +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void SetAreaPortalAreas_r (node_t *node) +{ + bspbrush_t *b; + entity_t *e; + + if (node->planenum != PLANENUM_LEAF) + { + SetAreaPortalAreas_r (node->children[0]); + SetAreaPortalAreas_r (node->children[1]); + return; + } //end if + + if (node->contents == CONTENTS_AREAPORTAL) + { + if (node->area) + return; // allready set + + b = node->brushlist; + e = &entities[b->original->entitynum]; + node->area = e->portalareas[0]; + if (!e->portalareas[1]) + { + Log_Print("WARNING: areaportal entity %i doesn't touch two areas\n", b->original->entitynum); + return; + } //end if + } //end if +} //end of the function SetAreaPortalAreas_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +/* +void EmitAreaPortals(node_t *headnode) +{ + int i, j; + entity_t *e; + dareaportal_t *dp; + + if (c_areas > MAX_MAP_AREAS) + Error ("MAX_MAP_AREAS"); + numareas = c_areas+1; + numareaportals = 1; // leave 0 as an error + + for (i=1 ; i<=c_areas ; i++) + { + dareas[i].firstareaportal = numareaportals; + for (j=0 ; jareaportalnum) + continue; + dp = &dareaportals[numareaportals]; + if (e->portalareas[0] == i) + { + dp->portalnum = e->areaportalnum; + dp->otherarea = e->portalareas[1]; + numareaportals++; + } //end if + else if (e->portalareas[1] == i) + { + dp->portalnum = e->areaportalnum; + dp->otherarea = e->portalareas[0]; + numareaportals++; + } //end else if + } //end for + dareas[i].numareaportals = numareaportals - dareas[i].firstareaportal; + } //end for + + Log_Print("%5i numareas\n", numareas); + Log_Print("%5i numareaportals\n", numareaportals); +} //end of the function EmitAreaPortals +*/ +//=========================================================================== +// Mark each leaf with an area, bounded by CONTENTS_AREAPORTAL +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FloodAreas (tree_t *tree) +{ + Log_Print("--- FloodAreas ---\n"); + FindAreas_r (tree->headnode); + SetAreaPortalAreas_r (tree->headnode); + Log_Print("%5i areas\n", c_areas); +} //end of the function FloodAreas +//=========================================================================== +// Finds a brush side to use for texturing the given portal +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void FindPortalSide (portal_t *p) +{ + int viscontents; + bspbrush_t *bb; + mapbrush_t *brush; + node_t *n; + int i,j; + int planenum; + side_t *side, *bestside; + float dot, bestdot; + plane_t *p1, *p2; + + // decide which content change is strongest + // solid > lava > water, etc + viscontents = VisibleContents (p->nodes[0]->contents ^ p->nodes[1]->contents); + if (!viscontents) + return; + + planenum = p->onnode->planenum; + bestside = NULL; + bestdot = 0; + + for (j=0 ; j<2 ; j++) + { + n = p->nodes[j]; + p1 = &mapplanes[p->onnode->planenum]; + for (bb=n->brushlist ; bb ; bb=bb->next) + { + brush = bb->original; + if ( !(brush->contents & viscontents) ) + continue; + for (i=0 ; inumsides ; i++) + { + side = &brush->original_sides[i]; + if (side->flags & SFL_BEVEL) + continue; + if (side->texinfo == TEXINFO_NODE) + continue; // non-visible + if ((side->planenum&~1) == planenum) + { // exact match + bestside = &brush->original_sides[i]; + goto gotit; + } //end if + // see how close the match is + p2 = &mapplanes[side->planenum&~1]; + dot = DotProduct (p1->normal, p2->normal); + if (dot > bestdot) + { + bestdot = dot; + bestside = side; + } //end if + } //end for + } //end for + } //end for + +gotit: + if (!bestside) + Log_Print("WARNING: side not found for portal\n"); + + p->sidefound = true; + p->side = bestside; +} //end of the function FindPortalSide +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void MarkVisibleSides_r (node_t *node) +{ + portal_t *p; + int s; + + if (node->planenum != PLANENUM_LEAF) + { + MarkVisibleSides_r (node->children[0]); + MarkVisibleSides_r (node->children[1]); + return; + } //end if + + // empty leaves are never boundary leaves + if (!node->contents) return; + + // see if there is a visible face + for (p=node->portals ; p ; p = p->next[!s]) + { + s = (p->nodes[0] == node); + if (!p->onnode) + continue; // edge of world + if (!p->sidefound) + FindPortalSide (p); + if (p->side) + p->side->flags |= SFL_VISIBLE; + } //end for +} //end of the function MarkVisibleSides_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void MarkVisibleSides(tree_t *tree, int startbrush, int endbrush) +{ + int i, j; + mapbrush_t *mb; + int numsides; + + Log_Print("--- MarkVisibleSides ---\n"); + + // clear all the visible flags + for (i=startbrush ; inumsides; + for (j=0 ; joriginal_sides[j].flags &= ~SFL_VISIBLE; + } + + // set visible flags on the sides that are used by portals + MarkVisibleSides_r (tree->headnode); +} //end of the function MarkVisibleSides + diff --git a/code/bspc/prtfile.c b/code/bspc/prtfile.c new file mode 100644 index 00000000..58d12065 --- /dev/null +++ b/code/bspc/prtfile.c @@ -0,0 +1,287 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" + +/* +============================================================================== + +PORTAL FILE GENERATION + +Save out name.prt for qvis to read +============================================================================== +*/ + + +#define PORTALFILE "PRT1" + +FILE *pf; +int num_visclusters; // clusters the player can be in +int num_visportals; + +void WriteFloat2 (FILE *f, vec_t v) +{ + if ( fabs(v - Q_rint(v)) < 0.001 ) + fprintf (f,"%i ",(int)Q_rint(v)); + else + fprintf (f,"%f ",v); +} + +/* +================= +WritePortalFile_r +================= +*/ +void WritePortalFile_r (node_t *node) +{ + int i, s; + portal_t *p; + winding_t *w; + vec3_t normal; + vec_t dist; + + // decision node + if (node->planenum != PLANENUM_LEAF && !node->detail_seperator) + { + WritePortalFile_r (node->children[0]); + WritePortalFile_r (node->children[1]); + return; + } + + if (node->contents & CONTENTS_SOLID) + return; + + for (p = node->portals ; p ; p=p->next[s]) + { + w = p->winding; + s = (p->nodes[1] == node); + if (w && p->nodes[0] == node) + { + if (!Portal_VisFlood (p)) + continue; + // write out to the file + + // sometimes planes get turned around when they are very near + // the changeover point between different axis. interpret the + // plane the same way vis will, and flip the side orders if needed + // FIXME: is this still relevent? + WindingPlane (w, normal, &dist); + if ( DotProduct (p->plane.normal, normal) < 0.99 ) + { // backwards... + fprintf (pf,"%i %i %i ",w->numpoints, p->nodes[1]->cluster, p->nodes[0]->cluster); + } + else + fprintf (pf,"%i %i %i ",w->numpoints, p->nodes[0]->cluster, p->nodes[1]->cluster); + for (i=0 ; inumpoints ; i++) + { + fprintf (pf,"("); + WriteFloat2 (pf, w->p[i][0]); + WriteFloat2 (pf, w->p[i][1]); + WriteFloat2 (pf, w->p[i][2]); + fprintf (pf,") "); + } + fprintf (pf,"\n"); + } + } + +} + +/* +================ +FillLeafNumbers_r + +All of the leafs under node will have the same cluster +================ +*/ +void FillLeafNumbers_r (node_t *node, int num) +{ + if (node->planenum == PLANENUM_LEAF) + { + if (node->contents & CONTENTS_SOLID) + node->cluster = -1; + else + node->cluster = num; + return; + } + node->cluster = num; + FillLeafNumbers_r (node->children[0], num); + FillLeafNumbers_r (node->children[1], num); +} + +/* +================ +NumberLeafs_r +================ +*/ +void NumberLeafs_r (node_t *node) +{ + portal_t *p; + + if (node->planenum != PLANENUM_LEAF && !node->detail_seperator) + { // decision node + node->cluster = -99; + NumberLeafs_r (node->children[0]); + NumberLeafs_r (node->children[1]); + return; + } + + // either a leaf or a detail cluster + + if ( node->contents & CONTENTS_SOLID ) + { // solid block, viewpoint never inside + node->cluster = -1; + return; + } + + FillLeafNumbers_r (node, num_visclusters); + num_visclusters++; + + // count the portals + for (p = node->portals ; p ; ) + { + if (p->nodes[0] == node) // only write out from first leaf + { + if (Portal_VisFlood (p)) + num_visportals++; + p = p->next[0]; + } + else + p = p->next[1]; + } + +} + + +/* +================ +CreateVisPortals_r +================ +*/ +void CreateVisPortals_r (node_t *node) +{ + // stop as soon as we get to a detail_seperator, which + // means that everything below is in a single cluster + if (node->planenum == PLANENUM_LEAF || node->detail_seperator ) + return; + + MakeNodePortal (node); + SplitNodePortals (node); + + CreateVisPortals_r (node->children[0]); + CreateVisPortals_r (node->children[1]); +} + +/* +================ +FinishVisPortals_r +================ +*/ +void FinishVisPortals2_r (node_t *node) +{ + if (node->planenum == PLANENUM_LEAF) + return; + + MakeNodePortal (node); + SplitNodePortals (node); + + FinishVisPortals2_r (node->children[0]); + FinishVisPortals2_r (node->children[1]); +} + +void FinishVisPortals_r (node_t *node) +{ + if (node->planenum == PLANENUM_LEAF) + return; + + if (node->detail_seperator) + { + FinishVisPortals2_r (node); + return; + } + + FinishVisPortals_r (node->children[0]); + FinishVisPortals_r (node->children[1]); +} + + +int clusterleaf; +void SaveClusters_r (node_t *node) +{ + if (node->planenum == PLANENUM_LEAF) + { + dleafs[clusterleaf++].cluster = node->cluster; + return; + } + SaveClusters_r (node->children[0]); + SaveClusters_r (node->children[1]); +} + +/* +================ +WritePortalFile +================ +*/ +void WritePortalFile (tree_t *tree) +{ + char filename[1024]; + node_t *headnode; + + qprintf ("--- WritePortalFile ---\n"); + + headnode = tree->headnode; + num_visclusters = 0; + num_visportals = 0; + + Tree_FreePortals_r (headnode); + + MakeHeadnodePortals (tree); + + CreateVisPortals_r (headnode); + +// set the cluster field in every leaf and count the total number of portals + + NumberLeafs_r (headnode); + +// write the file + sprintf (filename, "%s.prt", source); + printf ("writing %s\n", filename); + pf = fopen (filename, "w"); + if (!pf) + Error ("Error opening %s", filename); + + fprintf (pf, "%s\n", PORTALFILE); + fprintf (pf, "%i\n", num_visclusters); + fprintf (pf, "%i\n", num_visportals); + + qprintf ("%5i visclusters\n", num_visclusters); + qprintf ("%5i visportals\n", num_visportals); + + WritePortalFile_r (headnode); + + fclose (pf); + + // we need to store the clusters out now because ordering + // issues made us do this after writebsp... + clusterleaf = 1; + SaveClusters_r (headnode); +} + diff --git a/code/bspc/q2files.h b/code/bspc/q2files.h new file mode 100644 index 00000000..5779bfac --- /dev/null +++ b/code/bspc/q2files.h @@ -0,0 +1 @@ +#include "../qcommon/surfaceflags.h" \ No newline at end of file diff --git a/code/bspc/q3files.h b/code/bspc/q3files.h new file mode 100644 index 00000000..167183ae --- /dev/null +++ b/code/bspc/q3files.h @@ -0,0 +1,436 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#ifndef __QFILES_H__ +#define __QFILES_H__ + +// +// qfiles.h: quake file formats +// This file must be identical in the quake and utils directories +// + +//Ignore __attribute__ on non-gcc platforms +#ifndef __GNUC__ +#ifndef __attribute__ +#define __attribute__(x) +#endif +#endif + +// surface geometry should not exceed these limits +#define SHADER_MAX_VERTEXES 2048 // 1000 su44: I've increased it a bit... +#define SHADER_MAX_INDEXES (6*SHADER_MAX_VERTEXES) +#define SHADER_MAX_TRIANGLES (2*SHADER_MAX_VERTEXES) + +// the maximum size of game relative pathnames +#define MAX_QPATH 64 + +/* +======================================================================== + +.MD3 triangle model file format + +======================================================================== +*/ + +#define MD3_IDENT (('3'<<24)+('P'<<16)+('D'<<8)+'I') +#define MD3_VERSION 15 + +// limits +#define MD3_MAX_LODS 3 +#define MD3_MAX_TRIANGLES 8192 // per surface +#define MD3_MAX_VERTS 4096 // per surface +#define MD3_MAX_SHADERS 256 // per surface +#define MD3_MAX_FRAMES 1024 // per model +#define MD3_MAX_SURFACES 32 // per model +#define MD3_MAX_TAGS 16 // per frame + +// vertex scales +#define MD3_XYZ_SCALE (1.0/64) + +typedef struct md3Frame_s { + vec3_t bounds[2]; + vec3_t localOrigin; + float radius; + char name[16]; +} md3Frame_t; + +typedef struct md3Tag_s { + char name[MAX_QPATH]; // tag name + vec3_t origin; + vec3_t axis[3]; +} md3Tag_t; + +/* +** md3Surface_t +** +** CHUNK SIZE +** header sizeof( md3Surface_t ) +** shaders sizeof( md3Shader_t ) * numShaders +** triangles[0] sizeof( md3Triangle_t ) * numTriangles +** st sizeof( md3St_t ) * numVerts +** XyzNormals sizeof( md3XyzNormal_t ) * numVerts * numFrames +*/ +typedef struct { + int ident; // + + char name[MAX_QPATH]; // polyset name + + int flags; + int numFrames; // all surfaces in a model should have the same + + int numShaders; // all surfaces in a model should have the same + int numVerts; + + int numTriangles; + int ofsTriangles; + + int ofsShaders; // offset from start of md3Surface_t + int ofsSt; // texture coords are common for all frames + int ofsXyzNormals; // numVerts * numFrames + + int ofsEnd; // next surface follows +} md3Surface_t; + +typedef struct { + char name[MAX_QPATH]; + int shaderIndex; // for in-game use +} md3Shader_t; + +typedef struct { + int indexes[3]; +} md3Triangle_t; + +typedef struct { + float st[2]; +} md3St_t; + +typedef struct { + short xyz[3]; + short normal; +} md3XyzNormal_t; + +typedef struct { + int ident; + int version; + + char name[MAX_QPATH]; // model name + + int flags; + + int numFrames; + int numTags; + int numSurfaces; + + int numSkins; + + int ofsFrames; // offset for first frame + int ofsTags; // numFrames * numTags + int ofsSurfaces; // first surface, others follow + + int ofsEnd; // end of file +} md3Header_t; + + +/* +============================================================================== + + .BSP file format + +============================================================================== +*/ + + +#define BSP_IDENT (('5'<<24)+('1'<<16)+('0'<<8)+'2') + // little-endian "2015" + +#define BSP_VERSION 19 // vanilla Allied Assault + + +// there shouldn't be any problem with increasing these values at the +// expense of more memory allocation in the utilities +#define MAX_MAP_MODELS 0x400 +#define MAX_MAP_BRUSHES 0x8000 +#define MAX_MAP_ENTITIES 0x2000 // 0x800 // su44: increased for t2l1.map +#define MAX_MAP_ENTSTRING 0x100000 //0x40000 // su44: increased for t2l1.map +#define MAX_MAP_SHADERS 0x400 + +#define MAX_MAP_AREAS 0x100 // MAX_MAP_AREA_BYTES in q_shared must match! +#define MAX_MAP_FOGS 0x100 +#define MAX_MAP_PLANES 0x20000 +#define MAX_MAP_NODES 0x20000 +#define MAX_MAP_BRUSHSIDES 0x20000 +#define MAX_MAP_LEAFS 0x20000 +#define MAX_MAP_LEAFFACES 0x20000 +#define MAX_MAP_LEAFBRUSHES 0x40000 +#define MAX_MAP_PORTALS 0x20000 +#define MAX_MAP_LIGHTING 0x800000 +#define MAX_MAP_LIGHTGRID 0x800000 +#define MAX_MAP_VISIBILITY 0x200000 + +#define MAX_MAP_DRAW_SURFS 0x20000 +#define MAX_MAP_DRAW_VERTS 0x80000 +#define MAX_MAP_DRAW_INDEXES 0x80000 + + +// key / value pair sizes in the entities lump +#define MAX_KEY 32 +#define MAX_VALUE 1024 + +// the editor uses these predefined yaw angles to orient entities up or down +#define ANGLE_UP -1 +#define ANGLE_DOWN -2 + +#define LIGHTMAP_WIDTH 128 +#define LIGHTMAP_HEIGHT 128 +#define LIGHTMAP_SIZE 128 // IneQuation: moved it here, MUST MATCH THE FORMER TWO + +#define MAX_WORLD_COORD ( 128*1024 ) +#define MIN_WORLD_COORD ( -128*1024 ) +#define WORLD_SIZE ( MAX_WORLD_COORD - MIN_WORLD_COORD ) + +//============================================================================= + + +typedef struct { + int fileofs, filelen; +} lump_t; + +// new lump defines. lump numbers are different in mohaa +#define LUMP_SHADERS 0 +#define LUMP_PLANES 1 +#define LUMP_LIGHTMAPS 2 +#define LUMP_SURFACES 3 +#define LUMP_DRAWVERTS 4 +#define LUMP_DRAWINDEXES 5 +#define LUMP_LEAFBRUSHES 6 +#define LUMP_LEAFSURFACES 7 +#define LUMP_LEAFS 8 +#define LUMP_NODES 9 +#define LUMP_SIDEEQUATIONS 10 +#define LUMP_BRUSHSIDES 11 +#define LUMP_BRUSHES 12 +/* +// FOG seems to be handled differently in MOHAA - no fog lump found yet +#define LUMP_FOGS 0 +*/ +#define LUMP_MODELS 13 +#define LUMP_ENTITIES 14 +#define LUMP_VISIBILITY 15 +#define LUMP_LIGHTGRIDPALETTE 16 +#define LUMP_LIGHTGRIDOFFSETS 17 +#define LUMP_LIGHTGRIDDATA 18 +#define LUMP_SPHERELIGHTS 19 +#define LUMP_SPHERELIGHTVIS 20 +#define LUMP_LIGHTDEFS 21 +#define LUMP_TERRAIN 22 +#define LUMP_TERRAININDEXES 23 +#define LUMP_STATICMODELDATA 24 +#define LUMP_STATICMODELDEF 25 +#define LUMP_STATICMODELINDEXES 26 +#define LUMP_DUMMY10 27 + +#define HEADER_LUMPS 28 + +typedef struct { + int ident; + int version; + int dummy; + + lump_t lumps[HEADER_LUMPS]; +} dheader_t; + +typedef struct { + float mins[3], maxs[3]; + int firstSurface, numSurfaces; + int firstBrush, numBrushes; +} dmodel_t; + +typedef struct { + char shader[MAX_QPATH]; + int surfaceFlags; + int contentFlags; + int subdivisions; + char fenceMaskImage[MAX_QPATH]; +} dshader_t; + +// planes x^1 is allways the opposite of plane x + +typedef struct { + float normal[3]; + float dist; +} dplane_t; + +typedef struct { + int planeNum; + int children[2]; // negative numbers are -(leafs+1), not nodes + int mins[3]; // for frustom culling + int maxs[3]; +} dnode_t; + +typedef struct { + int cluster; // -1 = opaque cluster (do I still store these?) + int area; + + int mins[3]; // for frustum culling + int maxs[3]; + + int firstLeafSurface; + int numLeafSurfaces; + + int firstLeafBrush; + int numLeafBrushes; + + //added for mohaa + int dummy1; + int dummy2; + int firstStaticModel; + int numStaticModels; +} dleaf_t; + +// su44: It seems that sideEquations +// are somehow related to fencemasks... +// MoHAA loads them only in CM (CM_LoadMap). +typedef struct { + float fSeq[4]; + float fTeq[4]; +} dsideEquation_t; + +typedef struct { + int planeNum; // positive plane side faces out of the leaf + int shaderNum; + + //added for mohaa + int equationNum; // su44: that's a dsideEquation_t index +} dbrushside_t; + +typedef struct { + int firstSide; + int numSides; + int shaderNum; // the shader that determines the contents flags +} dbrush_t; + +typedef struct { + char shader[MAX_QPATH]; + int brushNum; + int visibleSide; // the brush side that ray tests need to clip against (-1 == none) +} dfog_t; + +typedef struct { + vec3_t xyz; + float st[2]; + float lightmap[2]; + vec3_t normal; + byte color[4]; +} drawVert_t; + +#define drawVert_t_cleared(x) drawVert_t (x) = {{0, 0, 0}, {0, 0}, {0, 0}, {0, 0, 0}, {0, 0, 0, 0}} + +typedef enum { + MST_BAD, + MST_PLANAR, + MST_PATCH, + MST_TRIANGLE_SOUP, + MST_FLARE +} mapSurfaceType_t; + +typedef struct { + int shaderNum; + int fogNum; + int surfaceType; + + int firstVert; + int numVerts; + + int firstIndex; + int numIndexes; + + int lightmapNum; + int lightmapX, lightmapY; + int lightmapWidth, lightmapHeight; + + vec3_t lightmapOrigin; + vec3_t lightmapVecs[3]; // for patches, [0] and [1] are lodbounds + + int patchWidth; + int patchHeight; + + //added for mohaa + float dummy; +} dsurface_t; + +// IneQuation was here +typedef struct dterPatch_s { + byte flags; + byte scale; + byte lmCoords[2]; + float texCoords[8]; + char x; + char y; + short baseZ; + unsigned short shader; + short lightmap; + short dummy[4]; + short vertFlags[2][63]; + byte heightmap[9][9]; +} dterPatch_t; + +// su44 was here +typedef struct dstaticModel_s { + char model[128]; + vec3_t origin; + vec3_t angles; + float scale; + int firstVertexData; + short numVertexData; +} dstaticModel_t; + +typedef struct { + float origin[3]; + float color[3]; + float intensity; + int leaf; + qboolean needs_trace; + qboolean spot_light; + float spot_dir[3]; + float spot_radiusbydistance; +} dspherel_t; + +typedef struct { + float origin[3]; + float axis[3]; + int bounds[3]; +} dlightGrid_t; + +typedef struct { + int lightIntensity; + int lightAngle; + int lightmapResolution; + qboolean twoSided; + qboolean lightLinear; + vec3_t lightColor; + float lightFalloff; + float backsplashFraction; + float backsplashDistance; + float lightSubdivide; + qboolean autosprite; +} dlightdef_t; + +#endif diff --git a/code/bspc/qbsp.h b/code/bspc/qbsp.h new file mode 100644 index 00000000..c7d87cb8 --- /dev/null +++ b/code/bspc/qbsp.h @@ -0,0 +1,483 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + + +#if defined(WIN32) || defined(_WIN32) +#include +#endif +#include +#include "l_cmd.h" +#include "l_math.h" +#include "l_poly.h" +#include "l_threads.h" +#include "../botlib/l_script.h" +#include "l_bsp_ent.h" +#include "q2files.h" +#include "l_mem.h" +#include "l_utils.h" +#include "l_log.h" +#include "l_qfiles.h" + +#define BSPC_VERSION "2.1h" + +#define ME +#define DEBUG +#define NODELIST +#define SIN + +#define MAX_BRUSH_SIDES 128 //maximum number of sides per brush +#define CLIP_EPSILON 0.1 +#define MAX_MAP_BOUNDS 65535 +#define BOGUS_RANGE (MAX_MAP_BOUNDS+128) //somewhere outside the map +#define TEXINFO_NODE -1 //side is allready on a node +#define PLANENUM_LEAF -1 //used for leaf nodes +#define MAXEDGES 20 //maximum number of face edges +#define MAX_NODE_BRUSHES 8 //maximum brushes in a node +//side flags +#define SFL_TESTED 1 +#define SFL_VISIBLE 2 +#define SFL_BEVEL 4 +#define SFL_TEXTURED 8 +#define SFL_CURVE 16 + +// FIXME - IS THIS CORRECT ??? +#define LAST_VISIBLE_CONTENTS 64 + +#define Com_Memset memset +#define Com_Memcpy memcpy + +//map plane +typedef struct plane_s +{ + vec3_t normal; + vec_t dist; + int type; + int signbits; + struct plane_s *hash_chain; +} plane_t; +//brush texture +typedef struct +{ + vec_t shift[2]; + vec_t rotate; + vec_t scale[2]; + char name[32]; + int flags; + int value; +} brush_texture_t; +//brush side +typedef struct side_s +{ + int planenum; // map plane this side is in + int texinfo; // texture reference + winding_t *winding; // winding of this side + struct side_s *original; // bspbrush_t sides will reference the mapbrush_t sides + int lightinfo; // for SIN only + int contents; // from miptex + int surf; // from miptex + unsigned short flags; // side flags +} side_t; //sizeof(side_t) = 36 +//map brush +typedef struct mapbrush_s +{ + int entitynum; + int brushnum; + + int contents; +#ifdef ME + int expansionbbox; //bbox used for expansion of the brush + int leafnum; + int modelnum; +#endif + + vec3_t mins, maxs; + + int numsides; + side_t *original_sides; +} mapbrush_t; +//bsp face +typedef struct face_s +{ + struct face_s *next; // on node + + // the chain of faces off of a node can be merged or split, + // but each face_t along the way will remain in the chain + // until the entire tree is freed + struct face_s *merged; // if set, this face isn't valid anymore + struct face_s *split[2]; // if set, this face isn't valid anymore + + struct portal_s *portal; + int texinfo; +#ifdef SIN + int lightinfo; +#endif + int planenum; + int contents; // faces in different contents can't merge + int outputnumber; + winding_t *w; + int numpoints; + qboolean badstartvert; // tjunctions cannot be fixed without a midpoint vertex + int vertexnums[MAXEDGES]; +} face_t; +//bsp brush +typedef struct bspbrush_s +{ + struct bspbrush_s *next; + vec3_t mins, maxs; + int side, testside; // side of node during construction + mapbrush_t *original; + int numsides; + side_t sides[6]; // variably sized +} bspbrush_t; //sizeof(bspbrush_t) = 44 + numsides * sizeof(side_t) +//bsp node +typedef struct node_s +{ + //both leafs and nodes + int planenum; // -1 = leaf node + struct node_s *parent; + vec3_t mins, maxs; // valid after portalization + bspbrush_t *volume; // one for each leaf/node + + // nodes only + qboolean detail_seperator; // a detail brush caused the split + side_t *side; // the side that created the node + struct node_s *children[2]; + face_t *faces; + + // leafs only + bspbrush_t *brushlist; // fragments of all brushes in this leaf + int contents; // OR of all brush contents + int occupied; // 1 or greater can reach entity + entity_t *occupant; // for leak file testing + int cluster; // for portalfile writing + int area; // for areaportals + struct portal_s *portals; // also on nodes during construction +#ifdef NODELIST + struct node_s *next; //next node in the nodelist +#endif +#ifdef ME + int expansionbboxes; //OR of all bboxes used for expansion of the brushes + int modelnum; +#endif +} node_t; //sizeof(node_t) = 80 bytes +//bsp portal +typedef struct portal_s +{ + plane_t plane; + node_t *onnode; // NULL = outside box + node_t *nodes[2]; // [0] = front side of plane + struct portal_s *next[2]; + winding_t *winding; + + qboolean sidefound; // false if ->side hasn't been checked + side_t *side; // NULL = non-visible + face_t *face[2]; // output face in bsp file +#ifdef ME + struct tmp_face_s *tmpface; //pointer to the tmpface created for this portal + int planenum; //number of the map plane used by the portal +#endif +} portal_t; +//bsp tree +typedef struct +{ + node_t *headnode; + node_t outside_node; + vec3_t mins, maxs; +} tree_t; + +//============================================================================= +// bspc.c +//============================================================================= + +extern qboolean noprune; +extern qboolean nodetail; +extern qboolean fulldetail; +extern qboolean nomerge; +extern qboolean nosubdiv; +extern qboolean nowater; +extern qboolean noweld; +extern qboolean noshare; +extern qboolean notjunc; +extern qboolean onlyents; +#ifdef ME +extern qboolean nocsg; +extern qboolean create_aas; +extern qboolean freetree; +extern qboolean lessbrushes; +extern qboolean nobrushmerge; +extern qboolean cancelconversion; +extern qboolean noliquids; +extern qboolean capsule_collision; +#endif //ME + +extern float subdivide_size; +extern vec_t microvolume; + +extern char outbase[32]; +extern char source[1024]; + +//============================================================================= +// map.c +//============================================================================= + +#define MAX_MAPFILE_PLANES 256000 +#define MAX_MAPFILE_BRUSHES 65535 +#define MAX_MAPFILE_BRUSHSIDES (MAX_MAPFILE_BRUSHES*8) +#define MAX_MAPFILE_TEXINFO 8192 + +extern int entity_num; + +extern plane_t mapplanes[MAX_MAPFILE_PLANES]; +extern int nummapplanes; +extern int mapplaneusers[MAX_MAPFILE_PLANES]; + +extern int nummapbrushes; +extern mapbrush_t mapbrushes[MAX_MAPFILE_BRUSHES]; + +extern vec3_t map_mins, map_maxs; + +extern int nummapbrushsides; +extern side_t brushsides[MAX_MAPFILE_BRUSHSIDES]; +extern brush_texture_t side_brushtextures[MAX_MAPFILE_BRUSHSIDES]; + +#ifdef ME + +typedef struct +{ + float vecs[2][4]; // [s/t][xyz offset] + int flags; // miptex flags + overrides + int value; + char texture[64]; // texture name (textures/*.wal) + int nexttexinfo; // for animations, -1 = end of chain +} map_texinfo_t; + +extern map_texinfo_t map_texinfo[MAX_MAPFILE_TEXINFO]; +extern int map_numtexinfo; +#define NODESTACKSIZE 1024 + +#define MAPTYPE_QUAKE1 1 +#define MAPTYPE_QUAKE2 2 +#define MAPTYPE_QUAKE3 3 +#define MAPTYPE_HALFLIFE 4 +#define MAPTYPE_SIN 5 + +extern int nodestack[NODESTACKSIZE]; +extern int *nodestackptr; +extern int nodestacksize; +extern int brushmodelnumbers[MAX_MAPFILE_BRUSHES]; +extern int dbrushleafnums[MAX_MAPFILE_BRUSHES]; +extern int dplanes2mapplanes[MAX_MAPFILE_PLANES]; + +extern int loadedmaptype; +#endif //ME + +extern int c_boxbevels; +extern int c_edgebevels; +extern int c_areaportals; +extern int c_clipbrushes; +extern int c_squattbrushes; + +//finds a float plane for the given normal and distance +int FindFloatPlane(vec3_t normal, vec_t dist); +//returns the plane type for the given normal +int PlaneTypeForNormal(vec3_t normal); +//returns the plane defined by the three given points +int PlaneFromPoints(int *p0, int *p1, int *p2); +//add bevels to the map brush +void AddBrushBevels(mapbrush_t *b); +//makes brush side windings for the brush +qboolean MakeBrushWindings(mapbrush_t *ob); +//marks brush bevels of the brush as bevel +void MarkBrushBevels(mapbrush_t *brush); +//returns true if the map brush already exists +int BrushExists(mapbrush_t *brush); +//loads a map from a bsp file +int LoadMapFromBSP(struct quakefile_s *qf); +//resets map loading +void ResetMapLoading(void); +//print some map info +void PrintMapInfo(void); +//writes a map file (type depending on loaded map type) +void WriteMapFile(char *filename); + +//============================================================================= +// map_q2.c +//============================================================================= + +void Q2_ResetMapLoading(void); +//loads a Quake2 map file +void Q2_LoadMapFile(char *filename); +//loads a map from a Quake2 bsp file +void Q2_LoadMapFromBSP(char *filename, int offset, int length); + +//============================================================================= +// map_q1.c +//============================================================================= + +void Q1_ResetMapLoading(void); +//loads a Quake2 map file +void Q1_LoadMapFile(char *filename); +//loads a map from a Quake1 bsp file +void Q1_LoadMapFromBSP(char *filename, int offset, int length); + +//============================================================================= +// map_q3.c +//============================================================================= +void Q3_ResetMapLoading(void); +//loads a map from a Quake3 bsp file +void Q3_LoadMapFromBSP(struct quakefile_s *qf); + +//============================================================================= +// map_sin.c +//============================================================================= + +void Sin_ResetMapLoading(void); +//loads a Sin map file +void Sin_LoadMapFile(char *filename); +//loads a map from a Sin bsp file +void Sin_LoadMapFromBSP(char *filename, int offset, int length); + +//============================================================================= +// map_hl.c +//============================================================================= + +void HL_ResetMapLoading(void); +//loads a Half-Life map file +void HL_LoadMapFile(char *filename); +//loads a map from a Half-Life bsp file +void HL_LoadMapFromBSP(char *filename, int offset, int length); + +//============================================================================= +// textures.c +//============================================================================= + +typedef struct +{ + char name[64]; + int flags; + int value; + int contents; + char animname[64]; +} textureref_t; + +#define MAX_MAP_TEXTURES 1024 + +extern textureref_t textureref[MAX_MAP_TEXTURES]; + +int FindMiptex(char *name); +int TexinfoForBrushTexture(plane_t *plane, brush_texture_t *bt, vec3_t origin); +void TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv); + +//============================================================================= +// csg +//============================================================================= + +bspbrush_t *MakeBspBrushList(int startbrush, int endbrush, vec3_t clipmins, vec3_t clipmaxs); +bspbrush_t *ChopBrushes(bspbrush_t *head); +bspbrush_t *InitialBrushList(bspbrush_t *list); +bspbrush_t *OptimizedBrushList(bspbrush_t *list); +void WriteBrushMap(char *name, bspbrush_t *list); +void CheckBSPBrush(bspbrush_t *brush); +void BSPBrushWindings(bspbrush_t *brush); +bspbrush_t *TryMergeBrushes(bspbrush_t *brush1, bspbrush_t *brush2); +tree_t *ProcessWorldBrushes(int brush_start, int brush_end); + +//============================================================================= +// brushbsp +//============================================================================= + +#define PSIDE_FRONT 1 +#define PSIDE_BACK 2 +#define PSIDE_BOTH (PSIDE_FRONT|PSIDE_BACK) +#define PSIDE_FACING 4 + +void WriteBrushList(char *name, bspbrush_t *brush, qboolean onlyvis); +bspbrush_t *CopyBrush(bspbrush_t *brush); +void SplitBrush(bspbrush_t *brush, int planenum, bspbrush_t **front, bspbrush_t **back); +node_t *AllocNode(void); +bspbrush_t *AllocBrush(int numsides); +int CountBrushList(bspbrush_t *brushes); +void FreeBrush(bspbrush_t *brushes); +vec_t BrushVolume(bspbrush_t *brush); +void BoundBrush(bspbrush_t *brush); +void FreeBrushList(bspbrush_t *brushes); +tree_t *BrushBSP(bspbrush_t *brushlist, vec3_t mins, vec3_t maxs); +bspbrush_t *BrushFromBounds(vec3_t mins, vec3_t maxs); +int BrushMostlyOnSide(bspbrush_t *brush, plane_t *plane); +qboolean WindingIsHuge(winding_t *w); +qboolean WindingIsTiny(winding_t *w); +void ResetBrushBSP(void); + +//============================================================================= +// portals.c +//============================================================================= + +int VisibleContents (int contents); +void MakeHeadnodePortals (tree_t *tree); +void MakeNodePortal (node_t *node); +void SplitNodePortals (node_t *node); +qboolean Portal_VisFlood (portal_t *p); +qboolean FloodEntities (tree_t *tree); +void FillOutside (node_t *headnode); +void FloodAreas (tree_t *tree); +void MarkVisibleSides (tree_t *tree, int start, int end); +void FreePortal (portal_t *p); +void EmitAreaPortals (node_t *headnode); +void MakeTreePortals (tree_t *tree); + +//============================================================================= +// glfile.c +//============================================================================= + +void OutputWinding(winding_t *w, FILE *glview); +void WriteGLView(tree_t *tree, char *source); + +//============================================================================= +// gldraw.c +//============================================================================= + +extern vec3_t draw_mins, draw_maxs; +extern qboolean drawflag; + +void Draw_ClearWindow (void); +void DrawWinding (winding_t *w); +void GLS_BeginScene (void); +void GLS_Winding (winding_t *w, int code); +void GLS_EndScene (void); + +//============================================================================= +// leakfile.c +//============================================================================= + +void LeakFile (tree_t *tree); + +//============================================================================= +// tree.c +//============================================================================= + +tree_t *Tree_Alloc(void); +void Tree_Free(tree_t *tree); +void Tree_Free_r(node_t *node); +void Tree_Print_r(node_t *node, int depth); +void Tree_FreePortals_r(node_t *node); +void Tree_PruneNodes_r(node_t *node); +void Tree_PruneNodes(node_t *node); diff --git a/code/bspc/qfiles.h b/code/bspc/qfiles.h new file mode 100644 index 00000000..317e47cc --- /dev/null +++ b/code/bspc/qfiles.h @@ -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 +=========================================================================== +*/ + +// +// qfiles.h: quake file formats +// This file must be identical in the quake and utils directories +// + +/* +======================================================================== + +The .pak files are just a linear collapse of a directory tree + +======================================================================== +*/ + +#define IDPAKHEADER (('K'<<24)+('C'<<16)+('A'<<8)+'P') + +typedef struct +{ + char name[56]; + int filepos, filelen; +} dpackfile_t; + +typedef struct +{ + int ident; // == IDPAKHEADER + int dirofs; + int dirlen; +} dpackheader_t; + +#define MAX_FILES_IN_PACK 4096 + + +/* +======================================================================== + +PCX files are used for as many images as possible + +======================================================================== +*/ + +typedef struct +{ + char manufacturer; + char version; + char encoding; + char bits_per_pixel; + unsigned short xmin,ymin,xmax,ymax; + unsigned short hres,vres; + unsigned char palette[48]; + char reserved; + char color_planes; + unsigned short bytes_per_line; + unsigned short palette_type; + char filler[58]; + unsigned char data; // unbounded +} pcx_t; + + +/* +======================================================================== + +.MD2 triangle model file format + +======================================================================== +*/ + +#define IDALIASHEADER (('2'<<24)+('P'<<16)+('D'<<8)+'I') +#define ALIAS_VERSION 8 + +#define MAX_TRIANGLES 4096 +#define MAX_VERTS 2048 +#define MAX_FRAMES 512 +#define MAX_MD2SKINS 32 +#define MAX_SKINNAME 64 + +typedef struct +{ + short s; + short t; +} dstvert_t; + +typedef struct +{ + short index_xyz[3]; + short index_st[3]; +} dtriangle_t; + +typedef struct +{ + byte v[3]; // scaled byte to fit in frame mins/maxs + byte lightnormalindex; +} dtrivertx_t; + +#define DTRIVERTX_V0 0 +#define DTRIVERTX_V1 1 +#define DTRIVERTX_V2 2 +#define DTRIVERTX_LNI 3 +#define DTRIVERTX_SIZE 4 + +typedef struct +{ + float scale[3]; // multiply byte verts by this + float translate[3]; // then add this + char name[16]; // frame name from grabbing + dtrivertx_t verts[1]; // variable sized +} daliasframe_t; + + +// the glcmd format: +// a positive integer starts a tristrip command, followed by that many +// vertex structures. +// a negative integer starts a trifan command, followed by -x vertexes +// a zero indicates the end of the command list. +// a vertex consists of a floating point s, a floating point t, +// and an integer vertex index. + + +typedef struct +{ + int ident; + int version; + + int skinwidth; + int skinheight; + int framesize; // byte size of each frame + + int num_skins; + int num_xyz; + int num_st; // greater than num_xyz for seams + int num_tris; + int num_glcmds; // dwords in strip/fan command list + int num_frames; + + int ofs_skins; // each skin is a MAX_SKINNAME string + int ofs_st; // byte offset from start for stverts + int ofs_tris; // offset for dtriangles + int ofs_frames; // offset for first frame + int ofs_glcmds; + int ofs_end; // end of file + +} dmdl_t; + +/* +======================================================================== + +.SP2 sprite file format + +======================================================================== +*/ + +#define IDSPRITEHEADER (('2'<<24)+('S'<<16)+('D'<<8)+'I') + // little-endian "IDS2" +#define SPRITE_VERSION 2 + +typedef struct +{ + int width, height; + int origin_x, origin_y; // raster coordinates inside pic + char name[MAX_SKINNAME]; // name of pcx file +} dsprframe_t; + +typedef struct { + int ident; + int version; + int numframes; + dsprframe_t frames[1]; // variable sized +} dsprite_t; + +/* +============================================================================== + + .WAL texture file format + +============================================================================== +*/ + + +#define MIPLEVELS 4 +typedef struct miptex_s +{ + char name[32]; + unsigned width, height; + unsigned offsets[MIPLEVELS]; // four mip maps stored + char animname[32]; // next frame in animation chain + int flags; + int contents; + int value; +} miptex_t; + + + +/* +============================================================================== + + .BSP file format + +============================================================================== +*/ + +#define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I') + // little-endian "IBSP" + +#define BSPVERSION 38 + + +// upper design bounds +// leaffaces, leafbrushes, planes, and verts are still bounded by +// 16 bit short limits +#define MAX_MAP_MODELS 1024 +#define MAX_MAP_BRUSHES 8192 +#define MAX_MAP_ENTITIES 2048 +#define MAX_MAP_ENTSTRING 0x40000 +#define MAX_MAP_TEXINFO 8192 + +#define MAX_MAP_AREAS 256 +#define MAX_MAP_AREAPORTALS 1024 +#define MAX_MAP_PLANES 65536 +#define MAX_MAP_NODES 65536 +#define MAX_MAP_BRUSHSIDES 65536 +#define MAX_MAP_LEAFS 65536 +#define MAX_MAP_VERTS 65536 +#define MAX_MAP_FACES 65536 +#define MAX_MAP_LEAFFACES 65536 +#define MAX_MAP_LEAFBRUSHES 65536 +#define MAX_MAP_PORTALS 65536 +#define MAX_MAP_EDGES 128000 +#define MAX_MAP_SURFEDGES 256000 +#define MAX_MAP_LIGHTING 0x320000 +#define MAX_MAP_VISIBILITY 0x280000 + +// key / value pair sizes + +#define MAX_KEY 32 +#define MAX_VALUE 1024 + +//============================================================================= + +typedef struct +{ + int fileofs, filelen; +} lump_t; + +#define LUMP_ENTITIES 0 +#define LUMP_PLANES 1 +#define LUMP_VERTEXES 2 +#define LUMP_VISIBILITY 3 +#define LUMP_NODES 4 +#define LUMP_TEXINFO 5 +#define LUMP_FACES 6 +#define LUMP_LIGHTING 7 +#define LUMP_LEAFS 8 +#define LUMP_LEAFFACES 9 +#define LUMP_LEAFBRUSHES 10 +#define LUMP_EDGES 11 +#define LUMP_SURFEDGES 12 +#define LUMP_MODELS 13 +#define LUMP_BRUSHES 14 +#define LUMP_BRUSHSIDES 15 +#define LUMP_POP 16 +#define LUMP_AREAS 17 +#define LUMP_AREAPORTALS 18 +#define HEADER_LUMPS 19 + +typedef struct +{ + int ident; + int version; + lump_t lumps[HEADER_LUMPS]; +} dheader_t; + +typedef struct +{ + float mins[3], maxs[3]; + float origin[3]; // for sounds or lights + int headnode; + int firstface, numfaces; // submodels just draw faces + // without walking the bsp tree +} dmodel_t; + + +typedef struct +{ + float point[3]; +} dvertex_t; + + +// 0-2 are axial planes +#define PLANE_X 0 +#define PLANE_Y 1 +#define PLANE_Z 2 + +// 3-5 are non-axial planes snapped to the nearest +#define PLANE_ANYX 3 +#define PLANE_ANYY 4 +#define PLANE_ANYZ 5 + +// planes (x&~1) and (x&~1)+1 are allways opposites + +typedef struct +{ + float normal[3]; + float dist; + int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate +} dplane_t; + + +// contents flags are seperate bits +// a given brush can contribute multiple content bits +// multiple brushes can be in a single leaf + +// these definitions also need to be in q_shared.h! + +// lower bits are stronger, and will eat weaker brushes completely +#define CONTENTS_SOLID 1 // an eye is never valid in a solid +#define CONTENTS_WINDOW 2 // translucent, but not watery +#define CONTENTS_AUX 4 +#define CONTENTS_LAVA 8 +#define CONTENTS_SLIME 16 +#define CONTENTS_WATER 32 +#define CONTENTS_MIST 64 +#define LAST_VISIBLE_CONTENTS 64 + +// remaining contents are non-visible, and don't eat brushes + +#define CONTENTS_AREAPORTAL 0x8000 + +#define CONTENTS_PLAYERCLIP 0x10000 +#define CONTENTS_MONSTERCLIP 0x20000 + +// currents can be added to any other contents, and may be mixed +#define CONTENTS_CURRENT_0 0x40000 +#define CONTENTS_CURRENT_90 0x80000 +#define CONTENTS_CURRENT_180 0x100000 +#define CONTENTS_CURRENT_270 0x200000 +#define CONTENTS_CURRENT_UP 0x400000 +#define CONTENTS_CURRENT_DOWN 0x800000 + +#define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity + +#define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game +#define CONTENTS_DEADMONSTER 0x4000000 +#define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs +//renamed because it's in conflict with the Q3A translucent contents +#define CONTENTS_Q2TRANSLUCENT 0x10000000 // auto set if any surface has trans +#define CONTENTS_LADDER 0x20000000 + + + +#define SURF_LIGHT 0x1 // value will hold the light strength + +#define SURF_SLICK 0x2 // effects game physics + +#define SURF_SKY 0x4 // don't draw, but add to skybox +#define SURF_WARP 0x8 // turbulent water warp +#define SURF_TRANS33 0x10 +#define SURF_TRANS66 0x20 +#define SURF_FLOWING 0x40 // scroll towards angle +#define SURF_NODRAW 0x80 // don't bother referencing the texture + +#define SURF_HINT 0x100 // make a primary bsp splitter +#define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes + + + +typedef struct +{ + int planenum; + int children[2]; // negative numbers are -(leafs+1), not nodes + short mins[3]; // for frustom culling + short maxs[3]; + unsigned short firstface; + unsigned short numfaces; // counting both sides +} dnode_t; + + +typedef struct texinfo_s +{ + float vecs[2][4]; // [s/t][xyz offset] + int flags; // miptex flags + overrides + int value; // light emission, etc + char texture[32]; // texture name (textures/*.wal) + int nexttexinfo; // for animations, -1 = end of chain +} texinfo_t; + + +// note that edge 0 is never used, because negative edge nums are used for +// counterclockwise use of the edge in a face +typedef struct +{ + unsigned short v[2]; // vertex numbers +} dedge_t; + +#define MAXLIGHTMAPS 4 +typedef struct +{ + unsigned short planenum; + short side; + + int firstedge; // we must support > 64k edges + short numedges; + short texinfo; + +// lighting info + byte styles[MAXLIGHTMAPS]; + int lightofs; // start of [numstyles*surfsize] samples +} dface_t; + +typedef struct +{ + int contents; // OR of all brushes (not needed?) + + short cluster; + short area; + + short mins[3]; // for frustum culling + short maxs[3]; + + unsigned short firstleafface; + unsigned short numleaffaces; + + unsigned short firstleafbrush; + unsigned short numleafbrushes; +} dleaf_t; + +typedef struct +{ + unsigned short planenum; // facing out of the leaf + short texinfo; +} dbrushside_t; + +typedef struct +{ + int firstside; + int numsides; + int contents; +} dbrush_t; + +#define ANGLE_UP -1 +#define ANGLE_DOWN -2 + + +// the visibility lump consists of a header with a count, then +// byte offsets for the PVS and PHS of each cluster, then the raw +// compressed bit vectors +#define DVIS_PVS 0 +#define DVIS_PHS 1 +typedef struct +{ + int numclusters; + int bitofs[8][2]; // bitofs[numclusters][2] +} dvis_t; + +// each area has a list of portals that lead into other areas +// when portals are closed, other areas may not be visible or +// hearable even if the vis info says that it should be +typedef struct +{ + int portalnum; + int otherarea; +} dareaportal_t; + +typedef struct +{ + int numareaportals; + int firstareaportal; +} darea_t; diff --git a/code/bspc/sinfiles.h b/code/bspc/sinfiles.h new file mode 100644 index 00000000..bcb5ee68 --- /dev/null +++ b/code/bspc/sinfiles.h @@ -0,0 +1,365 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +/* +============================================================================== + + .BSP file format + +============================================================================== +*/ + +#define SIN + +#define SINBSPVERSION 41 + +// upper design bounds +// leaffaces, leafbrushes, planes, and verts are still bounded by +// 16 bit short limits +#define SIN_MAX_MAP_MODELS 1024 +#define SIN_MAX_MAP_BRUSHES 8192 +#define SIN_MAX_MAP_ENTITIES 2048 +#define SIN_MAX_MAP_ENTSTRING 0x40000 +#define SIN_MAX_MAP_TEXINFO 8192 + +#define SIN_MAX_MAP_AREAS 256 +#define SIN_MAX_MAP_AREAPORTALS 1024 +#define SIN_MAX_MAP_PLANES 65536 +#define SIN_MAX_MAP_NODES 65536 +#define SIN_MAX_MAP_BRUSHSIDES 65536 +#define SIN_MAX_MAP_LEAFS 65536 +#define SIN_MAX_MAP_VERTS 65536 +#define SIN_MAX_MAP_FACES 65536 +#define SIN_MAX_MAP_LEAFFACES 65536 +#define SIN_MAX_MAP_LEAFBRUSHES 65536 +#define SIN_MAX_MAP_PORTALS 65536 +#define SIN_MAX_MAP_EDGES 128000 +#define SIN_MAX_MAP_SURFEDGES 256000 +#define SIN_MAX_MAP_LIGHTING 0x320000 +#define SIN_MAX_MAP_VISIBILITY 0x280000 + +#ifdef SIN +#define SIN_MAX_MAP_LIGHTINFO 8192 +#endif + +#ifdef SIN +#undef SIN_MAX_MAP_LIGHTING //undef the Quake2 bsp version +#define SIN_MAX_MAP_LIGHTING 0x300000 +#endif + +#ifdef SIN +#undef SIN_MAX_MAP_VISIBILITY //undef the Quake2 bsp version +#define SIN_MAX_MAP_VISIBILITY 0x280000 +#endif + +//============================================================================= + +typedef struct +{ + int fileofs, filelen; +} sin_lump_t; + +#define SIN_LUMP_ENTITIES 0 +#define SIN_LUMP_PLANES 1 +#define SIN_LUMP_VERTEXES 2 +#define SIN_LUMP_VISIBILITY 3 +#define SIN_LUMP_NODES 4 +#define SIN_LUMP_TEXINFO 5 +#define SIN_LUMP_FACES 6 +#define SIN_LUMP_LIGHTING 7 +#define SIN_LUMP_LEAFS 8 +#define SIN_LUMP_LEAFFACES 9 +#define SIN_LUMP_LEAFBRUSHES 10 +#define SIN_LUMP_EDGES 11 +#define SIN_LUMP_SURFEDGES 12 +#define SIN_LUMP_MODELS 13 +#define SIN_LUMP_BRUSHES 14 +#define SIN_LUMP_BRUSHSIDES 15 +#define SIN_LUMP_POP 16 +#define SIN_LUMP_AREAS 17 +#define SIN_LUMP_AREAPORTALS 18 + +#ifdef SIN +#define SIN_LUMP_LIGHTINFO 19 +#define SINHEADER_LUMPS 20 +#endif + +typedef struct +{ + int ident; + int version; + sin_lump_t lumps[SINHEADER_LUMPS]; +} sin_dheader_t; + +typedef struct +{ + float mins[3], maxs[3]; + float origin[3]; // for sounds or lights + int headnode; + int firstface, numfaces; // submodels just draw faces + // without walking the bsp tree +} sin_dmodel_t; + +typedef struct +{ + float point[3]; +} sin_dvertex_t; + + +// 0-2 are axial planes +#define PLANE_X 0 +#define PLANE_Y 1 +#define PLANE_Z 2 + +// 3-5 are non-axial planes snapped to the nearest +#define PLANE_ANYX 3 +#define PLANE_ANYY 4 +#define PLANE_ANYZ 5 + +// planes (x&~1) and (x&~1)+1 are allways opposites + +typedef struct +{ + float normal[3]; + float dist; + int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate +} sin_dplane_t; + + +// contents flags are seperate bits +// a given brush can contribute multiple content bits +// multiple brushes can be in a single leaf + +// these definitions also need to be in q_shared.h! + +// lower bits are stronger, and will eat weaker brushes completely +#ifdef SIN +#define CONTENTS_FENCE 4 +#endif +// remaining contents are non-visible, and don't eat brushes + +#ifdef SIN +#define CONTENTS_DUMMYFENCE 0x1000 +#endif + +#ifdef SIN +#define SURF_MASKED 0x2 // surface texture is masked +#endif + +#define SURF_SKY 0x4 // don't draw, but add to skybox +#define SURF_WARP 0x8 // turbulent water warp + +#ifdef SIN +#define SURF_NONLIT 0x10 // surface is not lit +#define SURF_NOFILTER 0x20 // surface is not bi-linear filtered +#endif + +#define SURF_FLOWING 0x40 // scroll towards angle +#define SURF_NODRAW 0x80 // don't bother referencing the texture + +#define SURF_HINT 0x100 // make a primary bsp splitter +#define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes + +#ifdef SIN +#define SURF_CONVEYOR 0x40 // surface is not lit +#endif + +#ifdef SIN +#define SURF_WAVY 0x400 // surface has waves +#define SURF_RICOCHET 0x800 // projectiles bounce literally bounce off this surface +#define SURF_PRELIT 0x1000 // surface has intensity information for pre-lighting +#define SURF_MIRROR 0x2000 // surface is a mirror +#define SURF_CONSOLE 0x4000 // surface is a console +#define SURF_USECOLOR 0x8000 // surface is lit with non-lit * color +#define SURF_HARDWAREONLY 0x10000 // surface has been damaged +#define SURF_DAMAGE 0x20000 // surface can be damaged +#define SURF_WEAK 0x40000 // surface has weak hit points +#define SURF_NORMAL 0x80000 // surface has normal hit points +#define SURF_ADD 0x100000 // surface will be additive +#define SURF_ENVMAPPED 0x200000 // surface is envmapped +#define SURF_RANDOMANIMATE 0x400000 // surface start animating on a random frame +#define SURF_ANIMATE 0x800000 // surface animates +#define SURF_RNDTIME 0x1000000 // time between animations is random +#define SURF_TRANSLATE 0x2000000 // surface translates +#define SURF_NOMERGE 0x4000000 // surface is not merged in csg phase +#define SURF_TYPE_BIT0 0x8000000 // 0 bit of surface type +#define SURF_TYPE_BIT1 0x10000000 // 1 bit of surface type +#define SURF_TYPE_BIT2 0x20000000 // 2 bit of surface type +#define SURF_TYPE_BIT3 0x40000000 // 3 bit of surface type + +#define SURF_START_BIT 27 +#define SURFACETYPE_FROM_FLAGS( x ) ( ( x >> (SURF_START_BIT) ) & 0xf ) + + +#define SURF_TYPE_SHIFT(x) ( (x) << (SURF_START_BIT) ) // macro for getting proper bit mask + +#define SURF_TYPE_NONE SURF_TYPE_SHIFT(0) +#define SURF_TYPE_WOOD SURF_TYPE_SHIFT(1) +#define SURF_TYPE_METAL SURF_TYPE_SHIFT(2) +#define SURF_TYPE_STONE SURF_TYPE_SHIFT(3) +#define SURF_TYPE_CONCRETE SURF_TYPE_SHIFT(4) +#define SURF_TYPE_DIRT SURF_TYPE_SHIFT(5) +#define SURF_TYPE_FLESH SURF_TYPE_SHIFT(6) +#define SURF_TYPE_GRILL SURF_TYPE_SHIFT(7) +#define SURF_TYPE_GLASS SURF_TYPE_SHIFT(8) +#define SURF_TYPE_FABRIC SURF_TYPE_SHIFT(9) +#define SURF_TYPE_MONITOR SURF_TYPE_SHIFT(10) +#define SURF_TYPE_GRAVEL SURF_TYPE_SHIFT(11) +#define SURF_TYPE_VEGETATION SURF_TYPE_SHIFT(12) +#define SURF_TYPE_PAPER SURF_TYPE_SHIFT(13) +#define SURF_TYPE_DUCT SURF_TYPE_SHIFT(14) +#define SURF_TYPE_WATER SURF_TYPE_SHIFT(15) +#endif + + +typedef struct +{ + int planenum; + int children[2]; // negative numbers are -(leafs+1), not nodes + short mins[3]; // for frustom culling + short maxs[3]; + unsigned short firstface; + unsigned short numfaces; // counting both sides +} sin_dnode_t; + +#ifdef SIN + +typedef struct sin_lightvalue_s +{ + int value; // light emission, etc + vec3_t color; + float direct; + float directangle; + float directstyle; + char directstylename[32]; +} sin_lightvalue_t; + +typedef struct sin_texinfo_s +{ + float vecs[2][4]; // [s/t][xyz offset] + int flags; // miptex flags + overrides + char texture[64]; // texture name (textures/*.wal) + int nexttexinfo; // for animations, -1 = end of chain + float trans_mag; + int trans_angle; + int base_angle; + float animtime; + float nonlit; + float translucence; + float friction; + float restitution; + vec3_t color; + char groupname[32]; +} sin_texinfo_t; + +#endif //SIN + +// note that edge 0 is never used, because negative edge nums are used for +// counterclockwise use of the edge in a face +typedef struct +{ + unsigned short v[2]; // vertex numbers +} sin_dedge_t; + +#ifdef MAXLIGHTMAPS +#undef MAXLIGHTMAPS +#endif +#define MAXLIGHTMAPS 16 +typedef struct +{ + unsigned short planenum; + short side; + + int firstedge; // we must support > 64k edges + short numedges; + short texinfo; + +// lighting info + byte styles[MAXLIGHTMAPS]; + int lightofs; // start of [numstyles*surfsize] samples +#ifdef SIN + int lightinfo; +#endif +} sin_dface_t; + +typedef struct +{ + int contents; // OR of all brushes (not needed?) + + short cluster; + short area; + + short mins[3]; // for frustum culling + short maxs[3]; + + unsigned short firstleafface; + unsigned short numleaffaces; + + unsigned short firstleafbrush; + unsigned short numleafbrushes; +} sin_dleaf_t; + +typedef struct +{ + unsigned short planenum; // facing out of the leaf + short texinfo; +#ifdef SIN + int lightinfo; +#endif +} sin_dbrushside_t; + +typedef struct +{ + int firstside; + int numsides; + int contents; +} sin_dbrush_t; + +#define ANGLE_UP -1 +#define ANGLE_DOWN -2 + + +// the visibility lump consists of a header with a count, then +// byte offsets for the PVS and PHS of each cluster, then the raw +// compressed bit vectors +#define DVIS_PVS 0 +#define DVIS_PHS 1 +typedef struct +{ + int numclusters; + int bitofs[8][2]; // bitofs[numclusters][2] +} sin_dvis_t; + +// each area has a list of portals that lead into other areas +// when portals are closed, other areas may not be visible or +// hearable even if the vis info says that it should be +typedef struct +{ + int portalnum; + int otherarea; +} sin_dareaportal_t; + +typedef struct +{ + int numareaportals; + int firstareaportal; +} sin_darea_t; diff --git a/code/bspc/tetrahedron.c b/code/bspc/tetrahedron.c new file mode 100644 index 00000000..4c4d2514 --- /dev/null +++ b/code/bspc/tetrahedron.c @@ -0,0 +1,1389 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" +#include "l_mem.h" +#include "../botlib/aasfile.h" +#include "aas_store.h" +#include "aas_cfg.h" +#include "aas_file.h" + +// +// creating tetrahedrons from a arbitrary world bounded by triangles +// +// a triangle has 3 corners and 3 edges +// a tetrahedron is build out of 4 triangles +// a tetrahedron has 6 edges +// we start with a world bounded by triangles, a side of a triangle facing +// towards the oudside of the world is marked as part of tetrahedron -1 +// +// a tetrahedron is defined by two non-coplanar triangles with a shared edge +// +// a tetrahedron is defined by one triangle and a vertex not in the triangle plane +// +// if all triangles using a specific vertex have tetrahedrons +// at both sides then this vertex will never be part of a new tetrahedron +// +// if all triangles using a specific edge have tetrahedrons +// at both sides then this vertex will never be part of a new tetrahedron +// +// each triangle can only be shared by two tetrahedrons +// when all triangles have tetrahedrons at both sides then we're done +// +// if we cannot create any new tetrahedrons and there is at least one triangle +// which has a tetrahedron only at one side then the world leaks +// + +#define Sign(x) (x < 0 ? 1 : 0) + +#define MAX_TH_VERTEXES 128000 +#define MAX_TH_PLANES 128000 +#define MAX_TH_EDGES 512000 +#define MAX_TH_TRIANGLES 51200 +#define MAX_TH_TETRAHEDRONS 12800 + +#define PLANEHASH_SIZE 1024 +#define EDGEHASH_SIZE 1024 +#define TRIANGLEHASH_SIZE 1024 +#define VERTEXHASH_SHIFT 7 +#define VERTEXHASH_SIZE ((MAX_MAP_BOUNDS>>(VERTEXHASH_SHIFT-1))+1) //was 64 + +#define NORMAL_EPSILON 0.0001 +#define DIST_EPSILON 0.1 +#define VERTEX_EPSILON 0.01 +#define INTEGRAL_EPSILON 0.01 + + +//plane +typedef struct th_plane_s +{ + vec3_t normal; + float dist; + int type; + int signbits; + struct th_plane_s *hashnext; //next plane in hash +} th_plane_t; + +//vertex +typedef struct th_vertex_s +{ + vec3_t v; + int usercount; //2x the number of to be processed + //triangles using this vertex + struct th_vertex_s *hashnext; //next vertex in hash +} th_vertex_t; + +//edge +typedef struct th_edge_s +{ + int v[2]; //vertex indexes + int usercount; //number of to be processed + //triangles using this edge + struct th_edge_s *hashnext; //next edge in hash +} th_edge_t; + +//triangle +typedef struct th_triangle_s +{ + int edges[3]; //negative if edge is flipped + th_plane_t planes[3]; //triangle bounding planes + int planenum; //plane the triangle is in + int front; //tetrahedron at the front + int back; //tetrahedron at the back + vec3_t mins, maxs; //triangle bounding box + struct th_triangle_s *prev, *next; //links in linked triangle lists + struct th_triangle_s *hashnext; //next triangle in hash +} th_triangle_t; + +//tetrahedron +typedef struct th_tetrahedron_s +{ + int triangles[4]; //negative if at backside of triangle + float volume; //tetrahedron volume +} th_tetrahedron_t; + +typedef struct th_s +{ + //vertexes + int numvertexes; + th_vertex_t *vertexes; + th_vertex_t *vertexhash[VERTEXHASH_SIZE * VERTEXHASH_SIZE]; + //planes + int numplanes; + th_plane_t *planes; + th_plane_t *planehash[PLANEHASH_SIZE]; + //edges + int numedges; + th_edge_t *edges; + th_edge_t *edgehash[EDGEHASH_SIZE]; + //triangles + int numtriangles; + th_triangle_t *triangles; + th_triangle_t *trianglehash[TRIANGLEHASH_SIZE]; + //tetrahedrons + int numtetrahedrons; + th_tetrahedron_t *tetrahedrons; +} th_t; + +th_t thworld; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_InitMaxTH(void) +{ + //get memory for the tetrahedron data + thworld.vertexes = (th_vertex_t *) GetClearedMemory(MAX_TH_VERTEXES * sizeof(th_vertex_t)); + thworld.planes = (th_plane_t *) GetClearedMemory(MAX_TH_PLANES * sizeof(th_plane_t)); + thworld.edges = (th_edge_t *) GetClearedMemory(MAX_TH_EDGES * sizeof(th_edge_t)); + thworld.triangles = (th_triangle_t *) GetClearedMemory(MAX_TH_TRIANGLES * sizeof(th_triangle_t)); + thworld.tetrahedrons = (th_tetrahedron_t *) GetClearedMemory(MAX_TH_TETRAHEDRONS * sizeof(th_tetrahedron_t)); + //reset the hash tables + memset(thworld.vertexhash, 0, VERTEXHASH_SIZE * sizeof(th_vertex_t *)); + memset(thworld.planehash, 0, PLANEHASH_SIZE * sizeof(th_plane_t *)); + memset(thworld.edgehash, 0, EDGEHASH_SIZE * sizeof(th_edge_t *)); + memset(thworld.trianglehash, 0, TRIANGLEHASH_SIZE * sizeof(th_triangle_t *)); +} //end of the function TH_InitMaxTH +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_FreeMaxTH(void) +{ + if (thworld.vertexes) FreeMemory(thworld.vertexes); + thworld.vertexes = NULL; + thworld.numvertexes = 0; + if (thworld.planes) FreeMemory(thworld.planes); + thworld.planes = NULL; + thworld.numplanes = 0; + if (thworld.edges) FreeMemory(thworld.edges); + thworld.edges = NULL; + thworld.numedges = 0; + if (thworld.triangles) FreeMemory(thworld.triangles); + thworld.triangles = NULL; + thworld.numtriangles = 0; + if (thworld.tetrahedrons) FreeMemory(thworld.tetrahedrons); + thworld.tetrahedrons = NULL; + thworld.numtetrahedrons = 0; +} //end of the function TH_FreeMaxTH +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float TH_TriangleArea(th_triangle_t *tri) +{ + return 0; +} //end of the function TH_TriangleArea +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +float TH_TetrahedronVolume(th_tetrahedron_t *tetrahedron) +{ + int edgenum, verts[3], i, j, v2; + float volume, d; + th_triangle_t *tri, *tri2; + th_plane_t *plane; + + tri = &thworld.triangles[abs(tetrahedron->triangles[0])]; + for (i = 0; i < 3; i++) + { + edgenum = tri->edges[i]; + if (edgenum < 0) verts[i] = thworld.edges[abs(edgenum)].v[1]; + else verts[i] = thworld.edges[edgenum].v[0]; + } //end for + // + tri2 = &thworld.triangles[abs(tetrahedron->triangles[1])]; + for (j = 0; j < 3; j++) + { + edgenum = tri2->edges[i]; + if (edgenum < 0) v2 = thworld.edges[abs(edgenum)].v[1]; + else v2 = thworld.edges[edgenum].v[0]; + if (v2 != verts[0] && + v2 != verts[1] && + v2 != verts[2]) break; + } //end for + + plane = &thworld.planes[tri->planenum]; + d = -(DotProduct (thworld.vertexes[v2].v, plane->normal) - plane->dist); + volume = TH_TriangleArea(tri) * d / 3; + return volume; +} //end of the function TH_TetrahedronVolume +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_PlaneSignBits(vec3_t normal) +{ + int i, signbits; + + signbits = 0; + for (i = 2; i >= 0; i--) + { + signbits = (signbits << 1) + Sign(normal[i]); + } //end for + return signbits; +} //end of the function TH_PlaneSignBits +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_PlaneTypeForNormal(vec3_t normal) +{ + vec_t ax, ay, az; + +// NOTE: should these have an epsilon around 1.0? + if (normal[0] == 1.0 || normal[0] == -1.0) + return PLANE_X; + if (normal[1] == 1.0 || normal[1] == -1.0) + return PLANE_Y; + if (normal[2] == 1.0 || normal[2] == -1.0) + return PLANE_Z; + + ax = fabs(normal[0]); + ay = fabs(normal[1]); + az = fabs(normal[2]); + + if (ax >= ay && ax >= az) + return PLANE_ANYX; + if (ay >= ax && ay >= az) + return PLANE_ANYY; + return PLANE_ANYZ; +} //end of the function TH_PlaneTypeForNormal +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +qboolean TH_PlaneEqual(th_plane_t *p, vec3_t normal, vec_t dist) +{ + if ( + fabs(p->normal[0] - normal[0]) < NORMAL_EPSILON + && fabs(p->normal[1] - normal[1]) < NORMAL_EPSILON + && fabs(p->normal[2] - normal[2]) < NORMAL_EPSILON + && fabs(p->dist - dist) < DIST_EPSILON ) + return true; + return false; +} //end of the function TH_PlaneEqual +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_AddPlaneToHash(th_plane_t *p) +{ + int hash; + + hash = (int)fabs(p->dist) / 8; + hash &= (PLANEHASH_SIZE-1); + + p->hashnext = thworld.planehash[hash]; + thworld.planehash[hash] = p; +} //end of the function TH_AddPlaneToHash +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_CreateFloatPlane(vec3_t normal, vec_t dist) +{ + th_plane_t *p, temp; + + if (VectorLength(normal) < 0.5) + Error ("FloatPlane: bad normal"); + // create a new plane + if (thworld.numplanes+2 > MAX_TH_PLANES) + Error ("MAX_TH_PLANES"); + + p = &thworld.planes[thworld.numplanes]; + VectorCopy (normal, p->normal); + p->dist = dist; + p->type = (p+1)->type = TH_PlaneTypeForNormal (p->normal); + p->signbits = TH_PlaneSignBits(p->normal); + + VectorSubtract (vec3_origin, normal, (p+1)->normal); + (p+1)->dist = -dist; + (p+1)->signbits = TH_PlaneSignBits((p+1)->normal); + + thworld.numplanes += 2; + + // allways put axial planes facing positive first + if (p->type < 3) + { + if (p->normal[0] < 0 || p->normal[1] < 0 || p->normal[2] < 0) + { + // flip order + temp = *p; + *p = *(p+1); + *(p+1) = temp; + + TH_AddPlaneToHash(p); + TH_AddPlaneToHash(p+1); + return thworld.numplanes - 1; + } //end if + } //end if + + TH_AddPlaneToHash(p); + TH_AddPlaneToHash(p+1); + return thworld.numplanes - 2; +} //end of the function TH_CreateFloatPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_SnapVector(vec3_t normal) +{ + int i; + + for (i = 0; i < 3; i++) + { + if ( fabs(normal[i] - 1) < NORMAL_EPSILON ) + { + VectorClear (normal); + normal[i] = 1; + break; + } //end if + if ( fabs(normal[i] - -1) < NORMAL_EPSILON ) + { + VectorClear (normal); + normal[i] = -1; + break; + } //end if + } //end for +} //end of the function TH_SnapVector +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_SnapPlane(vec3_t normal, vec_t *dist) +{ + TH_SnapVector(normal); + + if (fabs(*dist-Q_rint(*dist)) < DIST_EPSILON) + *dist = Q_rint(*dist); +} //end of the function TH_SnapPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_FindFloatPlane(vec3_t normal, vec_t dist) +{ + int i; + th_plane_t *p; + int hash, h; + + TH_SnapPlane (normal, &dist); + hash = (int)fabs(dist) / 8; + hash &= (PLANEHASH_SIZE-1); + + // search the border bins as well + for (i = -1; i <= 1; i++) + { + h = (hash+i)&(PLANEHASH_SIZE-1); + for (p = thworld.planehash[h]; p; p = p->hashnext) + { + if (TH_PlaneEqual(p, normal, dist)) + { + return p - thworld.planes; + } //end if + } //end for + } //end for + return TH_CreateFloatPlane(normal, dist); +} //end of the function TH_FindFloatPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_PlaneFromPoints(int v1, int v2, int v3) +{ + vec3_t t1, t2, normal; + vec_t dist; + float *p0, *p1, *p2; + + p0 = thworld.vertexes[v1].v; + p1 = thworld.vertexes[v2].v; + p2 = thworld.vertexes[v3].v; + + VectorSubtract(p0, p1, t1); + VectorSubtract(p2, p1, t2); + CrossProduct(t1, t2, normal); + VectorNormalize(normal); + + dist = DotProduct(p0, normal); + + return TH_FindFloatPlane(normal, dist); +} //end of the function TH_PlaneFromPoints +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_AddEdgeUser(int edgenum) +{ + th_edge_t *edge; + + edge = &thworld.edges[abs(edgenum)]; + //increase edge user count + edge->usercount++; + //increase vertex user count as well + thworld.vertexes[edge->v[0]].usercount++; + thworld.vertexes[edge->v[1]].usercount++; +} //end of the function TH_AddEdgeUser +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_RemoveEdgeUser(int edgenum) +{ + th_edge_t *edge; + + edge = &thworld.edges[abs(edgenum)]; + //decrease edge user count + edge->usercount--; + //decrease vertex user count as well + thworld.vertexes[edge->v[0]].usercount--; + thworld.vertexes[edge->v[1]].usercount--; +} //end of the function TH_RemoveEdgeUser +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_FreeTriangleEdges(th_triangle_t *tri) +{ + int i; + + for (i = 0; i < 3; i++) + { + TH_RemoveEdgeUser(abs(tri->edges[i])); + } //end for +} //end of the function TH_FreeTriangleEdges +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +unsigned TH_HashVec(vec3_t vec) +{ + int x, y; + + x = (MAX_MAP_BOUNDS + (int)(vec[0]+0.5)) >> VERTEXHASH_SHIFT; + y = (MAX_MAP_BOUNDS + (int)(vec[1]+0.5)) >> VERTEXHASH_SHIFT; + + if (x < 0 || x >= VERTEXHASH_SIZE || y < 0 || y >= VERTEXHASH_SIZE) + Error("HashVec: point %f %f %f outside valid range", vec[0], vec[1], vec[2]); + + return y*VERTEXHASH_SIZE + x; +} //end of the function TH_HashVec +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_FindVertex(vec3_t v) +{ + int i, h; + th_vertex_t *vertex; + vec3_t vert; + + for (i = 0; i < 3; i++) + { + if ( fabs(v[i] - Q_rint(v[i])) < INTEGRAL_EPSILON) + vert[i] = Q_rint(v[i]); + else + vert[i] = v[i]; + } //end for + + h = TH_HashVec(vert); + + for (vertex = thworld.vertexhash[h]; vertex; vertex = vertex->hashnext) + { + if (fabs(vertex->v[0] - vert[0]) < VERTEX_EPSILON && + fabs(vertex->v[1] - vert[1]) < VERTEX_EPSILON && + fabs(vertex->v[2] - vert[2]) < VERTEX_EPSILON) + { + return vertex - thworld.vertexes; + } //end if + } //end for + return 0; +} //end of the function TH_FindVertex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_AddVertexToHash(th_vertex_t *vertex) +{ + int hashvalue; + + hashvalue = TH_HashVec(vertex->v); + vertex->hashnext = thworld.vertexhash[hashvalue]; + thworld.vertexhash[hashvalue] = vertex; +} //end of the function TH_AddVertexToHash +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_CreateVertex(vec3_t v) +{ + if (thworld.numvertexes == 0) thworld.numvertexes = 1; + if (thworld.numvertexes >= MAX_TH_VERTEXES) + Error("MAX_TH_VERTEXES"); + VectorCopy(v, thworld.vertexes[thworld.numvertexes].v); + thworld.vertexes[thworld.numvertexes].usercount = 0; + TH_AddVertexToHash(&thworld.vertexes[thworld.numvertexes]); + thworld.numvertexes++; + return thworld.numvertexes-1; +} //end of the function TH_CreateVertex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_FindOrCreateVertex(vec3_t v) +{ + int vertexnum; + + vertexnum = TH_FindVertex(v); + if (!vertexnum) vertexnum = TH_CreateVertex(v); + return vertexnum; +} //end of the function TH_FindOrCreateVertex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_FindEdge(int v1, int v2) +{ + int hashvalue; + th_edge_t *edge; + + hashvalue = (v1 + v2) & (EDGEHASH_SIZE-1); + + for (edge = thworld.edgehash[hashvalue]; edge; edge = edge->hashnext) + { + if (edge->v[0] == v1 && edge->v[1] == v2) return edge - thworld.edges; + if (edge->v[1] == v1 && edge->v[0] == v2) return -(edge - thworld.edges); + } //end for + return 0; +} //end of the function TH_FindEdge +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_AddEdgeToHash(th_edge_t *edge) +{ + int hashvalue; + + hashvalue = (edge->v[0] + edge->v[1]) & (EDGEHASH_SIZE-1); + edge->hashnext = thworld.edgehash[hashvalue]; + thworld.edgehash[hashvalue] = edge; +} //end of the function TH_AddEdgeToHash +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_CreateEdge(int v1, int v2) +{ + th_edge_t *edge; + + if (thworld.numedges == 0) thworld.numedges = 1; + if (thworld.numedges >= MAX_TH_EDGES) + Error("MAX_TH_EDGES"); + edge = &thworld.edges[thworld.numedges++]; + edge->v[0] = v1; + edge->v[1] = v2; + TH_AddEdgeToHash(edge); + return thworld.numedges-1; +} //end of the function TH_CreateEdge +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_FindOrCreateEdge(int v1, int v2) +{ + int edgenum; + + edgenum = TH_FindEdge(v1, v2); + if (!edgenum) edgenum = TH_CreateEdge(v1, v2); + return edgenum; +} //end of the function TH_FindOrCreateEdge +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_FindTriangle(int verts[3]) +{ + int i, hashvalue, edges[3]; + th_triangle_t *tri; + + for (i = 0; i < 3; i++) + { + edges[i] = TH_FindEdge(verts[i], verts[(i+1)%3]); + if (!edges[i]) return false; + } //end for + hashvalue = (abs(edges[0]) + abs(edges[1]) + abs(edges[2])) & (TRIANGLEHASH_SIZE-1); + for (tri = thworld.trianglehash[hashvalue]; tri; tri = tri->next) + { + for (i = 0; i < 3; i++) + { + if (abs(tri->edges[i]) != abs(edges[0]) && + abs(tri->edges[i]) != abs(edges[1]) && + abs(tri->edges[i]) != abs(edges[2])) break; + } //end for + if (i >= 3) return tri - thworld.triangles; + } //end for + return 0; +} //end of the function TH_FindTriangle +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_AddTriangleToHash(th_triangle_t *tri) +{ + int hashvalue; + + hashvalue = (abs(tri->edges[0]) + abs(tri->edges[1]) + abs(tri->edges[2])) & (TRIANGLEHASH_SIZE-1); + tri->hashnext = thworld.trianglehash[hashvalue]; + thworld.trianglehash[hashvalue] = tri; +} //end of the function TH_AddTriangleToHash +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_CreateTrianglePlanes(int verts[3], th_plane_t *triplane, th_plane_t *planes) +{ + int i; + vec3_t dir; + + for (i = 0; i < 3; i++) + { + VectorSubtract(thworld.vertexes[verts[(i+1)%3]].v, thworld.vertexes[verts[i]].v, dir); + CrossProduct(dir, triplane->normal, planes[i].normal); + VectorNormalize(planes[i].normal); + planes[i].dist = DotProduct(thworld.vertexes[verts[i]].v, planes[i].normal); + } //end for +} //end of the function TH_CreateTrianglePlanes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_CreateTriangle(int verts[3]) +{ + th_triangle_t *tri; + int i; + + if (thworld.numtriangles == 0) thworld.numtriangles = 1; + if (thworld.numtriangles >= MAX_TH_TRIANGLES) + Error("MAX_TH_TRIANGLES"); + tri = &thworld.triangles[thworld.numtriangles++]; + for (i = 0; i < 3; i++) + { + tri->edges[i] = TH_FindOrCreateEdge(verts[i], verts[(i+1)%3]); + TH_AddEdgeUser(abs(tri->edges[i])); + } //end for + tri->front = 0; + tri->back = 0; + tri->planenum = TH_PlaneFromPoints(verts[0], verts[1], verts[2]); + tri->prev = NULL; + tri->next = NULL; + tri->hashnext = NULL; + TH_CreateTrianglePlanes(verts, &thworld.planes[tri->planenum], tri->planes); + TH_AddTriangleToHash(tri); + ClearBounds(tri->mins, tri->maxs); + for (i = 0; i < 3; i++) + { + AddPointToBounds(thworld.vertexes[verts[i]].v, tri->mins, tri->maxs); + } //end for + return thworld.numtriangles-1; +} //end of the function TH_CreateTriangle +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_CreateTetrahedron(int triangles[4]) +{ + th_tetrahedron_t *tetrahedron; + int i; + + if (thworld.numtetrahedrons == 0) thworld.numtetrahedrons = 1; + if (thworld.numtetrahedrons >= MAX_TH_TETRAHEDRONS) + Error("MAX_TH_TETRAHEDRONS"); + tetrahedron = &thworld.tetrahedrons[thworld.numtetrahedrons++]; + for (i = 0; i < 4; i++) + { + tetrahedron->triangles[i] = triangles[i]; + if (thworld.triangles[abs(triangles[i])].front) + { + thworld.triangles[abs(triangles[i])].back = thworld.numtetrahedrons-1; + } //end if + else + { + thworld.triangles[abs(triangles[i])].front = thworld.numtetrahedrons-1; + } //end else + } //end for + tetrahedron->volume = 0; + return thworld.numtetrahedrons-1; +} //end of the function TH_CreateTetrahedron +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_IntersectTrianglePlanes(int v1, int v2, th_plane_t *triplane, th_plane_t *planes) +{ + float *p1, *p2, front, back, frac, d; + int i, side, lastside; + vec3_t mid; + + p1 = thworld.vertexes[v1].v; + p2 = thworld.vertexes[v2].v; + + front = DotProduct(p1, triplane->normal) - triplane->dist; + back = DotProduct(p2, triplane->normal) - triplane->dist; + //if both points at the same side of the plane + if (front < 0.1 && back < 0.1) return false; + if (front > -0.1 && back > -0.1) return false; + // + frac = front/(front-back); + mid[0] = p1[0] + (p2[0] - p1[0]) * frac; + mid[1] = p1[1] + (p2[1] - p1[1]) * frac; + mid[2] = p1[2] + (p2[2] - p1[2]) * frac; + //if the mid point is at the same side of all the tri bounding planes + lastside = 0; + for (i = 0; i < 3; i++) + { + d = DotProduct(mid, planes[i].normal) - planes[i].dist; + side = d < 0; + if (i && side != lastside) return false; + lastside = side; + } //end for + return true; +} //end of the function TH_IntersectTrianglePlanes +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_OutsideBoundingBox(int v1, int v2, vec3_t mins, vec3_t maxs) +{ + float *p1, *p2; + int i; + + p1 = thworld.vertexes[v1].v; + p2 = thworld.vertexes[v2].v; + //if both points are at the outer side of one of the bounding box planes + for (i = 0; i < 3; i++) + { + if (p1[i] < mins[i] && p2[i] < mins[i]) return true; + if (p1[i] > maxs[i] && p2[i] > maxs[i]) return true; + } //end for + return false; +} //end of the function TH_OutsideBoundingBox +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_TryEdge(int v1, int v2) +{ + int i, j, v; + th_plane_t *plane; + th_triangle_t *tri; + + //if the edge already exists it must be valid + if (TH_FindEdge(v1, v2)) return true; + //test the edge with all existing triangles + for (i = 1; i < thworld.numtriangles; i++) + { + tri = &thworld.triangles[i]; + //if triangle is enclosed by two tetrahedrons we don't have to test it + //because the edge always has to go through another triangle of those + //tetrahedrons first to reach the enclosed triangle + if (tri->front && tri->back) continue; + //if the edges is totally outside the triangle bounding box + if (TH_OutsideBoundingBox(v1, v2, tri->mins, tri->maxs)) continue; + //if one of the edge vertexes is used by this triangle + for (j = 0; j < 3; j++) + { + v = thworld.edges[abs(tri->edges[j])].v[tri->edges[j] < 0]; + if (v == v1 || v == v2) break; + } //end for + if (j < 3) continue; + //get the triangle plane + plane = &thworld.planes[tri->planenum]; + //if the edge intersects with a triangle then it's not valid + if (TH_IntersectTrianglePlanes(v1, v2, plane, tri->planes)) return false; + } //end for + return true; +} //end of the function TH_TryEdge +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_TryTriangle(int verts[3]) +{ + th_plane_t planes[3], triplane; + vec3_t t1, t2; + float *p0, *p1, *p2; + int i, j; + + p0 = thworld.vertexes[verts[0]].v; + p1 = thworld.vertexes[verts[1]].v; + p2 = thworld.vertexes[verts[2]].v; + + VectorSubtract(p0, p1, t1); + VectorSubtract(p2, p1, t2); + CrossProduct(t1, t2, triplane.normal); + VectorNormalize(triplane.normal); + triplane.dist = DotProduct(p0, triplane.normal); + // + TH_CreateTrianglePlanes(verts, &triplane, planes); + //test if any existing edge intersects with this triangle + for (i = 1; i < thworld.numedges; i++) + { + //if the edge is only used by triangles with tetrahedrons at both sides + if (!thworld.edges[i].usercount) continue; + //if one of the triangle vertexes is used by this edge + for (j = 0; j < 3; j++) + { + if (verts[j] == thworld.edges[j].v[0] || + verts[j] == thworld.edges[j].v[1]) break; + } //end for + if (j < 3) continue; + //if this edge intersects with the triangle + if (TH_IntersectTrianglePlanes(thworld.edges[i].v[0], thworld.edges[i].v[1], &triplane, planes)) return false; + } //end for + return true; +} //end of the function TH_TryTriangle +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_AddTriangleToList(th_triangle_t **trianglelist, th_triangle_t *tri) +{ + tri->prev = NULL; + tri->next = *trianglelist; + if (*trianglelist) (*trianglelist)->prev = tri; + *trianglelist = tri; +} //end of the function TH_AddTriangleToList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_RemoveTriangleFromList(th_triangle_t **trianglelist, th_triangle_t *tri) +{ + if (tri->next) tri->next->prev = tri->prev; + if (tri->prev) tri->prev->next = tri->next; + else *trianglelist = tri->next; +} //end of the function TH_RemoveTriangleFromList +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_FindTetrahedron1(th_triangle_t *tri, int *triangles) +{ + int i, j, edgenum, side, v1, v2, v3, v4; + int verts1[3], verts2[3]; + th_triangle_t *tri2; + + //find another triangle with a shared edge + for (tri2 = tri->next; tri2; tri2 = tri2->next) + { + //if the triangles are in the same plane + if ((tri->planenum & ~1) == (tri2->planenum & ~1)) continue; + //try to find a shared edge + for (i = 0; i < 3; i++) + { + edgenum = abs(tri->edges[i]); + for (j = 0; j < 3; j++) + { + if (edgenum == abs(tri2->edges[j])) break; + } //end for + if (j < 3) break; + } //end for + //if the triangles have a shared edge + if (i < 3) + { + edgenum = tri->edges[(i+1)%3]; + if (edgenum < 0) v1 = thworld.edges[abs(edgenum)].v[0]; + else v1 = thworld.edges[edgenum].v[1]; + edgenum = tri2->edges[(j+1)%3]; + if (edgenum < 0) v2 = thworld.edges[abs(edgenum)].v[0]; + else v2 = thworld.edges[edgenum].v[1]; + //try the new edge + if (TH_TryEdge(v1, v2)) + { + edgenum = tri->edges[i]; + side = edgenum < 0; + //get the vertexes of the shared edge + v3 = thworld.edges[abs(edgenum)].v[side]; + v4 = thworld.edges[abs(edgenum)].v[!side]; + //try the two new triangles + verts1[0] = v1; + verts1[1] = v2; + verts1[2] = v3; + triangles[2] = TH_FindTriangle(verts1); + if (triangles[2] || TH_TryTriangle(verts1)) + { + verts2[0] = v2; + verts2[1] = v1; + verts2[2] = v4; + triangles[3] = TH_FindTriangle(verts2); + if (triangles[3] || TH_TryTriangle(verts2)) + { + triangles[0] = tri - thworld.triangles; + triangles[1] = tri2 - thworld.triangles; + if (!triangles[2]) triangles[2] = TH_CreateTriangle(verts1); + if (!triangles[3]) triangles[3] = TH_CreateTriangle(verts2); + return true; + } //end if + } //end if + } //end if + } //end if + } //end for + return false; +} //end of the function TH_FindTetrahedron +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_FindTetrahedron2(th_triangle_t *tri, int *triangles) +{ + int i, edgenum, v1, verts[3], triverts[3]; + float d; + th_plane_t *plane; + + //get the verts of this triangle + for (i = 0; i < 3; i++) + { + edgenum = tri->edges[i]; + if (edgenum < 0) verts[i] = thworld.edges[abs(edgenum)].v[1]; + else verts[i] = thworld.edges[edgenum].v[0]; + } //end for + // + plane = &thworld.planes[tri->planenum]; + for (v1 = 0; v1 < thworld.numvertexes; v1++) + { + //if the vertex is only used by triangles with tetrahedrons at both sides + if (!thworld.vertexes[v1].usercount) continue; + //check if the vertex is not coplanar with the triangle + d = DotProduct(thworld.vertexes[v1].v, plane->normal) - plane->dist; + if (fabs(d) < 1) continue; + //check if we can create edges from the triangle towards this new vertex + for (i = 0; i < 3; i++) + { + if (v1 == verts[i]) break; + if (!TH_TryEdge(v1, verts[i])) break; + } //end for + if (i < 3) continue; + //check if the triangles are valid + for (i = 0; i < 3; i++) + { + triverts[0] = v1; + triverts[1] = verts[i]; + triverts[2] = verts[(i+1)%3]; + //if the triangle already exists then it is valid + triangles[i] = TH_FindTriangle(triverts); + if (!triangles[i]) + { + if (!TH_TryTriangle(triverts)) break; + } //end if + } //end for + if (i < 3) continue; + //create the tetrahedron triangles using the new vertex + for (i = 0; i < 3; i++) + { + if (!triangles[i]) + { + triverts[0] = v1; + triverts[1] = verts[i]; + triverts[2] = verts[(i+1)%3]; + triangles[i] = TH_CreateTriangle(triverts); + } //end if + } //end for + //add the existing triangle + triangles[3] = tri - thworld.triangles; + // + return true; + } //end for + return false; +} //end of the function TH_FindTetrahedron2 +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_TetrahedralDecomposition(th_triangle_t *triangles) +{ + int i, thtriangles[4], numtriangles; + th_triangle_t *donetriangles, *tri; + + donetriangles = NULL; + + /* + numtriangles = 0; + qprintf("%6d triangles", numtriangles); + for (tri = triangles; tri; tri = triangles) + { + qprintf("\r%6d", numtriangles++); + if (!TH_FindTetrahedron1(tri, thtriangles)) + { +// if (!TH_FindTetrahedron2(tri, thtriangles)) + { +// Error("triangle without tetrahedron"); + TH_RemoveTriangleFromList(&triangles, tri); + continue; + } //end if + } //end if + //create a tetrahedron from the triangles + TH_CreateTetrahedron(thtriangles); + // + for (i = 0; i < 4; i++) + { + if (thworld.triangles[abs(thtriangles[i])].front && + thworld.triangles[abs(thtriangles[i])].back) + { + TH_RemoveTriangleFromList(&triangles, &thworld.triangles[abs(thtriangles[i])]); + TH_AddTriangleToList(&donetriangles, &thworld.triangles[abs(thtriangles[i])]); + TH_FreeTriangleEdges(&thworld.triangles[abs(thtriangles[i])]); + } //end if + else + { + TH_AddTriangleToList(&triangles, &thworld.triangles[abs(thtriangles[i])]); + } //end else + } //end for + } //end for*/ + qprintf("%6d tetrahedrons", thworld.numtetrahedrons); + do + { + do + { + numtriangles = 0; + for (i = 1; i < thworld.numtriangles; i++) + { + tri = &thworld.triangles[i]; + if (tri->front && tri->back) continue; + //qprintf("\r%6d", numtriangles++); + if (!TH_FindTetrahedron1(tri, thtriangles)) + { +// if (!TH_FindTetrahedron2(tri, thtriangles)) + { + continue; + } //end if + } //end if + numtriangles++; + //create a tetrahedron from the triangles + TH_CreateTetrahedron(thtriangles); + qprintf("\r%6d", thworld.numtetrahedrons); + } //end for + } while(numtriangles); + for (i = 1; i < thworld.numtriangles; i++) + { + tri = &thworld.triangles[i]; + if (tri->front && tri->back) continue; + //qprintf("\r%6d", numtriangles++); +// if (!TH_FindTetrahedron1(tri, thtriangles)) + { + if (!TH_FindTetrahedron2(tri, thtriangles)) + { + continue; + } //end if + } //end if + numtriangles++; + //create a tetrahedron from the triangles + TH_CreateTetrahedron(thtriangles); + qprintf("\r%6d", thworld.numtetrahedrons); + } //end for + } while(numtriangles); + // + numtriangles = 0; + for (i = 1; i < thworld.numtriangles; i++) + { + tri = &thworld.triangles[i]; + if (!tri->front && !tri->back) numtriangles++; + } //end for + Log_Print("\r%6d triangles with front only\n", numtriangles); + Log_Print("\r%6d tetrahedrons\n", thworld.numtetrahedrons-1); +} //end of the function TH_TetrahedralDecomposition +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_AASFaceVertex(aas_face_t *face, int index, vec3_t vertex) +{ + int edgenum, side; + + edgenum = aasworld.edgeindex[face->firstedge + index]; + side = edgenum < 0; + VectorCopy(aasworld.vertexes[aasworld.edges[abs(edgenum)].v[side]], vertex); +} //end of the function TH_AASFaceVertex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TH_Colinear(float *v0, float *v1, float *v2) +{ + vec3_t t1, t2, vcross; + float d; + + VectorSubtract(v1, v0, t1); + VectorSubtract(v2, v0, t2); + CrossProduct (t1, t2, vcross); + d = VectorLength( vcross ); + + // if cross product is zero point is colinear + if (d < 10) + { + return true; + } //end if + return false; +} //end of the function TH_Colinear +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_FaceCenter(aas_face_t *face, vec3_t center) +{ + int i, edgenum, side; + aas_edge_t *edge; + + VectorClear(center); + for (i = 0; i < face->numedges; i++) + { + edgenum = abs(aasworld.edgeindex[face->firstedge + i]); + side = edgenum < 0; + edge = &aasworld.edges[abs(edgenum)]; + VectorAdd(aasworld.vertexes[edge->v[side]], center, center); + } //end for + VectorScale(center, 1.0 / face->numedges, center); +} //end of the function TH_FaceCenter +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +th_triangle_t *TH_CreateAASFaceTriangles(aas_face_t *face) +{ + int i, first, verts[3], trinum; + vec3_t p0, p1, p2, p3, p4, center; + th_triangle_t *tri, *triangles; + + triangles = NULL; + //find three points that are not colinear + for (i = 0; i < face->numedges; i++) + { + TH_AASFaceVertex(face, (face->numedges + i-2)%face->numedges, p0); + TH_AASFaceVertex(face, (face->numedges + i-1)%face->numedges, p1); + TH_AASFaceVertex(face, (i )%face->numedges, p2); + if (TH_Colinear(p2, p0, p1)) continue; + TH_AASFaceVertex(face, (i+1)%face->numedges, p3); + TH_AASFaceVertex(face, (i+2)%face->numedges, p4); + if (TH_Colinear(p2, p3, p4)) continue; + break; + } //end for + //if there are three points that are not colinear + if (i < face->numedges) + { + //normal triangulation + first = i; //left and right most point of three non-colinear points + TH_AASFaceVertex(face, first, p0); + verts[0] = TH_FindOrCreateVertex(p0); + for (i = 1; i < face->numedges-1; i++) + { + TH_AASFaceVertex(face, (first+i )%face->numedges, p1); + TH_AASFaceVertex(face, (first+i+1)%face->numedges, p2); + verts[1] = TH_FindOrCreateVertex(p1); + verts[2] = TH_FindOrCreateVertex(p2); + trinum = TH_CreateTriangle(verts); + tri = &thworld.triangles[trinum]; + tri->front = -1; + TH_AddTriangleToList(&triangles, tri); + } //end for + } //end if + else + { + //fan triangulation + TH_FaceCenter(face, center); + // + verts[0] = TH_FindOrCreateVertex(center); + for (i = 0; i < face->numedges; i++) + { + TH_AASFaceVertex(face, (i )%face->numedges, p1); + TH_AASFaceVertex(face, (i+1)%face->numedges, p2); + if (TH_Colinear(center, p1, p2)) continue; + verts[1] = TH_FindOrCreateVertex(p1); + verts[2] = TH_FindOrCreateVertex(p2); + trinum = TH_CreateTriangle(verts); + tri = &thworld.triangles[trinum]; + tri->front = -1; + TH_AddTriangleToList(&triangles, tri); + } //end for + } //end else + return triangles; +} //end of the function TH_CreateAASFaceTriangles +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +th_triangle_t *TH_AASToTriangleMesh(void) +{ + int i, j, facenum, otherareanum; + aas_face_t *face; + th_triangle_t *tri, *nexttri, *triangles; + + triangles = NULL; + for (i = 1; i < aasworld.numareas; i++) + { + //if (!(aasworld.areasettings[i].presencetype & PRESENCE_NORMAL)) continue; + for (j = 0; j < aasworld.areas[i].numfaces; j++) + { + facenum = abs(aasworld.faceindex[aasworld.areas[i].firstface + j]); + face = &aasworld.faces[facenum]; + //only convert solid faces into triangles + if (!(face->faceflags & FACE_SOLID)) + { + /* + if (face->frontarea == i) otherareanum = face->backarea; + else otherareanum = face->frontarea; + if (aasworld.areasettings[otherareanum].presencetype & PRESENCE_NORMAL) continue; + */ + continue; + } //end if + // + tri = TH_CreateAASFaceTriangles(face); + for (; tri; tri = nexttri) + { + nexttri = tri->next; + TH_AddTriangleToList(&triangles, tri); + } //end for + } //end if + } //end for + return triangles; +} //end of the function TH_AASToTriangleMesh +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void TH_AASToTetrahedrons(char *filename) +{ + th_triangle_t *triangles, *tri, *lasttri; + int cnt; + + if (!AAS_LoadAASFile(filename, 0, 0)) + Error("couldn't load %s\n", filename); + + // + TH_InitMaxTH(); + //create a triangle mesh from the solid faces in the AAS file + triangles = TH_AASToTriangleMesh(); + // + cnt = 0; + lasttri = NULL; + for (tri = triangles; tri; tri = tri->next) + { + cnt++; + if (tri->prev != lasttri) Log_Print("BAH\n"); + lasttri = tri; + } //end for + Log_Print("%6d triangles\n", cnt); + //create a tetrahedral decomposition of the world bounded by triangles + TH_TetrahedralDecomposition(triangles); + // + TH_FreeMaxTH(); +} //end of the function TH_AASToTetrahedrons diff --git a/code/bspc/tetrahedron.h b/code/bspc/tetrahedron.h new file mode 100644 index 00000000..2c6293d5 --- /dev/null +++ b/code/bspc/tetrahedron.h @@ -0,0 +1,24 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +void TH_AASToTetrahedrons(char *filename); + diff --git a/code/bspc/textures.c b/code/bspc/textures.c new file mode 100644 index 00000000..df737f5a --- /dev/null +++ b/code/bspc/textures.c @@ -0,0 +1,117 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" + +int nummiptex; +textureref_t textureref[MAX_MAP_TEXTURES]; + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int FindMiptex (char *name) +{ + //int i; + //char path[1024]; + //miptex_t *mt; + + //for (i = 0; i < nummiptex; i++) + //{ + // if (!strcmp (name, textureref[i].name)) + // { + // return i; + // } //end if + //} //end for + //if (nummiptex == MAX_MAP_TEXTURES) + // Error ("MAX_MAP_TEXTURES"); + //strcpy (textureref[i].name, name); + + //// load the miptex to get the flags and values + //sprintf (path, "%stextures/%s.wal", gamedir, name); + //if (TryLoadFile (path, (void **)&mt) != -1) + //{ + // textureref[i].value = LittleLong (mt->value); + // textureref[i].flags = LittleLong (mt->flags); + // textureref[i].contents = LittleLong (mt->contents); + // strcpy (textureref[i].animname, mt->animname); + // FreeMemory(mt); + //} //end if + //nummiptex++; + + //if (textureref[i].animname[0]) + // FindMiptex (textureref[i].animname); + + //return i; + return 0; +} //end of the function FindMipTex +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +vec3_t baseaxis[18] = +{ +{0,0,1}, {1,0,0}, {0,-1,0}, // floor +{0,0,-1}, {1,0,0}, {0,-1,0}, // ceiling +{1,0,0}, {0,1,0}, {0,0,-1}, // west wall +{-1,0,0}, {0,1,0}, {0,0,-1}, // east wall +{0,1,0}, {1,0,0}, {0,0,-1}, // south wall +{0,-1,0}, {1,0,0}, {0,0,-1} // north wall +}; + +void TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv) +{ + int bestaxis; + vec_t dot,best; + int i; + + best = 0; + bestaxis = 0; + + for (i=0 ; i<6 ; i++) + { + dot = DotProduct (pln->normal, baseaxis[i*3]); + if (dot > best) + { + best = dot; + bestaxis = i; + } + } + + VectorCopy (baseaxis[bestaxis*3+1], xv); + VectorCopy (baseaxis[bestaxis*3+2], yv); +} //end of the function TextureAxisFromPlane +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +int TexinfoForBrushTexture(plane_t *plane, brush_texture_t *bt, vec3_t origin) +{ + + return 0; +} //end of the function TexinfoForBrushTexture diff --git a/code/bspc/tree.c b/code/bspc/tree.c new file mode 100644 index 00000000..484ce77b --- /dev/null +++ b/code/bspc/tree.c @@ -0,0 +1,285 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "qbsp.h" + +extern int c_nodes; +int c_pruned; +int freedtreemem = 0; + +void RemovePortalFromNode (portal_t *portal, node_t *l); + +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +node_t *NodeForPoint (node_t *node, vec3_t origin) +{ + plane_t *plane; + vec_t d; + + while (node->planenum != PLANENUM_LEAF) + { + plane = &mapplanes[node->planenum]; + d = DotProduct (origin, plane->normal) - plane->dist; + if (d >= 0) + node = node->children[0]; + else + node = node->children[1]; + } + return node; +} //end of the function NodeForPoint +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Tree_FreePortals_r (node_t *node) +{ + portal_t *p, *nextp; + int s; + + // free children + if (node->planenum != PLANENUM_LEAF) + { + Tree_FreePortals_r(node->children[0]); + Tree_FreePortals_r(node->children[1]); + } + + // free portals + for (p = node->portals; p; p = nextp) + { + s = (p->nodes[1] == node); + nextp = p->next[s]; + + RemovePortalFromNode (p, p->nodes[!s]); +#ifdef ME + if (p->winding) freedtreemem += MemorySize(p->winding); + freedtreemem += MemorySize(p); +#endif //ME + FreePortal(p); + } + node->portals = NULL; +} //end of the function Tree_FreePortals_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Tree_Free_r (node_t *node) +{ +// face_t *f, *nextf; + bspbrush_t *brush, *nextbrush; + + //free children + if (node->planenum != PLANENUM_LEAF) + { + Tree_Free_r (node->children[0]); + Tree_Free_r (node->children[1]); + } //end if + //free bspbrushes +// FreeBrushList (node->brushlist); + for (brush = node->brushlist; brush; brush = nextbrush) + { + nextbrush = brush->next; +#ifdef ME + freedtreemem += MemorySize(brush); +#endif //ME + FreeBrush(brush); + } //end for + node->brushlist = NULL; + + /* + NOTE: only used when creating Q2 bsp + // free faces + for (f = node->faces; f; f = nextf) + { + nextf = f->next; +#ifdef ME + if (f->w) freedtreemem += MemorySize(f->w); + freedtreemem += sizeof(face_t); +#endif //ME + FreeFace(f); + } //end for + */ + + // free the node + if (node->volume) + { +#ifdef ME + freedtreemem += MemorySize(node->volume); +#endif //ME + FreeBrush (node->volume); + } //end if + + if (numthreads == 1) c_nodes--; +#ifdef ME + freedtreemem += MemorySize(node); +#endif //ME + FreeMemory(node); +} //end of the function Tree_Free_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Tree_Free(tree_t *tree) +{ + //if no tree just return + if (!tree) return; + // + freedtreemem = 0; + // + Tree_FreePortals_r(tree->headnode); + Tree_Free_r(tree->headnode); +#ifdef ME + freedtreemem += MemorySize(tree); +#endif //ME + FreeMemory(tree); +#ifdef ME + Log_Print("freed "); + PrintMemorySize(freedtreemem); + Log_Print(" of tree memory\n"); +#endif //ME +} //end of the function Tree_Free +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +tree_t *Tree_Alloc(void) +{ + tree_t *tree; + + tree = GetMemory(sizeof(*tree)); + memset (tree, 0, sizeof(*tree)); + ClearBounds (tree->mins, tree->maxs); + + return tree; +} //end of the function Tree_Alloc +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Tree_Print_r (node_t *node, int depth) +{ + int i; + plane_t *plane; + bspbrush_t *bb; + + for (i=0 ; iplanenum == PLANENUM_LEAF) + { + if (!node->brushlist) + printf ("NULL\n"); + else + { + for (bb=node->brushlist ; bb ; bb=bb->next) + printf ("%i ", bb->original->brushnum); + printf ("\n"); + } + return; + } + + plane = &mapplanes[node->planenum]; + printf ("#%i (%5.2f %5.2f %5.2f):%5.2f\n", node->planenum, + plane->normal[0], plane->normal[1], plane->normal[2], + plane->dist); + Tree_Print_r (node->children[0], depth+1); + Tree_Print_r (node->children[1], depth+1); +} //end of the function Tree_Print_r +//=========================================================================== +// NODES THAT DON'T SEPERATE DIFFERENT CONTENTS CAN BE PRUNED +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Tree_PruneNodes_r (node_t *node) +{ + bspbrush_t *b, *next; + + if (node->planenum == PLANENUM_LEAF) return; + + Tree_PruneNodes_r (node->children[0]); + Tree_PruneNodes_r (node->children[1]); + + if (create_aas) + { +#ifdef CONTENTS_LADDER + if ((node->children[0]->contents & CONTENTS_LADDER) || + (node->children[1]->contents & CONTENTS_LADDER)) return; +#endif // CONTENTS_LADDER + } + + if ((node->children[0]->contents & CONTENTS_SOLID) + && (node->children[1]->contents & CONTENTS_SOLID)) + { + if (node->faces) + Error ("node->faces seperating CONTENTS_SOLID"); + if (node->children[0]->faces || node->children[1]->faces) + Error ("!node->faces with children"); + // FIXME: free stuff + node->planenum = PLANENUM_LEAF; + node->contents = CONTENTS_SOLID; + node->detail_seperator = false; + + if (node->brushlist) + Error ("PruneNodes: node->brushlist"); + // combine brush lists + node->brushlist = node->children[1]->brushlist; + + for (b = node->children[0]->brushlist; b; b = next) + { + next = b->next; + b->next = node->brushlist; + node->brushlist = b; + } //end for + //free the child nodes + FreeMemory(node->children[0]); + FreeMemory(node->children[1]); + //two nodes are cut away + c_pruned += 2; + } //end if +} //end of the function Tree_PruneNodes_r +//=========================================================================== +// +// Parameter: - +// Returns: - +// Changes Globals: - +//=========================================================================== +void Tree_PruneNodes(node_t *node) +{ + Log_Print("------- Prune Nodes --------\n"); + c_pruned = 0; + Tree_PruneNodes_r(node); + Log_Print("%5i pruned nodes\n", c_pruned); +} //end of the function Tree_PruneNodes diff --git a/code/bspc/writebsp.c b/code/bspc/writebsp.c new file mode 100644 index 00000000..b6cf4e4a --- /dev/null +++ b/code/bspc/writebsp.c @@ -0,0 +1,595 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#include "qbsp.h" + +int c_nofaces; +int c_facenodes; + + +/* +========================================================= + +ONLY SAVE OUT PLANES THAT ARE ACTUALLY USED AS NODES + +========================================================= +*/ + +int planeused[MAX_MAP_PLANES]; + +/* +============ +EmitPlanes + +There is no oportunity to discard planes, because all of the original +brushes will be saved in the map. +============ +*/ +void EmitPlanes (void) +{ + int i; + dplane_t *dp; + plane_t *mp; + //ME: this causes a crash?? +// int planetranslate[MAX_MAP_PLANES]; + + mp = mapplanes; + for (i=0 ; inormal, dp->normal); + dp->dist = mp->dist; + dp->type = mp->type; + numplanes++; + if (numplanes >= MAX_MAP_PLANES) + Error("MAX_MAP_PLANES"); + } +} + + +//======================================================== + +void EmitMarkFace (dleaf_t *leaf_p, face_t *f) +{ + int i; + int facenum; + + while (f->merged) + f = f->merged; + + if (f->split[0]) + { + EmitMarkFace (leaf_p, f->split[0]); + EmitMarkFace (leaf_p, f->split[1]); + return; + } + + facenum = f->outputnumber; + if (facenum == -1) + return; // degenerate face + + if (facenum < 0 || facenum >= numfaces) + Error ("Bad leafface"); + for (i=leaf_p->firstleafface ; i= MAX_MAP_LEAFFACES) + Error ("MAX_MAP_LEAFFACES"); + + dleaffaces[numleaffaces] = facenum; + numleaffaces++; + } + +} + + +/* +================== +EmitLeaf +================== +*/ +void EmitLeaf (node_t *node) +{ + dleaf_t *leaf_p; + portal_t *p; + int s; + face_t *f; + bspbrush_t *b; + int i; + int brushnum; + + // emit a leaf + if (numleafs >= MAX_MAP_LEAFS) + Error ("MAX_MAP_LEAFS"); + + leaf_p = &dleafs[numleafs]; + numleafs++; + + leaf_p->contents = node->contents; + leaf_p->cluster = node->cluster; + leaf_p->area = node->area; + + // + // write bounding box info + // + VectorCopy (node->mins, leaf_p->mins); + VectorCopy (node->maxs, leaf_p->maxs); + + // + // write the leafbrushes + // + leaf_p->firstleafbrush = numleafbrushes; + for (b=node->brushlist ; b ; b=b->next) + { + if (numleafbrushes >= MAX_MAP_LEAFBRUSHES) + Error ("MAX_MAP_LEAFBRUSHES"); + + brushnum = b->original - mapbrushes; + for (i=leaf_p->firstleafbrush ; inumleafbrushes = numleafbrushes - leaf_p->firstleafbrush; + + // + // write the leaffaces + // + if (leaf_p->contents & CONTENTS_SOLID) + return; // no leaffaces in solids + + leaf_p->firstleafface = numleaffaces; + + for (p = node->portals ; p ; p = p->next[s]) + { + s = (p->nodes[1] == node); + f = p->face[s]; + if (!f) + continue; // not a visible portal + + EmitMarkFace (leaf_p, f); + } + + leaf_p->numleaffaces = numleaffaces - leaf_p->firstleafface; +} + + +/* +================== +EmitFace +================== +*/ +void EmitFace (face_t *f) +{ + dface_t *df; + int i; + int e; + + f->outputnumber = -1; + + if (f->numpoints < 3) + { + return; // degenerated + } + if (f->merged || f->split[0] || f->split[1]) + { + return; // not a final face + } + + // save output number so leaffaces can use + f->outputnumber = numfaces; + + if (numfaces >= MAX_MAP_FACES) + Error ("numfaces == MAX_MAP_FACES"); + df = &dfaces[numfaces]; + numfaces++; + + // planenum is used by qlight, but not quake + df->planenum = f->planenum & (~1); + df->side = f->planenum & 1; + + df->firstedge = numsurfedges; + df->numedges = f->numpoints; + df->texinfo = f->texinfo; + for (i=0 ; inumpoints ; i++) + { +// e = GetEdge (f->pts[i], f->pts[(i+1)%f->numpoints], f); + e = GetEdge2 (f->vertexnums[i], f->vertexnums[(i+1)%f->numpoints], f); + if (numsurfedges >= MAX_MAP_SURFEDGES) + Error ("numsurfedges == MAX_MAP_SURFEDGES"); + dsurfedges[numsurfedges] = e; + numsurfedges++; + } +} + +/* +============ +EmitDrawingNode_r +============ +*/ +int EmitDrawNode_r (node_t *node) +{ + dnode_t *n; + face_t *f; + int i; + + if (node->planenum == PLANENUM_LEAF) + { + EmitLeaf (node); + return -numleafs; + } + + // emit a node + if (numnodes == MAX_MAP_NODES) + Error ("MAX_MAP_NODES"); + n = &dnodes[numnodes]; + numnodes++; + + VectorCopy (node->mins, n->mins); + VectorCopy (node->maxs, n->maxs); + + planeused[node->planenum]++; + planeused[node->planenum^1]++; + + if (node->planenum & 1) + Error ("WriteDrawNodes_r: odd planenum"); + n->planenum = node->planenum; + n->firstface = numfaces; + + if (!node->faces) + c_nofaces++; + else + c_facenodes++; + + for (f=node->faces ; f ; f=f->next) + EmitFace (f); + + n->numfaces = numfaces - n->firstface; + + + // + // recursively output the other nodes + // + for (i=0 ; i<2 ; i++) + { + if (node->children[i]->planenum == PLANENUM_LEAF) + { + n->children[i] = -(numleafs + 1); + EmitLeaf (node->children[i]); + } + else + { + n->children[i] = numnodes; + EmitDrawNode_r (node->children[i]); + } + } + + return n - dnodes; +} + +//========================================================= + + +/* +============ +WriteBSP +============ +*/ +void WriteBSP (node_t *headnode) +{ + int oldfaces; + + c_nofaces = 0; + c_facenodes = 0; + + qprintf ("--- WriteBSP ---\n"); + + oldfaces = numfaces; + dmodels[nummodels].headnode = EmitDrawNode_r (headnode); + EmitAreaPortals (headnode); + + qprintf ("%5i nodes with faces\n", c_facenodes); + qprintf ("%5i nodes without faces\n", c_nofaces); + qprintf ("%5i faces\n", numfaces-oldfaces); +} + +//=========================================================== + +/* +============ +SetModelNumbers +============ +*/ +void SetModelNumbers (void) +{ + int i; + int models; + char value[10]; + + models = 1; + for (i=1 ; icontents = b->contents; + db->firstside = numbrushsides; + db->numsides = b->numsides; + for (j=0 ; jnumsides ; j++) + { + if (numbrushsides == MAX_MAP_BRUSHSIDES) + Error ("MAX_MAP_BRUSHSIDES"); + cp = &dbrushsides[numbrushsides]; + numbrushsides++; + cp->planenum = b->original_sides[j].planenum; + cp->texinfo = b->original_sides[j].texinfo; + } + +#ifdef ME + //for collision detection, bounding boxes are axial :) + //brushes are convex so just add dot or line touching planes on the sides of + //the brush parallell to the axis planes +#endif + // add any axis planes not contained in the brush to bevel off corners + for (x=0 ; x<3 ; x++) + for (s=-1 ; s<=1 ; s+=2) + { + // add the plane + VectorCopy (vec3_origin, normal); + normal[x] = s; + if (s == -1) + dist = -b->mins[x]; + else + dist = b->maxs[x]; + planenum = FindFloatPlane (normal, dist); + for (i=0 ; inumsides ; i++) + if (b->original_sides[i].planenum == planenum) + break; + if (i == b->numsides) + { + if (numbrushsides >= MAX_MAP_BRUSHSIDES) + Error ("MAX_MAP_BRUSHSIDES"); + + dbrushsides[numbrushsides].planenum = planenum; + dbrushsides[numbrushsides].texinfo = + dbrushsides[numbrushsides-1].texinfo; + numbrushsides++; + db->numsides++; + } + } + + } + +} + +//=========================================================== + +/* +================== +BeginBSPFile +================== +*/ +void BeginBSPFile (void) +{ + // these values may actually be initialized + // if the file existed when loaded, so clear them explicitly + nummodels = 0; + numfaces = 0; + numnodes = 0; + numbrushsides = 0; + numvertexes = 0; + numleaffaces = 0; + numleafbrushes = 0; + numsurfedges = 0; + + // edge 0 is not used, because 0 can't be negated + numedges = 1; + + // leave vertex 0 as an error + numvertexes = 1; + + // leave leaf 0 as an error + numleafs = 1; + dleafs[0].contents = CONTENTS_SOLID; +} + + +/* +============ +EndBSPFile +============ +*/ +void EndBSPFile (void) +{ +#if 0 + char path[1024]; + int len; + byte *buf; +#endif + + + EmitBrushes (); + EmitPlanes (); + Q2_UnparseEntities (); + + // load the pop +#if 0 + sprintf (path, "%s/pics/pop.lmp", gamedir); + len = LoadFile (path, &buf); + memcpy (dpop, buf, sizeof(dpop)); + FreeMemory(buf); +#endif +} + + +/* +================== +BeginModel +================== +*/ +int firstmodleaf; +extern int firstmodeledge; +extern int firstmodelface; +void BeginModel (void) +{ + dmodel_t *mod; + int start, end; + mapbrush_t *b; + int j; + entity_t *e; + vec3_t mins, maxs; + + if (nummodels == MAX_MAP_MODELS) + Error ("MAX_MAP_MODELS"); + mod = &dmodels[nummodels]; + + mod->firstface = numfaces; + + firstmodleaf = numleafs; + firstmodeledge = numedges; + firstmodelface = numfaces; + + // + // bound the brushes + // + e = &entities[entity_num]; + + start = e->firstbrush; + end = start + e->numbrushes; + ClearBounds (mins, maxs); + + for (j=start ; jnumsides) + continue; // not a real brush (origin brush) + AddPointToBounds (b->mins, mins, maxs); + AddPointToBounds (b->maxs, mins, maxs); + } + + VectorCopy (mins, mod->mins); + VectorCopy (maxs, mod->maxs); +} + + +/* +================== +EndModel +================== +*/ +void EndModel (void) +{ + dmodel_t *mod; + + mod = &dmodels[nummodels]; + + mod->numfaces = numfaces - mod->firstface; + + nummodels++; +} + diff --git a/code/cgame/cg_beam.c b/code/cgame/cg_beam.c new file mode 100644 index 00000000..2bad4209 --- /dev/null +++ b/code/cgame/cg_beam.c @@ -0,0 +1,1231 @@ +/* +=========================================================================== +Copyright (C) 2000 by Ritual Entertainment, Inc. +Copyright (C) 2011 by su44 + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_beams.c - beam effects + +#include "cg_local.h" + +#define BEAM_LIGHTNING_EFFECT (1<<0) +#define BEAM_USEMODEL (1<<1) +#define BEAM_PERSIST_EFFECT (1<<2) +#define BEAM_SPHERE_EFFECT (1<<3) +#define BEAM_RANDOM_DELAY (1<<4) +#define BEAM_TOGGLE (1<<5) +#define BEAM_RANDOM_TOGGLEDELAY (1<<6) +#define BEAM_WAVE_EFFECT (1<<7) +#define BEAM_USE_NOISE (1<<8) +#define BEAM_PARENT (1<<9) +#define BEAM_TILESHADER (1<<10) +#define BEAM_OFFSET_ENDPOINTS (1<<11) + +#define MAX_BEAMS 256 + +typedef struct beam_s { + int entity; + qhandle_t hModel; + int endtime; + vec3_t start, end; + float scale; + float alpha; + int flags; + int parent; + float max_offset; + float min_offset; + int numSubdivisions; + int overlap; + int beamshader; + byte shaderRGBA[4]; + int update_time; + int delay; + float life; + int numspherebeams; + float sphereradius; + int toggletime; + int toggledelay; + qboolean active; + float alphastep; + int renderfx; + char name[128]; +} beam_t; + +void CG_InitBeam(beam_t *b) { + memset(b,0,sizeof(beam_t)); + b->parent=ENTITYNUM_NONE; +} + +static beam_t cg_beams[MAX_BEAMS]; + +static int seed = 100; // chosen by fair dice roll + +#define MAX_BEAM_BACKUP 6 +#define MAX_BEAM_SEGMENTS 32 + +typedef struct beamSegment_s { + polyVert_t points[4]; +} beamSegment_t; + +typedef struct beamList_s { + int time; + int updatetime; + int numsegments; + beamSegment_t segments[MAX_BEAM_SEGMENTS]; +} beamList_t; + +typedef struct beamEnt_s { + int owner; + int numbeams; + int life; + int renderfx; + beamList_t beamlist[MAX_BEAM_BACKUP]; + struct beamEnt_s *next, *prev; +} beamEnt_t; + +#define MAX_BEAM_ENTITIES 512 + +static beamEnt_t beamEnts[MAX_BEAM_ENTITIES]; +static beamEnt_t cg_activeBeamEnts; // double linked list +static beamEnt_t *cg_freeBeamEnts; // single linked list + +void CG_InitBeams() { + int i; + + memset( beamEnts, 0, sizeof( beamEnts ) ); + cg_activeBeamEnts.next = &cg_activeBeamEnts; + cg_activeBeamEnts.prev = &cg_activeBeamEnts; + cg_freeBeamEnts = beamEnts; + for ( i = 0 ; i < MAX_BEAM_ENTITIES - 1 ; i++ ) { + beamEnts[i].next = &beamEnts[i+1]; + } +} + +static beamEnt_t *CG_AllocBeamEnt() { + beamEnt_t *be; + + if ( !cg_freeBeamEnts ) { + CG_Printf("CG_AllocBeamEnt: no free beamEnts\n"); + return 0; + } + + be = cg_freeBeamEnts; + cg_freeBeamEnts = cg_freeBeamEnts->next; + + memset( be, 0, sizeof( *be ) ); + + // link into the active list + be->next = cg_activeBeamEnts.next; + be->prev = &cg_activeBeamEnts; + cg_activeBeamEnts.next->prev = be; + cg_activeBeamEnts.next = be; + return be; +} + +static void CG_FreeBeamEnt(beamEnt_t *be) { + if ( !be->prev ) { + CG_Error( "CG_FreeBeamEnt: not active" ); + } + + // remove from the doubly linked active list + be->prev->next = be->next; + be->next->prev = be->prev; + + // the free list is only singly linked + be->next = cg_freeBeamEnts; + cg_freeBeamEnts = be; +} + +static void RemoveBeamList(int owner) { + beamEnt_t *be, *next; + be = cg_activeBeamEnts.next; + for ( ; be != &cg_activeBeamEnts ; be = next ) { + // grab next now, so if the event is freed we + // still have it + next = be->next; + if ( owner == be->owner ) { + // free + CG_FreeBeamEnt(be); + continue; + } + } + +} + +static beamEnt_t *FindBeamList( int owner ) { + beamEnt_t *be, *next; + be = cg_activeBeamEnts.next; + for ( ; be != &cg_activeBeamEnts ; be = next ) { + // grab next now, so if the event is freed we + // still have it + next = be->next; + if ( owner == be->owner ) { + return be; + } + } + return NULL; +} + +static int CreateNewBeamEntity(int owner, float life) { + beamEnt_t *be; + int i,oldest,oldest_time; + + be = FindBeamList( owner ); + + if ( !be ) { + be = CG_AllocBeamEnt(); + + if ( !be ) + CG_Error("Could not allocate memory for beamEnt.\n" ); + + memset ( be, 0, sizeof( beamEnt_t ) ); + memset ( be->beamlist, 0, sizeof( beamList_t ) * MAX_BEAM_BACKUP ); + be->owner = owner; + be->life = life; + + + } + + // find the oldest beam and overwrite it. + oldest = -1; + oldest_time = 999999999; + + for ( i=0; ibeamlist[ i ].time; + + if ( !t ) { + oldest = i; + break; + } + + if ( t < oldest_time ) { + oldest = i; + oldest_time = t; + } + } + + // Use the oldest beam for the next beam. + be->beamlist[ oldest ].numsegments = 0; + be->beamlist[ oldest ].time = cg.time; + be->beamlist[ oldest ].updatetime = cg.time + be->life; + return oldest; +} + +static void RemoveBeamEntity(int owner) { + RemoveBeamList( owner ); +} + +static void AddBeamSegmentToList(int owner, polyVert_t points[4], int beamnum, + int segnum, int renderfx) { + beamEnt_t *be; + + be = FindBeamList( owner ); + + if ( !be ) { + CG_Printf( "Could not find beam entity for owner:%d\n", owner ); + return; + } + + if ( segnum >= MAX_BEAM_SEGMENTS ) + return; + + be->renderfx = renderfx; + + // Copy the 4 points + memcpy( &be->beamlist[beamnum].segments[segnum].points, points, 4 * sizeof( polyVert_t ) ); + + // Increase the segment counter + be->beamlist[beamnum].numsegments++; +} + +static void CG_AddBeamsFromList(int owner, int beamshader) { + int i,j,k,l; + float frac, fade; + beamEnt_t *be = FindBeamList( owner ); + polyVert_t newpoints[4]; + + if ( !be ) { + return; + } + + for ( i=0; ibeamlist[i]; + + if ( !bl->time ) + continue; + + // Calculate the blend factor for fading + frac = (float)( cg.time - bl->time ) / (float)be->life; + fade = 1.0f - frac; + + if ( fade <= 0 ) { + bl->time = 0; // RemoveBeamList( owner ); + continue; + } + + // Go through each segment and draw it with the new modulate + assert( bl->numsegments < MAX_BEAM_SEGMENTS ); + + for ( j=0; jnumsegments; j++ ) { + memcpy( newpoints, bl->segments[j].points, 4 * sizeof( polyVert_t ) ); + + for ( k=0; k<4; k++ ) { + for ( l=0; l<4; l++ ) { + newpoints[k].modulate[l] = bl->segments[j].points[k].modulate[l] * fade; + } + } + + cgi.R_AddPolyToScene( beamshader, 4, newpoints/*, be->renderfx*/ ); + } + } +} + +static void RenderSegment(vec3_t pt1a, vec3_t pt1b, vec3_t pt2a, vec3_t pt2b, + byte modulate[4], int beamshader, int renderfx) { + int i,j; + polyVert_t points[4]; + + VectorCopy( pt1a, points[0].xyz ); + VectorCopy( pt2a, points[1].xyz ); + VectorCopy( pt2b, points[2].xyz ); + VectorCopy( pt1b, points[3].xyz ); + + points[0].st[0] = 1; points[0].st[1] = 1; + points[1].st[0] = 0; points[1].st[1] = 1; + points[2].st[0] = 0; points[2].st[1] = 0; + points[3].st[0] = 1; points[3].st[1] = 0; + + // Set the color of the verts + for ( i=0; i<4; i++ ) { + for ( j=0; j<4; j++ ) { + points[i].modulate[j] = modulate[j]; + } + } + + // Add a segment to the list + cgi.R_AddPolyToScene( beamshader, 4, points/*, renderfx */); +} + +#define MAX_SUBPOINTS 256 +static vec3_t subpoints[MAX_SUBPOINTS]; +static int ptctr=0; +/* +=============== +CG_Subdivide + +a, b, and c are control points. +the subdivided sequence will be: a, out1, out2, out3, c +=============== +*/ +static void CG_Subdivide( vec3_t a, vec3_t b, vec3_t c, vec3_t out1, vec3_t out2, vec3_t out3 ) { + VectorLerp(a,b,0.5,out1); + VectorLerp(b,c,0.5,out3); + VectorLerp(out1,out3,0.5,out2); +} + +static void CG_MultiBeamBegin() { + ptctr = 0; +} + +static void CG_MultiBeamAddPoints(vec3_t start, vec3_t end, int numsegments, int flags, + float minoffset, float maxoffset, qboolean addstartpoint) { + vec3_t delta,dir,randdir; + float length; + int i; + + if ( ptctr > MAX_SUBPOINTS ) + return; + + if ( addstartpoint ) { + _VectorCopy(start, subpoints[ ptctr++ ]); + } + + VectorSubtract(end,start,delta); + length = VectorLength(delta); + length /= numsegments; + + // get the dir of beam + VectorCopy(delta,dir); + VectorNormalize(dir); + + for ( i=1; i MAX_SUBPOINTS ) + return; + + randdir[0] = crandom(); + randdir[1] = crandom(); + randdir[2] = crandom(); + + VectorScale(dir,i * length,newpt); + VectorAdd(newpt,start,newpt); + + VectorScale(randdir,minoffset,tmp); + VectorAdd(newpt,tmp,newpt); + + VectorScale(randdir,maxoffset,tmp); + VectorAdd(newpt,tmp,newpt); + + _VectorCopy(newpt, subpoints[ ptctr++ ]); + } + _VectorCopy(end, subpoints[ ptctr++ ]); +} + +void CG_MultiBeamEnd( float scale, int renderfx, const char *beamshadername, + byte modulate[4], int flags, int owner, float life) { + vec3_t prevpt,currpt; + vec3_t v1,v2,up,currpt1,currpt2,prevpt1,prevpt2; + qboolean prevptvalid=qfalse; + int i,beamshader; + + beamshader = cgi.R_RegisterShader( beamshadername ); + + VectorCopy(subpoints[0],prevpt); + prevptvalid = qfalse; + + for ( i=1; icurrentState.tag_num == ENTITYNUM_NONE ) { + CG_Printf( "CG_MultiBeamSubdivide : Multi beam entity does not have a child\n" ); + return; + } + VectorCopy(current->lerpOrigin, pt1); + + // Get pt2 + current = &cg_entities[ current->currentState.tag_num ]; + // Make sure that child is a multibeam + if ( current->currentState.eType != ET_MULTIBEAM ) + return; + + if ( current->currentState.tag_num == ENTITYNUM_NONE ) { + CG_Printf( "CG_MultiBeamSubdivide : Multi beam entity does not have a child\n" ); + return; + } + + VectorCopy(current->lerpOrigin,pt2); + + // Get pt3 + current = &cg_entities[ current->currentState.tag_num ]; + // Make sure that child is a multibeam + if ( current->currentState.eType != ET_MULTIBEAM ) { + return; + } + + if ( current->currentState.tag_num == ENTITYNUM_NONE ) { + CG_Printf( "CG_MultiBeamSubdivide : Multi beam entity does not have a child\n" ); + return; + } + VectorCopy(current->lerpOrigin,pt3); + + // First point into the subdivided points + _VectorCopy(pt1, subpoints[ptctr++]); + + while ( 1 ) { + // Do the subdivide + CG_Subdivide( pt1, pt2, pt3, out1, out2, out3 ); + CG_Subdivide( pt1, out1, out2, out4, out5, out6 ); + + if ( ( ptctr + 4 ) > MAX_SUBPOINTS ) + break; + + // Save the points + _VectorCopy(out4,subpoints[ptctr++]); + _VectorCopy(out5,subpoints[ptctr++]); + _VectorCopy(out6,subpoints[ptctr++]); + _VectorCopy(out2,subpoints[ptctr++]); + + // end condition + if ( ( current->currentState.tag_num == ENTITYNUM_NONE ) || ( !current->currentValid ) ) { + CG_Subdivide( out2, out3, pt3, out7, out8, out9 ); + + _VectorCopy(out7,subpoints[ptctr++]); + _VectorCopy(out8,subpoints[ptctr++]); + _VectorCopy(out9,subpoints[ptctr++]); + _VectorCopy(pt3,subpoints[ptctr++]); + + + break; + } + + // Advance to next ent + current = &cg_entities[ current->currentState.tag_num ]; + + if ( !current->currentValid ) { + break; + } + + // Advance the points down the line + VectorCopy(out2,pt1); + VectorCopy(pt3,pt2); + VectorCopy(current->lerpOrigin,pt3); + } +} + +void CG_MultiBeam(centity_t *cent) { + vec3_t prevpt,currpt; + entityState_t *s1; + vec3_t v1,v2,up,currpt1,currpt2,prevpt1,prevpt2; + const char *beamshadername; + int beamshader; + byte modulate[4]; + qboolean prevptvalid=qfalse; + int i; + + s1 = ¢->currentState; + + // If this isn't the parent of the beam, then return + if ( !s1->surfaces[0] ) { + return; + } + + // Subdivide up the segments + CG_MultiBeamSubdivide( cent ); + + // This is the top of the beam ent list, build up a renderer beam based on all the children + beamshadername = CG_ConfigString( CS_IMAGES + s1->surfaces[1] ); // index for shader configstring + beamshader = cgi.R_RegisterShader( beamshadername ); + //beamshader = cgi.R_RegisterShader( "" ); + for ( i=0;i<4;i++ ) + modulate[i] = cent->color[i] * 255; + + if ( ptctr < 3 ) { + return; + } + + VectorCopy(subpoints[0],prevpt); + prevptvalid = qfalse; + + for ( i=1; iscale,tmp); + VectorAdd(currpt,tmp,currpt1); + + VectorScale(up,-s1->scale,tmp); + VectorAdd(currpt,tmp,currpt2); + + if ( !prevptvalid ) { + VectorScale(up,s1->scale,tmp); + VectorAdd(prevpt,tmp,prevpt1); + + VectorScale(up,-s1->scale,tmp); + VectorAdd(prevpt,tmp,prevpt2); + prevptvalid = qtrue; + } + + RenderSegment( currpt1, currpt2, prevpt1, prevpt2, modulate, beamshader, s1->renderfx ); + + VectorCopy(currpt,prevpt); + VectorCopy(currpt1,prevpt1); + VectorCopy(currpt2,prevpt2); + } +} +float R_Noise( float x, float y, float z, float t ) { + return 1.f; // TODO +} +static void CG_BuildRendererBeam( vec3_t start, vec3_t end, float angleVar, int numSubdivisions, + byte color[4], int beamshader, float scale, float overlap, int owner, float life, + int flags, float startalpha, float alphastep, int renderfx) { + vec3_t p1, p2, v1, v2, dir, prevpt1, prevpt2, delta, up; + int i,ii,jj; + polyVert_t points[4]; + float length; + int segnum = 0; + int beamnum = 0; + float alphafactor; + int picW; + vec3_t tmp; + + // Create or increment the number of beams for this owner and check to + // see if we should add a new beam + if ( flags & BEAM_PERSIST_EFFECT ) { + beamnum = CreateNewBeamEntity( owner, life ); + if ( beamnum < 0 ) + return; + } + + // For debugging texture coords + //beamshader = cgi.R_RegisterShader( "" ); + + picW = cgi.R_GetShaderWidth( beamshader ); + + // calcluate length of beam segment + VectorSubtract(end,start,delta); + length = VectorLength(delta); + length /= numSubdivisions; + + // get the dir of beam + VectorCopy(delta,dir); + VectorNormalize(dir); + + // Calculate the first up vector + VectorSubtract(start,cg.refdef.vieworg,v1); + VectorSubtract(end,cg.refdef.vieworg,v2); + + CrossProduct(v1,v2,up); + VectorNormalize(up); + + // Calculate the first points + VectorScale(up,scale,tmp); + VectorAdd(start,tmp,prevpt1); + + VectorScale(up,-scale,tmp); + VectorAdd(start,tmp,prevpt2); + + VectorCopy(start,p1); + + // go through and calculate each point of the beam and offset it by the anglevar + for ( i=1; i<=numSubdivisions; i++ ) { + // Calculate the next point along the beam + VectorScale(dir,i*length,tmp); + VectorAdd(start,tmp,p2); + + // Random variance on the next point ( except if it's the last ) + if ( i != numSubdivisions ) { + if ( flags & BEAM_WAVE_EFFECT ) { + float phase = p2[0] + p2[1]; + p2[2] += sin( phase + cg.time ) * angleVar; + } else if ( flags & BEAM_USE_NOISE ) { + p2[0] += R_Noise( p2[0],p2[1],p2[2],cg.time ) * angleVar; + p2[1] += R_Noise( p2[0],p2[1],p2[2],cg.time ) * angleVar; + p2[2] += R_Noise( p2[0],p2[1],p2[2],cg.time ) * angleVar; + } else { + p2[0] += Q_crandom( &seed ) * angleVar; + p2[1] += Q_crandom( &seed ) * angleVar; + p2[2] += Q_crandom( &seed ) * angleVar; + } + } + + // Create the up vec for the beam which is parallel to the viewplane + + VectorSubtract(p1,cg.refdef.vieworg,v1); + VectorSubtract(p2,cg.refdef.vieworg,v2); + CrossProduct(v1,v2,up); + VectorNormalize(up); + + // Build the quad + VectorMA( p2, scale, up, points[0].xyz ); + VectorCopy( prevpt1, points[1].xyz ); + VectorCopy( prevpt2, points[2].xyz ); + VectorMA( p2, -scale, up, points[3].xyz ); + + if ( flags & BEAM_TILESHADER ) {// Tile the shader across the beam + float startS = ( length * ( i-1 ) ) / (float)picW; + float endS = ( length * ( i ) ) / (float)picW; + + points[0].st[0] = startS; points[0].st[1] = 1; + points[1].st[0] = endS; points[1].st[1] = 1; + points[2].st[0] = endS; points[2].st[1] = 0; + points[3].st[0] = startS; points[3].st[1] = 0; + } else { + points[0].st[0] = 1; points[0].st[1] = 1; + points[1].st[0] = 0; points[1].st[1] = 1; + points[2].st[0] = 0; points[2].st[1] = 0; + points[3].st[0] = 1; points[3].st[1] = 0; + } + + + if ( !alphastep ) + alphafactor = 1.0f; + else + alphafactor = startalpha + (alphastep * i); + + // Set the color of the verts + for ( ii=0; ii<4; ii++ ) { + for ( jj=0; jj<4; jj++ ) { + points[ii].modulate[jj] = color[jj] * alphafactor; + } + } + + if ( flags & BEAM_PERSIST_EFFECT ) { + // Save the segment for backup for drawing faded out + AddBeamSegmentToList( owner, points, beamnum, segnum++, renderfx ); + } else { + // Add it to the ref + cgi.R_AddPolyToScene( beamshader, 4, points/*, renderfx*/ ); + } + + + // Subtract off the overlap + if ( overlap ) { + vec3_t tmp; + VectorScale(dir,-overlap,tmp); + VectorAdd(p2,tmp,p2); + } + + // Save off the last point to use as the first point on the next quad + VectorMA( p2, scale, up, prevpt1 ); + VectorMA( p2, -scale, up, prevpt2 ); + VectorCopy(p2,p1); + } +} + +static void CG_CreateModelBeam(beam_t *b, vec3_t org, vec3_t dist, float total_length, + vec3_t ndir, vec3_t left, vec3_t up) { +#if 0 + tiki_t *tiki; + vec3_t bounds[2]; + int single_beam_length; + refEntity_t ent; + int count; + int j; + float factor[3]; + float t; + vec3_t angles; + int i; + + // Find the length of a single beam + tiki = cgi.TIKIForModel( b->hModel ); + + // Calculate the bounds of the model to get it's length + cgi.TIKI_AppendFrameBoundsAndRadius(tiki,0,0,&t,bounds); + + single_beam_length = bounds[1][0] - bounds[0][0]; + + // Create the beam entity + memset (&ent, 0, sizeof(ent)); + count = 0; + + // Initialize the factors + for ( j=0; j<3; j++) + factor[j] = 0.3f * crandom(); + + t = 0; + + while ( t >= 0 && t < 1 ) + { + float dot; + vec3_t pdir; + float delta; + vec3_t distance_point; + + count++; + + // Set the origin of the current beam using the last calculated org + VectorCopy( org, ent.origin ); + + // Advance the org one beam length in the new direction ( dist is the newly calculated direction ) + for ( j=0 ; j<3 ; j++ ) + org[j] += dist[j] * ( single_beam_length - b->overlap ); + + // Offset the org by a random amount to simulate lightning + + VectorMA( org, single_beam_length * factor[2], up, org ); + VectorMA( org, single_beam_length * factor[1], left, org ); + + // Calculate (t) - how far this new point is along the overall distance + VectorSubtract( org, b->start, pdir ); + dot = DotProduct( pdir, ndir ); + t = dot/total_length; + + // Calculate point at current distance along center beam + VectorMA( b->start, total_length * t, ndir, distance_point ); + + // Allow any variations + if ( t > 0.1 && t < 0.9 ) + { + for ( j=0; j<3; j++ ) + { + delta = org[j] - distance_point[j]; + if ( delta > b->max_offset ) + { + org[j] = distance_point[j] + b->max_offset; + factor[j] = -0.3 * crandom(); + } + else if ( delta < -b->max_offset ) + { + org[j] = distance_point[j] - b->max_offset; + factor[j] = 0.3 * crandom(); + } + else + factor[j] = 0.3 * crandom(); + } + } + else // Clamp to mins + { + for ( j=0; j<3; j++ ) + { + delta = org[j] - distance_point[j]; + if ( delta > b->min_offset ) + { + org[j] -= 0.4 * single_beam_length; + factor[j] = -0.2; + } + else if ( delta < -b->min_offset ) + { + org[j] += 0.4 * single_beam_length; + factor[j] = 0.2; + } + else + factor[j] = 0; + } + } + + // Calculate the new dist vector so we can get pitch and yaw for this beam + VectorSubtract (org, ent.origin, dist); + + // Set the pitch and the yaw based off this new vector + vectoangles( dist, angles ); + + // Fill in the ent fields + ent.hModel = b->hModel; + ent.scale = b->scale; + ent.renderfx = b->renderfx; + + for( i=0; i<4; i++ ) + ent.shaderRGBA[i] = b->shaderRGBA[i]; + + VectorCopy(ent.origin, ent.oldorigin); + AnglesToAxis( angles, ent.axis ); + + // Add in this beam to the ref + cgi.R_AddRefEntityToScene( &ent ); + } +#endif +} + +// called every frame +void CG_AddBeams() { + int i,ii; + beam_t *b; + vec3_t delta; + vec3_t angles; + vec3_t forward, left, up; + float length; + byte color[4]; + float fade; + + b=cg_beams; + for (i=0 ; ihModel || b->endtime < cg.time ) { + // Make sure endtime is not 0, and remove the beam entirely + if ( b->endtime ) { + RemoveBeamList( b->entity ); + b->entity = ENTITYNUM_NONE; + b->endtime = 0; + } + continue; + } + + // Fade the beam based on it's life + fade = (float)( b->endtime - cg.time ) / (float) b->life; + + for ( ii=0; ii<4; ii++ ) + color[ii] = b->shaderRGBA[ii] * fade; + + // Check to see if the beam should be toggled + if ( b->flags & BEAM_TOGGLE ) { + if ( cg.time > b->toggletime ) { + b->active = !b->active; + if ( b->flags & BEAM_RANDOM_TOGGLEDELAY ) + b->toggletime = cg.time + random() * b->toggledelay; + else + b->toggletime = cg.time + b->toggledelay; + } + } + + if ( !b->active ) { + CG_AddBeamsFromList( b->entity, b->beamshader ); + continue; + } + + if ( ( b->flags & BEAM_PERSIST_EFFECT ) && ( b->update_time > cg.time ) ) { + CG_AddBeamsFromList( b->entity, b->beamshader ); + continue; + } + + b->update_time = cg.time + b->delay; + + if ( !b->active ) + continue; + + if ( b->flags & BEAM_USEMODEL ) { + // Calculate the direction + VectorSubtract( b->start, b->end, delta ); + + // Calculate the beam length + length = VectorLength( delta ); + + // Get the perpendicular vectors to this vector + vectoangles( delta, angles ); + AngleVectors( angles, forward, left, up ); + CG_CreateModelBeam( b, b->start, delta, length, forward, left, up ); + } else { + // Do a sphere effect + if ( b->flags & BEAM_SPHERE_EFFECT ) { + int k; + + // Calculate the direction + VectorSubtract( b->start, b->end, delta ); + + // Calculate the beam length + length = VectorLength( delta ); + + for( k=0; knumspherebeams; k++ ) { + vec3_t offset; + vec3_t tmp; + vec3_t start,end; + offset[0] = crandom(); + offset[1] = crandom(); + offset[2] = crandom(); + + VectorScale(offset,b->sphereradius,tmp); + VectorAdd(b->start,offset,start); + + VectorScale(offset,length,tmp); + VectorAdd(b->start,offset,end); + + CG_BuildRendererBeam( start, end, b->max_offset, + b->numSubdivisions, color, b->beamshader, b->scale, + b->overlap, b->entity, b->life, b->flags, b->alpha, + b->alphastep, b->renderfx ); + } + } else { + //CG_Printf( "%2f %2f %2f\n", b->start[0],b->start[1],b->start[2] ); + CG_BuildRendererBeam( b->start, b->end, b->max_offset, + b->numSubdivisions, color, b->beamshader, b->scale, + b->overlap, b->entity, b->life, b->flags, b->alpha, + b->alphastep, b->renderfx ); + } + if ( b->flags & BEAM_PERSIST_EFFECT ) + CG_AddBeamsFromList( b->entity, b->beamshader ); + } + } +} + +void CG_CreateBeam(vec3_t start, vec3_t dir, int owner, qhandle_t hModel, float alpha, + float scale, int flags, float length, int life, qboolean create, vec3_t endpointvec, + int min_offset, int max_offset, int overlap, int numSubdivisions, int delay, + const char *beamshadername, byte modulate[4], int numspherebeams, float sphereradius, + int toggledelay, float endalpha, int renderfx, const char *name) { + int i; + beam_t *b; + vec3_t end; + trace_t trace; + + // Check to see if endpoint is specified + if ( endpointvec ) { + VectorCopy( endpointvec, end ); + } else { + // Trace to find the endpoint with a shot + VectorMA( start, length, dir, end ); + CG_Trace( &trace,start, vec3_origin, vec3_origin, end, 0, MASK_SHOT/*, qfalse, qtrue, "Create Beam"*/ ); + VectorCopy( trace.endpos, end ); + } + + // If we aren't creating a beam, then search the beams for this one already active + if ( !create ) { + for ( i=0, b=cg_beams ; i< MAX_BEAMS ; i++, b++ ) { + if ( b->entity == owner ) { + if ( name && b->name == name ) { + b->endtime = cg.time + life; + b->hModel = hModel; + b->scale = scale; + b->flags = flags; + b->overlap = overlap; + b->min_offset = min_offset; + b->max_offset = max_offset; + b->alpha = alpha; + b->beamshader = cgi.R_RegisterShader( beamshadername ); + b->numSubdivisions = numSubdivisions; + b->delay = delay; + b->life = life; + b->numspherebeams = numspherebeams; + b->sphereradius = sphereradius; + b->renderfx = renderfx; + + // take the alpha from the entity if less than 1, else grab it from the client commands version + if ( alpha < 1 ) + b->shaderRGBA[ 3 ] = alpha * 255; + else + b->shaderRGBA[ 3 ] = modulate[3]; + + // Modulation based off the color + for( i=0; i<3; i++ ) + b->shaderRGBA[ i ] = modulate[ i ] * ( (float)b->shaderRGBA[3] / 255.0f ); + + b->alphastep = ( (float)( endalpha - alpha ) / (float)b->numSubdivisions ); + + VectorCopy( start, b->start ); + VectorCopy( end, b->end ); + return; + } + } + } + } + + // find a free beam + for ( i=0, b=cg_beams ; i< MAX_BEAMS ; i++, b++ ) { + if ( b->endtime < cg.time ) { + b->entity = owner; + b->endtime = cg.time + life; + b->hModel = hModel; + b->alpha = alpha; + b->scale = scale; + b->flags = flags; + b->overlap = overlap; + b->min_offset = min_offset; + b->max_offset = max_offset; + b->beamshader = cgi.R_RegisterShader( beamshadername ); + b->numSubdivisions = numSubdivisions; + b->delay = delay; + b->update_time = 0;//cg.time + delay; + b->life = life; + b->numspherebeams = numspherebeams; + b->sphereradius = sphereradius; + b->active = qtrue; + b->toggledelay = toggledelay; + b->renderfx = renderfx; + strcpy( b->name, name ); + + // take the alpha from the entity if less than 1, else grab it from the client commands version + if ( alpha < 1 ) + b->shaderRGBA[ 3 ] = alpha * 255; + else + b->shaderRGBA[ 3 ] = modulate[ 3 ]; + + // Modulation based off the color + for( i=0; i<3; i++ ) + b->shaderRGBA[ i ] = modulate[ i ] * ( (float)b->shaderRGBA[3] / 255.0f ); + + + b->alphastep = ( (float)( endalpha - alpha ) / (float)b->numSubdivisions ); + + VectorCopy( start, b->start ); + VectorCopy( end, b->end ); + return; + } + } + return; +} + +static void CG_KillBeams(int entity_number) { + int i; + beam_t *b; + + for ( i=0, b=cg_beams ; i< MAX_BEAMS ; i++, b++ ) { + if ( b->entity == entity_number ) { + b->entity = ENTITYNUM_NONE; + b->endtime = 0; + } + } +} + +static void CG_RestartBeams(int timedelta) { + int i; + beam_t *b; + + for ( i=0, b=cg_beams ; i< MAX_BEAMS ; i++, b++ ) { + if ( b->active && ( b->update_time > cg.time ) ) { + b->endtime -= timedelta; + b->update_time -= timedelta; + if ( b->toggletime ) + b->toggletime -= timedelta; + } + } +} + +#if 1 +void CG_Rope(centity_t *cent) { + entityState_t *s1; + vec3_t top, mid, bottom, up, v1, v2; + vec3_t currpt1, currpt2, prevpt1, prevpt2; + const char *beamshadername; + int beamshader; + byte modulate[4]; + float picH, length, endT; + int i,j; + polyVert_t points[4]; + vec3_t tmp; + + s1 = ¢->currentState; + + VectorCopy(s1->origin2,top); + VectorCopy(cent->lerpOrigin,mid); + VectorCopy(cent->lerpOrigin,bottom); + + bottom[2] -= s1->alpha; + + // This is the top of the beam ent list, build up a renderer beam based on all the children + beamshadername = CG_ConfigString( CS_IMAGES + s1->surfaces[0] ); // index for shader configstring + beamshader = cgi.R_RegisterShader( beamshadername ); + + picH = cgi.R_GetShaderHeight( beamshader ); + + for ( i=0;i<4;i++ ) + modulate[i] = cent->color[i] * 255; + + // Generate the up vector + VectorSubtract(top,cg.refdef.vieworg,v1); + VectorSubtract(bottom,cg.refdef.vieworg,v2); + + + CrossProduct(v1,v2,up); + VectorNormalize(up); + + // Set the color of the verts + for ( i=0; i<4; i++ ) { + for ( j=0; j<4; j++ ) { + points[i].modulate[j] = modulate[j]; + } + } + // set the s coordinates + points[0].st[0] = 1; + points[1].st[0] = 1; + points[2].st[0] = 0; + points[3].st[0] = 0; + + // Calculate the first points + VectorScale(up, s1->scale,tmp); + VectorAdd(top,tmp,prevpt1); + + VectorScale(up, -s1->scale,tmp); + VectorAdd(top,tmp,prevpt2); + + // draw the top section + VectorScale(up, s1->scale,tmp); + VectorAdd(mid,tmp,currpt1); + + VectorScale(up, -s1->scale,tmp); + VectorAdd(mid,tmp,currpt2); + + + VectorSubtract(mid,top,tmp); + + + length = VectorLength(tmp); + + VectorCopy( currpt1, points[0].xyz ); + VectorCopy( prevpt1, points[1].xyz ); + VectorCopy( prevpt2, points[2].xyz ); + VectorCopy( currpt2, points[3].xyz ); + + endT = length / picH; + points[0].st[1] = endT; + points[3].st[1] = endT; + points[1].st[1] = 0; + points[2].st[1] = 0; + + // Add a segment to the list + cgi.R_AddPolyToScene( beamshader, 4, points/*, s1->renderfx*/ ); + + if ( s1->alpha > 0 ) { + // draw the bottom section + vec3_t tmp; + VectorCopy(currpt1,prevpt1); + VectorCopy(currpt2,prevpt2); + VectorScale(up,s1->scale,tmp); + VectorAdd(bottom,tmp,currpt1); + + VectorScale(up,-s1->scale,tmp); + VectorAdd(bottom,tmp,currpt2); + + VectorCopy( currpt1, points[0].xyz ); + VectorCopy( prevpt1, points[1].xyz ); + VectorCopy( prevpt2, points[2].xyz ); + VectorCopy( currpt2, points[3].xyz ); + + // add on the rest of the rope + length += s1->alpha; + + // use previous T value for the start of this segment + points[1].st[1] = endT; + points[2].st[1] = endT; + endT = length / picH; + points[0].st[1] = endT; + points[3].st[1] = endT; + + // Add a segment to the list + cgi.R_AddPolyToScene( beamshader, 4, points/*, s1->renderfx*/ ); + } +} + +#endif \ No newline at end of file diff --git a/code/cgame/cg_consolecmds.c b/code/cgame/cg_consolecmds.c new file mode 100644 index 00000000..bf137c49 --- /dev/null +++ b/code/cgame/cg_consolecmds.c @@ -0,0 +1,336 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_consolecmds.c -- text commands typed in at the local console, or +// executed by a key binding + +#include "cg_local.h" + + +void CG_TargetCommand_f( void ) { + int targetNum; + char *test; + + targetNum = CG_CrosshairPlayer(); + if (!targetNum ) { + return; + } + + test = cgi.Argv( 1 ); + cgi.SendConsoleCommand( va( "gc %i %i", targetNum, atoi( test ) ) ); +} + + + +/* +================= +CG_SizeUp_f + +Keybinding command +================= +*/ +static void CG_SizeUp_f (void) { + cgi.Cvar_Set("cg_viewsize", va("%i",(int)(cg_viewsize->integer+10))); +} + + +/* +================= +CG_SizeDown_f + +Keybinding command +================= +*/ +static void CG_SizeDown_f (void) { + cgi.Cvar_Set("cg_viewsize", va("%i",(int)(cg_viewsize->integer-10))); +} + + +/* +============= +CG_Viewpos_f + +Debugging command to print the current position +============= +*/ +static void CG_Viewpos_f (void) { + CG_Printf ("(%i %i %i) : %i\n", (int)cg.refdef.vieworg[0], + (int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2], + (int)cg.refdefViewAngles[YAW]); +} + + +static void CG_ScoresDown_f( void ) { + + if ( cg.scoresRequestTime + 1000 < cg.time ) { + // the scores are more than two seconds out of data, + // so request new ones + cg.scoresRequestTime = cg.time; + cgi.SendClientCommand( "score" ); + + // leave the current scores up if they were already + // displayed, but if this is the first hit, clear them out + if ( !cg.showScores ) { + cg.showScores = qtrue; + cg.numScores = 0; + } + } else { + // show the cached contents even if they just pressed if it + // is within two seconds + cg.showScores = qtrue; + } + cg.scoreBoardShowing = qtrue; + cgi.Cvar_Set( "ui_showscores", "1" ); +} + +static void CG_ScoresUp_f( void ) { + if ( cg.showScores ) { + cg.showScores = qfalse; + cg.scoreFadeTime = cg.time; + } + cg.scoreBoardShowing = qfalse; + cgi.Cvar_Set( "ui_showscores", "0" ); +} + +static void CG_TellTarget_f( void ) { + int clientNum; + char command[128]; + char *message; + + clientNum = CG_CrosshairPlayer(); + if ( clientNum == -1 ) { + return; + } + + message = cgi.Args(); + Com_sprintf( command, 128, "tell %i %s", clientNum, message ); + cgi.SendClientCommand( command ); +} + +static void CG_TellAttacker_f( void ) { + int clientNum; + char command[128]; + char *message; + + clientNum = CG_LastAttacker(); + if ( clientNum == -1 ) { + return; + } + + message = cgi.Args(); + Com_sprintf( command, 128, "tell %i %s", clientNum, message ); + cgi.SendClientCommand( command ); +} + +/* +================== +CG_StartOrbit_f +================== +*/ + +static void CG_StartOrbit_f( void ) { + char var[MAX_TOKEN_CHARS]; + + cgi.Cvar_VariableStringBuffer( "developer", var, sizeof( var ) ); + if ( !atoi(var) ) { + return; + } + if (cg_cameraOrbit->value != 0) { + cgi.Cvar_Set ("cg_cameraOrbit", "0"); + cgi.Cvar_Set("cg_thirdPerson", "0"); + } else { + cgi.Cvar_Set("cg_cameraOrbit", "5"); + cgi.Cvar_Set("cg_thirdPerson", "1"); + cgi.Cvar_Set("cg_thirdPersonAngle", "0"); + cgi.Cvar_Set("cg_thirdPersonRange", "100"); + } +} + +static void CG_LocationPrint_f(void) { + char *buffer; + int x,y; + + buffer = cgi.Argv( 1 ); + x = atoi(buffer); + buffer = cgi.Argv( 2 ); + y = atoi(buffer); + buffer = cgi.Argv( 3 ); + buffer[511] = 0; + CG_LocationPrint( buffer, x, y, SMALLCHAR_WIDTH ); +} + +// su44: in MoHAA, "useweaponclass pistol/rifle/etc" +// commands are usually bound to 1,2,3,4,5,6 keys +static void CG_UseWeaponClass_f(void) { + const char *name; + + if(cgi.Argc() < 2) { + CG_Printf("usage: useweaponclass \n"); + return; + } + + // get weapon classname + name = CG_Argv(1); + if(!Q_stricmp(name,"pistol")) { + cg.iWeaponCommand = 1; + } else if(!Q_stricmp(name,"rifle")) { + cg.iWeaponCommand = 2; + } else if(!Q_stricmp(name,"smg")) { + cg.iWeaponCommand = 3; + } else if(!Q_stricmp(name,"mg")) { + cg.iWeaponCommand = 4; + } else if(!Q_stricmp(name,"grenade")) { + cg.iWeaponCommand = 5; + } else if(!Q_stricmp(name,"heavy")) { + cg.iWeaponCommand = 6; + } else if(!Q_stricmp(name,"item2")) { + cg.iWeaponCommand = 8; // su44: AFAIK it's not used at all in MoHAA + } else if(!Q_stricmp(name,"item3")) { + cg.iWeaponCommand = 9; // su44: AFAIK it's not used at all in MoHAA + } else if(!Q_stricmp(name,"item4")) { + cg.iWeaponCommand = 10; // su44: AFAIK it's not used at all in MoHAA + } else if(!Q_stricmp(name,"item") || !Q_stricmp(name,"item1")) { + cg.iWeaponCommand = 7; // su44: I think it's used for "Papers" item + } else { + CG_Printf("useweaponclass: unknown weapon %s\n", name); + } + cg.iWeaponCommandSend = 0; +} + +typedef struct { + char *cmd; + void (*function)(void); +} consoleCommand_t; + +static consoleCommand_t commands[] = { + { "testgun", CG_TestGun_f }, + { "testmodel", CG_TestModel_f }, + { "testmodelanim", CG_TestModelAnim_f }, + { "testmodelanimspeedscale", CG_TestModelAnimSpeedScale_f }, + { "nextframe", CG_TestModelNextFrame_f }, + { "prevframe", CG_TestModelPrevFrame_f }, + { "nextskin", CG_TestModelNextSkin_f }, + { "prevskin", CG_TestModelPrevSkin_f }, + { "viewpos", CG_Viewpos_f }, + { "+scores", CG_ScoresDown_f }, + { "-scores", CG_ScoresUp_f }, + { "+zoom", CG_ZoomDown_f }, + { "-zoom", CG_ZoomUp_f }, + { "sizeup", CG_SizeUp_f }, + { "sizedown", CG_SizeDown_f }, + { "weapnext", CG_NextWeapon_f }, + { "weapprev", CG_PrevWeapon_f }, + { "tell_target", CG_TellTarget_f }, + { "tell_attacker", CG_TellAttacker_f }, + { "tcmd", CG_TargetCommand_f }, + { "startOrbit", CG_StartOrbit_f }, + //{ "camera", CG_Camera_f }, + { "locationprint", CG_LocationPrint_f }, + // su44: MoHAA commands + { "toggleitem", CG_ToggleItem_f }, + { "weapdrop", CG_DropWeapon_f }, + { "holster", CG_HolsterWeapon_f }, + { "weapnext", CG_NextWeapon_f }, + { "weapprev", CG_PrevWeapon_f }, + { "useweaponclass", CG_UseWeaponClass_f }, +}; + + +/* +================= +CG_ConsoleCommand + +The string has been tokenized and can be retrieved with +Cmd_Argc() / Cmd_Argv() +================= +*/ +qboolean CG_ConsoleCommand( void ) { + const char *cmd; + int i; + + cmd = CG_Argv(0); + + for ( i = 0 ; i < sizeof( commands ) / sizeof( commands[0] ) ; i++ ) { + if ( !Q_stricmp( cmd, commands[i].cmd ) ) { + commands[i].function(); + return qtrue; + } + } + + return qfalse; +} + + +/* +================= +CG_InitConsoleCommands + +Let the client system know about all of our commands +so it can perform tab completion +================= +*/ +void CG_InitConsoleCommands( void ) { + int i; + + for ( i = 0 ; i < sizeof( commands ) / sizeof( commands[0] ) ; i++ ) { + cgi.AddCommand( commands[i].cmd, NULL ); + } + + // + // the game server will interpret these commands, which will be automatically + // forwarded to the server after they are not recognized locally + // + // wombat: mohaa servers understand the following + cgi.AddCommand( "dog", NULL ); // Sets the god mode cheat or toggles it. + cgi.AddCommand ("notarget", NULL ); // Toggles the notarget cheat. + cgi.AddCommand ("noclip", NULL ); // Toggles the noclip cheat. + + cgi.AddCommand ("weapdrop", NULL ); // Drops the player's current weapon. + cgi.AddCommand ("reload", NULL ); // Reloads the player's weapon + cgi.AddCommand ("give", NULL ); // Gives the player the specified thing (weapon, ammo, item, etc.) and optionally the amount. + cgi.AddCommand ("jump", NULL ); // Makes the player jump. + cgi.AddCommand ("holster", NULL ); // Holsters all wielded weapons, or unholsters previously put away weapons + // su44 + cgi.AddCommand ("join_team", NULL ); // Join the specified team (allies or axis) + cgi.AddCommand ("auto_join_team", NULL ); // Join the team with fewer players + cgi.AddCommand ("spectator", NULL ); // Become a spectator + + // wombat: mohaa arena what is that??? + cgi.AddCommand ("join_arena", NULL ); // Join the specified arena + cgi.AddCommand ("leave_arena", NULL ); // Leave the current arena + cgi.AddCommand ("create_team", NULL ); // Create a team in the current arena + cgi.AddCommand ("leave_team", NULL ); // Leave the current team + cgi.AddCommand ("arena_ui", NULL ); // Refresh the arena UI + + cgi.AddCommand ("callvote", NULL ); // Player calls a vote + cgi.AddCommand ("vote", NULL ); // Player votes either yes or no + + cgi.AddCommand ("primarydmweapon", NULL ); // Sets the player's primary DM weapon + // primarydmweapon rifle / smg / mg / heavy / shotgun + + cgi.AddCommand ("kill", NULL ); + cgi.AddCommand ("say", NULL ); + cgi.AddCommand ("sayone", NULL ); // talk to one client + cgi.AddCommand ("sayprivate", NULL ); // same as sayone?? + cgi.AddCommand ("sayteam", NULL ); // talk to team + cgi.AddCommand ("teamsay", NULL ); // talk to team +} diff --git a/code/cgame/cg_draw.c b/code/cgame/cg_draw.c new file mode 100644 index 00000000..63df83ad --- /dev/null +++ b/code/cgame/cg_draw.c @@ -0,0 +1,1576 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_draw.c -- draw all of the graphical elements during +// active (after loading) gameplay + +#include "cg_local.h" + +vec4_t menu_text_color = {1.0f, 1.0f, 1.0f, 1.0f}; +vec4_t menu_dim_color = {0.0f, 0.0f, 0.0f, 0.75f}; +vec4_t color_black = {0.00f, 0.00f, 0.00f, 1.00f}; +vec4_t color_white = {1.00f, 1.00f, 1.00f, 1.00f}; +vec4_t color_yellow = {1.00f, 1.00f, 0.00f, 1.00f}; +vec4_t color_blue = {0.00f, 0.00f, 1.00f, 1.00f}; +vec4_t color_lightOrange = {1.00f, 0.68f, 0.00f, 1.00f }; +vec4_t color_orange = {1.00f, 0.43f, 0.00f, 1.00f}; +vec4_t color_red = {1.00f, 0.00f, 0.00f, 1.00f}; +vec4_t color_transred = {1.00f, 0.00f, 0.00f, 0.60f}; +vec4_t color_transreddk = {1.00f, 0.00f, 0.30f, 0.60f}; +vec4_t color_dim = {0.00f, 0.00f, 0.00f, 0.25f}; +vec4_t color_gray = {0.00f, 0.00f, 0.00f, 0.6f}; +vec4_t color_green = {0.10f, 0.70f, 0.10f, 1.00f}; +vec4_t color_transgreen = {0.10f, 0.70f, 0.10f, 0.60f}; +vec4_t color_transgreendk = {0.10f, 0.70f, 0.30f, 0.60f}; +vec4_t color_dkgreen = {0.40f, 0.40f, 0.40f, 1.00f}; + +// for printing game messages +vec4_t color_hud = {0.70f, 0.60f, 0.05f, 1.00f}; +vec4_t color_grey = {0.75f, 0.75f, 0.75f, 1.00f}; +vec4_t color_lightRed = {0.70f, 0.50f, 0.50f, 1.00f}; + + +int drawTeamOverlayModificationCount = -1; + + +int sortedTeamPlayers[TEAM_MAXOVERLAY]; +int numSortedTeamPlayers; + +char systemChat[256]; +char teamChat1[256]; +char teamChat2[256]; + +/* +================ +CG_Draw3DModel + +================ +*/ +void CG_Draw3DModel( float x, float y, float w, float h, qhandle_t model, qhandle_t skin, vec3_t origin, vec3_t angles ) { + refdef_t refdef; + refEntity_t ent; + + if ( !cg_draw3dIcons->integer || !cg_drawIcons->integer ) { + return; + } + + CG_AdjustFrom640( &x, &y, &w, &h ); + + memset( &refdef, 0, sizeof( refdef ) ); + + memset( &ent, 0, sizeof( ent ) ); + AnglesToAxis( angles, ent.axis ); + VectorCopy( origin, ent.origin ); + ent.model = model; + ent.customSkin = skin; + ent.renderfx &= ~RF_SHADOW; // no stencil shadows + + refdef.rdflags = RDF_NOWORLDMODEL; + + AxisClear( refdef.viewaxis ); + + refdef.fov_x = 30; + refdef.fov_y = 30; + + refdef.x = x; + refdef.y = y; + refdef.width = w; + refdef.height = h; + + refdef.time = cg.time; + + cgi.R_ClearScene(); + cgi.R_AddRefEntityToScene( &ent ); + cgi.R_RenderScene( &refdef ); +} + + +/* +=========================================================================================== + + UPPER RIGHT CORNER + +=========================================================================================== +*/ + +/* +================ +CG_DrawAttacker + +su44: draw attacker client name and team +flag in the left down corner of the screen +================ +*/ +#define ATTACKER_X 80 +#define ATTACKER_Y 400 +static void CG_DrawAttacker() { + int clientNum; + clientInfo_t *info; + qhandle_t handle; + + if ( cg_drawAttacker->integer == 0) + return; + + clientNum = cg.predictedPlayerState.stats[STAT_ATTACKERCLIENT]; + if ( clientNum < 0 || clientNum >= MAX_CLIENTS || clientNum == cg.snap->ps.clientNum ) { + return; + } + + info = &cgs.clientinfo[clientNum]; + + cgi.R_SetColor( color_red ); + cgi.R_Text_Paint(&cgs.media.verdana, ATTACKER_X,ATTACKER_Y,1,0,info->name,0,0,qfalse,qtrue); + cgi.R_SetColor( NULL ); + + if(info->team == TEAM_AXIS) { + handle = cgi.R_RegisterShader("textures/hud/axis"); + CG_DrawPic(ATTACKER_X-30,ATTACKER_Y-4,24,24,handle); + } else if(info->team == TEAM_ALLIES) { + handle = cgi.R_RegisterShader("textures/hud/allies"); + CG_DrawPic(ATTACKER_X-30,ATTACKER_Y-4,24,24,handle); + } +} + +/* +================== +CG_DrawSnapshot +================== +*/ +static float CG_DrawSnapshot( float y ) { + char *s; + int w; + + s = va( "time:%i snap:%i cmd:%i", cg.snap->serverTime, + cg.latestSnapshotNum, cgs.serverCommandSequence ); + w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; + + CG_DrawBigString( 635 - w, y + 2, s, 1.0F); + + return y + BIGCHAR_HEIGHT + 4; +} + +/* +================== +CG_DrawFPS +================== +*/ +#define FPS_FRAMES 4 +static float CG_DrawFPS( float y ) { + char *s; + int w; + static int previousTimes[FPS_FRAMES]; + static int index; + int i, total; + int fps; + static int previous; + int t, frameTime; + + // don't use serverTime, because that will be drifting to + // correct for internet lag changes, timescales, timedemos, etc + t = cgi.Milliseconds(); + frameTime = t - previous; + previous = t; + + previousTimes[index % FPS_FRAMES] = frameTime; + index++; + if ( index > FPS_FRAMES ) { + // average multiple frames together to smooth changes out a bit + total = 0; + for ( i = 0 ; i < FPS_FRAMES ; i++ ) { + total += previousTimes[i]; + } + if ( !total ) { + total = 1; + } + fps = 1000 * FPS_FRAMES / total; + + s = va( "%ifps", fps ); + w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; + + CG_DrawBigString( 635 - w, y + 2, s, 1.0F); + } + + return y + BIGCHAR_HEIGHT + 4; +} + +/* +================= +CG_DrawTimer +================= +*/ +static float CG_DrawTimer( float y ) { + char *s; + int w; + int mins, seconds, tens; + int msec; + + msec = cg.time - cgs.levelStartTime; + + seconds = msec / 1000; + mins = seconds / 60; + seconds -= mins * 60; + tens = seconds / 10; + seconds -= tens * 10; + + s = va( "%i:%i%i", mins, tens, seconds ); + w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; + + CG_DrawBigString( 635 - w, y + 2, s, 1.0F); + + return y + BIGCHAR_HEIGHT + 4; +} + + +/* +================= +CG_DrawTeamOverlay +================= +*/ + +static float CG_DrawTeamOverlay( float y, qboolean right, qboolean upper ) { +// int x, w, h, xx; +// int i, j, len; +// const char *p; +// vec4_t hcolor; +// int pwidth, lwidth; +// int plyrs; +// char st[16]; +// clientInfo_t *ci; +// int ret_y, count; +// +// if ( !cg_drawTeamOverlay->integer ) { +// return y; +// } +// +// if ( cg.snap->ps.stats[STAT_TEAM] != TEAM_RED && cg.snap->ps.stats[STAT_TEAM] != TEAM_BLUE ) { +// return y; // Not on any team +// } +// +// plyrs = 0; +// +// // max player name width +// pwidth = 0; +// count = (numSortedTeamPlayers > 8) ? 8 : numSortedTeamPlayers; +// for (i = 0; i < count; i++) { +// ci = cgs.clientinfo + sortedTeamPlayers[i]; +// if ( ci->infoValid && ci->team == cg.snap->ps.stats[STAT_TEAM]) { +// plyrs++; +// len = CG_DrawStrlen(ci->name); +// if (len > pwidth) +// pwidth = len; +// } +// } +// +// if (!plyrs) +// return y; +// +// if (pwidth > TEAM_OVERLAY_MAXNAME_WIDTH) +// pwidth = TEAM_OVERLAY_MAXNAME_WIDTH; +// +// // max location name width +// lwidth = 0; +// for (i = 1; i < MAX_LOCATIONS; i++) { +// p = CG_ConfigString(CS_LOCATIONS + i); +// if (p && *p) { +// len = CG_DrawStrlen(p); +// if (len > lwidth) +// lwidth = len; +// } +// } +// +// if (lwidth > TEAM_OVERLAY_MAXLOCATION_WIDTH) +// lwidth = TEAM_OVERLAY_MAXLOCATION_WIDTH; +// +// w = (pwidth + lwidth + 4 + 7) * TINYCHAR_WIDTH; +// +// if ( right ) +// x = 640 - w; +// else +// x = 0; +// +// h = plyrs * TINYCHAR_HEIGHT; +// +// if ( upper ) { +// ret_y = y + h; +// } else { +// y -= h; +// ret_y = y; +// } +// +// if ( cg.snap->ps.stats[STAT_TEAM] == TEAM_RED ) { +// hcolor[0] = 1.0f; +// hcolor[1] = 0.0f; +// hcolor[2] = 0.0f; +// hcolor[3] = 0.33f; +// } else { // if ( cg.snap->ps.stats[STAT_TEAM] == TEAM_BLUE ) +// hcolor[0] = 0.0f; +// hcolor[1] = 0.0f; +// hcolor[2] = 1.0f; +// hcolor[3] = 0.33f; +// } +// cgi.R_SetColor( hcolor ); +// CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar ); +// cgi.R_SetColor( NULL ); +// +// for (i = 0; i < count; i++) { +// ci = cgs.clientinfo + sortedTeamPlayers[i]; +// if ( ci->infoValid && ci->team == cg.snap->ps.stats[STAT_TEAM]) { +// +// hcolor[0] = hcolor[1] = hcolor[2] = hcolor[3] = 1.0; +// +// xx = x + TINYCHAR_WIDTH; +// +// CG_DrawStringExt( xx, y, +// ci->name, hcolor, qfalse, qfalse, +// TINYCHAR_WIDTH, TINYCHAR_HEIGHT, TEAM_OVERLAY_MAXNAME_WIDTH); +// +// if (lwidth) { +// p = CG_ConfigString(CS_LOCATIONS + ci->location); +// if (!p || !*p) +// p = "unknown"; +// len = CG_DrawStrlen(p); +// if (len > lwidth) +// len = lwidth; +// +//// xx = x + TINYCHAR_WIDTH * 2 + TINYCHAR_WIDTH * pwidth + +//// ((lwidth/2 - len/2) * TINYCHAR_WIDTH); +// xx = x + TINYCHAR_WIDTH * 2 + TINYCHAR_WIDTH * pwidth; +// CG_DrawStringExt( xx, y, +// p, hcolor, qfalse, qfalse, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, +// TEAM_OVERLAY_MAXLOCATION_WIDTH); +// } +// +// CG_GetColorForHealth( ci->health, ci->armor, hcolor ); +// +// Com_sprintf (st, sizeof(st), "%3i %3i", ci->health, ci->armor); +// +// xx = x + TINYCHAR_WIDTH * 3 + +// TINYCHAR_WIDTH * pwidth + TINYCHAR_WIDTH * lwidth; +// +// CG_DrawStringExt( xx, y, +// st, hcolor, qfalse, qfalse, +// TINYCHAR_WIDTH, TINYCHAR_HEIGHT, 0 ); +// +// // draw weapon icon +// xx += TINYCHAR_WIDTH * 3; +// +// if ( cg_weapons[ci->curWeapon].weaponIcon ) { +// CG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, +// cg_weapons[ci->curWeapon].weaponIcon ); +// } else { +// CG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, +// cgs.media.deferShader ); +// } +// +// // Draw powerup icons +// if (right) { +// xx = x; +// } else { +// xx = x + w - TINYCHAR_WIDTH; +// } +// for (j = 0; j <= PW_NUM_POWERUPS; j++) { +// if (ci->powerups & (1 << j)) { +// +// item = BG_FindItemForPowerup( j ); +// +// if (item) { +// CG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT, +// cgi.R_RegisterShader( item->icon ) ); +// if (right) { +// xx -= TINYCHAR_WIDTH; +// } else { +// xx += TINYCHAR_WIDTH; +// } +// } +// } +// } +// +// y += TINYCHAR_HEIGHT; +// } +// } +// +// return ret_y; +////#endif +return y; +} + + +/* +===================== +CG_DrawUpperRight + +===================== +*/ +static void CG_DrawUpperRight( void ) { + float y; + + y = 0; + + if ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay->integer == 1 ) { + y = CG_DrawTeamOverlay( y, qtrue, qtrue ); + } + if ( cg_drawSnapshot->integer ) { + y = CG_DrawSnapshot( y ); + } + if ( cg_drawFPS->integer ) { + y = CG_DrawFPS( y ); + } + if ( cg_drawTimer->integer ) { + y = CG_DrawTimer( y ); + } +} + +/* +=========================================================================================== + + LOWER RIGHT CORNER + +=========================================================================================== +*/ + + +// +///* +//===================== +//CG_DrawLowerRight +// +//===================== +//*/ +//#ifndef MISSIONPACK +//static void CG_DrawLowerRight( void ) { +// float y; +// +// y = 480 - ICON_SIZE; +// +// if ( cgs.gametype >= GT_TEAM && cg_drawTeamOverlay->integer == 2 ) { +// y = CG_DrawTeamOverlay( y, qtrue, qfalse ); +// } +// +// y = CG_DrawScores( y ); +// y = CG_DrawPowerups( y ); +//} +//#endif // MISSIONPACK + +//=========================================================================================== + + +/* +=============================================================================== + +LAGOMETER + +=============================================================================== +*/ + +#define LAG_SAMPLES 128 + + +typedef struct { + int frameSamples[LAG_SAMPLES]; + int frameCount; + int snapshotFlags[LAG_SAMPLES]; + int snapshotSamples[LAG_SAMPLES]; + int snapshotCount; +} lagometer_t; + +lagometer_t lagometer; + +/* +============== +CG_AddLagometerFrameInfo + +Adds the current interpolate / extrapolate bar for this frame +============== +*/ +void CG_AddLagometerFrameInfo( void ) { + int offset; + + offset = cg.time - cg.latestSnapshotTime; + lagometer.frameSamples[ lagometer.frameCount & ( LAG_SAMPLES - 1) ] = offset; + lagometer.frameCount++; +} + +/* +============== +CG_AddLagometerSnapshotInfo + +Each time a snapshot is received, log its ping time and +the number of snapshots that were dropped before it. + +Pass NULL for a dropped packet. +============== +*/ +void CG_AddLagometerSnapshotInfo( snapshot_t *snap ) { + // dropped packet + if ( !snap ) { + lagometer.snapshotSamples[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = -1; + lagometer.snapshotCount++; + return; + } + + // add this snapshot's info + lagometer.snapshotSamples[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = snap->ping; + lagometer.snapshotFlags[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = snap->snapFlags; + lagometer.snapshotCount++; +} + +/* +============== +CG_DrawDisconnect + +Should we draw something differnet for long lag vs no packets? +============== +*/ +static void CG_DrawDisconnect( void ) { + float x, y; + int cmdNum; + usercmd_t cmd; + const char *s; + int w; + + // draw the phone jack if we are completely past our buffers + cmdNum = cgi.GetCurrentCmdNumber() - CMD_BACKUP + 1; + cgi.GetUserCmd( cmdNum, &cmd ); + if ( cmd.serverTime <= cg.snap->ps.commandTime + || cmd.serverTime > cg.time ) { // special check for map_restart + return; + } + + // also add text in center of screen + s = "Connection Interrupted"; + w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; + CG_DrawBigString( 320 - w/2, 100, s, 1.0F); + + // blink the icon + if ( ( cg.time >> 9 ) & 1 ) { + return; + } + + x = 640 - 48; + y = 480 - 48; + + CG_DrawPic( x, y, 48, 48, cgi.R_RegisterShader("gfx/2d/net.tga" ) ); +} + + +#define MAX_LAGOMETER_PING 900 +#define MAX_LAGOMETER_RANGE 300 + +/* +============== +CG_DrawLagometer +============== +*/ +static void CG_DrawLagometer( void ) { + int a, x, y, i; + float v; + float ax, ay, aw, ah, mid, range; + int color; + float vscale; + + if ( !cg_lagometer->integer || cgs.localServer ) { + CG_DrawDisconnect(); + return; + } + + // + // draw the graph + // +#ifdef MISSIONPACK + x = 640 - 48; + y = 480 - 144; +#else + x = 640 - 48; + y = 480 - 48; +#endif + + cgi.R_SetColor( NULL ); +// CG_DrawPic( x, y, 48, 48, cgs.media.lagometerShader ); + + ax = x; + ay = y; + aw = 48; + ah = 48; + CG_AdjustFrom640( &ax, &ay, &aw, &ah ); + + color = -1; + range = ah / 3; + mid = ay + range; + + vscale = range / MAX_LAGOMETER_RANGE; + + // draw the frame interpoalte / extrapolate graph + for ( a = 0 ; a < aw ; a++ ) { + i = ( lagometer.frameCount - 1 - a ) & (LAG_SAMPLES - 1); + v = lagometer.frameSamples[i]; + v *= vscale; + if ( v > 0 ) { + if ( color != 1 ) { + color = 1; + cgi.R_SetColor( g_color_table[ColorIndex(COLOR_YELLOW)] ); + } + if ( v > range ) { + v = range; + } + cgi.R_DrawStretchPic ( ax + aw - a, mid - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader ); + } else if ( v < 0 ) { + if ( color != 2 ) { + color = 2; + cgi.R_SetColor( g_color_table[ColorIndex(COLOR_BLUE)] ); + } + v = -v; + if ( v > range ) { + v = range; + } + cgi.R_DrawStretchPic( ax + aw - a, mid, 1, v, 0, 0, 0, 0, cgs.media.whiteShader ); + } + } + + // draw the snapshot latency / drop graph + range = ah / 2; + vscale = range / MAX_LAGOMETER_PING; + + for ( a = 0 ; a < aw ; a++ ) { + i = ( lagometer.snapshotCount - 1 - a ) & (LAG_SAMPLES - 1); + v = lagometer.snapshotSamples[i]; + if ( v > 0 ) { + if ( lagometer.snapshotFlags[i] & SNAPFLAG_RATE_DELAYED ) { + if ( color != 5 ) { + color = 5; // YELLOW for rate delay + cgi.R_SetColor( g_color_table[ColorIndex(COLOR_YELLOW)] ); + } + } else { + if ( color != 3 ) { + color = 3; + cgi.R_SetColor( g_color_table[ColorIndex(COLOR_GREEN)] ); + } + } + v = v * vscale; + if ( v > range ) { + v = range; + } + cgi.R_DrawStretchPic( ax + aw - a, ay + ah - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader ); + } else if ( v < 0 ) { + if ( color != 4 ) { + color = 4; // RED for dropped snapshots + cgi.R_SetColor( g_color_table[ColorIndex(COLOR_RED)] ); + } + cgi.R_DrawStretchPic( ax + aw - a, ay + ah - range, 1, range, 0, 0, 0, 0, cgs.media.whiteShader ); + } + } + + cgi.R_SetColor( NULL ); + + if ( cg_nopredict->integer || cg_synchronousClients->integer ) { + CG_DrawBigString( ax, ay, "snc", 1.0 ); + } + + CG_DrawDisconnect(); +} + + + +/* +=============================================================================== + +CENTER PRINTING + +=============================================================================== +*/ + + +/* +============== +CG_CenterPrint + +Called for important messages that should stay in the center of the screen +for a few moments +============== +*/ +void CG_CenterPrint( const char *str, int y, int charWidth ) { + char *s; + + Q_strncpyz( cg.centerPrint, str, sizeof(cg.centerPrint) ); + + cg.centerPrintTime = cg.time; + cg.centerPrintY = y; + cg.centerPrintCharWidth = charWidth; + + // count the number of lines for centering + cg.centerPrintLines = 1; + s = cg.centerPrint; + while( *s ) { + if (*s == '\n') + cg.centerPrintLines++; + s++; + } +} + +void CG_LocationPrint( const char *str, int x, int y, int charWidth ) { + char *s; + + Q_strncpyz( cg.locationPrint, str, sizeof(cg.locationPrint) ); + + cg.locationPrintTime = cg.time; + cg.locationPrintX = x; + cg.locationPrintY = y; + cg.locationPrintCharWidth = charWidth; + + // count the number of lines for centering + cg.locationPrintLines = 1; + s = cg.locationPrint; + while( *s ) { + if (*s == '\n') + cg.locationPrintLines++; + s++; + } +} + + +/* +=================== +CG_DrawCenterString +=================== +*/ +static void CG_DrawCenterString( void ) { + char *start; + int l; + int x, y, w; + float *color; + + if ( !cg.centerPrintTime ) { + return; + } + + color = CG_FadeColor( cg.centerPrintTime, 1000 * cg_centertime->value ); + if ( !color ) { + return; + } + + cgi.R_SetColor( color ); + + start = cg.centerPrint; + + y = cg.centerPrintY - cg.centerPrintLines * BIGCHAR_HEIGHT / 2; + + while ( 1 ) { + char linebuffer[1024]; + + for ( l = 0; l < 50; l++ ) { + if ( !start[l] || start[l] == '\n' ) { + break; + } + linebuffer[l] = start[l]; + } + linebuffer[l] = 0; + + + w = cg.centerPrintCharWidth * CG_DrawStrlen( linebuffer ); + + x = ( SCREEN_WIDTH - w ) / 2; + + CG_DrawStringExt( x, y, linebuffer, color, qfalse, qtrue, + cg.centerPrintCharWidth, (int)(cg.centerPrintCharWidth * 1.5), 0 ); + + y += cg.centerPrintCharWidth * 1.5; + + while ( *start && ( *start != '\n' ) ) { + start++; + } + if ( !*start ) { + break; + } + start++; + } + + cgi.R_SetColor( NULL ); +} + +/* +=================== +CG_DrawLocationString +=================== +*/ +static void CG_DrawLocationString( void ) { + char *start; + int l; + int x, y, w; + float *color; + + if ( !cg.locationPrintTime ) { + return; + } + + color = CG_FadeColor( cg.locationPrintTime, 1000 * cg_locationtime->value ); + if ( !color ) { + return; + } + + cgi.R_SetColor( color ); + + start = cg.locationPrint; + + y = cg.locationPrintY - cg.locationPrintLines * BIGCHAR_HEIGHT / 2; + + while ( 1 ) { + char linebuffer[1024]; + + for ( l = 0; l < 50; l++ ) { + if ( !start[l] || start[l] == '\n' ) { + break; + } + linebuffer[l] = start[l]; + } + linebuffer[l] = 0; + + w = cg.locationPrintCharWidth * CG_DrawStrlen( linebuffer ); + + x = ( SCREEN_WIDTH - w ) / 2; + + CG_DrawStringExt( x, y, linebuffer, color, qfalse, qtrue, + cg.locationPrintCharWidth, (int)(cg.locationPrintCharWidth * 1.5), 0 ); + + y += cg.locationPrintCharWidth * 1.5; + + while ( *start && ( *start != '\n' ) ) { + start++; + } + if ( !*start ) { + break; + } + start++; + } + + cgi.R_SetColor( NULL ); +} + +/* +=================== +CG_DrawGameMessages +=================== +*/ +#define CG_GAMEMESSAGETIMEOUT 4000 +static void CG_DrawGameMessages( void ) { + int i; + + if ( cg.time - cg.gameMessageTime > CG_GAMEMESSAGETIMEOUT + && cg.gameMessagePtr1 != cg.gameMessagePtr2 ) { + cg.gameMessagePtr1=(cg.gameMessagePtr1+1)%MAX_GAMEMESSAGES; + cg.gameMessageTime = cg.time; + if ( cg.gameMessagePtr1 == (cg.gameMessagePtr2+1)%MAX_GAMEMESSAGES ) + cg.gameMessagePtr2 = (cg.gameMessagePtr2+1)%MAX_GAMEMESSAGES; + } + for (i=0;i CG_GAMEMESSAGETIMEOUT + && cg.chatDeathMessagePtr1 != cg.chatDeathMessagePtr2 ) { + cg.chatDeathMessagePtr1 = (cg.chatDeathMessagePtr1+1)%MAX_CHATDEATHMESSAGES; + cg.chatDeathMessageTime = cg.time; + if ( cg.chatDeathMessagePtr1 == (cg.chatDeathMessagePtr2+1)%MAX_CHATDEATHMESSAGES ) + cg.chatDeathMessagePtr2 = (cg.chatDeathMessagePtr2+1)%MAX_CHATDEATHMESSAGES; + } + for (i=0;ips.pm_flags & PMF_SPECTATE_FOLLOW) ) { + return qfalse; + } + color[0] = 1; + color[1] = 1; + color[2] = 1; + color[3] = 1; + + + CG_DrawBigString( 320 - 9 * 8, 24, "following", 1.0F ); + + name = cgs.clientinfo[ cg.snap->ps.clientNum ].name; + + x = 0.5 * ( 640 - GIANT_WIDTH * CG_DrawStrlen( name ) ); + + CG_DrawStringExt( x, 40, name, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 ); + + return qtrue; +} + + + + +/* +================= +CG_DrawWarmup +================= +*/ +static void CG_DrawWarmup( void ) { + int w; + int sec; + float scale; + int cw; + const char *s; + + sec = cg.warmup; + if ( !sec ) { + return; + } + + if ( sec < 0 ) { + s = "Waiting for players"; + w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; + CG_DrawBigString(320 - w / 2, 24, s, 1.0F); + cg.warmupCount = 0; + return; + } + + + { + if ( cgs.gametype == GT_FFA ) { + s = "Free For All"; + } else if ( cgs.gametype == GT_TEAM ) { + s = "Team Deathmatch"; + } else { + s = ""; + } +#ifdef MISSIONPACK + w = CG_Text_Width(s, 0.6f, 0); + CG_Text_Paint(320 - w / 2, 90, 0.6f, colorWhite, s, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE); +#else + w = CG_DrawStrlen( s ); + if ( w > 640 / GIANT_WIDTH ) { + cw = 640 / w; + } else { + cw = GIANT_WIDTH; + } + CG_DrawStringExt( 320 - w * cw/2, 25,s, colorWhite, + qfalse, qtrue, cw, (int)(cw * 1.1f), 0 ); +#endif + } + + sec = ( sec - cg.time ) / 1000; + if ( sec < 0 ) { + cg.warmup = 0; + sec = 0; + } + s = va( "Starts in: %i", sec + 1 ); + if ( sec != cg.warmupCount ) { + cg.warmupCount = sec; + switch ( sec ) { + case 0: +// cgi.S_StartLocalSound( cgs.media.count1Sound, CHAN_ANNOUNCER ); + break; + case 1: +// cgi.S_StartLocalSound( cgs.media.count2Sound, CHAN_ANNOUNCER ); + break; + case 2: +// cgi.S_StartLocalSound( cgs.media.count3Sound, CHAN_ANNOUNCER ); + break; + default: + break; + } + } + scale = 0.45f; + switch ( cg.warmupCount ) { + case 0: + cw = 28; + scale = 0.54f; + break; + case 1: + cw = 24; + scale = 0.51f; + break; + case 2: + cw = 20; + scale = 0.48f; + break; + default: + cw = 16; + scale = 0.45f; + break; + } + +#ifdef MISSIONPACK + w = CG_Text_Width(s, scale, 0); + CG_Text_Paint(320 - w / 2, 125, scale, colorWhite, s, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE); +#else + w = CG_DrawStrlen( s ); + CG_DrawStringExt( 320 - w * cw/2, 70, s, colorWhite, + qfalse, qtrue, cw, (int)(cw * 1.5), 0 ); +#endif +} + +//================================================================================== + +char* extractValues( char **start ) { + char *end, *ret; + + ret = *start; + end = strstr( *start, " " ); + if (end) { + *end = 0; + *start = end+1; + } + + return ret; +} + +/* +================= +CG_DrawScores + +Draw the normal in-game scoreboard +================= +*/ +void CG_DrawScores( void ) { + int i, numScores; + char *ptr; + char buffer[MAX_STRING_CHARS]; + fontInfo_t *font; + int facfontheight, verdanaheight; + + if ( cg.scoresRequestTime + 1000 < cg.time ) { + // the scores are more than two seconds out of data, + // so request new ones + cg.scoresRequestTime = cg.time; + cgi.SendClientCommand( "score" ); + } + + Q_strncpyz( buffer, cg.aScore, sizeof(buffer) ); + CG_DrawStdBox( 32, 56, 384, 392, qfalse ); + + ptr = buffer; + numScores = atoi( extractValues( &ptr ) ); + + facfontheight = 20; + verdanaheight = 14; + + if ( cgs.gametype == GT_FFA || cgs.gametype == GT_SINGLE_PLAYER ) { + font = &cgs.media.verdana; + for ( i=0; i= 448 ) + break; + clientNum = atoi( extractValues( &ptr ) ); + cgi.R_Text_Paint( font, 32, 56 + i*verdanaheight, 1, 1, Info_ValueForKey( CG_ConfigString( CS_PLAYERS + clientNum ), "name" ), 1, 32, qtrue, qfalse ); // name + cgi.R_Text_Paint( font, 160, 56 + i*verdanaheight, 1, 1, extractValues( &ptr ), 1, 32, qtrue, qfalse ); + cgi.R_Text_Paint( font, 224, 56 + i*verdanaheight, 1, 1, extractValues( &ptr ), 1, 32, qtrue, qfalse ); + cgi.R_Text_Paint( font, 288, 56 + i*verdanaheight, 1, 1, extractValues( &ptr ), 1, 32, qtrue, qfalse ); + cgi.R_Text_Paint( font, 352, 56 + i*verdanaheight, 1, 1, extractValues( &ptr ), 1, 32, qtrue, qfalse ); + } + } else { + for ( i=0; i= 448 ) + break; + clientNum = atoi( extractValues( &ptr ) ); + team = (teamtype_t)atoi( extractValues( &ptr ) ); + switch ( team ) { + case TEAM_AXIS: + if ( clientNum == -1 ) + cgi.R_SetColor( color_transreddk ); + else + cgi.R_SetColor( color_transred ); + CG_DrawBox( 33,56+i*verdanaheight,384,verdanaheight,qfalse); + cgi.R_SetColor( NULL ); + break; + case TEAM_ALLIES: + if ( clientNum == -1 ) + cgi.R_SetColor( color_transgreendk ); + else + cgi.R_SetColor( color_transgreen ); + CG_DrawBox( 33,56+i*verdanaheight,384,verdanaheight,qfalse); + cgi.R_SetColor( NULL ); + break; + default: break; + } + if ( clientNum == -1 ) { + font = &cgs.media.facfont; + if ( team == TEAM_ALLIES ) + cgi.R_Text_Paint( font, 32, 56 + i*verdanaheight, 1, 1, "Allies", 1, 32, qtrue, qfalse ); + else if ( team == TEAM_AXIS ) + cgi.R_Text_Paint( font, 32, 56 + i*verdanaheight, 1, 1, "Axis", 1, 32, qtrue, qfalse ); + else if ( team == TEAM_SPECTATOR ) + cgi.R_Text_Paint( font, 32, 56 + i*verdanaheight, 1, 1, "Spectators", 1, 32, qtrue, qfalse ); + } else { + font = &cgs.media.verdana; + cgi.R_Text_Paint( font, 32, 56 + i*verdanaheight, 1, 1, Info_ValueForKey( CG_ConfigString( CS_PLAYERS + clientNum ), "name" ), 1, 32, qtrue, qfalse ); // name + } + cgi.R_Text_Paint( font, 160, 56 + i*verdanaheight, 1, 1, extractValues( &ptr ), 1, 32, qtrue, qfalse ); + cgi.R_Text_Paint( font, 224, 56 + i*verdanaheight, 1, 1, extractValues( &ptr ), 1, 32, qtrue, qfalse ); + cgi.R_Text_Paint( font, 288, 56 + i*verdanaheight, 1, 1, extractValues( &ptr ), 1, 32, qtrue, qfalse ); + cgi.R_Text_Paint( font, 352, 56 + i*verdanaheight, 1, 1, extractValues( &ptr ), 1, 32, qtrue, qfalse ); + } + } +} +/* +================= +CG_DrawPlayerTeam + +Draws team icon of local player +================= +*/ +void CG_DrawPlayerTeam() { + //if ( cg_hud->integer ) + { + if ( cg.snap ) { + if ( cgs.gametype > GT_FFA ) { + qhandle_t handle = 0; + + if ( cg.snap->ps.stats[STAT_TEAM] == TEAM_ALLIES ) { + handle = cgi.R_RegisterShader("textures/hud/allies"); + } else { + if ( cg.snap->ps.stats[STAT_TEAM] == TEAM_AXIS ) + handle = cgi.R_RegisterShader("textures/hud/axis"); + } + if ( handle ) { + cgi.R_SetColor(0); + cgi.R_DrawStretchPic(96.f, (cgs.glconfig.vidHeight - 46), 24.f, 24.f, 0.f, 0.f, 1.f, 1.f, handle); + } + } + } + } +} +static void CG_DrawOverlayTopBottom(qhandle_t handleTop, qhandle_t handleBottom, float fAlpha) { + float halfH; + float ofs; + float ofsHR; + vec4_t color; + + color[0] = 1.f; + color[1] = 1.f; + color[2] = 1.f; + color[3] = fAlpha; + cgi.R_SetColor(color); + + halfH = cgs.glconfig.vidHeight >> 1; + ofs = (cgs.glconfig.vidWidth - cgs.glconfig.vidHeight) >> 1; + ofsHR = ofs + halfH; + + // draw overlay square + cgi.R_DrawStretchPic( ofs, 0, halfH, halfH, 1.f, 0, 0, 1.f, handleTop); + cgi.R_DrawStretchPic( ofsHR, 0, halfH, halfH, 0, 0, 1.f, 1.f, handleTop); + cgi.R_DrawStretchPic( ofs, halfH, halfH, halfH, 1.f, 0, 0, 1.f, handleBottom); + cgi.R_DrawStretchPic( ofsHR, halfH, halfH, halfH, 0, 0, 1.f, 1.f, handleBottom); + + // draw black borders + VectorSet(color,0,0,0); + cgi.R_SetColor(color); + cgi.R_DrawStretchPic( 0, 0, ofs, cgs.glconfig.vidHeight, 0, 0, 1.f, 1.f, cgs.media.blackShader); + cgi.R_DrawStretchPic( cgs.glconfig.vidWidth - ofs, 0, ofs, cgs.glconfig.vidHeight, + 0, 0, 1.f, 1.f, cgs.media.blackShader); +} + +static void CG_DrawOverlayMiddle(qhandle_t handle, float fAlpha ) { + float halfH; + float ofs; + float ofsHR; + float color[4]; + + color[0] = 1.f; + color[1] = 1.f; + color[2] = 1.f; + // su44: thats a hack, such a thing is not done in MoHAA. + // probably something is wrong with our shader system + // maybe "textures/hud/zoomoverlay" cGen is broken? + color[3] = 1.f - fAlpha; // should be: "color[3] = fAlpha; + cgi.R_SetColor(color); + + halfH = cgs.glconfig.vidHeight >> 1; + ofs = (cgs.glconfig.vidWidth - cgs.glconfig.vidHeight) >> 1; + ofsHR = ofs + halfH; + + // draw overlay square + cgi.R_DrawStretchPic(ofs, 0, halfH, halfH, 0, 0, 1.f, 1.f, handle); + cgi.R_DrawStretchPic( ofsHR, 0, halfH, halfH, 1.f, 0, 0, 1.f, handle); + cgi.R_DrawStretchPic( ofs, halfH, halfH, halfH, 0, 1.f, 1.f, 0, handle); + cgi.R_DrawStretchPic( ofsHR, halfH, halfH, halfH, 1.f, 1.f, 0, 0, handle); + + // draw black borders + VectorSet(color,0,0,0); + color[3] = fAlpha; + cgi.R_SetColor(color); + cgi.R_DrawStretchPic( 0, 0, ofs, cgs.glconfig.vidHeight, 0, 0, 1.f, 1.f, cgs.media.blackShader); + cgi.R_DrawStretchPic(cgs.glconfig.vidWidth - ofs, 0, cgs.glconfig.vidWidth - ofs, + cgs.glconfig.vidHeight, 0, 0, 1.f, 1.f, cgs.media.blackShader); +} +static void CG_DrawOverlayFullScreen(qhandle_t handle, float fAlpha) { + float halfH; + float halfW; + vec4_t color; + + VectorSet(color,1.f,1.f,1.f); + color[3] = fAlpha; + cgi.R_SetColor(color); + + halfH = cgs.glconfig.vidHeight >> 1; + halfW = cgs.glconfig.vidWidth >> 1; + + cgi.R_DrawStretchPic( 0, 0, halfW, halfH, 1.f, 0, 0, 1.f, handle ); + cgi.R_DrawStretchPic( halfW, 0, halfW, halfH, 1.f, 0, 0, 1.f, handle ); + cgi.R_DrawStretchPic( 0, halfH, halfW, halfH, 0, 1.f, 1.f, 0, handle ); + cgi.R_DrawStretchPic( halfW, halfH, halfW, halfH, 1.f, 1.f, 0, 0, handle ); +} + +/* +================= +CG_DrawZoomOverlay +================= +*/ +static float cg_alpha; +static int cg_zoomType; +static void CG_DrawZoomOverlay() { + const char *itemName; + int drawOverlay; + int itemIndex; + signed int inZoom; + snapshot_t *snap; + + snap = cg.snap; + itemName = ""; + drawOverlay = 1; + if ( snap ) { + itemIndex = snap->ps.activeItems[ITEM_WEAPON]; + if ( itemIndex >= 0 ) { + itemName = CG_ConfigString(CS_WEAPONS + itemIndex); + } + + if ( strcmp(itemName, "Spy Camera") ) { + if ( strcmp(itemName, "Binoculars") ) { + inZoom = cg.snap->ps.stats[STAT_INZOOM]; + if ( inZoom && inZoom <= 30 ) { + if ( strcmp(itemName, "KAR98 - Sniper") ) + cg_zoomType = 0; + else + cg_zoomType = 1; + } else { + drawOverlay = 0; + } + } else { + cg_zoomType = 3; + } + } else { + cg_zoomType = 2; + } + if ( drawOverlay ) { + cg_alpha += cg.frametime * 0.015; + if ( cg_alpha > 1.0 ) + cg_alpha = 1.0; +drawOverlayLabel: + if ( cg_zoomType == 1 ) { + CG_DrawOverlayTopBottom(cgs.media.kar98TopOverlayShader, cgs.media.kar98BottomOverlayShader, cg_alpha); + } else { + if ( cg_zoomType > 1 ) { + if ( cg_zoomType != 2 ) { + if ( cg_zoomType == 3 ) + CG_DrawOverlayFullScreen(cgs.media.binocularsOverlayShader, cg_alpha); + } + } else { + if ( !cg_zoomType ) + CG_DrawOverlayMiddle(cgs.media.zoomOverlayShader, cg_alpha); + } + } + return; + } + cg_alpha -= cg.frametime * 0.015; + if(cg_alpha < 0) { + cg_alpha = 0; + } else { + goto drawOverlayLabel; + } + } +} +/* +================= +CG_DrawCrosshairPlayerInfo +================= +*/ +static void CG_DrawCrosshairPlayerInfo() { + int clientNum; + clientInfo_t *info; + + clientNum = cg.snap->ps.stats[STAT_INFOCLIENT]; + + if(clientNum == -1) + return; + + info = &cgs.clientinfo[clientNum]; + + cgi.R_SetColor(color_green); + cgi.R_Text_Paint( &cgs.media.facfont, 64, 280, 1, 1, info->name, 1, 0, qfalse, qfalse ); + cgi.R_SetColor(color_green); + cgi.R_Text_Paint( &cgs.media.facfont, 64, 296, 1, 1, va("%i", + cg.snap->ps.stats[ STAT_INFOCLIENT_HEALTH ] ), 1, 0, qfalse, qfalse ); + +} +/* +================= +CG_Draw2D + +Draws CG related 2D stuff on top of HUD +================= +*/ +void CG_Draw2D( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback ) { + + // if we are taking a levelshot for the menu, don't draw anything + if ( cg.levelShot ) { + return; + } + + if ( cg_draw2D->integer == 0 ) { + return; + } + + CG_DrawLagometer(); + CG_DrawGameMessages(); + CG_DrawChatDeathMessages(); + + // su44: draw player's team icon (axis or allies) + CG_DrawPlayerTeam(); + // su44: draw custom hud elements set by cg messages + CG_HudDrawElements(); + // su44: draw sniper rifles/binoculars zoom overlay + CG_DrawZoomOverlay(); + // su44: draw info about the player local client is currently aiming at + CG_DrawCrosshairPlayerInfo(); + // su44: draw attacker client name and team flag in the left down corner of the screen + CG_DrawAttacker(); + + + + + CG_DrawUpperRight(); + + + //CG_DrawLowerRight(); + //CG_DrawLowerLeft(); + +/* if ( !CG_DrawFollow() ) { + CG_DrawWarmup(); + }*/ + + // don't draw center string if scoreboard is up + if ( !cg.scoreBoardShowing) { + CG_DrawCenterString(); + CG_DrawLocationString(); + } + else + CG_DrawScores(); +} + + +static void CG_DrawTourneyScoreboard( void ) { + +} + +/* +===================== +CG_DrawActive + +Perform all drawing needed to completely fill the screen +===================== +*/ +void CG_DrawActive( stereoFrame_t stereoView ) { + float separation; + vec3_t baseOrg; + + // optionally draw the info screen instead + if ( !cg.snap ) { + CG_DrawInformation(); + return; + } + + switch ( stereoView ) { + case STEREO_CENTER: + separation = 0; + break; + case STEREO_LEFT: + separation = -cg_stereoSeparation->value / 2; + break; + case STEREO_RIGHT: + separation = cg_stereoSeparation->value / 2; + break; + default: + separation = 0; + CG_Error( "CG_DrawActive: Undefined stereoView" ); + } + + + // clear around the rendered view if sized down + CG_TileClear(); + + // offset vieworg appropriately if we're doing stereo separation + VectorCopy( cg.refdef.vieworg, baseOrg ); + if ( separation != 0 ) { + VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg ); + } + + // draw 3D view + cgi.R_RenderScene( &cg.refdef ); + + // restore original viewpoint if running stereo + if ( separation != 0 ) { + VectorCopy( baseOrg, cg.refdef.vieworg ); + } + + // draw status bar and other floating elements +// CG_Draw2D(); + // Draw2D is now called by client directly after UI +} + +// Wombat +/* +================= +UI_DrawBox +UI_DrawStdBox - gray box with borders +ctrCoord == qtrue: draw box with center at x,y +ctrCoord == qfalse: box with upper left corner at x,y +================= +*/ +#define LINE_THICKNESS 1 +void CG_DrawBox( int x, int y, int w, int h, qboolean ctrCoord ) { + + if ( ctrCoord ) { + x -= w/2; + y -= h/2; + } + +// cgi.R_SetColor( color_gray ); + cgi.R_DrawStretchPic( x*cgs.screenXScale, y*cgs.screenYScale, w*cgs.screenXScale, h*cgs.screenYScale, 0, 0, 16, 16, cgs.media.whiteShader ); +// cgi.R_SetColor( color_white ); +// cgi.R_DrawStretchPic( x*cgs.screenXScale, y*cgs.screenYScale, w*cgs.screenXScale, LINE_THICKNESS*cgs.screenYScale, 0, 0, 32, 32, cgs.media.blackShader ); +// cgi.R_DrawStretchPic( x*cgs.screenXScale, y*cgs.screenYScale, LINE_THICKNESS*cgs.screenXScale, h*cgs.screenYScale, 0, 0, 32, 32, cgs.media.blackShader ); +// cgi.R_DrawStretchPic( x*cgs.screenXScale, (y+h)*cgs.screenYScale, w*cgs.screenXScale, LINE_THICKNESS*cgs.screenYScale, 0, 0, 32, 32, cgs.media.blackShader ); +// cgi.R_DrawStretchPic( (x+w)*cgs.screenXScale, y*cgs.screenYScale, LINE_THICKNESS*cgs.screenXScale, (h+LINE_THICKNESS)*cgs.screenYScale, 0, 0, 32, 32, cgs.media.blackShader ); +// cgi.R_SetColor( NULL ); +} + +void CG_DrawStdBox( int x, int y, int w, int h, qboolean ctrCoord ) { + + if ( ctrCoord ) { + x -= w/2; + y -= h/2; + } + + cgi.R_SetColor( color_gray ); + cgi.R_DrawStretchPic( x*cgs.screenXScale, y*cgs.screenYScale, w*cgs.screenXScale, h*cgs.screenYScale, 0, 0, 16, 16, cgs.media.blackShader ); + cgi.R_SetColor( color_white ); + cgi.R_DrawStretchPic( x*cgs.screenXScale, y*cgs.screenYScale, w*cgs.screenXScale, LINE_THICKNESS*cgs.screenYScale, 0, 0, 32, 32, cgs.media.blackShader ); + cgi.R_DrawStretchPic( x*cgs.screenXScale, y*cgs.screenYScale, LINE_THICKNESS*cgs.screenXScale, h*cgs.screenYScale, 0, 0, 32, 32, cgs.media.blackShader ); + cgi.R_DrawStretchPic( x*cgs.screenXScale, (y+h)*cgs.screenYScale, w*cgs.screenXScale, LINE_THICKNESS*cgs.screenYScale, 0, 0, 32, 32, cgs.media.blackShader ); + cgi.R_DrawStretchPic( (x+w)*cgs.screenXScale, y*cgs.screenYScale, LINE_THICKNESS*cgs.screenXScale, (h+LINE_THICKNESS)*cgs.screenYScale, 0, 0, 32, 32, cgs.media.blackShader ); + cgi.R_SetColor( NULL ); +} + + + + + diff --git a/code/cgame/cg_drawtools.c b/code/cgame/cg_drawtools.c new file mode 100644 index 00000000..ecffaff8 --- /dev/null +++ b/code/cgame/cg_drawtools.c @@ -0,0 +1,245 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_drawtools.c -- helper functions called by cg_draw, cg_scoreboard, cg_info, etc +#include "cg_local.h" + +/* +================ +CG_AdjustFrom640 + +Adjusted for resolution and screen aspect ratio +================ +*/ +void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) { +#if 0 + // adjust for wide screens + if ( cgs.glconfig.vidWidth * 480 > cgs.glconfig.vidHeight * 640 ) { + *x += 0.5 * ( cgs.glconfig.vidWidth - ( cgs.glconfig.vidHeight * 640 / 480 ) ); + } +#endif + // scale for screen sizes + *x *= cgs.screenXScale; + *y *= cgs.screenYScale; + *w *= cgs.screenXScale; + *h *= cgs.screenYScale; +} + +/* +================ +CG_FillRect + +Coordinates are 640*480 virtual values +================= +*/ +void CG_FillRect( float x, float y, float width, float height, const float *color ) { + cgi.R_SetColor( color ); + + CG_AdjustFrom640( &x, &y, &width, &height ); + cgi.R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cgs.media.whiteShader ); + + cgi.R_SetColor( NULL ); +} + +/* +================ +CG_DrawSides + +Coords are virtual 640x480 +================ +*/ +void CG_DrawSides(float x, float y, float w, float h, float size) { + CG_AdjustFrom640( &x, &y, &w, &h ); + size *= cgs.screenXScale; + cgi.R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader ); + cgi.R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader ); +} + +void CG_DrawTopBottom(float x, float y, float w, float h, float size) { + CG_AdjustFrom640( &x, &y, &w, &h ); + size *= cgs.screenYScale; + cgi.R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, cgs.media.whiteShader ); + cgi.R_DrawStretchPic( x, y + h - size, w, size, 0, 0, 0, 0, cgs.media.whiteShader ); +} +/* +================ +UI_DrawRect + +Coordinates are 640*480 virtual values +================= +*/ +void CG_DrawRect( float x, float y, float width, float height, float size, const float *color ) { + cgi.R_SetColor( color ); + + CG_DrawTopBottom(x, y, width, height, size); + CG_DrawSides(x, y, width, height, size); + + cgi.R_SetColor( NULL ); +} + + + +/* +================ +CG_DrawPic + +Coordinates are 640*480 virtual values +================= +*/ +void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader ) { + CG_AdjustFrom640( &x, &y, &width, &height ); + cgi.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader ); +} + + +/* +================= +CG_DrawStrlen + +Returns character count, skiping color escape codes +================= +*/ +int CG_DrawStrlen( const char *str ) { + const char *s = str; + int count = 0; + +// while ( *s ) { +// if ( Q_IsColorString( s ) ) { +// s += 2; +// } else { +// count++; +// s++; +// } +// } + return cgi.R_Text_Width( &cgs.media.verdana, str, -1, qtrue ); +} + +/* +============= +CG_TileClearBox + +This repeats a 64*64 tile graphic to fill the screen around a sized down +refresh window. +============= +*/ +static void CG_TileClearBox( int x, int y, int w, int h, qhandle_t hShader ) { + float s1, t1, s2, t2; + + s1 = x/64.0; + t1 = y/64.0; + s2 = (x+w)/64.0; + t2 = (y+h)/64.0; + cgi.R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, hShader ); +} + +/* +============== +CG_TileClear + +Clear around a sized down screen +============== +*/ +void CG_TileClear( void ) { + int top, bottom, left, right; + int w, h; + + w = cgs.glconfig.vidWidth; + h = cgs.glconfig.vidHeight; + + if ( cg.refdef.x == 0 && cg.refdef.y == 0 && + cg.refdef.width == w && cg.refdef.height == h ) { + return; // full screen rendering + } + + top = cg.refdef.y; + bottom = top + cg.refdef.height-1; + left = cg.refdef.x; + right = left + cg.refdef.width-1; + + // clear above view screen + CG_TileClearBox( 0, 0, w, top, cgs.media.backTileShader ); + + // clear below view screen + CG_TileClearBox( 0, bottom, w, h - bottom, cgs.media.backTileShader ); + + // clear left of view screen + CG_TileClearBox( 0, top, left, bottom - top + 1, cgs.media.backTileShader ); + + // clear right of view screen + CG_TileClearBox( right, top, w - right, bottom - top + 1, cgs.media.backTileShader ); +} + +/* +================ +CG_FadeColor +================ +*/ +float *CG_FadeColor( int startMsec, int totalMsec ) { + static vec4_t color; + int t; + + if ( startMsec == 0 ) { + return NULL; + } + + t = cg.time - startMsec; + + if ( t >= totalMsec ) { + return NULL; + } + + // fade out + if ( totalMsec - t < FADE_TIME ) { + color[3] = ( totalMsec - t ) * 1.0/FADE_TIME; + } else { + color[3] = 1.0; + } + color[0] = color[1] = color[2] = 1; + + return color; +} + +/* +================== +CG_DrawStringExt + +Draws a multi-colored string with a drop shadow, optionally forcing +to a fixed color. + +Coordinates are at 640 by 480 virtual resolution +================== +*/ +void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, + qboolean forceColor, qboolean shadow, int charWidth, int charHeight, int maxChars ) { + if(string == 0 || string[0] == 0) + return; + cgi.R_SetColor(setColor); + cgi.R_Text_Paint(&cgs.media.verdana, x, y, 1, 1, string, 0, maxChars, qfalse, qfalse); +} +void CG_DrawBigString( int x, int y, const char *s, float alpha ) { + float color[4]; + + color[0] = color[1] = color[2] = 1.0; + color[3] = alpha; + CG_DrawStringExt( x, y, s, color, qfalse, qtrue, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0 ); +} + diff --git a/code/cgame/cg_effects.c b/code/cgame/cg_effects.c new file mode 100644 index 00000000..8ebfa976 --- /dev/null +++ b/code/cgame/cg_effects.c @@ -0,0 +1,453 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_effects.c -- these functions generate localentities, usually as a result +// of event processing + +#include "cg_local.h" + + +/* +================== +CG_BubbleTrail + +Bullets shot underwater +================== +*/ +void CG_BubbleTrail( vec3_t start, vec3_t end, float spacing ) { + //vec3_t move; + //vec3_t vec; + //float len; + //int i; + + //if ( cg_noProjectileTrail->integer ) { + // return; + //} + + //VectorCopy (start, move); + //VectorSubtract (end, start, vec); + //len = VectorNormalize (vec); + + //// advance a random amount first + //i = rand() % (int)spacing; + //VectorMA( move, i, vec, move ); + + //VectorScale (vec, spacing, vec); + + //for ( ; i < len; i += spacing ) { + // localEntity_t *le; + // refEntity_t *re; + + // le = CG_AllocLocalEntity(); + // le->leFlags = LEF_PUFF_DONT_SCALE; + // le->leType = LE_MOVE_SCALE_FADE; + // le->startTime = cg.time; + // le->endTime = cg.time + 1000 + random() * 250; + // le->lifeRate = 1.0 / ( le->endTime - le->startTime ); + + // re = &le->refEntity; + // re->shaderTime = cg.time / 1000.0f; + + // re->reType = RT_SPRITE; + // re->rotation = 0; + // re->radius = 3; + // re->customShader = cgs.media.waterBubbleShader; + // re->shaderRGBA[0] = 0xff; + // re->shaderRGBA[1] = 0xff; + // re->shaderRGBA[2] = 0xff; + // re->shaderRGBA[3] = 0xff; + + // le->color[3] = 1.0; + + // le->pos.trType = TR_LINEAR; + // le->pos.trTime = cg.time; + // VectorCopy( move, le->pos.trBase ); + // le->pos.trDelta[0] = crandom()*5; + // le->pos.trDelta[1] = crandom()*5; + // le->pos.trDelta[2] = crandom()*5 + 6; + + // VectorAdd (move, vec, move); + //} +} + +/* +===================== +CG_SmokePuff + +Adds a smoke puff or blood trail localEntity. +===================== +*/ +localEntity_t *CG_SmokePuff( const vec3_t p, const vec3_t vel, + float radius, + float r, float g, float b, float a, + float duration, + int startTime, + int fadeInTime, + int leFlags, + qhandle_t hShader ) { +// static int seed = 0x92; +// localEntity_t *le; +// refEntity_t *re; +//// int fadeInTime = startTime + duration / 2; +// +// le = CG_AllocLocalEntity(); +// le->leFlags = leFlags; +// le->radius = radius; +// +// re = &le->refEntity; +// re->rotation = Q_random( &seed ) * 360; +// re->radius = radius; +// re->shaderTime = startTime / 1000.0f; +// +// le->leType = LE_MOVE_SCALE_FADE; +// le->startTime = startTime; +// le->fadeInTime = fadeInTime; +// le->endTime = startTime + duration; +// if ( fadeInTime > startTime ) { +// le->lifeRate = 1.0 / ( le->endTime - le->fadeInTime ); +// } +// else { +// le->lifeRate = 1.0 / ( le->endTime - le->startTime ); +// } +// le->color[0] = r; +// le->color[1] = g; +// le->color[2] = b; +// le->color[3] = a; +// +// +// le->pos.trType = TR_LINEAR; +// le->pos.trTime = startTime; +// VectorCopy( vel, le->pos.trDelta ); +// VectorCopy( p, le->pos.trBase ); +// +// VectorCopy( p, re->origin ); +// re->customShader = hShader; +// +// // rage pro can't alpha fade, so use a different shader +// if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) { +// re->customShader = cgs.media.smokePuffRageProShader; +// re->shaderRGBA[0] = 0xff; +// re->shaderRGBA[1] = 0xff; +// re->shaderRGBA[2] = 0xff; +// re->shaderRGBA[3] = 0xff; +// } else { +// re->shaderRGBA[0] = le->color[0] * 0xff; +// re->shaderRGBA[1] = le->color[1] * 0xff; +// re->shaderRGBA[2] = le->color[2] * 0xff; +// re->shaderRGBA[3] = 0xff; +// } +// +// re->reType = RT_SPRITE; +// re->radius = le->radius; +// +// return le; + return 0; +} + +/* +================== +CG_ScorePlum +================== +*/ +void CG_ScorePlum( int client, vec3_t org, int score ) { + localEntity_t *le; + refEntity_t *re; + vec3_t angles; + static vec3_t lastPos; + + // only visualize for the client that scored + if (client != cg.predictedPlayerState.clientNum || cg_scorePlum->integer == 0) { + return; + } + + le = CG_AllocLocalEntity(); + le->leFlags = 0; + le->leType = LE_SCOREPLUM; + le->startTime = cg.time; + le->endTime = cg.time + 4000; + le->lifeRate = 1.0 / ( le->endTime - le->startTime ); + + + le->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0; + le->radius = score; + + VectorCopy( org, le->pos.trDelta ); + if (org[2] >= lastPos[2] - 20 && org[2] <= lastPos[2] + 20) { + le->pos.trDelta[ 2 ] -= 20; + } + + //CG_Printf( "Plum origin %i %i %i -- %i\n", (int)org[0], (int)org[1], (int)org[2], (int)Distance(org, lastPos)); + VectorCopy(org, lastPos); + + + re = &le->refEntity; + + re->reType = RT_SPRITE; + re->radius = 16; + + VectorClear(angles); + AnglesToAxis( angles, re->axis ); +} + + +/* +==================== +CG_MakeExplosion +==================== +*/ +localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, + qhandle_t hModel, qhandle_t shader, + int msec, qboolean isSprite ) { + float ang; + localEntity_t *ex; + int offset; + vec3_t tmpVec, newOrigin; + + if ( msec <= 0 ) { + CG_Error( "CG_MakeExplosion: msec = %i", msec ); + } + + // skew the time a bit so they aren't all in sync + offset = rand() & 63; + + ex = CG_AllocLocalEntity(); + if ( isSprite ) { + ex->leType = LE_SPRITE_EXPLOSION; + + // randomly rotate sprite orientation + ex->refEntity.rotation = rand() % 360; + VectorScale( dir, 16, tmpVec ); + VectorAdd( tmpVec, origin, newOrigin ); + } else { + ex->leType = LE_EXPLOSION; + VectorCopy( origin, newOrigin ); + + // set axis with random rotate + if ( !dir ) { + AxisClear( ex->refEntity.axis ); + } else { + ang = rand() % 360; + VectorCopy( dir, ex->refEntity.axis[0] ); + RotateAroundDirection( ex->refEntity.axis, ang ); + } + } + + ex->startTime = cg.time - offset; + ex->endTime = ex->startTime + msec; + + // bias the time so all shader effects start correctly + ex->refEntity.shaderTime = ex->startTime / 1000.0f; + + ex->refEntity.model = hModel; + ex->refEntity.customShader = shader; + + // set origin + VectorCopy( newOrigin, ex->refEntity.origin ); + VectorCopy( newOrigin, ex->refEntity.oldorigin ); + + ex->color[0] = ex->color[1] = ex->color[2] = 1.0; + + return ex; +} + + +/* +================= +CG_Bleed + +This is the spurt of blood when a character gets hit +================= +*/ +void CG_Bleed( vec3_t origin, int entityNum ) { + localEntity_t *ex; + + if ( !cg_blood->integer ) { + return; + } + + ex = CG_AllocLocalEntity(); + ex->leType = LE_EXPLOSION; + + ex->startTime = cg.time; + ex->endTime = ex->startTime + 500; + + VectorCopy ( origin, ex->refEntity.origin); + ex->refEntity.reType = RT_SPRITE; + ex->refEntity.rotation = rand() % 360; + ex->refEntity.radius = 24; + + ex->refEntity.customShader = 0; //cgs.media.bloodExplosionShader; + + // don't show player's own blood in view + if ( entityNum == cg.snap->ps.clientNum ) { + ex->refEntity.renderfx |= RF_THIRD_PERSON; + } +} + + + +/* +================== +CG_LaunchGib +================== +*/ +void CG_LaunchGib( vec3_t origin, vec3_t velocity, qhandle_t hModel ) { + localEntity_t *le; + refEntity_t *re; + + le = CG_AllocLocalEntity(); + re = &le->refEntity; + + le->leType = LE_FRAGMENT; + le->startTime = cg.time; + le->endTime = le->startTime + 5000 + random() * 3000; + + VectorCopy( origin, re->origin ); + AxisCopy( axisDefault, re->axis ); + re->model = hModel; + + VectorCopy( origin, le->pos.trDelta ); + VectorCopy( velocity, le->pos.trDelta ); + le->pos.trTime = cg.time; + + le->bounceFactor = 0.6f; + + le->leBounceSoundType = LEBS_BLOOD; + le->leMarkType = LEMT_BLOOD; +} + +/* +=================== +CG_GibPlayer + +Generated a bunch of gibs launching out from the bodies location +=================== +*/ +#define GIB_VELOCITY 250 +#define GIB_JUMP 250 +void CG_GibPlayer( vec3_t playerOrigin ) { + //vec3_t origin, velocity; + + //if ( !cg_blood->integer ) { + // return; + //} + + //VectorCopy( playerOrigin, origin ); + //velocity[0] = crandom()*GIB_VELOCITY; + //velocity[1] = crandom()*GIB_VELOCITY; + //velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY; + //if ( rand() & 1 ) { + // CG_LaunchGib( origin, velocity, cgs.media.gibSkull ); + //} else { + // CG_LaunchGib( origin, velocity, cgs.media.gibBrain ); + //} + + //// allow gibs to be turned off for speed + //if ( !cg_gibs->integer ) { + // return; + //} + + //VectorCopy( playerOrigin, origin ); + //velocity[0] = crandom()*GIB_VELOCITY; + //velocity[1] = crandom()*GIB_VELOCITY; + //velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY; + //CG_LaunchGib( origin, velocity, cgs.media.gibAbdomen ); + + //VectorCopy( playerOrigin, origin ); + //velocity[0] = crandom()*GIB_VELOCITY; + //velocity[1] = crandom()*GIB_VELOCITY; + //velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY; + //CG_LaunchGib( origin, velocity, cgs.media.gibArm ); + + //VectorCopy( playerOrigin, origin ); + //velocity[0] = crandom()*GIB_VELOCITY; + //velocity[1] = crandom()*GIB_VELOCITY; + //velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY; + //CG_LaunchGib( origin, velocity, cgs.media.gibChest ); + + //VectorCopy( playerOrigin, origin ); + //velocity[0] = crandom()*GIB_VELOCITY; + //velocity[1] = crandom()*GIB_VELOCITY; + //velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY; + //CG_LaunchGib( origin, velocity, cgs.media.gibFist ); + + //VectorCopy( playerOrigin, origin ); + //velocity[0] = crandom()*GIB_VELOCITY; + //velocity[1] = crandom()*GIB_VELOCITY; + //velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY; + //CG_LaunchGib( origin, velocity, cgs.media.gibFoot ); + + //VectorCopy( playerOrigin, origin ); + //velocity[0] = crandom()*GIB_VELOCITY; + //velocity[1] = crandom()*GIB_VELOCITY; + //velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY; + //CG_LaunchGib( origin, velocity, cgs.media.gibForearm ); + + //VectorCopy( playerOrigin, origin ); + //velocity[0] = crandom()*GIB_VELOCITY; + //velocity[1] = crandom()*GIB_VELOCITY; + //velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY; + //CG_LaunchGib( origin, velocity, cgs.media.gibIntestine ); + + //VectorCopy( playerOrigin, origin ); + //velocity[0] = crandom()*GIB_VELOCITY; + //velocity[1] = crandom()*GIB_VELOCITY; + //velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY; + //CG_LaunchGib( origin, velocity, cgs.media.gibLeg ); + + //VectorCopy( playerOrigin, origin ); + //velocity[0] = crandom()*GIB_VELOCITY; + //velocity[1] = crandom()*GIB_VELOCITY; + //velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY; + //CG_LaunchGib( origin, velocity, cgs.media.gibLeg ); +} + +/* +================== +CG_LaunchGib +================== +*/ +void CG_LaunchExplode( vec3_t origin, vec3_t velocity, qhandle_t hModel ) { + localEntity_t *le; + refEntity_t *re; + + le = CG_AllocLocalEntity(); + re = &le->refEntity; + + le->leType = LE_FRAGMENT; + le->startTime = cg.time; + le->endTime = le->startTime + 10000 + random() * 6000; + + VectorCopy( origin, re->origin ); + AxisCopy( axisDefault, re->axis ); + re->model = hModel; + + VectorCopy( origin, le->pos.trDelta ); + VectorCopy( velocity, le->pos.trDelta ); + le->pos.trTime = cg.time; + + le->bounceFactor = 0.1f; + + le->leBounceSoundType = LEBS_BRASS; + le->leMarkType = LEMT_NONE; +} + diff --git a/code/cgame/cg_ents.c b/code/cgame/cg_ents.c new file mode 100644 index 00000000..a54d43dd --- /dev/null +++ b/code/cgame/cg_ents.c @@ -0,0 +1,580 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_ents.c -- present snapshot entities, happens every single frame + +#include "cg_local.h" + +/* +========================================================================== + +FUNCTIONS CALLED EACH FRAME + +========================================================================== +*/ + +/* +====================== +CG_SetEntitySoundPosition + +Also called by event processing code +====================== +*/ +void CG_SetEntitySoundPosition( centity_t *cent ) { + if ( cent->currentState.solid == SOLID_BMODEL ) { + vec3_t origin; + float *v; + + v = cgs.inlineModelMidpoints[ cent->currentState.modelindex ]; + VectorAdd( cent->lerpOrigin, v, origin ); + cgi.S_UpdateEntityPosition( cent->currentState.number, origin ); + } else { + cgi.S_UpdateEntityPosition( cent->currentState.number, cent->lerpOrigin ); + } +} + +/* +================== +CG_EntityEffects + +Add continuous entity effects, like local entity emission and lighting +================== +*/ +static void CG_EntityEffects( centity_t *cent ) { + + // update sound origins + CG_SetEntitySoundPosition( cent ); + + // add loop sound + if ( cent->currentState.loopSound ) { + if (cent->currentState.eType != ET_SPEAKER) { + cgi.S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, + cgs.gameSounds[ cent->currentState.loopSound ] ); + } else { + cgi.S_AddRealLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, + cgs.gameSounds[ cent->currentState.loopSound ] ); + } + } + + + // constant light glow + if ( cent->currentState.constantLight != -1 ) { + int cl; + int i, r, g, b; + + cl = cent->currentState.constantLight; + r = cl & 255; + g = ( cl >> 8 ) & 255; + b = ( cl >> 16 ) & 255; + i = ( ( cl >> 24 ) & 255 ) * CONSTANTLIGHT_RADIUS_SCALE; + cgi.R_AddLightToScene( cent->lerpOrigin, i, r, g, b ); + } +} + + +/* +================== +CG_General +================== +*/ +static void CG_General( centity_t *cent ) { + refEntity_t ent; + entityState_t *s1; + + s1 = ¢->currentState; + + // if set to invisible, skip + if (!s1->modelindex) { + return; + } + + memset (&ent, 0, sizeof(ent)); + + VectorCopy( cent->lerpOrigin, ent.origin); + VectorCopy( cent->lerpOrigin, ent.oldorigin); + + ent.model = cgs.gameModels[ s1->modelindex ]; + + // player model + if (s1->number == cg.snap->ps.clientNum) { + ent.renderfx |= RF_THIRD_PERSON; // only draw from mirrors + } + + // convert angles to axis + AnglesToAxis( cent->lerpAngles, ent.axis ); + + // add to refresh list + cgi.R_AddRefEntityToScene (&ent); +} + +//============================================================================ + +/* +=============== +CG_Mover +=============== +*/ +static void CG_Mover( centity_t *cent ) { + refEntity_t ent; + entityState_t *s1; + + s1 = ¢->currentState; + + // create the render entity + memset (&ent, 0, sizeof(ent)); + VectorCopy( cent->lerpOrigin, ent.origin); + VectorCopy( cent->lerpOrigin, ent.oldorigin); + AnglesToAxis( cent->lerpAngles, ent.axis ); + + ent.renderfx &= ~RF_SHADOW; + + // flicker between two skins (FIXME?) + ent.skinNum = ( cg.time >> 6 ) & 1; + + // get the model, either as a bmodel or a modelindex + if ( s1->solid == SOLID_BMODEL ) { + ent.model = cgs.inlineDrawModel[ s1->modelindex ]; + } else { + ent.model = cgs.gameModels[ s1->modelindex ]; + } + + // add to refresh list + cgi.R_AddRefEntityToScene(&ent); +} + +/* +=============== +CG_Beam +=============== +*/ +#define DECODE_BEAM_PARM( x ) ( ((double)x)*0.0625 ) +void CG_Beam( centity_t *cent ) { +#if 0 + refEntity_t ent; + entityState_t *s1; + + s1 = ¢->currentState; + + // create the render entity + memset (&ent, 0, sizeof(ent)); + VectorCopy( s1->origin, ent.origin ); + VectorCopy( s1->origin2, ent.oldorigin ); + AxisClear( ent.axis ); + ent.reType = RT_BEAM; + + ent.renderfx = RF_NOSHADOW; + + // add to refresh list + cgi.R_AddRefEntityToScene(&ent); +#else + entityState_t *s1; + vec3_t vz={0,0,0},origin={0,0,0}; + byte modulate[4]; + int i; + + s1 = ¢->currentState; + + for ( i=0;i<4;i++ ) + modulate[i] = cent->color[i] * 255; + +#if 0 + memset(&modulate,0xff,4); +#endif + + if ( s1->beam_entnum != ENTITYNUM_NONE ) { + centity_t *parent; + parent = &cg_entities[s1->beam_entnum]; + VectorAdd( s1->origin, parent->lerpOrigin, origin ); + } else { + VectorCopy( s1->origin, origin ); + } + + CG_CreateBeam( origin, // start + vz, // dir ( auto calculated by using origin2-origin ) + s1->number, // owner number + cgs.gameModels[s1->modelindex], //hModel + s1->alpha, // alpha + s1->scale, // scale + s1->skinNum, // flags + 0, // length ( auto calculated ) + DECODE_BEAM_PARM( s1->surfaces[0] ) * 1000, // life + qfalse, // don't always create the beam, just update it + s1->origin2, // endpoint + s1->bone_angles[0][0], // min offset + s1->bone_angles[0][1], // max offset + DECODE_BEAM_PARM( s1->surfaces[3] ), // overlap + s1->surfaces[4], // subdivisions + DECODE_BEAM_PARM( s1->surfaces[5] ) * 1000, // delay + CG_ConfigString( CS_IMAGES + s1->tag_num ), // index for shader configstring + modulate, // modulate color + s1->surfaces[6], // num sphere beams + DECODE_BEAM_PARM( s1->surfaces[7] ), // sphere radius + DECODE_BEAM_PARM( s1->surfaces[8] ), // toggle delay + DECODE_BEAM_PARM( s1->surfaces[9] ), // end alpha + s1->renderfx, + "" + ); +#endif +} + + +/* +=============== +CG_Portal +=============== +*/ +static void CG_Portal( centity_t *cent ) { + //refEntity_t ent; + //entityState_t *s1; + + //s1 = ¢->currentState; + + //// create the render entity + //memset (&ent, 0, sizeof(ent)); + //VectorCopy( cent->lerpOrigin, ent.origin ); + //VectorCopy( s1->origin2, ent.oldorigin ); + //ByteToDir( s1->eventParm, ent.axis[0] ); + //PerpendicularVector( ent.axis[1], ent.axis[0] ); + + //// negating this tends to get the directions like they want + //// we really should have a camera roll value + //VectorSubtract( vec3_origin, ent.axis[1], ent.axis[1] ); + + //CrossProduct( ent.axis[0], ent.axis[1], ent.axis[2] ); + //ent.reType = RT_PORTALSURFACE; + //ent.oldframe = s1->powerups; + //ent.frame = s1->frame; // rotation speed + //ent.skinNum = s1->clientNum/256.0 * 360; // roll offset + + //// add to refresh list + //cgi.R_AddRefEntityToScene(&ent); +} + + +/* +========================= +CG_AdjustPositionForMover + +Also called by client movement prediction code +========================= +*/ +void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out ) { + //centity_t *cent; + //vec3_t oldOrigin, origin, deltaOrigin; + //vec3_t oldAngles, angles, deltaAngles; + + //if ( moverNum <= 0 || moverNum >= ENTITYNUM_MAX_NORMAL ) { + // VectorCopy( in, out ); + // return; + //} + + //cent = &cg_entities[ moverNum ]; + //if ( cent->currentState.eType != ET_MOVER ) { + // VectorCopy( in, out ); + // return; + //} + + //BG_EvaluateTrajectory( ¢->currentState.pos, fromTime, oldOrigin ); + //BG_EvaluateTrajectory( ¢->currentState.apos, fromTime, oldAngles ); + + //BG_EvaluateTrajectory( ¢->currentState.pos, toTime, origin ); + //BG_EvaluateTrajectory( ¢->currentState.apos, toTime, angles ); + + //VectorSubtract( origin, oldOrigin, deltaOrigin ); + //VectorSubtract( angles, oldAngles, deltaAngles ); + + //VectorAdd( in, deltaOrigin, out ); + + //// FIXME: origin change when on a rotating object +} + + +/* +============================= +CG_InterpolateEntityPosition +============================= +*/ +static void CG_InterpolateEntityPosition( centity_t *cent ) { + float *current, *next; + float f; + + // it would be an internal error to find an entity that interpolates without + // a snapshot ahead of the current one + if ( cg.nextSnap == NULL ) { + CG_Error( "CG_InterpoateEntityPosition: cg.nextSnap == NULL" ); + } + + f = cg.frameInterpolation; + + // this will linearize a sine or parabolic curve, but it is important + // to not extrapolate player positions if more recent data is available + // su44: adjusted for MOH + current = ¢->currentState.origin[0]; + next = ¢->nextState.origin[0]; + + cent->lerpOrigin[0] = current[0] + f * ( next[0] - current[0] ); + cent->lerpOrigin[1] = current[1] + f * ( next[1] - current[1] ); + cent->lerpOrigin[2] = current[2] + f * ( next[2] - current[2] ); + + current = ¢->currentState.angles[0]; + next = ¢->nextState.angles[0]; + + cent->lerpAngles[0] = LerpAngle( current[0], next[0], f ); + cent->lerpAngles[1] = LerpAngle( current[1], next[1], f ); + cent->lerpAngles[2] = LerpAngle( current[2], next[2], f ); + +} + +/* +=============== +CG_CalcEntityLerpPositions + +=============== +*/ +static void CG_CalcEntityLerpPositions( centity_t *cent ) { +#if 0 + // if this player does not want to see extrapolated players + if ( !cg_smoothClients.integer ) { + // make sure the clients use TR_INTERPOLATE + if ( cent->currentState.number < MAX_CLIENTS ) { + cent->currentState.pos.trType = TR_INTERPOLATE; + cent->nextState.pos.trType = TR_INTERPOLATE; + } + } + + if ( cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE ) { + CG_InterpolateEntityPosition( cent ); + return; + } + + // first see if we can interpolate between two snaps for + // linear extrapolated clients + if ( cent->interpolate && cent->currentState.pos.trType == TR_LINEAR_STOP && + cent->currentState.number < MAX_CLIENTS) { + CG_InterpolateEntityPosition( cent ); + return; + } + + // just use the current frame and evaluate as best we can + BG_EvaluateTrajectory( ¢->currentState.pos, cg.time, cent->lerpOrigin ); + BG_EvaluateTrajectory( ¢->currentState.apos, cg.time, cent->lerpAngles ); +#else + if(cg.nextSnap) { + CG_InterpolateEntityPosition( cent ); + } else { + VectorCopy(cent->currentState.origin,cent->lerpOrigin ); + VectorCopy(cent->currentState.angles,cent->lerpAngles ); + } + +#endif + // adjust for riding a mover if it wasn't rolled into the predicted + // player state + //if ( cent != &cg.predictedPlayerEntity ) { + // CG_AdjustPositionForMover( cent->lerpOrigin, cent->currentState.groundEntityNum, + // cg.snap->serverTime, cg.time, cent->lerpOrigin ); + //} +} + +// su44: prints all unknown eFlags +// NOTE: it seems that flag 4 has something to do with player weapons, +// try holstering/unholstering player weapon and watch changes +// NOTE2: flags 64 is present on vehicles/opeltruck.tik, +// vehicles/tigertank.tik (both body model and its cannon), +// vehicles/panzer_tank.tik, vehicles/tigertank.tik +// All of those modes have animated tank-wheels shader... +static void CG_ShowEntUnknownEFlags(centity_t *cent) { + int f = cent->currentState.eFlags; + f &= ~EF_ALLIES; + f &= ~EF_AXIS; + f &= ~EF_DEAD; + f &= ~EF_UNARMED; + + if(f) { + CG_Printf("Timenow %i, ent %i ef %i\n",cg.time, cent->currentState.number,f); + } +} +// renderFX 16 - thompsonsmg.tik, bar.tik, etc, tigertank.tik +// su44: From gamex86.dll rendereffects event +// invisible - 33554432 - +// preciseshadow - 16777216 +// shadow - 2048 - 2^11 - matches FAKK +// lightstyledynamiclight - 8388608 +// additivedynamiclight - ?????????????? +// fullbright - no longer supported +// skyorigin - 8192 +// lightoffset - no longer supported +// viewlensflare - 8 +// lensflare - 256 +// dontdraw - 128 + +static void CG_ShowEntUnknownRenderFX(centity_t *cent) { + int f = cent->currentState.renderfx; + if( f & RF_DEPTHHACK ) { + f &= ~RF_DEPTHHACK; + } + if( f & RF_SHADOW ) { + f &= ~RF_SHADOW; + } + if( f & RF_FULLBRIGHT ) { + f &= ~RF_FULLBRIGHT; + } + if( f & RF_VIEWLENSFLARE ) { + f &= ~RF_VIEWLENSFLARE; + } + if( f & RF_PRECISESHADOW ) { + f &= ~RF_PRECISESHADOW; + } + if( f & RF_LIGHTSTYLE_DLIGHT ) { + f &= ~RF_LIGHTSTYLE_DLIGHT; + } + if(f) { + CG_Printf("Timenow %i, ent %i renderFX %i\n",cg.time, cent->currentState.number,f); + } +} +/* +=============== +CG_AddCEntity + +=============== +*/ +static void CG_AddCEntity( centity_t *cent ) { + // event-only entities will have been dealt with already + if ( cent->currentState.eType >= ET_EVENTS ) { + return; + } + + // calculate the current origin + CG_CalcEntityLerpPositions( cent ); + + switch ( cent->currentState.eType ) { + case 0: break; // 0 spams console with bad entity type + default: + //su44: changed to printf, so I can debug our gamex code without getting Com_Error + //CG_Error( "Bad entity type: %i\n", cent->currentState.eType ); + CG_Printf( "Bad entity type: %i\n", cent->currentState.eType ); + break; +case ET_MOVER: // su44: ET_MOVER is used only if running a local openmohaa server. + // this needs to be fixed soon in our game code + case ET_GENERAL: + CG_ModelAnim( cent ); + //CG_General( cent ); + break; + case ET_PLAYER: + case ET_VEHICLE: + case ET_ITEM: + case ET_MODELANIM: + CG_ModelAnim( cent ); + //CG_ShowEntUnknownEFlags(cent); + //CG_ShowEntUnknownRenderFX(cent); + + if( cent->currentState.number < cgs.maxclients ) { + + // su44: save player team to clientInfo_t + CG_ExtractPlayerTeam( cent ); + // su44: draw axis/allies icon over player head. + // Function below must be called after CG_ModelAnim, + // because it might need to use centity_t::bones. + CG_PlayerSprites( cent ); + } + break; + case ET_RAIN: // su44: ET_RAIN is used on dm/mohdm5 for snow effect + CG_Rain( cent ); + break; + // su44: beams are used on some servers with custom scripts + case ET_BEAM: + CG_Beam( cent ); + break; + case ET_ROPE: + CG_Rope( cent ); + break; + case ET_MULTIBEAM: + CG_MultiBeam( cent ); + break; + } + + // add automatic effects + CG_EntityEffects( cent ); +} + +/* +=============== +CG_AddPacketEntities + +=============== +*/ +void CG_AddPacketEntities( void ) { + int num; + centity_t *cent; + playerState_t *ps; + + // set cg.frameInterpolation + if ( cg.nextSnap ) { + int delta; + + delta = (cg.nextSnap->serverTime - cg.snap->serverTime); + if ( delta == 0 ) { + cg.frameInterpolation = 0; + } else { + cg.frameInterpolation = (float)( cg.time - cg.snap->serverTime ) / delta; + } + } else { + cg.frameInterpolation = 0; // actually, it should never be used, because + // no entities should be marked as interpolating + } + + // the auto-rotating items will all have the same axis + cg.autoAngles[0] = 0; + cg.autoAngles[1] = ( cg.time & 2047 ) * 360 / 2048.0; + cg.autoAngles[2] = 0; + + cg.autoAnglesFast[0] = 0; + cg.autoAnglesFast[1] = ( cg.time & 1023 ) * 360 / 1024.0f; + cg.autoAnglesFast[2] = 0; + + AnglesToAxis( cg.autoAngles, cg.autoAxis ); + AnglesToAxis( cg.autoAnglesFast, cg.autoAxisFast ); + +#if 1 // su44: that's not done here in MoHAA (?) + // generate and add the entity from the playerstate + ps = &cg.predictedPlayerState; + BG_PlayerStateToEntityState( ps, &cg.predictedPlayerEntity.currentState, qfalse ); + CG_AddCEntity( &cg.predictedPlayerEntity ); +#else + ps = &cg.predictedPlayerState; + BG_PlayerStateToEntityState( ps, &cg.predictedPlayerEntity.currentState, qfalse ); + if(cg_entities[ ps->clientNum ].currentValid==qtrue) { + cg_entities[ ps->clientNum ].currentState.groundEntityNum = ps->groundEntityNum; + } else { + //CG_AddCEntity( &cg.predictedPlayerEntity ); + } +#endif + // lerp the non-predicted value for lightning gun origins + CG_CalcEntityLerpPositions( &cg_entities[ cg.snap->ps.clientNum ] ); + + // add each entity sent over by the server + for ( num = 0 ; num < cg.snap->numEntities ; num++ ) + { + cent = &cg_entities[ cg.snap->entities[ num ].number ]; + CG_AddCEntity( cent ); + } +} + diff --git a/code/cgame/cg_eventSystem.c b/code/cgame/cg_eventSystem.c new file mode 100644 index 00000000..93522ea2 --- /dev/null +++ b/code/cgame/cg_eventSystem.c @@ -0,0 +1,613 @@ +/* +=========================================================================== +Copyright (C) 2011 su44 + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// cg_eventSystem.c + +#include "cg_local.h" +#include "../qcommon/tiki_local.h" + +typedef struct event_s { + centity_t *ent; + char buffer[1024]; + int execTime; // event should be executed and fried if cg.time >= ev->execTime + struct event_s *next,*prev; // linked list +} event_t; + +#define MAX_PENDING_EVENTS 512 + +static event_t events[MAX_PENDING_EVENTS]; +static event_t cg_pendingEvents; // double linked list +static event_t *cg_freeEvents; // single linked list + +void CG_InitEventSystem() { + int i; + + memset( events, 0, sizeof( events ) ); + cg_pendingEvents.next = &cg_pendingEvents; + cg_pendingEvents.prev = &cg_pendingEvents; + cg_freeEvents = events; + for ( i = 0 ; i < MAX_PENDING_EVENTS - 1 ; i++ ) { + events[i].next = &events[i+1]; + } +} +/* +Generates a random float component for MoHAA events. +If random is specified, the component will range from 0 to specified value. +If crandom is specified, the component will range from -specified to +specified value. +If range is specified, the component needs two values; it will randomly pick a number in the range +from the first number to the first number plus the second number. +This is used by "randvel", "randvelaxis", "offset", "offsetalongaxis", "angles", MoHAA events +*/ +float CG_ParseEventFloatParm(char **text) { + char *token; + float value; + token = COM_ParseExt( text, qfalse ); + if(!Q_stricmp(token,"random")) { + token = COM_ParseExt( text, qfalse ); + value = random()*atof(token); + } else if(!Q_stricmp(token,"crandom")) { + token = COM_ParseExt( text, qfalse ); + value = crandom()*atof(token); + } else if(!Q_stricmp(token,"range")) { + float range; + token = COM_ParseExt( text, qfalse ); + value = atof(token); + + token = COM_ParseExt( text, qfalse ); + range = atof(token); + + value += random()*range; + } else { +#if 0 + CG_Printf("CG_ParseEventFloatParm: unknown first parm, expected 'random', 'crandom' or 'range', found %s\n",token); + value = 0; +#else + value = atof(token); +#endif + } + return value; +} +// this is used by both "tagspawn" and "originspawn" events +void CG_ProcessSpawnEvent(centity_t *ent, vec3_t spawnOrigin, vec3_t spawnAngles, char *text) { + char *token; + qhandle_t h; + tiki_t *tiki; + vec3_t v; + localEntity_t *le; + char *dot; + + // skip optional paramter(s) ? see rechamber anim of weapons/kar98.tik + do { + token = COM_ParseExt( &text, qtrue ); + if(token[0]==0) { + CG_Printf("'***spawn' event without parameters block\n"); + return; + } + } while(token[0] != '('); + if(token[1] == 0) { + token = COM_ParseExt( &text, qtrue ); + } else { + token++; + } + + le = CG_AllocLocalEntity(); + le->endTime = cg.time + 10000; + le->leType = LE_SKIP; + //le->leFlags = LEF_TUMBLE; + le->pos.trTime = cg.time - (rand()&15); + VectorCopy( spawnOrigin, le->pos.trDelta ); + VectorCopy(spawnOrigin,le->refEntity.origin); + VectorCopy( spawnAngles, le->angles.trDelta ); + AnglesToAxis(spawnAngles,le->refEntity.axis); + tiki = le->tiki; + // parse parameters ( ... ) block + while(token[0] != ')') { + if(token[0]==0) { + CG_Printf("'***spawn' missing ')' in tiki %s\n",tiki->name); + return; + } + Q_strlwr(token); + if(!strcmp(token,"spawnrange")) { + token = COM_ParseExt( &text, qtrue ); + + } else if(!strcmp(token,"spawnrate")) { + token = COM_ParseExt( &text, qtrue ); + + } else if(!strcmp(token,"count")) { + token = COM_ParseExt( &text, qtrue ); + + } else if(!strcmp(token,"model")) { + // both .tik and .spr models are used here + token = COM_ParseExt( &text, qtrue ); + h = cgi.R_RegisterModel(token); + le->refEntity.model = h; + le->leType = LE_FRAGMENT; + dot = strchr(token,'.'); + if(dot && !Q_stricmp(dot+1,"tik")) { + le->tiki = cgi.TIKI_RegisterModel(token); + } + } else if(!strcmp(token,"color")) { + token = COM_ParseExt( &text, qfalse ); + token = COM_ParseExt( &text, qfalse ); + token = COM_ParseExt( &text, qfalse ); + + } else if(!strcmp(token,"varycolor")) { + token = COM_ParseExt( &text, qfalse ); + + } else if(!strcmp(token,"alpha")) { + token = COM_ParseExt( &text, qfalse ); + + } else if(!strcmp(token,"offset")) { + token = COM_ParseExt( &text, qfalse ); // x + token = COM_ParseExt( &text, qfalse ); // y + token = COM_ParseExt( &text, qfalse ); // z + + } else if(!strcmp(token,"offsetalongaxis")) { + v[0] = CG_ParseEventFloatParm(&text); // x + v[1] = CG_ParseEventFloatParm(&text); // y + v[2] = CG_ParseEventFloatParm(&text); // z + + } else if(!strcmp(token,"randvelaxis")) { + v[0] = CG_ParseEventFloatParm(&text); // x + v[1] = CG_ParseEventFloatParm(&text); // y + v[2] = CG_ParseEventFloatParm(&text); // z + + } else if(!strcmp(token,"scale")) { + token = COM_ParseExt( &text, qtrue ); + + } else if(!strcmp(token,"scalemin")) { + token = COM_ParseExt( &text, qtrue ); + + } else if(!strcmp(token,"scalemax")) { + token = COM_ParseExt( &text, qtrue ); + + } else if(!strcmp(token,"scalerate")) { + token = COM_ParseExt( &text, qtrue ); + + } else if(!strcmp(token,"velocity")) { + token = COM_ParseExt( &text, qtrue ); // forwardVelocity + + } else if(!strcmp(token,"angles")) { + v[0] = CG_ParseEventFloatParm(&text); + v[1] = CG_ParseEventFloatParm(&text); + v[2] = CG_ParseEventFloatParm(&text); + VectorCopy( v, le->angles.trDelta ); + AnglesToAxis(v,le->refEntity.axis); + + } else if(!strcmp(token,"randvel")) { + v[0] = CG_ParseEventFloatParm(&text); + v[1] = CG_ParseEventFloatParm(&text); + v[2] = CG_ParseEventFloatParm(&text); + VectorCopy(v,le->pos.trDelta); + } else if(!strcmp(token,"emitterangles")) { + token = COM_ParseExt( &text, qfalse ); // pitchofs + token = COM_ParseExt( &text, qfalse ); // yawofs + token = COM_ParseExt( &text, qfalse ); // rollofs + } else if(!strcmp(token,"avelocity")) { + // crandom keyword is used for avelocity in weapons/mp40.tik + v[YAW] = CG_ParseEventFloatParm(&text); // yawVel + v[PITCH] = CG_ParseEventFloatParm(&text); // pitchVel + v[ROLL] = CG_ParseEventFloatParm(&text); // rollVel + + //VectorCopy(v,le->apos.trDelta); + + } else if(!strcmp(token,"accel")) { + // NOTE: This acceleration is applied using the world axis + token = COM_ParseExt( &text, qfalse ); // accelX + token = COM_ParseExt( &text, qfalse ); // accelY + token = COM_ParseExt( &text, qfalse ); // accelZ + + } else if(!strcmp(token,"physicsrate")) { + token = COM_ParseExt( &text, qtrue ); + if(!Q_stricmp(token,"every")) { + + } + } else if(!strcmp(token,"life")) { + token = COM_ParseExt( &text, qtrue ); + le->endTime = cg.time + atof(token)*1000; + } else if(!strcmp(token,"fadedelay")) { + token = COM_ParseExt( &text, qtrue ); + + } else if(!strcmp(token,"alignstretch")) { + token = COM_ParseExt( &text, qfalse ); // scaleMultiplier + + } else if(!strcmp(token,"alignonce")) { + + } else if(!strcmp(token,"align")) { + + } else if(!strcmp(token,"collision")) { + + } else if(!strcmp(token,"fade")) { + + } else if(!strcmp(token,"randomroll")) { + + } else if(!strcmp(token,"spritegridlighting")) { + + } else if(!strcmp(token,"volumetric")) { + // set the effect to spawn volumetric sources rather than tempmodels + + } else if(!strcmp(token,"wateronly")) { + // makes the temp model remove itself if it leaves water + + } else if(!strcmp(token,"wind")) { + // makes the temp model be affected by wind + + } else if(!strcmp(token,"bouncefactor")) { + token = COM_ParseExt( &text, qtrue ); + le->bounceFactor = atof(token); + } else if(!strcmp(token,"bouncesoundonce")) { + token = COM_ParseExt( &text, qtrue ); + + + } else if(!strcmp(token,"friction")) { + token = COM_ParseExt( &text, qtrue ); + + } else { + //CG_Printf("Uknown '***spawn' parameter %s\n",token); + } + COM_ParseExt( &text, qtrue ); + } + + + +} + +void CG_ProcessEventText(centity_t *ent, const char *eventText) { + char str[128]; + char *text; + char *token; + float f; + int i; + int boneName; + tiki_t *tiki; + vec3_t v,a; + + + text = (char*)eventText; +again: + // if(cg_printEvents.integer) + // CG_Printf("CG_ProcessEventText: event %s\n",eventText); + + // get event name + token = COM_ParseExt( &text, qtrue ); + Q_strlwr(token); + if(!strcmp(token,"sound")) { + // syntax: sound( String soundName, + // [ String channelName ], [ Float volume ], + // [ Float min_distance ], [ Float pitch ], + // [ Float randompitch ], [ String randomvolume ] ) + char *name; + //float volume, minDist, pitch, randompitch; + soundChannel_t channel; + ubersound_t* sound; + name = COM_ParseExt( &text, qtrue ); + sound = CG_GetUbersound(name); + + if (!sound) + return; + token = COM_ParseExt( &text, qtrue ); + + if ( token[0] ) { + if ( !Q_strncmp( token, "auto", MAX_QPATH ) ) + channel = CHAN_AUTO; + else if ( !Q_strncmp( token, "body", MAX_QPATH ) ) + channel = CHAN_BODY; + else if ( !Q_strncmp( token, "item", MAX_QPATH ) ) + channel = CHAN_ITEM; + else if ( !Q_strncmp( token, "weaponidle", MAX_QPATH ) ) + channel = CHAN_WEAPONIDLE; + else if ( !Q_strncmp( token, "voice", MAX_QPATH ) ) + channel = CHAN_VOICE; + else if ( !Q_strncmp( token, "local", MAX_QPATH ) ) + channel = CHAN_LOCAL; + else if ( !Q_strncmp( token, "weapon", MAX_QPATH ) ) + channel = CHAN_WEAPON; + else if ( !Q_strncmp( token, "dialog_secondary", MAX_QPATH ) ) + channel = CHAN_DIALOG_SECONDARY; + else if ( !Q_strncmp( token, "dialog", MAX_QPATH ) ) + channel = CHAN_DIALOG; + else if ( !Q_strncmp( token, "menu", MAX_QPATH ) ) + channel = CHAN_MENU; + else { + //CG_Printf( "Event sound unrecognized channel %s for %s\n", token, name ); + channel = sound->channel; + } + //token = COM_ParseExt( &text, qtrue ); + } else channel = sound->channel; + +/* if ( token[0] ) { + volume = atof( token ); + token = COM_ParseExt( &text, qtrue ); + } + minDist = atof( COM_ParseExt( &text, qtrue ) ); + pitch = atof( COM_ParseExt( &text, qtrue ) ); + randompitch = atof( COM_ParseExt( &text, qtrue ) ); + randomvolume = COM_ParseExt( &text, qtrue );*/ +#if 0 + cgi.S_StartSound( ent->currentState.origin, -1, channel, sound->sfxHandle ); +#else + cgi.S_StartSound( 0, ent->currentState.number, channel, sound->sfxHandle ); +#endif + } else if(!strcmp(token,"stopsound")) { + // syntax: stopsound( String channelName ) + // TODO + } else if(!strcmp(token,"loopsound")) { + // syntax: loopsound( String soundName, [ Float volume ], + // [ Float min_distance ], Float pitch ) + char *name; + //float volume, minDist, pitch; + ubersound_t* snd; + name = COM_ParseExt( &text, qtrue ); + snd = CG_GetUbersound(name); +/* volume = atof( COM_ParseExt( &text, qtrue ) ); + minDist = atof( COM_ParseExt( &text, qtrue ) ); + pitch = atof( COM_ParseExt( &text, qtrue ) ); +*/ + if (snd) + cgi.S_AddLoopingSound( ent->currentState.number, ent->currentState.origin, vec3_origin, snd->sfxHandle ); + } else if(!strcmp(token,"stoploopsound")) { + cgi.S_StopLoopingSound( ent->currentState.number ); + } else if(!strcmp(token,"stopaliaschannel")) { + token = COM_ParseExt( &text, qtrue ); + } else if(!strcmp(token,"viewkick")) { + // viewkick( Float pitchmin, Float pitchmax, + // Float yawmin, Float yawmax, Float recenterspeed, + // String patters, Float pitchmax, Float yawmax ) + // TODO + } else if(!strcmp(token,"cache")) { + token = COM_ParseExt( &text, qtrue ); + //CG_Printf("Caching %s...\n",token); + cgi.R_RegisterModel(token); + } else if(!strcmp(token,"commanddelay")) { + token = COM_ParseExt( &text, qtrue ); + f = atof(token); + CG_PostEvent(ent,text,f*1000); + } else if(!strcmp(token,"originspawn")) { + CG_ProcessSpawnEvent(ent,ent->lerpOrigin, ent->lerpAngles, text); + } else if(!strcmp(token,"tagspawn")) { + tiki = cgs.gameTIKIs[ent->currentState.modelindex]; + if(!tiki) { + CG_Printf("'tagspawn' event cast on entity with null TIKI\n"); + return; + } + // parse tagname + token = COM_ParseExt( &text, qtrue ); + // find tag in tiki + boneName = cgi.TIKI_GetBoneNameIndex(token); + for(i = 0; i < tiki->numBones; i++) { + if(tiki->boneNames[i] == boneName) { + break; + } + } + if(i == tiki->numBones) { + CG_Printf("Cant find bone %s in tiki %s for 'tagspawn' event\n",token,tiki->name); + return; + } + if(ent->bones == 0) { + CG_Printf("'tagspawn' event cast on entity with null bones ptr\n"); + return; + } + CG_CentBoneIndexLocal2World(i,ent,v,a); + CG_ProcessSpawnEvent(ent,v,a,text); + } else if(!strcmp(token,"tagspawnlinked")) { + return; // FIXME! + } else if(!strcmp(token,"tagdlight")) { + float r,g,b,intensity; + // tagdlight( String tagName, Float red, Float green, + // Float blue, Float intensity, Float life, + // [ String intvel ], [ String type1 ] ) + /* + Spawn a dynamic light from the specified tag + The red,green,blue parms are the color of the light + The intensity is the radius of the light + type is the type of light to create (lensflare,viewlensflare,additive) + */ + tiki = cgs.gameTIKIs[ent->currentState.modelindex]; + if(!tiki) { + CG_Printf("'tagdlight' event cast on entity with null TIKI\n"); + return; + } + // parse tagname + token = COM_ParseExt( &text, qtrue ); + // find tag in tiki + boneName = cgi.TIKI_GetBoneNameIndex(token); + for(i = 0; i < tiki->numBones; i++) { + if(tiki->boneNames[i] == boneName) { + break; + } + } + if(i == tiki->numBones) { + CG_Printf("Cant find bone %s in tiki %s for 'tagdlight' event\n",token,tiki->name); + return; + } + if(ent->bones == 0) { + CG_Printf("'tagdlight' event cast on entity with null bones ptr\n"); + return; + } + token = COM_ParseExt( &text, qtrue ); + r = atof(token); + token = COM_ParseExt( &text, qtrue ); + g = atof(token); + token = COM_ParseExt( &text, qtrue ); + b = atof(token); + token = COM_ParseExt( &text, qtrue ); + intensity = atof(token); + // optional parameters + token = COM_ParseExt( &text, qtrue ); + if(token[0]) { + // TODO + token = COM_ParseExt( &text, qtrue ); + if(token[0]) { + if(!Q_stricmp(token,"addictive")) { + + } else if(!Q_stricmp(token,"lensflare")) { + + } else if(!Q_stricmp(token,"viewlensflare")) { + + } + } + } + CG_CentBoneIndexLocal2World(i,ent,v,0); + cgi.R_AddLightToScene(v,intensity,r,g,b); + } else if(!strcmp(token,"sfx")) { + goto again; + + } else if(!strcmp(token,"bodyfall")) { + + } else if(!strcmp(token,"footstep")) { + int iRunning; + int iEquipment; + //footstep( String tag, String sRunning, [ Integer iEquipment ] ) + // plays a footstep sound that is appropriate to the surface + // we are currently stepping on. + // sRunning should be set to run, walk, or ladder + tiki = cgs.gameTIKIs[ent->currentState.modelindex]; + if(!tiki) { + CG_Printf("'footstep' event cast on entity with null TIKI\n"); + return; + } + // parse tagname + token = COM_ParseExt( &text, qfalse ); + strcpy(str,token); + /* + // find tag in tiki + boneName = cgi.TIKI_GetBoneNameIndex(token); + for(i = 0; i < tiki->numBones; i++) { + if(tiki->boneNames[i] == boneName) { + break; + } + } + if(i == tiki->numBones) { + CG_Printf("Cant find bone %s in tiki %s for 'footstep' event\n",token,tiki->name); + return; + } + if(ent->bones == 0) { + CG_Printf("'footstep' event cast on entity with null bones ptr\n"); + return; + } + */ + // sRunning + token = COM_ParseExt( &text, qfalse ); + if(!Q_stricmp(token,"run")) { + //iRunning = ??; + } else if(!Q_stricmp(token,"walk")) { + //iRunning = ??; + } else if(!Q_stricmp(token,"ladder")) { + //iRunning = ??; + } else if(!Q_stricmp(token,"R")) { + //iRunning = ??; + } else if(!Q_stricmp(token,"L")) { + //iRunning = ??; + } else { + //iRunning = ??; + CG_Printf("'footstep' event: unknown sRunning type %s\n",token); + } + // Integer iEquipment + token = COM_ParseExt( &text, qfalse ); + iEquipment = 0; + if(token[0]) { + iEquipment = atoi(token); + } + + iRunning = 0; + CG_Footstep(str,ent,/*0,*/iRunning,iEquipment); + + } else if(!strcmp(token,"emitteroff")) { + + } else if(!strcmp(token,"emitteron")) { + + } else { + CG_Printf("CG_ProcessEventText: unknown event %s\n",token); + } + + + +} + +void CG_FreeEvent(event_t *ev) { + if ( !ev->prev ) { + CG_Error( "CG_FreeEvent: not active" ); + } + + // remove from the doubly linked active list + ev->prev->next = ev->next; + ev->next->prev = ev->prev; + + // the free list is only singly linked + ev->next = cg_freeEvents; + cg_freeEvents = ev; +} +event_t *CG_AllocEvent() { + event_t *ev; + + if ( !cg_freeEvents ) { + CG_Printf("CG_AllocEvent: no free events\n"); + return 0; + } + + ev = cg_freeEvents; + cg_freeEvents = cg_freeEvents->next; + + memset( ev, 0, sizeof( *ev ) ); + + // link into the active list + ev->next = cg_pendingEvents.next; + ev->prev = &cg_pendingEvents; + cg_pendingEvents.next->prev = ev; + cg_pendingEvents.next = ev; + return ev; +} + +void CG_PostEvent(centity_t *ent, const char *eventText, int eventDelay) { + event_t *ev; + ev = CG_AllocEvent(); + if(!ev) + return; // failed to alloc an event + ev->ent = ent; + strcpy(ev->buffer,eventText); + ev->execTime = cg.time + eventDelay; +} + +void CG_ProcessEvent(event_t *ev) { + CG_ProcessEventText(ev->ent,ev->buffer); + CG_FreeEvent(ev); +} + +void CG_ProcessPendingEvents() { + event_t *ev, *next; + ev = cg_pendingEvents.next; + for ( ; ev != &cg_pendingEvents ; ev = next ) { + // grab next now, so if the event is freed we + // still have it + next = ev->next; + if ( cg.time >= ev->execTime ) { + // execute it + CG_ProcessEventText(ev->ent, ev->buffer); + // and free + CG_FreeEvent(ev); + continue; + } + } + +} + + + diff --git a/code/cgame/cg_info.c b/code/cgame/cg_info.c new file mode 100644 index 00000000..d8f42641 --- /dev/null +++ b/code/cgame/cg_info.c @@ -0,0 +1,55 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_info.c -- display information while data is being loading + +#include "cg_local.h" + +/* +====================== +CG_LoadingString + +====================== +*/ +void CG_LoadingString( const char *s ) { + char buffer[16]; + + Q_strncpyz( cg.infoScreenText, s, sizeof( cg.infoScreenText ) ); + Q_snprintf( buffer, sizeof(buffer), "%f", (float)cgs.loadingStage/6 ); + cgi.Cvar_Set( "loadingbar", buffer ); + + cgs.loadingStage++; + cgi.UpdateScreen(); +} + +/* +==================== +CG_DrawInformation + +Draw all the status / pacifier stuff during level loading +==================== +*/ +void CG_DrawInformation( void ) { + + +} + diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h new file mode 100644 index 00000000..e3d2641f --- /dev/null +++ b/code/cgame/cg_local.h @@ -0,0 +1,985 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +#include "../qcommon/q_shared.h" +#include "../renderercommon/tr_types.h" +#include "../game/bg_public.h" +#include "../qcommon/tiki_local.h" +#include "cg_public.h" + + +// The entire cgame module is unloaded and reloaded on each level change, +// so there is NO persistant data between levels on the client side. +// If you absolutely need something stored, it can either be kept +// by the server in the server stored userinfos, or stashed in a cvar. + +#define FADE_TIME 200 +#define PULSE_TIME 200 +#define DAMAGE_DEFLECT_TIME 100 +#define DAMAGE_RETURN_TIME 400 +#define DAMAGE_TIME 500 +#define LAND_DEFLECT_TIME 150 +#define LAND_RETURN_TIME 300 +#define STEP_TIME 200 +#define DUCK_TIME 100 +#define PAIN_TWITCH_TIME 200 +#define WEAPON_SELECT_TIME 1400 +#define ZOOM_TIME 150 +#define ITEM_BLOB_TIME 200 +#define MUZZLE_FLASH_TIME 20 +#define SINK_TIME 1000 // time for fragments to sink into ground before going away +#define ATTACKER_HEAD_TIME 10000 + +#define MAX_STEP_CHANGE 32 + +#define MAX_VERTS_ON_POLY 10 +#define MAX_MARK_POLYS 256 + +#define STAT_MINUS 10 // num frame for '-' stats digit + +#define CHAR_WIDTH 32 +#define CHAR_HEIGHT 48 +#define TEXT_ICON_SPACE 4 + +#define TEAMCHAT_WIDTH 80 +#define TEAMCHAT_HEIGHT 8 + +// very large characters +#define GIANT_WIDTH 32 +#define GIANT_HEIGHT 48 + +#define NUM_CROSSHAIRS 3 + +#define TEAM_OVERLAY_MAXNAME_WIDTH 12 +#define TEAM_OVERLAY_MAXLOCATION_WIDTH 16 + +#define DEFAULT_MODEL "american_army" + +//================================================= + +typedef enum { + SMT_NONE, + SMT_YELLOW, // below compass, color yellow + SMT_CHAT, // right of compass, color grey + SMT_WHITE, // below compass, color white + SMT_DEATH, // right of compass, color red + SMT_UNKNOWN, // don't know if exists. observe with breakpoint + SMT_MAX +} serverMessageType_t; + +//================================================= + +// centity_t have a direct corespondence with gentity_t in the game, but +// only the entityState_t is directly communicated to the cgame +typedef struct centity_s { + entityState_t currentState; // from cg.frame + entityState_t nextState; // from cg.nextFrame, if available + qboolean interpolate; // true if next is valid to interpolate to + qboolean currentValid; // true if cg.frame holds this entity + + int snapShotTime; // last time this entity was found in a snapshot + + int errorTime; // decay the error from this time + vec3_t errorOrigin; + vec3_t errorAngles; + + qboolean extrapolated; // false if origin / angles is an interpolation + vec3_t rawOrigin; + vec3_t rawAngles; + + vec3_t beamEnd; + + // exact interpolated position of entity on this frame + vec3_t lerpOrigin; + vec3_t lerpAngles; + + bone_t *bones; // su44: for tiki models + + vec4_t color; + + int bFootOnGround_Right; + int bFootOnGround_Left; +} centity_t; + + +//====================================================================== + +// local entities are created as a result of events or predicted actions, +// and live independantly from all server transmitted entities + +typedef struct markPoly_s { + struct markPoly_s *prevMark, *nextMark; + int time; + qhandle_t markShader; + qboolean alphaFade; // fade alpha instead of rgb + float color[4]; + poly_t poly; + polyVert_t verts[MAX_VERTS_ON_POLY]; +} markPoly_t; + + +typedef enum { + LE_SKIP, + LE_MARK, + LE_EXPLOSION, + LE_SPRITE_EXPLOSION, + LE_FRAGMENT, + LE_MOVE_SCALE_FADE, + LE_FALL_SCALE_FADE, + LE_FADE_RGB, + LE_SCALE_FADE, + LE_SCOREPLUM, +#ifdef MISSIONPACK + LE_KAMIKAZE, + LE_INVULIMPACT, + LE_INVULJUICED, + LE_SHOWREFENTITY +#endif +} leType_t; + +typedef enum { + LEF_PUFF_DONT_SCALE = 0x0001, // do not scale size over time + LEF_TUMBLE = 0x0002, // tumble over time, used for ejecting shells + LEF_SOUND1 = 0x0004, // sound 1 for kamikaze + LEF_SOUND2 = 0x0008 // sound 2 for kamikaze +} leFlag_t; + +typedef enum { + LEMT_NONE, + LEMT_BURN, + LEMT_BLOOD +} leMarkType_t; // fragment local entities can leave marks on walls + +typedef enum { + LEBS_NONE, + LEBS_BLOOD, + LEBS_BRASS +} leBounceSoundType_t; // fragment local entities can make sounds on impacts + +typedef struct localEntity_s { + struct localEntity_s *prev, *next; + leType_t leType; + int leFlags; + + int startTime; + int endTime; + int fadeInTime; + + float lifeRate; // 1.0 / (endTime - startTime) + + trajectory_t pos; + trajectory_t angles; + + float bounceFactor; // 0.0 = no bounce, 1.0 = perfect + + float color[4]; + + float radius; + + float light; + vec3_t lightColor; + + leMarkType_t leMarkType; // mark to leave on fragment impact + leBounceSoundType_t leBounceSoundType; + + refEntity_t refEntity; + + tiki_t *tiki; +} localEntity_t; + +//====================================================================== + +typedef struct { + int team; + char name[64]; +} clientInfo_t; + +// su44: MoHAA rain/snow effect +typedef struct { + float density; + float speed; + int speed_vary; + int slant; + float length; + float min_dist; + float width; + char shader[16][2048]; + int numshaders; +} crain_t; + +#define MAX_REWARDSTACK 10 +#define MAX_SOUNDBUFFER 20 + +//====================================================================== + +// all cg.stepTime, cg.duckTime, cg.landTime, etc are set to cg.time when the action +// occurs, and they will have visible effects for #define STEP_TIME or whatever msec after + +typedef struct { + int clientFrame; // incremented each frame + + int clientNum; + + qboolean demoPlayback; + qboolean levelShot; // taking a level menu screenshot + + // there are only one or two snapshot_t that are relevent at a time + int latestSnapshotNum; // the number of snapshots the client system has received + int latestSnapshotTime; // the time from latestSnapshotNum, so we don't need to read the snapshot yet + + snapshot_t *snap; // cg.snap->serverTime <= cg.time + snapshot_t *nextSnap; // cg.nextSnap->serverTime > cg.time, or NULL + snapshot_t activeSnapshots[2]; + + float frameInterpolation; // (float)( cg.time - cg.frame->serverTime ) / (cg.nextFrame->serverTime - cg.frame->serverTime) + + qboolean thisFrameTeleport; + qboolean nextFrameTeleport; + + int frametime; // cg.time - cg.oldTime + + int time; // this is the time value that the client + // is rendering at. + int oldTime; // time at last frame, used for missile trails and prediction checking + + int physicsTime; // either cg.snap->time or cg.nextSnap->time + + int timelimitWarnings; // 5 min, 1 min, overtime + int fraglimitWarnings; + + qboolean mapRestart; // set on a map restart to set back the weapon + + qboolean renderingThirdPerson; // during deaths, chasecams, etc + + // prediction state + qboolean hyperspace; // true if prediction has hit a trigger_teleport + playerState_t predictedPlayerState; + centity_t predictedPlayerEntity; + qboolean validPPS; // clear until the first call to CG_PredictPlayerState + int predictedErrorTime; + vec3_t predictedError; + + float stepChange; // for stair up smoothing + int stepTime; + + float duckChange; // for duck viewheight smoothing + int duckTime; + + float landChange; // for landing hard + int landTime; + + // auto rotating items + vec3_t autoAngles; + vec3_t autoAxis[3]; + vec3_t autoAnglesFast; + vec3_t autoAxisFast[3]; + + // view rendering + refdef_t refdef; + vec3_t refdefViewAngles; // will be converted to refdef.viewaxis + + // zoom key + qboolean zoomed; + int zoomTime; + float zoomSensitivity; + + // information screen text during loading + char infoScreenText[MAX_STRING_CHARS]; + + // scoreboard + char aScore[MAX_STRING_CHARS]; + int scoresRequestTime; + int numScores; + int selectedScore; + int teamScores[2]; + qboolean showScores; + qboolean scoreBoardShowing; + int scoreFadeTime; + char killerName[MAX_NAME_LENGTH]; + + // centerprinting + int centerPrintTime; + int centerPrintCharWidth; + int centerPrintY; + char centerPrint[1024]; + int centerPrintLines; + + // locationprinting + int locationPrintTime; + int locationPrintCharWidth; + int locationPrintX; + int locationPrintY; + char locationPrint[1024]; + int locationPrintLines; + + // Game Messages +#define MAX_GAMEMESSAGES 4 +#define MAX_CHATDEATHMESSAGES 8 + + int gameMessageTime; + char gameMessages[MAX_GAMEMESSAGES][MAX_QPATH]; + serverMessageType_t gameMessageTypes[MAX_GAMEMESSAGES]; + int gameMessagePtr1; + int gameMessagePtr2; + + int chatDeathMessageTime; + char chatDeathMessages[MAX_CHATDEATHMESSAGES][MAX_QPATH]; + serverMessageType_t chatDeathMessageTypes[MAX_CHATDEATHMESSAGES]; + int chatDeathMessagePtr1; + int chatDeathMessagePtr2; + + // kill timers for carnage reward + int lastKillTime; + + // attacking player + int attackerTime; + int voiceTime; + + // warmup countdown + int warmup; + int warmupCount; + + //========================== + + int itemPickup; + int itemPickupTime; + int itemPickupBlendTime; // the pulse around the crosshair is timed seperately + + int weaponSelectTime; + int weaponAnimation; + int weaponAnimationTime; + + // blend blobs + float damageTime; + float damageX, damageY, damageValue; + + // view movement + float v_dmg_time; + float v_dmg_pitch; + float v_dmg_roll; + + vec3_t kick_angles; // weapon kicks + vec3_t kick_origin; + + // temp working variables for player view + float bobfracsin; + int bobcycle; + float xyspeed; + int nextOrbitTime; + + float fCurrentViewBobAmp; + float fCurrentViewBobPhase; + + // su44: MoHAA fog + float farplane_distance; + float farplane_color[3]; + qboolean farplane_cull; + + crain_t rain; + + int iWeaponCommand; + int iWeaponCommandSend; + + //qboolean cameraMode; // if rendering from a loaded camera + + + // development tool + refEntity_t testModelEntity; + char testModelName[MAX_QPATH]; + char testModelAnim[MAX_QPATH]; // su44: for testing TIKI model animations + qboolean testGun; + float testModelAnimSpeedScale; + +} cg_t; + + +// all of the model, shader, and sound references that are +// loaded at gamestate time are stored in cgMedia_t +// Other media that can be tied to clients, weapons, or items are +// stored in the clientInfo_t, itemInfo_t, weaponInfo_t, and powerupInfo_t +typedef struct { + qhandle_t whiteShader; + qhandle_t blackShader; + + qhandle_t connectionShader; + qhandle_t balloonShader; + + qhandle_t crosshairShader[3]; + + qhandle_t shadowMarkShader; + qhandle_t backTileShader, wakeMarkShader; + + + + + // su44: MoHAA zoom overlay shaders + qhandle_t zoomOverlayShader; + qhandle_t kar98TopOverlayShader; + qhandle_t kar98BottomOverlayShader; + qhandle_t binocularsOverlayShader; + + // font to use in cgame texts + fontInfo_t facfont; + fontInfo_t verdana; +} cgMedia_t; + + +// The client game static (cgs) structure hold everything +// loaded or calculated from the gamestate. It will NOT +// be cleared when a tournement restart is done, allowing +// all clients to begin playing instantly +typedef struct { + gameState_t gameState; // gamestate from server + glconfig_t glconfig; // rendering configuration + float screenXScale; // derived from glconfig + float screenYScale; + float screenXBias; + + int serverCommandSequence; // reliable command stream counter + int processedSnapshotNum;// the number of snapshots cgame has requested + + qboolean localServer; // detected on startup by checking sv_running + + // parsed from serverinfo + gametype_t gametype; + int dmflags; + int teamflags; + int fraglimit; + int capturelimit; + int timelimit; + int maxclients; + char mapname[MAX_QPATH]; + + int levelStartTime; + + // + // locally derived information from gamestate + // + qhandle_t gameModels[MAX_MODELS]; + sfxHandle_t gameSounds[MAX_SOUNDS]; + tiki_t * gameTIKIs[MAX_MODELS]; + + int numInlineModels; + qhandle_t inlineDrawModel[MAX_MODELS]; + vec3_t inlineModelMidpoints[MAX_MODELS]; + + clientInfo_t clientinfo[MAX_CLIENTS]; + + // teamchat width is *3 because of embedded color codes + char teamChatMsgs[TEAMCHAT_HEIGHT][TEAMCHAT_WIDTH*3+1]; + int teamChatMsgTimes[TEAMCHAT_HEIGHT]; + int teamChatPos; + int teamLastChatPos; + + int cursorX; + int cursorY; + qboolean eventHandling; + qboolean mouseCaptured; + qboolean sizingHud; + void *capturedItem; + qhandle_t activeCursor; + + // media + cgMedia_t media; + + int loadingStage; + +} cgs_t; + +//============================================================================== + +extern cgs_t cgs; +extern cg_t cg; +extern centity_t cg_entities[MAX_GENTITIES]; +extern markPoly_t cg_markPolys[MAX_MARK_POLYS]; + +extern cvar_t *cg_centertime; +extern cvar_t *cg_locationtime; +extern cvar_t *cg_runpitch; +extern cvar_t *cg_runroll; +extern cvar_t *cg_bobup; +extern cvar_t *cg_bobpitch; +extern cvar_t *cg_bobroll; +extern cvar_t *cg_swingSpeed; +extern cvar_t *cg_shadows; +extern cvar_t *cg_gibs; +extern cvar_t *cg_drawTimer; +extern cvar_t *cg_drawFPS; +extern cvar_t *cg_drawSnapshot; +extern cvar_t *cg_draw3dIcons; +extern cvar_t *cg_drawIcons; +extern cvar_t *cg_drawAmmoWarning; +extern cvar_t *cg_drawCrosshair; +extern cvar_t *cg_drawCrosshairNames; +extern cvar_t *cg_drawRewards; +extern cvar_t *cg_drawTeamOverlay; +extern cvar_t *cg_teamOverlayUserinfo; +extern cvar_t *cg_crosshairX; +extern cvar_t *cg_crosshairY; +extern cvar_t *cg_crosshairSize; +extern cvar_t *cg_crosshairHealth; +extern cvar_t *cg_drawStatus; +extern cvar_t *cg_draw2D; +extern cvar_t *cg_animSpeed; +extern cvar_t *cg_debugAnim; +extern cvar_t *cg_debugPosition; +extern cvar_t *cg_debugEvents; +extern cvar_t *cg_railTrailTime; +extern cvar_t *cg_errorDecay; +extern cvar_t *cg_nopredict; +extern cvar_t *cg_noPlayerAnims; +extern cvar_t *cg_showmiss; +extern cvar_t *cg_footsteps; +extern cvar_t *cg_addMarks; +extern cvar_t *cg_brassTime; +extern cvar_t *cg_gun_frame; +extern cvar_t *cg_gun_x; +extern cvar_t *cg_gun_y; +extern cvar_t *cg_gun_z; +extern cvar_t *cg_drawGun; +extern cvar_t *cg_viewsize; +extern cvar_t *cg_tracerChance; +extern cvar_t *cg_tracerWidth; +extern cvar_t *cg_tracerLength; +extern cvar_t *cg_autoswitch; +extern cvar_t *cg_ignore; +extern cvar_t *cg_simpleItems; +extern cvar_t *cg_fov; +extern cvar_t *cg_zoomFov; +extern cvar_t *cg_thirdPersonRange; +extern cvar_t *cg_thirdPersonAngle; +extern cvar_t *cg_thirdPerson; +extern cvar_t *cg_stereoSeparation; +extern cvar_t *cg_lagometer; +extern cvar_t *cg_drawAttacker; +extern cvar_t *cg_synchronousClients; +extern cvar_t *cg_teamChatTime; +extern cvar_t *cg_teamChatHeight; +extern cvar_t *cg_stats; +extern cvar_t *cg_forceModel; +extern cvar_t *cg_buildScript; +extern cvar_t *cg_paused; +extern cvar_t *cg_blood; +extern cvar_t *cg_predictItems; +extern cvar_t *cg_deferPlayers; +extern cvar_t *cg_drawFriend; +extern cvar_t *cg_teamChatsOnly; +extern cvar_t *cg_noVoiceChats; +extern cvar_t *cg_noVoiceText; +extern cvar_t *cg_scorePlum; +extern cvar_t *cg_smoothClients; +extern cvar_t *pmove_fixed; +extern cvar_t *pmove_msec; +//extern cvar_t *cg_pmove_fixed; +extern cvar_t *cg_cameraOrbit; +extern cvar_t *cg_cameraOrbitDelay; +extern cvar_t *cg_timescaleFadeEnd; +extern cvar_t *cg_timescaleFadeSpeed; +extern cvar_t *cg_timescale; +extern cvar_t *cg_cameraMode; +extern cvar_t *cg_smallFont; +extern cvar_t *cg_bigFont; +extern cvar_t *cg_noTaunt; +extern cvar_t *cg_noProjectileTrail; +extern cvar_t *cg_trueLightning; + +extern cvar_t *vm_offset_max; +extern cvar_t *vm_offset_speed; +extern cvar_t *vm_sway_front; +extern cvar_t *vm_sway_side; +extern cvar_t *vm_sway_up; +extern cvar_t *vm_offset_air_front; +extern cvar_t *vm_offset_air_side; +extern cvar_t *vm_offset_air_up; +extern cvar_t *vm_offset_crouch_front; +extern cvar_t *vm_offset_crouch_side; +extern cvar_t *vm_offset_crouch_up; +extern cvar_t *vm_offset_rocketcrouch_front; +extern cvar_t *vm_offset_rocketcrouch_side; +extern cvar_t *vm_offset_rocketcrouch_up; +extern cvar_t *vm_offset_shotguncrouch_front; +extern cvar_t *vm_offset_shotguncrouch_side; +extern cvar_t *vm_offset_shotguncrouch_up; +extern cvar_t *vm_offset_vel_base; +extern cvar_t *vm_offset_vel_front; +extern cvar_t *vm_offset_vel_side; +extern cvar_t *vm_offset_vel_up; +extern cvar_t *vm_offset_upvel; +extern cvar_t *vm_lean_lower; +extern cvar_t *cg_debugCGMessages; // su44: for debuging in cg_parsemsg.c + +// UBERSOUND +#define UBERSOUND_FILE "ubersound/ubersound.scr" +#define UBERDIALOG_FILE "ubersound/uberdialog.scr" +// su44: vanilla AA uberdialog.scr is 870195 +// wombat: it is larger in German version +#define UBERSOUND_SIZE 1048576 // 300000 +#define MUSIC_SIZE 10000 +#define MAPSTRING_LENGTH 512 + +typedef struct ubersound_s { + char name[MAX_QPATH]; + char wavfile[128]; + float basevol; + float volmod; + float basepitch; + float pitchmod; + float minDist; + float maxDist; + soundChannel_t channel; + qboolean loaded; // loaded or streamed + char mapstring[MAPSTRING_LENGTH]; + char subtitle[512]; // su44: for uberdialog.scr loading + + sfxHandle_t sfxHandle; + qboolean hasLoaded; + int variations; // some sounds have enumerated variations + struct ubersound_s* nextVariation; + struct ubersound_s* hashNext; +} ubersound_t; + +// +// cg_main.c +// +extern clientGameImport_t cgi; +extern clientGameExport_t cge; + +const char *CG_ConfigString( int index ); +const char *CG_Argv( int arg ); + +void QDECL CG_Printf( const char *msg, ... ); +void QDECL CG_Error( const char *msg, ... ); + +void CG_StartMusic( void ); + +void CG_UpdateCvars( void ); + +int CG_CrosshairPlayer( void ); +int CG_LastAttacker( void ); +void CG_LoadMenus(const char *menuFile); +void CG_KeyEvent(int key, qboolean down); +void CG_MouseEvent(int x, int y); +void CG_EventHandling(int type); +void CG_RankRunFrame( void ); +void CG_SetScoreSelection(void *menu); + +// +// cg_view.c +// +void CG_TestModel_f (void); +void CG_TestGun_f (void); +void CG_TestModelNextFrame_f (void); +void CG_TestModelPrevFrame_f (void); +void CG_TestModelNextSkin_f (void); +void CG_TestModelPrevSkin_f (void); +void CG_TestModelAnim_f (void); +void CG_TestModelAnimSpeedScale_f (void); +void CG_ZoomDown_f( void ); +void CG_ZoomUp_f( void ); +void CG_AddBufferedSound( sfxHandle_t sfx); + +void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback ); +void CG_Draw2D( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback ); + + +// +// cg_drawtools.c +// +void CG_AdjustFrom640( float *x, float *y, float *w, float *h ); +void CG_FillRect( float x, float y, float width, float height, const float *color ); +void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader ); +int CG_DrawStrlen( const char *str ); + +float *CG_FadeColor( int startMsec, int totalMsec ); +float *CG_TeamColor( int team ); +void CG_TileClear( void ); +void CG_ColorForHealth( vec4_t hcolor ); +void CG_GetColorForHealth( int health, int armor, vec4_t hcolor ); + +void UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ); +void CG_DrawRect( float x, float y, float width, float height, float size, const float *color ); +void CG_DrawSides(float x, float y, float w, float h, float size); +void CG_DrawTopBottom(float x, float y, float w, float h, float size); +void CG_DrawBigString( int x, int y, const char *s, float alpha ); +void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, + qboolean forceColor, qboolean shadow, int charWidth, int charHeight, int maxChars ); + + +// +// cg_draw.c, cg_newDraw.c +// +extern int sortedTeamPlayers[TEAM_MAXOVERLAY]; +extern int numSortedTeamPlayers; +extern int drawTeamOverlayModificationCount; +extern char systemChat[256]; +extern char teamChat1[256]; +extern char teamChat2[256]; + +void CG_AddLagometerFrameInfo( void ); +void CG_AddLagometerSnapshotInfo( snapshot_t *snap ); +void CG_CenterPrint( const char *str, int y, int charWidth ); +void CG_LocationPrint( const char *str, int x, int y, int charWidth ); +void CG_DrawActive( stereoFrame_t stereoView ); +void CG_DrawFlagModel( float x, float y, float w, float h, int team, qboolean force2D ); +void CG_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle); +void CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style); +int CG_Text_Width(const char *text, float scale, int limit); +int CG_Text_Height(const char *text, float scale, int limit); +void CG_SelectPrevPlayer( void ); +void CG_SelectNextPlayer( void ); +float CG_GetValue(int ownerDraw); +qboolean CG_OwnerDrawVisible(int flags); +void CG_RunMenuScript(char **args); +void CG_ShowResponseHead( void ); +void CG_SetPrintString(int type, const char *p); +void CG_InitTeamChat( void ); +void CG_GetTeamColor(vec4_t *color); +const char *CG_GetGameStatusText( void ); +const char *CG_GetKillerText( void ); +void CG_Draw3DModel( float x, float y, float w, float h, qhandle_t model, qhandle_t skin, vec3_t origin, vec3_t angles ); +void CG_Text_PaintChar(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, qhandle_t hShader); +void CG_CheckOrderPending( void ); +const char *CG_GameTypeString( void ); +qboolean CG_YourTeamHasFlag( void ); +qboolean CG_OtherTeamHasFlag( void ); +qhandle_t CG_StatusHandle(int task); +void CG_DrawBox( int x, int y, int w, int h, qboolean ctrCoord ); +void CG_DrawStdBox( int x, int y, int w, int h, qboolean ctrCoord ); + +// +// cg_player.c +// +void CG_Player( centity_t *cent ); +void CG_PlayerSprites( centity_t *cent ); +void CG_ExtractPlayerTeam( centity_t *cent ); +void CG_ResetPlayerEntity( centity_t *cent ); +void CG_NewClientInfo( int clientNum ); +sfxHandle_t CG_CustomSound( int clientNum, const char *soundName ); + +// +// cg_predict.c +// +void CG_BuildSolidList( void ); +int CG_PointContents( const vec3_t point, int passEntityNum ); +void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + int skipNumber, int mask ); +void CG_PlayerTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + int skipNumber, int mask, int capsule, qboolean traceDeep ); +void CG_PredictPlayerState( void ); + +// +// cg_ents.c +// +void CG_SetEntitySoundPosition( centity_t *cent ); +void CG_AddPacketEntities( void ); +void CG_Beam( centity_t *cent ); +void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out ); + + +// +// cg_weapons.c +// +void CG_NextWeapon_f( void ); +void CG_PrevWeapon_f( void ); +void CG_UseLastWeapon_f( void ); +void CG_HolsterWeapon_f( void ); +void CG_DropWeapon_f( void ); +void CG_ToggleItem_f( void ); + +void CG_FireWeapon( centity_t *cent ); +void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, int soundType ); +void CG_MissileHitPlayer( int weapon, vec3_t origin, vec3_t dir, int entityNum ); +void CG_ShotgunFire( entityState_t *es ); +void CG_Bullet( vec3_t origin, int sourceEntityNum, vec3_t normal, qboolean flesh, int fleshEntityNum ); + +void CG_RailTrail( clientInfo_t *ci, vec3_t start, vec3_t end ); +void CG_AddViewWeapon (playerState_t *ps); +void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent, int team ); +int CG_WeaponCommandButtonBits(); + +// +// cg_marks.c +// +void CG_InitMarkPolys( void ); +void CG_AddMarks( void ); +void CG_ImpactMark( qhandle_t markShader, + const vec3_t origin, const vec3_t dir, + float orientation, + float r, float g, float b, float a, + qboolean alphaFade, + float radius, qboolean temporary ); + +// +// cg_localents.c +// +void CG_InitLocalEntities( void ); +localEntity_t *CG_AllocLocalEntity( void ); +void CG_AddLocalEntities( void ); + +// +// cg_effects.c +// +localEntity_t *CG_SmokePuff( const vec3_t p, + const vec3_t vel, + float radius, + float r, float g, float b, float a, + float duration, + int startTime, + int fadeInTime, + int leFlags, + qhandle_t hShader ); +void CG_BubbleTrail( vec3_t start, vec3_t end, float spacing ); +#ifdef MISSIONPACK +void CG_KamikazeEffect( vec3_t org ); +void CG_ObeliskExplode( vec3_t org, int entityNum ); +void CG_ObeliskPain( vec3_t org ); +void CG_InvulnerabilityImpact( vec3_t org, vec3_t angles ); +void CG_InvulnerabilityJuiced( vec3_t org ); +void CG_LightningBoltBeam( vec3_t start, vec3_t end ); +#endif +void CG_ScorePlum( int client, vec3_t org, int score ); + +void CG_GibPlayer( vec3_t playerOrigin ); +void CG_BigExplode( vec3_t playerOrigin ); + +void CG_Bleed( vec3_t origin, int entityNum ); + +localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, + qhandle_t hModel, qhandle_t shader, int msec, + qboolean isSprite ); + +// +// cg_snapshot.c +// +void CG_ProcessSnapshots( void ); + +// +// cg_info.c +// +void CG_LoadingString( const char *s ); +void CG_LoadingClient( int clientNum ); +void CG_DrawInformation( void ); + +// +// cg_scoreboard.c +// +qboolean CG_DrawOldScoreboard( void ); +void CG_DrawOldTourneyScoreboard( void ); + +// +// cg_consolecmds.c +// +qboolean CG_ConsoleCommand( void ); +void CG_InitConsoleCommands( void ); + +// +// cg_servercmds.c +// +void CG_ExecuteNewServerCommands( int latestSequence ); +void CG_ParseServerinfo( void ); +void CG_SetConfigValues( void ); + +// +// cg_playerstate.c +// +void CG_Respawn( void ); +void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops ); +void CG_CheckChangedPredictableEvents( playerState_t *ps ); + +// +// cg_modelanim.c +// +void CG_ModelAnim( centity_t *cent ); +void CG_BoneLocal2World(bone_t *b, vec3_t pos, vec3_t rot, vec3_t outPos, vec3_t outRot); +void CG_CentBoneLocal2World(bone_t *b, centity_t *cent, vec3_t outPos, vec3_t outRot); +void CG_CentBoneIndexLocal2World(int boneIndex, centity_t *cent, vec3_t outPos, vec3_t outRot); + +// +// cg_viewmodelanim.c +// +void CG_RegisterItemName( int index, const char *str ); +const char *CG_GetItemName( int index ); +void CG_AddViewModelAnimAttachment( refEntity_t *ent, centity_t *cent ); +void CG_ViewModelAnim(); + +// +// cg_eventSystem.c +// +void CG_InitEventSystem(); // called once from CG_Init +void CG_ProcessEventText(centity_t *ent, const char *eventText); +void CG_PostEvent(centity_t *ent, const char *eventText, int eventDelay); +void CG_ProcessPendingEvents(); // called every frame + +//=============================================== + +typedef enum { + SYSTEM_PRINT, + CHAT_PRINT, + TEAMCHAT_PRINT +} q3print_t; + +void CG_ClearParticles (void); +void CG_AddParticles (void); +void CG_ParticleSnow (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum); +void CG_ParticleSmoke (qhandle_t pshader, centity_t *cent); +void CG_AddParticleShrapnel (localEntity_t *le); +void CG_ParticleSnowFlurry (qhandle_t pshader, centity_t *cent); +void CG_ParticleBulletDebris (vec3_t org, vec3_t vel, int duration); +void CG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed); +void CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir); +void CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha); +void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd); +extern qboolean initparticles; +int CG_NewParticleArea ( int num ); + +// cg_ubersound.c +void CG_LoadUbersound( void ); +ubersound_t* CG_GetUbersound( const char *name ); +const char* CG_LoadMusic( const char *musicfile ); + +// cg_parsemsg.c +void CG_ParseCGMessage(); +void CG_AddBulletTracers(); +void CG_AddBulletImpacts(); +void CG_HudDrawElements(); + +// cg_beams.c +void CG_InitBeams(); +void CG_AddBeams(); +void CG_CreateBeam(vec3_t start, vec3_t dir, int owner, qhandle_t hModel, float alpha, + float scale, int flags, float length, int life, qboolean create, vec3_t endpointvec, + int min_offset, int max_offset, int overlap, int numSubdivisions, int delay, + const char *beamshadername, byte modulate[4], int numspherebeams, float sphereradius, + int toggledelay, float endalpha, int renderfx, const char *name); +void CG_Rope(centity_t *cent); // afaik that's not used in MoHAA, but who cares? +void CG_MultiBeam(centity_t *cent); + +// cg_rain.c +void CG_InitRainEffect(); +void CG_RainCSUpdated(int num, const char *str); +void CG_Rain(centity_t *cent); + +// cg_specialfx.c +void CG_MeleeImpact(float *vStart, float *vEnd); +void CG_Footstep(char *szTagName, centity_t *ent, /*refEntity_t *pREnt,*/ + int iRunning, int iEquipment); + diff --git a/code/cgame/cg_localents.c b/code/cgame/cg_localents.c new file mode 100644 index 00000000..9942a34e --- /dev/null +++ b/code/cgame/cg_localents.c @@ -0,0 +1,683 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +// cg_localents.c -- every frame, generate renderer commands for locally +// processed entities, like smoke puffs, gibs, shells, etc. + +#include "cg_local.h" + +#define MAX_LOCAL_ENTITIES 512 +localEntity_t cg_localEntities[MAX_LOCAL_ENTITIES]; +localEntity_t cg_activeLocalEntities; // double linked list +localEntity_t *cg_freeLocalEntities; // single linked list + +/* +=================== +CG_InitLocalEntities + +This is called at startup and for tournement restarts +=================== +*/ +void CG_InitLocalEntities( void ) { + int i; + + memset( cg_localEntities, 0, sizeof( cg_localEntities ) ); + cg_activeLocalEntities.next = &cg_activeLocalEntities; + cg_activeLocalEntities.prev = &cg_activeLocalEntities; + cg_freeLocalEntities = cg_localEntities; + for ( i = 0 ; i < MAX_LOCAL_ENTITIES - 1 ; i++ ) { + cg_localEntities[i].next = &cg_localEntities[i+1]; + } +} + + +/* +================== +CG_FreeLocalEntity +================== +*/ +void CG_FreeLocalEntity( localEntity_t *le ) { + if ( !le->prev ) { + CG_Error( "CG_FreeLocalEntity: not active" ); + } + + // remove from the doubly linked active list + le->prev->next = le->next; + le->next->prev = le->prev; + + // the free list is only singly linked + le->next = cg_freeLocalEntities; + cg_freeLocalEntities = le; +} + +/* +=================== +CG_AllocLocalEntity + +Will allways succeed, even if it requires freeing an old active entity +=================== +*/ +localEntity_t *CG_AllocLocalEntity( void ) { + localEntity_t *le; + + if ( !cg_freeLocalEntities ) { + // no free entities, so free the one at the end of the chain + // remove the oldest active entity + CG_FreeLocalEntity( cg_activeLocalEntities.prev ); + } + + le = cg_freeLocalEntities; + cg_freeLocalEntities = cg_freeLocalEntities->next; + + memset( le, 0, sizeof( *le ) ); + + // link into the active list + le->next = cg_activeLocalEntities.next; + le->prev = &cg_activeLocalEntities; + cg_activeLocalEntities.next->prev = le; + cg_activeLocalEntities.next = le; + return le; +} + + +/* +==================================================================================== + +FRAGMENT PROCESSING + +A fragment localentity interacts with the environment in some way (hitting walls), +or generates more localentities along a trail. + +==================================================================================== +*/ + +/* +================ +CG_BloodTrail + +Leave expanding blood puffs behind gibs +================ +*/ +void CG_BloodTrail( localEntity_t *le ) { + //int t; + //int t2; + //int step; + //vec3_t newOrigin; + //localEntity_t *blood; + + //step = 150; + //t = step * ( (cg.time - cg.frametime + step ) / step ); + //t2 = step * ( cg.time / step ); + + //for ( ; t <= t2; t += step ) { + // BG_EvaluateTrajectory( &le->pos, t, newOrigin ); + + // blood = CG_SmokePuff( newOrigin, vec3_origin, + // 20, // radius + // 1, 1, 1, 1, // color + // 2000, // trailTime + // t, // startTime + // 0, // fadeInTime + // 0, // flags + // cgs.media.bloodTrailShader ); + // // use the optimized version + // blood->leType = LE_FALL_SCALE_FADE; + // // drop a total of 40 units over its lifetime + // blood->pos.trDelta[2] = 40; + //} +} + + +/* +================ +CG_FragmentBounceMark +================ +*/ +void CG_FragmentBounceMark( localEntity_t *le, trace_t *trace ) { + //int radius; + + //if ( le->leMarkType == LEMT_BLOOD ) { + + // radius = 16 + (rand()&31); + // CG_ImpactMark( cgs.media.bloodMarkShader, trace->endpos, trace->plane.normal, random()*360, + // 1,1,1,1, qtrue, radius, qfalse ); + //} else if ( le->leMarkType == LEMT_BURN ) { + + // radius = 8 + (rand()&15); + // CG_ImpactMark( cgs.media.burnMarkShader, trace->endpos, trace->plane.normal, random()*360, + // 1,1,1,1, qtrue, radius, qfalse ); + //} + + + //// don't allow a fragment to make multiple marks, or they + //// pile up while settling + //le->leMarkType = LEMT_NONE; +} + +/* +================ +CG_FragmentBounceSound +================ +*/ +void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) { + // don't allow a fragment to make multiple bounce sounds, + // or it gets too noisy as they settle + le->leBounceSoundType = LEBS_NONE; +} + + +/* +================ +CG_ReflectVelocity +================ +*/ +void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) { + vec3_t velocity; + float dot; + int hitTime; + + // reflect the velocity on the trace plane + hitTime = cg.time - cg.frametime + cg.frametime * trace->fraction; + BG_EvaluateTrajectoryDelta( &le->pos, hitTime, velocity ); + dot = DotProduct( velocity, trace->plane.normal ); + VectorMA( velocity, -2*dot, trace->plane.normal, le->pos.trDelta ); + + VectorScale( le->pos.trDelta, le->bounceFactor, le->pos.trDelta ); + + VectorCopy( trace->endpos, le->pos.trDelta ); + le->pos.trTime = cg.time; + + + // check for stop, making sure that even on low FPS systems it doesn't bobble + if ( trace->allsolid || + ( trace->plane.normal[2] > 0 && + ( le->pos.trDelta[2] < 40 || le->pos.trDelta[2] < -cg.frametime * le->pos.trDelta[2] ) ) ) { + } else { + + } +} + +/* +================ +CG_AddFragment +================ +*/ +void CG_AddFragment( localEntity_t *le ) { + vec3_t newOrigin; + trace_t trace; + refEntity_t *e; + tiki_t *tiki; + + // if that's a tiki, we need to animate it + if(le->tiki) { + float time = 0; + int anim = 0; + e = &le->refEntity; + tiki = le->tiki; + e->bones = cgi.TIKI_GetBones(tiki->numBones); + cgi.TIKI_AppendFrameBoundsAndRadius(tiki,anim,time,&e->radius,e->bounds); + cgi.TIKI_SetChannels(tiki,anim,time,1,e->bones); + cgi.TIKI_Animate(tiki,e->bones); + } + + // calculate new position + BG_EvaluateTrajectory( &le->pos, cg.time, newOrigin ); + + // trace a line from previous position to new position + CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID ); + if ( trace.fraction == 1.0 ) { + // still in free fall + VectorCopy( newOrigin, le->refEntity.origin ); + + if ( le->leFlags & LEF_TUMBLE ) { + vec3_t angles; + + BG_EvaluateTrajectory( &le->angles, cg.time, angles ); + AnglesToAxis( angles, le->refEntity.axis ); + } + cgi.R_AddRefEntityToScene( &le->refEntity ); + + // add a blood trail + if ( le->leBounceSoundType == LEBS_BLOOD ) { + CG_BloodTrail( le ); + } + + return; + } + + // if it is in a nodrop zone, remove it + // this keeps gibs from waiting at the bottom of pits of death + // and floating levels + if ( cgi.CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) { + CG_FreeLocalEntity( le ); + return; + } + + // leave a mark + CG_FragmentBounceMark( le, &trace ); + + // do a bouncy sound + CG_FragmentBounceSound( le, &trace ); + + // reflect the velocity on the trace plane + CG_ReflectVelocity( le, &trace ); + + cgi.R_AddRefEntityToScene( &le->refEntity ); +} + +/* +===================================================================== + +TRIVIAL LOCAL ENTITIES + +These only do simple scaling or modulation before passing to the renderer +===================================================================== +*/ + +/* +==================== +CG_AddFadeRGB +==================== +*/ +void CG_AddFadeRGB( localEntity_t *le ) { + refEntity_t *re; + float c; + + re = &le->refEntity; + + c = ( le->endTime - cg.time ) * le->lifeRate; + c *= 0xff; + + re->shaderRGBA[0] = le->color[0] * c; + re->shaderRGBA[1] = le->color[1] * c; + re->shaderRGBA[2] = le->color[2] * c; + re->shaderRGBA[3] = le->color[3] * c; + + cgi.R_AddRefEntityToScene( re ); +} + +/* +================== +CG_AddMoveScaleFade +================== +*/ +static void CG_AddMoveScaleFade( localEntity_t *le ) { + refEntity_t *re; + float c; + vec3_t delta; + float len; + + re = &le->refEntity; + + if ( le->fadeInTime > le->startTime && cg.time < le->fadeInTime ) { + // fade / grow time + c = 1.0 - (float) ( le->fadeInTime - cg.time ) / ( le->fadeInTime - le->startTime ); + } + else { + // fade / grow time + c = ( le->endTime - cg.time ) * le->lifeRate; + } + + re->shaderRGBA[3] = 0xff * c * le->color[3]; + + if ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) { + re->radius = le->radius * ( 1.0 - c ) + 8; + } + + BG_EvaluateTrajectory( &le->pos, cg.time, re->origin ); + + // if the view would be "inside" the sprite, kill the sprite + // so it doesn't add too much overdraw + VectorSubtract( re->origin, cg.refdef.vieworg, delta ); + len = VectorLength( delta ); + if ( len < le->radius ) { + CG_FreeLocalEntity( le ); + return; + } + + cgi.R_AddRefEntityToScene( re ); +} + + +/* +=================== +CG_AddScaleFade + +For rocket smokes that hang in place, fade out, and are +removed if the view passes through them. +There are often many of these, so it needs to be simple. +=================== +*/ +static void CG_AddScaleFade( localEntity_t *le ) { + refEntity_t *re; + float c; + vec3_t delta; + float len; + + re = &le->refEntity; + + // fade / grow time + c = ( le->endTime - cg.time ) * le->lifeRate; + + re->shaderRGBA[3] = 0xff * c * le->color[3]; + re->radius = le->radius * ( 1.0 - c ) + 8; + + // if the view would be "inside" the sprite, kill the sprite + // so it doesn't add too much overdraw + VectorSubtract( re->origin, cg.refdef.vieworg, delta ); + len = VectorLength( delta ); + if ( len < le->radius ) { + CG_FreeLocalEntity( le ); + return; + } + + cgi.R_AddRefEntityToScene( re ); +} + + +/* +================= +CG_AddFallScaleFade + +This is just an optimized CG_AddMoveScaleFade +For blood mists that drift down, fade out, and are +removed if the view passes through them. +There are often 100+ of these, so it needs to be simple. +================= +*/ +static void CG_AddFallScaleFade( localEntity_t *le ) { + refEntity_t *re; + float c; + vec3_t delta; + float len; + + re = &le->refEntity; + + // fade time + c = ( le->endTime - cg.time ) * le->lifeRate; + + re->shaderRGBA[3] = 0xff * c * le->color[3]; + + re->origin[ 2 ] = le->pos.trDelta[ 2 ] - ( 1.0 - c ) * le->pos.trDelta[ 2 ]; + + re->radius = le->radius * ( 1.0 - c ) + 16; + + // if the view would be "inside" the sprite, kill the sprite + // so it doesn't add too much overdraw + VectorSubtract( re->origin, cg.refdef.vieworg, delta ); + len = VectorLength( delta ); + if ( len < le->radius ) { + CG_FreeLocalEntity( le ); + return; + } + + cgi.R_AddRefEntityToScene( re ); +} + + + +/* +================ +CG_AddExplosion +================ +*/ +static void CG_AddExplosion( localEntity_t *ex ) { + refEntity_t *ent; + + ent = &ex->refEntity; + + // add the entity + cgi.R_AddRefEntityToScene(ent); + + // add the dlight + if ( ex->light ) { + float light; + + light = (float)( cg.time - ex->startTime ) / ( ex->endTime - ex->startTime ); + if ( light < 0.5 ) { + light = 1.0; + } else { + light = 1.0 - ( light - 0.5 ) * 2; + } + light = ex->light * light; + cgi.R_AddLightToScene(ent->origin, light, ex->lightColor[0], ex->lightColor[1], ex->lightColor[2] ); + } +} + +/* +================ +CG_AddSpriteExplosion +================ +*/ +static void CG_AddSpriteExplosion( localEntity_t *le ) { + refEntity_t re; + float c; + + re = le->refEntity; + + c = ( le->endTime - cg.time ) / ( float ) ( le->endTime - le->startTime ); + if ( c > 1 ) { + c = 1.0; // can happen during connection problems + } + + re.shaderRGBA[0] = 0xff; + re.shaderRGBA[1] = 0xff; + re.shaderRGBA[2] = 0xff; + re.shaderRGBA[3] = 0xff * c * 0.33; + + re.reType = RT_SPRITE; + re.radius = 42 * ( 1.0 - c ) + 30; + + cgi.R_AddRefEntityToScene( &re ); + + // add the dlight + if ( le->light ) { + float light; + + light = (float)( cg.time - le->startTime ) / ( le->endTime - le->startTime ); + if ( light < 0.5 ) { + light = 1.0; + } else { + light = 1.0 - ( light - 0.5 ) * 2; + } + light = le->light * light; + cgi.R_AddLightToScene(re.origin, light, le->lightColor[0], le->lightColor[1], le->lightColor[2] ); + } +} + + +/* +=================== +CG_AddScorePlum +=================== +*/ +#define NUMBER_SIZE 8 + +void CG_AddScorePlum( localEntity_t *le ) { + //refEntity_t *re; + //vec3_t origin, delta, dir, vec, up = {0, 0, 1}; + //float c, len; + //int i, score, digits[10], numdigits, negative; + + //re = &le->refEntity; + + //c = ( le->endTime - cg.time ) * le->lifeRate; + + //score = le->radius; + //if (score < 0) { + // re->shaderRGBA[0] = 0xff; + // re->shaderRGBA[1] = 0x11; + // re->shaderRGBA[2] = 0x11; + //} + //else { + // re->shaderRGBA[0] = 0xff; + // re->shaderRGBA[1] = 0xff; + // re->shaderRGBA[2] = 0xff; + // if (score >= 50) { + // re->shaderRGBA[1] = 0; + // } else if (score >= 20) { + // re->shaderRGBA[0] = re->shaderRGBA[1] = 0; + // } else if (score >= 10) { + // re->shaderRGBA[2] = 0; + // } else if (score >= 2) { + // re->shaderRGBA[0] = re->shaderRGBA[2] = 0; + // } + + //} + //if (c < 0.25) + // re->shaderRGBA[3] = 0xff * 4 * c; + //else + // re->shaderRGBA[3] = 0xff; + + //re->radius = NUMBER_SIZE / 2; + + //VectorCopy(le->pos.trBase, origin); + //origin[2] += 110 - c * 100; + + //VectorSubtract(cg.refdef.vieworg, origin, dir); + //CrossProduct(dir, up, vec); + //VectorNormalize(vec); + + //VectorMA(origin, -10 + 20 * sin(c * 2 * M_PI), vec, origin); + + //// if the view would be "inside" the sprite, kill the sprite + //// so it doesn't add too much overdraw + //VectorSubtract( origin, cg.refdef.vieworg, delta ); + //len = VectorLength( delta ); + //if ( len < 20 ) { + // CG_FreeLocalEntity( le ); + // return; + //} + + //negative = qfalse; + //if (score < 0) { + // negative = qtrue; + // score = -score; + //} + + //for (numdigits = 0; !(numdigits && !score); numdigits++) { + // digits[numdigits] = score % 10; + // score = score / 10; + //} + + //if (negative) { + // digits[numdigits] = 10; + // numdigits++; + //} + + //for (i = 0; i < numdigits; i++) { + // VectorMA(origin, (float) (((float) numdigits / 2) - i) * NUMBER_SIZE, vec, re->origin); + // re->customShader = cgs.media.numberShaders[digits[numdigits-1-i]]; + // cgi.R_AddRefEntityToScene( re ); + //} +} + + + + +//============================================================================== + +/* +=================== +CG_AddLocalEntities + +=================== +*/ +void CG_AddLocalEntities( void ) { + localEntity_t *le, *next; + + // walk the list backwards, so any new local entities generated + // (trails, marks, etc) will be present this frame + le = cg_activeLocalEntities.prev; + for ( ; le != &cg_activeLocalEntities ; le = next ) { + // grab next now, so if the local entity is freed we + // still have it + next = le->prev; + + if ( cg.time >= le->endTime ) { + CG_FreeLocalEntity( le ); + continue; + } + switch ( le->leType ) { + default: + CG_Error( "Bad leType: %i", le->leType ); + break; + case LE_SKIP: + // do nothing + break; + case LE_MARK: + break; + + case LE_SPRITE_EXPLOSION: + CG_AddSpriteExplosion( le ); + break; + + case LE_EXPLOSION: + CG_AddExplosion( le ); + break; + + case LE_FRAGMENT: // gibs and brass + CG_AddFragment( le ); + break; + + case LE_MOVE_SCALE_FADE: // water bubbles + CG_AddMoveScaleFade( le ); + break; + + case LE_FADE_RGB: // teleporters, railtrails + CG_AddFadeRGB( le ); + break; + + case LE_FALL_SCALE_FADE: // gib blood trails + CG_AddFallScaleFade( le ); + break; + + case LE_SCALE_FADE: // rocket trails + CG_AddScaleFade( le ); + break; + + case LE_SCOREPLUM: + CG_AddScorePlum( le ); + break; + +#ifdef MISSIONPACK + case LE_KAMIKAZE: + CG_AddKamikaze( le ); + break; + case LE_INVULIMPACT: + CG_AddInvulnerabilityImpact( le ); + break; + case LE_INVULJUICED: + CG_AddInvulnerabilityJuiced( le ); + break; + case LE_SHOWREFENTITY: + CG_AddRefEntity( le ); + break; +#endif + } + } +} + + + + diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c new file mode 100644 index 00000000..7ed33dc2 --- /dev/null +++ b/code/cgame/cg_main.c @@ -0,0 +1,816 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_main.c -- initialization and primary entry point for cgame +#include "cg_local.h" + +clientGameImport_t cgi; +clientGameExport_t cge; + +int forceModelModificationCount = -1; + +void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum, int randomSeed ); +void CG_Shutdown( void ); + +#if 0 +/* +================ +vmMain + +This is the only way control passes into the module. +This must be the very first function compiled into the .q3vm file +================ +*/ +intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { + + switch ( command ) { + case CG_INIT: + CG_Init( arg0, arg1, arg2, arg3 ); + return 0; + case CG_SHUTDOWN: + CG_Shutdown(); + return 0; + case CG_CONSOLE_COMMAND: + return CG_ConsoleCommand(); + case CG_DRAW_ACTIVE_FRAME: + CG_DrawActiveFrame( arg0, arg1, arg2 ); + return 0; + case CG_DRAW_2D: + CG_Draw2D( arg0, arg1, arg2 ); + return 0; + case CG_CROSSHAIR_PLAYER: + return CG_CrosshairPlayer(); + case CG_LAST_ATTACKER: + return CG_LastAttacker(); + case CG_KEY_EVENT: + CG_KeyEvent(arg0, arg1); + return 0; + case CG_MOUSE_EVENT: + CG_MouseEvent(arg0, arg1); + return 0; + case CG_EVENT_HANDLING: + CG_EventHandling(arg0); + return 0; + case CG_CENTERPRINT: + CG_CenterPrint( (const char*)arg0, 200, 10 ); + return 0; + case CG_LOCATIONPRINT: + CG_LocationPrint( (const char*)arg0, arg1, arg2, 10 ); + return 0; + case CG_PARSEMSG: + CG_ParseCGMessage(); + return 0; + default: + CG_Error( "vmMain: unknown command %i", command ); + break; + } + return -1; +} +#endif + +cg_t cg; +cgs_t cgs; +centity_t cg_entities[ MAX_GENTITIES ]; + +cvar_t *cg_railTrailTime; +cvar_t *cg_centertime; +cvar_t *cg_locationtime; +cvar_t *cg_runpitch; +cvar_t *cg_runroll; +cvar_t *cg_bobup; +cvar_t *cg_bobpitch; +cvar_t *cg_bobroll; +cvar_t *cg_swingSpeed; +cvar_t *cg_shadows; +cvar_t *cg_gibs; +cvar_t *cg_drawTimer; +cvar_t *cg_drawFPS; +cvar_t *cg_drawSnapshot; +cvar_t *cg_draw3dIcons; +cvar_t *cg_drawIcons; +cvar_t *cg_drawAmmoWarning; +cvar_t *cg_drawCrosshair; +cvar_t *cg_drawCrosshairNames; +cvar_t *cg_drawRewards; +cvar_t *cg_crosshairSize; +cvar_t *cg_crosshairX; +cvar_t *cg_crosshairY; +cvar_t *cg_crosshairHealth; +cvar_t *cg_draw2D; +cvar_t *cg_drawStatus; +cvar_t *cg_animSpeed; +cvar_t *cg_debugAnim; +cvar_t *cg_debugPosition; +cvar_t *cg_debugEvents; +cvar_t *cg_errorDecay; +cvar_t *cg_nopredict; +cvar_t *cg_noPlayerAnims; +cvar_t *cg_showmiss; +cvar_t *cg_footsteps; +cvar_t *cg_addMarks; +cvar_t *cg_brassTime; +cvar_t *cg_viewsize; +cvar_t *cg_drawGun; +cvar_t *cg_gun_frame; +cvar_t *cg_gun_x; +cvar_t *cg_gun_y; +cvar_t *cg_gun_z; +cvar_t *cg_tracerChance; +cvar_t *cg_tracerWidth; +cvar_t *cg_tracerLength; +cvar_t *cg_autoswitch; +cvar_t *cg_ignore; +cvar_t *cg_simpleItems; +cvar_t *cg_fov; +cvar_t *cg_zoomFov; +cvar_t *cg_thirdPerson; +cvar_t *cg_thirdPersonRange; +cvar_t *cg_thirdPersonAngle; +cvar_t *cg_stereoSeparation; +cvar_t *cg_lagometer; +cvar_t *cg_drawAttacker; +cvar_t *cg_synchronousClients; +cvar_t *cg_teamChatTime; +cvar_t *cg_teamChatHeight; +cvar_t *cg_stats; +cvar_t *cg_buildScript; +cvar_t *cg_forceModel; +cvar_t *cg_paused; +cvar_t *cg_blood; +cvar_t *cg_predictItems; +cvar_t *cg_deferPlayers; +cvar_t *cg_drawTeamOverlay; +cvar_t *cg_teamOverlayUserinfo; +cvar_t *cg_drawFriend; +cvar_t *cg_teamChatsOnly; +cvar_t *cg_noVoiceChats; +cvar_t *cg_noVoiceText; +cvar_t *cg_hudFiles; +cvar_t *cg_scorePlum; +cvar_t *cg_smoothClients; +cvar_t *pmove_fixed; +cvar_t *cg_pmove_fixed; +cvar_t *pmove_msec; +cvar_t *cg_pmove_msec; +cvar_t *cg_cameraMode; +cvar_t *cg_cameraOrbit; +cvar_t *cg_cameraOrbitDelay; +cvar_t *cg_timescaleFadeEnd; +cvar_t *cg_timescaleFadeSpeed; +cvar_t *cg_timescale; +cvar_t *cg_smallFont; +cvar_t *cg_bigFont; +cvar_t *cg_noTaunt; +cvar_t *cg_noProjectileTrail; +cvar_t *cg_trueLightning; + +cvar_t *vm_offset_max; +cvar_t *vm_offset_speed; +cvar_t *vm_sway_front; +cvar_t *vm_sway_side; +cvar_t *vm_sway_up; +cvar_t *vm_offset_air_front; +cvar_t *vm_offset_air_side; +cvar_t *vm_offset_air_up; +cvar_t *vm_offset_crouch_front; +cvar_t *vm_offset_crouch_side; +cvar_t *vm_offset_crouch_up; +cvar_t *vm_offset_rocketcrouch_front; +cvar_t *vm_offset_rocketcrouch_side; +cvar_t *vm_offset_rocketcrouch_up; +cvar_t *vm_offset_shotguncrouch_front; +cvar_t *vm_offset_shotguncrouch_side; +cvar_t *vm_offset_shotguncrouch_up; +cvar_t *vm_offset_vel_base; +cvar_t *vm_offset_vel_front; +cvar_t *vm_offset_vel_side; +cvar_t *vm_offset_vel_up; +cvar_t *vm_offset_upvel; +cvar_t *vm_lean_lower; +cvar_t *cg_debugCGMessages; + +typedef struct { + cvar_t **cvar; + char *cvarName; + char *defaultString; + int cvarFlags; +} cvarTable_t; + +static cvarTable_t cvarTable[] = { + { &cg_ignore, "cg_ignore", "0", 0 }, // used for debugging + { &cg_autoswitch, "cg_autoswitch", "1", CVAR_ARCHIVE }, + { &cg_drawGun, "cg_drawGun", "1", CVAR_ARCHIVE }, + { &cg_zoomFov, "cg_zoomfov", "22.5", CVAR_ARCHIVE }, + { &cg_fov, "cg_fov", "90", CVAR_ARCHIVE }, + { &cg_viewsize, "cg_viewsize", "100", CVAR_ARCHIVE }, + { &cg_stereoSeparation, "cg_stereoSeparation", "0.4", CVAR_ARCHIVE }, + { &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE }, + { &cg_gibs, "cg_gibs", "1", CVAR_ARCHIVE }, + { &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE }, + { &cg_drawStatus, "cg_drawStatus", "1", CVAR_ARCHIVE }, + { &cg_drawTimer, "cg_drawTimer", "0", CVAR_ARCHIVE }, + { &cg_drawFPS, "cg_drawFPS", "0", CVAR_ARCHIVE }, + { &cg_drawSnapshot, "cg_drawSnapshot", "0", CVAR_ARCHIVE }, + { &cg_draw3dIcons, "cg_draw3dIcons", "1", CVAR_ARCHIVE }, + { &cg_drawIcons, "cg_drawIcons", "1", CVAR_ARCHIVE }, + { &cg_drawAmmoWarning, "cg_drawAmmoWarning", "1", CVAR_ARCHIVE }, + { &cg_drawAttacker, "cg_drawAttacker", "1", CVAR_ARCHIVE }, + { &cg_drawCrosshair, "cg_drawCrosshair", "1", CVAR_ARCHIVE }, + { &cg_drawCrosshairNames, "cg_drawCrosshairNames", "1", CVAR_ARCHIVE }, + { &cg_drawRewards, "cg_drawRewards", "1", CVAR_ARCHIVE }, + { &cg_crosshairSize, "cg_crosshairSize", "24", CVAR_ARCHIVE }, + { &cg_crosshairHealth, "cg_crosshairHealth", "1", CVAR_ARCHIVE }, + { &cg_crosshairX, "cg_crosshairX", "0", CVAR_ARCHIVE }, + { &cg_crosshairY, "cg_crosshairY", "0", CVAR_ARCHIVE }, + { &cg_brassTime, "cg_brassTime", "2500", CVAR_ARCHIVE }, + { &cg_simpleItems, "cg_simpleItems", "0", CVAR_ARCHIVE }, + { &cg_addMarks, "cg_marks", "1", CVAR_ARCHIVE }, + { &cg_lagometer, "cg_lagometer", "1", CVAR_ARCHIVE }, + { &cg_railTrailTime, "cg_railTrailTime", "400", CVAR_ARCHIVE }, + { &cg_gun_x, "cg_gunX", "0", CVAR_CHEAT | CVAR_ARCHIVE }, + { &cg_gun_y, "cg_gunY", "0", CVAR_CHEAT | CVAR_ARCHIVE }, + { &cg_gun_z, "cg_gunZ", "0", CVAR_CHEAT | CVAR_ARCHIVE }, + { &cg_centertime, "cg_centertime", "3", CVAR_CHEAT }, + { &cg_locationtime, "cg_locationtime", "3", CVAR_CHEAT }, + { &cg_runpitch, "cg_runpitch", "0.002", CVAR_ARCHIVE}, + { &cg_runroll, "cg_runroll", "0.005", CVAR_ARCHIVE }, + { &cg_bobup , "cg_bobup", "0.005", CVAR_CHEAT }, + { &cg_bobpitch, "cg_bobpitch", "0.002", CVAR_ARCHIVE }, + { &cg_bobroll, "cg_bobroll", "0.002", CVAR_ARCHIVE }, + { &cg_swingSpeed, "cg_swingSpeed", "0.3", CVAR_CHEAT }, + { &cg_animSpeed, "cg_animspeed", "1", CVAR_CHEAT }, + { &cg_debugAnim, "cg_debuganim", "0", CVAR_CHEAT }, + { &cg_debugPosition, "cg_debugposition", "0", CVAR_CHEAT }, + { &cg_debugEvents, "cg_debugevents", "0", CVAR_CHEAT }, + { &cg_errorDecay, "cg_errordecay", "100", 0 }, + { &cg_nopredict, "cg_nopredict", "0", 0 }, + { &cg_noPlayerAnims, "cg_noplayeranims", "0", CVAR_CHEAT }, + { &cg_showmiss, "cg_showmiss", "0", 0 }, + { &cg_footsteps, "cg_footsteps", "1", CVAR_CHEAT }, + { &cg_tracerChance, "cg_tracerchance", "0.4", CVAR_CHEAT }, + { &cg_tracerWidth, "cg_tracerwidth", "1", CVAR_CHEAT }, + { &cg_tracerLength, "cg_tracerlength", "100", CVAR_CHEAT }, + { &cg_thirdPersonRange, "cg_thirdPersonRange", "40", CVAR_CHEAT }, + { &cg_thirdPersonAngle, "cg_thirdPersonAngle", "0", CVAR_CHEAT }, + { &cg_thirdPerson, "cg_thirdPerson", "0", 0 }, + { &cg_teamChatTime, "cg_teamChatTime", "3000", CVAR_ARCHIVE }, + { &cg_teamChatHeight, "cg_teamChatHeight", "0", CVAR_ARCHIVE }, + { &cg_forceModel, "cg_forceModel", "0", CVAR_ARCHIVE }, + { &cg_predictItems, "cg_predictItems", "1", CVAR_ARCHIVE }, + { &cg_deferPlayers, "cg_deferPlayers", "1", CVAR_ARCHIVE }, + { &cg_drawTeamOverlay, "cg_drawTeamOverlay", "0", CVAR_ARCHIVE }, + { &cg_teamOverlayUserinfo, "teamoverlay", "0", CVAR_ROM | CVAR_USERINFO }, + { &cg_stats, "cg_stats", "0", 0 }, + { &cg_drawFriend, "cg_drawFriend", "1", CVAR_ARCHIVE }, + { &cg_teamChatsOnly, "cg_teamChatsOnly", "0", CVAR_ARCHIVE }, + { &cg_noVoiceChats, "cg_noVoiceChats", "0", CVAR_ARCHIVE }, + { &cg_noVoiceText, "cg_noVoiceText", "0", CVAR_ARCHIVE }, + // the following variables are created in other parts of the system, + // but we also reference them here + { &cg_buildScript, "com_buildScript", "0", 0 }, // force loading of all possible data amd error on failures + { &cg_paused, "cl_paused", "0", CVAR_ROM }, + { &cg_blood, "com_blood", "1", CVAR_ARCHIVE }, + { &cg_synchronousClients, "g_synchronousClients", "0", 0 }, // communicated by systeminfo + + { &cg_cameraOrbit, "cg_cameraOrbit", "0", CVAR_CHEAT}, + { &cg_cameraOrbitDelay, "cg_cameraOrbitDelay", "50", CVAR_ARCHIVE}, + { &cg_timescaleFadeEnd, "cg_timescaleFadeEnd", "1", 0}, + { &cg_timescaleFadeSpeed, "cg_timescaleFadeSpeed", "0", 0}, + { &cg_timescale, "timescale", "1", 0}, + { &cg_scorePlum, "cg_scorePlums", "1", CVAR_USERINFO | CVAR_ARCHIVE}, + { &cg_smoothClients, "cg_smoothClients", "0", CVAR_USERINFO | CVAR_ARCHIVE}, + { &cg_cameraMode, "com_cameraMode", "0", CVAR_CHEAT}, + + { &pmove_fixed, "pmove_fixed", "0", 0}, + { &pmove_msec, "pmove_msec", "8", 0}, + { &cg_noTaunt, "cg_noTaunt", "0", CVAR_ARCHIVE}, + { &cg_noProjectileTrail, "cg_noProjectileTrail", "0", CVAR_ARCHIVE}, + { &cg_smallFont, "ui_smallFont", "0.25", CVAR_ARCHIVE}, + { &cg_bigFont, "ui_bigFont", "0.4", CVAR_ARCHIVE}, + { &cg_trueLightning, "cg_trueLightning", "0.0", CVAR_ARCHIVE}, +// { &cg_pmove_fixed, "cg_pmove_fixed", "0", CVAR_USERINFO | CVAR_ARCHIVE }, + + // su44: MoHAA viewmodel-related cvars + { &vm_offset_max, "vm_offset_max", "8.0", 0}, + { &vm_offset_speed, "vm_offset_speed", "8.0", 0}, + { &vm_sway_front, "vm_sway_front", "0.1", 0}, + { &vm_sway_side, "vm_sway_side", "0.005", 0}, + { &vm_sway_up, "vm_sway_up", "0.003", 0}, + { &vm_offset_air_front, "vm_offset_air_front", "-3.0", 0}, + { &vm_offset_air_side, "vm_offset_air_side", "1.5", 0}, + { &vm_offset_air_up, "vm_offset_air_up", "-6.0", 0}, + { &vm_offset_crouch_front, "vm_offset_crouch_front", "-0.5", 0}, + { &vm_offset_crouch_side, "vm_offset_crouch_side", "2.25", 0}, + { &vm_offset_crouch_up, "vm_offset_crouch_up", "0.2", 0}, + { &vm_offset_rocketcrouch_front, "vm_offset_rocketcrouch_front", "0", 0}, + { &vm_offset_rocketcrouch_side, "vm_offset_rocketcrouch_side", "0", 0}, + { &vm_offset_rocketcrouch_up, "vm_offset_rocketcrouch_up", "0", 0}, + { &vm_offset_shotguncrouch_front, "vm_offset_shotguncrouch_front", "-1", 0}, + { &vm_offset_shotguncrouch_side, "vm_offset_shotguncrouch_side", "-1.1", 0}, + { &vm_offset_shotguncrouch_up, "vm_offset_shotguncrouch_up", "-1.1", 0}, + { &vm_offset_vel_base, "vm_offset_vel_base", "100", 0}, + { &vm_offset_vel_front, "vm_offset_vel_front", "-2.0", 0}, + { &vm_offset_vel_side, "vm_offset_vel_side", "1.5", 0}, + { &vm_offset_vel_up, "vm_offset_vel_up", "-4.0", 0}, + { &vm_offset_upvel, "vm_offset_upvel", "0.0025", 0}, + { &vm_lean_lower, "vm_lean_lower", "0.1", 0}, + { &cg_debugCGMessages, "cg_debugCGMessages", "0", 0}, +}; + +static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); + +/* +================= +CG_RegisterCvars +================= +*/ +void CG_RegisterCvars( void ) { + int i; + cvarTable_t *cv; + cvar_t *sv_running; + + for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) { + *cv->cvar = cgi.Cvar_Get( cv->cvarName, cv->defaultString, cv->cvarFlags ); + } + + sv_running = cgi.Cvar_Get( "sv_running", "", 0 ); + + // see if we are also running the server on this machine + cgs.localServer = sv_running->integer; + + forceModelModificationCount = cg_forceModel->modificationCount; + + cgi.Cvar_Get( "model", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE ); +} + +/* +=================== +CG_ForceModelChange +=================== +*/ +static void CG_ForceModelChange( void ) { + int i; + + for (i=0 ; imodificationCount ) { + drawTeamOverlayModificationCount = cg_drawTeamOverlay->modificationCount; + + if ( cg_drawTeamOverlay->integer > 0 ) { + cgi.Cvar_Set( "teamoverlay", "1" ); + } else { + cgi.Cvar_Set( "teamoverlay", "0" ); + } + } + + // if force model changed + if ( forceModelModificationCount != cg_forceModel->modificationCount ) { + forceModelModificationCount = cg_forceModel->modificationCount; + CG_ForceModelChange(); + } +} + +int CG_CrosshairPlayer( void ) { + if(cg.snap == 0) + return -1; + return cg.snap->ps.stats[STAT_INFOCLIENT]; +} + +int CG_LastAttacker( void ) { + if ( !cg.attackerTime ) { + return -1; + } + return cg.snap->ps.stats[STAT_ATTACKERCLIENT]; +} + +void QDECL CG_Printf( const char *msg, ... ) { + va_list argptr; + char text[1024]; + + va_start (argptr, msg); + vsprintf (text, msg, argptr); + va_end (argptr); + + cgi.Printf( text ); +} + +void QDECL CG_Error( const char *msg, ... ) { + va_list argptr; + char text[1024]; + + va_start (argptr, msg); + vsprintf (text, msg, argptr); + va_end (argptr); + + cgi.Error( ERR_DROP, text ); +} + +void QDECL Com_Error( int level, const char *error, ... ) { + va_list argptr; + char text[1024]; + + va_start (argptr, error); + vsprintf (text, error, argptr); + va_end (argptr); + + CG_Error( "%s", text); +} + +void QDECL Com_Printf( const char *msg, ... ) { + va_list argptr; + char text[1024]; + + va_start (argptr, msg); + vsprintf (text, msg, argptr); + va_end (argptr); + + CG_Printf ("%s", text); +} + +/* +================ +CG_Argv +================ +*/ +const char *CG_Argv( int arg ) { + return cgi.Argv( arg ); +} + + +//======================================================================== + +/* +================= +CG_RegisterSounds + +called during a precache command +================= +*/ +static void CG_RegisterSounds( void ) { + int i; + const char *soundName; + char buffer[MAX_STRING_CHARS]; + + for ( i = 1 ; i < MAX_SOUNDS ; i++ ) { + soundName = CG_ConfigString( CS_SOUNDS+i ); + if ( !soundName[0] ) { + break; + } + if ( soundName[0] == '*' ) { + continue; // custom sound + } + Q_strncpyz( buffer, soundName, sizeof(buffer) ); + if (buffer[strlen( buffer )-1] == '0' || buffer[strlen( buffer )-1] == '1') + buffer[strlen( buffer )-1] = 0; + cgs.gameSounds[i] = cgi.S_RegisterSound( buffer, qfalse ); + } +} + + +//=================================================================================== + + +/* +================= +CG_RegisterGraphics + +This function may execute for a couple of minutes with a slow disk. +================= +*/ +static void CG_RegisterGraphics( void ) { + int i; + const char *str; + + // clear any references to old media + memset( &cg.refdef, 0, sizeof( cg.refdef ) ); + cgi.R_ClearScene(); + + CG_LoadingString( cgs.mapname ); + + cgi.R_LoadWorldMap( cgs.mapname ); + + // precache status bar pics + CG_LoadingString( "game media" ); + + + cgs.media.crosshairShader[0] = cgi.R_RegisterShader( "gfx/2d/BLANK" ); + cgs.media.crosshairShader[1] = cgi.R_RegisterShader( "textures/hud/crosshair" ); + cgs.media.crosshairShader[2] = cgi.R_RegisterShader( "gfx/2d/crosshair" ); + + cgs.media.backTileShader = cgi.R_RegisterShader( "gfx/2d/backtile" ); + + cgs.media.shadowMarkShader = cgi.R_RegisterShader( "markShadow" ); + cgs.media.wakeMarkShader = cgi.R_RegisterShader( "wake" ); + + // su44: MoHAA zoom overlays + cgs.media.zoomOverlayShader = cgi.R_RegisterShader("textures/hud/zoomoverlay"); + cgs.media.kar98TopOverlayShader = cgi.R_RegisterShader("textures/hud/kartop.tga"); + cgs.media.kar98BottomOverlayShader = cgi.R_RegisterShader("textures/hud/karbottom.tga"); + cgs.media.binocularsOverlayShader = cgi.R_RegisterShader("textures/hud/binocularsoverlay"); + + // register the inline models + cgs.numInlineModels = cgi.CM_NumInlineModels(); + for ( i = 1 ; i < cgs.numInlineModels ; i++ ) { + char name[10]; + vec3_t mins, maxs; + int j; + + Com_sprintf( name, sizeof(name), "*%i", i ); + cgs.inlineDrawModel[i] = cgi.R_RegisterModel( name ); + cgi.R_ModelBounds( cgs.inlineDrawModel[i], mins, maxs ); + for ( j = 0 ; j < 3 ; j++ ) { + cgs.inlineModelMidpoints[i][j] = mins[j] + 0.5 * ( maxs[j] - mins[j] ); + } + } + + // register all the server specified models + for (i=1 ; i= MAX_CONFIGSTRINGS ) { + CG_Error( "CG_ConfigString: bad index: %i", index ); + } + return cgs.gameState.stringData + cgs.gameState.stringOffsets[ index ]; +} + +//================================================================== + +/* +====================== +CG_StartMusic + +====================== +*/ +void CG_StartMusic( void ) { + + cgi.S_StartBackgroundTrack( CG_LoadMusic(CG_ConfigString(CS_MUSIC)),"" ); +} + +/* +================= +CG_Init + +Called after every level change or subsystem restart +Will perform callbacks to make the loading info screen update. +================= +*/ +void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum, int randomSeed ) { + const char *s; + + // clear everything + memset( &cgs, 0, sizeof( cgs ) ); + memset( &cg, 0, sizeof( cg ) ); + memset( cg_entities, 0, sizeof(cg_entities) ); + + srand( randomSeed ); + + cg.clientNum = clientNum; + + cgs.processedSnapshotNum = serverMessageNum; + cgs.serverCommandSequence = serverCommandSequence; + + cgi.R_RegisterFont( "facfont-20", 0, &cgs.media.facfont ); + cgi.R_RegisterFont( "verdana-14", 0, &cgs.media.verdana ); + + // load a few needed things before we do any screen updates +// cgs.media.charsetShader = cgi.R_RegisterShader( "gfx/2d/bigchars" ); + cgs.media.whiteShader = cgi.R_RegisterShader( "*white" ); +// cgs.media.charsetProp = cgi.R_RegisterShaderNoMip( "menu/art/font1_prop.tga" ); +// cgs.media.charsetPropGlow = cgi.R_RegisterShaderNoMip( "menu/art/font1_prop_glo.tga" ); +// cgs.media.charsetPropB = cgi.R_RegisterShaderNoMip( "menu/art/font2_prop.tga" ); + cgs.media.blackShader = cgi.R_RegisterShaderNoMip( "textures/mohmenu/black.tga" ); + + CG_RegisterCvars(); + + CG_InitConsoleCommands(); + + // get the rendering configuration from the client system + cgi.GetGlconfig( &cgs.glconfig ); + cgs.screenXScale = cgs.glconfig.vidWidth / 640.0; + cgs.screenYScale = cgs.glconfig.vidHeight / 480.0; + + // get the gamestate from the client system + cgi.GetGameState( &cgs.gameState ); + + // check version + s = CG_ConfigString( CS_GAME_VERSION ); + if ( strcmp( s, GAME_VERSION ) ) { + CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s ); + } + + s = CG_ConfigString( CS_LEVEL_START_TIME ); + cgs.levelStartTime = atoi( s ); + + CG_ParseServerinfo(); + + // load the new map + CG_LoadingString( "collision map" ); + + cgi.CM_LoadMap( cgs.mapname ); + + CG_LoadingString( "sounds" ); + + CG_RegisterSounds(); + CG_LoadUbersound(); + + CG_LoadingString( "graphics" ); + + CG_RegisterGraphics(); + + CG_LoadingString( "clients" ); + + CG_RegisterClients(); // if low on memory, some clients will be deferred + + CG_InitLocalEntities(); + + CG_InitMarkPolys(); + + CG_InitEventSystem(); + + CG_InitBeams(); + + CG_InitRainEffect(); + + // remove the last loading update + cg.infoScreenText[0] = 0; + + // Make sure we have update values (scores) + CG_SetConfigValues(); + + CG_StartMusic(); + + CG_LoadingString( "" ); + + cgi.S_ClearLoopingSounds( qtrue ); +} + +/* +================= +CG_Shutdown + +Called before every level change or subsystem restart +================= +*/ +void CG_Shutdown( void ) { + // some mods may need to do cleanup work here, + // like closing files or archiving session data +} + +/* +================ +GetCGameAPI + +Gets client game imports and returns client game exports +================ +*/ +clientGameExport_t* GetCGameAPI( clientGameImport_t *import ) +{ + cgi = *import; + + cge.CG_Init = CG_Init; + cge.CG_Shutdown = CG_Shutdown; + + cge.CG_ConsoleCommand = CG_ConsoleCommand; + + cge.CG_DrawActiveFrame = CG_DrawActiveFrame; + cge.CG_Draw2D = CG_Draw2D; + + cge.CG_CrosshairPlayer = CG_CrosshairPlayer; + cge.CG_LastAttacker = CG_LastAttacker; + + cge.CG_KeyEvent = CG_KeyEvent; + cge.CG_MouseEvent = CG_MouseEvent; + cge.CG_EventHandling = CG_EventHandling; + + cge.CG_CenterPrint = CG_CenterPrint; + cge.CG_LocationPrint = CG_LocationPrint; + + cge.CG_ParseCGMessage = CG_ParseCGMessage; + + return &cge; +} + +/* +================== +CG_EventHandling +================== + type 0 - no event handling + 1 - team menu + 2 - hud editor + +*/ + +void CG_EventHandling(int type) { + +} + +void CG_KeyEvent(int key, qboolean down) { + +} + +void CG_MouseEvent(int x, int y) { + +} + + diff --git a/code/cgame/cg_marks.c b/code/cgame/cg_marks.c new file mode 100644 index 00000000..d957de37 --- /dev/null +++ b/code/cgame/cg_marks.c @@ -0,0 +1,2049 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_marks.c -- wall marks + +#include "cg_local.h" + +/* +=================================================================== + +MARK POLYS + +=================================================================== +*/ + + +markPoly_t cg_activeMarkPolys; // double linked list +markPoly_t *cg_freeMarkPolys; // single linked list +markPoly_t cg_markPolys[MAX_MARK_POLYS]; +static int markTotal; + +/* +=================== +CG_InitMarkPolys + +This is called at startup and for tournement restarts +=================== +*/ +void CG_InitMarkPolys( void ) { + int i; + + memset( cg_markPolys, 0, sizeof(cg_markPolys) ); + + cg_activeMarkPolys.nextMark = &cg_activeMarkPolys; + cg_activeMarkPolys.prevMark = &cg_activeMarkPolys; + cg_freeMarkPolys = cg_markPolys; + for ( i = 0 ; i < MAX_MARK_POLYS - 1 ; i++ ) { + cg_markPolys[i].nextMark = &cg_markPolys[i+1]; + } +} + + +/* +================== +CG_FreeMarkPoly +================== +*/ +void CG_FreeMarkPoly( markPoly_t *le ) { + if ( !le->prevMark ) { + CG_Error( "CG_FreeLocalEntity: not active" ); + } + + // remove from the doubly linked active list + le->prevMark->nextMark = le->nextMark; + le->nextMark->prevMark = le->prevMark; + + // the free list is only singly linked + le->nextMark = cg_freeMarkPolys; + cg_freeMarkPolys = le; +} + +/* +=================== +CG_AllocMark + +Will allways succeed, even if it requires freeing an old active mark +=================== +*/ +markPoly_t *CG_AllocMark( void ) { + markPoly_t *le; + int time; + + if ( !cg_freeMarkPolys ) { + // no free entities, so free the one at the end of the chain + // remove the oldest active entity + time = cg_activeMarkPolys.prevMark->time; + while (cg_activeMarkPolys.prevMark && time == cg_activeMarkPolys.prevMark->time) { + CG_FreeMarkPoly( cg_activeMarkPolys.prevMark ); + } + } + + le = cg_freeMarkPolys; + cg_freeMarkPolys = cg_freeMarkPolys->nextMark; + + memset( le, 0, sizeof( *le ) ); + + // link into the active list + le->nextMark = cg_activeMarkPolys.nextMark; + le->prevMark = &cg_activeMarkPolys; + cg_activeMarkPolys.nextMark->prevMark = le; + cg_activeMarkPolys.nextMark = le; + return le; +} + + + +/* +================= +CG_ImpactMark + +origin should be a point within a unit of the plane +dir should be the plane normal + +temporary marks will not be stored or randomly oriented, but immediately +passed to the renderer. +================= +*/ +#define MAX_MARK_FRAGMENTS 128 +#define MAX_MARK_POINTS 384 + +void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, + float orientation, float red, float green, float blue, float alpha, + qboolean alphaFade, float radius, qboolean temporary ) { + vec3_t axis[3]; + float texCoordScale; + vec3_t originalPoints[4]; + byte colors[4]; + int i, j; + int numFragments; + markFragment_t markFragments[MAX_MARK_FRAGMENTS], *mf; + vec3_t markPoints[MAX_MARK_POINTS]; + vec3_t projection; + + if ( !cg_addMarks->integer ) { + return; + } + + if ( radius <= 0 ) { + CG_Error( "CG_ImpactMark called with <= 0 radius" ); + } + + //if ( markTotal >= MAX_MARK_POLYS ) { + // return; + //} + + // create the texture axis + VectorNormalize2( dir, axis[0] ); + PerpendicularVector( axis[1], axis[0] ); + RotatePointAroundVector( axis[2], axis[0], axis[1], orientation ); + CrossProduct( axis[0], axis[2], axis[1] ); + + texCoordScale = 0.5 * 1.0 / radius; + + // create the full polygon + for ( i = 0 ; i < 3 ; i++ ) { + originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i]; + originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i]; + originalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i]; + originalPoints[3][i] = origin[i] - radius * axis[1][i] + radius * axis[2][i]; + } + + // get the fragments + VectorScale( dir, -20, projection ); + numFragments = cgi.CM_MarkFragments( 4, (void *)originalPoints, + projection, MAX_MARK_POINTS, markPoints[0], + MAX_MARK_FRAGMENTS, markFragments ); + + colors[0] = red * 255; + colors[1] = green * 255; + colors[2] = blue * 255; + colors[3] = alpha * 255; + + for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) { + polyVert_t *v; + polyVert_t verts[MAX_VERTS_ON_POLY]; + markPoly_t *mark; + + // we have an upper limit on the complexity of polygons + // that we store persistantly + if ( mf->numPoints > MAX_VERTS_ON_POLY ) { + mf->numPoints = MAX_VERTS_ON_POLY; + } + for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) { + vec3_t delta; + + VectorCopy( markPoints[mf->firstPoint + j], v->xyz ); + + VectorSubtract( v->xyz, origin, delta ); + v->st[0] = 0.5 + DotProduct( delta, axis[1] ) * texCoordScale; + v->st[1] = 0.5 + DotProduct( delta, axis[2] ) * texCoordScale; + *(int *)v->modulate = *(int *)colors; + } + + // if it is a temporary (shadow) mark, add it immediately and forget about it + if ( temporary ) { + cgi.R_AddPolyToScene( markShader, mf->numPoints, verts ); + continue; + } + + // otherwise save it persistantly + mark = CG_AllocMark(); + mark->time = cg.time; + mark->alphaFade = alphaFade; + mark->markShader = markShader; + mark->poly.numVerts = mf->numPoints; + mark->color[0] = red; + mark->color[1] = green; + mark->color[2] = blue; + mark->color[3] = alpha; + memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[0] ) ); + markTotal++; + } +} + + +/* +=============== +CG_AddMarks +=============== +*/ +#define MARK_TOTAL_TIME 10000 +#define MARK_FADE_TIME 1000 + +void CG_AddMarks( void ) { + int j; + markPoly_t *mp, *next; + int t; + int fade; + + if ( !cg_addMarks->integer ) { + return; + } + + mp = cg_activeMarkPolys.nextMark; + for ( ; mp != &cg_activeMarkPolys ; mp = next ) { + // grab next now, so if the local entity is freed we + // still have it + next = mp->nextMark; + + // see if it is time to completely remove it + if ( cg.time > mp->time + MARK_TOTAL_TIME ) { + CG_FreeMarkPoly( mp ); + continue; + } + + // fade all marks out with time + t = mp->time + MARK_TOTAL_TIME - cg.time; + if ( t < MARK_FADE_TIME ) { + fade = 255 * t / MARK_FADE_TIME; + if ( mp->alphaFade ) { + for ( j = 0 ; j < mp->poly.numVerts ; j++ ) { + mp->verts[j].modulate[3] = fade; + } + } else { + for ( j = 0 ; j < mp->poly.numVerts ; j++ ) { + mp->verts[j].modulate[0] = mp->color[0] * fade; + mp->verts[j].modulate[1] = mp->color[1] * fade; + mp->verts[j].modulate[2] = mp->color[2] * fade; + } + } + } + + + cgi.R_AddPolyToScene( mp->markShader, mp->poly.numVerts, mp->verts ); + } +} + +// cg_particles.c + +#define BLOODRED 2 +#define EMISIVEFADE 3 +#define GREY75 4 + +typedef struct particle_s +{ + struct particle_s *next; + + float time; + float endtime; + + vec3_t org; + vec3_t vel; + vec3_t accel; + int color; + float colorvel; + float alpha; + float alphavel; + int type; + qhandle_t pshader; + + float height; + float width; + + float endheight; + float endwidth; + + float start; + float end; + + float startfade; + qboolean rotate; + int snum; + + qboolean link; + + // Ridah + int shaderAnim; + int roll; + + int accumroll; + +} cparticle_t; + +typedef enum +{ + P_NONE, + P_WEATHER, + P_FLAT, + P_SMOKE, + P_ROTATE, + P_WEATHER_TURBULENT, + P_ANIM, // Ridah + P_BAT, + P_BLEED, + P_FLAT_SCALEUP, + P_FLAT_SCALEUP_FADE, + P_WEATHER_FLURRY, + P_SMOKE_IMPACT, + P_BUBBLE, + P_BUBBLE_TURBULENT, + P_SPRITE +} particle_type_t; + +#define MAX_SHADER_ANIMS 32 +#define MAX_SHADER_ANIM_FRAMES 64 + +static char *shaderAnimNames[MAX_SHADER_ANIMS] = { + "explode1", + NULL +}; +static qhandle_t shaderAnims[MAX_SHADER_ANIMS][MAX_SHADER_ANIM_FRAMES]; +static int shaderAnimCounts[MAX_SHADER_ANIMS] = { + 23 +}; +static float shaderAnimSTRatio[MAX_SHADER_ANIMS] = { + 1.0f +}; +static int numShaderAnims; +// done. + +#define PARTICLE_GRAVITY 40 +#define MAX_PARTICLES 1024 + +cparticle_t *active_particles, *free_particles; +cparticle_t particles[MAX_PARTICLES]; +int cl_numparticles = MAX_PARTICLES; + +qboolean initparticles = qfalse; +vec3_t pvforward, pvright, pvup; +vec3_t rforward, rright, rup; + +float oldtime; + +/* +=============== +CL_ClearParticles +=============== +*/ +void CG_ClearParticles (void) +{ + int i; + + memset( particles, 0, sizeof(particles) ); + + free_particles = &particles[0]; + active_particles = NULL; + + for (i=0 ;itype == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY + || p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) + {// create a front facing polygon + + if (p->type != P_WEATHER_FLURRY) + { + if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) + { + if (org[2] > p->end) + { + p->time = cg.time; + VectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground + + p->org[2] = ( p->start + crandom () * 4 ); + + + if (p->type == P_BUBBLE_TURBULENT) + { + p->vel[0] = crandom() * 4; + p->vel[1] = crandom() * 4; + } + + } + } + else + { + if (org[2] < p->end) + { + p->time = cg.time; + VectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground + + while (p->org[2] < p->end) + { + p->org[2] += (p->start - p->end); + } + + + if (p->type == P_WEATHER_TURBULENT) + { + p->vel[0] = crandom() * 16; + p->vel[1] = crandom() * 16; + } + + } + } + + + // Rafael snow pvs check + if (!p->link) + return; + + p->alpha = 1; + } + + // Ridah, had to do this or MAX_POLYS is being exceeded in village1.bsp + if (Distance( cg.snap->ps.origin, org ) > 1024) { + return; + } + // done. + + if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) + { + VectorMA (org, -p->height, pvup, point); + VectorMA (point, -p->width, pvright, point); + VectorCopy (point, verts[0].xyz); + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255; + verts[0].modulate[1] = 255; + verts[0].modulate[2] = 255; + verts[0].modulate[3] = 255 * p->alpha; + + VectorMA (org, -p->height, pvup, point); + VectorMA (point, p->width, pvright, point); + VectorCopy (point, verts[1].xyz); + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255; + verts[1].modulate[1] = 255; + verts[1].modulate[2] = 255; + verts[1].modulate[3] = 255 * p->alpha; + + VectorMA (org, p->height, pvup, point); + VectorMA (point, p->width, pvright, point); + VectorCopy (point, verts[2].xyz); + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255; + verts[2].modulate[1] = 255; + verts[2].modulate[2] = 255; + verts[2].modulate[3] = 255 * p->alpha; + + VectorMA (org, p->height, pvup, point); + VectorMA (point, -p->width, pvright, point); + VectorCopy (point, verts[3].xyz); + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255; + verts[3].modulate[1] = 255; + verts[3].modulate[2] = 255; + verts[3].modulate[3] = 255 * p->alpha; + } + else + { + VectorMA (org, -p->height, pvup, point); + VectorMA (point, -p->width, pvright, point); + VectorCopy( point, TRIverts[0].xyz ); + TRIverts[0].st[0] = 1; + TRIverts[0].st[1] = 0; + TRIverts[0].modulate[0] = 255; + TRIverts[0].modulate[1] = 255; + TRIverts[0].modulate[2] = 255; + TRIverts[0].modulate[3] = 255 * p->alpha; + + VectorMA (org, p->height, pvup, point); + VectorMA (point, -p->width, pvright, point); + VectorCopy (point, TRIverts[1].xyz); + TRIverts[1].st[0] = 0; + TRIverts[1].st[1] = 0; + TRIverts[1].modulate[0] = 255; + TRIverts[1].modulate[1] = 255; + TRIverts[1].modulate[2] = 255; + TRIverts[1].modulate[3] = 255 * p->alpha; + + VectorMA (org, p->height, pvup, point); + VectorMA (point, p->width, pvright, point); + VectorCopy (point, TRIverts[2].xyz); + TRIverts[2].st[0] = 0; + TRIverts[2].st[1] = 1; + TRIverts[2].modulate[0] = 255; + TRIverts[2].modulate[1] = 255; + TRIverts[2].modulate[2] = 255; + TRIverts[2].modulate[3] = 255 * p->alpha; + } + + } + else if (p->type == P_SPRITE) + { + vec3_t rr, ru; + vec3_t rotate_ang; + + VectorSet (color, 1.0, 1.0, 0.5); + time = cg.time - p->time; + time2 = p->endtime - p->time; + ratio = time / time2; + + width = p->width + ( ratio * ( p->endwidth - p->width) ); + height = p->height + ( ratio * ( p->endheight - p->height) ); + + if (p->roll) { + vectoangles( cg.refdef.viewaxis[0], rotate_ang ); + rotate_ang[ROLL] += p->roll; + AngleVectors ( rotate_ang, NULL, rr, ru); + } + + if (p->roll) { + VectorMA (org, -height, ru, point); + VectorMA (point, -width, rr, point); + } else { + VectorMA (org, -height, pvup, point); + VectorMA (point, -width, pvright, point); + } + VectorCopy (point, verts[0].xyz); + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255; + verts[0].modulate[1] = 255; + verts[0].modulate[2] = 255; + verts[0].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, 2*height, ru, point); + } else { + VectorMA (point, 2*height, pvup, point); + } + VectorCopy (point, verts[1].xyz); + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255; + verts[1].modulate[1] = 255; + verts[1].modulate[2] = 255; + verts[1].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, 2*width, rr, point); + } else { + VectorMA (point, 2*width, pvright, point); + } + VectorCopy (point, verts[2].xyz); + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255; + verts[2].modulate[1] = 255; + verts[2].modulate[2] = 255; + verts[2].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, -2*height, ru, point); + } else { + VectorMA (point, -2*height, pvup, point); + } + VectorCopy (point, verts[3].xyz); + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255; + verts[3].modulate[1] = 255; + verts[3].modulate[2] = 255; + verts[3].modulate[3] = 255; + } + else if (p->type == P_SMOKE || p->type == P_SMOKE_IMPACT) + {// create a front rotating facing polygon + + if ( p->type == P_SMOKE_IMPACT && Distance( cg.snap->ps.origin, org ) > 1024) { + return; + } + + if (p->color == BLOODRED) + VectorSet (color, 0.22f, 0.0f, 0.0f); + else if (p->color == GREY75) + { + float len; + float greyit; + float val; + len = Distance (cg.snap->ps.origin, org); + if (!len) + len = 1; + + val = 4096/len; + greyit = 0.25 * val; + if (greyit > 0.5) + greyit = 0.5; + + VectorSet (color, greyit, greyit, greyit); + } + else + VectorSet (color, 1.0, 1.0, 1.0); + + time = cg.time - p->time; + time2 = p->endtime - p->time; + ratio = time / time2; + + if (cg.time > p->startfade) + { + invratio = 1 - ( (cg.time - p->startfade) / (p->endtime - p->startfade) ); + + if (p->color == EMISIVEFADE) + { + float fval; + fval = (invratio * invratio); + if (fval < 0) + fval = 0; + VectorSet (color, fval , fval , fval ); + } + invratio *= p->alpha; + } + else + invratio = 1 * p->alpha; + + if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) + invratio = 1; + + if (invratio > 1) + invratio = 1; + + width = p->width + ( ratio * ( p->endwidth - p->width) ); + height = p->height + ( ratio * ( p->endheight - p->height) ); + + if (p->type != P_SMOKE_IMPACT) + { + vec3_t temp; + + vectoangles (rforward, temp); + p->accumroll += p->roll; + temp[ROLL] += p->accumroll * 0.1; + AngleVectors ( temp, NULL, rright2, rup2); + } + else + { + VectorCopy (rright, rright2); + VectorCopy (rup, rup2); + } + + if (p->rotate) + { + VectorMA (org, -height, rup2, point); + VectorMA (point, -width, rright2, point); + } + else + { + VectorMA (org, -p->height, pvup, point); + VectorMA (point, -p->width, pvright, point); + } + VectorCopy (point, verts[0].xyz); + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255 * color[0]; + verts[0].modulate[1] = 255 * color[1]; + verts[0].modulate[2] = 255 * color[2]; + verts[0].modulate[3] = 255 * invratio; + + if (p->rotate) + { + VectorMA (org, -height, rup2, point); + VectorMA (point, width, rright2, point); + } + else + { + VectorMA (org, -p->height, pvup, point); + VectorMA (point, p->width, pvright, point); + } + VectorCopy (point, verts[1].xyz); + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255 * color[0]; + verts[1].modulate[1] = 255 * color[1]; + verts[1].modulate[2] = 255 * color[2]; + verts[1].modulate[3] = 255 * invratio; + + if (p->rotate) + { + VectorMA (org, height, rup2, point); + VectorMA (point, width, rright2, point); + } + else + { + VectorMA (org, p->height, pvup, point); + VectorMA (point, p->width, pvright, point); + } + VectorCopy (point, verts[2].xyz); + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255 * color[0]; + verts[2].modulate[1] = 255 * color[1]; + verts[2].modulate[2] = 255 * color[2]; + verts[2].modulate[3] = 255 * invratio; + + if (p->rotate) + { + VectorMA (org, height, rup2, point); + VectorMA (point, -width, rright2, point); + } + else + { + VectorMA (org, p->height, pvup, point); + VectorMA (point, -p->width, pvright, point); + } + VectorCopy (point, verts[3].xyz); + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255 * color[0]; + verts[3].modulate[1] = 255 * color[1]; + verts[3].modulate[2] = 255 * color[2]; + verts[3].modulate[3] = 255 * invratio; + + } + else if (p->type == P_BLEED) + { + vec3_t rr, ru; + vec3_t rotate_ang; + float alpha; + + alpha = p->alpha; + + if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) + alpha = 1; + + if (p->roll) + { + vectoangles( cg.refdef.viewaxis[0], rotate_ang ); + rotate_ang[ROLL] += p->roll; + AngleVectors ( rotate_ang, NULL, rr, ru); + } + else + { + VectorCopy (pvup, ru); + VectorCopy (pvright, rr); + } + + VectorMA (org, -p->height, ru, point); + VectorMA (point, -p->width, rr, point); + VectorCopy (point, verts[0].xyz); + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 111; + verts[0].modulate[1] = 19; + verts[0].modulate[2] = 9; + verts[0].modulate[3] = 255 * alpha; + + VectorMA (org, -p->height, ru, point); + VectorMA (point, p->width, rr, point); + VectorCopy (point, verts[1].xyz); + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 111; + verts[1].modulate[1] = 19; + verts[1].modulate[2] = 9; + verts[1].modulate[3] = 255 * alpha; + + VectorMA (org, p->height, ru, point); + VectorMA (point, p->width, rr, point); + VectorCopy (point, verts[2].xyz); + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 111; + verts[2].modulate[1] = 19; + verts[2].modulate[2] = 9; + verts[2].modulate[3] = 255 * alpha; + + VectorMA (org, p->height, ru, point); + VectorMA (point, -p->width, rr, point); + VectorCopy (point, verts[3].xyz); + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 111; + verts[3].modulate[1] = 19; + verts[3].modulate[2] = 9; + verts[3].modulate[3] = 255 * alpha; + + } + else if (p->type == P_FLAT_SCALEUP) + { + float width, height; + float sinR, cosR; + + if (p->color == BLOODRED) + VectorSet (color, 1, 1, 1); + else + VectorSet (color, 0.5, 0.5, 0.5); + + time = cg.time - p->time; + time2 = p->endtime - p->time; + ratio = time / time2; + + width = p->width + ( ratio * ( p->endwidth - p->width) ); + height = p->height + ( ratio * ( p->endheight - p->height) ); + + if (width > p->endwidth) + width = p->endwidth; + + if (height > p->endheight) + height = p->endheight; + + sinR = height * sin(DEG2RAD(p->roll)) * sqrt(2); + cosR = width * cos(DEG2RAD(p->roll)) * sqrt(2); + + VectorCopy (org, verts[0].xyz); + verts[0].xyz[0] -= sinR; + verts[0].xyz[1] -= cosR; + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255 * color[0]; + verts[0].modulate[1] = 255 * color[1]; + verts[0].modulate[2] = 255 * color[2]; + verts[0].modulate[3] = 255; + + VectorCopy (org, verts[1].xyz); + verts[1].xyz[0] -= cosR; + verts[1].xyz[1] += sinR; + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255 * color[0]; + verts[1].modulate[1] = 255 * color[1]; + verts[1].modulate[2] = 255 * color[2]; + verts[1].modulate[3] = 255; + + VectorCopy (org, verts[2].xyz); + verts[2].xyz[0] += sinR; + verts[2].xyz[1] += cosR; + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255 * color[0]; + verts[2].modulate[1] = 255 * color[1]; + verts[2].modulate[2] = 255 * color[2]; + verts[2].modulate[3] = 255; + + VectorCopy (org, verts[3].xyz); + verts[3].xyz[0] += cosR; + verts[3].xyz[1] -= sinR; + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255 * color[0]; + verts[3].modulate[1] = 255 * color[1]; + verts[3].modulate[2] = 255 * color[2]; + verts[3].modulate[3] = 255; + } + else if (p->type == P_FLAT) + { + + VectorCopy (org, verts[0].xyz); + verts[0].xyz[0] -= p->height; + verts[0].xyz[1] -= p->width; + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255; + verts[0].modulate[1] = 255; + verts[0].modulate[2] = 255; + verts[0].modulate[3] = 255; + + VectorCopy (org, verts[1].xyz); + verts[1].xyz[0] -= p->height; + verts[1].xyz[1] += p->width; + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255; + verts[1].modulate[1] = 255; + verts[1].modulate[2] = 255; + verts[1].modulate[3] = 255; + + VectorCopy (org, verts[2].xyz); + verts[2].xyz[0] += p->height; + verts[2].xyz[1] += p->width; + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255; + verts[2].modulate[1] = 255; + verts[2].modulate[2] = 255; + verts[2].modulate[3] = 255; + + VectorCopy (org, verts[3].xyz); + verts[3].xyz[0] += p->height; + verts[3].xyz[1] -= p->width; + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255; + verts[3].modulate[1] = 255; + verts[3].modulate[2] = 255; + verts[3].modulate[3] = 255; + + } + // Ridah + else if (p->type == P_ANIM) { + vec3_t rr, ru; + vec3_t rotate_ang; + int i, j; + + time = cg.time - p->time; + time2 = p->endtime - p->time; + ratio = time / time2; + if (ratio >= 1.0f) { + ratio = 0.9999f; + } + + width = p->width + ( ratio * ( p->endwidth - p->width) ); + height = p->height + ( ratio * ( p->endheight - p->height) ); + + // if we are "inside" this sprite, don't draw + if (Distance( cg.snap->ps.origin, org ) < width/1.5) { + return; + } + + i = p->shaderAnim; + j = (int)floor(ratio * shaderAnimCounts[p->shaderAnim]); + p->pshader = shaderAnims[i][j]; + + if (p->roll) { + vectoangles( cg.refdef.viewaxis[0], rotate_ang ); + rotate_ang[ROLL] += p->roll; + AngleVectors ( rotate_ang, NULL, rr, ru); + } + + if (p->roll) { + VectorMA (org, -height, ru, point); + VectorMA (point, -width, rr, point); + } else { + VectorMA (org, -height, pvup, point); + VectorMA (point, -width, pvright, point); + } + VectorCopy (point, verts[0].xyz); + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255; + verts[0].modulate[1] = 255; + verts[0].modulate[2] = 255; + verts[0].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, 2*height, ru, point); + } else { + VectorMA (point, 2*height, pvup, point); + } + VectorCopy (point, verts[1].xyz); + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255; + verts[1].modulate[1] = 255; + verts[1].modulate[2] = 255; + verts[1].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, 2*width, rr, point); + } else { + VectorMA (point, 2*width, pvright, point); + } + VectorCopy (point, verts[2].xyz); + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255; + verts[2].modulate[1] = 255; + verts[2].modulate[2] = 255; + verts[2].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, -2*height, ru, point); + } else { + VectorMA (point, -2*height, pvup, point); + } + VectorCopy (point, verts[3].xyz); + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255; + verts[3].modulate[1] = 255; + verts[3].modulate[2] = 255; + verts[3].modulate[3] = 255; + } + // done. + + if (!p->pshader) { +// (SA) temp commented out for DM +// CG_Printf ("CG_AddParticleToScene type %d p->pshader == ZERO\n", p->type); + return; + } + + if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY) + cgi.R_AddPolyToScene( p->pshader, 3, TRIverts ); + else + cgi.R_AddPolyToScene( p->pshader, 4, verts ); + +} + +// Ridah, made this static so it doesn't interfere with other files +static float roll = 0.0; + +/* +=============== +CG_AddParticles +=============== +*/ +void CG_AddParticles (void) +{ + cparticle_t *p, *next; + float alpha; + float time, time2; + vec3_t org; + int color; + cparticle_t *active, *tail; + int type; + vec3_t rotate_ang; + + if (!initparticles) + CG_ClearParticles (); + + VectorCopy( cg.refdef.viewaxis[0], pvforward ); + VectorCopy( cg.refdef.viewaxis[1], pvright ); + VectorCopy( cg.refdef.viewaxis[2], pvup ); + + vectoangles( cg.refdef.viewaxis[0], rotate_ang ); + roll += ((cg.time - oldtime) * 0.1) ; + rotate_ang[ROLL] += (roll*0.9); + AngleVectors ( rotate_ang, rforward, rright, rup); + + oldtime = cg.time; + + active = NULL; + tail = NULL; + + for (p=active_particles ; p ; p=next) + { + + next = p->next; + + time = (cg.time - p->time)*0.001; + + alpha = p->alpha + time*p->alphavel; + if (alpha <= 0) + { // faded out + p->next = free_particles; + free_particles = p; + p->type = 0; + p->color = 0; + p->alpha = 0; + continue; + } + + if (p->type == P_SMOKE || p->type == P_ANIM || p->type == P_BLEED || p->type == P_SMOKE_IMPACT) + { + if (cg.time > p->endtime) + { + p->next = free_particles; + free_particles = p; + p->type = 0; + p->color = 0; + p->alpha = 0; + + continue; + } + + } + + if (p->type == P_WEATHER_FLURRY) + { + if (cg.time > p->endtime) + { + p->next = free_particles; + free_particles = p; + p->type = 0; + p->color = 0; + p->alpha = 0; + + continue; + } + } + + + if (p->type == P_FLAT_SCALEUP_FADE) + { + if (cg.time > p->endtime) + { + p->next = free_particles; + free_particles = p; + p->type = 0; + p->color = 0; + p->alpha = 0; + continue; + } + + } + + if ((p->type == P_BAT || p->type == P_SPRITE) && p->endtime < 0) { + // temporary sprite + CG_AddParticleToScene (p, p->org, alpha); + p->next = free_particles; + free_particles = p; + p->type = 0; + p->color = 0; + p->alpha = 0; + continue; + } + + p->next = NULL; + if (!tail) + active = tail = p; + else + { + tail->next = p; + tail = p; + } + + if (alpha > 1.0) + alpha = 1; + + color = p->color; + + time2 = time*time; + + org[0] = p->org[0] + p->vel[0]*time + p->accel[0]*time2; + org[1] = p->org[1] + p->vel[1]*time + p->accel[1]*time2; + org[2] = p->org[2] + p->vel[2]*time + p->accel[2]*time2; + + type = p->type; + + CG_AddParticleToScene (p, org, alpha); + } + + active_particles = active; +} + +/* +====================== +CG_AddParticles +====================== +*/ +void CG_ParticleSnowFlurry (qhandle_t pshader, centity_t *cent) +{ + cparticle_t *p; + qboolean turb = qtrue; + + if (!pshader) + CG_Printf ("CG_ParticleSnowFlurry pshader == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->color = 0; + p->alpha = 0.90f; + p->alphavel = 0; + + p->start = cent->currentState.origin2[0]; + p->end = cent->currentState.origin2[1]; + + p->pshader = pshader; + + if (rand()%100 > 90) + { + p->height = 32; + p->width = 32; + p->alpha = 0.10f; + } + else + { + p->height = 1; + p->width = 1; + } + + p->vel[2] = -20; + + p->type = P_WEATHER_FLURRY; + + if (turb) + p->vel[2] = -10; + + VectorCopy(cent->currentState.origin, p->org); + + p->org[0] = p->org[0]; + p->org[1] = p->org[1]; + p->org[2] = p->org[2]; + + p->vel[0] = p->vel[1] = 0; + + p->accel[0] = p->accel[1] = p->accel[2] = 0; + + p->vel[0] += cent->currentState.angles[0] * 32 + (crandom() * 16); + p->vel[1] += cent->currentState.angles[1] * 32 + (crandom() * 16); + p->vel[2] += cent->currentState.angles[2]; + + if (turb) + { + p->accel[0] = crandom () * 16; + p->accel[1] = crandom () * 16; + } + +} + +void CG_ParticleSnow (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum) +{ + cparticle_t *p; + + if (!pshader) + CG_Printf ("CG_ParticleSnow pshader == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->color = 0; + p->alpha = 0.40f; + p->alphavel = 0; + p->start = origin[2]; + p->end = origin2[2]; + p->pshader = pshader; + p->height = 1; + p->width = 1; + + p->vel[2] = -50; + + if (turb) + { + p->type = P_WEATHER_TURBULENT; + p->vel[2] = -50 * 1.3; + } + else + { + p->type = P_WEATHER; + } + + VectorCopy(origin, p->org); + + p->org[0] = p->org[0] + ( crandom() * range); + p->org[1] = p->org[1] + ( crandom() * range); + p->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); + + p->vel[0] = p->vel[1] = 0; + + p->accel[0] = p->accel[1] = p->accel[2] = 0; + + if (turb) + { + p->vel[0] = crandom() * 16; + p->vel[1] = crandom() * 16; + } + + // Rafael snow pvs check + p->snum = snum; + p->link = qtrue; + +} + +void CG_ParticleBubble (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum) +{ + cparticle_t *p; + float randsize; + + if (!pshader) + CG_Printf ("CG_ParticleSnow pshader == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->color = 0; + p->alpha = 0.40f; + p->alphavel = 0; + p->start = origin[2]; + p->end = origin2[2]; + p->pshader = pshader; + + randsize = 1 + (crandom() * 0.5); + + p->height = randsize; + p->width = randsize; + + p->vel[2] = 50 + ( crandom() * 10 ); + + if (turb) + { + p->type = P_BUBBLE_TURBULENT; + p->vel[2] = 50 * 1.3; + } + else + { + p->type = P_BUBBLE; + } + + VectorCopy(origin, p->org); + + p->org[0] = p->org[0] + ( crandom() * range); + p->org[1] = p->org[1] + ( crandom() * range); + p->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); + + p->vel[0] = p->vel[1] = 0; + + p->accel[0] = p->accel[1] = p->accel[2] = 0; + + if (turb) + { + p->vel[0] = crandom() * 4; + p->vel[1] = crandom() * 4; + } + + // Rafael snow pvs check + p->snum = snum; + p->link = qtrue; + +} + +void CG_ParticleSmoke (qhandle_t pshader, centity_t *cent) +{ + +} + + +void CG_ParticleBulletDebris (vec3_t org, vec3_t vel, int duration) +{ + + //cparticle_t *p; + + //if (!free_particles) + // return; + //p = free_particles; + //free_particles = p->next; + //p->next = active_particles; + //active_particles = p; + //p->time = cg.time; + // + //p->endtime = cg.time + duration; + //p->startfade = cg.time + duration/2; + // + //p->color = EMISIVEFADE; + //p->alpha = 1.0; + //p->alphavel = 0; + + //p->height = 0.5; + //p->width = 0.5; + //p->endheight = 0.5; + //p->endwidth = 0.5; + + //p->pshader = cgs.media.tracerShader; + + //p->type = P_SMOKE; + // + //VectorCopy(org, p->org); + + //p->vel[0] = vel[0]; + //p->vel[1] = vel[1]; + //p->vel[2] = vel[2]; + //p->accel[0] = p->accel[1] = p->accel[2] = 0; + + //p->accel[2] = -60; + //p->vel[2] += -20; + // +} + +/* +====================== +CG_ParticleExplosion +====================== +*/ + +void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd) +{ + cparticle_t *p; + int anim; + + if (animStr < (char *)10) + CG_Error( "CG_ParticleExplosion: animStr is probably an index rather than a string" ); + + // find the animation string + for (anim=0; shaderAnimNames[anim]; anim++) { + if (!Q_stricmp( animStr, shaderAnimNames[anim] )) + break; + } + if (!shaderAnimNames[anim]) { + CG_Error("CG_ParticleExplosion: unknown animation string: %s\n", animStr); + return; + } + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->alpha = 0.5; + p->alphavel = 0; + + if (duration < 0) { + duration *= -1; + p->roll = 0; + } else { + p->roll = crandom()*179; + } + + p->shaderAnim = anim; + + p->width = sizeStart; + p->height = sizeStart*shaderAnimSTRatio[anim]; // for sprites that are stretch in either direction + + p->endheight = sizeEnd; + p->endwidth = sizeEnd*shaderAnimSTRatio[anim]; + + p->endtime = cg.time + duration; + + p->type = P_ANIM; + + VectorCopy( origin, p->org ); + VectorCopy( vel, p->vel ); + VectorClear( p->accel ); + +} + +// Rafael Shrapnel +void CG_AddParticleShrapnel (localEntity_t *le) +{ + return; +} +// done. + +int CG_NewParticleArea (int num) +{ + // const char *str; + //char *str; + //char *token; + //int type; + //vec3_t origin, origin2; + //int i; + //float range = 0; + //int turb; + //int numparticles; + //int snum; + // + //str = (char *) CG_ConfigString (num); + //if (!str[0]) + // return (0); + // + //// returns type 128 64 or 32 + //token = COM_Parse (&str); + //type = atoi (token); + // + //if (type == 1) + // range = 128; + //else if (type == 2) + // range = 64; + //else if (type == 3) + // range = 32; + //else if (type == 0) + // range = 256; + //else if (type == 4) + // range = 8; + //else if (type == 5) + // range = 16; + //else if (type == 6) + // range = 32; + //else if (type == 7) + // range = 64; + + + //for (i=0; i<3; i++) + //{ + // token = COM_Parse (&str); + // origin[i] = atof (token); + //} + + //for (i=0; i<3; i++) + //{ + // token = COM_Parse (&str); + // origin2[i] = atof (token); + //} + // + //token = COM_Parse (&str); + //numparticles = atoi (token); + // + //token = COM_Parse (&str); + //turb = atoi (token); + + //token = COM_Parse (&str); + //snum = atoi (token); + // + //for (i=0; i= 4) + // CG_ParticleBubble (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum); + // else + // CG_ParticleSnow (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum); + //} + + return (1); +} + +void CG_SnowLink (centity_t *cent, qboolean particleOn) +{ + +} + +void CG_ParticleImpactSmokePuff (qhandle_t pshader, vec3_t origin) +{ + cparticle_t *p; + + if (!pshader) + CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->alpha = 0.25; + p->alphavel = 0; + p->roll = crandom()*179; + + p->pshader = pshader; + + p->endtime = cg.time + 1000; + p->startfade = cg.time + 100; + + p->width = rand()%4 + 8; + p->height = rand()%4 + 8; + + p->endheight = p->height *2; + p->endwidth = p->width * 2; + + p->endtime = cg.time + 500; + + p->type = P_SMOKE_IMPACT; + + VectorCopy( origin, p->org ); + VectorSet(p->vel, 0, 0, 20); + VectorSet(p->accel, 0, 0, 20); + + p->rotate = qtrue; +} + +void CG_Particle_Bleed (qhandle_t pshader, vec3_t start, vec3_t dir, int fleshEntityNum, int duration) +{ + cparticle_t *p; + + if (!pshader) + CG_Printf ("CG_Particle_Bleed pshader == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->alpha = 1.0; + p->alphavel = 0; + p->roll = 0; + + p->pshader = pshader; + + p->endtime = cg.time + duration; + + if (fleshEntityNum) + p->startfade = cg.time; + else + p->startfade = cg.time + 100; + + p->width = 4; + p->height = 4; + + p->endheight = 4+rand()%3; + p->endwidth = p->endheight; + + p->type = P_SMOKE; + + VectorCopy( start, p->org ); + p->vel[0] = 0; + p->vel[1] = 0; + p->vel[2] = -20; + VectorClear( p->accel ); + + p->rotate = qfalse; + + p->roll = rand()%179; + + p->color = BLOODRED; + p->alpha = 0.75; + +} + +void CG_Particle_OilParticle (qhandle_t pshader, centity_t *cent) +{ + // FIXME: [delete] unused +} + + +void CG_Particle_OilSlick (qhandle_t pshader, centity_t *cent) +{ + // FIXME: [delete] unused +} + +void CG_OilSlickRemove (centity_t *cent) +{ + // FIXME: [delete] unused +} + +qboolean ValidBloodPool (vec3_t start) +{ +#define EXTRUDE_DIST 0.5 + + vec3_t angles; + vec3_t right, up; + vec3_t this_pos, x_pos, center_pos, end_pos; + float x, y; + float fwidth, fheight; + trace_t trace; + vec3_t normal; + + fwidth = 16; + fheight = 16; + + VectorSet (normal, 0, 0, 1); + + vectoangles (normal, angles); + AngleVectors (angles, NULL, right, up); + + VectorMA (start, EXTRUDE_DIST, normal, center_pos); + + for (x= -fwidth/2; xendpos, start); + legit = ValidBloodPool (start); + + if (!legit) + return; + + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + + p->endtime = cg.time + 3000; + p->startfade = p->endtime; + + p->alpha = 1.0; + p->alphavel = 0; + p->roll = 0; + + p->pshader = pshader; + + rndSize = 0.4 + random()*0.6; + + p->width = 8*rndSize; + p->height = 8*rndSize; + + p->endheight = 16*rndSize; + p->endwidth = 16*rndSize; + + p->type = P_FLAT_SCALEUP; + + VectorCopy(start, p->org ); + + p->vel[0] = 0; + p->vel[1] = 0; + p->vel[2] = 0; + VectorClear( p->accel ); + + p->rotate = qfalse; + + p->roll = rand()%179; + + p->alpha = 0.75; + + p->color = BLOODRED; +} + +#define NORMALSIZE 16 +#define LARGESIZE 32 + +void CG_ParticleBloodCloud (centity_t *cent, vec3_t origin, vec3_t dir) +{ + //float length; + //float dist; + //float crittersize; + //vec3_t angles, forward; + //vec3_t point; + //cparticle_t *p; + //int i; + // + //dist = 0; + + //length = VectorLength (dir); + //vectoangles (dir, angles); + //AngleVectors (angles, forward, NULL, NULL); + + //crittersize = LARGESIZE; + + //if (length) + // dist = length / crittersize; + + //if (dist < 1) + // dist = 1; + + //VectorCopy (origin, point); + + //for (i=0; inext; + // p->next = active_particles; + // active_particles = p; + + // p->time = cg.time; + // p->alpha = 1.0; + // p->alphavel = 0; + // p->roll = 0; + + // p->pshader = cgs.media.smokePuffShader; + + // p->endtime = cg.time + 350 + (crandom() * 100); + // + // p->startfade = cg.time; + // + // p->width = LARGESIZE; + // p->height = LARGESIZE; + // p->endheight = LARGESIZE; + // p->endwidth = LARGESIZE; + + // p->type = P_SMOKE; + + // VectorCopy( origin, p->org ); + // + // p->vel[0] = 0; + // p->vel[1] = 0; + // p->vel[2] = -1; + // + // VectorClear( p->accel ); + + // p->rotate = qfalse; + + // p->roll = rand()%179; + // + // p->color = BLOODRED; + // + // p->alpha = 0.75; + // + //} + + +} + +void CG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed) +{ + /*cparticle_t *p; + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + + p->endtime = cg.time + duration; + p->startfade = cg.time + duration/2; + + p->color = EMISIVEFADE; + p->alpha = 0.4f; + p->alphavel = 0; + + p->height = 0.5; + p->width = 0.5; + p->endheight = 0.5; + p->endwidth = 0.5; + + p->pshader = cgs.media.tracerShader; + + p->type = P_SMOKE; + + VectorCopy(org, p->org); + + p->org[0] += (crandom() * x); + p->org[1] += (crandom() * y); + + p->vel[0] = vel[0]; + p->vel[1] = vel[1]; + p->vel[2] = vel[2]; + + p->accel[0] = p->accel[1] = p->accel[2] = 0; + + p->vel[0] += (crandom() * 4); + p->vel[1] += (crandom() * 4); + p->vel[2] += (20 + (crandom() * 10)) * speed; + + p->accel[0] = crandom () * 4; + p->accel[1] = crandom () * 4;*/ + +} + +void CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir) +{ + //float length; + //float dist; + //float crittersize; + //vec3_t angles, forward; + //vec3_t point; + //cparticle_t *p; + //int i; + // + //dist = 0; + + //VectorNegate (dir, dir); + //length = VectorLength (dir); + //vectoangles (dir, angles); + //AngleVectors (angles, forward, NULL, NULL); + + //crittersize = LARGESIZE; + + //if (length) + // dist = length / crittersize; + + //if (dist < 1) + // dist = 1; + + //VectorCopy (origin, point); + + //for (i=0; inext; + // p->next = active_particles; + // active_particles = p; + + // p->time = cg.time; + // p->alpha = 5.0; + // p->alphavel = 0; + // p->roll = 0; + + // p->pshader = cgs.media.smokePuffShader; + + // // RF, stay around for long enough to expand and dissipate naturally + // if (length) + // p->endtime = cg.time + 4500 + (crandom() * 3500); + // else + // p->endtime = cg.time + 750 + (crandom() * 500); + // + // p->startfade = cg.time; + // + // p->width = LARGESIZE; + // p->height = LARGESIZE; + + // // RF, expand while falling + // p->endheight = LARGESIZE*3.0; + // p->endwidth = LARGESIZE*3.0; + + // if (!length) + // { + // p->width *= 0.2f; + // p->height *= 0.2f; + + // p->endheight = NORMALSIZE; + // p->endwidth = NORMALSIZE; + // } + + // p->type = P_SMOKE; + + // VectorCopy( point, p->org ); + // + // p->vel[0] = crandom()*6; + // p->vel[1] = crandom()*6; + // p->vel[2] = random()*20; + + // // RF, add some gravity/randomness + // p->accel[0] = crandom()*3; + // p->accel[1] = crandom()*3; + // p->accel[2] = -PARTICLE_GRAVITY*0.4; + + // VectorClear( p->accel ); + + // p->rotate = qfalse; + + // p->roll = rand()%179; + // + // p->alpha = 0.75; + // + //} + + +} + +void CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha) +{ + cparticle_t *p; + + if (!pshader) + CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n"); + + if (!free_particles) + return; + + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->alpha = 1.0; + p->alphavel = 0; + p->roll = rand()%179; + + p->pshader = pshader; + + if (duration > 0) + p->endtime = cg.time + duration; + else + p->endtime = duration; + + p->startfade = cg.time; + + p->width = size; + p->height = size; + + p->endheight = size; + p->endwidth = size; + + p->type = P_SPRITE; + + VectorCopy( origin, p->org ); + + p->rotate = qfalse; +} + diff --git a/code/cgame/cg_modelanim.c b/code/cgame/cg_modelanim.c new file mode 100644 index 00000000..cef9e89d --- /dev/null +++ b/code/cgame/cg_modelanim.c @@ -0,0 +1,355 @@ +/* +=========================================================================== +Copyright (C) 2009-2010 su44 + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cg_local.h" +//translate bone_s b to pos/rot coordinates space. (treat pos/rot as parent bone orientation) +void CG_BoneLocal2World(bone_t *b, vec3_t pos, vec3_t rot, vec3_t outPos, vec3_t outRot) { + quat_t q,qpos,res,tmp; + quat_t outQuat; +#if 0 + QuatFromAngles(q,rot[0],rot[1],rot[2]); +#else + matrix_t m; + MatrixFromAngles(m,rot[0],rot[1],rot[2]); + QuatFromMatrix(q,m); +#endif + VectorCopy(b->p,qpos); + qpos[3] = 0; + + + QuaternionMultiply(tmp,qpos,q); + + QuatInverse(q); + QuaternionMultiply(res,q,tmp); + QuatInverse(q); + + outPos[0] = res[0] + pos[0]; + outPos[1] = res[1] + pos[1]; + outPos[2] = res[2] + pos[2]; + + QuaternionMultiply(outQuat,b->q,q); + QuatNormalize(outQuat); + if(outRot) { +#if 0 + QuatToAngles(outQuat, outRot); +#else + MatrixFromQuat(m,outQuat); + MatrixToAngles(m,outRot); +#endif + } +} +void CG_CentBoneLocal2World(bone_t *b, centity_t *cent, vec3_t outPos, vec3_t outRot) { + CG_BoneLocal2World(b,cent->lerpOrigin,cent->lerpAngles,outPos,outRot); +} +void CG_CentBoneIndexLocal2World(int boneIndex, centity_t *cent, vec3_t outPos, vec3_t outRot) { + CG_BoneLocal2World(cent->bones+boneIndex,cent->lerpOrigin,cent->lerpAngles,outPos,outRot); +} +int CG_TIKI_BoneIndexForName(tiki_t *tiki, char *name) { + int nameIndex; + int i; + nameIndex = cgi.TIKI_GetBoneNameIndex(name); + for(i = 0; i < tiki->numBones; i++) { + if(tiki->boneNames[i] == nameIndex) { + return i; + } + } + return -1; +} +void CG_AttachEntity(refEntity_t *e, centity_t *parent, int boneIndex, vec3_t outAngles) { + bone_t *b; + vec3_t a; + if(parent->bones==0) + return; + b = &parent->bones[boneIndex]; + CG_BoneLocal2World(b,parent->lerpOrigin,parent->lerpAngles,e->origin,a); + AnglesToAxis(a,e->axis); + if(outAngles) + VectorCopy(a,outAngles); +} +qboolean CG_TIKI_BoneOnGround(centity_t *cent, tiki_t *tiki, int boneIndex) +{ + if(cent->bones == 0) + return qfalse; + //CG_Printf("Z: %f\n",cent->bones[boneIndex].p[2]); + if(cent->bones[boneIndex].p[2] < 6) + return qfalse; + return qtrue; +} +void CG_ModelAnim( centity_t *cent ) +{ + refEntity_t ent; + entityState_t *s1; + tiki_t *tiki; + int i; + qboolean attachedToViewmodel; + s1 = ¢->currentState; + + attachedToViewmodel = qfalse; + + memset( &ent, 0, sizeof( ent ) ); + + for( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + frameInfo_t *frame = ¢->currentState.frameInfo[ i ]; + frameInfo_t *nextframe = ¢->nextState.frameInfo[ i ]; + + if( frame->index != nextframe->index || !cent->interpolate ) { + continue; + } + + if( frame->time <= nextframe->time ) { + frame->time += cg.frametime / 1000.0f; + } else { + frame->time -= cg.frametime / 1000.0f; + } + } + + if(s1->tag_num != -1 && s1->parent != 1023) { + if(s1->parent == cg.clientNum && !cg.renderingThirdPerson) { + ent.renderfx |= RF_THIRD_PERSON; + attachedToViewmodel = qtrue; + } else { + CG_AttachEntity(&ent,&cg_entities[s1->parent],s1->tag_num,cent->lerpAngles); + // save pos/rot for events + VectorCopy(ent.origin,cent->lerpOrigin); + } + + } else { + AnglesToAxis(cent->lerpAngles,ent.axis); + VectorCopy(cent->lerpOrigin,ent.origin); + } + + if(s1->eType == ET_MOVER) { + ent.model = cgs.inlineDrawModel[ s1->modelindex ]; + } else { + ent.model = cgs.gameModels[ s1->modelindex ]; + } + + tiki = cgs.gameTIKIs[ s1->modelindex ]; + + if(tiki && tiki->numAnims) { + int idleIndex = 0; + ent.bones = cgi.TIKI_GetBones(tiki->numBones); + cent->bones = ent.bones; +#if 0 + for(i = 0; i < tiki->numAnims; i++) { + if(!Q_stricmp(tiki->anims[i]->alias,"unarmed_stand_idle")) { + idleIndex = i; + break; + } + } + if(idleIndex!=0) { + cgi.TIKI_SetChannels(tiki,idleIndex,0,0,ent.bones); + } else +#endif + + + { + frameInfo_t *fi = s1->frameInfo; + ClearBounds(ent.bounds[0],ent.bounds[1]); + ent.radius = 0; + for(i = 0; i < 16; i++) { + if(fi->weight!=0) { + cgi.TIKI_AppendFrameBoundsAndRadius(tiki,fi->index,fi->time,&ent.radius,ent.bounds); + cgi.TIKI_SetChannels(tiki,fi->index,fi->time,fi->weight,ent.bones); + } + fi++; + } + } + + /*if( cent->currentState.number == cg.clientNum ) + { + vec3_t angles; + + QuatToAngles( ent.bones[ 0 ].q, angles ); + + angles[ 0 ] -= 90.0f; + angles[ 2 ] -= 90.0f; + + EulerToQuat( angles, ent.bones[ 0 ].q ); + }*/ + +#if 0 + for(i = 0; i < 5; i++) { + if(s1->bone_tag[i] != -1) { + matrix_t m; + matrix_t m2; + matrix_t mf; + quat_t q; + // CG_Printf("i %i of 5, tag %i, angles %f %f %f\n",i,s1->bone_tag[i], + // s1->bone_angles[i][0],s1->bone_angles[i][1],s1->bone_angles[i][2]); + //bone_quat is always 0 0 0 0? + if(s1->bone_quat[i][0] != 0 || s1->bone_quat[i][1] != 0 || s1->bone_quat[i][2] != 0 || s1->bone_quat[i][3] != 0) { + CG_Printf("i %i of 5, tag %i, quat %f %f %f %f\n",i,s1->bone_tag[i], + s1->bone_quat[i][0],s1->bone_quat[i][1],s1->bone_quat[i][2],s1->bone_quat[i][3]); + __asm int 3 + } + // s1->bone_angles[i][0] changes when looking up / down (PITCH) + // s1->bone_angles[i][2] changes when leaning left/right (ROLL) + //AnglesToMatrix(s1->bone_angles[i],m); + // ...? + MatrixFromAngles(m,-s1->bone_angles[i][2],-s1->bone_angles[i][0],0); + MatrixFromQuat(m2,ent.bones[s1->bone_tag[i]].q); + Matrix4x4Multiply(m,m2,mf); + QuatFromMatrix(ent.bones[s1->bone_tag[i]].q,mf); + } + } +#endif + + cgi.TIKI_Animate( tiki, ent.bones ); + + for( i = 0; i < NUM_BONE_CONTROLLERS; i++ ) + { + int tag = s1->bone_tag[ i ]; + + //if( tag == cgi.Tag_NumForName( tiki, "Bip01 Pelvis" ) ) { + // continue; + //} + + if( tag >= 0 ) + { + matrix_t m; + matrix_t m2; + matrix_t mf; + quat_t quat; + + MatrixFromAngles( m, s1->bone_angles[ i ][ 0 ] * 2.0f, s1->bone_angles[ i ][ 1 ], s1->bone_angles[ i ][ 2 ] * 4.0f ); + MatrixFromQuat( m2, ent.bones[ tag ].q ); + Matrix4x4Multiply( m, m2, mf ); + QuatFromMatrix( quat, mf ); + + /*MatrixFromAngles( m, -cent->nextState.bone_angles[ i ][ 2 ] * 4.0f, -cent->nextState.bone_angles[ i ][ 0 ], cent->nextState.bone_angles[ i ][ 1 ] ); + MatrixFromQuat( m2, ent.bones[ tag ].q ); + Matrix4x4Multiply( m, m2, mf ); + QuatFromMatrix( nextquat, mf ); + + if( ( cent->interpolate ) && ( cent->nextState.bone_tag[ i ] == cent->currentState.bone_tag[ i ] ) ) + { + QuatSlerp( quat, nextquat, + cg.frameInterpolation, ent.bones[ tag ].q ); + } + else*/ + { + ent.bones[ tag ].q[ 0 ] = quat[ 0 ]; + ent.bones[ tag ].q[ 1 ] = quat[ 1 ]; + ent.bones[ tag ].q[ 2 ] = quat[ 2 ]; + ent.bones[ tag ].q[ 3 ] = quat[ 3 ]; + } + } + } + } + + // player model + if( cent->currentState.number == cg.clientNum ) { +#if 1 //calculate eye pos/rot for usereyes_t + if( tiki ) { + vec3_t pos, rot; +#if 0 + VectorSet( eyePos, 0, 0, cg.predictedPlayerState.viewheight ); + + VectorCopy( cg.predictedPlayerState.viewangles, eyeRot ); + cgi.SetEyeInfo( eyePos, eyeRot ); +#else + int eyeBoneName; + int torso_tag; + eyeBoneName = cgi.TIKI_GetBoneNameIndex( "eyes bone" );//("tag_weapon_right"); + torso_tag = cgi.TIKI_GetBoneNameIndex( "Bip01 Spine1" ); + for( i = 0; i < tiki->numBones; i++ ) { + if( tiki->boneNames[ i ] == eyeBoneName ) { + CG_BoneLocal2World( ent.bones + i, ent.origin, cent->lerpAngles, pos, rot ); + + VectorCopy( cg.predictedPlayerState.viewangles, rot ); + VectorSubtract( pos, cent->lerpOrigin, pos ); + cgi.SetEyeInfo( pos, rot ); + } + /*else if( tiki->boneNames[ i ] == torso_tag ) + { + bone_t *bone = ent.bones + i; + + CG_BoneLocal2World( ent.bones + i, ent.origin, cent->lerpAngles, pos, rot ); + + VectorCopy( s1->bone_angles[ 1 ], rot ); + VectorSubtract( pos, cent->lerpOrigin, pos ); + + VectorCopy( rot, bone->p ); + EulerToQuat( rot, bone->q ); + }*/ + } +#endif + } +#endif + if( !cg.renderingThirdPerson ) { + ent.renderfx = RF_THIRD_PERSON; // only draw in mirrors + } else { + if( cg_cameraMode->integer ) { + return; + } + } + + CG_ViewModelAnim(); // maybe I should put it somewhere else.. + } + + if(cent->currentState.groundEntityNum == ENTITYNUM_NONE) { + cent->bFootOnGround_Right = 0; + cent->bFootOnGround_Left = 0; + } else if(tiki) { + int tagNum; + + tagNum = CG_TIKI_BoneIndexForName(tiki,"Bip01 L Foot"); + if(tagNum != -1) { + if(CG_TIKI_BoneOnGround(cent,tiki,tagNum)) { + if(!cent->bFootOnGround_Left) { + CG_Footstep("Bip01 L Foot",cent,1,0); + } + cent->bFootOnGround_Left = 1; + } else { + cent->bFootOnGround_Left = 0; + } + } + + tagNum = CG_TIKI_BoneIndexForName(tiki,"Bip01 R Foot"); + if(tagNum != -1) { + if(CG_TIKI_BoneOnGround(cent,tiki,tagNum)) { + if(!cent->bFootOnGround_Right) { + CG_Footstep("Bip01 R Foot",cent,1,0); + } + cent->bFootOnGround_Right = 1; + } else { + cent->bFootOnGround_Right = 0; + } + } + } + + for( i = 0; i < 32; i++ ) + { + if( cent->currentState.surfaces[ i ] & MDL_SURFACE_NODRAW ) + { + ent.surfaceBits |= 1 << i; + } + } + + cgi.R_AddRefEntityToScene(&ent); + if(attachedToViewmodel) { + CG_AddViewModelAnimAttachment(&ent,cent); + } + +} diff --git a/code/cgame/cg_parsemsg.c b/code/cgame/cg_parsemsg.c new file mode 100644 index 00000000..3031f145 --- /dev/null +++ b/code/cgame/cg_parsemsg.c @@ -0,0 +1,653 @@ +/* +=========================================================================== +Copyright (C) 2011 su44 + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// cg_parsemsg.c + +#include "cg_local.h" + +#define MAX_HDELEMENTS 256 + +hdelement_t hdelements[MAX_HDELEMENTS]; + +typedef struct { + float i_vBarrel[3]; + float i_vStart[3]; + float (*i_vEnd)[3]; + int i_iNumBullets; + qboolean iLarge; + int iTracerVisible; + qboolean bIgnoreEntities; +} bullet_tracer_t; + +#define MAX_IMPACTS 64 +#define MAX_BULLER_TRACERS 32 +#define MAX_BULLET_TRACE_BULLETS 1024 + +// bullet tracers +static bullet_tracer_t bullet_tracers[MAX_BULLER_TRACERS]; +static int bullet_tracers_count; +static float bullet_tracer_bullets[MAX_BULLET_TRACE_BULLETS][3]; +static int bullet_tracer_bullets_count; + +// wall impacts +static vec3_t wall_impact_pos[MAX_IMPACTS]; +static vec3_t wall_impact_norm[MAX_IMPACTS]; +static int wall_impact_large[MAX_IMPACTS]; +static int wall_impact_type[MAX_IMPACTS]; // 0,2,3,4,5 +static int wall_impact_count; +// flesh impacts +static vec3_t flesh_impact_pos[MAX_IMPACTS]; +static vec3_t flesh_impact_norm[MAX_IMPACTS]; +static int flesh_impact_large[MAX_IMPACTS]; +static int flesh_impact_type[MAX_IMPACTS]; +static int flesh_impact_count; + +static int current_entity_number; + +void CG_MakeBulletHole(float *i_vPos, float *i_vNorm, int iLarge, + trace_t *pPreTrace, qboolean bMakeSound) { + char *s; + +#if 0 + // su44: make an "explosion" effect here so I can debug bullet holes coordinates + CG_MakeExplosion(i_vPos,vec3_origin,0,cgi.R_RegisterShader("heavy_pipe"),250,qtrue); +#endif + s = "bhole_"; + + // TODO: choose an appropriate decal shader and play hit sound + + CG_ImpactMark(cgi.R_RegisterShader("bhole_wood"),i_vPos,i_vNorm,0,1,1,1,1,qfalse,8,qfalse); +} + +void CG_AddBulletImpacts() { + int i; + char *s; + int type; + + for(i = 0; i < wall_impact_count; i++) { + CG_MakeBulletHole(wall_impact_pos[i],wall_impact_norm[i], + wall_impact_large[i],0,qtrue); + + type = wall_impact_type[i]; + if(type) { + if ( wall_impact_type[i] < 2 || wall_impact_type[i] > 3 ) + s = "snd_bh_metal"; + else + s = "snd_bh_wood"; + //CG_PlaySound(s,wall_impact_pos[i],-1, + } + } + for(i = 0; i < flesh_impact_count; i++) { + + } +} + +static void CG_MakeBubbleTrail(float *i_vStart, float *i_vEnd, int iLarge) { + // TODO +} +// this is called from CG_MakeBulletTracerInternal +static void CG_BulletTracerEffect(float *i_vStart, float *i_vEnd) +{ + byte fTracerColor[4]; // su44: in MoHAA it was "float[4]" + int iLife; + vec3_t vNewStart; + int v2; + + VectorCopy(i_vStart,vNewStart); + + v2 = 1; + + iLife = 20; + fTracerColor[0] = 255; + fTracerColor[1] = 255; + fTracerColor[2] = 255; + fTracerColor[3] = 255; + CG_CreateBeam( + vNewStart, // start + vec3_origin, // dir + 0, // owner + 1, // model + 1.0, // alpha + 1.0, // scale + 8192, // flags + 1000.0, // len + iLife, // life + 1, // qboolean create + i_vEnd, // endpointvec + 0, // min_ofs + 0, // maxs_ofs + 0, // overlap + 1, // numSubdivions + 0, // delay + "tracer", // beamshadername + fTracerColor, // modulate (in FAKK that's a byte[4], in MoH that's float[4]) + 0, // numSphereBeams + 0.0, // sphereradius + v2, //toggleDelay + 1.0, //endapha + 0, // renderfx + "tracereffect"); // name +} + +static void CG_MakeBulletTracerInternal(float *i_vBarrel, float *i_vStart, + float (*i_vEnd)[3], int i_iNumBullets, qboolean iLarge, + int iTracerVisible, qboolean bIgnoreEntities) { + trace_t tr; + int i; + + for(i = 0; i < i_iNumBullets; i++) { + CG_BulletTracerEffect(i_vBarrel,i_vEnd[i]); + CG_Trace(&tr,i_vBarrel,vec3_origin,vec3_origin,i_vEnd[i],-1,MASK_SHOT); + if(tr.fraction != 1.f && tr.allsolid == qfalse) { + CG_MakeBulletHole(tr.endpos,tr.plane.normal,iLarge,&tr,qfalse); + } else { + // su44: it happens quite often. Is it a bug? + //CG_Printf("CG_MakeBulletTracerInternal: missed\n"); + } + } + +} + +static void CG_MakeBulletTracer(float *i_vBarrel, float *i_vStart, + float (*i_vEnd)[3], int i_iNumBullets, qboolean iLarge, + int iTracerVisible, qboolean bIgnoreEntities) { + bullet_tracer_t *bt; + int i; + if(bullet_tracers_count < MAX_BULLER_TRACERS) { + if(i_iNumBullets + bullet_tracer_bullets_count < MAX_BULLET_TRACE_BULLETS) { + bt = bullet_tracers + bullet_tracers_count; + VectorCopy(i_vBarrel,bt->i_vBarrel); + VectorCopy(i_vStart,bt->i_vStart); + bt->i_vEnd = &bullet_tracer_bullets[bullet_tracer_bullets_count]; + bt->i_iNumBullets = i_iNumBullets; + bt->iLarge = iLarge; + bt->iTracerVisible = iTracerVisible; + bt->bIgnoreEntities = bIgnoreEntities; + bullet_tracers_count++; + for(i = 0; i < i_iNumBullets; i++) { + VectorCopy(i_vEnd[i],bullet_tracer_bullets[bullet_tracer_bullets_count]); + bullet_tracer_bullets_count++; + } + } else { + CG_Printf("CG_MakeBulletTracerInternal: MAX_BULLET_TRACE_BULLETS exceeded\n"); + } + } else { + CG_Printf("CG_MakeBulletTracer: MAX_BULLER_TRACERS exceeded\n"); + } +} + +// su44: this should be called after CG_AddPacketEntities and before CG_DrawActive +void CG_AddBulletTracers() { + int i; + bullet_tracer_t *bt; + + bt = bullet_tracers; + for(i = 0; i < bullet_tracers_count; i++,bt++) { + CG_MakeBulletTracerInternal(bt->i_vBarrel,bt->i_vStart,bt->i_vEnd,bt->i_iNumBullets, + bt->iLarge,bt->iTracerVisible,bt->bIgnoreEntities); + } + bullet_tracers_count = 0; + bullet_tracer_bullets_count = 0; +} + +static void CG_MakeExplosionEffect(float *vPos, int iType) { + CG_MakeExplosion(vPos,vec3_origin,0,cgi.R_RegisterShader("gren_explosion"),1000,qtrue); +} + +static void CG_MakeEffect_Normal(int iEffect, vec3_t vPos, vec3_t vNormal) { + // TODO +} + +static void CG_SpawnEffectModel(const char *model, vec3_t origin) { + localEntity_t *le; + vec3_t spawnAngles = { 0, 0, 0 }; + qhandle_t h; + + le = CG_AllocLocalEntity(); + le->endTime = cg.time + 5000; + le->leType = LE_SKIP; + le->pos.trTime = cg.time - (rand()&15); + VectorCopy( origin, le->pos.trDelta ); + VectorCopy(origin,le->refEntity.origin); + VectorCopy( spawnAngles, le->angles.trDelta ); + AnglesToAxis(spawnAngles,le->refEntity.axis); + + h = cgi.R_RegisterModel(model); + le->refEntity.model = h; + le->leType = LE_FRAGMENT; + le->tiki = cgi.TIKI_RegisterModel(model); +} + +void CG_HudDrawElements() { + int i; + hdelement_t *hdi; + + //if ( cg_huddraw_force.integer || cg_hud.integer ) + { + hdi = hdelements; + for ( i = 0; i < MAX_HDELEMENTS; i++, hdi++ ) { + if ( hdi->hShader || hdi->string[0] ) { + if ( hdi->vColor[3] != 0.f ) { + float x = hdi->iX; + float y = hdi->iY; + float w = hdi->iWidth; + float h = hdi->iHeight; + + if ( hdi->iHorizontalAlign == 1 ) { + if ( hdi->bVirtualScreen ) + x = 320.f - w * 0.5f + x; + else + x = cgs.glconfig.vidWidth * 0.5f - w * 0.5f + x; + } else { + if ( hdi->iHorizontalAlign == 2 ) { + if ( hdi->bVirtualScreen ) + x = x + 640.f; + else + x = cgs.glconfig.vidWidth + x; + } + } + + if ( hdi->iVerticalAlign == 1 ) { + if ( hdi->bVirtualScreen ) + y = 240.f - h * 0.5f + y; + else + y = cgs.glconfig.vidHeight * 0.5f - h * 0.5f + y; + } else { + if ( hdi->iVerticalAlign == 2 ) { + if ( hdi->bVirtualScreen ) + y = y + 480.f; + else + y = cgs.glconfig.vidHeight + y; + } + } + + cgi.R_SetColor(hdi->vColor); + + // su44: that's wrong + if(hdi->bVirtualScreen) { + if(x > 640) + x -= 640; + if(x < 0) + x += 640; + if(y > 480) + y -= 480; + if(y < 0) + y += 480; + } + + if ( hdi->string[0] ) { + if ( hdi->pFont.glyphs[0].glyph ) { + cgi.R_Text_Paint(&hdi->pFont, x, y, 1, 1, hdi->string,0,-1, qfalse, hdi->bVirtualScreen); + } else { + cgi.R_Text_Paint(&cgs.media.verdana, x, y, 1, 1, hdi->string,0,-1, qfalse, hdi->bVirtualScreen); + } + } else { + if ( hdi->bVirtualScreen ) + CG_AdjustFrom640(&x, &y, &w, &h); + + cgi.R_DrawStretchPic(x, y, w, h, 0.f, 0.f, 1.f, 1.f, hdi->hShader); + } + } + } + } + } +} + +static void CG_HudDrawShader (int iInfo) { + hdelement_t *hdi = hdelements + iInfo; + if(hdi->shaderName[0]) { + hdi->hShader = cgi.R_RegisterShaderNoMip(hdi->shaderName); + } else { + hdi->hShader = 0; + } +} + +static void CG_HudDrawFont (int iInfo) { + hdelement_t *hdi = hdelements + iInfo; + if(hdi->fontName[0]) { + cgi.R_RegisterFont(hdi->fontName,0,&hdi->pFont); + } else { + memset(&hdi->pFont,0,sizeof(hdi->pFont)); + } +} + +static void CG_PlaySound(char *sound_name, float *origin, int channel, + float volume, float min_distance, float pitch, int argstype) { + ubersound_t* sound; + + sound = CG_GetUbersound(sound_name); + + if(sound) + cgi.S_StartSound( origin, -1, sound->channel, sound->sfxHandle ); + + +} + +/* +===================== +CG_ParseCGMessage +===================== +*/ +void CG_ParseCGMessage() { + int msgtype; + vec3_t vecStart, vecTmp, vecEnd, vecArray[64]; + int iCount, iLarge; + int i, iTemp; + char *s; + hdelement_t *hde; + + // thats a hack, it should be done somewhere else [?] + wall_impact_count = 0; + flesh_impact_count = 0; + + do { + msgtype = cgi.MSG_ReadBits( 6 ); + if(cg_debugCGMessages->integer) { + Com_Printf( "CG_ParseCGMessage: command type %i\n", msgtype ); + } + switch ( msgtype ) { + case 1: // BulletTracer (visible?) + vecTmp[0] = cgi.MSG_ReadCoord(); + vecTmp[1] = cgi.MSG_ReadCoord(); + vecTmp[2] = cgi.MSG_ReadCoord(); + case 2: // BulletTracer (invisible?) + case 5: // BubbleTrail + vecStart[0] = cgi.MSG_ReadCoord(); + vecStart[1] = cgi.MSG_ReadCoord(); + vecStart[2] = cgi.MSG_ReadCoord(); + if ( msgtype != 1 ) { + vecTmp[0] = vecStart[0]; + vecTmp[1] = vecStart[1]; + vecTmp[2] = vecStart[2]; + } + vecArray[0][0] = cgi.MSG_ReadCoord(); + vecArray[0][1] = cgi.MSG_ReadCoord(); + vecArray[0][2] = cgi.MSG_ReadCoord(); + + iLarge = cgi.MSG_ReadBits( 1 ); + if(msgtype==5) { + CG_MakeBubbleTrail(vecStart,vecArray[0],iLarge); + } else if(msgtype==1) { + // su44: I am not sure about the last parameters... + CG_MakeBulletTracer(vecTmp, vecStart, vecArray, 1, iLarge, 1, 1); + } else { //msgtype == 2 + CG_MakeBulletTracer(vecTmp, vecStart, vecArray, 1, iLarge, 0, 1); + } + break; + case 3: // BulletTracer multiple times + vecTmp[0] = cgi.MSG_ReadCoord(); + vecTmp[1] = cgi.MSG_ReadCoord(); + vecTmp[2] = cgi.MSG_ReadCoord(); + iTemp = cgi.MSG_ReadBits( 6 ); + case 4: // BulletTracer multiple times (shotgun shot) + if ( msgtype == 4 ) + iTemp = 0; + vecStart[0] = cgi.MSG_ReadCoord(); + vecStart[1] = cgi.MSG_ReadCoord(); + vecStart[2] = cgi.MSG_ReadCoord(); + + iLarge = cgi.MSG_ReadBits( 1 ); + iCount = cgi.MSG_ReadBits( 6 ); + + // this check is missing in MOHAA code, so this has buffer overflow risk in AA + if ( iCount > 64 ) + Com_Error( ERR_DROP, "CG message type 4 sent too many data.\n" ); + for (i=0;ishaderName, cgi.MSG_ReadString(), sizeof(hde->shaderName) ); + hde->string[0] = 0; + memset(&hde->pFont,0,sizeof(hde->pFont)); + hde->fontName[0] = 0; + + CG_HudDrawShader(i); + break; + case 28: // HUD drawing... + i = cgi.MSG_ReadByte(); + hde = hdelements + i; + hde->iHorizontalAlign = cgi.MSG_ReadBits( 2 ); + hde->iHorizontalAlign = cgi.MSG_ReadBits( 2 ); + break; + case 29: + i = cgi.MSG_ReadByte(); + hde = hdelements + i; + hde->iX = cgi.MSG_ReadShort(); + hde->iY = cgi.MSG_ReadShort(); + hde->iWidth = cgi.MSG_ReadShort(); + hde->iHeight = cgi.MSG_ReadShort(); + break; + case 30: + i = cgi.MSG_ReadByte(); + hde = hdelements + i; + hde->bVirtualScreen = cgi.MSG_ReadBits( 1 ); + break; + case 31: // huddraw_color + i = cgi.MSG_ReadByte(); + hde = hdelements + i; + hde->vColor[0] = cgi.MSG_ReadByte()*0.003921568859368563; + hde->vColor[1] = cgi.MSG_ReadByte()*0.003921568859368563; + hde->vColor[2] = cgi.MSG_ReadByte()*0.003921568859368563; + break; + case 32: // huddraw_alpha + i = cgi.MSG_ReadByte(); + hde = hdelements + i; + hde->vColor[3] = cgi.MSG_ReadByte()*0.003921568859368563; + break; + case 33: // huddraw_string + i = cgi.MSG_ReadByte(); + hde = hdelements + i; + hde->hShader = 0; + Q_strncpyz( hde->string, cgi.MSG_ReadString(), sizeof(hde->string) ); + break; + case 34: // huddraw_font + i = cgi.MSG_ReadByte(); + hde = hdelements + i; + Q_strncpyz( hde->fontName, cgi.MSG_ReadString(), sizeof(hde->fontName) ); + hde->hShader = 0; + hde->shaderName[0] = 0; + CG_HudDrawFont(i); + break; + case 35: + case 36: + // TODO - play sound (?) + //CG_PlaySound(s, 0, 5, 2.0, -1.0, vecStart, 1); + break; + case 37: // voicechat message (squad command, taunt, etc...) + vecStart[0] = cgi.MSG_ReadCoord(); + vecStart[1] = cgi.MSG_ReadCoord(); + vecStart[2] = cgi.MSG_ReadCoord(); + + iTemp = cgi.MSG_ReadBits( 1 ); + // read client index + i = cgi.MSG_ReadBits( 6 ); + // read voicechat sound alias + s = cgi.MSG_ReadString(); + + if(iTemp) { + current_entity_number = i; + + } + //CG_Printf("Case 37: iTemp %i, i %i, s %s\n",iTemp,i,s); + // play an aliased sound from uberdialog.scr + // wombat: only if there is a sound to be played + if ( *s ) + CG_PlaySound(s,vecStart,5,-1.0,-1.0,-1.0,0); + break; + } + } while ( cgi.MSG_ReadBits(1) ); +} diff --git a/code/cgame/cg_particles.c b/code/cgame/cg_particles.c new file mode 100644 index 00000000..95ce7096 --- /dev/null +++ b/code/cgame/cg_particles.c @@ -0,0 +1,2018 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// Rafael particles +// cg_particles.c + +#include "cg_local.h" + +#define BLOODRED 2 +#define EMISIVEFADE 3 +#define GREY75 4 + +typedef struct particle_s +{ + struct particle_s *next; + + float time; + float endtime; + + vec3_t org; + vec3_t vel; + vec3_t accel; + int color; + float colorvel; + float alpha; + float alphavel; + int type; + qhandle_t pshader; + + float height; + float width; + + float endheight; + float endwidth; + + float start; + float end; + + float startfade; + qboolean rotate; + int snum; + + qboolean link; + + // Ridah + int shaderAnim; + int roll; + + int accumroll; + +} cparticle_t; + +typedef enum +{ + P_NONE, + P_WEATHER, + P_FLAT, + P_SMOKE, + P_ROTATE, + P_WEATHER_TURBULENT, + P_ANIM, // Ridah + P_BAT, + P_BLEED, + P_FLAT_SCALEUP, + P_FLAT_SCALEUP_FADE, + P_WEATHER_FLURRY, + P_SMOKE_IMPACT, + P_BUBBLE, + P_BUBBLE_TURBULENT, + P_SPRITE +} particle_type_t; + +#define MAX_SHADER_ANIMS 32 +#define MAX_SHADER_ANIM_FRAMES 64 + +static char *shaderAnimNames[MAX_SHADER_ANIMS] = { + "explode1", + "blacksmokeanim", + "twiltb2", + "expblue", + "blacksmokeanimb", // uses 'explode1' sequence + "blood", + NULL +}; +static qhandle_t shaderAnims[MAX_SHADER_ANIMS][MAX_SHADER_ANIM_FRAMES]; +static int shaderAnimCounts[MAX_SHADER_ANIMS] = { + 23, + 25, + 45, + 25, + 23, + 5, +}; +static float shaderAnimSTRatio[MAX_SHADER_ANIMS] = { + 1.405f, + 1.0f, + 1.0f, + 1.0f, + 1.0f, + 1.0f, +}; +static int numShaderAnims; +// done. + +#define PARTICLE_GRAVITY 40 +#define MAX_PARTICLES 1024 * 8 + +cparticle_t *active_particles, *free_particles; +cparticle_t particles[MAX_PARTICLES]; +int cl_numparticles = MAX_PARTICLES; + +qboolean initparticles = qfalse; +vec3_t vforward, vright, vup; +vec3_t rforward, rright, rup; + +float oldtime; + +/* +=============== +CL_ClearParticles +=============== +*/ +void CG_ClearParticles (void) +{ + int i; + + memset( particles, 0, sizeof(particles) ); + + free_particles = &particles[0]; + active_particles = NULL; + + for (i=0 ;itype == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY + || p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) + {// create a front facing polygon + + if (p->type != P_WEATHER_FLURRY) + { + if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) + { + if (org[2] > p->end) + { + p->time = cg.time; + VectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground + + p->org[2] = ( p->start + crandom () * 4 ); + + + if (p->type == P_BUBBLE_TURBULENT) + { + p->vel[0] = crandom() * 4; + p->vel[1] = crandom() * 4; + } + + } + } + else + { + if (org[2] < p->end) + { + p->time = cg.time; + VectorCopy (org, p->org); // Ridah, fixes rare snow flakes that flicker on the ground + + while (p->org[2] < p->end) + { + p->org[2] += (p->start - p->end); + } + + + if (p->type == P_WEATHER_TURBULENT) + { + p->vel[0] = crandom() * 16; + p->vel[1] = crandom() * 16; + } + + } + } + + + // Rafael snow pvs check + if (!p->link) + return; + + p->alpha = 1; + } + + // Ridah, had to do this or MAX_POLYS is being exceeded in village1.bsp + if (Distance( cg.snap->ps.origin, org ) > 1024) { + return; + } + // done. + + if (p->type == P_BUBBLE || p->type == P_BUBBLE_TURBULENT) + { + VectorMA (org, -p->height, vup, point); + VectorMA (point, -p->width, vright, point); + VectorCopy (point, verts[0].xyz); + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255; + verts[0].modulate[1] = 255; + verts[0].modulate[2] = 255; + verts[0].modulate[3] = 255 * p->alpha; + + VectorMA (org, -p->height, vup, point); + VectorMA (point, p->width, vright, point); + VectorCopy (point, verts[1].xyz); + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255; + verts[1].modulate[1] = 255; + verts[1].modulate[2] = 255; + verts[1].modulate[3] = 255 * p->alpha; + + VectorMA (org, p->height, vup, point); + VectorMA (point, p->width, vright, point); + VectorCopy (point, verts[2].xyz); + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255; + verts[2].modulate[1] = 255; + verts[2].modulate[2] = 255; + verts[2].modulate[3] = 255 * p->alpha; + + VectorMA (org, p->height, vup, point); + VectorMA (point, -p->width, vright, point); + VectorCopy (point, verts[3].xyz); + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255; + verts[3].modulate[1] = 255; + verts[3].modulate[2] = 255; + verts[3].modulate[3] = 255 * p->alpha; + } + else + { + VectorMA (org, -p->height, vup, point); + VectorMA (point, -p->width, vright, point); + VectorCopy( point, TRIverts[0].xyz ); + TRIverts[0].st[0] = 1; + TRIverts[0].st[1] = 0; + TRIverts[0].modulate[0] = 255; + TRIverts[0].modulate[1] = 255; + TRIverts[0].modulate[2] = 255; + TRIverts[0].modulate[3] = 255 * p->alpha; + + VectorMA (org, p->height, vup, point); + VectorMA (point, -p->width, vright, point); + VectorCopy (point, TRIverts[1].xyz); + TRIverts[1].st[0] = 0; + TRIverts[1].st[1] = 0; + TRIverts[1].modulate[0] = 255; + TRIverts[1].modulate[1] = 255; + TRIverts[1].modulate[2] = 255; + TRIverts[1].modulate[3] = 255 * p->alpha; + + VectorMA (org, p->height, vup, point); + VectorMA (point, p->width, vright, point); + VectorCopy (point, TRIverts[2].xyz); + TRIverts[2].st[0] = 0; + TRIverts[2].st[1] = 1; + TRIverts[2].modulate[0] = 255; + TRIverts[2].modulate[1] = 255; + TRIverts[2].modulate[2] = 255; + TRIverts[2].modulate[3] = 255 * p->alpha; + } + + } + else if (p->type == P_SPRITE) + { + vec3_t rr, ru; + vec3_t rotate_ang; + + VectorSet (color, 1.0, 1.0, 1.0); + time = cg.time - p->time; + time2 = p->endtime - p->time; + ratio = time / time2; + + width = p->width + ( ratio * ( p->endwidth - p->width) ); + height = p->height + ( ratio * ( p->endheight - p->height) ); + + if (p->roll) { + vectoangles( cg.refdef.viewaxis[0], rotate_ang ); + rotate_ang[ROLL] += p->roll; + AngleVectors ( rotate_ang, NULL, rr, ru); + } + + if (p->roll) { + VectorMA (org, -height, ru, point); + VectorMA (point, -width, rr, point); + } else { + VectorMA (org, -height, vup, point); + VectorMA (point, -width, vright, point); + } + VectorCopy (point, verts[0].xyz); + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255; + verts[0].modulate[1] = 255; + verts[0].modulate[2] = 255; + verts[0].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, 2*height, ru, point); + } else { + VectorMA (point, 2*height, vup, point); + } + VectorCopy (point, verts[1].xyz); + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255; + verts[1].modulate[1] = 255; + verts[1].modulate[2] = 255; + verts[1].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, 2*width, rr, point); + } else { + VectorMA (point, 2*width, vright, point); + } + VectorCopy (point, verts[2].xyz); + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255; + verts[2].modulate[1] = 255; + verts[2].modulate[2] = 255; + verts[2].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, -2*height, ru, point); + } else { + VectorMA (point, -2*height, vup, point); + } + VectorCopy (point, verts[3].xyz); + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255; + verts[3].modulate[1] = 255; + verts[3].modulate[2] = 255; + verts[3].modulate[3] = 255; + } + else if (p->type == P_SMOKE || p->type == P_SMOKE_IMPACT) + {// create a front rotating facing polygon + + if ( p->type == P_SMOKE_IMPACT && Distance( cg.snap->ps.origin, org ) > 1024) { + return; + } + + if (p->color == BLOODRED) + VectorSet (color, 0.22f, 0.0f, 0.0f); + else if (p->color == GREY75) + { + float len; + float greyit; + float val; + len = Distance (cg.snap->ps.origin, org); + if (!len) + len = 1; + + val = 4096/len; + greyit = 0.25 * val; + if (greyit > 0.5) + greyit = 0.5; + + VectorSet (color, greyit, greyit, greyit); + } + else + VectorSet (color, 1.0, 1.0, 1.0); + + time = cg.time - p->time; + time2 = p->endtime - p->time; + ratio = time / time2; + + if (cg.time > p->startfade) + { + invratio = 1 - ( (cg.time - p->startfade) / (p->endtime - p->startfade) ); + + if (p->color == EMISIVEFADE) + { + float fval; + fval = (invratio * invratio); + if (fval < 0) + fval = 0; + VectorSet (color, fval , fval , fval ); + } + invratio *= p->alpha; + } + else + invratio = 1 * p->alpha; + + if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) + invratio = 1; + + if (invratio > 1) + invratio = 1; + + width = p->width + ( ratio * ( p->endwidth - p->width) ); + height = p->height + ( ratio * ( p->endheight - p->height) ); + + if (p->type != P_SMOKE_IMPACT) + { + vec3_t temp; + + vectoangles (rforward, temp); + p->accumroll += p->roll; + temp[ROLL] += p->accumroll * 0.1; + AngleVectors ( temp, NULL, rright2, rup2); + } + else + { + VectorCopy (rright, rright2); + VectorCopy (rup, rup2); + } + + if (p->rotate) + { + VectorMA (org, -height, rup2, point); + VectorMA (point, -width, rright2, point); + } + else + { + VectorMA (org, -p->height, vup, point); + VectorMA (point, -p->width, vright, point); + } + VectorCopy (point, verts[0].xyz); + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255 * color[0]; + verts[0].modulate[1] = 255 * color[1]; + verts[0].modulate[2] = 255 * color[2]; + verts[0].modulate[3] = 255 * invratio; + + if (p->rotate) + { + VectorMA (org, -height, rup2, point); + VectorMA (point, width, rright2, point); + } + else + { + VectorMA (org, -p->height, vup, point); + VectorMA (point, p->width, vright, point); + } + VectorCopy (point, verts[1].xyz); + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255 * color[0]; + verts[1].modulate[1] = 255 * color[1]; + verts[1].modulate[2] = 255 * color[2]; + verts[1].modulate[3] = 255 * invratio; + + if (p->rotate) + { + VectorMA (org, height, rup2, point); + VectorMA (point, width, rright2, point); + } + else + { + VectorMA (org, p->height, vup, point); + VectorMA (point, p->width, vright, point); + } + VectorCopy (point, verts[2].xyz); + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255 * color[0]; + verts[2].modulate[1] = 255 * color[1]; + verts[2].modulate[2] = 255 * color[2]; + verts[2].modulate[3] = 255 * invratio; + + if (p->rotate) + { + VectorMA (org, height, rup2, point); + VectorMA (point, -width, rright2, point); + } + else + { + VectorMA (org, p->height, vup, point); + VectorMA (point, -p->width, vright, point); + } + VectorCopy (point, verts[3].xyz); + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255 * color[0]; + verts[3].modulate[1] = 255 * color[1]; + verts[3].modulate[2] = 255 * color[2]; + verts[3].modulate[3] = 255 * invratio; + + } + else if (p->type == P_BLEED) + { + vec3_t rr, ru; + vec3_t rotate_ang; + float alpha; + + alpha = p->alpha; + + if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) + alpha = 1; + + if (p->roll) + { + vectoangles( cg.refdef.viewaxis[0], rotate_ang ); + rotate_ang[ROLL] += p->roll; + AngleVectors ( rotate_ang, NULL, rr, ru); + } + else + { + VectorCopy (vup, ru); + VectorCopy (vright, rr); + } + + VectorMA (org, -p->height, ru, point); + VectorMA (point, -p->width, rr, point); + VectorCopy (point, verts[0].xyz); + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 111; + verts[0].modulate[1] = 19; + verts[0].modulate[2] = 9; + verts[0].modulate[3] = 255 * alpha; + + VectorMA (org, -p->height, ru, point); + VectorMA (point, p->width, rr, point); + VectorCopy (point, verts[1].xyz); + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 111; + verts[1].modulate[1] = 19; + verts[1].modulate[2] = 9; + verts[1].modulate[3] = 255 * alpha; + + VectorMA (org, p->height, ru, point); + VectorMA (point, p->width, rr, point); + VectorCopy (point, verts[2].xyz); + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 111; + verts[2].modulate[1] = 19; + verts[2].modulate[2] = 9; + verts[2].modulate[3] = 255 * alpha; + + VectorMA (org, p->height, ru, point); + VectorMA (point, -p->width, rr, point); + VectorCopy (point, verts[3].xyz); + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 111; + verts[3].modulate[1] = 19; + verts[3].modulate[2] = 9; + verts[3].modulate[3] = 255 * alpha; + + } + else if (p->type == P_FLAT_SCALEUP) + { + float width, height; + float sinR, cosR; + + if (p->color == BLOODRED) + VectorSet (color, 1, 1, 1); + else + VectorSet (color, 0.5, 0.5, 0.5); + + time = cg.time - p->time; + time2 = p->endtime - p->time; + ratio = time / time2; + + width = p->width + ( ratio * ( p->endwidth - p->width) ); + height = p->height + ( ratio * ( p->endheight - p->height) ); + + if (width > p->endwidth) + width = p->endwidth; + + if (height > p->endheight) + height = p->endheight; + + sinR = height * sin(DEG2RAD(p->roll)) * sqrt(2); + cosR = width * cos(DEG2RAD(p->roll)) * sqrt(2); + + VectorCopy (org, verts[0].xyz); + verts[0].xyz[0] -= sinR; + verts[0].xyz[1] -= cosR; + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255 * color[0]; + verts[0].modulate[1] = 255 * color[1]; + verts[0].modulate[2] = 255 * color[2]; + verts[0].modulate[3] = 255; + + VectorCopy (org, verts[1].xyz); + verts[1].xyz[0] -= cosR; + verts[1].xyz[1] += sinR; + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255 * color[0]; + verts[1].modulate[1] = 255 * color[1]; + verts[1].modulate[2] = 255 * color[2]; + verts[1].modulate[3] = 255; + + VectorCopy (org, verts[2].xyz); + verts[2].xyz[0] += sinR; + verts[2].xyz[1] += cosR; + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255 * color[0]; + verts[2].modulate[1] = 255 * color[1]; + verts[2].modulate[2] = 255 * color[2]; + verts[2].modulate[3] = 255; + + VectorCopy (org, verts[3].xyz); + verts[3].xyz[0] += cosR; + verts[3].xyz[1] -= sinR; + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255 * color[0]; + verts[3].modulate[1] = 255 * color[1]; + verts[3].modulate[2] = 255 * color[2]; + verts[3].modulate[3] = 255; + } + else if (p->type == P_FLAT) + { + + VectorCopy (org, verts[0].xyz); + verts[0].xyz[0] -= p->height; + verts[0].xyz[1] -= p->width; + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255; + verts[0].modulate[1] = 255; + verts[0].modulate[2] = 255; + verts[0].modulate[3] = 255; + + VectorCopy (org, verts[1].xyz); + verts[1].xyz[0] -= p->height; + verts[1].xyz[1] += p->width; + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255; + verts[1].modulate[1] = 255; + verts[1].modulate[2] = 255; + verts[1].modulate[3] = 255; + + VectorCopy (org, verts[2].xyz); + verts[2].xyz[0] += p->height; + verts[2].xyz[1] += p->width; + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255; + verts[2].modulate[1] = 255; + verts[2].modulate[2] = 255; + verts[2].modulate[3] = 255; + + VectorCopy (org, verts[3].xyz); + verts[3].xyz[0] += p->height; + verts[3].xyz[1] -= p->width; + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255; + verts[3].modulate[1] = 255; + verts[3].modulate[2] = 255; + verts[3].modulate[3] = 255; + + } + // Ridah + else if (p->type == P_ANIM) { + vec3_t rr, ru; + vec3_t rotate_ang; + int i, j; + + time = cg.time - p->time; + time2 = p->endtime - p->time; + ratio = time / time2; + if (ratio >= 1.0f) { + ratio = 0.9999f; + } + + width = p->width + ( ratio * ( p->endwidth - p->width) ); + height = p->height + ( ratio * ( p->endheight - p->height) ); + + // if we are "inside" this sprite, don't draw + if (Distance( cg.snap->ps.origin, org ) < width/1.5) { + return; + } + + i = p->shaderAnim; + j = (int)floor(ratio * shaderAnimCounts[p->shaderAnim]); + p->pshader = shaderAnims[i][j]; + + if (p->roll) { + vectoangles( cg.refdef.viewaxis[0], rotate_ang ); + rotate_ang[ROLL] += p->roll; + AngleVectors ( rotate_ang, NULL, rr, ru); + } + + if (p->roll) { + VectorMA (org, -height, ru, point); + VectorMA (point, -width, rr, point); + } else { + VectorMA (org, -height, vup, point); + VectorMA (point, -width, vright, point); + } + VectorCopy (point, verts[0].xyz); + verts[0].st[0] = 0; + verts[0].st[1] = 0; + verts[0].modulate[0] = 255; + verts[0].modulate[1] = 255; + verts[0].modulate[2] = 255; + verts[0].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, 2*height, ru, point); + } else { + VectorMA (point, 2*height, vup, point); + } + VectorCopy (point, verts[1].xyz); + verts[1].st[0] = 0; + verts[1].st[1] = 1; + verts[1].modulate[0] = 255; + verts[1].modulate[1] = 255; + verts[1].modulate[2] = 255; + verts[1].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, 2*width, rr, point); + } else { + VectorMA (point, 2*width, vright, point); + } + VectorCopy (point, verts[2].xyz); + verts[2].st[0] = 1; + verts[2].st[1] = 1; + verts[2].modulate[0] = 255; + verts[2].modulate[1] = 255; + verts[2].modulate[2] = 255; + verts[2].modulate[3] = 255; + + if (p->roll) { + VectorMA (point, -2*height, ru, point); + } else { + VectorMA (point, -2*height, vup, point); + } + VectorCopy (point, verts[3].xyz); + verts[3].st[0] = 1; + verts[3].st[1] = 0; + verts[3].modulate[0] = 255; + verts[3].modulate[1] = 255; + verts[3].modulate[2] = 255; + verts[3].modulate[3] = 255; + } + // done. + + if (!p->pshader) { +// (SA) temp commented out for DM +// CG_Printf ("CG_AddParticleToScene type %d p->pshader == ZERO\n", p->type); + return; + } + + if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT || p->type == P_WEATHER_FLURRY) + cgi.R_AddPolyToScene( p->pshader, 3, TRIverts ); + else + cgi.R_AddPolyToScene( p->pshader, 4, verts ); + +} + +// Ridah, made this static so it doesn't interfere with other files +static float roll = 0.0; + +/* +=============== +CG_AddParticles +=============== +*/ +void CG_AddParticles (void) +{ + cparticle_t *p, *next; + float alpha; + float time, time2; + vec3_t org; + int color; + cparticle_t *active, *tail; + int type; + vec3_t rotate_ang; + + if (!initparticles) + CG_ClearParticles (); + + VectorCopy( cg.refdef.viewaxis[0], vforward ); + VectorCopy( cg.refdef.viewaxis[1], vright ); + VectorCopy( cg.refdef.viewaxis[2], vup ); + + vectoangles( cg.refdef.viewaxis[0], rotate_ang ); + roll += ((cg.time - oldtime) * 0.1) ; + rotate_ang[ROLL] += (roll*0.9); + AngleVectors ( rotate_ang, rforward, rright, rup); + + oldtime = cg.time; + + active = NULL; + tail = NULL; + + for (p=active_particles ; p ; p=next) + { + + next = p->next; + + time = (cg.time - p->time)*0.001; + + alpha = p->alpha + time*p->alphavel; + if (alpha <= 0) + { // faded out + p->next = free_particles; + free_particles = p; + p->type = 0; + p->color = 0; + p->alpha = 0; + continue; + } + + if (p->type == P_SMOKE || p->type == P_ANIM || p->type == P_BLEED || p->type == P_SMOKE_IMPACT) + { + if (cg.time > p->endtime) + { + p->next = free_particles; + free_particles = p; + p->type = 0; + p->color = 0; + p->alpha = 0; + + continue; + } + + } + + if (p->type == P_WEATHER_FLURRY) + { + if (cg.time > p->endtime) + { + p->next = free_particles; + free_particles = p; + p->type = 0; + p->color = 0; + p->alpha = 0; + + continue; + } + } + + + if (p->type == P_FLAT_SCALEUP_FADE) + { + if (cg.time > p->endtime) + { + p->next = free_particles; + free_particles = p; + p->type = 0; + p->color = 0; + p->alpha = 0; + continue; + } + + } + + if ((p->type == P_BAT || p->type == P_SPRITE) && p->endtime < 0) { + // temporary sprite + CG_AddParticleToScene (p, p->org, alpha); + p->next = free_particles; + free_particles = p; + p->type = 0; + p->color = 0; + p->alpha = 0; + continue; + } + + p->next = NULL; + if (!tail) + active = tail = p; + else + { + tail->next = p; + tail = p; + } + + if (alpha > 1.0) + alpha = 1; + + color = p->color; + + time2 = time*time; + + org[0] = p->org[0] + p->vel[0]*time + p->accel[0]*time2; + org[1] = p->org[1] + p->vel[1]*time + p->accel[1]*time2; + org[2] = p->org[2] + p->vel[2]*time + p->accel[2]*time2; + + type = p->type; + + CG_AddParticleToScene (p, org, alpha); + } + + active_particles = active; +} + +/* +====================== +CG_AddParticles +====================== +*/ +void CG_ParticleSnowFlurry (qhandle_t pshader, centity_t *cent) +{ + cparticle_t *p; + qboolean turb = qtrue; + + if (!pshader) + CG_Printf ("CG_ParticleSnowFlurry pshader == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->color = 0; + p->alpha = 0.90f; + p->alphavel = 0; + + p->start = cent->currentState.origin2[0]; + p->end = cent->currentState.origin2[1]; + + p->endtime = cg.time + cent->currentState.time; + p->startfade = cg.time + cent->currentState.time2; + + p->pshader = pshader; + + if (rand()%100 > 90) + { + p->height = 32; + p->width = 32; + p->alpha = 0.10f; + } + else + { + p->height = 1; + p->width = 1; + } + + p->vel[2] = -20; + + p->type = P_WEATHER_FLURRY; + + if (turb) + p->vel[2] = -10; + + VectorCopy(cent->currentState.origin, p->org); + + p->org[0] = p->org[0]; + p->org[1] = p->org[1]; + p->org[2] = p->org[2]; + + p->vel[0] = p->vel[1] = 0; + + p->accel[0] = p->accel[1] = p->accel[2] = 0; + + p->vel[0] += cent->currentState.angles[0] * 32 + (crandom() * 16); + p->vel[1] += cent->currentState.angles[1] * 32 + (crandom() * 16); + p->vel[2] += cent->currentState.angles[2]; + + if (turb) + { + p->accel[0] = crandom () * 16; + p->accel[1] = crandom () * 16; + } + +} + +void CG_ParticleSnow (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum) +{ + cparticle_t *p; + + if (!pshader) + CG_Printf ("CG_ParticleSnow pshader == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->color = 0; + p->alpha = 0.40f; + p->alphavel = 0; + p->start = origin[2]; + p->end = origin2[2]; + p->pshader = pshader; + p->height = 1; + p->width = 1; + + p->vel[2] = -50; + + if (turb) + { + p->type = P_WEATHER_TURBULENT; + p->vel[2] = -50 * 1.3; + } + else + { + p->type = P_WEATHER; + } + + VectorCopy(origin, p->org); + + p->org[0] = p->org[0] + ( crandom() * range); + p->org[1] = p->org[1] + ( crandom() * range); + p->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); + + p->vel[0] = p->vel[1] = 0; + + p->accel[0] = p->accel[1] = p->accel[2] = 0; + + if (turb) + { + p->vel[0] = crandom() * 16; + p->vel[1] = crandom() * 16; + } + + // Rafael snow pvs check + p->snum = snum; + p->link = qtrue; + +} + +void CG_ParticleBubble (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum) +{ + cparticle_t *p; + float randsize; + + if (!pshader) + CG_Printf ("CG_ParticleSnow pshader == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->color = 0; + p->alpha = 0.40f; + p->alphavel = 0; + p->start = origin[2]; + p->end = origin2[2]; + p->pshader = pshader; + + randsize = 1 + (crandom() * 0.5); + + p->height = randsize; + p->width = randsize; + + p->vel[2] = 50 + ( crandom() * 10 ); + + if (turb) + { + p->type = P_BUBBLE_TURBULENT; + p->vel[2] = 50 * 1.3; + } + else + { + p->type = P_BUBBLE; + } + + VectorCopy(origin, p->org); + + p->org[0] = p->org[0] + ( crandom() * range); + p->org[1] = p->org[1] + ( crandom() * range); + p->org[2] = p->org[2] + ( crandom() * (p->start - p->end)); + + p->vel[0] = p->vel[1] = 0; + + p->accel[0] = p->accel[1] = p->accel[2] = 0; + + if (turb) + { + p->vel[0] = crandom() * 4; + p->vel[1] = crandom() * 4; + } + + // Rafael snow pvs check + p->snum = snum; + p->link = qtrue; + +} + +void CG_ParticleSmoke (qhandle_t pshader, centity_t *cent) +{ + + // using cent->density = enttime + // cent->frame = startfade + cparticle_t *p; + + if (!pshader) + CG_Printf ("CG_ParticleSmoke == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + + p->endtime = cg.time + cent->currentState.time; + p->startfade = cg.time + cent->currentState.time2; + + p->color = 0; + p->alpha = 1.0; + p->alphavel = 0; + p->start = cent->currentState.origin[2]; + p->end = cent->currentState.origin2[2]; + p->pshader = pshader; + p->rotate = qfalse; + p->height = 8; + p->width = 8; + p->endheight = 32; + p->endwidth = 32; + p->type = P_SMOKE; + + VectorCopy(cent->currentState.origin, p->org); + + p->vel[0] = p->vel[1] = 0; + p->accel[0] = p->accel[1] = p->accel[2] = 0; + + p->vel[2] = 5; + + if (cent->currentState.frame == 1)// reverse gravity + p->vel[2] *= -1; + + p->roll = 8 + (crandom() * 4); +} + + +void CG_ParticleBulletDebris (vec3_t org, vec3_t vel, int duration) +{ + + cparticle_t *p; + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + + p->endtime = cg.time + duration; + p->startfade = cg.time + duration/2; + + p->color = EMISIVEFADE; + p->alpha = 1.0; + p->alphavel = 0; + + p->height = 0.5; + p->width = 0.5; + p->endheight = 0.5; + p->endwidth = 0.5; + + p->pshader = cgs.media.tracerShader; + + p->type = P_SMOKE; + + VectorCopy(org, p->org); + + p->vel[0] = vel[0]; + p->vel[1] = vel[1]; + p->vel[2] = vel[2]; + p->accel[0] = p->accel[1] = p->accel[2] = 0; + + p->accel[2] = -60; + p->vel[2] += -20; + +} + +/* +====================== +CG_ParticleExplosion +====================== +*/ + +void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd) +{ + cparticle_t *p; + int anim; + + if (animStr < (char *)10) + CG_Error( "CG_ParticleExplosion: animStr is probably an index rather than a string" ); + + // find the animation string + for (anim=0; shaderAnimNames[anim]; anim++) { + if (!Q_stricmp( animStr, shaderAnimNames[anim] )) + break; + } + if (!shaderAnimNames[anim]) { + CG_Error("CG_ParticleExplosion: unknown animation string: %s\n", animStr); + return; + } + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->alpha = 1.0; + p->alphavel = 0; + + if (duration < 0) { + duration *= -1; + p->roll = 0; + } else { + p->roll = crandom()*179; + } + + p->shaderAnim = anim; + + p->width = sizeStart; + p->height = sizeStart*shaderAnimSTRatio[anim]; // for sprites that are stretch in either direction + + p->endheight = sizeEnd; + p->endwidth = sizeEnd*shaderAnimSTRatio[anim]; + + p->endtime = cg.time + duration; + + p->type = P_ANIM; + + VectorCopy( origin, p->org ); + VectorCopy( vel, p->vel ); + VectorClear( p->accel ); + +} + +// Rafael Shrapnel +void CG_AddParticleShrapnel (localEntity_t *le) +{ + return; +} +// done. + +int CG_NewParticleArea (int num) +{ + // const char *str; + char *str; + char *token; + int type; + vec3_t origin, origin2; + int i; + float range = 0; + int turb; + int numparticles; + int snum; + + str = (char *) CG_ConfigString (num); + if (!str[0]) + return (0); + + // returns type 128 64 or 32 + token = COM_Parse (&str); + type = atoi (token); + + if (type == 1) + range = 128; + else if (type == 2) + range = 64; + else if (type == 3) + range = 32; + else if (type == 0) + range = 256; + else if (type == 4) + range = 8; + else if (type == 5) + range = 16; + else if (type == 6) + range = 32; + else if (type == 7) + range = 64; + + + for (i=0; i<3; i++) + { + token = COM_Parse (&str); + origin[i] = atof (token); + } + + for (i=0; i<3; i++) + { + token = COM_Parse (&str); + origin2[i] = atof (token); + } + + token = COM_Parse (&str); + numparticles = atoi (token); + + token = COM_Parse (&str); + turb = atoi (token); + + token = COM_Parse (&str); + snum = atoi (token); + + for (i=0; i= 4) + CG_ParticleBubble (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum); + else + CG_ParticleSnow (cgs.media.waterBubbleShader, origin, origin2, turb, range, snum); + } + + return (1); +} + +void CG_SnowLink (centity_t *cent, qboolean particleOn) +{ + cparticle_t *p, *next; + int id; + + id = cent->currentState.frame; + + for (p=active_particles ; p ; p=next) + { + next = p->next; + + if (p->type == P_WEATHER || p->type == P_WEATHER_TURBULENT) + { + if (p->snum == id) + { + if (particleOn) + p->link = qtrue; + else + p->link = qfalse; + } + } + + } +} + +void CG_ParticleImpactSmokePuff (qhandle_t pshader, vec3_t origin) +{ + cparticle_t *p; + + if (!pshader) + CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->alpha = 0.25; + p->alphavel = 0; + p->roll = crandom()*179; + + p->pshader = pshader; + + p->endtime = cg.time + 1000; + p->startfade = cg.time + 100; + + p->width = rand()%4 + 8; + p->height = rand()%4 + 8; + + p->endheight = p->height *2; + p->endwidth = p->width * 2; + + p->endtime = cg.time + 500; + + p->type = P_SMOKE_IMPACT; + + VectorCopy( origin, p->org ); + VectorSet(p->vel, 0, 0, 20); + VectorSet(p->accel, 0, 0, 20); + + p->rotate = qtrue; +} + +void CG_Particle_Bleed (qhandle_t pshader, vec3_t start, vec3_t dir, int fleshEntityNum, int duration) +{ + cparticle_t *p; + + if (!pshader) + CG_Printf ("CG_Particle_Bleed pshader == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->alpha = 1.0; + p->alphavel = 0; + p->roll = 0; + + p->pshader = pshader; + + p->endtime = cg.time + duration; + + if (fleshEntityNum) + p->startfade = cg.time; + else + p->startfade = cg.time + 100; + + p->width = 4; + p->height = 4; + + p->endheight = 4+rand()%3; + p->endwidth = p->endheight; + + p->type = P_SMOKE; + + VectorCopy( start, p->org ); + p->vel[0] = 0; + p->vel[1] = 0; + p->vel[2] = -20; + VectorClear( p->accel ); + + p->rotate = qfalse; + + p->roll = rand()%179; + + p->color = BLOODRED; + p->alpha = 0.75; + +} + +void CG_Particle_OilParticle (qhandle_t pshader, centity_t *cent) +{ + cparticle_t *p; + + int time; + int time2; + float ratio; + + float duration = 1500; + + time = cg.time; + time2 = cg.time + cent->currentState.time; + + ratio =(float)1 - ((float)time / (float)time2); + + if (!pshader) + CG_Printf ("CG_Particle_OilParticle == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->alpha = 1.0; + p->alphavel = 0; + p->roll = 0; + + p->pshader = pshader; + + p->endtime = cg.time + duration; + + p->startfade = p->endtime; + + p->width = 1; + p->height = 3; + + p->endheight = 3; + p->endwidth = 1; + + p->type = P_SMOKE; + + VectorCopy(cent->currentState.origin, p->org ); + + p->vel[0] = (cent->currentState.origin2[0] * (16 * ratio)); + p->vel[1] = (cent->currentState.origin2[1] * (16 * ratio)); + p->vel[2] = (cent->currentState.origin2[2]); + + p->snum = 1.0f; + + VectorClear( p->accel ); + + p->accel[2] = -20; + + p->rotate = qfalse; + + p->roll = rand()%179; + + p->alpha = 0.75; + +} + + +void CG_Particle_OilSlick (qhandle_t pshader, centity_t *cent) +{ + cparticle_t *p; + + if (!pshader) + CG_Printf ("CG_Particle_OilSlick == ZERO!\n"); + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + + if (cent->currentState.angles2[2]) + p->endtime = cg.time + cent->currentState.angles2[2]; + else + p->endtime = cg.time + 60000; + + p->startfade = p->endtime; + + p->alpha = 1.0; + p->alphavel = 0; + p->roll = 0; + + p->pshader = pshader; + + if (cent->currentState.angles2[0] || cent->currentState.angles2[1]) + { + p->width = cent->currentState.angles2[0]; + p->height = cent->currentState.angles2[0]; + + p->endheight = cent->currentState.angles2[1]; + p->endwidth = cent->currentState.angles2[1]; + } + else + { + p->width = 8; + p->height = 8; + + p->endheight = 16; + p->endwidth = 16; + } + + p->type = P_FLAT_SCALEUP; + + p->snum = 1.0; + + VectorCopy(cent->currentState.origin, p->org ); + + p->org[2]+= 0.55 + (crandom() * 0.5); + + p->vel[0] = 0; + p->vel[1] = 0; + p->vel[2] = 0; + VectorClear( p->accel ); + + p->rotate = qfalse; + + p->roll = rand()%179; + + p->alpha = 0.75; + +} + +void CG_OilSlickRemove (centity_t *cent) +{ + cparticle_t *p, *next; + int id; + + id = 1.0f; + + if (!id) + CG_Printf ("CG_OilSlickRevove NULL id\n"); + + for (p=active_particles ; p ; p=next) + { + next = p->next; + + if (p->type == P_FLAT_SCALEUP) + { + if (p->snum == id) + { + p->endtime = cg.time + 100; + p->startfade = p->endtime; + p->type = P_FLAT_SCALEUP_FADE; + + } + } + + } +} + +qboolean ValidBloodPool (vec3_t start) +{ +#define EXTRUDE_DIST 0.5 + + vec3_t angles; + vec3_t right, up; + vec3_t this_pos, x_pos, center_pos, end_pos; + float x, y; + float fwidth, fheight; + trace_t trace; + vec3_t normal; + + fwidth = 16; + fheight = 16; + + VectorSet (normal, 0, 0, 1); + + vectoangles (normal, angles); + AngleVectors (angles, NULL, right, up); + + VectorMA (start, EXTRUDE_DIST, normal, center_pos); + + for (x= -fwidth/2; xendpos, start); + legit = ValidBloodPool (start); + + if (!legit) + return; + + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + + p->endtime = cg.time + 3000; + p->startfade = p->endtime; + + p->alpha = 1.0; + p->alphavel = 0; + p->roll = 0; + + p->pshader = pshader; + + rndSize = 0.4 + random()*0.6; + + p->width = 8*rndSize; + p->height = 8*rndSize; + + p->endheight = 16*rndSize; + p->endwidth = 16*rndSize; + + p->type = P_FLAT_SCALEUP; + + VectorCopy(start, p->org ); + + p->vel[0] = 0; + p->vel[1] = 0; + p->vel[2] = 0; + VectorClear( p->accel ); + + p->rotate = qfalse; + + p->roll = rand()%179; + + p->alpha = 0.75; + + p->color = BLOODRED; +} + +#define NORMALSIZE 16 +#define LARGESIZE 32 + +void CG_ParticleBloodCloud (centity_t *cent, vec3_t origin, vec3_t dir) +{ + float length; + float dist; + float crittersize; + vec3_t angles, forward; + vec3_t point; + cparticle_t *p; + int i; + + dist = 0; + + length = VectorLength (dir); + vectoangles (dir, angles); + AngleVectors (angles, forward, NULL, NULL); + + crittersize = LARGESIZE; + + if (length) + dist = length / crittersize; + + if (dist < 1) + dist = 1; + + VectorCopy (origin, point); + + for (i=0; inext; + p->next = active_particles; + active_particles = p; + + p->time = cg.time; + p->alpha = 1.0; + p->alphavel = 0; + p->roll = 0; + + p->pshader = cgs.media.smokePuffShader; + + p->endtime = cg.time + 350 + (crandom() * 100); + + p->startfade = cg.time; + + p->width = LARGESIZE; + p->height = LARGESIZE; + p->endheight = LARGESIZE; + p->endwidth = LARGESIZE; + + p->type = P_SMOKE; + + VectorCopy( origin, p->org ); + + p->vel[0] = 0; + p->vel[1] = 0; + p->vel[2] = -1; + + VectorClear( p->accel ); + + p->rotate = qfalse; + + p->roll = rand()%179; + + p->color = BLOODRED; + + p->alpha = 0.75; + + } + + +} + +void CG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed) +{ + cparticle_t *p; + + if (!free_particles) + return; + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + + p->endtime = cg.time + duration; + p->startfade = cg.time + duration/2; + + p->color = EMISIVEFADE; + p->alpha = 0.4f; + p->alphavel = 0; + + p->height = 0.5; + p->width = 0.5; + p->endheight = 0.5; + p->endwidth = 0.5; + + p->pshader = cgs.media.tracerShader; + + p->type = P_SMOKE; + + VectorCopy(org, p->org); + + p->org[0] += (crandom() * x); + p->org[1] += (crandom() * y); + + p->vel[0] = vel[0]; + p->vel[1] = vel[1]; + p->vel[2] = vel[2]; + + p->accel[0] = p->accel[1] = p->accel[2] = 0; + + p->vel[0] += (crandom() * 4); + p->vel[1] += (crandom() * 4); + p->vel[2] += (20 + (crandom() * 10)) * speed; + + p->accel[0] = crandom () * 4; + p->accel[1] = crandom () * 4; + +} + +void CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir) +{ + float length; + float dist; + float crittersize; + vec3_t angles, forward; + vec3_t point; + cparticle_t *p; + int i; + + dist = 0; + + VectorNegate (dir, dir); + length = VectorLength (dir); + vectoangles (dir, angles); + AngleVectors (angles, forward, NULL, NULL); + + crittersize = LARGESIZE; + + if (length) + dist = length / crittersize; + + if (dist < 1) + dist = 1; + + VectorCopy (origin, point); + + for (i=0; inext; + p->next = active_particles; + active_particles = p; + + p->time = cg.time; + p->alpha = 5.0; + p->alphavel = 0; + p->roll = 0; + + p->pshader = cgs.media.smokePuffShader; + + // RF, stay around for long enough to expand and dissipate naturally + if (length) + p->endtime = cg.time + 4500 + (crandom() * 3500); + else + p->endtime = cg.time + 750 + (crandom() * 500); + + p->startfade = cg.time; + + p->width = LARGESIZE; + p->height = LARGESIZE; + + // RF, expand while falling + p->endheight = LARGESIZE*3.0; + p->endwidth = LARGESIZE*3.0; + + if (!length) + { + p->width *= 0.2f; + p->height *= 0.2f; + + p->endheight = NORMALSIZE; + p->endwidth = NORMALSIZE; + } + + p->type = P_SMOKE; + + VectorCopy( point, p->org ); + + p->vel[0] = crandom()*6; + p->vel[1] = crandom()*6; + p->vel[2] = random()*20; + + // RF, add some gravity/randomness + p->accel[0] = crandom()*3; + p->accel[1] = crandom()*3; + p->accel[2] = -PARTICLE_GRAVITY*0.4; + + VectorClear( p->accel ); + + p->rotate = qfalse; + + p->roll = rand()%179; + + p->alpha = 0.75; + + } + + +} + +void CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha) +{ + cparticle_t *p; + + if (!pshader) + CG_Printf ("CG_ParticleImpactSmokePuff pshader == ZERO!\n"); + + if (!free_particles) + return; + + p = free_particles; + free_particles = p->next; + p->next = active_particles; + active_particles = p; + p->time = cg.time; + p->alpha = 1.0; + p->alphavel = 0; + p->roll = rand()%179; + + p->pshader = pshader; + + if (duration > 0) + p->endtime = cg.time + duration; + else + p->endtime = duration; + + p->startfade = cg.time; + + p->width = size; + p->height = size; + + p->endheight = size; + p->endwidth = size; + + p->type = P_SPRITE; + + VectorCopy( origin, p->org ); + + p->rotate = qfalse; +} diff --git a/code/cgame/cg_players.c b/code/cgame/cg_players.c new file mode 100644 index 00000000..85a7f83e --- /dev/null +++ b/code/cgame/cg_players.c @@ -0,0 +1,396 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_players.c -- handle the media and animation for player entities +#include "cg_local.h" + +/* +============================================================================= + +CLIENT INFO + +============================================================================= +*/ + +/* +====================== +CG_NewClientInfo +====================== +*/ +// su44: it seems MoHAA's CS_PLAYERS +// contains only player names. +void CG_NewClientInfo( int clientNum ) { + clientInfo_t *ci; + clientInfo_t newInfo; + const char *configstring; + const char *v; + + ci = &cgs.clientinfo[clientNum]; + + configstring = CG_ConfigString( clientNum + CS_PLAYERS ); + if ( !configstring[0] ) { + memset( ci, 0, sizeof( *ci ) ); + return; // player just left + } + + // build into a temp buffer so the defer checks can use + // the old value + memset( &newInfo, 0, sizeof( newInfo ) ); + + // isolate the player's name + v = Info_ValueForKey(configstring, "name"); + Q_strncpyz( newInfo.name, v, sizeof( newInfo.name ) ); + + // replace whatever was there with the new one + *ci = newInfo; +} + +//========================================================================== + +/* +=============== +CG_PlayerFloatSprite + +Float a sprite over the player's head +=============== +*/ +static void CG_PlayerFloatSprite( centity_t *cent, qhandle_t shader ) { + int rf; + refEntity_t ent; + int b; + + if ( cent->currentState.number == cg.snap->ps.clientNum && !cg.renderingThirdPerson ) { + rf = RF_THIRD_PERSON; // only show in mirrors + } else { + rf = 0; + } + + memset( &ent, 0, sizeof( ent ) ); + // su44: try to get "eyes bone" bone position and use it to position the sprite + if(cent->bones && cgs.gameTIKIs[cent->currentState.modelindex] && + (b = cgi.TIKI_GetBoneIndex(cgs.gameTIKIs[cent->currentState.modelindex],"eyes bone")) != -1) { + vec3_t dummy; + CG_BoneLocal2World(¢->bones[b],cent->lerpOrigin,cent->lerpAngles,ent.origin,dummy); + ent.origin[2] += 24; + } else { + VectorCopy( cent->lerpOrigin, ent.origin ); + ent.origin[2] += 98; + } + ent.reType = RT_SPRITE; + ent.customShader = shader; + ent.radius = 8; + ent.renderfx = rf; + ent.shaderRGBA[0] = 255; + ent.shaderRGBA[1] = 255; + ent.shaderRGBA[2] = 255; + ent.shaderRGBA[3] = 255; + cgi.R_AddRefEntityToScene( &ent ); +} + +/* +=============== +CG_ExtractPlayerTeam + +su44: extract player team from entityState_t::eFlags +and save it to cg.clientinfo +=============== +*/ +void CG_ExtractPlayerTeam( centity_t *cent ) { + clientInfo_t *ci; + if( cent->currentState.number >= cgs.maxclients ) { + CG_Error("CG_ExtractPlayerTeam on non-client entity (%i)", cent->currentState.number ); + } + + ci = &cgs.clientinfo[cent->currentState.number]; + + // MoHAA sends ET_PLAYER team in entityFlags + if(cent->currentState.eFlags & EF_AXIS) { + ci->team = TEAM_AXIS; + } else if(cent->currentState.eFlags & EF_ALLIES) { + ci->team = TEAM_ALLIES; + //} else if(cent->currentState.eFlags & EF_SPECTATOR) { + // ci->team = TEAM_SPECTATOR; + } else { + ci->team = TEAM_FREEFORALL; + } +} + +/* +=============== +CG_PlayerSprites + +Float sprites over the player's head +=============== +*/ +void CG_PlayerSprites( centity_t *cent ) { + //int team; + + //if ( cent->currentState.eFlags & EF_CONNECTION ) { + // CG_PlayerFloatSprite( cent, cgs.media.connectionShader ); + // return; + //} + + //if ( cent->currentState.eFlags & EF_TALK ) { + // CG_PlayerFloatSprite( cent, cgs.media.balloonShader ); + // return; + //} + + //team = cgs.clientinfo[ cent->currentState.clientNum ].team; + //if ( !(cent->currentState.eFlags & EF_DEAD) && + // cg.snap->ps.stats[STAT_TEAM] == team && + // cgs.gametype >= GT_TEAM) { + // if (cg_drawFriend->integer) { + // //CG_PlayerFloatSprite( cent, cgs.media.friendShader ); + // } + // return; + //} + + // show team icons over friend heads + if(cgs.gametype >= GT_TEAM && !(cent->currentState.eFlags & EF_DEAD)) { + if(cent->currentState.eFlags & EF_AXIS && cg.snap->ps.stats[STAT_TEAM] == TEAM_AXIS) { + CG_PlayerFloatSprite(cent,cgi.R_RegisterShader("textures/hud/axis.tga")); + } else if(cent->currentState.eFlags & EF_ALLIES && cg.snap->ps.stats[STAT_TEAM] == TEAM_ALLIES) { + CG_PlayerFloatSprite(cent,cgi.R_RegisterShader("textures/hud/allies.tga")); + } + } +} + +/* +=============== +CG_PlayerShadow + +Returns the Z component of the surface being shadowed + + should it return a full plane instead of a Z? +=============== +*/ +#define SHADOW_DISTANCE 128 +static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) { + vec3_t end, mins = {-15, -15, 0}, maxs = {15, 15, 2}; + trace_t trace; + float alpha; + + *shadowPlane = 0; + + if ( cg_shadows->integer == 0 ) { + return qfalse; + } + + // send a trace down from the player to the ground + VectorCopy( cent->lerpOrigin, end ); + end[2] -= SHADOW_DISTANCE; + + cgi.CM_BoxTrace( &trace, cent->lerpOrigin, end, mins, maxs, 0, MASK_PLAYERSOLID, qfalse ); + + // no shadow if too high + if ( trace.fraction == 1.0 || trace.startsolid || trace.allsolid ) { + return qfalse; + } + + *shadowPlane = trace.endpos[2] + 1; + + if ( cg_shadows->integer != 1 ) { // no mark for stencil or projection shadows + return qtrue; + } + + // fade the shadow out with height + alpha = 1.0 - trace.fraction; + + // hack / FPE - bogus planes? + //assert( DotProduct( trace.plane.normal, trace.plane.normal ) != 0.0f ) + + // add the mark as a temporary, so it goes directly to the renderer + // without taking a spot in the cg_marks array + CG_ImpactMark( cgs.media.shadowMarkShader, trace.endpos, trace.plane.normal, + /*cent->pe.legs.yawAngle*/ 0 , alpha,alpha,alpha,1, qfalse, 24, qtrue ); + + return qtrue; +} + + +/* +=============== +CG_PlayerSplash + +Draw a mark at the water surface +=============== +*/ +static void CG_PlayerSplash( centity_t *cent ) { + //vec3_t start, end; + //trace_t trace; + //int contents; + //polyVert_t verts[4]; + + //if ( !cg_shadows->integer ) { + // return; + //} + + //VectorCopy( cent->lerpOrigin, end ); + //end[2] -= 24; + + //// if the feet aren't in liquid, don't make a mark + //// this won't handle moving water brushes, but they wouldn't draw right anyway... + //contents = cgi.CM_PointContents( end, 0 ); + //if ( !( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) ) { + // return; + //} + + //VectorCopy( cent->lerpOrigin, start ); + //start[2] += 32; + + //// if the head isn't out of liquid, don't make a mark + //contents = cgi.CM_PointContents( start, 0 ); + //if ( contents & ( CONTENTS_SOLID | CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) { + // return; + //} + + //// trace down to find the surface + //cgi.CM_BoxTrace( &trace, start, end, NULL, NULL, 0, ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ); + + //if ( trace.fraction == 1.0 ) { + // return; + //} + + //// create a mark polygon + //VectorCopy( trace.endpos, verts[0].xyz ); + //verts[0].xyz[0] -= 32; + //verts[0].xyz[1] -= 32; + //verts[0].st[0] = 0; + //verts[0].st[1] = 0; + //verts[0].modulate[0] = 255; + //verts[0].modulate[1] = 255; + //verts[0].modulate[2] = 255; + //verts[0].modulate[3] = 255; + + //VectorCopy( trace.endpos, verts[1].xyz ); + //verts[1].xyz[0] -= 32; + //verts[1].xyz[1] += 32; + //verts[1].st[0] = 0; + //verts[1].st[1] = 1; + //verts[1].modulate[0] = 255; + //verts[1].modulate[1] = 255; + //verts[1].modulate[2] = 255; + //verts[1].modulate[3] = 255; + + //VectorCopy( trace.endpos, verts[2].xyz ); + //verts[2].xyz[0] += 32; + //verts[2].xyz[1] += 32; + //verts[2].st[0] = 1; + //verts[2].st[1] = 1; + //verts[2].modulate[0] = 255; + //verts[2].modulate[1] = 255; + //verts[2].modulate[2] = 255; + //verts[2].modulate[3] = 255; + + //VectorCopy( trace.endpos, verts[3].xyz ); + //verts[3].xyz[0] += 32; + //verts[3].xyz[1] -= 32; + //verts[3].st[0] = 1; + //verts[3].st[1] = 0; + //verts[3].modulate[0] = 255; + //verts[3].modulate[1] = 255; + //verts[3].modulate[2] = 255; + //verts[3].modulate[3] = 255; + + //cgi.R_AddPolyToScene( cgs.media.wakeMarkShader, 4, verts ); +} + +/* +================= +CG_LightVerts +================= +*/ +int CG_LightVerts( vec3_t normal, int numVerts, polyVert_t *verts ) +{ +#if 0 + int i, j; + float incoming; + vec3_t ambientLight; + vec3_t lightDir; + vec3_t directedLight; + + for (i = 0; i < numVerts; i++) { + incoming = DotProduct (normal, lightDir); + if ( incoming <= 0 ) { + verts[i].modulate[0] = ambientLight[0]; + verts[i].modulate[1] = ambientLight[1]; + verts[i].modulate[2] = ambientLight[2]; + verts[i].modulate[3] = 255; + continue; + } + j = ( ambientLight[0] + incoming * directedLight[0] ); + if ( j > 255 ) { + j = 255; + } + verts[i].modulate[0] = j; + + j = ( ambientLight[1] + incoming * directedLight[1] ); + if ( j > 255 ) { + j = 255; + } + verts[i].modulate[1] = j; + + j = ( ambientLight[2] + incoming * directedLight[2] ); + if ( j > 255 ) { + j = 255; + } + verts[i].modulate[2] = j; + + verts[i].modulate[3] = 255; + } +#endif + return qtrue; +} + +/* +=============== +CG_Player +=============== +*/ +void CG_Player( centity_t *cent ) { + +} + + +//===================================================================== + +/* +=============== +CG_ResetPlayerEntity + +A player just came into view or teleported, so reset all animation info +=============== +*/ +void CG_ResetPlayerEntity( centity_t *cent ) { + cent->errorTime = -99999; // guarantee no error decay added + cent->extrapolated = qfalse; + + //BG_EvaluateTrajectory( ¢->currentState.pos, cg.time, cent->lerpOrigin ); + //BG_EvaluateTrajectory( ¢->currentState.apos, cg.time, cent->lerpAngles ); + + VectorCopy( cent->currentState.origin, cent->lerpOrigin ); + VectorCopy( cent->currentState.angles, cent->lerpAngles ); + + VectorCopy( cent->lerpOrigin, cent->rawOrigin ); + VectorCopy( cent->lerpAngles, cent->rawAngles ); +} + diff --git a/code/cgame/cg_playerstate.c b/code/cgame/cg_playerstate.c new file mode 100644 index 00000000..cf944c81 --- /dev/null +++ b/code/cgame/cg_playerstate.c @@ -0,0 +1,180 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_playerstate.c -- this file acts on changes in a new playerState_t +// With normal play, this will be done after local prediction, but when +// following another player or playing back a demo, it will be checked +// when the snapshot transitions like all the other entities + +#include "cg_local.h" + +/* +============== +CG_DamageFeedback +============== +*/ +void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) { + float left, front, up; + float kick; + int health; + float scale; + vec3_t dir; + vec3_t angles; + float dist; + float yaw, pitch; + + // show the attacking player's head and name in corner + cg.attackerTime = cg.time; + + // the lower on health you are, the greater the view kick will be + health = cg.snap->ps.stats[STAT_HEALTH]; + if ( health < 40 ) { + scale = 1; + } else { + scale = 40.0 / health; + } + kick = damage * scale; + + if (kick < 5) + kick = 5; + if (kick > 10) + kick = 10; + + // if yaw and pitch are both 255, make the damage always centered (falling, etc) + if ( yawByte == 255 && pitchByte == 255 ) { + cg.damageX = 0; + cg.damageY = 0; + cg.v_dmg_roll = 0; + cg.v_dmg_pitch = -kick; + } else { + // positional + pitch = pitchByte / 255.0 * 360; + yaw = yawByte / 255.0 * 360; + + angles[PITCH] = pitch; + angles[YAW] = yaw; + angles[ROLL] = 0; + + AngleVectors( angles, dir, NULL, NULL ); + VectorSubtract( vec3_origin, dir, dir ); + + front = DotProduct (dir, cg.refdef.viewaxis[0] ); + left = DotProduct (dir, cg.refdef.viewaxis[1] ); + up = DotProduct (dir, cg.refdef.viewaxis[2] ); + + dir[0] = front; + dir[1] = left; + dir[2] = 0; + dist = VectorLength( dir ); + if ( dist < 0.1 ) { + dist = 0.1f; + } + + cg.v_dmg_roll = kick * left; + + cg.v_dmg_pitch = -kick * front; + + if ( front <= 0.1 ) { + front = 0.1f; + } + cg.damageX = -left / front; + cg.damageY = up / dist; + } + + // clamp the position + if ( cg.damageX > 1.0 ) { + cg.damageX = 1.0; + } + if ( cg.damageX < - 1.0 ) { + cg.damageX = -1.0; + } + + if ( cg.damageY > 1.0 ) { + cg.damageY = 1.0; + } + if ( cg.damageY < - 1.0 ) { + cg.damageY = -1.0; + } + + // don't let the screen flashes vary as much + if ( kick > 10 ) { + kick = 10; + } + cg.damageValue = kick; + cg.v_dmg_time = cg.time + DAMAGE_TIME; + cg.damageTime = cg.snap->serverTime; +} + + + + +/* +================ +CG_Respawn + +A respawn happened this snapshot +================ +*/ +void CG_Respawn( void ) { + // no error decay on player movement + cg.thisFrameTeleport = qtrue; + + // display weapons available + cg.weaponSelectTime = cg.time; +} + +/* +=============== +CG_TransitionPlayerState + +=============== +*/ +void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops ) { + // check for changing follow mode + if ( ps->clientNum != ops->clientNum ) { + cg.thisFrameTeleport = qtrue; + // make sure we don't get any unwanted transition effects + *ops = *ps; + } + + // damage events (player is getting wounded) + //if ( ps->damageEvent != ops->damageEvent && ps->damageCount ) { + // CG_DamageFeedback( ps->damageYaw, ps->damagePitch, ps->damageCount ); + //} + + // respawning - TODO + //if ( ps->persistant[PERS_SPAWN_COUNT] != ops->persistant[PERS_SPAWN_COUNT] ) { + // CG_Respawn(); + //} + + if ( cg.mapRestart ) { + CG_Respawn(); + cg.mapRestart = qfalse; + } + + // smooth the ducking viewheight change + if ( ps->viewheight != ops->viewheight ) { + cg.duckChange = ps->viewheight - ops->viewheight; + cg.duckTime = cg.time; + } +} + diff --git a/code/cgame/cg_predict.c b/code/cgame/cg_predict.c new file mode 100644 index 00000000..17dd0391 --- /dev/null +++ b/code/cgame/cg_predict.c @@ -0,0 +1,556 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_predict.c -- this file generates cg.predictedPlayerState by either +// interpolating between snapshots from the server or locally predicting +// ahead the client's movement. +// It also handles local physics interaction, like fragments bouncing off walls + +#include "cg_local.h" + +static pmove_t cg_pmove; + +static int cg_numSolidEntities; +static centity_t *cg_solidEntities[MAX_ENTITIES_IN_SNAPSHOT]; +static int cg_numTriggerEntities; +static centity_t *cg_triggerEntities[MAX_ENTITIES_IN_SNAPSHOT]; + +/* +==================== +CG_BuildSolidList + +When a new cg.snap has been set, this function builds a sublist +of the entities that are actually solid, to make for more +efficient collision detection +==================== +*/ +void CG_BuildSolidList( void ) { + int i; + centity_t *cent; + snapshot_t *snap; + entityState_t *ent; + + cg_numSolidEntities = 0; + cg_numTriggerEntities = 0; + + if ( cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport ) { + snap = cg.nextSnap; + } else { + snap = cg.snap; + } + + for ( i = 0 ; i < snap->numEntities ; i++ ) { + cent = &cg_entities[ snap->entities[ i ].number ]; + ent = ¢->currentState; + + if ( ent->eType == ET_ITEM || ent->eType == ET_PUSH_TRIGGER || ent->eType == ET_TELEPORT_TRIGGER ) { + cg_triggerEntities[cg_numTriggerEntities] = cent; + cg_numTriggerEntities++; + continue; + } + + if ( cent->nextState.solid ) { + cg_solidEntities[cg_numSolidEntities] = cent; + cg_numSolidEntities++; + continue; + } + } +} + +/* +==================== +CG_ClipMoveToEntities + +==================== +*/ +static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + int skipNumber, int mask, trace_t *tr ) { + int i, x, zd, zu; + trace_t trace; + entityState_t *ent; + clipHandle_t cmodel; + vec3_t bmins, bmaxs; + vec3_t origin, angles; + centity_t *cent; + + for ( i = 0 ; i < cg_numSolidEntities ; i++ ) { + cent = cg_solidEntities[ i ]; + ent = ¢->currentState; + + if ( ent->number == skipNumber ) { + continue; + } + + if ( ent->solid == SOLID_BMODEL ) { + // special value for bmodel + cmodel = cgi.CM_InlineModel( ent->modelindex ); + VectorCopy( cent->lerpAngles, angles ); + //BG_EvaluateTrajectory( ¢->currentState.pos, cg.physicsTime, origin ); + // su44: BG_EvaluateTrajectory isnt used in MoHAA + VectorCopy(cent->lerpOrigin,origin); + } else { + // encoded bbox + x = (ent->solid & 255); + zd = ((ent->solid>>8) & 255); + zu = ((ent->solid>>16) & 255) - 32; + + bmins[0] = bmins[1] = -x; + bmaxs[0] = bmaxs[1] = x; + bmins[2] = -zd; + bmaxs[2] = zu; + + cmodel = cgi.CM_TempBoxModel( bmins, bmaxs, qfalse ); + VectorCopy( vec3_origin, angles ); + VectorCopy( cent->lerpOrigin, origin ); + } + + + cgi.CM_TransformedBoxTrace ( &trace, start, end, + mins, maxs, cmodel, mask, origin, angles, qfalse ); + + if (trace.allsolid || trace.fraction < tr->fraction) { + trace.entityNum = ent->number; + *tr = trace; + } else if (trace.startsolid) { + tr->startsolid = qtrue; + } + if ( tr->allsolid ) { + return; + } + } +} + +/* +================ +CG_Trace +================ +*/ +void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + int skipNumber, int mask ) { + CG_PlayerTrace( result, start, mins, maxs, end, skipNumber, mask, qfalse, qfalse ); +} + +/* +================ +CG_PlayerTrace +================ +*/ +void CG_PlayerTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + int skipNumber, int mask, int capsule, qboolean traceDeep ) { + trace_t t; + + cgi.CM_BoxTrace( &t, start, end, mins, maxs, 0, mask, traceDeep ); + t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; + // check all other solid models + CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t ); + + *result = t; +} + +/* +================ +CG_PointContents +================ +*/ +int CG_PointContents( const vec3_t point, int passEntityNum ) { + int i; + entityState_t *ent; + centity_t *cent; + clipHandle_t cmodel; + int contents; + + contents = cgi.CM_PointContents (point, 0); + + for ( i = 0 ; i < cg_numSolidEntities ; i++ ) { + cent = cg_solidEntities[ i ]; + + ent = ¢->currentState; + + if ( ent->number == passEntityNum ) { + continue; + } + + if (ent->solid != SOLID_BMODEL) { // special value for bmodel + continue; + } + + cmodel = cgi.CM_InlineModel( ent->modelindex ); + if ( !cmodel ) { + continue; + } + + contents |= cgi.CM_TransformedPointContents( point, cmodel, ent->origin, ent->angles ); + } + + return contents; +} + + +/* +======================== +CG_InterpolatePlayerState + +Generates cg.predictedPlayerState by interpolating between +cg.snap->player_state and cg.nextFrame->player_state +======================== +*/ +static void CG_InterpolatePlayerState( qboolean grabAngles ) { + float f; + int i; + playerState_t *out; + snapshot_t *prev, *next; + + out = &cg.predictedPlayerState; + prev = cg.snap; + next = cg.nextSnap; + + *out = cg.snap->ps; + + // if we are still allowing local input, short circuit the view angles + if ( grabAngles ) { + usercmd_t cmd; + int cmdNum; + + cmdNum = cgi.GetCurrentCmdNumber(); + cgi.GetUserCmd( cmdNum, &cmd ); + + PM_UpdateViewAngles( out, &cmd ); + } + + // if the next frame is a teleport, we can't lerp to it + if ( cg.nextFrameTeleport ) { + return; + } + + if ( !next || next->serverTime <= prev->serverTime ) { + return; + } + + f = (float)( cg.time - prev->serverTime ) / ( next->serverTime - prev->serverTime ); + + i = next->ps.bobCycle; + if ( i < prev->ps.bobCycle ) { + i += 256; // handle wraparound + } + out->bobCycle = prev->ps.bobCycle + f * ( i - prev->ps.bobCycle ); + + out->fLeanAngle = prev->ps.fLeanAngle + + f * (next->ps.fLeanAngle - prev->ps.fLeanAngle ); + + for ( i = 0 ; i < 3 ; i++ ) { + out->origin[i] = prev->ps.origin[i] + f * (next->ps.origin[i] - prev->ps.origin[i] ); + if ( !grabAngles ) { + out->viewangles[i] = LerpAngle( + prev->ps.viewangles[i], next->ps.viewangles[i], f ); + } + out->velocity[i] = prev->ps.velocity[i] + + f * (next->ps.velocity[i] - prev->ps.velocity[i] ); + } + +} + +/* +========================= +CG_TouchTriggerPrediction + +Predict push triggers and items +========================= +*/ +static void CG_TouchTriggerPrediction( void ) { + int i; + trace_t trace; + entityState_t *ent; + clipHandle_t cmodel; + centity_t *cent; + qboolean spectator; + + // dead clients don't activate triggers + if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) { + return; + } + + spectator = ( cg.predictedPlayerState.pm_type == PM_NOCLIP ); + + if ( cg.predictedPlayerState.pm_type != PM_NORMAL && !spectator ) { + return; + } + + for ( i = 0 ; i < cg_numTriggerEntities ; i++ ) { + cent = cg_triggerEntities[ i ]; + ent = ¢->currentState; + + if ( ent->solid != SOLID_BMODEL ) { + continue; + } + + cmodel = cgi.CM_InlineModel( ent->modelindex ); + if ( !cmodel ) { + continue; + } + + cgi.CM_BoxTrace( &trace, cg.predictedPlayerState.origin, cg.predictedPlayerState.origin, + cg_pmove.mins, cg_pmove.maxs, cmodel, -1, qfalse ); + + if ( !trace.startsolid ) { + continue; + } + + if ( ent->eType == ET_TELEPORT_TRIGGER ) { + cg.hyperspace = qtrue; + } else if ( ent->eType == ET_PUSH_TRIGGER ) { + //BG_TouchJumpPad( &cg.predictedPlayerState, ent ); + } + } +} + + + +/* +================= +CG_PredictPlayerState + +Generates cg.predictedPlayerState for the current cg.time +cg.predictedPlayerState is guaranteed to be valid after exiting. + +For demo playback, this will be an interpolation between two valid +playerState_t. + +For normal gameplay, it will be the result of predicted usercmd_t on +top of the most recent playerState_t received from the server. + +Each new snapshot will usually have one or more new usercmd over the last, +but we simulate all unacknowledged commands each time, not just the new ones. +This means that on an internet connection, quite a few pmoves may be issued +each frame. + +OPTIMIZE: don't re-simulate unless the newly arrived snapshot playerState_t +differs from the predicted one. Would require saving all intermediate +playerState_t during prediction. + +We detect prediction errors and allow them to be decayed off over several frames +to ease the jerk. +================= +*/ +void CG_PredictPlayerState( void ) { + int cmdNum, current; + playerState_t oldPlayerState; + qboolean moved; + usercmd_t oldestCmd; + usercmd_t latestCmd; + + cg.hyperspace = qfalse; // will be set if touching a trigger_teleport + + // if this is the first frame we must guarantee + // predictedPlayerState is valid even if there is some + // other error condition + if ( !cg.validPPS ) { + cg.validPPS = qtrue; + cg.predictedPlayerState = cg.snap->ps; + } + + + // demo playback just copies the moves + if ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_SPECTATE_FOLLOW) ) { + CG_InterpolatePlayerState( qfalse ); + return; + } + + // non-predicting local movement will grab the latest angles + if ( cg_nopredict->integer || cg_synchronousClients->integer ) { + CG_InterpolatePlayerState( qtrue ); + return; + } + +#if 1 + // su44: temporary disabling playerstate prediction + CG_InterpolatePlayerState( qtrue ); + return; +#endif + + // prepare for pmove + cg_pmove.ps = &cg.predictedPlayerState; + cg_pmove.trace = CG_PlayerTrace; + cg_pmove.pointcontents = CG_PointContents; + if ( cg_pmove.ps->pm_type == PM_DEAD ) { + cg_pmove.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; + } + else { + cg_pmove.tracemask = MASK_PLAYERSOLID; + } + if ( cg.snap->ps.stats[STAT_TEAM] == TEAM_SPECTATOR ) { + cg_pmove.tracemask &= ~CONTENTS_BODY; // spectators can fly through bodies + } + cg_pmove.noFootsteps = ( cgs.dmflags & DF_NO_FOOTSTEPS ) > 0; + + // save the state before the pmove so we can detect transitions + oldPlayerState = cg.predictedPlayerState; + + current = cgi.GetCurrentCmdNumber(); + + // if we don't have the commands right after the snapshot, we + // can't accurately predict a current position, so just freeze at + // the last good position we had + cmdNum = current - CMD_BACKUP + 1; + cgi.GetUserCmd( cmdNum, &oldestCmd ); + if ( oldestCmd.serverTime > cg.snap->ps.commandTime + && oldestCmd.serverTime < cg.time ) { // special check for map_restart + if ( cg_showmiss->integer ) { + CG_Printf ("exceeded PACKET_BACKUP on commands\n"); + } + return; + } + + // get the latest command so we can know which commands are from previous map_restarts + cgi.GetUserCmd( current, &latestCmd ); + + // get the most recent information we have, even if + // the server time is beyond our current cg.time, + // because predicted player positions are going to + // be ahead of everything else anyway + if ( cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport ) { + cg.predictedPlayerState = cg.nextSnap->ps; + cg.physicsTime = cg.nextSnap->serverTime; + } else { + cg.predictedPlayerState = cg.snap->ps; + cg.physicsTime = cg.snap->serverTime; + } + + if ( pmove_msec->integer < 8 ) { + cgi.Cvar_Set("pmove_msec", "8"); + } + else if (pmove_msec->integer > 33) { + cgi.Cvar_Set("pmove_msec", "33"); + } + + cg_pmove.pmove_fixed = pmove_fixed->integer;// | cg_pmove_fixed->integer; + cg_pmove.pmove_msec = pmove_msec->integer; + + // run cmds + moved = qfalse; + for ( cmdNum = current - CMD_BACKUP + 1 ; cmdNum <= current ; cmdNum++ ) { + // get the command + cgi.GetUserCmd( cmdNum, &cg_pmove.cmd ); + + if ( cg_pmove.pmove_fixed ) { + PM_UpdateViewAngles( cg_pmove.ps, &cg_pmove.cmd ); + } + + // don't do anything if the time is before the snapshot player time + if ( cg_pmove.cmd.serverTime <= cg.predictedPlayerState.commandTime ) { + continue; + } + + // don't do anything if the command was from a previous map_restart + if ( cg_pmove.cmd.serverTime > latestCmd.serverTime ) { + continue; + } + + // check for a prediction error from last frame + // on a lan, this will often be the exact value + // from the snapshot, but on a wan we will have + // to predict several commands to get to the point + // we want to compare + if ( cg.predictedPlayerState.commandTime == oldPlayerState.commandTime ) { + vec3_t delta; + float len; + + if ( cg.thisFrameTeleport ) { + // a teleport will not cause an error decay + VectorClear( cg.predictedError ); + if ( cg_showmiss->integer ) { + CG_Printf( "PredictionTeleport\n" ); + } + cg.thisFrameTeleport = qfalse; + } else { + vec3_t adjusted; + CG_AdjustPositionForMover( cg.predictedPlayerState.origin, + cg.predictedPlayerState.groundEntityNum, cg.physicsTime, cg.oldTime, adjusted ); + + if ( cg_showmiss->integer ) { + if (!VectorCompare( oldPlayerState.origin, adjusted )) { + CG_Printf("prediction error\n"); + } + } + VectorSubtract( oldPlayerState.origin, adjusted, delta ); + len = VectorLength( delta ); + if ( len > 0.1 ) { + if ( cg_showmiss->integer ) { + CG_Printf("Prediction miss: %f\n", len); + } + if ( cg_errorDecay->integer ) { + int t; + float f; + + t = cg.time - cg.predictedErrorTime; + f = ( cg_errorDecay->value - t ) / cg_errorDecay->value; + if ( f < 0 ) { + f = 0; + } + if ( f > 0 && cg_showmiss->integer ) { + CG_Printf("Double prediction decay: %f\n", f); + } + VectorScale( cg.predictedError, f, cg.predictedError ); + } else { + VectorClear( cg.predictedError ); + } + VectorAdd( delta, cg.predictedError, cg.predictedError ); + cg.predictedErrorTime = cg.oldTime; + } + } + } + + if ( cg_pmove.pmove_fixed ) { + cg_pmove.cmd.serverTime = ((cg_pmove.cmd.serverTime + pmove_msec->integer-1) / pmove_msec->integer) * pmove_msec->integer; + } + + Pmove (&cg_pmove); + + moved = qtrue; + + // add push trigger movement effects + CG_TouchTriggerPrediction(); + + // check for predictable events that changed from previous predictions + //CG_CheckChangedPredictableEvents(&cg.predictedPlayerState); + } + + if ( cg_showmiss->integer > 1 ) { + CG_Printf( "[%i : %i] ", cg_pmove.cmd.serverTime, cg.time ); + } + + if ( !moved ) { + if ( cg_showmiss->integer ) { + CG_Printf( "not moved\n" ); + } + return; + } + + // adjust for the movement of the groundentity + CG_AdjustPositionForMover( cg.predictedPlayerState.origin, + cg.predictedPlayerState.groundEntityNum, + cg.physicsTime, cg.time, cg.predictedPlayerState.origin ); + + // fire events and other transition triggered things + CG_TransitionPlayerState( &cg.predictedPlayerState, &oldPlayerState ); +} + + diff --git a/code/cgame/cg_public.h b/code/cgame/cg_public.h new file mode 100644 index 00000000..14bd6345 --- /dev/null +++ b/code/cgame/cg_public.h @@ -0,0 +1,585 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +#ifndef __CG_PUBLIC_H__ +#define __CG_PUBLIC_H__ + +#define CMD_BACKUP 64 +#define CMD_MASK (CMD_BACKUP - 1) +// allow a lot of command backups for very fast systems +// multiple commands may be combined into a single packet, so this +// needs to be larger than PACKET_BACKUP + + +#define MAX_ENTITIES_IN_SNAPSHOT 256 +#define MAX_SOUNDS_IN_SNAPSHOT 64 +#define MAX_HUDDRAW_ELEMENTS 256 + +// snapshots are a view of the server at a given time + +// Snapshots are generated at regular time intervals by the server, +// but they may not be sent if a client's rate level is exceeded, or +// they may be dropped by the network. +typedef struct { + int snapFlags; // SNAPFLAG_RATE_DELAYED, etc + int ping; + + int serverTime; // server time the message is valid for (in msec) + + byte areamask[MAX_MAP_AREA_BYTES]; // portalarea visibility bits + + playerState_t ps; // complete information about the current player at this time + + int numEntities; // all of the entities that need to be presented + entityState_t entities[MAX_ENTITIES_IN_SNAPSHOT]; // at the time of this snapshot + + int numServerCommands; // text based server commands to execute when this + int serverCommandSequence; // snapshot becomes current + + int number_of_sounds; + server_sound_t sounds[MAX_SOUNDS_IN_SNAPSHOT]; +} snapshot_t; + +typedef struct stopwatch_s { + int iStartTime; + int iEndTime; +} stopwatch_t; + +typedef struct hdelement_s { + qhandle_t hShader; + char shaderName[ 64 ]; + int iX; + int iY; + int iWidth; + int iHeight; + float vColor[ 4 ]; + int iHorizontalAlign; + int iVerticalAlign; + qboolean bVirtualScreen; + char string[ 2048 ]; + char fontName[ 64 ]; + fontheader_t *pFont; +} hdelement_t; + +/* +================================================================== + +clientAnim_t structure, wiped each new gamestate +reserved for viewmodelanim + +================================================================== +*/ +typedef struct clientAnim_s +{ + frameInfo_t vmFrameInfo[ MAX_FRAMEINFOS ]; + int lastVMAnim; + int lastVMAnimChanged; + + int currentVMAnimSlot; + int currentVMDuration; + + qboolean crossBlending; + + int lastEquippedWeaponStat; + char lastActiveItem[ 80 ]; + int lastAnimPrefixIndex; + + vec3_t currentVMPosOffset; + + refEntity_t ref; + dtiki_t *tiki; + +} clientAnim_t; + +enum { + CGAME_EVENT_NONE, + CGAME_EVENT_TEAMMENU, + CGAME_EVENT_SCOREBOARD, + CGAME_EVENT_EDITHUD +}; + + +/* +================================================================== + +functions imported from the main executable + +================================================================== +*/ + +#define CGAME_IMPORT_API_VERSION 4 + +#if 0 +typedef struct clientGameImport_s { + + // print message on the local console + void( *Printf )( const char *fmt, ... ); + void( *DPrintf )( const char *fmt, ... ); + + // abort the game + void( *Error )( int level, const char *fmt, ... ); + + // milliseconds should only be used for performance tuning, never + // for anything game related. Get time from the CG_DrawActiveFrame parameter + int( *Milliseconds )( void ); + + void *( *Malloc )( int size ); + void( *Free )( void *ptr ); + + // console variable interaction + cvar_t *( *Cvar_Get )( const char *varName, const char *varValue, int varFlags ); + void( *Cvar_Register )( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ); + void( *Cvar_Update )( vmCvar_t *vmCvar ); + void( *Cvar_Set )( const char *var_name, const char *value ); + void( *Cvar_VariableStringBuffer )( const char *var_name, char *buffer, int bufsize ); + + // ServerCommand and ConsoleCommand parameter access + int( *Argc )( void ); + char *( *Argv )( int n ); + char *( *Args )( void ); + + // filesystem access + // returns length of file + int( *FS_FOpenFile )( const char *qpath, fileHandle_t *f, fsMode_t mode ); + int ( *FS_Read )( void *buffer, int len, fileHandle_t f ); + int ( *FS_Write )( const void *buffer, int len, fileHandle_t f ); + void ( *FS_FCloseFile )( fileHandle_t f ); + int ( *FS_GetFileList )( const char *path, const char *extension, char *listbuf, int bufsize ); + int ( *FS_Seek )( fileHandle_t f, long offset, fsOrigin_t origin ); // fsOrigin_t + int ( *FS_ReadFile )( const char *name, void **buffer, qboolean quiet ); + void ( *FS_FreeFile )( void *buffer ); + int ( *FS_WriteFile )( const char *qpath, const void *buffer, int size ); + int ( *FS_FOpenFileWrite )( const char *name ); + void ( *FS_Flush )( fileHandle_t f ); + + // add commands to the local console as if they were typed in + // for map changing, etc. The command is not executed immediately, + // but will be executed in order the next time console commands + // are processed + void( *SendConsoleCommand )( const char *text ); + + // register a command name so the console can perform command completion. + // FIXME: replace this with a normal console command "defineCommand"? + void( *AddCommand )( const char *cmdName, xcommand_t function ); + + // send a string to the server over the network + void( *SendClientCommand )( const char *s ); + + // force a screen update, only used during gamestate load + void( *UpdateScreen )( void ); + + // model collision + void( *CM_LoadMap )( const char *mapname ); + int( *CM_NumInlineModels )( void ); + clipHandle_t( *CM_InlineModel )( int index ); // 0 = world, 1+ = bmodels + clipHandle_t( *CM_TempBoxModel )( const vec3_t mins, const vec3_t maxs, qboolean capsule ); + int( *CM_PointContents )( const vec3_t p, clipHandle_t model ); + int( *CM_TransformedPointContents )( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles ); + void( *CM_BoxTrace )( trace_t *results, const vec3_t start, const vec3_t end, + const vec3_t mins, const vec3_t maxs, + clipHandle_t model, int brushmask, qboolean capsule ); + void( *CM_TransformedBoxTrace )( trace_t *results, const vec3_t start, const vec3_t end, + const vec3_t mins, const vec3_t maxs, + clipHandle_t model, int brushmask, + const vec3_t origin, const vec3_t angles, qboolean capsule ); + + // Returns the projection of a polygon onto the solid brushes in the world + int( *CM_MarkFragments )( int numPoints, const vec3_t *points, + const vec3_t projection, + int maxPoints, vec3_t pointBuffer, + int maxFragments, markFragment_t *fragmentBuffer ); + + // normal sounds will have their volume dynamically changed as their entity + // moves and the listener moves + void( *S_StartSound )( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx ); + void( *S_StopLoopingSound )( int entnum ); + + // a local sound is always played full volume + void( *S_StartLocalSound )( sfxHandle_t sfx, int channelNum ); + void( *S_ClearLoopingSounds )( qboolean killall ); + void( *S_AddLoopingSound )( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ); + void( *S_AddRealLoopingSound )( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ); + void( *S_UpdateEntityPosition )( int entityNum, const vec3_t origin ); + + // respatialize recalculates the volumes of sound as they should be heard by the + // given entityNum and position + void( *S_Respatialize )( int entityNum, const vec3_t origin, vec3_t axis[ 3 ], int inwater ); + sfxHandle_t( *S_RegisterSound )( const char *sample, qboolean compressed ); // returns buzz if not found + void( *S_StartBackgroundTrack )( const char *intro, const char *loop ); // empty name stops music + void( *S_StopBackgroundTrack )( void ); + + + void( *R_LoadWorldMap )( const char *mapname ); + + // all media should be registered during level startup to prevent + // hitches during gameplay + qhandle_t( *R_RegisterModel )( const char *name ); // returns rgb axis if not found + qhandle_t( *R_RegisterSkin )( const char *name ); // returns all white if not found + qhandle_t( *R_RegisterShader )( const char *name ); // returns all white if not found + qhandle_t( *R_RegisterShaderNoMip )( const char *name ); // returns all white if not found + + // a scene is built up by calls to R_ClearScene and the various R_Add functions. + // Nothing is drawn until R_RenderScene is called. + void( *R_ClearScene )( void ); + void( *R_AddRefEntityToScene )( const refEntity_t *re ); + + // polys are intended for simple wall marks, not really for doing + // significant construction + void( *R_AddPolyToScene )( qhandle_t hShader, int numVerts, const polyVert_t *verts ); + void( *R_AddPolysToScene )( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys ); + void( *R_AddLightToScene )( const vec3_t org, float intensity, float r, float g, float b ); + int( *R_LightForPoint )( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); + void( *R_RenderScene )( const refdef_t *fd ); + void( *R_SetColor )( const float *rgba ); // NULL = 1,1,1,1 + void( *R_DrawStretchPic )( float x, float y, float w, float h, + float s1, float t1, float s2, float t2, qhandle_t hShader ); + void( *R_ModelBounds )( clipHandle_t model, vec3_t mins, vec3_t maxs ); + int( *R_LerpTag )( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, + float frac, const char *tagName ); + void( *R_RemapShader )( const char *oldShader, const char *newShader, const char *timeOffset ); + + // The glconfig_t will not change during the life of a cgame. + // If it needs to change, the entire cgame will be restarted, because + // all the qhandle_t are then invalid. + void( *GetGlconfig )( glconfig_t *glconfig ); + + // the gamestate should be grabbed at startup, and whenever a + // configstring changes + void( *GetGameState )( gameState_t *gamestate ); + + // cgame will poll each frame to see if a newer snapshot has arrived + // that it is interested in. The time is returned seperately so that + // snapshot latency can be calculated. + void( *GetCurrentSnapshotNumber )( int *snapshotNumber, int *serverTime ); + + // a snapshot get can fail if the snapshot (or the entties it holds) is so + // old that it has fallen out of the client system queue + qboolean( *GetSnapshot )( int snapshotNumber, snapshot_t *snapshot ); + + // retrieve a text command from the server stream + // the current snapshot will hold the number of the most recent command + // qfalse can be returned if the client system handled the command + // argc )() / argv )() can be used to examine the parameters of the command + qboolean( *GetServerCommand )( int serverCommandNumber ); + + // returns the most recent command number that can be passed to GetUserCmd + // this will always be at least one higher than the number in the current + // snapshot, and it may be quite a few higher if it is a fast computer on + // a lagged connection + int( *GetCurrentCmdNumber )( void ); + + qboolean( *GetUserCmd )( int cmdNumber, usercmd_t *ucmd ); + + // used for the weapon select and zoom + void( *SetUserCmdValue )( int stateValue, float sensitivityScale ); + + int( *MemoryRemaining )( void ); + void( *R_RegisterFont )( const char *fontName, int pointSize, fontInfo_t *font ); + qboolean( *Key_IsDown )( int keynum ); + int( *Key_GetCatcher )( void ); + void( *Key_SetCatcher )( int catcher ); + int( *Key_GetKey )( const char *binding ); + + // ley0k: animation system + const char *( *Anim_NameForNum )( tiki_t *tiki, int animNum ); + int( *Anim_NumForName )( tiki_t *tiki, const char *name ); + int( *Anim_Random )( tiki_t *tiki, const char *name ); + int( *Anim_NumFrames )( tiki_t *tiki, int animNum ); + float( *Anim_Time )( tiki_t *tiki, int animNum ); + float( *Anim_Frametime )( tiki_t *tiki, int animNum ); + int ( *Anim_Delta )( tiki_t *tiki, int animNum, vec3_t delta ); + int ( *Anim_Flags )( tiki_t *tiki, int animNum ); + float ( *Anim_CrossblendTime )( tiki_t *tiki, int animNum ); + qboolean ( *Anim_HasCommands )( tiki_t *tiki, int animNum ); + qboolean ( *Frame_Commands )( tiki_t *tiki, int animNum, int frameNum, tiki_cmd_t *tikiCmds ); + qboolean( *Frame_CommandsTime )( tiki_t *pmdl, int animNum, float start, float end, tiki_cmd_t *tikiCmd ); + + // ley0k: TIKI tags + int ( *Tag_NumForName )( tiki_t *tiki, const char * name ); + const char *( *Tag_NameForNum )( tiki_t *tiki, int num ); + + // IneQuation, wombat + int ( *R_Text_Width )( fontInfo_t *font, const char *text, int limit, qboolean useColourCodes ); + int ( *R_Text_Height )( fontInfo_t *font, const char *text, int limit, qboolean useColourCodes ); + void ( *R_Text_Paint )( fontInfo_t *font, float x, float y, float scale, float alpha, const char *text, float adjust, int limit, qboolean useColourCodes, qboolean is640 ); + void ( *R_Text_PaintChar )( fontInfo_t *font, float x, float y, float scale, int c, qboolean is640 ); + // su44: MoHAA TIKI model system API + tiki_t* ( *TIKI_RegisterModel )( const char *fname ); + bone_t* ( *TIKI_GetBones )( int numBones ); + void ( *TIKI_SetChannels )( struct tiki_s *tiki, int animIndex, float animTime, float animWeight, bone_t *bones ); + void ( *TIKI_AppendFrameBoundsAndRadius )( struct tiki_s *tiki, int animIndex, float animTime, float *outRadius, vec3_t outBounds[ 2 ] ); + void ( *TIKI_Animate )( struct tiki_s *tiki, bone_t *bones ); + int ( *TIKI_GetBoneNameIndex )( const char *boneName ); + int ( *TIKI_GetAnimIndex )( tiki_t *tiki, const char *animName ); // returns -1 if not found + int ( *TIKI_GetBoneIndex )( tiki_t *tiki, const char *boneName ); // returns -1 if not found + void ( *SetEyeInfo )( vec3_t origin, vec3_t angles ); + // su44: these are here only for cg_parsemsg.c + int ( *MSG_ReadBits )( int bits ); + int ( *MSG_ReadByte )(); + int ( *MSG_ReadShort )(); + float ( *MSG_ReadCoord )(); + void ( *MSG_ReadDir )( vec3_t dir ); + char *( *MSG_ReadString )(); + // su44: I need these for cg_beam.c + int ( *R_GetShaderWidth )( qhandle_t shader ); + int ( *R_GetShaderHeight )( qhandle_t shader ); + + int ( *CIN_PlayCinematic )( const char *arg0, int xpos, int ypos, int width, int height, int bits ); + e_status ( *CIN_StopCinematic )( int handle ); + e_status ( *CIN_RunCinematic )( int handle ); + void ( *CIN_DrawCinematic )( int handle ); + void ( *CIN_SetExtents )( int handle, int x, int y, int w, int h ); + + qboolean ( *loadCamera )( const char *name ); + void ( *startCamera )( int time ); + qboolean ( *getCameraInfo )( int time, vec3_t *origin, vec3_t *angles ); + + qboolean ( *GetEntityToken )( char *buffer, int bufferSize ); + + clientAnim_t *anim; +} clientGameImport_t; +#endif + +typedef struct clientGameImport_s { + + int apiVersion; + + void ( *Printf )( const char *fmt, ... ); + void ( *DPrintf )( const char *fmt, ... ); + void ( *DebugPrintf )( const char *fmt, ... ); + void * ( *Malloc )( size_t size ); + void ( *Free )( void *ptr ); + void ( *Error )( int level, const char *fmt, ... ); + int ( *Milliseconds )( ); + const char * ( *LV_ConvertString )( const char *string ); + cvar_t * ( *Cvar_Get )( const char *varName, const char *varValue, int varFlags ); + void ( *Cvar_Set )( const char *varName, const char *varValue ); + int ( *Argc )( ); + char * ( *Argv )( int arg ); + char * ( *Args )( ); + void ( *AddCommand )( const char *cmdName ); + void ( *Cmd_Stuff )( const char *text ); + void ( *Cmd_Execute )( int exec_when, const char *text ); + void ( *Cmd_TokenizeString )( const char *textIn ); + int ( *FS_ReadFile )( const char *qpath, void **buffer, qboolean quiet ); + void ( *FS_FreeFile )( void *buffer ); + int ( *FS_WriteFile )( const char *qpath, const void *buffer, int size ); + void ( *FS_WriteTextFile )( const char *qpath, const void *buffer, int size ); + void ( *SendConsoleCommand )( const char *text ); + int ( *MSG_ReadBits )( int bits ); + int ( *MSG_ReadChar )( ); + int ( *MSG_ReadByte )( ); + int ( *MSG_ReadSVC )( ); + int ( *MSG_ReadShort )( ); + int ( *MSG_ReadLong )( ); + float ( *MSG_ReadFloat )( ); + char * ( *MSG_ReadString )( ); + char * ( *MSG_ReadStringLine )( ); + float ( *MSG_ReadAngle8 )( ); + float ( *MSG_ReadAngle16 )( ); + void ( *MSG_ReadData )( void *data, int len ); + float ( *MSG_ReadCoord )( ); + void ( *MSG_ReadDir )( vec3_t dir ); + void ( *SendClientCommand )( const char *text ); + void ( *CM_LoadMap )( const char *name ); + clipHandle_t ( *CM_InlineModel )( int index ); + int ( *CM_NumInlineModels )( ); + int ( *CM_PointContents )( const vec3_t point, clipHandle_t model ); + int ( *CM_TransformedPointContents )( const vec3_t point, clipHandle_t model, const vec3_t origin, const vec3_t angles ); + void ( *CM_BoxTrace )( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, int model, int brushMask, int cylinder ); + void ( *CM_TransformedBoxTrace )( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, int model, int brushMask, const vec3_t origin, const vec3_t angles, int cylinder ); + clipHandle_t ( *CM_TempBoxModel )( const vec3_t mins, const vec3_t maxs, int contents ); + void ( *CM_PrintBSPFileSizes )( ); + qboolean ( *CM_LeafInPVS )( int leaf1, int leaf2 ); + int ( *CM_PointLeafnum )( const vec3_t p ); + int ( *R_MarkFragments )( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared ); + int ( *R_MarkFragmentsForInlineModel )( clipHandle_t bmodel, vec3_t vAngles, vec3_t vOrigin, int numPoints, vec3_t *points, vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared ); + void ( *R_GetInlineModelBounds )( int index, vec3_t mins, vec3_t maxs ); + void ( *R_GetLightingForDecal )( vec3_t light, vec3_t facing, vec3_t origin ); + void ( *R_GetLightingForSmoke )( vec3_t light, vec3_t origin ); + int ( *R_GatherLightSources )( vec3_t pos, vec3_t *lightPos, vec3_t *lightIntensity, int maxLights ); + void ( *S_StartSound )( const vec3_t origin, int entNum, int entChannel, sfxHandle_t sfxHandle, float volume, float minDist, float pitch, float maxDist, int streamed ); + void ( *S_StartLocalSound )( const char *sound_name ); + void ( *S_StopSound )( int entNum, int channel ); + void ( *S_ClearLoopingSounds )( ); + void ( *S_AddLoopingSound )( const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle, float volume, float minDist, float maxDist, float pitch, int flags ); + void ( *S_Respatialize )( int entityNum, const vec3_t head, vec3_t axis[3] ); + void ( *S_BeginRegistration )( ); + sfxHandle_t ( *S_RegisterSound )( const char *name, qboolean streamed ); + void ( *S_EndRegistration )( ); + void ( *S_UpdateEntity )( int entityNum, const vec3_t origin, const vec3_t velocity, qboolean useListener ); + void ( *S_SetReverb )( int reverbType, float reverbLevel ); + void ( *S_SetGlobalAmbientVolumeLevel )( float volume ); + float ( *S_GetSoundTime )( sfxHandle_t handle ); + int ( *S_ChannelNameToNum )( const char *name ); + const char * ( *S_ChannelNumToName )( int channel ); + int ( *S_IsSoundPlaying )( int channelNumber, const char *name ); + void ( *MUSIC_NewSoundtrack )( const char *name ); + void( *MUSIC_UpdateMood )( int current, int fallback ); + void ( *MUSIC_UpdateVolume )( float volume, float fadeTime ); + float * ( *get_camera_offset )( qboolean *lookActive, qboolean *resetView ); + void ( *R_ClearScene )( ); + void ( *R_RenderScene )( const refdef_t *fd ); + void ( *R_LoadWorldMap )( const char *name ); + void ( *R_PrintBSPFileSizes )( ); + int ( *MapVersion )( ); + int ( *R_MapVersion )( ); + qhandle_t ( *R_RegisterModel )( const char *name ); + qhandle_t ( *R_SpawnEffectModel )( const char *name, vec3_t pos, vec3_t axis[3] ); + qhandle_t ( *R_RegisterServerModel )( const char *name ); + void ( *R_UnregisterServerModel )( qhandle_t hModel ); + qhandle_t ( *R_RegisterSkin )( const char *name ); + qhandle_t ( *R_RegisterShader )( const char *name ); + qhandle_t ( *R_RegisterShaderNoMip )( const char *name ); + void ( *R_AddRefEntityToScene )( const refEntity_t *ent, int parentEntityNumber ); + void ( *R_AddRefSpriteToScene )( const refEntity_t *ent ); + void ( *R_AddLightToScene )( const vec3_t org, float intensity, float r, float g, float b, int type ); + qboolean ( *R_AddPolyToScene )( qhandle_t hShader, int numVerts, const polyVert_t *verts, int renderFx ); + void ( *R_AddTerrainMarkToScene )( int terrainIndex, qhandle_t hShader, int numVerts, polyVert_t *verts, int renderFx ); + void ( *R_SetColor )( const vec4_t rgba ); + void ( *R_DrawStretchPic )( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); + fontheader_t * ( *R_LoadFont )( const char *name ); + void( *R_DrawString )( fontheader_t *font, const char *text, float x, float y, int maxLen, qboolean virtualScreen ); + refEntity_t * ( *R_GetRenderEntity )( int entityNumber ); + void ( *R_ModelBounds )( clipHandle_t model, vec3_t mins, vec3_t maxs ); + float ( *R_ModelRadius )( qhandle_t handle ); + float ( *R_Noise )( float x, float y, float z, float t ); + void ( *R_DebugLine )( vec3_t start, vec3_t end, float r, float g, float b, float alpha ); + baseshader_t * ( *GetShader )( int shaderNum ); + void ( *R_SwipeBegin )( float thistime, float life, qhandle_t shader ); + void ( *R_SwipePoint )( vec3_t point1, vec3_t point2, float time ); + void ( *R_SwipeEnd )( ); + int ( *R_GetShaderWidth )( qhandle_t hShader ); + int ( *R_GetShaderHeight )( qhandle_t hShader ); + void ( *R_DrawBox )( float x, float y, float w, float h ); + void ( *GetGameState )( gameState_t *gameState ); + int ( *GetSnapshot )( int snapshotNumber, snapshot_t *snapshot ); + int ( *GetServerStartTime )( ); + void ( *SetTime )( int time ); + void ( *GetCurrentSnapshotNumber )( int *snapshotNumber, int *serverTime ); + void ( *GetGlconfig )( glconfig_t *glConfig ); + qboolean ( *GetParseEntityState )( int parseEntityNumber, entityState_t *state ); + int ( *GetCurrentCmdNumber )( ); + qboolean ( *GetUserCmd )( int cmdNumber, usercmd_t *userCmd ); + qboolean ( *GetServerCommand )( int serverCommandNumber, qboolean differentServer ); + qboolean ( *Alias_Add )( const char *alias, const char *name, const char *parameters ); + qboolean( *Alias_ListAdd )( AliasList_t *list, const char *alias, const char *name, const char *parameters ); + const char * ( *Alias_FindRandom )( const char *alias, AliasListNode_t **ret ); + const char * ( *Alias_ListFindRandom )( AliasList_t *list, const char *alias, AliasListNode_t **ret ); + void ( *Alias_Dump )( ); + void ( *Alias_Clear )( ); + AliasList_t * ( *AliasList_New )( const char *name ); + void( *Alias_ListFindRandomRange )( AliasList_t *list, const char *alias, int *minIndex, int *maxIndex, float *totalWeight ); + AliasList_t * ( *Alias_GetGlobalList )( ); + void ( *UI_ShowMenu )( const char *name, qboolean bForce ); + void ( *UI_HideMenu )( const char *name, qboolean bForce ); + int ( *UI_FontStringWidth )( fontheader_t *font, const char *string, int maxLen ); + int ( *Key_StringToKeynum )( const char *str ); + const char * ( *Key_KeynumToBindString )( int keyNum ); + void ( *Key_GetKeysForCommand )( const char *command, int *key1, int *key2 ); + dtiki_t * ( *R_Model_GetHandle )( qhandle_t handle ); + int ( *TIKI_NumAnims )( dtiki_t *pmdl ); + void ( *TIKI_CalculateBounds )( dtiki_t *pmdl, float scale, vec3_t mins, vec3_t maxs ); + const char * ( *TIKI_Name )( dtiki_t *tiki ); + void * ( *TIKI_GetSkeletor )( dtiki_t *tiki, int entNum ); + void ( *TIKI_SetEyeTargetPos )( dtiki_t *tiki, int entNum, vec3_t pos ); + const char * ( *Anim_NameForNum )( dtiki_t *tiki, int animNum ); + int ( *Anim_NumForName )( dtiki_t *tiki, const char *name ); + int ( *Anim_Random )( dtiki_t *tiki, const char *name ); + int ( *Anim_NumFrames )( dtiki_t *tiki, int animNum ); + float ( *Anim_Time )( dtiki_t *tiki, int animNum ); + float ( *Anim_Frametime )( dtiki_t *tiki, int animNum ); + void ( *Anim_Delta )( dtiki_t *tiki, int animNum, vec3_t delta ); + int ( *Anim_Flags )( dtiki_t *tiki, int animNum ); + int ( *Anim_FlagsSkel )( dtiki_t *tiki, int animNum ); + float ( *Anim_CrossblendTime )( dtiki_t *tiki, int animNum ); + qboolean ( *Anim_HasCommands )( dtiki_t *tiki, int animNum ); + qboolean ( *Frame_Commands )( dtiki_t *tiki, int animNum, int frameNum, tiki_cmd_t *tikiCmds ); + qboolean ( *Frame_CommandsTime )( dtiki_t *pmdl, int animNum, float start, float end, tiki_cmd_t *tikiCmd ); + int ( *Surface_NameToNum )( dtiki_t *pmdl, const char *name ); + int ( *Tag_NumForName )( dtiki_t *pmdl, const char *name ); + const char * ( *Tag_NameForNum )( dtiki_t *pmdl, int animNum ); + void ( *ForceUpdatePose )( refEntity_t *model ); + orientation_t ( *TIKI_Orientation )( refEntity_t *model, int tagNum ); + qboolean ( *TIKI_IsOnGround )( refEntity_t *model, int tagNum, float threshold ); + void ( *UI_ShowScoreBoard )( const char *menuName ); + void ( *UI_HideScoreBoard )( ); + void ( *UI_SetScoreBoardItem )( int itemNumber, const char *data1, const char *data2, const char *data3, const char *data4, const char *data5, const char *data6, const char *data7, const char *data8, vec3_t textColor, vec3_t backColor, qboolean isHeader ); + void ( *UI_DeleteScoreBoardItems )( int maxIndex ); + void ( *UI_ToggleDMMessageConsole )( int consoleMode ); + dtiki_t * ( *TIKI_FindTiki )( const char *path ); + void ( *LoadResource )( const char *name ); + void ( *FS_CanonicalFilename )( char *name ); + + cvar_t *fsDebug; + hdelement_t *hudDrawElements; + clientAnim_t *anim; + stopwatch_t *stopWatch; + void *pUnknownVar; +} clientGameImport_t; + +/* +================================================================== + +functions exported to the main executable + +================================================================== +*/ + +typedef struct clientGameExport_s { + void ( *CG_Init )( clientGameImport_t *imported, int serverMessageNum, int serverCommandSequence, int clientNum ); + void ( *CG_Shutdown )( void ); + void ( *CG_DrawActiveFrame )( int serverTime, int frametime, stereoFrame_t stereoView, qboolean demoPlayback ); + qboolean ( *CG_ConsoleCommand )( void ); + void ( *CG_GetRendererConfig )( void ); + void ( *CG_Draw2D )( void ); + void ( *CG_EyePosition )( vec3_t *eyePos ); + void ( *CG_EyeOffset )( vec3_t *eyeOffset ); + void ( *CG_EyeAngles )( vec3_t *eyeAngles ); + float ( *CG_SensitivityScale )( ); + void ( *CG_ParseCGMessage )( ); + void ( *CG_RefreshHudDrawElements )( ); + void ( *CG_HudDrawShader )( int info ); + void ( *CG_HudDrawFont )( int info ); + int ( *CG_GetParent )( int entNum ); + float ( *CG_GetObjectiveAlpha )( ); + int ( *CG_PermanentMark )( vec3_t origin, vec3_t dir, float orientation, float sScale, float tScale, float red, float green, float blue, float alpha, qboolean doLighting, float sCenter, float tCenter, markFragment_t *markFragments, void *polyVerts ); + int ( *CG_PermanentTreadMarkDecal )( treadMark_t *treadMark, qboolean startSegment, qboolean doLighting, markFragment_t *markFragments, void *polyVerts ); + int ( *CG_PermanentUpdateTreadMark )( treadMark_t *treadMark, float alpha, float minSegment, float maxSegment, float maxOffset, float texScale ); + void ( *CG_ProcessInitCommands )( dtiki_t *tiki, refEntity_t *ent ); + void ( *CG_EndTiki )( dtiki_t *tiki ); + char *( *CG_GetColumnName )( int columnNum, int *columnWidth ); + void ( *CG_GetScoreBoardColor )( float *red, float *green, float *blue, float *alpha ); + void ( *CG_GetScoreBoardFontColor )( float *red, float *green, float *blue, float *alpha ); + int ( *CG_GetScoreBoardDrawHeader )( ); + void ( *CG_GetScoreBoardPosition )( float *x, float *y, float *width, float *height ); + int ( *CG_WeaponCommandButtonBits )( ); + int ( *CG_CheckCaptureKey )( int key, qboolean down, unsigned int time ); + + qboolean ( *CG_Command_ProcessFile )( char *name, qboolean quiet, dtiki_t *curTiki ); + +} clientGameExport_t; + +//---------------------------------------------- + +#endif // __CG_PUBLIC_H__ diff --git a/code/cgame/cg_rain.c b/code/cgame/cg_rain.c new file mode 100644 index 00000000..d5115e8a --- /dev/null +++ b/code/cgame/cg_rain.c @@ -0,0 +1,175 @@ +/* +=========================================================================== +Copyright (C) 2011 su44 + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// cg_rain.c - MoHAA rain/snow effects + +#include "cg_local.h" + +void CG_InitRainEffect() { + cg.rain.density = 0; + cg.rain.speed = 2048.0; + cg.rain.length = 90.0; + cg.rain.min_dist = 512.0; + cg.rain.width = 1.f; + cg.rain.speed_vary = 512; + cg.rain.slant = 50; + memset(cg.rain.shader,0,sizeof(cg.rain.shader)); + strcpy(cg.rain.shader[0],"textures/hud/allies"); // only for debuging + cg.rain.numshaders = 0; +} + +void CG_RainCSUpdated(int num, const char *str) { + if( num == CS_RAIN_DENSITY ) { + cg.rain.density = atof(str); + } else if( num == CS_RAIN_SPEED ) { + cg.rain.speed = atof(str); + } else if( num == CS_RAIN_SPEEDVARY ) { + cg.rain.speed_vary = atof(str); + } else if( num == CS_RAIN_SLANT ) { + cg.rain.slant = atof(str); + } else if( num == CS_RAIN_LENGTH ) { + cg.rain.length = atof(str); + } else if( num == CS_RAIN_MINDIST ) { + cg.rain.min_dist = atof(str); + } else if( num == CS_RAIN_WIDTH ) { + cg.rain.width = atof(str); + } else if( num == CS_RAIN_SHADER ) { + if(cg.rain.numshaders) { + int i; + for(i = 0; i < cg.rain.numshaders; i++) { + sprintf(cg.rain.shader[i],"%s%i",str,i); + } + } + } else if( num == CS_RAIN_NUMSHADERS ) { + cg.rain.numshaders = atoi(str); + } else { + CG_Error("CG_RainCSUpdated: unknown cs index\n"); + } +} + +void CG_Rain(centity_t *cent) { + char *shadername; + vec3_t vEnd; + vec3_t vStart; + //vec4_t fcolor; + byte fcolor[4]; // su44: in MoHAA that's a float[4] + vec3_t maxs; + vec3_t mins; + float f; + vec3_t tMins,tMaxs; + vec3_t size; + int i; + int density; + int r; + + fcolor[0] = 1.f; + fcolor[1] = 1.f; + fcolor[2] = 1.f; + fcolor[3] = 1.f; + //if ( !cg_rain.integer ) + // return; + cgi.R_ModelBounds(cgs.gameModels[cent->currentState.modelindex],mins,maxs); + + tMins[0] = mins[0] + cent->lerpOrigin[0]; + f = cg.snap->ps.origin[0] - cg.rain.min_dist; + if ( f > tMins[0] ) + tMins[0] = f; + + tMins[1] = mins[1] + cent->lerpOrigin[1]; + f = cg.snap->ps.origin[1] - cg.rain.min_dist; + if ( f > tMins[1] ) + tMins[1] = f; + tMins[2] = mins[2] + cent->lerpOrigin[2]; + + tMaxs[0] = maxs[0] + cent->lerpOrigin[0]; + f = cg.snap->ps.origin[0] + cg.rain.min_dist; + if ( f > tMaxs[0] ) + tMaxs[0] = f; + + tMaxs[1] = maxs[1] + cent->lerpOrigin[1]; + f = cg.snap->ps.origin[1] + cg.rain.min_dist; + if( f > tMaxs[1] ) + tMaxs[1] = f; + + tMaxs[2] = maxs[2] + cent->lerpOrigin[2]; + if ( tMins[0] >= tMaxs[0] ) + return; + + if (tMins[1] >= tMaxs[1] ) + return; + + + size[0] = tMaxs[0] - tMins[0]; + size[1] = tMaxs[1] - tMins[1]; + size[2] = tMaxs[2] - tMins[2]; + density = (signed int)(cg.rain.density / 200.0 * sqrt(size[1] * size[0])); + if ( density > 4096 ) + density = 4096; + r = rand(); + if ( cg.rain.numshaders ) { + shadername = &cg.rain.shader[r % cg.rain.numshaders][0]; + } else { + shadername = &cg.rain.shader[0][0]; + } + for(i = 0; i < density; i++) { + int iLife; + + iLife = (signed int)(size[2] / ((long double)(r % cg.rain.speed_vary) + cg.rain.speed) * 1000.0); + f = (long double)(r % (signed int)(size[0] + 1.0)); + r = ((214013 * r + 2531011) >> 16) & 0x7FFF; + vStart[2] = tMaxs[2]; + vStart[0] = f + tMins[0]; + vStart[1] = (long double)(r % (signed int)(size[1] + 1.0)) + tMins[1]; + //if( ) + { + f = r % cg.rain.slant; + r = ((214013 * r + 2531011) >> 16) & 0x7FFF; + vEnd[0] = f + vStart[0] + /*vss_wind_x->value*/8; + vEnd[1] = (r % cg.rain.slant) + vStart[1] + /*vss_wind_y->value*/4; + vEnd[2] = tMins[2]; + CG_CreateBeam( + vStart, // start + vec3_origin,// dir + 0, // owner + 1, // model + 1.0, // alpha + cg.rain.width, // scale + 16384, // flags + 0, // length <- isnt smth wrong there? + iLife, // life + 1, // create + vEnd, // endpointvec + 0, // min_offset + 0, // max_offset + 0, // overlap + 1, // numSubdivisions + 0, // delay + shadername, // beamshadername + fcolor, // modulate (byte[4] here, float[4] in MoHAA) + 0, // numspherebeams + 0.0, // sphereradius + cg.rain.length, // toggledelay + 1.0, // endalpha + 0, // renderfx + "raineffect"); // name + } + } +} \ No newline at end of file diff --git a/code/cgame/cg_servercmds.c b/code/cgame/cg_servercmds.c new file mode 100644 index 00000000..8a86329e --- /dev/null +++ b/code/cgame/cg_servercmds.c @@ -0,0 +1,540 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_servercmds.c -- reliably sequenced text commands sent by the server +// these are processed at snapshot transition time, so there will definately +// be a valid snapshot this frame + +#include "cg_local.h" + +/* +================ +CG_ParseServerinfo + +This is called explicitly when the gamestate is first received, +and whenever the server updates any serverinfo flagged cvars +================ +*/ +void CG_ParseServerinfo( void ) { + const char *info; + char *mapname; + + info = CG_ConfigString( CS_SERVERINFO ); + cgs.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) ); + cgi.Cvar_Set("g_gametype", va("%i", cgs.gametype)); + cgs.dmflags = atoi( Info_ValueForKey( info, "dmflags" ) ); + cgs.teamflags = atoi( Info_ValueForKey( info, "teamflags" ) ); + cgs.fraglimit = atoi( Info_ValueForKey( info, "fraglimit" ) ); + cgs.capturelimit = atoi( Info_ValueForKey( info, "capturelimit" ) ); + cgs.timelimit = atoi( Info_ValueForKey( info, "timelimit" ) ); + cgs.maxclients = atoi( Info_ValueForKey( info, "sv_maxclients" ) ); + mapname = Info_ValueForKey( info, "mapname" ); + Com_sprintf( cgs.mapname, sizeof( cgs.mapname ), "maps/%s.bsp", mapname ); + cgi.Cvar_Set( "cg_scoreboardpic", Info_ValueForKey( info,"g_scoreboardpic" ) ); +} + +/* +================== +CG_ParseWarmup +================== +*/ +static void CG_ParseWarmup( void ) { + const char *info; + int warmup; + + info = CG_ConfigString( CS_WARMUP ); + + warmup = atoi( info ); + cg.warmupCount = -1; + + if ( warmup == 0 && cg.warmup ) { + + } else if ( warmup > 0 && cg.warmup <= 0 ) { + + { +// cgi.S_StartLocalSound( cgs.media.countPrepareSound, CHAN_ANNOUNCER ); + } + } + + cg.warmup = warmup; +} + +/* +================ +CG_SetConfigValues + +Called on load to set the initial values from configure strings +================ +*/ +void CG_SetConfigValues( void ) { + cgs.levelStartTime = atoi( CG_ConfigString( CS_LEVEL_START_TIME ) ); + cg.warmup = atoi( CG_ConfigString( CS_WARMUP ) ); +} + +/* +================ +CG_ConfigStringModified + +================ +*/ +static void CG_ConfigStringModified( void ) { + const char *str; + int num; + char buffer[MAX_QPATH]; + + num = atoi( CG_Argv( 1 ) ); + + // get the gamestate from the client system, which will have the + // new configstring already integrated + cgi.GetGameState( &cgs.gameState ); + + // look up the individual string that was modified + str = CG_ConfigString( num ); + + // do something with it if necessary + if ( num == CS_MUSIC ) { + CG_StartMusic(); + } else if ( num == CS_SERVERINFO ) { + CG_ParseServerinfo(); + } else if ( num == CS_WARMUP ) { + CG_ParseWarmup(); + } else if( num >= CS_RAIN_DENSITY && num <= CS_RAIN_NUMSHADERS) { + CG_RainCSUpdated(num,str); + } else if ( num == CS_FOGINFO ) { + sscanf(str, "%d %f %f %f %f", &cg.farplane_cull, &cg.farplane_distance, + &cg.farplane_color[0], &cg.farplane_color[1], &cg.farplane_color[2]); + } else if ( num == CS_LEVEL_START_TIME ) { + cgs.levelStartTime = atoi( str ); + } else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) { + cgs.gameModels[ num-CS_MODELS ] = cgi.R_RegisterModel( str ); + if(str[0] && str[0] != '*') { + cgs.gameTIKIs[num-CS_MODELS] = cgi.TIKI_RegisterModel( str ); + if(cgs.gameTIKIs[num-CS_MODELS] == 0) { + CG_Printf("CG_ConfigStringModified: failed to load tiki file %s (%i)\n",str,num-CS_MODELS); + } + } + } else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS ) { + if ( str[0] != '*' ) { // player specific sounds don't register here + Q_strncpyz( buffer, str, sizeof(buffer) ); + if (buffer[strlen( buffer )-1] == '0' || buffer[strlen( buffer )-1] == '1') + buffer[strlen( buffer )-1] = 0; + cgs.gameSounds[ num-CS_SOUNDS] = cgi.S_RegisterSound( buffer, qfalse ); + } + } else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) { + CG_NewClientInfo( num - CS_PLAYERS ); + } else if( num >= CS_WEAPONS && num < CS_TEAMS ) { + CG_RegisterItemName(num - CS_WEAPONS, str); + } +} + + +/* +======================= +CG_AddToTeamChat + +======================= +*/ +static void CG_AddToTeamChat( const char *str ) { + int len; + char *p, *ls; + int lastcolor; + int chatHeight; + + if (cg_teamChatHeight->integer < TEAMCHAT_HEIGHT) { + chatHeight = cg_teamChatHeight->integer; + } else { + chatHeight = TEAMCHAT_HEIGHT; + } + + if (chatHeight <= 0 || cg_teamChatTime->integer <= 0) { + // team chat disabled, dump into normal chat + cgs.teamChatPos = cgs.teamLastChatPos = 0; + return; + } + + len = 0; + + p = cgs.teamChatMsgs[cgs.teamChatPos % chatHeight]; + *p = 0; + + lastcolor = '7'; + + ls = NULL; + while (*str) { + if (len > TEAMCHAT_WIDTH - 1) { + if (ls) { + str -= (p - ls); + str++; + p -= (p - ls); + } + *p = 0; + + cgs.teamChatMsgTimes[cgs.teamChatPos % chatHeight] = cg.time; + + cgs.teamChatPos++; + p = cgs.teamChatMsgs[cgs.teamChatPos % chatHeight]; + *p = 0; + *p++ = Q_COLOR_ESCAPE; + *p++ = lastcolor; + len = 0; + ls = NULL; + } + + if ( Q_IsColorString( str ) ) { + *p++ = *str++; + lastcolor = *str; + *p++ = *str++; + continue; + } + if (*str == ' ') { + ls = p; + } + *p++ = *str++; + len++; + } + *p = 0; + + cgs.teamChatMsgTimes[cgs.teamChatPos % chatHeight] = cg.time; + cgs.teamChatPos++; + + if (cgs.teamChatPos - cgs.teamLastChatPos > chatHeight) + cgs.teamLastChatPos = cgs.teamChatPos - chatHeight; +} + +/* +=============== +CG_MapRestart + +The server has issued a map_restart, so the next snapshot +is completely new and should not be interpolated to. + +A tournement restart will clear everything, but doesn't +require a reload of all the media +=============== +*/ +static void CG_MapRestart( void ) { + if ( cg_showmiss->integer ) { + CG_Printf( "CG_MapRestart\n" ); + } + + CG_InitLocalEntities(); + CG_InitMarkPolys(); + CG_ClearParticles (); + + // make sure the "3 frags left" warnings play again + cg.fraglimitWarnings = 0; + + cg.timelimitWarnings = 0; + + cg.mapRestart = qtrue; + + CG_StartMusic(); + + cgi.S_ClearLoopingSounds(qtrue); + + // we really should clear more parts of cg here and stop sounds + + // play the "fight" sound if this is a restart without warmup + if ( cg.warmup == 0 /* && cgs.gametype == GT_TOURNAMENT */) { +// cgi.S_StartLocalSound( cgs.media.countFightSound, CHAN_ANNOUNCER ); + CG_CenterPrint( "FIGHT!", 120, GIANTCHAR_WIDTH*2 ); + } + + cgi.Cvar_Set("cg_thirdPerson", "0"); +} + +/* +================= +CG_RemoveChatEscapeChar +================= +*/ +static void CG_RemoveChatEscapeChar( char *text ) { + int i, l; + + l = 0; + for ( i = 0; text[i]; i++ ) { + if (text[i] == '\x19') + continue; + text[l++] = text[i]; + } + text[l] = '\0'; +} + +// Wombat: Lists of blocked and allowed stufftext commands +const char *stufftextBlock[] = { + "quit" +}; + +typedef struct { + char *cmd; + int args; +} stufftextCommand_t; + +stufftextCommand_t stufftextSafe[] = { + { "pushmenu_teamselect", 0 }, + { "pushmenu_weaponselect", 0 }, + { "wait", 1 }, + { "locationprint", 3 }, // locationprint + { "add", 2 }, // add + // su44: these are used on "-(V)ethod-Clan" server ( 8.9.16.34:12203 ) + // for some kind of anticheat + { "set", 2 }, // set + { "setu", 2 }, // setu +}; + +/* +================= +CG_StufftextCommand + +Wombat: MOHAA servers may send certain server commands +that contain console commands supposed to be executed +on the client's console. +I don't like the idea that a remote machine can execute +*anything*, so i think i will implement a filter to pass only +sane commands... +================= +*/ +void CG_StufftextCommand( const char *cmd ) { + int i; + char *ptr; + const char *ptr2; + + ptr = ( char * )cmd; + ptr2 = COM_Parse(&ptr); + for ( i = 0 ; i < sizeof( stufftextBlock ) / sizeof( stufftextBlock[0] ) ; i++ ) { + if ( !Q_stricmp( ptr2, stufftextBlock[i] ) ) { + return; + } + } + // wombat: some servers use ST commands for anti-cheat measures + // we don't use the whitelist right now... + Com_Printf( "^3Executing stufftext command: \"%s\"\n", cmd ); + cgi.SendConsoleCommand( cmd ); + return; + + for ( i = 0 ; i < sizeof( stufftextSafe ) / sizeof( stufftextSafe[0] ) ; i++ ) { + if ( !Q_stricmp( ptr2, stufftextSafe[i].cmd ) ) { + cgi.SendConsoleCommand( cmd ); + return; + } + } + Com_Printf( "Unlisted stufftext command: \"%s\"\n", cmd ); +} + +/* +================= +CG_AddGameMessage + +To be printed below the compass +================= +*/ +void CG_AddGameMessage( const char *cmd, serverMessageType_t smt ) { + ubersound_t *click; + + click = CG_GetUbersound( "click" ); + switch ( smt ) { + case SMT_YELLOW: + case SMT_WHITE: + if ( cg.gameMessageTime == 0 ) + cg.gameMessageTime = cg.time; + cg.gameMessageTypes[cg.gameMessagePtr2] = smt; + Q_strncpyz( cg.gameMessages[cg.gameMessagePtr2], cmd, sizeof(cg.gameMessages[cg.gameMessagePtr2]) ); + CG_Printf( "Game Message: %s", cmd ); + cgi.S_StartLocalSound( click->sfxHandle, click->channel ); + cg.gameMessagePtr2 = (cg.gameMessagePtr2+1) % MAX_GAMEMESSAGES; + if ( cg.gameMessagePtr2 == cg.gameMessagePtr1 ) { + cg.gameMessagePtr1 = (cg.gameMessagePtr1+1) % MAX_GAMEMESSAGES; + cg.gameMessageTime = cg.time; + } + break; + case SMT_CHAT: + CG_Printf( "Chat: %s", cmd ); + cgi.S_StartLocalSound( click->sfxHandle, click->channel ); + case SMT_DEATH: + if ( cg.chatDeathMessageTime == 0 ) + cg.chatDeathMessageTime = cg.time; + cg.chatDeathMessageTypes[cg.chatDeathMessagePtr2] = smt; + Q_strncpyz( cg.chatDeathMessages[cg.chatDeathMessagePtr2], cmd, sizeof(cg.chatDeathMessages[cg.chatDeathMessagePtr2]) ); + if ( smt == SMT_DEATH ) + CG_Printf( "Death: %s", cmd ); + cg.chatDeathMessagePtr2 = (cg.chatDeathMessagePtr2+1) % MAX_CHATDEATHMESSAGES; + if (cg.chatDeathMessagePtr2 == cg.chatDeathMessagePtr1 ) { + cg.chatDeathMessagePtr1 = (cg.chatDeathMessagePtr1+1) % MAX_CHATDEATHMESSAGES; + cg.chatDeathMessageTime = cg.time; + } + break; + case SMT_UNKNOWN: + CG_Printf( "Unknown Message: %s", cmd ); + break; + } +} + +/* +================= +CG_ServerCommand + +The string has been tokenized and can be retrieved with +Cmd_Argc() / Cmd_Argv() +================= +*/ +static void CG_ServerCommand( void ) { + const char *cmd; + char stufftextBuffer[512]; + const char *ptr; + char letter; + int i; + int lastpos; + + cmd = CG_Argv(0); + + if ( !cmd[0] ) { + // server claimed the command + return; + } + + // wombat: stufftext is something specific to MOHAA + if ( !strcmp( cmd, "stufftext" ) ) { + + ptr = CG_Argv(1); + for ( i=0,lastpos=0; iinteger ) { +//// cgi.S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND ); +// Q_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT ); +// CG_RemoveChatEscapeChar( text ); +// CG_Printf( "%s\n", text ); +// } +// return; +// } +// +// if ( !strcmp( cmd, "tchat" ) ) { +//// cgi.S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND ); +// Q_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT ); +// CG_RemoveChatEscapeChar( text ); +// CG_AddToTeamChat( text ); +// CG_Printf( "%s\n", text ); +// return; +// } + + if ( !strcmp( cmd, "scores" ) ) { + //CG_ParseScores(); + Q_strncpyz( cg.aScore, cgi.Args(), sizeof( cg.aScore ) ); + return; + } + + //if ( !strcmp( cmd, "map_restart" ) ) { + // CG_MapRestart(); + // return; + //} + + // clientLevelShot is sent before taking a special screenshot for + // the menu system during development + if ( !strcmp( cmd, "clientLevelShot" ) ) { + cg.levelShot = qtrue; + return; + } + + // MoHAA's stopwatch + if ( !strcmp( cmd, "stopwatch" ) ) { + // TODO + return; + } + + if ( !strcmp( cmd, "svlag" ) ) { + // TODO + return; + } + + // su44: send just before server map change + if ( !strcmp( cmd, "fadesound" ) ) { + // TODO + return; + } + + + CG_Printf( "Unknown client game command: %s\n", cmd ); +} + + +/* +==================== +CG_ExecuteNewServerCommands + +Execute all of the server commands that were received along +with this this snapshot. +==================== +*/ +void CG_ExecuteNewServerCommands( int latestSequence ) { + while ( cgs.serverCommandSequence < latestSequence ) { + if ( cgi.GetServerCommand( ++cgs.serverCommandSequence ) ) { + CG_ServerCommand(); + } + } +} diff --git a/code/cgame/cg_snapshot.c b/code/cgame/cg_snapshot.c new file mode 100644 index 00000000..2fc3a920 --- /dev/null +++ b/code/cgame/cg_snapshot.c @@ -0,0 +1,492 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_snapshot.c -- things that happen on snapshot transition, +// not necessarily every single rendered frame + +#include "cg_local.h" +#include "../qcommon/tiki_local.h" + + +/* +================== +CG_ResetEntity +================== +*/ +static void CG_ResetEntity( centity_t *cent ) { + VectorCopy (cent->currentState.origin, cent->lerpOrigin); + VectorCopy (cent->currentState.angles, cent->lerpAngles); + if ( cent->currentState.eType == ET_PLAYER ) { + CG_ResetPlayerEntity( cent ); + } +} + +/* +=============== +CG_TransitionEntity + +cent->nextState is moved to cent->currentState and events are fired +=============== +*/ +static int TIKI_FrameNumForTime(tiki_t *tiki, int animIndex, float animTime) { + int i; + tikiAnim_t *anim; + if(tiki->numAnims <= animIndex) { + Com_Printf("TIKI_FrameNumForTime: animIndex %i out of range %i\n",animIndex,tiki->numAnims); + return 0; + } + anim = tiki->anims[animIndex]; + if(anim->numFrames == 1) { + return 0; + } + i = 0; + while(animTime > anim->frameTime) { + animTime -= anim->frameTime; + i++; + } + return i; +} +static void CG_ExecuteFrameCommands(centity_t *cent, tikiAnim_t *anim, int frameIndex) { + int i; + tikiCommand_t *cmd; + cmd = anim->clientCmds; + for(i = 0; i < anim->numClientCmds; i++,cmd++) { + if(cmd->frame == frameIndex) { + //CG_Printf("Frame %i command %s\n",cmd->frame,cmd->text); + //CG_ProcessEventText(cent,cmd->text); + CG_PostEvent(cent,cmd->text,0); + } + } +} +static void CG_ExecuteFramesCommands(centity_t *cent, tikiAnim_t *anim, int start, int stop) { + int i; + tikiCommand_t *cmd; + cmd = anim->clientCmds; + for(i = 0; i < anim->numClientCmds; i++,cmd++) { + if(cmd->frame >= start && cmd->frame <= stop) { + //CG_Printf("Frame %i command %s\n",cmd->frame,cmd->text); + //CG_ProcessEventText(cent,cmd->text); + CG_PostEvent(cent,cmd->text,0); + } + } +} + +static void CG_TransitionEntity( centity_t *cent ) { + frameInfo_t *fi0, *fi1; + tiki_t *tiki0,*tiki1; + tikiAnim_t *a0, *a1; + int f0, f1; + int i; + + tiki0 = cgs.gameTIKIs[cent->currentState.modelindex]; + tiki1 = cgs.gameTIKIs[cent->nextState.modelindex]; + if(tiki0 || tiki1) { + // su44: It should be placed somewhere else soon + fi0 = cent->currentState.frameInfo; + fi1 = cent->nextState.frameInfo; + for(i = 0; i < 16; i++,fi0++,fi1++) { + if(fi0->weight && tiki0 && fi0->index < tiki0->numAnims) { + a0 = tiki0->anims[fi0->index]; + f0 = TIKI_FrameNumForTime(tiki0,fi0->index,fi0->time); + if(fi1->weight && tiki1 && fi1->index < tiki1->numAnims) { + if(fi0->index != fi1->index || tiki0 != tiki1) { + a1 = tiki1->anims[fi1->index]; + CG_ExecuteFrameCommands(cent,a0,TIKI_FRAME_EXIT); + CG_ExecuteFrameCommands(cent,a1,TIKI_FRAME_ENTRY); + } else { + f1 = TIKI_FrameNumForTime(tiki1,fi1->index,fi1->time); + if(f1 > f0) { + CG_ExecuteFramesCommands(cent,a0,f0,f1); + } else { + CG_ExecuteFramesCommands(cent,a0,f1,f0); + } + } + } else { + // anim has stopped + //CG_ExecuteFramesCommands(cent,anim,fi0-> + CG_ExecuteFrameCommands(cent,a0,TIKI_FRAME_EXIT); + } + } else if(fi1->weight && tiki1 && fi1->index < tiki1->numAnims) { + // anim is starting + a1 = tiki1->anims[fi1->index]; + f1 = TIKI_FrameNumForTime(tiki1,fi1->index,fi1->time); + CG_ExecuteFrameCommands(cent,a1,TIKI_FRAME_ENTRY); + } + } + } + cent->currentState = cent->nextState; + cent->currentValid = qtrue; + + // reset if the entity wasn't in the last frame or was teleported + if ( !cent->interpolate ) { + CG_ResetEntity( cent ); + } + + // clear the next state. if will be set by the next CG_SetNextSnap + cent->interpolate = qfalse; +} + + +/* +================== +CG_SetInitialSnapshot + +This will only happen on the very first snapshot, or +on tourney restarts. All other times will use +CG_TransitionSnapshot instead. + +FIXME: Also called by map_restart? +================== +*/ +void CG_SetInitialSnapshot( snapshot_t *snap ) { + int i; + centity_t *cent; + entityState_t *state; + + cg.snap = snap; + + BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].currentState, qfalse ); + + // sort out solid entities + CG_BuildSolidList(); + + CG_ExecuteNewServerCommands( snap->serverCommandSequence ); + + // set our local weapon selection pointer to + // what the server has indicated the current weapon is + CG_Respawn(); + + for ( i = 0 ; i < cg.snap->numEntities ; i++ ) { + state = &cg.snap->entities[ i ]; + cent = &cg_entities[ state->number ]; + + memcpy(¢->currentState, state, sizeof(entityState_t)); + //cent->currentState = *state; + cent->interpolate = qfalse; + cent->currentValid = qtrue; + + CG_ResetEntity( cent ); + } +} + + +/* +=================== +CG_TransitionSnapshot + +The transition point from snap to nextSnap has passed +=================== +*/ +static void CG_TransitionSnapshot( void ) { + centity_t *cent; + snapshot_t *oldFrame; + int i; + + server_sound_t *snd; + + if ( !cg.snap ) { + CG_Error( "CG_TransitionSnapshot: NULL cg.snap" ); + } + if ( !cg.nextSnap ) { + CG_Error( "CG_TransitionSnapshot: NULL cg.nextSnap" ); + } + + // execute any server string commands before transitioning entities + CG_ExecuteNewServerCommands( cg.nextSnap->serverCommandSequence ); + + // if we had a map_restart, set everthing with initial + if ( !cg.snap ) { + } + + // clear the currentValid flag for all entities in the existing snapshot + for ( i = 0 ; i < cg.snap->numEntities ; i++ ) { + cent = &cg_entities[ cg.snap->entities[ i ].number ]; + cent->currentValid = qfalse; + } + + // move nextSnap to snap and do the transitions + oldFrame = cg.snap; + cg.snap = cg.nextSnap; + + BG_PlayerStateToEntityState( &cg.snap->ps, &cg_entities[ cg.snap->ps.clientNum ].currentState, qfalse ); + cg_entities[ cg.snap->ps.clientNum ].interpolate = qfalse; + + for ( i = 0 ; i < cg.snap->numEntities ; i++ ) { + cent = &cg_entities[ cg.snap->entities[ i ].number ]; + CG_TransitionEntity( cent ); + + // remember time of snapshot this entity was last updated in + cent->snapShotTime = cg.snap->serverTime; + } + + + + for ( i=0;inumber_of_sounds;i++ ) { + snd = &cg.snap->sounds[i]; + if ( snd->sound_index == 0 ) // wombat: we get these sometimes, no clue why + continue; + if (snd->stop_flag) { + cgi.S_StopLoopingSound( snd->entity_number ); + } + else { + cgi.S_StartSound( snd->origin, snd->entity_number, snd->channel, cgs.gameSounds[snd->sound_index] ); + } + } + + cg.nextSnap = NULL; + + // check for playerstate transition events + if ( oldFrame ) { + playerState_t *ops, *ps; + + ops = &oldFrame->ps; + ps = &cg.snap->ps; + // teleporting checks are irrespective of prediction + //if ( ( ps->eFlags ^ ops->eFlags ) & EF_TELEPORT_BIT ) { + // cg.thisFrameTeleport = qtrue; // will be cleared by prediction code + //} + + // if we are not doing client side movement prediction for any + // reason, then the client events and view changes will be issued now + if ( cg.demoPlayback /*|| (cg.snap->ps.pm_flags & PMF_FOLLOW)*/ + || cg_nopredict->integer || cg_synchronousClients->integer ) { + CG_TransitionPlayerState( ps, ops ); + } + } + +} + + +/* +=================== +CG_SetNextSnap + +A new snapshot has just been read in from the client system. +=================== +*/ +static void CG_SetNextSnap( snapshot_t *snap ) { + int num; + entityState_t *es; + centity_t *cent; + + cg.nextSnap = snap; + + BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].nextState, qfalse ); + cg_entities[ cg.snap->ps.clientNum ].interpolate = qtrue; + + // check for extrapolation errors + for ( num = 0 ; num < snap->numEntities ; num++ ) { + es = &snap->entities[num]; + cent = &cg_entities[ es->number ]; + + memcpy(¢->nextState, es, sizeof(entityState_t)); + //cent->nextState = *es; + + // if this frame is a teleport, or the entity wasn't in the + // previous frame, don't interpolate + if ( !cent->currentValid || ( ( cent->currentState.eFlags ^ es->eFlags ) & EF_TELEPORT_BIT ) ) { + cent->interpolate = qfalse; + } else { + cent->interpolate = qtrue; + } + } + + // if the next frame is a teleport for the playerstate, we + // can't interpolate during demos + //if ( cg.snap && ( ( snap->ps.eFlags ^ cg.snap->ps.eFlags ) & EF_TELEPORT_BIT ) ) { + // cg.nextFrameTeleport = qtrue; + //} else + + { + cg.nextFrameTeleport = qfalse; + } + + // if changing follow mode, don't interpolate + if ( cg.nextSnap->ps.clientNum != cg.snap->ps.clientNum ) { + cg.nextFrameTeleport = qtrue; + } + + // if changing server restarts, don't interpolate + if ( ( cg.nextSnap->snapFlags ^ cg.snap->snapFlags ) & SNAPFLAG_SERVERCOUNT ) { + cg.nextFrameTeleport = qtrue; + } + + // sort out solid entities + CG_BuildSolidList(); +} + + +/* +======================== +CG_ReadNextSnapshot + +This is the only place new snapshots are requested +This may increment cgs.processedSnapshotNum multiple +times if the client system fails to return a +valid snapshot. +======================== +*/ +static snapshot_t *CG_ReadNextSnapshot( void ) { + qboolean r; + snapshot_t *dest; + + if ( cg.latestSnapshotNum > cgs.processedSnapshotNum + 1000 ) { + CG_Printf( "WARNING: CG_ReadNextSnapshot: way out of range, %i > %i", + cg.latestSnapshotNum, cgs.processedSnapshotNum ); + } + + while ( cgs.processedSnapshotNum < cg.latestSnapshotNum ) { + // decide which of the two slots to load it into + if ( cg.snap == &cg.activeSnapshots[0] ) { + dest = &cg.activeSnapshots[1]; + } else { + dest = &cg.activeSnapshots[0]; + } + + // try to read the snapshot from the client system + cgs.processedSnapshotNum++; + r = cgi.GetSnapshot( cgs.processedSnapshotNum, dest ); + + // FIXME: why would cgi.GetSnapshot return a snapshot with the same server time + if ( cg.snap && r && dest->serverTime == cg.snap->serverTime ) { + //continue; + } + + // if it succeeded, return + if ( r ) { + CG_AddLagometerSnapshotInfo( dest ); + return dest; + } + + // a GetSnapshot will return failure if the snapshot + // never arrived, or is so old that its entities + // have been shoved off the end of the circular + // buffer in the client system. + + // record as a dropped packet + CG_AddLagometerSnapshotInfo( NULL ); + + // If there are additional snapshots, continue trying to + // read them. + } + + // nothing left to read + return NULL; +} + + +/* +============ +CG_ProcessSnapshots + +We are trying to set up a renderable view, so determine +what the simulated time is, and try to get snapshots +both before and after that time if available. + +If we don't have a valid cg.snap after exiting this function, +then a 3D game view cannot be rendered. This should only happen +right after the initial connection. After cg.snap has been valid +once, it will never turn invalid. + +Even if cg.snap is valid, cg.nextSnap may not be, if the snapshot +hasn't arrived yet (it becomes an extrapolating situation instead +of an interpolating one) + +============ +*/ +void CG_ProcessSnapshots( void ) { + snapshot_t *snap; + int n; + + // see what the latest snapshot the client system has is + cgi.GetCurrentSnapshotNumber( &n, &cg.latestSnapshotTime ); + if ( n != cg.latestSnapshotNum ) { + if ( n < cg.latestSnapshotNum ) { + // this should never happen + CG_Error( "CG_ProcessSnapshots: n < cg.latestSnapshotNum" ); + } + cg.latestSnapshotNum = n; + } + + // If we have yet to receive a snapshot, check for it. + // Once we have gotten the first snapshot, cg.snap will + // always have valid data for the rest of the game + while ( !cg.snap ) { + snap = CG_ReadNextSnapshot(); + if ( !snap ) { + // we can't continue until we get a snapshot + return; + } + + // set our weapon selection to what + // the playerstate is currently using + if ( !( snap->snapFlags & SNAPFLAG_NOT_ACTIVE ) ) { + CG_SetInitialSnapshot( snap ); + } + } + + // loop until we either have a valid nextSnap with a serverTime + // greater than cg.time to interpolate towards, or we run + // out of available snapshots + do { + // if we don't have a nextframe, try and read a new one in + if ( !cg.nextSnap ) { + snap = CG_ReadNextSnapshot(); + + // if we still don't have a nextframe, we will just have to + // extrapolate + if ( !snap ) { + break; + } + + CG_SetNextSnap( snap ); + + + // if time went backwards, we have a level restart + if ( cg.nextSnap->serverTime < cg.snap->serverTime ) { + CG_Error( "CG_ProcessSnapshots: Server time went backwards" ); + } + } + + // if our time is < nextFrame's, we have a nice interpolating state + if ( cg.time >= cg.snap->serverTime && cg.time < cg.nextSnap->serverTime ) { + break; + } + + // we have passed the transition from nextFrame to frame + CG_TransitionSnapshot(); + } while ( 1 ); + + // assert our valid conditions upon exiting + if ( cg.snap == NULL ) { + CG_Error( "CG_ProcessSnapshots: cg.snap == NULL" ); + } + if ( cg.time < cg.snap->serverTime ) { + // this can happen right after a vid_restart + cg.time = cg.snap->serverTime; + } + if ( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time ) { + CG_Error( "CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time" ); + } + +} + diff --git a/code/cgame/cg_specialfx.c b/code/cgame/cg_specialfx.c new file mode 100644 index 00000000..cb46d5c7 --- /dev/null +++ b/code/cgame/cg_specialfx.c @@ -0,0 +1,234 @@ +/* +=========================================================================== +Copyright (C) 2011 su44 + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// cg_specialfx.c - MoHAA special effects + +#include "cg_local.h" + +// MoHAA footstep sounds (from ubersound.scr) : +// snd_step_paper, snd_step_glass, snd_step_wood, snd_step_metal, +// snd_step_grill, snd_step_stone, snd_step_dirt, snd_step_grass, +// snd_step_mud, snd_step_puddle, snd_step_gravel, snd_step_sand, +// snd_step_foliage, snd_step_snow, snd_step_carpet +// BODY MOVEMENT +// snd_step_equipment - (equipment; for walking) +// snd_step_wade - (wade; for when wading through deeper water) + +static void CG_FootstepMain(trace_t *trace, int iRunning, int iEquipment) { + char sSoundName[MAX_QPATH] = "snd_step_"; + + int contents; + int surfaceFlags; + vec3_t pos; + + ubersound_t *snd = 0; + + if ( !iRunning ) + return; + + // su44: it seems that trace_t::surfaceFlags + // are not set if trace_t::allsolid == qtrue + if( trace->allsolid == qtrue ) + return; + + if ( iEquipment ) { + snd = CG_GetUbersound( "snd_step_equipment" ); + if (snd) + cgi.S_StartSound( trace->endpos, trace->entityNum, CHAN_ITEM, snd->sfxHandle ); + } + + surfaceFlags = trace->surfaceFlags; + contents = CG_PointContents(trace->endpos,-1); + if (contents & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER) ) { + // wombat: we test if the water is deep or shallow + VectorCopy( trace->endpos, pos ); + pos[2] += 16.0f; + contents = CG_PointContents(pos,-1); + if (contents & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER) ) + snd = CG_GetUbersound( "snd_step_wade" ); + else + snd = CG_GetUbersound( "snd_step_puddle" ); + } else { + if ( surfaceFlags & SURF_PAPER ) { + snd = CG_GetUbersound( "snd_step_paper" ); + } + else if ( surfaceFlags & SURF_WOOD ) { + snd = CG_GetUbersound( "snd_step_wood" ); + } + else if ( surfaceFlags & SURF_METAL ) { + snd = CG_GetUbersound( "snd_step_metal" ); + } + else if ( surfaceFlags & SURF_ROCK ) { + snd = CG_GetUbersound( "snd_step_stone" ); + } + else if ( surfaceFlags & SURF_DIRT ) { + snd = CG_GetUbersound( "snd_step_dirt" ); + } + else if ( surfaceFlags & SURF_GRILL ) { + snd = CG_GetUbersound( "snd_step_grill" ); + } + else if ( surfaceFlags & SURF_GRASS ) { + snd = CG_GetUbersound( "snd_step_grass" ); + } + else if ( surfaceFlags & SURF_MUD ) { + snd = CG_GetUbersound( "snd_step_mud" ); + } + else if ( surfaceFlags & SURF_PUDDLE ) { + snd = CG_GetUbersound( "snd_step_puddle" ); + } + else if ( surfaceFlags & SURF_GLASS ) { + snd = CG_GetUbersound( "snd_step_glass" ); + } + else if ( surfaceFlags & SURF_GRAVEL ) { + snd = CG_GetUbersound( "snd_step_gravel" ); + } + else if ( surfaceFlags & SURF_SAND ) { + snd = CG_GetUbersound( "snd_step_sand" ); + } + else if ( surfaceFlags & SURF_FOLIAGE ) { + snd = CG_GetUbersound( "snd_step_foliage" ); + } + else if ( surfaceFlags & SURF_SNOW ) { + snd = CG_GetUbersound( "snd_step_snow" ); + } + else if ( surfaceFlags & SURF_CARPET ) { + snd = CG_GetUbersound( "snd_step_carpet" ); + } + } + if ( !snd ) { + if(trace->surfaceFlags) { + CG_Printf( "CG_FootstepMain: could not load sound for surface %i\n", trace->surfaceFlags ); + } + return; + } + cgi.S_StartSound( trace->endpos, trace->entityNum, CHAN_BODY, snd->sfxHandle ); +} + +void CG_MeleeImpact(float *vStart, float *vEnd) { + trace_t trace; + float vMins[3] = { -4.0, -4.0, 0 }; + float vMaxs[3] = { 4.0, 4.0, 2.0 }; + CG_Trace(&trace,vStart,vMins,vMaxs,vEnd,1023,MASK_SHOT); + if(trace.fraction != 1.f) { + CG_FootstepMain(&trace,1,0); + } +} + + +void CG_Footstep(char *szTagName, centity_t *ent, /*refEntity_t *pREnt,*/ + int iRunning, int iEquipment) +{ + int mask; + int cylinder; + int cliptoentities; + trace_t trace; + vec3_t mins, maxs; + vec3_t vStart, vEnd, forward; + + +// CG_Printf("CG_Footstep: %s\n",szTagName); + + vStart[0] = ent->lerpOrigin[0]; + vStart[1] = ent->lerpOrigin[1]; + vStart[2] = ent->lerpOrigin[2] + 8.0; + if ( szTagName ) { + tiki_t *tiki; + int boneName; + int tagIndex; + vec3_t a; + + tiki = cgs.gameTIKIs[ent->currentState.modelindex]; + + if(tiki == 0) { + CG_Printf("CG_Footstep: tiki is NULL\n"); + return; + } + + // find tag in tiki + boneName = cgi.TIKI_GetBoneNameIndex(szTagName); + for(tagIndex = 0; tagIndex < tiki->numBones; tagIndex++) { + if(tiki->boneNames[tagIndex] == boneName) { + break; + } + } + if(tagIndex == tiki->numBones) { + CG_Printf("CG_Footstep: Cant find bone %s in tiki %s f\n",szTagName,tiki->name); + return; + } + if(ent->bones == 0) { + CG_Printf("CG_Footstep: entity has null bones ptr\n"); + return; + } + + CG_CentBoneIndexLocal2World(tagIndex, ent, vStart, a); + vStart[2] += 8; + } + if ( iRunning == -1 ) { + AngleVectors(ent->lerpAngles, forward, 0, 0); + vStart[0] = forward[0] * -16.0 + vStart[0]; + vStart[1] = forward[1] * -16.0 + vStart[1]; + vStart[2] = forward[2] * -16.0 + vStart[2]; + vEnd[0] = forward[0] * 64.0 + vStart[0]; + vEnd[1] = forward[1] * 64.0 + vStart[1]; + vEnd[2] = forward[2] * 64.0 + vStart[2]; + mins[0] = -2.0; + mins[1] = -2.0; + mins[2] = -8.0; + maxs[0] = 2.0; + maxs[1] = 2.0; + maxs[2] = 8.0; + } else { + vEnd[0] = vStart[0]; + vEnd[1] = vStart[1]; + + vStart[2] = vStart[2] + 16.0; + vEnd[2] = vStart[2] - 64.0; + + mins[0] = -4.0; + mins[1] = -4.0; + mins[2] = 0.0; + + maxs[0] = 4.0; + maxs[1] = 4.0; + maxs[2] = 2.0; + } + if ( ent->currentState.eType == ET_PLAYER ) { + cliptoentities = 1; + cylinder = 1; + mask = MASK_TREADMARK; + } else { + cliptoentities = 0; + cylinder = 0; + mask = MASK_FOOTSTEP; + } + CG_Trace(&trace, vStart, mins, maxs, vEnd, + ent->currentState.number, mask/*, cylinder, cliptoentities*/); + if ( trace.fraction != 1.0 ) { + int equip; + if (rand() > RAND_MAX*0.70) + equip = qtrue; // play only in 30% of cases + else equip = qfalse; + CG_FootstepMain(&trace, iRunning, equip); + } else { + //if ( cg_debugFootsteps.integer ) + // CG_Printf("Footstep: missed floor\n"); + } +} \ No newline at end of file diff --git a/code/cgame/cg_ubersound.c b/code/cgame/cg_ubersound.c new file mode 100644 index 00000000..f854c8b1 --- /dev/null +++ b/code/cgame/cg_ubersound.c @@ -0,0 +1,298 @@ +/* +=========================================================================== +Copyright (C) 2010-2011 Michael Rieder + +This file is part of OpenMohaa source code. + +OpenMohaa 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. + +OpenMohaa 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 OpenMohaa source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#include "cg_local.h" + +#define MAX_UBERSOUNDS 8192 +ubersound_t snd_indexes[MAX_UBERSOUNDS]; +int snd_numIndexes; +char *buffer; + +#define FILE_HASH_SIZE 256 +static ubersound_t* hashTable[FILE_HASH_SIZE]; + +static long generateHashValue( const char *fname ) { + int i; + long hash; + char letter; + + hash = 0; + i = 0; + while (fname[i] != '\0') { + letter = tolower(fname[i]); + hash+=(long)(letter)*(i+119); + i++; + } + hash &= (FILE_HASH_SIZE-1); + return hash; +} + +static ubersound_t* US_Find( const char *snd_name ) { + ubersound_t* snd; + long hash; + + hash = generateHashValue(snd_name); + + for (snd=hashTable[hash] ; snd ; snd=snd->hashNext) { + if (!Q_stricmp(snd_name, snd->name)) { + return snd; + } + } + + return NULL; +} + +ubersound_t* CG_GetUbersound( const char *name ) { + ubersound_t *snd; + + snd = US_Find( name ); + + if ( !snd ) { + CG_Printf( "CG_GetUbersound: sound \"%s\" not found.\n", name ); + return NULL; + } + // if there are more than one version, choose randomly + if ( snd->variations ) { + int i, var; + + var = rand(); + var *= snd->variations; + var /= RAND_MAX+1; + + // CG_Printf( "random sound %i of %i\n", var, snd->variations ); + for (i=0;inextVariation; + } + + if ( snd->hasLoaded == qfalse ) + snd->sfxHandle = cgi.S_RegisterSound( snd->wavfile, qfalse ); + + return snd; +} + +void CG_ParseUSline( char **ptr, ubersound_t *snd ) { + const char *chan; + const char *token; + // name + Q_strncpyz( snd->name, COM_Parse(ptr), sizeof(snd->name) ); + Q_strncpyz( snd->wavfile, COM_Parse(ptr), sizeof(snd->wavfile) ); + // soundparms + if ( !Q_strncmp( COM_Parse(ptr), "soundparms", MAX_QPATH ) ) { + snd->basevol = atof(COM_Parse(ptr)); + snd->volmod = atof(COM_Parse(ptr)); + snd->basepitch = atof(COM_Parse(ptr)); + snd->pitchmod = atof(COM_Parse(ptr)); + snd->minDist = atof(COM_Parse(ptr)); + snd->maxDist = atof(COM_Parse(ptr)); + + // channel + chan = COM_Parse(ptr); + if ( !Q_strncmp( chan, "auto", MAX_QPATH ) ) + snd->channel = CHAN_AUTO; + else if ( !Q_strncmp( chan, "body", MAX_QPATH ) ) + snd->channel = CHAN_BODY; + else if ( !Q_strncmp( chan, "item", MAX_QPATH ) ) + snd->channel = CHAN_ITEM; + else if ( !Q_strncmp( chan, "weaponidle", MAX_QPATH ) ) + snd->channel = CHAN_WEAPONIDLE; + else if ( !Q_strncmp( chan, "voice", MAX_QPATH ) ) + snd->channel = CHAN_VOICE; + else if ( !Q_strncmp( chan, "local", MAX_QPATH ) ) + snd->channel = CHAN_LOCAL; + else if ( !Q_strncmp( chan, "weapon", MAX_QPATH ) ) + snd->channel = CHAN_WEAPON; + else if ( !Q_strncmp( chan, "dialog_secondary", MAX_QPATH ) ) + snd->channel = CHAN_DIALOG_SECONDARY; + else if ( !Q_strncmp( chan, "dialog", MAX_QPATH ) ) + snd->channel = CHAN_DIALOG; + else if ( !Q_strncmp( chan, "menu", MAX_QPATH ) ) + snd->channel = CHAN_MENU; + else + CG_Printf( "Ubersound unrecognized channel %s for %s\n", chan, snd->name ); + // loaded /Streamed + chan = COM_Parse(ptr); + if ( !Q_strncmp( chan, "loaded", MAX_QPATH ) ) + snd->loaded = qtrue; + else if ( !Q_strncmp( chan, "streamed", MAX_QPATH ) ) + snd->loaded = qfalse; + else + CG_Printf( "Ubersound unrecognized loaded state %s for %s\n", chan, snd->name ); + } + token = COM_Parse(ptr); + // subtitle - su44: we need this for ubersound/uberdialog.scr loading + if ( !Q_stricmp( token, "subtitle" ) ) { + Q_strncpyz( snd->subtitle, COM_Parse(ptr), sizeof(snd->subtitle) ); + token = COM_Parse(ptr); + } + // maplist + if ( !Q_stricmp( token, "maps" ) ) + Q_strncpyz( snd->mapstring, COM_Parse(ptr), MAPSTRING_LENGTH ); +} + +qboolean US_CheckMapstring( const char *mapstring ) { + char *ptr; + const char *token; + + ptr = (char*)mapstring; + token = COM_Parse(&ptr); + while (*token) { + if ( strstr( cgs.mapname, token ) ) + return qtrue; + token = COM_Parse(&ptr); + } + + return qfalse; +} + +void CG_LoadUberSoundFile( const char *fname, qboolean sndVar ) { + // sndVar decides whether the last digit (if it is a digit) provides a variation of the same sound + int len; + + const char *token; + char *ptr; + qboolean end; + ubersound_t *oldSnd, *newSnd; + int i; + + CG_Printf( "=== Loading %s ===\n", fname ); + + len = cgi.FS_ReadFile( fname, &buffer, qfalse ); + + if( len <= 0 ) { + CG_Printf( "couldn't load %s. file not found.\n", fname ); + return; + } + + end = qfalse; + ptr = buffer; + token = COM_Parse( &ptr ); + + while (*token) { + newSnd = &snd_indexes[snd_numIndexes]; + if ( !Q_strncmp(token,"aliascache",MAX_QPATH) || !Q_strncmp(token,"alias",MAX_QPATH) ) { + CG_ParseUSline( &ptr, newSnd ); + + if ( US_CheckMapstring( newSnd->mapstring ) == qtrue ) { + int variation; + + variation = atoi(newSnd->name + strlen(newSnd->name)-1); + if ( sndVar == qtrue && variation ) { + newSnd->name[strlen(newSnd->name)-1] = 0; + oldSnd = US_Find(newSnd->name); + if ( oldSnd ) { + oldSnd->variations++; + for (i=oldSnd->variations;i>2;i--) + oldSnd = oldSnd->nextVariation; + oldSnd->nextVariation = newSnd; + if ( newSnd->loaded == qtrue ) { + newSnd->sfxHandle = cgi.S_RegisterSound( newSnd->wavfile, qfalse ); + newSnd->hasLoaded = qtrue; + } + snd_numIndexes++; + if ( snd_numIndexes >= MAX_UBERSOUNDS ) { + snd_numIndexes--; + CG_Error( "CG_LoadUbersound: too many aliascaches in file.\n" ); + } + continue; + } + else newSnd->variations++; + } + + i = generateHashValue(newSnd->name); + oldSnd = hashTable[i]; + if (oldSnd) { + while (oldSnd->hashNext) + oldSnd = oldSnd->hashNext; + oldSnd->hashNext = newSnd; + } + else + hashTable[i] = newSnd; + if ( newSnd->loaded == qtrue ) { + newSnd->sfxHandle = cgi.S_RegisterSound( newSnd->wavfile, qfalse ); + newSnd->hasLoaded = qtrue; + } + snd_numIndexes++; + if ( snd_numIndexes >= MAX_UBERSOUNDS ) { + snd_numIndexes--; + CG_Error( "CG_LoadUbersound: too many aliascaches in file.\n" ); + } + } else { + Com_Memset(newSnd,0,sizeof(ubersound_t) ); + } + } //su44: "end" token is missing in MoHAA's uberdialog.scr + //else if ( !Q_strncmp( token, "end", MAX_QPATH ) ) { + // end = qtrue; + // break; + //} + token = COM_Parse( &ptr ); + } + //if ( end == qfalse ) + // Com_Printf( "CG_LoadUbersound hit end of file without end statement\n" ); + + cgi.FS_FreeFile( buffer ); + CG_Printf( "=== Finished %s ===\n", fname ); +} + +void CG_LoadUbersound( void ) { + Com_Memset(snd_indexes, 0, sizeof(snd_indexes)); + Com_Memset(hashTable, 0, sizeof(hashTable)); + snd_numIndexes = 0; + + CG_LoadUberSoundFile(UBERSOUND_FILE, qtrue); + // su44: used by MoHAA voicechats + CG_LoadUberSoundFile(UBERDIALOG_FILE, qfalse); +} + +const char* CG_LoadMusic( const char *musicfile ) { + + int len; + + const char *token; + char *ptr; + char path[MAX_QPATH]; + char name[MAX_QPATH]; + + if( !musicfile[ 0 ] ) + { + return ""; + } + + CG_Printf( "=== Loading %s ===\n", musicfile ); + + len = cgi.FS_ReadFile( musicfile, &buffer, qfalse ); + + if( len <= 0 ) { + CG_Printf( "couldn't load %s. file not found.\n", musicfile ); + return NULL; + } + + ptr = buffer; + token = COM_Parse( &ptr ); + while (*token) { + if ( !Q_strncmp(token,"path",MAX_QPATH) ) + Q_strncpyz( path, COM_Parse(&ptr), MAX_QPATH ); + else if ( !Q_strncmp(token,"normal",MAX_QPATH) ) + Q_strncpyz( name, COM_Parse(&ptr), MAX_QPATH ); + token = COM_Parse( &ptr ); + } + Q_snprintf( buffer, MAX_QPATH, "%s/%s", path, name ); + return buffer; +} \ No newline at end of file diff --git a/code/cgame/cg_view.c b/code/cgame/cg_view.c new file mode 100644 index 00000000..8b6abd23 --- /dev/null +++ b/code/cgame/cg_view.c @@ -0,0 +1,919 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_view.c -- setup all the parameters (position, angle, etc) +// for a 3D rendering +#include "cg_local.h" + +/* +============================================================================= + + MODEL TESTING + +The viewthing and gun positioning tools from Q2 have been integrated and +enhanced into a single model testing facility. + +Model viewing can begin with either "testmodel " or "testgun ". + +The names must be the full pathname after the basedir, like +"models/weapons/v_launch/tris.md3" or "players/male/tris.md3" + +Testmodel will create a fake entity 100 units in front of the current view +position, directly facing the viewer. It will remain immobile, so you can +move around it to view it from different angles. + +Testgun will cause the model to follow the player around and supress the real +view weapon model. The default frame 0 of most guns is completely off screen, +so you will probably have to cycle a couple frames to see it. + +"nextframe", "prevframe", "nextskin", and "prevskin" commands will change the +frame or skin of the testmodel. These are bound to F5, F6, F7, and F8 in +q3default.cfg. + +If a gun is being tested, the "gun_x", "gun_y", and "gun_z" variables will let +you adjust the positioning. + +Note that none of the model testing features update while the game is paused, so +it may be convenient to test with deathmatch set to 1 so that bringing down the +console doesn't pause the game. + +============================================================================= +*/ + +/* +================= +CG_TestModel_f + +Creates an entity in front of the current position, which +can then be moved around +================= +*/ +void CG_TestModel_f (void) { + vec3_t angles; + char tmp[128]; + + memset( &cg.testModelEntity, 0, sizeof(cg.testModelEntity) ); + if ( cgi.Argc() < 2 ) { + return; + } + + Q_strncpyz (cg.testModelName, CG_Argv( 1 ), MAX_QPATH ); + cg.testModelEntity.model = cgi.R_RegisterModel( cg.testModelName ); + + if ( cgi.Argc() == 3 ) { + cg.testModelEntity.backlerp = atof( CG_Argv( 2 ) ); + cg.testModelEntity.frame = 1; + cg.testModelEntity.oldframe = 0; + } + if( !cg.testModelEntity.model ) { + strcpy(tmp,"models/"); + strcat(tmp,cg.testModelName); + strcpy(cg.testModelName,tmp); + cg.testModelEntity.model = cgi.R_RegisterModel( cg.testModelName ); + if( !cg.testModelEntity.model ) { + CG_Printf( "Can't register model\n" ); + return; + } + } + + VectorMA( cg.refdef.vieworg, 100, cg.refdef.viewaxis[0], cg.testModelEntity.origin ); + + angles[PITCH] = 0; + angles[YAW] = 180 + cg.refdefViewAngles[1]; + angles[ROLL] = 0; + + AnglesToAxis( angles, cg.testModelEntity.axis ); + cg.testGun = qfalse; +} + +void CG_TestModelAnim_f (void) { + Q_strncpyz (cg.testModelAnim, CG_Argv( 1 ), MAX_QPATH ); +} + +void CG_TestModelAnimSpeedScale_f(void) { + cg.testModelAnimSpeedScale = atof(CG_Argv(1)); +} + +/* +================= +CG_TestGun_f + +Replaces the current view weapon with the given model +================= +*/ +void CG_TestGun_f (void) { + CG_TestModel_f(); + cg.testGun = qtrue; + cg.testModelEntity.renderfx = RF_MINLIGHT | RF_DEPTHHACK | RF_FIRST_PERSON; +} + + +void CG_TestModelNextFrame_f (void) { + cg.testModelEntity.frame++; + CG_Printf( "frame %i\n", cg.testModelEntity.frame ); +} + +void CG_TestModelPrevFrame_f (void) { + cg.testModelEntity.frame--; + if ( cg.testModelEntity.frame < 0 ) { + cg.testModelEntity.frame = 0; + } + CG_Printf( "frame %i\n", cg.testModelEntity.frame ); +} + +void CG_TestModelNextSkin_f (void) { + cg.testModelEntity.skinNum++; + CG_Printf( "skin %i\n", cg.testModelEntity.skinNum ); +} + +void CG_TestModelPrevSkin_f (void) { + cg.testModelEntity.skinNum--; + if ( cg.testModelEntity.skinNum < 0 ) { + cg.testModelEntity.skinNum = 0; + } + CG_Printf( "skin %i\n", cg.testModelEntity.skinNum ); +} + +static void CG_AddTestModel (void) { + int i; + tiki_t *tiki; + // re-register the model, because the level may have changed + cg.testModelEntity.model = cgi.R_RegisterModel( cg.testModelName ); + tiki = cgi.TIKI_RegisterModel( cg.testModelName ); + if( !cg.testModelEntity.model ) { + CG_Printf ("Can't register model\n"); + return; + } + + // if testing a gun, set the origin reletive to the view origin + if ( cg.testGun ) { + VectorCopy( cg.refdef.vieworg, cg.testModelEntity.origin ); + VectorCopy( cg.refdef.viewaxis[0], cg.testModelEntity.axis[0] ); + VectorCopy( cg.refdef.viewaxis[1], cg.testModelEntity.axis[1] ); + VectorCopy( cg.refdef.viewaxis[2], cg.testModelEntity.axis[2] ); + + // allow the position to be adjusted + for (i=0 ; i<3 ; i++) { + cg.testModelEntity.origin[i] += cg.refdef.viewaxis[0][i] * cg_gun_x->value; + cg.testModelEntity.origin[i] += cg.refdef.viewaxis[1][i] * cg_gun_y->value; + cg.testModelEntity.origin[i] += cg.refdef.viewaxis[2][i] * cg_gun_z->value; + } + } + if( tiki ) { + int animIndex; + + cg.testModelEntity.bones = cgi.TIKI_GetBones(tiki->numBones); + ClearBounds(cg.testModelEntity.bounds[0],cg.testModelEntity.bounds[1]); + cg.testModelEntity.radius = 0; + + animIndex = cgi.TIKI_GetAnimIndex(tiki,cg.testModelAnim); + if(cg.testModelAnim[0]) { + float t = cg.time / 1000.f; + if(cg.testModelAnimSpeedScale != 0.f) { + t *= cg.testModelAnimSpeedScale; + } + cgi.TIKI_AppendFrameBoundsAndRadius(tiki,animIndex,t,&cg.testModelEntity.radius,cg.testModelEntity.bounds); + cgi.TIKI_SetChannels(tiki,animIndex,t,1,cg.testModelEntity.bones); + } else { + cgi.TIKI_AppendFrameBoundsAndRadius(tiki,0,0,&cg.testModelEntity.radius,cg.testModelEntity.bounds); + cgi.TIKI_SetChannels(tiki,0,0,1,cg.testModelEntity.bones); + } + cgi.TIKI_Animate(tiki,cg.testModelEntity.bones); + } + cgi.R_AddRefEntityToScene( &cg.testModelEntity ); +} + + + +//============================================================================ + + +/* +================= +CG_CalcVrect + +Sets the coordinates of the rendered window +================= +*/ +static void CG_CalcVrect (void) { + int size; + + // bound normal viewsize + if (cg_viewsize->integer < 30) { + cgi.Cvar_Set ("cg_viewsize","30"); + size = 30; + } else if (cg_viewsize->integer > 100) { + cgi.Cvar_Set ("cg_viewsize","100"); + size = 100; + } else { + size = cg_viewsize->integer; + } + + cg.refdef.width = cgs.glconfig.vidWidth*size/100; + cg.refdef.width &= ~1; + + cg.refdef.height = cgs.glconfig.vidHeight*size/100; + cg.refdef.height &= ~1; + + cg.refdef.x = (cgs.glconfig.vidWidth - cg.refdef.width)/2; + cg.refdef.y = (cgs.glconfig.vidHeight - cg.refdef.height)/2; +} + +//============================================================================== + + +/* +=============== +CG_OffsetThirdPersonView + +=============== +*/ +#define FOCUS_DISTANCE 512 +static void CG_OffsetThirdPersonView( void ) { + vec3_t forward, right, up; + vec3_t view; + vec3_t focusAngles; + trace_t trace; + static vec3_t mins = { -4, -4, -4 }; + static vec3_t maxs = { 4, 4, 4 }; + vec3_t focusPoint; + float focusDist; + float forwardScale, sideScale; + + cg.refdef.vieworg[2] += cg.predictedPlayerState.viewheight; + + VectorCopy( cg.refdefViewAngles, focusAngles ); + + // if dead, look at killer + if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) { + focusAngles[YAW] = cg.predictedPlayerState.stats[STAT_DEAD_YAW]; + cg.refdefViewAngles[YAW] = cg.predictedPlayerState.stats[STAT_DEAD_YAW]; + } + + if ( focusAngles[PITCH] > 45 ) { + focusAngles[PITCH] = 45; // don't go too far overhead + } + AngleVectors( focusAngles, forward, NULL, NULL ); + + VectorMA( cg.refdef.vieworg, FOCUS_DISTANCE, forward, focusPoint ); + + VectorCopy( cg.refdef.vieworg, view ); + + view[2] += 8; + + cg.refdefViewAngles[PITCH] *= 0.5; + + AngleVectors( cg.refdefViewAngles, forward, right, up ); + + forwardScale = cos( cg_thirdPersonAngle->value / 180 * M_PI ); + sideScale = sin( cg_thirdPersonAngle->value / 180 * M_PI ); + VectorMA( view, -cg_thirdPersonRange->value * forwardScale, forward, view ); + VectorMA( view, -cg_thirdPersonRange->value * sideScale, right, view ); + + // trace a ray from the origin to the viewpoint to make sure the view isn't + // in a solid block. Use an 8 by 8 block to prevent the view from near clipping anything + + if (!cg_cameraMode->integer) { + CG_Trace( &trace, cg.refdef.vieworg, mins, maxs, view, cg.predictedPlayerState.clientNum, MASK_SOLID ); + + if ( trace.fraction != 1.0 ) { + VectorCopy( trace.endpos, view ); + view[2] += (1.0 - trace.fraction) * 32; + // try another trace to this position, because a tunnel may have the ceiling + // close enogh that this is poking out + + CG_Trace( &trace, cg.refdef.vieworg, mins, maxs, view, cg.predictedPlayerState.clientNum, MASK_SOLID ); + VectorCopy( trace.endpos, view ); + } + } + + + VectorCopy( view, cg.refdef.vieworg ); + + // select pitch to look at focus point from vieword + VectorSubtract( focusPoint, cg.refdef.vieworg, focusPoint ); + focusDist = sqrt( focusPoint[0] * focusPoint[0] + focusPoint[1] * focusPoint[1] ); + if ( focusDist < 1 ) { + focusDist = 1; // should never happen + } + cg.refdefViewAngles[PITCH] = -180 / M_PI * atan2( focusPoint[2], focusDist ); + cg.refdefViewAngles[YAW] -= cg_thirdPersonAngle->value; +} + + +// this causes a compiler bug on mac MrC compiler +static void CG_StepOffset( void ) { + int timeDelta; + + // smooth out stair climbing + timeDelta = cg.time - cg.stepTime; + if ( timeDelta < STEP_TIME ) { + cg.refdef.vieworg[2] -= cg.stepChange + * (STEP_TIME - timeDelta) / STEP_TIME; + } +} + +/* +=============== +CG_OffsetFirstPersonView + +=============== +*/ +static void CG_OffsetFirstPersonView( void ) { + float *origin; + float *angles; + float bob; + float ratio; + float delta; + float f; + int timeDelta; + vec3_t tmp; + vec3_t right; + trace_t trace; + vec3_t mins = { -8, -8, -8 }; + vec3_t maxs = { 8, 8, 8 }; + matrix_t m; + vec3_t pos, v; + + origin = cg.refdef.vieworg; + angles = cg.refdefViewAngles; + + // if dead, fix the angle and don't add any kick + if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) { + angles[ROLL] = 40; + angles[PITCH] = -15; + angles[YAW] = cg.snap->ps.stats[STAT_DEAD_YAW]; + origin[2] += cg.predictedPlayerState.viewheight; + return; + } + + // add angles based on weapon kick + VectorAdd (angles, cg.kick_angles, angles); + + // add angles based on damage kick + if ( cg.damageTime ) { + ratio = cg.time - cg.damageTime; + if ( ratio < DAMAGE_DEFLECT_TIME ) { + ratio /= DAMAGE_DEFLECT_TIME; + angles[PITCH] += ratio * cg.v_dmg_pitch; + angles[ROLL] += ratio * cg.v_dmg_roll; + } else { + ratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME; + if ( ratio > 0 ) { + angles[PITCH] += ratio * cg.v_dmg_pitch; + angles[ROLL] += ratio * cg.v_dmg_roll; + } + } + } + + // add pitch based on fall kick +#if 0 + ratio = ( cg.time - cg.landTime) / FALL_TIME; + if (ratio < 0) + ratio = 0; + angles[PITCH] += ratio * cg.fall_value; +#endif + +#if 0 + + // add angles based on velocity + VectorCopy( cg.predictedPlayerState.velocity, predictedVelocity ); + + delta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[0]); + angles[PITCH] += delta * cg_runpitch->value; + + delta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[1]); + angles[ROLL] -= delta * cg_runroll->value; + + // add angles based on bob + + // make sure the bob is visible even at low speeds + speed = cg.xyspeed > 200 ? cg.xyspeed : 200; + + delta = cg.bobfracsin * cg_bobpitch->value * speed; + if (cg.predictedPlayerState.pm_flags & PMF_DUCKED) + delta *= 3; // crouching + angles[PITCH] += delta; + delta = cg.bobfracsin * cg_bobroll->value * speed; + if (cg.predictedPlayerState.pm_flags & PMF_DUCKED) + delta *= 3; // crouching accentuates roll + if (cg.bobcycle & 1) + delta = -delta; + angles[ROLL] += delta; +#endif + +//=================================== + + // add view height + origin[ 2 ] += cg.predictedPlayerState.viewheight; + + // smooth out duck height changes + timeDelta = cg.time - cg.duckTime; + if ( timeDelta < DUCK_TIME) { + cg.refdef.vieworg[ 2 ] -= cg.duckChange + * ( DUCK_TIME - timeDelta ) / DUCK_TIME; + } + + if( cg.predictedPlayerState.groundEntityNum != ENTITYNUM_NONE ) + { + float vel = VectorLength( cg.predictedPlayerState.velocity ); + + cg.fCurrentViewBobPhase = ( ( ( float )cg.frametime ) / 1000 ) * M_PI + * ( vel * 0.001500000013038516 + 0.8999999761581421 ) * 2 + cg.fCurrentViewBobPhase; + + if( cg.fCurrentViewBobAmp != 0.0 ) + vel = vel * 0.5; + + cg.fCurrentViewBobAmp = vel; + + if( cg.predictedPlayerState.fLeanAngle != 0.f ) { + cg.fCurrentViewBobAmp = cg.fCurrentViewBobAmp * 0.75; + } + + cg.fCurrentViewBobAmp = ( 1.0 - fabs( cg.refdefViewAngles[ 0 ] ) * 0.01111111138015985 * 0.5 ) + * 0.5 + * cg.fCurrentViewBobAmp; + } + else if( cg.fCurrentViewBobAmp > 0.0 ) + { + float f; + + f = ( ( float )cg.frametime ) * 0.001 * cg.fCurrentViewBobAmp; + cg.fCurrentViewBobAmp -= ( f + f ); + } + + if( cg.fCurrentViewBobAmp > 0.0 ) { + + } + + // add bob values + VectorClear( pos ); + + bob = cg.fCurrentViewBobAmp * ( sin( cg.fCurrentViewBobPhase - 0.9424778335276408 + cg.fCurrentViewBobPhase - 0.9424778335276408 + 3.141592653589793 ) + + sin( ( cg.fCurrentViewBobPhase - 0.9424778335276408 ) * 4.0 + 1.570796326794897 ) * 0.125 ) * 0.05f; + + pos[ 1 ] = -( sin( cg.fCurrentViewBobPhase + 0.3141592700403172 ) * cg.fCurrentViewBobAmp * 0.05f ) * 1.5f; + + MatrixFromAngles( m, cg.refdefViewAngles[ 0 ], cg.refdefViewAngles[ 1 ], cg.refdefViewAngles[ 2 ] ); + MatrixTransformPoint( m, pos, v ); + + VectorSubtract( origin, v, origin ); + + origin[ 2 ] += bob; + + // add fall height + delta = cg.time - cg.landTime; + if ( delta < LAND_DEFLECT_TIME ) { + f = delta / LAND_DEFLECT_TIME; + cg.refdef.vieworg[2] += cg.landChange * f; + } else if ( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME ) { + delta -= LAND_DEFLECT_TIME; + f = 1.0 - ( delta / LAND_RETURN_TIME ); + cg.refdef.vieworg[2] += cg.landChange * f; + } + + // add step offset + CG_StepOffset(); + + // add kick offset + + VectorAdd (origin, cg.kick_origin, origin); + + // pivot the eye based on a neck length +#if 0 + { +#define NECK_LENGTH 8 + vec3_t forward, up; + + cg.refdef.vieworg[2] -= NECK_LENGTH; + AngleVectors( cg.refdefViewAngles, forward, NULL, up ); + VectorMA( cg.refdef.vieworg, 3, forward, cg.refdef.vieworg ); + VectorMA( cg.refdef.vieworg, NECK_LENGTH, up, cg.refdef.vieworg ); + } +#endif + + // add leaning rotation + cg.refdefViewAngles[ROLL] = cg.predictedPlayerState.fLeanAngle * 0.300000011920929; + + // add leaning offset +#if 0 + a[0] = cg.refdefViewAngles[0]; + a[1] = cg.refdefViewAngles[1]; + a[2] = 0; + AngleVectors(a,forward,0,0); + + //VectorCopy(cg.refdef.vieworg,tmp); + RotatePointAroundVector(tmp, forward, vec3_origin, cg.predictedPlayerState.fLeanAngle); + VectorAdd(tmp,cg.refdef.vieworg,cg.refdef.vieworg); +#else + //add leaning offset + AngleVectors( cg.refdefViewAngles, 0, right, 0 ); + VectorMA( cg.refdef.vieworg, cg.predictedPlayerState.fLeanAngle*0.5f, right, tmp ); + CG_Trace(&trace,cg.refdef.vieworg,mins,maxs,tmp,-1,CONTENTS_SOLID); + VectorCopy(trace.endpos,cg.refdef.vieworg); + // fLeanAngle range: <-40,40> + //CG_Printf("Leanangle: %f\n",cg.predictedPlayerState.fLeanAngle); +#endif +} + +//====================================================================== + +void CG_ZoomDown_f( void ) { + if ( cg.zoomed ) { + return; + } + cg.zoomed = qtrue; + cg.zoomTime = cg.time; +} + +void CG_ZoomUp_f( void ) { + if ( !cg.zoomed ) { + return; + } + cg.zoomed = qfalse; + cg.zoomTime = cg.time; +} + + +/* +==================== +CG_CalcFov + +Fixed fov at intermissions, otherwise account for fov variable and zooms. +==================== +*/ +#define WAVE_AMPLITUDE 1 +#define WAVE_FREQUENCY 0.4 + +static int CG_CalcFov( void ) { + float x; + float phase; + float v; + int contents; + float fov_x, fov_y; + int inwater; + +#if 0 + if ( cg.predictedPlayerState.pm_type == PM_INTERMISSION ) { + // if in intermission, use a fixed value + fov_x = 90; + } else { + // user selectable + if ( cgs.dmflags & DF_FIXED_FOV ) { + // dmflag to prevent wide fov for all clients + fov_x = 90; + } else { + fov_x = cg_fov->value; + if ( fov_x < 1 ) { + fov_x = 1; + } else if ( fov_x > 160 ) { + fov_x = 160; + } + } + + // account for zooms + zoomFov = cg_zoomFov->value; + if ( zoomFov < 1 ) { + zoomFov = 1; + } else if ( zoomFov > 160 ) { + zoomFov = 160; + } + + if ( cg.zoomed ) { + f = ( cg.time - cg.zoomTime ) / (float)ZOOM_TIME; + if ( f > 1.0 ) { + fov_x = zoomFov; + } else { + fov_x = fov_x + f * ( zoomFov - fov_x ); + } + } else { + f = ( cg.time - cg.zoomTime ) / (float)ZOOM_TIME; + if ( f > 1.0 ) { + fov_x = fov_x; + } else { + fov_x = zoomFov + f * ( fov_x - zoomFov ); + } + } + } +#else + // su44: use FOV value send by MoHAA server + if(cg.snap) + fov_x = cg.snap->ps.fov; + else + fov_x = 90; +#endif + + x = cg.refdef.width / tan( fov_x / 360 * M_PI ); + fov_y = atan2( cg.refdef.height, x ); + fov_y = fov_y * 360 / M_PI; + + // warp if underwater + contents = CG_PointContents( cg.refdef.vieworg, -1 ); + if ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ){ + phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2; + v = WAVE_AMPLITUDE * sin( phase ); + fov_x += v; + fov_y -= v; + inwater = qtrue; + } + else { + inwater = qfalse; + } + + + // set it + cg.refdef.fov_x = fov_x; + cg.refdef.fov_y = fov_y; + + if ( !cg.zoomed ) { + cg.zoomSensitivity = 1; + } else { + cg.zoomSensitivity = cg.refdef.fov_y / 75.0; + } + + return inwater; +} + + + +/* +=============== +CG_DamageBlendBlob + +=============== +*/ +static void CG_DamageBlendBlob( void ) { + //int t; + //int maxTime; + //refEntity_t ent; + + //if ( !cg.damageValue ) { + // return; + //} + + ////if (cg.cameraMode) { + //// return; + ////} + + //// ragePro systems can't fade blends, so don't obscure the screen + //if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) { + // return; + //} + + //maxTime = DAMAGE_TIME; + //t = cg.time - cg.damageTime; + //if ( t <= 0 || t >= maxTime ) { + // return; + //} + + + //memset( &ent, 0, sizeof( ent ) ); + //ent.reType = RT_SPRITE; + //ent.renderfx = RF_FIRST_PERSON; + + //VectorMA( cg.refdef.vieworg, 8, cg.refdef.viewaxis[0], ent.origin ); + //VectorMA( ent.origin, cg.damageX * -8, cg.refdef.viewaxis[1], ent.origin ); + //VectorMA( ent.origin, cg.damageY * 8, cg.refdef.viewaxis[2], ent.origin ); + + //ent.radius = cg.damageValue * 3; + //ent.customShader = cgs.media.viewBloodShader; + //ent.shaderRGBA[0] = 255; + //ent.shaderRGBA[1] = 255; + //ent.shaderRGBA[2] = 255; + //ent.shaderRGBA[3] = 200 * ( 1.0 - ((float)t / maxTime) ); + //cgi.R_AddRefEntityToScene( &ent ); +} + + +/* +=============== +CG_CalcViewValues + +Sets cg.refdef view values +=============== +*/ +static int CG_CalcViewValues( void ) { + playerState_t *ps; + + memset( &cg.refdef, 0, sizeof( cg.refdef ) ); + + // su44: copy MoHAA fog data + VectorCopy(cg.farplane_color,cg.refdef.farplane_color); + cg.refdef.farplane_cull = cg.farplane_cull; + cg.refdef.farplane_distance = cg.farplane_distance; + + // strings for in game rendering + // Q_strncpyz( cg.refdef.text[0], "Park Ranger", sizeof(cg.refdef.text[0]) ); + // Q_strncpyz( cg.refdef.text[1], "19", sizeof(cg.refdef.text[1]) ); + + // calculate size of 3D view + CG_CalcVrect(); + + ps = &cg.predictedPlayerState; +/* + if (cg.cameraMode) { + vec3_t origin, angles; + if (cgi.getCameraInfo(cg.time, &origin, &angles)) { + VectorCopy(origin, cg.refdef.vieworg); + angles[ROLL] = 0; + VectorCopy(angles, cg.refdefViewAngles); + AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); + return CG_CalcFov(); + } else { + cg.cameraMode = qfalse; + } + } +*/ + cg.bobcycle = ( ps->bobCycle & 128 ) >> 7; + cg.bobfracsin = fabs( sin( ( ps->bobCycle & 127 ) / 127.0 * M_PI ) ); + cg.xyspeed = sqrt( ps->velocity[0] * ps->velocity[0] + + ps->velocity[1] * ps->velocity[1] ); + + + VectorCopy( ps->origin, cg.refdef.vieworg ); + VectorCopy( ps->viewangles, cg.refdefViewAngles ); + + if (cg_cameraOrbit->integer) { + if (cg.time > cg.nextOrbitTime) { + cg.nextOrbitTime = cg.time + cg_cameraOrbitDelay->integer; + cg_thirdPersonAngle->value += cg_cameraOrbit->value; + } + } + // add error decay + if ( cg_errorDecay->value > 0 ) { + int t; + float f; + + t = cg.time - cg.predictedErrorTime; + f = ( cg_errorDecay->value - t ) / cg_errorDecay->value; + if ( f > 0 && f < 1 ) { + VectorMA( cg.refdef.vieworg, f, cg.predictedError, cg.refdef.vieworg ); + } else { + cg.predictedErrorTime = 0; + } + } + + if ( cg.renderingThirdPerson ) { + // back away from character + CG_OffsetThirdPersonView(); + } else { + // offset for local bobbing and kicks + CG_OffsetFirstPersonView(); + } + + // position eye reletive to origin + AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); + + if ( cg.hyperspace ) { + cg.refdef.rdflags |= RDF_NOWORLDMODEL | RDF_HYPERSPACE; + } + + // field of view + return CG_CalcFov(); +} + +//========================================================================= + +/* +================= +CG_DrawActiveFrame + +Generates and draws a game scene and status information at the given time. +================= +*/ +void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback ) { + int inwater; + int i; + + cg.time = serverTime; + cg.demoPlayback = demoPlayback; + + // update cvars + CG_UpdateCvars(); + + // if we are only updating the screen as a loading + // pacifier, don't even try to read snapshots + if ( cg.infoScreenText[0] != 0 ) { + CG_DrawInformation(); + return; + } + + // any looped sounds will be respecified as entities + // are added to the render list + cgi.S_ClearLoopingSounds(qfalse); + + // clear all the render lists + cgi.R_ClearScene(); + + // set up cg.snap and possibly cg.nextSnap + CG_ProcessSnapshots(); + + // if we haven't received any snapshots yet, all + // we can draw is the information screen + if ( !cg.snap || ( cg.snap->snapFlags & SNAPFLAG_NOT_ACTIVE ) ) { + CG_DrawInformation(); + return; + } + + // let the client system know what our weapon and zoom settings are + cgi.SetUserCmdValue( CG_WeaponCommandButtonBits(), cg.zoomSensitivity ); + + // this counter will be bumped for every valid scene we generate + cg.clientFrame++; + + // update cg.predictedPlayerState + CG_PredictPlayerState(); + + // decide on third person view + cg.renderingThirdPerson = cg_thirdPerson->integer || (cg.snap->ps.stats[STAT_HEALTH] <= 0); + + // build cg.refdef + inwater = CG_CalcViewValues(); + + // first person blend blobs, done after AnglesToAxis + if ( !cg.renderingThirdPerson ) { + CG_DamageBlendBlob(); + } + + // build the render lists + if ( !cg.hyperspace ) { + CG_AddPacketEntities(); // adter calcViewValues, so predicted player state is correct + CG_AddBulletTracers(); + CG_AddBulletImpacts(); + CG_AddBeams(); + CG_AddMarks(); + CG_AddParticles (); + CG_AddLocalEntities(); + } + // process MoHAA clientside events + CG_ProcessPendingEvents(); + + CG_AddViewWeapon( &cg.predictedPlayerState ); + + // finish up the rest of the refdef + if( cg.testModelEntity.model ) { + CG_AddTestModel(); + } + cg.refdef.time = cg.time; + memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) ); + + // update audio positions + cgi.S_Respatialize( cg.snap->ps.clientNum, cg.refdef.vieworg, cg.refdef.viewaxis, inwater ); + + // make sure the lagometerSample and frame timing isn't done twice when in stereo + if ( stereoView != STEREO_RIGHT ) { + cg.frametime = cg.time - cg.oldTime; + if ( cg.frametime < 0 ) { + cg.frametime = 0; + } + cg.oldTime = cg.time; + CG_AddLagometerFrameInfo(); + } + if (cg_timescale->value != cg_timescaleFadeEnd->value) { + if (cg_timescale->value < cg_timescaleFadeEnd->value) { + cg_timescale->value += cg_timescaleFadeSpeed->value * ((float)cg.frametime) / 1000; + if (cg_timescale->value > cg_timescaleFadeEnd->value) + cg_timescale->value = cg_timescaleFadeEnd->value; + } + else { + cg_timescale->value -= cg_timescaleFadeSpeed->value * ((float)cg.frametime) / 1000; + if (cg_timescale->value < cg_timescaleFadeEnd->value) + cg_timescale->value = cg_timescaleFadeEnd->value; + } + if (cg_timescaleFadeSpeed->value) { + cgi.Cvar_Set("timescale", va("%f", cg_timescale->value)); + } + } + + // actually issue the rendering calls + CG_DrawActive( stereoView ); + + if ( cg_stats->integer ) { + CG_Printf( "cg.clientFrame:%i\n", cg.clientFrame ); + } + + // bones pointers are no longer valid + for( i = 0; i < MAX_ENTITIES; i++) { + cg_entities[i].bones = 0; + } +} + diff --git a/code/cgame/cg_viewmodelanim.c b/code/cgame/cg_viewmodelanim.c new file mode 100644 index 00000000..02d5bc74 --- /dev/null +++ b/code/cgame/cg_viewmodelanim.c @@ -0,0 +1,606 @@ +/* +=========================================================================== +Copyright (C) 2010 su44 + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cg_local.h" + +#define VIEWMODEL_PITCH_FIX 8.0f + +char itemNames[64][64]; +void CG_RegisterItemName(int index, const char *str) { + if(index >= 64 || index < 0) { + CG_Error("CG_RegisterItemName: item index out of range 64 (%i, %s)\n",index,str); + return; + } + strcpy(itemNames[index],str); +} + +const char *CG_GetItemName(int index) { + if(index >= 64 || index < 0) { + CG_Error("CG_GetItemName: item index out of range 64 (%i)\n",index); + return 0; + } + return itemNames[index]; +} +//papers colt45 p38 histandard garand kar98 kar98sniper springfield thompson mp40 bar mp44 fraggrenade stielhandgranate bazooka panzerschreck shotgun unarmed +//Papers Colt 45 Walther P38 Hi-Standard Silenced M1 Garand Mauser KAR 98K KAR98 - Sniper Springfield '03 Sniper Thompson MP40 BAR StG 44 Frag Grenade Stielhandgranate Bazooka Panzerschreck Shotgun +const char *CG_GetVMAnimPrefixString(int index) { + const char *wpn; + wpn = CG_ConfigString( CS_WEAPONS + index ); //CG_GetItemName(index); + if(wpn) { + if(!Q_stricmp(wpn,"Papers")) + return "papers"; + if(!Q_stricmp(wpn,"Colt 45")) + return "colt45"; + if(!Q_stricmp(wpn,"Walther P38")) + return "p38"; + if(!Q_stricmp(wpn,"Hi-Standard Silenced")) + return "histandard"; + if(!Q_stricmp(wpn,"M1 Garand")) + return "garand"; + if(!Q_stricmp(wpn,"Mauser KAR 98K")) + return "kar98"; + if(!Q_stricmp(wpn,"KAR98 - Sniper")) + return "kar98sniper"; + if(!Q_stricmp(wpn,"Springfield '03 Sniper")) + return "springfield"; + if(!Q_stricmp(wpn,"Thompson")) + return "thompson"; + if(!Q_stricmp(wpn,"MP40")) + return "mp40"; + if(!Q_stricmp(wpn,"BAR")) + return "bar"; + if(!Q_stricmp(wpn,"StG 44")) + return "mp44"; + if(!Q_stricmp(wpn,"Frag Grenade")) + return "fraggrenade"; + if(!Q_stricmp(wpn,"Stielhandgranate")) + return "stielhandgranate"; + if(!Q_stricmp(wpn,"Bazooka")) + return "bazooka"; + if(!Q_stricmp(wpn,"Panzerschreck")) + return "panzerschreck"; + if(!Q_stricmp(wpn,"Shotgun")) + return "shotgun"; + } + return "unarmed"; +} + +char *viewModelAnimTypes[] = { + "idle", // 0 + "charge", // 1 + "fire", // 2 + "fire_secondary", // 3 + "rechamber", // 4 + "reload", // 5 + "reload_single", // 6 + "reload_end", // 7 + "pullout", // 8 + "putaway", // 9 + "ladderstep" // 10 +}; +const char *CG_GetVMTypeString(int index) { + if(index < 0 || index > VMA_NUMANIMATIONS) { + return "idle"; + } + return viewModelAnimTypes[index]; +} +void CG_AddViewModelAnimAttachment( refEntity_t *ent, centity_t *cent ) { + vec3_t outRot; + vec3_t angles; + + int boneName; + int i; + if(cg.renderingThirdPerson || cgi.anim->ref.bones == 0) + return; + if(cg.snap->ps.stats[STAT_INZOOM]) + return; + ent->renderfx = RF_FIRST_PERSON; +#if 0 //doesnt work, tag_num is incorrect.. + CG_BoneLocal2World(cg.viewModelEnt.bones+cent->currentState.tag_num,cg.viewModelEnt.origin,cg.refdefViewAngles,ent->origin,outRot); +#else + if(cgs.gameTIKIs[cg_entities[cent->currentState.parent].currentState.modelindex]==0) { + //CG_Printf("CG_AddViewModelAnimAttachment: entity %i has null tiki; cannot attach %i\n",cent->currentState.parent, cent->currentState.number); + return; + } + boneName = cgs.gameTIKIs[cg_entities[cent->currentState.parent].currentState.modelindex]->boneNames[cent->currentState.tag_num]; + for(i = 0; i < cgi.anim->tiki->numBones; i++) { + if( boneName == cgi.anim->tiki->boneNames[ i ] ) + break; + } + if( i == cgi.anim->tiki->numBones ) + return; + + VectorCopy( cg.refdefViewAngles, angles ); + + angles[ PITCH ] += VIEWMODEL_PITCH_FIX; + + CG_BoneLocal2World(cgi.anim->ref.bones+i,cgi.anim->ref.origin,angles,ent->origin,outRot); +#endif + VectorCopy(ent->origin,cent->lerpOrigin); + VectorCopy(outRot,cent->lerpAngles); + + AnglesToAxis(outRot,ent->axis); + + cgi.R_AddRefEntityToScene(ent); +} +void CG_CalcViewModelMovement(float fViewBobPhase, float fViewBobAmp, + float *vVelocity, float *vMovement ) { + float tmp,tmp2; + float frac; + vec3_t vmOfs; + float vMovementLen; + vec3_t vMovementNormalized; + float *curAnimVMPosOfs; + int i; + + vMovement[1] = sin(fViewBobPhase + 0.3141592700403172) * fViewBobAmp * vm_sway_side->value; + vMovement[0] = vMovement[1] * vm_sway_front->value; + tmp = sin(fViewBobPhase - 0.9424778335276408 + fViewBobPhase - 0.9424778335276408 + 3.141592653589793) + + sin((fViewBobPhase - 0.9424778335276408) * 4.0 + 1.570796326794897) * 0.125; + vMovement[2] = fViewBobAmp * tmp * vm_sway_up->value; + + //if(!cg.predictedPlayerState.walking) { + if(cg.predictedPlayerState.groundEntityNum == ENTITYNUM_NONE) { + // player is in air + vmOfs[0] = vm_offset_air_front->value; + vmOfs[1] = vm_offset_air_side->value; + vmOfs[2] = vm_offset_air_up->value; + // append offset depending on Z velocity + if(vVelocity[2] != 0.f) { + vmOfs[2] -= vVelocity[2] * vm_offset_upvel->value; + } + } else { + // player is walking + if ( cg.predictedPlayerState.viewheight == 48 ) { + // and crouching? + + /* + // special cases for shotgun and rocked launchers - TODO + if(using shotgun) { + vmOfs[0] = vm_offset_shotguncrouch_front->value; + vmOfs[1] = vm_offset_shotguncrouch_side->value; + vmOfs[2] = vm_offset_shotguncrouch_up->value; + } else if(using rockets) { + vmOfs[0] = vm_offset_rocketcrouch_front->value; + vmOfs[1] = vm_offset_rocketcrouch_side->value; + vmOfs[2] = vm_offset_rocketcrouch_up->value; + } else + */ + { + vmOfs[0] = vm_offset_crouch_front->value; + vmOfs[1] = vm_offset_crouch_side->value; + vmOfs[2] = vm_offset_crouch_up->value; + } + } else { + // player is standing + VectorClear(vmOfs); + } + tmp = VectorLength(vVelocity) - vm_offset_vel_base->value; + + if(tmp > 0) { + tmp2 = 250.0 - vm_offset_vel_base->value; + if( tmp > tmp2 ) + tmp = tmp2; + frac = tmp / tmp2; + + vmOfs[0] += frac * vm_offset_vel_front->value; + vmOfs[1] += frac * vm_offset_vel_side->value; + vmOfs[2] += frac * vm_offset_vel_up->value; + } + + + + } + + + // for each coordinate + curAnimVMPosOfs = &cgi.anim->currentVMPosOffset[0]; + for(i = 0; i < 3; i++) { + float ofsDelta; + ofsDelta = vmOfs[i] - curAnimVMPosOfs[i]; + curAnimVMPosOfs[i] += (float)cg.frametime + * 0.001 + * ofsDelta + * vm_offset_speed->value; + //if(ofsDelta < 0) { + // if ( vmOfs[i] <= curAnimVMPosOfs[i] ) { + + // } else { + // curAnimVMPosOfs[i] = vmOfs[i]; + // } + //} else if(ofsDelta > 0) { + // if ( vmOfs[i] < curAnimVMPosOfs[i] ) { + + // } else { + // curAnimVMPosOfs[i] = vmOfs[i]; + // } + //} + } + + vMovement[ 0 ] = vMovement[ 0 ] + cgi.anim->currentVMPosOffset[ 0 ]; + vMovement[ 1 ] = vMovement[ 1 ] + cgi.anim->currentVMPosOffset[ 1 ]; + vMovement[ 2 ] = vMovement[ 2 ] + cgi.anim->currentVMPosOffset[ 2 ]; + + // add lean offset + if(cg.predictedPlayerState.fLeanAngle != 0.f) { + vMovement[2] -= fabs(cg.predictedPlayerState.fLeanAngle) * vm_lean_lower->value; + } + vMovementLen = VectorNormalize2(vMovement, vMovementNormalized); + if(vm_offset_max->value < vMovementLen) { + vMovement[0] = vm_offset_max->value * vMovementNormalized[0]; + vMovement[1] = vm_offset_max->value * vMovementNormalized[1]; + vMovement[2] = vm_offset_max->value * vMovementNormalized[2]; + } + + + +} + +void CG_ViewModelAnim() { + char anim[128]; + char tmp[128]; + int i; + char *ptr; + tiki_t *fps, *tiki; + refEntity_t *ent; + bone_t *bone; + vec3_t v; + int boneName; + matrix_t m; + vec3_t vMovement, angles; + int slot; + int index; + float crossblend; + float time, weight; + qboolean m_bAnimChange = qfalse; + + if( cg.renderingThirdPerson ) + return; + + if( cg.snap->ps.stats[ STAT_INZOOM ] ) + return; + + slot = cgi.anim->currentVMAnimSlot; + + if( slot < 0 || slot > MAX_FRAMEINFOS ) + { + slot = 0; + } + + ent = &cgi.anim->ref; + + VectorCopy( cg.refdefViewAngles, angles ); + + angles[ PITCH ] += VIEWMODEL_PITCH_FIX; + + //CG_Printf("vma changed %i\n",cg.predictedPlayerState.iViewModelAnimChanged); + + // mp40_reload, mp40_fire + if(cg.predictedPlayerState.activeItems[ITEM_WEAPON]!=-1) { + sprintf(anim,"%s_%s",CG_GetVMAnimPrefixString(cg.predictedPlayerState.activeItems[ITEM_WEAPON]),CG_GetVMTypeString(cg.predictedPlayerState.iViewModelAnim)); + //CG_Printf("VMA %s \n",anim); + } else + return; +#if 0 + for(i = 0; i < 8; i++) { + if(cg.predictedPlayerState.activeItems[i]!= -1 && cg.predictedPlayerState.activeItems[i]) { + CG_Printf("Item %i of 8, %s (indx %i)\n",i,itemNames[cg.predictedPlayerState.activeItems[i]],cg.predictedPlayerState.activeItems[i]); + } + /* +item 0 "pistol" +item 1 "Walther P38" +item 2 "Binoculars" + +item 0 "mg" +item 1 "MP44" +item 2 "Binoculars" + */ + } +#endif + //tiki = cgs.gameTIKIs[cg.predictedPlayerEntity.currentState.modelindex]; // doesnt work... currentState.modelindex == 0 + tiki = cgs.gameTIKIs[cg_entities[cg.clientNum].currentState.modelindex]; + if(!tiki) { + if(cg.snap->ps.stats[STAT_TEAM]==TEAM_AXIS) { + tiki = cgi.TIKI_RegisterModel("models/player/german_wehrmacht_soldier.tik"); + } else { + tiki = cgi.TIKI_RegisterModel("models/player/american_army.tik"); + } + if(!tiki) + return; + } + strcpy(tmp,tiki->name); + ptr = strchr(tmp,'.'); + + if( !ptr ) + return; + + *ptr = 0; + strcat(tmp,"_fps.tik"); + fps = cgi.TIKI_RegisterModel(tmp); + + if(!fps) { + CG_Printf("CG_ViewModelAnim: error, cannot register first person player model for %s\n",tiki->name); + return; + } + + cgi.anim->tiki = fps; + + if( cgi.anim->lastVMAnim == -1 ) + { + index = cgi.Anim_Random( fps, anim ); + + if( index < 0 ) + { + index = cgi.Anim_Random( fps, "idle" ); + + if( index == -1 ) { + index = 0; + } + + cgi.Printf( "Warning: #1 Couldn't find view model animation \"%s\"\n", anim ); + } + + cgi.anim->vmFrameInfo[ slot ].index = index; + + cgi.anim->vmFrameInfo[ slot ].time = 0.0f; + cgi.anim->vmFrameInfo[ slot ].weight = 1.0f; + cgi.anim->lastVMAnim = VMA_IDLE; + } + + if( cg.snap->ps.iViewModelAnimChanged != cgi.anim->lastVMAnimChanged ) + { + m_bAnimChange = qtrue; + + cgi.anim->lastVMAnim = cg.snap->ps.iViewModelAnim; + cgi.anim->lastVMAnimChanged = cg.snap->ps.iViewModelAnimChanged; + } + + if( m_bAnimChange ) + { + crossblend = cgi.Anim_CrossblendTime( tiki, cgi.anim->vmFrameInfo[ slot ].index ); + time = cgi.anim->currentVMDuration / 1000.0f; + + if( time < crossblend ) + { + weight = time / crossblend; + + for( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + float w; + + w = cgi.anim->vmFrameInfo[ i ].weight; + + if( w == 0.0f ) + { + continue; + } + + if( i == slot ) + { + cgi.anim->vmFrameInfo[ i ].weight = weight; + } + else + { + w = ( 1.0f - weight ) * cgi.anim->vmFrameInfo[ i ].weight; + cgi.anim->vmFrameInfo[ i ].weight = w; + } + } + } + + slot = ( slot + 1 ) % MAX_FRAMEINFOS; + cgi.anim->currentVMAnimSlot = slot; + + index = cgi.Anim_Random( fps, anim ); + + if( index < 0 ) + { + cgi.Printf( "Warning: #2 Couldn't find view model animation \"%s\"\n", anim ); + + sprintf( anim, "%s_idle", CG_GetVMAnimPrefixString( cg.predictedPlayerState.activeItems[ ITEM_WEAPON ] ) ); + + index = cgi.Anim_Random( fps, anim ); + + if( index < 0 ) { + index = 0; + } + } + + cgi.anim->vmFrameInfo[ slot ].index = index; + cgi.anim->vmFrameInfo[ slot ].time = 0.0f; + cgi.anim->vmFrameInfo[ slot ].weight = 1.0f; + + cgi.anim->currentVMDuration = 0; + + crossblend = cgi.Anim_CrossblendTime( tiki, index ); + + if( crossblend == 0.0f ) + { + for( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + if( i != slot ) { + cgi.anim->vmFrameInfo[ i ].weight = 0.0f; + } + } + + cgi.anim->crossBlending = qfalse; + } + else + { + cgi.anim->crossBlending = qtrue; + } + } + + cgi.anim->currentVMDuration += cg.frametime / 2; + + if( cgi.anim->crossBlending ) + { + crossblend = cgi.Anim_CrossblendTime( tiki, cgi.anim->vmFrameInfo[ slot ].index ); + time = cgi.anim->currentVMDuration / 1000.0f; + + if( time >= crossblend ) + { + for( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + if( slot != i ) { + cgi.anim->vmFrameInfo[ i ].weight = 0.0f; + } + } + + cgi.anim->crossBlending = qfalse; + } + else + { + weight = time / crossblend; + } + } + + // su44: ok, we have chosen the proper viewmodelanim + // but ent->origin and ent->axis still needs to be adjusted + memset( ent, 0, sizeof( *ent ) ); + + ent->renderfx = RF_FIRST_PERSON; + ent->model = cgi.R_RegisterModel( tmp ); + ent->bones = cgi.TIKI_GetBones( fps->numBones ); + + // dont bother culling hands model + VectorSet( ent->bounds[ 0 ], -99999, -99999, -99999 ); + VectorSet( ent->bounds[ 1 ], 99999, 99999, 99999 ); + + ent->radius = 99999; + + //ClearBounds( ent->bounds[ 0 ], ent->bounds[ 1 ] ); + //ent->radius = 0; + + // su44: kinda strange, but thats how its done by MoHAA + // we have two different hand surfaces - one is visible only while carrying rifles, + // second is used for the rest of weapons + ptr = itemNames[ cg.predictedPlayerState.activeItems[ ITEM_WEAPON ] ]; + + if( !Q_stricmp( ptr, "M1 Garand" ) || !Q_stricmp( ptr, "Springfield '03 Sniper" ) + || !Q_stricmp( ptr, "KAR98 - Sniper" ) || !Q_stricmp( ptr, "Mauser KAR 98K" ) ) + { + ent->surfaceBits |= ( 1 << TIKI_GetSurfaceIndex( fps, "lefthand" ) ); // hide "lefthand" surface + } + else + { + ent->surfaceBits |= ( 1 << TIKI_GetSurfaceIndex( fps, "garandhand" ) ); // hide "garandhand" surface + } + + for( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + float w, frametime; + + if( cgi.anim->vmFrameInfo[ i ].index >= 0 && cgi.anim->vmFrameInfo[ i ].weight != 0.0f ) + { + //cgi.TIKI_AppendFrameBoundsAndRadius( fps, cgi.anim->vmFrameInfo[ i ].index, cgi.anim->vmFrameInfo[ i ].time, &ent->radius, ent->bounds ); + cgi.TIKI_SetChannels( fps, cgi.anim->vmFrameInfo[ i ].index, cgi.anim->vmFrameInfo[ i ].time, cgi.anim->vmFrameInfo[ i ].weight, ent->bones ); + + w = cgi.anim->vmFrameInfo[ i ].weight; + + if( w == 0.0f ) + { + cgi.anim->vmFrameInfo[ i ].index = 0; + cgi.anim->vmFrameInfo[ i ].time = 0.0f; + cgi.anim->vmFrameInfo[ i ].weight = 0.0f; + + continue; + } + + frametime = cgi.Anim_Frametime( tiki, cgi.anim->vmFrameInfo[ i ].index ); + + cgi.anim->vmFrameInfo[ i ].time += cg.frametime / 2000.0f; + + if( cgi.anim->crossBlending ) + { + if( slot == i ) + { + cgi.anim->vmFrameInfo[ i ].weight = weight; + } + else + { + cgi.anim->vmFrameInfo[ i ].weight = ( 1.0f - weight ) * cgi.anim->vmFrameInfo[ i ].weight; + } + } + else + { + cgi.anim->vmFrameInfo[ i ].weight = 1.0f; + } + } + } + + cgi.TIKI_Animate( fps, ent->bones ); + + CG_CalcViewModelMovement(cg.fCurrentViewBobPhase,cg.fCurrentViewBobAmp,cg.predictedPlayerState.velocity,vMovement); + //CG_Printf("Movement: %f %f %f\n",vMovement[0],vMovement[1],vMovement[2]); + + // in MoHAA "eyes bone" is used here + bone = 0; + boneName = cgi.TIKI_GetBoneNameIndex("eyes bone"); + + for(i = 0; i < fps->numBones; i++) + { + if( fps->boneNames[ i ] == boneName ) + { + bone = ent->bones+i; + break; + } + } + + if( bone == 0 ) + { + CG_Printf("CG_OffsetFirstPersonView warning: Couldn't find 'eyes bone' for player\n"); + } +#if 1 + + bone->p[ 0 ] += 4.55f; // front + bone->p[ 1 ] += 0.15f; // side + bone->p[ 2 ] -= 1.25f; // up + + VectorSubtract( bone->p, vMovement, bone->p ); + + +#if 0 + CG_BoneLocal2World( bone, vec3_origin, cg.refdefViewAngles, v, a ); +#else + MatrixFromAngles( m, cg.refdefViewAngles[ 0 ], cg.refdefViewAngles[ 1 ], cg.refdefViewAngles[ 2 ] ); + MatrixTransformPoint( m, bone->p, v ); +#endif + VectorSubtract( cg.refdef.vieworg, v, ent->origin ); +#else + VectorCopy(cg.predictedPlayerState.origin,ent->origin); + ent->origin[2] += cg.predictedPlayerState.viewheight; + //ent->origin[2] += bone->p[2]; + // transform vMovement from players model space to worldspace + MatrixFromAngles(m,cg.refdefViewAngles[0],cg.refdefViewAngles[1],cg.refdefViewAngles[2]); + MatrixTransformPoint(m,vMovement,v); + // add it + VectorAdd(ent->origin,v,ent->origin); +#endif + + VectorMA( ent->origin, cg_gun_x->value, cg.refdef.viewaxis[ 0 ], ent->origin ); + VectorMA( ent->origin, cg_gun_y->value, cg.refdef.viewaxis[ 1 ], ent->origin ); + VectorMA( ent->origin, cg_gun_z->value, cg.refdef.viewaxis[ 2 ], ent->origin ); + + AnglesToAxis( angles, ent->axis ); + + cgi.R_AddRefEntityToScene( ent ); +} diff --git a/code/cgame/cg_weapons.c b/code/cgame/cg_weapons.c new file mode 100644 index 00000000..be6e8c33 --- /dev/null +++ b/code/cgame/cg_weapons.c @@ -0,0 +1,446 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// cg_weapons.c -- events and effects dealing with weapons +#include "cg_local.h" + +/* +========================== +CG_MachineGunEjectBrass +========================== +*/ +static void CG_MachineGunEjectBrass( centity_t *cent ) { + /*localEntity_t *le; + refEntity_t *re; + vec3_t velocity, xvelocity; + vec3_t offset, xoffset; + float waterScale = 1.0f; + vec3_t v[3]; + + if ( cg_brassTime.integer <= 0 ) { + return; + } + + le = CG_AllocLocalEntity(); + re = &le->refEntity; + + velocity[0] = 0; + velocity[1] = -50 + 40 * crandom(); + velocity[2] = 100 + 50 * crandom(); + + le->leType = LE_FRAGMENT; + le->startTime = cg.time; + le->endTime = le->startTime + cg_brassTime.integer + ( cg_brassTime.integer / 4 ) * random(); + + le->pos.trType = TR_GRAVITY; + le->pos.trTime = cg.time - (rand()&15); + + AnglesToAxis( cent->lerpAngles, v ); + + offset[0] = 8; + offset[1] = -4; + offset[2] = 24; + + xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0]; + xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1]; + xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2]; + VectorAdd( cent->lerpOrigin, xoffset, re->origin ); + + VectorCopy( re->origin, le->pos.trBase ); + + if ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) { + waterScale = 0.10f; + } + + xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0]; + xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1]; + xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2]; + VectorScale( xvelocity, waterScale, le->pos.trDelta ); + + AxisCopy( axisDefault, re->axis ); + re->hModel = cgs.media.machinegunBrassModel; + + le->bounceFactor = 0.4 * waterScale; + + le->angles.trType = TR_LINEAR; + le->angles.trTime = cg.time; + le->angles.trBase[0] = rand()&31; + le->angles.trBase[1] = rand()&31; + le->angles.trBase[2] = rand()&31; + le->angles.trDelta[0] = 2; + le->angles.trDelta[1] = 1; + le->angles.trDelta[2] = 0; + + le->leFlags = LEF_TUMBLE; + le->leBounceSoundType = LEBS_BRASS; + le->leMarkType = LEMT_NONE;*/ +} + +/* +========================== +CG_ShotgunEjectBrass +========================== +*/ +static void CG_ShotgunEjectBrass( centity_t *cent ) { + //localEntity_t *le; + //refEntity_t *re; + //vec3_t velocity, xvelocity; + //vec3_t offset, xoffset; + //vec3_t v[3]; + //int i; + + //if ( cg_brassTime.integer <= 0 ) { + // return; + //} + + //for ( i = 0; i < 2; i++ ) { + // float waterScale = 1.0f; + + // le = CG_AllocLocalEntity(); + // re = &le->refEntity; + + // velocity[0] = 60 + 60 * crandom(); + // if ( i == 0 ) { + // velocity[1] = 40 + 10 * crandom(); + // } else { + // velocity[1] = -40 + 10 * crandom(); + // } + // velocity[2] = 100 + 50 * crandom(); + + // le->leType = LE_FRAGMENT; + // le->startTime = cg.time; + // le->endTime = le->startTime + cg_brassTime.integer*3 + cg_brassTime.integer * random(); + + // le->pos.trType = TR_GRAVITY; + // le->pos.trTime = cg.time; + + // AnglesToAxis( cent->lerpAngles, v ); + + // offset[0] = 8; + // offset[1] = 0; + // offset[2] = 24; + + // xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0]; + // xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1]; + // xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2]; + // VectorAdd( cent->lerpOrigin, xoffset, re->origin ); + // VectorCopy( re->origin, le->pos.trBase ); + // if ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) { + // waterScale = 0.10f; + // } + + // xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0]; + // xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1]; + // xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2]; + // VectorScale( xvelocity, waterScale, le->pos.trDelta ); + + // AxisCopy( axisDefault, re->axis ); + // re->hModel = cgs.media.shotgunBrassModel; + // le->bounceFactor = 0.3f; + + // le->angles.trType = TR_LINEAR; + // le->angles.trTime = cg.time; + // le->angles.trBase[0] = rand()&31; + // le->angles.trBase[1] = rand()&31; + // le->angles.trBase[2] = rand()&31; + // le->angles.trDelta[0] = 1; + // le->angles.trDelta[1] = 0.5; + // le->angles.trDelta[2] = 0; + + // le->leFlags = LEF_TUMBLE; + // le->leBounceSoundType = LEBS_BRASS; + // le->leMarkType = LEMT_NONE; + //} +} + + +#ifdef MISSIONPACK +/* +========================== +CG_NailgunEjectBrass +========================== +*/ +static void CG_NailgunEjectBrass( centity_t *cent ) { + localEntity_t *smoke; + vec3_t origin; + vec3_t v[3]; + vec3_t offset; + vec3_t xoffset; + vec3_t up; + + AnglesToAxis( cent->lerpAngles, v ); + + offset[0] = 0; + offset[1] = -12; + offset[2] = 24; + + xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0]; + xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1]; + xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2]; + VectorAdd( cent->lerpOrigin, xoffset, origin ); + + VectorSet( up, 0, 0, 64 ); + + smoke = CG_SmokePuff( origin, up, 32, 1, 1, 1, 0.33f, 700, cg.time, 0, 0, cgs.media.smokePuffShader ); + // use the optimized local entity add + smoke->leType = LE_SCALE_FADE; +} +#endif + + +/* +======================================================================================== + +VIEW WEAPON + +======================================================================================== +*/ + + +/* +============== +CG_CalculateWeaponPosition +============== +*/ +static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) { + float scale; + int delta; + float fracsin; + + VectorCopy( cg.refdef.vieworg, origin ); + VectorCopy( cg.refdefViewAngles, angles ); + + // on odd legs, invert some angles + if ( cg.bobcycle & 1 ) { + scale = -cg.xyspeed; + } else { + scale = cg.xyspeed; + } + + // gun angles from bobbing + angles[ROLL] += scale * cg.bobfracsin * 0.005; + angles[YAW] += scale * cg.bobfracsin * 0.01; + angles[PITCH] += cg.xyspeed * cg.bobfracsin * 0.005; + + // drop the weapon when landing + delta = cg.time - cg.landTime; + if ( delta < LAND_DEFLECT_TIME ) { + origin[2] += cg.landChange*0.25 * delta / LAND_DEFLECT_TIME; + } else if ( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME ) { + origin[2] += cg.landChange*0.25 * + (LAND_DEFLECT_TIME + LAND_RETURN_TIME - delta) / LAND_RETURN_TIME; + } + +#if 0 + // drop the weapon when stair climbing + delta = cg.time - cg.stepTime; + if ( delta < STEP_TIME/2 ) { + origin[2] -= cg.stepChange*0.25 * delta / (STEP_TIME/2); + } else if ( delta < STEP_TIME ) { + origin[2] -= cg.stepChange*0.25 * (STEP_TIME - delta) / (STEP_TIME/2); + } +#endif + + // idle drift + scale = cg.xyspeed + 40; + fracsin = sin( cg.time * 0.001 ); + angles[ROLL] += scale * fracsin * 0.01; + angles[YAW] += scale * fracsin * 0.01; + angles[PITCH] += scale * fracsin * 0.01; +} + + +/* +============== +CG_AddViewWeapon + +Add the weapon, and flash for the player's view +============== +*/ +void CG_AddViewWeapon( playerState_t *ps ) { + //refEntity_t hand; + //centity_t *cent; + //clientInfo_t *ci; + //float fovOffset; + //vec3_t angles; + + ////if ( ps->stats[STAT_TEAM] == TEAM_SPECTATOR ) { + //// return; + ////} + + //if ( ps->pm_type == PM_INTERMISSION ) { + // return; + //} + + //// no gun if in third person view or a camera is active + ////if ( cg.renderingThirdPerson || cg.cameraMode) { + //if ( cg.renderingThirdPerson ) { + // return; + //} + + + ////// allow the gun to be completely removed + ////if ( !cg_drawGun.integer ) { + //// vec3_t origin; + + //// if ( cg.predictedPlayerState.eFlags & EF_FIRING ) { + //// // special hack for lightning gun... + //// VectorCopy( cg.refdef.vieworg, origin ); + //// VectorMA( origin, -8, cg.refdef.viewaxis[2], origin ); + //// CG_LightningBolt( &cg_entities[ps->clientNum], origin ); + //// } + //// return; + ////} + + //// don't draw if testing a gun model + //if ( cg.testGun ) { + // return; + //} + + //// drop gun lower at higher fov + //if ( cg_fov.integer > 90 ) { + // fovOffset = -0.2 * ( cg_fov.integer - 90 ); + //} else { + // fovOffset = 0; + //} + + //cent = &cg.predictedPlayerEntity; // &cg_entities[cg.snap->ps.clientNum]; + + + //memset (&hand, 0, sizeof(hand)); + + //// set up gun position + //CG_CalculateWeaponPosition( hand.origin, angles ); + + //VectorMA( hand.origin, cg_gun_x.value, cg.refdef.viewaxis[0], hand.origin ); + //VectorMA( hand.origin, cg_gun_y.value, cg.refdef.viewaxis[1], hand.origin ); + //VectorMA( hand.origin, (cg_gun_z.value+fovOffset), cg.refdef.viewaxis[2], hand.origin ); + + //AnglesToAxis( angles, hand.axis ); + + //// map torso animations to weapon animations + //if ( cg_gun_frame.integer ) { + // // development tool + // hand.frame = hand.oldframe = cg_gun_frame.integer; + // hand.backlerp = 0; + //} else { + // // get clientinfo for animation map + // ci = &cgs.clientinfo[ cent->currentState.clientNum ]; + // hand.frame = CG_MapTorsoToWeaponFrame( ci, cent->pe.torso.frame ); + // hand.oldframe = CG_MapTorsoToWeaponFrame( ci, cent->pe.torso.oldFrame ); + // hand.backlerp = cent->pe.torso.backlerp; + //} + + //hand.hModel = weapon->handsModel; + //hand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT; + + //// add everything onto the hand + //CG_AddPlayerWeapon( &hand, ps, &cg.predictedPlayerEntity, ps->stats[STAT_TEAM] ); +} + +/* +============================================================================== + +WEAPON SELECTION + +============================================================================== +*/ + +/* +=============== +CG_NextWeapon_f +=============== +*/ +void CG_NextWeapon_f( void ) { + cg.iWeaponCommand = 12; + cg.iWeaponCommandSend = 0; +} + +/* +=============== +CG_PrevWeapon_f +=============== +*/ +void CG_PrevWeapon_f( void ) { + cg.iWeaponCommand = 11; + cg.iWeaponCommandSend = 0; +} + +/* +=============== +CG_PrevWeapon_f +=============== +*/ +void CG_UseLastWeapon_f( void ) +{ + cg.iWeaponCommand = 13; + cg.iWeaponCommandSend = 0; +} + +/* +=============== +CG_HolsterWeapon_f +=============== +*/ +void CG_HolsterWeapon_f( void ) +{ + cg.iWeaponCommand = 14; + cg.iWeaponCommandSend = 0; +} + +/* +=============== +CG_DropWeapon_f +=============== +*/ +void CG_DropWeapon_f( void ) +{ + cg.iWeaponCommand = 15; + cg.iWeaponCommandSend = 0; +} + +/* +=============== +CG_ToggleItem_f +=============== +*/ +void CG_ToggleItem_f() +{ + cg.iWeaponCommand = 7; + cg.iWeaponCommandSend = 0; +} + +// su44: encode current weapon command for MoHAA +int CG_WeaponCommandButtonBits() { + int ret; + if( !cg.iWeaponCommand ) + return 0; + + ret = (cg.iWeaponCommand << 7) & 0x780; + + cg.iWeaponCommandSend++; + + if( cg.iWeaponCommandSend > 2 ) + cg.iWeaponCommand = 0; + + return ret; +} diff --git a/code/cgame_hook/animate.h b/code/cgame_hook/animate.h new file mode 100644 index 00000000..0910c09a --- /dev/null +++ b/code/cgame_hook/animate.h @@ -0,0 +1 @@ +#include "script/canimate.h" \ No newline at end of file diff --git a/code/cgame_hook/asm.h b/code/cgame_hook/asm.h new file mode 100644 index 00000000..ae2de62e --- /dev/null +++ b/code/cgame_hook/asm.h @@ -0,0 +1,183 @@ +#ifndef __ASM_H__ +#define __ASM_H__ + +#if defined ( CGAME_DLL ) + #define _CGAME_CODE() if(1) +#else + #define _CGAME_CODE() if(0) +#endif + +#if defined ( WIN32 ) + #define _LINUX_CODE() if(0) + #define WIN32_CODE() if(1) +#else + #define _CGAME_CODE() if(0) + #define _LINUX_CODE() if(1) + #define WIN32_CODE() if(0) +#endif + +#ifdef WIN32 +#define NAKED __declspec(naked) +#else +#define NAKED +#endif + +#ifdef __GNUC__ +#define JMPTO( addr ) asm("leave;mov %0, %%edx;jmp *%%edx;" : : "g"((DWORD)addr) ) +#define JMPTO_DIRECT( addr ) asm("movl %0, %%edx;jmp *%%edx;" : : "g"((DWORD)addr) ) +#define CALL( addr ) asm("movl %0, %%edx;call *%%edx;" : : "g"((DWORD)addr) ) //{ DWORD address_CALL = (DWORD) addr; __asm__ __volatile__("movl %0, %%edx;call *%%edx;" : : "g"(address_CALL) ); } +#define PUSH( addr ) asm("pushl %0;" : : "g"(*(DWORD *)&addr) ) //{ DWORD address_PUSH = (DWORD) addr; __asm__ __volatile__("push %0;" :: "g"(address_PUSH)); } +#define POP( addr ) asm("popl %0;" : : "g"(*(DWORD *)&addr) ) //{ DWORD address_PUSH = (DWORD) addr; __asm__ __volatile__("push %0;" :: "g"(address_PUSH)); } +#ifndef WIN32 +#define SET_CLASS( addr ) asm("movl %0, %%eax; movl %%eax, (%%esp);" : : "g"((DWORD)addr) ) // asm("movl %0, %%ecx;" : : "g"(addr) ) //{ DWORD address_SET_CLASS = (DWORD) addr; __asm__ __volatile__("movl %0, %%ecx;" : : "g"(address_SET_CLASS) ); } +#define GET_CLASS( var ) asm("movl %%esp, %0;" : "=r"(var) ) +#else +#define SET_CLASS( addr ) asm("movl %0, %%ecx;" : : "g"((DWORD)addr) ) // asm("movl %0, %%ecx;" : : "g"(addr) ) //{ DWORD address_SET_CLASS = (DWORD) addr; __asm__ __volatile__("movl %0, %%ecx;" : : "g"(address_SET_CLASS) ); } +#define GET_CLASS( var ) asm("movl %%ecx, %0;" : "=r"(var) ) +#endif + +#define MAKE_JUMPER( declaration, gamex86_address, fgameded_symbol, cgamex86_address ) declaration {} //asm( ".globl " #fgameded_symbol "\n\t" #fgameded_symbol ":\n\tmovl _" #fgameded_symbol "_, %edx;jmp *%edx;" ) +#else +#define JMPTO( addr ) { _asm leave _asm mov edx, addr _asm jmp edx } +#define JMPTO_DIRECT( addr ) { _asm mov edx, addr _asm jmp edx } +#define CALL( addr ) { _asm mov edx, addr _asm call edx } +#define PUSH( addr ) { _asm push addr } +#define POP( addr ) { _asm pop addr } +#define SET_CLASS( addr ) { _asm mov ecx, addr } +#define GET_CLASS( var ) { _asm mov var, ecx } + +#define MAKE_JUMPER( declaration, gamex86_address, fgameded_symbol, cgamex86_address ) \ + __declspec(naked) declaration { JMPTO_DIRECT_WIN32( gamex86_address) JMPTO_DIRECT_CGAME( cgamex86_address ) } +#endif + +#if defined ( _UBER_SDK ) + #define MP_NUMBER( gamex86, fgameded, cgamex86 ) 0 + #define MP_STRING( gamex86, fgameded, cgamex86 ) 0 +#endif + +#if defined ( CGAME_DLL ) + #define MP_NUMBER( gamex86, fgameded, cgamex86 ) cgamex86 + #define MP_STRING( gamex86, fgameded, cgamex86 ) cgamex86 + #define JMPTO_CGAME(addr) JMPTO(addr) + #define JMPTO_DIRECT_CGAME(addr) JMPTO_DIRECT(addr) + +#if defined( SPEARHEAD ) || defined( SH ) + #define JMPTO_SH_CGAME(addr) JMPTO(addr) + #define JMPTO_SH_DIRECT_GAME(addr) JMPTO_DIRECT(addr) +#else + #define JMPTO_SH_CGAME(addr) + #define JMPTO_SH_DIRECT_GAME(addr) +#endif + +#if defined( BREAKTHROUGH ) || defined( BT ) + #define JMPTO_BT_CGAME(addr) JMPTO(addr) + #define JMPTO_BT_DIRECT_GAME(addr) JMPTO_DIRECT(addr) +#else + #define JMPTO_BT_CGAME(addr) + #define JMPTO_BT_DIRECT_GAME(addr) +#endif + + #define CALL_CGAME(addr) CALL(addr) +#else + #define JMPTO_CGAME(addr) + #define JMPTO_DIRECT_CGAME(addr) + #define CALL_CGAME(addr) CALL(addr) + #define JMPTO_SH_CGAME(addr) + #define JMPTO_SH_DIRECT_GAME(addr) + #define JMPTO_BT_CGAME(addr) + #define JMPTO_BT_DIRECT_GAME(addr) +#endif + +#if !defined( SPEARHEAD ) && !defined( SH ) + #define JMPTO_SH_WIN32(addr) + #define JMPTO_SH_DIRECT_WIN32(addr) + #define JMPTO_SH_LINUX(addr) + #define JMPTO_SH_DIRECT_LINUX(addr) +#endif + +#if !defined( BREAKTHROUGH ) && !defined( BT ) + #define JMPTO_BT_WIN32(addr) + #define JMPTO_BT_DIRECT_WIN32(addr) + #define JMPTO_BT_LINUX(addr) + #define JMPTO_BT_DIRECT_LINUX(addr) +#endif + +#if defined ( WIN32 ) + + #if defined( GAME_DLL ) + #define MP_NUMBER( gamex86, fgameded, cgamex86 ) gamex86 + #define MP_STRING( gamex86, fgameded, cgamex86 ) gamex86 + #define CALL_WIN32(addr) CALL(addr) + #define JMPTO_WIN32(addr) JMPTO(addr) + #define JMPTO_DIRECT_WIN32(addr) JMPTO_DIRECT(addr) + + #if defined( SPEARHEAD ) || defined( SH ) + #define JMPTO_SH_WIN32(addr) JMPTO(addr) + #define JMPTO_SH_DIRECT_WIN32(addr) JMPTO_DIRECT(addr) + #endif + + #if defined( BREAKTHROUGH ) || defined( BT ) + #define JMPTO_BT_WIN32(addr) JMPTO(addr) + #define JMPTO_BT_DIRECT_WIN32(addr) JMPTO_DIRECT(addr) + #endif + #else + #define CALL_WIN32(addr) + #define JMPTO_WIN32(addr) + #define JMPTO_DIRECT_WIN32(addr) + #define JMPTO_SH_WIN32(addr) + #define JMPTO_SH_DIRECT_WIN32(addr) + #define JMPTO_BT_WIN32(addr) + #define JMPTO_BT_DIRECT_WIN32(addr) + #endif + + #define JMPTO_LINUX(addr) + #define JMPTO_DIRECT_LINUX(addr) + #define JMPTO_SH_LINUX(addr) + #define JMPTO_SH_DIRECT_LINUX(addr) + #define JMPTO_BT_LINUX(addr) + #define JMPTO_BT_DIRECT_LINUX(addr) + #define CALL_LINUX(addr) + #define SET_CLASS_LINUX( addr ) + #define SET_CLASS_WIN32( addr ) SET_CLASS( addr ) +#else + #define MP_NUMBER( gamex86, fgameded, cgamex86 ) fgameded + #define MP_STRING( gamex86, fgameded, cgamex86 ) fgameded + #define JMPTO_CLIENT(addr) + #define JMPTO_LINUX(addr) JMPTO(addr) + #define JMPTO_WIN32(addr) + #define JMPTO_DIRECT_CLIENT(addr) + #define JMPTO_DIRECT_LINUX(addr) JMPTO_DIRECT(addr) + #define JMPTO_DIRECT_WIN32(addr) + + #if defined( SPEARHEAD ) || defined( SH ) + #define JMPTO_SH_LINUX(addr) JMPTO(addr) + #define JMPTO_SH_DIRECT_LINUX(addr) JMPTO_DIRECT(addr) + #endif + + #if defined( BREAKTHROUGH ) || defined( BT ) + #define JMPTO_BT_LINUX(addr) JMPTO(addr) + #define JMPTO_BT_DIRECT_LINUX(addr) JMPTO_DIRECT(addr) + #endif + + #define CALL_LINUX(addr) CALL(addr) + #define CALL_WIN32(addr) + #define SET_CLASS_LINUX( addr ) SET_CLASS( addr ) + #define SET_CLASS_WIN32( addr ) +#endif + +#define MP_CODE( gamex86, fgameded, cgamex86 ) MP_NUMBER( gamex86, fgameded, cgamex86 ) + +#ifndef WIN32 + +extern void* dl_fgame_sym( const char *symbol ); + +#define SYMBOL_DECLARE( symbol ) DWORD _##symbol##_ = (DWORD)dl_fgame_sym( #symbol ) //void* symbol = dlsym( hmod, #symbol ) +#define SYMBOL_GET( symbol ) _##symbol##_ +#else +#define SYMBOL_DECLARE( symbol ) +#define SYMBOL_GET( symbol ) 0 +#endif + +#define SYM( symbol ) SYMBOL_GET( symbol ) + +#endif /* __ASM_H__ */ diff --git a/code/cgame_hook/cgame/cg_hook.cpp b/code/cgame_hook/cgame/cg_hook.cpp new file mode 100644 index 00000000..8580778b --- /dev/null +++ b/code/cgame_hook/cgame/cg_hook.cpp @@ -0,0 +1,294 @@ +#include "glb_local.h" +#include "cg_servercmds.h" +#include "cg_viewmodelanim.h" +#include "listener.h" +#include + +void CG_HookCGM() +{ + BYTE jmp_code01[] = { + 0xBA, + 0x99,0x99,0x99,0x99,0xFF,0xE2 + }; + + /*BYTE jmp_code01[] = { + 0xE9, + 0x4E,0x04,0x00,0x00 + }; + + BYTE jmp_code02[] = { + 0xE9, + 0x44,0x05,0x00,0x00 + }; + + BYTE jmp_code03[] = { + 0xE9, + 0xF2,0x03,0x00,0x00 + }; + + BYTE jmp_code04[] = { + 0xE9, + 0x71,0x01,0x00,0x00 + }; + + BYTE jmp_code05[] = { + 0xE9, + 0x33,0x0F,0x00,0x00 + }; + + BYTE jmp_code06[] = { + 0xE9, + 0x2A,0x05,0x00,0x00 + }; + + BYTE jmp_code07[] = { + 0xE9, + 0x26,0x00,0x00,0x00 + }; + + BYTE jmp_code08[] = { + 0xE9, + 0x21,0x01,0x00,0x00 + };*/ + + //test + + *( DWORD * )( ( BYTE * )jmp_code01 + 1 ) = 0x30031346; + + WriteMemory( 0x30030E5D, jmp_code01, sizeof( jmp_code01 ) ); + WriteMemory( 0x30030EFC, jmp_code01, sizeof( jmp_code01 ) ); + WriteMemory( 0x30030F4F, jmp_code01, sizeof( jmp_code01 ) ); + WriteMemory( 0x30030FD0, jmp_code01, sizeof( jmp_code01 ) ); + WriteMemory( 0x30031002, jmp_code01, sizeof( jmp_code01 ) ); + WriteMemory( 0x3003109C, jmp_code01, sizeof( jmp_code01 ) ); + WriteMemory( 0x300310DB, jmp_code01, sizeof( jmp_code01 ) ); + WriteMemory( 0x30031135, jmp_code01, sizeof( jmp_code01 ) ); +} + +VOID CG_HookClientGame() +{ + int i; + + /* thunk_code1 + * mov edx, 99999999h + * mov eax, [esp+24h+4] + * mov ebp, ecx + * + * push eax + * call edx + */ + /*BYTE thunk_code[250] = { 0xBA, + 0x99,0x99,0x99,0x99,0xFF,0xD2,0x89,0x45, + 0xB0 + };*/ + + BYTE thunk_code[] = { + 0xBA, + 0x99,0x99,0x99,0x99,0xFF,0xE2, + }; + + /* thunk_code2 + * mov edx, 99999999h + * call edx + */ + BYTE thunk_code2[] = { 0xBA, + 0x99,0x99,0x99,0x99,0xFF,0xD2,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90 + }; + + /* thunk_code3 + * mov ecx, [99999999h+eax*4] + * push ecx + */ + BYTE thunk_code3[] = { 0x99, + 0x99,0x99,0x99 + }; + + /* thunk_code4 + * mov edx, 99999999h + * push eax + * call edx + */ + BYTE thunk_code4[] = { 0xBA, + 0x99,0x99,0x99,0x99,0x50,0xFF,0xD2,0xC9, + 0xC3 + }; + + /* thunk_code5 + * mov edx, 99999999h + * call edx + */ + BYTE thunk_code5[] = { 0xBA, + 0x99,0x99,0x99,0x99,0xFF,0xD2,0x90 + }; + + /* thunk_code6 + * mov edx, 99999999h + * call edx + * leave + * retn + */ + /*BYTE thunk_code6[] = { 0xBA, + 0x99,0x99,0x99,0x99,0xFF,0xD2,0x5D,0xC3 + };*/ + + BYTE thunk_code6[] = { + 0xBA, + 0x99,0x99,0x99,0x99,0xFF,0xE2, + }; + + /* thunk_code7 + * push 303EBF2Ch ; offset unk_303EBF2C + * push 303EBFD0h ; offset dword_303EBFD0 + * mov edx, 3005C83Ch + * call edx + * add esp, 8 + * + * push 0 + * lea edx, [ebp-198h] ; [ebp+Dst] + * push edx + * mov eax, 300473F0h + * call eax ; CG_OffsetFirstPersonView + * add esp, 8 + */ + + /*BYTE thunk_code7[65] = { 0x68, + 0x2C,0xBF,0x3E,0x30,0x68,0xD0,0xBF,0x3E, + 0x30,0xBA,0x3C,0xC8,0x05,0x30,0xFF,0xD2, + 0x81,0xC4,0x08,0x00,0x00,0x00,0x68,0x00, + 0x00,0x00,0x00,0x8D,0x95,0x68,0xFE,0xFF, + 0xFF,0x52,0xB8,0xF0,0x73,0x04,0x30,0xFF, + 0xD0,0x81,0xC4,0x08,0x00,0x00,0x00 + };*/ + BYTE thunk_code7[6]; + + /* thunk_code8 + * cmp [ebp+var_28], 2 + */ + BYTE thunk_code8[4] = { 0x83, + 0x7D,0xD8,0x02 + }; + + BYTE thunk_code9[4]; + BYTE thunk_code10[15]; + BYTE thunk_code11[60]; + + BYTE thunk_code12[] = { + 0xBA, + 0x99,0x99,0x99,0x99,0xFF,0xB5,0xC4,0xFC, + 0xFF,0xFF,0xFF,0xD2 + }; + + /*BYTE thunk_code13[] = { + 0xBA, + 0x99,0x99,0x99,0x99,0xFF,0xB5,0x70,0xFE, + 0xFF,0xFF,0xFF,0xD2,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90 + };*/ + + BYTE thunk_code13[] = { + 0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, + 0x90,0x90,0x90,0x90,0x90 + }; + + BYTE thunk_code14[] = { + 0xBA, + 0x99,0x99,0x99,0x99,0xFF,0xE2 + }; + + BYTE thunk_code15[] = { + 0x31, + 0xC0, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90 + }; + + BYTE thunk_code16[] = { + 0x90, + 0x90 + }; + + BYTE thunk_code17[] = { + 0xEB, + 0x2B + }; + + //for(i=10;i<250;i++) + // thunk_code[i] = 0x90; // NOP instructions + + /*for(i=13;i +#include +#include + +//Stuff for menu credit to okidoki +uidef_t *uid; +qkey_t *keys; +qboolean *inGuiMouse = ( qboolean * )0x12F6FF8; + +// ***fonts*** +fontHeader_t *facfont20 = NULL; +fontHeader_t *courier16 = NULL; +fontHeader_t *courier18 = NULL; +fontHeader_t *courier20 = NULL; +fontHeader_t *handle16 = NULL; +fontHeader_t *handle18 = NULL; +fontHeader_t *marlett = NULL; +fontHeader_t *verdana12 = NULL; +fontHeader_t *verdana14 = NULL; + +/*Cvars*/ +cvar_t *stats; +cvar_t *menu; + +//Stat Variables +int headshots; +int killingspree; +int unstoppable; +int rampage; +int godlike; +int kills; +int bashes; +int dominating; +int double_kill_time; +int gotdouble; + +int doublekill; +int multikill; +int ultrakill; +int monsterkill; + +float hintAlpha = 1.0f; +int hintAlphaTime = 0; +qboolean hintClear = false; +char hintString[ MAX_STRING_TOKENS ]; + +// colors +vec4_t colorDkRed = {0.5, 0, 0, 1}; +vec4_t colorDkGreen = {0, 0.5, 0, 1}; +vec4_t colorDkBlue = {0, 0, 0.5, 1}; +vec4_t colorLtRed = {1, 0.5, 0.5, 1}; +vec4_t colorLtGreen = {0.5, 1, 0.5, 1}; +vec4_t colorLtBlue = {0.5, 0.5, 1, 1}; +vec4_t colorAlBlue = {0, 0, 1, 0.25}; +vec4_t colorAlRed = {1, 0, 0, 0.25}; +vec4_t colorLtzzTEST = {1, 1, 1, 0.25}; +vec4_t alphaLight = { 0, 0, 0, 0.25 }; +vec4_t alphaMid = { 0, 0, 0, 0.5 }; +vec4_t alphaDark = { 0, 0, 0, 0.75 }; +vec4_t colorTransRed = { 1, 0, 0, 0.5 }; +vec4_t colorTransBlue = { 0, 0, 1, 0.5 }; +vec4_t colorTransWhite = { 1, 1, 1, 0.5 }; +vec4_t colorDarkRed = { 0.34117647058823529411764705882353f, 0.035294117647058823529411764705882f, 0.035294117647058823529411764705882f, 1 }; + +hdExtend_t *huddrawExtends; + +void CG_DrawMenu() +{ + time_t rawtime; + struct tm * timeinfo = (tm * )malloc(sizeof(tm)); + time( &rawtime ); + localtime_s( timeinfo, &rawtime); + + char buff[64]; + /*Draw the menu*/ + if(menu->integer) + { + //Enable the mouse + *inGuiMouse = uid->uiHasMouse = true; + + //Get Cursor coordinates + uid->mouseX; + uid->mouseY; + + /*Widgets*/ + //We want to make a few selections(widgets) +//-------------First Widget--------------------- + cgi.R_SetColor( colorWhite ); //outer outline will be white + cgi.R_DrawBox(10, 160, 101, 16); + cgi.R_SetColor( colorDarkRed ); //inner red box + cgi.R_DrawBox(11, 161, 99, 14); + cgi.R_SetColor( colorWhite ); //font color + sprintf_s( buff, "First Widget");//name of widget + cgi.R_DrawString( verdana12, buff, 12, 161, -1, 0 ); + +//-------------Second Widget--------------------- + cgi.R_SetColor( colorWhite ); //outer outline will be white + cgi.R_DrawBox(10, 180, 101, 16); + cgi.R_SetColor( colorDarkRed ); //inner red box + cgi.R_DrawBox(11, 181, 99, 14); + cgi.R_SetColor( colorWhite ); //font color + sprintf_s( buff, "Second Widget");//name of widget + cgi.R_DrawString( verdana12, buff, 12, 181, -1, 0 ); + +//-------------Third Widget--------------------- + cgi.R_SetColor( colorWhite ); //outer outline will be white + cgi.R_DrawBox(10, 200, 101, 16); + cgi.R_SetColor( colorDarkRed ); //inner red box + cgi.R_DrawBox(11, 201, 99, 14); + cgi.R_SetColor( colorWhite ); //font color + sprintf_s( buff, "Third Widget");//name of widget + cgi.R_DrawString( verdana12, buff, 12, 201, -1, 0 ); + +//-------------Fourth Widget--------------------- + cgi.R_SetColor( colorWhite ); //outer outline will be white + cgi.R_DrawBox(10, 220, 101, 16); + cgi.R_SetColor( colorDarkRed ); //inner red box + cgi.R_DrawBox(11, 221, 99, 14); + cgi.R_SetColor( colorWhite ); //font color + sprintf_s( buff, "Fourth Widget");//name of widget + cgi.R_DrawString( verdana12, buff, 12, 221, -1, 0 ); + + //Check if it was clicked + if(keys[181].down) + { + if((uid->mouseX >= 11)&&(uid->mouseX <= 110)&&(uid->mouseY >= 161)&&(uid->mouseY <= 175)) + { + cgi.R_SetColor( colorWhite ); //font color + sprintf_s( buff, (const char *)cg->snap->ps.stats);//name of widget + cgi.R_DrawString( verdana12, buff, 12, 300, -1, 0 ); + + cgi.Printf("I clicked the first widget \n"); + } + + if((uid->mouseX >= 11)&&(uid->mouseX <= 110)&&(uid->mouseY >= 181)&&(uid->mouseY <= 195)) + cgi.Printf("I clicked the second widget \n"); + + if((uid->mouseX >= 11)&&(uid->mouseX <= 110)&&(uid->mouseY >= 201)&&(uid->mouseY <= 215)) + cgi.Printf("I clicked the third widget \n"); + + if((uid->mouseX >= 11)&&(uid->mouseX <= 110)&&(uid->mouseY >= 211)&&(uid->mouseY <= 235)) + cgi.Printf("I clicked the fourth widget \n"); + } +//-------------Time--------------------- + if(timeinfo->tm_hour == 00) + { + cgi.R_SetColor( colorWhite ); + sprintf_s( buff, "%02i:%02i:%02i AM", timeinfo->tm_hour + 12, timeinfo->tm_min, timeinfo->tm_sec); + cgi.R_DrawString( verdana12, buff, 12, 241, 10, 0 ); + } + else if(timeinfo->tm_hour > 13) + { + cgi.R_SetColor( colorWhite ); + sprintf_s( buff, "%i:%02i:%02i PM", ((timeinfo->tm_hour)%12), timeinfo->tm_min, timeinfo->tm_sec); + cgi.R_DrawString( verdana12, buff, 12, 241, 10, 0 ); + } + else if(timeinfo->tm_hour > 00 && timeinfo->tm_hour < 13) + { + cgi.R_SetColor( colorWhite ); + sprintf_s( buff, "%i:%02i:%02i AM", ((timeinfo->tm_hour)%12), timeinfo->tm_min, timeinfo->tm_sec); + cgi.R_DrawString( verdana12, buff, 12, 241, 10, 0 ); + } + + cgi.R_SetColor( NULL ); + } +} + +qboolean CG_WorldToScreen(vec3_t pt, int *x, int *y, qboolean bOptionalSeen, int shader_width, int shader_height) +{ + float xzi, yzi; + vec3_t local, transformed; + vec3_t vfwd, vright, vup; + qboolean bNotShown = false; + + AngleVectors(cg->refdefViewAngles, vfwd, vright, vup); + + VectorSubtract(pt, cg->refdef.viewOrg, local); + + transformed[0] = DotProduct( local, vright ); + transformed[1] = DotProduct( local, vup ); + transformed[2] = DotProduct( local, vfwd ); + + if(transformed[2] < 0.01f) + { + if(!bOptionalSeen) + return false; + + bNotShown = true; + + //transformed[0] = -transformed[0]; + //transformed[1] = -transformed[1]; + //return qfalse; + } + + int centerX = (cgs->glConfig.vidWidth / 2); + int centerY = (cgs->glConfig.vidHeight / 2); + xzi = centerX / transformed[2] * ( 90.0f / cg->refdef.fovX ); + yzi = centerY / transformed[2] * ( 90.0f / cg->refdef.fovY ); + *x = centerX + (int)( xzi * transformed[0] ); + *y = centerY - (int)( yzi * transformed[1] ); + + if(!bOptionalSeen) + return true; + + int limitX = cgs->glConfig.vidWidth - shader_width; + int limitY = cgs->glConfig.vidHeight - shader_height; + + if(bNotShown) + { + if(*x < limitX) + *x = limitX; + else if(*x > 0) + *x = 0; + else if(*y < limitY) + *y = limitY; + else if(*y > 0) + *y = 0; + } + + if(*x > limitX) + *x = limitX; + else if(*x < 0) + *x = 0; + + if(*y > limitY) + *y = limitY; + else if(*y < 0) + *y = 0; + + return true; +} + +#if 0 +void CG_Draw3DIcon(hdExtend_t * hdex, hdElement_t * hde) +{ + int x, y; + centity_t * ce; + int width, height; + + /* Reset if huddraw_rect has been called */ + if(hdex->h3d.x != hde->x || hdex->h3d.y != hde->y) + { + memset(&hdex->h3d, 0, sizeof(hdex->h3d)); + return; + } + + if(hdex->h3d.ent_num != -1) + ce = CG_GetEntity(hdex->h3d.ent_num); + else + ce = NULL; + + if(ce != NULL) + VectorAdd(hdex->h3d.vector, ce->currentState.origin, hdex->h3d.currentOrg); + //else + // VectorCopy(hdex->h3d.vector, hdex->h3d.currentOrg); + + if(hde->shader) + { + width = cgi.R_GetShaderWidth(hde->shader); + height = cgi.R_GetShaderWidth(hde->shader); + } + else + { + width = hde->width; + height = hde->height; + } + + if(!CG_WorldToScreen(hdex->h3d.currentOrg, &x, &y, hdex->h3d.bAlwaysShow, width, height)) + return; + + hde->horizontalAlign = 0; + hde->verticalAlign = 0; + hde->virtualScreen = 0; + + hde->x = x; + hde->y = y; + + hdex->h3d.x = x; + hdex->h3d.y = y; +} + +void CG_DrawTimers(hdExtend_t * hdex, hdElement_t * hde) +{ + int minutes; + float seconds; + char *string; + + if( !hdex->timer.bEnabled || hdex->timer.current <= 0.0f ) { + return; + } + + hdex->timer.current -= 0.001000000047497451f * cg_frametime; + + if(hdex->timer.current <= 0.0f) + { + if(hdex->timer.fade_out_time >= 0.0f) + { + hde->color[3] = 0.0f; + hdex->timer.alpha = 0.0f; + } + + hdex->timer.current = 0.0f; + } + + if(hdex->timer.current >= 60.00000000f) + { + seconds = (float)((int)hdex->timer.current % 60); + minutes = (int)(hdex->timer.current / 60.0f); + } + else + { + if(hdex->timer.current >= 30.0f) + seconds = (float)(int)hdex->timer.current; + else + seconds = hdex->timer.current; + minutes = 0; + } + + if(hdex->timer.current >= 30.0f) + string = "%d:%02.0f"; + else + { + if(hdex->timer.current >= 10.0f) + string = "%d:%02.1f"; + else + string = "%d:0%.1f"; + } + + + if(hdex->timer.current * 1000.0f < hdex->timer.fade_out_time) + { + hde->color[3] -= (2.0f-hdex->timer.alpha)/hdex->timer.fade_out_time * cg_frametime; + + if(hde->color[3] < 0.0f) + hde->color[3] = 0.0f; + } + else + hdex->timer.alpha = hde->color[3]; + + if(!hde->shader) + { + if(_strcmpi(hde->string, hdex->timer.string) == 0) + { + sprintf(hde->string, string, minutes, seconds); + strcpy(hdex->timer.string, hde->string); + } + } + else + memset(hde->string, 0, MAX_STRINGCHARS); +} + +void CG_DrawExtendedHud() +{ + int i; + hdExtend_t *hdex; + hdElement_t *hde; + + if( hintString[0] != '\0' ) + { + int key1 = 0, key2 = 0; + const char *keyname1, *keyname2; + char *hintStringFormatted; + char *hintStringKey; + char *hintStringPart; + int i, old_c; + + if( !facfont20 ) { + return; + } + + // Fade out the string over time + if( hintClear ) + { + if( hintAlpha > 0.0f ) + { + float ratio = hintAlphaTime/100.0f; + hintAlphaTime += cg->frametime; + + if( ratio >= 1.0f ) { + hintAlpha = 0.0f; + } else { + hintAlpha = 1.0f + ( 0.0f - 1.0f ) * ratio; + } + } + else + { + hintAlpha = 0.0f; + hintAlphaTime = 0; + hintClear = false; + memset( hintString, '\0', strlen( hintString ) ); + } + } else { + hintAlpha = 1.0f; + } + + cgi.Key_GetKeysForCommand( "+use", &key1, &key2 ); + + keyname1 = uppercase( cgi.LV_ConvertString ( cgi.Key_KeynumToBindString( key1 ) ) ); + keyname2 = uppercase( cgi.LV_ConvertString ( cgi.Key_KeynumToBindString( key2 ) ) ); + + // Format the hint string + hintStringFormatted = replace( hintString, "&&1", "\t&&1" ); + hintStringFormatted = replace( hintStringFormatted, "&&1", keyname1 ); + + char *hintStringLocalized = cgi.LV_ConvertString( hintStringFormatted ); + + int w = re.GetFontStringWidth( facfont20, hintStringLocalized ) - 10; + + for( i = 0; i < strlen( hintStringLocalized ); i++ ) + { + if( hintStringLocalized[ i ] == '\t' ) + { + hintStringLocalized[ i ] = '\0'; + break; + } + } + + int x = ( cgs->glConfig.vidWidth - w ) / 2; + int y = cgs->glConfig.vidHeight / 1.75; + + vec4_t rgba = { 1, 1, 1, hintAlpha }; + + cgi.R_SetColor( rgba ); + cgi.R_DrawString( facfont20, hintStringLocalized, x, y, MAX_STRINGTOKENS, false ); + + x += re.GetFontStringWidth( facfont20, hintStringLocalized ); + + hintStringKey = hintStringLocalized + i + 1; + + // yellow + rgba[0] = 1.0f; + rgba[1] = 1.0f; + rgba[2] = 0.0f; + rgba[3] = hintAlpha; + + int len = strlen( keyname1 ); + + old_c = hintStringKey[ len ]; + hintStringKey[ len ] = '\0'; + + cgi.R_SetColor( rgba ); + cgi.R_DrawString( facfont20, hintStringKey, x, y, MAX_STRINGTOKENS, false ); + + hintStringKey[ len ] = old_c; + + x += re.GetFontStringWidth( facfont20, keyname1 ); + + hintStringPart = hintStringKey + len; + + rgba[0] = 1.0f; + rgba[1] = 1.0f; + rgba[2] = 1.0f; + rgba[3] = hintAlpha; + + cgi.R_SetColor( rgba ); + cgi.R_DrawString( facfont20, hintStringPart, x, y, MAX_STRINGTOKENS, false ); + } + + for( i = 0; i < 256; i++ ) + { + hde = cgi.hudDrawElements + i; + hdex = huddrawExtends + i; + + if( hdex->h3d.bEnabled ) { + CG_Draw3DIcon( hdex, hde ); + } + + if( hdex->timer.bEnabled ) { + CG_DrawTimers( hdex, hde ); + } + } +} +#endif + +void CG_DrawHintString() +{ + if( hintString[0] != '\0' ) + { + int key1 = 0, key2 = 0; + str keyname1, keyname2; + char *hintStringFormatted; + char *hintStringKey; + char *hintStringPart; + int i, old_c; + + if( !facfont20 ) { + return; + } + + // Fade out the string over time + if( hintClear ) + { + if( hintAlpha > 0.0f ) + { + float ratio = hintAlphaTime/100.0f; + hintAlphaTime += cg->frametime; + + if( ratio >= 1.0f ) { + hintAlpha = 0.0f; + } else { + hintAlpha = 1.0f + ( 0.0f - 1.0f ) * ratio; + } + } + else + { + hintAlpha = 0.0f; + hintAlphaTime = 0; + hintClear = false; + memset( hintString, '\0', strlen( hintString ) ); + } + } else { + hintAlpha = 1.0f; + } + + cgi.Key_GetKeysForCommand( "+use", &key1, &key2 ); + + keyname1 = cgi.LV_ConvertString( cgi.Key_KeynumToBindString( key1 ) ); + keyname2 = cgi.LV_ConvertString( cgi.Key_KeynumToBindString( key2 ) ); + + keyname1.toupper(); + keyname2.toupper(); + + // Format the hint string + hintStringFormatted = replace( hintString, "&&1", "\t&&1" ); + hintStringFormatted = replace( hintStringFormatted, "&&1", keyname1 ); + + char *hintStringLocalized = cgi.LV_ConvertString( hintStringFormatted ); + + float w = re.GetFontStringWidth( facfont20, hintStringLocalized ) - 10; + + for( i = 0; i < strlen( hintStringLocalized ); i++ ) + { + if( hintStringLocalized[ i ] == '\t' ) + { + hintStringLocalized[ i ] = '\0'; + break; + } + } + + float x = ( cgs->glConfig.vidWidth - w ) / 2; + float y = cgs->glConfig.vidHeight / 1.75; + + vec4_t rgba = { 1, 1, 1, hintAlpha }; + + cgi.R_SetColor( rgba ); + cgi.R_DrawString( facfont20, hintStringLocalized, x, y, MAX_STRING_TOKENS, false ); + + x += re.GetFontStringWidth( facfont20, hintStringLocalized ); + + hintStringKey = hintStringLocalized + i + 1; + + // yellow + rgba[0] = 1.0f; + rgba[1] = 1.0f; + rgba[2] = 0.0f; + rgba[3] = hintAlpha; + + int len = strlen( keyname1 ); + + old_c = hintStringKey[ len ]; + hintStringKey[ len ] = '\0'; + + cgi.R_SetColor( rgba ); + cgi.R_DrawString( facfont20, hintStringKey, x, y, MAX_STRING_TOKENS, false ); + + hintStringKey[ len ] = old_c; + + x += re.GetFontStringWidth( facfont20, keyname1 ); + + hintStringPart = hintStringKey + len; + + rgba[0] = 1.0f; + rgba[1] = 1.0f; + rgba[2] = 1.0f; + rgba[3] = hintAlpha; + + cgi.R_SetColor( rgba ); + cgi.R_DrawString( facfont20, hintStringPart, x, y, MAX_STRING_TOKENS, false ); + } +} + +void CG_ShowHint( const char * hint ) +{ + if( hint == NULL || strlen( hint ) <= 0 || _stricmp( hint, "" ) == 0 || hint[0] == '\0' ) + { + hintAlphaTime = 0; + hintClear = true; + return; + } + + hintClear = false; + strcpy( hintString, hint ); +} + +void CG_Draw2D(void) +{ +// CG_DrawStats(); +// CG_DrawMenu(); +// CG_DrawExtendedHud(); + + if( facfont20 == NULL ) { + facfont20 = cgi.R_LoadFont( "facfont-20" ); + } + + if( courier16 == NULL ) { + courier16 = cgi.R_LoadFont( "courier-16" ); + } + + if( courier18 == NULL ) { + courier18 = cgi.R_LoadFont( "courier-18" ); + } + + if( courier20 == NULL ) { + courier20 = cgi.R_LoadFont( "courier-20" ); + } + + if( handle16 == NULL ) { + handle16 = cgi.R_LoadFont( "handle-16" ); + } + + if( handle18 == NULL ) { + handle18 = cgi.R_LoadFont( "handle-18" ); + } + + if( marlett == NULL ) { + marlett = cgi.R_LoadFont( "marlett" ); + } + + if( verdana12 == NULL ) { + verdana12 = cgi.R_LoadFont( "verdana-12" ); + } + + if( verdana14 == NULL ) { + verdana14 = cgi.R_LoadFont( "verdana-14" ); + } + + CG_DrawHintString(); + + // huddraw elements have the lowest priority + Hud::ProcessThink(); + + vec4_t col = { 1.f, 1.f, 1.f, 1.f }; + cgi.R_SetColor( col ); + + cge.CG_Draw2D(); +} diff --git a/code/cgame_hook/cgame/cg_hud.h b/code/cgame_hook/cgame/cg_hud.h new file mode 100644 index 00000000..1cc2b160 --- /dev/null +++ b/code/cgame_hook/cgame/cg_hud.h @@ -0,0 +1,65 @@ +#ifndef __CG_HUD_H__ +#define __CG_HUD_H__ + +#include "hud.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern cvar_t *stats; +extern cvar_t *menu; + +extern uidef_t *uid; +extern qkey_t *keys; + +extern fontHeader_t *facfont20; +extern fontHeader_t *courier16; +extern fontHeader_t *courier18; +extern fontHeader_t *courier20; +extern fontHeader_t *handle16; +extern fontHeader_t *handle18; +extern fontHeader_t *marlett; +extern fontHeader_t *verdana12; +extern fontHeader_t *verdana14; + +void CG_Draw2D(); +void CG_ShowHint( const char * hint ); + +typedef struct hdTimer_s +{ + qboolean bEnabled; + + float duration; + float current; + float fade_out_time; + float alpha; + char string[ MAX_STRING_CHARS ]; +} hdTimer_t; + +typedef struct hd3d_s +{ + qboolean bEnabled; + qboolean bAlwaysShow; + qboolean bDepth; + + vec3_t vector; + int ent_num; + vec3_t currentOrg; + + int x, y; +} hd3d_t; + +typedef struct hdExtend_s +{ + struct hdTimer_s timer; + struct hd3d_s h3d; +} hdExtend_t; + +extern hdExtend_t *huddrawExtends; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/code/cgame_hook/cgame/cg_parsemsg.cpp b/code/cgame_hook/cgame/cg_parsemsg.cpp new file mode 100644 index 00000000..3839270a --- /dev/null +++ b/code/cgame_hook/cgame/cg_parsemsg.cpp @@ -0,0 +1,872 @@ +#include "glb_local.h" +#include "script/clientgamecommand.h" +#include "cg_hud.h" +#include "cg_viewmodelanim.h" + +#include "script/cplayer.h" +#include "scriptvariable.h" +#include "scriptmaster.h" + +#define MAX_IMPACTS 64 + +// wall impacts +static vec3_t *wall_impact_pos = ( vec3_t * )0x302659E8; +static vec3_t *wall_impact_norm = ( vec3_t * )0x30265CE8; +static int *wall_impact_large = ( int * )0x302655E8; +static int *wall_impact_type = ( int * )0x30266568; +static int *wall_impact_count = ( int * )0x30269A74; + +// flesh impacts +static vec3_t *flesh_impact_pos = ( vec3_t * )0x302656E8; +static vec3_t *flesh_impact_norm = ( vec3_t * )0x30266768; +static int *flesh_impact_large = ( int * )0x30266668; +static int *flesh_impact_count = ( int * )0x30269A78; + +static int *current_entity_number = ( int * )0x3007C68C; + +typedef void ( *CG_MakeBulletTracer_f )( float *i_vBarrel, float *i_vStart, + float (*i_vEnd)[3], int i_iNumBullets, qboolean iLarge, + int iTracerVisible, qboolean bIgnoreEntities ); +CG_MakeBulletTracer_f CG_MakeBulletTracer = ( CG_MakeBulletTracer_f )0x300313F6; + +typedef void ( *CG_MakeBubbleTrail_f )( float *i_vStart, float *i_vEnd, int iLarge ); +CG_MakeBubbleTrail_f CG_MakeBubbleTrail = ( CG_MakeBubbleTrail_f )0x3002E233; + +typedef void ( *CG_MeleeImpact_f )( float *vStart, float *vEnd ); +CG_MeleeImpact_f CG_MeleeImpact = ( CG_MeleeImpact_f )0x30035AD4; + +typedef void ( *CG_MakeExplosionEffect_f )( float *vPos, int iType ); +CG_MakeExplosionEffect_f CG_MakeExplosionEffect = ( CG_MakeExplosionEffect_f )0x3002FD7B; + +typedef void ( *CG_SpawnEffectModel_f )( const char *model, vec3_t origin, vec3_t axis[3] ); +CG_SpawnEffectModel_f CG_SpawnEffectModel = ( CG_SpawnEffectModel_f )0x302A52E8; + +int ReadNumber() +{ + if( reborn ) { + return cgi.MSG_ReadShort(); + } else { + return cgi.MSG_ReadByte(); + } +} + +void CG_ParseCGMessage2() { + int msgtype; + vec3_t vecStart, vecTmp, vecEnd, vecArray[64]; + vec3_t axis[3]; + int iCount, iLarge; + int i, iTemp; + const char *s; + qboolean loop; + hdElement_t *hde; + + int index; + const char *name; + Hud *hud; + float col_x, col_y, col_z; + const char *weapname, *prefix; + const char *hint; + qboolean bFullAnim; + float alpha; + float time, fade_at_time; + float rate; + qboolean time_up; + short width, height; + float speed; + float volume; + + Vector vector_or_offset; + short ent_num; + qboolean always_show; + qboolean has_depth; + + do { + msgtype = cgi.MSG_ReadBits( 6 ); + + //if(cg_debugCGMessages.integer) { + // Com_Printf( "CG_ParseCGMessage: command type %i\n", msgtype ); + //} + switch ( msgtype ) { + case 1: // BulletTracer (visible?) + vecTmp[0] = cgi.MSG_ReadCoord(); + vecTmp[1] = cgi.MSG_ReadCoord(); + vecTmp[2] = cgi.MSG_ReadCoord(); + case 2: // BulletTracer (invisible?) + case 5: // BubbleTrail + vecStart[0] = cgi.MSG_ReadCoord(); + vecStart[1] = cgi.MSG_ReadCoord(); + vecStart[2] = cgi.MSG_ReadCoord(); + + if ( msgtype != 1 ) { + vecTmp[0] = vecStart[0]; + vecTmp[1] = vecStart[1]; + vecTmp[2] = vecStart[2]; + } + + vecArray[0][0] = cgi.MSG_ReadCoord(); + vecArray[0][1] = cgi.MSG_ReadCoord(); + vecArray[0][2] = cgi.MSG_ReadCoord(); + + iLarge = cgi.MSG_ReadBits( 1 ); + + if( msgtype==1 ) { + CG_MakeBulletTracer( vecTmp, vecStart, vecArray, 1, iLarge, 1, 1 ); + } else if( msgtype==2 ) { + CG_MakeBulletTracer( vecTmp, vecStart, vecArray, 1, iLarge, 0, 1 ); + } else { + CG_MakeBubbleTrail( vecStart, vecArray[0], iLarge ); + } + break; + case 3: // BulletTracer multiple times + vecTmp[0] = cgi.MSG_ReadCoord(); + vecTmp[1] = cgi.MSG_ReadCoord(); + vecTmp[2] = cgi.MSG_ReadCoord(); + iTemp = cgi.MSG_ReadBits( 6 ); + case 4: // BulletTracer multiple times (shotgun shot) + if ( msgtype == 4 ) { + iTemp = 0; + } + + vecStart[0] = cgi.MSG_ReadCoord(); + vecStart[1] = cgi.MSG_ReadCoord(); + vecStart[2] = cgi.MSG_ReadCoord(); + + iLarge = cgi.MSG_ReadBits( 1 ); + iCount = cgi.MSG_ReadBits( 6 ); + + // this check is missing in MOHAA code, so this has buffer overflow risk in AA + if ( iCount > 64 ) { + cgi.Error( ERR_DROP, "CG message type 4 sent too many data.\n" ); + } + + for (i=0;iMakeEffect_Normal( msgtype + 67, vecStart, vecEnd ); + break; + case 23: // broke crate + case 24: // broke glass window + vecStart[0] = cgi.MSG_ReadCoord(); + vecStart[1] = cgi.MSG_ReadCoord(); + vecStart[2] = cgi.MSG_ReadCoord(); + + i = cgi.MSG_ReadByte(); + + if( msgtype == 23 ) { + s = va( "models/fx/crates/debris_%i.tik", i ); + } else { + s = va( "models/fx/windows/debris_%i.tik", i ); + } + + VectorSet( axis[0], 0.f, 0.f, 1.f ); + VectorSet( axis[1], 0.f, 1.f, 0.f ); + VectorSet( axis[2], 1.f, 0.f, 0.f ); + + cgi.R_SpawnEffectModel( s, vecStart, axis ); + break; + case 25: // Bullet tracer + vecTmp[0] = cgi.MSG_ReadCoord(); + vecTmp[1] = cgi.MSG_ReadCoord(); + vecTmp[2] = cgi.MSG_ReadCoord(); + vecStart[0] = cgi.MSG_ReadCoord(); + vecStart[1] = cgi.MSG_ReadCoord(); + vecStart[2] = cgi.MSG_ReadCoord(); + + vecArray[0][0] = cgi.MSG_ReadCoord(); + vecArray[0][1] = cgi.MSG_ReadCoord(); + vecArray[0][2] = cgi.MSG_ReadCoord(); + + iLarge = cgi.MSG_ReadBits( 1 ); + + CG_MakeBulletTracer(vecTmp,vecStart,vecArray,1,iLarge,0,1); + break; + case 26: // Bullet tracer + vecTmp[0] = 0; + vecTmp[1] = 0; + vecTmp[2] = 0; + vecStart[0] = cgi.MSG_ReadCoord(); + vecStart[1] = cgi.MSG_ReadCoord(); + vecStart[2] = cgi.MSG_ReadCoord(); + + vecArray[0][0] = cgi.MSG_ReadCoord(); + vecArray[0][1] = cgi.MSG_ReadCoord(); + vecArray[0][2] = cgi.MSG_ReadCoord(); + + iLarge = cgi.MSG_ReadBits( 1 ); + CG_MakeBulletTracer(vecTmp,vecStart,vecArray,1,iLarge,0,1); + break; + case CGM_HUDDRAW_SHADER: + index = ReadNumber(); + + name = cgi.MSG_ReadString(); + + hud = Hud::FindOrCreate( index ); + hud->SetShader( name, -1 , -1 ); + + break; + + case CGM_HUDDRAW_ALIGN: + index = ReadNumber(); + + hud = Hud::FindOrCreate( index ); + + hud->SetAlignX( ( hudAlign_t )cgi.MSG_ReadBits( 2 ) ); + hud->SetAlignY( ( hudAlign_t )cgi.MSG_ReadBits( 2 ) ); + + break; + + case CGM_HUDDRAW_RECT: + index = ReadNumber(); + + hud = Hud::FindOrCreate( index ); + + hud->SetRectX( cgi.MSG_ReadShort() ); + hud->SetRectY( cgi.MSG_ReadShort() ); + hud->SetRectWidth( cgi.MSG_ReadShort() ); + hud->SetRectHeight( cgi.MSG_ReadShort() ); + + break; + + case CGM_HUDDRAW_VIRTUALSIZE: + index = ReadNumber(); + + hud = Hud::FindOrCreate( index ); + + hud->SetVirtualSize( cgi.MSG_ReadBits( 1 ) ); + + break; + + case CGM_HUDDRAW_COLOR: + index = ReadNumber(); + + hud = Hud::FindOrCreate( index ); + + col_x = cgi.MSG_ReadByte() / 255.0f; + col_y = cgi.MSG_ReadByte() / 255.0f; + col_z = cgi.MSG_ReadByte() / 255.0f; + + hud->SetColor( Vector( col_x, col_y, col_z ) ); + + break; + + case CGM_HUDDRAW_ALPHA: + index = ReadNumber(); + + alpha = cgi.MSG_ReadByte() / 255.0f; + + hud = Hud::FindOrCreate( index ); + hud->SetAlpha( alpha ); + + break; + + case CGM_HUDDRAW_STRING: + index = ReadNumber(); + + hud = Hud::FindOrCreate( index ); + + hud->SetText( cgi.MSG_ReadString() ); + + break; + + case CGM_HUDDRAW_FONT: + index = ReadNumber(); + + hud = Hud::FindOrCreate( index ); + + hud->SetFont( cgi.MSG_ReadString() ); + + break; + case 35: + case 36: + + *current_entity_number = cg->snap->ps.clientNum; + + if( msgtype == 36 ) + { + s = "dm_kill_notify"; + } + else + { + s = "dm_hit_notify"; + } + + commandManager->PlaySound( ( const char * )s, + Vector( 0, 0, 0 ), + 5, + 2.0, + -1.0, + -1.0, + 1 ); + //CG_PlaySound( s, 0, 5, 2.0, -1.0, vecStart, 1 ); + break; + case 37: // voicechat message (squad command, taunt, etc...) + vecStart[0] = cgi.MSG_ReadCoord(); + vecStart[1] = cgi.MSG_ReadCoord(); + vecStart[2] = cgi.MSG_ReadCoord(); + + iTemp = cgi.MSG_ReadBits( 1 ); + // read client index + i = cgi.MSG_ReadBits( 6 ); + // read voicechat sound alias + s = cgi.MSG_ReadString(); + + if( iTemp ) { + *current_entity_number = i; + + } + //CG_Printf("Case 37: iTemp %i, i %i, s %s\n",iTemp,i,s); + // play an aliased sound from uberdialog.scr + // wombat: only if there is a sound to be played + if ( *s ) { + commandManager->PlaySound( s, vecStart, 5, -1.0, -1.0, -1.0, 0 ); + } + + break; + + case CGM_VIEWMODELANIM: + name = cgi.MSG_ReadStringLine(); + bFullAnim = cgi.MSG_ReadByte(); + + CG_ViewModelAnim(( char * )name, bFullAnim ); + break; + + case CGM_VIEWMODELPREFIX: + weapname = cgi.MSG_ReadStringLine(); + prefix = cgi.MSG_ReadString(); + + VM_AddViewModelPrefix( weapname, prefix ); + break; + + case CGM_MODHEIGHTFLOAT: + modheightfloat_used = true; + viewHeight = cgi.MSG_ReadLong(); + max_z = cgi.MSG_ReadFloat(); + break; + + case CGM_SETVMASPEED: + name = cgi.MSG_ReadStringLine(); + speed = cgi.MSG_ReadFloat(); + + CG_SetVMASpeed( name, speed ); + break; + + case CGM_HUDDRAW_TIMER: + index = ReadNumber(); + + time = cgi.MSG_ReadFloat(); + fade_at_time = cgi.MSG_ReadFloat(); + time_up = cgi.MSG_ReadBits( 1 ); + + hud = Hud::FindOrCreate( index ); + if( !time_up ) { + hud->SetTimer( time, fade_at_time ); + } else { + hud->SetTimerUp( time, fade_at_time ); + } + + break; + + case CGM_HUDDRAW_3D: + index = ReadNumber(); + + vector_or_offset[ 0 ] = cgi.MSG_ReadCoord(); + vector_or_offset[ 1 ] = cgi.MSG_ReadCoord(); + vector_or_offset[ 2 ] = cgi.MSG_ReadCoord(); + + ent_num = cgi.MSG_ReadShort(); + always_show = cgi.MSG_ReadBits( 1 ); + has_depth = cgi.MSG_ReadBits( 1 ); + + hud = Hud::FindOrCreate( index ); + hud->Set3D( vector_or_offset, always_show, has_depth, ent_num ); + + break; + + case CGM_HUDDRAW_BREAK3D: + index = ReadNumber(); + + hud = Hud::FindOrCreate( index ); + hud->SetNon3D(); + + break; + + case CGM_HUDDRAW_FADE: + index = ReadNumber(); + + time = cgi.MSG_ReadFloat(); + + hud = Hud::FindOrCreate( index ); + hud->FadeOverTime( time ); + + break; + + case CGM_HUDDRAW_MOVE: + index = ReadNumber(); + + time = cgi.MSG_ReadFloat(); + + hud = Hud::FindOrCreate( index ); + hud->MoveOverTime( time ); + + break; + + case CGM_HUDDRAW_SCALE: + index = ReadNumber(); + + time = cgi.MSG_ReadFloat(); + width = cgi.MSG_ReadShort(); + height = cgi.MSG_ReadShort(); + + hud = Hud::FindOrCreate( index ); + hud->ScaleOverTime( time, width, height ); + + break; + + case CGM_HINTSTRING: // approaching an entity which have an hint string + hint = cgi.MSG_ReadStringLine(); + + CG_ShowHint( hint ); + break; + + case CGM_PLAYLOCALSOUND: + s = cgi.MSG_ReadStringLine(); + loop = cgi.MSG_ReadBits( 1 ); + time = cgi.MSG_ReadFloat(); + volume = cgi.MSG_ReadFloat(); + + commandManager->PlayLocalSound( s, loop, volume, time ); + break; + + case CGM_STOPLOCALSOUND: + s = cgi.MSG_ReadStringLine(); + time = cgi.MSG_ReadFloat(); + + commandManager->StopLocalSound( s, time ); + break; + + case CGM_SETLOCALSOUNDRATE: + s = cgi.MSG_ReadStringLine(); + rate = cgi.MSG_ReadFloat(); + time = cgi.MSG_ReadFloat(); + + commandManager->SetLocalSoundRate( s, rate, time ); + break; + + case CGM_HUDDRAW_RECTX: + index = ReadNumber(); + + hud = Hud::FindOrCreate( index ); + hud->SetRectX( cgi.MSG_ReadShort() ); + break; + + case CGM_HUDDRAW_RECTY: + index = ReadNumber(); + + hud = Hud::FindOrCreate( index ); + hud->SetRectY( cgi.MSG_ReadShort() ); + break; + + case CGM_HUDDRAW_RECTWH: + index = ReadNumber(); + + hud = Hud::FindOrCreate( index ); + hud->SetRectWidth( cgi.MSG_ReadShort() ); + hud->SetRectHeight( cgi.MSG_ReadShort() ); + break; + + case CGM_REPLICATION: + index = cgi.MSG_ReadBits( 4 ); + name = cgi.MSG_ReadString(); + + { + ScriptVariable var; + + var.SetKey( Director.AddString( name ) ); + + switch( index ) + { + case VARIABLE_CHAR: + var.setCharValue( cgi.MSG_ReadChar() ); + player.replication.ReplicateVariable( var ); + break; + + case VARIABLE_CONSTSTRING: + case VARIABLE_STRING: + var.setStringValue( cgi.MSG_ReadString() ); + player.replication.ReplicateVariable( var ); + break; + + case VARIABLE_FLOAT: + var.setFloatValue( cgi.MSG_ReadFloat() ); + player.replication.ReplicateVariable( var ); + break; + + case VARIABLE_INTEGER: + var.setIntValue( cgi.MSG_ReadLong() ); + player.replication.ReplicateVariable( var ); + break; + + case VARIABLE_VECTOR: + vecTmp[ 0 ] = cgi.MSG_ReadCoord(); + vecTmp[ 1 ] = cgi.MSG_ReadCoord(); + vecTmp[ 2 ] = cgi.MSG_ReadCoord(); + + var.setVectorValue( ( Vector )vecTmp ); + player.replication.ReplicateVariable( var ); + break; + } + } + break; + + case CGM_HUDDRAW_DELETE: + hud = Hud::Find( cgi.MSG_ReadShort() ); + + if( hud ) + { + delete hud; + } + break; + } + } while( cgi.MSG_ReadBits( 1 ) ); +} + +/*void __stdcall CG_ParseCGMessage( int msgtype ) +{ + int index; + float duration, fade_out_time; + hdElement_t *hde; + hdExtend_t *hdex; + const char *weap_name; + const char *prefix; + const char *name; + qboolean bFullAnim; + vec3_t vector; + int ent_num; + qboolean bAlwaysShow, bDepth; + const char * hintstring; + + float col_x, col_y, col_z; + + Hud *hud; + + switch(msgtype) + { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + break; + + case CGM_HUDDRAW_SHADER: + index = cgi.MSG_ReadByte(); + name = cgi.MSG_ReadString(); + + hud = Hud::FindOrCreate( index ); + hud->SetShader( name, -1 , -1 ); + + break; + + case CGM_HUDDRAW_ALIGN: + index = cgi.MSG_ReadByte(); + + hud = Hud::FindOrCreate( index ); + + hud->SetAlignX( ( hudAlign_t )cgi.MSG_ReadBits( 2 ) ); + hud->SetAlignY( ( hudAlign_t )cgi.MSG_ReadBits( 2 ) ); + + break; + + case CGM_HUDDRAW_RECT: + index = cgi.MSG_ReadByte(); + + hud = Hud::FindOrCreate( index ); + + hud->SetRectX( cgi.MSG_ReadShort() ); + hud->SetRectY( cgi.MSG_ReadShort() ); + hud->SetRectHeight( cgi.MSG_ReadShort() ); + hud->SetRectWidth( cgi.MSG_ReadShort() ); + + break; + + case CGM_HUDDRAW_VIRTUALSIZE: + index = cgi.MSG_ReadByte(); + + hud = Hud::FindOrCreate( index ); + + hud->SetVirtualSize( cgi.MSG_ReadBits( 1 ) ); + + break; + + case CGM_HUDDRAW_COLOR: + index = cgi.MSG_ReadByte(); + + hud = Hud::FindOrCreate( index ); + + col_x = cgi.MSG_ReadByte() / 255.0f; + col_y = cgi.MSG_ReadByte() / 255.0f; + col_z = cgi.MSG_ReadByte() / 255.0f; + + hud->SetColor( Vector( col_x, col_y, col_z ) ); + + break; + + case CGM_HUDDRAW_ALPHA: + index = cgi.MSG_ReadByte(); + + hud = Hud::FindOrCreate( index ); + + hud->SetAlpha( cgi.MSG_ReadByte() / 255.0f ); + + break; + + case CGM_HUDDRAW_STRING: + index = cgi.MSG_ReadByte(); + + hud = Hud::FindOrCreate( index ); + + hud->SetText( cgi.MSG_ReadString() ); + + break; + + case CGM_HUDDRAW_FONT: + index = cgi.MSG_ReadByte(); + + hud = Hud::FindOrCreate( index ); + + hud->SetFont( cgi.MSG_ReadString() ); + + break; + + case 35: + case 36: + case 37: + break; + + case CGM_HUDDRAW_TIMER: // huddraw_timer + index = cgi.MSG_ReadByte(); + + duration = cgi.MSG_ReadFloat(); + fade_out_time = cgi.MSG_ReadFloat(); + + hde = cgi.hudDrawElements + index; + hdex = huddrawExtends + index; + + hde->shader = 0; + memset(hde->shaderName, 0, sizeof(hde->shaderName)); + + if(duration <= 0.0f) + memset(&hdex->timer, 0, sizeof(hdTimer_t)); + else + { + hdex->timer.bEnabled = true; + hdex->timer.duration = duration; + hdex->timer.current = duration; + hdex->timer.fade_out_time = fade_out_time * 1000.0f; + hdex->timer.alpha = hde->color[3]; + + strcpy(hde->string, hdex->timer.string); + } + break; + + case CGM_VIEWMODELANIM: // viewmodelanim + name = cgi.MSG_ReadStringLine(); + bFullAnim = cgi.MSG_ReadByte(); + + CG_ViewModelAnim((char*)name, bFullAnim); + break; + + case CGM_VIEWMODELPREFIX: // viewmodelprefix + weap_name = cgi.MSG_ReadStringLine(); + prefix = cgi.MSG_ReadString(); + + VM_AddViewModelPrefix( weap_name, prefix ); + break; + + case CGM_MODHEIGHTFLOAT: // modheightfloat + modheightfloat_used = true; + viewHeight = cgi.MSG_ReadLong(); + max_z = cgi.MSG_ReadFloat(); + break; + + case CGM_SETBOBSPEED: // setviewbobspeed + bobMovementMultiplier = cgi.MSG_ReadFloat(); + break; + + case CGM_HUDDRAW_3D: // huddraw_3d + index = cgi.MSG_ReadByte(); + + vector[0] = cgi.MSG_ReadCoord(); + vector[1] = cgi.MSG_ReadCoord(); + vector[2] = cgi.MSG_ReadCoord(); + + ent_num = cgi.MSG_ReadShort(); + + bAlwaysShow = cgi.MSG_ReadByte(); + bDepth = cgi.MSG_ReadByte(); + + hde = cgi.hudDrawElements + index; + hdex = huddrawExtends + index; + + hdex->h3d.bEnabled = true; + VectorCopy( vector, hdex->h3d.vector ); + VectorCopy( vector, hdex->h3d.currentOrg ); + hdex->h3d.ent_num = ent_num; + + hdex->h3d.bAlwaysShow = bAlwaysShow; + hdex->h3d.bDepth = bDepth; + + hde->x = hdex->h3d.x; + hde->y = hdex->h3d.y; + + break; + + case CGM_HINTSTRING: // approaching an entity which have an hint string + hintstring = cgi.MSG_ReadStringLine(); + + CG_ShowHint( hintstring ); + break; + + case CGM_HUDDRAW_FADE: + case CGM_HUDDRAW_MOVE: + case CGM_HUDDRAW_SCALE: + case 48: + case 49: + case 50: + case 51: + case 52: + break; + + default: + cgi.Error( ERR_DROP, "CG_ParseCGMessage: Unknown CGM message type" ); + } +}*/ diff --git a/code/cgame_hook/cgame/cg_servercmds.cpp b/code/cgame_hook/cgame/cg_servercmds.cpp new file mode 100644 index 00000000..1575bb16 --- /dev/null +++ b/code/cgame_hook/cgame/cg_servercmds.cpp @@ -0,0 +1,164 @@ +#include "glb_local.h" +#include "cg_viewmodelanim.h" +#include "cl_sound.h" +#include "script/earthquake.h" +#include "script/clientservercommand.h" + +void CG_AddViewModelPrefix(const char * weapon_name, const char * prefix); + +void CG_ServerCommand() +{ + /*const char *command = cgi.Argv( 0 ); + char *param1 = cgi.Argv( 1 ); + char *param2 = cgi.Argv( 2 ); + char *param3 = cgi.Argv( 3 ); + char *param4 = cgi.Argv( 4 ); + char *param5 = cgi.Argv( 5 ); + char *param6 = cgi.Argv( 6 ); + char *param7 = cgi.Argv( 7 ); + char *param8 = cgi.Argv( 8 ); + char *param9 = cgi.Argv( 9 ); + char *param10 = cgi.Argv( 10 );*/ + + char *buffer[ MAX_STRING_CHARS ]; + int arguments = cgi.Argc(); + + for( int i = 0; i < arguments; i++ ) { + buffer[ i ] = cgi.Argv( i ); + } + + svcommandManager.ExecuteCommand( buffer, arguments ); + + /*if(strcmp(command, "viewmodelanim") == 0) + { + vm_anim_name = param1; + + if(param2) + vm_fullanim = atoi(param2); + else + vm_fullanim = 0; + } + else if(strcmp(command, "viewmodelprefix") == 0) + CG_AddViewModelPrefix(param1, param2); + else if(strcmp(command, "modheightfloat") == 0) + { + __try + { + modheightfloat_used = qtrue; + viewHeight = atoi(param1); + max_z = (float)atof(param2); + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + } + } + else if(strcmp(command, "setviewbobspeed") == 0) + { + __try + { + bobMovementMultiplier = atof(param1); + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + } + }*/ + + /*if(strcmp(command, "visioneffect") == 0) + { + char * name = param1; + float fadetime, intensity, red, green, blue; + float parameters[2]; + vec3_t colors; + qboolean effectAdd; + + effectAdd = atoi(param2); + fadetime = (float)atof(param3); + intensity = (float)atof(param4); + red = (float)atof(param5); + green = (float)atof(param6); + blue = (float)atof(param7); + parameters[0] = (float)atof(param8); + parameters[1] = (float)atof(param9); + + colors[0] = red; + colors[1] = green; + colors[2] = blue; + + R_PostProcessEffect(name, intensity, colors, fadetime, effectAdd, parameters); + } + else if(strcmp(command, "fadesound2") == 0) + { + float time; + float min_vol; + + time = (float)atof(param1); + min_vol = (float)atof(param2); + + CL_FadeSound2(time, min_vol); + } + else if(strcmp(command, "restoresound") == 0) + { + float time; + float max_vol; + + time = (float)atof(param1); + max_vol = (float)atof(param2); + + CL_RestoreSound(time, max_vol); + } + else if( strcmp( command, "eq" ) == 0 ) + { + float duration; + float magnitude; + qboolean no_rampup; + qboolean no_rampdown; + str location; + float radius; + + duration = ( float )atof( param1 ); + magnitude = ( float )atof( param2 ); + no_rampup = atoi( param3 ); + no_rampdown = atoi( param4 ); + + if( param5 && param6 && param7 ) + { + location = param5; + location += str( " " ) + param6; + location += str( " " ) + param7; + + radius = ( float )atof( param8 ); + } + + Earthquake * earthquake = new Earthquake; + + earthquake->SetDuration( duration ); + earthquake->SetMagnitude( magnitude ); + earthquake->SetNoRampup( no_rampup ); + earthquake->SetNoRampdown( no_rampdown ); + + if( location ) + { + earthquake->SetLocation( Vector( location.c_str() ) ); + earthquake->SetRadius( radius ); + } + + earthquake->Enable(); + } else if ( strcmp( command, "vsn" ) == 0 ) { + R_ProcessVision( param1, atof( param2 ) ); + } + else if( strcmp( command, "setshader" ) == 0 ) + { + int ent_num = -1; + const char * shadername = NULL; + qboolean fReset = false; + + ent_num = atoi( param1 ); + shadername = param2; + fReset = atoi( param3 ); + + R_SetShader( ent_num, shadername, fReset ); + + } else { + cgi.Printf( "Unknown client game command: %s\n", command ); + }*/ +} diff --git a/code/cgame_hook/cgame/cg_servercmds.h b/code/cgame_hook/cgame/cg_servercmds.h new file mode 100644 index 00000000..5c0dc876 --- /dev/null +++ b/code/cgame_hook/cgame/cg_servercmds.h @@ -0,0 +1,7 @@ +#ifndef __SERVERCMDS_H__ +#define __SERVERCMDS_H__ + +void __stdcall CG_ParseCGMessage(int msgtype); +void CG_ServerCommand(); + +#endif diff --git a/code/cgame_hook/cgame/cg_viewmodelanim.cpp b/code/cgame_hook/cgame/cg_viewmodelanim.cpp new file mode 100644 index 00000000..95d9de21 --- /dev/null +++ b/code/cgame_hook/cgame/cg_viewmodelanim.cpp @@ -0,0 +1,1521 @@ +#include "glb_local.h" +#include "cg_viewmodelanim.h" +#include "script/cplayer.h" +#include "script/clientgamecommand.h" + +cvar_t *cg_fakepredict; + +float max_z = 94.0f; +int viewHeight = 82; +qboolean modheightfloat_used = false; +float viewHeight_mult = 1.0f; + +char vm_anim_name[MAX_STRING_CHARS] = "idle"; +qboolean vm_fullanim = false; +int currentviewModelAnim = 0; +int currentviewModelAnimChanged = 0; + +qboolean fNoMove = 0; + +vec3_t currentDeltaVMPosOffset; +vec3_t currentDeltaVMPosOffset2; + +vec3_t currentVMAnglesOffset; + +vec3_t oldAngles; +vec3_t deltaAngles; +vec3_t newAngles; + +vec3_t eyeOldAngles; +vec3_t eyeNormalAngles; +vec3_t eyeDeltaAngles; + +vec3_t eyeStartAngles; + +vec3_t previousVelocity; + +qboolean fIsReloading; + +int landHeight = 0; +qboolean fLanding, fFell; +qboolean fLandingUp; + +float landDownValue = 0.0f, landDownDelayScale = 0.0f, landDownViewScale = 0.0f; + +vec3_t deltaPosition; + +qboolean move_godown_z = false; + +double bobMovementMultiplier = 1.0; // default 1.0 + +int internal_bobOffset = 1; + +float *bobValue = (float*)0x303EBFF8; + +float time_step = 0; +float viewbob = 0; + +float vm_time = 0.0f; + +Container< vma_t * > vmalist; +vma_t *current_vma = NULL; + +/********************************************** + * + * CG_ViewInit + * Client game hook initialization + * + **********************************************/ +void CG_ViewInit() +{ + cg_fakepredict = cgi.Cvar_Get("cg_fakepredict", "0", 0); + + VM_VMInit(); +} + +/********************************************** + * + * CG_MatchEyesBone + * Set the player's viewangles depending on the + * current FPS animation's eyes bone + * + **********************************************/ + +vec3_t eyesDeltaStart = { 0, 0, 0 }; +vec3_t eyesDeltaStart2 = { 0, 0, 0 }; +float eyesCurrentCrossTime = 0.0f; +float eyesCurrentTime = 0.0f; + +void CG_MatchEyesBone( refEntity_t * model ) +{ + dtiki_t * tiki; + int tagNum; + orientation_t orientation, orientation_head; + vec3_t eyeAngles, eyeStartAngles, refdefAngles, local; + int i; + qboolean bFirstTime = false; + float ratio = 1.0f; + int vmAnim = cgi.anim->lastVMAnim; + + VectorSubtract( cg->refdefViewAngles, player.eyesDeltaOld, cg->refdefViewAngles ); + VectorCopy( player.eyesDelta, player.eyesDeltaOld ); + + tiki = model->tiki; + + if( tiki == NULL ) + { + cgi.Printf( "Invalid tiki\n" ); + return; + } + + /*if( vmAnim == VMA_IDLE || + vmAnim == VMA_FIRE || + vmAnim == VMA_FIRE_SECONDARY || + vmAnim == VMA_CHARGE ) + { + float crossblend = cgi.Anim_CrossblendTime( tiki, cgi.anim->vmFrameInfo[ cgi.anim->currentVMAnimSlot ].index ) * 1000.0f; + + if( crossblend ) { + ratio = eyesCurrentTime/crossblend; + } else { + ratio = 1.0f; + } + + if( ratio > 1.0f ) { + ratio = 1.0f; + } + + eyesCurrentTime += cg->frametime; + + player.eyesDelta[ 0 ] = eyesDeltaStart[ 0 ] + ( 0 - eyesDeltaStart[ 0 ] ) * ratio; + player.eyesDelta[ 1 ] = eyesDeltaStart[ 1 ] + ( 0 - eyesDeltaStart[ 1 ] ) * ratio; + player.eyesDelta[ 2 ] = eyesDeltaStart[ 2 ] + ( 0 - eyesDeltaStart[ 2 ] ) * ratio; + + VectorCopy( player.eyesDelta, eyesDeltaStart2 ); + + return; + } + else + { + eyesCurrentTime = 0.0f; + VectorCopy( player.eyesDelta, eyesDeltaStart ); + }*/ + + eyesCurrentTime = 0.0f; + VectorCopy( player.eyesDelta, eyesDeltaStart ); + + /*if( !fIsReloading ) + { + fIsReloading = true; + bFirstTime = true; + }*/ + + tagNum = cgi.Tag_NumForName( tiki, "eyes bone" ); + + if( tagNum == -1 ) + { + cgi.Printf( "Can't find 'eyes bone' for player\n" ); + return; + } + + if( player.GetNumber() != model->entityNumber ) { + player.AssignNumber( model->entityNumber ); + } + + orientation = ri.TIKI_OrientationInternal( tiki, model->entityNumber, tagNum, 1.0f ); + + MatrixToEulerAngles( orientation.axis, eyeAngles ); + MatrixToEulerAngles( cg->refdef.viewAxis, refdefAngles ); + + if( cgi.anim->crossBlending ) + { + float crossblend = cgi.Anim_CrossblendTime( tiki, cgi.anim->vmFrameInfo[ cgi.anim->currentVMAnimSlot ].index ) * 1000.0f; + + ratio = eyesCurrentCrossTime/crossblend; + + if( ratio > 1.0f ) { + ratio = 1.0f; + } + + eyesCurrentCrossTime += cg->frametime; + } else { + eyesCurrentCrossTime = 0.0f; + } + + eyeAngles[0] -= ( refdefAngles[0] + 8.0f ); + + local[0] = eyesDeltaStart2[0] + ( -eyeAngles[0] - eyesDeltaStart2[0] ) * ratio; + local[1] = eyesDeltaStart2[1] + ( -eyeAngles[1] - eyesDeltaStart2[1] ) * ratio; + local[2] = eyesDeltaStart2[2] + ( -eyeAngles[2] - eyesDeltaStart2[2] ) * ratio; + + VectorCopy( local, player.eyesDelta ); +} + +/********************************************** + * + * CG_FakePredict + * Fake prediction like jump, fire, crouch, etc. + * + **********************************************/ + +qboolean attackprimary_up; +qboolean movedown_up; +qboolean moveup_up; + +void CG_FakePredict() +{ + kbutton_t *attackprimary; + kbutton_t *movedown; + kbutton_t *moveup; + + if(!cg_fakepredict->integer) + return; + + attackprimary = (kbutton_t*)0x012F70E0; + movedown = (kbutton_t*)0x012F6FC0; + moveup = (kbutton_t*)0x012F6FA0; + + if(attackprimary->active) + { + if(cgi.anim->lastVMAnim != VMA_IDLE) + goto _skip_attackprimary; + + if(attackprimary_up) + goto _skip_attackprimary; + + attackprimary_up = true; + + cg->predictedPlayerState.iViewModelAnim = VMA_FIRE; + cg->predictedPlayerState.iViewModelAnimChanged = ( cg->predictedPlayerState.iViewModelAnimChanged + 1 ) & 3; + + cgi.anim->lastVMAnim = VMA_FIRE; + cgi.anim->lastVMAnimChanged = (cgi.anim->lastVMAnimChanged + 1) & 3; + } + else + attackprimary_up = false; + +_skip_attackprimary: + + if(movedown->active) + { + if(movedown_up) + goto _skip_movedown; + + movedown_up = true; + + if( viewHeight == 48 ) // crouching + viewHeight = 82; + else if( viewHeight == 82 ) // standing + viewHeight = 48; + } + else + movedown_up = false; + +_skip_movedown: + + if(moveup->active) + { + if(moveup_up) + goto _skip_moveup; + + moveup_up = true; + + if( viewHeight == 48 ) // crouching + viewHeight = 82; // stand + + else if(viewHeight == 82 && cg->predictedPlayerState.velocity[2] <= 10 && cg->predictedPlayerState.velocity[2] >= -5) + { + int i; + + if(cg->snap != NULL) + { + cg->snap->ps.velocity[2] += (float)sqrt( 2.0f * 800 * 56 ); + cg->snap->ps.walking = false; // make sure the player leaves the ground + } + + if(cg->nextSnap != NULL) + { + cg->nextSnap->ps.velocity[2] += (float)sqrt( 2.0f * 800 * 56 ); + cg->nextSnap->ps.walking = false; + } + + for(i=0;i<2;i++) + { + cg->activeSnapshots[i].ps.velocity[2] += (float)sqrt( 2.0f * 800 * 56 ); + cg->activeSnapshots[i].ps.walking = false; + } + + cg->predictedPlayerState.velocity[2] += (float)sqrt( 2.0f * 800 * 56 ); + cg->predictedPlayerState.walking = false; + } + } + else + moveup_up = false; + +_skip_moveup: + return; +} + +#if 0 +void __stdcall CG_CalcViewBob( float value ) +{ + float multiplier; + float speed_scale; + trace_t results; + float val = value; + + //if(value > 250.0f) + + if( value > 10.0f ) { + value = 235.0f; + } + + multiplier = value * 0.001500000013038516f + 0.8999999761581421f; + + speed_scale = ( float )( cg->frametime * bobMovementMultiplier ); + + *bobValue -= ( speed_scale * 0.001000000047497451f + speed_scale * 0.001000000047497451f ) + * M_PI + * multiplier; + + viewbob += ( speed_scale * 0.001000000047497451f + speed_scale * 0.001000000047497451f ) + * M_PI + * multiplier; + + //if(*bobValue < -4) + // *bobValue = 0.0f; + + //*bobValue = (float)((int)*bobValue % 4); + + //time_step += speed_scale * 0.001000000047497451f; + + if( viewbob > 3.1f ) // time_step > 0.37f ) + { + str string; + vec3_t mins; + vec3_t maxs; + vec3_t start; + vec3_t end; + float *height = (float*)0x303EBC6C; + const char * snd_name; + int flags; + + //time_step = 0.0f; + viewbob = 0; + + if( val < 10.0f || cent == NULL ) + return; + + memcpy( start, (const void *)0x303EBBD0, sizeof(vec3_t) ); + memcpy( end, (const void *)0x303EBBD0, sizeof(vec3_t) ); + + //start[2] += *height; + end[2] -= 1000; + + //VectorSet( mins, -6.0f, -6.0f, -6.0f ); + //VectorSet( maxs, 6.0f, 6.0f, 6.0f ); + + memcpy( mins, ( const void * )0x30077554, sizeof( vec3_t ) ); + memcpy( maxs, ( const void * )0x30077560, sizeof( vec3_t ) ); + + CG_Trace( &results, start, mins, maxs, end, cg->activeSnapshots[0].ps.clientNum, MASK_VISIBLE, 0, 1, "CG_CalcViewBob" ); + + flags = results.surfaceFlags; + + if( flags & SURF_PAPER ) + snd_name = "snd_step_paper"; + else if( flags & SURF_WOOD ) + snd_name = "snd_step_wood"; + else if( flags & SURF_METAL) + snd_name = "snd_step_metal"; + else if( flags & SURF_STONE) + snd_name = "snd_step_stone"; + else if( flags & SURF_DIRT ) + snd_name = "snd_step_dirt"; + else if( flags & SURF_METALGRILL ) + snd_name = "snd_step_grill"; + else if( flags & SURF_GRASS ) + snd_name = "snd_step_grass"; + else if( flags & SURF_MUD ) + snd_name = "snd_step_mud"; + else if( flags & SURF_PUDDLE ) + snd_name = "snd_step_puddle"; + else if( flags & SURF_GLASS ) + snd_name = "snd_step_glass"; + else if( flags & SURF_GRAVEL ) + snd_name = "snd_step_gravel"; + else if( flags & SURF_SAND ) + snd_name = "snd_step_sand"; + else if( flags & SURF_FOLIAGE ) + snd_name = "snd_step_foliage"; + else if( flags & SURF_SNOW ) + snd_name = "snd_step_snow"; + else if( flags & SURF_CARPET ) + snd_name = "snd_step_carpet"; + else + snd_name = "snd_step_stone"; + + if( results.contents & CONTENTS_WATER ) + snd_name = "snd_step_water"; + + string = snd_name; + + CG_PlaySound( ( char * )string.data, cent->currentState.origin, 5, -1.0, -1.0, -1.0, 1); + } +} +#endif + +uintptr_t CG_OffsetFirstPersonView_f = 0; +uintptr_t CG_OffsetThirdPersonView_f = 0; +uintptr_t CG_ModelAnim_f = 0; + +void CG_OffsetFirstPersonViewReal( refEntity_t *model, int a2 ) +{ + JMPTO( CG_OffsetFirstPersonView_f ); +} + +void CG_OffsetThirdPersonViewReal() +{ + JMPTO( CG_OffsetThirdPersonView_f ); +} + +void CG_ModelAnimReal( centity_t *ent, int un1 ) +{ + JMPTO( CG_ModelAnim_f ); +} + +void CG_ProcessDeltaAngles( qboolean isDead ) +{ + vec3_t angles; + + if( isDead ) { + MatrixToEulerAngles( cg->refdef.viewAxis, angles ); + } else { + VectorCopy( cg->refdefViewAngles, angles ); + } + + // Process delta angles (shock, etc) + for( int i = 0; i < MAX_DELTAANGLES; i++ ) + { + vec3_t angles2; + + VectorCopy( player.deltaAnglesOld[ i ], angles2 ); + + /*if( isDead ) + { + angles2[ 0 ] *= 0.035f; + angles2[ 1 ] *= 0.035f; + angles2[ 2 ] *= 0.035f; + }*/ + + VectorSubtract( angles, angles2, angles ); + VectorCopy( player.deltaAngles[ i ], player.deltaAnglesOld[ i ] ); + } + + if( isDead ) { + AnglesToAxis( angles, cg->refdef.viewAxis ); + } else { + VectorCopy( angles, cg->refdefViewAngles ); + } +} + +void CG_OffsetFirstPersonView( refEntity_t *model, int a2 ) +{ + int old_frametime = cg->frametime; + float speed_scale; + trace_t results; + vec3_t modelAngles; + float sv_crouchspeedmult; + int sv_runspeed; + + CG_ProcessDeltaAngles( false ); + + player.DebugCamera(); + + if( cg_debugview->integer ) { + return;// CG_OffsetFirstPersonViewReal( model, a2 ); + } + + model->renderfx &= ~RF_INVISIBLE; + model->renderfx &= ~RF_DONTDRAW; + + CG_MoveWeapon( cg->frametime ); + //CG_MatchEyesBone( model ); + + float speed = sqrt( cg->predictedPlayerState.velocity[0] * cg->predictedPlayerState.velocity[0] + + cg->predictedPlayerState.velocity[1] * cg->predictedPlayerState.velocity[1] + + cg->predictedPlayerState.velocity[2] * cg->predictedPlayerState.velocity[2] ); + + if( reborn ) + { + sv_crouchspeedmult = atof( CG_GetServerVariable( "sv_crouchspeedmult" ) ); + sv_runspeed = atoi( CG_GetServerVariable( "sv_runspeed" ) ); + } + else + { + sv_crouchspeedmult = 1.0f; + sv_runspeed = ( int )speed; + } + + if( cg->predictedPlayerState.viewheight == 48 ) { + sv_runspeed = ( int )( ( float )sv_runspeed * sv_crouchspeedmult ); + } + + if( sv_runspeed <= 1 ) + sv_runspeed = 1; + + bobMovementMultiplier = speed / sv_runspeed; + + if( speed > 15.0f ) { + speed = 235.0f; + } + + cg->predictedPlayerState.viewheight = ( int )( ( float )cg->predictedPlayerState.viewheight * viewHeight_mult ); + + if( cg->predictedPlayerState.walking ) + { + float multiplier = cg->frametime * 0.001000000047497451 * bobMovementMultiplier; + + cg->currentViewBobPhase += ( multiplier + multiplier ) + * M_PI + * ( speed * 0.001500000013038516 + 0.8999999761581421 ); + + viewbob += ( multiplier + multiplier ) + * M_PI + * ( speed * 0.001500000013038516 + 0.8999999761581421 ); + + + cg->predictedPlayerState.velocity[0] *= bobMovementMultiplier; + cg->predictedPlayerState.velocity[1] *= bobMovementMultiplier; + cg->predictedPlayerState.velocity[2] *= bobMovementMultiplier; + + cg->currentViewBobAmp = ( 1.0 - fabs( cg->refdefViewAngles[ 0 ] ) * 0.01111111138015985 * 0.5 ) * 0.5 * 0.75; + } + + CG_OffsetFirstPersonViewReal( model, a2 ); + + if( viewbob > M_PI ) + { + vec3_t mins; + vec3_t maxs; + Vector start; + Vector end; + float *height = (float*)0x303EBC6C; + const char * snd_name; + int flags; + + viewbob = 0; + + if( speed < 10.0f || cent == NULL || !cl_run->integer ) { + return; + } + + //memcpy( start, (const void *)0x303EBBD0, sizeof(vec3_t) ); + //memcpy( end, (const void *)0x303EBBD0, sizeof(vec3_t) ); + + start = cg->predictedPlayerState.origin; + start.z += cg->predictedPlayerState.viewheight; + + end = cg->predictedPlayerState.origin; + end.z -= 1000; + + //VectorSet( mins, -6.0f, -6.0f, -6.0f ); + //VectorSet( maxs, 6.0f, 6.0f, 6.0f ); + + memcpy( mins, ( const void * )0x30077554, sizeof( vec3_t ) ); + memcpy( maxs, ( const void * )0x30077560, sizeof( vec3_t ) ); + + CG_Trace( &results, start, mins, maxs, end, model->entityNumber, MASK_BEAM, 0, 1, "CG_CalcViewBob" ); + + flags = results.surfaceFlags; + + if( flags & SURF_PAPER ) + snd_name = "snd_step_paper"; + else if( flags & SURF_WOOD ) + snd_name = "snd_step_wood"; + else if( flags & SURF_METAL) + snd_name = "snd_step_metal"; + else if( flags & SURF_ROCK ) + snd_name = "snd_step_stone"; + else if( flags & SURF_DIRT ) + snd_name = "snd_step_dirt"; + else if( flags & SURF_GRILL ) + snd_name = "snd_step_grill"; + else if( flags & SURF_GRASS ) + snd_name = "snd_step_grass"; + else if( flags & SURF_MUD ) + snd_name = "snd_step_mud"; + else if( flags & SURF_PUDDLE ) + snd_name = "snd_step_puddle"; + else if( flags & SURF_GLASS ) + snd_name = "snd_step_glass"; + else if( flags & SURF_GRAVEL ) + snd_name = "snd_step_gravel"; + else if( flags & SURF_SAND ) + snd_name = "snd_step_sand"; + else if( flags & SURF_FOLIAGE ) + snd_name = "snd_step_foliage"; + else if( flags & SURF_SNOW ) + snd_name = "snd_step_snow"; + else if( flags & SURF_CARPET ) + snd_name = "snd_step_carpet"; + else + snd_name = "snd_step_stone"; + + if( results.contents & CONTENTS_WATER ) + snd_name = "snd_step_water"; + + commandManager->PlaySound( snd_name, cent->currentState.origin, 5, -1.0, -1.0, -1.0, 1 ); + } +} + +void CG_OffsetThirdPersonView() +{ + CG_ProcessDeltaAngles( false ); + + player.DebugCamera(); + + if( cg_debugview->integer ) { + return; + } + + CG_OffsetThirdPersonViewReal(); +} + +void CG_ModelAnim( centity_t *ent, int un1 ) +{ + qboolean isDead = ( ent->currentState.eFlags & EF_DEAD ); + + if( isDead ) + { + CG_ProcessDeltaAngles( isDead ); + player.DebugCamera(); + } + + CG_ModelAnimReal( ent, un1 ); +} + +/********************************************** + * + * CG_MoveWeapon + * Make the arms always animated + * + **********************************************/ + +void CG_MoveWeapon(int frametime) +{ + vec3_t offsetAngles; + vec3_t ratio; + float limit = 32.0f; + + CG_FakePredict(); + + if( fNoMove ) { + return; + } + + //if( cg->predictedPlayerState.pm_type == PM_NOCLIP ) { + // cgi.anim->currentVMPosOffset[2] = vm_offset_air_up->value; + //} + + internal_bobOffset = ( int )( frametime * bobMovementMultiplier ); + + //if(fLanding) + // goto _falling; + + /* FIXME: This can be improved */ + + VectorSubtract( cgi.anim->currentVMPosOffset, currentDeltaVMPosOffset2, cgi.anim->currentVMPosOffset ); + VectorAdd( cgi.anim->currentVMPosOffset, currentDeltaVMPosOffset, cgi.anim->currentVMPosOffset ); + + VectorCopy( currentDeltaVMPosOffset, currentDeltaVMPosOffset2 ); + + VectorSet( currentDeltaVMPosOffset, 0, 0, 0 ); + + /* Get the delta angles before getting the old view angles */ + deltaAngles[0] = ( cg->predictedPlayerState.viewangles[0] - oldAngles[0] ); + deltaAngles[1] = ( cg->predictedPlayerState.viewangles[1] - oldAngles[1] ); + deltaAngles[2] = ( cg->predictedPlayerState.viewangles[2] - oldAngles[2] ); + + /* Set the old angles */ + oldAngles[0] = cg->predictedPlayerState.viewangles[0]; + oldAngles[1] = cg->predictedPlayerState.viewangles[1]; + oldAngles[2] = cg->predictedPlayerState.viewangles[2]; + + /*if( deltaAngles[0] > limit ) { + deltaAngles[0] = limit; + } else if ( deltaAngles[0] < -limit ) { + deltaAngles[0] = -limit; + } + + if( deltaAngles[1] > limit ) { + deltaAngles[1] = limit; + } else if ( deltaAngles[1] < -limit ) { + deltaAngles[1] = -limit; + } + + if( deltaAngles[2] > limit ) { + deltaAngles[2] = limit; + } else if ( deltaAngles[2] < -limit ) { + deltaAngles[2] = -limit; + }*/ + + ratio[0] = abs( deltaAngles[0]/limit ); + ratio[1] = abs( deltaAngles[1]/limit ); + ratio[2] = abs( deltaAngles[2]/limit ); + + /*deltaAngles[0] /= limit; + deltaAngles[1] /= limit; + deltaAngles[2] /= limit;*/ + + /* Set the new angles for the viewmodel */ + newAngles[0] = -( deltaAngles[0] / 12 ); + newAngles[1] = -( deltaAngles[1] / 24 ); + newAngles[2] = -( deltaAngles[2] / 48 ); + + /* Get the future angles */ + offsetAngles[0] = currentVMAnglesOffset[0] + newAngles[0]; + offsetAngles[1] = currentVMAnglesOffset[1] + newAngles[1]; + offsetAngles[2] = currentVMAnglesOffset[2] + newAngles[2]; + + /* Set the viewmodel offset with a limit to prevent it + * from getting ugly + */ + if( offsetAngles[0] < 3.0 && offsetAngles[0] > -3.0 ) { + cgi.anim->currentVMPosOffset[0] += newAngles[0] / 2; + } + + if( offsetAngles[1] < 2.0 && offsetAngles[1] > -2.3 ) { + cgi.anim->currentVMPosOffset[1] += newAngles[1] / 2; + } + + if( offsetAngles[2] < 2.0 && offsetAngles[2] > -2.0 ) { + cgi.anim->currentVMPosOffset[2] += newAngles[2] / 2; + } + + /* If we're idling, animate the viewmodel by + * moving it + */ + if((cg->predictedPlayerState.velocity[0] == 0 && + cg->predictedPlayerState.velocity[1] == 0 && + cg->predictedPlayerState.velocity[2] == 0) || + cg->predictedPlayerState.pm_type == PM_NOCLIP) + { + if(deltaPosition[1] > 0.0005f) + deltaPosition[1] = 0.0005f; + else if(deltaPosition[1] < -0.0005f) + deltaPosition[1] = -0.0005f; + + if(deltaPosition[2] > 0.0002f) + deltaPosition[2] = 0.0002f; + else if(deltaPosition[2] < -0.0002f) + deltaPosition[2] = -0.0002f; + + if(cgi.anim->currentVMPosOffset[2] < 0.3 && !move_godown_z) + { + if(cgi.anim->currentVMPosOffset[2] <= 0.15) + { + deltaPosition[1] -= 0.0000004f * frametime; + deltaPosition[2] += 0.0000001f * frametime; + } + else + { + deltaPosition[1] += 0.0000004f * frametime; + deltaPosition[2] -= 0.00000015f * frametime; + } + cgi.anim->currentVMPosOffset[1] += deltaPosition[1] * frametime; + cgi.anim->currentVMPosOffset[2] += deltaPosition[2] * frametime; + } + else + { + move_godown_z = true; + + if(cgi.anim->currentVMPosOffset[2] > -0.3) + { + if(cgi.anim->currentVMPosOffset[2] >= -0.15) + { + deltaPosition[1] += 0.0000004f * frametime; + deltaPosition[2] -= 0.0000001f * frametime; + } + else + { + deltaPosition[1] -= 0.0000004f * frametime; + deltaPosition[2] += 0.00000015f * frametime; + } + cgi.anim->currentVMPosOffset[1] -= deltaPosition[1] * frametime; + cgi.anim->currentVMPosOffset[2] -= -deltaPosition[2] * frametime; //0.0001f * frametime; + } + else + move_godown_z = false; + } + } + +//_falling: + if( !cg->fpsOnGround && !fLanding && !fFell ) // && + //cg->predictedPlayerState.pm_type == PM_NORMAL) + { + fLanding = true; + } + else if( ( cg->fpsOnGround || fFell ) && fLanding ) // && cg->predictedPlayerState.pm_type == PM_NORMAL ) + { + if(landDownValue == 0) + { + if(previousVelocity[2] > -100) + { + landHeight = viewHeight; + goto _landCleanup; + } + else if(previousVelocity[2] <= -230 && previousVelocity[2] > -570) + { + landDownValue = -3.00f; + landDownDelayScale = 1.0f; + landDownViewScale = 0.16f; + } + else if(previousVelocity[2] <= -570 && previousVelocity[2] > -800) + { + landDownValue = -4.25f; + landDownDelayScale = 1.25f; + landDownViewScale = 0.25f; + } + else if(previousVelocity[2] <= -800) + { + landDownValue = -6.5f; + landDownDelayScale = 2.0f; + landDownViewScale = 0.33f; + } + } + + if(!fLandingUp) + { + if(landHeight == 0) + landHeight = viewHeight; + + // The weapon/view is going down + + fFell = true; + //cg->refdef.viewOrg[2] -= 0.009f * frametime; + /*viewHeight -= (int)((landDownViewScale + 0.02) * (float)frametime); + + if(viewHeight < 5) + viewHeight = 5;*/ + + viewHeight_mult -= ( ( landDownViewScale + 0.02f ) * 0.005f ) * frametime; + + //CG_SetViewHeight( viewHeight * viewHeight_mult ); + cgi.anim->currentVMPosOffset[2] -= 0.016f * frametime * landDownDelayScale; + + if(cgi.anim->currentVMPosOffset[2] < landDownValue) + fLandingUp = true; + } + else + { + //cg->refdef.viewOrg[2] += 0.009f * frametime; + /*viewHeight += (int)(landDownViewScale * (float)frametime); + + if(viewHeight > 82) + viewHeight = 82;*/ + + viewHeight_mult += ( landDownViewScale * 0.005f ) * frametime; + + //CG_SetViewHeight( viewHeight * viewHeight_mult ); + cgi.anim->currentVMPosOffset[2] += 0.011f * frametime * landDownDelayScale; + + if(cgi.anim->currentVMPosOffset[2] > 0.0f) + goto _landCleanup; + } + } + + previousVelocity[0] = cg->predictedPlayerState.velocity[0]; + previousVelocity[1] = cg->predictedPlayerState.velocity[1]; + previousVelocity[2] = cg->predictedPlayerState.velocity[2]; + + return; + +_landCleanup: + fLanding = false; + fLandingUp = false; + fFell = false; + cgi.anim->currentVMPosOffset[2] = 0.0f; + //viewHeight = landHeight; + viewHeight_mult = 1.0f; + landHeight = 0; + landDownValue = 0.0f; + landDownDelayScale = 0.0f; + landDownViewScale = 0.0f; +} + +/********************************************** +* +* CG_SetVMASpeed +* Sets the speed of a view model animation +* +**********************************************/ + +void CG_SetVMASpeed( const char *name, float speed ) +{ + vma_t *vma = CG_GetVMA( name ); + + vma->speed = speed; +} + +/********************************************** + * + * CG_HeightCheck + * + **********************************************/ +void CG_HeightCheck() +{ + pmove_t *pm = ( pmove_t * )*( uintptr_t * )0x30596AE4; + + pm->ps->speed = ( int )( ( float )cg->activeSnapshots[ 0 ].ps.speed * player.m_fMoveSpeedScale ); + + /*pm->ps->velocity[ 0 ] *= player.m_fMoveSpeedScale; + pm->ps->velocity[ 1 ] *= player.m_fMoveSpeedScale; + pm->ps->velocity[ 2 ] *= player.m_fMoveSpeedScale;*/ + + pm->mins[0] = -15.0f; + pm->mins[1] = -15.0f; + + pm->maxs[0] = 15.0f; + pm->maxs[1] = 15.0f; + + pm->mins[2] = 0.0f; + + if ( pm->ps->pm_type == PM_DEAD ) + { + pm->maxs[2] = 32.0f; + pm->ps->viewheight = 48; + + max_z = 32.0f; + viewHeight = 48; + } + else if ( ( pm->ps->pm_flags & 3 ) == 3 ) + { + pm->maxs[2] = 54.0f; + pm->ps->viewheight = 48; + + max_z = 54.0f; + viewHeight = 48; + } + else if ( pm->ps->pm_flags & 1 ) + { + pm->maxs[2] = 60.0f; + pm->ps->viewheight = 48; + + max_z = 60.0f; + viewHeight = 48; + } + else if ( pm->ps->pm_flags & 2 ) + { + pm->maxs[2] = 20.0f; + pm->ps->viewheight = 16; + + max_z = 20.0f; + viewHeight = 16; + } + else if ( pm->ps->pm_flags & 0x800 ) + { + pm->maxs[2] = 94.0f; + pm->mins[2] = 54.0f; + pm->ps->viewheight = 82; + + max_z = 94.0f; + viewHeight = 82; + } + else if ( pm->ps->pm_flags & 0x1000 ) + { + pm->maxs[2] = 94.0f; + pm->ps->viewheight = 52; + + max_z = 94.0f; + viewHeight = 52; + } + else + { + pm->maxs[2] = 94.0f; + pm->ps->viewheight = 82; + + /*pm->maxs[2] = max_z; + pm->ps->viewheight = viewHeight; + + CG_SetViewHeight( viewHeight );*/ + } + + /*if( fLanding ) + { + CG_SetViewHeight( pm->ps->viewheight * viewHeight_mult ); + return; + }*/ +} + +void CG_SetViewHeight(int newHeight) +{ + int i; + + pmove_t * pm = ( pmove_t * )*( uintptr_t * )0x30596AE4; + + if(cg->snap != NULL) + cg->snap->ps.viewheight = newHeight; + + if(cg->nextSnap != NULL) + cg->nextSnap->ps.viewheight = newHeight; + + for(i=0;i<2;i++) + cg->activeSnapshots[i].ps.viewheight = newHeight; + + cg->predictedPlayerState.viewheight = newHeight; + //viewHeight = newHeight; + pm->ps->viewheight = newHeight; +} + +const char *CG_GetCurrentWeaponName(void) +{ + return CG_ConfigString(cg->activeSnapshots->ps.activeItems[1] + 1748); +} + +const char *CG_GetCurrentWeaponPrefix(void) +{ + int index = VM_GetVMAnimPrefixString( ( char * )CG_GetCurrentWeaponName() ); + + return itemPrefix[index]; +} + +vma_t *CG_GetVMA( const char *name ) +{ + vma_t *vma; + + for( int i = 0; i < vmalist.NumObjects(); i++ ) + { + vma = vmalist[ i ]; + + if( vma->name.icmp( name ) == 0 ) { + return vma; + } + } + + vma = new vma_t; + + vma->name = name; + vma->speed = 1.0f; + + vmalist.AddObject( vma ); + + return vma; +} + +/********************************************** + * + * CG_GetVMAnimPrefixString + * + **********************************************/ + +/*int CG_GetVMAnimPrefixString(char * weapon_name) +{ + int i; + + if(weapon_name == NULL) + return 18; // unarmed + + for(i=1;i<255;i++) + { + if(Q_strcmpi(itemName[i], weapon_name) == 0) + return i; + } + + return 18; +}*/ + +/********************************************** + * + * CG_GetViewModelAnimName + * + **********************************************/ + +void CG_GetViewModelAnimName(char * Dest, char * Format, char * prefix, char * anim_name) +{ + if(!vm_fullanim) + sprintf(Dest, Format, prefix, anim_name); + else + strcpy(Dest, anim_name); +} + +/********************************************** + * + * CG_AddViewModelPrefix + * + **********************************************/ + +void CG_AddViewModelPrefix( const char * weapon_name, const char * prefix ) +{ + int i; + char *weapon_name_allocated; + char *weapon_prefix_allocated; + + for( i = 1; i < 255; i++ ) + { + /* Don't add this more than once... */ + if( itemPrefix[ i ] != NULL && strcmp( itemPrefix[ i ], prefix ) == 0 && strcmp( itemName[ i ], weapon_name ) == 0 ) + return; + } + + int weapon_name_length = strnlen( weapon_name, 255 ); + int weapon_prefix_length = strnlen( prefix, 255 ); + + /* Allocate the name so that it will be always present in the database */ + weapon_name_allocated = new char[ weapon_name_length + 1 ]; //( char * )malloc( weapon_name_length ); + weapon_prefix_allocated = new char[ weapon_prefix_length + 1 ]; //( char * )malloc( weapon_name_prefix ); + + strncpy( weapon_name_allocated, weapon_name, weapon_name_length ); + strncpy( weapon_prefix_allocated, prefix, weapon_prefix_length ); + + for( i = 1; i < 255; i++ ) + { + if( itemName[ i ] == NULL ) + { + itemName[ i ] = ( char * )weapon_name_allocated; + itemPrefix[ i ] = ( char * )weapon_prefix_allocated; + break; + } + } +} + +int CG_ViewModelAnimNum(char *name, qboolean bFullAnim) +{ + int num; + char anim_name[255]; + + if(!bFullAnim) + sprintf(anim_name, "%s_%s", CG_GetCurrentWeaponPrefix(), name); + + num = cgi.Anim_NumForName(cg->playerFPSModel, bFullAnim ? name : anim_name); + + if(num == -1) + cgi.Printf("Couldn't find view model animation %s\n", bFullAnim ? name : anim_name); + + return num; +} + +void CG_ViewModelAnim(char *name, qboolean bFullAnim) +{ + /*if(CG_ViewModelAnimNum(name, bFullAnim) == -1) + { + int i; + + if(_strcmpi(name, vm_anim_name) == 0) + { + currentviewModelAnim = VMA_IDLE; + currentviewModelAnimChanged = (currentviewModelAnimChanged + 1) & 3; + + strcpy(vm_anim_name, "idle"); + + vm_fullanim = false; + } + + if(cg->snap != NULL) + { + cg->snap->ps.iViewModelAnim = currentviewModelAnim; + cg->snap->ps.iViewModelAnimChanged = currentviewModelAnimChanged; + } + + if(cg->nextSnap != NULL) + { + cg->nextSnap->ps.iViewModelAnim = currentviewModelAnim; + cg->nextSnap->ps.iViewModelAnimChanged = currentviewModelAnimChanged; + } + + for(i=0;iactiveSnapshots[i].ps.iViewModelAnim = currentviewModelAnim; + cg->activeSnapshots[i].ps.iViewModelAnimChanged = currentviewModelAnimChanged; + } + + cg->predictedPlayerState.iViewModelAnim = currentviewModelAnim; + cg->predictedPlayerState.iViewModelAnimChanged = currentviewModelAnimChanged; + + cgi.anim->lastVMAnim = currentviewModelAnim; + cgi.anim->lastVMAnimChanged = currentviewModelAnimChanged; + + return; + }*/ + + currentviewModelAnim = cg->predictedPlayerState.iViewModelAnim; + currentviewModelAnimChanged = cg->predictedPlayerState.iViewModelAnimChanged; + + strncpy(vm_anim_name, name, sizeof(vm_anim_name)); + + if(bFullAnim) + vm_fullanim = true; + else + vm_fullanim = false; +} + +/********************************************** + * + * CG_ViewModelUninitialize + * + **********************************************/ + +void CG_ViewModelUninitialize(void) +{ + int i; + + /* Destroy the name to free some mem */ + for( i = 19; i < 255; i++ ) + { + if( itemName[ i ] != NULL ) + { + delete itemName[ i ]; + itemName[ i ] = NULL; + } + + if( itemPrefix[ i ] != NULL ) + { + delete itemPrefix[ i ]; + itemPrefix[ i ] = NULL; + } + } +} + +/********************************************** + * + * CG_ViewModelAnimCheck + * + **********************************************/ + +void CG_ViewModelAnimCheck( clientAnim_t * newAnim ) +{ + dtiki_t * tiki; + const char * item; + int index = 0, i; + int num; + + qboolean bAnimCheck = false; + qboolean bNewWeapon = false; + + char anim_name[ MAX_STRING_TOKENS ] = { 'i', 'd', 'l', 'e' }; + const char * lastVMAnim; + int slot = cgi.anim->currentVMAnimSlot; + + float weight = 0.0f, crossblend = 0.0f, time = 0.0f; + + if( slot < 0 ) { + slot = 0; + } + + tiki = ( dtiki_t * )newAnim->tiki; + + item = CG_ConfigString(cg->snap->ps.activeItems[1] + 1748); + + if( cgi.anim->lastEquippedWeaponStat != cg->snap->ps.stats[ STAT_EQUIPPED_WEAPON ] + || ( item != NULL && strcmp( cgi.anim->lastActiveItem, item ) != 0 ) ) + { + index = VM_GetVMAnimPrefixString( ( char * )item ); + cgi.anim->lastEquippedWeaponStat = cg->snap->ps.stats[ STAT_EQUIPPED_WEAPON ]; + + strcpy(cgi.anim->lastActiveItem, item); + cgi.anim->lastAnimPrefixIndex = index; + + bAnimCheck = true; + bNewWeapon = true; + } else { + index = cgi.anim->lastAnimPrefixIndex; + } + + if ( cgi.anim->lastVMAnim == -1 ) + { + sprintf( anim_name, "%s_idle", itemPrefix[index] ); + + num = cgi.Anim_Random( tiki, anim_name ); + + if ( num == -1 ) + { + num = cgi.Anim_Random( tiki, "idle" ); + + if( num == -1 ) { + num = 0; + } + + cgi.Printf("Warning: #1 Couldn't find view model animation %s\n", anim_name); + } + + cgi.anim->vmFrameInfo[slot].index = num; + + cgi.anim->vmFrameInfo[slot].time = 0.0f; + cgi.anim->vmFrameInfo[slot].weight = 1.0f; + cgi.anim->lastVMAnim = 0; + } + + if ( cg->snap->ps.iViewModelAnimChanged != cgi.anim->lastVMAnimChanged ) + { + bAnimCheck = true; + + cgi.anim->lastVMAnim = cg->snap->ps.iViewModelAnim; + cgi.anim->lastVMAnimChanged = cg->snap->ps.iViewModelAnimChanged; + } + + /*if(CG_ViewModelAnimNum(vm_anim_name, vm_fullanim) == -1) + { + cgi.anim->lastVMAnim = VMA_IDLE; + cgi.anim->lastVMAnimChanged = (cgi.anim->lastVMAnimChanged + 1) & 3; + }*/ + + if( !bAnimCheck ) { + goto _skip_anim_check; + } + + switch ( cgi.anim->lastVMAnim ) + { + case VMA_IDLE: + lastVMAnim = "idle"; + break; + + case VMA_CHARGE: + lastVMAnim = "charge"; + break; + + case VMA_FIRE: + lastVMAnim = "fire"; + break; + + case VMA_FIRE_SECONDARY: + lastVMAnim = "fire_secondary"; + break; + + case VMA_RECHAMBER: + lastVMAnim = "rechamber"; + break; + + case VMA_RELOAD: + lastVMAnim = "reload"; + break; + + case VMA_RELOAD_SINGLE: + lastVMAnim = "reload_single"; + break; + + case VMA_RELOAD_END: + lastVMAnim = "reload_end"; + break; + + case VMA_PULLOUT: + lastVMAnim = "pullout"; + break; + + case VMA_PUTAWAY: + lastVMAnim = "putaway"; + break; + + case VMA_LADDERSTEP: + lastVMAnim = "ladderstep"; + break; + + case VMA_ENABLE: + lastVMAnim = "enable"; + break; + + default: + lastVMAnim = vm_anim_name; + } + + if( !vm_fullanim ) { + sprintf( anim_name, "%s_%s", itemPrefix[ index ], lastVMAnim ); + } else { + strcpy( anim_name, lastVMAnim ); + } + + current_vma = CG_GetVMA( lastVMAnim ); + + crossblend = cgi.Anim_CrossblendTime( tiki, cgi.anim->vmFrameInfo[slot].index ); + time = cgi.anim->currentVMDuration * 0.001000000047497451f; + + if( time < crossblend ) + { + weight = time / crossblend; + + for ( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + float w; + + w = cgi.anim->vmFrameInfo[i].weight; + + if( w == 0.0f ) + continue; + + if( i == slot ) + cgi.anim->vmFrameInfo[i].weight = weight; + else + { + w = ( 1.0f - weight ) * cgi.anim->vmFrameInfo[i].weight; + cgi.anim->vmFrameInfo[i].weight = w; + } + } + } + + slot = ( slot + 1 ) % 16; + cgi.anim->currentVMAnimSlot = slot; + num = cgi.Anim_Random( tiki, anim_name ); + + if ( num < 0 ) + { + cgi.Printf( "Warning: #2 Couldn't find view model animation %s\n", anim_name ); + + if( !bNewWeapon ) { + goto _skip_anim_check; + } + else + { + if(!vm_fullanim) { + sprintf( anim_name, "%s_idle", itemPrefix[index], lastVMAnim ); + } else { + strcpy( anim_name, "idle" ); + } + + num = cgi.Anim_Random( tiki, anim_name ); + + if( num < 0 ) { + num = 0; + } + } + } + + cgi.anim->vmFrameInfo[slot].index = num; + + cgi.anim->vmFrameInfo[slot].time = 0.0f; + cgi.anim->vmFrameInfo[slot].weight = 1.0f; + cgi.anim->currentVMDuration = 0; + + crossblend = cgi.Anim_CrossblendTime( tiki, cgi.anim->vmFrameInfo[slot].index ); + + if ( crossblend == 0.0f ) + { + for( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + if ( i != slot ) + cgi.anim->vmFrameInfo[i].weight = 0.0f; + } + + cgi.anim->crossBlending = 0; + } + else + cgi.anim->crossBlending = 1; + +_skip_anim_check: + + cgi.anim->currentVMDuration += cg->frametime; + + if( cgi.anim->crossBlending ) + { + crossblend = cgi.Anim_CrossblendTime( tiki, cgi.anim->vmFrameInfo[slot].index ); + time = cgi.anim->currentVMDuration * 0.001000000047497451f; + + if( time >= crossblend ) + { + for( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + if ( slot != i ) + cgi.anim->vmFrameInfo[ i ].weight = 0.0f; + } + + cgi.anim->crossBlending = 0; + } + else + weight = time / crossblend; + } + + for( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + float w, frametime; + + w = cgi.anim->vmFrameInfo[ i ].weight; + + if ( w == 0.0f ) + { + newAnim->vmFrameInfo[ i + 7 ].index = 0; + newAnim->vmFrameInfo[ i + 7 ].time = 0.0f; + newAnim->vmFrameInfo[ i + 7 ].weight = 0.0f; + + continue; + } + + frametime = cgi.Anim_Frametime( tiki, cgi.anim->vmFrameInfo[ i ].index ); + + float speed; + + if( current_vma != NULL ) { + speed = current_vma->speed; + } else { + speed = 1.0f; + } + + cgi.anim->vmFrameInfo[ i ].time += ( ( float )cg->frametime * speed ) / 1000.0f; // *0.001000000047497451f; + + /*if( cgi.Anim_FlagsSkel( tiki, cgi.anim->vmFrameInfo[ i ].index ) & 0x20 ) { + cgi.anim->vmFrameInfo[ i ].time -= frametime; + } else { + cgi.anim->vmFrameInfo[ i ].time = frametime; + }*/ + + newAnim->vmFrameInfo[ i + 7 ].index = cgi.anim->vmFrameInfo[ i ].index; + newAnim->vmFrameInfo[ i + 7 ].time = cgi.anim->vmFrameInfo[ i ].time; + + if ( cgi.anim->crossBlending ) + { + if ( slot == i ) + newAnim->vmFrameInfo[i + 7].weight = weight; + else + newAnim->vmFrameInfo[i + 7].weight = (1.0f - weight) * cgi.anim->vmFrameInfo[i].weight; + } + else + newAnim->vmFrameInfo[i + 7].weight = 1.0f; + } + + // Loop if needed + if( cgi.anim->vmFrameInfo[ slot ].time > cgi.Anim_Time( tiki, cgi.anim->vmFrameInfo[slot].index ) && + cgi.anim->vmFrameInfo[ slot ].index == 0 && + cgi.Anim_Flags( tiki, cgi.anim->vmFrameInfo[ slot ].index ) & 0x20 ) + { + cgi.anim->lastVMAnimChanged = -1; + } + + *(uintptr_t *)&newAnim->lastActiveItem[60] = 0x3F800000u; +} diff --git a/code/cgame_hook/cgame/cg_viewmodelanim.h b/code/cgame_hook/cgame/cg_viewmodelanim.h new file mode 100644 index 00000000..9ffe6dae --- /dev/null +++ b/code/cgame_hook/cgame/cg_viewmodelanim.h @@ -0,0 +1,55 @@ +#ifndef __VIEWMODELANIM_H__ +#define __VIEWMODELANIM_H__ + +typedef struct vma_s { + str name; + float speed; +} vma_t; + +void CG_AddViewModelPrefix( const char * weapon_name, const char * prefix ); +void __stdcall CG_CalcViewBob( float value ); +void CG_ProcessDeltaAngles( void ); +void CG_OffsetFirstPersonView( refEntity_t *model, int a2 ); +void CG_OffsetThirdPersonView(); +void CG_OffsetThirdPersonViewReal(); +void CG_ModelAnim( centity_t *ent, int un1 ); +void CG_GetViewModelAnimName( char * Dest, char * Format, char * prefix, char * anim_name ); +char * CG_GetViewModelAnimPrefix(); +const char *CG_GetCurrentWeaponName( void ); +const char *CG_GetCurrentWeaponPrefix( void ); +vma_t *CG_GetVMA( const char *name ); +//int CG_GetVMAnimPrefixString(char * weapon_name); +void CG_HeightCheck( void ); +void CG_MatchEyesBone( refEntity_t * model ); +void CG_MoveWeapon( int frametime ); +void CG_SetVMASpeed( const char *vma, float speed ); +void CG_SetViewHeight( int newHeight ); +void CG_ViewInit( void ); +void CG_ViewModelAnim( char *name, qboolean bFullAnim ); +//char * CG_ViewModelAnimCheck(); +void CG_ViewModelAnimCheck( clientAnim_t * anim ); +void CG_ViewModelUninitialize( void ); + +extern uintptr_t CG_OffsetFirstPersonView_f; +extern uintptr_t CG_OffsetThirdPersonView_f; +extern uintptr_t CG_ModelAnim_f; + +extern vec3_t currentDeltaVMPosOffset; + +extern vec3_t oldAngles; +extern vec3_t deltaAngles; + +extern double bobMovementMultiplier; + +extern int internal_bobOffset; + +extern float max_z; +extern int viewHeight ; +extern qboolean modheightfloat_used ; + +extern char vm_anim_name[ MAX_STRING_CHARS ]; +extern qboolean vm_fullanim; + +extern float vm_time; + +#endif diff --git a/code/cgame_hook/cgame/cl_sound.cpp b/code/cgame_hook/cgame/cl_sound.cpp new file mode 100644 index 00000000..0c8c6f85 --- /dev/null +++ b/code/cgame_hook/cgame/cl_sound.cpp @@ -0,0 +1,100 @@ +#include "glb_local.h" +#include "cl_sound.h" + +uint8_t *bFadeSoundOrig = ( uint8_t * )0x007F7371; +qboolean *bFadeSoundTrack = ( qboolean * )0x007F7410; +/*DWORD *sound_frame = (DWORD*)0x00FF2A14; +float *fade_soundorig_frame = (float*)0x007F5D68; +float *fade_soundorig_time = (float*)0x007F5D50;*/ + +qboolean bFadeSound; +float sound_fade_startvol; +float sound_fade_time; +float sound_fade_minvol; + +qboolean bRestoreSound; +float sound_restore_startvol; +float sound_restore_time; +float sound_restore_maxvol; + +float *sound_global_volume = (float*)0x00551A4C; + +void CL_FadeSound2(float time, float min_volume) +{ + cgi.Printf("Called FadeSound with: %f %f\n", time, min_volume); + + if(bRestoreSound) + bRestoreSound = 0; + + if(*sound_global_volume < min_volume) + { + *sound_global_volume = min_volume; + return; + } + + bFadeSound = 1; + + sound_fade_startvol = *sound_global_volume; + sound_fade_time = time; + sound_fade_minvol = min_volume; +} + +void CL_RestoreSound(float time, float max_volume) +{ + cgi.Printf("Called RestoreSound with: %f %f\n", time, max_volume); + + if(bFadeSound || *bFadeSoundOrig) + { + *bFadeSoundOrig = false; + bFadeSound = 0; + } + + if(*sound_global_volume > max_volume) + { + *sound_global_volume = max_volume; + return; + } + + bRestoreSound = 1; + + sound_restore_startvol = *sound_global_volume; + sound_restore_time = time; + sound_restore_maxvol = max_volume; +} + +void CL_SoundProcessing(int frametime) +{ + float volume = *sound_global_volume; + + if(bFadeSound) + { + volume -= (1.0f-sound_fade_minvol)/sound_fade_time * frametime; + + *sound_global_volume = volume; + + if(*sound_global_volume < sound_fade_minvol) + { + *sound_global_volume = sound_fade_minvol; + bFadeSound = false; + *bFadeSoundTrack = false; + } + + *bFadeSoundTrack = true; + } + + if(bRestoreSound) + { + volume += (sound_restore_maxvol)/sound_restore_time * frametime; + + *sound_global_volume = volume; + + if(*sound_global_volume > sound_restore_maxvol) + { + *sound_global_volume = sound_restore_maxvol; + bRestoreSound = false; + *bFadeSoundTrack = false; + } + + *bFadeSoundTrack = true; + } +} diff --git a/code/cgame_hook/cgame/cl_sound.h b/code/cgame_hook/cgame/cl_sound.h new file mode 100644 index 00000000..d6066333 --- /dev/null +++ b/code/cgame_hook/cgame/cl_sound.h @@ -0,0 +1,10 @@ +#ifndef __CL_SOUND_H__ +#define __CL_SOUND_H__ + +extern float *sound_global_volume; + +void CL_FadeSound2(float time, float min_volume); +void CL_RestoreSound(float time, float max_volume); +void CL_SoundProcessing(int frametime); + +#endif // __CL_SOUND_H__ diff --git a/code/cgame_hook/cgamex86.cpp b/code/cgame_hook/cgamex86.cpp new file mode 100644 index 00000000..eecf4d87 --- /dev/null +++ b/code/cgame_hook/cgamex86.cpp @@ -0,0 +1,592 @@ +#include "glb_local.h" +#include "cgame/cg_hook.h" +#include "cgame/cg_hud.h" +#include "cgame/cg_servercmds.h" +#include "cgame/cg_viewmodelanim.h" +#include "cgame/cl_sound.h" +#include +#include +#include "archive.h" +#include "script/cplayer.h" +#include "level.h" +#include "script/clientgamecommand.h" +#include "ogl/opengl_api.h" +#include "cgamex86.h" + +#include "renderer/qfx_library.h" +#include "renderer/qfx_log.h" +#include "renderer/qfx_settings.h" +#include "renderer/qfx_opengl.h" +#include "renderer/qfx_renderer.h" +#include "renderer/qfx_shader.h" +#include "renderer/qfx_glprogs.h" + +#include +#include + +HMODULE hmod; +uintptr_t dwCGameBase = 0; + +qboolean inited = false; + +CG_CONFIGSTRING CG_ConfigString = (CG_CONFIGSTRING)0x30023FA7; +SPRINTF2 sprintf2 = (SPRINTF2)0x3005D214; +Q_STRCMPI Q_strcmpi = (Q_STRCMPI)0x3005DC34; + +typedef clientGameExport_t* (*pGetCGameAPI_spec)( void ); +pGetCGameAPI_spec pGetCGameAPI; + +pfnCG_CastFootShadow CG_CastFootShadow = ( pfnCG_CastFootShadow )0x30029AA4; + +CG_PlaySound_f CG_PlaySound = (CG_PlaySound_f)0x30015E0C; +CG_Trace_t CG_Trace = (CG_Trace_t)0x30031BCB; + +HINSTANCE hSystem86 = NULL; + +typedef void *( *pSystemMalloc_spec )( int size ); +extern pSystemMalloc_spec pSystemMalloc; + +typedef void( *pSystemFree_spec )( void *ptr ); +extern pSystemFree_spec pSystemFree; + +pSystemMalloc_spec pSystemMalloc = NULL; +pSystemFree_spec pSystemFree = NULL; + +clientGameExport_t cge; +clientGameImport_t cgi; +refImport_t ri; +refExport_t re; + +cg_t *cg; +cgs_t *cgs; + +centity_t *cg_entities; + +centity_t *cent = NULL; + +cvar_t *developer; +cvar_t *timescale; + +cvar_t *cg_debugview; +cvar_t *cg_hud; +cvar_t *cl_run; +cvar_t *fs_basepath; +cvar_t *r_anaglyph; +cvar_t *ui_hud; +cvar_t *vm_offset_air_up; +cvar_t *vm_offset_air_side; +cvar_t *vm_offset_air_front; +cvar_t *vm_offset_crouch_side; +cvar_t *vm_offset_vel_up; +cvar_t *vm_offset_vel_side; +cvar_t *vm_offset_vel_front; +cvar_t *archive_save; + +cvar_t *s_volume; + +cvar_t *cg_showopcodes; +cvar_t *cg_scriptcheck; +cvar_t *cl_scriptfiles; + +qboolean reborn; + +float *viewAngles = (float*)0x01100B14; + +int RenderedScene[5]; + +int cg_frametime; + +qboolean fUnloading = false; + +extern qboolean render_inited; +extern void R_Init(); + +regCvar_t cvars[] = { + { &developer, "developer", "0", CVAR_ARCHIVE }, + { &cg_debugview, "cg_debugview", "0", CVAR_ARCHIVE }, + { &cg_hud, "cg_hud", "1", 0 }, + { &cl_run, "cl_run", "1", CVAR_ARCHIVE }, + { &fs_basepath, "fs_basepath", "", CVAR_ARCHIVE }, + { &r_anaglyph, "r_anaglyph", "0", CVAR_ARCHIVE }, + { &ui_hud, "ui_hud", "1", 0 }, + { &vm_offset_air_up, "vm_offset_air_up", "-2.0", CVAR_ARCHIVE }, + { &vm_offset_air_side, "vm_offset_air_side", "0", CVAR_ARCHIVE }, + { &vm_offset_air_front, "vm_offset_air_front", "0", CVAR_ARCHIVE }, + { &vm_offset_crouch_side, "vm_offset_crouch_side", "1.5", CVAR_ARCHIVE }, + { &vm_offset_vel_up, "vm_offset_vel_up", "0", CVAR_ARCHIVE }, + { &vm_offset_vel_side, "vm_offset_vel_side", "0", CVAR_ARCHIVE }, + { &vm_offset_vel_front, "vm_offset_vel_front", "0", CVAR_ARCHIVE }, + { &archive_save, "archive_save", "0", CVAR_ARCHIVE }, + { &s_volume, "s_volume", "0.9", CVAR_ARCHIVE }, + { &cg_showopcodes, "cg_showopcodes", "0", CVAR_ARCHIVE }, + { &cg_scriptcheck, "cg_scriptcheck", "0", CVAR_ARCHIVE }, + { &cl_scriptfiles, "cl_scriptfiles", "0", CVAR_ARCHIVE }, + { NULL, NULL, NULL, NULL }, +}; + +//=================================================================== + +void QDECL Com_Error( int level, const char *error, ... ) { + va_list argptr; + char text[ 1024 ]; + + va_start( argptr, error ); + vsprintf( text, error, argptr ); + va_end( argptr ); + + cgi.Error( ( errorParm_t )level, "%s", text ); +} + +void QDECL Com_Printf( const char *msg, ... ) { + va_list argptr; + char text[ 1024 ]; + + va_start( argptr, msg ); + vsprintf( text, msg, argptr ); + va_end( argptr ); + + cgi.Printf( "%s", text ); +} + +void *( *CL_Malloc )( int size ); +void ( *CL_Free )( void *ptr ); + +void* CG_Malloc( int size ) +{ + return CL_Malloc( size ); +} + +void CG_Free( void *ptr ) +{ + int zoneId = *( int * )( ( unsigned char * )ptr - 4 ); + int size = ( int )( ( unsigned char * )ptr - 16 ); + + assert( ptr ); + + if( zoneId == 0xC057 ) + return; + + assert( zoneId == 0x2015 ); + if( zoneId != 0x2015 ) + return; + + assert( *( unsigned int * )( *( unsigned int * )size + size - 4 ) == 0x2015 ); + if( *( unsigned int * )( *( unsigned int * )size + size - 4 ) != 0x2015 ) + return; + + CL_Free( ptr ); +} + + +void dummy_Printf( char * format, ... ) +{ + +} + +centity_t * CG_GetEntity( int ent_num ) +{ + entityState_t * ce = NULL; + int i; + + for( i = 0; i < cg->activeSnapshots[ 0 ].numEntities; i++ ) + { + if( cg->activeSnapshots[ 0 ].entities[ i ].number == ent_num ) { + ce = &cg->activeSnapshots[ 0 ].entities[ i ]; + } + } + + return ( centity_t * )ce; +} + +void debug_save() +{ + Archiver arc; + + if( !arc.Create( "test.reborn" ) ) { + cgi.Printf( "error saving to file\n" ); + return; + } + + //Class::PrepareArchive( arc ); + + arc.Close(); + + cgi.Printf( "successfully saved\n" ); +} + +void debug_restore() +{ + Archiver arc; + + if( !arc.Read( "test.reborn" ) ) + { + cgi.Printf( "error restoring from file\n" ); + return; + } + + //Class::PrepareArchive( arc ); + + arc.Close(); + + cgi.Printf( "successfully restored\n" ); +} + +const char *CG_GetServerInfo() +{ + return cgs->gameState.stringData + + cgs->gameState.stringOffsets[ CS_SERVERINFO ]; +} + +const char *CG_GetServerVariable( const char *variable ) +{ + return Info_ValueForKey( CG_GetServerInfo(), variable ); +} + +qboolean script_loaded = false; + +void CG_DrawActiveFrame( int serverTime, int frametime, stereoFrame_t stereoView, qboolean demoPlayback ) +{ + if( !render_inited ) { + R_Init(); + } + + if( frametime < 1 ) + { + frametime = 1; + } + + level.setFrametime( frametime ); + level.setTime( serverTime ); + + //ScriptTimer::HandleTimer( ( float )frametime ); + + L_ProcessPendingEvents(); + + if( !script_loaded ) + { + script_loaded = true; + ClientGameCommandManager::Initialize(); + //ClientScript::AutoLoadScripts(); + } + + if( archive_save->integer == 1 ) + { + cgi.Cvar_Set( "archive_save", "0" ); + debug_save(); + } + else if( archive_save->integer == 2 ) + { + cgi.Cvar_Set( "archive_save", "0" ); + debug_restore(); + } + + cg_frametime = frametime; + + R_ProcessEffectsFade( frametime ); + + CL_SoundProcessing( frametime ); + CL_ProcessCEntities(); + + if( cg_debugview->integer ) + { + if( cg->snap != NULL ) { + cg->snap->ps.pm_flags = 0; + } + + if( cg->nextSnap != NULL ) { + cg->nextSnap->ps.pm_flags = 0; + } + + cg->activeSnapshots[0].ps.pm_flags = 0; + cg->activeSnapshots[1].ps.pm_flags = 0; + + cg->predictedPlayerState.pm_flags = 0; + } + + cge.CG_DrawActiveFrame( serverTime, frametime, stereoView, demoPlayback ); +} + +void CG_Shutdown(void) +{ + //CG_ViewModelUninitialize(); + + ClientGameCommandManager::CleanUp(); + + cge.CG_Shutdown(); + + /* Unload the original cgamex86mohaa to prevent crashes because of the + * replaced instructions + */ + //FreeLibrary( hmod ); +} + +void R_RenderScene( refDef_t *fd ); + +int R_CvarSize( void ); + +void CG_InitCvars( void ) +{ + int i; + + for ( i = 0 ; i < sizeof( cvars ) / sizeof( cvars[0] ) ; i++ ) + { + if( cvars[i].cvar == NULL ) { + continue; + } + + *cvars[i].cvar = cgi.Cvar_Get( cvars[i].name, cvars[i].value, cvars[i].flags ); + } + + for ( i = 0 ; i < R_CvarSize() ; i++ ) + { + if( r_cvars[i].cvar == NULL ) { + continue; + } + + *r_cvars[i].cvar = cgi.Cvar_Get( r_cvars[i].name, r_cvars[i].value, r_cvars[i].flags ); + } +} + +float Anim_FrameTime( dtiki_t *tiki, int animNum ) +{ + float time = cgi.Anim_Frametime( tiki, animNum ); + + time /= 2.f; + + return time; +} + +int GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) +{ + int result = cgi.GetSnapshot( snapshotNumber, snapshot ); + + return result; +} + +void CG_Init( clientGameImport_t *imported, int serverMessageNum, int serverCommandSequence, int clientNum ) +{ + CL_Malloc = imported->Malloc; + imported->Malloc = CG_Malloc; + + CL_Free = imported->Free; + imported->Free = CG_Free; + + memcpy( &cgi, imported, sizeof( cgi ) ); + + imported->R_RenderScene = R_RenderScene; + imported->R_AddRefEntityToScene = R_AddRefEntityToScene; + imported->R_AddRefSpriteToScene = R_AddRefSpriteToScene; + imported->GetSnapshot = GetSnapshot; + + //cvars + menu = cgi.Cvar_Get( "menu", "0", CVAR_ARCHIVE ); + stats = cgi.Cvar_Get( "stats", "0", CVAR_ARCHIVE ); + + timescale = cgi.Cvar_Get( "timescale", "1.0", CVAR_CHEAT ); + + CG_ViewInit(); + + huddrawExtends = (hdExtend_t*)malloc(sizeof(hdExtend_t) * 256); + memset(huddrawExtends, 0, sizeof(huddrawExtends) * 256); + + CG_InitCvars(); + + Director.Reset(); + L_InitEvents(); + + world = new World; + player.SetTargetName( "player" ); + + cge.CG_Init( imported, serverMessageNum, serverCommandSequence, clientNum ); + + char buffer[ MAX_QPATH ]; + + strcpy( buffer, cgs->mapName + 5 ); + + COM_StripExtension( buffer, buffer, sizeof( buffer ) ); + + try + { + Director.ExecuteThread( "clientscripts/maps/" + str( buffer ) + ".ccr", "" ); + } + catch( ScriptException& exc ) + { + glbs.Printf( "%s\n", exc.string.c_str() ); + } + + level.AddWaitTill( "prespawn" ); + + level.Unregister( "prespawn" ); + //level.prespawned = true; + + const char *value = CG_GetServerVariable( "sv_reborn" ); + + if( value != NULL && isdigit( *value ) ) { + reborn = !!atoi( value ); + } else { + reborn = false; + } + + R_ProcessVision( buffer, 0.f ); + + level.AddWaitTill( "spawn" ); + + level.Unregister( "spawn" ); + + Director.Reset( false ); + + //level.spawned = true; + +/* char tmp[ MAX_STRINGCHARS ]; + int intValue; + + Archiver arc; + + if( !arc.FileExists( "main/test.reborn" ) ) + { + arc.Save( "main/test.reborn" ); + } else { + arc.Load( "main/test.reborn" ); + } + + if( arc.Loading() ) { + arc.RemoveSave(); + } + + ClientObject::PrepareArchive( arc ); + + arc.Dump(); + arc.Close();*/ +} + +qboolean CG_ConsoleCommand( void ) +{ + char *cmd = cgi.Argv( 0 ); + ScriptThreadLabel *label = m_scriptCmds.findKeyValue( cmd ); + + if( label != NULL ) + { + Event event; + + for( int i = 1; i < cgi.Argc(); i++ ) + { + event.AddString( cgi.Argv( i ) ); + } + + label->Execute( NULL, event ); + } + + return cge.CG_ConsoleCommand(); +} + +/* +================ +GetCGameAPI + +The only exported function from this module +================ +*/ +clientGameExport_t* GetCGameAPI( void ) +{ + + clientGameExport_t *exp = pGetCGameAPI(); + + memcpy( &cge, exp, sizeof(cge) ); + + exp->CG_Init = CG_Init; + + //exp->CG_ParseCGMessage = CG_ParseCGMessage; + exp->CG_Draw2D = CG_Draw2D; + exp->CG_DrawActiveFrame = CG_DrawActiveFrame; + exp->CG_Shutdown = CG_Shutdown; + exp->CG_ParseCGMessage = CG_ParseCGMessage2; + + exp->CG_ConsoleCommand = CG_ConsoleCommand; + + //exp->CG_Command_ProcessFile = CG_Command_ProcessFile; + + return exp; + +} + +void fuck_cgi_printf_crash_noob_shit( const char *fmt, ... ) +{ + +} + +BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) +{ + char path[MAX_PATH]; + int i; + + switch ( ul_reason_for_call ) + { + case DLL_PROCESS_ATTACH: + if( inited ) { + return TRUE; + } + + inited = true; + + /*GetModuleFileName( NULL, path, sizeof(path) ); + + for ( i=strlen(path); i>0; i-- ) + { + if (path[i] == '\\') + { + path[i+1] = 0; + break; + } + }*/ + + hmod = LoadLibrary( "main\\cgamex86mohaa.dll" ); + + if ( !hmod ) + { + printf( "LoadLibrary failed: \"0x%lX\"\n", GetLastError() ); + exit( GetLastError() ); + } + + pGetCGameAPI = (pGetCGameAPI_spec)GetProcAddress( hmod, "GetCGameAPI" ); + + dwCGameBase = PtrToUlong( hmod ); + + uid = ( uidef_t * )0xBF3B78; + keys = ( qkey_t * )0x12F4B20; + cg = ( cg_t * )( dwCGameBase + 0x2B7DC0 ); + cgs = ( cgs_t * )( dwCGameBase + 0x2A5460 ); + cg_entities = ( centity_t * )( dwCGameBase + 0x3FDA00 ); + + /*RenderedScene[0] = (int *)0x01313938; + RenderedScene[1] = (int *)0x01313940; + RenderedScene[2] = (int *)0x01313934; + RenderedScene[3] = (int *)0x01313950; + RenderedScene[4] = (int *)0x0131394C;*/ + + hSystem86 = LoadLibraryA( "system86.dll" ); + + pSystemMalloc = (pSystemMalloc_spec)GetProcAddress( hSystem86, "MemoryMalloc" ); + pSystemFree = ( pSystemFree_spec )GetProcAddress( hSystem86, "MemoryFree" ); + + CG_HookClientGame(); + + break; + + case DLL_PROCESS_DETACH: + fUnloading = true; + // Remove the OpenGL hooks when disconnecting/changing maps + R_Shutdown(); + FreeLibrary( hmod ); + + break; + } + + return TRUE; +} + +void loadDll() +{ + if ( !inited ) { + DllMain( GetModuleHandle( 0 ), DLL_PROCESS_ATTACH, NULL ); + } +} diff --git a/code/cgame_hook/cgamex86.h b/code/cgame_hook/cgamex86.h new file mode 100644 index 00000000..085be902 --- /dev/null +++ b/code/cgame_hook/cgamex86.h @@ -0,0 +1,788 @@ +#ifndef __CGAMEX86_H__ +#define __CGAMEX86_H__ + +#include "hook.h" +#include "renderer_api.h" +#include "../game/bg_public.h" + +#define MAX_CVARS 255; + +typedef struct { + cvar_t **cvar; + const char *name; + const char *value; + int flags; +} regCvar_t; + +typedef struct centity_s +{ + entityState_t currentState; + entityState_t nextState; + int teleported; + int interpolate; + int currentValid; + int miscTime; + int snapShotTime; + int errorTime; + vec3_t errorOrigin; + vec3_t errorAngles; + int extrapolated; + vec3_t rawOrigin; + vec3_t rawAngles; + vec3_t beamEnd; + vec3_t lerpOrigin; + vec3_t lerpAngles; + int tikiLoopSound; + float tikiLoopSoundVolume; + float tikiLoopSoundMinDist; + float tikiLoopSoundMaxDist; + float tikiLoopSoundPitch; + int tikiLoopSoundFlags; + vec4_t color; + vec4_t clientColor; + int clientFlags; + int splashLastSpawnTime; + int splashStillCount; + vec4_t boneQuat[ 5 ]; + float animLastTimes[ MAX_FRAMEINFOS ]; + int animLast[ MAX_FRAMEINFOS ]; + int animLastWeight; + int usageIndexLast; + int footOnGround_Right; + int footOnGround_Left; + int nextLandTime; + +} centity_t; + +typedef void ( __stdcall *CG_PlaySound_f )( char *sound_name, float *origin, int channel, + float volume, float min_distance, float pitch, int argstype ); +extern CG_PlaySound_f CG_PlaySound; + +typedef void ( *CG_Trace_t )(trace_t *results, const vec3_t start, const vec3_t mins , + const vec3_t maxs, const vec3_t end, int headnode, int brushmask, int cylinder, + qboolean bClipEntities, char *description); +extern CG_Trace_t CG_Trace; + +void CG_ParseCGMessage2( void ); + +class CPlayer; + +extern uintptr_t dwCGameBase; +extern pmove_t * pm; + +extern cvar_t *developer; +extern cvar_t *timescale; + +extern cvar_t *cg_debugview; +extern cvar_t *cg_hud; +extern cvar_t *cl_run; +extern cvar_t *fs_basepath; +extern cvar_t *r_anaglyph; +extern cvar_t *ui_hud; +extern cvar_t *vm_offset_air_up; +extern cvar_t *vm_offset_air_side; +extern cvar_t *vm_offset_air_front; +extern cvar_t *vm_offset_crouch_side; +extern cvar_t *vm_offset_vel_up; +extern cvar_t *vm_offset_vel_side; +extern cvar_t *vm_offset_vel_front; + +extern cvar_t *s_volume; + +extern cvar_t *cg_showopcodes; +extern cvar_t *cg_scriptcheck; +extern cvar_t *cl_scriptfiles; + +extern regCvar_t r_cvars[]; + +class Entity; + +extern qboolean reborn; + +centity_t * CG_GetEntity(int ent_num); +Entity *R_SpawnModel( const char *model, vec3_t origin, vec3_t angles ); + +const char *CG_GetServerInfo(); +const char *CG_GetServerVariable( const char *variable ); + +#define ITEM_MAX_NAME 255 +#define ITEM_MAX_PREFIX 255 // 255 is enough for a list of new items + +typedef struct serverSound_s +{ + vec3_t origin; + int entityNumber; + int channel; + short int soundIndex; + float volume; + float minDist; + float maxDist; + float pitch; + qboolean stopFlag; + qboolean streamed; + +} serverSound_t; + +typedef struct snapshot_s +{ + int snapFlags; + int ping; + int serverTime; + unsigned char areaMask[ 32 ]; + playerState_t ps; + int numEntities; + entityState_t entities[ 1024 ]; + int numServerCommands; + int serverCommandSequence; + int numberOfSounds; + serverSound_t sounds[ 64 ]; + +} snapshot_t; + +typedef struct baseShader_s +{ + char shader[ MAX_QPATH ]; + int surfaceFlags; + int contentFlags; + +} baseShader_t; + +typedef struct clientInfo_s +{ + int team; + +} clientInfo_t; + +typedef struct objective_s +{ + char text[ MAX_STRING_CHARS ]; + int flags; + +} objective_t; + +typedef struct rain_s +{ + float density; + float speed; + int speedVary; + int slant; + float length; + float minDist; + float width; + char shader[ 16 ][ MAX_STRING_CHARS ]; + int numShaders; + +} rain_t; + +typedef struct cgs_s +{ + gameState_t gameState; + glconfig_t glConfig; + float screenXScale; + float screenYScale; + float screenXBias; + int serverCommandSequence; + int processedSnapshotNum; + qboolean localServer; + int levelStartTime; + int matchEndTime; + int serverLagTime; + int gameType; + int dmFlags; + int teamFlags; + int fragLimit; + int timeLimit; + int maxClients; + int cinematic; + char mapName[MAX_QPATH]; + int modelDraw[MAX_MODELS]; + int soundPrecache[MAX_SOUNDS]; + int numInlineModels; + int inlineDrawModel[MAX_MODELS]; + vec3_t inlineModelMidpoints[MAX_MODELS]; + media_t media; + +} cgs_t; + +typedef struct cg_s +{ + int clientFrame; + int clientNum; + int demoPlayback; + int levelShot; + int latestSnapshotNum; + int latestSnapshotTime; + snapshot_t *snap; + snapshot_t *nextSnap; + snapshot_t activeSnapshots[ 2 ]; + float frameInterpolation; + int thisFrameTeleport; + int nextFrameTeleport; + int nextFrameCameraCut; + int frametime; + int time; + int physicsTime; + int renderingThirdPerson; + int hyperSpace; + playerState_t predictedPlayerState; + int validPPS; + int predictedErrorTime; + vec3_t predictedError; + int weaponCommand; + int weaponCommandSend; + vec3_t autoAngles; + vec3_t autoAxis[3]; + vec3_t autoAnglesSlow; + vec3_t autoAxisSlow[3]; + vec3_t autoAnglesFast; + vec3_t autoAxisFast[3]; + refDef_t refdef; + vec3_t playerHeadPos; + vec3_t refdefViewAngles; + vec3_t currentViewPos; + vec3_t currentViewAngles; + float currentViewHeight; + float currentViewBobPhase; + float currentViewBobAmp; + dtiki_t *lastPlayerWorldModel; + dtiki_t *playerFPSModel; + int playerFPSModelHandle; + int fpsModelLastFrame; + int fpsOnGround; + dtiki_t *alliedPlayerModel; + int alliedPlayerModelHandle; + dtiki_t *axisPlayerModel; + int axisPlayerModelHandle; + vec3_t offsetViewAngles; + vec3_t lastHeadAngles; + vec3_t lastViewAngles; + vec3_t eyeOffsetMax; + float eyeOffsetFrac; + vec3_t soundOrg; + vec3_t soundAxis[3]; + vec3_t cameraOrigin; + vec3_t cameraAngles; + float cameraFov; + float zoomSensitivity; + int intermissionDisplay; + int scoresRequestTime; + int showScores; + char scoresMenuName[256]; + int instaMessageMenu; + int centerPrintTime; + int centerPrintCharWidth; + int centerPrintY; + char centerPrint[1024]; + int centerPrintLines; + int matchStartTime; + refEntity_t testModelEntity; + char testModelName[MAX_QPATH]; + int testGun; + float farplaneDistance; + float farplaneColor[3]; + int farplaneCull; + int skyPortal; + float skyAlpha; + vec3_t skyOrigin; + vec3_t skyAxis[3]; + vec2_t viewKick; + float viewKickRecenter; + float viewKickMinDecay; + float viewKickMaxDecay; + objective_t objectives[ MAX_OBJECTIVES ]; + float objectivesAlphaTime; + float objectivesBaseAlpha; + float objectivesDesiredAlpha; + float objectivesCurrentAlpha; + rain_t rain; + clientInfo_t clientinfo[MAX_CLIENTS]; + +} cg_t; + +typedef struct uidef_s +{ + int time; + int vidWidth; + int vidHeight; + int mouseX; + int mouseY; + unsigned int mouseFlags; + qboolean uiHasMouse; + +} uidef_t; + +// +// cl_input +// +typedef struct { + int down[2]; // key nums holding it down + unsigned downtime; // msec timestamp + unsigned msec; // msec down this frame if both a down and up happened + qboolean active; // current state + qboolean wasPressed; // set when down, not cleared when up +} kbutton_t; + +typedef struct qkey_s +{ + qboolean down; + int repeats; + char *binding; + +} qkey_t; + +typedef struct fontHandle_s +{ + int bla; +} fontHandle_t; + +typedef struct clientAnim_s +{ + frameInfo_t vmFrameInfo[MAX_FRAMEINFOS]; + int lastVMAnim; + int lastVMAnimChanged; + int currentVMAnimSlot; + int currentVMDuration; + qboolean crossBlending; + int lastEquippedWeaponStat; + char lastActiveItem[80]; + int lastAnimPrefixIndex; + vec3_t currentVMPosOffset; + unsigned char un1[72]; + dtiki_t * tiki; + +} clientAnim_t; + +typedef struct hdElement_s +{ + qhandle_t shader; + char shaderName[MAX_QPATH]; + int x; + int y; + int width; + int height; + vec4_t color; + int horizontalAlign; + int verticalAlign; + qboolean virtualScreen; + char string[MAX_STRING_CHARS]; + char fontName[MAX_QPATH]; + fontHeader_t *font; + +} hdElement_t; + +typedef struct stopWatch_s +{ + int startTime; + int endTime; + +} stopWatch_t; + +typedef enum keyNum_e +{ + K_TAB = 9, + K_ENTER = 13, + K_ESCAPE = 27, + K_SPACE = 32, + + K_BACKSPACE = 127, + K_COMMAND, + K_CAPSLOCK, + K_POWER, + K_PAUSE, + K_UPARROW, + K_DOWNARROW, + K_LEFTARROW, + K_RIGHTARROW, + K_LALT, + K_LCTRL, + K_LSHIFT, + K_RALT, + K_RCTRL, + K_RSHIFT, + K_INS, + K_DEL, + K_PGDN, + K_PGUP, + K_HOME, + K_END, + K_F1, + K_F2, + K_F3, + K_F4, + K_F5, + K_F6, + K_F7, + K_F8, + K_F9, + K_F10, + K_F11, + K_F12, + K_F13, + K_F14, + K_F15, + K_KPHOME, + K_KPUPARROW, + K_KPPGUP, + K_KPLEFTARROW, + K_KP5, + K_KPRIGHTARROW, + K_KPEND, + K_KPDOWNARROW, + K_KPPGDN, + K_KPENTER, + K_KPINS, + K_KPDEL, + K_KPSLASH, + K_KPMINUS, + K_KPPLUS, + K_KPNUMLOCK, + K_KPSTAR, + K_KPEQUALS, + K_MOUSE1, + K_MOUSE2, + K_MOUSE3, + K_MOUSE4, + K_MOUSE5, + K_MWHEELDOWN, + K_MWHEELUP, + K_JOY1, + K_JOY2, + K_JOY3, + K_JOY4, + K_JOY5, + K_JOY6, + K_JOY7, + K_JOY8, + K_JOY9, + K_JOY10, + K_JOY11, + K_JOY12, + K_JOY13, + K_JOY14, + K_JOY15, + K_JOY16, + K_JOY17, + K_JOY18, + K_JOY19, + K_JOY20, + K_JOY21, + K_JOY22, + K_JOY23, + K_JOY24, + K_JOY25, + K_JOY26, + K_JOY27, + K_JOY28, + K_JOY29, + K_JOY30, + K_JOY31, + K_JOY32, + K_AUX1, + K_AUX2, + K_AUX3, + K_AUX4, + K_AUX5, + K_AUX6, + K_AUX7, + K_AUX8, + K_AUX9, + K_AUX10, + K_AUX11, + K_AUX12, + K_AUX13, + K_AUX14, + K_AUX15, + K_AUX16, + K_LWINKEY, + K_RWINKEY, + K_MENUKEY, + K_LASTKEY + +} keyNum_t; + +// Dump memory to a file then read it +typedef struct tmpArchive +{ + +} tmpArchive; + +typedef struct profVar_s +{ + int start; + int clockCycles; + int calls; + float time; + float totTime; + float avgTime; + float low; + float high; + +} profVar_t; + +typedef struct profCGame_s +{ + profVar_t CG_AddCEntity; + profVar_t CG_DrawActiveFrame; + profVar_t CG_AddPacketEntities; + profVar_t CG_DrawActive; + profVar_t CG_EntityShadow; + profVar_t CG_Rain; + profVar_t CG_AddBeams; + profVar_t CG_ModelAnim; + profVar_t CG_ProcessSnapshots; + profVar_t CProbe1; + profVar_t CProbe2; + profVar_t CProbe3; + +} profCGame_t; + +typedef struct clientGameImport_s +{ + int apiVersion; + + void ( *Printf )( const char *fmt, ... ); + void ( *DPrintf )( const char *fmt, ... ); + void ( *DebugPrintf )( const char *fmt, ... ); + void * ( *Malloc )( size_t size ); + void ( *Free )( void *ptr ); + void ( *Error )( errorParm_t code, const char *fmt, ... ); + int ( *Milliseconds )( ); + char * ( *LV_ConvertString )( const char *string ); + cvar_t * ( *Cvar_Get )( const char *varName, const char *varValue, int varFlags ); + void ( *Cvar_Set )( const char *varName, const char *varValue ); + int ( *Argc )( ); + char * ( *Argv )( int arg ); + char * ( *Args )( ); + void ( *AddCommand )( char *cmdName, xcommand_t cmdFunction ); + void ( *Cmd_Stuff )( const char *text ); + void ( *Cmd_Execute )( cbufExec_t execWhen, char *text ); + void ( *Cmd_TokenizeString )( char *textIn ); + int ( *FS_ReadFile )( const char *qpath, void **buffer, qboolean bSilent ); + void ( *FS_FreeFile )( void *buffer ); + int ( *FS_WriteFile )( const char *qpath, void *buffer, int size ); + void ( *FS_WriteTextFile )( const char *qpath, void *buffer, int size ); + void ( *SendConsoleCommand )( const char *text ); + int ( *MSG_ReadBits )( int bits ); + int ( *MSG_ReadChar )( ); + int ( *MSG_ReadByte )( ); + int ( *MSG_ReadSVC )( ); + int ( *MSG_ReadShort )( ); + int ( *MSG_ReadLong )( ); + float ( *MSG_ReadFloat )( ); + char * ( *MSG_ReadString )( ); + char * ( *MSG_ReadStringLine )( ); + float ( *MSG_ReadAngle8 )( ); + float ( *MSG_ReadAngle16 )( ); + void ( *MSG_ReadData )( void *data, int len ); + float ( *MSG_ReadCoord )( ); + void ( *MSG_ReadDir )( vec3_t dir ); + void ( *SendClientCommand )( const char *text ); + void ( *CM_LoadMap )( char *name ); + clipHandle_t ( *CM_InlineModel )( int index ); + int ( *CM_NumInlineModels )( ); + int ( *CM_PointContents )( vec3_t point, clipHandle_t model ); + int ( *CM_TransformedPointContents )( vec3_t point, clipHandle_t model, vec3_t origin, vec3_t angles ); + void ( *CM_BoxTrace )( trace_t *results, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int model, int brushMask, int cylinder ); + void ( *CM_TransformedBoxTrace )( trace_t *results, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int model, int brushMask, vec3_t origin, vec3_t angles, int cylinder ); + clipHandle_t ( *CM_TempBoxModel )( vec3_t mins, vec3_t maxs, int contents ); + void ( *CM_PrintBSPFileSizes )( ); + qboolean ( *CM_LeafInPVS )( int leaf1, int leaf2 ); + int ( *CM_PointLeafnum )( vec3_t p ); + int ( *R_MarkFragments )( int numPoints, vec3_t *points, vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared ); + int ( *R_MarkFragmentsForInlineModel )( clipHandle_t bmodel, vec3_t vAngles, vec3_t vOrigin, int numPoints, vec3_t *points, vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared ); + void ( *R_GetInlineModelBounds )( int index, vec3_t mins, vec3_t maxs ); + void ( *R_GetLightingForDecal )( vec3_t light, vec3_t facing, vec3_t origin ); + void ( *R_GetLightingForSmoke )( vec3_t light, vec3_t origin ); + int ( *R_GatherLightSources )( vec3_t pos, vec3_t *lightPos, vec3_t *lightIntensity, int maxLights ); + void ( *S_StartSound )( vec3_t origin, int entNum, int entChannel, sfxHandle_t sfxHandle, float volume, float minDist, float pitch, float maxDist, int streamed ); + void ( *S_StartLocalSound )( char *soundName, int channel ); + void ( *S_StopSound )( int entNum, int channel ); + void ( *S_ClearLoopingSounds )( ); + void ( *S_AddLoopingSound )( vec3_t origin, vec3_t velocity, sfxHandle_t sfxHandle, float volume, float minDist, float maxDist, float pitch, int flags ); + void ( *S_Respatialize )( int entityNum, vec3_t head, vec3_t axis[3] ); + void ( *S_BeginRegistration )( ); + sfxHandle_t ( *S_RegisterSound )( char *name, int streamed, qboolean forceLoad ); + void ( *S_EndRegistration )( ); + void ( *S_UpdateEntity )( int entityNum, vec3_t origin, vec3_t velocity, qboolean useListener ); + void ( *S_SetReverb )( int reverbType, float reverbLevel ); + void ( *S_SetGlobalAmbientVolumeLevel )( float volume ); + float ( *S_GetSoundTime )( sfxHandle_t handle ); + int ( *S_ChannelNameToNum )( char *name ); + char * ( *S_ChannelNumToName )( int channel ); + int ( *S_IsSoundPlaying )( int channelNumber, char *name ); + void ( *MUSIC_NewSoundtrack )( char *name ); + void( *MUSIC_UpdateMood )( music_mood_t current, music_mood_t fallback ); + void ( *MUSIC_UpdateVolume )( float volume, float fadeTime ); + float * ( *get_camera_offset )( qboolean *lookActive, qboolean *resetView ); + void ( *R_ClearScene )( ); + void ( *R_RenderScene )( refDef_t *fd ); + void ( *R_LoadWorldMap )( char *name ); + void ( *R_PrintBSPFileSizes )( ); + int ( *MapVersion )( ); + int ( *R_MapVersion )( ); + qhandle_t ( *R_RegisterModel )( const char *name ); + qhandle_t ( *R_SpawnEffectModel )( const char *name, vec3_t pos, vec3_t axis[3] ); + qhandle_t ( *R_RegisterServerModel )( const char *name ); + void ( *R_UnregisterServerModel )( qhandle_t hModel ); + qhandle_t ( *R_RegisterSkin )( const char *name ); + qhandle_t ( *R_RegisterShader )( const char *name ); + qhandle_t ( *R_RegisterShaderNoMip )( const char *name ); + void ( *R_AddRefEntityToScene )( refEntity_t *ent, int parentEntityNumber ); + void ( *R_AddRefSpriteToScene )( refEntity_t *ent ); + void ( *R_AddLightToScene )( vec3_t org, float intensity, float r, float g, float b, dlightType_t type ); + qboolean ( *R_AddPolyToScene )( qhandle_t hShader, int numVerts, polyVert_t *verts, int renderFx ); + void ( *R_AddTerrainMarkToScene )( int terrainIndex, qhandle_t hShader, int numVerts, polyVert_t *verts, int renderFx ); + void ( *R_SetColor )( vec4_t rgba ); + void ( *R_DrawStretchPic )( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); + fontHeader_t * ( *R_LoadFont )( const char *name ); + void ( *R_DrawString )( fontHeader_t *font, const char *text, float x, float y, int maxLen, qboolean virtualScreen ); + refEntity_t * ( *R_GetRenderEntity )( int entityNumber ); + void ( *R_ModelBounds )( clipHandle_t model, vec3_t mins, vec3_t maxs ); + float ( *R_ModelRadius )( qhandle_t handle ); + float ( *R_Noise )( float x, float y, float z, float t ); + void ( *R_DebugLine )( vec3_t start, vec3_t end, float r, float g, float b, float alpha ); + baseShader_t * ( *GetShader )( int shaderNum ); + void ( *R_SwipeBegin )( float thistime, float life, qhandle_t shader ); + void ( *R_SwipePoint )( vec3_t point1, vec3_t point2, float time ); + void ( *R_SwipeEnd )( ); + int ( *R_GetShaderWidth )( qhandle_t hShader ); + int ( *R_GetShaderHeight )( qhandle_t hShader ); + void ( *R_DrawBox )( float x, float y, float w, float h ); + void ( *GetGameState )( gameState_t *gameState ); + int ( *GetSnapshot )( int snapshotNumber, snapshot_t *snapshot ); + int ( *GetServerStartTime )( ); + void ( *SetTime )( float time ); + void ( *GetCurrentSnapshotNumber )( int *snapshotNumber, int *serverTime ); + void ( *GetGlconfig )( glconfig_t *glConfig ); + qboolean ( *GetParseEntityState )( int parseEntityNumber, entityState_t *state ); + int ( *GetCurrentCmdNumber )( ); + qboolean ( *GetUserCmd )( int cmdNumber, usercmd_t *userCmd ); + qboolean ( *GetServerCommand )( int serverCommandNumber, qboolean differentServer ); + qboolean ( *Alias_Add )( char *alias, char *name, char *parameters ); + qboolean ( *Alias_ListAdd )( AliasList_t *list, const char *alias, const char *name, const char *parameters ); + char * ( *Alias_FindRandom )( const char *alias, AliasListNode_t **ret ); + char * ( *Alias_ListFindRandom )( AliasList_t *list, const char *alias, AliasListNode_t **ret ); + void ( *Alias_Dump )( ); + void ( *Alias_Clear )( ); + AliasList_t * ( *AliasList_New )( char *name ); + void ( *Alias_ListFindRandomRange )( AliasList_t *list, char *alias, int *minIndex, int *maxIndex, float *totalWeight ); + AliasList_t * ( *Alias_GetGlobalList )( ); + void ( *UI_ShowMenu )( char *name, qboolean bForce ); + void ( *UI_HideMenu )( char *name, qboolean bForce ); + int ( *UI_FontStringWidth )( fontHeader_t *font, char *string, int maxLen ); + int ( *Key_StringToKeynum )( char *str ); + char * ( *Key_KeynumToBindString )( int keyNum ); + void ( *Key_GetKeysForCommand )( const char *command, int *key1, int *key2 ); + dtiki_t * ( *R_Model_GetHandle )( qhandle_t handle ); + int ( *TIKI_NumAnims )( dtiki_t *pmdl ); + void ( *TIKI_CalculateBounds )( dtiki_t *pmdl, float scale, vec3_t mins, vec3_t maxs ); + char * ( *TIKI_Name )( dtiki_t *tiki, int entNum ); + void * ( *TIKI_GetSkeletor )( dtiki_t *tiki, int entNum ); + void ( *TIKI_SetEyeTargetPos )( dtiki_t *tiki, int entNum, vec3_t pos ); + char * ( *Anim_NameForNum )( dtiki_t *tiki, int animNum ); + int ( *Anim_NumForName )( dtiki_t *tiki, const char *name ); + int ( *Anim_Random )( dtiki_t *tiki, const char *name ); + int ( *Anim_NumFrames )( dtiki_t *tiki, int animNum ); + float ( *Anim_Time )( dtiki_t *tiki, int animNum ); + float ( *Anim_Frametime )( dtiki_t *tiki, int animNum ); + void ( *Anim_Delta )( dtiki_t *tiki, int animNum, vec3_t delta ); + int ( *Anim_Flags )( dtiki_t *tiki, int animNum ); + int ( *Anim_FlagsSkel )( dtiki_t *tiki, int animNum ); + float ( *Anim_CrossblendTime )( dtiki_t *tiki, int animNum ); + qboolean ( *Anim_HasCommands )( dtiki_t *tiki, int animNum ); + qboolean ( *Frame_Commands )( dtiki_t *tiki, int animNum, int frameNum, tiki_cmd_t *tikiCmds ); + qboolean ( *Frame_CommandsTime )( dtiki_t *pmdl, int animNum, float start, float end, tiki_cmd_t *tikiCmd ); + int ( *Surface_NameToNum )( dtiki_t *pmdl, const char *name ); + int ( *Tag_NumForName )( dtiki_t *pmdl, const char *name ); + char * ( *Tag_NameForNum )( dtiki_t *pmdl, int animNum ); + void ( *ForceUpdatePose )( refEntity_t *model ); + orientation_t ( *TIKI_Orientation )( orientation_t *orientation, refEntity_t *model, int tagNum ); + qboolean ( *TIKI_IsOnGround )( refEntity_t *model, int tagNum, float threshold ); + void ( *UI_ShowScoreBoard )( const char *menuName ); + void ( *UI_HideScoreBoard )( ); + void ( *UI_SetScoreBoardItem )( int itemNumber, char *data1, char *data2, char *data3, char *data4, char *data5, char *data6, char *data7, char *data8, float *textColor, float *backColor, qboolean isHeader ); + void ( *UI_DeleteScoreBoardItems )( int maxIndex ); + void ( *UI_ToggleDMMessageConsole )( int consoleMode ); + dtiki_t * ( *TIKI_FindTiki )( char *path ); + void ( *LoadResource )( char *name ); + void ( *FS_CanonicalFilename )( char *name ); + + cvar_t *fsDebug; + hdElement_t *hudDrawElements; + clientAnim_t *anim; + stopWatch_t *stopWatch; + + int( *FS_Read )( void *buffer, int len, fileHandle_t fileHandle ); + void( *FS_FCloseFile )( fileHandle_t fileHandle ); + int( *FS_Tell )( fileHandle_t fileHandle ); + int( *FS_Seek )( fileHandle_t fileHandle, long int offset, fsOrigin_t origin ); + fileHandle_t( *FS_FOpenFileWrite )( const char *fileName ); + int( *FS_Write )( void *buffer, int size, fileHandle_t fileHandle ); + char **( *FS_ListFiles )( const char *qpath, const char *extension, qboolean wantSubs, int *numFiles ); + void( *FS_FreeFileList )( char **list ); + +} clientGameImport_t; + +typedef struct clientGameExport_s +{ + void ( *CG_Init )( clientGameImport_t *imported, int serverMessageNum, int serverCommandSequence, int clientNum ); + void ( *CG_Shutdown )( ); + void ( *CG_DrawActiveFrame )( int serverTime, int frameTime, stereoFrame_t stereoView, qboolean demoPlayback ); + qboolean ( *CG_ConsoleCommand )( ); + void ( *CG_GetRendererConfig )( ); + void ( *CG_Draw2D )( ); + void ( *CG_EyePosition )( vec3_t *eyePos ); + void ( *CG_EyeOffset )( vec3_t *eyeOffset ); + void ( *CG_EyeAngles )( vec3_t *eyeAngles ); + float ( *CG_SensitivityScale )( ); + void ( *CG_ParseCGMessage )( ); + void ( *CG_RefreshHudDrawElements )( ); + void ( *CG_HudDrawShader )( int info ); + void ( *CG_HudDrawFont )( int info ); + int ( *CG_GetParent )( int entNum ); + float ( *CG_GetObjectiveAlpha )( ); + int ( *CG_PermanentMark )( vec3_t origin, vec3_t dir, float orientation, float sScale, float tScale, float red, float green, float blue, float alpha, qboolean doLighting, float sCenter, float tCenter, markFragment_t *markFragments, void *polyVerts ); + int ( *CG_PermanentTreadMarkDecal )( treadMark_t *treadMark, qboolean startSegment, qboolean doLighting, markFragment_t *markFragments, void *polyVerts ); + int ( *CG_PermanentUpdateTreadMark )( treadMark_t *treadMark, float alpha, float minSegment, float maxSegment, float maxOffset, float texScale ); + void ( *CG_ProcessInitCommands )( dtiki_t *tiki, refEntity_t *ent ); + void ( *CG_EndTiki )( dtiki_t *tiki ); + char * ( *CG_GetColumnName )( int columnNum, int *columnWidth ); + void ( *CG_GetScoreBoardColor )( float *red, float *green, float *blue, float *alpha ); + void ( *CG_GetScoreBoardFontColor )( float *red, float *green, float *blue, float *alpha ); + int ( *CG_GetScoreBoardDrawHeader )( ); + void ( *CG_GetScoreBoardPosition )( float *x, float *y, float *width, float *height ); + int ( *CG_WeaponCommandButtonBits )( ); + int ( *CG_CheckCaptureKey )( keyNum_t key, qboolean down, unsigned int time ); + + profCGame_t *profStruct; + + qboolean ( *CG_Command_ProcessFile )( char *name, qboolean quiet, dtiki_t *curTiki ); + +} clientGameExport_t; + +clientGameExport_t * GetCGameAPI( ); + +extern cg_t *cg; +extern cgs_t *cgs; +extern centity_t *cg_entities; +extern centity_t *cent; +extern float *viewAngles; + +extern int cg_frametime; + +extern clientGameExport_t cge; +extern clientGameImport_t cgi; + +typedef char* (__cdecl * CG_CONFIGSTRING)(int ID); +extern CG_CONFIGSTRING CG_ConfigString; + +typedef char* (__cdecl *SPRINTF2)(char * Format, ...); +extern SPRINTF2 sprintf2; + +typedef int (__cdecl *Q_STRCMPI)(char * Str1, char * Str2); +extern Q_STRCMPI Q_strcmpi; + +typedef void ( __cdecl *pfnCG_CastFootShadow )( vec3_t lightPos, vec3_t lightIntensity, int tagNum, refEntity_t *ref ); +extern pfnCG_CastFootShadow CG_CastFootShadow; + +#endif /* __CGAMEX86_H */ diff --git a/code/cgame_hook/game.cpp b/code/cgame_hook/game.cpp new file mode 100644 index 00000000..11a82003 --- /dev/null +++ b/code/cgame_hook/game.cpp @@ -0,0 +1,62 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// game.cpp : TU Game. + +#include "game.h" + +Game game; + +void CacheResource( const char *name ) +{ + +} + +SimpleEntity *G_FindTarget( SimpleEntity *next, const char *classname ) +{ + return NULL; +} + +Vector G_GetMovedir( float angle ) +{ + if( angle == -1.0f ) + { + return Vector( 0.0f, 0.0f, 1.0f ); + } + else if( angle == -2.0f ) + { + return Vector( 0.0f, 0.0f, -1.0f ); + } + + angle *= ( M_PI * 2.0f / 360.0f ); + return Vector( cos( angle ), sin( angle ), 0.0f ); +} + +float G_Random( float value ) +{ + return fmod( rand(), value ); +} + +CLASS_DECLARATION( Listener, Game, NULL ) +{ + { NULL, NULL } +}; diff --git a/code/cgame_hook/game.h b/code/cgame_hook/game.h new file mode 100644 index 00000000..07108633 --- /dev/null +++ b/code/cgame_hook/game.h @@ -0,0 +1,40 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// game.h : TU Game. + +#ifndef __GAME_H__ +#define __GAME_H__ + +#include + +class Game : public Listener { + CLASS_PROTOTYPE( Game ); +}; + +extern Game game; + +SimpleEntity *G_FindTarget( SimpleEntity *next, const char *classname ); +Vector G_GetMovedir( float angle ); +float G_Random( float value ); + +#endif /* __GAME_H__*/ \ No newline at end of file diff --git a/code/cgame_hook/hook.cpp b/code/cgame_hook/hook.cpp new file mode 100644 index 00000000..f82e54fa --- /dev/null +++ b/code/cgame_hook/hook.cpp @@ -0,0 +1,414 @@ +/* +=========================================================================== +Copyright (C) 2008 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// hook.cpp : Hooks & Detours + +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#define _WINSOCKAPI_ +#include "windows.h" +#else +#include +#endif + +#include "glb_local.h" +#include + +#include "hook.h" +#include "md5.h" + +//#pragma warning(disable : 4172) +#pragma warning(disable : 4005 4083 4244 4047 4018 4700) + +int bDataCompare( const uint8_t* pData, const uint8_t* bMask, const char* szMask ) +{ + for(;*szMask;++szMask,++pData,++bMask) + if(*szMask=='x' && *pData!=*bMask ) + return 0; + return (*szMask) == 0; +} + +uintptr_t dwFindPattern( uintptr_t dwAddress, uintptr_t dwLen, uint8_t *bMask, const char * szMask ) +{ + DWORD i; + + for( i=0; i < dwLen; i++) + if( bDataCompare( (BYTE*)( dwAddress+i ),bMask,szMask) ) + return (DWORD)(dwAddress+i); + + return 0; +} + +void ReadMemory( uintptr_t dwBaseAddress, uint8_t buffer[], uintptr_t dwLen ) +{ +#ifndef WIN32 + int ret = unprotect( GET_PAGE( (void *)dwBaseAddress ), 4096 ); + + if ( ret == -1 ) { + handle_error( "Read memory error #1" ); + } + + if ( ( ( (uint)dwBaseAddress ) & 0xfff ) > 0xff9 ) + ret = unprotect( GET_PAGE( (void *)dwBaseAddress + 4096 ), 4096 ); + + if ( ret == -1 ) { + handle_error( "Read memory error #2" ); + } +#endif + + memcpy( ( void* )buffer, ( void* )dwBaseAddress, dwLen ); +} + +void WriteMemory( uintptr_t dwBaseAddress, uint8_t buffer[], uintptr_t dwLen ) +{ +#ifdef WIN32 + DWORD old_protection; + DWORD old_protectionRevert; + + VirtualProtect( (LPVOID)dwBaseAddress, dwLen+5, PAGE_EXECUTE_READWRITE, &old_protection); +#else + + int ret = 0; + + ret = unprotect( GET_PAGE( (void *)dwBaseAddress ), 4096 ); + + if ( ret == -1 ) { + Com_Printf( "dwBaseAddress = %p\n", dwBaseAddress ); + handle_error( "Write memory error #1" ); + } + + if ( ( ( (uint)dwBaseAddress ) & 0xfff ) > 0xff9 ) + ret = unprotect( GET_PAGE( (void *)dwBaseAddress + 4096 ), 4096 ); + + if ( ret == -1 ) { + Com_Printf( "dwBaseAddress = %p\n", dwBaseAddress ); + handle_error( "Write memory error #2" ); + } + +#endif + + memcpy( (void*)dwBaseAddress, (void*)buffer, dwLen ); + +#ifdef WIN32 + VirtualProtect( (LPVOID)dwBaseAddress, dwLen+5, old_protection, &old_protectionRevert); +#endif +} + +BYTE *detour_function( void *orig, void *detour, int len ) +{ + if ( orig == NULL || detour == NULL ) { + return NULL; + } + + unsigned char *tramp; + unsigned char *tmp; + +#ifdef WIN32 + DWORD old_protection; + DWORD old_protectionRevert; +#endif + + if ( len<5 ) + { + Com_Printf( "detour_function : length must be 5 or above (len=%d)! (orig=0x%p|detour=0x%p)\n", len, orig, detour ); + + cgi.Error( ERR_FATAL, "Wrong length\n" ); + + return NULL; + } + + tramp = (unsigned char *)malloc( len + 5 + ( 2 * sizeof(DWORD) ) ); + + *( DWORD * )tramp = (DWORD)orig; // store the original function address in the trampoline + *( DWORD * )( tramp + 4 ) = len; // store the length in the trampoline + tramp += 8; + + memset( tramp, 0x90, len+5 ); + + memcpy( tramp, orig, len ); + tramp[len] = 0xE9; + + *( (void **)( tramp + len + 1 ) ) = (void *)( ( ( (unsigned int)orig ) + len ) - (unsigned int)( tramp + len + 5 ) ); + +#ifdef WIN32 + VirtualProtect( (LPVOID)orig, len+10, PAGE_EXECUTE_READWRITE, &old_protection); +#else + unprotect( GET_PAGE( orig ), 4096 ); + + if ( ( ( (uint)orig ) & 0xfff ) > 0xff9 ) + unprotect( GET_PAGE( orig + 4096 ), 4096 ); +#endif + + *( (unsigned char *)orig ) = 0xE9; + *( (void **)( (unsigned int)orig + 1 ) ) = (void*)( ( (unsigned int)detour ) - ( ( (unsigned int)orig ) + 5 ) ); + tmp = (unsigned char*)( ( (unsigned int)orig ) + 5 ); + + for ( ; len>5; len--, tmp++ ) + *tmp = 0xCC; + +#ifdef WIN32 + VirtualProtect( (LPVOID)orig, len+10, old_protection, &old_protectionRevert); +#endif + + return tramp; +} + +void detour_remove( void * orig, void * detour ) +{ + if ( orig == NULL || detour == NULL ) { + return; + } + +#ifdef WIN32 + DWORD old_protection; + DWORD old_protectionRevert; +#endif + + DWORD dwOld; + int len; + + dwOld = *( DWORD * )( ( DWORD )detour - 8 ); // retrieve the original function address from the detour + len = *( DWORD * ) ( ( DWORD )detour - 4 ); // retrieve the length from the detour + +#ifdef WIN32 + VirtualProtect( (LPVOID)dwOld, len+10, PAGE_EXECUTE_READWRITE, &old_protection); +#else + + unprotect( GET_PAGE( dwOld ), 4096 ); + if ( ( ( (uint)dwOld ) & 0xfff ) > 0xff9 ) + unprotect( GET_PAGE( dwOld + 4096 ), 4096 ); +#endif + + memcpy( (void*)dwOld, detour, len ); + + free( ( void* )( ( DWORD )detour - 8 ) ); + +#ifdef WIN32 + VirtualProtect( (LPVOID)orig, len+10, old_protection, &old_protectionRevert); +#endif +} + +DWORD DetourPatchcall( PBYTE pSrc, PBYTE pDst, BOOL bForce ) +{ + DWORD dwOrgCallDest = 0; + DWORD dwOldProtection = 0; + DWORD dwRel = 0; + + if(!pSrc || !pDst) return (0); + + //type call + if( *pSrc == 0xE8 || bForce ) + { + if( *pSrc == 0xE8 ){ + dwRel = *(DWORD*)( pSrc + 1 ); + dwOrgCallDest = ( (DWORD)pSrc + dwRel + 0x5 ); + } else { + dwOrgCallDest = 1; // return 1 means no original call at pSrc + } + +#ifdef WIN32 + if( !VirtualProtect( (PVOID)pSrc, 0x1000, PAGE_EXECUTE_READWRITE, &dwOldProtection ) ) + return (0); +#else + unprotect( GET_PAGE( pSrc ), 4096 ); + + if ( ( ( (unsigned long)pSrc ) & 0xfff ) > 0xff9 ) + unprotect( GET_PAGE( pSrc + 4096 ), 4096 ); +#endif + + *pSrc = 0xE8; + *( DWORD* )( pSrc + 1 ) = (DWORD)( pDst - pSrc - 5 ); + +#ifdef WIN32 + VirtualProtect( (PVOID)pSrc, 0x1000, dwOldProtection, &dwOldProtection ); +#endif + + return dwOrgCallDest; + } + + return (0); +} + +char *replace( char *string, const char *search, const char *replace ) +{ + static char strings[ 2 ][ MAX_STRING_TOKENS ]; + static int index = 0; + char *buffer; + + buffer = strings[ index & 1 ]; + index++; + + char *p; + + if( !( p = strstr( string, search ) ) ) { + return string; + } + + strncpy( buffer, string, p - string ); // Copy characters from 'str' start to 'orig' st$ + buffer[ p - string ] = '\0'; + + sprintf( buffer + ( p - string ), "%s%s", replace, p + strlen( search ) ); + + return buffer; +} + +void replace2( char *s, const char *s1, const char *s2 ) +{ + char *p, *sp, *dp; + int len, cnt; + + for( ;; ) + { + if( ( p = strstr( s, s1 ) ) == NULL ) return; + + len = strlen( s2 ) - strlen( s1 ); + if( len ) + { + // Locate the string and replace string length, requiring shift action + sp = p + strlen( s1 ); // From the SP referring location + dp = sp + len; // Move to the location referred to dp + cnt = strlen( sp ) + 1; // The length + memmove( p + strlen( s1 ) + len, p + strlen( s1 ), cnt ); + } + memcpy( p, s2, strlen( s2 ) ); + } +} + +const char *itemName[255] = +{ + "", + "Papers", + "Colt 45", + "Walther P38", + "Hi-Standard Silenced", + "M1 Garand", + "Mauser KAR 98K", + "KAR98 - Sniper", + "Springfield '03 Sniper", + "Thompson", + "MP40", + "BAR", + "StG 44", + "Frag Grenade", + "Stielhandgranate", + "Bazooka", + "Panzerschreck", + "Shotgun", + "unarmed", + NULL +}; + +const char *itemPrefix[255] = +{ + "", + "papers", + "colt45", + "p38", + "histandard", + "garand", + "kar98", + "kar98sniper", + "springfield", + "thompson", + "mp40", + "bar", + "mp44", + "fraggrenade", + "stielhandgranate", + "bazooka", + "panzerschreck", + "shotgun", + "unarmed", + NULL +}; + +void VM_AddViewModelPrefix( const char * weapon_name, const char * prefix ) +{ + int i; + char *weapon_name_allocated; + char *weapon_prefix_allocated; + + for( i = 1; i < 255; i++ ) + { + /* Don't add this more than once... */ + if( itemPrefix[i] != NULL && _stricmp( itemPrefix[i], prefix ) == 0 && _stricmp( itemName[i], weapon_name ) == 0 ) { + return; + } + } + + /* Allocate the name so that it will be always present in the database */ + weapon_name_allocated = ( char * )malloc( strnlen( weapon_name, 255 ) ); + weapon_prefix_allocated = ( char * )malloc( strnlen( prefix, 255 ) ); + + strcpy( weapon_name_allocated, weapon_name ); + strcpy( weapon_prefix_allocated, prefix ); + + for( i = 1; i < 255; i++ ) + { + if( itemName[i] == NULL || itemPrefix[i] == NULL ) + { + itemName[i] = ( char * )weapon_name_allocated; + itemPrefix[i] = ( char * )weapon_prefix_allocated; + break; + } + } +} + +int VM_GetVMAnimPrefixString( char * weapon_name ) +{ + int i; + + if( weapon_name == NULL ) { + return 18; // unarmed + } + + for( i = 1; i < 255; i++ ) + { + if( itemName[i] == NULL ) { + continue; + } + + if( _stricmp( itemName[i], weapon_name ) == 0 ) { + return i; + } + } + + return 18; +} + +void VM_VMInit( void ) +{ + int i; + + for( i = 1; i < 255; i++ ) + { + if( itemName[i] == NULL || itemPrefix[i] == NULL ) { + break; + } + } + + for( ; i < 255; i ++ ) + { + itemName[i] = NULL; + itemPrefix[i] = NULL; + } +} diff --git a/code/cgame_hook/hook.h b/code/cgame_hook/hook.h new file mode 100644 index 00000000..771fa815 --- /dev/null +++ b/code/cgame_hook/hook.h @@ -0,0 +1,129 @@ +/* +=========================================================================== +Copyright (C) 2008 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// hook.h : Hooks & Detours + +#if defined ( CGAME_DLL ) +#include "cgamex86.h" +#else +#include "ubersdk.h" +#endif + +#include "asm.h" +#include "vector.h" + +#if defined ( CGAME_DLL ) +#define glbs cgi +#else +#define glbs ugi +#endif + +//==================== +// CGM Messages +//==================== + +#define CGM_HUDDRAW_SHADER 27 +#define CGM_HUDDRAW_ALIGN 28 +#define CGM_HUDDRAW_RECT 29 +#define CGM_HUDDRAW_VIRTUALSIZE 30 +#define CGM_HUDDRAW_COLOR 31 +#define CGM_HUDDRAW_ALPHA 32 +#define CGM_HUDDRAW_STRING 33 +#define CGM_HUDDRAW_FONT 34 +#define CGM_HUDDRAW_TIMER 38 +#define CGM_HUDDRAW_3D 39 +#define CGM_HUDDRAW_BREAK3D 40 +#define CGM_HUDDRAW_FADE 41 +#define CGM_HUDDRAW_MOVE 42 +#define CGM_HUDDRAW_SCALE 43 +#define CGM_VIEWMODELANIM 44 +#define CGM_VIEWMODELPREFIX 45 +#define CGM_MODHEIGHTFLOAT 46 +#define CGM_SETVMASPEED 47 +#define CGM_HINTSTRING 48 +#define CGM_PLAYLOCALSOUND 49 +#define CGM_SETLOCALSOUNDRATE 50 +#define CGM_STOPLOCALSOUND 51 +#define CGM_HUDDRAW_RECTX 52 +#define CGM_HUDDRAW_RECTY 53 +#define CGM_HUDDRAW_RECTWH 54 +#define CGM_REPLICATION 55 +#define CGM_HUDDRAW_DELETE 56 + +//==================== +// Hooks & Detours +//==================== + +#define unprotect(addr,len) (mprotect(addr,len,PROT_READ|PROT_WRITE|PROT_EXEC)) +#define GET_PAGE(a) ((void*)(((unsigned long)a)&0xfffff000)) + +#define handle_error(msg) \ + do { perror( msg ); exit( EXIT_FAILURE ); } while ( 0 ) + + +//==================== +// Misc Functions +//==================== + +extern int bDataCompare( const uint8_t* pData, const uint8_t* bMask, const char* szMask ); +extern uintptr_t dwFindPattern( uintptr_t dwAddress, uintptr_t dwLen, uint8_t *bMask, const char * szMask ); + +extern void ReadMemory( uintptr_t dwBaseAddress, uint8_t buffer[], uintptr_t dwLen ); +extern void WriteMemory( uintptr_t dwBaseAddress, uint8_t buffer[], uintptr_t dwLen ); + +uint8_t *detour_function( void * orig, void * detour, int len ); +void detour_remove( void * orig, void * detour ); + +extern uintptr_t DetourPatchcall( uintptr_t pSrc, uintptr_t pDst, uintptr_t bForce ); + +#define _wpm(a,b,s) WriteProcessMemory(GetCurrentProcess(), (PVOID)(a), (PBYTE)(b), (s), NULL ) + +char *replace( char *string, const char *search, const char *replace ); +void replace2( char *s, const char *s1, const char *s2 ); + +//==================== +// Misc Functions +//==================== +extern const char *itemName[]; +extern const char *itemPrefix[]; + +void VM_AddViewModelPrefix( const char * weapon_name, const char * prefix ); +int VM_GetVMAnimPrefixString( char * weapon_name ); +void VM_VMInit( void ); + +//++++++++END+++++++++ + +#ifndef WIN32 + +void initsighandlers(void); +void resetsighandlers(void); +void sighandler(int sig, siginfo_t *info, void *secret); + +#else + +void initExceptions( void ); + +#endif + +#ifndef __FUNCTION__ +#define __FUNCTION__ const char * function +#endif diff --git a/code/cgame_hook/img/IMAGE.h b/code/cgame_hook/img/IMAGE.h new file mode 100644 index 00000000..04c262c6 --- /dev/null +++ b/code/cgame_hook/img/IMAGE.h @@ -0,0 +1,88 @@ +////////////////////////////////////////////////////////////////////////////////////////// +// IMAGE.h +// Image class declaration +// Downloaded from: www.paulsprojects.net +// Created: 20th July 2002 +// Modified: 9th November 2002 - Corrected stride for TGA textures +// - Split up .cpp files +// - Added support for paletted textures +// +// Copyright (c) 2006, Paul Baker +// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at +// http://www.paulsprojects.net/NewBSDLicense.txt) +////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef IMAGE_H +#define IMAGE_H + +class IMAGE +{ +public: + IMAGE() : data(NULL), bpp(0), width(0), height(0), stride(0), + paletted(false), paletteBpp(0), palette(NULL) + {} + + ~IMAGE() + { + if(data) + delete [] data; + data=NULL; + + if(palette) + delete [] palette; + palette=NULL; + } + + //Load image + bool Load(char * filename); + + //Use the color indices from a paletted image as the alpha channel for this image + bool LoadAlpha(const IMAGE & alphaImage); + +protected: + //Load BMPs + bool LoadBMP(char * filename); + bool Load8BitBMP(char * filename); + bool Load24BitBMP(char * filename); + + //Load TGAs + bool LoadTGA(char * filename); + bool LoadUncompressed8BitTGA(char * filename); + bool LoadUncompressedTrueColorTGA(char * filename); + bool LoadCompressedTrueColorTGA(char * filename); + + //Calculate the number of bytes in a row, including padding bytes + unsigned int CalculateStride(unsigned int testBpp=-1, unsigned int testWidth=-1); + //Do not pass values to use class members + +public: + //Alter the image + void FlipVertically(void); + void MirrorHorizontally(void); + void ExpandPalette(void); //convert a paletted image into a non-paletted one + + unsigned int bpp; //bits per pixel + unsigned int width, height; //size + unsigned int stride; //bytes per row, including padding bytes + GLuint format; //format (eg GL_RGBA) + + //Data + GLubyte * data; + + //palette data (256 entries) + bool paletted; + + unsigned int paletteBpp; + GLuint paletteFormat; + GLubyte * palette; +}; + +//Bitmap ID +const DWORD bitmapID=0x4D42; + +#endif //IMAGE_H + + + + + diff --git a/code/cgame_hook/img/IMAGE_CalculateStride.cpp b/code/cgame_hook/img/IMAGE_CalculateStride.cpp new file mode 100644 index 00000000..f17b854f --- /dev/null +++ b/code/cgame_hook/img/IMAGE_CalculateStride.cpp @@ -0,0 +1,38 @@ +////////////////////////////////////////////////////////////////////////////////////////// +// IMAGE_CalculateStride.cpp +// Calculate the number of bytes in an image row, including padding bytes +// Downloaded from: www.paulsprojects.net +// Created: 9th November 2002 +// +// Copyright (c) 2006, Paul Baker +// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at +// http://www.paulsprojects.net/NewBSDLicense.txt) +////////////////////////////////////////////////////////////////////////////////////////// +#define WIN32_LEAN_AND_MEAN +#include +#include +#include "IMAGE.h" + +//Calculate the number of bytes in an image row, including padding bytes +//default parameters (-1, -1). If a parameter is -1, use class varibles +unsigned int IMAGE::CalculateStride(unsigned int testBpp, unsigned int testWidth) +{ + //See if we should use the class' own variables + if(testWidth==-1) + testWidth=width; + + if(testBpp==-1) + testBpp=bpp; + + //Calculate the number of bits per line + unsigned int bitsPerLine=testWidth*testBpp; + + //Find how many to add on to make 32-bit aligned + unsigned int bitsToAdd=0; + + if((bitsPerLine%32)!=0) + bitsToAdd=32-(bitsPerLine%32); + + //return stride + return (bitsPerLine+bitsToAdd)/8; +} \ No newline at end of file diff --git a/code/cgame_hook/img/IMAGE_ExpandPalette.cpp b/code/cgame_hook/img/IMAGE_ExpandPalette.cpp new file mode 100644 index 00000000..243fc65c --- /dev/null +++ b/code/cgame_hook/img/IMAGE_ExpandPalette.cpp @@ -0,0 +1,62 @@ +////////////////////////////////////////////////////////////////////////////////////////// +// IMAGE_CalculateStride.cpp +// Convert a paletted image into a non-paletted one +// Downloaded from: www.paulsprojects.net +// Created: 9th November 2002 +// +// Copyright (c) 2006, Paul Baker +// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at +// http://www.paulsprojects.net/NewBSDLicense.txt) +////////////////////////////////////////////////////////////////////////////////////////// +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include "IMAGE.h" + +//Convert a paletted image into a non-paletted one +void IMAGE::ExpandPalette(void) +{ + //Do not expand non-paletted images, or those with no data + if(!paletted || !data) + return; + + //Calculate the stride of the expanded image + unsigned int newStride=CalculateStride(paletteBpp); + + //Create space for the expanded image data + GLubyte * newData=new GLubyte[newStride*height]; + if(!newData) + { + printf("Unable to create memory for expanded data\n"); + return; + } + + //Loop through and fill in the unpaletted data + for(unsigned int row=0; row +#include +#include +#include "IMAGE.h" + +//Load an image from a file +bool IMAGE::Load(char * filename) +{ + //Clear the member variables if already used + bpp=0; + width=height=0; + stride=0; + format=0; + + if(data) + delete [] data; + data=NULL; + + paletted=false; + paletteBpp=0; + paletteFormat=0; + if(palette) + delete [] palette; + palette=NULL; + + //Call the correct loading function based on the filename + int filenameLength=strlen(filename); + + if( strncmp(filename+filenameLength-3, "BMP", 3)==0 || + strncmp(filename+filenameLength-3, "bmp", 3)==0) + return LoadBMP(filename); + + if( strncmp(filename+filenameLength-3, "TGA", 3)==0 || + strncmp(filename+filenameLength-3, "tga", 3)==0) + return LoadTGA(filename); + + printf("%s does not end with \"bmp\" or \"tga\"\n", filename); + return false; +} diff --git a/code/cgame_hook/img/IMAGE_Load24BitBMP.cpp b/code/cgame_hook/img/IMAGE_Load24BitBMP.cpp new file mode 100644 index 00000000..7fe528c8 --- /dev/null +++ b/code/cgame_hook/img/IMAGE_Load24BitBMP.cpp @@ -0,0 +1,96 @@ +////////////////////////////////////////////////////////////////////////////////////////// +// IMAGE_Load24BitBMP.cpp +// Load a 24 bit .bmp file +// Downloaded from: www.paulsprojects.net +// Created: 9th November 2002 +// +// Copyright (c) 2006, Paul Baker +// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at +// http://www.paulsprojects.net/NewBSDLicense.txt) +////////////////////////////////////////////////////////////////////////////////////////// +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include "IMAGE.h" + +//Load a 24 bit .bmp file +bool IMAGE::Load24BitBMP(char * filename) +{ + printf("Loading %s in Load24BitBMP()\n", filename); + + FILE * file; + BITMAPFILEHEADER fileHeader; + BITMAPINFOHEADER infoHeader; + + //Open file for reading + file=fopen(filename, "rb"); + if(!file) + { + printf("Unable to open %s\n", filename); + return false; + } + + //read the file header + fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, file); + + //Check this is a bitmap + if(fileHeader.bfType != bitmapID) + { + fclose(file); + printf("%s is not a legal .bmp\n", filename); + return false; + } + + //Read in the information header + fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, file); + + if(infoHeader.biBitCount!=24) + { + fclose(file); + printf("%s is not a 24 bit .bmp\n", filename); + return false; + } + + //Set class variables + bpp=24; + format=GL_RGB; + width=infoHeader.biWidth; + height=infoHeader.biHeight; + + //Calculate the stride in bytes for each row (allow for 4-byte padding) + stride=CalculateStride(); + + //Point "file" to the beginning of the data + fseek(file, fileHeader.bfOffBits, SEEK_SET); + + //Allocate space for the image data + data=new GLubyte[stride*height]; + if(!data) + { + fclose(file); + printf( "Unable to allocate data for %s of size %d x %d\n", filename, + stride, height); + return false; + } + + //read in the data + fread(data, 1, stride*height, file); + + fclose(file); + + //Data is in BGR format + //swap b and r + for(unsigned int row=0; row +#include +#include +#include "IMAGE.h" + +//Load an 8 bit .bmp file +bool IMAGE::Load8BitBMP(char * filename) +{ + printf("Loading %s in Load8BitBMP()\n", filename); + + FILE * file; + BITMAPFILEHEADER fileHeader; + BITMAPINFOHEADER infoHeader; + + //Open file for reading + file=fopen(filename, "rb"); + if(!file) + { + printf("Unable to open %s\n", filename); + return false; + } + + //read the file header + fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, file); + + //Check this is a bitmap + if(fileHeader.bfType != bitmapID) + { + fclose(file); + printf("%s is not a legal .bmp\n", filename); + return false; + } + + //Read in the information header + fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, file); + + if(infoHeader.biBitCount!=8) + { + fclose(file); + printf("%s is not an 8 bit .bmp\n", filename); + return false; + } + + //Set class variables + bpp=8; + format=GL_COLOR_INDEX; + width=infoHeader.biWidth; + height=infoHeader.biHeight; + + paletted=true; + paletteBpp=24; + paletteFormat=GL_RGB; + + //Calculate the stride in bytes for each row (allow for 4-byte padding) + stride=CalculateStride(); + + //Create space for a temporary palette + GLubyte * tempPalette=new GLubyte[256*4]; + if(!tempPalette) + { + fclose(file); + printf("Unable to allocate space for palette\n"); + return false; + } + + //Load the palette + fread(tempPalette, 256*4, 1, file); + + //Create space for palette (disregard needless 4th entry) + palette=new GLubyte[256*3]; + if(!palette) + { + fclose(file); + printf("Unable to allocate space for palette\n"); + return false; + } + + //Copy the palette entries from tempPalette to palette + //swap bytes 0 and 2 to go from BGR to RGB + for(int i=0; i<256; ++i) + { + palette[i*3+0]=tempPalette[i*4+2]; + palette[i*3+1]=tempPalette[i*4+1]; + palette[i*3+2]=tempPalette[i*4+0]; + } + + //Clear "tempPalette" data + if(tempPalette) + delete [] tempPalette; + tempPalette=NULL; + + //Point "file" to the beginning of the data + fseek(file, fileHeader.bfOffBits, SEEK_SET); + + //Allocate space for the image data + data=new GLubyte[stride*height]; + if(!data) + { + fclose(file); + printf( "Unable to allocate data for %s of size %d x %d\n", filename, + stride, height); + return false; + } + + //read in the data + fread(data, 1, stride*height, file); + + fclose(file); + + printf("Loaded %s Correctly!\n", filename); + return true; +} diff --git a/code/cgame_hook/img/IMAGE_LoadAlpha.cpp b/code/cgame_hook/img/IMAGE_LoadAlpha.cpp new file mode 100644 index 00000000..e928b9f2 --- /dev/null +++ b/code/cgame_hook/img/IMAGE_LoadAlpha.cpp @@ -0,0 +1,74 @@ +////////////////////////////////////////////////////////////////////////////////////////// +// IMAGE_LoadAlpha.cpp +// Use the color indices from a paletted image as the alpha channel for this image +// Downloaded from: www.paulsprojects.net +// Created: 17th November 2002 +// +// Copyright (c) 2006, Paul Baker +// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at +// http://www.paulsprojects.net/NewBSDLicense.txt) +////////////////////////////////////////////////////////////////////////////////////////// +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include "IMAGE.h" + +//Load an image from a file +bool IMAGE::LoadAlpha(const IMAGE & alphaImage) +{ + //Cannot load alpha channel into a paletted image + if(paletted) + { + printf("Cannot load alpha channel into a paletted image\n"); + return false; + } + + //Check alpha image is paletted + if(!alphaImage.paletted) + { + printf("Alpha image is non-paletted\n"); + return false; + } + + //Check the images are the same size + if(alphaImage.width!=width || alphaImage.height!=height) + { + printf("Alpha image is not the same size as color image\n"); + return false; + } + + //Create space for new data + int newStride=CalculateStride(32); + + GLubyte * tempData=new GLubyte[newStride*height]; + if(!tempData) + { + printf("Unable to allocate memory for temporary image data\n"); + return false; + } + + //Fill in the temporary data + for(unsigned int row=0; row +#include +#include +#include "IMAGE.h" + +//Open a BMP and find out what type it is +bool IMAGE::LoadBMP(char * filename) +{ + FILE * file; + BITMAPFILEHEADER fileHeader; + BITMAPINFOHEADER infoHeader; + + //Open file for reading + file=fopen(filename, "rb"); + if(!file) + { + printf("Unable to open %s\n", filename); + return false; + } + + //read the file header + fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, file); + + //Check this is a bitmap + if(fileHeader.bfType != bitmapID) + { + fclose(file); + printf("%s is not a legal .bmp\n", filename); + return false; + } + + //Read in the information header + fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, file); + + //close the file + fclose(file); + + //Find out the bpp and go to correct loading function + if(infoHeader.biBitCount==8) + return Load8BitBMP(filename); + if(infoHeader.biBitCount==24) + return Load24BitBMP(filename); + + printf("%s has an unsupported bpp\n", filename); + + return false; +} + diff --git a/code/cgame_hook/img/IMAGE_LoadCompressedTrueColorTGA.cpp b/code/cgame_hook/img/IMAGE_LoadCompressedTrueColorTGA.cpp new file mode 100644 index 00000000..11c8877d --- /dev/null +++ b/code/cgame_hook/img/IMAGE_LoadCompressedTrueColorTGA.cpp @@ -0,0 +1,183 @@ +////////////////////////////////////////////////////////////////////////////////////////// +// IMAGE_LoadCompressedTrueColorTGA.cpp +// Load a compressed true color TGA (24 or 32 bit) +// Downloaded from: www.paulsprojects.net +// Created: 16th November 2002 +// +// Copyright (c) 2006, Paul Baker +// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at +// http://www.paulsprojects.net/NewBSDLicense.txt) +////////////////////////////////////////////////////////////////////////////////////////// +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include "IMAGE.h" + +//Load an compressed true color TGA (24 or 32 bit) +bool IMAGE::LoadCompressedTrueColorTGA(char * filename) +{ + unsigned char compTGAHeader[12]={0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + unsigned char TGAcompare[12]; + unsigned char header[6]; + + printf("Loading %s in LoadCompressedTGA\n", filename); + + FILE * file=fopen(filename, "rb"); + + if(!file) + { + printf("Unable to open %s\n", filename); + return false; + } + + //read the "compare" header + fread(TGAcompare, 1, sizeof(TGAcompare), file); + if(memcmp(compTGAHeader, TGAcompare, sizeof(compTGAHeader))!=0) + { + printf("%s is not an uncompressed true color TGA\n", filename); + return false; + } + + //read in header + fread(header, 1, sizeof(header), file); + + //Save data into class member variables + width= header[1]*256+header[0]; + height= header[3]*256+header[2]; + bpp= header[4]; + + if(width<=0 || height<=0 || (bpp!=24 && bpp!=32)) + { + fclose(file); + printf("%s's height or width is less than zero, or the TGA is not 24/32 bpp\n", filename); + return false; + } + + //Set format + if(bpp==24) + format=GL_RGB; + if(bpp==32) + format=GL_RGBA; + + //allocate space for temporary data storage + GLubyte * tempData=new GLubyte[width*height*bpp/8]; + if(!tempData) + { + printf("unable to allocate memory for temporary image data\n"); + fclose(file); + return false; + } + + //read in the image data + int pixelCount=width*height; + int currentPixel=0; + int currentByte=0; + unsigned char * colorBuffer=new unsigned char[bpp/8]; + + do + { + unsigned char chunkHeader=0; + + if(fread(&chunkHeader, sizeof(unsigned char), 1, file)==0) + { + printf("could not read RLE chunk header\n"); + fclose(file); + return false; + } + + if(chunkHeader<128) //read raw colour values + { + ++chunkHeader; + + for(int counter=0; counterpixelCount) + { + printf("too many pixels read\n"); + fclose(file); + return false; + } + } + } + else //chunkHeader>=128 + { + chunkHeader-=127; + + if(fread(colorBuffer, 1, bpp/8, file) != bpp/8) + { + printf("unable to read image data\n"); + fclose(file); + return false; + } + + for(int counter=0; counterpixelCount) + { + printf("too many pixels read\n"); + fclose(file); + return false; + } + } + } + }while(currentPixel +#include +#include +#include "IMAGE.h" + +//Open a TGA and find out what type it is +bool IMAGE::LoadTGA(char * filename) +{ + unsigned char uncompTGAHeader[12] ={0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + unsigned char compTGAHeader[12] ={0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + unsigned char uncomp8Bit24TGAHeader[12] ={0, 1, 1, 0, 0, 0, 1, 24, 0, 0, 0, 0}; + unsigned char uncomp8Bit32TGAHeader[12] ={0, 1, 1, 0, 0, 0, 1, 32, 0, 0, 0, 0}; + + unsigned char TGAcompare[12]; + + FILE * file; + + //Open file for reading + file=fopen(filename, "rb"); + if(!file) + { + printf("Unable to open %s\n", filename); + return false; + } + + //read the file header + fread(TGAcompare, sizeof(TGAcompare), 1, file); + + //close the file + fclose(file); + + //Find out the type and go to correct loading function + if(memcmp(uncompTGAHeader, TGAcompare, sizeof(uncompTGAHeader))==0) + return LoadUncompressedTrueColorTGA(filename); + + if(memcmp(compTGAHeader, TGAcompare, sizeof(compTGAHeader))==0) + return LoadCompressedTrueColorTGA(filename); + + if( memcmp(uncomp8Bit24TGAHeader, TGAcompare, sizeof(uncomp8Bit24TGAHeader))==0 || + memcmp(uncomp8Bit32TGAHeader, TGAcompare, sizeof(uncomp8Bit32TGAHeader))==0) + { + return LoadUncompressed8BitTGA(filename); + } + + + printf("%s has an unsupported bpp\n", filename); + + return false; +} \ No newline at end of file diff --git a/code/cgame_hook/img/IMAGE_LoadUncompressed8BitTGA.cpp b/code/cgame_hook/img/IMAGE_LoadUncompressed8BitTGA.cpp new file mode 100644 index 00000000..b0c78c34 --- /dev/null +++ b/code/cgame_hook/img/IMAGE_LoadUncompressed8BitTGA.cpp @@ -0,0 +1,114 @@ +////////////////////////////////////////////////////////////////////////////////////////// +// IMAGE_LoadUncompressed8BitTGA.cpp +// Load an uncompressed 8 Bit TGA +// Downloaded from: www.paulsprojects.net +// Created: 16th November 2002 +// +// Copyright (c) 2006, Paul Baker +// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at +// http://www.paulsprojects.net/NewBSDLicense.txt) +////////////////////////////////////////////////////////////////////////////////////////// +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include "IMAGE.h" + +//Load an uncompressed 8 Bit TGA (24 or 32 bit) +bool IMAGE::LoadUncompressed8BitTGA(char * filename) +{ + unsigned char uncomp8Bit24TGAHeader[12]={0, 1, 1, 0, 0, 0, 1, 24, 0, 0, 0, 0}; + unsigned char uncomp8Bit32TGAHeader[12]={0, 1, 1, 0, 0, 0, 1, 32, 0, 0, 0, 0}; + unsigned char TGAcompare[12]; + unsigned char header[6]; + + printf("Loading %s in LoadUncompressed8BitTGA\n", filename); + + FILE * file=fopen(filename, "rb"); + + if(!file) + { + printf("Unable to open %s\n", filename); + return false; + } + + //read the "compare" header + fread(TGAcompare, 1, sizeof(TGAcompare), file); + if( memcmp(uncomp8Bit24TGAHeader, TGAcompare, sizeof(uncomp8Bit24TGAHeader))!=0 && + memcmp(uncomp8Bit32TGAHeader, TGAcompare, sizeof(uncomp8Bit32TGAHeader))!=0) + { + printf("%s is not an uncompressed 8Bit TGA\n", filename); + return false; + } + + //read in header + fread(header, 1, sizeof(header), file); + + //Save data into class member variables + width= header[1]*256+header[0]; + height= header[3]*256+header[2]; + bpp= header[4]; + + if(width<=0 || height<=0 || bpp!=8) + { + fclose(file); + printf("%s's height or width is less than zero, or the TGA is not 8 bpp\n", filename); + return false; + } + + paletted=true; + paletteBpp=TGAcompare[7]; + if(paletteBpp==24) + paletteFormat=GL_RGB; + if(paletteBpp==32) + paletteFormat=GL_RGBA; + + //make space for palette + palette=new GLubyte[256*paletteBpp/8]; + if(!palette) + { + fclose(file); + printf("unable to allocate memory for palette\n"); + return false; + } + + //load in the palette + fread(palette, 256*paletteBpp/8, 1, file); + + //Palette is in BGR format + //swap b and r + for(int i=0; i<256; ++i) + { + //Repeated XOR to swap bytes 0 and 2 + palette[i*(paletteBpp/8)] ^= palette[i*(paletteBpp/8)+2] ^= + palette[i*(paletteBpp/8)] ^= palette[i*(paletteBpp/8)+2]; + } + + //Set format + format=GL_COLOR_INDEX; + + //Calculate the stride in bytes for each row (allow for 4-byte padding) + stride=CalculateStride(); + + //Allocate space for the image data + data=new GLubyte[stride*height]; + if(!data) + { + fclose(file); + printf( "Unable to allocate data for %s of size %d x %d\n", filename, + stride, height); + return false; + } + + //read in the data a line at a time, and save it into the array, + //hence making it 32-byte aligned + for(unsigned int row=0; row +#include +#include +#include "IMAGE.h" + +//Load an uncompressed true color TGA (24 or 32 bit) +bool IMAGE::LoadUncompressedTrueColorTGA(char * filename) +{ + unsigned char uncompTGAHeader[12]={0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + unsigned char TGAcompare[12]; + unsigned char header[6]; + + printf("Loading %s in LoadUncompressedTGA\n", filename); + + FILE * file=fopen(filename, "rb"); + + if(!file) + { + printf("Unable to open %s\n", filename); + return false; + } + + //read the "compare" header + fread(TGAcompare, 1, sizeof(TGAcompare), file); + if(memcmp(uncompTGAHeader, TGAcompare, sizeof(uncompTGAHeader))!=0) + { + printf("%s is not an uncompressed true color TGA\n", filename); + return false; + } + + //read in header + fread(header, 1, sizeof(header), file); + + //Save data into class member variables + width= header[1]*256+header[0]; + height= header[3]*256+header[2]; + bpp= header[4]; + + if(width<=0 || height<=0 || (bpp!=24 && bpp!=32)) + { + fclose(file); + printf("%s's height or width is less than zero, or the TGA is not 24/32 bpp\n", filename); + return false; + } + + //Set format + if(bpp==24) + format=GL_RGB; + if(bpp==32) + format=GL_RGBA; + + //Calculate the stride in bytes for each row (allow for 4-byte padding) + stride=CalculateStride(); + + //Allocate space for the image data + data=new GLubyte[stride*height]; + if(!data) + { + fclose(file); + printf( "Unable to allocate data for %s of size %d x %d\n", filename, + stride, height); + return false; + } + + //read in the data a line at a time, and save it into the array, + //hence making it 32-byte aligned + for(unsigned int row=0; row +#include +#include +#include +#include "TORUS.h" + +TORUS::TORUS() +{ + InitTorus(); +} + +TORUS::~TORUS() +{ + if(indices) + delete [] indices; + indices=NULL; + + if(vertices) + delete [] vertices; + vertices=NULL; +} + +bool TORUS::InitTorus() +{ + numVertices=(torusPrecision+1)*(torusPrecision+1); + numIndices=2*torusPrecision*torusPrecision*3; + + vertices=new TORUS_VERTEX[numVertices]; + if(!vertices) + { + printf("Unable to allocate memory for torus vertices\n"); + return false; + } + + indices=new unsigned int[numIndices]; + if(!indices) + { + printf("Unable to allocate memory for torus indices\n"); + return false; + } + + //calculate the first ring - inner radius 4, outer radius 1.5 + for(int i=0; iframetime = frametime / 1000.0f; +} + +CLASS_DECLARATION( Listener, Level, NULL ) +{ + { NULL, NULL } +}; diff --git a/code/cgame_hook/level.h b/code/cgame_hook/level.h new file mode 100644 index 00000000..13a999bd --- /dev/null +++ b/code/cgame_hook/level.h @@ -0,0 +1,70 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// level.h : TU Level. + +#ifndef __LEVEL_H__ +#define __LEVEL_H__ + +#include + +class SimpleArchivedEntity; + +class Level : public Listener { +public: + bool m_LoopDrop; + bool m_LoopProtection; + + str m_mapscript; + str current_map; + + // Level time + int framenum; + int inttime; + int intframetime; + + float time; + float frametime; + + int spawnflags; + + // Server time + int svsTime; + float svsFloatTime; + int svsStartTime; + int svsEndTime; + + bool m_bScriptSpawn; + bool m_bRejectSpawn; + + Container< SimpleArchivedEntity * > m_SimpleArchivedEntities; + +public: + CLASS_PROTOTYPE( Level ); + + void setTime( int _svsTime_ ); + void setFrametime( int frameTime ); +}; + +extern Level level; + +#endif /* __LEVEL_H__*/ \ No newline at end of file diff --git a/code/cgame_hook/ogl/OtherOGL.cpp b/code/cgame_hook/ogl/OtherOGL.cpp new file mode 100644 index 00000000..0e002977 --- /dev/null +++ b/code/cgame_hook/ogl/OtherOGL.cpp @@ -0,0 +1,2506 @@ +/* +* Game-Deception Blank Wrapper v2 +* Copyright (c) Crusader 2002 +*/ + +/* +* Functions not mainly used by half-life, or functions that would allow limited to no +* advantage by hooking. + +* Todo? : These functions should be naked to save on time/space +*/ + +#include "opengl_api.h" + + HMODULE hOpenGL = 0; + func_glActiveTextureARB_t orig_glActiveTextureARB; + func_BindTextureEXT_t orig_BindTextureEXT; + func_glMultiTexCoord2fARB_t orig_glMultiTexCoord2fARB; + func_glAccum_t orig_glAccum; + func_glAlphaFunc_t orig_glAlphaFunc; + func_glAreTexturesResident_t orig_glAreTexturesResident; + func_glArrayElement_t orig_glArrayElement; + func_glBegin_t orig_glBegin; + func_glBindTexture_t orig_glBindTexture; + func_glBitmap_t orig_glBitmap; + func_glBlendFunc_t orig_glBlendFunc; + func_glCallList_t orig_glCallList; + func_glCallLists_t orig_glCallLists; + func_glClear_t orig_glClear; + func_glClearAccum_t orig_glClearAccum; + func_glClearColor_t orig_glClearColor; + func_glClearDepth_t orig_glClearDepth; + func_glClearIndex_t orig_glClearIndex; + func_glClearStencil_t orig_glClearStencil; + func_glClipPlane_t orig_glClipPlane; + func_glColor3b_t orig_glColor3b; + func_glColor3bv_t orig_glColor3bv; + func_glColor3d_t orig_glColor3d; + func_glColor3dv_t orig_glColor3dv; + func_glColor3f_t orig_glColor3f; + func_glColor3fv_t orig_glColor3fv; + func_glColor3i_t orig_glColor3i; + func_glColor3iv_t orig_glColor3iv; + func_glColor3s_t orig_glColor3s; + func_glColor3sv_t orig_glColor3sv; + func_glColor3ub_t orig_glColor3ub; + func_glColor3ubv_t orig_glColor3ubv; + func_glColor3ui_t orig_glColor3ui; + func_glColor3uiv_t orig_glColor3uiv; + func_glColor3us_t orig_glColor3us; + func_glColor3usv_t orig_glColor3usv; + func_glColor4b_t orig_glColor4b; + func_glColor4bv_t orig_glColor4bv; + func_glColor4d_t orig_glColor4d; + func_glColor4dv_t orig_glColor4dv; + func_glColor4f_t orig_glColor4f; + func_glColor4fv_t orig_glColor4fv; + func_glColor4i_t orig_glColor4i; + func_glColor4iv_t orig_glColor4iv; + func_glColor4s_t orig_glColor4s; + func_glColor4sv_t orig_glColor4sv; + func_glColor4ub_t orig_glColor4ub; + func_glColor4ubv_t orig_glColor4ubv; + func_glColor4ui_t orig_glColor4ui; + func_glColor4uiv_t orig_glColor4uiv; + func_glColor4us_t orig_glColor4us; + func_glColor4usv_t orig_glColor4usv; + func_glColorMask_t orig_glColorMask; + func_glColorMaterial_t orig_glColorMaterial; + func_glColorPointer_t orig_glColorPointer; + func_glCopyPixels_t orig_glCopyPixels; + func_glCopyTexImage1D_t orig_glCopyTexImage1D; + func_glCopyTexImage2D_t orig_glCopyTexImage2D; + func_glCopyTexSubImage1D_t orig_glCopyTexSubImage1D; + func_glCopyTexSubImage2D_t orig_glCopyTexSubImage2D; + func_glCullFace_t orig_glCullFace; + func_glDebugEntry_t orig_glDebugEntry; + func_glDeleteLists_t orig_glDeleteLists; + func_glDeleteTextures_t orig_glDeleteTextures; + func_glDepthFunc_t orig_glDepthFunc; + func_glDepthMask_t orig_glDepthMask; + func_glDepthRange_t orig_glDepthRange; + func_glDisable_t orig_glDisable; + func_glDisableClientState_t orig_glDisableClientState; + func_glDrawArrays_t orig_glDrawArrays; + func_glDrawBuffer_t orig_glDrawBuffer; + func_glDrawElements_t orig_glDrawElements; + func_glDrawPixels_t orig_glDrawPixels; + func_glEdgeFlag_t orig_glEdgeFlag; + func_glEdgeFlagPointer_t orig_glEdgeFlagPointer; + func_glEdgeFlagv_t orig_glEdgeFlagv; + func_glEnable_t orig_glEnable; + func_glEnableClientState_t orig_glEnableClientState; + func_glEnd_t orig_glEnd; + func_glEndList_t orig_glEndList; + func_glEvalCoord1d_t orig_glEvalCoord1d; + func_glEvalCoord1dv_t orig_glEvalCoord1dv; + func_glEvalCoord1f_t orig_glEvalCoord1f; + func_glEvalCoord1fv_t orig_glEvalCoord1fv; + func_glEvalCoord2d_t orig_glEvalCoord2d; + func_glEvalCoord2dv_t orig_glEvalCoord2dv; + func_glEvalCoord2f_t orig_glEvalCoord2f; + func_glEvalCoord2fv_t orig_glEvalCoord2fv; + func_glEvalMesh1_t orig_glEvalMesh1; + func_glEvalMesh2_t orig_glEvalMesh2; + func_glEvalPoint1_t orig_glEvalPoint1; + func_glEvalPoint2_t orig_glEvalPoint2; + func_glFeedbackBuffer_t orig_glFeedbackBuffer; + func_glFinish_t orig_glFinish; + func_glFlush_t orig_glFlush; + func_glFogf_t orig_glFogf; + func_glFogfv_t orig_glFogfv; + func_glFogi_t orig_glFogi; + func_glFogiv_t orig_glFogiv; + func_glFrontFace_t orig_glFrontFace; + func_glFrustum_t orig_glFrustum; + func_glGenLists_t orig_glGenLists; + func_glGenTextures_t orig_glGenTextures; + func_glGetBooleanv_t orig_glGetBooleanv; + func_glGetClipPlane_t orig_glGetClipPlane; + func_glGetDoublev_t orig_glGetDoublev; + func_glGetError_t orig_glGetError; + func_glGetFloatv_t orig_glGetFloatv; + func_glGetIntegerv_t orig_glGetIntegerv; + func_glGetLightfv_t orig_glGetLightfv; + func_glGetLightiv_t orig_glGetLightiv; + func_glGetMapdv_t orig_glGetMapdv; + func_glGetMapfv_t orig_glGetMapfv; + func_glGetMapiv_t orig_glGetMapiv; + func_glGetMaterialfv_t orig_glGetMaterialfv; + func_glGetMaterialiv_t orig_glGetMaterialiv; + func_glGetPixelMapfv_t orig_glGetPixelMapfv; + func_glGetPixelMapuiv_t orig_glGetPixelMapuiv; + func_glGetPixelMapusv_t orig_glGetPixelMapusv; + func_glGetPointerv_t orig_glGetPointerv; + func_glGetPolygonStipple_t orig_glGetPolygonStipple; + func_glGetString_t orig_glGetString; + func_glGetTexEnvfv_t orig_glGetTexEnvfv; + func_glGetTexEnviv_t orig_glGetTexEnviv; + func_glGetTexGendv_t orig_glGetTexGendv; + func_glGetTexGenfv_t orig_glGetTexGenfv; + func_glGetTexGeniv_t orig_glGetTexGeniv; + func_glGetTexImage_t orig_glGetTexImage; + func_glGetTexLevelParameterfv_t orig_glGetTexLevelParameterfv; + func_glGetTexLevelParameteriv_t orig_glGetTexLevelParameteriv; + func_glGetTexParameterfv_t orig_glGetTexParameterfv; + func_glGetTexParameteriv_t orig_glGetTexParameteriv; + func_glHint_t orig_glHint; + func_glIndexMask_t orig_glIndexMask; + func_glIndexPointer_t orig_glIndexPointer; + func_glIndexd_t orig_glIndexd; + func_glIndexdv_t orig_glIndexdv; + func_glIndexf_t orig_glIndexf; + func_glIndexfv_t orig_glIndexfv; + func_glIndexi_t orig_glIndexi; + func_glIndexiv_t orig_glIndexiv; + func_glIndexs_t orig_glIndexs; + func_glIndexsv_t orig_glIndexsv; + func_glIndexub_t orig_glIndexub; + func_glIndexubv_t orig_glIndexubv; + func_glInitNames_t orig_glInitNames; + func_glInterleavedArrays_t orig_glInterleavedArrays; + func_glIsEnabled_t orig_glIsEnabled; + func_glIsList_t orig_glIsList; + func_glIsTexture_t orig_glIsTexture; + func_glLightModelf_t orig_glLightModelf; + func_glLightModelfv_t orig_glLightModelfv; + func_glLightModeli_t orig_glLightModeli; + func_glLightModeliv_t orig_glLightModeliv; + func_glLightf_t orig_glLightf; + func_glLightfv_t orig_glLightfv; + func_glLighti_t orig_glLighti; + func_glLightiv_t orig_glLightiv; + func_glLineStipple_t orig_glLineStipple; + func_glLineWidth_t orig_glLineWidth; + func_glListBase_t orig_glListBase; + func_glLoadIdentity_t orig_glLoadIdentity; + func_glLoadMatrixd_t orig_glLoadMatrixd; + func_glLoadMatrixf_t orig_glLoadMatrixf; + func_glLoadName_t orig_glLoadName; + func_glLogicOp_t orig_glLogicOp; + func_glMap1d_t orig_glMap1d; + func_glMap1f_t orig_glMap1f; + func_glMap2d_t orig_glMap2d; + func_glMap2f_t orig_glMap2f; + func_glMapGrid1d_t orig_glMapGrid1d; + func_glMapGrid1f_t orig_glMapGrid1f; + func_glMapGrid2d_t orig_glMapGrid2d; + func_glMapGrid2f_t orig_glMapGrid2f; + func_glMaterialf_t orig_glMaterialf; + func_glMaterialfv_t orig_glMaterialfv; + func_glMateriali_t orig_glMateriali; + func_glMaterialiv_t orig_glMaterialiv; + func_glMatrixMode_t orig_glMatrixMode; + func_glMultMatrixd_t orig_glMultMatrixd; + func_glMultMatrixf_t orig_glMultMatrixf; + func_glNewList_t orig_glNewList; + func_glNormal3b_t orig_glNormal3b; + func_glNormal3bv_t orig_glNormal3bv; + func_glNormal3d_t orig_glNormal3d; + func_glNormal3dv_t orig_glNormal3dv; + func_glNormal3f_t orig_glNormal3f; + func_glNormal3fv_t orig_glNormal3fv; + func_glNormal3i_t orig_glNormal3i; + func_glNormal3iv_t orig_glNormal3iv; + func_glNormal3s_t orig_glNormal3s; + func_glNormal3sv_t orig_glNormal3sv; + func_glNormalPointer_t orig_glNormalPointer; + func_glOrtho_t orig_glOrtho; + func_glPassThrough_t orig_glPassThrough; + func_glPixelMapfv_t orig_glPixelMapfv; + func_glPixelMapuiv_t orig_glPixelMapuiv; + func_glPixelMapusv_t orig_glPixelMapusv; + func_glPixelStoref_t orig_glPixelStoref; + func_glPixelStorei_t orig_glPixelStorei; + func_glPixelTransferf_t orig_glPixelTransferf; + func_glPixelTransferi_t orig_glPixelTransferi; + func_glPixelZoom_t orig_glPixelZoom; + func_glPointSize_t orig_glPointSize; + func_glPolygonMode_t orig_glPolygonMode; + func_glPolygonOffset_t orig_glPolygonOffset; + func_glPolygonStipple_t orig_glPolygonStipple; + func_glPopAttrib_t orig_glPopAttrib; + func_glPopClientAttrib_t orig_glPopClientAttrib; + func_glPopMatrix_t orig_glPopMatrix; + func_glPopName_t orig_glPopName; + func_glPrioritizeTextures_t orig_glPrioritizeTextures; + func_glPushAttrib_t orig_glPushAttrib; + func_glPushClientAttrib_t orig_glPushClientAttrib; + func_glPushMatrix_t orig_glPushMatrix; + func_glPushName_t orig_glPushName; + func_glRasterPos2d_t orig_glRasterPos2d; + func_glRasterPos2dv_t orig_glRasterPos2dv; + func_glRasterPos2f_t orig_glRasterPos2f; + func_glRasterPos2fv_t orig_glRasterPos2fv; + func_glRasterPos2i_t orig_glRasterPos2i; + func_glRasterPos2iv_t orig_glRasterPos2iv; + func_glRasterPos2s_t orig_glRasterPos2s; + func_glRasterPos2sv_t orig_glRasterPos2sv; + func_glRasterPos3d_t orig_glRasterPos3d; + func_glRasterPos3dv_t orig_glRasterPos3dv; + func_glRasterPos3f_t orig_glRasterPos3f; + func_glRasterPos3fv_t orig_glRasterPos3fv; + func_glRasterPos3i_t orig_glRasterPos3i; + func_glRasterPos3iv_t orig_glRasterPos3iv; + func_glRasterPos3s_t orig_glRasterPos3s; + func_glRasterPos3sv_t orig_glRasterPos3sv; + func_glRasterPos4d_t orig_glRasterPos4d; + func_glRasterPos4dv_t orig_glRasterPos4dv; + func_glRasterPos4f_t orig_glRasterPos4f; + func_glRasterPos4fv_t orig_glRasterPos4fv; + func_glRasterPos4i_t orig_glRasterPos4i; + func_glRasterPos4iv_t orig_glRasterPos4iv; + func_glRasterPos4s_t orig_glRasterPos4s; + func_glRasterPos4sv_t orig_glRasterPos4sv; + func_glReadBuffer_t orig_glReadBuffer; + func_glReadPixels_t orig_glReadPixels; + func_glRectd_t orig_glRectd; + func_glRectdv_t orig_glRectdv; + func_glRectf_t orig_glRectf; + func_glRectfv_t orig_glRectfv; + func_glRecti_t orig_glRecti; + func_glRectiv_t orig_glRectiv; + func_glRects_t orig_glRects; + func_glRectsv_t orig_glRectsv; + func_glRenderMode_t orig_glRenderMode; + func_glRotated_t orig_glRotated; + func_glRotatef_t orig_glRotatef; + func_glScaled_t orig_glScaled; + func_glScalef_t orig_glScalef; + func_glScissor_t orig_glScissor; + func_glSelectBuffer_t orig_glSelectBuffer; + func_glShadeModel_t orig_glShadeModel; + func_glStencilFunc_t orig_glStencilFunc; + func_glStencilMask_t orig_glStencilMask; + func_glStencilOp_t orig_glStencilOp; + func_glSwapBuffers_t orig_glSwapBuffers; + func_glTexCoord1d_t orig_glTexCoord1d; + func_glTexCoord1dv_t orig_glTexCoord1dv; + func_glTexCoord1f_t orig_glTexCoord1f; + func_glTexCoord1fv_t orig_glTexCoord1fv; + func_glTexCoord1i_t orig_glTexCoord1i; + func_glTexCoord1iv_t orig_glTexCoord1iv; + func_glTexCoord1s_t orig_glTexCoord1s; + func_glTexCoord1sv_t orig_glTexCoord1sv; + func_glTexCoord2d_t orig_glTexCoord2d; + func_glTexCoord2dv_t orig_glTexCoord2dv; + func_glTexCoord2f_t orig_glTexCoord2f; + func_glTexCoord2fv_t orig_glTexCoord2fv; + func_glTexCoord2i_t orig_glTexCoord2i; + func_glTexCoord2iv_t orig_glTexCoord2iv; + func_glTexCoord2s_t orig_glTexCoord2s; + func_glTexCoord2sv_t orig_glTexCoord2sv; + func_glTexCoord3d_t orig_glTexCoord3d; + func_glTexCoord3dv_t orig_glTexCoord3dv; + func_glTexCoord3f_t orig_glTexCoord3f; + func_glTexCoord3fv_t orig_glTexCoord3fv; + func_glTexCoord3i_t orig_glTexCoord3i; + func_glTexCoord3iv_t orig_glTexCoord3iv; + func_glTexCoord3s_t orig_glTexCoord3s; + func_glTexCoord3sv_t orig_glTexCoord3sv; + func_glTexCoord4d_t orig_glTexCoord4d; + func_glTexCoord4dv_t orig_glTexCoord4dv; + func_glTexCoord4f_t orig_glTexCoord4f; + func_glTexCoord4fv_t orig_glTexCoord4fv; + func_glTexCoord4i_t orig_glTexCoord4i; + func_glTexCoord4iv_t orig_glTexCoord4iv; + func_glTexCoord4s_t orig_glTexCoord4s; + func_glTexCoord4sv_t orig_glTexCoord4sv; + func_glTexCoordPointer_t orig_glTexCoordPointer; + func_glTexEnvf_t orig_glTexEnvf; + func_glTexEnvfv_t orig_glTexEnvfv; + func_glTexEnvi_t orig_glTexEnvi; + func_glTexEnviv_t orig_glTexEnviv; + func_glTexGend_t orig_glTexGend; + func_glTexGendv_t orig_glTexGendv; + func_glTexGenf_t orig_glTexGenf; + func_glTexGenfv_t orig_glTexGenfv; + func_glTexGeni_t orig_glTexGeni; + func_glTexGeniv_t orig_glTexGeniv; + func_glTexImage1D_t orig_glTexImage1D; + func_glTexImage2D_t orig_glTexImage2D; + func_glTexParameterf_t orig_glTexParameterf; + func_glTexParameterfv_t orig_glTexParameterfv; + func_glTexParameteri_t orig_glTexParameteri; + func_glTexParameteriv_t orig_glTexParameteriv; + func_glTexSubImage1D_t orig_glTexSubImage1D; + func_glTexSubImage2D_t orig_glTexSubImage2D; + func_glTranslated_t orig_glTranslated; + func_glTranslatef_t orig_glTranslatef; + func_glVertex2d_t orig_glVertex2d; + func_glVertex2dv_t orig_glVertex2dv; + func_glVertex2f_t orig_glVertex2f; + func_glVertex2fv_t orig_glVertex2fv; + func_glVertex2i_t orig_glVertex2i; + func_glVertex2iv_t orig_glVertex2iv; + func_glVertex2s_t orig_glVertex2s; + func_glVertex2sv_t orig_glVertex2sv; + func_glVertex3d_t orig_glVertex3d; + func_glVertex3dv_t orig_glVertex3dv; + func_glVertex3f_t orig_glVertex3f; + func_glVertex3fv_t orig_glVertex3fv; + func_glVertex3i_t orig_glVertex3i; + func_glVertex3iv_t orig_glVertex3iv; + func_glVertex3s_t orig_glVertex3s; + func_glVertex3sv_t orig_glVertex3sv; + func_glVertex4d_t orig_glVertex4d; + func_glVertex4dv_t orig_glVertex4dv; + func_glVertex4f_t orig_glVertex4f; + func_glVertex4fv_t orig_glVertex4fv; + func_glVertex4i_t orig_glVertex4i; + func_glVertex4iv_t orig_glVertex4iv; + func_glVertex4s_t orig_glVertex4s; + func_glVertex4sv_t orig_glVertex4sv; + func_glVertexPointer_t orig_glVertexPointer; + func_glViewport_t orig_glViewport; + func_wglChoosePixelFormat_t orig_wglChoosePixelFormat; + func_wglCopyContext_t orig_wglCopyContext; + func_wglCreateContext_t orig_wglCreateContext; + func_wglCreateLayerContext_t orig_wglCreateLayerContext; + func_wglDeleteContext_t orig_wglDeleteContext; + func_wglDescribeLayerPlane_t orig_wglDescribeLayerPlane; + func_wglDescribePixelFormat_t orig_wglDescribePixelFormat; + func_wglGetCurrentContext_t orig_wglGetCurrentContext; + func_wglGetCurrentDC_t orig_wglGetCurrentDC; + func_wglGetDefaultProcAddress_t orig_wglGetDefaultProcAddress; + func_wglGetLayerPaletteEntries_t orig_wglGetLayerPaletteEntries; + func_wglGetPixelFormat_t orig_wglGetPixelFormat; + func_wglGetProcAddress_t orig_wglGetProcAddress; + func_wglMakeCurrent_t orig_wglMakeCurrent; + func_wglRealizeLayerPalette_t orig_wglRealizeLayerPalette; + func_wglSetLayerPaletteEntries_t orig_wglSetLayerPaletteEntries; + func_wglSetPixelFormat_t orig_wglSetPixelFormat; + func_wglShareLists_t orig_wglShareLists; + func_wglSwapBuffers_t orig_wglSwapBuffers; + func_wglSwapLayerBuffers_t orig_wglSwapLayerBuffers; + func_wglUseFontBitmapsA_t orig_wglUseFontBitmapsA; + func_wglUseFontBitmapsW_t orig_wglUseFontBitmapsW; + func_wglUseFontOutlinesA_t orig_wglUseFontOutlinesA; + func_wglUseFontOutlinesW_t orig_wglUseFontOutlinesW; + + func_glBegin_t orig_exp_glBegin; + DWORD *exp_glBegin = (DWORD*)0x013E4198; + func_glDrawElements_t orig_exp_glDrawElements; + DWORD *exp_glDrawElements = (DWORD*)0x013E3D04; + func_glViewport_t orig_exp_glViewport; + DWORD *exp_glViewport = (DWORD*)0x013E3FD0; + +BOOL glInit (void) +{ + /*char sysdir[MAX_PATH]; + + GetSystemDirectory (sysdir, sizeof(sysdir)); + strcat (sysdir, "\\"); + strcat (sysdir, ORIGINAL_DLL); + + hOpenGL = GetModuleHandle(sysdir); + + if ( !hOpenGL ) + return FALSE;*/ + +#if 0 + if ( (gl::qglAccum = (pfn_glAccum) GetProcAddress (hOpenGL, "glAccum")) == NULL ) + return FALSE; + + if ( (gl::qglAlphaFunc = (pfn_glAlphaFunc) GetProcAddress (hOpenGL, "glAlphaFunc")) == NULL ) + return FALSE; + + if ( (gl::qglAreTexturesResident = (pfn_glAreTexturesResident) GetProcAddress (hOpenGL, "glAreTexturesResident")) == NULL ) + return FALSE; + + if ( (gl::qglArrayElement = (pfn_glArrayElement) GetProcAddress (hOpenGL, "glArrayElement")) == NULL ) + return FALSE; + + if ( (gl::qglBegin = (pfn_glBegin) GetProcAddress (hOpenGL, "glBegin")) == NULL ) + return FALSE; + + if ( (gl::qglBindTexture = (pfn_glBindTexture) GetProcAddress (hOpenGL, "glBindTexture")) == NULL ) + return FALSE; + + if ( (gl::qglBitmap = (pfn_glBitmap) GetProcAddress (hOpenGL, "glBitmap")) == NULL ) + return FALSE; + + if ( (gl::qglBlendFunc = (pfn_glBlendFunc) GetProcAddress (hOpenGL, "glBlendFunc")) == NULL ) + return FALSE; + + if ( (gl::qglCallList = (pfn_glCallList) GetProcAddress (hOpenGL, "glCallList")) == NULL ) + return FALSE; + + if ( (gl::qglCallLists = (pfn_glCallLists) GetProcAddress (hOpenGL, "glCallLists")) == NULL ) + return FALSE; + + if ( (gl::qglClear = (pfn_glClear) GetProcAddress (hOpenGL, "glClear")) == NULL ) + return FALSE; + + if ( (gl::qglClearAccum = (pfn_glClearAccum) GetProcAddress (hOpenGL, "glClearAccum")) == NULL ) + return FALSE; + + if ( (gl::qglClearColor = (pfn_glClearColor) GetProcAddress (hOpenGL, "glClearColor")) == NULL ) + return FALSE; + + if ( (gl::qglClearDepth = (pfn_glClearDepth) GetProcAddress (hOpenGL, "glClearDepth")) == NULL ) + return FALSE; + + if ( (gl::qglClearIndex = (pfn_glClearIndex) GetProcAddress (hOpenGL, "glClearIndex")) == NULL ) + return FALSE; + + if ( (gl::qglClearStencil = (pfn_glClearStencil) GetProcAddress (hOpenGL, "glClearStencil")) == NULL ) + return FALSE; + + if ( (gl::qglClipPlane = (pfn_glClipPlane) GetProcAddress (hOpenGL, "glClipPlane")) == NULL ) + return FALSE; + + if ( (gl::qglColor3b = (pfn_glColor3b) GetProcAddress (hOpenGL, "glColor3b")) == NULL ) + return FALSE; + + if ( (gl::qglColor3bv = (pfn_glColor3bv) GetProcAddress (hOpenGL, "glColor3bv")) == NULL ) + return FALSE; + + if ( (gl::qglColor3d = (pfn_glColor3d) GetProcAddress (hOpenGL, "glColor3d")) == NULL ) + return FALSE; + + if ( (gl::qglColor3dv = (pfn_glColor3dv) GetProcAddress (hOpenGL, "glColor3dv")) == NULL ) + return FALSE; + + if ( (gl::qglColor3f = (pfn_glColor3f) GetProcAddress (hOpenGL, "glColor3f")) == NULL ) + return FALSE; + + if ( (gl::qglColor3fv = (pfn_glColor3fv) GetProcAddress (hOpenGL, "glColor3fv")) == NULL ) + return FALSE; + + if ( (gl::qglColor3i = (pfn_glColor3i) GetProcAddress (hOpenGL, "glColor3i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor3i()"); + return FALSE; + } + + if ( (gl::qglColor3iv = (pfn_glColor3iv) GetProcAddress (hOpenGL, "glColor3iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor3iv()"); + return FALSE; + } + + if ( (gl::qglColor3s = (pfn_glColor3s) GetProcAddress (hOpenGL, "glColor3s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor3s()"); + return FALSE; + } + + if ( (gl::qglColor3sv = (pfn_glColor3sv) GetProcAddress (hOpenGL, "glColor3sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor3sv()"); + return FALSE; + } + + if ( (gl::qglColor3ub = (pfn_glColor3ub) GetProcAddress (hOpenGL, "glColor3ub")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor3ub()"); + return FALSE; + } + + if ( (gl::qglColor3ubv = (pfn_glColor3ubv) GetProcAddress (hOpenGL, "glColor3ubv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor3ubv()"); + return FALSE; + } + + if ( (gl::qglColor3ui = (pfn_glColor3ui) GetProcAddress (hOpenGL, "glColor3ui")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor3ui()"); + return FALSE; + } + + if ( (gl::qglColor3uiv = (pfn_glColor3uiv) GetProcAddress (hOpenGL, "glColor3uiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor3uiv()"); + return FALSE; + } + + if ( (gl::qglColor3us = (pfn_glColor3us) GetProcAddress (hOpenGL, "glColor3us")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor3us()"); + return FALSE; + } + + if ( (gl::qglColor3usv = (pfn_glColor3usv) GetProcAddress (hOpenGL, "glColor3usv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor3usv()"); + return FALSE; + } + + if ( (gl::qglColor4b = (pfn_glColor4b) GetProcAddress (hOpenGL, "glColor4b")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4b()"); + return FALSE; + } + + if ( (gl::qglColor4bv = (pfn_glColor4bv) GetProcAddress (hOpenGL, "glColor4bv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4bv()"); + return FALSE; + } + + if ( (gl::qglColor4d = (pfn_glColor4d) GetProcAddress (hOpenGL, "glColor4d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4d()"); + return FALSE; + } + + if ( (gl::qglColor4dv = (pfn_glColor4dv) GetProcAddress (hOpenGL, "glColor4dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4dv()"); + return FALSE; + } + + if ( (gl::qglColor4f = (pfn_glColor4f) GetProcAddress (hOpenGL, "glColor4f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4f()"); + return FALSE; + } + + if ( (gl::qglColor4fv = (pfn_glColor4fv) GetProcAddress (hOpenGL, "glColor4fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4fv()"); + return FALSE; + } + + if ( (gl::qglColor4i = (pfn_glColor4i) GetProcAddress (hOpenGL, "glColor4i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4i()"); + return FALSE; + } + + if ( (gl::qglColor4iv = (pfn_glColor4iv) GetProcAddress (hOpenGL, "glColor4iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4iv()"); + return FALSE; + } + + if ( (gl::qglColor4s = (pfn_glColor4s) GetProcAddress (hOpenGL, "glColor4s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4s()"); + return FALSE; + } + + if ( (gl::qglColor4sv = (pfn_glColor4sv) GetProcAddress (hOpenGL, "glColor4sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4sv()"); + return FALSE; + } + + if ( (gl::qglColor4ub = (pfn_glColor4ub) GetProcAddress (hOpenGL, "glColor4ub")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4ub()"); + return FALSE; + } + + if ( (gl::qglColor4ubv = (pfn_glColor4ubv) GetProcAddress (hOpenGL, "glColor4ubv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4ubv()"); + return FALSE; + } + + if ( (gl::qglColor4ui = (pfn_glColor4ui) GetProcAddress (hOpenGL, "glColor4ui")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4ui()"); + return FALSE; + } + + if ( (gl::qglColor4uiv = (pfn_glColor4uiv) GetProcAddress (hOpenGL, "glColor4uiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4uiv()"); + return FALSE; + } + + if ( (gl::qglColor4us = (pfn_glColor4us) GetProcAddress (hOpenGL, "glColor4us")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4us()"); + return FALSE; + } + + if ( (gl::qglColor4usv = (pfn_glColor4usv) GetProcAddress (hOpenGL, "glColor4usv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColor4usv()"); + return FALSE; + } + + if ( (gl::qglColorMask = (pfn_glColorMask) GetProcAddress (hOpenGL, "glColorMask")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColorMask()"); + return FALSE; + } + + if ( (gl::qglColorMaterial = (pfn_glColorMaterial) GetProcAddress (hOpenGL, "glColorMaterial")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColorMaterial()"); + return FALSE; + } + + if ( (gl::qglColorPointer = (pfn_glColorPointer) GetProcAddress (hOpenGL, "glColorPointer")) == NULL ) + { + //add_log ("Couldn't found a prototype for glColorPointer()"); + return FALSE; + } + + if ( (gl::qglCopyPixels = (pfn_glCopyPixels) GetProcAddress (hOpenGL, "glCopyPixels")) == NULL ) + { + //add_log ("Couldn't found a prototype for glCopyPixels()"); + return FALSE; + } + + if ( (gl::qglCopyTexImage1D = (pfn_glCopyTexImage1D) GetProcAddress (hOpenGL, "glCopyTexImage1D")) == NULL ) + { + //add_log ("Couldn't found a prototype for glCopyTexImage1D()"); + return FALSE; + } + + if ( (gl::qglCopyTexImage2D = (pfn_glCopyTexImage2D) GetProcAddress (hOpenGL, "glCopyTexImage2D")) == NULL ) + { + //add_log ("Couldn't found a prototype for glCopyTexImage2D()"); + return FALSE; + } + + if ( (gl::qglCopyTexSubImage1D = (pfn_glCopyTexSubImage1D) GetProcAddress (hOpenGL, "glCopyTexSubImage1D")) == NULL ) + { + //add_log ("Couldn't found a prototype for glCopyTexSubImage1D()"); + return FALSE; + } + + if ( (gl::qglCopyTexSubImage2D = (pfn_glCopyTexSubImage2D) GetProcAddress (hOpenGL, "glCopyTexSubImage2D")) == NULL ) + { + //add_log ("Couldn't found a prototype for glCopyTexSubImage2D()"); + return FALSE; + } + + if ( (gl::qglCullFace = (pfn_glCullFace) GetProcAddress (hOpenGL, "glCullFace")) == NULL ) + { + //add_log ("Couldn't found a prototype for glCullFace()"); + return FALSE; + } + + /*if ( (gl::qglDebugEntry = (pfn_glDebugEntry) GetProcAddress (hOpenGL, "glDebugEntry")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDebugEntry()"); + return FALSE; + }*/ + + if ( (gl::qglDeleteLists = (pfn_glDeleteLists) GetProcAddress (hOpenGL, "glDeleteLists")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDeleteLists()"); + return FALSE; + } + + if ( (gl::qglDeleteTextures = (pfn_glDeleteTextures) GetProcAddress (hOpenGL, "glDeleteTextures")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDeleteTextures()"); + return FALSE; + } + + if ( (gl::qglDepthFunc = (pfn_glDepthFunc) GetProcAddress (hOpenGL, "glDepthFunc")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDepthFunc()"); + return FALSE; + } + + if ( (gl::qglDepthMask = (pfn_glDepthMask) GetProcAddress (hOpenGL, "glDepthMask")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDepthMask()"); + return FALSE; + } + + if ( (gl::qglDepthRange = (pfn_glDepthRange) GetProcAddress (hOpenGL, "glDepthRange")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDepthRange()"); + return FALSE; + } + + if ( (gl::qglDisable = (pfn_glDisable) GetProcAddress (hOpenGL, "glDisable")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDisable()"); + return FALSE; + } + + if ( (gl::qglDisableClientState = (pfn_glDisableClientState) GetProcAddress (hOpenGL, "glDisableClientState")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDisableClientState()"); + return FALSE; + } + + if ( (gl::qglDrawArrays = (pfn_glDrawArrays) GetProcAddress (hOpenGL, "glDrawArrays")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDrawArrays()"); + return FALSE; + } + + if ( (gl::qglDrawBuffer = (pfn_glDrawBuffer) GetProcAddress (hOpenGL, "glDrawBuffer")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDrawBuffer()"); + return FALSE; + } + + if ( (gl::qglDrawElements = (pfn_glDrawElements) GetProcAddress (hOpenGL, "glDrawElements")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDrawElements()"); + return FALSE; + } + + if ( (gl::qglDrawPixels = (pfn_glDrawPixels) GetProcAddress (hOpenGL, "glDrawPixels")) == NULL ) + { + //add_log ("Couldn't found a prototype for glDrawPixels()"); + return FALSE; + } + + if ( (gl::qglEdgeFlag = (pfn_glEdgeFlag) GetProcAddress (hOpenGL, "glEdgeFlag")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEdgeFlag()"); + return FALSE; + } + + if ( (gl::qglEdgeFlagPointer = (pfn_glEdgeFlagPointer) GetProcAddress (hOpenGL, "glEdgeFlagPointer")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEdgeFlagPointer()"); + return FALSE; + } + + if ( (gl::qglEdgeFlagv = (pfn_glEdgeFlagv) GetProcAddress (hOpenGL, "glEdgeFlagv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEdgeFlagv()"); + return FALSE; + } + + if ( (gl::qglEnable = (pfn_glEnable) GetProcAddress (hOpenGL, "glEnable")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEnable()"); + return FALSE; + } + + if ( (gl::qglEnableClientState = (pfn_glEnableClientState) GetProcAddress (hOpenGL, "glEnableClientState")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEnableClientState()"); + return FALSE; + } + + if ( (gl::qglEnd = (pfn_glEnd) GetProcAddress (hOpenGL, "glEnd")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEnd()"); + return FALSE; + } + + if ( (gl::qglEndList = (pfn_glEndList) GetProcAddress (hOpenGL, "glEndList")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEndList()"); + return FALSE; + } + + if ( (gl::qglEvalCoord1d = (pfn_glEvalCoord1d) GetProcAddress (hOpenGL, "glEvalCoord1d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalCoord1d()"); + return FALSE; + } + + if ( (gl::qglEvalCoord1dv = (pfn_glEvalCoord1dv) GetProcAddress (hOpenGL, "glEvalCoord1dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalCoord1dv()"); + return FALSE; + } + + if ( (gl::qglEvalCoord1f = (pfn_glEvalCoord1f) GetProcAddress (hOpenGL, "glEvalCoord1f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalCoord1f()"); + return FALSE; + } + + if ( (gl::qglEvalCoord1fv = (pfn_glEvalCoord1fv) GetProcAddress (hOpenGL, "glEvalCoord1fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalCoord1fv()"); + return FALSE; + } + + if ( (gl::qglEvalCoord2d = (pfn_glEvalCoord2d) GetProcAddress (hOpenGL, "glEvalCoord2d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalCoord2d()"); + return FALSE; + } + + if ( (gl::qglEvalCoord2dv = (pfn_glEvalCoord2dv) GetProcAddress (hOpenGL, "glEvalCoord2dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalCoord2dv()"); + return FALSE; + } + + if ( (gl::qglEvalCoord2f = (pfn_glEvalCoord2f) GetProcAddress (hOpenGL, "glEvalCoord2f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalCoord2f()"); + return FALSE; + } + + if ( (gl::qglEvalCoord2fv = (pfn_glEvalCoord2fv) GetProcAddress (hOpenGL, "glEvalCoord2fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalCoord2fv()"); + return FALSE; + } + + if ( (gl::qglEvalMesh1 = (pfn_glEvalMesh1) GetProcAddress (hOpenGL, "glEvalMesh1")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalMesh1()"); + return FALSE; + } + + if ( (gl::qglEvalMesh2 = (pfn_glEvalMesh2) GetProcAddress (hOpenGL, "glEvalMesh2")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalMesh2()"); + return FALSE; + } + + if ( (gl::qglEvalPoint1 = (pfn_glEvalPoint1) GetProcAddress (hOpenGL, "glEvalPoint1")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalPoint1()"); + return FALSE; + } + + if ( (gl::qglEvalPoint2 = (pfn_glEvalPoint2) GetProcAddress (hOpenGL, "glEvalPoint2")) == NULL ) + { + //add_log ("Couldn't found a prototype for glEvalPoint2()"); + return FALSE; + } + + if ( (gl::qglFeedbackBuffer = (pfn_glFeedbackBuffer) GetProcAddress (hOpenGL, "glFeedbackBuffer")) == NULL ) + { + //add_log ("Couldn't found a prototype for glFeedbackBuffer()"); + return FALSE; + } + + if ( (gl::qglFinish = (pfn_glFinish) GetProcAddress (hOpenGL, "glFinish")) == NULL ) + { + //add_log ("Couldn't found a prototype for glFinish()"); + return FALSE; + } + + if ( (gl::qglFlush = (pfn_glFlush) GetProcAddress (hOpenGL, "glFlush")) == NULL ) + { + //add_log ("Couldn't found a prototype for glFlush()"); + return FALSE; + } + + if ( (gl::qglFogf = (pfn_glFogf) GetProcAddress (hOpenGL, "glFogf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glFogf()"); + return FALSE; + } + + if ( (gl::qglFogfv = (pfn_glFogfv) GetProcAddress (hOpenGL, "glFogfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glFogfv()"); + return FALSE; + } + + if ( (gl::qglFogi = (pfn_glFogi) GetProcAddress (hOpenGL, "glFogi")) == NULL ) + { + //add_log ("Couldn't found a prototype for glFogi()"); + return FALSE; + } + + if ( (gl::qglFogiv = (pfn_glFogiv) GetProcAddress (hOpenGL, "glFogiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glFogiv()"); + return FALSE; + } + + if ( (gl::qglFrontFace = (pfn_glFrontFace) GetProcAddress (hOpenGL, "glFrontFace")) == NULL ) + { + //add_log ("Couldn't found a prototype for glFrontFace()"); + return FALSE; + } + + if ( (gl::qglFrustum = (pfn_glFrustum) GetProcAddress (hOpenGL, "glFrustum")) == NULL ) + { + //add_log ("Couldn't found a prototype for glFrustum()"); + return FALSE; + } + + if ( (gl::qglGenLists = (pfn_glGenLists) GetProcAddress (hOpenGL, "glGenLists")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGenLists()"); + return FALSE; + } + + if ( (gl::qglGenTextures = (pfn_glGenTextures) GetProcAddress (hOpenGL, "glGenTextures")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGenTextures()"); + return FALSE; + } + + if ( (gl::qglGetBooleanv = (pfn_glGetBooleanv) GetProcAddress (hOpenGL, "glGetBooleanv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetBooleanv()"); + return FALSE; + } + + if ( (gl::qglGetClipPlane = (pfn_glGetClipPlane) GetProcAddress (hOpenGL, "glGetClipPlane")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetClipPlane()"); + return FALSE; + } + + if ( (gl::qglGetDoublev = (pfn_glGetDoublev) GetProcAddress (hOpenGL, "glGetDoublev")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetDoublev()"); + return FALSE; + } + + if ( (gl::qglGetError = (pfn_glGetError) GetProcAddress (hOpenGL, "glGetError")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetError()"); + return FALSE; + } + + if ( (gl::qglGetFloatv = (pfn_glGetFloatv) GetProcAddress (hOpenGL, "glGetFloatv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetFloatv()"); + return FALSE; + } + + if ( (gl::qglGetIntegerv = (pfn_glGetIntegerv) GetProcAddress (hOpenGL, "glGetIntegerv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetIntegerv()"); + return FALSE; + } + + if ( (gl::qglGetLightfv = (pfn_glGetLightfv) GetProcAddress (hOpenGL, "glGetLightfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetLightfv()"); + return FALSE; + } + + if ( (gl::qglGetLightiv = (pfn_glGetLightiv) GetProcAddress (hOpenGL, "glGetLightiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetLightiv()"); + return FALSE; + } + + if ( (gl::qglGetMapdv = (pfn_glGetMapdv) GetProcAddress (hOpenGL, "glGetMapdv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetMapdv()"); + return FALSE; + } + + if ( (gl::qglGetMapfv = (pfn_glGetMapfv) GetProcAddress (hOpenGL, "glGetMapfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetMapfv()"); + return FALSE; + } + + if ( (gl::qglGetMapiv = (pfn_glGetMapiv) GetProcAddress (hOpenGL, "glGetMapiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetMapiv()"); + return FALSE; + } + + if ( (gl::qglGetMaterialfv = (pfn_glGetMaterialfv) GetProcAddress (hOpenGL, "glGetMaterialfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetMaterialfv()"); + return FALSE; + } + + if ( (gl::qglGetMaterialiv = (pfn_glGetMaterialiv) GetProcAddress (hOpenGL, "glGetMaterialiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetMaterialiv()"); + return FALSE; + } + + if ( (gl::qglGetPixelMapfv = (pfn_glGetPixelMapfv) GetProcAddress (hOpenGL, "glGetPixelMapfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetPixelMapfv()"); + return FALSE; + } + + if ( (gl::qglGetPixelMapuiv = (pfn_glGetPixelMapuiv) GetProcAddress (hOpenGL, "glGetPixelMapuiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetPixelMapuiv()"); + return FALSE; + } + + if ( (gl::qglGetPixelMapusv = (pfn_glGetPixelMapusv) GetProcAddress (hOpenGL, "glGetPixelMapusv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetPixelMapusv()"); + return FALSE; + } + + if ( (gl::qglGetPointerv = (pfn_glGetPointerv) GetProcAddress (hOpenGL, "glGetPointerv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetPointerv()"); + return FALSE; + } + + if ( (gl::qglGetPolygonStipple = (pfn_glGetPolygonStipple) GetProcAddress (hOpenGL, "glGetPolygonStipple")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetPolygonStipple()"); + return FALSE; + } + + if ( (gl::qglGetString = (pfn_glGetString) GetProcAddress (hOpenGL, "glGetString")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetString()"); + return FALSE; + } + + if ( (gl::qglGetTexEnvfv = (pfn_glGetTexEnvfv) GetProcAddress (hOpenGL, "glGetTexEnvfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetTexEnvfv()"); + return FALSE; + } + + if ( (gl::qglGetTexEnviv = (pfn_glGetTexEnviv) GetProcAddress (hOpenGL, "glGetTexEnviv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetTexEnviv()"); + return FALSE; + } + + if ( (gl::qglGetTexGendv = (pfn_glGetTexGendv) GetProcAddress (hOpenGL, "glGetTexGendv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetTexGendv()"); + return FALSE; + } + + if ( (gl::qglGetTexGenfv = (pfn_glGetTexGenfv) GetProcAddress (hOpenGL, "glGetTexGenfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetTexGenfv()"); + return FALSE; + } + + if ( (gl::qglGetTexGeniv = (pfn_glGetTexGeniv) GetProcAddress (hOpenGL, "glGetTexGeniv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetTexGeniv()"); + return FALSE; + } + + if ( (gl::qglGetTexImage = (pfn_glGetTexImage) GetProcAddress (hOpenGL, "glGetTexImage")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetTexImage()"); + return FALSE; + } + + if ( (gl::qglGetTexLevelParameterfv = (pfn_glGetTexLevelParameterfv) GetProcAddress (hOpenGL, "glGetTexLevelParameterfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetTexLevelParameterfv()"); + return FALSE; + } + + if ( (gl::qglGetTexLevelParameteriv = (pfn_glGetTexLevelParameteriv) GetProcAddress (hOpenGL, "glGetTexLevelParameteriv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetTexLevelParameteriv()"); + return FALSE; + } + + if ( (gl::qglGetTexParameterfv = (pfn_glGetTexParameterfv) GetProcAddress (hOpenGL, "glGetTexParameterfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetTexParameterfv()"); + return FALSE; + } + + if ( (gl::qglGetTexParameteriv = (pfn_glGetTexParameteriv) GetProcAddress (hOpenGL, "glGetTexParameteriv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glGetTexParameteriv()"); + return FALSE; + } + + if ( (gl::qglHint = (pfn_glHint) GetProcAddress (hOpenGL, "glHint")) == NULL ) + { + //add_log ("Couldn't found a prototype for glHint()"); + return FALSE; + } + + if ( (gl::qglIndexMask = (pfn_glIndexMask) GetProcAddress (hOpenGL, "glIndexMask")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexMask()"); + return FALSE; + } + + if ( (gl::qglIndexPointer = (pfn_glIndexPointer) GetProcAddress (hOpenGL, "glIndexPointer")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexPointer()"); + return FALSE; + } + + if ( (gl::qglIndexd = (pfn_glIndexd) GetProcAddress (hOpenGL, "glIndexd")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexd()"); + return FALSE; + } + + if ( (gl::qglIndexdv = (pfn_glIndexdv) GetProcAddress (hOpenGL, "glIndexdv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexdv()"); + return FALSE; + } + + if ( (gl::qglIndexf = (pfn_glIndexf) GetProcAddress (hOpenGL, "glIndexf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexf()"); + return FALSE; + } + + if ( (gl::qglIndexfv = (pfn_glIndexfv) GetProcAddress (hOpenGL, "glIndexfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexfv()"); + return FALSE; + } + + if ( (gl::qglIndexi = (pfn_glIndexi) GetProcAddress (hOpenGL, "glIndexi")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexi()"); + return FALSE; + } + + if ( (gl::qglIndexiv = (pfn_glIndexiv) GetProcAddress (hOpenGL, "glIndexiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexiv()"); + return FALSE; + } + + if ( (gl::qglIndexs = (pfn_glIndexs) GetProcAddress (hOpenGL, "glIndexs")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexs()"); + return FALSE; + } + + if ( (gl::qglIndexsv = (pfn_glIndexsv) GetProcAddress (hOpenGL, "glIndexsv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexsv()"); + return FALSE; + } + + if ( (gl::qglIndexub = (pfn_glIndexub) GetProcAddress (hOpenGL, "glIndexub")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexub()"); + return FALSE; + } + + if ( (gl::qglIndexubv = (pfn_glIndexubv) GetProcAddress (hOpenGL, "glIndexubv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIndexubv()"); + return FALSE; + } + + if ( (gl::qglInitNames = (pfn_glInitNames) GetProcAddress (hOpenGL, "glInitNames")) == NULL ) + { + //add_log ("Couldn't found a prototype for glInitNames()"); + return FALSE; + } + + if ( (gl::qglInterleavedArrays = (pfn_glInterleavedArrays) GetProcAddress (hOpenGL, "glInterleavedArrays")) == NULL ) + { + //add_log ("Couldn't found a prototype for glInterleavedArrays()"); + return FALSE; + } + + if ( (gl::qglIsEnabled = (pfn_glIsEnabled) GetProcAddress (hOpenGL, "glIsEnabled")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIsEnabled()"); + return FALSE; + } + + if ( (gl::qglIsList = (pfn_glIsList) GetProcAddress (hOpenGL, "glIsList")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIsList()"); + return FALSE; + } + + if ( (gl::qglIsTexture = (pfn_glIsTexture) GetProcAddress (hOpenGL, "glIsTexture")) == NULL ) + { + //add_log ("Couldn't found a prototype for glIsTexture()"); + return FALSE; + } + + if ( (gl::qglLightModelf = (pfn_glLightModelf) GetProcAddress (hOpenGL, "glLightModelf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLightModelf()"); + return FALSE; + } + + if ( (gl::qglLightModelfv = (pfn_glLightModelfv) GetProcAddress (hOpenGL, "glLightModelfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLightModelfv()"); + return FALSE; + } + + if ( (gl::qglLightModeli = (pfn_glLightModeli) GetProcAddress (hOpenGL, "glLightModeli")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLightModeli()"); + return FALSE; + } + + if ( (gl::qglLightModeliv = (pfn_glLightModeliv) GetProcAddress (hOpenGL, "glLightModeliv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLightModeliv()"); + return FALSE; + } + + if ( (gl::qglLightf = (pfn_glLightf) GetProcAddress (hOpenGL, "glLightf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLightf()"); + return FALSE; + } + + if ( (gl::qglLightfv = (pfn_glLightfv) GetProcAddress (hOpenGL, "glLightfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLightfv()"); + return FALSE; + } + + if ( (gl::qglLighti = (pfn_glLighti) GetProcAddress (hOpenGL, "glLighti")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLighti()"); + return FALSE; + } + + if ( (gl::qglLightiv = (pfn_glLightiv) GetProcAddress (hOpenGL, "glLightiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLightiv()"); + return FALSE; + } + + if ( (gl::qglLineStipple = (pfn_glLineStipple) GetProcAddress (hOpenGL, "glLineStipple")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLineStipple()"); + return FALSE; + } + + if ( (gl::qglLineWidth = (pfn_glLineWidth) GetProcAddress (hOpenGL, "glLineWidth")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLineWidth()"); + return FALSE; + } + + if ( (gl::qglListBase = (pfn_glListBase) GetProcAddress (hOpenGL, "glListBase")) == NULL ) + { + //add_log ("Couldn't found a prototype for glListBase()"); + return FALSE; + } + + if ( (gl::qglLoadIdentity = (pfn_glLoadIdentity) GetProcAddress (hOpenGL, "glLoadIdentity")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLoadIdentity()"); + return FALSE; + } + + if ( (gl::qglLoadMatrixd = (pfn_glLoadMatrixd) GetProcAddress (hOpenGL, "glLoadMatrixd")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLoadMatrixd()"); + return FALSE; + } + + if ( (gl::qglLoadMatrixf = (pfn_glLoadMatrixf) GetProcAddress (hOpenGL, "glLoadMatrixf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLoadMatrixf()"); + return FALSE; + } + + if ( (gl::qglLoadName = (pfn_glLoadName) GetProcAddress (hOpenGL, "glLoadName")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLoadName()"); + return FALSE; + } + + if ( (gl::qglLogicOp = (pfn_glLogicOp) GetProcAddress (hOpenGL, "glLogicOp")) == NULL ) + { + //add_log ("Couldn't found a prototype for glLogicOp()"); + return FALSE; + } + + if ( (gl::qglMap1d = (pfn_glMap1d) GetProcAddress (hOpenGL, "glMap1d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMap1d()"); + return FALSE; + } + + if ( (gl::qglMap1f = (pfn_glMap1f) GetProcAddress (hOpenGL, "glMap1f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMap1f()"); + return FALSE; + } + + if ( (gl::qglMap2d = (pfn_glMap2d) GetProcAddress (hOpenGL, "glMap2d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMap2d()"); + return FALSE; + } + + if ( (gl::qglMap2f = (pfn_glMap2f) GetProcAddress (hOpenGL, "glMap2f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMap2f()"); + return FALSE; + } + + if ( (gl::qglMapGrid1d = (pfn_glMapGrid1d) GetProcAddress (hOpenGL, "glMapGrid1d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMapGrid1d()"); + return FALSE; + } + + if ( (gl::qglMapGrid1f = (pfn_glMapGrid1f) GetProcAddress (hOpenGL, "glMapGrid1f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMapGrid1f()"); + return FALSE; + } + + if ( (gl::qglMapGrid2d = (pfn_glMapGrid2d) GetProcAddress (hOpenGL, "glMapGrid2d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMapGrid2d()"); + return FALSE; + } + + if ( (gl::qglMapGrid2f = (pfn_glMapGrid2f) GetProcAddress (hOpenGL, "glMapGrid2f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMapGrid2f()"); + return FALSE; + } + + if ( (gl::qglMaterialf = (pfn_glMaterialf) GetProcAddress (hOpenGL, "glMaterialf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMaterialf()"); + return FALSE; + } + + if ( (gl::qglMaterialfv = (pfn_glMaterialfv) GetProcAddress (hOpenGL, "glMaterialfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMaterialfv()"); + return FALSE; + } + + if ( (gl::qglMateriali = (pfn_glMateriali) GetProcAddress (hOpenGL, "glMateriali")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMateriali()"); + return FALSE; + } + + if ( (gl::qglMaterialiv = (pfn_glMaterialiv) GetProcAddress (hOpenGL, "glMaterialiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMaterialiv()"); + return FALSE; + } + + if ( (gl::qglMatrixMode = (pfn_glMatrixMode) GetProcAddress (hOpenGL, "glMatrixMode")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMatrixMode()"); + return FALSE; + } + + if ( (gl::qglMultMatrixd = (pfn_glMultMatrixd) GetProcAddress (hOpenGL, "glMultMatrixd")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMultMatrixd()"); + return FALSE; + } + + if ( (gl::qglMultMatrixf = (pfn_glMultMatrixf) GetProcAddress (hOpenGL, "glMultMatrixf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glMultMatrixf()"); + return FALSE; + } + + if ( (gl::qglNewList = (pfn_glNewList) GetProcAddress (hOpenGL, "glNewList")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNewList()"); + return FALSE; + } + + if ( (gl::qglNormal3b = (pfn_glNormal3b) GetProcAddress (hOpenGL, "glNormal3b")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormal3b()"); + return FALSE; + } + + if ( (gl::qglNormal3bv = (pfn_glNormal3bv) GetProcAddress (hOpenGL, "glNormal3bv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormal3bv()"); + return FALSE; + } + + if ( (gl::qglNormal3d = (pfn_glNormal3d) GetProcAddress (hOpenGL, "glNormal3d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormal3d()"); + return FALSE; + } + + if ( (gl::qglNormal3dv = (pfn_glNormal3dv) GetProcAddress (hOpenGL, "glNormal3dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormal3dv()"); + return FALSE; + } + + if ( (gl::qglNormal3f = (pfn_glNormal3f) GetProcAddress (hOpenGL, "glNormal3f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormal3f()"); + return FALSE; + } + + if ( (gl::qglNormal3fv = (pfn_glNormal3fv) GetProcAddress (hOpenGL, "glNormal3fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormal3fv()"); + return FALSE; + } + + if ( (gl::qglNormal3i = (pfn_glNormal3i) GetProcAddress (hOpenGL, "glNormal3i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormal3i()"); + return FALSE; + } + + if ( (gl::qglNormal3iv = (pfn_glNormal3iv) GetProcAddress (hOpenGL, "glNormal3iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormal3iv()"); + return FALSE; + } + + if ( (gl::qglNormal3s = (pfn_glNormal3s) GetProcAddress (hOpenGL, "glNormal3s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormal3s()"); + return FALSE; + } + + if ( (gl::qglNormal3sv = (pfn_glNormal3sv) GetProcAddress (hOpenGL, "glNormal3sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormal3sv()"); + return FALSE; + } + + if ( (gl::qglNormalPointer = (pfn_glNormalPointer) GetProcAddress (hOpenGL, "glNormalPointer")) == NULL ) + { + //add_log ("Couldn't found a prototype for glNormalPointer()"); + return FALSE; + } + + if ( (gl::qglOrtho = (pfn_glOrtho) GetProcAddress (hOpenGL, "glOrtho")) == NULL ) + { + //add_log ("Couldn't found a prototype for glOrtho()"); + return FALSE; + } + + if ( (gl::qglPassThrough = (pfn_glPassThrough) GetProcAddress (hOpenGL, "glPassThrough")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPassThrough()"); + return FALSE; + } + + if ( (gl::qglPixelMapfv = (pfn_glPixelMapfv) GetProcAddress (hOpenGL, "glPixelMapfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPixelMapfv()"); + return FALSE; + } + + if ( (gl::qglPixelMapuiv = (pfn_glPixelMapuiv) GetProcAddress (hOpenGL, "glPixelMapuiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPixelMapuiv()"); + return FALSE; + } + + if ( (gl::qglPixelMapusv = (pfn_glPixelMapusv) GetProcAddress (hOpenGL, "glPixelMapusv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPixelMapusv()"); + return FALSE; + } + + if ( (gl::qglPixelStoref = (pfn_glPixelStoref) GetProcAddress (hOpenGL, "glPixelStoref")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPixelStoref()"); + return FALSE; + } + + if ( (gl::qglPixelStorei = (pfn_glPixelStorei) GetProcAddress (hOpenGL, "glPixelStorei")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPixelStorei()"); + return FALSE; + } + + if ( (gl::qglPixelTransferf = (pfn_glPixelTransferf) GetProcAddress (hOpenGL, "glPixelTransferf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPixelTransferf()"); + return FALSE; + } + + if ( (gl::qglPixelTransferi = (pfn_glPixelTransferi) GetProcAddress (hOpenGL, "glPixelTransferi")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPixelTransferi()"); + return FALSE; + } + + if ( (gl::qglPixelZoom = (pfn_glPixelZoom) GetProcAddress (hOpenGL, "glPixelZoom")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPixelZoom()"); + return FALSE; + } + + if ( (gl::qglPointSize = (pfn_glPointSize) GetProcAddress (hOpenGL, "glPointSize")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPointSize()"); + return FALSE; + } + + if ( (gl::qglPolygonMode = (pfn_glPolygonMode) GetProcAddress (hOpenGL, "glPolygonMode")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPolygonMode()"); + return FALSE; + } + + if ( (gl::qglPolygonOffset = (pfn_glPolygonOffset) GetProcAddress (hOpenGL, "glPolygonOffset")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPolygonOffset()"); + return FALSE; + } + + if ( (gl::qglPolygonStipple = (pfn_glPolygonStipple) GetProcAddress (hOpenGL, "glPolygonStipple")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPolygonStipple()"); + return FALSE; + } + + if ( (gl::qglPopAttrib = (pfn_glPopAttrib) GetProcAddress (hOpenGL, "glPopAttrib")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPopAttrib()"); + return FALSE; + } + + if ( (gl::qglPopClientAttrib = (pfn_glPopClientAttrib) GetProcAddress (hOpenGL, "glPopClientAttrib")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPopClientAttrib()"); + return FALSE; + } + + if ( (gl::qglPopMatrix = (pfn_glPopMatrix) GetProcAddress (hOpenGL, "glPopMatrix")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPopMatrix()"); + return FALSE; + } + + if ( (gl::qglPopName = (pfn_glPopName) GetProcAddress (hOpenGL, "glPopName")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPopName()"); + return FALSE; + } + + if ( (gl::qglPrioritizeTextures = (pfn_glPrioritizeTextures) GetProcAddress (hOpenGL, "glPrioritizeTextures")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPrioritizeTextures()"); + return FALSE; + } + + if ( (gl::qglPushAttrib = (pfn_glPushAttrib) GetProcAddress (hOpenGL, "glPushAttrib")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPushAttrib()"); + return FALSE; + } + + if ( (gl::qglPushClientAttrib = (pfn_glPushClientAttrib) GetProcAddress (hOpenGL, "glPushClientAttrib")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPushClientAttrib()"); + return FALSE; + } + + if ( (gl::qglPushMatrix = (pfn_glPushMatrix) GetProcAddress (hOpenGL, "glPushMatrix")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPushMatrix()"); + return FALSE; + } + + if ( (gl::qglPushName = (pfn_glPushName) GetProcAddress (hOpenGL, "glPushName")) == NULL ) + { + //add_log ("Couldn't found a prototype for glPushName()"); + return FALSE; + } + + if ( (gl::qglRasterPos2d = (pfn_glRasterPos2d) GetProcAddress (hOpenGL, "glRasterPos2d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos2d()"); + return FALSE; + } + + if ( (gl::qglRasterPos2dv = (pfn_glRasterPos2dv) GetProcAddress (hOpenGL, "glRasterPos2dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos2dv()"); + return FALSE; + } + + if ( (gl::qglRasterPos2f = (pfn_glRasterPos2f) GetProcAddress (hOpenGL, "glRasterPos2f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos2f()"); + return FALSE; + } + + if ( (gl::qglRasterPos2fv = (pfn_glRasterPos2fv) GetProcAddress (hOpenGL, "glRasterPos2fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos2fv()"); + return FALSE; + } + + if ( (gl::qglRasterPos2i = (pfn_glRasterPos2i) GetProcAddress (hOpenGL, "glRasterPos2i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos2i()"); + return FALSE; + } + + if ( (gl::qglRasterPos2iv = (pfn_glRasterPos2iv) GetProcAddress (hOpenGL, "glRasterPos2iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos2iv()"); + return FALSE; + } + + if ( (gl::qglRasterPos2s = (pfn_glRasterPos2s) GetProcAddress (hOpenGL, "glRasterPos2s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos2s()"); + return FALSE; + } + + if ( (gl::qglRasterPos2sv = (pfn_glRasterPos2sv) GetProcAddress (hOpenGL, "glRasterPos2sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos2sv()"); + return FALSE; + } + + if ( (gl::qglRasterPos3d = (pfn_glRasterPos3d) GetProcAddress (hOpenGL, "glRasterPos3d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos3d()"); + return FALSE; + } + + if ( (gl::qglRasterPos3dv = (pfn_glRasterPos3dv) GetProcAddress (hOpenGL, "glRasterPos3dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos3dv()"); + return FALSE; + } + + if ( (gl::qglRasterPos3f = (pfn_glRasterPos3f) GetProcAddress (hOpenGL, "glRasterPos3f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos3f()"); + return FALSE; + } + + if ( (gl::qglRasterPos3fv = (pfn_glRasterPos3fv) GetProcAddress (hOpenGL, "glRasterPos3fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos3fv()"); + return FALSE; + } + + if ( (gl::qglRasterPos3i = (pfn_glRasterPos3i) GetProcAddress (hOpenGL, "glRasterPos3i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos3i()"); + return FALSE; + } + + if ( (gl::qglRasterPos3iv = (pfn_glRasterPos3iv) GetProcAddress (hOpenGL, "glRasterPos3iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos3iv()"); + return FALSE; + } + + if ( (gl::qglRasterPos3s = (pfn_glRasterPos3s) GetProcAddress (hOpenGL, "glRasterPos3s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos3s()"); + return FALSE; + } + + if ( (gl::qglRasterPos3sv = (pfn_glRasterPos3sv) GetProcAddress (hOpenGL, "glRasterPos3sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos3sv()"); + return FALSE; + } + + if ( (gl::qglRasterPos4d = (pfn_glRasterPos4d) GetProcAddress (hOpenGL, "glRasterPos4d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos4d()"); + return FALSE; + } + + if ( (gl::qglRasterPos4dv = (pfn_glRasterPos4dv) GetProcAddress (hOpenGL, "glRasterPos4dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos4dv()"); + return FALSE; + } + + if ( (gl::qglRasterPos4f = (pfn_glRasterPos4f) GetProcAddress (hOpenGL, "glRasterPos4f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos4f()"); + return FALSE; + } + + if ( (gl::qglRasterPos4fv = (pfn_glRasterPos4fv) GetProcAddress (hOpenGL, "glRasterPos4fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos4fv()"); + return FALSE; + } + + if ( (gl::qglRasterPos4i = (pfn_glRasterPos4i) GetProcAddress (hOpenGL, "glRasterPos4i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos4i()"); + return FALSE; + } + + if ( (gl::qglRasterPos4iv = (pfn_glRasterPos4iv) GetProcAddress (hOpenGL, "glRasterPos4iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos4iv()"); + return FALSE; + } + + if ( (gl::qglRasterPos4s = (pfn_glRasterPos4s) GetProcAddress (hOpenGL, "glRasterPos4s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos4s()"); + return FALSE; + } + + if ( (gl::qglRasterPos4sv = (pfn_glRasterPos4sv) GetProcAddress (hOpenGL, "glRasterPos4sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRasterPos4sv()"); + return FALSE; + } + + if ( (gl::qglReadBuffer = (pfn_glReadBuffer) GetProcAddress (hOpenGL, "glReadBuffer")) == NULL ) + { + //add_log ("Couldn't found a prototype for glReadBuffer()"); + return FALSE; + } + + if ( (gl::qglReadPixels = (pfn_glReadPixels) GetProcAddress (hOpenGL, "glReadPixels")) == NULL ) + { + //add_log ("Couldn't found a prototype for glReadPixels()"); + return FALSE; + } + + if ( (gl::qglRectd = (pfn_glRectd) GetProcAddress (hOpenGL, "glRectd")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRectd()"); + return FALSE; + } + + if ( (gl::qglRectdv = (pfn_glRectdv) GetProcAddress (hOpenGL, "glRectdv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRectdv()"); + return FALSE; + } + + if ( (gl::qglRectf = (pfn_glRectf) GetProcAddress (hOpenGL, "glRectf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRectf()"); + return FALSE; + } + + if ( (gl::qglRectfv = (pfn_glRectfv) GetProcAddress (hOpenGL, "glRectfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRectfv()"); + return FALSE; + } + + if ( (gl::qglRecti = (pfn_glRecti) GetProcAddress (hOpenGL, "glRecti")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRecti()"); + return FALSE; + } + + if ( (gl::qglRectiv = (pfn_glRectiv) GetProcAddress (hOpenGL, "glRectiv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRectiv()"); + return FALSE; + } + + if ( (gl::qglRects = (pfn_glRects) GetProcAddress (hOpenGL, "glRects")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRects()"); + return FALSE; + } + + if ( (gl::qglRectsv = (pfn_glRectsv) GetProcAddress (hOpenGL, "glRectsv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRectsv()"); + return FALSE; + } + + if ( (gl::qglRenderMode = (pfn_glRenderMode) GetProcAddress (hOpenGL, "glRenderMode")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRenderMode()"); + return FALSE; + } + + if ( (gl::qglRotated = (pfn_glRotated) GetProcAddress (hOpenGL, "glRotated")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRotated()"); + return FALSE; + } + + if ( (gl::qglRotatef = (pfn_glRotatef) GetProcAddress (hOpenGL, "glRotatef")) == NULL ) + { + //add_log ("Couldn't found a prototype for glRotatef()"); + return FALSE; + } + + if ( (gl::qglScaled = (pfn_glScaled) GetProcAddress (hOpenGL, "glScaled")) == NULL ) + { + //add_log ("Couldn't found a prototype for glScaled()"); + return FALSE; + } + + if ( (gl::qglScalef = (pfn_glScalef) GetProcAddress (hOpenGL, "glScalef")) == NULL ) + { + //add_log ("Couldn't found a prototype for glScalef()"); + return FALSE; + } + + if ( (gl::qglScissor = (pfn_glScissor) GetProcAddress (hOpenGL, "glScissor")) == NULL ) + { + //add_log ("Couldn't found a prototype for glScissor()"); + return FALSE; + } + + if ( (gl::qglSelectBuffer = (pfn_glSelectBuffer) GetProcAddress (hOpenGL, "glSelectBuffer")) == NULL ) + { + //add_log ("Couldn't found a prototype for glSelectBuffer()"); + return FALSE; + } + + if ( (gl::qglShadeModel = (pfn_glShadeModel) GetProcAddress (hOpenGL, "glShadeModel")) == NULL ) + { + //add_log ("Couldn't found a prototype for glShadeModel()"); + return FALSE; + } + + if ( (gl::qglStencilFunc = (pfn_glStencilFunc) GetProcAddress (hOpenGL, "glStencilFunc")) == NULL ) + { + //add_log ("Couldn't found a prototype for glStencilFunc()"); + return FALSE; + } + + if ( (gl::qglStencilMask = (pfn_glStencilMask) GetProcAddress (hOpenGL, "glStencilMask")) == NULL ) + { + //add_log ("Couldn't found a prototype for glStencilMask()"); + return FALSE; + } + + if ( (gl::qglStencilOp = (pfn_glStencilOp) GetProcAddress (hOpenGL, "glStencilOp")) == NULL ) + { + //add_log ("Couldn't found a prototype for glStencilOp()"); + return FALSE; + } + + if ( (gl::wglSwapBuffers = (pfn_wglSwapBuffers) GetProcAddress (hOpenGL, "wglSwapBuffers")) == NULL ) + { + //add_log ("Couldn't found a prototype for glStencilOp()"); + return FALSE; + } + + if ( (gl::qglTexCoord1d = (pfn_glTexCoord1d) GetProcAddress (hOpenGL, "glTexCoord1d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord1d()"); + return FALSE; + } + + if ( (gl::qglTexCoord1dv = (pfn_glTexCoord1dv) GetProcAddress (hOpenGL, "glTexCoord1dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord1dv()"); + return FALSE; + } + + if ( (gl::qglTexCoord1f = (pfn_glTexCoord1f) GetProcAddress (hOpenGL, "glTexCoord1f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord1f()"); + return FALSE; + } + + if ( (gl::qglTexCoord1fv = (pfn_glTexCoord1fv) GetProcAddress (hOpenGL, "glTexCoord1fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord1fv()"); + return FALSE; + } + + if ( (gl::qglTexCoord1i = (pfn_glTexCoord1i) GetProcAddress (hOpenGL, "glTexCoord1i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord1i()"); + return FALSE; + } + + if ( (gl::qglTexCoord1iv = (pfn_glTexCoord1iv) GetProcAddress (hOpenGL, "glTexCoord1iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord1iv()"); + return FALSE; + } + + if ( (gl::qglTexCoord1s = (pfn_glTexCoord1s) GetProcAddress (hOpenGL, "glTexCoord1s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord1s()"); + return FALSE; + } + + if ( (gl::qglTexCoord1sv = (pfn_glTexCoord1sv) GetProcAddress (hOpenGL, "glTexCoord1sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord1sv()"); + return FALSE; + } + + if ( (gl::qglTexCoord2d = (pfn_glTexCoord2d) GetProcAddress (hOpenGL, "glTexCoord2d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord2d()"); + return FALSE; + } + + if ( (gl::qglTexCoord2dv = (pfn_glTexCoord2dv) GetProcAddress (hOpenGL, "glTexCoord2dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord2dv()"); + return FALSE; + } + + if ( (gl::qglTexCoord2f = (pfn_glTexCoord2f) GetProcAddress (hOpenGL, "glTexCoord2f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord2f()"); + return FALSE; + } + + if ( (gl::qglTexCoord2fv = (pfn_glTexCoord2fv) GetProcAddress (hOpenGL, "glTexCoord2fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord2fv()"); + return FALSE; + } + + if ( (gl::qglTexCoord2i = (pfn_glTexCoord2i) GetProcAddress (hOpenGL, "glTexCoord2i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord2i()"); + return FALSE; + } + + if ( (gl::qglTexCoord2iv = (pfn_glTexCoord2iv) GetProcAddress (hOpenGL, "glTexCoord2iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord2iv()"); + return FALSE; + } + + if ( (gl::qglTexCoord2s = (pfn_glTexCoord2s) GetProcAddress (hOpenGL, "glTexCoord2s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord2s()"); + return FALSE; + } + + if ( (gl::qglTexCoord2sv = (pfn_glTexCoord2sv) GetProcAddress (hOpenGL, "glTexCoord2sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord2sv()"); + return FALSE; + } + + if ( (gl::qglTexCoord3d = (pfn_glTexCoord3d) GetProcAddress (hOpenGL, "glTexCoord3d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord3d()"); + return FALSE; + } + + if ( (gl::qglTexCoord3dv = (pfn_glTexCoord3dv) GetProcAddress (hOpenGL, "glTexCoord3dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord3dv()"); + return FALSE; + } + + if ( (gl::qglTexCoord3f = (pfn_glTexCoord3f) GetProcAddress (hOpenGL, "glTexCoord3f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord3f()"); + return FALSE; + } + + if ( (gl::qglTexCoord3fv = (pfn_glTexCoord3fv) GetProcAddress (hOpenGL, "glTexCoord3fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord3fv()"); + return FALSE; + } + + if ( (gl::qglTexCoord3i = (pfn_glTexCoord3i) GetProcAddress (hOpenGL, "glTexCoord3i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord3i()"); + return FALSE; + } + + if ( (gl::qglTexCoord3iv = (pfn_glTexCoord3iv) GetProcAddress (hOpenGL, "glTexCoord3iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord3iv()"); + return FALSE; + } + + if ( (gl::qglTexCoord3s = (pfn_glTexCoord3s) GetProcAddress (hOpenGL, "glTexCoord3s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord3s()"); + return FALSE; + } + + if ( (gl::qglTexCoord3sv = (pfn_glTexCoord3sv) GetProcAddress (hOpenGL, "glTexCoord3sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord3sv()"); + return FALSE; + } + + if ( (gl::qglTexCoord4d = (pfn_glTexCoord4d) GetProcAddress (hOpenGL, "glTexCoord4d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord4d()"); + return FALSE; + } + + if ( (gl::qglTexCoord4dv = (pfn_glTexCoord4dv) GetProcAddress (hOpenGL, "glTexCoord4dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord4dv()"); + return FALSE; + } + + if ( (gl::qglTexCoord4f = (pfn_glTexCoord4f) GetProcAddress (hOpenGL, "glTexCoord4f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord4f()"); + return FALSE; + } + + if ( (gl::qglTexCoord4fv = (pfn_glTexCoord4fv) GetProcAddress (hOpenGL, "glTexCoord4fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord4fv()"); + return FALSE; + } + + if ( (gl::qglTexCoord4i = (pfn_glTexCoord4i) GetProcAddress (hOpenGL, "glTexCoord4i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord4i()"); + return FALSE; + } + + if ( (gl::qglTexCoord4iv = (pfn_glTexCoord4iv) GetProcAddress (hOpenGL, "glTexCoord4iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord4iv()"); + return FALSE; + } + + if ( (gl::qglTexCoord4s = (pfn_glTexCoord4s) GetProcAddress (hOpenGL, "glTexCoord4s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord4s()"); + return FALSE; + } + + if ( (gl::qglTexCoord4sv = (pfn_glTexCoord4sv) GetProcAddress (hOpenGL, "glTexCoord4sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoord4sv()"); + return FALSE; + } + + if ( (gl::qglTexCoordPointer = (pfn_glTexCoordPointer) GetProcAddress (hOpenGL, "glTexCoordPointer")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexCoordPointer()"); + return FALSE; + } + + if ( (gl::qglTexEnvf = (pfn_glTexEnvf) GetProcAddress (hOpenGL, "glTexEnvf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexEnvf()"); + return FALSE; + } + + if ( (gl::qglTexEnvfv = (pfn_glTexEnvfv) GetProcAddress (hOpenGL, "glTexEnvfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexEnvfv()"); + return FALSE; + } + + if ( (gl::qglTexEnvi = (pfn_glTexEnvi) GetProcAddress (hOpenGL, "glTexEnvi")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexEnvi()"); + return FALSE; + } + + if ( (gl::qglTexEnviv = (pfn_glTexEnviv) GetProcAddress (hOpenGL, "glTexEnviv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexEnviv()"); + return FALSE; + } + + if ( (gl::qglTexGend = (pfn_glTexGend) GetProcAddress (hOpenGL, "glTexGend")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexGend()"); + return FALSE; + } + + if ( (gl::qglTexGendv = (pfn_glTexGendv) GetProcAddress (hOpenGL, "glTexGendv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexGendv()"); + return FALSE; + } + + if ( (gl::qglTexGenf = (pfn_glTexGenf) GetProcAddress (hOpenGL, "glTexGenf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexGenf()"); + return FALSE; + } + + if ( (gl::qglTexGenfv = (pfn_glTexGenfv) GetProcAddress (hOpenGL, "glTexGenfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexGenfv()"); + return FALSE; + } + + if ( (gl::qglTexGeni = (pfn_glTexGeni) GetProcAddress (hOpenGL, "glTexGeni")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexGeni()"); + return FALSE; + } + + if ( (gl::qglTexGeniv = (pfn_glTexGeniv) GetProcAddress (hOpenGL, "glTexGeniv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexGeniv()"); + return FALSE; + } + + if ( (gl::qglTexImage1D = (pfn_glTexImage1D) GetProcAddress (hOpenGL, "glTexImage1D")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexImage1D()"); + return FALSE; + } + + if ( (gl::qglTexImage2D = (pfn_glTexImage2D) GetProcAddress (hOpenGL, "glTexImage2D")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexImage2D()"); + return FALSE; + } + + if ( (gl::qglTexParameterf = (pfn_glTexParameterf) GetProcAddress (hOpenGL, "glTexParameterf")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexParameterf()"); + return FALSE; + } + + if ( (gl::qglTexParameterfv = (pfn_glTexParameterfv) GetProcAddress (hOpenGL, "glTexParameterfv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexParameterfv()"); + return FALSE; + } + + if ( (gl::qglTexParameteri = (pfn_glTexParameteri) GetProcAddress (hOpenGL, "glTexParameteri")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexParameteri()"); + return FALSE; + } + + if ( (gl::qglTexParameteriv = (pfn_glTexParameteriv) GetProcAddress (hOpenGL, "glTexParameteriv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexParameteriv()"); + return FALSE; + } + + if ( (gl::qglTexSubImage1D = (pfn_glTexSubImage1D) GetProcAddress (hOpenGL, "glTexSubImage1D")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexSubImage1D()"); + return FALSE; + } + + if ( (gl::qglTexSubImage2D = (pfn_glTexSubImage2D) GetProcAddress (hOpenGL, "glTexSubImage2D")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTexSubImage2D()"); + return FALSE; + } + + if ( (gl::qglTranslated = (pfn_glTranslated) GetProcAddress (hOpenGL, "glTranslated")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTranslated()"); + return FALSE; + } + + if ( (gl::qglTranslatef = (pfn_glTranslatef) GetProcAddress (hOpenGL, "glTranslatef")) == NULL ) + { + //add_log ("Couldn't found a prototype for glTranslatef()"); + return FALSE; + } + + if ( (gl::qglVertex2d = (pfn_glVertex2d) GetProcAddress (hOpenGL, "glVertex2d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex2d()"); + return FALSE; + } + + if ( (gl::qglVertex2dv = (pfn_glVertex2dv) GetProcAddress (hOpenGL, "glVertex2dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex2dv()"); + return FALSE; + } + + if ( (gl::qglVertex2f = (pfn_glVertex2f) GetProcAddress (hOpenGL, "glVertex2f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex2f()"); + return FALSE; + } + + if ( (gl::qglVertex2fv = (pfn_glVertex2fv) GetProcAddress (hOpenGL, "glVertex2fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex2fv()"); + return FALSE; + } + + if ( (gl::qglVertex2i = (pfn_glVertex2i) GetProcAddress (hOpenGL, "glVertex2i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex2i()"); + return FALSE; + } + + if ( (gl::qglVertex2iv = (pfn_glVertex2iv) GetProcAddress (hOpenGL, "glVertex2iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex2iv()"); + return FALSE; + } + + if ( (gl::qglVertex2s = (pfn_glVertex2s) GetProcAddress (hOpenGL, "glVertex2s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex2s()"); + return FALSE; + } + + if ( (gl::qglVertex2sv = (pfn_glVertex2sv) GetProcAddress (hOpenGL, "glVertex2sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex2sv()"); + return FALSE; + } + + if ( (gl::qglVertex3d = (pfn_glVertex3d) GetProcAddress (hOpenGL, "glVertex3d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex3d()"); + return FALSE; + } + + if ( (gl::qglVertex3dv = (pfn_glVertex3dv) GetProcAddress (hOpenGL, "glVertex3dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex3dv()"); + return FALSE; + } + + if ( (gl::qglVertex3f = (pfn_glVertex3f) GetProcAddress (hOpenGL, "glVertex3f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex3f()"); + return FALSE; + } + + if ( (gl::qglVertex3fv = (pfn_glVertex3fv) GetProcAddress (hOpenGL, "glVertex3fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex3fv()"); + return FALSE; + } + + if ( (gl::qglVertex3i = (pfn_glVertex3i) GetProcAddress (hOpenGL, "glVertex3i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex3i()"); + return FALSE; + } + + if ( (gl::qglVertex3iv = (pfn_glVertex3iv) GetProcAddress (hOpenGL, "glVertex3iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex3iv()"); + return FALSE; + } + + if ( (gl::qglVertex3s = (pfn_glVertex3s) GetProcAddress (hOpenGL, "glVertex3s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex3s()"); + return FALSE; + } + + if ( (gl::qglVertex3sv = (pfn_glVertex3sv) GetProcAddress (hOpenGL, "glVertex3sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex3sv()"); + return FALSE; + } + + if ( (gl::qglVertex4d = (pfn_glVertex4d) GetProcAddress (hOpenGL, "glVertex4d")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex4d()"); + return FALSE; + } + + if ( (gl::qglVertex4dv = (pfn_glVertex4dv) GetProcAddress (hOpenGL, "glVertex4dv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex4dv()"); + return FALSE; + } + + if ( (gl::qglVertex4f = (pfn_glVertex4f) GetProcAddress (hOpenGL, "glVertex4f")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex4f()"); + return FALSE; + } + + if ( (gl::qglVertex4fv = (pfn_glVertex4fv) GetProcAddress (hOpenGL, "glVertex4fv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex4fv()"); + return FALSE; + } + + if ( (gl::qglVertex4i = (pfn_glVertex4i) GetProcAddress (hOpenGL, "glVertex4i")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex4i()"); + return FALSE; + } + + if ( (gl::qglVertex4iv = (pfn_glVertex4iv) GetProcAddress (hOpenGL, "glVertex4iv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex4iv()"); + return FALSE; + } + + if ( (gl::qglVertex4s = (pfn_glVertex4s) GetProcAddress (hOpenGL, "glVertex4s")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex4s()"); + return FALSE; + } + + if ( (gl::qglVertex4sv = (pfn_glVertex4sv) GetProcAddress (hOpenGL, "glVertex4sv")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertex4sv()"); + return FALSE; + } + + if ( (gl::qglVertexPointer = (pfn_glVertexPointer) GetProcAddress (hOpenGL, "glVertexPointer")) == NULL ) + { + //add_log ("Couldn't found a prototype for glVertexPointer()"); + return FALSE; + } + + if ( (gl::qglViewport = (pfn_glViewport) GetProcAddress (hOpenGL, "glViewport")) == NULL ) + { + //add_log ("Couldn't found a prototype for glViewport()"); + return FALSE; + } + + if ( (gl::wglChoosePixelFormat = (pfn_wglChoosePixelFormat) GetProcAddress (hOpenGL, "wglChoosePixelFormat")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglChoosePixelFormat()"); + return FALSE; + } + + if ( (gl::wglCopyContext = (pfn_wglCopyContext) GetProcAddress (hOpenGL, "wglCopyContext")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglCopyContext()"); + return FALSE; + } + + if ( (gl::wglCreateContext = (pfn_wglCreateContext) GetProcAddress (hOpenGL, "wglCreateContext")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglCreateContext()"); + return FALSE; + } + + if ( (gl::wglCreateLayerContext = (pfn_wglCreateLayerContext) GetProcAddress (hOpenGL, "wglCreateLayerContext")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglCreateLayerContext()"); + return FALSE; + } + + if ( (gl::wglDeleteContext = (pfn_wglDeleteContext) GetProcAddress (hOpenGL, "wglDeleteContext")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglDeleteContext()"); + return FALSE; + } + + if ( (gl::wglDescribeLayerPlane = (pfn_wglDescribeLayerPlane) GetProcAddress (hOpenGL, "wglDescribeLayerPlane")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglDescribeLayerPlane()"); + return FALSE; + } + + if ( (gl::wglDescribePixelFormat = (pfn_wglDescribePixelFormat) GetProcAddress (hOpenGL, "wglDescribePixelFormat")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglDescribePixelFormat()"); + return FALSE; + } + + if ( (gl::wglGetCurrentContext = (pfn_wglGetCurrentContext) GetProcAddress (hOpenGL, "wglGetCurrentContext")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglGetCurrentContext()"); + return FALSE; + } + + if ( (gl::wglGetCurrentDC = (pfn_wglGetCurrentDC) GetProcAddress (hOpenGL, "wglGetCurrentDC")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglGetCurrentDC()"); + return FALSE; + } + + if ( (gl::wglGetLayerPaletteEntries = (pfn_wglGetLayerPaletteEntries) GetProcAddress (hOpenGL, "wglGetLayerPaletteEntries")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglGetLayerPaletteEntries()"); + return FALSE; + } + + if ( (gl::wglGetPixelFormat = (pfn_wglGetPixelFormat) GetProcAddress (hOpenGL, "wglGetPixelFormat")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglGetPixelFormat()"); + return FALSE; + } + + if ( (gl::wglGetProcAddress = (pfn_wglGetProcAddress) GetProcAddress (hOpenGL, "wglGetProcAddress")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglGetProcAddress()"); + return FALSE; + } + + if ( (gl::wglMakeCurrent = (pfn_wglMakeCurrent) GetProcAddress (hOpenGL, "wglMakeCurrent")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglMakeCurrent()"); + return FALSE; + } + + if ( (gl::wglRealizeLayerPalette = (pfn_wglRealizeLayerPalette) GetProcAddress (hOpenGL, "wglRealizeLayerPalette")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglRealizeLayerPalette()"); + return FALSE; + } + + if ( (gl::wglSetLayerPaletteEntries = (pfn_wglSetLayerPaletteEntries) GetProcAddress (hOpenGL, "wglSetLayerPaletteEntries")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglSetLayerPaletteEntries()"); + return FALSE; + } + + if ( (gl::wglSetPixelFormat = (pfn_wglSetPixelFormat) GetProcAddress (hOpenGL, "wglSetPixelFormat")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglSetPixelFormat()"); + return FALSE; + } + + if ( (gl::wglShareLists = (pfn_wglShareLists) GetProcAddress (hOpenGL, "wglShareLists")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglShareLists()"); + return FALSE; + } + + if ( (gl::wglSwapBuffers = (pfn_wglSwapBuffers) GetProcAddress (hOpenGL, "wglSwapBuffers")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglSwapBuffers()"); + return FALSE; + } + + if ( (gl::wglSwapLayerBuffers = (pfn_wglSwapLayerBuffers) GetProcAddress (hOpenGL, "wglSwapLayerBuffers")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglSwapLayerBuffers()"); + return FALSE; + } + + if ( (gl::wglUseFontBitmapsA = (pfn_wglUseFontBitmapsA) GetProcAddress (hOpenGL, "wglUseFontBitmapsA")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglUseFontBitmapsA()"); + return FALSE; + } + + if ( (gl::wglUseFontBitmapsW = (pfn_wglUseFontBitmapsW) GetProcAddress (hOpenGL, "wglUseFontBitmapsW")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglUseFontBitmapsW()"); + return FALSE; + } + + if ( (gl::wglUseFontOutlinesA = (pfn_wglUseFontOutlinesA) GetProcAddress (hOpenGL, "wglUseFontOutlinesA")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglUseFontOutlinesA()"); + return FALSE; + } + + if ( (gl::wglUseFontOutlinesW = (pfn_wglUseFontOutlinesW) GetProcAddress (hOpenGL, "wglUseFontOutlinesW")) == NULL ) + { + //add_log ("Couldn't found a prototype for wglUseFontOutlinesW()"); + return FALSE; + } +#endif + + return TRUE; +} + + + + diff --git a/code/cgame_hook/ogl/opengl32.cpp b/code/cgame_hook/ogl/opengl32.cpp new file mode 100644 index 00000000..48915c07 --- /dev/null +++ b/code/cgame_hook/ogl/opengl32.cpp @@ -0,0 +1,51 @@ +/* +* Game-Deception Blank Wrapper v2 +* Copyright (c) Crusader 2002 +*/ + +/* +* Useful ogl functions for half-life including hooked extensions +*/ + +#include "opengl_api.h" + +/* +#pragma warning(disable:4100) +BOOL __stdcall DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) +{ + switch(fdwReason) + { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls (hOpenGL); + return Init(); + + case DLL_PROCESS_DETACH: + if ( hOpenGL != NULL ) + { + FreeLibrary(hOpenGL); + hOpenGL = NULL; + } + break; + } + return TRUE; +} +#pragma warning(default:4100) +*/ + + +void __cdecl add_log (const char * fmt, ...) +{ + va_list va_alist; + char logbuf[256] = ""; + FILE * fp; + + va_start (va_alist, fmt); + _vsnprintf (logbuf+strlen(logbuf), sizeof(logbuf) - strlen(logbuf), fmt, va_alist); + va_end (va_alist); + + if ( (fp = fopen ("opengl32.log", "ab")) != NULL ) + { + fprintf ( fp, "%s\n", logbuf ); + fclose (fp); + } +} \ No newline at end of file diff --git a/code/cgame_hook/ogl/opengl_api.h b/code/cgame_hook/ogl/opengl_api.h new file mode 100644 index 00000000..4090c0ea --- /dev/null +++ b/code/cgame_hook/ogl/opengl_api.h @@ -0,0 +1,790 @@ +/* +* Game-Deception Blank Wrapper v2 +* Copyright (c) Crusader 2002 +*/ + +#ifndef H_OPENGL32 +#define H_OPENGL32 + +#define ORIGINAL_DLL "opengl32.dll" + +/* Original function typedefs */ +#include +#include +#include +#include +#include +#include +//#include +#include + +#define WANT_OPENGL +#include "cgamex86.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +//#define GL_TEXTURE_WRAP_R 0x2804 +#define GL_CLAMP_TO_EDGE 0x812F + +extern BOOL glInit (void); +//extern void __cdecl add_log ( const char * fmt, ... ); +extern HMODULE hOpenGL; + +typedef void ( WINAPI *func_glActiveTextureARB_t) (GLenum target); +typedef void ( WINAPI *func_BindTextureEXT_t) (GLenum target, GLuint texture); +typedef void ( WINAPI *func_glMultiTexCoord2fARB_t) (GLenum target, GLfloat s, GLfloat t); +typedef void ( WINAPI *func_glAccum_t) (GLenum op, GLfloat value); +typedef void ( WINAPI *func_glAlphaFunc_t) (GLenum func, GLclampf ref); +typedef GLboolean ( WINAPI *func_glAreTexturesResident_t) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void ( WINAPI *func_glArrayElement_t) (GLint i); +typedef void ( WINAPI *func_glBegin_t) (GLenum mode); +typedef void ( WINAPI *func_glBindTexture_t) (GLenum target, GLuint texture); +typedef void ( WINAPI *func_glBitmap_t) (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); +typedef void ( WINAPI *func_glBlendFunc_t) (GLenum sfactor, GLenum dfactor); +typedef void ( WINAPI *func_glCallList_t) (GLuint list); +typedef void ( WINAPI *func_glCallLists_t) (GLsizei n, GLenum type, const GLvoid *lists); +typedef void ( WINAPI *func_glClear_t) (GLbitfield mask); +typedef void ( WINAPI *func_glClearAccum_t) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void ( WINAPI *func_glClearColor_t) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void ( WINAPI *func_glClearDepth_t) (GLclampd depth); +typedef void ( WINAPI *func_glClearIndex_t) (GLfloat c); +typedef void ( WINAPI *func_glClearStencil_t) (GLint s); +typedef void ( WINAPI *func_glClipPlane_t) (GLenum plane, const GLdouble *equation); +typedef void ( WINAPI *func_glColor3b_t) (GLbyte red, GLbyte green, GLbyte blue); +typedef void ( WINAPI *func_glColor3bv_t) (const GLbyte *v); +typedef void ( WINAPI *func_glColor3d_t) (GLdouble red, GLdouble green, GLdouble blue); +typedef void ( WINAPI *func_glColor3dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glColor3f_t) (GLfloat red, GLfloat green, GLfloat blue); +typedef void ( WINAPI *func_glColor3fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glColor3i_t) (GLint red, GLint green, GLint blue); +typedef void ( WINAPI *func_glColor3iv_t) (const GLint *v); +typedef void ( WINAPI *func_glColor3s_t) (GLshort red, GLshort green, GLshort blue); +typedef void ( WINAPI *func_glColor3sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glColor3ub_t) (GLubyte red, GLubyte green, GLubyte blue); +typedef void ( WINAPI *func_glColor3ubv_t) (const GLubyte *v); +typedef void ( WINAPI *func_glColor3ui_t) (GLuint red, GLuint green, GLuint blue); +typedef void ( WINAPI *func_glColor3uiv_t) (const GLuint *v); +typedef void ( WINAPI *func_glColor3us_t) (GLushort red, GLushort green, GLushort blue); +typedef void ( WINAPI *func_glColor3usv_t) (const GLushort *v); +typedef void ( WINAPI *func_glColor4b_t) (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +typedef void ( WINAPI *func_glColor4bv_t) (const GLbyte *v); +typedef void ( WINAPI *func_glColor4d_t) (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +typedef void ( WINAPI *func_glColor4dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glColor4f_t) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void ( WINAPI *func_glColor4fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glColor4i_t) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void ( WINAPI *func_glColor4iv_t) (const GLint *v); +typedef void ( WINAPI *func_glColor4s_t) (GLshort red, GLshort green, GLshort blue, GLshort alpha); +typedef void ( WINAPI *func_glColor4sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glColor4ub_t) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +typedef void ( WINAPI *func_glColor4ubv_t) (const GLubyte *v); +typedef void ( WINAPI *func_glColor4ui_t) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +typedef void ( WINAPI *func_glColor4uiv_t) (const GLuint *v); +typedef void ( WINAPI *func_glColor4us_t) (GLushort red, GLushort green, GLushort blue, GLushort alpha); +typedef void ( WINAPI *func_glColor4usv_t) (const GLushort *v); +typedef void ( WINAPI *func_glColorMask_t) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void ( WINAPI *func_glColorMaterial_t) (GLenum face, GLenum mode); +typedef void ( WINAPI *func_glColorPointer_t) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void ( WINAPI *func_glCopyPixels_t) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +typedef void ( WINAPI *func_glCopyTexImage1D_t) (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); +typedef void ( WINAPI *func_glCopyTexImage2D_t) (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void ( WINAPI *func_glCopyTexSubImage1D_t) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void ( WINAPI *func_glCopyTexSubImage2D_t) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void ( WINAPI *func_glCullFace_t) (GLenum mode); +typedef void ( WINAPI *func_glDebugEntry_t) (void); +typedef void ( WINAPI *func_glDeleteLists_t) (GLuint list, GLsizei range); +typedef void ( WINAPI *func_glDeleteTextures_t) (GLsizei n, const GLuint *textures); +typedef void ( WINAPI *func_glDepthFunc_t) (GLenum func); +typedef void ( WINAPI *func_glDepthMask_t) (GLboolean flag); +typedef void ( WINAPI *func_glDepthRange_t) (GLclampd zNear, GLclampd zFar); +typedef void ( WINAPI *func_glDisable_t) (GLenum cap); +typedef void ( WINAPI *func_glDisableClientState_t) (GLenum array); +typedef void ( WINAPI *func_glDrawArrays_t) (GLenum mode, GLint first, GLsizei count); +typedef void ( WINAPI *func_glDrawBuffer_t) (GLenum mode); +typedef void ( WINAPI *func_glDrawElements_t) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +typedef void ( WINAPI *func_glDrawPixels_t) (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void ( WINAPI *func_glEdgeFlag_t) (GLboolean flag); +typedef void ( WINAPI *func_glEdgeFlagPointer_t) (GLsizei stride, const GLvoid *pointer); +typedef void ( WINAPI *func_glEdgeFlagv_t) (const GLboolean *flag); +typedef void ( WINAPI *func_glEnable_t) (GLenum cap); +typedef void ( WINAPI *func_glEnableClientState_t) (GLenum array); +typedef void ( WINAPI *func_glEnd_t) (void); +typedef void ( WINAPI *func_glEndList_t) (void); +typedef void ( WINAPI *func_glEvalCoord1d_t) (GLdouble u); +typedef void ( WINAPI *func_glEvalCoord1dv_t) (const GLdouble *u); +typedef void ( WINAPI *func_glEvalCoord1f_t) (GLfloat u); +typedef void ( WINAPI *func_glEvalCoord1fv_t) (const GLfloat *u); +typedef void ( WINAPI *func_glEvalCoord2d_t) (GLdouble u, GLdouble v); +typedef void ( WINAPI *func_glEvalCoord2dv_t) (const GLdouble *u); +typedef void ( WINAPI *func_glEvalCoord2f_t) (GLfloat u, GLfloat v); +typedef void ( WINAPI *func_glEvalCoord2fv_t) (const GLfloat *u); +typedef void ( WINAPI *func_glEvalMesh1_t) (GLenum mode, GLint i1, GLint i2); +typedef void ( WINAPI *func_glEvalMesh2_t) (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +typedef void ( WINAPI *func_glEvalPoint1_t) (GLint i); +typedef void ( WINAPI *func_glEvalPoint2_t) (GLint i, GLint j); +typedef void ( WINAPI *func_glFeedbackBuffer_t) (GLsizei size, GLenum type, GLfloat *buffer); +typedef void ( WINAPI *func_glFinish_t) (void); +typedef void ( WINAPI *func_glFlush_t) (void); +typedef void ( WINAPI *func_glFogf_t) (GLenum pname, GLfloat param); +typedef void ( WINAPI *func_glFogfv_t) (GLenum pname, const GLfloat *params); +typedef void ( WINAPI *func_glFogi_t) (GLenum pname, GLint param); +typedef void ( WINAPI *func_glFogiv_t) (GLenum pname, const GLint *params); +typedef void ( WINAPI *func_glFrontFace_t) (GLenum mode); +typedef void ( WINAPI *func_glFrustum_t) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef GLuint ( WINAPI *func_glGenLists_t) (GLsizei range); +typedef void ( WINAPI *func_glGenTextures_t) (GLsizei n, GLuint *textures); +typedef void ( WINAPI *func_glGetBooleanv_t) (GLenum pname, GLboolean *params); +typedef void ( WINAPI *func_glGetClipPlane_t) (GLenum plane, GLdouble *equation); +typedef void ( WINAPI *func_glGetDoublev_t) (GLenum pname, GLdouble *params); +typedef GLenum ( WINAPI *func_glGetError_t) (void); +typedef void ( WINAPI *func_glGetFloatv_t) (GLenum pname, GLfloat *params); +typedef void ( WINAPI *func_glGetIntegerv_t) (GLenum pname, GLint *params); +typedef void ( WINAPI *func_glGetLightfv_t) (GLenum light, GLenum pname, GLfloat *params); +typedef void ( WINAPI *func_glGetLightiv_t) (GLenum light, GLenum pname, GLint *params); +typedef void ( WINAPI *func_glGetMapdv_t) (GLenum target, GLenum query, GLdouble *v); +typedef void ( WINAPI *func_glGetMapfv_t) (GLenum target, GLenum query, GLfloat *v); +typedef void ( WINAPI *func_glGetMapiv_t) (GLenum target, GLenum query, GLint *v); +typedef void ( WINAPI *func_glGetMaterialfv_t) (GLenum face, GLenum pname, GLfloat *params); +typedef void ( WINAPI *func_glGetMaterialiv_t) (GLenum face, GLenum pname, GLint *params); +typedef void ( WINAPI *func_glGetPixelMapfv_t) (GLenum map, GLfloat *values); +typedef void ( WINAPI *func_glGetPixelMapuiv_t) (GLenum map, GLuint *values); +typedef void ( WINAPI *func_glGetPixelMapusv_t) (GLenum map, GLushort *values); +typedef void ( WINAPI *func_glGetPointerv_t) (GLenum pname, GLvoid* *params); +typedef void ( WINAPI *func_glGetPolygonStipple_t) (GLubyte *mask); +typedef const GLubyte * ( WINAPI *func_glGetString_t) (GLenum name); +typedef void ( WINAPI *func_glGetTexEnvfv_t) (GLenum target, GLenum pname, GLfloat *params); +typedef void ( WINAPI *func_glGetTexEnviv_t) (GLenum target, GLenum pname, GLint *params); +typedef void ( WINAPI *func_glGetTexGendv_t) (GLenum coord, GLenum pname, GLdouble *params); +typedef void ( WINAPI *func_glGetTexGenfv_t) (GLenum coord, GLenum pname, GLfloat *params); +typedef void ( WINAPI *func_glGetTexGeniv_t) (GLenum coord, GLenum pname, GLint *params); +typedef void ( WINAPI *func_glGetTexImage_t) (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void ( WINAPI *func_glGetTexLevelParameterfv_t) (GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void ( WINAPI *func_glGetTexLevelParameteriv_t) (GLenum target, GLint level, GLenum pname, GLint *params); +typedef void ( WINAPI *func_glGetTexParameterfv_t) (GLenum target, GLenum pname, GLfloat *params); +typedef void ( WINAPI *func_glGetTexParameteriv_t) (GLenum target, GLenum pname, GLint *params); +typedef void ( WINAPI *func_glHint_t) (GLenum target, GLenum mode); +typedef void ( WINAPI *func_glIndexMask_t) (GLuint mask); +typedef void ( WINAPI *func_glIndexPointer_t) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void ( WINAPI *func_glIndexd_t) (GLdouble c); +typedef void ( WINAPI *func_glIndexdv_t) (const GLdouble *c); +typedef void ( WINAPI *func_glIndexf_t) (GLfloat c); +typedef void ( WINAPI *func_glIndexfv_t) (const GLfloat *c); +typedef void ( WINAPI *func_glIndexi_t) (GLint c); +typedef void ( WINAPI *func_glIndexiv_t) (const GLint *c); +typedef void ( WINAPI *func_glIndexs_t) (GLshort c); +typedef void ( WINAPI *func_glIndexsv_t) (const GLshort *c); +typedef void ( WINAPI *func_glIndexub_t) (GLubyte c); +typedef void ( WINAPI *func_glIndexubv_t) (const GLubyte *c); +typedef void ( WINAPI *func_glInitNames_t) (void); +typedef void ( WINAPI *func_glInterleavedArrays_t) (GLenum format, GLsizei stride, const GLvoid *pointer); +typedef GLboolean ( WINAPI *func_glIsEnabled_t) (GLenum cap); +typedef GLboolean ( WINAPI *func_glIsList_t) (GLuint list); +typedef GLboolean ( WINAPI *func_glIsTexture_t) (GLuint texture); +typedef void ( WINAPI *func_glLightModelf_t) (GLenum pname, GLfloat param); +typedef void ( WINAPI *func_glLightModelfv_t) (GLenum pname, const GLfloat *params); +typedef void ( WINAPI *func_glLightModeli_t) (GLenum pname, GLint param); +typedef void ( WINAPI *func_glLightModeliv_t) (GLenum pname, const GLint *params); +typedef void ( WINAPI *func_glLightf_t) (GLenum light, GLenum pname, GLfloat param); +typedef void ( WINAPI *func_glLightfv_t) (GLenum light, GLenum pname, const GLfloat *params); +typedef void ( WINAPI *func_glLighti_t) (GLenum light, GLenum pname, GLint param); +typedef void ( WINAPI *func_glLightiv_t) (GLenum light, GLenum pname, const GLint *params); +typedef void ( WINAPI *func_glLineStipple_t) (GLint factor, GLushort pattern); +typedef void ( WINAPI *func_glLineWidth_t) (GLfloat width); +typedef void ( WINAPI *func_glListBase_t) (GLuint base); +typedef void ( WINAPI *func_glLoadIdentity_t) (void); +typedef void ( WINAPI *func_glLoadMatrixd_t) (const GLdouble *m); +typedef void ( WINAPI *func_glLoadMatrixf_t) (const GLfloat *m); +typedef void ( WINAPI *func_glLoadName_t) (GLuint name); +typedef void ( WINAPI *func_glLogicOp_t) (GLenum opcode); +typedef void ( WINAPI *func_glMap1d_t) (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void ( WINAPI *func_glMap1f_t) (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void ( WINAPI *func_glMap2d_t) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void ( WINAPI *func_glMap2f_t) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +typedef void ( WINAPI *func_glMapGrid1d_t) (GLint un, GLdouble u1, GLdouble u2); +typedef void ( WINAPI *func_glMapGrid1f_t) (GLint un, GLfloat u1, GLfloat u2); +typedef void ( WINAPI *func_glMapGrid2d_t) (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +typedef void ( WINAPI *func_glMapGrid2f_t) (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +typedef void ( WINAPI *func_glMaterialf_t) (GLenum face, GLenum pname, GLfloat param); +typedef void ( WINAPI *func_glMaterialfv_t) (GLenum face, GLenum pname, const GLfloat *params); +typedef void ( WINAPI *func_glMateriali_t) (GLenum face, GLenum pname, GLint param); +typedef void ( WINAPI *func_glMaterialiv_t) (GLenum face, GLenum pname, const GLint *params); +typedef void ( WINAPI *func_glMatrixMode_t) (GLenum mode); +typedef void ( WINAPI *func_glMultMatrixd_t) (const GLdouble *m); +typedef void ( WINAPI *func_glMultMatrixf_t) (const GLfloat *m); +typedef void ( WINAPI *func_glNewList_t) (GLuint list, GLenum mode); +typedef void ( WINAPI *func_glNormal3b_t) (GLbyte nx, GLbyte ny, GLbyte nz); +typedef void ( WINAPI *func_glNormal3bv_t) (const GLbyte *v); +typedef void ( WINAPI *func_glNormal3d_t) (GLdouble nx, GLdouble ny, GLdouble nz); +typedef void ( WINAPI *func_glNormal3dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glNormal3f_t) (GLfloat nx, GLfloat ny, GLfloat nz); +typedef void ( WINAPI *func_glNormal3fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glNormal3i_t) (GLint nx, GLint ny, GLint nz); +typedef void ( WINAPI *func_glNormal3iv_t) (const GLint *v); +typedef void ( WINAPI *func_glNormal3s_t) (GLshort nx, GLshort ny, GLshort nz); +typedef void ( WINAPI *func_glNormal3sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glNormalPointer_t) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void ( WINAPI *func_glOrtho_t) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void ( WINAPI *func_glPassThrough_t) (GLfloat token); +typedef void ( WINAPI *func_glPixelMapfv_t) (GLenum map, GLsizei mapsize, const GLfloat *values); +typedef void ( WINAPI *func_glPixelMapuiv_t) (GLenum map, GLsizei mapsize, const GLuint *values); +typedef void ( WINAPI *func_glPixelMapusv_t) (GLenum map, GLsizei mapsize, const GLushort *values); +typedef void ( WINAPI *func_glPixelStoref_t) (GLenum pname, GLfloat param); +typedef void ( WINAPI *func_glPixelStorei_t) (GLenum pname, GLint param); +typedef void ( WINAPI *func_glPixelTransferf_t) (GLenum pname, GLfloat param); +typedef void ( WINAPI *func_glPixelTransferi_t) (GLenum pname, GLint param); +typedef void ( WINAPI *func_glPixelZoom_t) (GLfloat xfactor, GLfloat yfactor); +typedef void ( WINAPI *func_glPointSize_t) (GLfloat size); +typedef void ( WINAPI *func_glPolygonMode_t) (GLenum face, GLenum mode); +typedef void ( WINAPI *func_glPolygonOffset_t) (GLfloat factor, GLfloat units); +typedef void ( WINAPI *func_glPolygonStipple_t) (const GLubyte *mask); +typedef void ( WINAPI *func_glPopAttrib_t) (void); +typedef void ( WINAPI *func_glPopClientAttrib_t) (void); +typedef void ( WINAPI *func_glPopMatrix_t) (void); +typedef void ( WINAPI *func_glPopName_t) (void); +typedef void ( WINAPI *func_glPrioritizeTextures_t) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +typedef void ( WINAPI *func_glPushAttrib_t) (GLbitfield mask); +typedef void ( WINAPI *func_glPushClientAttrib_t) (GLbitfield mask); +typedef void ( WINAPI *func_glPushMatrix_t) (void); +typedef void ( WINAPI *func_glPushName_t) (GLuint name); +typedef void ( WINAPI *func_glRasterPos2d_t) (GLdouble x, GLdouble y); +typedef void ( WINAPI *func_glRasterPos2dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glRasterPos2f_t) (GLfloat x, GLfloat y); +typedef void ( WINAPI *func_glRasterPos2fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glRasterPos2i_t) (GLint x, GLint y); +typedef void ( WINAPI *func_glRasterPos2iv_t) (const GLint *v); +typedef void ( WINAPI *func_glRasterPos2s_t) (GLshort x, GLshort y); +typedef void ( WINAPI *func_glRasterPos2sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glRasterPos3d_t) (GLdouble x, GLdouble y, GLdouble z); +typedef void ( WINAPI *func_glRasterPos3dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glRasterPos3f_t) (GLfloat x, GLfloat y, GLfloat z); +typedef void ( WINAPI *func_glRasterPos3fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glRasterPos3i_t) (GLint x, GLint y, GLint z); +typedef void ( WINAPI *func_glRasterPos3iv_t) (const GLint *v); +typedef void ( WINAPI *func_glRasterPos3s_t) (GLshort x, GLshort y, GLshort z); +typedef void ( WINAPI *func_glRasterPos3sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glRasterPos4d_t) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void ( WINAPI *func_glRasterPos4dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glRasterPos4f_t) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void ( WINAPI *func_glRasterPos4fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glRasterPos4i_t) (GLint x, GLint y, GLint z, GLint w); +typedef void ( WINAPI *func_glRasterPos4iv_t) (const GLint *v); +typedef void ( WINAPI *func_glRasterPos4s_t) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void ( WINAPI *func_glRasterPos4sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glReadBuffer_t) (GLenum mode); +typedef void ( WINAPI *func_glReadPixels_t) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +typedef void ( WINAPI *func_glRectd_t) (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +typedef void ( WINAPI *func_glRectdv_t) (const GLdouble *v1, const GLdouble *v2); +typedef void ( WINAPI *func_glRectf_t) (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +typedef void ( WINAPI *func_glRectfv_t) (const GLfloat *v1, const GLfloat *v2); +typedef void ( WINAPI *func_glRecti_t) (GLint x1, GLint y1, GLint x2, GLint y2); +typedef void ( WINAPI *func_glRectiv_t) (const GLint *v1, const GLint *v2); +typedef void ( WINAPI *func_glRects_t) (GLshort x1, GLshort y1, GLshort x2, GLshort y2); +typedef void ( WINAPI *func_glRectsv_t) (const GLshort *v1, const GLshort *v2); +typedef GLint ( WINAPI *func_glRenderMode_t) (GLenum mode); +typedef void ( WINAPI *func_glRotated_t) (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void ( WINAPI *func_glRotatef_t) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void ( WINAPI *func_glScaled_t) (GLdouble x, GLdouble y, GLdouble z); +typedef void ( WINAPI *func_glScalef_t) (GLfloat x, GLfloat y, GLfloat z); +typedef void ( WINAPI *func_glScissor_t) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void ( WINAPI *func_glSelectBuffer_t) (GLsizei size, GLuint *buffer); +typedef void ( WINAPI *func_glShadeModel_t) (GLenum mode); +typedef void ( WINAPI *func_glStencilFunc_t) (GLenum func, GLint ref, GLuint mask); +typedef void ( WINAPI *func_glStencilMask_t) (GLuint mask); +typedef void ( WINAPI *func_glStencilOp_t) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void ( WINAPI *func_glSwapBuffers_t) (void); +typedef void ( WINAPI *func_glTexCoord1d_t) (GLdouble s); +typedef void ( WINAPI *func_glTexCoord1dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glTexCoord1f_t) (GLfloat s); +typedef void ( WINAPI *func_glTexCoord1fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glTexCoord1i_t) (GLint s); +typedef void ( WINAPI *func_glTexCoord1iv_t) (const GLint *v); +typedef void ( WINAPI *func_glTexCoord1s_t) (GLshort s); +typedef void ( WINAPI *func_glTexCoord1sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glTexCoord2d_t) (GLdouble s, GLdouble t); +typedef void ( WINAPI *func_glTexCoord2dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glTexCoord2f_t) (GLfloat s, GLfloat t); +typedef void ( WINAPI *func_glTexCoord2fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glTexCoord2i_t) (GLint s, GLint t); +typedef void ( WINAPI *func_glTexCoord2iv_t) (const GLint *v); +typedef void ( WINAPI *func_glTexCoord2s_t) (GLshort s, GLshort t); +typedef void ( WINAPI *func_glTexCoord2sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glTexCoord3d_t) (GLdouble s, GLdouble t, GLdouble r); +typedef void ( WINAPI *func_glTexCoord3dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glTexCoord3f_t) (GLfloat s, GLfloat t, GLfloat r); +typedef void ( WINAPI *func_glTexCoord3fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glTexCoord3i_t) (GLint s, GLint t, GLint r); +typedef void ( WINAPI *func_glTexCoord3iv_t) (const GLint *v); +typedef void ( WINAPI *func_glTexCoord3s_t) (GLshort s, GLshort t, GLshort r); +typedef void ( WINAPI *func_glTexCoord3sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glTexCoord4d_t) (GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void ( WINAPI *func_glTexCoord4dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glTexCoord4f_t) (GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void ( WINAPI *func_glTexCoord4fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glTexCoord4i_t) (GLint s, GLint t, GLint r, GLint q); +typedef void ( WINAPI *func_glTexCoord4iv_t) (const GLint *v); +typedef void ( WINAPI *func_glTexCoord4s_t) (GLshort s, GLshort t, GLshort r, GLshort q); +typedef void ( WINAPI *func_glTexCoord4sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glTexCoordPointer_t) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void ( WINAPI *func_glTexEnvf_t) (GLenum target, GLenum pname, GLfloat param); +typedef void ( WINAPI *func_glTexEnvfv_t) (GLenum target, GLenum pname, const GLfloat *params); +typedef void ( WINAPI *func_glTexEnvi_t) (GLenum target, GLenum pname, GLint param); +typedef void ( WINAPI *func_glTexEnviv_t) (GLenum target, GLenum pname, const GLint *params); +typedef void ( WINAPI *func_glTexGend_t) (GLenum coord, GLenum pname, GLdouble param); +typedef void ( WINAPI *func_glTexGendv_t) (GLenum coord, GLenum pname, const GLdouble *params); +typedef void ( WINAPI *func_glTexGenf_t) (GLenum coord, GLenum pname, GLfloat param); +typedef void ( WINAPI *func_glTexGenfv_t) (GLenum coord, GLenum pname, const GLfloat *params); +typedef void ( WINAPI *func_glTexGeni_t) (GLenum coord, GLenum pname, GLint param); +typedef void ( WINAPI *func_glTexGeniv_t) (GLenum coord, GLenum pname, const GLint *params); +typedef void ( WINAPI *func_glTexImage1D_t) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void ( WINAPI *func_glTexImage2D_t) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void ( WINAPI *func_glTexParameterf_t) (GLenum target, GLenum pname, GLfloat param); +typedef void ( WINAPI *func_glTexParameterfv_t) (GLenum target, GLenum pname, const GLfloat *params); +typedef void ( WINAPI *func_glTexParameteri_t) (GLenum target, GLenum pname, GLint param); +typedef void ( WINAPI *func_glTexParameteriv_t) (GLenum target, GLenum pname, const GLint *params); +typedef void ( WINAPI *func_glTexSubImage1D_t) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void ( WINAPI *func_glTexSubImage2D_t) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void ( WINAPI *func_glTranslated_t) (GLdouble x, GLdouble y, GLdouble z); +typedef void ( WINAPI *func_glTranslatef_t) (GLfloat x, GLfloat y, GLfloat z); +typedef void ( WINAPI *func_glVertex2d_t) (GLdouble x, GLdouble y); +typedef void ( WINAPI *func_glVertex2dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glVertex2f_t) (GLfloat x, GLfloat y); +typedef void ( WINAPI *func_glVertex2fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glVertex2i_t) (GLint x, GLint y); +typedef void ( WINAPI *func_glVertex2iv_t) (const GLint *v); +typedef void ( WINAPI *func_glVertex2s_t) (GLshort x, GLshort y); +typedef void ( WINAPI *func_glVertex2sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glVertex3d_t) (GLdouble x, GLdouble y, GLdouble z); +typedef void ( WINAPI *func_glVertex3dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glVertex3f_t) (GLfloat x, GLfloat y, GLfloat z); +typedef void ( WINAPI *func_glVertex3fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glVertex3i_t) (GLint x, GLint y, GLint z); +typedef void ( WINAPI *func_glVertex3iv_t) (const GLint *v); +typedef void ( WINAPI *func_glVertex3s_t) (GLshort x, GLshort y, GLshort z); +typedef void ( WINAPI *func_glVertex3sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glVertex4d_t) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void ( WINAPI *func_glVertex4dv_t) (const GLdouble *v); +typedef void ( WINAPI *func_glVertex4f_t) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void ( WINAPI *func_glVertex4fv_t) (const GLfloat *v); +typedef void ( WINAPI *func_glVertex4i_t) (GLint x, GLint y, GLint z, GLint w); +typedef void ( WINAPI *func_glVertex4iv_t) (const GLint *v); +typedef void ( WINAPI *func_glVertex4s_t) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void ( WINAPI *func_glVertex4sv_t) (const GLshort *v); +typedef void ( WINAPI *func_glVertexPointer_t) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void ( WINAPI *func_glViewport_t) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void ( WINAPI *func_wglChoosePixelFormat_t) (void); +typedef void ( WINAPI *func_wglCopyContext_t) (void); +typedef void ( WINAPI *func_wglCreateContext_t) (void); +typedef void ( WINAPI *func_wglCreateLayerContext_t) (void); +typedef void ( WINAPI *func_wglDeleteContext_t) (void); +typedef void ( WINAPI *func_wglDescribeLayerPlane_t) (void); +typedef void ( WINAPI *func_wglDescribePixelFormat_t) (void); +typedef void ( WINAPI *func_wglGetCurrentContext_t) (void); +typedef HDC ( WINAPI *func_wglGetCurrentDC_t) (void); +typedef void ( WINAPI *func_wglGetDefaultProcAddress_t) (void); +typedef void ( WINAPI *func_wglGetLayerPaletteEntries_t) (void); +typedef void ( WINAPI *func_wglGetPixelFormat_t) (void); +typedef PROC ( WINAPI *func_wglGetProcAddress_t) (LPCSTR); +typedef void ( WINAPI *func_wglMakeCurrent_t) (void); +typedef void ( WINAPI *func_wglRealizeLayerPalette_t) (void); +typedef void ( WINAPI *func_wglSetLayerPaletteEntries_t) (void); +typedef void ( WINAPI *func_wglSetPixelFormat_t) (void); +typedef void ( WINAPI *func_wglShareLists_t) (void); +typedef void ( WINAPI *func_wglSwapBuffers_t) (HDC hDC); +typedef void ( WINAPI *func_wglSwapLayerBuffers_t) (void); +typedef void ( WINAPI *func_wglUseFontBitmapsA_t) (HDC, DWORD, DWORD, DWORD); +typedef void ( WINAPI *func_wglUseFontBitmapsW_t) (void); +typedef void ( WINAPI *func_wglUseFontOutlinesA_t) (HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT); +typedef void ( WINAPI *func_wglUseFontOutlinesW_t) (void); + +extern func_glActiveTextureARB_t orig_glActiveTextureARB; +extern func_BindTextureEXT_t orig_BindTextureEXT; +extern func_glMultiTexCoord2fARB_t orig_glMultiTexCoord2fARB; +extern func_glAccum_t orig_glAccum; +extern func_glAlphaFunc_t orig_glAlphaFunc; +extern func_glAreTexturesResident_t orig_glAreTexturesResident; +extern func_glArrayElement_t orig_glArrayElement; +extern func_glBegin_t orig_glBegin; +extern func_glBindTexture_t orig_glBindTexture; +extern func_glBitmap_t orig_glBitmap; +extern func_glBlendFunc_t orig_glBlendFunc; +extern func_glCallList_t orig_glCallList; +extern func_glCallLists_t orig_glCallLists; +extern func_glClear_t orig_glClear; +extern func_glClearAccum_t orig_glClearAccum; +extern func_glClearColor_t orig_glClearColor; +extern func_glClearDepth_t orig_glClearDepth; +extern func_glClearIndex_t orig_glClearIndex; +extern func_glClearStencil_t orig_glClearStencil; +extern func_glClipPlane_t orig_glClipPlane; +extern func_glColor3b_t orig_glColor3b; +extern func_glColor3bv_t orig_glColor3bv; +extern func_glColor3d_t orig_glColor3d; +extern func_glColor3dv_t orig_glColor3dv; +extern func_glColor3f_t orig_glColor3f; +extern func_glColor3fv_t orig_glColor3fv; +extern func_glColor3i_t orig_glColor3i; +extern func_glColor3iv_t orig_glColor3iv; +extern func_glColor3s_t orig_glColor3s; +extern func_glColor3sv_t orig_glColor3sv; +extern func_glColor3ub_t orig_glColor3ub; +extern func_glColor3ubv_t orig_glColor3ubv; +extern func_glColor3ui_t orig_glColor3ui; +extern func_glColor3uiv_t orig_glColor3uiv; +extern func_glColor3us_t orig_glColor3us; +extern func_glColor3usv_t orig_glColor3usv; +extern func_glColor4b_t orig_glColor4b; +extern func_glColor4bv_t orig_glColor4bv; +extern func_glColor4d_t orig_glColor4d; +extern func_glColor4dv_t orig_glColor4dv; +extern func_glColor4f_t orig_glColor4f; +extern func_glColor4fv_t orig_glColor4fv; +extern func_glColor4i_t orig_glColor4i; +extern func_glColor4iv_t orig_glColor4iv; +extern func_glColor4s_t orig_glColor4s; +extern func_glColor4sv_t orig_glColor4sv; +extern func_glColor4ub_t orig_glColor4ub; +extern func_glColor4ubv_t orig_glColor4ubv; +extern func_glColor4ui_t orig_glColor4ui; +extern func_glColor4uiv_t orig_glColor4uiv; +extern func_glColor4us_t orig_glColor4us; +extern func_glColor4usv_t orig_glColor4usv; +extern func_glColorMask_t orig_glColorMask; +extern func_glColorMaterial_t orig_glColorMaterial; +extern func_glColorPointer_t orig_glColorPointer; +extern func_glCopyPixels_t orig_glCopyPixels; +extern func_glCopyTexImage1D_t orig_glCopyTexImage1D; +extern func_glCopyTexImage2D_t orig_glCopyTexImage2D; +extern func_glCopyTexSubImage1D_t orig_glCopyTexSubImage1D; +extern func_glCopyTexSubImage2D_t orig_glCopyTexSubImage2D; +extern func_glCullFace_t orig_glCullFace; +extern func_glDebugEntry_t orig_glDebugEntry; +extern func_glDeleteLists_t orig_glDeleteLists; +extern func_glDeleteTextures_t orig_glDeleteTextures; +extern func_glDepthFunc_t orig_glDepthFunc; +extern func_glDepthMask_t orig_glDepthMask; +extern func_glDepthRange_t orig_glDepthRange; +extern func_glDisable_t orig_glDisable; +extern func_glDisableClientState_t orig_glDisableClientState; +extern func_glDrawArrays_t orig_glDrawArrays; +extern func_glDrawBuffer_t orig_glDrawBuffer; +extern func_glDrawElements_t orig_glDrawElements; +extern func_glDrawPixels_t orig_glDrawPixels; +extern func_glEdgeFlag_t orig_glEdgeFlag; +extern func_glEdgeFlagPointer_t orig_glEdgeFlagPointer; +extern func_glEdgeFlagv_t orig_glEdgeFlagv; +extern func_glEnable_t orig_glEnable; +extern func_glEnableClientState_t orig_glEnableClientState; +extern func_glEnd_t orig_glEnd; +extern func_glEndList_t orig_glEndList; +extern func_glEvalCoord1d_t orig_glEvalCoord1d; +extern func_glEvalCoord1dv_t orig_glEvalCoord1dv; +extern func_glEvalCoord1f_t orig_glEvalCoord1f; +extern func_glEvalCoord1fv_t orig_glEvalCoord1fv; +extern func_glEvalCoord2d_t orig_glEvalCoord2d; +extern func_glEvalCoord2dv_t orig_glEvalCoord2dv; +extern func_glEvalCoord2f_t orig_glEvalCoord2f; +extern func_glEvalCoord2fv_t orig_glEvalCoord2fv; +extern func_glEvalMesh1_t orig_glEvalMesh1; +extern func_glEvalMesh2_t orig_glEvalMesh2; +extern func_glEvalPoint1_t orig_glEvalPoint1; +extern func_glEvalPoint2_t orig_glEvalPoint2; +extern func_glFeedbackBuffer_t orig_glFeedbackBuffer; +extern func_glFinish_t orig_glFinish; +extern func_glFlush_t orig_glFlush; +extern func_glFogf_t orig_glFogf; +extern func_glFogfv_t orig_glFogfv; +extern func_glFogi_t orig_glFogi; +extern func_glFogiv_t orig_glFogiv; +extern func_glFrontFace_t orig_glFrontFace; +extern func_glFrustum_t orig_glFrustum; +extern func_glGenLists_t orig_glGenLists; +extern func_glGenTextures_t orig_glGenTextures; +extern func_glGetBooleanv_t orig_glGetBooleanv; +extern func_glGetClipPlane_t orig_glGetClipPlane; +extern func_glGetDoublev_t orig_glGetDoublev; +extern func_glGetError_t orig_glGetError; +extern func_glGetFloatv_t orig_glGetFloatv; +extern func_glGetIntegerv_t orig_glGetIntegerv; +extern func_glGetLightfv_t orig_glGetLightfv; +extern func_glGetLightiv_t orig_glGetLightiv; +extern func_glGetMapdv_t orig_glGetMapdv; +extern func_glGetMapfv_t orig_glGetMapfv; +extern func_glGetMapiv_t orig_glGetMapiv; +extern func_glGetMaterialfv_t orig_glGetMaterialfv; +extern func_glGetMaterialiv_t orig_glGetMaterialiv; +extern func_glGetPixelMapfv_t orig_glGetPixelMapfv; +extern func_glGetPixelMapuiv_t orig_glGetPixelMapuiv; +extern func_glGetPixelMapusv_t orig_glGetPixelMapusv; +extern func_glGetPointerv_t orig_glGetPointerv; +extern func_glGetPolygonStipple_t orig_glGetPolygonStipple; +extern func_glGetString_t orig_glGetString; +extern func_glGetTexEnvfv_t orig_glGetTexEnvfv; +extern func_glGetTexEnviv_t orig_glGetTexEnviv; +extern func_glGetTexGendv_t orig_glGetTexGendv; +extern func_glGetTexGenfv_t orig_glGetTexGenfv; +extern func_glGetTexGeniv_t orig_glGetTexGeniv; +extern func_glGetTexImage_t orig_glGetTexImage; +extern func_glGetTexLevelParameterfv_t orig_glGetTexLevelParameterfv; +extern func_glGetTexLevelParameteriv_t orig_glGetTexLevelParameteriv; +extern func_glGetTexParameterfv_t orig_glGetTexParameterfv; +extern func_glGetTexParameteriv_t orig_glGetTexParameteriv; +extern func_glHint_t orig_glHint; +extern func_glIndexMask_t orig_glIndexMask; +extern func_glIndexPointer_t orig_glIndexPointer; +extern func_glIndexd_t orig_glIndexd; +extern func_glIndexdv_t orig_glIndexdv; +extern func_glIndexf_t orig_glIndexf; +extern func_glIndexfv_t orig_glIndexfv; +extern func_glIndexi_t orig_glIndexi; +extern func_glIndexiv_t orig_glIndexiv; +extern func_glIndexs_t orig_glIndexs; +extern func_glIndexsv_t orig_glIndexsv; +extern func_glIndexub_t orig_glIndexub; +extern func_glIndexubv_t orig_glIndexubv; +extern func_glInitNames_t orig_glInitNames; +extern func_glInterleavedArrays_t orig_glInterleavedArrays; +extern func_glIsEnabled_t orig_glIsEnabled; +extern func_glIsList_t orig_glIsList; +extern func_glIsTexture_t orig_glIsTexture; +extern func_glLightModelf_t orig_glLightModelf; +extern func_glLightModelfv_t orig_glLightModelfv; +extern func_glLightModeli_t orig_glLightModeli; +extern func_glLightModeliv_t orig_glLightModeliv; +extern func_glLightf_t orig_glLightf; +extern func_glLightfv_t orig_glLightfv; +extern func_glLighti_t orig_glLighti; +extern func_glLightiv_t orig_glLightiv; +extern func_glLineStipple_t orig_glLineStipple; +extern func_glLineWidth_t orig_glLineWidth; +extern func_glListBase_t orig_glListBase; +extern func_glLoadIdentity_t orig_glLoadIdentity; +extern func_glLoadMatrixd_t orig_glLoadMatrixd; +extern func_glLoadMatrixf_t orig_glLoadMatrixf; +extern func_glLoadName_t orig_glLoadName; +extern func_glLogicOp_t orig_glLogicOp; +extern func_glMap1d_t orig_glMap1d; +extern func_glMap1f_t orig_glMap1f; +extern func_glMap2d_t orig_glMap2d; +extern func_glMap2f_t orig_glMap2f; +extern func_glMapGrid1d_t orig_glMapGrid1d; +extern func_glMapGrid1f_t orig_glMapGrid1f; +extern func_glMapGrid2d_t orig_glMapGrid2d; +extern func_glMapGrid2f_t orig_glMapGrid2f; +extern func_glMaterialf_t orig_glMaterialf; +extern func_glMaterialfv_t orig_glMaterialfv; +extern func_glMateriali_t orig_glMateriali; +extern func_glMaterialiv_t orig_glMaterialiv; +extern func_glMatrixMode_t orig_glMatrixMode; +extern func_glMultMatrixd_t orig_glMultMatrixd; +extern func_glMultMatrixf_t orig_glMultMatrixf; +extern func_glNewList_t orig_glNewList; +extern func_glNormal3b_t orig_glNormal3b; +extern func_glNormal3bv_t orig_glNormal3bv; +extern func_glNormal3d_t orig_glNormal3d; +extern func_glNormal3dv_t orig_glNormal3dv; +extern func_glNormal3f_t orig_glNormal3f; +extern func_glNormal3fv_t orig_glNormal3fv; +extern func_glNormal3i_t orig_glNormal3i; +extern func_glNormal3iv_t orig_glNormal3iv; +extern func_glNormal3s_t orig_glNormal3s; +extern func_glNormal3sv_t orig_glNormal3sv; +extern func_glNormalPointer_t orig_glNormalPointer; +extern func_glOrtho_t orig_glOrtho; +extern func_glPassThrough_t orig_glPassThrough; +extern func_glPixelMapfv_t orig_glPixelMapfv; +extern func_glPixelMapuiv_t orig_glPixelMapuiv; +extern func_glPixelMapusv_t orig_glPixelMapusv; +extern func_glPixelStoref_t orig_glPixelStoref; +extern func_glPixelStorei_t orig_glPixelStorei; +extern func_glPixelTransferf_t orig_glPixelTransferf; +extern func_glPixelTransferi_t orig_glPixelTransferi; +extern func_glPixelZoom_t orig_glPixelZoom; +extern func_glPointSize_t orig_glPointSize; +extern func_glPolygonMode_t orig_glPolygonMode; +extern func_glPolygonOffset_t orig_glPolygonOffset; +extern func_glPolygonStipple_t orig_glPolygonStipple; +extern func_glPopAttrib_t orig_glPopAttrib; +extern func_glPopClientAttrib_t orig_glPopClientAttrib; +extern func_glPopMatrix_t orig_glPopMatrix; +extern func_glPopName_t orig_glPopName; +extern func_glPrioritizeTextures_t orig_glPrioritizeTextures; +extern func_glPushAttrib_t orig_glPushAttrib; +extern func_glPushClientAttrib_t orig_glPushClientAttrib; +extern func_glPushMatrix_t orig_glPushMatrix; +extern func_glPushName_t orig_glPushName; +extern func_glRasterPos2d_t orig_glRasterPos2d; +extern func_glRasterPos2dv_t orig_glRasterPos2dv; +extern func_glRasterPos2f_t orig_glRasterPos2f; +extern func_glRasterPos2fv_t orig_glRasterPos2fv; +extern func_glRasterPos2i_t orig_glRasterPos2i; +extern func_glRasterPos2iv_t orig_glRasterPos2iv; +extern func_glRasterPos2s_t orig_glRasterPos2s; +extern func_glRasterPos2sv_t orig_glRasterPos2sv; +extern func_glRasterPos3d_t orig_glRasterPos3d; +extern func_glRasterPos3dv_t orig_glRasterPos3dv; +extern func_glRasterPos3f_t orig_glRasterPos3f; +extern func_glRasterPos3fv_t orig_glRasterPos3fv; +extern func_glRasterPos3i_t orig_glRasterPos3i; +extern func_glRasterPos3iv_t orig_glRasterPos3iv; +extern func_glRasterPos3s_t orig_glRasterPos3s; +extern func_glRasterPos3sv_t orig_glRasterPos3sv; +extern func_glRasterPos4d_t orig_glRasterPos4d; +extern func_glRasterPos4dv_t orig_glRasterPos4dv; +extern func_glRasterPos4f_t orig_glRasterPos4f; +extern func_glRasterPos4fv_t orig_glRasterPos4fv; +extern func_glRasterPos4i_t orig_glRasterPos4i; +extern func_glRasterPos4iv_t orig_glRasterPos4iv; +extern func_glRasterPos4s_t orig_glRasterPos4s; +extern func_glRasterPos4sv_t orig_glRasterPos4sv; +extern func_glReadBuffer_t orig_glReadBuffer; +extern func_glReadPixels_t orig_glReadPixels; +extern func_glRectd_t orig_glRectd; +extern func_glRectdv_t orig_glRectdv; +extern func_glRectf_t orig_glRectf; +extern func_glRectfv_t orig_glRectfv; +extern func_glRecti_t orig_glRecti; +extern func_glRectiv_t orig_glRectiv; +extern func_glRects_t orig_glRects; +extern func_glRectsv_t orig_glRectsv; +extern func_glRenderMode_t orig_glRenderMode; +extern func_glRotated_t orig_glRotated; +extern func_glRotatef_t orig_glRotatef; +extern func_glScaled_t orig_glScaled; +extern func_glScalef_t orig_glScalef; +extern func_glScissor_t orig_glScissor; +extern func_glSelectBuffer_t orig_glSelectBuffer; +extern func_glShadeModel_t orig_glShadeModel; +extern func_glStencilFunc_t orig_glStencilFunc; +extern func_glStencilMask_t orig_glStencilMask; +extern func_glStencilOp_t orig_glStencilOp; +extern func_glSwapBuffers_t orig_glSwapBuffers; +extern func_glTexCoord1d_t orig_glTexCoord1d; +extern func_glTexCoord1dv_t orig_glTexCoord1dv; +extern func_glTexCoord1f_t orig_glTexCoord1f; +extern func_glTexCoord1fv_t orig_glTexCoord1fv; +extern func_glTexCoord1i_t orig_glTexCoord1i; +extern func_glTexCoord1iv_t orig_glTexCoord1iv; +extern func_glTexCoord1s_t orig_glTexCoord1s; +extern func_glTexCoord1sv_t orig_glTexCoord1sv; +extern func_glTexCoord2d_t orig_glTexCoord2d; +extern func_glTexCoord2dv_t orig_glTexCoord2dv; +extern func_glTexCoord2f_t orig_glTexCoord2f; +extern func_glTexCoord2fv_t orig_glTexCoord2fv; +extern func_glTexCoord2i_t orig_glTexCoord2i; +extern func_glTexCoord2iv_t orig_glTexCoord2iv; +extern func_glTexCoord2s_t orig_glTexCoord2s; +extern func_glTexCoord2sv_t orig_glTexCoord2sv; +extern func_glTexCoord3d_t orig_glTexCoord3d; +extern func_glTexCoord3dv_t orig_glTexCoord3dv; +extern func_glTexCoord3f_t orig_glTexCoord3f; +extern func_glTexCoord3fv_t orig_glTexCoord3fv; +extern func_glTexCoord3i_t orig_glTexCoord3i; +extern func_glTexCoord3iv_t orig_glTexCoord3iv; +extern func_glTexCoord3s_t orig_glTexCoord3s; +extern func_glTexCoord3sv_t orig_glTexCoord3sv; +extern func_glTexCoord4d_t orig_glTexCoord4d; +extern func_glTexCoord4dv_t orig_glTexCoord4dv; +extern func_glTexCoord4f_t orig_glTexCoord4f; +extern func_glTexCoord4fv_t orig_glTexCoord4fv; +extern func_glTexCoord4i_t orig_glTexCoord4i; +extern func_glTexCoord4iv_t orig_glTexCoord4iv; +extern func_glTexCoord4s_t orig_glTexCoord4s; +extern func_glTexCoord4sv_t orig_glTexCoord4sv; +extern func_glTexCoordPointer_t orig_glTexCoordPointer; +extern func_glTexEnvf_t orig_glTexEnvf; +extern func_glTexEnvfv_t orig_glTexEnvfv; +extern func_glTexEnvi_t orig_glTexEnvi; +extern func_glTexEnviv_t orig_glTexEnviv; +extern func_glTexGend_t orig_glTexGend; +extern func_glTexGendv_t orig_glTexGendv; +extern func_glTexGenf_t orig_glTexGenf; +extern func_glTexGenfv_t orig_glTexGenfv; +extern func_glTexGeni_t orig_glTexGeni; +extern func_glTexGeniv_t orig_glTexGeniv; +extern func_glTexImage1D_t orig_glTexImage1D; +extern func_glTexImage2D_t orig_glTexImage2D; +extern func_glTexParameterf_t orig_glTexParameterf; +extern func_glTexParameterfv_t orig_glTexParameterfv; +extern func_glTexParameteri_t orig_glTexParameteri; +extern func_glTexParameteriv_t orig_glTexParameteriv; +extern func_glTexSubImage1D_t orig_glTexSubImage1D; +extern func_glTexSubImage2D_t orig_glTexSubImage2D; +extern func_glTranslated_t orig_glTranslated; +extern func_glTranslatef_t orig_glTranslatef; +extern func_glVertex2d_t orig_glVertex2d; +extern func_glVertex2dv_t orig_glVertex2dv; +extern func_glVertex2f_t orig_glVertex2f; +extern func_glVertex2fv_t orig_glVertex2fv; +extern func_glVertex2i_t orig_glVertex2i; +extern func_glVertex2iv_t orig_glVertex2iv; +extern func_glVertex2s_t orig_glVertex2s; +extern func_glVertex2sv_t orig_glVertex2sv; +extern func_glVertex3d_t orig_glVertex3d; +extern func_glVertex3dv_t orig_glVertex3dv; +extern func_glVertex3f_t orig_glVertex3f; +extern func_glVertex3fv_t orig_glVertex3fv; +extern func_glVertex3i_t orig_glVertex3i; +extern func_glVertex3iv_t orig_glVertex3iv; +extern func_glVertex3s_t orig_glVertex3s; +extern func_glVertex3sv_t orig_glVertex3sv; +extern func_glVertex4d_t orig_glVertex4d; +extern func_glVertex4dv_t orig_glVertex4dv; +extern func_glVertex4f_t orig_glVertex4f; +extern func_glVertex4fv_t orig_glVertex4fv; +extern func_glVertex4i_t orig_glVertex4i; +extern func_glVertex4iv_t orig_glVertex4iv; +extern func_glVertex4s_t orig_glVertex4s; +extern func_glVertex4sv_t orig_glVertex4sv; +extern func_glVertexPointer_t orig_glVertexPointer; +extern func_glViewport_t orig_glViewport; +extern func_wglChoosePixelFormat_t orig_wglChoosePixelFormat; +extern func_wglCopyContext_t orig_wglCopyContext; +extern func_wglCreateContext_t orig_wglCreateContext; +extern func_wglCreateLayerContext_t orig_wglCreateLayerContext; +extern func_wglDeleteContext_t orig_wglDeleteContext; +extern func_wglDescribeLayerPlane_t orig_wglDescribeLayerPlane; +extern func_wglDescribePixelFormat_t orig_wglDescribePixelFormat; +extern func_wglGetCurrentContext_t orig_wglGetCurrentContext; +extern func_wglGetCurrentDC_t orig_wglGetCurrentDC; +extern func_wglGetDefaultProcAddress_t orig_wglGetDefaultProcAddress; +extern func_wglGetLayerPaletteEntries_t orig_wglGetLayerPaletteEntries; +extern func_wglGetPixelFormat_t orig_wglGetPixelFormat; +extern func_wglGetProcAddress_t orig_wglGetProcAddress; +extern func_wglMakeCurrent_t orig_wglMakeCurrent; +extern func_wglRealizeLayerPalette_t orig_wglRealizeLayerPalette; +extern func_wglSetLayerPaletteEntries_t orig_wglSetLayerPaletteEntries; +extern func_wglSetPixelFormat_t orig_wglSetPixelFormat; +extern func_wglShareLists_t orig_wglShareLists; +extern func_wglSwapBuffers_t orig_wglSwapBuffers; +extern func_wglSwapLayerBuffers_t orig_wglSwapLayerBuffers; +extern func_wglUseFontBitmapsA_t orig_wglUseFontBitmapsA; +extern func_wglUseFontBitmapsW_t orig_wglUseFontBitmapsW; +extern func_wglUseFontOutlinesA_t orig_wglUseFontOutlinesA; +extern func_wglUseFontOutlinesW_t orig_wglUseFontOutlinesW; + +extern func_glBegin_t orig_exp_glBegin; +extern DWORD *exp_glBegin; +extern func_glDrawElements_t orig_exp_glDrawElements; +extern DWORD *exp_glDrawElements; +extern func_glViewport_t orig_exp_glViewport; +extern DWORD *exp_glViewport; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/code/cgame_hook/renderer/glext.h b/code/cgame_hook/renderer/glext.h new file mode 100644 index 00000000..a6661e62 --- /dev/null +++ b/code/cgame_hook/renderer/glext.h @@ -0,0 +1,12754 @@ +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007-2012 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated $Date: 2012-08-13 16:18:01 -0700 (Mon, 13 Aug 2012) $ */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 84 +/* Function declaration macros - to move into glplatform.h */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif + +#ifndef GL_ARB_imaging_DEPRECATED +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#endif + +#ifndef GL_VERSION_1_5_DEPRECATED +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC1_ALPHA 0x8589 +#define GL_SRC2_ALPHA 0x858A +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_VERSION_2_0_DEPRECATED +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +#endif + +#ifndef GL_VERSION_2_1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#endif + +#ifndef GL_VERSION_2_1_DEPRECATED +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#endif + +#ifndef GL_VERSION_3_0 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +/* Reuse tokens from ARB_depth_buffer_float */ +/* reuse GL_DEPTH_COMPONENT32F */ +/* reuse GL_DEPTH32F_STENCIL8 */ +/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_DEFAULT */ +/* reuse GL_FRAMEBUFFER_UNDEFINED */ +/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ +/* reuse GL_INDEX */ +/* reuse GL_MAX_RENDERBUFFER_SIZE */ +/* reuse GL_DEPTH_STENCIL */ +/* reuse GL_UNSIGNED_INT_24_8 */ +/* reuse GL_DEPTH24_STENCIL8 */ +/* reuse GL_TEXTURE_STENCIL_SIZE */ +/* reuse GL_TEXTURE_RED_TYPE */ +/* reuse GL_TEXTURE_GREEN_TYPE */ +/* reuse GL_TEXTURE_BLUE_TYPE */ +/* reuse GL_TEXTURE_ALPHA_TYPE */ +/* reuse GL_TEXTURE_DEPTH_TYPE */ +/* reuse GL_UNSIGNED_NORMALIZED */ +/* reuse GL_FRAMEBUFFER_BINDING */ +/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_BINDING */ +/* reuse GL_READ_FRAMEBUFFER */ +/* reuse GL_DRAW_FRAMEBUFFER */ +/* reuse GL_READ_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_SAMPLES */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* reuse GL_FRAMEBUFFER_COMPLETE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ +/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ +/* reuse GL_MAX_COLOR_ATTACHMENTS */ +/* reuse GL_COLOR_ATTACHMENT0 */ +/* reuse GL_COLOR_ATTACHMENT1 */ +/* reuse GL_COLOR_ATTACHMENT2 */ +/* reuse GL_COLOR_ATTACHMENT3 */ +/* reuse GL_COLOR_ATTACHMENT4 */ +/* reuse GL_COLOR_ATTACHMENT5 */ +/* reuse GL_COLOR_ATTACHMENT6 */ +/* reuse GL_COLOR_ATTACHMENT7 */ +/* reuse GL_COLOR_ATTACHMENT8 */ +/* reuse GL_COLOR_ATTACHMENT9 */ +/* reuse GL_COLOR_ATTACHMENT10 */ +/* reuse GL_COLOR_ATTACHMENT11 */ +/* reuse GL_COLOR_ATTACHMENT12 */ +/* reuse GL_COLOR_ATTACHMENT13 */ +/* reuse GL_COLOR_ATTACHMENT14 */ +/* reuse GL_COLOR_ATTACHMENT15 */ +/* reuse GL_DEPTH_ATTACHMENT */ +/* reuse GL_STENCIL_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_RENDERBUFFER_WIDTH */ +/* reuse GL_RENDERBUFFER_HEIGHT */ +/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ +/* reuse GL_STENCIL_INDEX1 */ +/* reuse GL_STENCIL_INDEX4 */ +/* reuse GL_STENCIL_INDEX8 */ +/* reuse GL_STENCIL_INDEX16 */ +/* reuse GL_RENDERBUFFER_RED_SIZE */ +/* reuse GL_RENDERBUFFER_GREEN_SIZE */ +/* reuse GL_RENDERBUFFER_BLUE_SIZE */ +/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ +/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ +/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ +/* reuse GL_MAX_SAMPLES */ +/* Reuse tokens from ARB_framebuffer_sRGB */ +/* reuse GL_FRAMEBUFFER_SRGB */ +/* Reuse tokens from ARB_half_float_vertex */ +/* reuse GL_HALF_FLOAT */ +/* Reuse tokens from ARB_map_buffer_range */ +/* reuse GL_MAP_READ_BIT */ +/* reuse GL_MAP_WRITE_BIT */ +/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ +/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ +/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ +/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ +/* Reuse tokens from ARB_texture_compression_rgtc */ +/* reuse GL_COMPRESSED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_RG_RGTC2 */ +/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ +/* Reuse tokens from ARB_texture_rg */ +/* reuse GL_RG */ +/* reuse GL_RG_INTEGER */ +/* reuse GL_R8 */ +/* reuse GL_R16 */ +/* reuse GL_RG8 */ +/* reuse GL_RG16 */ +/* reuse GL_R16F */ +/* reuse GL_R32F */ +/* reuse GL_RG16F */ +/* reuse GL_RG32F */ +/* reuse GL_R8I */ +/* reuse GL_R8UI */ +/* reuse GL_R16I */ +/* reuse GL_R16UI */ +/* reuse GL_R32I */ +/* reuse GL_R32UI */ +/* reuse GL_RG8I */ +/* reuse GL_RG8UI */ +/* reuse GL_RG16I */ +/* reuse GL_RG16UI */ +/* reuse GL_RG32I */ +/* reuse GL_RG32UI */ +/* Reuse tokens from ARB_vertex_array_object */ +/* reuse GL_VERTEX_ARRAY_BINDING */ +#endif + +#ifndef GL_VERSION_3_0_DEPRECATED +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_TEXTURE_LUMINANCE_TYPE */ +/* reuse GL_TEXTURE_INTENSITY_TYPE */ +#endif + +#ifndef GL_VERSION_3_1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +/* Reuse tokens from ARB_copy_buffer */ +/* reuse GL_COPY_READ_BUFFER */ +/* reuse GL_COPY_WRITE_BUFFER */ +/* Reuse tokens from ARB_draw_instanced (none) */ +/* Reuse tokens from ARB_uniform_buffer_object */ +/* reuse GL_UNIFORM_BUFFER */ +/* reuse GL_UNIFORM_BUFFER_BINDING */ +/* reuse GL_UNIFORM_BUFFER_START */ +/* reuse GL_UNIFORM_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ +/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ +/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ +/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ +/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ +/* reuse GL_UNIFORM_TYPE */ +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_INDEX */ +/* reuse GL_UNIFORM_OFFSET */ +/* reuse GL_UNIFORM_ARRAY_STRIDE */ +/* reuse GL_UNIFORM_MATRIX_STRIDE */ +/* reuse GL_UNIFORM_IS_ROW_MAJOR */ +/* reuse GL_UNIFORM_BLOCK_BINDING */ +/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ +/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_INVALID_INDEX */ +#endif + +#ifndef GL_VERSION_3_2 +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* Reuse tokens from ARB_depth_clamp */ +/* reuse GL_DEPTH_CLAMP */ +/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ +/* Reuse tokens from ARB_fragment_coord_conventions (none) */ +/* Reuse tokens from ARB_provoking_vertex */ +/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +/* Reuse tokens from ARB_seamless_cube_map */ +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ +/* Reuse tokens from ARB_sync */ +/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ +/* reuse GL_OBJECT_TYPE */ +/* reuse GL_SYNC_CONDITION */ +/* reuse GL_SYNC_STATUS */ +/* reuse GL_SYNC_FLAGS */ +/* reuse GL_SYNC_FENCE */ +/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ +/* reuse GL_UNSIGNALED */ +/* reuse GL_SIGNALED */ +/* reuse GL_ALREADY_SIGNALED */ +/* reuse GL_TIMEOUT_EXPIRED */ +/* reuse GL_CONDITION_SATISFIED */ +/* reuse GL_WAIT_FAILED */ +/* reuse GL_TIMEOUT_IGNORED */ +/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ +/* reuse GL_TIMEOUT_IGNORED */ +/* Reuse tokens from ARB_texture_multisample */ +/* reuse GL_SAMPLE_POSITION */ +/* reuse GL_SAMPLE_MASK */ +/* reuse GL_SAMPLE_MASK_VALUE */ +/* reuse GL_MAX_SAMPLE_MASK_WORDS */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_SAMPLES */ +/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ +/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ +/* reuse GL_MAX_INTEGER_SAMPLES */ +/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +/* Reuse tokens from ARB_blend_func_extended */ +/* reuse GL_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_ALPHA */ +/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ +/* Reuse tokens from ARB_explicit_attrib_location (none) */ +/* Reuse tokens from ARB_occlusion_query2 */ +/* reuse GL_ANY_SAMPLES_PASSED */ +/* Reuse tokens from ARB_sampler_objects */ +/* reuse GL_SAMPLER_BINDING */ +/* Reuse tokens from ARB_shader_bit_encoding (none) */ +/* Reuse tokens from ARB_texture_rgb10_a2ui */ +/* reuse GL_RGB10_A2UI */ +/* Reuse tokens from ARB_texture_swizzle */ +/* reuse GL_TEXTURE_SWIZZLE_R */ +/* reuse GL_TEXTURE_SWIZZLE_G */ +/* reuse GL_TEXTURE_SWIZZLE_B */ +/* reuse GL_TEXTURE_SWIZZLE_A */ +/* reuse GL_TEXTURE_SWIZZLE_RGBA */ +/* Reuse tokens from ARB_timer_query */ +/* reuse GL_TIME_ELAPSED */ +/* reuse GL_TIMESTAMP */ +/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ +/* reuse GL_INT_2_10_10_10_REV */ +#endif + +#ifndef GL_VERSION_4_0 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +/* Reuse tokens from ARB_texture_query_lod (none) */ +/* Reuse tokens from ARB_draw_buffers_blend (none) */ +/* Reuse tokens from ARB_draw_indirect */ +/* reuse GL_DRAW_INDIRECT_BUFFER */ +/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_gpu_shader5 */ +/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +/* Reuse tokens from ARB_gpu_shader_fp64 */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +/* Reuse tokens from ARB_shader_subroutine */ +/* reuse GL_ACTIVE_SUBROUTINES */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ +/* reuse GL_MAX_SUBROUTINES */ +/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +/* Reuse tokens from ARB_tessellation_shader */ +/* reuse GL_PATCHES */ +/* reuse GL_PATCH_VERTICES */ +/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ +/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ +/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ +/* reuse GL_TESS_GEN_MODE */ +/* reuse GL_TESS_GEN_SPACING */ +/* reuse GL_TESS_GEN_VERTEX_ORDER */ +/* reuse GL_TESS_GEN_POINT_MODE */ +/* reuse GL_ISOLINES */ +/* reuse GL_FRACTIONAL_ODD */ +/* reuse GL_FRACTIONAL_EVEN */ +/* reuse GL_MAX_PATCH_VERTICES */ +/* reuse GL_MAX_TESS_GEN_LEVEL */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_CONTROL_SHADER */ +/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ +/* Reuse tokens from ARB_transform_feedback2 */ +/* reuse GL_TRANSFORM_FEEDBACK */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ +/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ +/* Reuse tokens from ARB_transform_feedback3 */ +/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_VERSION_4_1 +/* Reuse tokens from ARB_ES2_compatibility */ +/* reuse GL_FIXED */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ +/* reuse GL_LOW_FLOAT */ +/* reuse GL_MEDIUM_FLOAT */ +/* reuse GL_HIGH_FLOAT */ +/* reuse GL_LOW_INT */ +/* reuse GL_MEDIUM_INT */ +/* reuse GL_HIGH_INT */ +/* reuse GL_SHADER_COMPILER */ +/* reuse GL_NUM_SHADER_BINARY_FORMATS */ +/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ +/* reuse GL_MAX_VARYING_VECTORS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ +/* reuse GL_RGB565 */ +/* Reuse tokens from ARB_get_program_binary */ +/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ +/* reuse GL_PROGRAM_BINARY_LENGTH */ +/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ +/* reuse GL_PROGRAM_BINARY_FORMATS */ +/* Reuse tokens from ARB_separate_shader_objects */ +/* reuse GL_VERTEX_SHADER_BIT */ +/* reuse GL_FRAGMENT_SHADER_BIT */ +/* reuse GL_GEOMETRY_SHADER_BIT */ +/* reuse GL_TESS_CONTROL_SHADER_BIT */ +/* reuse GL_TESS_EVALUATION_SHADER_BIT */ +/* reuse GL_ALL_SHADER_BITS */ +/* reuse GL_PROGRAM_SEPARABLE */ +/* reuse GL_ACTIVE_PROGRAM */ +/* reuse GL_PROGRAM_PIPELINE_BINDING */ +/* Reuse tokens from ARB_shader_precision (none) */ +/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ +/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ +/* reuse GL_MAX_VIEWPORTS */ +/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ +/* reuse GL_VIEWPORT_BOUNDS_RANGE */ +/* reuse GL_LAYER_PROVOKING_VERTEX */ +/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ +/* reuse GL_UNDEFINED_VERTEX */ +#endif + +#ifndef GL_VERSION_4_2 +/* Reuse tokens from ARB_base_instance (none) */ +/* Reuse tokens from ARB_shading_language_420pack (none) */ +/* Reuse tokens from ARB_transform_feedback_instanced (none) */ +/* Reuse tokens from ARB_compressed_texture_pixel_storage */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */ +/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */ +/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */ +/* Reuse tokens from ARB_conservative_depth (none) */ +/* Reuse tokens from ARB_internalformat_query */ +/* reuse GL_NUM_SAMPLE_COUNTS */ +/* Reuse tokens from ARB_map_buffer_alignment */ +/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */ +/* Reuse tokens from ARB_shader_atomic_counters */ +/* reuse GL_ATOMIC_COUNTER_BUFFER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_START */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */ +/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */ +/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */ +/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */ +/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */ +/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */ +/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */ +/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */ +/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */ +/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */ +/* Reuse tokens from ARB_shader_image_load_store */ +/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */ +/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */ +/* reuse GL_UNIFORM_BARRIER_BIT */ +/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */ +/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */ +/* reuse GL_COMMAND_BARRIER_BIT */ +/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */ +/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */ +/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */ +/* reuse GL_FRAMEBUFFER_BARRIER_BIT */ +/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */ +/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */ +/* reuse GL_ALL_BARRIER_BITS */ +/* reuse GL_MAX_IMAGE_UNITS */ +/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ +/* reuse GL_IMAGE_BINDING_NAME */ +/* reuse GL_IMAGE_BINDING_LEVEL */ +/* reuse GL_IMAGE_BINDING_LAYERED */ +/* reuse GL_IMAGE_BINDING_LAYER */ +/* reuse GL_IMAGE_BINDING_ACCESS */ +/* reuse GL_IMAGE_1D */ +/* reuse GL_IMAGE_2D */ +/* reuse GL_IMAGE_3D */ +/* reuse GL_IMAGE_2D_RECT */ +/* reuse GL_IMAGE_CUBE */ +/* reuse GL_IMAGE_BUFFER */ +/* reuse GL_IMAGE_1D_ARRAY */ +/* reuse GL_IMAGE_2D_ARRAY */ +/* reuse GL_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_INT_IMAGE_1D */ +/* reuse GL_INT_IMAGE_2D */ +/* reuse GL_INT_IMAGE_3D */ +/* reuse GL_INT_IMAGE_2D_RECT */ +/* reuse GL_INT_IMAGE_CUBE */ +/* reuse GL_INT_IMAGE_BUFFER */ +/* reuse GL_INT_IMAGE_1D_ARRAY */ +/* reuse GL_INT_IMAGE_2D_ARRAY */ +/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_1D */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D */ +/* reuse GL_UNSIGNED_INT_IMAGE_3D */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */ +/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */ +/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */ +/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_MAX_IMAGE_SAMPLES */ +/* reuse GL_IMAGE_BINDING_FORMAT */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */ +/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */ +/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */ +/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */ +/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */ +/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */ +/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */ +/* Reuse tokens from ARB_shading_language_packing (none) */ +/* Reuse tokens from ARB_texture_storage */ +/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ +#endif + +#ifndef GL_VERSION_4_3 +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +/* Reuse tokens from ARB_arrays_of_arrays (none, GLSL only) */ +/* Reuse tokens from ARB_fragment_layer_viewport (none, GLSL only) */ +/* Reuse tokens from ARB_shader_image_size (none, GLSL only) */ +/* Reuse tokens from ARB_ES3_compatibility */ +/* reuse GL_COMPRESSED_RGB8_ETC2 */ +/* reuse GL_COMPRESSED_SRGB8_ETC2 */ +/* reuse GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ +/* reuse GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ +/* reuse GL_COMPRESSED_RGBA8_ETC2_EAC */ +/* reuse GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC */ +/* reuse GL_COMPRESSED_R11_EAC */ +/* reuse GL_COMPRESSED_SIGNED_R11_EAC */ +/* reuse GL_COMPRESSED_RG11_EAC */ +/* reuse GL_COMPRESSED_SIGNED_RG11_EAC */ +/* reuse GL_PRIMITIVE_RESTART_FIXED_INDEX */ +/* reuse GL_ANY_SAMPLES_PASSED_CONSERVATIVE */ +/* reuse GL_MAX_ELEMENT_INDEX */ +/* Reuse tokens from ARB_clear_buffer_object (none) */ +/* Reuse tokens from ARB_compute_shader */ +/* reuse GL_COMPUTE_SHADER */ +/* reuse GL_MAX_COMPUTE_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_COMPUTE_IMAGE_UNIFORMS */ +/* reuse GL_MAX_COMPUTE_SHARED_MEMORY_SIZE */ +/* reuse GL_MAX_COMPUTE_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTERS */ +/* reuse GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMPUTE_LOCAL_INVOCATIONS */ +/* reuse GL_MAX_COMPUTE_WORK_GROUP_COUNT */ +/* reuse GL_MAX_COMPUTE_WORK_GROUP_SIZE */ +/* reuse GL_COMPUTE_LOCAL_WORK_SIZE */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_DISPATCH_INDIRECT_BUFFER */ +/* reuse GL_DISPATCH_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_copy_image (none) */ +/* Reuse tokens from KHR_debug */ +/* reuse GL_DEBUG_OUTPUT_SYNCHRONOUS */ +/* reuse GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH */ +/* reuse GL_DEBUG_CALLBACK_FUNCTION */ +/* reuse GL_DEBUG_CALLBACK_USER_PARAM */ +/* reuse GL_DEBUG_SOURCE_API */ +/* reuse GL_DEBUG_SOURCE_WINDOW_SYSTEM */ +/* reuse GL_DEBUG_SOURCE_SHADER_COMPILER */ +/* reuse GL_DEBUG_SOURCE_THIRD_PARTY */ +/* reuse GL_DEBUG_SOURCE_APPLICATION */ +/* reuse GL_DEBUG_SOURCE_OTHER */ +/* reuse GL_DEBUG_TYPE_ERROR */ +/* reuse GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR */ +/* reuse GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR */ +/* reuse GL_DEBUG_TYPE_PORTABILITY */ +/* reuse GL_DEBUG_TYPE_PERFORMANCE */ +/* reuse GL_DEBUG_TYPE_OTHER */ +/* reuse GL_MAX_DEBUG_MESSAGE_LENGTH */ +/* reuse GL_MAX_DEBUG_LOGGED_MESSAGES */ +/* reuse GL_DEBUG_LOGGED_MESSAGES */ +/* reuse GL_DEBUG_SEVERITY_HIGH */ +/* reuse GL_DEBUG_SEVERITY_MEDIUM */ +/* reuse GL_DEBUG_SEVERITY_LOW */ +/* reuse GL_DEBUG_TYPE_MARKER */ +/* reuse GL_DEBUG_TYPE_PUSH_GROUP */ +/* reuse GL_DEBUG_TYPE_POP_GROUP */ +/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */ +/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_BUFFER */ +/* reuse GL_SHADER */ +/* reuse GL_PROGRAM */ +/* reuse GL_QUERY */ +/* reuse GL_PROGRAM_PIPELINE */ +/* reuse GL_SAMPLER */ +/* reuse GL_DISPLAY_LIST */ +/* reuse GL_MAX_LABEL_LENGTH */ +/* reuse GL_DEBUG_OUTPUT */ +/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */ +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +/* Reuse tokens from ARB_explicit_uniform_location */ +/* reuse GL_MAX_UNIFORM_LOCATIONS */ +/* Reuse tokens from ARB_framebuffer_no_attachments */ +/* reuse GL_FRAMEBUFFER_DEFAULT_WIDTH */ +/* reuse GL_FRAMEBUFFER_DEFAULT_HEIGHT */ +/* reuse GL_FRAMEBUFFER_DEFAULT_LAYERS */ +/* reuse GL_FRAMEBUFFER_DEFAULT_SAMPLES */ +/* reuse GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_MAX_FRAMEBUFFER_WIDTH */ +/* reuse GL_MAX_FRAMEBUFFER_HEIGHT */ +/* reuse GL_MAX_FRAMEBUFFER_LAYERS */ +/* reuse GL_MAX_FRAMEBUFFER_SAMPLES */ +/* Reuse tokens from ARB_internalformat_query2 */ +/* reuse GL_INTERNALFORMAT_SUPPORTED */ +/* reuse GL_INTERNALFORMAT_PREFERRED */ +/* reuse GL_INTERNALFORMAT_RED_SIZE */ +/* reuse GL_INTERNALFORMAT_GREEN_SIZE */ +/* reuse GL_INTERNALFORMAT_BLUE_SIZE */ +/* reuse GL_INTERNALFORMAT_ALPHA_SIZE */ +/* reuse GL_INTERNALFORMAT_DEPTH_SIZE */ +/* reuse GL_INTERNALFORMAT_STENCIL_SIZE */ +/* reuse GL_INTERNALFORMAT_SHARED_SIZE */ +/* reuse GL_INTERNALFORMAT_RED_TYPE */ +/* reuse GL_INTERNALFORMAT_GREEN_TYPE */ +/* reuse GL_INTERNALFORMAT_BLUE_TYPE */ +/* reuse GL_INTERNALFORMAT_ALPHA_TYPE */ +/* reuse GL_INTERNALFORMAT_DEPTH_TYPE */ +/* reuse GL_INTERNALFORMAT_STENCIL_TYPE */ +/* reuse GL_MAX_WIDTH */ +/* reuse GL_MAX_HEIGHT */ +/* reuse GL_MAX_DEPTH */ +/* reuse GL_MAX_LAYERS */ +/* reuse GL_MAX_COMBINED_DIMENSIONS */ +/* reuse GL_COLOR_COMPONENTS */ +/* reuse GL_DEPTH_COMPONENTS */ +/* reuse GL_STENCIL_COMPONENTS */ +/* reuse GL_COLOR_RENDERABLE */ +/* reuse GL_DEPTH_RENDERABLE */ +/* reuse GL_STENCIL_RENDERABLE */ +/* reuse GL_FRAMEBUFFER_RENDERABLE */ +/* reuse GL_FRAMEBUFFER_RENDERABLE_LAYERED */ +/* reuse GL_FRAMEBUFFER_BLEND */ +/* reuse GL_READ_PIXELS */ +/* reuse GL_READ_PIXELS_FORMAT */ +/* reuse GL_READ_PIXELS_TYPE */ +/* reuse GL_TEXTURE_IMAGE_FORMAT */ +/* reuse GL_TEXTURE_IMAGE_TYPE */ +/* reuse GL_GET_TEXTURE_IMAGE_FORMAT */ +/* reuse GL_GET_TEXTURE_IMAGE_TYPE */ +/* reuse GL_MIPMAP */ +/* reuse GL_MANUAL_GENERATE_MIPMAP */ +/* reuse GL_AUTO_GENERATE_MIPMAP */ +/* reuse GL_COLOR_ENCODING */ +/* reuse GL_SRGB_READ */ +/* reuse GL_SRGB_WRITE */ +/* reuse GL_FILTER */ +/* reuse GL_VERTEX_TEXTURE */ +/* reuse GL_TESS_CONTROL_TEXTURE */ +/* reuse GL_TESS_EVALUATION_TEXTURE */ +/* reuse GL_GEOMETRY_TEXTURE */ +/* reuse GL_FRAGMENT_TEXTURE */ +/* reuse GL_COMPUTE_TEXTURE */ +/* reuse GL_TEXTURE_SHADOW */ +/* reuse GL_TEXTURE_GATHER */ +/* reuse GL_TEXTURE_GATHER_SHADOW */ +/* reuse GL_SHADER_IMAGE_LOAD */ +/* reuse GL_SHADER_IMAGE_STORE */ +/* reuse GL_SHADER_IMAGE_ATOMIC */ +/* reuse GL_IMAGE_TEXEL_SIZE */ +/* reuse GL_IMAGE_COMPATIBILITY_CLASS */ +/* reuse GL_IMAGE_PIXEL_FORMAT */ +/* reuse GL_IMAGE_PIXEL_TYPE */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_SIZE */ +/* reuse GL_CLEAR_BUFFER */ +/* reuse GL_TEXTURE_VIEW */ +/* reuse GL_VIEW_COMPATIBILITY_CLASS */ +/* reuse GL_FULL_SUPPORT */ +/* reuse GL_CAVEAT_SUPPORT */ +/* reuse GL_IMAGE_CLASS_4_X_32 */ +/* reuse GL_IMAGE_CLASS_2_X_32 */ +/* reuse GL_IMAGE_CLASS_1_X_32 */ +/* reuse GL_IMAGE_CLASS_4_X_16 */ +/* reuse GL_IMAGE_CLASS_2_X_16 */ +/* reuse GL_IMAGE_CLASS_1_X_16 */ +/* reuse GL_IMAGE_CLASS_4_X_8 */ +/* reuse GL_IMAGE_CLASS_2_X_8 */ +/* reuse GL_IMAGE_CLASS_1_X_8 */ +/* reuse GL_IMAGE_CLASS_11_11_10 */ +/* reuse GL_IMAGE_CLASS_10_10_10_2 */ +/* reuse GL_VIEW_CLASS_128_BITS */ +/* reuse GL_VIEW_CLASS_96_BITS */ +/* reuse GL_VIEW_CLASS_64_BITS */ +/* reuse GL_VIEW_CLASS_48_BITS */ +/* reuse GL_VIEW_CLASS_32_BITS */ +/* reuse GL_VIEW_CLASS_24_BITS */ +/* reuse GL_VIEW_CLASS_16_BITS */ +/* reuse GL_VIEW_CLASS_8_BITS */ +/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGB */ +/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGBA */ +/* reuse GL_VIEW_CLASS_S3TC_DXT3_RGBA */ +/* reuse GL_VIEW_CLASS_S3TC_DXT5_RGBA */ +/* reuse GL_VIEW_CLASS_RGTC1_RED */ +/* reuse GL_VIEW_CLASS_RGTC2_RG */ +/* reuse GL_VIEW_CLASS_BPTC_UNORM */ +/* reuse GL_VIEW_CLASS_BPTC_FLOAT */ +/* Reuse tokens from ARB_invalidate_subdata (none) */ +/* Reuse tokens from ARB_multi_draw_indirect (none) */ +/* Reuse tokens from ARB_program_interface_query */ +/* reuse GL_UNIFORM */ +/* reuse GL_UNIFORM_BLOCK */ +/* reuse GL_PROGRAM_INPUT */ +/* reuse GL_PROGRAM_OUTPUT */ +/* reuse GL_BUFFER_VARIABLE */ +/* reuse GL_SHADER_STORAGE_BLOCK */ +/* reuse GL_VERTEX_SUBROUTINE */ +/* reuse GL_TESS_CONTROL_SUBROUTINE */ +/* reuse GL_TESS_EVALUATION_SUBROUTINE */ +/* reuse GL_GEOMETRY_SUBROUTINE */ +/* reuse GL_FRAGMENT_SUBROUTINE */ +/* reuse GL_COMPUTE_SUBROUTINE */ +/* reuse GL_VERTEX_SUBROUTINE_UNIFORM */ +/* reuse GL_TESS_CONTROL_SUBROUTINE_UNIFORM */ +/* reuse GL_TESS_EVALUATION_SUBROUTINE_UNIFORM */ +/* reuse GL_GEOMETRY_SUBROUTINE_UNIFORM */ +/* reuse GL_FRAGMENT_SUBROUTINE_UNIFORM */ +/* reuse GL_COMPUTE_SUBROUTINE_UNIFORM */ +/* reuse GL_TRANSFORM_FEEDBACK_VARYING */ +/* reuse GL_ACTIVE_RESOURCES */ +/* reuse GL_MAX_NAME_LENGTH */ +/* reuse GL_MAX_NUM_ACTIVE_VARIABLES */ +/* reuse GL_MAX_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_NAME_LENGTH */ +/* reuse GL_TYPE */ +/* reuse GL_ARRAY_SIZE */ +/* reuse GL_OFFSET */ +/* reuse GL_BLOCK_INDEX */ +/* reuse GL_ARRAY_STRIDE */ +/* reuse GL_MATRIX_STRIDE */ +/* reuse GL_IS_ROW_MAJOR */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_INDEX */ +/* reuse GL_BUFFER_BINDING */ +/* reuse GL_BUFFER_DATA_SIZE */ +/* reuse GL_NUM_ACTIVE_VARIABLES */ +/* reuse GL_ACTIVE_VARIABLES */ +/* reuse GL_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_REFERENCED_BY_GEOMETRY_SHADER */ +/* reuse GL_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_TOP_LEVEL_ARRAY_SIZE */ +/* reuse GL_TOP_LEVEL_ARRAY_STRIDE */ +/* reuse GL_LOCATION */ +/* reuse GL_LOCATION_INDEX */ +/* reuse GL_IS_PER_PATCH */ +/* Reuse tokens from ARB_robust_buffer_access_behavior (none) */ +/* Reuse tokens from ARB_shader_storage_buffer_object */ +/* reuse GL_SHADER_STORAGE_BUFFER */ +/* reuse GL_SHADER_STORAGE_BUFFER_BINDING */ +/* reuse GL_SHADER_STORAGE_BUFFER_START */ +/* reuse GL_SHADER_STORAGE_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS */ +/* reuse GL_MAX_SHADER_STORAGE_BLOCK_SIZE */ +/* reuse GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_SHADER_STORAGE_BARRIER_BIT */ +/* reuse GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES */ +/* Reuse tokens from ARB_stencil_texturing */ +/* reuse GL_DEPTH_STENCIL_TEXTURE_MODE */ +/* Reuse tokens from ARB_texture_buffer_range */ +/* reuse GL_TEXTURE_BUFFER_OFFSET */ +/* reuse GL_TEXTURE_BUFFER_SIZE */ +/* reuse GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT */ +/* Reuse tokens from ARB_texture_query_levels (none) */ +/* Reuse tokens from ARB_texture_storage_multisample (none) */ +/* Reuse tokens from ARB_texture_view */ +/* reuse GL_TEXTURE_VIEW_MIN_LEVEL */ +/* reuse GL_TEXTURE_VIEW_NUM_LEVELS */ +/* reuse GL_TEXTURE_VIEW_MIN_LAYER */ +/* reuse GL_TEXTURE_VIEW_NUM_LAYERS */ +/* reuse GL_TEXTURE_IMMUTABLE_LEVELS */ +/* Reuse tokens from ARB_vertex_attrib_binding */ +/* reuse GL_VERTEX_ATTRIB_BINDING */ +/* reuse GL_VERTEX_ATTRIB_RELATIVE_OFFSET */ +/* reuse GL_VERTEX_BINDING_DIVISOR */ +/* reuse GL_VERTEX_BINDING_OFFSET */ +/* reuse GL_VERTEX_BINDING_STRIDE */ +/* reuse GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET */ +/* reuse GL_MAX_VERTEX_ATTRIB_BINDINGS */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#endif + +#ifndef GL_ARB_draw_instanced +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#endif + +#ifndef GL_ARB_framebuffer_object_DEPRECATED +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_HALF_FLOAT 0x140B +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_ARB_texture_rg +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#endif + +#ifndef GL_ARB_compatibility +/* ARB_compatibility just defines tokens from core 3.0 */ +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_READ_BUFFER GL_COPY_READ_BUFFER_BINDING +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_COPY_WRITE_BUFFER GL_COPY_WRITE_BUFFER_BINDING +#endif + +#ifndef GL_ARB_shader_texture_lod +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_DEPTH_CLAMP 0x864F +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#endif + +#ifndef GL_ARB_sync +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#endif + +#ifndef GL_ARB_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_ARB_draw_buffers_blend +#endif + +#ifndef GL_ARB_sample_shading +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif + +#ifndef GL_ARB_texture_gather +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#endif + +#ifndef GL_ARB_texture_query_lod +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_SRC1_COLOR 0x88F9 +/* reuse GL_SRC1_ALPHA */ +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#endif + +#ifndef GL_ARB_explicit_attrib_location +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_SAMPLER_BINDING 0x8919 +#endif + +#ifndef GL_ARB_shader_bit_encoding +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_RGB10_A2UI 0x906F +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#endif + +#ifndef GL_ARB_timer_query +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ +#define GL_INT_2_10_10_10_REV 0x8D9F +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +/* reuse GL_TRIANGLES */ +/* reuse GL_QUADS */ +#define GL_ISOLINES 0x8E7A +/* reuse GL_EQUAL */ +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +/* reuse GL_CCW */ +/* reuse GL_CW */ +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +/* reuse GL_RGB32F */ +/* reuse GL_RGB32UI */ +/* reuse GL_RGB32I */ +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED GL_TRANSFORM_FEEDBACK_PAUSED +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE GL_TRANSFORM_FEEDBACK_ACTIVE +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#endif + +#ifndef GL_ARB_shader_precision +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +/* reuse GL_RGB32I */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +#endif + +#ifndef GL_ARB_viewport_array +/* reuse GL_SCISSOR_BOX */ +/* reuse GL_VIEWPORT */ +/* reuse GL_DEPTH_RANGE */ +/* reuse GL_SCISSOR_TEST */ +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +#endif + +#ifndef GL_ARB_cl_event +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +#endif + +#ifndef GL_ARB_debug_output +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +#endif + +#ifndef GL_ARB_robustness +/* reuse GL_NO_ERROR */ +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif + +#ifndef GL_ARB_shader_stencil_export +#endif + +#ifndef GL_ARB_base_instance +#endif + +#ifndef GL_ARB_shading_language_420pack +#endif + +#ifndef GL_ARB_transform_feedback_instanced +#endif + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#endif + +#ifndef GL_ARB_conservative_depth +#endif + +#ifndef GL_ARB_internalformat_query +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#endif + +#ifndef GL_ARB_map_buffer_alignment +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#endif + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#endif + +#ifndef GL_ARB_shader_image_load_store +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#endif + +#ifndef GL_ARB_shading_language_packing +#endif + +#ifndef GL_ARB_texture_storage +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + +#ifndef GL_KHR_debug +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_DISPLAY_LIST 0x82E7 +/* DISPLAY_LIST used in compatibility profile only */ +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +#endif + +#ifndef GL_ARB_arrays_of_arrays +#endif + +#ifndef GL_ARB_clear_buffer_object +#endif + +#ifndef GL_ARB_compute_shader +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif + +#ifndef GL_ARB_copy_image +#endif + +#ifndef GL_ARB_texture_view +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#endif + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#endif + +#ifndef GL_ARB_robustness_isolation +#endif + +#ifndef GL_ARB_ES3_compatibility +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif + +#ifndef GL_ARB_explicit_uniform_location +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#endif + +#ifndef GL_ARB_fragment_layer_viewport +#endif + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#endif + +#ifndef GL_ARB_internalformat_query2 +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ +/* reuse GL_NUM_SAMPLE_COUNTS */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_SAMPLES */ +/* reuse GL_TEXTURE_1D */ +/* reuse GL_TEXTURE_1D_ARRAY */ +/* reuse GL_TEXTURE_2D */ +/* reuse GL_TEXTURE_2D_ARRAY */ +/* reuse GL_TEXTURE_3D */ +/* reuse GL_TEXTURE_CUBE_MAP */ +/* reuse GL_TEXTURE_CUBE_MAP_ARRAY */ +/* reuse GL_TEXTURE_RECTANGLE */ +/* reuse GL_TEXTURE_BUFFER */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_COMPRESSED */ +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_SRGB_DECODE_ARB 0x8299 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#endif + +#ifndef GL_ARB_invalidate_subdata +#endif + +#ifndef GL_ARB_multi_draw_indirect +#endif + +#ifndef GL_ARB_program_interface_query +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +/* reuse GL_ATOMIC_COUNTER_BUFFER */ +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +#endif + +#ifndef GL_ARB_robust_buffer_access_behavior +#endif + +#ifndef GL_ARB_shader_image_size +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x2000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS +/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ +#endif + +#ifndef GL_ARB_stencil_texturing +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#endif + +#ifndef GL_ARB_texture_buffer_range +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#endif + +#ifndef GL_ARB_texture_query_levels +#endif + +#ifndef GL_ARB_texture_storage_multisample +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif + +#ifndef GL_EXT_timer_query +#define GL_TIME_ELAPSED_EXT 0x88BF +#endif + +#ifndef GL_EXT_gpu_program_parameters +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ +/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ +/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ +/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +/* reuse GL_LINES_ADJACENCY_EXT */ +/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ +/* reuse GL_TRIANGLES_ADJACENCY_EXT */ +/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +/* reuse GL_PROGRAM_POINT_SIZE_EXT */ +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#endif + +#ifndef GL_EXT_draw_instanced +#endif + +#ifndef GL_EXT_packed_float +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif + +#ifndef GL_EXT_texture_array +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +#endif + +#ifndef GL_NV_fragment_program4 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef GL_NV_geometry_shader4 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +#endif + +#ifndef GL_EXT_draw_buffers2 +#endif + +#ifndef GL_NV_transform_feedback +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +#endif + +#ifndef GL_EXT_texture_integer +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +#endif + +#ifndef GL_GREMEDY_frame_terminator +#endif + +#ifndef GL_NV_conditional_render +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +#endif + +#ifndef GL_NV_present_video +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +#endif + +#ifndef GL_EXT_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +#endif + +#ifndef GL_ATI_meminfo +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +#endif + +#ifndef GL_AMD_texture_texture4 +#endif + +#ifndef GL_AMD_vertex_shader_tesselator +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +/* reuse GL_RED_SNORM */ +/* reuse GL_RG_SNORM */ +/* reuse GL_RGB_SNORM */ +/* reuse GL_RGBA_SNORM */ +/* reuse GL_R8_SNORM */ +/* reuse GL_RG8_SNORM */ +/* reuse GL_RGB8_SNORM */ +/* reuse GL_RGBA8_SNORM */ +/* reuse GL_R16_SNORM */ +/* reuse GL_RG16_SNORM */ +/* reuse GL_RGB16_SNORM */ +/* reuse GL_RGBA16_SNORM */ +/* reuse GL_SIGNED_NORMALIZED */ +#endif + +#ifndef GL_AMD_draw_buffers_blend +#endif + +#ifndef GL_APPLE_texture_range +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +/* reuse GL_STORAGE_CACHED_APPLE */ +/* reuse GL_STORAGE_SHARED_APPLE */ +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */ +/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */ +#endif + +#ifndef GL_NV_video_capture +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +#endif + +#ifndef GL_NV_copy_image +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +#endif + +#ifndef GL_NV_texture_barrier +#endif + +#ifndef GL_AMD_shader_stencil_export +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ +#endif + +#ifndef GL_AMD_conservative_depth +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +/* reuse GL_PATCHES */ +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +/* reuse GL_READ_WRITE */ +/* reuse GL_WRITE_ONLY */ +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +/* reuse GL_INT64_NV */ +/* reuse GL_UNSIGNED_INT64_NV */ +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_COVERAGE_SAMPLES_NV 0x80A9 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +#endif + +#ifndef GL_AMD_debug_output +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#endif + +#ifndef GL_AMD_depth_clamp_separate +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif + +#ifndef GL_NV_texture_multisample +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +#endif + +#ifndef GL_AMD_blend_minmax_factor +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif + +#ifndef GL_AMD_sample_positions +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#endif + +#ifndef GL_EXT_x11_sync_object +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +#endif + +#ifndef GL_AMD_multi_draw_indirect +#endif + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif + +#ifndef GL_NV_path_rendering +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_PATH_SAMPLE_QUALITY_NV 0x9085 +#define GL_PATH_STROKE_BOUND_NV 0x9086 +#define GL_PATH_STROKE_OVERSAMPLE_COUNT_NV 0x9087 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_MULTI_HULLS_NV 0x908C +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_PROJECTIVE_2D_NV 0x9093 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_PROJECTIVE_3D_NV 0x9095 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_PROJECTIVE_2D_NV 0x9097 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_TRANSPOSE_PROJECTIVE_3D_NV 0x9099 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_NV 0x00100000 +#define GL_FONT_ASCENDER_NV 0x00200000 +#define GL_FONT_DESCENDER_NV 0x00400000 +#define GL_FONT_HEIGHT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_NV 0x08000000 +#define GL_FONT_HAS_KERNING_NV 0x10000000 +#endif + +#ifndef GL_AMD_pinned_memory +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif + +#ifndef GL_AMD_stencil_operation_extended +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +#endif + +#ifndef GL_AMD_vertex_shader_viewport_index +#endif + +#ifndef GL_AMD_vertex_shader_layer +#endif + +#ifndef GL_NV_bindless_texture +#endif + +#ifndef GL_NV_shader_atomic_float +#endif + +#ifndef GL_AMD_query_buffer_object +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for program/shader text and shader object handles */ +typedef char GLcharARB; +typedef unsigned int GLhandleARB; +#endif + +/* GL type for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif + +#ifndef GL_EXT_timer_query +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#endif + +#ifndef GL_ARB_sync +typedef int64_t GLint64; +typedef uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + +#ifndef GL_ARB_cl_event +/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ +struct _cl_context; +struct _cl_event; +#endif + +#ifndef GL_ARB_debug_output +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_AMD_debug_output +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_KHR_debug +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_NV_vdpau_interop +typedef GLintptr GLvdpauSurfaceNV; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_VERSION_1_2_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_VERSION_1_3_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_VERSION_1_4_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +/* OpenGL 3.0 also reuses entry points from these extensions: */ +/* ARB_framebuffer_object */ +/* ARB_map_buffer_range */ +/* ARB_vertex_array_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +#endif + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +/* OpenGL 3.1 also reuses entry points from these extensions: */ +/* ARB_copy_buffer */ +/* ARB_uniform_buffer_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +#endif + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +/* OpenGL 3.2 also reuses entry points from these extensions: */ +/* ARB_draw_elements_base_vertex */ +/* ARB_provoking_vertex */ +/* ARB_sync */ +/* ARB_texture_multisample */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +/* OpenGL 3.3 also reuses entry points from these extensions: */ +/* ARB_blend_func_extended */ +/* ARB_sampler_objects */ +/* ARB_explicit_attrib_location, but it has none */ +/* ARB_occlusion_query2 (no entry points) */ +/* ARB_shader_bit_encoding (no entry points) */ +/* ARB_texture_rgb10_a2ui (no entry points) */ +/* ARB_texture_swizzle (no entry points) */ +/* ARB_timer_query */ +/* ARB_vertex_type_2_10_10_10_rev */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +/* OpenGL 4.0 also reuses entry points from these extensions: */ +/* ARB_texture_query_lod (no entry points) */ +/* ARB_draw_indirect */ +/* ARB_gpu_shader5 (no entry points) */ +/* ARB_gpu_shader_fp64 */ +/* ARB_shader_subroutine */ +/* ARB_tessellation_shader */ +/* ARB_texture_buffer_object_rgb32 (no entry points) */ +/* ARB_texture_cube_map_array (no entry points) */ +/* ARB_texture_gather (no entry points) */ +/* ARB_transform_feedback2 */ +/* ARB_transform_feedback3 */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +/* OpenGL 4.1 reuses entry points from these extensions: */ +/* ARB_ES2_compatibility */ +/* ARB_get_program_binary */ +/* ARB_separate_shader_objects */ +/* ARB_shader_precision (no entry points) */ +/* ARB_vertex_attrib_64bit */ +/* ARB_viewport_array */ +#endif + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +/* OpenGL 4.2 reuses entry points from these extensions: */ +/* ARB_base_instance */ +/* ARB_shading_language_420pack (no entry points) */ +/* ARB_transform_feedback_instanced */ +/* ARB_compressed_texture_pixel_storage (no entry points) */ +/* ARB_conservative_depth (no entry points) */ +/* ARB_internalformat_query */ +/* ARB_map_buffer_alignment (no entry points) */ +/* ARB_shader_atomic_counters */ +/* ARB_shader_image_load_store */ +/* ARB_shading_language_packing (no entry points) */ +/* ARB_texture_storage */ +#endif + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +/* OpenGL 4.3 reuses entry points from these extensions: */ +/* ARB_arrays_of_arrays (no entry points, GLSL only) */ +/* ARB_fragment_layer_viewport (no entry points, GLSL only) */ +/* ARB_shader_image_size (no entry points, GLSL only) */ +/* ARB_ES3_compatibility (no entry points) */ +/* ARB_clear_buffer_object */ +/* ARB_compute_shader */ +/* ARB_copy_image */ +/* KHR_debug (includes ARB_debug_output commands promoted to KHR without suffixes) */ +/* ARB_explicit_uniform_location (no entry points) */ +/* ARB_framebuffer_no_attachments */ +/* ARB_internalformat_query2 */ +/* ARB_invalidate_subdata */ +/* ARB_multi_draw_indirect */ +/* ARB_program_interface_query */ +/* ARB_robust_buffer_access_behavior (no entry points) */ +/* ARB_shader_storage_buffer_object */ +/* ARB_stencil_texturing (no entry points) */ +/* ARB_texture_buffer_range */ +/* ARB_texture_query_levels (no entry points) */ +/* ARB_texture_storage_multisample */ +/* ARB_texture_view */ +/* ARB_vertex_attrib_binding */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); +#endif + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#endif + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#endif + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +#endif + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* const *strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* const *strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +#endif + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#endif + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#endif + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +#endif + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +#endif + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +#endif + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +#endif + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#endif + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#endif + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#endif + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#endif + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#endif + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#endif + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +#endif + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#endif + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#endif + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#endif + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif + +#ifndef GL_AMD_vertex_shader_tesselator +#define GL_AMD_vertex_shader_tesselator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#endif + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#endif + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#endif + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#endif + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#endif + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#endif + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#endif + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#endif + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +#endif + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#endif + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#endif + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#endif + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#endif + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/code/cgame_hook/renderer/qfx_glprogs.h b/code/cgame_hook/renderer/qfx_glprogs.h new file mode 100644 index 00000000..202ab375 --- /dev/null +++ b/code/cgame_hook/renderer/qfx_glprogs.h @@ -0,0 +1,1078 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#ifndef QFX_GLPROGS_H +#define QFX_GLPROGS_H + +static const char g_szVertexShader_DOFDepth[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_DOFDepth[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform vec4 Local0;\n" +"uniform sampler2DRect Texture0;\n" +"float read_depth( vec2 coord )\n" +"{\n" +"return Local0.x / (Local0.y + Local0.x - texture2DRect( Texture0, coord ).r * Local0.y);\n" +"}\n" +"void main(void)\n" +"{\n" +"gl_FragColor.rgb = read_depth( gl_TexCoord[0].xy );\n" +"gl_FragColor.a = 1.0;\n" +"}\n"; + +static const char g_szVertexShader_DOFBlur[] = +"uniform vec4 Local0;\n" +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0 + Local0;\n" +"gl_TexCoord[1] = gl_MultiTexCoord0 + Local0 * 2.0;\n" +"gl_TexCoord[2] = gl_MultiTexCoord0 - Local0;\n" +"gl_TexCoord[3] = gl_MultiTexCoord0 - Local0 * 2.0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_DOFBlur[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform sampler2DRect Texture0;\n" +"void main(void)\n" +"{\n" +"vec3 col1 = texture2DRect(Texture0, gl_TexCoord[0].xy).rgb;\n" +"vec3 col2 = texture2DRect(Texture0, gl_TexCoord[1].xy).rgb;\n" +"vec3 col3 = texture2DRect(Texture0, gl_TexCoord[2].xy).rgb;\n" +"vec3 col4 = texture2DRect(Texture0, gl_TexCoord[3].xy).rgb;\n" +"gl_FragColor.rgb = (col1 + col2 + col3 + col4) / 4.0;\n" +"gl_FragColor.a = 1.0;\n" +"}\n"; + +static const char g_szVertexShader_DOFRender[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0.xyxy * vec4( 1.0, 1.0, 0.5, 0.5 );\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_DOFRender[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform vec4 Local0;\n" +"uniform sampler2DRect Texture0;\n" +"uniform sampler2DRect Texture1;\n" +"uniform sampler2DRect Texture2;\n" +"void main(void)\n" +"{\n" +"float ratio;\n" +"vec3 colNormal = texture2DRect(Texture0, gl_TexCoord[0].xy).rgb;\n" +"vec3 colBlur = texture2DRect(Texture1, gl_TexCoord[0].zw).rgb;\n" +"float depth = texture2DRect(Texture2, gl_TexCoord[0].zw).r;\n" +"if ( depth < Local0.x || depth == 1.0 ) ratio = 0.0;\n" +"else ratio = clamp( abs(depth - Local0.y) * Local0.z, 0.0, 1.0 );\n" +"gl_FragColor.rgb = mix( colNormal, colBlur, ratio * pow( depth, 0.25 ) );\n" +"gl_FragColor.a = 1.0;\n" +"}\n"; + +static const char g_szVertexShader_Emboss[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_Emboss[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform sampler2DRect Texture0;\n" +"uniform vec4 Local0;\n" +"void main(void)\n" +"{\n" +"vec3 col1 = texture2DRect(Texture0, gl_TexCoord[0].xy - vec2( 1.0, 1.0 )).rgb;\n" +"vec3 col2 = texture2DRect(Texture0, gl_TexCoord[0].xy).rgb;\n" +"vec3 col3 = texture2DRect(Texture0, gl_TexCoord[0].xy + vec2( 1.0, 1.0 )).rgb;\n" +"vec3 colEmboss = col1 * 2.0 - col2 - col3;\n" +"float colDot = max( 0.0, dot( colEmboss, vec3( 0.333, 0.333, 0.333 ) ) ) * Local0.x;\n" +"vec3 colFinal = col2 - vec3( colDot ) ;\n" +"float luminance = dot( col2, vec3( 0.6, 0.2, 0.2 ) );\n" +"gl_FragColor.rgb = mix( colFinal, col2, luminance * luminance );\n" +"gl_FragColor.a = 1.0;\n" +"}\n"; + +static const char g_szVertexShader_HSL[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +// This nice HSL color correction shader code was taken from: +// http://mouaif.wordpress.com/2009/01/05/photoshop-math-with-glsl-shaders/ +// It produces the same result as Photoshop + +// http://gamedev.stackexchange.com/questions/59797/glsl-shader-change-hue-saturation-brightness +static const char g_szFragmentShader_HSL[] = +"#version 130\n" +"#extension GL_ARB_texture_rectangle : enable\n" +"precision mediump float;\n" +"varying vec2 vTextureCoord;\n" +"uniform vec4 Local0;\n" +"uniform vec4 Local1;\n" +"uniform vec4 Local2;\n" +"uniform vec4 Local3;\n" +"uniform sampler2DRect Texture0;\n" +"vec3 rgb2hsv( vec3 c )\n" +"{\n" +" vec4 K = vec4( 0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0 );\n" +" vec4 p = mix( vec4( c.bg, K.wz ), vec4( c.gb, K.xy ), step( c.b, c.g ) );\n" +" vec4 q = mix( vec4( p.xyw, c.r ), vec4( c.r, p.yzx ), step( p.x, c.r ) );\n" +" float d = q.x - min( q.w, q.y );\n" +" float e = 1.0e-10;\n" +" return vec3( abs( q.z + ( q.w - q.y ) / ( 6.0 * d + e ) ), d / ( q.x + e ), q.x );\n" +"}\n" +"vec3 hsv2rgb( vec3 c )\n" +"{\n" +" vec4 K = vec4( 1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0 );\n" +" vec3 p = abs( fract( c.xxx + K.xyz ) * 6.0 - K.www );\n" +" return c.z * mix( K.xxx, clamp( p - K.xxx, 0.0, 1.0 ), c.y );\n" +"}\n" +"vec4 processHSV( vec4 textureColor, vec4 hsv )\n" +"{\n" +"vec3 fragRGB = textureColor.rgb;\n" +"vec3 fragHSV = rgb2hsv( fragRGB );\n" +"hsv.z = 0.9999;\n" +"float h = hsv.x / 360.0;\n" +"fragHSV.x *= h;\n" +"fragHSV.yz *= hsv.yz;\n" +"fragHSV.x = mod( fragHSV.x, 1.0 );\n" +"fragHSV.y = mod( fragHSV.y, 1.0 );\n" +"fragHSV.z = mod( fragHSV.z, 1.0 );\n" +"fragRGB = hsv2rgb( fragHSV );\n" +"return vec4( hsv2rgb( fragHSV ), textureColor.w );\n" +"}\n" +"void main() {\n" +"vec4 col = texture2DRect( Texture0, gl_TexCoord[0].xy );\n" +"vec4 rgb_dark = processHSV( col, Local0 );\n" +"vec4 rgb_mid = processHSV( col, Local1 );\n" +"vec4 rgb_light = processHSV( col, Local2 );\n" +"if( col.r >= Local3.x && col.r <= Local3.y ) { gl_FragColor.r = rgb_mid.r; } else if( col.r < Local3.x ) { gl_FragColor.r = rgb_dark.r; } else if( col.r > Local3.y ) { gl_FragColor.r = rgb_light.r; }\n" +"if( col.g >= Local3.x && col.g <= Local3.y ) { gl_FragColor.g = rgb_mid.g; } else if( col.g < Local3.x ) { gl_FragColor.g = rgb_dark.g; } else if( col.g > Local3.y ) { gl_FragColor.g = rgb_light.g; }\n" +"if( col.b >= Local3.x && col.b <= Local3.y ) { gl_FragColor.b = rgb_mid.b; } else if( col.b < Local3.x ) { gl_FragColor.b = rgb_dark.b; } else if( col.b > Local3.y ) { gl_FragColor.b = rgb_light.b; }\n" +"}\n"; +/*"uniform sampler2DRect Texture0;\n" +"uniform vec4 Local0;\n" +"uniform vec4 Local1;\n" +"uniform vec4 Local2;\n" +"uniform vec4 Local3;\n" +"vec3 rgb_to_hsl( const vec3 color )\n" +"{\n" +"vec3 hsl;\n" +"float fmin = min(min(color.r, color.g), color.b);\n" +"float fmax = max(max(color.r, color.g), color.b);\n" +"float delta = fmax - fmin;\n" +"hsl.z = (fmax + fmin) / 2.0;\n" +"if (delta == 0.0) {\n" +"hsl.x = 0.0;\n" +"hsl.y = 0.0;\n" +"} else {\n" +"if (hsl.z < 0.5) hsl.y = delta / (fmax + fmin);\n" +"else hsl.y = delta / (2.0 - fmax - fmin);\n" +"float deltaR = (((fmax - color.r) / 6.0) + (delta / 2.0)) / delta;\n" +"float deltaG = (((fmax - color.g) / 6.0) + (delta / 2.0)) / delta;\n" +"float deltaB = (((fmax - color.b) / 6.0) + (delta / 2.0)) / delta;\n" +"if (color.r == fmax ) hsl.x = deltaB - deltaG;\n" +"else if (color.g == fmax) hsl.x = (1.0 / 3.0) + deltaR - deltaB;\n" +"else if (color.b == fmax) hsl.x = (2.0 / 3.0) + deltaG - deltaR;\n" +"if (hsl.x < 0.0) hsl.x += 1.0;\n" +"else if (hsl.x > 1.0) hsl.x -= 1.0;\n" +"}\n" +"return hsl;\n" +"}\n" +"float hue_to_rgb( float f1, float f2, float hue )\n" +"{\n" +"if (hue < 0.0) hue += 1.0;\n" +"else if (hue > 1.0) hue -= 1.0;\n" +"float res;\n" +"if ((6.0 * hue) < 1.0) res = f1 + (f2 - f1) * 6.0 * hue;\n" +"else if ((2.0 * hue) < 1.0) res = f2;\n" +"else if ((3.0 * hue) < 2.0) res = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0;\n" +"else res = f1;\n" +"return res;\n" +"}\n" +"vec3 hsl_to_rgb( vec3 hsl )\n" +"{\n" +"vec3 rgb;\n" +"if (hsl.y == 0.0) rgb = vec3(hsl.z);\n" +"else {\n" +"float f2;\n" +"if (hsl.z < 0.5) f2 = hsl.z * (1.0 + hsl.y);\n" +"else f2 = (hsl.z + hsl.y) - (hsl.y * hsl.z);\n" +"float f1 = 2.0 * hsl.z - f2;\n" +"rgb.r = hue_to_rgb(f1, f2, hsl.x + (1.0/3.0));\n" +"rgb.g = hue_to_rgb(f1, f2, hsl.x);\n" +"rgb.b = hue_to_rgb(f1, f2, hsl.x - (1.0/3.0));\n" +"}\n" +"return rgb;\n" +"}\n" +"void main(void)\n" +"{\n" +"vec3 col = texture2DRect(Texture0, gl_TexCoord[0].xy).rgb;\n" +"vec3 hsl = rgb_to_hsl( col );\n" +"vec3 rgb_dark = hsl_to_rgb( hsl + Local0.xyz );\n" +"vec3 rgb_mid = hsl_to_rgb( hsl + Local1.xyz );\n" +"vec3 rgb_light = hsl_to_rgb( hsl + Local2.xyz );\n" +"if( col.r > Local3.y ) gl_FragColor.r = rgb_light.r;\n" // light +"if( col.g > Local3.y ) gl_FragColor.g = rgb_light.g;\n" +"if( col.b > Local3.y ) gl_FragColor.b = rgb_light.b;\n" +"if( col.r >= Local3.x && col.r <= Local3.y ) gl_FragColor.r = rgb_mid.r;\n" // mid +"if( col.g >= Local3.x && col.g <= Local3.y ) gl_FragColor.g = rgb_mid.g;\n" +"if( col.b >= Local3.x && col.b <= Local3.y ) gl_FragColor.b = rgb_mid.b;\n" +"if( col.r < Local3.x ) gl_FragColor.r = rgb_dark.r;\n" // dark +"if( col.g < Local3.x ) gl_FragColor.g = rgb_dark.g;\n" +"if( col.b < Local3.x ) gl_FragColor.b = rgb_dark.b;\n" +"gl_FragColor.a = 1.0;\n" +"}\n";*/ + +static const char g_szVertexShader_SSAORender[] = +"uniform vec4 Local0;\n" +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0.xyxy * vec4( 1.0, 1.0, 1.0 / Local0.z, 1.0 / Local0.w );\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_SSAORender[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform vec4 Local0;\n" +"uniform vec4 Local1;\n" +"uniform sampler2DRect Texture0;\n" +"float read_depth( vec2 coord )\n" +"{\n" +"return Local0.x / (Local0.y + Local0.x - texture2DRect( Texture0, coord ).r * Local0.y);\n" +"}\n" +"vec2 rand( vec2 coord )\n" +"{\n" +"float coordDot = dot( coord, vec2( 12.9898, 78.233 ) );\n" +"float noiseX = fract( sin( coordDot ) * 43758.5453 );\n" +"float noiseY = fract( sin( coordDot * 2.0 ) * 43758.5453 );\n" +"return vec2( noiseX, noiseY ) * 0.004;\n" +"}\n" +"float compare_depth( float depth1, float depth2 )\n" +"{\n" +"float aoRange = 60.0;\n" +"float depthDiff = depth1 - depth2;\n" +"float propagation = depthDiff * (Local0.y - Local0.x);\n" +"float rangeDiff = sqrt(clamp( 1.0 - propagation / aoRange, 0.0, 1.0 ));\n" +"float ao = Local1.z * depthDiff * (2.0 - depthDiff) * rangeDiff;\n" +"return ao;\n" +"}\n" +"void main(void)\n" +"{\n" +"float depth = read_depth( gl_TexCoord[0].xy );\n" +"float ao;\n" +"if ( depth > Local1.x && depth < Local1.y ) {\n" +"vec2 noise = rand( gl_TexCoord[0].zw );\n" +"float distScale = 1.0 + 5.0 * sqrt( 1.0 - depth );\n" +"float w = distScale + (noise.x*(1.0-noise.x)) * Local0.z;\n" +"float h = distScale + (noise.y*(1.0-noise.y)) * Local0.w;\n" +"vec2 ofs;\n" +"float d;\n" +"int samples = 3;\n" +"int rings = 3;\n" +"float TWO_PI = 2.0 * 3.14159265;\n" +"for ( int i = 1 ; i <= rings; i++ ) {\n" +"float angleStep = TWO_PI / float( samples * i );\n" +"for ( int j = 1 ; j <= samples*i; j++ ) {\n" +"ofs.x = cos( float(j) * angleStep ) * float(i) * w;\n" +"ofs.y = sin( float(j) * angleStep ) * float(i) * h;\n" +"d = read_depth( gl_TexCoord[0].xy + ofs );\n" +"// ignore occluder with too low depth value (possible viewmodel)\n" +"if ( d < Local1.x ) continue;\n" +"ao += compare_depth( depth, d );\n" +"}\n" +"}\n" +"ao = 1.0 - ao;\n" +"} else {\n" +"ao = 1.0;\n" +"}\n" +"gl_FragColor.rgb = vec3( ao );\n" +"gl_FragColor.a = 1.0;\n" +"}\n"; + +static const char g_szVertexShader_SSAOBlur[] = +"uniform vec4 Local0;\n" +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0 + Local0;\n" +"gl_TexCoord[1] = gl_MultiTexCoord0 + Local0 * 2.0;\n" +"gl_TexCoord[2] = gl_MultiTexCoord0 - Local0;\n" +"gl_TexCoord[3] = gl_MultiTexCoord0 - Local0 * 2.0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_SSAOBlur[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform sampler2DRect Texture0;\n" +"void main(void)\n" +"{\n" +"vec3 col1 = texture2DRect(Texture0, gl_TexCoord[0].xy).rgb;\n" +"vec3 col2 = texture2DRect(Texture0, gl_TexCoord[1].xy).rgb;\n" +"vec3 col3 = texture2DRect(Texture0, gl_TexCoord[2].xy).rgb;\n" +"vec3 col4 = texture2DRect(Texture0, gl_TexCoord[3].xy).rgb;\n" +"gl_FragColor.rgb = (col1 + col2 + col3 + col4) / 4.0;\n" +"gl_FragColor.a = 1.0;\n" +"}\n"; + +static const char g_szVertexShader_SSAOCombine[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_TexCoord[1] = gl_MultiTexCoord0 * 0.5;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_SSAOCombine[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform sampler2DRect Texture0;\n" +"uniform sampler2DRect Texture1;\n" +"void main(void)\n" +"{\n" +"vec3 col1 = texture2DRect(Texture0, gl_TexCoord[0].xy).rgb;\n" +"vec3 col2 = texture2DRect(Texture1, gl_TexCoord[1].xy).rgb;\n" +"float luminance = dot( col1, vec3( 0.6, 0.2, 0.2 ) );\n" +"gl_FragColor.rgb = mix( col1 * col2, col1, luminance * luminance );\n" +"gl_FragColor.a = 1.0;\n" +"}\n"; + +/*static const char g_szVertexShader_BloomDarken[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_BloomDarken[] = +"#ifdef GL_ES\n" +"precision highp float;\n" +"#endif\n" +"struct LightSource\n" +"{\n" +"int Type;\n" +"vec3 Position;\n" +"vec3 Attenuation;\n" +"vec3 Direction;\n" +"vec3 Colour;\n" +"float OuterCutoff;\n" +"float InnerCutoff;\n" +"float Exponent;\n" +"};\n" +"struct MaterialSource\n" +"{\n" +"vec3 Ambient;\n" +"vec4 Diffuse;\n" +"vec3 Specular;\n" +"float Shininess;\n" +"vec2 TextureOffset;\n" +"vec2 TextureScale;\n" +"};\n" +"uniform int NumLight;\n" +"uniform LightSource Light[4];\n" +"uniform MaterialSource Material;\n" +"varying vec4 vWorldVertex;\n" +"varying vec3 vWorldNormal;\n" +"varying vec2 vUv;\n" +"varying vec3 vViewVec;\n" +"void main ()\n" +"{\n" +"vec3 normal = normalize(vWorldNormal);\n" +"vec3 colour = Material.Ambient;\n" +"for (int i = 0; i < 4; ++i)\n" +"{\n" +"if ( i >= NumLight )\n" +"break;\n" +"vec3 lightVec = normalize(Light[i].Position - vWorldVertex.xyz);\n" +"float l = dot(normal, lightVec);\n" +"if ( l > 0.0 )\n" +"{\n" +"float spotlight = 1.0;\n" +"if ( Light[i].Type == 1 )\n" +"{\n" +"spotlight = max(-dot(lightVec, Light[i].Direction), 0.0);\n" +"float spotlightFade = clamp((Light[i].OuterCutoff - spotlight) / (Light[i].OuterCutoff - Light[i].InnerCutoff), 0.0, 1.0);\n" +"spotlight = pow(spotlight * spotlightFade, Light[i].Exponent);\n" +"}\n" +"vec3 r = -normalize(reflect(lightVec, normal));\n" +"float s = pow(max(dot(r, vViewVec), 0.0), Material.Shininess);\n" +"float d = distance(vWorldVertex.xyz, Light[i].Position);\n" +"float a = 1.0 / (Light[i].Attenuation.x + (Light[i].Attenuation.y * d) + (Light[i].Attenuation.z * d * d));\n" +"colour += ((Material.Diffuse.xyz * l) + (Material.Specular * s)) * Light[i].Colour * a * spotlight;\n" +"}\n" +"}\n" +"gl_FragColor = clamp(vec4(colour, Material.Diffuse.w), 0.0, 1.0);" +"}\n"; + +static const char g_szVertexShader_BloomBlur[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_BloomBlur[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"#ifdef GL_ES\n" +"precision highp float;\n" +"#endif\n" +"uniform vec4 Local0;\n" +"uniform vec2 TexelSize;\n" +"uniform sampler2DRect Sample0;\n" +"float Gaussian (float x, float deviation)\n" +"{\n" +"return (1.0 / sqrt(2.0 * 3.141592 * deviation)) * exp(-((x * x) / (2.0 * deviation)));\n" +"}\n" +"void main(void)\n" +"{\n" +"float halfBlur = float(Local0.y) * 0.5;\n" +"vec4 colour = vec4(0.0);\n" +"vec4 texColour = vec4(0.0);\n" +"float deviation = halfBlur * 0.35;\n" +"deviation *= deviation;\n" +"float strength = 1.0 - Local0[3];\n" +"if ( Local0.x == 0 )\n" +"{\n" +"for (int i = 0; i < 10; ++i)\n" +"{\n" +"if ( i >= Local0.y )\n" +"break;\n" +"float offset = float(i) - halfBlur;\n" +"texColour = texture2DRect(Sample0, gl_TexCoord[0].xy + vec2(offset * TexelSize.x * Local0.z, 0.0)) * Gaussian(offset * strength, deviation);\n" +"colour += texColour;\n" +"}\n" +"}\n" +"else\n" +"{\n" +"for (int i = 0; i < 10; ++i)\n" +"{\n" +"if ( i >= Local0.y )\n" +"break;\n" +"float offset = float(i) - halfBlur;\n" +"texColour = texture2DRect(Sample0, gl_TexCoord[0].xy + vec2(0.0, offset * TexelSize.y * Local0.z)) * Gaussian(offset * strength, deviation);\n" +"colour += texColour;\n" +"}\n" +"}\n" +"gl_FragColor = clamp(colour, 0.0, 1.0);\n" +"gl_FragColor.w = 1.0;\n" +"}\n"; + +static const char g_szVertexShader_BloomCombine[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_BloomCombine[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"#ifdef GL_ES\n" +"precision highp float;\n" +"#endif\n" +"uniform vec4 Local0;\n" +"uniform sampler2DRect Sample0;\n" +"uniform sampler2DRect Sample1;\n" +"void main ()\n" +"{\n" +"vec4 dst = texture2DRect(Sample0, gl_TexCoord[0].xy);\n" +"vec4 src = texture2DRect(Sample1, gl_TexCoord[0].xy);\n" +"if ( Local0.x == 0 )\n" +"{\n" +"gl_FragColor = min(src + dst, 1.0);\n" +"}\n" +"else if ( Local0.x == 1 )\n" +"{\n" +"gl_FragColor = clamp((src + dst) - (src * dst), 0.0, 1.0);\n" +"gl_FragColor.w = 1.0;\n" +"}\n" +"else\n" +"{\n" +"gl_FragColor = src;\n" +"}\n" +"}\n";*/ + +static const char g_szVertexShader_BloomDarken[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_BloomDarken[] = +"#version 130\n" +"#extension GL_ARB_texture_rectangle : enable\n" +"precision lowp float;\n" +"uniform vec4 Local0;\n" +"uniform sampler2DRect Texture0;\n" +"void main(void)\n" +"{\n" +"vec3 col = texture2DRect(Texture0, gl_TexCoord[0].xy).rgb;\n" +"gl_FragColor.rgb = pow( col, Local0.xxx );\n" +"gl_FragColor.a = 1.0;\n" +"}\n"; + +#if 0 +static const char g_szVertexShader_BloomBlur[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = ftransform();\n" +"}\n"; + +static const char g_szFragmentShader_BloomBlur[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform vec4 Local0;\n" +"uniform sampler2DRect source;\n" +"void main(void) {\n" +"vec2 tc = gl_TexCoord[0].st;\n" +"gl_FragColor = 0.0285367 * texture2DRect(source, tc);\n" +"for( int i = 0; i < 16; i += 2 ) {\n" +"gl_FragColor += ( 0.0567264 / (i/16+1) ) *\n" +"(texture2DRect(source, tc - (Local0.xy * ( 1.49817 + i ) )) +\n" +"texture2DRect(source, tc + (Local0.xy * ( 1.49817 + i ) )));\n" +"}\n" +/*"gl_FragColor += 0.0553599 *\n" +"(texture2DRect(source, tc - (Local0.xy * 3.49573)) +\n" +"texture2DRect(source, tc + (Local0.xy * 3.49573)));\n" +"gl_FragColor += 0.0529827 *\n" +"(texture2DRect(source, tc - (Local0.xy * 5.49329)) +\n" +"texture2DRect(source, tc + (Local0.xy * 5.49329)));\n" +"gl_FragColor += 0.0497279 *\n" +"(texture2DRect(source, tc - (Local0.xy * 7.49085)) +\n" +"texture2DRect(source, tc + (Local0.xy * 7.49085)));\n" +"gl_FragColor += 0.0457714 *\n" +"(texture2DRect(source, tc - (Local0.xy * 9.48841)) +\n" +"texture2DRect(source, tc + (Local0.xy * 9.48841)));\n" +"gl_FragColor += 0.0413158 *\n" +"(texture2DRect(source, tc - (Local0.xy * 11.486)) +\n" +"texture2DRect(source, tc + (Local0.xy * 11.486)));\n" +"gl_FragColor += 0.0365735 *\n" +"(texture2DRect(source, tc - (Local0.xy * 13.4835)) +\n" +"texture2DRect(source, tc + (Local0.xy * 13.4835)));\n" +"gl_FragColor += 0.0317501 *\n" +"(texture2DRect(source, tc - (Local0.xy * 15.4811)) +\n" +"texture2DRect(source, tc + (Local0.xy * 15.4811)));\n" +"gl_FragColor += 0.0270303 *\n" +"(texture2DRect(source, tc - (Local0.xy * 17.4787)) +\n" +"texture2DRect(source, tc + (Local0.xy * 17.4787)));\n" +"gl_FragColor += 0.0225676 *\n" +"(texture2DRect(source, tc - (Local0.xy * 19.4762)) +\n" +"texture2DRect(source, tc + (Local0.xy * 19.4762)));\n" +"gl_FragColor += 0.0184777 *\n" +"(texture2DRect(source, tc - (Local0.xy * 21.4738)) +\n" +"texture2DRect(source, tc + (Local0.xy * 21.4738)));\n" +"gl_FragColor += 0.0148367 *\n" +"(texture2DRect(source, tc - (Local0.xy * 23.4713)) +\n" +"texture2DRect(source, tc + (Local0.xy * 23.4713)));\n" +"gl_FragColor += 0.0116831 *\n" +"(texture2DRect(source, tc - (Local0.xy * 25.4689)) +\n" +"texture2DRect(source, tc + (Local0.xy * 25.4689)));\n" +"gl_FragColor += 0.00902199 *\n" +"(texture2DRect(source, tc - (Local0.xy * 27.4665)) +\n" +"texture2DRect(source, tc + (Local0.xy * 27.4665)));\n" +"gl_FragColor += 0.00683246 *\n" +"(texture2DRect(source, tc - (Local0.xy * 29.4641)) +\n" +"texture2DRect(source, tc + (Local0.xy * 29.4641)));\n" +"gl_FragColor += 0.00507434 *\n" +"(texture2DRect(source, tc - (Local0.xy * 31.4616)) +\n" +"texture2DRect(source, tc + (Local0.xy * 31.4616)));\n"*/ +"}\n"; + +#endif + +static const char g_szVertexShader_BloomBlur[] = +"#version 130\n" +"#extension GL_ARB_texture_rectangle : enable\n" +"precision lowp float;\n" +"uniform vec4 Local0;\n" +"varying vec4 texCoord[16];\n" +"void main(void)\n" +"{\n" +"texCoord[0] = gl_MultiTexCoord0 + Local0;\n" +"texCoord[1] = gl_MultiTexCoord0 + Local0 * 1.50;\n" +"texCoord[2] = gl_MultiTexCoord0 + Local0 * 1.75;\n" +"texCoord[3] = gl_MultiTexCoord0 + Local0 * 2.00;\n" +"texCoord[4] = gl_MultiTexCoord0 - Local0;\n" +"texCoord[5] = gl_MultiTexCoord0 - Local0 * 1.50;\n" +"texCoord[6] = gl_MultiTexCoord0 - Local0 * 1.75;\n" +"texCoord[7] = gl_MultiTexCoord0 - Local0 * 2.00;\n" +"gl_Position = ftransform();\n" +"}\n"; + +static const char g_szFragmentShader_BloomBlur[] = +"#version 130\n" +"#extension GL_ARB_texture_rectangle : enable\n" +"precision lowp float;\n" +"uniform sampler2DRect Texture0;\n" +"varying vec4 texCoord[16];\n" +"void main(void)\n" +"{\n" +"vec3 col1 = texture2DRect(Texture0, texCoord[0].xy).rgb;\n" +"vec3 col2 = texture2DRect(Texture0, texCoord[1].xy).rgb;\n" +"vec3 col3 = texture2DRect(Texture0, texCoord[2].xy).rgb;\n" +"vec3 col4 = texture2DRect(Texture0, texCoord[3].xy).rgb;\n" +"vec3 col5 = texture2DRect(Texture0, texCoord[4].xy).rgb;\n" +"vec3 col6 = texture2DRect(Texture0, texCoord[5].xy).rgb;\n" +"vec3 col7 = texture2DRect(Texture0, texCoord[6].xy).rgb;\n" +"vec3 col8 = texture2DRect(Texture0, texCoord[7].xy).rgb;\n" +"gl_FragColor.rgb = (col1 + col2 + col3 + col4 + col5 + col6 + col7 + col8) / 8.0;\n" +"gl_FragColor.a = 1.0;\n" +"}\n"; + +/*static const char g_szVertexShader_BloomBlur[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform vec4 Local0;\n" +"uniform vec4 Local1;\n" +"varying vec2 texCoord[31];\n" +"void main(void)\n" +"{\n" +"int i;\n" +"int j = 0;\n" +"int numSamples = int( Local1.x );\n" +"int numSamples_mid = int( Local1.x / 2 );\n" +"float inc = 2.0 / Local1.x;\n" +"for( i = 0; i < numSamples_mid; i++ ) {\n" +"if( j == 1 ) { j++; }\n" +"texCoord[i] = ( gl_MultiTexCoord0 + Local0 * ( inc * float( j ) + 1.0 ) ).xy;\n" +"j++;\n" +"}\n" +"j = 0;\n" +"for( i = numSamples_mid; i < numSamples; i++ ) {\n" +"if( j == 1 ) { j++; }\n" +"texCoord[i] = ( gl_MultiTexCoord0 - Local0 * ( inc * float( j ) + 1.0 ) ).xy;\n" +"j++;\n" +"}\n" +"gl_Position = ftransform();\n" +"}\n"; + +static const char g_szFragmentShader_BloomBlur[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"precision lowp float;\n" +"uniform sampler2DRect Texture0;\n" +"uniform vec4 Local1;\n" +"varying vec4 texCoord[31];\n" +"void main(void)\n" +"{\n" +"int numSamples = int( Local1.x );\n" +"gl_FragColor = vec4( 0.0 );\n" +"for( int i = 0; i < numSamples; i++ ) {\n" +"gl_FragColor += texture2DRect( Texture0, texCoord[i] );\n" +"}\n" +"gl_FragColor.rgb /= Local1.x;\n" +"gl_FragColor.a = 1.0;\n" +"}\n";*/ + +static const char g_szVertexShader_BloomCombine[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_TexCoord[1] = gl_MultiTexCoord0 * 0.5;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_BloomCombine[] = +"#version 130\n" +"#extension GL_ARB_texture_rectangle : enable\n" +"precision lowp float;\n" +"uniform vec4 Local0;\n" +"uniform sampler2DRect Texture0;\n" +"uniform sampler2DRect Texture1;\n" +"void main(void)\n" +"{\n" +"vec3 col1 = texture2DRect(Texture0, gl_TexCoord[0].xy).rgb;\n" +"vec3 col2 = texture2DRect(Texture1, gl_TexCoord[1].xy).rgb;\n" +"gl_FragColor.rgb = col1 + ( col2 * Local0.xxx + col2 * Local0.yyy );\n" +"gl_FragColor.a = 1.0;\n" +"}\n"; + +static const char g_szVertexShader_BrightnessContrast[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_BrightnessContrast[] = +"#version 130\n" +"#extension GL_ARB_texture_rectangle : enable\n" +"precision lowp float;\n" +"uniform sampler2DRect Texture0;\n" +"uniform vec4 Local0;\n" +"uniform vec4 Local3;\n" +"void main(void)\n" +"{\n" +"vec4 col = texture2DRect( Texture0, gl_TexCoord[0].xy );\n" +"vec4 AverageLuminance;\n" +"AverageLuminance = vec4( 0.5, 0.5, 0.5, 1.0 );" +"float Contrast = Local0.a - 1;\n" +"if( Contrast < 0.0 ) Contrast = 0.0;\n" +"vec3 bright = Local0.xyz;\n" +"vec4 luminance = mix( col * vec4( Local0.x+1.0, Local0.y+1.0, Local0.z+1.0, 1.0 ), mix( AverageLuminance, col, Local0.a ), 0.5 );\n" +"if( col.r >= Local3.x && col.r <= Local3.y ) { gl_FragColor.r = luminance.r; } else if( col.r < Local3.x ) { gl_FragColor.r = luminance.r; } else if( col.r > Local3.y ) { gl_FragColor.r = luminance.r; }\n" +"if( col.g >= Local3.x && col.g <= Local3.y ) { gl_FragColor.g = luminance.g; } else if( col.g < Local3.x ) { gl_FragColor.g = luminance.g; } else if( col.g > Local3.y ) { gl_FragColor.g = luminance.g; }\n" +"if( col.b >= Local3.x && col.b <= Local3.y ) { gl_FragColor.b = luminance.b; } else if( col.b < Local3.x ) { gl_FragColor.b = luminance.b; } else if( col.b > Local3.y ) { gl_FragColor.b = luminance.b; }\n" +"gl_FragColor.rgb += bright;\n" +"}\n"; + +static const char g_szVertexShader_Tint[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = ftransform();\n" +"}\n"; + +static const char g_szFragmentShader_Tint[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform vec4 Local0;\n" +"uniform vec4 Local1;\n" +"uniform vec4 Local2;\n" +"uniform vec4 Local3;\n" +"uniform vec4 Local4;\n" +"uniform vec4 Local5;\n" +"uniform sampler2DRect Texture0;\n" +"void main(void)\n" +"{\n" +"vec4 col = texture2DRect(Texture0, gl_TexCoord[0].xy);\n" +"vec4 AverageLuminance;\n" +"AverageLuminance = vec4( 0.5, 0.5, 0.5, 1.0 );" +"float Contrast = Local4.a - 1.0;\n" +"if( Contrast < 0.0 ) Contrast = 0.0;\n" +"vec3 bright = Local4.xyz;\n" +"vec4 luminance = mix( col * vec4( Local4.x+1.0, Local4.y+1.0, Local4.z+1.0, 1.0 ), mix( AverageLuminance, col, Local4.a ), 0.5 );\n" +"if( col.r >= Local3.x && col.r <= Local3.y ) { gl_FragColor.r = luminance.r * Local1.r; } else if( col.r < Local3.x ) { gl_FragColor.r = luminance.r * Local2.r; } else if( col.r > Local3.y ) { gl_FragColor.r = luminance.r * Local0.r; }\n" +"if( col.g >= Local3.x && col.g <= Local3.y ) { gl_FragColor.g = luminance.g * Local1.g; } else if( col.g < Local3.x ) { gl_FragColor.g = luminance.g * Local2.g; } else if( col.g > Local3.y ) { gl_FragColor.g = luminance.g * Local0.g; }\n" +"if( col.b >= Local3.x && col.b <= Local3.y ) { gl_FragColor.b = luminance.b * Local1.b; } else if( col.b < Local3.x ) { gl_FragColor.b = luminance.b * Local2.b; } else if( col.b > Local3.y ) { gl_FragColor.b = luminance.b * Local0.b; }\n" +"gl_FragColor.rgb += bright;\n" +"gl_FragColor.rgb *= Local5.xxx;\n" +"}\n"; + +static const char g_szVertexShader_Bleach[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_Bleach[] = +"#version 130\n" +"#extension GL_ARB_texture_rectangle : enable\n" +"precision lowp float;\n" +"uniform vec4 Local0;\n" +"uniform vec4 Local3;\n" +"uniform sampler2DRect Texture0;\n" +"void main(void)\n" +"{\n" +"vec3 col = texture2DRect(Texture0, gl_TexCoord[0].xy).rgb;\n" +/*"if( Local1.x < col.r ) if( Local0.z > col.r ) { gl_FragColor.r = Local0.z - col.r; } else { gl_FragColor.r = col.r - Local0.z; }\n" +"if( Local1.x < col.g ) if( Local0.z > col.g ) { gl_FragColor.g = Local0.z - col.g; } else { gl_FragColor.g = col.g - Local0.z; }\n" +"if( Local1.x < col.b ) if( Local0.z > col.b ) { gl_FragColor.b = Local0.z - col.b; } else { gl_FragColor.b = col.b - Local0.z; }\n" +"if( Local1.x >= col.r && Local1.y <= col.r ) if( Local0.y > col.r ) { gl_FragColor.r = Local0.y - col.r; } else { gl_FragColor.r = col.r - Local0.y; }\n" +"if( Local1.x >= col.g && Local1.y <= col.g ) if( Local0.y > col.g ) { gl_FragColor.g = Local0.y - col.g; } else { gl_FragColor.g = col.g - Local0.y; }\n" +"if( Local1.x >= col.b && Local1.y <= col.b ) if( Local0.y > col.b ) { gl_FragColor.b = Local0.y - col.b; } else { gl_FragColor.b = col.b - Local0.y; }\n" +"if( Local1.y > col.r ) if( Local0.x > col.r ) { gl_FragColor.r = Local0.x - col.r; } else { gl_FragColor.r = col.r - Local0.x; }\n" +"if( Local1.y > col.g ) if( Local0.x > col.g ) { gl_FragColor.g = Local0.x - col.g; } else { gl_FragColor.g = col.g - Local0.x; }\n" +"if( Local1.y > col.b ) if( Local0.x > col.b ) { gl_FragColor.b = Local0.x - col.b; } else { gl_FragColor.b = col.b - Local0.x; }\n"*/ +"if( Local3.x < col.r ) { gl_FragColor.r = pow( col.r, 1.0 - Local0.z ); }\n" +"if( Local3.x < col.g ) { gl_FragColor.g = pow( col.g, 1.0 - Local0.z ); }\n" +"if( Local3.x < col.b ) { gl_FragColor.b = pow( col.b, 1.0 - Local0.z ); }\n" +"if( Local3.x >= col.r && Local3.y <= col.r ) { gl_FragColor.r = pow( col.r, 1.0 - Local0.y ); }\n" +"if( Local3.x >= col.g && Local3.y <= col.g ) { gl_FragColor.g = pow( col.g, 1.0 - Local0.y ); }\n" +"if( Local3.x >= col.b && Local3.y <= col.b ) { gl_FragColor.b = pow( col.b, 1.0 - Local0.y ); }\n" +"if( Local3.y > col.r ) { gl_FragColor.r = pow( col.r, 1.0 - Local0.x ); }\n" +"if( Local3.y > col.g ) { gl_FragColor.g = pow( col.g, 1.0 - Local0.x ); }\n" +"if( Local3.y > col.b ) { gl_FragColor.b = pow( col.b, 1.0 - Local0.x ); }\n" +"}\n"; + +/*static const char g_szVertexShader_Invert[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"}\n"; + +static const char g_szFragmentShader_Invert[] = +"precision lowp float;\n" +"uniform vec4 Local0;\n" +"uniform sampler2DRect Texture0;\n" +"void main(void)\n" +"{\n" +"vec3 col = texture2DRect(Texture0, gl_TexCoord[0].xy).rgb;\n" +"gl_FragColor.rgb = 1 * Local0.x - col;\n" +"if( gl_FragColor.r < 0 ) gl_FragColor.r = -gl_FragColor.r;\n" +"if( gl_FragColor.g < 0 ) gl_FragColor.g = -gl_FragColor.g;\n" +"if( gl_FragColor.b < 0 ) gl_FragColor.b = -gl_FragColor.b;\n" +"gl_FragColor.a = 1.0;\n" +"}\n";*/ + +static const char g_szVertexShader_MotionBlur[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = ftransform();\n" +"}\n"; + +// https://subversion.assembla.com/svn/efekt/trunk/Src/shaders/blur_fs.glsl + +static const char g_szFragmentShader_MotionBlur[] = +"#version 150\n" +"uniform sampler2DArray tex;\n" +"uniform sampler2DArrayShadow depthTex;\n" +"uniform mat4 g_ViewProjectionInverseMatrix;\n" +"uniform mat4 g_previousViewProjectionMatrix;\n" +"uniform int SAMPLES;\n" +"in vec2 inoutTexCoord;\n" +"out vec4 outColor;\n" +"void main(void) {\n" +"outColor = vec4( 0.0 );" +"int SAMPLES2 = 40;\n" +"float zOverW = texture( depthTex, vec4( inoutTexCoord, 0, 0));\n" +"vec4 H = vec4(2*inoutTexCoord.x - 1.0f, 2*inoutTexCoord.y - 1.0f, 2*zOverW-1.0f, 1);\n" +"vec4 D = g_ViewProjectionInverseMatrix * H;\n" +"vec4 worldPos = D / D.w;\n" +"vec4 currentPos = H;\n" +"vec4 previousPos = g_previousViewProjectionMatrix * worldPos;\n" +"previousPos /= previousPos.w;\n" +"vec2 velocity = (currentPos - previousPos).xy/(SAMPLES2);\n" +"vec4 color = vec4(0);\n" +"vec2 texCoord = inoutTexCoord;\n" +"for(int i = 0; i < SAMPLES2; ++i, texCoord += velocity) {\n" +"color += texture( tex, vec3( clamp(texCoord,0.0,1.0), 0 ) );\n" +"}\n" +"outColor = color;\n" +"outColor /= outColor.a;" +"}\n"; + +static const char g_szVertexShader_Shadow[] = +"#version 330 core\n" +"layout(location = 0) in vec3 vertexPosition_modelspace;\n" +"uniform mat4 depthMVP;\n" +"void main() {\n" +"gl_Position = depthMVP * vec4(vertexPosition_modelspace,1);\n" +"}\n"; + +static const char g_szFragmentShader_Shadow[] = +"#version 330 core\n" +"layout(location = 0) out float fragmentdepth;\n" +"void main() {\n" +"fragmentdepth = gl_FragCoord.z;\n" +"}\n"; + +static const char g_szVertexShader_LightReflection[] = +"void main(void)\n" +"{\n" +"gl_TexCoord[0] = gl_MultiTexCoord0;\n" +"gl_Position = ftransform();\n" +"}\n"; + +static const char g_szFragmentShader_LightReflection[] = +"#version 150\n" +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform mat4 model;\n" +"uniform vec3 cameraPosition;\n" +"uniform sampler2D materialTex;\n" +"uniform float materialShininess;\n" +"uniform vec3 materialSpecularColor;\n" +"uniform struct Light {\n" +"vec3 position;\n" +"vec3 intensities;\n" +"float attenuation;\n" +"float ambientCoefficient;\n" +"} light;\n" +"in vec2 fragTexCoord;\n" +"in vec3 fragNormal;\n" +"in vec3 fragVert;\n" +"out vec4 finalColor;\n" +"void main() {\n" +"vec3 normal = normalize(transpose(inverse(mat3(model))) * fragNormal);\n" +"vec3 surfacePos = vec3(model * vec4(fragVert, 1));\n" +"vec4 surfaceColor = texture(materialTex, fragTexCoord);\n" +"vec3 surfaceToLight = normalize(light.position - surfacePos);\n" +"vec3 surfaceToCamera = normalize(cameraPosition - surfacePos);\n" +"vec3 ambient = light.ambientCoefficient * surfaceColor.rgb * light.intensities;\n" +"float diffuseCoefficient = max(0.0, dot(normal, surfaceToLight));\n" +"vec3 diffuse = diffuseCoefficient * surfaceColor.rgb * light.intensities;\n" +"float specularCoefficient = 0.0;\n" +"if(diffuseCoefficient > 0.0)\n" +"specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normal))), materialShininess);\n" +"vec3 specular = specularCoefficient * materialSpecularColor * light.intensities;\n" +"float distanceToLight = length(light.position - surfacePos);\n" +"float attenuation = 1.0 / (1.0 + light.attenuation * pow(distanceToLight, 2));\n" +"vec3 linearColor = ambient + attenuation*(diffuse + specular);\n" +"vec3 gamma = vec3(1.0/2.2);\n" +"finalColor = vec4(pow(linearColor, gamma), surfaceColor.a);\n" +"}\n"; + +// see http://www.geeks3d.com/20140213/glsl-shader-library-fish-eye-and-dome-and-barrel-distortion-post-processing-filters/2/ for distortion shaders + +static const char g_szVertexShader_Distortion[] = +"varying vec4 uv;\n" +"void main()\n" +"{\n" +"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +"uv = gl_MultiTexCoord0;\n" +"}\n"; + +static const char g_szFragmentShader_Distortion[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"varying vec4 uv;\n" +"uniform sampler2DRect Texture0;\n" +"uniform vec4 Local0;\n" +"void main()\n" +"{\n" +"vec2 textureCoordinateToUse = uv.xy;\n" +"vec2 center = Local0.xy;\n" +"float radius = Local0.z;\n" +"float scale = Local0.w / 10000.0;\n" +"float dist = distance( center, uv.xy );\n" +"textureCoordinateToUse -= center;\n" +"float percent = radius + ( ( 0.5 - dist ) / 0.5 ) * scale;\n" +"textureCoordinateToUse = textureCoordinateToUse * percent;\n" +"textureCoordinateToUse += center;\n" +"gl_FragColor = texture2DRect( Texture0, textureCoordinateToUse );\n" +"}\n"; + +// http://www.geeks3d.com/20100909/shader-library-gaussian-blur-post-processing-filter-in-glsl/ + +static const char g_szVertexShader_Blur[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"void main(void)\n" +"{\n" +"gl_Position = ftransform();\n" +"gl_TexCoord[ 0 ] = gl_MultiTexCoord0;\n" +"}\n"; + +static const char g_szFragmentShader_Blur[] = +"#version 120\n" +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform sampler2DRect Texture0;\n" +"uniform vec4 Local0;\n" +"float offset[ 5 ] = float[]( 0.0, 1.0, 2.0, 3.0, 4.0 );\n" +"float weight[ 5 ] = float[]( 0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162 );\n" +"void main()\n" +"{\n" +"vec3 tc;\n" +"vec2 uv = gl_TexCoord[ 0 ].xy;\n" +"tc = texture2DRect( Texture0, uv ).rgb * weight[ 0 ];\n" +"if( Local0.y > 0.0 ) {\n" +"for( int i = 1; i < 5; i++ )\n" +"{\n" +"tc += texture2DRect( Texture0, uv + vec2( 0.0, offset[ i ] ) * Local0.y ).rgb * weight[ i ];\n" +"tc += texture2DRect( Texture0, uv - vec2( 0.0, offset[ i ] ) * Local0.y ).rgb * weight[ i ];\n" +"}\n" +"} else {\n" +"for( int i = 1; i < 5; i++ )\n" +"{\n" +"tc += texture2DRect( Texture0, uv + vec2( offset[ i ], 0.0 ) * Local0.x ).rgb * weight[ i ];\n" +"tc += texture2DRect( Texture0, uv - vec2( offset[ i ], 0.0 ) * Local0.x ).rgb * weight[ i ];\n" +"}\n" +"}\n" +"gl_FragColor = vec4( tc, 1.0 );\n" +"}\n"; + +static const char g_szVertexShader_FXAA[] = +"void main( void ) {\n" +"gl_Position = ftransform();\n" +"gl_TexCoord[ 0 ] = gl_MultiTexCoord0;\n" +"}\n"; + +static const char g_szFragmentShader_FXAA[] = +"#extension GL_ARB_texture_rectangle : enable\n" +"uniform vec4 Local0;\n" +"uniform sampler2DRect Texture0;\n" +"void main( void ) {\n" +"float FXAA_SPAN_MAX = 8.0;\n" +"float FXAA_REDUCE_MUL = 1.0 / 8.0;\n" +"float FXAA_REDUCE_MIN = 1.0 / 128.0;\n" +"vec3 rgbNW = texture2DRect( Texture0, gl_TexCoord[ 0 ].xy + ( vec2( -1.0, -1.0 ) / Local0.xy ) ).xyz;\n" +"vec3 rgbNE = texture2DRect( Texture0, gl_TexCoord[ 0 ].xy + ( vec2( 1.0, -1.0 ) / Local0.xy ) ).xyz;\n" +"vec3 rgbSW = texture2DRect( Texture0, gl_TexCoord[ 0 ].xy + ( vec2( -1.0, 1.0 ) / Local0.xy ) ).xyz;\n" +"vec3 rgbSE = texture2DRect( Texture0, gl_TexCoord[ 0 ].xy + ( vec2( 1.0, 1.0 ) / Local0.xy ) ).xyz;\n" +"vec3 rgbM = texture2DRect( Texture0, gl_TexCoord[ 0 ].xy ).xyz;\n" +"vec3 luma = vec3( 0.299, 0.587, 0.114 );\n" +"float lumaNW = dot( rgbNW, luma );\n" +"float lumaNE = dot( rgbNE, luma );\n" +"float lumaSW = dot( rgbSW, luma );\n" +"float lumaSE = dot( rgbSE, luma );\n" +"float lumaM = dot( rgbM, luma );\n" +"float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n" +"float lumaMax = max( lumaM, max( max( lumaNW, lumaNE ), max( lumaSW, lumaSE ) ) );\n" +"vec2 dir;\n" +"dir.x = -( ( lumaNW + lumaNE ) - ( lumaSW + lumaSE ) );\n" +"dir.y = ( ( lumaNW + lumaSW ) - ( lumaNE + lumaSE ) );\n" +"float dirReduce = max(\n" +"( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ),\n" +"FXAA_REDUCE_MIN );\n" +"float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n" +"dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX ),\n" +"max( vec2( -FXAA_SPAN_MAX, -FXAA_SPAN_MAX ),\n" +"dir * rcpDirMin ) ) / Local0.xy;\n" +"vec3 rgbA = ( 1.0 / 2.0 ) * (\n" +"texture2DRect( Texture0, gl_TexCoord[ 0 ].xy + dir * ( 1.0 / 3.0 - 0.5 ) ).xyz +\n" +"texture2DRect( Texture0, gl_TexCoord[ 0 ].xy + dir * ( 2.0 / 3.0 - 0.5 ) ).xyz );\n" +"vec3 rgbB = rgbA * ( 1.0 / 2.0 ) + ( 1.0 / 4.0 ) * (\n" +"texture2DRect( Texture0, gl_TexCoord[ 0 ].xy + dir * ( 0.0 / 3.0 - 0.5 ) ).xyz +\n" +"texture2DRect( Texture0, gl_TexCoord[ 0 ].xy + dir * ( 3.0 / 3.0 - 0.5 ) ).xyz );\n" +"float lumaB = dot( rgbB, luma );\n" +"if( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) ){\n" +"gl_FragColor.xyz = vec4( rgbA, 1 );\n" +"}\n" +"else{\n" +"gl_FragColor.xyz = vec4( rgbB, 1 );\n" +"}\n" +"}\n"; + +static const char g_szVertexShader_Displacement[] = +"void main( void ) {\n" +"gl_Position = ftransform();\n" +"gl_TexCoord[ 0 ] = gl_MultiTexCoord0;\n" +"}\n"; + +static const char g_szFragmentShader_Displacement[] = +"void main( void ) {\n" +"gl_FragColor = vec4( 0, 0, 0, 0 );\n" +"}\n"; + +static const char g_szVertexShader_ShadowMap[] = +"varying vec4 ShadowCoord;\n" +"void main() {\n" +"ShadowCoord = gl_TextureMatrix[ 7 ] * gl_Vertex;\n" +"gl_Position = ftransform();\n" +"gl_FrontColor = gl_Color;\n" +"}\n"; + +static const char g_szFragmentShader_ShadowMap[] = +"uniform sampler2D Texture7;\n" +"varying vec4 ShadowCoord;\n" +"void main() {\n" +"vec4 shadowCoordinateWdivide = ShadowCoord / ShadowCoord.w;\n" +"shadowCoordinateWdivide.z += 0.0005;\n" +"float distanceFromLight = texture2D( Texture7, shadowCoordinateWdivide ).z;\n" +"float shadow = 1.0;\n" +"if( ShadowCoord.w > 0.0 )\n" +"shadow = distanceFromLight < shadowCoordinateWdivide.z ? 0.5 : 1.0;\n" +"gl_FragColor = shadow * gl_Color;\n" +"}\n"; + +#endif //QFX_GLPROGS_H diff --git a/code/cgame_hook/renderer/qfx_hooks.cpp b/code/cgame_hook/renderer/qfx_hooks.cpp new file mode 100644 index 00000000..f65d9e74 --- /dev/null +++ b/code/cgame_hook/renderer/qfx_hooks.cpp @@ -0,0 +1,191 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#include "qfx_library.h" +#include "qfx_log.h" +#include "qfx_opengl.h" +#include "qfx_renderer.h" + +//========================================= +// QFX Library Hooks +//----------------------------------------- +// Call our renderer in proper places +//========================================= +static const char s_szCustomVendorName[] = QFX_LIBRARY_VENDOR; +static GLenum s_glMatrixMode = GL_MODELVIEW; + +#define IS_3D_PROJECTION_MATRIX(x) ( x[2*4+3] < 0 ) + +const GLubyte * WINAPI glGetString( GLenum name ) +{ + if ( name == GL_VENDOR ) + return reinterpret_cast(s_szCustomVendorName); + else + return gl::qglGetString( name ); +} + +void WINAPI glMatrixMode( GLenum mode ) +{ + s_glMatrixMode = mode; + gl::qglMatrixMode( mode ); +} + +void WINAPI glLoadMatrixd( const GLdouble *m ) +{ + gl::qglLoadMatrixd( m ); + if ( s_glMatrixMode == GL_PROJECTION ) { + if ( gl::ext.FBO ) { + GLuint fboBinding = 0; + gl::qglGetIntegerv( GL_FRAMEBUFFER_BINDING_EXT, (GLint*)&fboBinding ); + if ( fboBinding ) return; + } + if ( IS_3D_PROJECTION_MATRIX(m) ) { + QFXRenderer::Instance().SetupZDimensions( m ); + QFXRenderer::Instance().SetOrtho( GL_FALSE ); + } else { + QFXRenderer::Instance().SetOrtho( GL_TRUE ); + } + } +} + +void WINAPI glLoadMatrixf( const GLfloat *m ) +{ + gl::qglLoadMatrixf( m ); + if ( s_glMatrixMode == GL_PROJECTION ) { + if ( gl::ext.FBO ) { + GLuint fboBinding = 0; + gl::qglGetIntegerv( GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&fboBinding ); + if ( fboBinding ) return; + } + if ( IS_3D_PROJECTION_MATRIX(m) ) { + QFXRenderer::Instance().SetupZDimensions( m ); + QFXRenderer::Instance().SetOrtho( GL_FALSE ); + } else { + QFXRenderer::Instance().SetOrtho( GL_TRUE ); + } + } +} + +void WINAPI glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar ) +{ + gl::qglFrustum( left, right, bottom, top, zNear, zFar ); + if ( s_glMatrixMode == GL_PROJECTION ) { + if ( gl::ext.FBO ) { + GLuint fboBinding = 0; + gl::qglGetIntegerv( GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&fboBinding ); + if ( fboBinding ) return; + } + QFXRenderer::Instance().SetupZDimensions( (GLfloat)zNear, (GLfloat)zFar ); + QFXRenderer::Instance().SetOrtho( GL_FALSE ); + } +} + +void WINAPI glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar ) +{ + gl::qglOrtho( left, right, bottom, top, zNear, zFar ); + if ( s_glMatrixMode == GL_PROJECTION ) { + if ( gl::ext.FBO ) { + GLuint fboBinding = 0; + gl::qglGetIntegerv( GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&fboBinding ); + if ( fboBinding ) return; + } + QFXRenderer::Instance().SetOrtho( GL_TRUE ); + } +} + +void WINAPI glDepthFunc( GLenum func ) +{ + QFXRenderer::Instance().SetupDepthFunc( func ); +} + +void WINAPI glDepthRange( GLclampd zNear, GLclampd zFar ) +{ + QFXRenderer::Instance().SetupDepthRange( zNear, zFar ); +} + +void WINAPI glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ) +{ + gl::qglTexImage2D( target, level, internalformat, width, height, border, format, type, pixels ); + if ( (target == GL_TEXTURE_2D) && !level && pixels ) + QFXRenderer::Instance().OnTexImage2D(); +} + +void WINAPI glTexParameterf( GLenum target, GLenum pname, GLfloat param ) +{ + if ( ( pname == GL_TEXTURE_MAX_ANISOTROPY_EXT ) && ( param > 1 ) ) + QFXRenderer::Instance().SetupAnisotropy(); + + gl::qglTexParameterf( target, pname, param ); +} + +void WINAPI glTexParameteri( GLenum target, GLenum pname, GLint param ) +{ + if ( ( pname == GL_TEXTURE_MAX_ANISOTROPY_EXT ) && ( param > 1 ) ) + QFXRenderer::Instance().SetupAnisotropy(); + + gl::qglTexParameteri( target, pname, param ); +} + +void WINAPI glEnable( GLenum cap ) +{ + if ( cap == GL_MULTISAMPLE_ARB ) + QFXRenderer::Instance().SetupMultisample(); + + gl::qglEnable( cap ); +} + +int WINAPI wrap_wglChoosePixelFormat( HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd ) +{ + PIXELFORMATDESCRIPTOR newPfd; + memcpy( &newPfd, ppfd, sizeof( PIXELFORMATDESCRIPTOR ) ); + newPfd.cColorBits = 32; + + gl::CheckInit(); + return gl::wglChoosePixelFormat( hdc, &newPfd ); +} + +BOOL WINAPI wrap_wglSetPixelFormat( HDC hdc, int i, CONST PIXELFORMATDESCRIPTOR *pfd ) +{ + gl::CheckInit(); + return QFXRenderer::Instance().OnSetPixelFormat( hdc, i, pfd ); +} + +BOOL WINAPI wrap_wglMakeCurrent( HDC hdc, HGLRC hglrc ) +{ + gl::CheckInit(); + if (!gl::wglMakeCurrent(hdc, hglrc)) + return FALSE; + + QFXRenderer::Instance().OnMakeCurrent( hdc, hglrc ); + return TRUE; +} + +BOOL WINAPI wrap_wglDeleteContext( HGLRC hglrc ) +{ + gl::CheckInit(); + QFXRenderer::Instance().OnDeleteContext( hglrc ); + return gl::wglDeleteContext( hglrc ); +} + +BOOL WINAPI wrap_wglSwapBuffers( HDC hdc ) +{ + gl::CheckInit(); + QFXRenderer::Instance().OnSwapBuffers(); + return gl::wglSwapBuffers( hdc ); +} diff --git a/code/cgame_hook/renderer/qfx_library.h b/code/cgame_hook/renderer/qfx_library.h new file mode 100644 index 00000000..5ee08155 --- /dev/null +++ b/code/cgame_hook/renderer/qfx_library.h @@ -0,0 +1,42 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#ifndef QFX_LIBRARY_H +#define QFX_LIBRARY_H + +#include +#include +#include +#include +#include + +#define WIN32_LEAN_AND_MEAN +#include +#include + +#define QFX_LIBRARY_TITLE "QeffectsGL" +#define QFX_LIBRARY_VERSION "1.2" +#define QFX_LIBRARY_VENDOR "Chain Studios (" QFX_LIBRARY_TITLE " " QFX_LIBRARY_VERSION ")" + +#define QFX_SINGLETON + +// make sure these identifiers do not conflict with anything +#define QFX_TEXTURE_IDENTIFIER_BASE 0xFFAA + +#endif //QFX_LIBRARY_H \ No newline at end of file diff --git a/code/cgame_hook/renderer/qfx_log.cpp b/code/cgame_hook/renderer/qfx_log.cpp new file mode 100644 index 00000000..2b7325c0 --- /dev/null +++ b/code/cgame_hook/renderer/qfx_log.cpp @@ -0,0 +1,138 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#include "qfx_library.h" +#include "qfx_log.h" + +#include "glb_local.h" + +//========================================= +// QFXLog class implementation +//----------------------------------------- +// Print messages to log file +//========================================= + +#define QFX_LOG_FILENAME QFX_LIBRARY_TITLE ".log" +#define QFX_LOG_MAXSTRING 8192 + +QFXLog :: QFXLog() : m_pszLogString( NULL ), m_pFile( NULL ) +{ + m_pszLogString = new char[ QFX_LOG_MAXSTRING ]; + assert( m_pszLogString != NULL ); + + /*char timeBuf[64]; + time_t t; + + if ( fopen_s( &m_pFile, QFX_LOG_FILENAME, "w" ) ) + return; + + m_pszLogString = new char[QFX_LOG_MAXSTRING]; + assert( m_pszLogString != NULL ); + + memset( &t, 0, sizeof(t) ); + time( &t ); + memset( timeBuf, 0, sizeof(timeBuf) ); + ctime_s( timeBuf, sizeof(timeBuf), &t ); + + fprintf( m_pFile, "==================================================================\n" ); + fprintf( m_pFile, " " QFX_LIBRARY_TITLE " initialized at %s", timeBuf ); + fprintf( m_pFile, "==================================================================\n" ); + + fprintf( m_pFile, "\n" ); + fflush( m_pFile );*/ +} + +QFXLog :: ~QFXLog() +{ + /*if ( m_pszLogString ) { + delete [] m_pszLogString; + m_pszLogString = NULL; + } + + if ( m_pFile ) { + char timeBuf[64]; + time_t t; + + memset( &t, 0, sizeof(t) ); + time( &t ); + memset( timeBuf, 0, sizeof(timeBuf) ); + ctime_s( timeBuf, sizeof(timeBuf), &t ); + + fprintf( m_pFile, "\n==================================================================\n" ); + fprintf( m_pFile, " " QFX_LIBRARY_TITLE " shutdown at %s", timeBuf ); + fprintf( m_pFile, "==================================================================\n" ); + + fclose( m_pFile ); + m_pFile = NULL; + }*/ +} + +void QFXLog :: Printf( const char *fmt, ... ) +{ + va_list argptr; + + //if ( !m_pFile || !m_pszLogString ) + // return; + + if( !m_pszLogString ) + return; + + va_start( argptr, fmt ); + _vsnprintf_s( m_pszLogString, QFX_LOG_MAXSTRING, QFX_LOG_MAXSTRING-1, fmt, argptr ); + va_end( argptr ); + + cgi.Printf( m_pszLogString ); + + //fputs( m_pszLogString, m_pFile ); + //fflush( m_pFile ); +} + +void QFXLog :: Error( const char *fmt, ... ) +{ + va_list argptr; + + if ( !m_pFile || !m_pszLogString ) + return; + + va_start( argptr, fmt ); + _vsnprintf_s( m_pszLogString, QFX_LOG_MAXSTRING, QFX_LOG_MAXSTRING-1, fmt, argptr ); + va_end( argptr ); + + cgi.Printf( m_pszLogString ); + + //fprintf( m_pFile, "ERROR: %s", m_pszLogString ); + //fflush( m_pFile ); +} + +void QFXLog :: Warning( const char *fmt, ... ) +{ + va_list argptr; + + if ( !m_pFile || !m_pszLogString ) + return; + + va_start( argptr, fmt ); + _vsnprintf_s( m_pszLogString, QFX_LOG_MAXSTRING, QFX_LOG_MAXSTRING-1, fmt, argptr ); + va_end( argptr ); + + cgi.Printf( m_pszLogString ); + + //fprintf( m_pFile, "WARNING: %s", m_pszLogString ); + //fflush( m_pFile ); +} diff --git a/code/cgame_hook/renderer/qfx_log.h b/code/cgame_hook/renderer/qfx_log.h new file mode 100644 index 00000000..d1909489 --- /dev/null +++ b/code/cgame_hook/renderer/qfx_log.h @@ -0,0 +1,42 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#ifndef QFX_LOG_H +#define QFX_LOG_H + +QFX_SINGLETON class QFXLog +{ +private: + QFXLog(); + static QFXLog& GetInstance() { static QFXLog logObject; return logObject; } + +public: + ~QFXLog(); + static QFXLog& Instance() { typedef QFXLog& (*pfnGetInstance)(); static pfnGetInstance pf = &GetInstance; return pf(); } + + void Printf( const char *fmt, ... ); + void Error( const char *fmt, ... ); + void Warning( const char *fmt, ... ); + +private: + FILE* m_pFile; + char* m_pszLogString; +}; + +#endif //QFX_LOG_H \ No newline at end of file diff --git a/code/cgame_hook/renderer/qfx_opengl.cpp b/code/cgame_hook/renderer/qfx_opengl.cpp new file mode 100644 index 00000000..bb82a1aa --- /dev/null +++ b/code/cgame_hook/renderer/qfx_opengl.cpp @@ -0,0 +1,1519 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#include "qfx_library.h" +#include "qfx_log.h" +#include "qfx_opengl.h" + +#include "glb_local.h" + +//========================================= +// OpenGL Wrapping Functions +//----------------------------------------- +// Forward calls to opengl32.dll +//========================================= + +void WINAPI glDepthFunc( GLenum func ); +void WINAPI glDepthRange( GLclampd zNear, GLclampd zFar ); +void WINAPI glDrawElements_h( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ); +void WINAPI glEnable( GLenum cap ); +void WINAPI glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar ); +const GLubyte * WINAPI glGetString( GLenum name ); +void WINAPI glLoadMatrixd( const GLdouble *m ); +void WINAPI glLoadMatrixf( const GLfloat *m ); +void WINAPI glMatrixMode( GLenum mode ); +void WINAPI glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar ); +void WINAPI glTexCoordPointer_h( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); +void WINAPI glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); +void WINAPI glTexParameterf( GLenum target, GLenum pname, GLfloat param ); +void WINAPI glTexParameteri( GLenum target, GLenum pname, GLint param ); +int WINAPI wrap_wglChoosePixelFormat( HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd ); +BOOL WINAPI wrap_wglSetPixelFormat( HDC hdc, int i, CONST PIXELFORMATDESCRIPTOR *pfd ); +BOOL WINAPI wrap_wglMakeCurrent( HDC hdc, HGLRC hglrc ); +BOOL WINAPI wrap_wglDeleteContext( HGLRC hglrc ); +BOOL WINAPI wrap_wglSwapBuffers( HDC hdc ); +int WINAPI wrap_wglDescribePixelFormat (HDC hdc, int i, UINT j, LPPIXELFORMATDESCRIPTOR ppfd) { gl::CheckInit(); return gl::wglDescribePixelFormat( hdc, i, j, ppfd ); } +int WINAPI wrap_wglGetPixelFormat(HDC hdc) { gl::CheckInit(); return gl::wglGetPixelFormat( hdc ); } +BOOL WINAPI wrap_wglCopyContext(HGLRC hglrc, HGLRC hglrc2, UINT i) { gl::CheckInit(); return gl::wglCopyContext( hglrc, hglrc2, i ); } +HGLRC WINAPI wrap_wglCreateContext(HDC hdc) { gl::CheckInit(); return gl::wglCreateContext( hdc ); } +HGLRC WINAPI wrap_wglGetCurrentContext(VOID) { gl::CheckInit(); return gl::wglGetCurrentContext(); } +HDC WINAPI wrap_wglGetCurrentDC(VOID) { gl::CheckInit(); return gl::wglGetCurrentDC(); } +PROC WINAPI wrap_wglGetProcAddress(LPCSTR s) { return gl::wglGetProcAddress(s); } +BOOL WINAPI wrap_wglShareLists(HGLRC hglrc, HGLRC hglrc2) { gl::CheckInit(); return gl::wglShareLists(hglrc, hglrc2); } +HGLRC WINAPI wrap_wglCreateLayerContext( HDC hdc, int iLayerPlane ) { gl::CheckInit(); return gl::wglCreateLayerContext(hdc, iLayerPlane); } +BOOL WINAPI wrap_wglDescribeLayerPlane( HDC hdc, int iPixelFormat, int iLayerPlane, UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd ) { gl::CheckInit(); return gl::wglDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd); } +int WINAPI wrap_wglGetLayerPaletteEntries( HDC hdc, int iLayerPlane, int iStart, int cEntries, COLORREF *pcr ) { gl::CheckInit(); return gl::wglGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr); } +int WINAPI wrap_wglSetLayerPaletteEntries(HDC hdc, int iLayerPlane, int iStart, int cEntries, CONST COLORREF *pcr) { gl::CheckInit(); return gl::wglSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr); } +BOOL WINAPI wrap_wglRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL b) { gl::CheckInit(); return gl::wglRealizeLayerPalette(hdc, iLayerPlane, b); } +BOOL WINAPI wrap_wglSwapLayerBuffers(HDC hdc, UINT i) { return gl::wglSwapLayerBuffers(hdc, i); } +BOOL WINAPI wrap_wglUseFontBitmapsA(HDC hdc, DWORD dw1, DWORD dw2, DWORD dw3) { gl::CheckInit(); return gl::wglUseFontBitmapsA(hdc, dw1, dw2, dw3); } +BOOL WINAPI wrap_wglUseFontBitmapsW(HDC hdc, DWORD dw1, DWORD dw2, DWORD dw3) { gl::CheckInit(); return gl::wglUseFontBitmapsW(hdc, dw1, dw2, dw3); } +BOOL WINAPI wrap_wglUseFontOutlinesA(HDC hdc, DWORD dw1, DWORD dw2, DWORD dw3, FLOAT f1, FLOAT f2, int i, LPGLYPHMETRICSFLOAT pgmf) { gl::CheckInit(); return gl::wglUseFontOutlinesA(hdc, dw1, dw2, dw3, f1, f2, i, pgmf); } +BOOL WINAPI wrap_wglUseFontOutlinesW(HDC hdc, DWORD dw1, DWORD dw2, DWORD dw3, FLOAT f1, FLOAT f2, int i, LPGLYPHMETRICSFLOAT pgmf) { gl::CheckInit(); return gl::wglUseFontOutlinesW(hdc, dw1, dw2, dw3, f1, f2, i, pgmf); } + +namespace gl +{ +pfn_glAccum qglAccum = NULL; +pfn_glAlphaFunc qglAlphaFunc = NULL; +pfn_glAreTexturesResident qglAreTexturesResident = NULL; +pfn_glArrayElement qglArrayElement = NULL; +pfn_glBegin qglBegin = NULL; +pfn_glBindTexture qglBindTexture = NULL; +pfn_glBitmap qglBitmap = NULL; +pfn_glBlendFunc qglBlendFunc = NULL; +pfn_glCallList qglCallList = NULL; +pfn_glCallLists qglCallLists = NULL; +pfn_glClear qglClear = NULL; +pfn_glClearAccum qglClearAccum = NULL; +pfn_glClearColor qglClearColor = NULL; +pfn_glClearDepth qglClearDepth = NULL; +pfn_glClearIndex qglClearIndex = NULL; +pfn_glClearStencil qglClearStencil = NULL; +pfn_glClipPlane qglClipPlane = NULL; +pfn_glColor3b qglColor3b = NULL; +pfn_glColor3bv qglColor3bv = NULL; +pfn_glColor3d qglColor3d = NULL; +pfn_glColor3dv qglColor3dv = NULL; +pfn_glColor3f qglColor3f = NULL; +pfn_glColor3fv qglColor3fv = NULL; +pfn_glColor3i qglColor3i = NULL; +pfn_glColor3iv qglColor3iv = NULL; +pfn_glColor3s qglColor3s = NULL; +pfn_glColor3sv qglColor3sv = NULL; +pfn_glColor3ub qglColor3ub = NULL; +pfn_glColor3ubv qglColor3ubv = NULL; +pfn_glColor3ui qglColor3ui = NULL; +pfn_glColor3uiv qglColor3uiv = NULL; +pfn_glColor3us qglColor3us = NULL; +pfn_glColor3usv qglColor3usv = NULL; +pfn_glColor4b qglColor4b = NULL; +pfn_glColor4bv qglColor4bv = NULL; +pfn_glColor4d qglColor4d = NULL; +pfn_glColor4dv qglColor4dv = NULL; +pfn_glColor4f qglColor4f = NULL; +pfn_glColor4fv qglColor4fv = NULL; +pfn_glColor4i qglColor4i = NULL; +pfn_glColor4iv qglColor4iv = NULL; +pfn_glColor4s qglColor4s = NULL; +pfn_glColor4sv qglColor4sv = NULL; +pfn_glColor4ub qglColor4ub = NULL; +pfn_glColor4ubv qglColor4ubv = NULL; +pfn_glColor4ui qglColor4ui = NULL; +pfn_glColor4uiv qglColor4uiv = NULL; +pfn_glColor4us qglColor4us = NULL; +pfn_glColor4usv qglColor4usv = NULL; +pfn_glColorMask qglColorMask = NULL; +pfn_glColorMaterial qglColorMaterial = NULL; +pfn_glColorPointer qglColorPointer = NULL; +pfn_glCopyPixels qglCopyPixels = NULL; +pfn_glCopyTexImage1D qglCopyTexImage1D = NULL; +pfn_glCopyTexImage2D qglCopyTexImage2D = NULL; +pfn_glCopyTexSubImage1D qglCopyTexSubImage1D = NULL; +pfn_glCopyTexSubImage2D qglCopyTexSubImage2D = NULL; +pfn_glCullFace qglCullFace = NULL; +pfn_glDeleteLists qglDeleteLists = NULL; +pfn_glDeleteTextures qglDeleteTextures = NULL; +pfn_glDepthFunc qglDepthFunc = NULL; +pfn_glDepthMask qglDepthMask = NULL; +pfn_glDepthRange qglDepthRange = NULL; +pfn_glDisable qglDisable = NULL; +pfn_glDisableClientState qglDisableClientState = NULL; +pfn_glDrawArrays qglDrawArrays = NULL; +pfn_glDrawBuffer qglDrawBuffer = NULL; +pfn_glDrawElements qglDrawElements = NULL; +pfn_glDrawPixels qglDrawPixels = NULL; +pfn_glEdgeFlag qglEdgeFlag = NULL; +pfn_glEdgeFlagPointer qglEdgeFlagPointer = NULL; +pfn_glEdgeFlagv qglEdgeFlagv = NULL; +pfn_glEnable qglEnable = NULL; +pfn_glEnableClientState qglEnableClientState = NULL; +pfn_glEnd qglEnd = NULL; +pfn_glEndList qglEndList = NULL; +pfn_glEvalCoord1d qglEvalCoord1d = NULL; +pfn_glEvalCoord1dv qglEvalCoord1dv = NULL; +pfn_glEvalCoord1f qglEvalCoord1f = NULL; +pfn_glEvalCoord1fv qglEvalCoord1fv = NULL; +pfn_glEvalCoord2d qglEvalCoord2d = NULL; +pfn_glEvalCoord2dv qglEvalCoord2dv = NULL; +pfn_glEvalCoord2f qglEvalCoord2f = NULL; +pfn_glEvalCoord2fv qglEvalCoord2fv = NULL; +pfn_glEvalMesh1 qglEvalMesh1 = NULL; +pfn_glEvalMesh2 qglEvalMesh2 = NULL; +pfn_glEvalPoint1 qglEvalPoint1 = NULL; +pfn_glEvalPoint2 qglEvalPoint2 = NULL; +pfn_glFeedbackBuffer qglFeedbackBuffer = NULL; +pfn_glFinish qglFinish = NULL; +pfn_glFlush qglFlush = NULL; +pfn_glFogf qglFogf = NULL; +pfn_glFogfv qglFogfv = NULL; +pfn_glFogi qglFogi = NULL; +pfn_glFogiv qglFogiv = NULL; +pfn_glFrontFace qglFrontFace = NULL; +pfn_glFrustum qglFrustum = NULL; +pfn_glGenLists qglGenLists = NULL; +pfn_glGenTextures qglGenTextures = NULL; +pfn_glGetBooleanv qglGetBooleanv = NULL; +pfn_glGetClipPlane qglGetClipPlane = NULL; +pfn_glGetDoublev qglGetDoublev = NULL; +pfn_glGetError qglGetError = NULL; +pfn_glGetFloatv qglGetFloatv = NULL; +pfn_glGetIntegerv qglGetIntegerv = NULL; +pfn_glGetLightfv qglGetLightfv = NULL; +pfn_glGetLightiv qglGetLightiv = NULL; +pfn_glGetMapdv qglGetMapdv = NULL; +pfn_glGetMapfv qglGetMapfv = NULL; +pfn_glGetMapiv qglGetMapiv = NULL; +pfn_glGetMaterialfv qglGetMaterialfv = NULL; +pfn_glGetMaterialiv qglGetMaterialiv = NULL; +pfn_glGetPixelMapfv qglGetPixelMapfv = NULL; +pfn_glGetPixelMapuiv qglGetPixelMapuiv = NULL; +pfn_glGetPixelMapusv qglGetPixelMapusv = NULL; +pfn_glGetPointerv qglGetPointerv = NULL; +pfn_glGetPolygonStipple qglGetPolygonStipple = NULL; +pfn_glGetString qglGetString = NULL; +pfn_glGetTexEnvfv qglGetTexEnvfv = NULL; +pfn_glGetTexEnviv qglGetTexEnviv = NULL; +pfn_glGetTexGendv qglGetTexGendv = NULL; +pfn_glGetTexGenfv qglGetTexGenfv = NULL; +pfn_glGetTexGeniv qglGetTexGeniv = NULL; +pfn_glGetTexImage qglGetTexImage = NULL; +pfn_glGetTexLevelParameterfv qglGetTexLevelParameterfv = NULL; +pfn_glGetTexLevelParameteriv qglGetTexLevelParameteriv = NULL; +pfn_glGetTexParameterfv qglGetTexParameterfv = NULL; +pfn_glGetTexParameteriv qglGetTexParameteriv = NULL; +pfn_glHint qglHint = NULL; +pfn_glIndexMask qglIndexMask = NULL; +pfn_glIndexPointer qglIndexPointer = NULL; +pfn_glIndexd qglIndexd = NULL; +pfn_glIndexdv qglIndexdv = NULL; +pfn_glIndexf qglIndexf = NULL; +pfn_glIndexfv qglIndexfv = NULL; +pfn_glIndexi qglIndexi = NULL; +pfn_glIndexiv qglIndexiv = NULL; +pfn_glIndexs qglIndexs = NULL; +pfn_glIndexsv qglIndexsv = NULL; +pfn_glIndexub qglIndexub = NULL; +pfn_glIndexubv qglIndexubv = NULL; +pfn_glInitNames qglInitNames = NULL; +pfn_glInterleavedArrays qglInterleavedArrays = NULL; +pfn_glIsEnabled qglIsEnabled = NULL; +pfn_glIsList qglIsList = NULL; +pfn_glIsTexture qglIsTexture = NULL; +pfn_glLightModelf qglLightModelf = NULL; +pfn_glLightModelfv qglLightModelfv = NULL; +pfn_glLightModeli qglLightModeli = NULL; +pfn_glLightModeliv qglLightModeliv = NULL; +pfn_glLightf qglLightf = NULL; +pfn_glLightfv qglLightfv = NULL; +pfn_glLighti qglLighti = NULL; +pfn_glLightiv qglLightiv = NULL; +pfn_glLineStipple qglLineStipple = NULL; +pfn_glLineWidth qglLineWidth = NULL; +pfn_glListBase qglListBase = NULL; +pfn_glLoadIdentity qglLoadIdentity = NULL; +pfn_glLoadMatrixd qglLoadMatrixd = NULL; +pfn_glLoadMatrixf qglLoadMatrixf = NULL; +pfn_glLoadName qglLoadName = NULL; +pfn_glLogicOp qglLogicOp = NULL; +pfn_glMap1d qglMap1d = NULL; +pfn_glMap1f qglMap1f = NULL; +pfn_glMap2d qglMap2d = NULL; +pfn_glMap2f qglMap2f = NULL; +pfn_glMapGrid1d qglMapGrid1d = NULL; +pfn_glMapGrid1f qglMapGrid1f = NULL; +pfn_glMapGrid2d qglMapGrid2d = NULL; +pfn_glMapGrid2f qglMapGrid2f = NULL; +pfn_glMaterialf qglMaterialf = NULL; +pfn_glMaterialfv qglMaterialfv = NULL; +pfn_glMateriali qglMateriali = NULL; +pfn_glMaterialiv qglMaterialiv = NULL; +pfn_glMatrixMode qglMatrixMode = NULL; +pfn_glMultMatrixd qglMultMatrixd = NULL; +pfn_glMultMatrixf qglMultMatrixf = NULL; +pfn_glNewList qglNewList = NULL; +pfn_glNormal3b qglNormal3b = NULL; +pfn_glNormal3bv qglNormal3bv = NULL; +pfn_glNormal3d qglNormal3d = NULL; +pfn_glNormal3dv qglNormal3dv = NULL; +pfn_glNormal3f qglNormal3f = NULL; +pfn_glNormal3fv qglNormal3fv = NULL; +pfn_glNormal3i qglNormal3i = NULL; +pfn_glNormal3iv qglNormal3iv = NULL; +pfn_glNormal3s qglNormal3s = NULL; +pfn_glNormal3sv qglNormal3sv = NULL; +pfn_glNormalPointer qglNormalPointer = NULL; +pfn_glOrtho qglOrtho = NULL; +pfn_glPassThrough qglPassThrough = NULL; +pfn_glPixelMapfv qglPixelMapfv = NULL; +pfn_glPixelMapuiv qglPixelMapuiv = NULL; +pfn_glPixelMapusv qglPixelMapusv = NULL; +pfn_glPixelStoref qglPixelStoref = NULL; +pfn_glPixelStorei qglPixelStorei = NULL; +pfn_glPixelTransferf qglPixelTransferf = NULL; +pfn_glPixelTransferi qglPixelTransferi = NULL; +pfn_glPixelZoom qglPixelZoom = NULL; +pfn_glPointSize qglPointSize = NULL; +pfn_glPolygonMode qglPolygonMode = NULL; +pfn_glPolygonOffset qglPolygonOffset = NULL; +pfn_glPolygonStipple qglPolygonStipple = NULL; +pfn_glPopAttrib qglPopAttrib = NULL; +pfn_glPopClientAttrib qglPopClientAttrib = NULL; +pfn_glPopMatrix qglPopMatrix = NULL; +pfn_glPopName qglPopName = NULL; +pfn_glPrioritizeTextures qglPrioritizeTextures = NULL; +pfn_glPushAttrib qglPushAttrib = NULL; +pfn_glPushClientAttrib qglPushClientAttrib = NULL; +pfn_glPushMatrix qglPushMatrix = NULL; +pfn_glPushName qglPushName = NULL; +pfn_glRasterPos2d qglRasterPos2d = NULL; +pfn_glRasterPos2dv qglRasterPos2dv = NULL; +pfn_glRasterPos2f qglRasterPos2f = NULL; +pfn_glRasterPos2fv qglRasterPos2fv = NULL; +pfn_glRasterPos2i qglRasterPos2i = NULL; +pfn_glRasterPos2iv qglRasterPos2iv = NULL; +pfn_glRasterPos2s qglRasterPos2s = NULL; +pfn_glRasterPos2sv qglRasterPos2sv = NULL; +pfn_glRasterPos3d qglRasterPos3d = NULL; +pfn_glRasterPos3dv qglRasterPos3dv = NULL; +pfn_glRasterPos3f qglRasterPos3f = NULL; +pfn_glRasterPos3fv qglRasterPos3fv = NULL; +pfn_glRasterPos3i qglRasterPos3i = NULL; +pfn_glRasterPos3iv qglRasterPos3iv = NULL; +pfn_glRasterPos3s qglRasterPos3s = NULL; +pfn_glRasterPos3sv qglRasterPos3sv = NULL; +pfn_glRasterPos4d qglRasterPos4d = NULL; +pfn_glRasterPos4dv qglRasterPos4dv = NULL; +pfn_glRasterPos4f qglRasterPos4f = NULL; +pfn_glRasterPos4fv qglRasterPos4fv = NULL; +pfn_glRasterPos4i qglRasterPos4i = NULL; +pfn_glRasterPos4iv qglRasterPos4iv = NULL; +pfn_glRasterPos4s qglRasterPos4s = NULL; +pfn_glRasterPos4sv qglRasterPos4sv = NULL; +pfn_glReadBuffer qglReadBuffer = NULL; +pfn_glReadPixels qglReadPixels = NULL; +pfn_glRectd qglRectd = NULL; +pfn_glRectdv qglRectdv = NULL; +pfn_glRectf qglRectf = NULL; +pfn_glRectfv qglRectfv = NULL; +pfn_glRecti qglRecti = NULL; +pfn_glRectiv qglRectiv = NULL; +pfn_glRects qglRects = NULL; +pfn_glRectsv qglRectsv = NULL; +pfn_glRenderMode qglRenderMode = NULL; +pfn_glRotated qglRotated = NULL; +pfn_glRotatef qglRotatef = NULL; +pfn_glScaled qglScaled = NULL; +pfn_glScalef qglScalef = NULL; +pfn_glScissor qglScissor = NULL; +pfn_glSelectBuffer qglSelectBuffer = NULL; +pfn_glShadeModel qglShadeModel = NULL; +pfn_glStencilFunc qglStencilFunc = NULL; +pfn_glStencilMask qglStencilMask = NULL; +pfn_glStencilOp qglStencilOp = NULL; +pfn_glTexCoord1d qglTexCoord1d = NULL; +pfn_glTexCoord1dv qglTexCoord1dv = NULL; +pfn_glTexCoord1f qglTexCoord1f = NULL; +pfn_glTexCoord1fv qglTexCoord1fv = NULL; +pfn_glTexCoord1i qglTexCoord1i = NULL; +pfn_glTexCoord1iv qglTexCoord1iv = NULL; +pfn_glTexCoord1s qglTexCoord1s = NULL; +pfn_glTexCoord1sv qglTexCoord1sv = NULL; +pfn_glTexCoord2d qglTexCoord2d = NULL; +pfn_glTexCoord2dv qglTexCoord2dv = NULL; +pfn_glTexCoord2f qglTexCoord2f = NULL; +pfn_glTexCoord2fv qglTexCoord2fv = NULL; +pfn_glTexCoord2i qglTexCoord2i = NULL; +pfn_glTexCoord2iv qglTexCoord2iv = NULL; +pfn_glTexCoord2s qglTexCoord2s = NULL; +pfn_glTexCoord2sv qglTexCoord2sv = NULL; +pfn_glTexCoord3d qglTexCoord3d = NULL; +pfn_glTexCoord3dv qglTexCoord3dv = NULL; +pfn_glTexCoord3f qglTexCoord3f = NULL; +pfn_glTexCoord3fv qglTexCoord3fv = NULL; +pfn_glTexCoord3i qglTexCoord3i = NULL; +pfn_glTexCoord3iv qglTexCoord3iv = NULL; +pfn_glTexCoord3s qglTexCoord3s = NULL; +pfn_glTexCoord3sv qglTexCoord3sv = NULL; +pfn_glTexCoord4d qglTexCoord4d = NULL; +pfn_glTexCoord4dv qglTexCoord4dv = NULL; +pfn_glTexCoord4f qglTexCoord4f = NULL; +pfn_glTexCoord4fv qglTexCoord4fv = NULL; +pfn_glTexCoord4i qglTexCoord4i = NULL; +pfn_glTexCoord4iv qglTexCoord4iv = NULL; +pfn_glTexCoord4s qglTexCoord4s = NULL; +pfn_glTexCoord4sv qglTexCoord4sv = NULL; +pfn_glTexCoordPointer qglTexCoordPointer = NULL; +pfn_glTexEnvf qglTexEnvf = NULL; +pfn_glTexEnvfv qglTexEnvfv = NULL; +pfn_glTexEnvi qglTexEnvi = NULL; +pfn_glTexEnviv qglTexEnviv = NULL; +pfn_glTexGend qglTexGend = NULL; +pfn_glTexGendv qglTexGendv = NULL; +pfn_glTexGenf qglTexGenf = NULL; +pfn_glTexGenfv qglTexGenfv = NULL; +pfn_glTexGeni qglTexGeni = NULL; +pfn_glTexGeniv qglTexGeniv = NULL; +pfn_glTexImage1D qglTexImage1D = NULL; +pfn_glTexImage2D qglTexImage2D = NULL; +pfn_glTexParameterf qglTexParameterf = NULL; +pfn_glTexParameterfv qglTexParameterfv = NULL; +pfn_glTexParameteri qglTexParameteri = NULL; +pfn_glTexParameteriv qglTexParameteriv = NULL; +pfn_glTexSubImage1D qglTexSubImage1D = NULL; +pfn_glTexSubImage2D qglTexSubImage2D = NULL; +pfn_glTranslated qglTranslated = NULL; +pfn_glTranslatef qglTranslatef = NULL; +pfn_glVertex2d qglVertex2d = NULL; +pfn_glVertex2dv qglVertex2dv = NULL; +pfn_glVertex2f qglVertex2f = NULL; +pfn_glVertex2fv qglVertex2fv = NULL; +pfn_glVertex2i qglVertex2i = NULL; +pfn_glVertex2iv qglVertex2iv = NULL; +pfn_glVertex2s qglVertex2s = NULL; +pfn_glVertex2sv qglVertex2sv = NULL; +pfn_glVertex3d qglVertex3d = NULL; +pfn_glVertex3dv qglVertex3dv = NULL; +pfn_glVertex3f qglVertex3f = NULL; +pfn_glVertex3fv qglVertex3fv = NULL; +pfn_glVertex3i qglVertex3i = NULL; +pfn_glVertex3iv qglVertex3iv = NULL; +pfn_glVertex3s qglVertex3s = NULL; +pfn_glVertex3sv qglVertex3sv = NULL; +pfn_glVertex4d qglVertex4d = NULL; +pfn_glVertex4dv qglVertex4dv = NULL; +pfn_glVertex4f qglVertex4f = NULL; +pfn_glVertex4fv qglVertex4fv = NULL; +pfn_glVertex4i qglVertex4i = NULL; +pfn_glVertex4iv qglVertex4iv = NULL; +pfn_glVertex4s qglVertex4s = NULL; +pfn_glVertex4sv qglVertex4sv = NULL; +pfn_glVertexPointer qglVertexPointer = NULL; +pfn_glViewport qglViewport = NULL; +pfn_wglChoosePixelFormat wglChoosePixelFormat = NULL; +pfn_wglDescribePixelFormat wglDescribePixelFormat = NULL; +pfn_wglGetPixelFormat wglGetPixelFormat = NULL; +pfn_wglSetPixelFormat wglSetPixelFormat = NULL; +pfn_wglSwapBuffers wglSwapBuffers = NULL; +pfn_wglCopyContext wglCopyContext = NULL; +pfn_wglCreateContext wglCreateContext = NULL; +pfn_wglDeleteContext wglDeleteContext = NULL; +pfn_wglGetCurrentContext wglGetCurrentContext = NULL; +pfn_wglGetCurrentDC wglGetCurrentDC = NULL; +pfn_wglGetProcAddress wglGetProcAddress = NULL; +pfn_wglMakeCurrent wglMakeCurrent = NULL; +pfn_wglShareLists wglShareLists = NULL; +pfn_wglCreateLayerContext wglCreateLayerContext = NULL; +pfn_wglDescribeLayerPlane wglDescribeLayerPlane = NULL; +pfn_wglGetLayerPaletteEntries wglGetLayerPaletteEntries = NULL; +pfn_wglSetLayerPaletteEntries wglSetLayerPaletteEntries = NULL; +pfn_wglRealizeLayerPalette wglRealizeLayerPalette = NULL; +pfn_wglSwapLayerBuffers wglSwapLayerBuffers = NULL; +pfn_wglUseFontBitmapsA wglUseFontBitmapsA = NULL; +pfn_wglUseFontBitmapsW wglUseFontBitmapsW = NULL; +pfn_wglUseFontOutlinesA wglUseFontOutlinesA = NULL; +pfn_wglUseFontOutlinesW wglUseFontOutlinesW = NULL; + +// GL extensions +PFNGLGETHANDLEARBPROC qglGetHandleARB = NULL; +PFNGLACTIVETEXTUREARBPROC qglActiveTextureARB = NULL; +PFNGLCLIENTACTIVETEXTUREARBPROC qglClientActiveTextureARB = NULL; +PFNGLMULTITEXCOORD2FARBPROC qglMultiTexCoord2fARB = NULL; +PFNGLMULTITEXCOORD2FVARBPROC qglMultiTexCoord2fvARB = NULL; +PFNGLDELETEOBJECTARBPROC qglDeleteObjectARB = NULL; +PFNGLDETACHOBJECTARBPROC qglDetachObjectARB = NULL; +PFNGLCREATESHADEROBJECTARBPROC qglCreateShaderObjectARB = NULL; +PFNGLSHADERSOURCEARBPROC qglShaderSourceARB = NULL; +PFNGLCOMPILESHADERARBPROC qglCompileShaderARB = NULL; +PFNGLCREATEPROGRAMOBJECTARBPROC qglCreateProgramObjectARB = NULL; +PFNGLATTACHOBJECTARBPROC qglAttachObjectARB = NULL; +PFNGLLINKPROGRAMARBPROC qglLinkProgramARB = NULL; +PFNGLUSEPROGRAMOBJECTARBPROC qglUseProgramObjectARB = NULL; +PFNGLVALIDATEPROGRAMARBPROC qglValidateProgramARB = NULL; +PFNGLGETUNIFORMLOCATIONARBPROC qglGetUniformLocationARB = NULL; +PFNGLUNIFORM1IARBPROC qglUniform1iARB = NULL; +PFNGLUNIFORM4FARBPROC qglUniform4fARB = NULL; +PFNGLUNIFORM4FVARBPROC qglUniform4fvARB = NULL; +PFNGLGETINFOLOGARBPROC qglGetInfoLogARB = NULL; +PFNGLGETOBJECTPARAMETERIVARBPROC qglGetObjectParameterivARB = NULL; +PFNGLGETATTACHEDOBJECTSARBPROC qglGetAttachedObjectsARB = NULL; + +PFNGLBINDFRAMEBUFFERPROC qglBindFramebuffer = NULL; +PFNGLCHECKFRAMEBUFFERSTATUSPROC qglCheckFramebufferStatus = NULL; +PFNGLDELETEFRAMEBUFFERSPROC qglDeleteFramebuffers = NULL; +PFNGLFRAMEBUFFERTEXTURE2DPROC qglFramebufferTexture2D = NULL; +PFNGLFRAMEBUFFERTEXTUREPROC qglFramebufferTexture = NULL; +PFNGLGENFRAMEBUFFERSPROC qglGenFramebuffers = NULL; +PFNGLGENERATEMIPMAPPROC qglGenerateMipmap = NULL; + +PFNGLBINDFRAMEBUFFERPROC qglBindFramebufferEXT = NULL; +PFNGLCHECKFRAMEBUFFERSTATUSPROC qglCheckFramebufferStatusEXT = NULL; +PFNGLDELETEFRAMEBUFFERSPROC qglDeleteFramebuffersEXT = NULL; +PFNGLFRAMEBUFFERTEXTURE2DPROC qglFramebufferTexture2DEXT = NULL; +PFNGLFRAMEBUFFERTEXTUREPROC qglFramebufferTextureEXT = NULL; +PFNGLGENFRAMEBUFFERSPROC qglGenFramebuffersEXT = NULL; +PFNGLGENERATEMIPMAPPROC qglGenerateMipmapEXT = NULL; + +DWORD *proc_glDepthFunc = ( DWORD * )0x13E3D28; +DWORD *proc_glDepthRange = ( DWORD * )0x13E3D88; +DWORD *proc_glDrawElements = ( DWORD * )0x13E3D04; +DWORD *proc_glEnable = ( DWORD * )0x13E3D08; +DWORD *proc_glFrustum = ( DWORD * )0x13E3C8C; +DWORD *proc_glGetString = ( DWORD * )0x13E3FD8; +DWORD *proc_glLoadMatrixd = ( DWORD * )0x13E3D9C; +DWORD *proc_glLoadMatrixf = ( DWORD * )0x13E3D98; +DWORD *proc_glMatrixMode = ( DWORD * )0x13E3DF8; +DWORD *proc_glOrtho = ( DWORD * )0x13E3E5C; +DWORD *proc_glTexCoordPointer = ( DWORD * )0x13E3E74; +DWORD *proc_glTexImage2D = ( DWORD * )0x13E3E48; +DWORD *proc_glTexParameterf = ( DWORD * )0x13E3F3C; +DWORD *proc_glTexParameteri = ( DWORD * )0x13E3F40; + +DWORD *proc_wglChoosePixelFormat = ( DWORD * )0x13E3E2C; +DWORD *proc_wglCopyContext = ( DWORD * )0x13E4030; +DWORD *proc_wglCreateContext = ( DWORD * )0x13E3DEC; +DWORD *proc_wglCreateLayerContext = ( DWORD * )0x13E3DFC; +DWORD *proc_wglDeleteContext = ( DWORD * )0x13E40FC; +DWORD *proc_wglDescribeLayerPlane = ( DWORD * )0x13E3E78; +DWORD *proc_wglDescribePixelFormat = ( DWORD * )0x13E3F74; +DWORD *proc_wglGetCurrentContext = ( DWORD * )0x13E3DA4; +DWORD *proc_wglGetCurrentDC = ( DWORD * )0x13E4044; +DWORD *proc_wglGetLayerPaletteEntries = ( DWORD * )0x13E3E00; +DWORD *proc_wglGetPixelFormat = ( DWORD * )0x13E3E84; +DWORD *proc_wglGetProcAddress = ( DWORD * )0x13E3FBC; +DWORD *proc_wglMakeCurrent = ( DWORD * )0x13E418C; +DWORD *proc_wglRealizeLayerPalette = ( DWORD * )0x13E3E1C; +DWORD *proc_wglSetLayerPaletteEntries = ( DWORD * )0x13E4164; +DWORD *proc_wglSetPixelFormat = ( DWORD * )0x13E3E28; +DWORD *proc_wglShareLists = ( DWORD * )0x13E4138; +DWORD *proc_wglSwapBuffers = ( DWORD * )0x13E40C8; +DWORD *proc_wglSwapLayerBuffers = ( DWORD * )0x13E4048; +DWORD *proc_wglUseFontBitmapsA = ( DWORD * )0x13E405C; +DWORD *proc_wglUseFontOutlinesA = ( DWORD * )0x13E3FC0; + +DWORD proc_glDepthFunc_f; +DWORD proc_glDepthRange_f; +DWORD proc_glDrawElements_f; +DWORD proc_glEnable_f; +DWORD proc_glFrustum_f; +DWORD proc_glGetString_f; +DWORD proc_glLoadMatrixd_f; +DWORD proc_glLoadMatrixf_f; +DWORD proc_glMatrixMode_f; +DWORD proc_glOrtho_f; +DWORD proc_glTexCoordPointer_f; +DWORD proc_glTexImage2D_f; +DWORD proc_glTexParameterf_f; +DWORD proc_glTexParameteri_f; + +DWORD proc_wglChoosePixelFormat_f; +DWORD proc_wglCopyContext_f; +DWORD proc_wglCreateContext_f; +DWORD proc_wglCreateLayerContext_f; +DWORD proc_wglDeleteContext_f; +DWORD proc_wglDescribeLayerPlane_f; +DWORD proc_wglDescribePixelFormat_f; +DWORD proc_wglGetCurrentContext_f; +DWORD proc_wglGetCurrentDC_f; +DWORD proc_wglGetLayerPaletteEntries_f; +DWORD proc_wglGetPixelFormat_f; +DWORD proc_wglGetProcAddress_f; +DWORD proc_wglMakeCurrent_f; +DWORD proc_wglRealizeLayerPalette_f; +DWORD proc_wglSetLayerPaletteEntries_f; +DWORD proc_wglSetPixelFormat_f; +DWORD proc_wglShareLists_f; +DWORD proc_wglSwapBuffers_f; +DWORD proc_wglSwapLayerBuffers_f; +DWORD proc_wglUseFontBitmapsA_f; +DWORD proc_wglUseFontOutlinesA_f; + +HMODULE hOpenGLDll = NULL; +bool bInitError = false; +ExtensionSupport_t ext; + +#define QFX_GPA( func ) q##func = ( pfn_##func )GetProcAddress( hOpenGLDll, #func ); if ( !q##func ) { QFXLog::Instance().Printf( "failed\n" ); QFXLog::Instance().Error( "Cannot find function \"%s\" in opengl32.dll!\n", #func ); bInitError = true; return false; } +#define QFX_GPAW( func ) func = ( pfn_##func )GetProcAddress( hOpenGLDll, #func ); if ( !func ) { QFXLog::Instance().Printf( "failed\n" ); QFXLog::Instance().Error( "Cannot find function \"%s\" in opengl32.dll!\n", #func ); bInitError = true; return false; } +#define QFX_EXT( type, func ) q##func = (type)gl::wglGetProcAddress( #func ); if ( !q##func ) { QFXLog::Instance().Error( "ERROR: cannot get proc address of \"%s\"!\n", #func ); } + +bool Initialize( void ) +{ + char szSystemLibrary[1024]; + + GetSystemDirectory( szSystemLibrary, sizeof( szSystemLibrary ) ); + strcat_s( szSystemLibrary, "\\opengl32.dll" ); + + QFXLog::Instance().Printf( "Loading \"%s\": ", szSystemLibrary ); + hOpenGLDll = GetModuleHandle( szSystemLibrary ); + if ( !hOpenGLDll ) { + QFXLog::Instance().Printf( "failed\n" ); + bInitError = true; + return false; + } + + QFXLog::Instance().Printf( "success\n" ); + QFXLog::Instance().Printf( "Loading functions: " ); + + QFX_GPA( glAccum ); + QFX_GPA( glAlphaFunc ); + QFX_GPA( glAreTexturesResident ); + QFX_GPA( glArrayElement ); + QFX_GPA( glBegin ); + QFX_GPA( glBindTexture ); + QFX_GPA( glBitmap ); + QFX_GPA( glBlendFunc ); + QFX_GPA( glCallList ); + QFX_GPA( glCallLists ); + QFX_GPA( glClear ); + QFX_GPA( glClearAccum ); + QFX_GPA( glClearColor ); + QFX_GPA( glClearDepth ); + QFX_GPA( glClearIndex ); + QFX_GPA( glClearStencil ); + QFX_GPA( glClipPlane ); + QFX_GPA( glColor3b ); + QFX_GPA( glColor3bv ); + QFX_GPA( glColor3d ); + QFX_GPA( glColor3dv ); + QFX_GPA( glColor3f ); + QFX_GPA( glColor3fv ); + QFX_GPA( glColor3i ); + QFX_GPA( glColor3iv ); + QFX_GPA( glColor3s ); + QFX_GPA( glColor3sv ); + QFX_GPA( glColor3ub ); + QFX_GPA( glColor3ubv ); + QFX_GPA( glColor3ui ); + QFX_GPA( glColor3uiv ); + QFX_GPA( glColor3us ); + QFX_GPA( glColor3usv ); + QFX_GPA( glColor4b ); + QFX_GPA( glColor4bv ); + QFX_GPA( glColor4d ); + QFX_GPA( glColor4dv ); + QFX_GPA( glColor4f ); + QFX_GPA( glColor4fv ); + QFX_GPA( glColor4i ); + QFX_GPA( glColor4iv ); + QFX_GPA( glColor4s ); + QFX_GPA( glColor4sv ); + QFX_GPA( glColor4ub ); + QFX_GPA( glColor4ubv ); + QFX_GPA( glColor4ui ); + QFX_GPA( glColor4uiv ); + QFX_GPA( glColor4us ); + QFX_GPA( glColor4usv ); + QFX_GPA( glColorMask ); + QFX_GPA( glColorMaterial ); + QFX_GPA( glColorPointer ); + QFX_GPA( glCopyPixels ); + QFX_GPA( glCopyTexImage1D ); + QFX_GPA( glCopyTexImage2D ); + QFX_GPA( glCopyTexSubImage1D ); + QFX_GPA( glCopyTexSubImage2D ); + QFX_GPA( glCullFace ); + QFX_GPA( glDeleteLists ); + QFX_GPA( glDeleteTextures ); + QFX_GPA( glDepthFunc ); + QFX_GPA( glDepthMask ); + QFX_GPA( glDepthRange ); + QFX_GPA( glDisable ); + QFX_GPA( glDisableClientState ); + QFX_GPA( glDrawArrays ); + QFX_GPA( glDrawBuffer ); + QFX_GPA( glDrawElements ); + QFX_GPA( glDrawPixels ); + QFX_GPA( glEdgeFlag ); + QFX_GPA( glEdgeFlagPointer ); + QFX_GPA( glEdgeFlagv ); + QFX_GPA( glEnable ); + QFX_GPA( glEnableClientState ); + QFX_GPA( glEnd ); + QFX_GPA( glEndList ); + QFX_GPA( glEvalCoord1d ); + QFX_GPA( glEvalCoord1dv ); + QFX_GPA( glEvalCoord1f ); + QFX_GPA( glEvalCoord1fv ); + QFX_GPA( glEvalCoord2d ); + QFX_GPA( glEvalCoord2dv ); + QFX_GPA( glEvalCoord2f ); + QFX_GPA( glEvalCoord2fv ); + QFX_GPA( glEvalMesh1 ); + QFX_GPA( glEvalMesh2 ); + QFX_GPA( glEvalPoint1 ); + QFX_GPA( glEvalPoint2 ); + QFX_GPA( glFeedbackBuffer ); + QFX_GPA( glFinish ); + QFX_GPA( glFlush ); + QFX_GPA( glFogf ); + QFX_GPA( glFogfv ); + QFX_GPA( glFogi ); + QFX_GPA( glFogiv ); + QFX_GPA( glFrontFace ); + QFX_GPA( glFrustum ); + QFX_GPA( glGenLists ); + QFX_GPA( glGenTextures ); + QFX_GPA( glGetBooleanv ); + QFX_GPA( glGetClipPlane ); + QFX_GPA( glGetDoublev ); + QFX_GPA( glGetError ); + QFX_GPA( glGetFloatv ); + QFX_GPA( glGetIntegerv ); + QFX_GPA( glGetLightfv ); + QFX_GPA( glGetLightiv ); + QFX_GPA( glGetMapdv ); + QFX_GPA( glGetMapfv ); + QFX_GPA( glGetMapiv ); + QFX_GPA( glGetMaterialfv ); + QFX_GPA( glGetMaterialiv ); + QFX_GPA( glGetPixelMapfv ); + QFX_GPA( glGetPixelMapuiv ); + QFX_GPA( glGetPixelMapusv ); + QFX_GPA( glGetPointerv ); + QFX_GPA( glGetPolygonStipple ); + QFX_GPA( glGetString ); + QFX_GPA( glGetTexEnvfv ); + QFX_GPA( glGetTexEnviv ); + QFX_GPA( glGetTexGendv ); + QFX_GPA( glGetTexGenfv ); + QFX_GPA( glGetTexGeniv ); + QFX_GPA( glGetTexImage ); + QFX_GPA( glGetTexLevelParameterfv ); + QFX_GPA( glGetTexLevelParameteriv ); + QFX_GPA( glGetTexParameterfv ); + QFX_GPA( glGetTexParameteriv ); + QFX_GPA( glHint ); + QFX_GPA( glIndexMask ); + QFX_GPA( glIndexPointer ); + QFX_GPA( glIndexd ); + QFX_GPA( glIndexdv ); + QFX_GPA( glIndexf ); + QFX_GPA( glIndexfv ); + QFX_GPA( glIndexi ); + QFX_GPA( glIndexiv ); + QFX_GPA( glIndexs ); + QFX_GPA( glIndexsv ); + QFX_GPA( glIndexub ); + QFX_GPA( glIndexubv ); + QFX_GPA( glInitNames ); + QFX_GPA( glInterleavedArrays ); + QFX_GPA( glIsEnabled ); + QFX_GPA( glIsList ); + QFX_GPA( glIsTexture ); + QFX_GPA( glLightModelf ); + QFX_GPA( glLightModelfv ); + QFX_GPA( glLightModeli ); + QFX_GPA( glLightModeliv ); + QFX_GPA( glLightf ); + QFX_GPA( glLightfv ); + QFX_GPA( glLighti ); + QFX_GPA( glLightiv ); + QFX_GPA( glLineStipple ); + QFX_GPA( glLineWidth ); + QFX_GPA( glListBase ); + QFX_GPA( glLoadIdentity ); + QFX_GPA( glLoadMatrixd ); + QFX_GPA( glLoadMatrixf ); + QFX_GPA( glLoadName ); + QFX_GPA( glLogicOp ); + QFX_GPA( glMap1d ); + QFX_GPA( glMap1f ); + QFX_GPA( glMap2d ); + QFX_GPA( glMap2f ); + QFX_GPA( glMapGrid1d ); + QFX_GPA( glMapGrid1f ); + QFX_GPA( glMapGrid2d ); + QFX_GPA( glMapGrid2f ); + QFX_GPA( glMaterialf ); + QFX_GPA( glMaterialfv ); + QFX_GPA( glMateriali ); + QFX_GPA( glMaterialiv ); + QFX_GPA( glMatrixMode ); + QFX_GPA( glMultMatrixd ); + QFX_GPA( glMultMatrixf ); + QFX_GPA( glNewList ); + QFX_GPA( glNormal3b ); + QFX_GPA( glNormal3bv ); + QFX_GPA( glNormal3d ); + QFX_GPA( glNormal3dv ); + QFX_GPA( glNormal3f ); + QFX_GPA( glNormal3fv ); + QFX_GPA( glNormal3i ); + QFX_GPA( glNormal3iv ); + QFX_GPA( glNormal3s ); + QFX_GPA( glNormal3sv ); + QFX_GPA( glNormalPointer ); + QFX_GPA( glOrtho ); + QFX_GPA( glPassThrough ); + QFX_GPA( glPixelMapfv ); + QFX_GPA( glPixelMapuiv ); + QFX_GPA( glPixelMapusv ); + QFX_GPA( glPixelStoref ); + QFX_GPA( glPixelStorei ); + QFX_GPA( glPixelTransferf ); + QFX_GPA( glPixelTransferi ); + QFX_GPA( glPixelZoom ); + QFX_GPA( glPointSize ); + QFX_GPA( glPolygonMode ); + QFX_GPA( glPolygonOffset ); + QFX_GPA( glPolygonStipple ); + QFX_GPA( glPopAttrib ); + QFX_GPA( glPopClientAttrib ); + QFX_GPA( glPopMatrix ); + QFX_GPA( glPopName ); + QFX_GPA( glPrioritizeTextures ); + QFX_GPA( glPushAttrib ); + QFX_GPA( glPushClientAttrib ); + QFX_GPA( glPushMatrix ); + QFX_GPA( glPushName ); + QFX_GPA( glRasterPos2d ); + QFX_GPA( glRasterPos2dv ); + QFX_GPA( glRasterPos2f ); + QFX_GPA( glRasterPos2fv ); + QFX_GPA( glRasterPos2i ); + QFX_GPA( glRasterPos2iv ); + QFX_GPA( glRasterPos2s ); + QFX_GPA( glRasterPos2sv ); + QFX_GPA( glRasterPos3d ); + QFX_GPA( glRasterPos3dv ); + QFX_GPA( glRasterPos3f ); + QFX_GPA( glRasterPos3fv ); + QFX_GPA( glRasterPos3i ); + QFX_GPA( glRasterPos3iv ); + QFX_GPA( glRasterPos3s ); + QFX_GPA( glRasterPos3sv ); + QFX_GPA( glRasterPos4d ); + QFX_GPA( glRasterPos4dv ); + QFX_GPA( glRasterPos4f ); + QFX_GPA( glRasterPos4fv ); + QFX_GPA( glRasterPos4i ); + QFX_GPA( glRasterPos4iv ); + QFX_GPA( glRasterPos4s ); + QFX_GPA( glRasterPos4sv ); + QFX_GPA( glReadBuffer ); + QFX_GPA( glReadPixels ); + QFX_GPA( glRectd ); + QFX_GPA( glRectdv ); + QFX_GPA( glRectf ); + QFX_GPA( glRectfv ); + QFX_GPA( glRecti ); + QFX_GPA( glRectiv ); + QFX_GPA( glRects ); + QFX_GPA( glRectsv ); + QFX_GPA( glRenderMode ); + QFX_GPA( glRotated ); + QFX_GPA( glRotatef ); + QFX_GPA( glScaled ); + QFX_GPA( glScalef ); + QFX_GPA( glScissor ); + QFX_GPA( glSelectBuffer ); + QFX_GPA( glShadeModel ); + QFX_GPA( glStencilFunc ); + QFX_GPA( glStencilMask ); + QFX_GPA( glStencilOp ); + QFX_GPA( glTexCoord1d ); + QFX_GPA( glTexCoord1dv ); + QFX_GPA( glTexCoord1f ); + QFX_GPA( glTexCoord1fv ); + QFX_GPA( glTexCoord1i ); + QFX_GPA( glTexCoord1iv ); + QFX_GPA( glTexCoord1s ); + QFX_GPA( glTexCoord1sv ); + QFX_GPA( glTexCoord2d ); + QFX_GPA( glTexCoord2dv ); + QFX_GPA( glTexCoord2f ); + QFX_GPA( glTexCoord2fv ); + QFX_GPA( glTexCoord2i ); + QFX_GPA( glTexCoord2iv ); + QFX_GPA( glTexCoord2s ); + QFX_GPA( glTexCoord2sv ); + QFX_GPA( glTexCoord3d ); + QFX_GPA( glTexCoord3dv ); + QFX_GPA( glTexCoord3f ); + QFX_GPA( glTexCoord3fv ); + QFX_GPA( glTexCoord3i ); + QFX_GPA( glTexCoord3iv ); + QFX_GPA( glTexCoord3s ); + QFX_GPA( glTexCoord3sv ); + QFX_GPA( glTexCoord4d ); + QFX_GPA( glTexCoord4dv ); + QFX_GPA( glTexCoord4f ); + QFX_GPA( glTexCoord4fv ); + QFX_GPA( glTexCoord4i ); + QFX_GPA( glTexCoord4iv ); + QFX_GPA( glTexCoord4s ); + QFX_GPA( glTexCoord4sv ); + QFX_GPA( glTexCoordPointer ); + QFX_GPA( glTexEnvf ); + QFX_GPA( glTexEnvfv ); + QFX_GPA( glTexEnvi ); + QFX_GPA( glTexEnviv ); + QFX_GPA( glTexGend ); + QFX_GPA( glTexGendv ); + QFX_GPA( glTexGenf ); + QFX_GPA( glTexGenfv ); + QFX_GPA( glTexGeni ); + QFX_GPA( glTexGeniv ); + QFX_GPA( glTexImage1D ); + QFX_GPA( glTexImage2D ); + QFX_GPA( glTexParameterf ); + QFX_GPA( glTexParameterfv ); + QFX_GPA( glTexParameteri ); + QFX_GPA( glTexParameteriv ); + QFX_GPA( glTexSubImage1D ); + QFX_GPA( glTexSubImage2D ); + QFX_GPA( glTranslated ); + QFX_GPA( glTranslatef ); + QFX_GPA( glVertex2d ); + QFX_GPA( glVertex2dv ); + QFX_GPA( glVertex2f ); + QFX_GPA( glVertex2fv ); + QFX_GPA( glVertex2i ); + QFX_GPA( glVertex2iv ); + QFX_GPA( glVertex2s ); + QFX_GPA( glVertex2sv ); + QFX_GPA( glVertex3d ); + QFX_GPA( glVertex3dv ); + QFX_GPA( glVertex3f ); + QFX_GPA( glVertex3fv ); + QFX_GPA( glVertex3i ); + QFX_GPA( glVertex3iv ); + QFX_GPA( glVertex3s ); + QFX_GPA( glVertex3sv ); + QFX_GPA( glVertex4d ); + QFX_GPA( glVertex4dv ); + QFX_GPA( glVertex4f ); + QFX_GPA( glVertex4fv ); + QFX_GPA( glVertex4i ); + QFX_GPA( glVertex4iv ); + QFX_GPA( glVertex4s ); + QFX_GPA( glVertex4sv ); + QFX_GPA( glVertexPointer ); + QFX_GPA( glViewport ); + + QFX_GPAW( wglCopyContext ); + QFX_GPAW( wglCreateContext ); + QFX_GPAW( wglDeleteContext ); + QFX_GPAW( wglGetCurrentContext ); + QFX_GPAW( wglGetCurrentDC ); + QFX_GPAW( wglGetProcAddress ); + QFX_GPAW( wglMakeCurrent ); + QFX_GPAW( wglShareLists ); + QFX_GPAW( wglChoosePixelFormat ); + QFX_GPAW( wglDescribePixelFormat ); + QFX_GPAW( wglGetPixelFormat ); + QFX_GPAW( wglSetPixelFormat ); + QFX_GPAW( wglSwapBuffers ); + QFX_GPAW( wglCreateLayerContext ); + QFX_GPAW( wglDescribeLayerPlane ); + QFX_GPAW( wglGetLayerPaletteEntries ); + QFX_GPAW( wglSetLayerPaletteEntries ); + QFX_GPAW( wglRealizeLayerPalette ); + QFX_GPAW( wglSwapLayerBuffers ); + QFX_GPAW( wglUseFontBitmapsA ); + QFX_GPAW( wglUseFontBitmapsW ); + QFX_GPAW( wglUseFontOutlinesA ); + QFX_GPAW( wglUseFontOutlinesW ); + + proc_glDepthFunc_f = *proc_glDepthFunc; + proc_glDepthRange_f = *proc_glDepthRange; + proc_glDrawElements_f = *proc_glDrawElements; + proc_glEnable_f = *proc_glEnable; + proc_glFrustum_f = *proc_glFrustum; + proc_glGetString_f = *proc_glGetString; + proc_glLoadMatrixd_f = *proc_glLoadMatrixd; + proc_glLoadMatrixf_f = *proc_glLoadMatrixf; + proc_glMatrixMode_f = *proc_glMatrixMode; + proc_glOrtho_f = *proc_glOrtho; + proc_glTexCoordPointer_f = *proc_glTexCoordPointer; + proc_glTexImage2D_f = *proc_glTexImage2D; + proc_glTexParameterf_f = *proc_glTexParameterf; + proc_glTexParameteri_f = *proc_glTexParameteri; + + proc_wglChoosePixelFormat_f = *proc_wglChoosePixelFormat; + proc_wglCopyContext_f = *proc_wglCopyContext; + proc_wglCreateContext_f = *proc_wglCreateContext; + proc_wglCreateLayerContext_f = *proc_wglCreateLayerContext; + proc_wglDeleteContext_f = *proc_wglDeleteContext; + proc_wglDescribeLayerPlane_f = *proc_wglDescribeLayerPlane; + proc_wglDescribePixelFormat_f = *proc_wglDescribePixelFormat; + proc_wglGetCurrentContext_f = *proc_wglGetCurrentContext; + proc_wglGetCurrentDC_f = *proc_wglGetCurrentDC; + proc_wglGetLayerPaletteEntries_f = *proc_wglGetLayerPaletteEntries; + proc_wglGetPixelFormat_f = *proc_wglGetPixelFormat; + proc_wglGetProcAddress_f = *proc_wglGetProcAddress; + proc_wglMakeCurrent_f = *proc_wglMakeCurrent; + proc_wglRealizeLayerPalette_f = *proc_wglRealizeLayerPalette; + proc_wglSetLayerPaletteEntries_f = *proc_wglSetLayerPaletteEntries; + proc_wglSetPixelFormat_f = *proc_wglSetPixelFormat; + proc_wglShareLists_f = *proc_wglShareLists; + proc_wglSwapBuffers_f = *proc_wglSwapBuffers; + proc_wglSwapLayerBuffers_f = *proc_wglSwapLayerBuffers; + proc_wglUseFontBitmapsA_f = *proc_wglUseFontBitmapsA; + proc_wglUseFontOutlinesA_f = *proc_wglUseFontOutlinesA; + + *proc_glDepthFunc = ( DWORD )( pfn_glDepthFunc )glDepthFunc; + *proc_glDepthRange = ( DWORD )( pfn_glDepthRange )glDepthRange; + *proc_glDrawElements = ( DWORD )( pfn_glDrawElements )glDrawElements_h; + *proc_glEnable = ( DWORD )( pfn_glEnable )glEnable; + *proc_glFrustum = ( DWORD )( pfn_glFrustum )glFrustum; + *proc_glGetString = ( DWORD )( pfn_glGetString )glGetString; + *proc_glLoadMatrixd = ( DWORD )( pfn_glLoadMatrixd )glLoadMatrixd; + *proc_glLoadMatrixf = ( DWORD )( pfn_glLoadMatrixf )glLoadMatrixf; + *proc_glMatrixMode = ( DWORD )( pfn_glMatrixMode )glMatrixMode; + *proc_glOrtho = ( DWORD )( pfn_glOrtho )glOrtho; + *proc_glTexCoordPointer = ( DWORD )( pfn_glTexCoordPointer )glTexCoordPointer_h; + *proc_glTexImage2D = ( DWORD )( pfn_glTexImage2D )glTexImage2D; + *proc_glTexParameterf = ( DWORD )( pfn_glTexParameterf )glTexParameterf; + *proc_glTexParameteri = ( DWORD )( pfn_glTexParameteri )glTexParameteri; + + *proc_wglChoosePixelFormat = ( DWORD )( pfn_wglChoosePixelFormat )wrap_wglChoosePixelFormat; + *proc_wglCopyContext = ( DWORD )( pfn_wglCopyContext )wrap_wglCopyContext; + *proc_wglCreateContext = ( DWORD )( pfn_wglCreateContext )wrap_wglCreateContext; + *proc_wglCreateLayerContext = ( DWORD )( pfn_wglCreateLayerContext )wrap_wglCreateLayerContext; + *proc_wglDeleteContext = ( DWORD )( pfn_wglDeleteContext )wrap_wglDeleteContext; + *proc_wglDescribeLayerPlane = ( DWORD )( pfn_wglDescribeLayerPlane )wrap_wglDescribeLayerPlane; + *proc_wglDescribePixelFormat = ( DWORD )( pfn_wglDescribePixelFormat )wrap_wglDescribePixelFormat; + *proc_wglGetCurrentContext = ( DWORD )( pfn_wglGetCurrentContext )wrap_wglGetCurrentContext; + *proc_wglGetCurrentDC = ( DWORD )( pfn_wglGetCurrentDC )wrap_wglGetCurrentDC; + *proc_wglGetLayerPaletteEntries = ( DWORD )( pfn_wglGetLayerPaletteEntries )wrap_wglGetLayerPaletteEntries; + *proc_wglGetPixelFormat = ( DWORD )( pfn_wglGetPixelFormat )wrap_wglGetPixelFormat; + *proc_wglGetProcAddress = ( DWORD )( pfn_wglGetProcAddress )wrap_wglGetProcAddress; + *proc_wglMakeCurrent = ( DWORD )( pfn_wglMakeCurrent )wrap_wglMakeCurrent; + *proc_wglRealizeLayerPalette = ( DWORD )( pfn_wglRealizeLayerPalette )wrap_wglRealizeLayerPalette; + *proc_wglSetLayerPaletteEntries = ( DWORD )( pfn_wglSetLayerPaletteEntries )wrap_wglSetLayerPaletteEntries; + *proc_wglSetPixelFormat = ( DWORD )( pfn_wglSetPixelFormat )wrap_wglSetPixelFormat; + *proc_wglShareLists = ( DWORD )( pfn_wglShareLists )wrap_wglShareLists; + *proc_wglSwapBuffers = ( DWORD )( pfn_wglSwapBuffers )wrap_wglSwapBuffers; + *proc_wglSwapLayerBuffers = ( DWORD )( pfn_wglSwapLayerBuffers )wrap_wglSwapLayerBuffers; + *proc_wglUseFontBitmapsA = ( DWORD )( pfn_wglUseFontBitmapsA )wrap_wglUseFontBitmapsA; + *proc_wglUseFontOutlinesA = ( DWORD )( pfn_wglUseFontOutlinesA )wrap_wglUseFontOutlinesA; + + QFXLog::Instance().Printf( "success\n" ); + return true; +} + +void InitializeExtensions( void ) +{ + // clear extensions + memset( &ext, 0, sizeof( ext ) ); + ext.edgeClampMode = GL_CLAMP; + + // get extension string + const char *pszExtensions = (const char *)qglGetString( GL_EXTENSIONS ); + + if ( !pszExtensions || !strlen( pszExtensions ) ) + return; + + // check for multitexture + if ( strstr( pszExtensions, "GL_ARB_multitexture" ) ) { + QFX_EXT( PFNGLACTIVETEXTUREARBPROC, glActiveTextureARB ); + QFX_EXT( PFNGLACTIVETEXTUREARBPROC, glClientActiveTextureARB ); + QFX_EXT( PFNGLMULTITEXCOORD2FARBPROC, glMultiTexCoord2fARB ); + QFX_EXT( PFNGLMULTITEXCOORD2FVARBPROC, glMultiTexCoord2fvARB ); + qglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &ext.maxActiveTextures ); + if ( ext.maxActiveTextures > 1 ) { + ext.Multitexture = 1; + QFXLog::Instance().Printf( "Using extension: GL_ARB_multitexture (%i TMU)\n", ext.maxActiveTextures ); + } + } + + // check for rectangle textures + if ( strstr( pszExtensions, "GL_ARB_texture_rectangle" ) ) { + ext.RectangleTexture = 1; + QFXLog::Instance().Printf( "Using extension: GL_ARB_texture_rectangle\n" ); + } + else if ( strstr( pszExtensions, "GL_NV_texture_rectangle" ) ) { + ext.RectangleTexture = 1; + QFXLog::Instance().Printf( "Using extension: GL_NV_texture_rectangle\n" ); + } + else if ( strstr( pszExtensions, "GL_EXT_texture_rectangle" ) ) { + ext.RectangleTexture = 1; + QFXLog::Instance().Printf( "Using extension: GL_EXT_texture_rectangle\n" ); + } + + // check for depth textures + if ( strstr( pszExtensions, "GL_ARB_depth_texture" ) ) { + ext.DepthTexture = 1; + QFXLog::Instance().Printf( "Using extension: GL_ARB_depth_texture\n" ); + } + else if ( strstr( pszExtensions, "GL_SGIS_depth_texture" ) ) { + ext.DepthTexture = 1; + QFXLog::Instance().Printf( "Using extension: GL_SGIS_depth_texture\n" ); + } + + // check for clamp to edge + if ( strstr( pszExtensions, "GL_EXT_texture_edge_clamp" ) ) { + ext.edgeClampMode = GL_CLAMP_TO_EDGE; + QFXLog::Instance().Printf( "Using extension: GL_EXT_texture_edge_clamp\n" ); + } + + // check for anisotropic filtering + if ( strstr( pszExtensions, "GL_EXT_texture_filter_anisotropic" ) ) { + qglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &ext.maxAnisotropy); + QFXLog::Instance().Printf( "Using extension: GL_EXT_texture_filter_anisotropic (max %i)\n", ext.maxAnisotropy ); + } + + // check for multisample filter hint + if ( strstr( pszExtensions, "GL_NV_multisample_filter_hint" ) ) { + ext.MultisampleHint = 1; + QFXLog::Instance().Printf( "Using extension: GL_NV_multisample_filter_hint\n" ); + } + + // check for FBO + if ( strstr( pszExtensions, "GL_ARB_framebuffer_object" ) ) + { + QFX_EXT( PFNGLBINDFRAMEBUFFERPROC, glBindFramebuffer ); + QFX_EXT( PFNGLCHECKFRAMEBUFFERSTATUSPROC, glCheckFramebufferStatus ); + QFX_EXT( PFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffers ); + QFX_EXT( PFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2D ); + QFX_EXT( PFNGLFRAMEBUFFERTEXTUREPROC, glFramebufferTexture ); + QFX_EXT( PFNGLGENFRAMEBUFFERSPROC, glGenFramebuffers ); + QFX_EXT( PFNGLGENERATEMIPMAPPROC, glGenerateMipmap ); + ext.FBO = 1; + QFXLog::Instance().Printf( "Using extension: GL_ARB_framebuffer_object\n" ); + } + if ( strstr( pszExtensions, "GL_EXT_framebuffer_object" ) ) + { + QFX_EXT( PFNGLBINDFRAMEBUFFERPROC, glBindFramebufferEXT ); + QFX_EXT( PFNGLCHECKFRAMEBUFFERSTATUSPROC, glCheckFramebufferStatusEXT ); + QFX_EXT( PFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffersEXT ); + QFX_EXT( PFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2DEXT ); + QFX_EXT( PFNGLFRAMEBUFFERTEXTUREPROC, glFramebufferTextureEXT ); + QFX_EXT( PFNGLGENFRAMEBUFFERSPROC, glGenFramebuffersEXT ); + QFX_EXT( PFNGLGENERATEMIPMAPPROC, glGenerateMipmapEXT ); + ext.FBO = 1; + QFXLog::Instance().Printf( "Using extension: GL_EXT_framebuffer_object\n" ); + } + + // check for shader objects + if ( strstr( pszExtensions, "GL_ARB_shader_objects" ) && + strstr( pszExtensions, "GL_ARB_shading_language_100" ) ) { + QFX_EXT( PFNGLGETHANDLEARBPROC, glGetHandleARB ); + QFX_EXT( PFNGLDELETEOBJECTARBPROC, glDeleteObjectARB ); + QFX_EXT( PFNGLDETACHOBJECTARBPROC, glDetachObjectARB ); + QFX_EXT( PFNGLCREATESHADEROBJECTARBPROC, glCreateShaderObjectARB ); + //qglCreateShaderObjectARB = ( PFNGLCREATESHADEROBJECTARBPROC )GetProcAddress( hOpenGLDll, "glCreateShader" ); + QFX_EXT( PFNGLSHADERSOURCEARBPROC, glShaderSourceARB ); + QFX_EXT( PFNGLCOMPILESHADERARBPROC, glCompileShaderARB ); + QFX_EXT( PFNGLCREATEPROGRAMOBJECTARBPROC, glCreateProgramObjectARB ); + QFX_EXT( PFNGLATTACHOBJECTARBPROC, glAttachObjectARB ); + QFX_EXT( PFNGLLINKPROGRAMARBPROC, glLinkProgramARB ); + QFX_EXT( PFNGLUSEPROGRAMOBJECTARBPROC, glUseProgramObjectARB ); + QFX_EXT( PFNGLVALIDATEPROGRAMARBPROC, glValidateProgramARB ); + QFX_EXT( PFNGLGETUNIFORMLOCATIONARBPROC, glGetUniformLocationARB ); + QFX_EXT( PFNGLUNIFORM4FARBPROC, glUniform4fARB ); + QFX_EXT( PFNGLUNIFORM4FVARBPROC, glUniform4fvARB ); + QFX_EXT( PFNGLUNIFORM1IARBPROC, glUniform1iARB ); + QFX_EXT( PFNGLGETINFOLOGARBPROC, glGetInfoLogARB ); + QFX_EXT( PFNGLGETOBJECTPARAMETERIVARBPROC, glGetObjectParameterivARB ); + QFX_EXT( PFNGLGETATTACHEDOBJECTSARBPROC, glGetAttachedObjectsARB ); + QFXLog::Instance().Printf( "Using extension: GL_ARB_shader_objects\n" ); + QFXLog::Instance().Printf( "Using extension: GL_ARB_shading_language_100\n" ); + + if ( strstr( pszExtensions, "GL_ARB_vertex_shader" ) ) { + QFXLog::Instance().Printf( "Using extension: GL_ARB_vertex_shader\n" ); + ext.VertexShader = 1; + } + if ( strstr( pszExtensions, "GL_ARB_fragment_shader" ) ) { + QFXLog::Instance().Printf( "Using extension: GL_ARB_fragment_shader\n" ); + ext.FragmentShader = 1; + } + } + + cgi.Printf( "pszExtentions = %s\n", pszExtensions ); +} + +void CheckInit( void ) +{ + if ( !hOpenGLDll && !bInitError ) { + Initialize(); + } +} + +void Shutdown( void ) +{ + if ( hOpenGLDll ) + { + hOpenGLDll = NULL; + + *proc_glDepthFunc = proc_glDepthFunc_f; + *proc_glDepthRange = proc_glDepthRange_f; + *proc_glDrawElements = proc_glDrawElements_f; + *proc_glEnable = proc_glEnable_f; + *proc_glFrustum = proc_glFrustum_f; + *proc_glGetString = proc_glGetString_f; + *proc_glLoadMatrixd = proc_glLoadMatrixd_f; + *proc_glLoadMatrixf = proc_glLoadMatrixf_f; + *proc_glMatrixMode = proc_glMatrixMode_f; + *proc_glOrtho = proc_glOrtho_f; + *proc_glTexCoordPointer = proc_glTexCoordPointer_f; + *proc_glTexImage2D = proc_glTexImage2D_f; + *proc_glTexParameterf = proc_glTexParameterf_f; + *proc_glTexParameteri = proc_glTexParameteri_f; + + *proc_wglChoosePixelFormat = proc_wglChoosePixelFormat_f; + *proc_wglCopyContext = proc_wglCopyContext_f; + *proc_wglCreateContext = proc_wglCreateContext_f; + *proc_wglCreateLayerContext = proc_wglCreateLayerContext_f; + *proc_wglDeleteContext = proc_wglDeleteContext_f; + *proc_wglDescribeLayerPlane = proc_wglDescribeLayerPlane_f; + *proc_wglDescribePixelFormat = proc_wglDescribePixelFormat_f; + *proc_wglGetCurrentContext = proc_wglGetCurrentContext_f; + *proc_wglGetCurrentDC = proc_wglGetCurrentDC_f; + *proc_wglGetLayerPaletteEntries = proc_wglGetLayerPaletteEntries_f; + *proc_wglGetPixelFormat = proc_wglGetPixelFormat_f; + *proc_wglGetProcAddress = proc_wglGetProcAddress_f; + *proc_wglMakeCurrent = proc_wglMakeCurrent_f; + *proc_wglRealizeLayerPalette = proc_wglRealizeLayerPalette_f; + *proc_wglSetLayerPaletteEntries = proc_wglSetLayerPaletteEntries_f; + *proc_wglSetPixelFormat = proc_wglSetPixelFormat_f; + *proc_wglShareLists = proc_wglShareLists_f; + *proc_wglSwapBuffers = proc_wglSwapBuffers_f; + *proc_wglSwapLayerBuffers = proc_wglSwapLayerBuffers_f; + *proc_wglUseFontBitmapsA = proc_wglUseFontBitmapsA_f; + *proc_wglUseFontOutlinesA = proc_wglUseFontOutlinesA_f; + } +} +} + +void WINAPI glAccum( GLenum op, GLfloat value ) { gl::qglAccum( op, value ); } +void WINAPI glAlphaFunc( GLenum func, GLclampf ref ) { gl::qglAlphaFunc( func, ref ); } +GLboolean WINAPI glAreTexturesResident( GLsizei n, const GLuint *textures, GLboolean *residences ) { return gl::qglAreTexturesResident( n, textures, residences ); } +void WINAPI glArrayElement( GLint i ) { gl::qglArrayElement( i ); } +void WINAPI glBegin( GLenum mode ) { gl::qglBegin( mode ); } +void WINAPI glBindTexture( GLenum target, GLuint texture ) { gl::qglBindTexture( target, texture ); } +void WINAPI glBitmap( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap ) { gl::qglBitmap( width, height, xorig, yorig, xmove, ymove, bitmap ); } +void WINAPI glBlendFunc( GLenum sfactor, GLenum dfactor ) { gl::qglBlendFunc( sfactor, dfactor ); } +void WINAPI glCallList( GLuint list ) { gl::qglCallList( list ); } +void WINAPI glCallLists( GLsizei n, GLenum type, const GLvoid *lists ) { gl::qglCallLists( n, type, lists ); } +void WINAPI glClear( GLbitfield mask ) { gl::qglClear( mask ); } +void WINAPI glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) { gl::qglClearAccum( red, green, blue, alpha ); } +void WINAPI glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) { gl::qglClearColor( red, green, blue, alpha ); } +void WINAPI glClearDepth( GLclampd depth ) { gl::qglClearDepth( depth ); } +void WINAPI glClearIndex( GLfloat c ) { gl::qglClearIndex( c ); } +void WINAPI glClearStencil( GLint s ) { gl::qglClearStencil( s ); } +void WINAPI glClipPlane( GLenum plane, const GLdouble *equation ) { gl::qglClipPlane( plane, equation ); } +void WINAPI glColor3b( GLbyte red, GLbyte green, GLbyte blue ) { gl::qglColor3b( red, green, blue ); } +void WINAPI glColor3bv( const GLbyte *v ) { gl::qglColor3bv( v ); } +void WINAPI glColor3d( GLdouble red, GLdouble green, GLdouble blue ) { gl::qglColor3d( red, green, blue ); } +void WINAPI glColor3dv( const GLdouble *v ) { gl::qglColor3dv( v ); } +void WINAPI glColor3f( GLfloat red, GLfloat green, GLfloat blue ) { gl::qglColor3f( red, green, blue ); } +void WINAPI glColor3fv( const GLfloat *v ) { gl::qglColor3fv( v ); } +void WINAPI glColor3i( GLint red, GLint green, GLint blue ) { gl::qglColor3i( red, green, blue ); } +void WINAPI glColor3iv( const GLint *v ) { gl::qglColor3iv( v ); } +void WINAPI glColor3s( GLshort red, GLshort green, GLshort blue ) { gl::qglColor3s( red, green, blue ); } +void WINAPI glColor3sv( const GLshort *v ) { gl::qglColor3sv( v ); } +void WINAPI glColor3ub( GLubyte red, GLubyte green, GLubyte blue ) { gl::qglColor3ub( red, green, blue ); } +void WINAPI glColor3ubv( const GLubyte *v ) { gl::qglColor3ubv( v ); } +void WINAPI glColor3ui( GLuint red, GLuint green, GLuint blue ) { gl::qglColor3ui( red, green, blue ); } +void WINAPI glColor3uiv( const GLuint *v ) { gl::qglColor3uiv( v ); } +void WINAPI glColor3us( GLushort red, GLushort green, GLushort blue ) { gl::qglColor3us( red, green, blue ); } +void WINAPI glColor3usv( const GLushort *v ) { gl::qglColor3usv( v ); } +void WINAPI glColor4b( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ) { gl::qglColor4b( red, green, blue, alpha ); } +void WINAPI glColor4bv( const GLbyte *v ) { gl::qglColor4bv( v ); } +void WINAPI glColor4d( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ) { gl::qglColor4d( red, green, blue, alpha ); } +void WINAPI glColor4dv( const GLdouble *v ) { gl::qglColor4dv( v ); } +void WINAPI glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) { gl::qglColor4f( red, green, blue, alpha ); } +void WINAPI glColor4fv( const GLfloat *v ) { gl::qglColor4fv( v ); } +void WINAPI glColor4i( GLint red, GLint green, GLint blue, GLint alpha ) { gl::qglColor4i( red, green, blue, alpha ); } +void WINAPI glColor4iv( const GLint *v ) { gl::qglColor4iv( v ); } +void WINAPI glColor4s( GLshort red, GLshort green, GLshort blue, GLshort alpha ) { gl::qglColor4s( red, green, blue, alpha ); } +void WINAPI glColor4sv( const GLshort *v ) { gl::qglColor4sv( v ); } +void WINAPI glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) { gl::qglColor4ub( red, green, blue, alpha ); } +void WINAPI glColor4ubv( const GLubyte *v ) { gl::qglColor4ubv( v ); } +void WINAPI glColor4ui( GLuint red, GLuint green, GLuint blue, GLuint alpha ) { gl::qglColor4ui( red, green, blue, alpha ); } +void WINAPI glColor4uiv( const GLuint *v ) { gl::qglColor4uiv( v ); } +void WINAPI glColor4us( GLushort red, GLushort green, GLushort blue, GLushort alpha ) { gl::qglColor4us( red, green, blue, alpha ); } +void WINAPI glColor4usv( const GLushort *v ) { gl::qglColor4usv( v ); } +void WINAPI glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ) { gl::qglColorMask( red, green, blue, alpha ); } +void WINAPI glColorMaterial( GLenum face, GLenum mode ) { gl::qglColorMaterial( face, mode ); } +void WINAPI glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) { gl::qglColorPointer( size, type, stride, pointer ); } +void WINAPI glCopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type ) { gl::qglCopyPixels( x, y, width, height, type ); } +void WINAPI glCopyTexImage1D( GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border ) { gl::qglCopyTexImage1D( target, level, internalFormat, x, y, width, border ); } +void WINAPI glCopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ) { gl::qglCopyTexImage2D( target, level, internalFormat, x, y, width, height, border ); } +void WINAPI glCopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ) { gl::qglCopyTexSubImage1D( target, level, xoffset, x, y, width ); } +void WINAPI glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ) { gl::qglCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height ); } +void WINAPI glCullFace( GLenum mode ) { gl::qglCullFace( mode ); } +void WINAPI glDeleteLists( GLuint list, GLsizei range ) { gl::qglDeleteLists( list, range ); } +void WINAPI glDeleteTextures( GLsizei n, const GLuint *textures ) { gl::qglDeleteTextures( n, textures ); } +void WINAPI glDepthMask( GLboolean flag ) { gl::qglDepthMask( flag ); } +void WINAPI glDisable( GLenum cap ) { gl::qglDisable( cap ); } +void WINAPI glDisableClientState( GLenum array ) { gl::qglDisableClientState( array ); } +void WINAPI glDrawArrays( GLenum mode, GLint first, GLsizei count ) { gl::qglDrawArrays( mode, first, count ); } +void WINAPI glDrawBuffer( GLenum mode ) { gl::qglDrawBuffer( mode ); } +void WINAPI glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ) { gl::qglDrawElements( mode, count, type, indices ); } +void WINAPI glDrawPixels( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ) { gl::qglDrawPixels( width, height, format, type, pixels ); } +void WINAPI glEdgeFlag( GLboolean flag ) { gl::qglEdgeFlag( flag ); } +void WINAPI glEdgeFlagPointer( GLsizei stride, const GLvoid *pointer ) { gl::qglEdgeFlagPointer( stride, pointer ); } +void WINAPI glEdgeFlagv( const GLboolean *flag ) { gl::qglEdgeFlagv( flag ); } +void WINAPI glEnableClientState( GLenum array ) { gl::qglEnableClientState( array ); } +void WINAPI glEnd( void ) { gl::qglEnd(); } +void WINAPI glEndList( void ) { gl::qglEndList(); } +void WINAPI glEvalCoord1d( GLdouble u ) { gl::qglEvalCoord1d( u ); } +void WINAPI glEvalCoord1dv( const GLdouble *u ) { gl::qglEvalCoord1dv( u ); } +void WINAPI glEvalCoord1f( GLfloat u ) { gl::qglEvalCoord1f( u ); } +void WINAPI glEvalCoord1fv( const GLfloat *u ) { gl::qglEvalCoord1fv( u ); } +void WINAPI glEvalCoord2d( GLdouble u, GLdouble v ) { gl::qglEvalCoord2d( u, v ); } +void WINAPI glEvalCoord2dv( const GLdouble *u ) { gl::qglEvalCoord2dv( u ); } +void WINAPI glEvalCoord2f( GLfloat u, GLfloat v ) { gl::qglEvalCoord2f( u, v ); } +void WINAPI glEvalCoord2fv( const GLfloat *u ) { gl::qglEvalCoord2fv( u ); } +void WINAPI glEvalMesh1( GLenum mode, GLint i1, GLint i2 ) { gl::qglEvalMesh1( mode, i1, i2 ); } +void WINAPI glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) { gl::qglEvalMesh2( mode, i1, i2, j1, j2 ); } +void WINAPI glEvalPoint1( GLint i ) { gl::qglEvalPoint1( i ); } +void WINAPI glEvalPoint2( GLint i, GLint j ) { gl::qglEvalPoint2( i, j ); } +void WINAPI glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ) { gl::qglFeedbackBuffer( size, type, buffer ); } +void WINAPI glFinish( void ) { gl::qglFinish(); } +void WINAPI glFlush( void ) { gl::qglFlush(); } +void WINAPI glFogf( GLenum pname, GLfloat param ) { gl::qglFogf( pname, param ); } +void WINAPI glFogfv( GLenum pname, const GLfloat *params ) { gl::qglFogfv( pname, params ); } +void WINAPI glFogi( GLenum pname, GLint param ) { gl::qglFogi( pname, param ); } +void WINAPI glFogiv( GLenum pname, const GLint *params ) { gl::qglFogiv( pname, params ); } +void WINAPI glFrontFace( GLenum mode ) { gl::qglFrontFace( mode ); } +GLuint WINAPI glGenLists( GLsizei range ) { return gl::qglGenLists( range ); } +void WINAPI glGenTextures( GLsizei n, GLuint *textures ) { gl::qglGenTextures( n, textures ); } +void WINAPI glGetBooleanv( GLenum pname, GLboolean *params ) { gl::qglGetBooleanv( pname, params ); } +void WINAPI glGetClipPlane( GLenum plane, GLdouble *equation ) { gl::qglGetClipPlane( plane, equation ); } +void WINAPI glGetDoublev( GLenum pname, GLdouble *params ) { gl::qglGetDoublev( pname, params ); } +GLenum WINAPI glGetError( void ) { return gl::qglGetError(); } +void WINAPI glGetFloatv( GLenum pname, GLfloat *params ) { gl::qglGetFloatv( pname, params ); } +void WINAPI glGetIntegerv( GLenum pname, GLint *params ) { gl::qglGetIntegerv( pname, params ); } +void WINAPI glGetLightfv( GLenum light, GLenum pname, GLfloat *params ) { gl::qglGetLightfv( light, pname, params ); } +void WINAPI glGetLightiv( GLenum light, GLenum pname, GLint *params ) { gl::qglGetLightiv( light, pname, params ); } +void WINAPI glGetMapdv( GLenum target, GLenum query, GLdouble *v ) { gl::qglGetMapdv( target, query, v ); } +void WINAPI glGetMapfv( GLenum target, GLenum query, GLfloat *v ) { gl::qglGetMapfv( target, query, v ); } +void WINAPI glGetMapiv( GLenum target, GLenum query, GLint *v ) { gl::qglGetMapiv( target, query, v ); } +void WINAPI glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ) { gl::qglGetMaterialfv( face, pname, params ); } +void WINAPI glGetMaterialiv( GLenum face, GLenum pname, GLint *params ) { gl::qglGetMaterialiv( face, pname, params ); } +void WINAPI glGetPixelMapfv( GLenum map, GLfloat *values ) { gl::qglGetPixelMapfv( map, values ); } +void WINAPI glGetPixelMapuiv( GLenum map, GLuint *values ) { gl::qglGetPixelMapuiv( map, values ); } +void WINAPI glGetPixelMapusv( GLenum map, GLushort *values ) { gl::qglGetPixelMapusv( map, values ); } +void WINAPI glGetPointerv( GLenum pname, GLvoid* *params ) { gl::qglGetPointerv( pname, params ); } +void WINAPI glGetPolygonStipple( GLubyte *mask ) { gl::qglGetPolygonStipple( mask ); } +void WINAPI glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) { gl::qglGetTexEnvfv( target, pname, params ); } +void WINAPI glGetTexEnviv( GLenum target, GLenum pname, GLint *params ) { gl::qglGetTexEnviv( target, pname, params ); } +void WINAPI glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) { gl::qglGetTexGendv( coord, pname, params ); } +void WINAPI glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) { gl::qglGetTexGenfv( coord, pname, params ); } +void WINAPI glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ) { gl::qglGetTexGeniv( coord, pname, params ); } +void WINAPI glGetTexImage( GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels ) { gl::qglGetTexImage( target, level, format, type, pixels ); } +void WINAPI glGetTexLevelParameterfv( GLenum target, GLint level, GLenum pname, GLfloat *params ) { gl::qglGetTexLevelParameterfv( target, level, pname, params ); } +void WINAPI glGetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ) { gl::qglGetTexLevelParameteriv( target, level, pname, params ); } +void WINAPI glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) { gl::qglGetTexParameterfv( target, pname, params ); } +void WINAPI glGetTexParameteriv( GLenum target, GLenum pname, GLint *params ) { gl::qglGetTexParameteriv( target, pname, params ); } +void WINAPI glHint( GLenum target, GLenum mode ) { gl::qglHint( target, mode ); } +void WINAPI glIndexMask( GLuint mask ) { gl::qglIndexMask( mask ); } +void WINAPI glIndexPointer( GLenum type, GLsizei stride, const GLvoid *pointer ) { gl::qglIndexPointer( type, stride, pointer ); } +void WINAPI glIndexd( GLdouble c ) { gl::qglIndexd( c ); } +void WINAPI glIndexdv( const GLdouble *c ) { gl::qglIndexdv( c ); } +void WINAPI glIndexf( GLfloat c ) { gl::qglIndexf( c ); } +void WINAPI glIndexfv( const GLfloat *c ) { gl::qglIndexfv( c ); } +void WINAPI glIndexi( GLint c ) { gl::qglIndexi( c ); } +void WINAPI glIndexiv( const GLint *c ) { gl::qglIndexiv( c ); } +void WINAPI glIndexs( GLshort c ) { gl::qglIndexs( c ); } +void WINAPI glIndexsv( const GLshort *c ) { gl::qglIndexsv( c ); } +void WINAPI glIndexub( GLubyte c ) { gl::qglIndexub( c ); } +void WINAPI glIndexubv( const GLubyte *c ) { gl::qglIndexubv( c ); } +void WINAPI glInitNames( void ) { gl::qglInitNames(); } +void WINAPI glInterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer ) { gl::qglInterleavedArrays( format, stride, pointer ); } +GLboolean WINAPI glIsEnabled( GLenum cap ) { return gl::qglIsEnabled( cap ); } +GLboolean WINAPI glIsList( GLuint list ) { return gl::qglIsList( list ); } +GLboolean WINAPI glIsTexture( GLuint texture ) { return gl::qglIsTexture( texture ); } +void WINAPI glLightModelf( GLenum pname, GLfloat param ) { gl::qglLightModelf( pname, param ); } +void WINAPI glLightModelfv( GLenum pname, const GLfloat *params ) { gl::qglLightModelfv( pname, params ); } +void WINAPI glLightModeli( GLenum pname, GLint param ) { gl::qglLightModeli( pname, param ); } +void WINAPI glLightModeliv( GLenum pname, const GLint *params ) { gl::qglLightModeliv( pname, params ); } +void WINAPI glLightf( GLenum light, GLenum pname, GLfloat param ) { gl::qglLightf( light, pname, param ); } +void WINAPI glLightfv( GLenum light, GLenum pname, const GLfloat *params ) { gl::qglLightfv( light, pname, params ); } +void WINAPI glLighti( GLenum light, GLenum pname, GLint param ) { gl::qglLighti( light, pname, param ); } +void WINAPI glLightiv( GLenum light, GLenum pname, const GLint *params ) { gl::qglLightiv( light, pname, params ); } +void WINAPI glLineStipple( GLint factor, GLushort pattern ) { gl::qglLineStipple( factor, pattern ); } +void WINAPI glLineWidth( GLfloat width ) { gl::qglLineWidth( width ); } +void WINAPI glListBase( GLuint base ) { gl::qglListBase( base ); } +void WINAPI glLoadIdentity( void ) { gl::qglLoadIdentity(); } +void WINAPI glLoadName( GLuint name ) { gl::qglLoadName( name ); } +void WINAPI glLogicOp( GLenum opcode ) { gl::qglLogicOp( opcode ); } +void WINAPI glMap1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points ) { gl::qglMap1d( target, u1, u2, stride, order, points ); } +void WINAPI glMap1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points ) { gl::qglMap1f( target, u1, u2, stride, order, points ); } +void WINAPI glMap2d( GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points ) { gl::qglMap2d( target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points ); } +void WINAPI glMap2f( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points ) { gl::qglMap2f( target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points ); } +void WINAPI glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) { gl::qglMapGrid1d( un, u1, u2 ); } +void WINAPI glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) { gl::qglMapGrid1f( un, u1, u2 ); } +void WINAPI glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2 ) { gl::qglMapGrid2d( un, u1, u2, vn, v1, v2 ); } +void WINAPI glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2 ) { gl::qglMapGrid2f( un, u1, u2, vn, v1, v2 ); } +void WINAPI glMaterialf( GLenum face, GLenum pname, GLfloat param ) { gl::qglMaterialf( face, pname, param ); } +void WINAPI glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ) { gl::qglMaterialfv( face, pname, params ); } +void WINAPI glMateriali( GLenum face, GLenum pname, GLint param ) { gl::qglMateriali( face, pname, param ); } +void WINAPI glMaterialiv( GLenum face, GLenum pname, const GLint *params ) { gl::qglMaterialiv( face, pname, params ); } +void WINAPI glMultMatrixd( const GLdouble *m ) { gl::qglMultMatrixd( m ); } +void WINAPI glMultMatrixf( const GLfloat *m ) { gl::qglMultMatrixf( m ); } +void WINAPI glNewList( GLuint list, GLenum mode ) { gl::qglNewList( list, mode ); } +void WINAPI glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ) { gl::qglNormal3b( nx, ny, nz ); } +void WINAPI glNormal3bv( const GLbyte *v ) { gl::qglNormal3bv( v ); } +void WINAPI glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ) { gl::qglNormal3d( nx, ny, nz ); } +void WINAPI glNormal3dv( const GLdouble *v ) { gl::qglNormal3dv( v ); } +void WINAPI glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ) { gl::qglNormal3f( nx, ny, nz ); } +void WINAPI glNormal3fv( const GLfloat *v ) { gl::qglNormal3fv( v ); } +void WINAPI glNormal3i( GLint nx, GLint ny, GLint nz ) { gl::qglNormal3i( nx, ny, nz ); } +void WINAPI glNormal3iv( const GLint *v ) { gl::qglNormal3iv( v ); } +void WINAPI glNormal3s( GLshort nx, GLshort ny, GLshort nz ) { gl::qglNormal3s( nx, ny, nz ); } +void WINAPI glNormal3sv( const GLshort *v ) { gl::qglNormal3sv( v ); } +void WINAPI glNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer ) { gl::qglNormalPointer( type, stride, pointer ); } +void WINAPI glPassThrough( GLfloat token ) { gl::qglPassThrough( token ); } +void WINAPI glPixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) { gl::qglPixelMapfv( map, mapsize, values ); } +void WINAPI glPixelMapuiv( GLenum map, GLsizei mapsize, const GLuint *values ) { gl::qglPixelMapuiv( map, mapsize, values ); } +void WINAPI glPixelMapusv( GLenum map, GLsizei mapsize, const GLushort *values ) { gl::qglPixelMapusv( map, mapsize, values ); } +void WINAPI glPixelStoref( GLenum pname, GLfloat param ) { gl::qglPixelStoref( pname, param ); } +void WINAPI glPixelStorei( GLenum pname, GLint param ) { gl::qglPixelStorei( pname, param ); } +void WINAPI glPixelTransferf( GLenum pname, GLfloat param ) { gl::qglPixelTransferf( pname, param ); } +void WINAPI glPixelTransferi( GLenum pname, GLint param ) { gl::qglPixelTransferi( pname, param ); } +void WINAPI glPixelZoom( GLfloat xfactor, GLfloat yfactor ) { gl::qglPixelZoom( xfactor, yfactor ); } +void WINAPI glPointSize( GLfloat size ) { gl::qglPointSize( size ); } +void WINAPI glPolygonMode( GLenum face, GLenum mode ) { gl::qglPolygonMode( face, mode ); } +void WINAPI glPolygonOffset( GLfloat factor, GLfloat units ) { gl::qglPolygonOffset( factor, units ); } +void WINAPI glPolygonStipple( const GLubyte *mask ) { gl::qglPolygonStipple( mask ); } +void WINAPI glPopAttrib( void ) { gl::qglPopAttrib(); } +void WINAPI glPopClientAttrib( void ) { gl::qglPopClientAttrib(); } +void WINAPI glPopMatrix( void ) { gl::qglPopMatrix(); } +void WINAPI glPopName( void ) { gl::qglPopName(); } +void WINAPI glPrioritizeTextures( GLsizei n, const GLuint *textures, const GLclampf *priorities ) { gl::qglPrioritizeTextures( n, textures, priorities ); } +void WINAPI glPushAttrib( GLbitfield mask ) { gl::qglPushAttrib( mask ); } +void WINAPI glPushClientAttrib( GLbitfield mask ) { gl::qglPushClientAttrib( mask ); } +void WINAPI glPushMatrix( void ) { gl::qglPushMatrix(); } +void WINAPI glPushName( GLuint name ) { gl::qglPushName( name ); } +void WINAPI glRasterPos2d( GLdouble x, GLdouble y ) { gl::qglRasterPos2d( x, y ); } +void WINAPI glRasterPos2dv( const GLdouble *v ) { gl::qglRasterPos2dv( v ); } +void WINAPI glRasterPos2f( GLfloat x, GLfloat y ) { gl::qglRasterPos2f( x, y ); } +void WINAPI glRasterPos2fv( const GLfloat *v ) { gl::qglRasterPos2fv( v ); } +void WINAPI glRasterPos2i( GLint x, GLint y ) { gl::qglRasterPos2i( x, y ); } +void WINAPI glRasterPos2iv( const GLint *v ) { gl::qglRasterPos2iv( v ); } +void WINAPI glRasterPos2s( GLshort x, GLshort y ) { gl::qglRasterPos2s( x, y ); } +void WINAPI glRasterPos2sv( const GLshort *v ) { gl::qglRasterPos2sv( v ); } +void WINAPI glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ) { gl::qglRasterPos3d( x, y, z ); } +void WINAPI glRasterPos3dv( const GLdouble *v ) { gl::qglRasterPos3dv( v ); } +void WINAPI glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ) { gl::qglRasterPos3f( x, y, z ); } +void WINAPI glRasterPos3fv( const GLfloat *v ) { gl::qglRasterPos3fv( v ); } +void WINAPI glRasterPos3i( GLint x, GLint y, GLint z ) { gl::qglRasterPos3i( x, y, z ); } +void WINAPI glRasterPos3iv( const GLint *v ) { gl::qglRasterPos3iv( v ); } +void WINAPI glRasterPos3s( GLshort x, GLshort y, GLshort z ) { gl::qglRasterPos3s( x, y, z ); } +void WINAPI glRasterPos3sv( const GLshort *v ) { gl::qglRasterPos3sv( v ); } +void WINAPI glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ) { gl::qglRasterPos4d( x, y, z, w ); } +void WINAPI glRasterPos4dv( const GLdouble *v ) { gl::qglRasterPos4dv( v ); } +void WINAPI glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { gl::qglRasterPos4f( x, y, z, w ); } +void WINAPI glRasterPos4fv( const GLfloat *v ) { gl::qglRasterPos4fv( v ); } +void WINAPI glRasterPos4i( GLint x, GLint y, GLint z, GLint w ) { gl::qglRasterPos4i( x, y, z, w ); } +void WINAPI glRasterPos4iv( const GLint *v ) { gl::qglRasterPos4iv( v ); } +void WINAPI glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ) { gl::qglRasterPos4s( x, y, z, w ); } +void WINAPI glRasterPos4sv( const GLshort *v ) { gl::qglRasterPos4sv( v ); } +void WINAPI glReadBuffer( GLenum mode ) { gl::qglReadBuffer( mode ); } +void WINAPI glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ) { gl::qglReadPixels( x, y, width, height, format, type, pixels ); } +void WINAPI glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ) { gl::qglRectd( x1, y1, x2, y2 ); } +void WINAPI glRectdv( const GLdouble *v1, const GLdouble *v2 ) { gl::qglRectdv( v1, v2 ); } +void WINAPI glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) { gl::qglRectf( x1, y1, x2, y2 ); } +void WINAPI glRectfv( const GLfloat *v1, const GLfloat *v2 ) { gl::qglRectfv( v1, v2 ); } +void WINAPI glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ) { gl::qglRecti( x1, y1, x2, y2 ); } +void WINAPI glRectiv( const GLint *v1, const GLint *v2 ) { gl::qglRectiv( v1, v2 ); } +void WINAPI glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ) { gl::qglRects( x1, y1, x2, y2 ); } +void WINAPI glRectsv( const GLshort *v1, const GLshort *v2 ) { gl::qglRectsv( v1, v2 ); } +GLint WINAPI glRenderMode( GLenum mode ) { return gl::qglRenderMode( mode ); } +void WINAPI glRotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) { gl::qglRotated( angle, x, y, z ); } +void WINAPI glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) { gl::qglRotatef( angle, x, y, z ); } +void WINAPI glScaled( GLdouble x, GLdouble y, GLdouble z ) { gl::qglScaled( x, y, z ); } +void WINAPI glScalef( GLfloat x, GLfloat y, GLfloat z ) { gl::qglScalef( x, y, z ); } +void WINAPI glScissor( GLint x, GLint y, GLsizei width, GLsizei height ) { gl::qglScissor( x, y, width, height ); } +void WINAPI glSelectBuffer( GLsizei size, GLuint *buffer ) { gl::qglSelectBuffer( size, buffer ); } +void WINAPI glShadeModel( GLenum mode ) { gl::qglShadeModel( mode ); } +void WINAPI glStencilFunc( GLenum func, GLint ref, GLuint mask ) { gl::qglStencilFunc( func, ref, mask ); } +void WINAPI glStencilMask( GLuint mask ) { gl::qglStencilMask( mask ); } +void WINAPI glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ) { gl::qglStencilOp( fail, zfail, zpass ); } +void WINAPI glTexCoord1d( GLdouble s ) { gl::qglTexCoord1d( s ); } +void WINAPI glTexCoord1dv( const GLdouble *v ) { gl::qglTexCoord1dv( v ); } +void WINAPI glTexCoord1f( GLfloat s ) { gl::qglTexCoord1f( s ); } +void WINAPI glTexCoord1fv( const GLfloat *v ) { gl::qglTexCoord1fv( v ); } +void WINAPI glTexCoord1i( GLint s ) { gl::qglTexCoord1i( s ); } +void WINAPI glTexCoord1iv( const GLint *v ) { gl::qglTexCoord1iv( v ); } +void WINAPI glTexCoord1s( GLshort s ) { gl::qglTexCoord1s( s ); } +void WINAPI glTexCoord1sv( const GLshort *v ) { gl::qglTexCoord1sv( v ); } +void WINAPI glTexCoord2d( GLdouble s, GLdouble t ) { gl::qglTexCoord2d( s, t ); } +void WINAPI glTexCoord2dv( const GLdouble *v ) { gl::qglTexCoord2dv( v ); } +void WINAPI glTexCoord2f( GLfloat s, GLfloat t ) { gl::qglTexCoord2f( s, t ); } +void WINAPI glTexCoord2fv( const GLfloat *v ) { gl::qglTexCoord2fv( v ); } +void WINAPI glTexCoord2i( GLint s, GLint t ) { gl::qglTexCoord2i( s, t ); } +void WINAPI glTexCoord2iv( const GLint *v ) { gl::qglTexCoord2iv( v ); } +void WINAPI glTexCoord2s( GLshort s, GLshort t ) { gl::qglTexCoord2s( s, t ); } +void WINAPI glTexCoord2sv( const GLshort *v ) { gl::qglTexCoord2sv( v ); } +void WINAPI glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ) { gl::qglTexCoord3d( s, t, r ); } +void WINAPI glTexCoord3dv( const GLdouble *v ) { gl::qglTexCoord3dv( v ); } +void WINAPI glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ) { gl::qglTexCoord3f( s, t, r ); } +void WINAPI glTexCoord3fv( const GLfloat *v ) { gl::qglTexCoord3fv( v ); } +void WINAPI glTexCoord3i( GLint s, GLint t, GLint r ) { gl::qglTexCoord3i( s, t, r ); } +void WINAPI glTexCoord3iv( const GLint *v ) { gl::qglTexCoord3iv( v ); } +void WINAPI glTexCoord3s( GLshort s, GLshort t, GLshort r ) { gl::qglTexCoord3s( s, t, r ); } +void WINAPI glTexCoord3sv( const GLshort *v ) { gl::qglTexCoord3sv( v ); } +void WINAPI glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ) { gl::qglTexCoord4d( s, t, r, q ); } +void WINAPI glTexCoord4dv( const GLdouble *v ) { gl::qglTexCoord4dv( v ); } +void WINAPI glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ) { gl::qglTexCoord4f( s, t, r, q ); } +void WINAPI glTexCoord4fv( const GLfloat *v ) { gl::qglTexCoord4fv( v ); } +void WINAPI glTexCoord4i( GLint s, GLint t, GLint r, GLint q ) { gl::qglTexCoord4i( s, t, r, q ); } +void WINAPI glTexCoord4iv( const GLint *v ) { gl::qglTexCoord4iv( v ); } +void WINAPI glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ) { gl::qglTexCoord4s( s, t, r, q ); } +void WINAPI glTexCoord4sv( const GLshort *v ) { gl::qglTexCoord4sv( v ); } +void WINAPI glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) { gl::qglTexCoordPointer( size, type, stride, pointer ); } +void WINAPI glTexEnvf( GLenum target, GLenum pname, GLfloat param ) { gl::qglTexEnvf( target, pname, param ); } +void WINAPI glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ) { gl::qglTexEnvfv( target, pname, params ); } +void WINAPI glTexEnvi( GLenum target, GLenum pname, GLint param ) { gl::qglTexEnvi( target, pname, param ); } +void WINAPI glTexEnviv( GLenum target, GLenum pname, const GLint *params ) { gl::qglTexEnviv( target, pname, params ); } +void WINAPI glTexGend( GLenum coord, GLenum pname, GLdouble param ) { gl::qglTexGend( coord, pname, param ); } +void WINAPI glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ) { gl::qglTexGendv( coord, pname, params ); } +void WINAPI glTexGenf( GLenum coord, GLenum pname, GLfloat param ) { gl::qglTexGenf( coord, pname, param ); } +void WINAPI glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) { gl::qglTexGenfv( coord, pname, params ); } +void WINAPI glTexGeni( GLenum coord, GLenum pname, GLint param ) { gl::qglTexGeni( coord, pname, param ); } +void WINAPI glTexGeniv( GLenum coord, GLenum pname, const GLint *params ) { gl::qglTexGeniv( coord, pname, params ); } +void WINAPI glTexImage1D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels ) { gl::qglTexImage1D( target, level, internalformat, width, border, format, type, pixels ); } +void WINAPI glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) { gl::qglTexParameterfv( target, pname, params ); } +void WINAPI glTexParameteriv( GLenum target, GLenum pname, const GLint *params ) { gl::qglTexParameteriv( target, pname, params ); } +void WINAPI glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels ) { gl::qglTexSubImage1D( target, level, xoffset, width, format, type, pixels ); } +void WINAPI glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ) { gl::qglTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels ); } +void WINAPI glTranslated( GLdouble x, GLdouble y, GLdouble z ) { gl::qglTranslated( x, y, z ); } +void WINAPI glTranslatef( GLfloat x, GLfloat y, GLfloat z ) { gl::qglTranslatef( x, y, z ); } +void WINAPI glVertex2d( GLdouble x, GLdouble y ) { gl::qglVertex2d( x, y ); } +void WINAPI glVertex2dv( const GLdouble *v ) { gl::qglVertex2dv( v ); } +void WINAPI glVertex2f( GLfloat x, GLfloat y ) { gl::qglVertex2f( x, y ); } +void WINAPI glVertex2fv( const GLfloat *v ) { gl::qglVertex2fv( v ); } +void WINAPI glVertex2i( GLint x, GLint y ) { gl::qglVertex2i( x, y ); } +void WINAPI glVertex2iv( const GLint *v ) { gl::qglVertex2iv( v ); } +void WINAPI glVertex2s( GLshort x, GLshort y ) { gl::qglVertex2s( x, y ); } +void WINAPI glVertex2sv( const GLshort *v ) { gl::qglVertex2sv( v ); } +void WINAPI glVertex3d( GLdouble x, GLdouble y, GLdouble z ) { gl::qglVertex3d( x, y, z ); } +void WINAPI glVertex3dv( const GLdouble *v ) { gl::qglVertex3dv( v ); } +void WINAPI glVertex3f( GLfloat x, GLfloat y, GLfloat z ) { gl::qglVertex3f( x, y, z ); } +void WINAPI glVertex3fv( const GLfloat *v ) { gl::qglVertex3fv( v ); } +void WINAPI glVertex3i( GLint x, GLint y, GLint z ) { gl::qglVertex3i( x, y, z ); } +void WINAPI glVertex3iv( const GLint *v ) { gl::qglVertex3iv( v ); } +void WINAPI glVertex3s( GLshort x, GLshort y, GLshort z ) { gl::qglVertex3s( x, y, z ); } +void WINAPI glVertex3sv( const GLshort *v ) { gl::qglVertex3sv( v ); } +void WINAPI glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ) { gl::qglVertex4d( x, y, z, w ); } +void WINAPI glVertex4dv( const GLdouble *v ) { gl::qglVertex4dv( v ); } +void WINAPI glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { gl::qglVertex4f( x, y, z, w ); } +void WINAPI glVertex4fv( const GLfloat *v ) { gl::qglVertex4fv( v ); } +void WINAPI glVertex4i( GLint x, GLint y, GLint z, GLint w ) { gl::qglVertex4i( x, y, z, w ); } +void WINAPI glVertex4iv( const GLint *v ) { gl::qglVertex4iv( v ); } +void WINAPI glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ) { gl::qglVertex4s( x, y, z, w ); } +void WINAPI glVertex4sv( const GLshort *v ) { gl::qglVertex4sv( v ); } +void WINAPI glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) { gl::qglVertexPointer( size, type, stride, pointer ); } +void WINAPI glViewport( GLint x, GLint y, GLsizei width, GLsizei height ) { gl::qglViewport( x, y, width, height ); } +void WINAPI glDebugEntry( DWORD dwArg1, DWORD dwArg2 ) {} diff --git a/code/cgame_hook/renderer/qfx_opengl.h b/code/cgame_hook/renderer/qfx_opengl.h new file mode 100644 index 00000000..c5d5c42c --- /dev/null +++ b/code/cgame_hook/renderer/qfx_opengl.h @@ -0,0 +1,1945 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#ifndef QFX_OPENGL_H +#define QFX_OPENGL_H + +/* + * OpenGL Datatypes + */ +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef void GLvoid; +typedef signed char GLbyte; /* 1-byte signed */ +typedef short GLshort; /* 2-byte signed */ +typedef int GLint; /* 4-byte signed */ +typedef unsigned char GLubyte; /* 1-byte unsigned */ +typedef unsigned short GLushort; /* 2-byte unsigned */ +typedef unsigned int GLuint; /* 4-byte unsigned */ +typedef int GLsizei; /* 4-byte signed */ +typedef float GLfloat; /* single precision float */ +typedef float GLclampf; /* single precision float in [0,1] */ +typedef double GLdouble; /* double precision float */ +typedef double GLclampd; /* double precision float in [0,1] */ +typedef char GLchar; + +/* Version */ +#define GL_VERSION_1_1 1 + +/* AccumOp */ +#define GL_ACCUM 0x0100 +#define GL_LOAD 0x0101 +#define GL_RETURN 0x0102 +#define GL_MULT 0x0103 +#define GL_ADD 0x0104 + +/* AlphaFunction */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 + +/* AttribMask */ +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0x000fffff + +/* BeginMode */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 + +/* BlendingFactorDest */ +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 + +/* BlendingFactorSrc */ +/* GL_ZERO */ +/* GL_ONE */ +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +/* GL_SRC_ALPHA */ +/* GL_ONE_MINUS_SRC_ALPHA */ +/* GL_DST_ALPHA */ +/* GL_ONE_MINUS_DST_ALPHA */ + +/* Boolean */ +#define GL_TRUE 1 +#define GL_FALSE 0 + +/* ClearBufferMask */ +/* GL_COLOR_BUFFER_BIT */ +/* GL_ACCUM_BUFFER_BIT */ +/* GL_STENCIL_BUFFER_BIT */ +/* GL_DEPTH_BUFFER_BIT */ + +/* ClientArrayType */ +/* GL_VERTEX_ARRAY */ +/* GL_NORMAL_ARRAY */ +/* GL_COLOR_ARRAY */ +/* GL_INDEX_ARRAY */ +/* GL_TEXTURE_COORD_ARRAY */ +/* GL_EDGE_FLAG_ARRAY */ + +/* ClipPlaneName */ +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 + +/* ColorMaterialFace */ +/* GL_FRONT */ +/* GL_BACK */ +/* GL_FRONT_AND_BACK */ + +/* ColorMaterialParameter */ +/* GL_AMBIENT */ +/* GL_DIFFUSE */ +/* GL_SPECULAR */ +/* GL_EMISSION */ +/* GL_AMBIENT_AND_DIFFUSE */ + +/* ColorPointerType */ +/* GL_BYTE */ +/* GL_UNSIGNED_BYTE */ +/* GL_SHORT */ +/* GL_UNSIGNED_SHORT */ +/* GL_INT */ +/* GL_UNSIGNED_INT */ +/* GL_FLOAT */ +/* GL_DOUBLE */ + +/* CullFaceMode */ +/* GL_FRONT */ +/* GL_BACK */ +/* GL_FRONT_AND_BACK */ + +/* DataType */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A + +/* DepthFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* DrawBufferMode */ +#define GL_NONE 0 +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C + +/* Enable */ +/* GL_FOG */ +/* GL_LIGHTING */ +/* GL_TEXTURE_1D */ +/* GL_TEXTURE_2D */ +/* GL_LINE_STIPPLE */ +/* GL_POLYGON_STIPPLE */ +/* GL_CULL_FACE */ +/* GL_ALPHA_TEST */ +/* GL_BLEND */ +/* GL_INDEX_LOGIC_OP */ +/* GL_COLOR_LOGIC_OP */ +/* GL_DITHER */ +/* GL_STENCIL_TEST */ +/* GL_DEPTH_TEST */ +/* GL_CLIP_PLANE0 */ +/* GL_CLIP_PLANE1 */ +/* GL_CLIP_PLANE2 */ +/* GL_CLIP_PLANE3 */ +/* GL_CLIP_PLANE4 */ +/* GL_CLIP_PLANE5 */ +/* GL_LIGHT0 */ +/* GL_LIGHT1 */ +/* GL_LIGHT2 */ +/* GL_LIGHT3 */ +/* GL_LIGHT4 */ +/* GL_LIGHT5 */ +/* GL_LIGHT6 */ +/* GL_LIGHT7 */ +/* GL_TEXTURE_GEN_S */ +/* GL_TEXTURE_GEN_T */ +/* GL_TEXTURE_GEN_R */ +/* GL_TEXTURE_GEN_Q */ +/* GL_MAP1_VERTEX_3 */ +/* GL_MAP1_VERTEX_4 */ +/* GL_MAP1_COLOR_4 */ +/* GL_MAP1_INDEX */ +/* GL_MAP1_NORMAL */ +/* GL_MAP1_TEXTURE_COORD_1 */ +/* GL_MAP1_TEXTURE_COORD_2 */ +/* GL_MAP1_TEXTURE_COORD_3 */ +/* GL_MAP1_TEXTURE_COORD_4 */ +/* GL_MAP2_VERTEX_3 */ +/* GL_MAP2_VERTEX_4 */ +/* GL_MAP2_COLOR_4 */ +/* GL_MAP2_INDEX */ +/* GL_MAP2_NORMAL */ +/* GL_MAP2_TEXTURE_COORD_1 */ +/* GL_MAP2_TEXTURE_COORD_2 */ +/* GL_MAP2_TEXTURE_COORD_3 */ +/* GL_MAP2_TEXTURE_COORD_4 */ +/* GL_POINT_SMOOTH */ +/* GL_LINE_SMOOTH */ +/* GL_POLYGON_SMOOTH */ +/* GL_SCISSOR_TEST */ +/* GL_COLOR_MATERIAL */ +/* GL_NORMALIZE */ +/* GL_AUTO_NORMAL */ +/* GL_VERTEX_ARRAY */ +/* GL_NORMAL_ARRAY */ +/* GL_COLOR_ARRAY */ +/* GL_INDEX_ARRAY */ +/* GL_TEXTURE_COORD_ARRAY */ +/* GL_EDGE_FLAG_ARRAY */ +/* GL_POLYGON_OFFSET_POINT */ +/* GL_POLYGON_OFFSET_LINE */ +/* GL_POLYGON_OFFSET_FILL */ + +/* ErrorCode */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 + +/* FeedBackMode */ +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 + +/* FeedBackToken */ +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_LINE_RESET_TOKEN 0x0707 + +/* FogMode */ +/* GL_LINEAR */ +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 + + +/* FogParameter */ +/* GL_FOG_COLOR */ +/* GL_FOG_DENSITY */ +/* GL_FOG_END */ +/* GL_FOG_INDEX */ +/* GL_FOG_MODE */ +/* GL_FOG_START */ + +/* FrontFaceDirection */ +#define GL_CW 0x0900 +#define GL_CCW 0x0901 + +/* GetMapTarget */ +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 + +/* GetPixelMap */ +/* GL_PIXEL_MAP_I_TO_I */ +/* GL_PIXEL_MAP_S_TO_S */ +/* GL_PIXEL_MAP_I_TO_R */ +/* GL_PIXEL_MAP_I_TO_G */ +/* GL_PIXEL_MAP_I_TO_B */ +/* GL_PIXEL_MAP_I_TO_A */ +/* GL_PIXEL_MAP_R_TO_R */ +/* GL_PIXEL_MAP_G_TO_G */ +/* GL_PIXEL_MAP_B_TO_B */ +/* GL_PIXEL_MAP_A_TO_A */ + +/* GetPointerTarget */ +/* GL_VERTEX_ARRAY_POINTER */ +/* GL_NORMAL_ARRAY_POINTER */ +/* GL_COLOR_ARRAY_POINTER */ +/* GL_INDEX_ARRAY_POINTER */ +/* GL_TEXTURE_COORD_ARRAY_POINTER */ +/* GL_EDGE_FLAG_ARRAY_POINTER */ + +/* GetTarget */ +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LIST_MODE 0x0B30 +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_SHADE_MODEL 0x0B54 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_FOG 0x0B60 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_COLOR 0x0B66 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_MATRIX_MODE 0x0BA0 +#define GL_NORMALIZE 0x0BA1 +#define GL_VIEWPORT 0x0BA2 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_FUNC 0x0BC1 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_DITHER 0x0BD0 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND 0x0BE2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_READ_BUFFER 0x0C02 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_INDEX_MODE 0x0C30 +#define GL_RGBA_MODE 0x0C31 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_RENDER_MODE 0x0C40 +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_INDEX_BITS 0x0D51 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 +/* GL_TEXTURE_BINDING_1D */ +/* GL_TEXTURE_BINDING_2D */ +/* GL_VERTEX_ARRAY */ +/* GL_NORMAL_ARRAY */ +/* GL_COLOR_ARRAY */ +/* GL_INDEX_ARRAY */ +/* GL_TEXTURE_COORD_ARRAY */ +/* GL_EDGE_FLAG_ARRAY */ +/* GL_VERTEX_ARRAY_SIZE */ +/* GL_VERTEX_ARRAY_TYPE */ +/* GL_VERTEX_ARRAY_STRIDE */ +/* GL_NORMAL_ARRAY_TYPE */ +/* GL_NORMAL_ARRAY_STRIDE */ +/* GL_COLOR_ARRAY_SIZE */ +/* GL_COLOR_ARRAY_TYPE */ +/* GL_COLOR_ARRAY_STRIDE */ +/* GL_INDEX_ARRAY_TYPE */ +/* GL_INDEX_ARRAY_STRIDE */ +/* GL_TEXTURE_COORD_ARRAY_SIZE */ +/* GL_TEXTURE_COORD_ARRAY_TYPE */ +/* GL_TEXTURE_COORD_ARRAY_STRIDE */ +/* GL_EDGE_FLAG_ARRAY_STRIDE */ +/* GL_POLYGON_OFFSET_FACTOR */ +/* GL_POLYGON_OFFSET_UNITS */ + +/* GetTextureParameter */ +/* GL_TEXTURE_MAG_FILTER */ +/* GL_TEXTURE_MIN_FILTER */ +/* GL_TEXTURE_WRAP_S */ +/* GL_TEXTURE_WRAP_T */ +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_BORDER 0x1005 +/* GL_TEXTURE_RED_SIZE */ +/* GL_TEXTURE_GREEN_SIZE */ +/* GL_TEXTURE_BLUE_SIZE */ +/* GL_TEXTURE_ALPHA_SIZE */ +/* GL_TEXTURE_LUMINANCE_SIZE */ +/* GL_TEXTURE_INTENSITY_SIZE */ +/* GL_TEXTURE_PRIORITY */ +/* GL_TEXTURE_RESIDENT */ + +/* HintMode */ +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* HintTarget */ +/* GL_PERSPECTIVE_CORRECTION_HINT */ +/* GL_POINT_SMOOTH_HINT */ +/* GL_LINE_SMOOTH_HINT */ +/* GL_POLYGON_SMOOTH_HINT */ +/* GL_FOG_HINT */ +/* GL_PHONG_HINT */ + +/* IndexPointerType */ +/* GL_SHORT */ +/* GL_INT */ +/* GL_FLOAT */ +/* GL_DOUBLE */ + +/* LightModelParameter */ +/* GL_LIGHT_MODEL_AMBIENT */ +/* GL_LIGHT_MODEL_LOCAL_VIEWER */ +/* GL_LIGHT_MODEL_TWO_SIDE */ + +/* LightName */ +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 + +/* LightParameter */ +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 + +/* InterleavedArrays */ +/* GL_V2F */ +/* GL_V3F */ +/* GL_C4UB_V2F */ +/* GL_C4UB_V3F */ +/* GL_C3F_V3F */ +/* GL_N3F_V3F */ +/* GL_C4F_N3F_V3F */ +/* GL_T2F_V3F */ +/* GL_T4F_V4F */ +/* GL_T2F_C4UB_V3F */ +/* GL_T2F_C3F_V3F */ +/* GL_T2F_N3F_V3F */ +/* GL_T2F_C4F_N3F_V3F */ +/* GL_T4F_C4F_N3F_V4F */ + +/* ListMode */ +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 + +/* ListNameType */ +/* GL_BYTE */ +/* GL_UNSIGNED_BYTE */ +/* GL_SHORT */ +/* GL_UNSIGNED_SHORT */ +/* GL_INT */ +/* GL_UNSIGNED_INT */ +/* GL_FLOAT */ +/* GL_2_BYTES */ +/* GL_3_BYTES */ +/* GL_4_BYTES */ + +/* LogicOp */ +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F + +/* MapTarget */ +/* GL_MAP1_COLOR_4 */ +/* GL_MAP1_INDEX */ +/* GL_MAP1_NORMAL */ +/* GL_MAP1_TEXTURE_COORD_1 */ +/* GL_MAP1_TEXTURE_COORD_2 */ +/* GL_MAP1_TEXTURE_COORD_3 */ +/* GL_MAP1_TEXTURE_COORD_4 */ +/* GL_MAP1_VERTEX_3 */ +/* GL_MAP1_VERTEX_4 */ +/* GL_MAP2_COLOR_4 */ +/* GL_MAP2_INDEX */ +/* GL_MAP2_NORMAL */ +/* GL_MAP2_TEXTURE_COORD_1 */ +/* GL_MAP2_TEXTURE_COORD_2 */ +/* GL_MAP2_TEXTURE_COORD_3 */ +/* GL_MAP2_TEXTURE_COORD_4 */ +/* GL_MAP2_VERTEX_3 */ +/* GL_MAP2_VERTEX_4 */ + +/* MaterialFace */ +/* GL_FRONT */ +/* GL_BACK */ +/* GL_FRONT_AND_BACK */ + +/* MaterialParameter */ +#define GL_EMISSION 0x1600 +#define GL_SHININESS 0x1601 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +/* GL_AMBIENT */ +/* GL_DIFFUSE */ +/* GL_SPECULAR */ + +/* MatrixMode */ +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +/* MeshMode1 */ +/* GL_POINT */ +/* GL_LINE */ + +/* MeshMode2 */ +/* GL_POINT */ +/* GL_LINE */ +/* GL_FILL */ + +/* NormalPointerType */ +/* GL_BYTE */ +/* GL_SHORT */ +/* GL_INT */ +/* GL_FLOAT */ +/* GL_DOUBLE */ + +/* PixelCopyType */ +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 + +/* PixelFormat */ +#define GL_COLOR_INDEX 0x1900 +#define GL_STENCIL_INDEX 0x1901 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +/* PixelMap */ +/* GL_PIXEL_MAP_I_TO_I */ +/* GL_PIXEL_MAP_S_TO_S */ +/* GL_PIXEL_MAP_I_TO_R */ +/* GL_PIXEL_MAP_I_TO_G */ +/* GL_PIXEL_MAP_I_TO_B */ +/* GL_PIXEL_MAP_I_TO_A */ +/* GL_PIXEL_MAP_R_TO_R */ +/* GL_PIXEL_MAP_G_TO_G */ +/* GL_PIXEL_MAP_B_TO_B */ +/* GL_PIXEL_MAP_A_TO_A */ + +/* PixelStore */ +/* GL_UNPACK_SWAP_BYTES */ +/* GL_UNPACK_LSB_FIRST */ +/* GL_UNPACK_ROW_LENGTH */ +/* GL_UNPACK_SKIP_ROWS */ +/* GL_UNPACK_SKIP_PIXELS */ +/* GL_UNPACK_ALIGNMENT */ +/* GL_PACK_SWAP_BYTES */ +/* GL_PACK_LSB_FIRST */ +/* GL_PACK_ROW_LENGTH */ +/* GL_PACK_SKIP_ROWS */ +/* GL_PACK_SKIP_PIXELS */ +/* GL_PACK_ALIGNMENT */ + +/* PixelTransfer */ +/* GL_MAP_COLOR */ +/* GL_MAP_STENCIL */ +/* GL_INDEX_SHIFT */ +/* GL_INDEX_OFFSET */ +/* GL_RED_SCALE */ +/* GL_RED_BIAS */ +/* GL_GREEN_SCALE */ +/* GL_GREEN_BIAS */ +/* GL_BLUE_SCALE */ +/* GL_BLUE_BIAS */ +/* GL_ALPHA_SCALE */ +/* GL_ALPHA_BIAS */ +/* GL_DEPTH_SCALE */ +/* GL_DEPTH_BIAS */ + +/* PixelType */ +#define GL_BITMAP 0x1A00 +/* GL_BYTE */ +/* GL_UNSIGNED_BYTE */ +/* GL_SHORT */ +/* GL_UNSIGNED_SHORT */ +/* GL_INT */ +/* GL_UNSIGNED_INT */ +/* GL_FLOAT */ + +/* PolygonMode */ +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 + +/* ReadBufferMode */ +/* GL_FRONT_LEFT */ +/* GL_FRONT_RIGHT */ +/* GL_BACK_LEFT */ +/* GL_BACK_RIGHT */ +/* GL_FRONT */ +/* GL_BACK */ +/* GL_LEFT */ +/* GL_RIGHT */ +/* GL_AUX0 */ +/* GL_AUX1 */ +/* GL_AUX2 */ +/* GL_AUX3 */ + +/* RenderingMode */ +#define GL_RENDER 0x1C00 +#define GL_FEEDBACK 0x1C01 +#define GL_SELECT 0x1C02 + +/* ShadingModel */ +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 + + +/* StencilFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* StencilOp */ +/* GL_ZERO */ +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +/* GL_INVERT */ + +/* StringName */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* TextureCoordName */ +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 + +/* TexCoordPointerType */ +/* GL_SHORT */ +/* GL_INT */ +/* GL_FLOAT */ +/* GL_DOUBLE */ + +/* TextureEnvMode */ +#define GL_MODULATE 0x2100 +#define GL_DECAL 0x2101 +/* GL_BLEND */ +/* GL_REPLACE */ + +/* TextureEnvParameter */ +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_ENV_COLOR 0x2201 + +/* TextureEnvTarget */ +#define GL_TEXTURE_ENV 0x2300 + +/* TextureGenMode */ +#define GL_EYE_LINEAR 0x2400 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_SPHERE_MAP 0x2402 + +/* TextureGenParameter */ +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_PLANE 0x2502 + +/* TextureMagFilter */ +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 + +/* TextureMinFilter */ +/* GL_NEAREST */ +/* GL_LINEAR */ +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 + +/* TextureParameterName */ +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +/* GL_TEXTURE_BORDER_COLOR */ +/* GL_TEXTURE_PRIORITY */ + +/* TextureTarget */ +/* GL_TEXTURE_1D */ +/* GL_TEXTURE_2D */ +/* GL_PROXY_TEXTURE_1D */ +/* GL_PROXY_TEXTURE_2D */ + +/* TextureWrapMode */ +#define GL_CLAMP 0x2900 +#define GL_REPEAT 0x2901 + +/* VertexPointerType */ +/* GL_SHORT */ +/* GL_INT */ +/* GL_FLOAT */ +/* GL_DOUBLE */ + +/* ClientAttribMask */ +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff + +/* polygon_offset */ +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 + +/* texture */ +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 + +/* texture_object */ +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 + +/* vertex_array */ +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D + +/* Extensions */ +#define GL_EXT_vertex_array 1 +#define GL_EXT_bgra 1 +#define GL_EXT_paletted_texture 1 +#define GL_WIN_swap_hint 1 +#define GL_WIN_draw_range_elements 1 +// #define GL_WIN_phong_shading 1 +// #define GL_WIN_specular_fog 1 + +/* EXT_vertex_array */ +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#define GL_DOUBLE_EXT GL_DOUBLE + +/* EXT_bgra */ +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 + +/* EXT_paletted_texture */ + +/* These must match the GL_COLOR_TABLE_*_SGI enumerants */ +#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 +#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF + +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 + +/* WIN_draw_range_elements */ +#define GL_MAX_ELEMENTS_VERTICES_WIN 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_WIN 0x80E9 + +/* WIN_phong_shading */ +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB + +/* WIN_specular_fog */ +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC + +/* For compatibility with OpenGL v1.0 */ +#define GL_LOGIC_OP GL_INDEX_LOGIC_OP +#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT + +/* For multisample */ +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_COLOR_BITS_ARB 0x2014 + +#include "glext.h" + +/* + * OpenGL Prototypes + */ +typedef void ( APIENTRY * pfn_glAccum )(GLenum op, GLfloat value); +typedef void ( APIENTRY * pfn_glAlphaFunc )(GLenum func, GLclampf ref); +typedef GLboolean ( APIENTRY * pfn_glAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void ( APIENTRY * pfn_glArrayElement )(GLint i); +typedef void ( APIENTRY * pfn_glBegin )(GLenum mode); +typedef void ( APIENTRY * pfn_glBindTexture )(GLenum target, GLuint texture); +typedef void ( APIENTRY * pfn_glBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); +typedef void ( APIENTRY * pfn_glBlendFunc )(GLenum sfactor, GLenum dfactor); +typedef void ( APIENTRY * pfn_glCallList )(GLuint list); +typedef void ( APIENTRY * pfn_glCallLists )(GLsizei n, GLenum type, const GLvoid *lists); +typedef void ( APIENTRY * pfn_glClear )(GLbitfield mask); +typedef void ( APIENTRY * pfn_glClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void ( APIENTRY * pfn_glClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void ( APIENTRY * pfn_glClearDepth )(GLclampd depth); +typedef void ( APIENTRY * pfn_glClearIndex )(GLfloat c); +typedef void ( APIENTRY * pfn_glClearStencil )(GLint s); +typedef void ( APIENTRY * pfn_glClipPlane )(GLenum plane, const GLdouble *equation); +typedef void ( APIENTRY * pfn_glColor3b )(GLbyte red, GLbyte green, GLbyte blue); +typedef void ( APIENTRY * pfn_glColor3bv )(const GLbyte *v); +typedef void ( APIENTRY * pfn_glColor3d )(GLdouble red, GLdouble green, GLdouble blue); +typedef void ( APIENTRY * pfn_glColor3dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glColor3f )(GLfloat red, GLfloat green, GLfloat blue); +typedef void ( APIENTRY * pfn_glColor3fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glColor3i )(GLint red, GLint green, GLint blue); +typedef void ( APIENTRY * pfn_glColor3iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glColor3s )(GLshort red, GLshort green, GLshort blue); +typedef void ( APIENTRY * pfn_glColor3sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glColor3ub )(GLubyte red, GLubyte green, GLubyte blue); +typedef void ( APIENTRY * pfn_glColor3ubv )(const GLubyte *v); +typedef void ( APIENTRY * pfn_glColor3ui )(GLuint red, GLuint green, GLuint blue); +typedef void ( APIENTRY * pfn_glColor3uiv )(const GLuint *v); +typedef void ( APIENTRY * pfn_glColor3us )(GLushort red, GLushort green, GLushort blue); +typedef void ( APIENTRY * pfn_glColor3usv )(const GLushort *v); +typedef void ( APIENTRY * pfn_glColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +typedef void ( APIENTRY * pfn_glColor4bv )(const GLbyte *v); +typedef void ( APIENTRY * pfn_glColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +typedef void ( APIENTRY * pfn_glColor4dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void ( APIENTRY * pfn_glColor4fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glColor4i )(GLint red, GLint green, GLint blue, GLint alpha); +typedef void ( APIENTRY * pfn_glColor4iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha); +typedef void ( APIENTRY * pfn_glColor4sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +typedef void ( APIENTRY * pfn_glColor4ubv )(const GLubyte *v); +typedef void ( APIENTRY * pfn_glColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha); +typedef void ( APIENTRY * pfn_glColor4uiv )(const GLuint *v); +typedef void ( APIENTRY * pfn_glColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha); +typedef void ( APIENTRY * pfn_glColor4usv )(const GLushort *v); +typedef void ( APIENTRY * pfn_glColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void ( APIENTRY * pfn_glColorMaterial )(GLenum face, GLenum mode); +typedef void ( APIENTRY * pfn_glColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void ( APIENTRY * pfn_glCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +typedef void ( APIENTRY * pfn_glCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); +typedef void ( APIENTRY * pfn_glCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void ( APIENTRY * pfn_glCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void ( APIENTRY * pfn_glCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void ( APIENTRY * pfn_glCullFace )(GLenum mode); +typedef void ( APIENTRY * pfn_glDeleteLists )(GLuint list, GLsizei range); +typedef void ( APIENTRY * pfn_glDeleteTextures )(GLsizei n, const GLuint *textures); +typedef void ( APIENTRY * pfn_glDepthFunc )(GLenum func); +typedef void ( APIENTRY * pfn_glDepthMask )(GLboolean flag); +typedef void ( APIENTRY * pfn_glDepthRange )(GLclampd zNear, GLclampd zFar); +typedef void ( APIENTRY * pfn_glDisable )(GLenum cap); +typedef void ( APIENTRY * pfn_glDisableClientState )(GLenum array); +typedef void ( APIENTRY * pfn_glDrawArrays )(GLenum mode, GLint first, GLsizei count); +typedef void ( APIENTRY * pfn_glDrawBuffer )(GLenum mode); +typedef void ( APIENTRY * pfn_glDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +typedef void ( APIENTRY * pfn_glDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void ( APIENTRY * pfn_glEdgeFlag )(GLboolean flag); +typedef void ( APIENTRY * pfn_glEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer); +typedef void ( APIENTRY * pfn_glEdgeFlagv )(const GLboolean *flag); +typedef void ( APIENTRY * pfn_glEnable )(GLenum cap); +typedef void ( APIENTRY * pfn_glEnableClientState )(GLenum array); +typedef void ( APIENTRY * pfn_glEnd )(void); +typedef void ( APIENTRY * pfn_glEndList )(void); +typedef void ( APIENTRY * pfn_glEvalCoord1d )(GLdouble u); +typedef void ( APIENTRY * pfn_glEvalCoord1dv )(const GLdouble *u); +typedef void ( APIENTRY * pfn_glEvalCoord1f )(GLfloat u); +typedef void ( APIENTRY * pfn_glEvalCoord1fv )(const GLfloat *u); +typedef void ( APIENTRY * pfn_glEvalCoord2d )(GLdouble u, GLdouble v); +typedef void ( APIENTRY * pfn_glEvalCoord2dv )(const GLdouble *u); +typedef void ( APIENTRY * pfn_glEvalCoord2f )(GLfloat u, GLfloat v); +typedef void ( APIENTRY * pfn_glEvalCoord2fv )(const GLfloat *u); +typedef void ( APIENTRY * pfn_glEvalMesh1 )(GLenum mode, GLint i1, GLint i2); +typedef void ( APIENTRY * pfn_glEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +typedef void ( APIENTRY * pfn_glEvalPoint1 )(GLint i); +typedef void ( APIENTRY * pfn_glEvalPoint2 )(GLint i, GLint j); +typedef void ( APIENTRY * pfn_glFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer); +typedef void ( APIENTRY * pfn_glFinish )(void); +typedef void ( APIENTRY * pfn_glFlush )(void); +typedef void ( APIENTRY * pfn_glFogf )(GLenum pname, GLfloat param); +typedef void ( APIENTRY * pfn_glFogfv )(GLenum pname, const GLfloat *params); +typedef void ( APIENTRY * pfn_glFogi )(GLenum pname, GLint param); +typedef void ( APIENTRY * pfn_glFogiv )(GLenum pname, const GLint *params); +typedef void ( APIENTRY * pfn_glFrontFace )(GLenum mode); +typedef void ( APIENTRY * pfn_glFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef GLuint ( APIENTRY * pfn_glGenLists )(GLsizei range); +typedef void ( APIENTRY * pfn_glGenTextures )(GLsizei n, GLuint *textures); +typedef void ( APIENTRY * pfn_glGetBooleanv )(GLenum pname, GLboolean *params); +typedef void ( APIENTRY * pfn_glGetClipPlane )(GLenum plane, GLdouble *equation); +typedef void ( APIENTRY * pfn_glGetDoublev )(GLenum pname, GLdouble *params); +typedef GLenum ( APIENTRY * pfn_glGetError )(void); +typedef void ( APIENTRY * pfn_glGetFloatv )(GLenum pname, GLfloat *params); +typedef void ( APIENTRY * pfn_glGetIntegerv )(GLenum pname, GLint *params); +typedef void ( APIENTRY * pfn_glGetLightfv )(GLenum light, GLenum pname, GLfloat *params); +typedef void ( APIENTRY * pfn_glGetLightiv )(GLenum light, GLenum pname, GLint *params); +typedef void ( APIENTRY * pfn_glGetMapdv )(GLenum target, GLenum query, GLdouble *v); +typedef void ( APIENTRY * pfn_glGetMapfv )(GLenum target, GLenum query, GLfloat *v); +typedef void ( APIENTRY * pfn_glGetMapiv )(GLenum target, GLenum query, GLint *v); +typedef void ( APIENTRY * pfn_glGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params); +typedef void ( APIENTRY * pfn_glGetMaterialiv )(GLenum face, GLenum pname, GLint *params); +typedef void ( APIENTRY * pfn_glGetPixelMapfv )(GLenum map, GLfloat *values); +typedef void ( APIENTRY * pfn_glGetPixelMapuiv )(GLenum map, GLuint *values); +typedef void ( APIENTRY * pfn_glGetPixelMapusv )(GLenum map, GLushort *values); +typedef void ( APIENTRY * pfn_glGetPointerv )(GLenum pname, GLvoid* *params); +typedef void ( APIENTRY * pfn_glGetPolygonStipple )(GLubyte *mask); +typedef const GLubyte * ( APIENTRY * pfn_glGetString )(GLenum name); +typedef void ( APIENTRY * pfn_glGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params); +typedef void ( APIENTRY * pfn_glGetTexEnviv )(GLenum target, GLenum pname, GLint *params); +typedef void ( APIENTRY * pfn_glGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params); +typedef void ( APIENTRY * pfn_glGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params); +typedef void ( APIENTRY * pfn_glGetTexGeniv )(GLenum coord, GLenum pname, GLint *params); +typedef void ( APIENTRY * pfn_glGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void ( APIENTRY * pfn_glGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void ( APIENTRY * pfn_glGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params); +typedef void ( APIENTRY * pfn_glGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params); +typedef void ( APIENTRY * pfn_glGetTexParameteriv )(GLenum target, GLenum pname, GLint *params); +typedef void ( APIENTRY * pfn_glHint )(GLenum target, GLenum mode); +typedef void ( APIENTRY * pfn_glIndexMask )(GLuint mask); +typedef void ( APIENTRY * pfn_glIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void ( APIENTRY * pfn_glIndexd )(GLdouble c); +typedef void ( APIENTRY * pfn_glIndexdv )(const GLdouble *c); +typedef void ( APIENTRY * pfn_glIndexf )(GLfloat c); +typedef void ( APIENTRY * pfn_glIndexfv )(const GLfloat *c); +typedef void ( APIENTRY * pfn_glIndexi )(GLint c); +typedef void ( APIENTRY * pfn_glIndexiv )(const GLint *c); +typedef void ( APIENTRY * pfn_glIndexs )(GLshort c); +typedef void ( APIENTRY * pfn_glIndexsv )(const GLshort *c); +typedef void ( APIENTRY * pfn_glIndexub )(GLubyte c); +typedef void ( APIENTRY * pfn_glIndexubv )(const GLubyte *c); +typedef void ( APIENTRY * pfn_glInitNames )(void); +typedef void ( APIENTRY * pfn_glInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer); +typedef GLboolean ( APIENTRY * pfn_glIsEnabled )(GLenum cap); +typedef GLboolean ( APIENTRY * pfn_glIsList )(GLuint list); +typedef GLboolean ( APIENTRY * pfn_glIsTexture )(GLuint texture); +typedef void ( APIENTRY * pfn_glLightModelf )(GLenum pname, GLfloat param); +typedef void ( APIENTRY * pfn_glLightModelfv )(GLenum pname, const GLfloat *params); +typedef void ( APIENTRY * pfn_glLightModeli )(GLenum pname, GLint param); +typedef void ( APIENTRY * pfn_glLightModeliv )(GLenum pname, const GLint *params); +typedef void ( APIENTRY * pfn_glLightf )(GLenum light, GLenum pname, GLfloat param); +typedef void ( APIENTRY * pfn_glLightfv )(GLenum light, GLenum pname, const GLfloat *params); +typedef void ( APIENTRY * pfn_glLighti )(GLenum light, GLenum pname, GLint param); +typedef void ( APIENTRY * pfn_glLightiv )(GLenum light, GLenum pname, const GLint *params); +typedef void ( APIENTRY * pfn_glLineStipple )(GLint factor, GLushort pattern); +typedef void ( APIENTRY * pfn_glLineWidth )(GLfloat width); +typedef void ( APIENTRY * pfn_glListBase )(GLuint base); +typedef void ( APIENTRY * pfn_glLoadIdentity )(void); +typedef void ( APIENTRY * pfn_glLoadMatrixd )(const GLdouble *m); +typedef void ( APIENTRY * pfn_glLoadMatrixf )(const GLfloat *m); +typedef void ( APIENTRY * pfn_glLoadName )(GLuint name); +typedef void ( APIENTRY * pfn_glLogicOp )(GLenum opcode); +typedef void ( APIENTRY * pfn_glMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void ( APIENTRY * pfn_glMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void ( APIENTRY * pfn_glMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void ( APIENTRY * pfn_glMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +typedef void ( APIENTRY * pfn_glMapGrid1d )(GLint un, GLdouble u1, GLdouble u2); +typedef void ( APIENTRY * pfn_glMapGrid1f )(GLint un, GLfloat u1, GLfloat u2); +typedef void ( APIENTRY * pfn_glMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +typedef void ( APIENTRY * pfn_glMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +typedef void ( APIENTRY * pfn_glMaterialf )(GLenum face, GLenum pname, GLfloat param); +typedef void ( APIENTRY * pfn_glMaterialfv )(GLenum face, GLenum pname, const GLfloat *params); +typedef void ( APIENTRY * pfn_glMateriali )(GLenum face, GLenum pname, GLint param); +typedef void ( APIENTRY * pfn_glMaterialiv )(GLenum face, GLenum pname, const GLint *params); +typedef void ( APIENTRY * pfn_glMatrixMode )(GLenum mode); +typedef void ( APIENTRY * pfn_glMultMatrixd )(const GLdouble *m); +typedef void ( APIENTRY * pfn_glMultMatrixf )(const GLfloat *m); +typedef void ( APIENTRY * pfn_glNewList )(GLuint list, GLenum mode); +typedef void ( APIENTRY * pfn_glNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz); +typedef void ( APIENTRY * pfn_glNormal3bv )(const GLbyte *v); +typedef void ( APIENTRY * pfn_glNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz); +typedef void ( APIENTRY * pfn_glNormal3dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz); +typedef void ( APIENTRY * pfn_glNormal3fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glNormal3i )(GLint nx, GLint ny, GLint nz); +typedef void ( APIENTRY * pfn_glNormal3iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glNormal3s )(GLshort nx, GLshort ny, GLshort nz); +typedef void ( APIENTRY * pfn_glNormal3sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void ( APIENTRY * pfn_glOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void ( APIENTRY * pfn_glPassThrough )(GLfloat token); +typedef void ( APIENTRY * pfn_glPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values); +typedef void ( APIENTRY * pfn_glPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values); +typedef void ( APIENTRY * pfn_glPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values); +typedef void ( APIENTRY * pfn_glPixelStoref )(GLenum pname, GLfloat param); +typedef void ( APIENTRY * pfn_glPixelStorei )(GLenum pname, GLint param); +typedef void ( APIENTRY * pfn_glPixelTransferf )(GLenum pname, GLfloat param); +typedef void ( APIENTRY * pfn_glPixelTransferi )(GLenum pname, GLint param); +typedef void ( APIENTRY * pfn_glPixelZoom )(GLfloat xfactor, GLfloat yfactor); +typedef void ( APIENTRY * pfn_glPointSize )(GLfloat size); +typedef void ( APIENTRY * pfn_glPolygonMode )(GLenum face, GLenum mode); +typedef void ( APIENTRY * pfn_glPolygonOffset )(GLfloat factor, GLfloat units); +typedef void ( APIENTRY * pfn_glPolygonStipple )(const GLubyte *mask); +typedef void ( APIENTRY * pfn_glPopAttrib )(void); +typedef void ( APIENTRY * pfn_glPopClientAttrib )(void); +typedef void ( APIENTRY * pfn_glPopMatrix )(void); +typedef void ( APIENTRY * pfn_glPopName )(void); +typedef void ( APIENTRY * pfn_glPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities); +typedef void ( APIENTRY * pfn_glPushAttrib )(GLbitfield mask); +typedef void ( APIENTRY * pfn_glPushClientAttrib )(GLbitfield mask); +typedef void ( APIENTRY * pfn_glPushMatrix )(void); +typedef void ( APIENTRY * pfn_glPushName )(GLuint name); +typedef void ( APIENTRY * pfn_glRasterPos2d )(GLdouble x, GLdouble y); +typedef void ( APIENTRY * pfn_glRasterPos2dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glRasterPos2f )(GLfloat x, GLfloat y); +typedef void ( APIENTRY * pfn_glRasterPos2fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glRasterPos2i )(GLint x, GLint y); +typedef void ( APIENTRY * pfn_glRasterPos2iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glRasterPos2s )(GLshort x, GLshort y); +typedef void ( APIENTRY * pfn_glRasterPos2sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glRasterPos3d )(GLdouble x, GLdouble y, GLdouble z); +typedef void ( APIENTRY * pfn_glRasterPos3dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glRasterPos3f )(GLfloat x, GLfloat y, GLfloat z); +typedef void ( APIENTRY * pfn_glRasterPos3fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glRasterPos3i )(GLint x, GLint y, GLint z); +typedef void ( APIENTRY * pfn_glRasterPos3iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glRasterPos3s )(GLshort x, GLshort y, GLshort z); +typedef void ( APIENTRY * pfn_glRasterPos3sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void ( APIENTRY * pfn_glRasterPos4dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void ( APIENTRY * pfn_glRasterPos4fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glRasterPos4i )(GLint x, GLint y, GLint z, GLint w); +typedef void ( APIENTRY * pfn_glRasterPos4iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w); +typedef void ( APIENTRY * pfn_glRasterPos4sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glReadBuffer )(GLenum mode); +typedef void ( APIENTRY * pfn_glReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +typedef void ( APIENTRY * pfn_glRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +typedef void ( APIENTRY * pfn_glRectdv )(const GLdouble *v1, const GLdouble *v2); +typedef void ( APIENTRY * pfn_glRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +typedef void ( APIENTRY * pfn_glRectfv )(const GLfloat *v1, const GLfloat *v2); +typedef void ( APIENTRY * pfn_glRecti )(GLint x1, GLint y1, GLint x2, GLint y2); +typedef void ( APIENTRY * pfn_glRectiv )(const GLint *v1, const GLint *v2); +typedef void ( APIENTRY * pfn_glRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2); +typedef void ( APIENTRY * pfn_glRectsv )(const GLshort *v1, const GLshort *v2); +typedef GLint ( APIENTRY * pfn_glRenderMode )(GLenum mode); +typedef void ( APIENTRY * pfn_glRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void ( APIENTRY * pfn_glRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void ( APIENTRY * pfn_glScaled )(GLdouble x, GLdouble y, GLdouble z); +typedef void ( APIENTRY * pfn_glScalef )(GLfloat x, GLfloat y, GLfloat z); +typedef void ( APIENTRY * pfn_glScissor )(GLint x, GLint y, GLsizei width, GLsizei height); +typedef void ( APIENTRY * pfn_glSelectBuffer )(GLsizei size, GLuint *buffer); +typedef void ( APIENTRY * pfn_glShadeModel )(GLenum mode); +typedef void ( APIENTRY * pfn_glStencilFunc )(GLenum func, GLint ref, GLuint mask); +typedef void ( APIENTRY * pfn_glStencilMask )(GLuint mask); +typedef void ( APIENTRY * pfn_glStencilOp )(GLenum fail, GLenum zfail, GLenum zpass); +typedef void ( APIENTRY * pfn_glTexCoord1d )(GLdouble s); +typedef void ( APIENTRY * pfn_glTexCoord1dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glTexCoord1f )(GLfloat s); +typedef void ( APIENTRY * pfn_glTexCoord1fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glTexCoord1i )(GLint s); +typedef void ( APIENTRY * pfn_glTexCoord1iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glTexCoord1s )(GLshort s); +typedef void ( APIENTRY * pfn_glTexCoord1sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glTexCoord2d )(GLdouble s, GLdouble t); +typedef void ( APIENTRY * pfn_glTexCoord2dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glTexCoord2f )(GLfloat s, GLfloat t); +typedef void ( APIENTRY * pfn_glTexCoord2fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glTexCoord2i )(GLint s, GLint t); +typedef void ( APIENTRY * pfn_glTexCoord2iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glTexCoord2s )(GLshort s, GLshort t); +typedef void ( APIENTRY * pfn_glTexCoord2sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glTexCoord3d )(GLdouble s, GLdouble t, GLdouble r); +typedef void ( APIENTRY * pfn_glTexCoord3dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glTexCoord3f )(GLfloat s, GLfloat t, GLfloat r); +typedef void ( APIENTRY * pfn_glTexCoord3fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glTexCoord3i )(GLint s, GLint t, GLint r); +typedef void ( APIENTRY * pfn_glTexCoord3iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glTexCoord3s )(GLshort s, GLshort t, GLshort r); +typedef void ( APIENTRY * pfn_glTexCoord3sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void ( APIENTRY * pfn_glTexCoord4dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void ( APIENTRY * pfn_glTexCoord4fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glTexCoord4i )(GLint s, GLint t, GLint r, GLint q); +typedef void ( APIENTRY * pfn_glTexCoord4iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q); +typedef void ( APIENTRY * pfn_glTexCoord4sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void ( APIENTRY * pfn_glTexEnvf )(GLenum target, GLenum pname, GLfloat param); +typedef void ( APIENTRY * pfn_glTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params); +typedef void ( APIENTRY * pfn_glTexEnvi )(GLenum target, GLenum pname, GLint param); +typedef void ( APIENTRY * pfn_glTexEnviv )(GLenum target, GLenum pname, const GLint *params); +typedef void ( APIENTRY * pfn_glTexGend )(GLenum coord, GLenum pname, GLdouble param); +typedef void ( APIENTRY * pfn_glTexGendv )(GLenum coord, GLenum pname, const GLdouble *params); +typedef void ( APIENTRY * pfn_glTexGenf )(GLenum coord, GLenum pname, GLfloat param); +typedef void ( APIENTRY * pfn_glTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params); +typedef void ( APIENTRY * pfn_glTexGeni )(GLenum coord, GLenum pname, GLint param); +typedef void ( APIENTRY * pfn_glTexGeniv )(GLenum coord, GLenum pname, const GLint *params); +typedef void ( APIENTRY * pfn_glTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void ( APIENTRY * pfn_glTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void ( APIENTRY * pfn_glTexParameterf )(GLenum target, GLenum pname, GLfloat param); +typedef void ( APIENTRY * pfn_glTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params); +typedef void ( APIENTRY * pfn_glTexParameteri )(GLenum target, GLenum pname, GLint param); +typedef void ( APIENTRY * pfn_glTexParameteriv )(GLenum target, GLenum pname, const GLint *params); +typedef void ( APIENTRY * pfn_glTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void ( APIENTRY * pfn_glTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void ( APIENTRY * pfn_glTranslated )(GLdouble x, GLdouble y, GLdouble z); +typedef void ( APIENTRY * pfn_glTranslatef )(GLfloat x, GLfloat y, GLfloat z); +typedef void ( APIENTRY * pfn_glVertex2d )(GLdouble x, GLdouble y); +typedef void ( APIENTRY * pfn_glVertex2dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glVertex2f )(GLfloat x, GLfloat y); +typedef void ( APIENTRY * pfn_glVertex2fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glVertex2i )(GLint x, GLint y); +typedef void ( APIENTRY * pfn_glVertex2iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glVertex2s )(GLshort x, GLshort y); +typedef void ( APIENTRY * pfn_glVertex2sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glVertex3d )(GLdouble x, GLdouble y, GLdouble z); +typedef void ( APIENTRY * pfn_glVertex3dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glVertex3f )(GLfloat x, GLfloat y, GLfloat z); +typedef void ( APIENTRY * pfn_glVertex3fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glVertex3i )(GLint x, GLint y, GLint z); +typedef void ( APIENTRY * pfn_glVertex3iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glVertex3s )(GLshort x, GLshort y, GLshort z); +typedef void ( APIENTRY * pfn_glVertex3sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void ( APIENTRY * pfn_glVertex4dv )(const GLdouble *v); +typedef void ( APIENTRY * pfn_glVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void ( APIENTRY * pfn_glVertex4fv )(const GLfloat *v); +typedef void ( APIENTRY * pfn_glVertex4i )(GLint x, GLint y, GLint z, GLint w); +typedef void ( APIENTRY * pfn_glVertex4iv )(const GLint *v); +typedef void ( APIENTRY * pfn_glVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w); +typedef void ( APIENTRY * pfn_glVertex4sv )(const GLshort *v); +typedef void ( APIENTRY * pfn_glVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void ( APIENTRY * pfn_glViewport )(GLint x, GLint y, GLsizei width, GLsizei height); + +typedef int ( WINAPI * pfn_wglChoosePixelFormat )(HDC, CONST PIXELFORMATDESCRIPTOR *); +typedef int ( WINAPI * pfn_wglDescribePixelFormat) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR); +typedef int ( WINAPI * pfn_wglGetPixelFormat)(HDC); +typedef BOOL ( WINAPI * pfn_wglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *); +typedef BOOL ( WINAPI * pfn_wglSwapBuffers)(HDC); +typedef BOOL ( WINAPI * pfn_wglCopyContext)(HGLRC, HGLRC, UINT); +typedef HGLRC ( WINAPI * pfn_wglCreateContext)(HDC); +typedef BOOL ( WINAPI * pfn_wglDeleteContext)(HGLRC); +typedef HGLRC ( WINAPI * pfn_wglGetCurrentContext)(VOID); +typedef HDC ( WINAPI * pfn_wglGetCurrentDC)(VOID); +typedef PROC ( WINAPI * pfn_wglGetProcAddress)(LPCSTR); +typedef BOOL ( WINAPI * pfn_wglMakeCurrent)(HDC, HGLRC); +typedef BOOL ( WINAPI * pfn_wglShareLists)(HGLRC, HGLRC); +typedef HGLRC ( WINAPI * pfn_wglCreateLayerContext)( HDC hdc, int iLayerPlane ); +typedef BOOL ( WINAPI * pfn_wglDescribeLayerPlane)( HDC hdc, int iPixelFormat, int iLayerPlane, UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd ); +typedef int ( WINAPI * pfn_wglGetLayerPaletteEntries)( HDC hdc, int iLayerPlane, int iStart, int cEntries, COLORREF *pcr ); +typedef int ( WINAPI * pfn_wglSetLayerPaletteEntries)(HDC hdc, int iLayerPlane, int iStart, int cEntries, CONST COLORREF *pcr); +typedef BOOL ( WINAPI * pfn_wglRealizeLayerPalette)(HDC hdc, int iLayerPlane, BOOL b); +typedef BOOL ( WINAPI * pfn_wglSwapLayerBuffers)(HDC hdc, UINT i); +typedef BOOL ( WINAPI * pfn_wglUseFontBitmapsA)(HDC hdc, DWORD dw1, DWORD dw2, DWORD dw3); +typedef BOOL ( WINAPI * pfn_wglUseFontBitmapsW)(HDC hdc, DWORD dw1, DWORD dw2, DWORD dw3); +typedef BOOL ( WINAPI * pfn_wglUseFontOutlinesA)(HDC hdc, DWORD dw1, DWORD dw2, DWORD dw3, FLOAT f1, FLOAT f2, int i, LPGLYPHMETRICSFLOAT pgmf); +typedef BOOL ( WINAPI * pfn_wglUseFontOutlinesW)(HDC hdc, DWORD dw1, DWORD dw2, DWORD dw3, FLOAT f1, FLOAT f2, int i, LPGLYPHMETRICSFLOAT pgmf); +typedef BOOL ( WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); + +typedef struct +{ + GLenum edgeClampMode; + int maxActiveTextures; + int maxAnisotropy; + unsigned char + Multitexture : 1, + VertexShader : 1, + FragmentShader : 1, + RectangleTexture: 1, + DepthTexture : 1, + FBO : 1, + MultisampleHint : 1, + : 1; +} ExtensionSupport_t; + +namespace gl +{ +extern pfn_glAccum qglAccum; +extern pfn_glAlphaFunc qglAlphaFunc; +extern pfn_glAreTexturesResident qglAreTexturesResident; +extern pfn_glArrayElement qglArrayElement; +extern pfn_glBegin qglBegin; +extern pfn_glBindTexture qglBindTexture; +extern pfn_glBitmap qglBitmap; +extern pfn_glBlendFunc qglBlendFunc; +extern pfn_glCallList qglCallList; +extern pfn_glCallLists qglCallLists; +extern pfn_glClear qglClear; +extern pfn_glClearAccum qglClearAccum; +extern pfn_glClearColor qglClearColor; +extern pfn_glClearDepth qglClearDepth; +extern pfn_glClearIndex qglClearIndex; +extern pfn_glClearStencil qglClearStencil; +extern pfn_glClipPlane qglClipPlane; +extern pfn_glColor3b qglColor3b; +extern pfn_glColor3bv qglColor3bv; +extern pfn_glColor3d qglColor3d; +extern pfn_glColor3dv qglColor3dv; +extern pfn_glColor3f qglColor3f; +extern pfn_glColor3fv qglColor3fv; +extern pfn_glColor3i qglColor3i; +extern pfn_glColor3iv qglColor3iv; +extern pfn_glColor3s qglColor3s; +extern pfn_glColor3sv qglColor3sv; +extern pfn_glColor3ub qglColor3ub; +extern pfn_glColor3ubv qglColor3ubv; +extern pfn_glColor3ui qglColor3ui; +extern pfn_glColor3uiv qglColor3uiv; +extern pfn_glColor3us qglColor3us; +extern pfn_glColor3usv qglColor3usv; +extern pfn_glColor4b qglColor4b; +extern pfn_glColor4bv qglColor4bv; +extern pfn_glColor4d qglColor4d; +extern pfn_glColor4dv qglColor4dv; +extern pfn_glColor4f qglColor4f; +extern pfn_glColor4fv qglColor4fv; +extern pfn_glColor4i qglColor4i; +extern pfn_glColor4iv qglColor4iv; +extern pfn_glColor4s qglColor4s; +extern pfn_glColor4sv qglColor4sv; +extern pfn_glColor4ub qglColor4ub; +extern pfn_glColor4ubv qglColor4ubv; +extern pfn_glColor4ui qglColor4ui; +extern pfn_glColor4uiv qglColor4uiv; +extern pfn_glColor4us qglColor4us; +extern pfn_glColor4usv qglColor4usv; +extern pfn_glColorMask qglColorMask; +extern pfn_glColorMaterial qglColorMaterial; +extern pfn_glColorPointer qglColorPointer; +extern pfn_glCopyPixels qglCopyPixels; +extern pfn_glCopyTexImage1D qglCopyTexImage1D; +extern pfn_glCopyTexImage2D qglCopyTexImage2D; +extern pfn_glCopyTexSubImage1D qglCopyTexSubImage1D; +extern pfn_glCopyTexSubImage2D qglCopyTexSubImage2D; +extern pfn_glCullFace qglCullFace; +extern pfn_glDeleteLists qglDeleteLists; +extern pfn_glDeleteTextures qglDeleteTextures; +extern pfn_glDepthFunc qglDepthFunc; +extern pfn_glDepthMask qglDepthMask; +extern pfn_glDepthRange qglDepthRange; +extern pfn_glDisable qglDisable; +extern pfn_glDisableClientState qglDisableClientState; +extern pfn_glDrawArrays qglDrawArrays; +extern pfn_glDrawBuffer qglDrawBuffer; +extern pfn_glDrawElements qglDrawElements; +extern pfn_glDrawPixels qglDrawPixels; +extern pfn_glEdgeFlag qglEdgeFlag; +extern pfn_glEdgeFlagPointer qglEdgeFlagPointer; +extern pfn_glEdgeFlagv qglEdgeFlagv; +extern pfn_glEnable qglEnable; +extern pfn_glEnableClientState qglEnableClientState; +extern pfn_glEnd qglEnd; +extern pfn_glEndList qglEndList; +extern pfn_glEvalCoord1d qglEvalCoord1d; +extern pfn_glEvalCoord1dv qglEvalCoord1dv; +extern pfn_glEvalCoord1f qglEvalCoord1f; +extern pfn_glEvalCoord1fv qglEvalCoord1fv; +extern pfn_glEvalCoord2d qglEvalCoord2d; +extern pfn_glEvalCoord2dv qglEvalCoord2dv; +extern pfn_glEvalCoord2f qglEvalCoord2f; +extern pfn_glEvalCoord2fv qglEvalCoord2fv; +extern pfn_glEvalMesh1 qglEvalMesh1; +extern pfn_glEvalMesh2 qglEvalMesh2; +extern pfn_glEvalPoint1 qglEvalPoint1; +extern pfn_glEvalPoint2 qglEvalPoint2; +extern pfn_glFeedbackBuffer qglFeedbackBuffer; +extern pfn_glFinish qglFinish; +extern pfn_glFlush qglFlush; +extern pfn_glFogf qglFogf; +extern pfn_glFogfv qglFogfv; +extern pfn_glFogi qglFogi; +extern pfn_glFogiv qglFogiv; +extern pfn_glFrontFace qglFrontFace; +extern pfn_glFrustum qglFrustum; +extern pfn_glGenLists qglGenLists; +extern pfn_glGenTextures qglGenTextures; +extern pfn_glGetBooleanv qglGetBooleanv; +extern pfn_glGetClipPlane qglGetClipPlane; +extern pfn_glGetDoublev qglGetDoublev; +extern pfn_glGetError qglGetError; +extern pfn_glGetFloatv qglGetFloatv; +extern pfn_glGetIntegerv qglGetIntegerv; +extern pfn_glGetLightfv qglGetLightfv; +extern pfn_glGetLightiv qglGetLightiv; +extern pfn_glGetMapdv qglGetMapdv; +extern pfn_glGetMapfv qglGetMapfv; +extern pfn_glGetMapiv qglGetMapiv; +extern pfn_glGetMaterialfv qglGetMaterialfv; +extern pfn_glGetMaterialiv qglGetMaterialiv; +extern pfn_glGetPixelMapfv qglGetPixelMapfv; +extern pfn_glGetPixelMapuiv qglGetPixelMapuiv; +extern pfn_glGetPixelMapusv qglGetPixelMapusv; +extern pfn_glGetPointerv qglGetPointerv; +extern pfn_glGetPolygonStipple qglGetPolygonStipple; +extern pfn_glGetString qglGetString; +extern pfn_glGetTexEnvfv qglGetTexEnvfv; +extern pfn_glGetTexEnviv qglGetTexEnviv; +extern pfn_glGetTexGendv qglGetTexGendv; +extern pfn_glGetTexGenfv qglGetTexGenfv; +extern pfn_glGetTexGeniv qglGetTexGeniv; +extern pfn_glGetTexImage qglGetTexImage; +extern pfn_glGetTexLevelParameterfv qglGetTexLevelParameterfv; +extern pfn_glGetTexLevelParameteriv qglGetTexLevelParameteriv; +extern pfn_glGetTexParameterfv qglGetTexParameterfv; +extern pfn_glGetTexParameteriv qglGetTexParameteriv; +extern pfn_glHint qglHint; +extern pfn_glIndexMask qglIndexMask; +extern pfn_glIndexPointer qglIndexPointer; +extern pfn_glIndexd qglIndexd; +extern pfn_glIndexdv qglIndexdv; +extern pfn_glIndexf qglIndexf; +extern pfn_glIndexfv qglIndexfv; +extern pfn_glIndexi qglIndexi; +extern pfn_glIndexiv qglIndexiv; +extern pfn_glIndexs qglIndexs; +extern pfn_glIndexsv qglIndexsv; +extern pfn_glIndexub qglIndexub; +extern pfn_glIndexubv qglIndexubv; +extern pfn_glInitNames qglInitNames; +extern pfn_glInterleavedArrays qglInterleavedArrays; +extern pfn_glIsEnabled qglIsEnabled; +extern pfn_glIsList qglIsList; +extern pfn_glIsTexture qglIsTexture; +extern pfn_glLightModelf qglLightModelf; +extern pfn_glLightModelfv qglLightModelfv; +extern pfn_glLightModeli qglLightModeli; +extern pfn_glLightModeliv qglLightModeliv; +extern pfn_glLightf qglLightf; +extern pfn_glLightfv qglLightfv; +extern pfn_glLighti qglLighti; +extern pfn_glLightiv qglLightiv; +extern pfn_glLineStipple qglLineStipple; +extern pfn_glLineWidth qglLineWidth; +extern pfn_glListBase qglListBase; +extern pfn_glLoadIdentity qglLoadIdentity; +extern pfn_glLoadMatrixd qglLoadMatrixd; +extern pfn_glLoadMatrixf qglLoadMatrixf; +extern pfn_glLoadName qglLoadName; +extern pfn_glLogicOp qglLogicOp; +extern pfn_glMap1d qglMap1d; +extern pfn_glMap1f qglMap1f; +extern pfn_glMap2d qglMap2d; +extern pfn_glMap2f qglMap2f; +extern pfn_glMapGrid1d qglMapGrid1d; +extern pfn_glMapGrid1f qglMapGrid1f; +extern pfn_glMapGrid2d qglMapGrid2d; +extern pfn_glMapGrid2f qglMapGrid2f; +extern pfn_glMaterialf qglMaterialf; +extern pfn_glMaterialfv qglMaterialfv; +extern pfn_glMateriali qglMateriali; +extern pfn_glMaterialiv qglMaterialiv; +extern pfn_glMatrixMode qglMatrixMode; +extern pfn_glMultMatrixd qglMultMatrixd; +extern pfn_glMultMatrixf qglMultMatrixf; +extern pfn_glNewList qglNewList; +extern pfn_glNormal3b qglNormal3b; +extern pfn_glNormal3bv qglNormal3bv; +extern pfn_glNormal3d qglNormal3d; +extern pfn_glNormal3dv qglNormal3dv; +extern pfn_glNormal3f qglNormal3f; +extern pfn_glNormal3fv qglNormal3fv; +extern pfn_glNormal3i qglNormal3i; +extern pfn_glNormal3iv qglNormal3iv; +extern pfn_glNormal3s qglNormal3s; +extern pfn_glNormal3sv qglNormal3sv; +extern pfn_glNormalPointer qglNormalPointer; +extern pfn_glOrtho qglOrtho; +extern pfn_glPassThrough qglPassThrough; +extern pfn_glPixelMapfv qglPixelMapfv; +extern pfn_glPixelMapuiv qglPixelMapuiv; +extern pfn_glPixelMapusv qglPixelMapusv; +extern pfn_glPixelStoref qglPixelStoref; +extern pfn_glPixelStorei qglPixelStorei; +extern pfn_glPixelTransferf qglPixelTransferf; +extern pfn_glPixelTransferi qglPixelTransferi; +extern pfn_glPixelZoom qglPixelZoom; +extern pfn_glPointSize qglPointSize; +extern pfn_glPolygonMode qglPolygonMode; +extern pfn_glPolygonOffset qglPolygonOffset; +extern pfn_glPolygonStipple qglPolygonStipple; +extern pfn_glPopAttrib qglPopAttrib; +extern pfn_glPopClientAttrib qglPopClientAttrib; +extern pfn_glPopMatrix qglPopMatrix; +extern pfn_glPopName qglPopName; +extern pfn_glPrioritizeTextures qglPrioritizeTextures; +extern pfn_glPushAttrib qglPushAttrib; +extern pfn_glPushClientAttrib qglPushClientAttrib; +extern pfn_glPushMatrix qglPushMatrix; +extern pfn_glPushName qglPushName; +extern pfn_glRasterPos2d qglRasterPos2d; +extern pfn_glRasterPos2dv qglRasterPos2dv; +extern pfn_glRasterPos2f qglRasterPos2f; +extern pfn_glRasterPos2fv qglRasterPos2fv; +extern pfn_glRasterPos2i qglRasterPos2i; +extern pfn_glRasterPos2iv qglRasterPos2iv; +extern pfn_glRasterPos2s qglRasterPos2s; +extern pfn_glRasterPos2sv qglRasterPos2sv; +extern pfn_glRasterPos3d qglRasterPos3d; +extern pfn_glRasterPos3dv qglRasterPos3dv; +extern pfn_glRasterPos3f qglRasterPos3f; +extern pfn_glRasterPos3fv qglRasterPos3fv; +extern pfn_glRasterPos3i qglRasterPos3i; +extern pfn_glRasterPos3iv qglRasterPos3iv; +extern pfn_glRasterPos3s qglRasterPos3s; +extern pfn_glRasterPos3sv qglRasterPos3sv; +extern pfn_glRasterPos4d qglRasterPos4d; +extern pfn_glRasterPos4dv qglRasterPos4dv; +extern pfn_glRasterPos4f qglRasterPos4f; +extern pfn_glRasterPos4fv qglRasterPos4fv; +extern pfn_glRasterPos4i qglRasterPos4i; +extern pfn_glRasterPos4iv qglRasterPos4iv; +extern pfn_glRasterPos4s qglRasterPos4s; +extern pfn_glRasterPos4sv qglRasterPos4sv; +extern pfn_glReadBuffer qglReadBuffer; +extern pfn_glReadPixels qglReadPixels; +extern pfn_glRectd qglRectd; +extern pfn_glRectdv qglRectdv; +extern pfn_glRectf qglRectf; +extern pfn_glRectfv qglRectfv; +extern pfn_glRecti qglRecti; +extern pfn_glRectiv qglRectiv; +extern pfn_glRects qglRects; +extern pfn_glRectsv qglRectsv; +extern pfn_glRenderMode qglRenderMode; +extern pfn_glRotated qglRotated; +extern pfn_glRotatef qglRotatef; +extern pfn_glScaled qglScaled; +extern pfn_glScalef qglScalef; +extern pfn_glScissor qglScissor; +extern pfn_glSelectBuffer qglSelectBuffer; +extern pfn_glShadeModel qglShadeModel; +extern pfn_glStencilFunc qglStencilFunc; +extern pfn_glStencilMask qglStencilMask; +extern pfn_glStencilOp qglStencilOp; +extern pfn_glTexCoord1d qglTexCoord1d; +extern pfn_glTexCoord1dv qglTexCoord1dv; +extern pfn_glTexCoord1f qglTexCoord1f; +extern pfn_glTexCoord1fv qglTexCoord1fv; +extern pfn_glTexCoord1i qglTexCoord1i; +extern pfn_glTexCoord1iv qglTexCoord1iv; +extern pfn_glTexCoord1s qglTexCoord1s; +extern pfn_glTexCoord1sv qglTexCoord1sv; +extern pfn_glTexCoord2d qglTexCoord2d; +extern pfn_glTexCoord2dv qglTexCoord2dv; +extern pfn_glTexCoord2f qglTexCoord2f; +extern pfn_glTexCoord2fv qglTexCoord2fv; +extern pfn_glTexCoord2i qglTexCoord2i; +extern pfn_glTexCoord2iv qglTexCoord2iv; +extern pfn_glTexCoord2s qglTexCoord2s; +extern pfn_glTexCoord2sv qglTexCoord2sv; +extern pfn_glTexCoord3d qglTexCoord3d; +extern pfn_glTexCoord3dv qglTexCoord3dv; +extern pfn_glTexCoord3f qglTexCoord3f; +extern pfn_glTexCoord3fv qglTexCoord3fv; +extern pfn_glTexCoord3i qglTexCoord3i; +extern pfn_glTexCoord3iv qglTexCoord3iv; +extern pfn_glTexCoord3s qglTexCoord3s; +extern pfn_glTexCoord3sv qglTexCoord3sv; +extern pfn_glTexCoord4d qglTexCoord4d; +extern pfn_glTexCoord4dv qglTexCoord4dv; +extern pfn_glTexCoord4f qglTexCoord4f; +extern pfn_glTexCoord4fv qglTexCoord4fv; +extern pfn_glTexCoord4i qglTexCoord4i; +extern pfn_glTexCoord4iv qglTexCoord4iv; +extern pfn_glTexCoord4s qglTexCoord4s; +extern pfn_glTexCoord4sv qglTexCoord4sv; +extern pfn_glTexCoordPointer qglTexCoordPointer; +extern pfn_glTexEnvf qglTexEnvf; +extern pfn_glTexEnvfv qglTexEnvfv; +extern pfn_glTexEnvi qglTexEnvi; +extern pfn_glTexEnviv qglTexEnviv; +extern pfn_glTexGend qglTexGend; +extern pfn_glTexGendv qglTexGendv; +extern pfn_glTexGenf qglTexGenf; +extern pfn_glTexGenfv qglTexGenfv; +extern pfn_glTexGeni qglTexGeni; +extern pfn_glTexGeniv qglTexGeniv; +extern pfn_glTexImage1D qglTexImage1D; +extern pfn_glTexImage2D qglTexImage2D; +extern pfn_glTexParameterf qglTexParameterf; +extern pfn_glTexParameterfv qglTexParameterfv; +extern pfn_glTexParameteri qglTexParameteri; +extern pfn_glTexParameteriv qglTexParameteriv; +extern pfn_glTexSubImage1D qglTexSubImage1D; +extern pfn_glTexSubImage2D qglTexSubImage2D; +extern pfn_glTranslated qglTranslated; +extern pfn_glTranslatef qglTranslatef; +extern pfn_glVertex2d qglVertex2d; +extern pfn_glVertex2dv qglVertex2dv; +extern pfn_glVertex2f qglVertex2f; +extern pfn_glVertex2fv qglVertex2fv; +extern pfn_glVertex2i qglVertex2i; +extern pfn_glVertex2iv qglVertex2iv; +extern pfn_glVertex2s qglVertex2s; +extern pfn_glVertex2sv qglVertex2sv; +extern pfn_glVertex3d qglVertex3d; +extern pfn_glVertex3dv qglVertex3dv; +extern pfn_glVertex3f qglVertex3f; +extern pfn_glVertex3fv qglVertex3fv; +extern pfn_glVertex3i qglVertex3i; +extern pfn_glVertex3iv qglVertex3iv; +extern pfn_glVertex3s qglVertex3s; +extern pfn_glVertex3sv qglVertex3sv; +extern pfn_glVertex4d qglVertex4d; +extern pfn_glVertex4dv qglVertex4dv; +extern pfn_glVertex4f qglVertex4f; +extern pfn_glVertex4fv qglVertex4fv; +extern pfn_glVertex4i qglVertex4i; +extern pfn_glVertex4iv qglVertex4iv; +extern pfn_glVertex4s qglVertex4s; +extern pfn_glVertex4sv qglVertex4sv; +extern pfn_glVertexPointer qglVertexPointer; +extern pfn_glViewport qglViewport; +extern pfn_wglChoosePixelFormat wglChoosePixelFormat; +extern pfn_wglDescribePixelFormat wglDescribePixelFormat; +extern pfn_wglGetPixelFormat wglGetPixelFormat; +extern pfn_wglSetPixelFormat wglSetPixelFormat; +extern pfn_wglSwapBuffers wglSwapBuffers; +extern pfn_wglCopyContext wglCopyContext; +extern pfn_wglCreateContext wglCreateContext; +extern pfn_wglDeleteContext wglDeleteContext; +extern pfn_wglGetCurrentContext wglGetCurrentContext; +extern pfn_wglGetCurrentDC wglGetCurrentDC; +extern pfn_wglGetProcAddress wglGetProcAddress; +extern pfn_wglMakeCurrent wglMakeCurrent; +extern pfn_wglShareLists wglShareLists; +extern pfn_wglCreateLayerContext wglCreateLayerContext; +extern pfn_wglDescribeLayerPlane wglDescribeLayerPlane; +extern pfn_wglGetLayerPaletteEntries wglGetLayerPaletteEntries; +extern pfn_wglSetLayerPaletteEntries wglSetLayerPaletteEntries; +extern pfn_wglRealizeLayerPalette wglRealizeLayerPalette; +extern pfn_wglSwapLayerBuffers wglSwapLayerBuffers; +extern pfn_wglUseFontBitmapsA wglUseFontBitmapsA; +extern pfn_wglUseFontBitmapsW wglUseFontBitmapsW; +extern pfn_wglUseFontOutlinesA wglUseFontOutlinesA; +extern pfn_wglUseFontOutlinesW wglUseFontOutlinesW; + +// GL extensions +extern PFNGLACTIVETEXTUREARBPROC qglActiveTextureARB; +extern PFNGLCLIENTACTIVETEXTUREARBPROC qglClientActiveTextureARB; +extern PFNGLMULTITEXCOORD2FARBPROC qglMultiTexCoord2fARB; +extern PFNGLMULTITEXCOORD2FVARBPROC qglMultiTexCoord2fvARB; + +extern PFNGLBINDFRAMEBUFFERPROC qglBindFramebuffer; +extern PFNGLCHECKFRAMEBUFFERSTATUSPROC qglCheckFramebufferStatus; +extern PFNGLDELETEFRAMEBUFFERSPROC qglDeleteFramebuffers; +extern PFNGLFRAMEBUFFERTEXTURE2DPROC qglFramebufferTexture2D; +extern PFNGLFRAMEBUFFERTEXTUREPROC qglFramebufferTexture; +extern PFNGLGENFRAMEBUFFERSPROC qglGenFramebuffers; +extern PFNGLGENERATEMIPMAPPROC qglGenerateMipmap; + +extern PFNGLBINDFRAMEBUFFERPROC qglBindFramebufferEXT; +extern PFNGLCHECKFRAMEBUFFERSTATUSPROC qglCheckFramebufferStatusEXT; +extern PFNGLDELETEFRAMEBUFFERSPROC qglDeleteFramebuffersEXT; +extern PFNGLFRAMEBUFFERTEXTURE2DPROC qglFramebufferTexture2DEXT; +extern PFNGLFRAMEBUFFERTEXTUREPROC qglFramebufferTextureEXT; +extern PFNGLGENFRAMEBUFFERSPROC qglGenFramebuffersEXT; +extern PFNGLGENERATEMIPMAPPROC qglGenerateMipmapEXT; + +extern PFNGLGETHANDLEARBPROC qglGetHandleARB; +extern PFNGLDELETEOBJECTARBPROC qglDeleteObjectARB; +extern PFNGLDETACHOBJECTARBPROC qglDetachObjectARB; +extern PFNGLCREATESHADEROBJECTARBPROC qglCreateShaderObjectARB; +extern PFNGLSHADERSOURCEARBPROC qglShaderSourceARB; +extern PFNGLCOMPILESHADERARBPROC qglCompileShaderARB; +extern PFNGLCREATEPROGRAMOBJECTARBPROC qglCreateProgramObjectARB; +extern PFNGLATTACHOBJECTARBPROC qglAttachObjectARB; +extern PFNGLLINKPROGRAMARBPROC qglLinkProgramARB; +extern PFNGLUSEPROGRAMOBJECTARBPROC qglUseProgramObjectARB; +extern PFNGLVALIDATEPROGRAMARBPROC qglValidateProgramARB; +extern PFNGLGETUNIFORMLOCATIONARBPROC qglGetUniformLocationARB; +extern PFNGLUNIFORM1IARBPROC qglUniform1iARB; +extern PFNGLUNIFORM4FARBPROC qglUniform4fARB; +extern PFNGLUNIFORM4FVARBPROC qglUniform4fvARB; +extern PFNGLGETINFOLOGARBPROC qglGetInfoLogARB; +extern PFNGLGETOBJECTPARAMETERIVARBPROC qglGetObjectParameterivARB; +extern PFNGLGETATTACHEDOBJECTSARBPROC qglGetAttachedObjectsARB; + +extern bool Initialize( void ); +extern void InitializeExtensions( void ); +extern void CheckInit( void ); +extern void Shutdown( void ); + +extern ExtensionSupport_t ext; +} + +#endif //QFX_OPENGL_H diff --git a/code/cgame_hook/renderer/qfx_renderer.cpp b/code/cgame_hook/renderer/qfx_renderer.cpp new file mode 100644 index 00000000..8ef97aa7 --- /dev/null +++ b/code/cgame_hook/renderer/qfx_renderer.cpp @@ -0,0 +1,1585 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#include "qfx_library.h" +#include "qfx_log.h" +#include "qfx_settings.h" +#include "qfx_opengl.h" +#include "qfx_renderer.h" +#include "qfx_shader.h" +#include "qfx_glprogs.h" + +#include "script/cplayer.h" +#include "script/vision.h" + +#include "glb_local.h" + +//========================================= +// QFXRenderer class implementation +//----------------------------------------- +// This is QeffectsGL's core +//========================================= +using namespace gl; + +QFXRenderer :: QFXRenderer() +{ + m_hDC = 0; + m_hGLRC = 0; + m_uiFrameCounter = 0; + m_uiRenderFrame = 0; + m_uiRenderFrameCounter = 0; + m_uiViewportFrame = 0; + m_zNear = 1.0f; + m_zFar = 1000.0f; + m_bOrtho = GL_FALSE; + m_bZTrick = GL_FALSE; + m_bInternalAnisotropy = GL_FALSE; + m_bInternalMultisample = GL_FALSE; + m_bMultisample = GL_FALSE; + m_uiBlurTexture = 0; + m_uiBlurDepth = 0; + m_uiScreenRGB = 0; + m_uiScreenDepth = 0; + m_pBloomDarkenShader = NULL; + m_pBloomBlurShader = NULL; + m_pBloomCombineShader = NULL; + m_pSSAORenderShader = NULL; + m_pSSAOBlurShader = NULL; + m_pSSAOCombineShader = NULL; + m_pHSLShader = NULL; + m_pEmbossShader = NULL; + m_iEnableRender = 1; + m_flLastDepth = -1.0f; + m_flLastTime = timeGetTime(); + m_flOldTime = timeGetTime(); + m_flFrameTime = 0.001f; + + GetVariables(); +} + +void QFXRenderer :: GetVariables( void ) +{ + m_varDebug = r_debug->integer; //QFXSettings::Instance().GetInteger( "Debug", 0 ); + m_varCompareMode = 0; //QFXSettings::Instance().GetInteger( "CompareMode", 0 ); + + m_varZTrickFix = 1; //QFXSettings::Instance().GetInteger( "ZTrickFix", 0 ); + m_varViewportFix = 1; //QFXSettings::Instance().GetInteger( "ViewportFix", 0 ); + + m_varRenderFrame = r_debug->integer; //QFXSettings::Instance().GetInteger( "RenderFrame", 0 ); + + m_varAnisotropy = r_texFilterAniso->integer; //QFXSettings::Instance().GetInteger( "Anisotropy", 8 ); + + m_varMultisample = 8; //QFXSettings::Instance().GetInteger( "Multisample", 4 ); + m_varMultisampleHint = 0; //QFXSettings::Instance().GetInteger( "MultisampleHint", 0 ); + +#if 0 + m_varBloomEnable = r_glowEnable->integer && r_glow.integer; //QFXSettings::Instance().GetInteger( "Bloom", 1 ); + m_varBloomNumSteps = r_glowQuality->integer; //min( 16, QFXSettings::Instance().GetInteger( "BloomSteps", 8 ) ); + m_varBloomDarkenPower = ( r_glowBloomCutoff.value_current + 1.5f ) * 2.0f; //r_glowRadius0.value_current; //QFXSettings::Instance().GetFloat( "BloomDarken", 3 ); + m_varBloomRadius0 = r_glowRadius0.value_current; + m_varBloomRadius1 = r_glowRadius1.value_current; + m_varBloomCombineScale0 = r_glowBloomIntensity0.value_current; //QFXSettings::Instance().GetFloat( "BloomScale", 1.5f ); + m_varBloomCombineScale1 = r_glowBloomIntensity1.value_current; +#endif + + m_varSSAOEnable = r_ssao->integer; //QFXSettings::Instance().GetInteger( "SSAO", 1 ); + m_varSSAOScale = 8.0f; //QFXSettings::Instance().GetFloat( "SSAOScale", 8.0f ); + m_varSSAOMinZ = 0.005f; //QFXSettings::Instance().GetFloat( "SSAOMinZ", 0.005f ); + m_varSSAOMaxZ = 1.0f; //QFXSettings::Instance().GetFloat( "SSAOMaxZ", 1.0f ); + + m_varHue = 1; //QFXSettings::Instance().GetInteger( "Hue", 0 ); + m_varSaturation = 1; //QFXSettings::Instance().GetInteger( "Saturation", 0 ); + m_varLightness = 1; //QFXSettings::Instance().GetInteger( "Lightness", 0 ); + + m_varEmboss = 0; //QFXSettings::Instance().GetInteger( "Emboss", 1 ); + m_varEmbossScale = 0.5f; //QFXSettings::Instance().GetFloat( "EmbossScale", 0.5f ); + + m_varDOF = 0; //QFXSettings::Instance().GetInteger( "DOF", 1 ); + m_varDOFSpeed = 10.0f; //QFXSettings::Instance().GetFloat( "DOFSpeed", 1.0f ); + m_varDOFScale = 100.0f; //QFXSettings::Instance().GetFloat( "DOFScale", 2.0f ); + m_varDOFMinZ = 0.0f; //0.005f; //QFXSettings::Instance().GetFloat( "DOFMinZ", 0.005f ); +} + +int QFXRenderer :: ChooseMultisamplePixelFormat( int fmt, HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd ) +{ + static bool classRegistered = false; + GLint sampleBuffers = 0; + + // register temp window class + if ( !classRegistered ) { + WNDCLASS wc; + memset( &wc, 0, sizeof( wc ) ); + wc.lpfnWndProc = DefWindowProc; + wc.hInstance = GetModuleHandle( NULL ); + wc.lpszClassName = QFX_LIBRARY_TITLE; + + if ( !RegisterClass( &wc ) ) { + QFXLog::Instance().Error( "ChooseMultisamplePixelFormat: RegisterClass failed\n" ); + return -1; + } + + classRegistered = true; + } + + // create temporary hidden window + HWND tempHWND = CreateWindowEx ( 0, QFX_LIBRARY_TITLE, "", WS_POPUP, 0, 0, 1, 1, NULL, NULL, GetModuleHandle( NULL ), NULL ); + if ( !tempHWND ) { + QFXLog::Instance().Error( "ChooseMultisamplePixelFormat: CreateWindowEx failed\n" ); + return -1; + } + + HDC tempDC = GetDC( tempHWND ); + if ( !tempDC ) { + QFXLog::Instance().Error( "ChooseMultisamplePixelFormat: GetDC failed\n" ); + DestroyWindow( tempHWND ); + return -1; + } + + if( !gl::wglSetPixelFormat( tempDC, fmt, ppfd ) ) { + QFXLog::Instance().Error( "ChooseMultisamplePixelFormat: SetPixelFormat failed\n" ); + ReleaseDC( tempHWND, tempDC ); + DestroyWindow( tempHWND ); + return -1; + } + + HGLRC tempRC = gl::wglCreateContext( tempDC ); + if ( !tempRC ) { + QFXLog::Instance().Error( "ChooseMultisamplePixelFormat: wglCreateContext failed\n" ); + ReleaseDC( tempHWND, tempDC ); + DestroyWindow( tempHWND ); + return -1; + } + + if ( !gl::wglMakeCurrent( tempDC, tempRC ) ) { + gl::wglDeleteContext( tempRC ); + QFXLog::Instance().Error( "ChooseMultisamplePixelFormat: wglMakeCurrent failed\n" ); + ReleaseDC( tempHWND, tempDC ); + DestroyWindow( tempHWND ); + return -1; + } + + qglGetIntegerv( GL_SAMPLE_BUFFERS_ARB, &sampleBuffers ); + if ( sampleBuffers ) + m_bInternalMultisample = GL_TRUE; + + PFNWGLCHOOSEPIXELFORMATARBPROC qwglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)gl::wglGetProcAddress( "wglChoosePixelFormatARB" ); + if ( !qwglChoosePixelFormatARB ) { + gl::wglMakeCurrent( tempDC, NULL ); + gl::wglDeleteContext( tempRC ); + QFXLog::Instance().Warning( "missing extension WGL_ARB_pixel_format\n" ); + QFXLog::Instance().Warning( "multisample is not supported\n" ); + ReleaseDC( tempHWND, tempDC ); + DestroyWindow( tempHWND ); + return -1; + } + + int pixelFormat; + UINT numFormats; + float fAttributes[] = { 0, 0 }; + + while ( m_varMultisample >= 2 ) { + int iAttributes[] = { + WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, + WGL_SUPPORT_OPENGL_ARB, GL_TRUE, + WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, + WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, + WGL_COLOR_BITS_ARB, 32, + WGL_ALPHA_BITS_ARB, ppfd->cAlphaBits, + WGL_DEPTH_BITS_ARB, (ppfd->cDepthBits > 16) ? 24 : 16, + WGL_STENCIL_BITS_ARB, ppfd->cStencilBits, + WGL_DOUBLE_BUFFER_ARB, (ppfd->dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE, + WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, + WGL_SAMPLES_ARB, m_varMultisample, + 0,0}; + + if ( qwglChoosePixelFormatARB( tempDC, iAttributes, fAttributes, 1, &pixelFormat, &numFormats ) ) { + if ( numFormats > 0 ) + break; + } + + QFXLog::Instance().Warning( "%ix FSAA is not supported\n", m_varMultisample ); + + if (m_varMultisample > 8) + m_varMultisample >>= 1; + else + m_varMultisample -= 2; + } + + if ( m_varMultisample >= 2 ) { + QFXLog::Instance().Printf( "Using %ix FSAA\n", m_varMultisample ); + } else { + QFXLog::Instance().Warning( "FSAA is not supported by hardware\n" ); + pixelFormat = -1; + } + + gl::wglMakeCurrent( tempDC, NULL ); + gl::wglDeleteContext( tempRC ); + ReleaseDC( tempHWND, tempDC ); + DestroyWindow( tempHWND ); + return pixelFormat; +} + +BOOL QFXRenderer :: OnSetPixelFormat( HDC hdc, int pixelformat, CONST PIXELFORMATDESCRIPTOR *ppfd ) +{ + if ( m_varMultisample > 1 ) { + int multisamplePixelFormat = ChooseMultisamplePixelFormat( pixelformat, hdc, ppfd ); + if ( multisamplePixelFormat >= 0 ) { + BOOL b = gl::wglSetPixelFormat( hdc, multisamplePixelFormat, ppfd ); + if ( b ) { + m_bMultisample = GL_TRUE; + return b; + } + } + } + + return gl::wglSetPixelFormat( hdc, pixelformat, ppfd ); +} + +void QFXRenderer :: OnMakeCurrent( HDC hdc, HGLRC hglrc ) +{ + if ( !hdc || !hglrc ) + return; + + if ( hdc != m_hDC || hglrc != m_hGLRC ) { + m_hDC = hdc; + m_hGLRC = hglrc; + gl::InitializeExtensions(); + InitializeGL(); + + if ( m_varMultisample ) { + qglEnable( GL_MULTISAMPLE_ARB ); + if ( m_varMultisampleHint ) + qglHint( GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST ); + } + } +} + +void QFXRenderer :: OnDeleteContext( HGLRC hglrc ) +{ + if ( !hglrc ) + return; + + if ( hglrc == m_hGLRC ) + ShutdownGL(); +} + +void QFXRenderer :: OnSwapBuffers( void ) +{ + if ( -1 == m_varRenderFrame ) + RenderGL(); + + m_uiFrameCounter++; +} + +void QFXRenderer :: SetupAnisotropy( void ) +{ + m_bInternalAnisotropy = GL_TRUE; +} + +void QFXRenderer :: OnTexImage2D( void ) +{ + if ( ext.maxAnisotropy > 1 && m_varAnisotropy > 1 ) { + int value = min( ext.maxAnisotropy, m_varAnisotropy ); + qglTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, value ); + } +} + +void QFXRenderer :: CheckHardware( void ) +{ + QFXLog::Instance().Printf( "Checking hardware caps:\n" ); + + m_bSupportsBloom = GL_TRUE; //(( ( ext.maxActiveTextures >= 2 ) && ext.VertexShader && ext.FragmentShader && ext.RectangleTexture ) ? GL_TRUE : GL_FALSE ); + m_bSupportsSSAO = GL_TRUE; //(( ( ext.maxActiveTextures >= 2 ) && ext.VertexShader && ext.FragmentShader && ext.RectangleTexture && ext.DepthTexture ) ? GL_TRUE : GL_FALSE ); + m_bSupportsColorCorrection = GL_TRUE; //(( ext.VertexShader && ext.FragmentShader && ext.RectangleTexture ) ? GL_TRUE : GL_FALSE ); + m_bSupportsEmboss = GL_TRUE; //(( ext.VertexShader && ext.FragmentShader && ext.RectangleTexture ) ? GL_TRUE : GL_FALSE ); + m_bSupportsDOF = GL_TRUE; //(( ( ext.maxActiveTextures >= 3 ) && ext.VertexShader && ext.FragmentShader && ext.RectangleTexture && ext.DepthTexture ) ? GL_TRUE : GL_FALSE ); +} + +void QFXRenderer :: InitializeGL( void ) +{ + GLboolean stateRectangleEnabled; + //GLboolean state2DEnabled; + GLuint stateRectangleBinding = 0; + GLuint state2DBinding = 0; + qglGetIntegerv( GL_VIEWPORT, m_3DViewport ); + + m_uiTextureIndex = QFX_TEXTURE_IDENTIFIER_BASE; + + QFXLog::Instance().Printf( "InitializeGL\n" ); + + HWND hCurrentWnd = WindowFromDC( gl::wglGetCurrentDC() ); + RECT rc; + GetClientRect( hCurrentWnd, &rc ); + m_WindowSize[0] = rc.right - rc.left; + m_WindowSize[1] = rc.bottom - rc.top; + + CheckHardware(); + + // load GLSL shaders + if ( m_bSupportsBloom ) { + m_pBloomDarkenShader = new QFXShader( g_szVertexShader_BloomDarken, g_szFragmentShader_BloomDarken, "Bloom Darken" ); + m_pBloomBlurShader = new QFXShader( g_szVertexShader_BloomBlur, g_szFragmentShader_BloomBlur, "Bloom Blur" ); + //m_pBloomBlurVertShader = new QFXShader( g_szVertexShader_BloomBlurVert, g_szFragmentShader_BloomBlurVert, "Bloom Blur Vertical" ); + m_pBloomCombineShader = new QFXShader( g_szVertexShader_BloomCombine, g_szFragmentShader_BloomCombine, "Bloom Combine" ); + if ( !m_pBloomDarkenShader || !m_pBloomDarkenShader->IsValid() ) m_bSupportsBloom = GL_FALSE; + if ( !m_pBloomBlurShader || !m_pBloomBlurShader->IsValid() ) m_bSupportsBloom = GL_FALSE; + if ( !m_pBloomCombineShader || !m_pBloomCombineShader->IsValid() ) m_bSupportsBloom = GL_FALSE; + } + + if ( m_bSupportsSSAO ) { + m_pSSAORenderShader = new QFXShader( g_szVertexShader_SSAORender, g_szFragmentShader_SSAORender, "SSA Renderer" ); + m_pSSAOBlurShader = new QFXShader( g_szVertexShader_SSAOBlur, g_szFragmentShader_SSAOBlur, "SSAO Blur" ); + m_pSSAOCombineShader = new QFXShader( g_szVertexShader_SSAOCombine, g_szFragmentShader_SSAOCombine, "SSAO Combine" ); + if ( !m_pSSAORenderShader || !m_pSSAORenderShader->IsValid() ) m_bSupportsSSAO = GL_FALSE; + if ( !m_pSSAOBlurShader || !m_pSSAOBlurShader->IsValid() ) m_bSupportsSSAO = GL_FALSE; + if ( !m_pSSAOCombineShader || !m_pSSAOCombineShader->IsValid() ) m_bSupportsSSAO = GL_FALSE; + } + + if ( m_bSupportsColorCorrection ) { + m_pHSLShader = new QFXShader( g_szVertexShader_HSL, g_szFragmentShader_HSL, "HSL Shader" ); + if ( !m_pHSLShader || !m_pHSLShader->IsValid() ) m_bSupportsColorCorrection = GL_FALSE; + } + + if ( m_bSupportsEmboss ) { + m_pEmbossShader = new QFXShader( g_szVertexShader_Emboss, g_szFragmentShader_Emboss, "Emboss Shader" ); + if ( !m_pEmbossShader || !m_pEmbossShader->IsValid() ) m_bSupportsEmboss = GL_FALSE; + } + + if ( m_bSupportsDOF ) { + m_pDOFBlurShader = new QFXShader( g_szVertexShader_DOFBlur, g_szFragmentShader_DOFBlur, "DOF Blur" ); + m_pDOFDepthShader = new QFXShader( g_szVertexShader_DOFDepth, g_szFragmentShader_DOFDepth, "DOF Depth" ); + m_pDOFRenderShader = new QFXShader( g_szVertexShader_DOFRender, g_szFragmentShader_DOFRender, "DOF Render" ); + if ( !m_pDOFBlurShader || !m_pDOFBlurShader->IsValid() ) m_bSupportsDOF = GL_FALSE; + if ( !m_pDOFDepthShader || !m_pDOFDepthShader->IsValid() ) m_bSupportsDOF = GL_FALSE; + if ( !m_pDOFRenderShader || !m_pDOFRenderShader->IsValid() ) m_bSupportsDOF = GL_FALSE; + } + + m_pBrightnessContrastShader = new QFXShader( g_szVertexShader_BrightnessContrast, g_szFragmentShader_BrightnessContrast, "Brightness and contrast" ); + m_pTintShader = new QFXShader( g_szVertexShader_Tint, g_szFragmentShader_Tint, "Tint" ); + m_pBleachShader = new QFXShader( g_szVertexShader_Bleach, g_szFragmentShader_Bleach, "Bleach" ); + /*m_pMotionBlurShader = new QFXShader( g_szVertexShader_MotionBlur, g_szFragmentShader_MotionBlur, "Motion Blur" ); + m_pShadowShader = new QFXShader( g_szVertexShader_Shadow, g_szFragmentShader_Shadow, "Shadow" ); + m_pLightReflectShader = new QFXShader( g_szVertexShader_LightReflection, g_szFragmentShader_LightReflection, "Light Reflection" );*/ + m_pDistortionShader = new QFXShader( g_szVertexShader_Distortion, g_szFragmentShader_Distortion, "Distortion" ); + m_pBlurShader = new QFXShader( g_szVertexShader_Blur, g_szFragmentShader_Blur, "Blur" ); + + m_pFXAAShader = new QFXShader( g_szVertexShader_FXAA, g_szFragmentShader_FXAA, "FXAA" ); + m_pDisplacement = new QFXShader( g_szVertexShader_Displacement, g_szFragmentShader_Displacement, "Displacement Mapping" ); + + m_pShadowMapping = new QFXShader( g_szVertexShader_ShadowMap, g_szFragmentShader_ShadowMap, "Shadow Mapping" ); + + // create textures + if ( ext.RectangleTexture ) { + stateRectangleEnabled = qglIsEnabled( GL_TEXTURE_RECTANGLE_ARB ); + qglGetIntegerv( GL_TEXTURE_BINDING_RECTANGLE_ARB, ( GLint* )( &stateRectangleBinding ) ); + qglEnable( GL_TEXTURE_RECTANGLE_ARB ); + + if ( m_bSupportsBloom || m_bSupportsSSAO || m_bSupportsDOF ) { + m_uiBlurTexture = AllocTextureId(); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurTexture ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, ext.edgeClampMode ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, ext.edgeClampMode ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + qglTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 3, m_3DViewport[ 2 ] >> 1, m_3DViewport[ 3 ] >> 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0 ); + } + if ( m_bSupportsDOF ) { + m_uiBlurDepth = AllocTextureId(); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurDepth ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, ext.edgeClampMode ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, ext.edgeClampMode ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + qglTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 3, m_3DViewport[ 2 ] >> 1, m_3DViewport[ 3 ] >> 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0 ); + } + + m_uiScreenRGB = AllocTextureId(); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiScreenRGB ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, ext.edgeClampMode ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, ext.edgeClampMode ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + qglTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 3, m_3DViewport[ 2 ], m_3DViewport[ 3 ], 0, GL_RGB, GL_UNSIGNED_BYTE, 0 ); + + /* + //m_eyeLeft = AllocTextureId(); + qglBindTexture( GL_TEXTURE_2D, AllocTextureId() ); + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); + qglTexImage2D( GL_TEXTURE_2D, 0, 4, m_3DViewport[ 2 ], m_3DViewport[ 3 ], 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0 ); + + //m_eyeRight = AllocTextureId(); + qglBindTexture( GL_TEXTURE_2D, AllocTextureId() ); + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); + qglTexImage2D( GL_TEXTURE_2D, 0, 4, m_3DViewport[ 2 ], m_3DViewport[ 3 ], 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0 ); + */ + + if ( m_bSupportsSSAO || m_bSupportsDOF ) { + m_uiScreenDepth = AllocTextureId(); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiScreenDepth ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, ext.edgeClampMode ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, ext.edgeClampMode ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + qglTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, GL_DEPTH_COMPONENT24, m_3DViewport[ 2 ], m_3DViewport[ 3 ], 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0 ); + } + + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, stateRectangleBinding ); + if ( !stateRectangleEnabled ) qglDisable( GL_TEXTURE_RECTANGLE_ARB ); + + // Try to use a texture depth component + m_uiShadowDepth = AllocTextureId(); + qglBindTexture( GL_TEXTURE_2D, m_uiShadowDepth ); + + // GL_LINEAR does not make sense for depth texture. However, next tutorial shows usage of GL_LINEAR and PCF + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + + // Remove artefact on the edges of the shadowmap + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); + + qglTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 256, 256, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0 ); + qglBindTexture( GL_TEXTURE_2D, 0 ); + } + + if( ext.FBO ) + { + // create a framebuffer object + qglGenFramebuffersEXT( 1, &m_uiFrameBuffer ); + qglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_uiFrameBuffer ); + qglFramebufferTexture2DEXT( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_uiShadowDepth, 0 ); + qglDrawBuffer( GL_NONE ); + qglReadBuffer( GL_NONE ); + qglBindFramebufferEXT( GL_FRAMEBUFFER, 0 ); + } + +/* state2DEnabled = qglIsEnabled( GL_TEXTURE_2D ); + qglGetIntegerv( GL_TEXTURE_BINDING_2D, (GLint*)(&state2DBinding) ); + qglEnable( GL_TEXTURE_2D ); + + //load 2D textures, if any + + qglBindTexture( GL_TEXTURE_2D, state2DBinding ); + if ( !state2DEnabled ) qglDisable( GL_TEXTURE_2D );*/ + + if ( !m_uiScreenRGB ) { + m_bSupportsEmboss = GL_FALSE; + m_bSupportsColorCorrection = GL_FALSE; + m_bSupportsSSAO = GL_FALSE; + m_bSupportsDOF = GL_FALSE; + m_bSupportsBloom = GL_FALSE; + } + if ( !m_uiBlurTexture ) { + m_bSupportsBloom = GL_FALSE; + m_bSupportsSSAO = GL_FALSE; + m_bSupportsDOF = GL_FALSE; + } + if ( !m_uiScreenDepth ) { + m_bSupportsSSAO = GL_FALSE; + m_bSupportsDOF = GL_FALSE; + } + if ( !m_uiBlurDepth ) { + m_bSupportsDOF = GL_FALSE; + } +} + +void QFXRenderer :: ShutdownGL( void ) +{ + QFXLog::Instance().Printf( "ShutdownGL\n" ); + + if ( m_pBloomDarkenShader ) { + delete m_pBloomDarkenShader; + m_pBloomDarkenShader = NULL; + } + if ( m_pBloomBlurShader ) { + delete m_pBloomBlurShader; + m_pBloomBlurShader = NULL; + } + if ( m_pBloomCombineShader ) { + delete m_pBloomCombineShader; + m_pBloomCombineShader = NULL; + } + if ( m_pSSAORenderShader ) { + delete m_pSSAORenderShader; + m_pSSAORenderShader = NULL; + } + if ( m_pSSAOBlurShader ) { + delete m_pSSAOBlurShader; + m_pSSAOBlurShader = NULL; + } + if ( m_pSSAOCombineShader ) { + delete m_pSSAOCombineShader; + m_pSSAOCombineShader = NULL; + } + if ( m_pHSLShader ) { + delete m_pHSLShader; + m_pHSLShader = NULL; + } + if ( m_pEmbossShader ) { + delete m_pEmbossShader; + m_pEmbossShader = NULL; + } + if ( m_pDOFBlurShader ) { + delete m_pDOFBlurShader; + m_pDOFBlurShader = NULL; + } + if ( m_pDOFDepthShader ) { + delete m_pDOFDepthShader; + m_pDOFDepthShader = NULL; + } + if ( m_pDOFRenderShader ) { + delete m_pDOFRenderShader; + m_pDOFRenderShader = NULL; + } + + if ( m_uiBlurTexture ) { + qglDeleteTextures( 1, &m_uiBlurTexture ); + m_uiBlurTexture = 0; + } + if ( m_uiBlurDepth ) { + qglDeleteTextures( 1, &m_uiBlurDepth ); + m_uiBlurDepth = 0; + } + if ( m_uiScreenRGB ) { + qglDeleteTextures( 1, &m_uiScreenRGB ); + m_uiScreenRGB = 0; + } + if ( m_uiScreenDepth ) { + qglDeleteTextures( 1, &m_uiScreenDepth ); + m_uiScreenDepth = 0; + } +} + +void QFXRenderer :: SetupZDimensions( GLfloat znear, GLfloat zfar ) +{ + m_zNear = znear; + m_zFar = zfar; + + if ( r_debug->integer ) + QFXLog::Instance().Printf("%5i: SetupZDimensions zn = %f, zf = %f\n", m_uiFrameCounter, m_zNear, m_zFar ); +} + +void QFXRenderer :: SetupZDimensions( const GLfloat* matrix ) +{ + GLfloat fC = matrix[2*4+2]; + GLfloat fD = matrix[3*4+2]; + GLfloat fQ = (1.0f + fC) / (1.0f - fC); + m_zFar = (fD * (1.0f + fQ)) / (2.0f * fQ); + m_zNear = (fD * m_zFar) / (fD - 2.0f*m_zFar); + if ( m_zFar < 0 ) m_zFar = -m_zFar; + + if ( r_debug->integer ) + QFXLog::Instance().Printf("%5i: SetupZDimensions zn = %f, zf = %f\n", m_uiFrameCounter, m_zNear, m_zFar ); +} + +void QFXRenderer :: SetupZDimensions( const GLdouble* matrix ) +{ + GLfloat fC = (GLfloat)matrix[2*4+2]; + GLfloat fD = (GLfloat)matrix[3*4+2]; + GLfloat fQ = (1.0f + fC) / (1.0f - fC); + m_zFar = (fD * (1.0f + fQ)) / (2.0f * fQ); + m_zNear = (fD * m_zFar) / (fD - 2.0f*m_zFar); + if ( m_zFar < 0 ) m_zFar = -m_zFar; + + if ( r_debug->integer ) + QFXLog::Instance().Printf("%5i: SetupZDimensions zn = %f, zf = %f\n", m_uiFrameCounter, m_zNear, m_zFar ); +} + +void QFXRenderer :: SetupDepthFunc( GLenum func ) +{ + if ( m_varZTrickFix && ( func == GL_GEQUAL ) ) { + m_bZTrick = true; + if ( r_debug->integer ) + QFXLog::Instance().Printf("%5i: ZTrick attempt detected\n", m_uiFrameCounter ); + qglDepthFunc( GL_LEQUAL ); + } else { + qglDepthFunc( func ); + } + + if ( m_bZTrick ) + qglClear( GL_DEPTH_BUFFER_BIT ); +} + +void QFXRenderer :: SetupDepthRange( GLclampd zNear, GLclampd zFar ) +{ + if ( m_bZTrick ) { + if ( zNear > zFar ) { + zNear = 1.0f - zNear; + zFar = 1.0f - zFar; + } + if ( zFar > 0.45 ) zFar = 1.0; + if ( zNear > 0.99 ) zNear = 0.0f; + } + qglDepthRange( zNear, zFar ); +} + +void QFXRenderer :: SetupMultisample( void ) +{ + m_bInternalMultisample = GL_TRUE; +} + +void gluLookAt( float eyeX, float eyeY, float eyeZ, float lookAtX, float lookAtY, float lookAtZ, float upX, float upY, float upZ ) +{ + // i am not using here proper implementation for vectors. + // if you want, you can replace the arrays with your own + // vector types + float f[ 3 ]; + + // calculating the viewing vector + f[ 0 ] = lookAtX - eyeX; + f[ 1 ] = lookAtY - eyeY; + f[ 2 ] = lookAtZ - eyeZ; + + float fMag, upMag; + fMag = sqrt( f[ 0 ] * f[ 0 ] + f[ 1 ] * f[ 1 ] + f[ 2 ] * f[ 2 ] ); + upMag = sqrt( upX*upX + upY*upY + upZ*upZ ); + + // normalizing the viewing vector + if( fMag != 0 ) + { + f[ 0 ] = f[ 0 ] / fMag; + f[ 1 ] = f[ 1 ] / fMag; + f[ 2 ] = f[ 2 ] / fMag; + } + + // normalising the up vector. no need for this here if you have your + // up vector already normalised, which is mostly the case. + if( upMag != 0 ) + { + upX = upX / upMag; + upY = upY / upMag; + upZ = upZ / upMag; + } + + float s[ 3 ], u[ 3 ]; + + CrossProduct( Vector( f[ 0 ], f[ 1 ], f[ 2 ] ), Vector( upX, upY, upZ ), s ); + CrossProduct( Vector( s[ 0 ], s[ 1 ], s[ 2 ] ), Vector( f[ 0 ], f[ 1 ], f[ 2 ] ), u ); + + float M[] = + { + s[ 0 ], u[ 0 ], -f[ 0 ], 0, + s[ 1 ], u[ 1 ], -f[ 1 ], 0, + s[ 2 ], u[ 2 ], -f[ 2 ], 0, + 0, 0, 0, 1 + }; + + qglMultMatrixf( M ); + qglTranslatef( -eyeX, -eyeY, -eyeZ ); +} + +void QFXRenderer::PreRenderScene( struct refDef_s *fd ) +{ + +} + +void QFXRenderer :: RenderGL( void ) +{ + DWORD t = timeGetTime(); + m_flFrameTime = (t - m_flOldTime) * 0.001f; + m_flOldTime = t; + + if ( m_varCompareMode ) { + if ( t - m_flLastTime > 2000 ) { + m_flLastTime = t; + + m_iEnableRender ^= 1; + + if ( (m_varAnisotropy > 1) && (ext.maxAnisotropy > 1) && !m_bInternalAnisotropy ) { + int value = m_iEnableRender ? min( ext.maxAnisotropy, m_varAnisotropy ) : 1; + GLuint state2DBinding; + qglGetIntegerv( GL_TEXTURE_BINDING_2D, (GLint*)(&state2DBinding) ); + for ( GLuint i = 1; i < 9999; i++ ) { + if ( qglIsTexture( i ) ) { + qglBindTexture( GL_TEXTURE_2D, i ); + qglTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, value ); + } + } + qglBindTexture( GL_TEXTURE_2D, state2DBinding ); + } + if ( m_bMultisample && !m_bInternalMultisample ) { + if ( m_iEnableRender ) + qglEnable( GL_MULTISAMPLE_ARB ); + else + qglDisable( GL_MULTISAMPLE_ARB ); + } + } + } + + if ( m_iEnableRender ) { + if ( r_debug->integer ) + QFXLog::Instance().Printf( "%5i: Postprocess at %i\n", m_uiFrameCounter, m_uiRenderFrame ); + PostProcess(); + } +} + +void QFXRenderer :: SetOrtho( GLboolean enable ) +{ + if ( r_debug->integer ) + QFXLog::Instance().Printf("%5i|%5i|%5i: ortho = %s\n", m_uiFrameCounter, m_uiRenderFrame, m_uiRenderFrameCounter, enable ? "true" : "false" ); + + if ( enable ) { + if ( m_uiRenderFrameCounter != m_uiFrameCounter ) { + m_uiRenderFrameCounter = m_uiFrameCounter; + m_uiRenderFrame = 0; + } else { + m_uiRenderFrame++; + } + + if ( m_uiRenderFrame == m_varRenderFrame ) + RenderGL(); + } else { + if ( m_uiViewportFrame != m_uiFrameCounter ) { + m_uiViewportFrame = m_uiFrameCounter; + qglGetIntegerv( GL_VIEWPORT, m_3DViewport ); + } + } + + m_bOrtho = enable; +} + +void QFXRenderer :: CaptureRGB( void ) +{ + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiScreenRGB ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[1] - m_3DViewport[3], m_3DViewport[2], m_3DViewport[3] ); +} + +void QFXRenderer :: CaptureDepth( void ) +{ + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiScreenDepth ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[1] - m_3DViewport[3], m_3DViewport[2], m_3DViewport[3] ); +} + +void QFXRenderer :: RenderFSQ( int wide, int tall ) +{ + float screenWidth = (float)wide; + float screenHeight = (float)tall; + + qglBegin( GL_QUADS ); + qglTexCoord2f( 0, screenHeight ); + qglVertex2f( 0, 0 ); + qglTexCoord2f( screenWidth, screenHeight ); + qglVertex2f( screenWidth, 0 ); + qglTexCoord2f( screenWidth, 0 ); + qglVertex2f( screenWidth, screenHeight ); + qglTexCoord2f( 0, 0 ); + qglVertex2f( 0, screenHeight ); + qglEnd(); +} + +void QFXRenderer :: RenderScaledFSQ( int wide, int tall, int wide2, int tall2 ) +{ + float screenWidth = (float)wide; + float screenHeight = (float)tall; + float screenWidth2 = (float)wide2; + float screenHeight2 = (float)tall2; + + qglBegin( GL_QUADS ); + qglTexCoord2f( 0, screenHeight2 ); + qglVertex2f( 0, 0 ); + qglTexCoord2f( screenWidth2, screenHeight2 ); + qglVertex2f( screenWidth, 0 ); + qglTexCoord2f( screenWidth2, 0 ); + qglVertex2f( screenWidth, screenHeight ); + qglTexCoord2f( 0, 0 ); + qglVertex2f( 0, screenHeight ); + qglEnd(); +} + +void QFXRenderer :: PostProcess( void ) +{ + GLboolean stateRectangleEnabled; + GLboolean state2DEnabled; + GLboolean stateBlendEnabled; + GLboolean stateCullEnabled; + GLboolean stateDepthTestEnabled; + GLboolean stateScissorEnabled; + GLuint stateRectangleBinding = 0; + GLuint state2DBinding = 0; + GLuint stateRectangleBindingMTex[3] = { 0, 0, 0 }; + GLenum stateSrcBlendFunc = GL_ONE; + GLenum stateDstBlendFunc = GL_ZERO; + GLenum stateMatrixMode = GL_MODELVIEW; + GLenum stateActiveTexture = GL_TEXTURE0_ARB; + GLenum stateTexEnv = GL_MODULATE; + GLboolean stateDepthMask = GL_FALSE; + GLfloat stateCurrentColor[4]; + GLhandleARB currentGLSLShader = 0; + GLint stateViewport[4]; + + // save current state + state2DEnabled = qglIsEnabled( GL_TEXTURE_2D ); + qglGetIntegerv( GL_TEXTURE_BINDING_2D, (GLint*)(&state2DBinding) ); + + if ( ext.RectangleTexture ) { + stateRectangleEnabled = qglIsEnabled( GL_TEXTURE_RECTANGLE_ARB ); + qglGetIntegerv( GL_TEXTURE_BINDING_RECTANGLE_ARB, (GLint*)(&stateRectangleBinding) ); + } + if ( ext.VertexShader || ext.FragmentShader ) { + currentGLSLShader = qglGetHandleARB( GL_PROGRAM_OBJECT_ARB ); + } + if ( ext.Multitexture ) { + qglGetIntegerv( GL_ACTIVE_TEXTURE_ARB, (GLint*)(&stateActiveTexture) ); + qglActiveTextureARB( GL_TEXTURE0_ARB ); + if ( ext.RectangleTexture ) { + qglActiveTextureARB( GL_TEXTURE1_ARB ); + qglGetIntegerv( GL_TEXTURE_BINDING_RECTANGLE_ARB, (GLint*)(&stateRectangleBindingMTex[1]) ); + qglActiveTextureARB( GL_TEXTURE2_ARB ); + qglGetIntegerv( GL_TEXTURE_BINDING_RECTANGLE_ARB, (GLint*)(&stateRectangleBindingMTex[2]) ); + qglActiveTextureARB( GL_TEXTURE0_ARB ); + qglGetIntegerv( GL_TEXTURE_BINDING_RECTANGLE_ARB, (GLint*)(&stateRectangleBindingMTex[0]) ); + } + } + + stateBlendEnabled = qglIsEnabled( GL_BLEND ); + stateCullEnabled = qglIsEnabled( GL_CULL_FACE ); + stateDepthTestEnabled = qglIsEnabled( GL_DEPTH_TEST ); + stateScissorEnabled = qglIsEnabled( GL_SCISSOR_TEST ); + qglGetIntegerv( GL_BLEND_SRC, (GLint*)(&stateSrcBlendFunc) ); + qglGetIntegerv( GL_BLEND_DST, (GLint*)(&stateDstBlendFunc) ); + qglGetIntegerv( GL_MATRIX_MODE, (GLint*)(&stateMatrixMode) ); + qglGetBooleanv( GL_DEPTH_WRITEMASK, &stateDepthMask ); + qglGetFloatv( GL_CURRENT_COLOR, stateCurrentColor ); + if ( !m_varViewportFix ) qglGetIntegerv( GL_VIEWPORT, stateViewport ); + qglGetIntegerv( GL_SCISSOR_BOX, m_3DScissor ); + qglGetTexEnviv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, (GLint*)(&stateTexEnv) ); + + // setup new state + qglDisable( GL_CULL_FACE ); + qglDisable( GL_DEPTH_TEST ); + qglDisable( GL_BLEND ); + qglEnable( GL_TEXTURE_2D ); + qglEnable( GL_TEXTURE_RECTANGLE_ARB ); + qglEnable( GL_SCISSOR_TEST ); + qglDepthMask( GL_FALSE ); + qglMatrixMode( GL_PROJECTION ); + qglPushMatrix(); + qglLoadIdentity(); + qglOrtho( 0, m_WindowSize[0], m_WindowSize[1], 0, -99999, 99999 ); + qglMatrixMode( GL_MODELVIEW ); + qglPushMatrix(); + qglLoadIdentity(); + qglColor4f( 1, 1, 1, 1 ); + if ( !m_varViewportFix ) qglViewport( m_3DViewport[0], m_3DViewport[1], m_3DViewport[2], m_3DViewport[3] ); + qglScissor( m_3DViewport[0], m_3DViewport[1], m_3DViewport[2], m_3DViewport[3] ); + + //PostProcess_Reflections(); + //PostProcess_Shadows(); + + // render DOF + if( m_bSupportsDOF && r_dof->integer ) { + PostProcess_DOF(); + } + + // render SSAO + if( m_bSupportsSSAO && r_ssao->integer ) { + PostProcess_SSAO(); + } + + // render distortions + if( r_distortionEnable.isEnabled() ) { + PostProcess_Distortion(); + } + + // render Emboss + if( m_bSupportsEmboss && m_varEmboss ) { + PostProcess_Emboss(); + } + + //if( r_filmEnable.isEnabled() ) + //{ + PostProcess_ColorCorrection(); + PostProcess_Tint(); + //PostProcess_BrightnessContrast(); + PostProcess_Bleach(); + //} + + PostProcess_Blur(); + + // render bloom effect + if( m_bSupportsBloom && r_glowEnable->integer && r_glow.isEnabled() ) { + PostProcess_Bloom(); + } + + if( r_fxaa->integer ) + { + PostProcess_FXAA(); + } + + //PostProcess_MotionBlur(); + + // restore current state + qglMatrixMode( GL_PROJECTION ); + qglPopMatrix(); + qglMatrixMode( GL_MODELVIEW ); + qglPopMatrix(); + if ( ext.Multitexture ) { + if ( ext.RectangleTexture ) { + qglActiveTextureARB( GL_TEXTURE1_ARB ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, stateRectangleBindingMTex[1] ); + qglActiveTextureARB( GL_TEXTURE2_ARB ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, stateRectangleBindingMTex[2] ); + qglActiveTextureARB( GL_TEXTURE0_ARB ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, stateRectangleBindingMTex[0] ); + } + qglActiveTextureARB( stateActiveTexture ); + } + if ( ext.RectangleTexture ) { + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, stateRectangleBinding ); + if ( !stateRectangleEnabled ) qglDisable( GL_TEXTURE_RECTANGLE_ARB ); + } + qglBindTexture( GL_TEXTURE_2D, state2DBinding ); + if ( !state2DEnabled ) qglDisable( GL_TEXTURE_2D ); + qglBlendFunc( stateSrcBlendFunc, stateDstBlendFunc ); + qglColor4fv( stateCurrentColor ); + qglMatrixMode( stateMatrixMode ); + if ( stateBlendEnabled ) qglEnable( GL_BLEND ); else qglDisable( GL_BLEND ); + if ( stateCullEnabled ) qglEnable( GL_CULL_FACE ); + if ( stateDepthTestEnabled ) qglEnable( GL_DEPTH_TEST ); + if ( !stateScissorEnabled ) qglDisable( GL_SCISSOR_TEST ); + qglScissor( m_3DScissor[0], m_3DScissor[1], m_3DScissor[2], m_3DScissor[3] ); + if ( !m_varViewportFix ) qglViewport( stateViewport[0], stateViewport[1], stateViewport[2], stateViewport[3] ); + qglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, stateTexEnv ); + if ( ext.VertexShader || ext.FragmentShader ) qglUseProgramObjectARB( currentGLSLShader ); + qglDepthMask( stateDepthMask ); +} + +void QFXRenderer :: PostProcess_SSAO( void ) +{ + int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + int blurTexWidth = m_3DViewport[2]>>1; + int blurTexHeight = m_3DViewport[3]>>1; + + // capture screen + CaptureRGB(); + + // capture depth + CaptureDepth(); + + // render raw SSAO + m_pSSAORenderShader->Bind(); + m_pSSAORenderShader->SetParameter4f( 0, 2.0f * m_zNear, m_zFar - m_zNear, (float)screenWidth, (float)screenHeight ); + m_pSSAORenderShader->SetParameter4f( 1, m_varSSAOMinZ, m_varSSAOMaxZ, m_varSSAOScale, 0 ); + RenderScaledFSQ( blurTexWidth, blurTexHeight, screenWidth, screenHeight ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurTexture ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[1] - blurTexHeight, blurTexWidth, blurTexHeight ); + + // blur SSAO + m_pSSAOBlurShader->Bind(); + m_pSSAOBlurShader->SetParameter4f( 0, 1, 0, 0, 0 ); + qglActiveTextureARB( GL_TEXTURE1_ARB ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiScreenDepth ); + qglActiveTextureARB( GL_TEXTURE0_ARB ); + RenderFSQ( blurTexWidth, blurTexHeight ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[1] - blurTexHeight, blurTexWidth, blurTexHeight ); + m_pSSAOBlurShader->SetParameter4f( 0, 0, 1, 0, 0 ); + RenderFSQ( blurTexWidth, blurTexHeight ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[1] - blurTexHeight, blurTexWidth, blurTexHeight ); + + // combine normal and AO scenes + m_pSSAOCombineShader->Bind(); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiScreenRGB ); + qglActiveTextureARB( GL_TEXTURE1_ARB ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurTexture ); + qglActiveTextureARB( GL_TEXTURE0_ARB ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pSSAOCombineShader->Unbind(); +} + +void QFXRenderer :: PostProcess_Bloom( void ) +{ + int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + int blurTexWidth = m_3DViewport[2]>>1; + int blurTexHeight = m_3DViewport[3]>>1; + + // capture screen + CaptureRGB(); + + // darken screen + m_pBloomDarkenShader->Bind(); + m_pBloomDarkenShader->SetParameter4f( 0, ( r_glowBloomCutoff.floatValue() + 1.5f ) * 2.0f, 0, 0, 0 ); + RenderScaledFSQ( blurTexWidth, blurTexHeight, screenWidth, screenHeight ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurTexture ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[1] - blurTexHeight, blurTexWidth, blurTexHeight ); + + // blur darkened texture + m_pBloomBlurShader->Bind(); + + if( r_glowQuality->integer < 1 ) { + r_glowQuality->integer = 1; + } + + if( r_glowSamples->integer < 1 ) { + r_glowSamples->integer = 1; + } + + if( r_glowSamples->integer > 15 ) { + r_glowSamples->integer = 15; + } + + float samples = ( float )r_glowSamples->integer * 2; + + for( int i = 0; i < r_glowQuality->integer; i++ ) + { + m_pBloomBlurShader->SetParameter4f( 0, r_glowRadius0.floatValue(), 0, 0, 0 ); + RenderScaledFSQ( blurTexWidth, blurTexHeight, ( int )( ( float )blurTexWidth * ( 1.0f + ( 0.004f * r_glowBloomStreakX.floatValue() ) ) ), blurTexHeight ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[1] - blurTexHeight, blurTexWidth, blurTexHeight ); + + m_pBloomBlurShader->SetParameter4f( 0, 0, r_glowRadius1.floatValue(), 0, 0 ); + RenderFSQ( blurTexWidth, ( int )( ( float )blurTexHeight * ( 1.0f + ( 0.004f * r_glowBloomStreakY.floatValue() ) ) ) ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[1] - blurTexHeight, blurTexWidth, blurTexHeight ); + } + + // combine normal and blurred scenes + m_pBloomCombineShader->Bind(); + m_pBloomCombineShader->SetParameter4f( 0, r_glowBloomIntensity0.floatValue(), r_glowBloomIntensity1.floatValue(), 0, 0 ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiScreenRGB ); + qglActiveTextureARB( GL_TEXTURE1_ARB ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurTexture ); + qglActiveTextureARB( GL_TEXTURE0_ARB ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pBloomCombineShader->Unbind(); +} + +void QFXRenderer :: PostProcess_ColorCorrection( void ) +{ + int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + + // capture screen + CaptureRGB(); + + // perform correction + m_pHSLShader->Bind(); + m_pHSLShader->SetParameter4f( 0, 360.0f - r_filmHue.vectorValue()[ 0 ], r_filmSaturation.vectorValue()[ 0 ], 0, 0 ); + m_pHSLShader->SetParameter4f( 1, 360.0f - r_filmHue.vectorValue()[ 1 ], r_filmSaturation.vectorValue()[ 1 ], 0, 0 ); + m_pHSLShader->SetParameter4f( 2, 360.0f - r_filmHue.vectorValue()[ 2 ], r_filmSaturation.vectorValue()[ 2 ], 0, 0 ); + m_pHSLShader->SetParameter4f( 3, r_filmMidStart.floatValue(), r_filmMidEnd.floatValue(), 0, 0 ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pHSLShader->Unbind(); + +} + +void QFXRenderer :: PostProcess_Emboss( void ) +{ + int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + + // capture screen + CaptureRGB(); + + // perform correction + m_pEmbossShader->Bind(); + m_pEmbossShader->SetParameter4f( 0, m_varEmbossScale, 0, 0, 0 ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pEmbossShader->Unbind(); +} + +void QFXRenderer :: PostProcess_DOF( void ) +{ + int screenWidth = m_3DViewport[ 2 ]; + int screenHeight = m_3DViewport[ 3 ]; + int blurTexWidth = m_3DViewport[ 2 ] >> 1; + int blurTexHeight = m_3DViewport[ 3 ] >> 1; + float depthValue = 0.0f; + + // get current depth value + qglReadPixels( blurTexWidth, blurTexHeight, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depthValue ); + depthValue = ( 2.0f * m_zNear ) / ( m_zFar + m_zNear - depthValue * ( m_zFar - m_zNear ) ); + if( m_flLastDepth < 0 ) { + m_flLastDepth = depthValue; + } else if( m_flLastDepth > depthValue ) { + m_flLastDepth -= min( m_flLastDepth - depthValue, m_varDOFSpeed * m_flFrameTime ); + } else if( m_flLastDepth < depthValue ) { + m_flLastDepth += min( depthValue - m_flLastDepth, m_varDOFSpeed * m_flFrameTime ); + } + + // capture screen + CaptureRGB(); + + // blur screen + m_pDOFBlurShader->Bind(); + m_pDOFBlurShader->SetParameter4f( 0, 1, 0, 0, 0 ); + RenderScaledFSQ( blurTexWidth, blurTexHeight, screenWidth, screenHeight ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurTexture ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[ 1 ] - blurTexHeight, blurTexWidth, blurTexHeight ); + m_pDOFBlurShader->SetParameter4f( 0, 0, 1, 0, 0 ); + RenderFSQ( blurTexWidth, blurTexHeight ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[ 1 ] - blurTexHeight, blurTexWidth, blurTexHeight ); + + // blur screen more + for( int i = 0; i < 3; i++ ) { + m_pDOFBlurShader->SetParameter4f( 0, 1, 0, 0, 0 ); + RenderFSQ( blurTexWidth, blurTexHeight ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[ 1 ] - blurTexHeight, blurTexWidth, blurTexHeight ); + m_pDOFBlurShader->SetParameter4f( 0, 0, 1, 0, 0 ); + RenderFSQ( blurTexWidth, blurTexHeight ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[ 1 ] - blurTexHeight, blurTexWidth, blurTexHeight ); + } + + // capture depth, if not captured previously in SSAO + if( m_bSupportsSSAO && r_ssao->integer ) + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiScreenDepth ); + else + CaptureDepth(); + + // linearize depth + m_pDOFDepthShader->Bind(); + m_pDOFDepthShader->SetParameter4f( 0, 2.0f * m_zNear, m_zFar - m_zNear, 0, 0 ); + RenderScaledFSQ( blurTexWidth, blurTexHeight, screenWidth, screenHeight ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurDepth ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[ 1 ] - blurTexHeight, blurTexWidth, blurTexHeight ); + + // blur depth + m_pDOFBlurShader->Bind(); + for( int i = 0; i < 4; i++ ) { + m_pDOFBlurShader->SetParameter4f( 0, 1, 0, 0, 0 ); + RenderFSQ( blurTexWidth, blurTexHeight ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[ 1 ] - blurTexHeight, blurTexWidth, blurTexHeight ); + m_pDOFBlurShader->SetParameter4f( 0, 0, 1, 0, 0 ); + RenderFSQ( blurTexWidth, blurTexHeight ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[ 1 ] - blurTexHeight, blurTexWidth, blurTexHeight ); + } + + // combine normal and blurred scenes + m_pDOFRenderShader->Bind(); + m_pDOFRenderShader->SetParameter4f( 0, m_varDOFMinZ, m_flLastDepth, m_varDOFScale, 0 ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiScreenRGB ); + qglActiveTextureARB( GL_TEXTURE1_ARB ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurTexture ); + qglActiveTextureARB( GL_TEXTURE2_ARB ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurDepth ); + qglActiveTextureARB( GL_TEXTURE0_ARB ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pDOFRenderShader->Unbind(); +} + +void QFXRenderer :: PostProcess_BrightnessContrast( void ) +{ + int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + + // capture screen + CaptureRGB(); + + // perform brightness and contrast + m_pBrightnessContrastShader->Bind(); + m_pBrightnessContrastShader->SetParameter4f( 0, r_filmBrightness.vectorValue()[ 0 ], r_filmBrightness.vectorValue()[ 1 ], r_filmBrightness.vectorValue()[ 2 ], r_filmContrast.floatValue() ); + m_pBrightnessContrastShader->SetParameter4f( 3, r_filmMidStart.floatValue(), r_filmMidEnd.floatValue(), 0, 0 ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pBrightnessContrastShader->Unbind(); +} + +#define AVG_SIZE_WIDTH 128 +#define AVG_SIZE_HEIGHT 128 + +void QFXRenderer :: PostProcess_Tint( void ) +{ + int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + Vector light, mid, dark; + Vector brightness; + GLubyte *data = ( GLubyte * )malloc( AVG_SIZE_WIDTH * AVG_SIZE_HEIGHT ); + float avg; + + light = r_filmLightTint.vectorValue(); + mid = r_filmMidTint.vectorValue(); + dark = r_filmDarkTint.vectorValue(); + brightness = r_filmBrightness.vectorValue(); + + avg = 0.5f; + + if( r_autoluminance->integer ) + { + qglReadPixels( 0, ( screenHeight >> 1 ) - AVG_SIZE_HEIGHT / 2, AVG_SIZE_WIDTH, AVG_SIZE_HEIGHT, GL_LUMINANCE, GL_UNSIGNED_BYTE, data ); + + for( int i = 0; i < AVG_SIZE_WIDTH * AVG_SIZE_HEIGHT; i++ ) + { + avg += ( float )data[ i ] / 255.0f; + } + + qglReadPixels( screenWidth - AVG_SIZE_WIDTH, ( screenHeight >> 1 ) - AVG_SIZE_HEIGHT / 2, AVG_SIZE_WIDTH, AVG_SIZE_HEIGHT, GL_LUMINANCE, GL_UNSIGNED_BYTE, data ); + + for( int i = 0; i < AVG_SIZE_WIDTH * AVG_SIZE_HEIGHT; i++ ) + { + avg += ( float )data[ i ] / 255.0f; + } + + avg /= AVG_SIZE_WIDTH * AVG_SIZE_HEIGHT * 2; + + if( avg <= 0.01f ) { + avg = 0.01f; + } + } + + player.m_fExposure = 0.5f/avg; + player.m_fExposure = player.m_fExposurePrevious + ( player.m_fExposure - player.m_fExposurePrevious ) * ( 0.002 * cg->frametime ); + + player.m_fExposurePrevious = player.m_fExposure; + + float light_r = light[ 0 ]; + float light_g = light[ 1 ]; + float light_b = light[ 2 ]; + + float mid_r = mid[ 0 ]; + float mid_g = mid[ 1 ]; + float mid_b = mid[ 2 ]; + + float dark_r = dark[ 0 ]; + float dark_g = dark[ 1 ]; + float dark_b = dark[ 2 ]; + + free( data ); + + CaptureRGB(); + + // perform light tint + m_pTintShader->Bind(); + m_pTintShader->SetParameter4f( 0, light_r, light_g, light_b, 0 ); + m_pTintShader->SetParameter4f( 1, mid_r, mid_g, mid_b, 0 ); + m_pTintShader->SetParameter4f( 2, dark_r, dark_g, dark_b, 0 ); + m_pTintShader->SetParameter4f( 3, r_filmMidStart.floatValue(), r_filmMidEnd.floatValue(), 0, 0 ); + m_pTintShader->SetParameter4f( 4, brightness[ 0 ], brightness[ 1 ], brightness[ 2 ], r_filmContrast.floatValue() ); + m_pTintShader->SetParameter4f( 5, player.m_fExposure, 0, 0, 0 ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pTintShader->Unbind(); +} + +void QFXRenderer :: PostProcess_Bleach( void ) +{ + int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + + // Optimize performances + + // capture screen + CaptureRGB(); + + // perform invert + m_pBleachShader->Bind(); + m_pBleachShader->SetParameter4f( 0, r_filmBleach.vectorValue()[ 0 ], r_filmBleach.vectorValue()[ 1 ], r_filmBleach.vectorValue()[ 2 ], 0 ); + m_pBleachShader->SetParameter4f( 3, r_filmMidStart.floatValue(), r_filmMidEnd.floatValue(), 0, 0 ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pBleachShader->Unbind(); +} + +#if 0 +void QFXRenderer :: PostProcess_MotionBlur( void ) +{ + int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + int blurTexWidth = m_3DViewport[2]>>1; + int blurTexHeight = m_3DViewport[3]>>1; + + // capture screen + CaptureRGB(); + + // perform invert + m_pMotionBlurShader->Bind(); + m_pMotionBlurShader->SetParameter4f( 0, 0, 0, 0, 0 ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pMotionBlurShader->Unbind(); +} + +void QFXRenderer :: PostProcess_Reflections( void ) +{ + int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + + //qglEnable( GL_LIGHTING ); + + // capture screen + CaptureRGB(); + + // perform invert + m_pLightReflectShader->Bind(); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pBloomCombineShader->Unbind(); + + //qglDisable( GL_LIGHTING ); +} + +void setTextureMatrix(void) +{ + static double modelView[16]; + static double projection[16]; + + // This is matrix transform every coordinate x,y,z + // x = x* 0.5 + 0.5 + // y = y* 0.5 + 0.5 + // z = z* 0.5 + 0.5 + // Moving from unit cube [-1,1] to [0,1] + const GLdouble bias[16] = { + 0.5, 0.0, 0.0, 0.0, + 0.0, 0.5, 0.0, 0.0, + 0.0, 0.0, 0.5, 0.0, + 0.5, 0.5, 0.5, 1.0}; + + // Grab modelview and transformation matrices + qglGetDoublev(GL_MODELVIEW_MATRIX, modelView); + qglGetDoublev(GL_PROJECTION_MATRIX, projection); + + + qglMatrixMode(GL_TEXTURE); + qglActiveTextureARB(GL_TEXTURE7); + + qglLoadIdentity(); + qglLoadMatrixd(bias); + + // concatating all matrice into one. + qglMultMatrixd (projection); + qglMultMatrixd (modelView); + + // Go back to normal matrix mode + qglMatrixMode(GL_MODELVIEW); +} + +void setupMatrices( float position_x, float position_y, float position_z, float lookAt_x, float lookAt_y, float lookAt_z ) +{ + qglMatrixMode(GL_PROJECTION); + qglLoadIdentity(); + //qgluPerspective( 45, screenWidth/screenHeight, 10, 40000 ); + qglMatrixMode(GL_MODELVIEW); + qglLoadIdentity(); + //qgluLookAt(position_x,position_y,position_z,lookAt_x,lookAt_y,lookAt_z,0,1,0); +} + +//Camera position +float p_camera[3] = {32,20,0}; + +//Camera lookAt +float l_camera[3] = {2,0,-10}; + +//Light position +float p_light[3] = {3,20,0}; + +//Light lookAt +float l_light[3] = {0,0,-5}; + +void QFXRenderer :: PostProcess_Shadows( void ) +{ + int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + vec3_t lightPos[128], lightIntensity[128]; + + //First step: Render from the light POV to a FBO, story depth values only + qglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_Framebuffer ); //Rendering offscreen + + //Using the fixed pipeline to render to the depthbuffer + qglUseProgramObjectARB( 0 ); + + // In the case we render the shadowmap to a higher resolution, the viewport must be modified accordingly. + qglViewport( 0, 0, screenWidth * 1, screenHeight * 1 ); + + // Clear previous frame values + qglClear( GL_DEPTH_BUFFER_BIT ); + + //Disable color rendering, we only want to write to the Z-Buffer + qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); + + setupMatrices( p_light[0], p_light[1], p_light[2], l_light[0], l_light[1], l_light[2] ); + + cgi.R_GatherLightSources( cent->currentState.origin, lightPos, lightIntensity, 128 ); + + // Culling switching, rendering only backface, this is done to avoid self-shadowing + qglCullFace( GL_FRONT ); + + //Save modelview/projection matrice into texture7, also add a biais + setTextureMatrix(); + + // Now rendering from the camera POV, using the FBO to generate shadows + qglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); + + qglViewport( 0, 0, screenWidth, screenHeight ); + + //Enabling color write (previously disabled for light POV z-buffer rendering) + qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + + // Clear previous frame values + qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + CaptureDepth(); + + //Using the shadow shader + m_pShadowShader->Bind(); + m_pShadowShader->SetParameter4f( 0, 0, 0, 0, 0 ); //qglUniform1iARB( shadowMapUniform, 7 ); + qglActiveTextureARB( GL_TEXTURE7 ); + qglBindTexture( GL_TEXTURE_2D, m_uiScreenDepth ); + RenderFSQ( screenWidth, screenHeight ); + + m_pShadowShader->Unbind(); + + setupMatrices( p_camera[0], p_camera[1], p_camera[2], l_camera[0], l_camera[1], l_camera[2] ); + + wglSwapBuffers( NULL ); + + /*int screenWidth = m_3DViewport[2]; + int screenHeight = m_3DViewport[3]; + + // capture screen + CaptureDepth(); + + // perform invert + m_pShadowShader->Bind(); + m_pShadowShader->SetParameter4f( 0, 0, 0, 0, 0 ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pShadowShader->Unbind();*/ +} +#endif + +void QFXRenderer::PostProcess_Distortion( void ) +{ + int screenWidth = m_3DViewport[ 2 ]; + int screenHeight = m_3DViewport[ 3 ]; + + CaptureRGB(); + + m_pDistortionShader->Bind(); + m_pDistortionShader->SetParameter4f( 0, ( float )( screenWidth >> 1 ), ( float )( screenHeight >> 1 ), r_distortionRadius.floatValue(), r_distortionScale.floatValue() ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pDistortionShader->Unbind(); +} + +void QFXRenderer::PostProcess_Blur( void ) +{ + int screenWidth = m_3DViewport[ 2 ]; + int screenHeight = m_3DViewport[ 3 ]; + int blurTexWidth = m_3DViewport[ 2 ] >> 1; + int blurTexHeight = m_3DViewport[ 3 ] >> 1; + + if( r_tweakBlurPasses->integer <= 0 ) { + return; + } + + float passes = ( float )r_tweakBlurPasses->integer; + + float velX = player.avel[ 1 ] * ( 15.0f / cg->frametime ); + float velY = player.avel[ 0 ] * ( 15.0f / cg->frametime ); + + float blurX = velX; + float blurY = velY; + + /*if( blurX <= 0.0f ) { + blurX = 0.01f; + } + + if( blurY <= 0.0f ) { + blurY = 0.01f; + }*/ + + for( int i = 0; i < r_tweakBlurPasses->integer; i++ ) + { + CaptureRGB(); + + m_pBlurShader->Bind(); + m_pBlurShader->SetParameter4f( 0, blurX, 0, 0, 0 ); + RenderFSQ( screenWidth, screenHeight ); + + m_pBlurShader->Unbind(); + + CaptureRGB(); + + m_pBlurShader->Bind(); + m_pBlurShader->SetParameter4f( 0, 0, blurY, 0, 0 ); + RenderFSQ( screenWidth, screenHeight ); + } + + // unbind shader + m_pBlurShader->Unbind(); + +#if 0 + + CaptureRGB(); + + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurTexture ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[ 1 ] - blurTexHeight, blurTexWidth, blurTexHeight ); + + for( int i = 0; i < r_tweakBlurPasses->integer; i++ ) + { + m_pBlurShader->Bind(); + m_pBlurShader->SetParameter4f( 0, r_tweakBlurX->value * r_tweakBlurPasses->integer, 0, 0, 0 ); + RenderFSQ( blurTexWidth, blurTexHeight ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[ 1 ] - blurTexHeight, blurTexWidth, blurTexHeight ); + + m_pBlurShader->Bind(); + m_pBlurShader->SetParameter4f( 0, 0, r_tweakBlurY->value * r_tweakBlurPasses->integer, 0, 0 ); + RenderFSQ( blurTexWidth, blurTexHeight ); + qglCopyTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, m_WindowSize[ 1 ] - blurTexHeight, blurTexWidth, blurTexHeight ); + } + + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiScreenRGB ); + qglActiveTextureARB( GL_TEXTURE1_ARB ); + qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, m_uiBlurTexture ); + qglActiveTextureARB( GL_TEXTURE0_ARB ); + + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pBlurShader->Unbind(); +#endif +} + + +void QFXRenderer::PostProcess_FXAA( void ) +{ + int screenWidth = m_3DViewport[ 2 ]; + int screenHeight = m_3DViewport[ 3 ]; + + CaptureRGB(); + + m_pFXAAShader->Bind(); + m_pFXAAShader->SetParameter4f( 0, 1.0f, 1.0f, 0, 0 ); + RenderFSQ( screenWidth, screenHeight ); + + // unbind shader + m_pFXAAShader->Unbind(); +} diff --git a/code/cgame_hook/renderer/qfx_renderer.h b/code/cgame_hook/renderer/qfx_renderer.h new file mode 100644 index 00000000..4481f538 --- /dev/null +++ b/code/cgame_hook/renderer/qfx_renderer.h @@ -0,0 +1,179 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#ifndef QFX_RENDERER_H +#define QFX_RENDERER_H + +class QFXShader; + +QFX_SINGLETON class QFXRenderer +{ +private: + QFXRenderer(); + static QFXRenderer& GetInstance() { static QFXRenderer rObject; return rObject; } + +public: + static QFXRenderer& Instance() { typedef QFXRenderer& (*pfnGetInstance)(); static pfnGetInstance pf = &GetInstance; return pf(); } + + void GetVariables( void ); + void InitializeGL( void ); + BOOL OnSetPixelFormat( HDC hdc, int pixelformat, CONST PIXELFORMATDESCRIPTOR *ppfd ); + void OnMakeCurrent( HDC hdc, HGLRC hglrc ); + void OnDeleteContext( HGLRC hglrc ); + void OnSwapBuffers( void ); + void OnTexImage2D( void ); + void PostProcess( void ); + void RenderGL( void ); + void SetOrtho( GLboolean enable ); + void SetupZDimensions( GLfloat znear, GLfloat zfar ); + void SetupZDimensions( const GLfloat* matrix ); + void SetupZDimensions( const GLdouble* matrix ); + void SetupDepthFunc( GLenum func ); + void SetupDepthRange( GLclampd zNear, GLclampd zFar ); + void SetupMultisample( void ); + void SetupAnisotropy( void ); + void ProcessShadow1( void ); + void ProcessShadow2( void ); + void PreRenderScene( struct refDef_s *fd ); + void PostRenderScene( void ); + +private: + GLuint AllocTextureId( void ) { return m_uiTextureIndex++; } + int ChooseMultisamplePixelFormat( int fmt, HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd ); + void CheckHardware( void ); + void ShutdownGL( void ); + void CaptureRGB( void ); + void CaptureDepth( void ); + void RenderFSQ( int wide, int tall ); + void RenderScaledFSQ( int wide, int tall, int wide2, int tall2 ); + + //void PostProcess( void ); + void PostProcess_SSAO( void ); + void PostProcess_Bloom( void ); + void PostProcess_ColorCorrection( void ); + void PostProcess_Emboss( void ); + void PostProcess_DOF( void ); + void PostProcess_BrightnessContrast( void ); + void PostProcess_Tint( void ); + void PostProcess_Bleach( void ); + void PostProcess_MotionBlur( void ); + void PostProcess_Reflections( void ); + void PostProcess_Shadows( void ); + void PostProcess_FXAA( void ); + void PostProcess_Distortion( void ); + void PostProcess_Blur( void ); + +private: + // contexts, internal state + HDC m_hDC; + HGLRC m_hGLRC; + GLboolean m_bOrtho; + GLboolean m_bZTrick; + GLboolean m_bInternalAnisotropy; + GLboolean m_bInternalMultisample; + GLboolean m_bMultisample; + GLuint m_uiRenderFrame; + GLuint m_uiRenderFrameCounter; + GLuint m_uiFrameCounter; + GLuint m_uiTextureIndex; + GLint m_WindowSize[2]; + GLfloat m_zNear; + GLfloat m_zFar; + DWORD m_iEnableRender; + GLfloat m_flFrameTime; + DWORD m_flOldTime; + DWORD m_flLastTime; + GLfloat m_flLastDepth; + GLuint m_uiFrameBuffer; + + // tracked GL state + GLuint m_uiViewportFrame; + GLint m_3DViewport[4]; + GLint m_3DScissor[4]; + + // hardware caps + GLboolean m_bSupportsBloom; + GLboolean m_bSupportsSSAO; + GLboolean m_bSupportsColorCorrection; + GLboolean m_bSupportsEmboss; + GLboolean m_bSupportsDOF; + + // renderer settings + int m_varDebug; + int m_varCompareMode; + int m_varZTrickFix; + int m_varViewportFix; + int m_varRenderFrame; + int m_varAnisotropy; + int m_varMultisample; + int m_varMultisampleHint; + int m_varBloomEnable; + int m_varBloomNumSteps; + float m_varBloomDarkenPower; + float m_varBloomRadius0; + float m_varBloomRadius1; + float m_varBloomCombineScale0; + float m_varBloomCombineScale1; + int m_varSSAOEnable; + float m_varSSAOScale; + float m_varSSAOMinZ; + float m_varSSAOMaxZ; + int m_varHue; + int m_varSaturation; + int m_varLightness; + int m_varEmboss; + float m_varEmbossScale; + int m_varDOF; + float m_varDOFSpeed; + float m_varDOFScale; + float m_varDOFMinZ; + +public: + // renderer data + GLuint m_uiScreenRGB; + GLuint m_uiScreenDepth; + GLuint m_uiBlurTexture; + GLuint m_uiBlurDepth; + GLuint m_uiShadowDepth; + QFXShader* m_pBloomDarkenShader; + QFXShader* m_pBloomBlurShader; + QFXShader* m_pBloomBlurVertShader; + QFXShader* m_pBloomCombineShader; + QFXShader* m_pSSAORenderShader; + QFXShader* m_pSSAOBlurShader; + QFXShader* m_pSSAOCombineShader; + QFXShader* m_pHSLShader; + QFXShader* m_pEmbossShader; + QFXShader* m_pDOFBlurShader; + QFXShader* m_pDOFDepthShader; + QFXShader* m_pDOFRenderShader; + QFXShader* m_pBrightnessContrastShader; + QFXShader* m_pTintShader; + QFXShader* m_pLightTintShader; + QFXShader* m_pMidTintShader; + QFXShader* m_pDarkTintShader; + QFXShader* m_pBleachShader; + QFXShader* m_pDistortionShader; + QFXShader* m_pBlurShader; + QFXShader* m_pFXAAShader; + QFXShader* m_pDisplacement; + QFXShader* m_pShadowMapping; +}; + +#endif //QFX_RENDERER_H diff --git a/code/cgame_hook/renderer/qfx_settings.cpp b/code/cgame_hook/renderer/qfx_settings.cpp new file mode 100644 index 00000000..1219332b --- /dev/null +++ b/code/cgame_hook/renderer/qfx_settings.cpp @@ -0,0 +1,94 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#include "qfx_library.h" +#include "qfx_log.h" +#include "qfx_settings.h" + +//========================================= +// QFXSettings class implementation +//----------------------------------------- +// Load settings from INI file +//========================================= +QFXSettings :: QFXSettings() +{ + // get current executable name + /*if (!GetModuleFileName( NULL, m_szExeName, sizeof(m_szExeName)-1 )) { + m_szExeName[0] = 0; + } + + if ( m_szExeName[1] != ':' ) { + // not a full path, assume current directory for INI + GetCurrentDirectory( sizeof(m_szIniFile)-1, m_szIniFile ); + strcat_s( m_szIniFile, "\\" QFX_LIBRARY_TITLE ".ini" ); + + } else { + // full path, assume its directory for INI + strcpy_s( m_szIniFile, m_szExeName ); + size_t l = strlen( m_szIniFile ); + for ( size_t i = l - 1; i > 0; i-- ) { + if ( m_szIniFile[i] == '\\' || m_szIniFile[i] == '/' ) { + m_szIniFile[i] = 0; + break; + } + } + strcat_s( m_szIniFile, "\\" QFX_LIBRARY_TITLE ".ini" ); + } + + char *p1 = strrchr( m_szExeName, '\\' ); + char *p2 = strrchr( m_szExeName, '/' ); + char *p = p1 > p2 ? p1 : p2; + if ( p ) + strncpy_s( m_szExeName, p + 1, strlen( p + 1 ) ); + + QFXLog::Instance().Printf("Settings: %s\n", m_szIniFile); + QFXLog::Instance().Printf("Module: %s\n", m_szExeName);*/ +} + +QFXSettings :: ~QFXSettings() +{ +} + +int QFXSettings :: GetInteger( const char *setting, int defaultValue ) +{ + int value = GetPrivateProfileInt( m_szExeName, setting, -99999, m_szIniFile ); + if ( value == -99999 ) + return GetPrivateProfileInt( "Generic", setting, defaultValue, m_szIniFile ); + else + return value; +} + +float QFXSettings :: GetFloat( const char *setting, float defaultValue ) +{ + char buffer[32]; + GetPrivateProfileString( m_szExeName, setting, NULL, buffer, sizeof(buffer)-1, m_szIniFile ); + if ( !strlen( buffer ) ) { + GetPrivateProfileString( "Generic", setting, NULL, buffer, sizeof(buffer)-1, m_szIniFile ); + if ( !strlen( buffer ) ) + return defaultValue; + } + return (float)atof( buffer ); +} + +bool QFXSettings :: CheckEXE( const char *s ) +{ + if ( !_stricmp( m_szExeName, s ) ) + return true; + return false; +} diff --git a/code/cgame_hook/renderer/qfx_settings.h b/code/cgame_hook/renderer/qfx_settings.h new file mode 100644 index 00000000..501ced9d --- /dev/null +++ b/code/cgame_hook/renderer/qfx_settings.h @@ -0,0 +1,42 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#ifndef QFX_SETTINGS_H +#define QFX_SETTINGS_H + +QFX_SINGLETON class QFXSettings +{ +private: + QFXSettings(); + static QFXSettings& GetInstance() { static QFXSettings sObject; return sObject; } + +public: + ~QFXSettings(); + static QFXSettings& Instance() { typedef QFXSettings& (*pfnGetInstance)(); static pfnGetInstance pf = &GetInstance; return pf(); } + + bool CheckEXE( const char *s ); + int GetInteger( const char *setting, int defaultValue ); + float GetFloat( const char *setting, float defaultValue ); + +private: + char m_szIniFile[MAX_PATH]; + char m_szExeName[MAX_PATH]; +}; + +#endif //QFX_SETTINGS_H \ No newline at end of file diff --git a/code/cgame_hook/renderer/qfx_shader.cpp b/code/cgame_hook/renderer/qfx_shader.cpp new file mode 100644 index 00000000..afabe974 --- /dev/null +++ b/code/cgame_hook/renderer/qfx_shader.cpp @@ -0,0 +1,200 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#include "qfx_library.h" +#include "qfx_log.h" +#include "qfx_opengl.h" +#include "qfx_shader.h" + +#include "glb_local.h" + +//========================================= +// QFXShader class implementation +//----------------------------------------- +// Class for GLSL shader objects +//========================================= +using namespace gl; + +QFXShader :: QFXShader( const char *szvp, const char *szfp, const char *program_name ) +{ + GLint objectStatus; + char nameBuffer[16]; + + m_bValid = false; + + m_hVShader = 0; + m_hFShader = 0; + m_hProgram = 0; + + if ( !szvp && !szfp ) + return; + + if ( szvp ) { + qglGetError(); + m_hVShader = qglCreateShaderObjectARB( GL_VERTEX_SHADER_ARB ); + GLint srcLen = strlen( szvp ); + qglShaderSourceARB( m_hVShader, 1, (const char**)&szvp, &srcLen ); + qglCompileShaderARB( m_hVShader ); + + if ( qglGetError() != GL_NO_ERROR ) { + QFXLog::Instance().Error( "Failed to compile vertex shader:\n\n%s\n", szvp ); + PrintInfoLog( m_hVShader, program_name ); + return; + } + + qglGetObjectParameterivARB( m_hVShader, GL_OBJECT_COMPILE_STATUS_ARB, &objectStatus ); + if ( !objectStatus ) { + QFXLog::Instance().Error( "Failed to compile vertex shader:\n\n%s\n", szvp ); + PrintInfoLog( m_hVShader, program_name ); + return; + } + } + + if ( szfp ) { + qglGetError(); + m_hFShader = qglCreateShaderObjectARB( GL_FRAGMENT_SHADER_ARB ); + GLint srcLen = strlen( szfp ); + qglShaderSourceARB( m_hFShader, 1, (const char**)&szfp, &srcLen); + qglCompileShaderARB( m_hFShader ); + + if ( qglGetError() != GL_NO_ERROR ) { + QFXLog::Instance().Error( "Failed to compile fragment shader:\n\n%s\n", szfp ); + PrintInfoLog( m_hFShader, program_name ); + return; + } + + qglGetObjectParameterivARB( m_hFShader, GL_OBJECT_COMPILE_STATUS_ARB, &objectStatus ); + if ( !objectStatus ) { + QFXLog::Instance().Error( "Failed to compile fragment shader:\n\n%s\n", szfp ); + PrintInfoLog( m_hFShader, program_name ); + return; + } + } + + m_hProgram = qglCreateProgramObjectARB(); + if ( szvp ) qglAttachObjectARB( m_hProgram, m_hVShader ); + if ( szfp ) qglAttachObjectARB( m_hProgram, m_hFShader ); + + qglGetError(); + qglLinkProgramARB( m_hProgram ); + + if ( qglGetError() != GL_NO_ERROR ) { + QFXLog::Instance().Error( "Failed to link shaders!\n\nVertex:\n%s\n\nFragment:\n%s\n", szvp ? szvp : "none", szfp ? szfp : "none" ); + PrintInfoLog( m_hProgram, program_name ); + return; + } + + qglGetObjectParameterivARB( m_hProgram, GL_OBJECT_LINK_STATUS_ARB, &objectStatus ); + if ( !objectStatus ) { + QFXLog::Instance().Error( "Failed to link shaders!\n\nVertex:\n%s\n\nFragment:\n%s\n", szvp ? szvp : "none", szfp ? szfp : "none" ); + PrintInfoLog( m_hProgram, program_name ); + return; + } + + qglUseProgramObjectARB( m_hProgram ); + + //Get uniforms + for ( int c = 0; c < QFX_MAX_SHADER_UNIFORMS; c++ ) { + sprintf_s( nameBuffer, "Local%i", c ); + m_iUniforms[c] = qglGetUniformLocationARB( m_hProgram, nameBuffer ); + } + + //Attach uniform textures + for ( int c = 0; c < QFX_MAX_SHADER_TEXTURES; c++ ) { + sprintf_s( nameBuffer, "Texture%i", c ); + GLint texunitloc = qglGetUniformLocationARB( m_hProgram, nameBuffer ); + if ( texunitloc != -1 ) qglUniform1iARB( texunitloc, c ); + } + + qglValidateProgramARB( m_hProgram ); + qglGetObjectParameterivARB( m_hProgram, GL_OBJECT_VALIDATE_STATUS_ARB, &objectStatus ); + if ( !objectStatus ) { + QFXLog::Instance().Error( "Failed to validate shaders!\n\nVertex:\n%s\n\nFragment:\n%s\n", szvp ? szvp : "none", szfp ? szfp : "none" ); + PrintInfoLog( m_hProgram, program_name ); + return; + } + + qglUseProgramObjectARB( 0 ); + m_bValid = true; +} + +QFXShader :: ~QFXShader() +{ + if ( m_hVShader ) { + qglDetachObjectARB( m_hProgram, m_hVShader ); + qglDeleteObjectARB( m_hVShader ); + } + if ( m_hFShader ) { + qglDetachObjectARB( m_hProgram, m_hFShader ); + qglDeleteObjectARB( m_hFShader ); + } + + qglDeleteObjectARB( m_hProgram ); +} + +void QFXShader :: Bind( void ) +{ + qglUseProgramObjectARB( m_hProgram ); +} + +void QFXShader :: Unbind( void ) +{ + qglUseProgramObjectARB( 0 ); +} + +void QFXShader :: SetParameter4f( int param, float x, float y, float z, float w ) +{ + if ( unsigned( param ) >= QFX_MAX_SHADER_UNIFORMS ) { + QFXLog::Instance().Warning( "QFXShader::SetParameter4f: parameter index out of range (%i)\n", param ); + return; + } + + qglUniform4fARB( m_iUniforms[param], x, y, z, w ); +} + +void QFXShader :: SetParameter4fv( int param, float* v ) +{ + if ( unsigned( param ) >= QFX_MAX_SHADER_UNIFORMS ) { + QFXLog::Instance().Warning( "QFXShader::SetParameter4fv: parameter index out of range (%i)\n", param ); + return; + } + + qglUniform4fvARB( m_iUniforms[param], 4, v ); +} + +void QFXShader :: PrintInfoLog( GLhandleARB object, const char * program_name ) +{ + int logMaxLen; + qglGetObjectParameterivARB( object, GL_OBJECT_INFO_LOG_LENGTH_ARB, &logMaxLen ); + if ( logMaxLen <= 0 ) + return; + + char *plog = new char[logMaxLen+1]; + qglGetInfoLogARB( object, logMaxLen, NULL, plog ); + + if (strlen(plog)) { + char buff[1024]; + + sprintf( buff, "Compile log for '%s': %s\n", program_name, plog ); + //QFXLog::Instance().Printf("Compile log: %s\n", plog); + MessageBox( NULL, buff, NULL, 0 ); + } + + delete [] plog; +} diff --git a/code/cgame_hook/renderer/qfx_shader.h b/code/cgame_hook/renderer/qfx_shader.h new file mode 100644 index 00000000..5852d883 --- /dev/null +++ b/code/cgame_hook/renderer/qfx_shader.h @@ -0,0 +1,50 @@ +/*************************************************************************** +* Copyright (C) 2012, Chain Studios. +* +* This file is part of QeffectsGL source code. +* +* QeffectsGL 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. +* +* QeffectsGL 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 this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +***************************************************************************/ +#ifndef QFX_SHADER_H +#define QFX_SHADER_H + +#define QFX_MAX_SHADER_UNIFORMS 8 +#define QFX_MAX_SHADER_TEXTURES 8 + +class QFXShader +{ +public: + QFXShader( const char *szvp, const char *szfp, const char *program_name ); + ~QFXShader(); + + bool IsValid( void ) { return m_bValid; } + + void Bind( void ); + void Unbind( void ); + void SetParameter4f( int param, float x, float y, float z, float w ); + void SetParameter4fv( int param, float* v ); + +private: + void PrintInfoLog( GLhandleARB object, const char *program_name ); + +private: + bool m_bValid; + GLhandleARB m_hProgram; + GLhandleARB m_hVShader; + GLhandleARB m_hFShader; + GLint m_iUniforms[QFX_MAX_SHADER_UNIFORMS]; +}; + +#endif //QFX_SHADER_H diff --git a/code/cgame_hook/renderer/r_postprocess.cpp b/code/cgame_hook/renderer/r_postprocess.cpp new file mode 100644 index 00000000..1745fa5c --- /dev/null +++ b/code/cgame_hook/renderer/r_postprocess.cpp @@ -0,0 +1,2581 @@ +#include "glb_local.h" + +#include "renderer/qfx_library.h" +#include "renderer/qfx_log.h" +#include "renderer/qfx_settings.h" +#include "renderer/qfx_opengl.h" +#include "renderer/qfx_renderer.h" +#include "renderer/qfx_shader.h" +#include "renderer/qfx_glprogs.h" + +#include "script/centity.h" +#include "script/cplayer.h" + +#include "script.h" +#include "scriptmaster.h" +#include "scripttimer.h" + +#include "script/vision.h" + +#include "img/IMAGE.h" +#include "img/TORUS.h" + +#define WANT_OPENGL +#include + +#pragma comment(lib, "opengl32.lib") +#pragma comment(lib, "glu32.lib") + +effect_t *effect_list[MAX_EFFECTS]; +qboolean render_inited = false; + +GLuint m_pBloomBlurShader = 0; +GLuint m_pBloomCombineShader = 0; +GLuint m_pBloomDarkenShader = 0; +GLuint m_uiBlurTexture = 0; +GLuint m_uiDesaturationTexture = 0; +GLuint m_uiInvertTexture = 0; +GLuint m_uiDarkTexture = 0; +GLuint m_uiLightTexture = 0; + +/*float vision_fadeTime = 0.0f; +str vision_current; +float vision_currentTime = 0.0f; +float vision_currentTime2 = 0.0f;*/ + +cvar_t *r_debug; +cvar_t *r_dof; +cvar_t *r_texFilterAniso; +cvar_t *r_tweakBlurX; +cvar_t *r_tweakBlurY; +cvar_t *r_tweakBlurPasses; +cvar_t *r_glowEnable; +cvar_t *r_glowQuality; +cvar_t *r_glowSamples; +cvar_t *r_ssao; +cvar_t *r_autoluminance; +cvar_t *r_fxaa; +cvar_t *r_test_color; +cvar_t *r_test_bump; + +// Vision variables +// CANNOT BE MODIFIED FROM CONSOLE ! + +ScriptTimer m_blurTimer( TIMER_NORMAL ); +ScriptTimer m_visionTimer( TIMER_GLIDE ); + +Container< VisionClass * > m_visionVar; + +VisionActivator r_anaglyphTweakEnable +( + "r_anaglyphTweakEnable", + "0" +); + +VisionActivator r_blur +( + "r_blur", + "1", + NULL, + &m_blurTimer +); + +VisionActivator r_distortionEnable +( + "r_distortionEnable", + "0" +); + +VisionActivator r_filmEnable +( + "r_filmEnable", + "0" +); + +VisionActivator r_glow +( + "r_glow", + "0" +); + +VisionVariable r_glowRadius0 +( + "r_glowRadius0", + "0.0000", + &r_glow +); + +VisionVariable r_glowRadius1 +( + "r_glowRadius1", + "0.0000", + &r_glow +); + +VisionVariable r_glowBloomCutoff +( + "r_glowBloomCutoff", + "0.0000", + &r_glow +); + +VisionVariable r_glowBloomDesaturation +( + "r_glowBloomDesaturation", + "0.0000", + &r_glow +); + +VisionVariable r_glowBloomIntensity0 +( + "r_glowBloomIntensity0", + "0.0000", + &r_glow +); + +VisionVariable r_glowBloomIntensity1 +( + "r_glowBloomIntensity1", + "0.0000", + &r_glow +); + +VisionVariable r_glowBloomStreakX +( + "r_glowBloomStreakX", + "0.0000", + &r_glow +); + +VisionVariable r_glowBloomStreakY +( + "r_glowBloomStreakY", + "0.0000", + &r_glow +); + +VisionVariable r_filmContrast +( + "r_filmContrast", + "1.0000 1.0000 1.0000", + &r_filmEnable +); + +VisionVariable r_filmBleach +( + "r_filmBleach", + "0.0000 0.0000 0.0000", + &r_filmEnable +); + +VisionVariable r_filmBrightness +( + "r_filmBrightness", + "0.0000", + &r_filmEnable +); + +VisionVariable r_filmHue +( + "r_filmHue", + "0.0000 0.0000 0.0000", + &r_filmEnable +); + +VisionVariable r_filmMidStart +( + "r_filmMidStart", + "0.2500", + &r_filmEnable +); + +VisionVariable r_filmMidEnd +( + "r_filmMidEnd", + "0.7500", + &r_filmEnable +); + +VisionVariable r_filmDarkTint +( + "r_filmDarkTint", + "1.0000 1.0000 1.0000", + &r_filmEnable +); + +VisionVariable r_filmMidTint +( + "r_filmMidTint", + "1.0000 1.0000 1.0000", + &r_filmEnable +); + +VisionVariable r_filmLightTint +( + "r_filmLightTint", + "1.0000 1.0000 1.0000", + &r_filmEnable +); + +VisionVariable r_filmSaturation +( + "r_filmSaturation", + "1.0000 1.0000 1.0000", + &r_filmEnable +); + +VisionVariable r_anaglyphAngleMult +( + "r_anaglyphAngleMult", + "0", + &r_anaglyphTweakEnable +); + +VisionVariable r_anaglyphOffsetMult +( + "r_anaglyphOffsetMult", + "0", + &r_anaglyphTweakEnable +); + +VisionVariable r_distortionRadius +( + "r_distortionRadius", + "1", + &r_distortionEnable +); + +VisionVariable r_distortionScale +( + "r_distortionScale", + "0", + &r_distortionEnable +); + +VisionVariable r_blurlevel +( + "r_blurlevel", + "0.0000", + &r_blur +); + +/*float m_blur_level = 0.0f; +float m_blur_currentlevel = 0.0f; +float m_blur_startlevel = 0.0f; +float m_blur_fadetime = 0.0f; +float m_blur_currentTime = 0.0f;*/ + +#if 0 +vvar_t r_glow; +vvar_t r_glowRadius0; +vvar_t r_glowRadius1; +vvar_t r_glowBloomCutoff; +vvar_t r_glowBloomDesaturation; +vvar_t r_glowBloomIntensity0; +vvar_t r_glowBloomIntensity1; +vvar_t r_glowBloomStreakX; +vvar_t r_glowBloomStreakY; + +vvar_t r_filmEnable; +vvar_t r_filmContrast; +vvar_t r_filmBrightness; +vvar_t r_filmDesaturation; +vvar_t r_filmSaturation; +vvar_t r_filmHue; +vvar_t r_filmBleach; +vvar_t r_filmLightTint; +vvar_t r_filmMidTint; +vvar_t r_filmMidStart; +vvar_t r_filmMidEnd; +vvar_t r_filmDarkTint; + +vvar_t r_anaglyphTweakEnable; +vvar_t r_anaglyphAngleMult; +vvar_t r_anaglyphOffsetMult; + +vvar_t r_distortionEnable; +vvar_t r_distortionRadius; +vvar_t r_distortionScale; + +regVis_t vvars[] = +{ + { &r_glow, "r_glow", "0" }, + { &r_glowRadius0, "r_glowRadius0", "0" }, + { &r_glowRadius1, "r_glowRadius1", "0" }, + { &r_glowBloomCutoff, "r_glowBloomCutoff", "0" }, + { &r_glowBloomDesaturation, "r_glowBloomDesaturation", "0" }, + { &r_glowBloomIntensity0, "r_glowBloomIntensity0", "0" }, + { &r_glowBloomIntensity1, "r_glowBloomIntensity1", "0" }, + { &r_glowBloomStreakX, "r_glowBloomStreakX", "0" }, + { &r_glowBloomStreakY, "r_glowBloomStreakY", "0" }, + + { &r_filmEnable, "r_filmEnable", "0" }, + { &r_filmContrast, "r_filmContrast", "1.0" }, + { &r_filmBrightness, "r_filmBrightness", "0.0" }, + { &r_filmDesaturation, "r_filmDesaturation", "0.0" }, + { &r_filmHue, "r_filmHue", "0 0 0" }, + { &r_filmSaturation, "r_filmSaturation", "1 1 1" }, + { &r_filmBleach, "r_filmBleach", "0 0 0" }, + { &r_filmLightTint, "r_filmLightTint", "1 1 1" }, + { &r_filmMidStart, "r_filmMidStart", "0.25" }, + { &r_filmMidEnd, "r_filmMidEnd", "0.75" }, + { &r_filmMidTint, "r_filmMidTint", "1 1 1" }, + { &r_filmDarkTint, "r_filmDarkTint", "1 1 1" }, + + { &r_anaglyphTweakEnable, "r_anaglyphTweakEnable", "0" }, + { &r_anaglyphAngleMult, "r_anaglyphAngleMult", "0" }, + { &r_anaglyphOffsetMult, "r_anaglyphOffsetMult", "0" }, + + { &r_distortionEnable, "r_distortionEnable", "0" }, + { &r_distortionRadius, "r_distortionRadius", "1" }, + { &r_distortionScale, "r_distortionScale", "0" }, +}; +#endif + +regCvar_t r_cvars[] = { + { &r_debug, "r_gfx_debug", "0", CVAR_ARCHIVE }, + { &r_dof, "r_gfx_dof", "0", CVAR_ARCHIVE }, + { &r_texFilterAniso, "r_gfx_texFilterAniso", "8", CVAR_ARCHIVE }, + { &r_ssao, "r_gfx_ssao", "0", CVAR_ARCHIVE }, + { &r_tweakBlurX, "r_gfx_tweakBlurX", "0", CVAR_ARCHIVE }, + { &r_tweakBlurY, "r_gfx_tweakBlurY", "0", CVAR_ARCHIVE }, + { &r_tweakBlurPasses, "r_gfx_tweakBlurPasses", "0", CVAR_ARCHIVE }, + { &r_glowEnable, "r_gfx_glowEnable", "1", CVAR_ARCHIVE }, + { &r_glowQuality, "r_gfx_glowQuality", "8", CVAR_ARCHIVE }, + { &r_glowSamples, "r_gfx_glowSamples", "8", CVAR_ARCHIVE }, + { &r_autoluminance, "r_gfx_autoluminance", "1", CVAR_ARCHIVE }, + { &r_fxaa, "r_gfx_fxaa", "1", CVAR_ARCHIVE }, + { &r_test_bump, "r_gfx_test_bump", "1", CVAR_ARCHIVE }, + { &r_test_color, "r_gfx_test_color", "1", CVAR_ARCHIVE }, + { NULL, NULL, NULL, NULL }, +}; + +/* Renderer stuff */ +GL_State_f GL_State = ( GL_State_f )0x00498A90; +GL_Bind_f GL_Bind = ( GL_Bind_f )0x00498780; +GL_Setup_f GL_Setup = ( GL_Setup_f )0x004B0FC0; + +typedef void( *R_Draw3D_f )( void ); +R_Draw3D_f R_Draw3D_o; + +DWORD ** ppWhite = ( DWORD ** )0x01313D98; + +#define VISION_CVAR(name, default_value) name = cgi.Cvar_Get(#name, #default_value, CVAR_ROM) + +void WINAPI glnDrawElements( GLuint returnAddress, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ); + +int R_CvarSize( void ) +{ + return sizeof( r_cvars ) / sizeof( r_cvars[0] ); +} + +void EmptyTexture( GLuint txtnumber ) +{ + unsigned int* data; // Stored Data + + // Create Storage Space For Texture Data (128x128x4) + data = (unsigned int*)new GLuint[ ( ( 512 * 512 )* 4 * sizeof(unsigned int) ) ]; + memset( data, 0, ( ( 512 * 512 ) * 4 * sizeof(unsigned int) ) ); // Clear Storage Memory + + glBindTexture(GL_TEXTURE_2D, txtnumber); // Bind The Texture + + glTexImage2D( GL_TEXTURE_2D, 0, 4, 512, 512, 0, + GL_RGBA, GL_UNSIGNED_BYTE, data ); // Build Texture Using Information In data + + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + + delete [] data; // Release data +} + +void R_RenderScene( refDef_t *fd ); + +int spamtime = 0; +int spamframetime = 0; +int spamprevioustime = 0; + +//Our torus +TORUS torus; + +//Normal map +GLuint normalMap; + +//Decal texture +GLuint decalTexture; + +//Normalisation cube map +GLuint normalisationCubeMap; + +IMAGE normalMapImage; +IMAGE decalImage; + +Vector worldLightPosition = Vector( 10.0f, 10.0f, 10.0f ); + +void RPrintf( int type, const char *fmt, ... ) +{ + // Fix for this damn error spamming the console and sometimes this message eats more FPS than the model itself + // This is a fix for CRAZY SERVER MODS in the map training + // We leave at least 250 ms for this message + if( _stricmp( "Exceeded MAX POLYS\n", fmt ) == 0 && spamtime <= 250 ) + { + // We have a custom frametime here because RPrintf can be called 10 times in a row + spamframetime = cgi.Milliseconds() - spamprevioustime; + spamprevioustime = cgi.Milliseconds(); + + spamtime += spamframetime; + + return; + } else if( _stricmp( "Exceeded MAX POLYS\n", fmt ) == 0 && spamtime > 250 ) { + spamtime = 0; + } + + char buffer[4100]; + va_list va; + + va_start( va, fmt ); + vsprintf( buffer, fmt, va ); + va_end( va ); + + ri.Printf( type, buffer ); +} + +bool GenerateNormalisationCubeMap() +{ + unsigned char * data = new unsigned char[ 32 * 32 * 3 ]; + if( !data ) + { + printf( "Unable to allocate memory for texture data for cube map\n" ); + return false; + } + + //some useful variables + int size = 32; + float offset = 0.5f; + float halfSize = 16.0f; + Vector tempVector; + unsigned char * bytePtr; + + //positive x + bytePtr = data; + + for( int j = 0; jPrintf = RPrintf; + + //refexp->RenderScene = R_RenderScene; + + //R_Draw3D_o = ( R_Draw3D_f )detour_function( ( PBYTE )0x0049A590, ( PBYTE )R_Draw3D, 6 ); + + /*for( int i = 0; i < sizeof( vvars ) / sizeof( vvars[0] ); i++ ) + { + vvars[i].vvar->name = ( char * )vvars[i].name; + + R_ProcessVisionVar( vvars[i].name, vvars[i].value ); + }*/ + + glGenTextures( 1, &m_pBloomBlurShader ); + + //EmptyTexture( m_pBloomBlurShader ); + + gl::CheckInit(); + gl::InitializeExtensions(); + QFXRenderer::Instance().InitializeGL(); + + glGenTextures( 1, &m_pBloomCombineShader ); + glGenTextures( 1, &m_pBloomDarkenShader ); + glGenTextures( 1, &m_uiBlurTexture ); + glGenTextures( 1, &m_uiInvertTexture ); + glGenTextures( 1, &m_uiDarkTexture ); + glGenTextures( 1, &m_uiLightTexture ); + + render_inited = true; + + //refexp->DrawBox = DrawBox; + //refimp->CM_EntityString = CM_EntityString; + + /* + //Load identity modelview + gl::qglMatrixMode( GL_MODELVIEW ); + gl::qglLoadIdentity(); + + //Shading states + gl::qglShadeModel( GL_SMOOTH ); + gl::qglClearColor( 0.2f, 0.4f, 0.2f, 0.0f ); + gl::qglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); + gl::qglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); + + //Depth states + gl::qglClearDepth( 1.0f ); + gl::qglDepthFunc( GL_LEQUAL ); + gl::qglEnable( GL_DEPTH_TEST ); + + gl::qglEnable( GL_CULL_FACE ); + + //Load normal map + normalMapImage.Load( "Normal map.bmp" ); + normalMapImage.ExpandPalette(); + + //Convert normal map to texture + gl::qglGenTextures( 1, &normalMap ); + gl::qglBindTexture( GL_TEXTURE_2D, normalMap ); + gl::qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, normalMapImage.width, normalMapImage.height, + 0, normalMapImage.format, GL_UNSIGNED_BYTE, normalMapImage.data ); + gl::qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + gl::qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + gl::qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); + gl::qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); + + //Load decal image + decalImage.Load( "decal.bmp" ); + decalImage.ExpandPalette(); + + //Convert decal image to texture + gl::qglGenTextures( 1, &decalTexture ); + gl::qglBindTexture( GL_TEXTURE_2D, decalTexture ); + gl::qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, decalImage.width, decalImage.height, + 0, decalImage.format, GL_UNSIGNED_BYTE, decalImage.data ); + gl::qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + gl::qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + gl::qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); + gl::qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); + + + //Create normalisation cube map + gl::qglGenTextures( 1, &normalisationCubeMap ); + gl::qglBindTexture( GL_TEXTURE_CUBE_MAP_ARB, normalisationCubeMap ); + GenerateNormalisationCubeMap(); + gl::qglTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + gl::qglTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + gl::qglTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + gl::qglTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + gl::qglTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); + */ +} + +void R_Shutdown(void) +{ + int i; + refImport_t *refimp = ( refImport_t * )( 0x01313C80 ); + + refimp->Printf = ri.Printf; + + gl::Shutdown(); + + /* Revert to the original function */ + /**exp_glBegin = (DWORD)orig_exp_glBegin; + *exp_glDrawElements = (DWORD)orig_exp_glDrawElements; + *exp_glViewport = (DWORD)orig_exp_glViewport;*/ + + detour_remove( R_Draw3D, R_Draw3D_o ); + + glDeleteTextures( 1, &m_pBloomBlurShader ); + glDeleteTextures( 1, &m_pBloomCombineShader ); + glDeleteTextures( 1, &m_pBloomDarkenShader ); + glDeleteTextures( 1, &m_uiBlurTexture ); + glDeleteTextures( 1, &m_uiInvertTexture ); + glDeleteTextures( 1, &m_uiDarkTexture ); + glDeleteTextures( 1, &m_uiLightTexture ); + + for( i = 0; i < MAX_EFFECTS; i++ ) + { + if( effect_list[ i ] == NULL ) + continue; + + R_RemoveEffect( effect_list[ i ] ); + } +} + +void DrawBlur( float blur ); +void DrawGBlur( int radius, float intensity, float cutoff, float desaturation ); +void R_FadeOverTime(); +void ProcessBloom( float radius ); +void ViewOrtho(); +void ViewPerspective(); + +void R_DrawModels() +{ + refEntity_t ref; + Entity *ent; + + for( int i = 0; i < s_entities.NumObjects(); i++ ) + { + ent = s_entities.ObjectAt( i + 1 ); + + if( !ent->modelhandle || ( ent->renderFx & RF_INVISIBLE ) ) { + continue; + } + + memset( &ref, 0, sizeof( refEntity_t ) ); + + if( ent->attached ) + { + orientation_t orient; + + memset( &orient, 0, sizeof( orientation_t ) ); + + ent->attached->GetTag( ent->attached_tagname, &orient ); + + if( ent->attached_use_angles ) + { + MatrixToEulerAngles( orient.axis, ent->angles ); + } + + ent->origin = ent->attached->origin + orient.origin + ent->attached_offset; + } + + VectorCopy( ent->origin, ref.lightingOrigin ); + VectorCopy( ent->origin, ref.origin ); + VectorCopy( ent->origin, ref.oldorigin ); + + //angles[ 1 ] += 90.f; + //angles[ 2 ] += 90.f; + + AnglesToAxis( ent->angles, ref.axis ); + + ref.reType = RT_MODEL; + + ref.scale = ent->scale; + ref.hModel = ent->modelhandle; + ref.hOldModel = ent->modelhandle; + ref.tiki = ent->tiki; + ref.entityNumber = 2048; + ref.actionWeight = 1.0f; + + for( int i = 0; i < ent->GetNumFrames(); i++ ) + { + frameInfo_t *frame = ent->GetFrameInfo( i ); + + ref.frameInfo[ i ].index = frame->index; + ref.frameInfo[ i ].time = frame->time; + ref.frameInfo[ i ].weight = frame->weight; + } + + cge.CG_ProcessInitCommands( ent->tiki, &ref ); + + ref.renderfx = ent->renderFx; + + cgi.R_AddRefEntityToScene( &ref, 0 ); + } +} + +Entity *R_SpawnModel( const char *model, vec3_t origin, vec3_t angles ) +{ + Entity *ent = new Entity; + + ent->setModel( model ); + + ent->setAngles( angles ); + ent->setOrigin( origin ); + + //ent->renderFx = RF_ADDITIVEDLIGHT | RF_EXTRALIGHT | RF_LIGHTINGORIGIN | RF_SHADOW | RF_SHADOWPRECISE | RF_FIRST_PERSON; + + return ent; +} + +int refEntityReadd = 0; +int refSpriteReadd = 0; +refEntity_t *refEntityList[ 1024 ]; +refEntity_t *refSpriteList[ 1024 ]; + +model_t *models = ( model_t * )0x1314890; + +void refEntityAdd() +{ + for( int i = 0; i < refSpriteReadd; i++ ) + { + refEntity_t *ent = refSpriteList[ i ]; + + cgi.R_AddRefSpriteToScene( ent ); + + free( ent ); + + refSpriteList[ i ] = NULL; + } + + for( int i = 0; i < refEntityReadd; i++ ) + { + refEntity_t *ent = refEntityList[ i ]; + model_t *pModel = &models[ ent->hModel ]; + + pModel->bmodel->haslightmap = false; + + cgi.R_AddRefEntityToScene( ent, ent->parentEntity ); + + free( ent ); + + refEntityList[ i ] = NULL; + } + + refEntityReadd = 0; + refSpriteReadd = 0; +} + +void R_RenderScene( refDef_t *fd ) +{ + GL_Setup(); + GL_State( GLS_DEPTHMASK_TRUE ); + R_DrawModels(); + + if( !r_anaglyph->integer && !r_anaglyphTweakEnable.isEnabled() ) + { + //QFXRenderer::Instance().PreRenderScene( fd ); + cgi.R_RenderScene( fd ); + //QFXRenderer::Instance().PostRenderScene(); + GL_Setup(); + GL_State( GLS_DEPTHMASK_TRUE ); + R_Draw3D(); + + return; + } + + glDrawBuffer( GL_BACK ); + glReadBuffer( GL_BACK ); + + /* Clear things */ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + //glClear( GL_ACCUM_BUFFER_BIT ); + + glViewport( 0, 0, cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + glColorMask( GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE ); + + Vector angles; + Vector leftvec; + + MatrixToEulerAngles( fd->viewAxis, angles ); + AngleVectors( angles, NULL, leftvec, NULL ); + + Vector old_angles = angles; + Vector old_origin = fd->viewOrg; + + /*if( r_anaglyph->integer ) + { + if( r_anaglyphAngleMult.value_current < 1.0f && ( r_anaglyphAngleMult.value >= 1.0f || !r_anaglyphTweakEnable.integer_target ) ) { + r_anaglyphAngleMult.value_current = 1.0f; + } + + if( r_anaglyphOffsetMult.value_current < 1.0f && ( r_anaglyphOffsetMult.value >= 1.0f || !r_anaglyphTweakEnable.integer_target ) ) { + r_anaglyphOffsetMult.value_current = 1.0f; + } + }*/ + + if( r_anaglyphTweakEnable.isEnabled() ) { + angles.y -= ( 1.0f * r_anaglyphAngleMult.floatValue() ); + } else { + angles.y -= 1.0f; + } + + AnglesToAxis( angles, fd->viewAxis ); + + cgi.R_RenderScene( fd ); + GL_Setup(); + glFlush(); + + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + + glDrawBuffer( GL_BACK ); + glClear( GL_DEPTH_BUFFER_BIT ); + + if( r_anaglyphTweakEnable.isEnabled() ) + { + fd->viewOrg[ 0 ] += leftvec[ 0 ] * ( 0.25f * r_anaglyphOffsetMult.floatValue() ); + fd->viewOrg[ 2 ] -= ( 0.25f * r_anaglyphOffsetMult.floatValue() ); + angles.y += ( 1.0f * r_anaglyphAngleMult.floatValue() ); + } + else + { + fd->viewOrg[ 0 ] += leftvec[ 0 ] * 0.25f; + fd->viewOrg[ 2 ] -= 0.25f; + angles.y += 1.0f; + } + + AnglesToAxis( angles, fd->viewAxis ); + + glViewport( 0, 0, cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + glColorMask( GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE ); + + refEntityAdd(); + + cgi.R_RenderScene( fd ); + GL_Setup(); + glFlush(); + + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + + AnglesToAxis( old_angles, fd->viewAxis ); + AnglesToAxis( old_angles, cg->refdef.viewAxis ); + + VectorCopy( old_origin, fd->viewOrg ); + VectorCopy( old_origin, cg->refdef.viewOrg ); + + R_Draw3D(); +} + +void R_Draw3D() +{ + int blend_src = 0, blend_dst = 0; + GLint viewport[4]; + + glHint( GL_GENERATE_MIPMAP_HINT, GL_NICEST ); + glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); + glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); + glHint( GL_POINT_SMOOTH_HINT, GL_NICEST ); + glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); + glHint( GL_FRAGMENT_SHADER_DERIVATIVE_HINT, GL_NICEST ); + +#if 0 + static float angle = 0.0f; + angle += 0.1f; + gl::qglRotatef( angle, 0.0f, 1.0f, 0.0f ); + + matrix_t inverseModelMatrix; + gl::qglPushMatrix(); + gl::qglLoadIdentity(); + gl::qglRotatef( -angle, 0.0f, 1.0f, 0.0f ); + gl::qglGetFloatv( GL_MODELVIEW_MATRIX, ( GLfloat * )inverseModelMatrix ); + gl::qglPopMatrix(); + + vec4_t o; + + MatrixTransform4( inverseModelMatrix, worldLightPosition, o ); + + Vector objectLightPosition; + + if( o[ 3 ] == 0.0f || o[ 3 ] == 1.0f ) + { + objectLightPosition = Vector( o[ 0 ], o[ 1 ], o[ 2 ] ); + } + else + { + objectLightPosition = Vector( o[ 0 ] / o[ 3 ], o[ 1 ] / o[ 3 ], o[ 2 ] / o[ 3 ] ); + } + + //Loop through vertices + for( int i = 0; iinteger ) + { + //Bind normal map to texture unit 0 + gl::qglBindTexture( GL_TEXTURE_2D, normalMap ); + gl::qglEnable( GL_TEXTURE_2D ); + + //Bind normalisation cube map to texture unit 1 + gl::qglActiveTextureARB( GL_TEXTURE1_ARB ); + gl::qglBindTexture( GL_TEXTURE_CUBE_MAP_ARB, normalisationCubeMap ); + gl::qglEnable( GL_TEXTURE_CUBE_MAP_ARB ); + gl::qglActiveTextureARB( GL_TEXTURE0_ARB ); + + //Send texture coords for normal map to unit 0 + gl::qglTexCoordPointer( 2, GL_FLOAT, sizeof( TORUS_VERTEX ), &torus.vertices[ 0 ].s ); + gl::qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); + + //Set vertex arrays for torus + gl::qglVertexPointer( 3, GL_FLOAT, sizeof( TORUS_VERTEX ), &torus.vertices[ 0 ].position ); + gl::qglEnableClientState( GL_VERTEX_ARRAY ); + + //Send tangent space light vectors for normalisation to unit 1 + gl::qglClientActiveTextureARB( GL_TEXTURE1_ARB ); + gl::qglTexCoordPointer( 3, GL_FLOAT, sizeof( TORUS_VERTEX ), &torus.vertices[ 0 ].tangentSpaceLight ); + gl::qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); + gl::qglClientActiveTextureARB( GL_TEXTURE0_ARB ); + + + //Set up texture environment to do (tex0 dot tex1)*color + gl::qglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB ); + gl::qglTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE ); + gl::qglTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE ); + + gl::qglActiveTextureARB( GL_TEXTURE1_ARB ); + + gl::qglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB ); + gl::qglTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE ); + gl::qglTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_DOT3_RGB_ARB ); + gl::qglTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB ); + + gl::qglActiveTextureARB( GL_TEXTURE0_ARB ); + + //Draw torus + gl::qglDrawElements( GL_TRIANGLES, torus.numIndices, GL_UNSIGNED_INT, torus.indices ); + + //Disable textures + gl::qglDisable( GL_TEXTURE_2D ); + + gl::qglActiveTextureARB( GL_TEXTURE1_ARB ); + gl::qglDisable( GL_TEXTURE_CUBE_MAP_ARB ); + gl::qglActiveTextureARB( GL_TEXTURE0_ARB ); + + //disable vertex arrays + gl::qglDisableClientState( GL_VERTEX_ARRAY ); + + gl::qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); + + gl::qglClientActiveTextureARB( GL_TEXTURE1_ARB ); + gl::qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); + gl::qglClientActiveTextureARB( GL_TEXTURE0_ARB ); + + //Return to standard modulate texenv + gl::qglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); + } + + if( r_test_bump->integer && r_test_color->integer ) + { + gl::qglBlendFunc( GL_DST_COLOR, GL_ZERO ); + gl::qglEnable( GL_BLEND ); + } + + if( r_test_color->integer ) + { + if( !r_test_bump->integer ) + { + gl::qglLightfv( GL_LIGHT1, GL_POSITION, ( const GLfloat * )&Quat( objectLightPosition ) ); + gl::qglLightfv( GL_LIGHT1, GL_DIFFUSE, ( const GLfloat * )&Quat( 1.0f, 1.0f, 1.0f, 1.0f ) ); + gl::qglLightfv( GL_LIGHT1, GL_AMBIENT, ( const GLfloat * )&Quat( 0.0f, 0.0f, 0.0f, 0.0f ) ); + gl::qglLightModelfv( GL_LIGHT_MODEL_AMBIENT, ( const GLfloat * )&Quat( 0.0f, 0.0f, 0.0f, 0.0f ) ); + gl::qglEnable( GL_LIGHT1 ); + gl::qglEnable( GL_LIGHTING ); + + gl::qglMaterialfv( GL_FRONT, GL_DIFFUSE, ( const GLfloat * )&Quat( 1.0f, 1.0f, 1.0f, 1.0f ) ); + } + + //Bind decal texture + gl::qglBindTexture( GL_TEXTURE_2D, decalTexture ); + gl::qglEnable( GL_TEXTURE_2D ); + + //Set vertex arrays for torus + gl::qglVertexPointer( 3, GL_FLOAT, sizeof( TORUS_VERTEX ), &torus.vertices[ 0 ].position ); + gl::qglEnableClientState( GL_VERTEX_ARRAY ); + + gl::qglNormalPointer( GL_FLOAT, sizeof( TORUS_VERTEX ), &torus.vertices[ 0 ].normal ); + gl::qglEnableClientState( GL_NORMAL_ARRAY ); + + gl::qglTexCoordPointer( 2, GL_FLOAT, sizeof( TORUS_VERTEX ), &torus.vertices[ 0 ].s ); + gl::qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); + + //Draw torus + gl::qglDrawElements( GL_TRIANGLES, torus.numIndices, GL_UNSIGNED_INT, torus.indices ); + + //Disable texture + gl::qglDisable( GL_TEXTURE_2D ); + + //disable vertex arrays + gl::qglDisableClientState( GL_VERTEX_ARRAY ); + gl::qglDisableClientState( GL_NORMAL_ARRAY ); + gl::qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); + } + + if( r_test_bump->integer && r_test_color->integer ) + { + gl::qglDisable( GL_BLEND ); + } + + gl::qglFinish(); +#endif + + QFXRenderer::Instance().GetVariables(); + QFXRenderer::Instance().RenderGL(); + + // Post-processing effects are after Draw3D + + /*if( r_glow.integer ) + { + DrawGBlur( r_glowRadius0.value_current, + r_glowBloomIntensity0.value_current, + r_glowBloomCutoff.value_current, + r_glowBloomDesaturation.value_current ); + }*/ + + DrawBlur( r_blurlevel.floatValue() ); +#if 0 + + ViewOrtho(); + + glDepthRange( 0.0f, 0.0f ); + + glGetIntegerv( GL_VIEWPORT, viewport ); + + glGetIntegerv( GL_BLEND_SRC, &blend_src ); + glGetIntegerv( GL_BLEND_DST, &blend_dst ); + + if( r_filmEnable.isEnabled() ) + { + // This part is complex + // It is doing a transition between inverted colors and normal colors + /*if( r_filmInvert.integer ) + { + float invert_value = r_filmInvert.value_current; + + if( invert_value != r_filmInvert.value ) { + glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA ); + } else { + glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO ); + } + + // Generate the invert texture + glBindTexture( GL_TEXTURE_2D, m_uiInvertTexture ); + + glBegin( GL_QUADS ); + glColor4f( 1.0f, 1.0f, 1.0f, 0.1f ); + glVertex2f( -cgs->glConfig.vidWidth, -cgs->glConfig.vidHeight ); + glVertex2f( cgs->glConfig.vidWidth, -cgs->glConfig.vidHeight ); + glVertex2f( cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glVertex2f( -cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glEnd(); + + if( invert_value != r_filmInvert.value ) + { + glBindTexture( GL_TEXTURE_2D, m_uiInvertTexture ); + + glBegin( GL_QUADS ); + glColor4f( 1.0f-invert_value, 1.0f-invert_value, 1.0f-invert_value, invert_value ); + glVertex2f( -cgs->glConfig.vidWidth, -cgs->glConfig.vidHeight ); + glVertex2f( cgs->glConfig.vidWidth, -cgs->glConfig.vidHeight ); + glVertex2f( cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glVertex2f( -cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glEnd(); + } + }*/ + + //R_SetSceneColor( r_filmLightTint.vector_current, r_filmDarkTint.vector_current ); + } + + //if( r_filmEnable.integer ) { + // R_SetSceneColor( r_filmLightTint.vector ); + //} + + /*memset( pixelData, 0, ( ( 512 * 512 ) * 4 * 4 ) ); + + glBindTexture( GL_TEXTURE_2D, m_pBloomBlurShader ); + glTexImage2D( GL_TEXTURE_2D, 0, 4, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelData ); + + glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0 ); + + glClearColor( 0, 0, 0.5f, 0 ); + + // Bloom/Glow effects + glViewport( 0, 0, 512, 512 ); + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + + //glReadPixels( 0, 0, 512, 512, GL_RGBA, GL_UNSIGNED_BYTE, pixelData ); + + for( int i = 0; i < 512 * 512 ; i ++ ) { + pixelData[i] = pixelData[i] / 64 * 64; + } + + glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 512, 512, GL_RGBA, GL_UNSIGNED_BYTE, pixelData ); + + //glDrawPixels( 512, 512, GL_RGB, GL_UNSIGNED_BYTE, pixelData ); + + free( pixelData ); + + glViewport( viewport[0], viewport[1], viewport[2], viewport[3] ); + + glBlendFunc( GL_SRC_ALPHA, GL_ONE ); + + glBegin( GL_QUADS ); + glVertex2f( -cgs->glConfig.vidWidth, -cgs->glConfig.vidHeight ); + glVertex2f( cgs->glConfig.vidWidth, -cgs->glConfig.vidHeight ); + glVertex2f( cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glVertex2f( -cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glEnd(); + + glFlush(); + + orig_wglSwapBuffers( NULL );*/ + + //glViewport( 0, 0, 512, 512 ); + //glViewport( viewport[0], viewport[1], viewport[2], viewport[3] ); + + ViewPerspective(); + + // 64, 0.55f + glDepthRange( 0.0f, 1.0f ); + + glBlendFunc( blend_src, blend_dst ); +#endif + + for( int i = m_visionVar.NumObjects(); i > 0; i-- ) + { + VisionClass *variable = m_visionVar.ObjectAt( i ); + + if( !variable ) { + continue; + } + + variable->Think(); + } + + //R_FadeOverTime(); + //R_FadeBlurOverTime(); +} + +void ViewOrtho() +{ + glMatrixMode( GL_PROJECTION ); + glPushMatrix(); + glLoadIdentity(); + glOrtho( 0, cgs->glConfig.vidWidth , cgs->glConfig.vidHeight , 0, -1, 1 ); + glMatrixMode( GL_MODELVIEW ); + glPushMatrix(); + glLoadIdentity(); +} + +void ViewPerspective() +{ + glPopMatrix(); + glMatrixMode( GL_PROJECTION ); + glPopMatrix(); + glMatrixMode( GL_MODELVIEW ); +} + +void DrawBlur( float blur ) +{ + if( blur <= 0.0f ) { + return; + } + + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + + // Generate the blur texture + glBindTexture( GL_TEXTURE_2D, m_uiBlurTexture ); + + glBegin( GL_QUADS ); + glColor4f( 0.0f, 0.0f, 0.0f, 0.0f ); + glVertex2f( ( GLfloat )-cgs->glConfig.vidWidth, ( GLfloat )-cgs->glConfig.vidHeight ); + glVertex2f( ( GLfloat )cgs->glConfig.vidWidth, ( GLfloat )-cgs->glConfig.vidHeight ); + glVertex2f( ( GLfloat )cgs->glConfig.vidWidth, ( GLfloat )cgs->glConfig.vidHeight ); + glVertex2f( ( GLfloat )-cgs->glConfig.vidWidth, ( GLfloat )cgs->glConfig.vidHeight ); + glEnd(); + + glAccum( GL_MULT, blur ); + glAccum( GL_ACCUM, 1.0f - blur ); + glAccum( GL_RETURN, 1.0f ); + + glFlush(); +} + +void WINAPI glnDrawElements( GLuint returnAddress, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ) +{ +#if 0 + int i; + GLubyte colorR[5000]; + GLubyte colorG[5000]; + GLubyte colorB[5000]; + char * lpCurrentShader = *( ( char ** ) 0x01313900 ); + + for ( i=0; i <= 4998; i = i+4 ) + { + colorR[i+0]=0xFF; + colorR[i+1]=0x00; + colorR[i+2]=0x00; + colorR[i+3]=0xFF; + + colorG[i+0]=0x00; + colorG[i+1]=0xFF; + colorG[i+2]=0x00; + colorG[i+3]=0xFF; + + colorB[i+0]=0x00; + colorB[i+1]=0x00; + colorB[i+2]=0xFF; + colorB[i+3]=0xFF; + } + + //if( returnAddress != ELM_FLAT ) + //{ + if( !strstr( lpCurrentShader, "DAK_pants_tan" ) && + !strstr( lpCurrentShader, "DAK_private_tunic" ) && + !strstr( lpCurrentShader, "c_DAK_private_tunic") && + !strstr( lpCurrentShader, "facewrap" ) && + !strstr( lpCurrentShader, "german-helmet_inside" ) && + !strstr( lpCurrentShader, "dak_helmet" ) ) { + return glDrawElements( mode, count, type, indices ); + } + + glDisable( GL_TEXTURE_2D ); + + //glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &colorG ); + glDrawElements( mode, count, type, indices ); + glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &colorB ); + glColorPointer( 4, GL_UNSIGNED_BYTE, 0, &colorG ); + + glEnable( GL_TEXTURE_2D ); + + //} +#endif + + gl::qglDrawElements( mode, count, type, indices ); +} + +void WINAPI glDrawElements_h( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ) +{ + gl::qglDrawElements( mode, count, type, indices ); +} + +void WINAPI glTexCoordPointer_h( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) +{ + gl::qglTexCoordPointer( size, type, stride, pointer ); +} + +void R_SetShader( int ent_num, const char * shader, qboolean fDefault ) +{ + if( !fDefault ) + { + Entity *entity = CL_GetCEntity( ent_num ); + + if( entity == NULL ) { + entity = new Entity; + } + + // Assign the number + entity->AssignNumber( ent_num ); + + entity->SetShader( shader ); + } + else + { + Entity *entity = CL_GetCEntity( ent_num ); + + if( entity != NULL ) { + entity->SetShader( NULL ); + } + } +} + +void R_AddRefEntityToScene( refEntity_t *ent, int parentEntityNumber ) +{ + centity_t *cent = CL_GetEntity( ent->entityNumber ); + Entity *entity = cent != NULL ? CL_GetCEntity( cent->currentState.number ) : NULL; + + if( entity != NULL && entity->fShader ) { // && ent->model != cg->playerFPSModelHandle && ent->entityNumber != cg->clientNum ) { + ent->customShader = entity->customshader; + } + + if( r_anaglyph->integer || r_anaglyphTweakEnable.isEnabled() ) + { + refEntity_t *newEnt = ( refEntity_t * )malloc( sizeof( refEntity_t ) ); + + memcpy( newEnt, ent, sizeof( refEntity_t ) ); + + refEntityList[ refEntityReadd ] = newEnt; + refEntityReadd++; + } + + cgi.R_AddRefEntityToScene( ent, parentEntityNumber ); +} + +void R_AddRefSpriteToScene( refEntity_t *ent ) +{ + if( r_anaglyph->integer || r_anaglyphTweakEnable.isEnabled() ) + { + refEntity_t *newEnt = ( refEntity_t * )malloc( sizeof( refEntity_t ) ); + + memcpy( newEnt, ent, sizeof( refEntity_t ) ); + + refSpriteList[ refSpriteReadd ] = newEnt; + refSpriteReadd++; + } + + cgi.R_AddRefSpriteToScene( ent ); +} + +/*void WINAPI glViewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + orig_exp_glViewport(x, y, width, height); +}*/ + +effect_t * R_GetEffectById(int ID) +{ + return effect_list[ID]; +} + +effect_t * R_GetEffectByName(const char * fxName) +{ + int i; + + if(!R_IsEffect(fxName)) + { + cgi.DPrintf("R_GetEffectByName : unknown effect name %s\n", fxName); + return NULL; + } + + for(i=0;ieffectName) == 0) + return effect_list[i]; + } + + return NULL; +} + +int R_GetEffectId(effect_t * effect) +{ + int i; + + if(effect == NULL) + return -1; + + for(i=0;ifadetime = fadetime; + + if(!bAddEffect) { + effect->bRemove = true; + } + + /* Remove effects that doesn't/can't fade */ + if(effect->fadetime == 0) + { + if(!bAddEffect) + R_RemoveEffect(effect); + } + else if(_strcmpi(effect->effectName, "invert") == 0) + { + if(!bAddEffect) + R_RemoveEffect(effect); + } + + if(bAddEffect == 2) + { + effect->intensity = intensity; + + effect->o_color[RED] = effect->t_color[RED]; + effect->o_color[GREEN] = effect->t_color[GREEN]; + effect->o_color[BLUE] = effect->t_color[BLUE]; + + effect->t_color[RED] = colors[RED]; + effect->t_color[GREEN] = colors[GREEN]; + effect->t_color[BLUE] = colors[BLUE]; + + memcpy(effect->param, parameters, sizeof(float)); + } + + return; + } + + bFound = false; + + /* Loop until we find a free spot in the used effects list */ + for(i=0;ieffectName, fxName); + + effect->intensity = intensity; + + effect->color[RED]= 1.0f; + effect->color[GREEN]= 1.0f; + effect->color[BLUE]= 1.0f; + + effect->t_color[RED] = colors[RED]; + effect->t_color[GREEN] = colors[GREEN]; + effect->t_color[BLUE] = colors[BLUE]; + + effect->o_color[RED] = colors[RED]; + effect->o_color[GREEN] = colors[GREEN]; + effect->o_color[BLUE] = colors[BLUE]; + + effect->fadetime = fadetime; + + memcpy(effect->param, parameters, sizeof(float)); + + cgi.DPrintf("R_PostProcessEffect : effect '%s' (%p) added to the effect list (intensity=%f|red=%f|green=%f|blue=%f|param1=%f|param2=%f)\n", effect->effectName, effect, intensity, effect->t_color[RED], effect->t_color[GREEN], effect->t_color[BLUE], parameters[0], parameters[1]); + + /* Place the effect in the used effect list */ + effect_list[i] = effect; +} + +void R_ProcessEffectFade(effect_t * effect, int frametime) +{ + float time; + int reverted; + + if(effect == NULL) + return; + + time = effect->fadetime * 1000.0f; + + /* Fade the RGB values over the specified time */ + + reverted = 0; + + if(!effect->bRemove) + { + if(effect->color[RED] > effect->t_color[RED]) + effect->color[RED] -= (1.0f-effect->t_color[RED])/time * frametime; + else if(effect->color[RED] < effect->t_color[RED]) + effect->color[RED] += (effect->t_color[RED]-effect->o_color[RED])/time * frametime; + + if(effect->color[GREEN] > effect->t_color[GREEN]) + effect->color[GREEN] -= (1.0f-effect->t_color[GREEN])/time * frametime; + else if(effect->color[GREEN] < effect->t_color[GREEN]) + effect->color[GREEN] += (effect->t_color[GREEN]-effect->o_color[GREEN])/time * frametime; + + if(effect->color[BLUE] > effect->t_color[BLUE]) + effect->color[BLUE] -= (1.0f-effect->t_color[BLUE])/time * frametime; + else if(effect->color[BLUE] < effect->t_color[BLUE]) + effect->color[BLUE] += (effect->t_color[BLUE]-effect->o_color[BLUE])/time * frametime; + } + else + { + /* If the effect is being removed, increase all RGB values up to 1.0 */ + + effect->color[RED] += 1.0f/time * frametime; + + if(effect->color[RED] > 1.0f) + { + effect->color[RED] = 1.0f; + reverted++; + } + + effect->color[GREEN] += 1.0f/time * frametime; + + if(effect->color[GREEN] > 1.0f) + { + effect->color[GREEN] = 1.0f; + reverted++; + } + + effect->color[BLUE] += 1.0f/time * frametime; + + if(effect->color[BLUE] > 1.0f) + { + effect->color[BLUE] = 1.0f; + reverted++; + } + + /* If the effect did the transition (colors values are all 1.0) then we can now remove it */ + if(reverted >= 3) + R_RemoveEffect(effect); + } +} + +void R_ProcessEffectsFade(int frametime) +{ + int i; + + /* Process the effects fading */ + + for(i=0;ibRemove = true; + + /* Remove the effect from the list */ + if(index != -1) + effect_list[index] = NULL; + + /* Just reallocate the effect name so that the debug message will show which effect + * has been removed + */ + fxName = (char*)malloc(strlen(effect->effectName)); + + strcpy(fxName, effect->effectName); + + memset(effect, 0, sizeof(effect_t)); + + /* Free the effect from the memory */ + free(effect); + + cgi.DPrintf("R_RemoveEffect : effect '%s' removed from the effect list\n", fxName); + + /* Free the effect name */ + free(fxName); +} + +#if 0 + +void R_SetSceneColor( vec3_t light, vec3_t dark ) +{ +#if 0 + GLfloat rgb[10010]; + int i; + + /* Set the RGB array values */ + for( i = 0; i <= 10007; i += 3 ) + { + rgb[i] = color[0]; + rgb[i+1] = color[1]; + rgb[i+2] = color[2]; + } + + /* Apply the RGB values to the scene */ + glEnable( GL_BLEND ); + glColorPointer( 3, GL_FLOAT, 0, rgb ); +#endif + + light[0] /= 2.0f; + light[1] /= 2.0f; + light[2] /= 2.0f; + + dark[0] /= 2.0f; + dark[1] /= 2.0f; + dark[2] /= 2.0f; + + GL_State( GLS_DEPTHMASK_TRUE ); + + glEnableClientState( GL_COLOR_ARRAY ); + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + + glEnable( GL_BLEND ); + + // Generate the light tint texture + + glBlendFunc( GL_DST_COLOR, GL_ONE ); + glBindTexture( GL_TEXTURE_2D, m_uiLightTexture ); + + glBegin( GL_QUADS ); + glColor3fv( light ); + glVertex2f( -cgs->glConfig.vidWidth, -cgs->glConfig.vidHeight ); + glVertex2f( cgs->glConfig.vidWidth, -cgs->glConfig.vidHeight ); + glVertex2f( cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glVertex2f( -cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glEnd(); + + // Generate the dark tint texture + + glBlendFunc( GL_DST_COLOR, GL_ZERO ); + + glBindTexture( GL_TEXTURE_2D, m_uiDarkTexture ); + + glBegin( GL_QUADS ); + glColor3fv( dark ); + glVertex2f( -cgs->glConfig.vidWidth, -cgs->glConfig.vidHeight ); + glVertex2f( cgs->glConfig.vidWidth, -cgs->glConfig.vidHeight ); + glVertex2f( cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glVertex2f( -cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glEnd(); + + // Generate the desaturation texture + + GLint viewport[4]; + + int HEIGHT = cgs->glConfig.vidHeight; + int WIDTH = cgs->glConfig.vidWidth; + float biggest = 0.0f; + + for( int i = 0; i < 3; i++ ) + { + if( r_filmDesaturation.vector_current[i] > biggest ) { + biggest = r_filmDesaturation.vector_current[i]; + } + } + + // Optimize performances + /*if( biggest > 0.0f ) + { + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + glBindTexture( GL_TEXTURE_2D, m_uiDesaturationTexture ); + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + + glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, cgs->glConfig.vidWidth, cgs->glConfig.vidHeight, 0 ); + + glColor4f( r_filmDesaturation.vector_current[0], r_filmDesaturation.vector_current[1], r_filmDesaturation.vector_current[2], biggest ); + glBegin( GL_QUADS ); + glTexCoord2f( 0, 1 ); glVertex2f( 0, 0 ); + glTexCoord2f( 1, 1 ); glVertex2f( cgs->glConfig.vidWidth, 0 ); + glTexCoord2f( 1, 0 ); glVertex2f( cgs->glConfig.vidWidth, cgs->glConfig.vidHeight ); + glTexCoord2f( 0, 0 ); glVertex2f( 0, cgs->glConfig.vidHeight ); + glEnd(); + + glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, cgs->glConfig.vidWidth, cgs->glConfig.vidHeight, 0 ); + }*/ + + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + + glDisable( GL_BLEND ); +} + +#endif + +void R_SetSkyColor( vec3_t color ) +{ + glEnable( GL_BLEND ); + glColor3f( color[0], color[1], color[2] ); +} + +void R_SetSceneColor2(float intensity, vec3_t color) +{ + glColor3ub((int)(color[0]*255.0f),(int)(color[1]*255.0f),(int)(color[2]*255.0f)); + glVertex2f(-1,-1); + glColor3ub((int)(color[0]*255.0f),(int)(color[1]*255.0f),(int)(color[2]*255.0f)); + glVertex2f(1,-1); + glColor3ub((int)(color[0]*255.0f),(int)(color[1]*255.0f),(int)(color[2]*255.0f)); + glVertex2f(1,1); +} + +/* +vvar_t * R_GetVisionVar( const char * name, regVis_t **vis = NULL ) +{ + for( int i = 0; i < sizeof( vvars ) / sizeof( vvars[0] ); i++ ) + { + if( _stricmp( vvars[i].name, name ) == 0 ) + { + if( vis != NULL ) { + *vis = &vvars[i]; + } + + return vvars[i].vvar; + } + } + + return NULL; +} + + +qboolean R_ProcessVisionVar( const char * variable, const char * value ) +{ + vvar_t *var; + const char *vec1, *vec2, *vec3; + qboolean isVector = false; + char buffer[MAX_STRINGTOKENS]; + regVis_t *vis = NULL; + + if( value == NULL ) { + return false; + } + + var = R_GetVisionVar( variable, &vis ); + + if( var == NULL ) { + return false; + } + + strcpy( buffer, value ); + + vec1 = strtok( ( char * )buffer, " " ); + + if( vec1 != NULL && isdigit( vec1[0] ) ) + { + vec2 = strtok( NULL, " " ); + + if( vec2 != NULL && isdigit( vec2[0] ) ) + { + vec3 = strtok( NULL, " " ); + + if( vec3 != NULL && isdigit( vec3[0] ) ) { + isVector = true; + } + } + } + + if( !isVector ) + { + var->integer_target = atoi( value ); + var->value = atof( value ); + + var->vector[0] = var->value; + var->vector[1] = var->value; + var->vector[2] = var->value; + } + else + { + // Cast values into vector + var->vector[0] = atof( vec1 ); + var->vector[1] = atof( vec2 ); + var->vector[2] = atof( vec3 ); + + var->value = var->vector[0]; + } + + if( !render_inited ) + { + VectorCopy( var->vector, var->vector_current ); + VectorCopy( var->vector, var->vector_start ); + + var->value_current = var->value; + var->value_start = var->value; + var->integer = var->integer_target; + } + else + { + var->value_start = var->value_current; + + VectorCopy( var->vector_current, var->vector_start ); + } + + var->bProcessed = true; + + return true; +} +*/ + +char * R_LineParseComment( char * line ) +{ + char * new_line = line; + int i = 0; + qboolean quotation = false; + + while( *new_line != '\n' && *new_line != '\0' ) + { + if( *new_line == '"' ) { + quotation = true; + } + + if( *new_line == '/' && *( new_line + 1 ) == '/' ) + { + if( i == 0 ) { + *new_line = '\0'; + } + + return new_line; + } + + //if( *new_line == '\t' ) { + // *new_line = ' '; + //} + + if( *new_line == ' ' && !quotation ){ + *new_line = '\t'; + } + + new_line++; + i++; + } + + return line; +} + +void R_ProcessBlur( float blur_level, float fade_time ) +{ + /*m_blur_startlevel = m_blur_currentlevel; + m_blur_level = blur_level; + m_blur_fadetime = fade_time * 1000.0f; + + m_blur_currentTime = 0.0f;*/ + + m_blurTimer.SetTime( fade_time ); + r_blurlevel.setFloatValue( blur_level ); +} + +void R_ProcessVision( str vision_name, float fade_time, float phase, str type ) +{ + Script m_visionScript; + VisionClass *visionVariable; + int warnings; + + str filename = type + "/" + vision_name + "." + type; + + m_visionTimer.SetTime( fade_time ); + + if( phase ) + { + m_visionTimer.SetPhase( phase ); + } + + if( vision_name.icmp( vision_current ) == 0 ) + { +#ifdef DEBUG + cgi.Printf( "DEBUG: Vision file '%s' was already processed!\n", filename.c_str() ); +#endif + return; + } + + m_visionScript.LoadFile( filename ); + + if( !m_visionScript.isValid() ) + { + Com_Printf( "Couldn't find vision '%s'! Setting to the default vision\n", vision_name.c_str() ); + + filename = type + "/" + "default" + "." + type; + + m_visionScript.LoadFile( filename ); + + if( !m_visionScript.isValid() ) + { + Com_Printf( "Couldn't find the default vision!\n" ); + return; + } + + vision_name = "default"; + } + + warnings = 0; + + while( m_visionScript.TokenAvailable( true ) ) + { + str variable = m_visionScript.GetToken( false ); + str value = m_visionScript.GetString( false ); + + visionVariable = VisionClass::Get( variable ); + + if( visionVariable != NULL && visionVariable->GetType() == "vision" ) + { + visionVariable->setValue( value ); + visionVariable->fProcessed = true; + } + else + { + cgi.Printf( "WARNING : unknown var '%s' in file '%s'\n", variable.c_str(), filename.c_str() ); + warnings++; + } + } + + if( warnings ) { + cgi.Printf( "Found %d warning(s) in file '%s'\n", warnings, filename.c_str() ); + } + + for( int i = 0; i < m_visionVar.NumObjects(); i++ ) + { + visionVariable = m_visionVar[ i ]; + + if( visionVariable->GetType() != "vision" ) { + continue; + } + + if( !visionVariable->fProcessed || !visionVariable->isNewEnabled() ) { + visionVariable->setValue( visionVariable->defaultValue() ); + } + + visionVariable->fProcessed = false; + } + + vision_current = vision_name; + +#ifdef DEBUG + cgi.Printf( "DEBUG: Processed vision file '%s' with %d warning(s)\n", filename.c_str(), warnings ); +#endif +} + +#if 0 +void R_ProcessVision( str vision_name, float fade_time ) +{ + char *content = NULL; + char **line = NULL; + char *variable, *value, *pch; + int i = 0, num_lines = 0; + int errors = 0; + int length = 0; + VisionClass *var; + + if( strlen( vision_name ) >= 64 ) + { + cgi.Printf( "vision exceeded the maximum length!\n" ); + return; + } + + str filename = "vision/" + vision_name + ".vision"; + + if( vision_name.icmp( vision_current ) == 0 ) + { +#ifdef DEBUG + cgi.Printf( "DEBUG: Vision file '%s' was already processed!\n", filename.c_str() ); +#endif + return; + } + + length = cgi.FS_ReadFile( filename.c_str(), ( void ** )&content ); + + if( length < 0 ) + { + Com_Printf( "Couldn't find vision '%s'! Setting to the default vision\n", vision_name.c_str() ); + length = cgi.FS_ReadFile( "vision/default.vision", ( void ** )&content ); + + if( length < 0 ) + { + Com_Printf( "Couldn't find the default vision!\n" ); + return; + } + + filename = "vision/default.vision"; + vision_name = "default"; + } + + //for( int i = 0; i < sizeof( vvars ) / sizeof( vvars[0] ); i++ ) { + // vvars[i].vvar->bProcessed = false; + //} + + pch = strtok( content, "\n" ); + + while( pch != NULL ) + { + line = ( char ** )realloc( line, sizeof( DWORD ) * ( i + 1 ) ); + line[i] = R_LineParseComment( pch ); + i++; + num_lines++; + + pch = strtok( NULL, "\n" ); + } + + i = 0; + + while( i < num_lines ) + { + value = NULL; + + // This means we're at a comment + if( line[i][0] == '\0' ) + { + i++; + continue; + } + + variable = strtok( line[i], "\t" ); + + if( variable != NULL ) { + value = strtok( NULL, "\t\"" ); + } + + if( value != NULL ) + { + // Process a vision variable + /*if( !R_ProcessVisionVar( variable, value ) ) + { + cgi.Printf( "WARNING : unknown var '%s' in file '%s'\n", variable, filename.c_str() ); + errors++; + }*/ + + var = VisionClass::Get( variable ); + + if( var != NULL && var->GetType() == "vision" ) + { + var->setValue( value ); + var->fProcessed = true; + } + else + { + cgi.Printf( "WARNING : unknown var '%s' in file '%s'\n", variable, filename.c_str() ); + errors++; + } + } + + i++; + } + + if( errors ) { + cgi.Printf( "Found %d warnings in file '%s'\n", errors, filename.c_str() ); + } + + for( int i = 0; i < m_visionVar.NumObjects(); i++ ) + { + var = m_visionVar[ i ]; + + if( var->GetType() != "vision" ) { + continue; + } + + if( !var->fProcessed || !var->isNewEnabled() ) { + var->setValue( var->defaultValue() ); + } + + var->fProcessed = false; + } + + /*for( int i = 0; i < sizeof( vvars ) / sizeof( vvars[0] ); i++ ) + { + // ALL variables must be processed + if( !vvars[i].vvar->bProcessed ) { + R_ProcessVisionVar( vvars[i].name, vvars[i].value ); + } + }*/ + + vision_current = vision_name; + +#ifdef DEBUG + cgi.Printf( "DEBUG: Processed vision file '%s' with %d error(s)\n", filename.c_str(), errors ); +#endif + + m_visionTimer.SetTime( fade_time ); +} +#endif + +// Vision class + +VisionClass *VisionClass::Get( str n ) +{ + for( int i = 0; i < m_visionVar.NumObjects(); i++ ) + { + VisionClass *variable = m_visionVar[ i ]; + + if( variable->GetName().icmp( n ) == 0 ) { + return variable; + } + } + + return NULL; +} + +void VisionClass::VisionInit( const char *n, const char *v, ScriptTimer *globalTimer ) +{ + name = n; + + defaultval = v; + + fProcessed = false; + + if( globalTimer == NULL ) { + globalTimer = &m_visionTimer; + } + + m_timer = globalTimer; + + m_visionVar.AddObject( this ); + + setValue( v ); +} + +VisionClass::VisionClass() +{ + value = 0.f; + value_start = 0.f; + value_target = 0.f; + + fProcessed = false; +} + +VisionClass::VisionClass( const char *n, const char *v, ScriptTimer *globalTimer ) +{ + VisionInit( n, v, globalTimer ); +} + +void VisionClass::GlobalArchive( Archiver &arc ) +{ + for( int i = 0; i < m_visionVar.NumObjects(); i++ ) { + arc.ArchiveObject( m_visionVar[ i ] ); + } +} + +void VisionClass::Archive( Archiver &arc ) +{ + Class::Archive( arc ); + + arc.ArchiveString( &string ); + + arc.ArchiveObject( m_timer ); + + arc.ArchiveFloat( &value ); + arc.ArchiveFloat( &value_start ); + arc.ArchiveFloat( &value_target ); + + arc.ArchiveBoolean( &fProcessed ); +} + +str VisionClass::GetName() +{ + return name; +} + +str VisionClass::defaultValue() +{ + return defaultval; +} + +float VisionClass::floatValue() +{ + return value; +} + +str VisionClass::stringValue() +{ + return string; +} + +ScriptTimer *VisionClass::GetTimer() +{ + return m_timer; +} + +str VisionClass::GetType() +{ + return ""; +} + +qboolean VisionClass::isBasic() +{ + return true; +} + +qboolean VisionClass::isEnabled() +{ + return true; +} + +qboolean VisionClass::isNewEnabled() +{ + return true; +} + +void VisionClass::setFloatValue( float v ) +{ + value_target = v; + + if( !render_inited ) + { + value = value_target; + value_start = value_target; + } else { + value_start = value; + } +} + +void VisionClass::setValue( str v ) +{ + float x; + + string = v; + + if( isdigit( *v ) ) { + x = atof( v ); + } else { + x = 0.f; + } + + value_target = x; + + if( !render_inited ) + { + value = value_target; + value_start = value_target; + } else { + value_start = value; + } +} + +void VisionClass::Think() +{ + if( !m_timer->isEnabled() ) { + m_timer->Enable(); + } + + value = m_timer->LerpValue( value_start, value_target ); +} + +VisionActivator::VisionActivator( const char *n, const char *v, const char *t, ScriptTimer *globalTimer ) +{ + VisionInit( n, v, globalTimer ); + + if( t == NULL ) { + t = "none"; + } + + vistype = t; +} + +VisionActivator::VisionActivator() +{ + +} + +void VisionActivator::Archive( Archiver &arc ) +{ + VisionClass::Archive( arc ); +} + +str VisionActivator::GetType() +{ + return vistype; +} + +qboolean VisionActivator::isBasic() +{ + return false; +} + +qboolean VisionActivator::isEnabled() +{ + return value > 0.0f || value_target > 0.0f; +} + +qboolean VisionActivator::isNewEnabled() +{ + return value_target > 0.0f; +} + +void VisionActivator::setValue( str v ) +{ + float floatvalue = ( float )atoi( v ); + char newval[ MAX_STRING_TOKENS ]; + + sprintf( newval, "%f", floatvalue ); + + VisionClass::setValue( newval ); +} + +VisionVariable::VisionVariable( const char *n, const char *v, VisionActivator *a ) +{ + VisionInit( n, v, a->GetTimer() ); + + activator = a; +} + +VisionVariable::VisionVariable() +{ + +} + +void VisionVariable::Archive( Archiver &arc ) +{ + VisionClass::Archive( arc ); + + arc.ArchiveVector( &vector ); + + arc.ArchiveVector( &vector_start ); + arc.ArchiveVector( &vector_target ); +} + +VisionActivator *VisionVariable::GetActivator() +{ + return activator; +} + +ScriptTimer *VisionVariable::GetTimer() +{ + return activator->GetTimer(); +} + +str VisionVariable::GetType() +{ + return activator->GetType(); +} + +Vector VisionVariable::vectorValue() +{ + return vector; +} + +qboolean VisionVariable::isBasic() +{ + return false; +} + +qboolean VisionVariable::isEnabled() +{ + if( !activator ) { + return true; + } + + return activator->isEnabled(); +} + +qboolean VisionVariable::isNewEnabled() +{ + if( !activator ) { + return true; + } + + return activator->isNewEnabled(); +} + +void VisionVariable::setValue( str v ) +{ + float x = 0.f, y = 0.f, z = 0.f; + char buffer[ MAX_STRING_TOKENS ]; + qboolean isVector; + + if( sscanf( v, "%f %f %f", &x, &y, &z ) == 3 ) { + isVector = true; + } else { + isVector = false; + } + + string = v; + + value_target = x; + + if( !isVector ) { + vector_target = Vector( x, x, x ); + } else { + // Cast values into vector + vector_target = Vector( x, y, z ); + } + + if( !render_inited ) + { + vector = vector_target; + vector_start = vector_target; + + value = value_target; + value_start = value_target; + } + else + { + value_start = value; + vector_start = vector; + } +} + +void VisionVariable::Think() +{ + if( activator == NULL ) { + return; + } + + ScriptTimer *t = GetTimer(); + + if( !t->isEnabled() ) { + t->Enable(); + } + + vector = t->LerpValue( vector_start, vector_target ); + value = t->LerpValue( value_start, value_target ); +} + +CLASS_DECLARATION( Class, VisionActivator, NULL ) +{ + { NULL, NULL } +}; + +CLASS_DECLARATION( Class, VisionClass, NULL ) +{ + { NULL, NULL } +}; + +CLASS_DECLARATION( Class, VisionVariable, NULL ) +{ + { NULL, NULL } +}; diff --git a/code/cgame_hook/renderer_api.h b/code/cgame_hook/renderer_api.h new file mode 100644 index 00000000..e7cfb9a8 --- /dev/null +++ b/code/cgame_hook/renderer_api.h @@ -0,0 +1,561 @@ +#ifndef _renderer_api_h +#define _renderer_api_h + +#include + +#ifdef _CGAME_DLL +#include "cgamex86.h" +#else +#include "gamex86.h" +#endif + +#ifdef WANT_OPENGL +#include "ogl\opengl_api.h" +#endif + +#define QUAT_EPSILON 0.00001 + +#ifndef M_PI +#define M_PI 3.1415926535897932384626433832795f +#endif + +#define random() ((rand () & 0x7fff) / ((float)0x7fff)) +#define crandom() (2.0 * (random() - 0.5)) + +#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F ) +#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI ) + +#define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535) +#define SHORT2ANGLE(x) ((x)*(360.0/65536)) + +#define SUBMAX( a, b ) ( a > b ? ( a - b ) : ( b - a ) ) +#define SUBMIN( a, b ) ( a < b ? ( a - b ) : ( b - a ) ) + +/*#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) +#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2]) +#define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2]) +#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) +#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s)) +#define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s)) +#define VectorCompare(a,b) (((a)[0]==(b)[0])&&((a)[1]==(b)[1])&&((a)[2]==(b)[2])) + +#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0) +#define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2]) +#define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z)) +#define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])*/ + +#define VectorInverse(a) ((a)[0]=-(a)[0],(a)[1]=-(a)[1],(a)[2]=-(a)[2]) + +#define PITCH 0 +#define YAW 1 +#define ROLL 2 + +#define RED 0 +#define GREEN 1 +#define BLUE 2 + +#define MAX_EFFECTS 10 +#define MAX_EFFECTS_LENGTH 64 + +/* Animation flags */ +#define ANIM_RANDOM 0x01 +#define ANIM_DELTADRIVEN 0x02 +#define ANIM_DONTREPEATE 0x03 +#define ANIM_AUTOSTEPS_DOG 0x04 +#define ANIM_DEFAULTANGLES 0x08 +#define ANIM_NOTIMECHECK 0x10 +#define ANIM_AUTOSTEPS_WALK 0x14 +#define ANIM_AUTOSTEPS_RUN 0x1C + +#define GLS_SRCBLEND_ZERO 0x00000001 +#define GLS_SRCBLEND_ONE 0x00000002 +#define GLS_SRCBLEND_DST_COLOR 0x00000003 +#define GLS_SRCBLEND_ONE_MINUS_DST_COLOR 0x00000004 +#define GLS_SRCBLEND_SRC_ALPHA 0x00000005 +#define GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA 0x00000006 +#define GLS_SRCBLEND_DST_ALPHA 0x00000007 +#define GLS_SRCBLEND_ONE_MINUS_DST_ALPHA 0x00000008 +#define GLS_SRCBLEND_ALPHA_SATURATE 0x00000009 +#define GLS_SRCBLEND_BITS 0x0000000f + +#define GLS_DSTBLEND_ZERO 0x00000010 +#define GLS_DSTBLEND_ONE 0x00000020 +#define GLS_DSTBLEND_SRC_COLOR 0x00000030 +#define GLS_DSTBLEND_ONE_MINUS_SRC_COLOR 0x00000040 +#define GLS_DSTBLEND_SRC_ALPHA 0x00000050 +#define GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA 0x00000060 +#define GLS_DSTBLEND_DST_ALPHA 0x00000070 +#define GLS_DSTBLEND_ONE_MINUS_DST_ALPHA 0x00000080 +#define GLS_DSTBLEND_BITS 0x000000f0 + +#define GLS_DEPTHMASK_TRUE 0x00000100 + +#define GLS_NODEPTH 0x00000200 +#define GLS_DEPTH 0x00000300 + +#define GLS_POLYMODE_LINE 0x00001000 + +#define GLS_DEPTHTEST_DISABLE 0x00010000 +#define GLS_DEPTHFUNC_EQUAL 0x00020000 + +#define GLS_ATEST_GT_0 0x10000000 +#define GLS_ATEST_LT_80 0x20000000 +#define GLS_ATEST_GE_80 0x40000000 +#define GLS_ATEST_BITS 0x70000000 + +#define GLS_DEFAULT GLS_DEPTHMASK_TRUE + +#define ELM_MODELS 0x004b56b3 +#define ELM_WALLS 0x004b598e + +#define ELM_FLAT 0x004b3993 +#define ELM_ENTS 0x004b56b3 +#define ELM_WORLD 0x004b598e + +static const char *anim_cmd[] = +{ + "weight", + "deltadriven", + "default_angles", + "notimecheck", + "crossblend", + "dontrepeate", + "random", + "autosteps_run", + "autosteps_walk", + "autosteps_dog", +}; + +static const char *effectName[MAX_EFFECTS] = +{ + "bloom", + "blur", + "darkwhite", + "dof", + "invert", + "scenecolor", + "thermal", + "wallhack", + "wave", +}; + +qboolean __inline R_IsEffect(const char * fxName) +{ + int i; + + /* Check if the name is a valid effect name */ + for(i=0;iframetime; + num_playing++; + } + else + { + frame[ i ].time = max_time; + } + } + + // Optimize performances + if( !num_playing && this->classinfo() == Animate::classinfostatic() ) { + turnThinkOff(); + } + + Entity::Think(); +} + +void Animate::PlayAnim( const char *name, int index ) +{ + int num = cgi.Anim_NumForName( tiki, name ); + + if( num != -1 ) { + PlayAnim( num, index ); + } +} + +void Animate::PlayAnim( int num, int index ) +{ + float frametime; + + if( index >= MAX_FRAMEINFOS ) { + return; + } + + if( index >= numframes ) + { + numframes++; + frame = ( frameInfo_t * )realloc( frame, sizeof( frameInfo_t ) * numframes ); + } + + frame[ index ].index = num; + frame[ index ].time = 0.0f; + frame[ index ].weight = 1.0f; + + frametime = cgi.Anim_Frametime( tiki, num ); + + if( cgi.Anim_HasCommands( tiki, num ) ) + { + float time = -frametime; + + // Exec anim commands + // They will be executed in the context of the commandManager + + for( int i = 0; i < cgi.Anim_NumFrames( tiki, num ); i++ ) + { + tiki_cmd_t cmds; + Event *ev; + + time += frametime; + + if( !cgi.Frame_Commands( tiki, num, i, &cmds ) ) { + continue; + } + + for( int k = 0; k < cmds.num_cmds; k++ ) + { + cgi.Printf( "args = '%s'\n", cmds.cmds[ k ].args[ 0 ] ); + ev = new Event( cmds.cmds[ k ].args[ 0 ] ); + + for( int c = 1; c < cmds.cmds[ k ].num_args; c++ ) + { + const char *argument = cmds.cmds[ k ].args[ c ]; + + ev->AddString( cmds.cmds[ k ].args[ c ] ); + } + + commandManager->PostEvent( ev, frametime, 0 ); + } + } + } +} + +void Animate::SetTime( int index, float time ) +{ + if( index >= numframes ) { + return; + } + + frame[ index ].time = time; + + turnThinkOn(); +} + +//=== SCRIPT ===\\ + +void Animate::ForwardExec( Event *ev ) +{ + str name = ev->GetString( 1 ); + + PlayAnim( name, 0 ); + SetTime( 0, 0.0f ); +} + +CLASS_DECLARATION( Entity, Animate, NULL ) +{ + { &EV_Animate_Anim, &Animate::ForwardExec }, + { NULL, NULL }, +}; diff --git a/code/cgame_hook/script/canimate.h b/code/cgame_hook/script/canimate.h new file mode 100644 index 00000000..8b01dfb8 --- /dev/null +++ b/code/cgame_hook/script/canimate.h @@ -0,0 +1,25 @@ +#ifndef __CANIMATE_H__ +#define __CANIMATE_H__ + +#include "centity.h" + +class Animate : public Entity +{ +public: + CLASS_PROTOTYPE( Animate ); + + virtual void Archive( Archiver &arc ); + + Animate(); + ~Animate(); + + virtual void Think(); + + void PlayAnim( const char *name, int index ); + void PlayAnim( int num, int index ); + void SetTime( int index, float time ); + + void ForwardExec( Event *ev ); +}; + +#endif /* __CANIMATE_H__ */ diff --git a/code/cgame_hook/script/centity.cpp b/code/cgame_hook/script/centity.cpp new file mode 100644 index 00000000..75da7e9b --- /dev/null +++ b/code/cgame_hook/script/centity.cpp @@ -0,0 +1,449 @@ +/* +* Entity.cpp +* +* DESCRIPTION : Client-side entity +*/ + +#include "centity.h" +#include "archive.h" + +Container< SafePtr< Entity > > s_entities; + +Event EV_Entity_Attach +( + "attach", + EV_DEFAULT, + "esIV", + "parent tagname use_angles offset", + "attach this entity to the parent's legs tag called tagname", + EV_NORMAL +); + +Event EV_Entity_Detach +( + "detach", + EV_DEFAULT, + NULL, + NULL, + "detach this entity from its parent.", + EV_NORMAL +); + +Event EV_Entity_GetModel +( + "model", + EV_DEFAULT, + NULL, + NULL, + "Gets the model.", + EV_RETURN +); + +Event EV_Entity_Getter_GetModel +( + "model", + EV_DEFAULT, + NULL, + NULL, + "Gets the model.", + EV_GETTER +); + +Event EV_Entity_GetScale +( + "scale", + EV_DEFAULT, + NULL, + NULL, + "Gets the scale.", + EV_GETTER +); + +Event EV_Entity_SetModel +( + "model", + EV_DEFAULT, + "s", + "modelName", + "Sets the model to modelName.", + EV_NORMAL +); + +Event EV_Entity_SetScale +( + "scale", + EV_DEFAULT, + "f", + "scale", + "Sets the scale.", + EV_SETTER +); + +Event EV_Entity_Setter_SetModel +( + "model", + EV_DEFAULT, + "s", + "modelName", + "Sets the model to modelName.", + EV_SETTER +); + +Event EV_Entity_SetSize +( + "setsize", + EV_DEFAULT, + "vv", + "mins maxs", + "Set the bounding box of the entity to mins and maxs.", + EV_NORMAL +); + +Event EV_Touch +( + "doTouch", + EV_CODEONLY, + "e", + "touchingEntity", + "sent to entity when touched.", + EV_NORMAL +); + +Entity * CL_GetCEntity( int ent_num ) +{ + // Iterate through simple client entities + for( int i = 0; i < s_entities.NumObjects(); i++ ) + { + Entity * ent = ( Entity * )s_entities[ i ]; + + if( !checkInheritance( &Entity::ClassInfo, ent->classinfo() ) ) { + continue; + } + + int entnum = ent->GetNumber(); + + if( entnum != -1 && entnum == ent_num ) { + return ent; + } + } + + return NULL; +} + +centity_t *CL_GetEntity( int ent_num ) +{ + entityState_t *ce = NULL; + int i; + + for( i = 0; i < cg->activeSnapshots[ 0 ].numEntities; i++ ) + { + if( cg->activeSnapshots[ 0 ].entities[ i ].number == ent_num ) { + ce = &cg->activeSnapshots[ 0 ].entities[ i ]; + } + } + + return ( centity_t * )ce; +} + +void CL_ProcessCEntities() +{ + // Iterate through client entities + for( int i = s_entities.NumObjects(); i > 0; i-- ) + { + Entity *ent = s_entities.ObjectAt( i ); + + if( !checkInheritance( &Entity::ClassInfo, ent->classinfo() ) ) { + continue; + } + + if( ent->CanThink() ) { + ent->Think(); + } + } +} + +Entity::Entity() +{ + cent = &cg_entities[ 0 ]; + centity = &cg_entities[ 0 ]; + + model = ""; + modelhandle = 0; + scale = 1.f; + renderFx = 0; + + tiki = NULL; + + frame = new frameInfo_t[ 1 ]; + numframes = 1; + + entnum = -1; + + frame[ 0 ].index = 0; + frame[ 0 ].time = 0.f; + frame[ 0 ].weight = 1.0f; + + //turnThinkOn(); + + absmin = absmax = mins = maxs = vec_zero; + + s_entities.AddObject( this ); +} + +Entity::~Entity() +{ + if( frame ) { + delete[] frame; + } + + numframes = 0; + + s_entities.RemoveObject( this ); +} + +bool Entity::IsTouching( Entity *ent ) +{ + return ent->absmin[ 0 ] <= absmax[ 0 ] + && ent->absmin[ 1 ] <= absmax[ 1 ] + && ent->absmin[ 2 ] <= absmax[ 2 ] + && absmin[ 0 ] <= ent->absmax[ 0 ] + && absmin[ 1 ] <= ent->absmax[ 1 ] + && absmin[ 2 ] <= ent->absmax[ 2 ]; +} + +float Entity::getScale() +{ + return scale; +} + +qboolean Entity::inRadius( Vector org, float rad ) +{ + if( Vector::Distance( origin, org ) <= rad ) { + return true; + } else { + return false; + } +} + +void Entity::setModel( const char *name ) +{ + model = name; + modelhandle = cgi.R_RegisterModel( name ); + + tiki = cgi.R_Model_GetHandle( modelhandle ); +} + +void Entity::setOrigin( Vector origin ) +{ + this->origin = origin; + + absmin = origin + mins; + absmax = origin + maxs; +} + +void Entity::setScale( float s ) +{ + scale = s; +} + +void Entity::Think() +{ + +} + +void Entity::Archive( Archiver &arc ) +{ + SimpleEntity::Archive( arc ); + + arc.ArchiveBoolean( &fShader ); + + if( fShader ) + { + arc.ArchiveString( &shader ); + + if( arc.Loading() ) { + customshader = cgi.R_RegisterShader( shader ); + } + } + + arc.ArchiveBoolean( &canThink ); + + arc.ArchiveFloat( &scale ); + arc.ArchiveInteger( &entnum ); + arc.ArchiveInteger( &renderFx ); + + arc.ArchiveString( &model ); +} + +frameInfo_t *Entity::GetFrameInfo( int index ) +{ + if( index >= numframes ) { + return NULL; + } else { + return &frame[ index ]; + } +} + +int Entity::GetNumFrames() +{ + return numframes; +} + +void Entity::GetTag( const char *tagname, orientation_t *orient ) +{ + refEntity_t ref; + + if( tiki == NULL ) { + return; + } + + int num = cgi.Tag_NumForName( tiki, tagname ); + + if( num == -1 ) { + return; + } + + memset( &ref, 0, sizeof( refEntity_t ) ); + + VectorCopy( origin, ref.origin ); + MatrixToEulerAngles( ref.axis, angles ); + + ref.reType = RT_MODEL; + + ref.scale = scale; + ref.hModel = modelhandle; + ref.hOldModel = modelhandle; + ref.tiki = tiki; + ref.entityNumber = 0; + ref.actionWeight = 1.0f; + + for( int i = 0; i < GetNumFrames(); i++ ) + { + frameInfo_t *frame = GetFrameInfo( i ); + + ref.frameInfo[ i ].index = frame->index; + ref.frameInfo[ i ].time = frame->time; + ref.frameInfo[ i ].weight = frame->weight; + } + + //cgi.TIKI_Orientation( orient, &ref, num ); + *orient = re.TIKI_Orientation( &ref, num ); +} + +void Entity::AssignNumber( int ent_num ) +{ + if( entnum == -1 ) { + entnum = ent_num; + } +} + +int Entity::GetNumber() +{ + return entnum; +} + +qboolean Entity::CanThink() +{ + return canThink; +} + +void Entity::turnThinkOn() +{ + canThink = true; +} + +void Entity::turnThinkOff() +{ + canThink = false; +} + +void Entity::SetShader( const char *name ) +{ + if( name == NULL ) + { + fShader = false; + shader = ""; + + return; + } + + fShader = true; + customshader = cgi.R_RegisterShader( name ); + shader = name; +} + +//=== SCRIPT ===\\ + +void Entity::EventAttach( Event *ev ) +{ + Entity *parent = ev->GetEntity( 1 ); + str tagname = ev->GetString( 2 ); + int use_angles; + Vector offset; + + if( ev->NumArgs() > 2 ) { + use_angles = ev->GetInteger( 3 ); + } else { + use_angles = 1; + } + + if( ev->NumArgs() > 3 ) { + offset = ev->GetVector( 4 ); + } else { + offset = vec_zero; + } + + attached = parent; + attached_tagname = tagname; + attached_use_angles = use_angles; + attached_offset = offset; +} + +void Entity::EventDetach( Event *ev ) +{ + attached = NULL; +} + +void Entity::EventGetModel( Event *ev ) +{ + ev->AddString( model ); +} + +void Entity::EventGetScale( Event *ev ) +{ + ev->AddFloat( getScale() ); +} + +void Entity::EventSetScale( Event *ev ) +{ + setScale( ev->GetFloat( 1 ) ); +} + +void Entity::EventSetModel( Event *ev ) +{ + str name = ev->GetString( 1 ); + + setModel( name ); +} + +void Entity::EventSetSize( Event *ev ) +{ + mins = ev->GetVector( 1 ); + maxs = ev->GetVector( 2 ); + + setOrigin( origin ); +} + +CLASS_DECLARATION( SimpleEntity, Entity, NULL ) +{ + { &EV_Entity_Attach, &Entity::EventAttach }, + { &EV_Entity_Detach, &Entity::EventDetach }, + { &EV_Entity_GetModel, &Entity::EventGetModel }, + { &EV_Entity_GetScale, &Entity::EventGetScale }, + { &EV_Entity_Getter_GetModel, &Entity::EventGetModel }, + { &EV_Entity_SetModel, &Entity::EventSetModel }, + { &EV_Entity_SetScale, &Entity::EventSetScale }, + { &EV_Entity_Setter_SetModel, &Entity::EventSetModel }, + { &EV_Entity_SetSize, &Entity::EventSetSize }, + { NULL, NULL } +}; diff --git a/code/cgame_hook/script/centity.h b/code/cgame_hook/script/centity.h new file mode 100644 index 00000000..f43b04f3 --- /dev/null +++ b/code/cgame_hook/script/centity.h @@ -0,0 +1,85 @@ +#ifndef __CENTITY_H__ +#define __CENTITY_H__ + +#include "simpleentity.h" + +#define MT_PHYSICS (1<<0) // This entity has physics + +extern Event EV_Touch; + +class Entity : public SimpleEntity { +public: + int entnum; + centity_t *centity; + qboolean fShader; + qhandle_t customshader; + str shader; + + str model; + qhandle_t modelhandle; + dtiki_t *tiki; + int renderFx; + float scale; + int moveType; + + SafePtr< Entity > attached; + str attached_tagname; + int attached_use_angles; + Vector attached_offset; + + Vector absmin, absmax; + Vector mins, maxs; + +private: + qboolean canThink; + +protected: + frameInfo_t *frame; + int numframes; + +public: + CLASS_PROTOTYPE( Entity ); + + virtual void Archive( Archiver &arc ); + + Entity(); + virtual ~Entity(); + + frameInfo_t *GetFrameInfo( int index ); + int GetNumFrames(); + void GetTag( const char *tagname, orientation_t *orient ); + + virtual void Think(); + + bool IsTouching( Entity *ent ); + + float getScale(); + qboolean inRadius( Vector org, float rad ); + void setModel( const char *name ); + virtual void setOrigin( Vector origin ); + void setScale( float scale ); + + void AssignNumber( int ent_num ); + qboolean CanThink( void ); + int GetNumber( void ); + void SetShader( const char *name ); + void turnThinkOn( void ); + void turnThinkOff( void ); + + void EventAttach( Event *ev ); + void EventDetach( Event *ev ); + void EventGetModel( Event *ev ); + void EventGetScale( Event *ev ); + void EventSetModel( Event *ev ); + void EventSetScale( Event *ev ); + void EventSetSize( Event *ev ); +}; + +Entity * CL_GetCEntity( int ent_num ); +centity_t * CL_GetEntity( int ent_num ); + +void CL_ProcessCEntities(); + +extern Container< SafePtr< Entity > > s_entities; + +#endif /* __CENTITY_H__ */ diff --git a/code/cgame_hook/script/clientgamecommand.cpp b/code/cgame_hook/script/clientgamecommand.cpp new file mode 100644 index 00000000..296e780d --- /dev/null +++ b/code/cgame_hook/script/clientgamecommand.cpp @@ -0,0 +1,353 @@ +/* + * ClientGameCommandManager.cpp + * + * DESCRIPTION : Client Game Command Manager + */ + +#include "clientgamecommand.h" +#include "cgame/cl_sound.h" +#include "archive.h" + +uintptr_t *sndDriver = ( uintptr_t * )0x7F5D74; + +typedef void( __cdecl *AIL_CLOSE_STREAM )( void *stream ); +typedef void* ( __cdecl *AIL_OPEN_STREAM )( uintptr_t soundDriver, const char *pFilename, int channel ); +typedef void ( __cdecl *AIL_SET_STREAM_LOOP_COUNT )( void *stream, int count ); +typedef void( __cdecl *AIL_SET_STREAM_PLAYBACK_RATE )( void *stream, int rate ); +typedef void( __cdecl *AIL_SET_STREAM_POSITION )( void *stream, int position ); +typedef void( __cdecl *AIL_SET_STREAM_VOLUME )( void *stream, int volume ); +typedef void ( __cdecl *AIL_START_STREAM )( void *stream ); +typedef int( __cdecl *AIL_STREAM_PLAYBACK_RATE )( void *stream ); +typedef int( __cdecl *AIL_STREAM_POSITION )( void *stream ); +typedef int ( __cdecl *AIL_STREAM_STATUS )( void *stream ); + +typedef char * ( __cdecl *GETFILEPATH )( const char *game_path, const char *path, const char *filename ); + +AIL_CLOSE_STREAM AIL_close_stream = ( AIL_CLOSE_STREAM )0x00486C80; +AIL_OPEN_STREAM AIL_open_stream = ( AIL_OPEN_STREAM )0x00486C20; +AIL_SET_STREAM_LOOP_COUNT AIL_set_stream_loop_count = ( AIL_SET_STREAM_LOOP_COUNT )0x00487030; +AIL_SET_STREAM_PLAYBACK_RATE AIL_set_stream_playback_rate = ( AIL_SET_STREAM_PLAYBACK_RATE )0x00486E70; +AIL_SET_STREAM_POSITION AIL_set_stream_position = ( AIL_SET_STREAM_POSITION )0x00487100; +AIL_SET_STREAM_VOLUME AIL_set_stream_volume = ( AIL_SET_STREAM_VOLUME )0x00486EE0; +AIL_START_STREAM AIL_start_stream = ( AIL_START_STREAM )0x00486DA0; +AIL_STREAM_PLAYBACK_RATE AIL_stream_playback_rate = ( AIL_STREAM_PLAYBACK_RATE )0x00487230; +AIL_STREAM_POSITION AIL_stream_position = ( AIL_STREAM_POSITION )0x004873E0; +AIL_STREAM_STATUS AIL_stream_status = ( AIL_STREAM_STATUS )0x004871E0; + +GETFILEPATH GetFilePath = ( GETFILEPATH )0x00450840; +char *gameDir = ( char * )0x00EC4EE0; + +Container< LocalSound * > localSounds; + +ClientGameCommandManager *commandManager = ( ClientGameCommandManager * )0x30117B90; +ClientSpecialEffectsManager *sfxManager = ( ClientSpecialEffectsManager * )0x3026AB78; + +Event EV_LocalSound_Think +( + "localsound_think", + EV_CODEONLY, + NULL, + NULL, + "Internal event", + EV_NORMAL +); + +LocalSound::LocalSound( str n, qboolean l ) +{ + path = GetFilePath( fs_basepath->string, gameDir, n ); + + stream = AIL_open_stream( *sndDriver, path, 0 ); + + name = n; + + stopping = false; + loop = l; + + if( loop ) { + AIL_set_stream_loop_count( stream, 0 ); + } else { + AIL_set_stream_loop_count( stream, 1 ); + } + + volume = 0.0f; + rate = 1.0f; + + localSounds.AddObject( this ); +} + +LocalSound::LocalSound() +{ + stream = NULL; + + stopping = false; + loop = false; + + volume = 0.0f; + rate = 1.0f; + + localSounds.AddObject( this ); +} + +LocalSound::~LocalSound() +{ + CancelEventsOfType( &EV_LocalSound_Think ); + + if( stream ) { + AIL_close_stream( stream ); + } + + localSounds.RemoveObject( this ); +} + +void LocalSound::Archive( Archiver &arc ) +{ + Listener::Archive( arc ); + + arc.ArchiveString( &name ); + + arc.ArchiveBoolean( &stopping ); + arc.ArchiveBoolean( &loop ); + + if( arc.Saving() ) { + position = AIL_stream_position( stream ); + } + + arc.ArchiveInteger( &position ); + + arc.ArchiveFloat( &volume ); + arc.ArchiveFloat( &start_volume ); + arc.ArchiveFloat( &target_volume ); + + arc.ArchiveFloat( &rate ); + + arc.ArchiveObject( &timer ); + + if( arc.Loading() ) + { + path = GetFilePath( fs_basepath->string, gameDir, name ); + + stream = AIL_open_stream( *sndDriver, path, 0 ); + + if( stream ) + { + AIL_start_stream( stream ); + + if( loop ) { + AIL_set_stream_loop_count( stream, 0 ); + } + else { + AIL_set_stream_loop_count( stream, 1 ); + } + + AIL_set_stream_position( stream, position ); + + Event *ev = new Event( &EV_LocalSound_Think ); + ProcessEvent( ev ); + } + } +} + +str LocalSound::GetName() +{ + return name; +} + +void LocalSound::Play( float time, float v ) +{ + stopping = false; + + start_volume = volume; + + if( time <= 0.0f ) { + volume = v; + } else { + volume = 0.0f; + AIL_set_stream_volume( stream, 0 ); + } + + target_volume = v; + + timer.SetTime( time ); + timer.Enable(); + + start_rate = 1.0f; + target_rate = 1.0f; + rate = 1.0f; + + if( stream ) + { + AIL_start_stream( stream ); + + baserate = AIL_stream_playback_rate( stream ); + + Event *ev = new Event( &EV_LocalSound_Think ); + ProcessEvent( ev ); + } +} + +void LocalSound::Stop( float time ) +{ + if( time <= 0.0f ) + { + delete this; + return; + } + + start_volume = volume; + + timer.SetTime( time ); + timer.Enable(); + + stopping = true; +} + +void LocalSound::SetRate( float r, float time ) +{ + target_rate = r; + start_rate = rate; + + timer_rate.SetTime( time ); + timer_rate.Enable(); + + if( time <= 0.0f ) + { + rate = r; + + if( stream ) + { + int ra = ( int )( ( float )baserate * rate ); + + AIL_set_stream_playback_rate( stream, ra ); + } + } +} + +void LocalSound::Think( Event *ev ) +{ + if( stopping ) { + volume = timer.LerpValue( start_volume, 0.0f ); + } + + AIL_set_stream_volume( stream, ( int )( volume * s_volume->value * *sound_global_volume * 100.0f ) ); + + if( !timer_rate.Done() ) { + rate = timer_rate.LerpValue( start_rate, target_rate ); + } + + int r = ( int )( ( float )baserate * rate ); + AIL_set_stream_playback_rate( stream, r ); + + if( ( stopping && timer.Done() ) || AIL_stream_status( stream ) != STREAM_PLAYING ) + { + CancelEventsOfType( &EV_LocalSound_Think ); + + delete this; + return; + } + + if( !stopping ) { + volume = timer.LerpValue( start_volume, target_volume ); + } + + CancelEventsOfType( &EV_LocalSound_Think ); + PostEvent( EV_LocalSound_Think, level.frametime, 0 ); +} + +CLASS_DECLARATION( Listener, LocalSound, NULL ) +{ + { &EV_LocalSound_Think, &LocalSound::Think }, + { NULL, NULL } +}; + +void ClientGameCommandManager::CleanUp() +{ + Container< LocalSound * > local = localSounds; + + for( int i = 0; i < local.NumObjects(); i++ ) + { + LocalSound *localSound = local[ i ]; + + delete localSound; + } + + localSounds.FreeObjectList(); +} + +void ClientGameCommandManager::ArchiveFunction( Archiver &arc ) +{ + int num = localSounds.NumObjects(); + + arc.ArchiveInteger( &num ); + + if( arc.Saving() ) + { + for( int i = 0; i < num; i++ ) { + arc.ArchiveObject( localSounds[ i ] ); + } + } + else + { + for( int i = 0; i < num; i++ ) { + arc.ReadObject(); + } + } +} + +void ClientGameCommandManager::Initialize() +{ + +} + +void ClientGameCommandManager::PlaySound( str sound_name, float *origin, int channel, float volume, float min_distance, float pitch, int argstype ) +{ + JMPTO( 0x30015E0C ); +} + +void ClientGameCommandManager::PlayLocalSound( str sound_name, qboolean loop, float volume, float time ) +{ + // Don't play the same sound again + StopLocalSound( sound_name ); + + LocalSound *localSound = new LocalSound( sound_name, loop ); + + localSound->Play( time, volume ); +} + +void ClientGameCommandManager::SetLocalSoundRate( str sound_name, float rate, float time ) +{ + LocalSound *localSound = GetLocalSound( sound_name ); + + if( !localSound ) { + return; + } + + localSound->SetRate( rate, time ); +} + +void ClientGameCommandManager::StopLocalSound( str sound_name, float time ) +{ + LocalSound *localSound = GetLocalSound( sound_name ); + + if( localSound ) { + localSound->Stop( time ); + } +} + +LocalSound *ClientGameCommandManager::GetLocalSound( str sound_name ) +{ + for( int i = 1; i <= localSounds.NumObjects(); i++ ) + { + LocalSound *localSound = localSounds.ObjectAt( i ); + + if( localSound->GetName() == sound_name ) { + return localSound; + } + } + + return NULL; +} + +void ClientSpecialEffectsManager::MakeEffect_Normal( int iEffect, Vector position, Vector normal ) +{ + JMPTO( 0x3003524D ); +} diff --git a/code/cgame_hook/script/clientgamecommand.h b/code/cgame_hook/script/clientgamecommand.h new file mode 100644 index 00000000..ec54924f --- /dev/null +++ b/code/cgame_hook/script/clientgamecommand.h @@ -0,0 +1,72 @@ +#ifndef __CLIENTGAMECOMMAND_H__ +#define __CLIENTGAMECOMMAND_H__ + +#include "listener.h" +#include "scripttimer.h" + +class LocalSound : public Listener { +private: + void *stream; + + str name; + str path; + + qboolean loop; + + qboolean stopping; + int position; + int baserate; + + float rate, start_rate, target_rate; + float volume, start_volume, target_volume; + + ScriptTimer timer; + ScriptTimer timer_rate; + +public: + CLASS_PROTOTYPE( LocalSound ); + + virtual void Archive( Archiver &arc ); + + LocalSound( str name, qboolean loop ); + LocalSound(); + ~LocalSound(); + + str GetName(); + + void Play( float time, float volume ); + void Stop( float time ); + + void SetRate( float rate, float time ); + + void Think( Event *ev ); +}; + +#define STREAM_PLAYING 4 +#define STREAM_PAUSED 16 + +class ClientGameCommandManager : public Listener +{ +public: + static void ArchiveFunction( Archiver &arc ); + static void CleanUp( void ); + static void Initialize( void ); + + void PlaySound( str sound_name, float *origin, int channel, float volume, float min_distance, float pitch, int argstype ); + + void PlayLocalSound( str sound_name, qboolean loop, float volume, float time = 0.0f ); + void SetLocalSoundRate( str sound_name, float rate, float time = 0.0f ); + void StopLocalSound( str sound_name, float time = 0.0f ); + LocalSound *GetLocalSound( str sound_name ); +}; + +class ClientSpecialEffectsManager : public Listener +{ +public: + void MakeEffect_Normal( int iEffect, Vector position, Vector normal ); +}; + +extern ClientGameCommandManager *commandManager; +extern ClientSpecialEffectsManager *sfxManager; + +#endif diff --git a/code/cgame_hook/script/clientservercommand.cpp b/code/cgame_hook/script/clientservercommand.cpp new file mode 100644 index 00000000..7f62d69b --- /dev/null +++ b/code/cgame_hook/script/clientservercommand.cpp @@ -0,0 +1,296 @@ +/* +* ClientServerCommandManager.cpp +* +* DESCRIPTION : Client Server Command Manager. Processes server commands as event (if one). +*/ + +#include "clientservercommand.h" +#include "earthquake.h" +#include "cgame/cl_sound.h" + +ClientServerCommandManager svcommandManager; + +Event EV_ServerCommand_Earthquake +( + "eq", + EV_SERVERCMD, + "ffbbVF", + "duration magnitude no_rampup no_rampdown location radius", + "Earthquake", + EV_NORMAL +); + +Event EV_ServerCommand_FadeSound +( + "fadesound2", + EV_SERVERCMD, + "ff", + "time min_vol", + "Fade the sound", + EV_NORMAL +); + +Event EV_ServerCommand_RestoreSound +( + "restoresound", + EV_SERVERCMD, + "ff", + "time max_vol", + "Restore the sound", + EV_NORMAL +); + +Event EV_ServerCommand_SetClientFlag +( + "cf", + EV_SERVERCMD, + "s", + "name", + "Client call back flag.", + EV_NORMAL +); + +Event EV_ServerCommand_SetShader +( + "setshader", + EV_SERVERCMD, + "isb", + "ent_num shader fReset", + "Set entity shader", + EV_NORMAL +); + +Event EV_ServerCommand_VisionSetBlur +( + "vsb", + EV_SERVERCMD, + "ff", + "blur_level transition_time", + "Specific server command for the naked blur vision", + EV_NORMAL +); + +Event EV_ServerCommand_VisionSetNaked +( + "vsn", + EV_SERVERCMD, + "sff", + "vision transition_time phase", + "Specific server command for the naked vision", + EV_NORMAL +); + +void ClientServerCommandManager::Archive( Archiver &arc ) +{ + +} + +void ClientServerCommandManager::ExecuteCommand( char *arguments[], int num_arguments ) +{ + const char *command = arguments[ 0 ]; + const char *formatspec; + int k; + + char **args = arguments + 1; + + Event *ev = new Event( command, EV_NORMAL ); + + if( ev->eventnum == 0 ) + { + delete ev; + return; + } + + formatspec = ev->GetFormat(); + + for( int i = 0, k = 0; k < num_arguments - 1; k++ ) + { + const char *argument = args[ i ]; + str vec; + + if( formatspec[ k ] == '\0' ) { + break; + } + + if( argument == NULL || *argument == '\0' ) { + continue; + } + + switch( formatspec[ k ] ) + { + case 'b': + case 'B': + ev->AddInteger( atoi( argument ) ); + i++; + break; + + case 's': + case 'S': + ev->AddString( argument ); + i++; + break; + + case 'i': + case 'I': + ev->AddInteger( atoi( argument ) ); + i++; + break; + + case 'f': + case 'F': + ev->AddFloat( ( float )atof( argument ) ); + i++; + break; + + case 'v': + case 'V': + vec = args[ i ]; + vec += str( " " ) + args[ i + 1 ]; + vec += str( " " ) + args[ i + 2 ]; + + ev->AddVector( Vector( vec.c_str() ) ); + i += 3; + break; + + default: + ev->AddString( argument ); + i++; + } + } + + try + { + ProcessEvent( ev ); + } + catch( ScriptException exc ) + { + cgi.Printf( exc.string ); + } +} + + +////==== EVENTS ====//// + +void ClientServerCommandManager::EventEarthquake( Event *ev ) +{ + float duration = ev->GetFloat( 1 ); + float magnitude = ev->GetFloat( 2 ); + qboolean no_rampup = ev->GetBoolean( 3 ); + qboolean no_rampdown = ev->GetBoolean( 4 ); + Vector org; + float radius; + + if( ev->NumArgs() > 4 ) + { + org = ev->GetVector( 5 ); + + if( ev->NumArgs() > 5 ) { + radius = ev->GetFloat( 6 ); + } + } + + Earthquake * earthquake = new Earthquake; + + earthquake->SetDuration( duration ); + earthquake->SetMagnitude( magnitude ); + earthquake->SetNoRampup( no_rampup ); + earthquake->SetNoRampdown( no_rampdown ); + + if( ev->NumArgs() > 4 ) + { + earthquake->SetLocation( org ); + + if( ev->NumArgs() > 5 ) { + earthquake->SetRadius( radius ); + } + } + + earthquake->Enable(); +} + +void ClientServerCommandManager::EventFadeSound( Event *ev ) +{ + float time = ev->GetFloat( 1 ); + float min_vol = ev->GetFloat( 2 ); + + CL_FadeSound2( time, min_vol ); +} + +void ClientServerCommandManager::EventRestoreSound( Event *ev ) +{ + float time = ev->GetFloat( 1 ); + float max_vol = ev->GetFloat( 2 ); + + CL_RestoreSound( time, max_vol ); +} + +void ClientServerCommandManager::EventSetClientFlag( Event *ev ) +{ + /*str name = ev->GetString( 1 ); + ClientScript *clientScript; + + clientScript = new ClientScript; + + clientScript->ExecuteCallback( name ); + + if( clientScript->ScriptFailed() ) { + delete clientScript; + }*/ +} + +void ClientServerCommandManager::EventSetShader( Event *ev ) +{ + int ent_num = ev->GetInteger( 1 ); + str shadername = ev->GetString( 2 ); + qboolean fReset = ev->GetBoolean( 3 ); + + R_SetShader( ent_num, shadername, fReset ); +} + +void ClientServerCommandManager::EventVisionSetBlur( Event *ev ) +{ + float blur_level = ev->GetFloat( 1 ); + float transition_time; + + if( ev->NumArgs() > 1 ) { + transition_time = ev->GetFloat( 2 ); + } else { + transition_time = 0.0f; + } + + R_ProcessBlur( blur_level, transition_time ); +} + +void ClientServerCommandManager::EventVisionSetNaked( Event *ev ) +{ + str vision_name = ev->GetString( 1 ); + float transition_time; + float phase; + + if( ev->NumArgs() > 1 ) { + transition_time = ev->GetFloat( 2 ); + } else { + transition_time = 0.0f; + } + + if( ev->NumArgs() > 2 ) { + phase = ev->GetFloat( 3 ); + } + else { + phase = 0.0f; + } + + R_ProcessVision( vision_name, transition_time, phase ); +} + +CLASS_DECLARATION( Listener, ClientServerCommandManager, NULL ) +{ + { &EV_ServerCommand_Earthquake, &ClientServerCommandManager::EventEarthquake }, + { &EV_ServerCommand_FadeSound, &ClientServerCommandManager::EventFadeSound }, + { &EV_ServerCommand_RestoreSound, &ClientServerCommandManager::EventRestoreSound }, + { &EV_ServerCommand_SetClientFlag, &ClientServerCommandManager::EventSetClientFlag }, + { &EV_ServerCommand_SetShader, &ClientServerCommandManager::EventSetShader }, + { &EV_ServerCommand_VisionSetBlur, &ClientServerCommandManager::EventVisionSetBlur }, + { &EV_ServerCommand_VisionSetNaked, &ClientServerCommandManager::EventVisionSetNaked }, + { NULL, NULL } +}; diff --git a/code/cgame_hook/script/clientservercommand.h b/code/cgame_hook/script/clientservercommand.h new file mode 100644 index 00000000..487a704f --- /dev/null +++ b/code/cgame_hook/script/clientservercommand.h @@ -0,0 +1,26 @@ +#ifndef __CLIENTSERVERCOMMAND_H__ +#define __CLIENTSERVERCOMMAND_H__ + +#include "listener.h" + +class ClientServerCommandManager : public Listener { +public: + CLASS_PROTOTYPE( ClientServerCommandManager ); + + virtual void Archive( Archiver &arc ); + + void ExecuteCommand( char *arguments[], int num_arguments ); + + // Events + void EventEarthquake( Event *ev ); + void EventFadeSound( Event *ev ); + void EventRestoreSound( Event *ev ); + void EventSetClientFlag( Event *ev ); + void EventSetShader( Event *ev ); + void EventVisionSetBlur( Event *ev ); + void EventVisionSetNaked( Event *ev ); +}; + +extern ClientServerCommandManager svcommandManager; + +#endif // __CLIENTSERVERCOMMAND_H__ diff --git a/code/cgame_hook/script/cplayer.cpp b/code/cgame_hook/script/cplayer.cpp new file mode 100644 index 00000000..6e5b3d8c --- /dev/null +++ b/code/cgame_hook/script/cplayer.cpp @@ -0,0 +1,688 @@ +/* + * CPlayer.cpp + * + * DESCRIPTION : Client-side player + */ + +#include "cplayer.h" +#include "earthquake.h" +#include "cgame/cg_viewmodelanim.h" +#include "archive.h" + +CPlayer player; + +Event EV_ReplicationInfo_GetVariable +( + "getvar", + EV_DEFAULT, + "s", + "name", + "Gets a replicated variable", + EV_RETURN +); + +Event EV_Player_GetReplicationInfo +( + "replicationinfo", + EV_DEFAULT, + NULL, + NULL, + "Gets the player's replication info", + EV_GETTER +); + +Event EV_Player_GetMovement +( + "getmovement", + EV_DEFAULT, + NULL, + NULL, + "Gets the player's movement state", + EV_RETURN +); + +Event EV_Player_GetSpeed +( + "movespeedscale", + EV_DEFAULT, + NULL, + NULL, + "Gets the player's speed scale", + EV_GETTER +); + +Event EV_Player_SetSpeed +( + "movespeedscale", + EV_DEFAULT, + "f", + "speed", + "Sets the player's speed scale until the next snapshot", + EV_SETTER +); + +Event EV_Player_ViewModelAnim +( + "viewmodelanim", + EV_DEFAULT, + "si", + "anim force_restart", + "Sets the player's view model animation", + EV_NORMAL +); + +void ReplicationInfo::ReplicateVariable( ScriptVariable& var ) +{ + replicatedvars.SetVariable( var.GetKey(), var ); +} + +void ReplicationInfo::EventGetVariable( Event *ev ) +{ + ScriptVariable *pVar = replicatedvars.GetVariable( ev->GetString( 1 ) ); + + if( pVar ) + { + ev->AddValue( *pVar ); + } + else + { + ev->AddNil(); + } +} + +CLASS_DECLARATION( Listener, ReplicationInfo, NULL ) +{ + { &EV_ReplicationInfo_GetVariable, &ReplicationInfo::EventGetVariable }, + { NULL, NULL } +}; + +CPlayer::CPlayer() +{ + for( int i = 0; i < MAX_DELTAANGLES; i++ ) + { + _targetActive[ i ][ 0 ] = false; + _targetActive[ i ][ 1 ] = false; + _targetActive[ i ][ 2 ] = false; + + VectorSet( _currentTarget[ i ], 0, 0, 0 ); + VectorSet( deltaAngles[ i ], 0, 0, 0 ); + VectorSet( deltaAnglesOld[ i ], 0, 0, 0 ); + } + + VectorSet( eyesDelta, 0, 0, 0 ); + VectorSet( eyesDeltaOld, 0, 0, 0 ); + + debugCamera = false; + debugCameraEnd = false; + debugPoint = Vector( 0, 0, 0 ); + + mins = Vector( -16, -16, 0 ); + maxs = Vector( 16, 16, 96 ); + + m_fMoveSpeedScale = 1.0f; + m_fExposure = 0.0f; + m_fExposurePrevious = 0.0f; + + m_ExposureTimer.setType( TIMER_GLIDE ); + + renderFx = RF_INVISIBLE; + + turnThinkOn(); +} + +void CPlayer::Archive( Archiver &arc ) +{ + str s; + + if( this != &player ) + { + player.Archive( arc ); + + delete this; + return; + } + + Animate::Archive( arc ); + + for( int i = 0; i < MAX_DELTAANGLES; i++ ) + { + arc.ArchiveVector( &_targetDeltaAngles[ i ] ); + arc.ArchiveVector( &_targetDeltaStart[ i ] ); + arc.ArchiveVector( &_targetDeltaTime[ i ] ); + + for( int x = 0; x < 3; x++ ) + { + arc.ArchiveBoolean( &_targetActive[ i ][ x ] ); + arc.ArchiveBoolean( &_godown[ i ][ x ] ); + arc.ArchiveBoolean( &_glidingDown[ i ][ x ] ); + arc.ArchiveBoolean( &_glideUse[ i ][ x ] ); + } + + arc.ArchiveVector( &_currentTarget[ i ] ); + arc.ArchiveVector( &_currentDeltaTime[ i ] ); + arc.ArchiveVector( &_glideRatio[ i ] ); + } + + arc.ArchiveBoolean( &debugCamera ); + arc.ArchiveBoolean( &debugCameraEnd ); + + arc.ArchiveVector( &debugPoint ); + arc.ArchiveVector( &debugAngles ); + arc.ArchiveVector( &debugPlayerAngles ); + + int num_prefixes = 19; + + if( !arc.Loading() ) + { + for( int i = 19; i < 255; i++ ) + { + if( itemName[i] != NULL && itemPrefix[i] != NULL ) { + num_prefixes++; + } + } + } + + arc.ArchiveInteger( &num_prefixes ); + + if( arc.Saving() ) + { + for( int i = 19; i < 255; i++ ) + { + if( itemName[ i ] != NULL && itemPrefix[ i ] != NULL ) + { + s = itemName[ i ]; + arc.ArchiveString( &s ); + + s = itemPrefix[ i ]; + arc.ArchiveString( &s ); + } + } + } + else + { + for( int i = 19; i < num_prefixes; i++ ) + { + arc.ArchiveString( &s ); + + itemName[ i ] = ( char * )malloc( s.length() + 1 ); + strcpy( ( char * )itemName[ i ], s.c_str() ); + + arc.ArchiveString( &s ); + + itemPrefix[ i ] = ( char * )malloc( s.length() + 1 ); + strcpy( ( char * )itemPrefix[ i ], s.c_str() ); + } + } + + arc.ArchiveVector( ( Vector * )&viewAngles ); + arc.ArchiveVector( &avel ); + arc.ArchiveVector( &oldAngles ); +} + +void CPlayer::Think() +{ + Vector a; + Entity *ent; + + cent = &cg_entities[ 0 ]; + + if( cg->playerFPSModel != NULL ) + { + model = cg->playerFPSModel->name; + modelhandle = cg->playerFPSModelHandle; + + tiki = cg->playerFPSModel; + } + else + { + model = ""; + modelhandle = 0; + tiki = NULL; + } + + MatrixToEulerAngles( cg->refdef.viewAxis, a ); + + setOrigin( cg->refdef.viewOrg ); + + ShakeCamera(); + SmoothProcessDeltaAngles(); + + a[ 0 ] = abs( a[ 0 ] ); + a[ 1 ] = abs( a[ 1 ] ); + a[ 2 ] = abs( a[ 2 ] ); + + avel = a - oldAngles; + + oldAngles = a; + + Container< SafePtr< Entity > > entities = s_entities; + + for( int i = entities.NumObjects(); i > 0; i-- ) + { + ent = entities.ObjectAt( i ); + + if( ent && IsTouching( ent ) ) + { + Event *event = new Event( EV_Touch ); + event->AddEntity( this ); + + ent->ProcessEvent( event ); + } + } + + /*if( m_ExposureTrigger != NULL && !IsTouching( m_ExposureTrigger ) ) + { + TriggerExposure *trigger = ( TriggerExposure * )m_ExposureTrigger.Pointer(); + + m_fExposureStart = m_fExposure; + m_fExposureTarget = 0.0f; + + m_ExposureTimer.SetTime( trigger->m_fExposureTime ); + m_ExposureTimer.Enable(); + + m_ExposureTrigger = NULL; + }*/ + + m_fExposure = m_ExposureTimer.LerpValue( m_fExposureStart, m_fExposureTarget ); + + Animate::Think(); +} + +void CPlayer::ShakeCamera() +{ + // Shake the current player's camera + float earthquakeMagnitude = 0.0f; + Earthquake *eq; + float magnitude; + + for( int i = earthquakes.NumObjects(); i > 0; i-- ) + { + eq = earthquakes.ObjectAt( i ); + + if( !eq->isActive() ) { + continue; + } + + magnitude = eq->getMagnitude(); + + if( eq->hasLocation() ) + { + Vector location = eq->getLocation(); + float radius = eq->getRadius(); + + if( inRadius( location, radius ) ) + { + Vector org = origin; + Vector dir = org - location; + float dist = dir.length(); + + magnitude = magnitude - ( magnitude * ( dist / radius ) ); + } + else + { + magnitude = 0.0f; + } + } + + earthquakeMagnitude += magnitude; + } + + if( earthquakeMagnitude <= 0.0f ) + { + VectorSet( deltaAngles[ ANGLES_EQ ], 0, 0, 0 ); + return; + } + + magnitude = earthquakeMagnitude / 2.0f; + + if( !_targetActive[ ANGLES_EQ ][ PITCH ] ) + { + float angle; + + if( !_godown[ ANGLES_EQ ][ PITCH ] ) + { + angle = 1.85f * magnitude; + _godown[ ANGLES_EQ ][ PITCH ] = true; + } + else + { + angle = -1.85f * magnitude; + _godown[ ANGLES_EQ ][ PITCH ] = false; + } + + SmoothSetDeltaAngle( ANGLES_EQ, PITCH, 0.105f, angle ); + } + + if( !_targetActive[ ANGLES_EQ ][ YAW ] ) + { + float angle; + + if( !_godown[ ANGLES_EQ ][ YAW ] ) + { + angle = 1.75f * magnitude; + _godown[ ANGLES_EQ ][ YAW ] = true; + } + else + { + angle = -1.75f * magnitude; + _godown[ ANGLES_EQ ][ YAW ] = false; + } + + SmoothSetDeltaAngle( ANGLES_EQ, YAW, 0.060f, angle ); + } + + if( !_targetActive[ ANGLES_EQ ][ ROLL ] ) + { + float angle; + + if( !_godown[ ANGLES_EQ ][ ROLL ] ) + { + angle = 1.35f * magnitude; + _godown[ ANGLES_EQ ][ ROLL ] = true; + } + else + { + angle = -1.35f * magnitude; + _godown[ ANGLES_EQ ][ ROLL ] = false; + } + + SmoothSetDeltaAngle( ANGLES_EQ, ROLL, 0.082f, angle ); + } +} + +void CPlayer::SmoothSetDeltaAngles( int port, float time, vec3_t newDeltaAngles, qboolean bMoveVM ) +{ + SmoothSetDeltaAngle( port, 0, time, newDeltaAngles[ 0 ] ); + SmoothSetDeltaAngle( port, 1, time, newDeltaAngles[ 1 ] ); + SmoothSetDeltaAngle( port, 2, time, newDeltaAngles[ 2 ] ); +} + +void CPlayer::SmoothSetDeltaAngle( int port, int index, float time, float angle ) +{ + if( index > 2 ) { + return; + } + + float realtime = time * 1000.0f + 0.5f; + + _currentDeltaTime[ port ][ index ] = 0.0f; + + deltaAngles[ port ][ index ] = _currentTarget[ port ][ index ]; + + _glideRatio[ port ][ index ] = 0.0f; + _glidingDown[ port ][ index ] = false; + _glideTime[ port ][ index ] = 0.0f; + _glideUse[ port ][ index ] = ( ( realtime / 2 ) > cg->frametime ) ? true : false; + + _targetDeltaAngles[ port ][ index ] = angle; + _targetDeltaStart[ port ][ index ] = _currentTarget[ port ][ index ]; + _targetDeltaTime[ port ][ index ] = realtime; + + _targetActive[ port ][ index ] = true; +} + +void CPlayer::SmoothProcessDeltaAngle( int port, int index ) +{ + if( index > 2 || port >= MAX_DELTAANGLES ) { + return; + } + + // Process each angle + + if( !_targetActive[ port ][ index ] ) { + return; + } + + _glideTime[ port ][ index ] += cg->frametime; + + // Glide the angle by time + if( _glideUse[ port ][ index ] ) + { + if( _glidingDown[ port ][ index ] ) + { + //_glideRatio[ port ][ index ] -= 2.0f/( _targetDeltaTime[ port ][ index ]/2 ) * cg->frametime; + _glideRatio[ port ][ index ] = 2.0f - 2.0f * _glideTime[ port ][ index ] / ( _targetDeltaTime[ port ][ index ] / 2.0f ); + + if( _glideRatio[ port ][ index ] < 0.0f ) + { + _glideRatio[ port ][ index ] = 0.0f; + _glidingDown[ port ][ index ] = false; + + _glideTime[ port ][ index ] = 0.0f; + } + } + else + { + //_glideRatio[ port ][ index ] += 2.0f/( _targetDeltaTime[ port ][ index ]/2 ) * cg->frametime; + _glideRatio[ port ][ index ] = 2.0f * _glideTime[ port ][ index ] / ( _targetDeltaTime[ port ][ index ] / 2.0f ); + + if( _glideRatio[ port ][ index ] > 2.0f ) + { + _glideRatio[ port ][ index ] = 2.0f; + _glidingDown[ port ][ index ] = true; + + _glideTime[ port ][ index ] = 0.0f; + } + } + + _currentDeltaTime[ port ][ index ] += cg->frametime * _glideRatio[ port ][ index ]; + } else { + _currentDeltaTime[ port ][ index ] += cg->frametime; + } + + float ratio = _currentDeltaTime[ port ][ index ] / _targetDeltaTime[ port ][ index ]; + + if( ratio >= 1.0f ) + { + deltaAngles[ port ][ index ] = _targetDeltaAngles[ port ][ index ]; + _currentTarget[ port ][ index ] = _targetDeltaAngles[ port ][ index ]; + _targetActive[ port ][ index ] = false; + + return; + } + + deltaAngles[ port ][ index ] = _targetDeltaStart[ port ][ index ] + ( _targetDeltaAngles[ port ][ index ] - _targetDeltaStart[ port ][ index ] ) * ratio; + + _currentTarget[ port ][ index ] = deltaAngles[ port ][ index ]; +} + +void CPlayer::SmoothProcessDeltaAngles() +{ + for( int i = 0; i < MAX_DELTAANGLES; i++ ) + { + SmoothProcessDeltaAngle( i, 0 ); + SmoothProcessDeltaAngle( i, 1 ); + SmoothProcessDeltaAngle( i, 2 ); + } +} + +void CPlayer::DebugCamera() +{ + if( !cg_debugview->integer ) + { + //debugCamera = false; + + if( !debugCameraEnd ) + { + // Restore the player's view angles + VectorCopy( debugPlayerAngles, viewAngles ); + + debugCameraEnd = true; + } + + return; + } + + // Initialize debug point + if( !debugCamera ) + { + debugCamera = true; + + debugAngles = cg->refdefViewAngles; + debugPoint = cg->refdef.viewOrg; + debugPoint.z += cg->predictedPlayerState.viewheight; + } + + if( debugCameraEnd ) + { + // Save the player's view angles + debugPlayerAngles = viewAngles; + + // Restore the debug camera's view angles + VectorCopy( debugAngles, viewAngles ); + + debugCameraEnd = false; + } + + // Save the camera's view angles + debugAngles = viewAngles; + + cg->predictedPlayerState.camera_flags |= 8; + + kbutton_t *forward = ( kbutton_t * )0x12F6FE0; + kbutton_t *backward = ( kbutton_t * )0x12F70C0; + kbutton_t *moveleft = ( kbutton_t * )0x12F7040; + kbutton_t *moveright = ( kbutton_t * )0x12F70A0; + kbutton_t *movedown = ( kbutton_t * )0x012F6FC0; + kbutton_t *moveup = ( kbutton_t* )0x012F6FA0; + + Vector newAngles = cg->refdefViewAngles; + + //newAngles[ 0 ] = 0.f; + + if( forward->active ) + { + Vector fwdvec; + + AngleVectors( newAngles, fwdvec, NULL, NULL ); + + debugPoint = debugPoint + fwdvec * ( ( float )cg->frametime * 2 ); + } + + if( backward->active ) + { + Vector backvec; + + AngleVectors( newAngles, backvec, NULL, NULL ); + + debugPoint = debugPoint - backvec * ( ( float )cg->frametime * 2 ); + } + + if( moveleft->active ) + { + Vector leftvec; + + AngleVectors( newAngles, NULL, leftvec, NULL ); + + debugPoint = debugPoint + leftvec * ( ( float )cg->frametime * 2 ); + } + + if( moveright->active ) + { + Vector rightvec; + + AngleVectors( newAngles, NULL, rightvec, NULL ); + + debugPoint = debugPoint - rightvec * ( ( float )cg->frametime * 2 ); + } + + if( moveup->active ) + { + Vector upvec; + + newAngles.x = 0.f; + + AngleVectors( newAngles, NULL, NULL, upvec ); + + debugPoint = debugPoint + upvec * ( ( float )cg->frametime ); + } + + if( movedown->active ) + { + Vector downvec; + + newAngles.x = 0.f; + + AngleVectors( newAngles, NULL, NULL, downvec ); + + debugPoint = debugPoint - downvec * ( ( float )cg->frametime ); + } + + cg->refdef.viewOrg[ 0 ] = debugPoint[ 0 ]; + cg->refdef.viewOrg[ 1 ] = debugPoint[ 1 ]; + cg->refdef.viewOrg[ 2 ] = debugPoint[ 2 ]; + + VectorCopy( cg->refdef.viewOrg, cg->currentViewPos ); + VectorCopy( cg->refdef.viewOrg, cg->playerHeadPos ); + VectorCopy( cg->refdef.viewOrg, cg->cameraOrigin ); + VectorCopy( cg->refdef.viewOrg, cg->soundOrg ); + + VectorCopy( cg->refdef.viewOrg, cg->predictedPlayerState.camera_origin ); + + //VectorCopy( cg->refdef.viewOrg, cg->predictedPlayerState.origin ); + //cg->predictedPlayerState.origin[ 0 ] -= cg->predictedPlayerState.viewHeight; +} + +// Script + +void CPlayer::EventGetMovement( Event *ev ) +{ + kbutton_t *forward = ( kbutton_t * )0x12F6FE0; + kbutton_t *movedown = ( kbutton_t* )0x012F6FC0; + kbutton_t *moveup = ( kbutton_t* )0x012F6FA0; + + if( forward->active && !moveup->active && !movedown->active ) + { + ev->AddString( "forward" ); + } + else if( movedown->active ) + { + ev->AddString( "crouch" ); + } + else if( moveup->active ) + { + ev->AddString( "jump" ); + } + else + { + ev->AddString( "idle" ); + } +} + +void CPlayer::EventGetReplicationInfo( Event *ev ) +{ + ev->AddListener( &replication ); +} + +void CPlayer::EventGetSpeed( Event *ev ) +{ + ev->AddFloat( m_fMoveSpeedScale ); +} + +void CPlayer::EventSetSpeed( Event *ev ) +{ + m_fMoveSpeedScale = ev->GetFloat( 1 ); +} + +void CPlayer::EventViewModelAnim( Event *ev ) +{ + if( cg->snap != NULL ) + { + cg->snap->ps.iViewModelAnim = VMA_CUSTOMANIMATION; + } + + cgi.anim->lastVMAnim = VMA_CUSTOMANIMATION; + cgi.anim->lastVMAnimChanged = ( cg->snap->ps.iViewModelAnimChanged + 1 ) & 3; + + CG_ViewModelAnim( ( char * )ev->GetString( 1 ).c_str(), false ); +} + +CLASS_DECLARATION( CAnimate, CPlayer, NULL ) +{ + { &EV_Player_GetMovement, &CPlayer::EventGetMovement }, + { &EV_Player_GetReplicationInfo, &CPlayer::EventGetReplicationInfo }, + { &EV_Player_GetSpeed, &CPlayer::EventGetSpeed }, + { &EV_Player_SetSpeed, &CPlayer::EventSetSpeed }, + { &EV_Player_ViewModelAnim, &CPlayer::EventViewModelAnim }, + { NULL, NULL } +}; diff --git a/code/cgame_hook/script/cplayer.h b/code/cgame_hook/script/cplayer.h new file mode 100644 index 00000000..ec497f4b --- /dev/null +++ b/code/cgame_hook/script/cplayer.h @@ -0,0 +1,97 @@ +#ifndef __CPLAYER_H__ +#define __CPLAYER_H__ + +#include "canimate.h" +#include "scripttimer.h" +#include "scriptvariable.h" + +// EQ prefix = earthquake + +#define ANGLES_EQ 0 +#define MAX_DELTAANGLES 4 + +class ReplicationInfo : public Listener +{ +private: + ScriptVariableList replicatedvars; + +public: + CLASS_PROTOTYPE( ReplicationInfo ); + + void ReplicateVariable( ScriptVariable& variable ); + + void EventGetVariable( Event *ev ); +}; + +class CPlayer : public Animate +{ +private: + Vector _targetDeltaAngles[ MAX_DELTAANGLES ]; + Vector _targetDeltaStart[ MAX_DELTAANGLES ]; + Vector _targetDeltaTime[ MAX_DELTAANGLES ]; + qboolean _targetActive[ MAX_DELTAANGLES ][ 3 ]; + qboolean _godown[ MAX_DELTAANGLES ][ 3 ]; + + Vector _currentTarget[ MAX_DELTAANGLES ]; + Vector _currentDeltaTime[ MAX_DELTAANGLES ]; + Vector _glideRatio[ MAX_DELTAANGLES ]; + Vector _glideTime[ MAX_DELTAANGLES ]; + qboolean _glidingDown[ MAX_DELTAANGLES ][ 3 ]; + qboolean _glideUse[ MAX_DELTAANGLES ][ 3 ]; + + qboolean debugCamera; + qboolean debugCameraEnd; + Vector debugPoint; + Vector debugAngles; + Vector debugPlayerAngles; + +public: + float deltaAnglesOld[MAX_DELTAANGLES][3]; + float deltaAngles[MAX_DELTAANGLES][3]; + Vector eyesDelta; + Vector eyesDeltaOld; + Vector vAngles; + + Vector oldAngles; + Vector avel; + + ReplicationInfo replication; + float m_fMoveSpeedScale; + + SafePtr< Entity > m_ExposureTrigger; + float m_fExposure; + float m_fExposurePrevious; + float m_fExposureStart; + float m_fExposureTarget; + ScriptTimer m_ExposureTimer; + + playerState_t *ps; + +private: + void SmoothProcessDeltaAngles( void ); + void SmoothProcessDeltaAngle( int port, int index ); + +public: + CLASS_PROTOTYPE( CPlayer ); + + virtual void Archive( Archiver &arc ); + + CPlayer(); + + virtual void Think( void ); + + void DebugCamera( void ); + void ShakeCamera( void ); + void SmoothSetDeltaAngles( int port, float time, vec3_t newDeltaAngles, qboolean bMoveVM = false ); + void SmoothSetDeltaAngle( int port, int index, float time, float angle ); + + void EventGetMovement( Event *ev ); + void EventGetReplicationInfo( Event *ev ); + void EventGetSpeed( Event *ev ); + void EventSetSpeed( Event *ev ); + void EventViewModelAnim( Event *ev ); +}; + +extern CPlayer player; + +#endif diff --git a/code/cgame_hook/script/earthquake.cpp b/code/cgame_hook/script/earthquake.cpp new file mode 100644 index 00000000..7190bcc3 --- /dev/null +++ b/code/cgame_hook/script/earthquake.cpp @@ -0,0 +1,232 @@ +/* + * Earthquake.cpp + * + * DESCRIPTION : Client-side realistic earthquake and network optimizer + */ + +#include "earthquake.h" +#include "archive.h" + +Event EV_Earthquake_Think +( + "eq_think", + EV_CODEONLY, + NULL, + NULL, + "Internal event", + EV_NORMAL +); + +Container< Earthquake * > earthquakes; + +Earthquake::Earthquake() +{ + _duration = 1.0f; + _magnitude = 0.7f; + _no_rampup = false; + _no_rampdown = false; + + _location = Vector( 0, 0, 0 ); + _radius = 1000.0f; + + active = false; + + earthquakes.AddObject( this ); +} + +Earthquake::Earthquake( float duration, float magnitude, qboolean no_rampup, qboolean no_rampdown, Vector location, float radius ) +{ + SetDuration( duration ); + SetMagnitude( magnitude ); + SetNoRampup( no_rampup ); + SetNoRampdown( no_rampdown ); + SetLocation( location ); + SetRadius( radius ); + + active = false; + + earthquakes.AddObject( this ); +} + +Earthquake::~Earthquake() +{ + Disable(); + + earthquakes.RemoveObject( this ); +} + +void Earthquake::Archive( Archiver &arc ) +{ + SimpleEntity::Archive( arc ); + + arc.ArchiveFloat( &_duration ); + arc.ArchiveFloat( &_magnitude ); + + arc.ArchiveBoolean( &_no_rampup ); + arc.ArchiveBoolean( &_no_rampdown ); + + arc.ArchiveVector( &_location ); + arc.ArchiveFloat( &_radius ); + + arc.ArchiveFloat( &_currentMagnitude ); + arc.ArchiveFloat( &_currentTime ); + + arc.ArchiveBoolean( &active ); + + if( arc.Loading() ) { + _startTime = cg->time - _currentTime; + } +} + +float Earthquake::getMagnitude() +{ + return _currentMagnitude; +} + +Vector Earthquake::getLocation() +{ + return _location; +} + +float Earthquake::getRadius() +{ + return _radius; +} + +qboolean Earthquake::hasLocation() +{ + return _location != Vector( 0, 0, 0 ); +} + +void Earthquake::SetDuration( float duration ) +{ + _duration = duration * 1000.0f; +} + +void Earthquake::SetMagnitude( float magnitude ) +{ + _magnitude = magnitude; +} + +void Earthquake::SetNoRampup( qboolean no_rampup ) +{ + _no_rampup = no_rampup; +} + +void Earthquake::SetNoRampdown( qboolean no_rampdown ) +{ + _no_rampdown = no_rampdown; +} + +void Earthquake::SetLocation( Vector origin ) +{ + _location = origin; +} + +void Earthquake::SetRadius( float radius ) +{ + _radius = radius; +} + +void Earthquake::Enable( void ) +{ + if ( _duration > 0.0f ) + { + _startTime = ( float )cg->time; + + _currentMagnitude = _magnitude; + _currentTime = 0.0f; + + active = true; + + ProcessScriptEvent( EV_Earthquake_Think ); + } +} + +void Earthquake::Disable( void ) +{ + active = false; + + _startTime = 0.0f; + _currentMagnitude = 0.0f; + _currentTime = 0.0f; + + CancelEventsOfType( EV_Earthquake_Think ); +} + +qboolean Earthquake::isActive( void ) +{ + return active; +} + +void Earthquake::Think( Event *ev ) +{ + float timeDelta; + + if( !active ) + { + CancelEventsOfType( EV_Earthquake_Think ); + return; + } + + // Disable the earthquake if the time reached the maximum duration + if( _currentTime >= _duration ) + { + delete this; + return; + } + + _currentTime += cg->frametime; + + timeDelta = cgi.Milliseconds() - _startTime; + + // we are in the first half of the earthquake + if ( timeDelta < ( _duration * 0.5f ) ) + { + if ( !_no_rampup ) + { + float rampUpTime; + + rampUpTime = _startTime + ( _duration * 0.33f ); + + if ( cg->time < rampUpTime ) + { + float scale; + + scale = ( timeDelta ) / ( _duration * 0.33f ); + _currentMagnitude = _magnitude * scale; + } else { + _currentMagnitude = _magnitude; + } + } + } + // we are in the second half of the earthquake + else + { + if ( !_no_rampdown ) + { + float rampDownTime; + + rampDownTime = _startTime + ( _duration * 0.66f ); + + if ( cg->time > rampDownTime ) + { + float scale; + + scale = 1.0f - ( ( cg->time - rampDownTime ) / ( _duration * 0.33f ) ); + _currentMagnitude = _magnitude * scale; + } else { + _currentMagnitude = _magnitude; + } + } + } + + CancelEventsOfType( EV_Earthquake_Think ); + PostEvent( EV_Earthquake_Think, level.frametime ); +} + +CLASS_DECLARATION( SimpleEntity, Earthquake, NULL ) +{ + { &EV_Earthquake_Think, &Earthquake::Think }, + { NULL, NULL }, +}; diff --git a/code/cgame_hook/script/earthquake.h b/code/cgame_hook/script/earthquake.h new file mode 100644 index 00000000..ef2166cd --- /dev/null +++ b/code/cgame_hook/script/earthquake.h @@ -0,0 +1,53 @@ +#ifndef __EARTHQUAKE_H__ +#define __EARTHQUAKE_H__ + +#include "simpleentity.h" + +class Earthquake : public SimpleEntity +{ +private: + float _duration; + float _magnitude; + qboolean _no_rampup; + qboolean _no_rampdown; + Vector _location; + float _radius; + + float _currentMagnitude; + float _currentTime; + float _startTime; + + qboolean active; + +public: + CLASS_PROTOTYPE( Earthquake ); + + virtual void Archive( Archiver &arc ); + + Earthquake(); + Earthquake( float duration, float magnitude, qboolean no_rampup, qboolean no_rampdown, Vector location = Vector( 0, 0, 0 ), float radius = 1.0f ); + virtual ~Earthquake(); + + void Enable( void ); + void Disable( void ); + qboolean isActive( void ); + + float getMagnitude( void ); + Vector getLocation( void ); + float getRadius( void ); + + qboolean hasLocation( void ); + + void SetDuration( float duration ); + void SetMagnitude( float magnitude ); + void SetNoRampup( qboolean no_rampup ); + void SetNoRampdown( qboolean no_rampdown ); + void SetLocation( Vector origin ); + void SetRadius( float radius ); + + void Think( Event *ev ); +}; + +extern Container< Earthquake * > earthquakes; + +#endif diff --git a/code/cgame_hook/script/level.cpp b/code/cgame_hook/script/level.cpp new file mode 100644 index 00000000..39329c1d --- /dev/null +++ b/code/cgame_hook/script/level.cpp @@ -0,0 +1,64 @@ +/* +* Level.cpp +* +* DESCRIPTION : Global level info +*/ + +#include "level.h" + +Event EV_Level_testf +( + "testf", + EV_DEFAULT, + "i", + "test_int", + "test", + EV_SETTER +); + +Level level; + +Level::Level() +{ + prespawned = false; + spawned = false; +} + +Level::~Level() +{ + +} + +void Level::setTime( int levelTime ) +{ + svsTime = levelTime; + inttime = levelTime - svsStartTime; + svsFloatTime = levelTime / 1000.0f; + time = inttime / 1000.0f; +} + +void Level::setFrametime( int frametime ) +{ + intframetime = frametime; + this->frametime = frametime / 1000.0f; +} + +void Level::Archive( Archiver &arc ) +{ + Listener::Archive( arc ); +} + +void Level::TestEvent( Event *ev ) +{ + int integer = ev->GetInteger( 1 ); + + cgi.Printf( "this = %p\n", this ); + + cgi.Printf( "SCRIPT: integer = %d\n", integer ); +} + +CLASS_DECLARATION( Listener, Level, NULL ) +{ + { &EV_Level_testf, &Level::TestEvent }, + { NULL, NULL } +}; diff --git a/code/cgame_hook/script/level.h b/code/cgame_hook/script/level.h new file mode 100644 index 00000000..c9486462 --- /dev/null +++ b/code/cgame_hook/script/level.h @@ -0,0 +1,58 @@ +#ifndef __LEVEL_H__ +#define __LEVEL_H__ + +#include "listener.h" + +class SimpleArchivedEntity; + +class Level : public Listener +{ +public: + bool m_LoopDrop; + bool m_LoopProtection; + + str m_mapscript; + str current_map; + + // Level time + int framenum; + int inttime; + int intframetime; + + float time; + float frametime; + + int spawnflags; + + // Server time + int svsTime; + float svsFloatTime; + int svsStartTime; + int svsEndTime; + + bool m_bScriptSpawn; + bool m_bRejectSpawn; + + Container< SimpleArchivedEntity * > m_SimpleArchivedEntities; + + qboolean prespawned; + qboolean spawned; + +public: + CLASS_PROTOTYPE( Level ); + + void setTime( int _svsTime_ ); + void setFrametime( int frameTime ); + + virtual void Archive( Archiver &arc ); + + Level(); + ~Level(); + + void TestEvent( Event *ev ); +}; + + +extern Level level; + +#endif // __LEVEL_H__ diff --git a/code/cgame_hook/script/scriptslave.cpp b/code/cgame_hook/script/scriptslave.cpp new file mode 100644 index 00000000..eb633fe5 --- /dev/null +++ b/code/cgame_hook/script/scriptslave.cpp @@ -0,0 +1,319 @@ +/* +* ScriptSlave.cpp +* +* DESCRIPTION : Client-side script slave +*/ + +#include "scriptslave.h" + +Event EV_ScriptSlave_GetSpeed +( + "speed", + EV_DEFAULT, + NULL, + NULL, + "Gets the speed.", + EV_GETTER +); + +Event EV_ScriptSlave_GetTime +( + "time", + EV_DEFAULT, + NULL, + NULL, + "Gets the travel time.", + EV_GETTER +); + +Event EV_ScriptSlave_MoveTo +( + "moveto", + EV_DEFAULT, + "s", + "vector_or_entity", + "Move to the specified vector or entity.", + EV_NORMAL +); + +Event EV_ScriptSlave_Move +( + "move", + EV_DEFAULT, + NULL, + NULL, + "Move the script slave.", + EV_NORMAL +); + +Event EV_ScriptSlave_SetSpeed +( + "speed", + EV_DEFAULT, + "f", + "speed", + "Sets the speed.", + EV_SETTER +); + +Event EV_ScriptSlave_SetTime +( + "time", + EV_DEFAULT, + "f", + "travel_time", + "Sets the travel time.", + EV_SETTER +); + +Event EV_ScriptSlave_StopMove +( + "stopmove", + EV_DEFAULT, + NULL, + NULL, + "Make the script slave stop moving.", + EV_NORMAL +); + +Event EV_ScriptSlave_WaitMove +( + "waitmove", + EV_DEFAULT, + NULL, + NULL, + "Move the script slave and wait until finished.", + EV_NORMAL +); + +void ScriptSlave::Archive( Archiver &arc ) +{ + +} + +ScriptSlave::ScriptSlave() +{ + moveflags = 0; + slavetype = MOVE_UNSET; + + target.origin = NULL; + + movespeed = 200.0f; + movetime = 1.0f; + moving = false; + currentTime = 0.f; + + turnThinkOn(); +} + +ScriptSlave::~ScriptSlave() +{ + ClearMove(); +} + +void ScriptSlave::Think() +{ + if( moving ) + { + float length; + Vector targetOrigin; + + // Calculate the length + if( slavetype == MOVE_ENTITY ) + { + Entity *ent = ( Entity* )target.entity->Pointer(); + + if( ent ) { + targetOrigin = ent->origin; + } else { + targetOrigin = vec_zero; + } + } + else + { + targetOrigin = target.origin; + } + + if( movespeed > 0.0f && !movetimedone ) + { + length = Vector::Distance( origin, targetOrigin ); + + movetime = ( length / movespeed ) * 1000.0f; + movetimedone = true; + } + + float ratio = currentTime / movetime; + currentTime += cg->frametime; + + if( ratio >= 1.0f ) + { + ratio = 1.0f; + ClearMove(); + } + + setOrigin( startOrigin + ( targetOrigin - startOrigin ) * ratio ); + } + + Animate::Think(); +} + +void ScriptSlave::ClearMove() +{ + if( slavetype == MOVE_ENTITY ) + { + if( target.entity ) { + delete target.entity; + } + } + else if( slavetype == MOVE_ORIGIN ) + { + if( target.origin ) { + delete ( Vector * ) target.origin; + } + } + + moving = false; + currentTime = 0.f; + slavetype = MOVE_UNSET; +} + +float ScriptSlave::GetSpeed() +{ + return movespeed; +} + +float ScriptSlave::GetTime() +{ + return movetime; +} + +void ScriptSlave::MoveTo( Entity *entity ) +{ + ClearMove(); + + setSlaveType( MOVE_ENTITY ); + + target.entity = new SafePtr < Entity > ; + + target.entity->InitSafePtr( entity ); +} + +void ScriptSlave::MoveTo( Vector origin ) +{ + ClearMove(); + + setSlaveType( MOVE_ORIGIN ); + + target.origin = ( float * ) new Vector( origin ); +} + +void ScriptSlave::Move() +{ + if( slavetype == MOVE_UNSET ) { + ScriptError( "No target set for the ScriptSlave !\n" ); + } + + moving = true; + movetimedone = false; + + startOrigin = origin; +} + +void ScriptSlave::SetSpeed( float speed ) +{ + if( speed >= 0.f ) + { + movespeed = speed; + movetime = 0.0f; + } +} + +void ScriptSlave::SetTime( float time ) +{ + if( time >= 0.f ) + { + movespeed = 0.0f; + movetime = time * 1000.0f; + } +} + +void ScriptSlave::StopMove() +{ + ClearMove(); +} + +s_movetype ScriptSlave::getSlaveType() +{ + return slavetype; +} + +void ScriptSlave::setSlaveType( s_movetype type ) +{ + slavetype = type; +} + +//=== SCRIPT ===\\ + +void ScriptSlave::EventGetSpeed( Event *ev ) +{ + ev->AddFloat( GetSpeed() ); +} + +void ScriptSlave::EventGetTime( Event *ev ) +{ + ev->AddFloat( GetTime() ); +} + +void ScriptSlave::EventMove( Event *ev ) +{ + Move(); +} + +void ScriptSlave::EventMoveTo( Event *ev ) +{ + if( ev->IsStringAt( 1 ) || ev->IsVectorAt( 1 ) ) + { + Vector pos = ev->GetVector( 1 ); + + MoveTo( pos ); + } + else if( ev->IsEntityAt( 1 ) ) + { + Entity *ent = ev->GetEntity( 1 ); + + MoveTo( ent ); + } +} + +void ScriptSlave::EventSetSpeed( Event *ev ) +{ + SetSpeed( ev->GetFloat( 1 ) ); +} + +void ScriptSlave::EventSetTime( Event *ev ) +{ + SetTime( ev->GetFloat( 1 ) ); +} + +void ScriptSlave::EventStopMove( Event *ev ) +{ + StopMove(); +} + +void ScriptSlave::EventWaitMove( Event *ev ) +{ + Move(); +} + +CLASS_DECLARATION( CAnimate, ScriptSlave, "client_script_object" ) +{ + { &EV_ScriptSlave_GetSpeed, &ScriptSlave::EventGetSpeed }, + { &EV_ScriptSlave_GetTime, &ScriptSlave::EventGetTime }, + { &EV_ScriptSlave_Move, &ScriptSlave::EventMove }, + { &EV_ScriptSlave_MoveTo, &ScriptSlave::EventMoveTo }, + { &EV_ScriptSlave_SetSpeed, &ScriptSlave::EventSetSpeed }, + { &EV_ScriptSlave_SetTime, &ScriptSlave::EventSetTime }, + { &EV_ScriptSlave_StopMove, &ScriptSlave::EventStopMove }, + { &EV_ScriptSlave_WaitMove, &ScriptSlave::EventWaitMove }, + { NULL, NULL } +}; diff --git a/code/cgame_hook/script/scriptslave.h b/code/cgame_hook/script/scriptslave.h new file mode 100644 index 00000000..283f2ce7 --- /dev/null +++ b/code/cgame_hook/script/scriptslave.h @@ -0,0 +1,71 @@ +#ifndef __SCRIPTSLAVE_H__ +#define __SCRIPTSLAVE_H__ + +#include "canimate.h" + +#define MF_GLIDE (1<<0) // The script slave will glide when moving +#define MF_TIMEDMOVE (1<<1) // The script slave will move within the specified time + +typedef enum +{ + MOVE_UNSET, + MOVE_ENTITY, + MOVE_ORIGIN +} s_movetype; + +class ScriptSlave : public Animate +{ +private: + int moveflags; + s_movetype slavetype; + float movespeed; + float movetime; + qboolean movetimedone; + float currentTime; + qboolean moving; + + union { + SafePtr *entity; + float *origin; + } target; + + Vector startOrigin; + +public: + CLASS_PROTOTYPE( ScriptSlave ); + + virtual void Archive( Archiver &arc ); + + ScriptSlave(); + ~ScriptSlave(); + + virtual void Think(); + + void ClearMove(); + + float GetSpeed(); + float GetTime(); + + void MoveTo( Entity *entity ); + void MoveTo( Vector origin ); + void Move(); + + void SetSpeed( float speed ); + void SetTime( float time ); + + void StopMove(); + + s_movetype getSlaveType(); + void setSlaveType( s_movetype type ); + + void EventGetSpeed( Event *ev ); + void EventGetTime( Event *ev ); + void EventMove( Event *ev ); + void EventMoveTo( Event *ev ); + void EventSetSpeed( Event *ev ); + void EventSetTime( Event *ev ); + void EventStopMove( Event *ev ); + void EventWaitMove( Event *ev ); +}; + +#endif /* __SCRIPTSLAVE_H__ */ diff --git a/code/cgame_hook/script/vision.h b/code/cgame_hook/script/vision.h new file mode 100644 index 00000000..f402f859 --- /dev/null +++ b/code/cgame_hook/script/vision.h @@ -0,0 +1,147 @@ +#ifndef __VISION_H__ +#define __VISION_H__ + +#include "class.h" + +class ScriptTimer; + +class VisionClass : public Class +{ +private: + str name; + + str defaultval; + +protected: + str string; + + ScriptTimer *m_timer; + + float value; + float value_start; + float value_target; + +public: + qboolean fProcessed; + +protected: + void VisionInit( const char *name, const char *value, ScriptTimer *globalTimer ); + +public: + CLASS_PROTOTYPE( VisionClass ); + + virtual void Archive( Archiver &arc ); + + static VisionClass *Get( str name ); + static void GlobalArchive( Archiver &arc ); + + VisionClass(); + VisionClass( const char *name, const char *value, ScriptTimer *globalTimer ); + + virtual void Think(); + + str GetName(); + ScriptTimer *GetTimer(); + virtual str GetType(); + + str defaultValue(); + + float floatValue(); + str stringValue(); + + virtual qboolean isBasic(); + virtual qboolean isEnabled(); + virtual qboolean isNewEnabled(); + + void setFloatValue( float value ); + virtual void setValue( str value ); +}; + +class VisionActivator : public VisionClass +{ +private: + str vistype; + +public: + CLASS_PROTOTYPE( VisionActivator ); + + virtual void Archive( Archiver &arc ); + + VisionActivator( const char *name, const char *value, const char *type = "vision", ScriptTimer *globalTimer = NULL ); + VisionActivator(); + + virtual str GetType(); + + virtual qboolean isBasic(); + virtual qboolean isEnabled(); + virtual qboolean isNewEnabled(); + + virtual void setValue( str value ); +}; + +class VisionVariable : public VisionClass +{ +private: + VisionActivator *activator; + + Vector vector; + + // target values + Vector vector_start; + Vector vector_target; + +public: + CLASS_PROTOTYPE( VisionVariable ); + + virtual void Archive( Archiver &arc ); + + VisionVariable( const char *name, const char *value, VisionActivator *activator ); + VisionVariable(); + + virtual void Think(); + + VisionActivator *GetActivator(); + ScriptTimer *GetTimer(); + virtual str GetType(); + + virtual qboolean isBasic(); + virtual qboolean isEnabled(); + virtual qboolean isNewEnabled(); + + Vector vectorValue(); + + virtual void setValue( str value ); +}; + +extern VisionActivator r_anaglyphTweakEnable; +extern VisionActivator r_distortionEnable; +extern VisionActivator r_filmEnable; +extern VisionActivator r_glow; + +extern VisionVariable r_glowRadius0; +extern VisionVariable r_glowRadius1; +extern VisionVariable r_glowBloomCutoff; +extern VisionVariable r_glowBloomDesaturation; +extern VisionVariable r_glowBloomIntensity0; +extern VisionVariable r_glowBloomIntensity1; +extern VisionVariable r_glowBloomStreakX; +extern VisionVariable r_glowBloomStreakY; + +extern VisionVariable r_filmContrast; +extern VisionVariable r_filmBleach; +extern VisionVariable r_filmBrightness; +extern VisionVariable r_filmHue; +extern VisionVariable r_filmMidStart; +extern VisionVariable r_filmMidEnd; +extern VisionVariable r_filmDarkTint; +extern VisionVariable r_filmMidTint; +extern VisionVariable r_filmLightTint; +extern VisionVariable r_filmSaturation; + +extern VisionVariable r_anaglyphAngleMult; +extern VisionVariable r_anaglyphOffsetMult; + +extern VisionVariable r_distortionRadius; +extern VisionVariable r_distortionScale; + +#endif diff --git a/code/client/cl_avi.cpp b/code/client/cl_avi.cpp new file mode 100644 index 00000000..a6e018f0 --- /dev/null +++ b/code/client/cl_avi.cpp @@ -0,0 +1,671 @@ +/* +=========================================================================== +Copyright (C) 2005-2006 Tim Angus + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "client.h" +#include "snd_local.h" + +#define INDEX_FILE_EXTENSION ".index.dat" + +#define MAX_RIFF_CHUNKS 16 + +typedef struct audioFormat_s +{ + int rate; + int format; + int channels; + int bits; + + int sampleSize; + int totalBytes; +} audioFormat_t; + +typedef struct aviFileData_s +{ + qboolean fileOpen; + fileHandle_t f; + char fileName[ MAX_QPATH ]; + int fileSize; + int moviOffset; + int moviSize; + + fileHandle_t idxF; + int numIndices; + + int frameRate; + int framePeriod; + int width, height; + int numVideoFrames; + int maxRecordSize; + qboolean motionJpeg; + + qboolean audio; + audioFormat_t a; + int numAudioFrames; + + int chunkStack[ MAX_RIFF_CHUNKS ]; + int chunkStackTop; + + byte *cBuffer, *eBuffer; +} aviFileData_t; + +static aviFileData_t afd; + +#define MAX_AVI_BUFFER 2048 + +static byte buffer[ MAX_AVI_BUFFER ]; +static int bufIndex; + +/* +=============== +SafeFS_Write +=============== +*/ +static ID_INLINE void SafeFS_Write( const void *buffer, int len, fileHandle_t f ) +{ + if( FS_Write( buffer, len, f ) < len ) + Com_Error( ERR_DROP, "Failed to write avi file\n" ); +} + +/* +=============== +WRITE_STRING +=============== +*/ +static ID_INLINE void WRITE_STRING( const char *s ) +{ + Com_Memcpy( &buffer[ bufIndex ], s, strlen( s ) ); + bufIndex += strlen( s ); +} + +/* +=============== +WRITE_4BYTES +=============== +*/ +static ID_INLINE void WRITE_4BYTES( int x ) +{ + buffer[ bufIndex + 0 ] = (byte)( ( x >> 0 ) & 0xFF ); + buffer[ bufIndex + 1 ] = (byte)( ( x >> 8 ) & 0xFF ); + buffer[ bufIndex + 2 ] = (byte)( ( x >> 16 ) & 0xFF ); + buffer[ bufIndex + 3 ] = (byte)( ( x >> 24 ) & 0xFF ); + bufIndex += 4; +} + +/* +=============== +WRITE_2BYTES +=============== +*/ +static ID_INLINE void WRITE_2BYTES( int x ) +{ + buffer[ bufIndex + 0 ] = (byte)( ( x >> 0 ) & 0xFF ); + buffer[ bufIndex + 1 ] = (byte)( ( x >> 8 ) & 0xFF ); + bufIndex += 2; +} + +/* +=============== +WRITE_1BYTES +=============== +*/ +static ID_INLINE void WRITE_1BYTES( int x ) +{ + buffer[ bufIndex ] = x; + bufIndex += 1; +} + +/* +=============== +START_CHUNK +=============== +*/ +static ID_INLINE void START_CHUNK( const char *s ) +{ + if( afd.chunkStackTop == MAX_RIFF_CHUNKS ) + { + Com_Error( ERR_DROP, "ERROR: Top of chunkstack breached\n" ); + } + + afd.chunkStack[ afd.chunkStackTop ] = bufIndex; + afd.chunkStackTop++; + WRITE_STRING( s ); + WRITE_4BYTES( 0 ); +} + +/* +=============== +END_CHUNK +=============== +*/ +static ID_INLINE void END_CHUNK( void ) +{ + int endIndex = bufIndex; + + if( afd.chunkStackTop <= 0 ) + { + Com_Error( ERR_DROP, "ERROR: Bottom of chunkstack breached\n" ); + } + + afd.chunkStackTop--; + bufIndex = afd.chunkStack[ afd.chunkStackTop ]; + bufIndex += 4; + WRITE_4BYTES( endIndex - bufIndex - 4 ); + bufIndex = endIndex; + bufIndex = PAD( bufIndex, 2 ); +} + +/* +=============== +CL_WriteAVIHeader +=============== +*/ +void CL_WriteAVIHeader( void ) +{ + bufIndex = 0; + afd.chunkStackTop = 0; + + START_CHUNK( "RIFF" ); + { + WRITE_STRING( "AVI " ); + { + START_CHUNK( "LIST" ); + { + WRITE_STRING( "hdrl" ); + WRITE_STRING( "avih" ); + WRITE_4BYTES( 56 ); //"avih" "chunk" size + WRITE_4BYTES( afd.framePeriod ); //dwMicroSecPerFrame + WRITE_4BYTES( afd.maxRecordSize * + afd.frameRate ); //dwMaxBytesPerSec + WRITE_4BYTES( 0 ); //dwReserved1 + WRITE_4BYTES( 0x110 ); //dwFlags bits HAS_INDEX and IS_INTERLEAVED + WRITE_4BYTES( afd.numVideoFrames ); //dwTotalFrames + WRITE_4BYTES( 0 ); //dwInitialFrame + + if( afd.audio ) //dwStreams + WRITE_4BYTES( 2 ); + else + WRITE_4BYTES( 1 ); + + WRITE_4BYTES( afd.maxRecordSize ); //dwSuggestedBufferSize + WRITE_4BYTES( afd.width ); //dwWidth + WRITE_4BYTES( afd.height ); //dwHeight + WRITE_4BYTES( 0 ); //dwReserved[ 0 ] + WRITE_4BYTES( 0 ); //dwReserved[ 1 ] + WRITE_4BYTES( 0 ); //dwReserved[ 2 ] + WRITE_4BYTES( 0 ); //dwReserved[ 3 ] + + START_CHUNK( "LIST" ); + { + WRITE_STRING( "strl" ); + WRITE_STRING( "strh" ); + WRITE_4BYTES( 56 ); //"strh" "chunk" size + WRITE_STRING( "vids" ); + + if( afd.motionJpeg ) + WRITE_STRING( "MJPG" ); + else + WRITE_4BYTES( 0 ); // BI_RGB + + WRITE_4BYTES( 0 ); //dwFlags + WRITE_4BYTES( 0 ); //dwPriority + WRITE_4BYTES( 0 ); //dwInitialFrame + + WRITE_4BYTES( 1 ); //dwTimescale + WRITE_4BYTES( afd.frameRate ); //dwDataRate + WRITE_4BYTES( 0 ); //dwStartTime + WRITE_4BYTES( afd.numVideoFrames ); //dwDataLength + + WRITE_4BYTES( afd.maxRecordSize ); //dwSuggestedBufferSize + WRITE_4BYTES( -1 ); //dwQuality + WRITE_4BYTES( 0 ); //dwSampleSize + WRITE_2BYTES( 0 ); //rcFrame + WRITE_2BYTES( 0 ); //rcFrame + WRITE_2BYTES( afd.width ); //rcFrame + WRITE_2BYTES( afd.height ); //rcFrame + + WRITE_STRING( "strf" ); + WRITE_4BYTES( 40 ); //"strf" "chunk" size + WRITE_4BYTES( 40 ); //biSize + WRITE_4BYTES( afd.width ); //biWidth + WRITE_4BYTES( afd.height ); //biHeight + WRITE_2BYTES( 1 ); //biPlanes + WRITE_2BYTES( 24 ); //biBitCount + + if( afd.motionJpeg ) //biCompression + { + WRITE_STRING( "MJPG" ); + WRITE_4BYTES( afd.width * + afd.height ); //biSizeImage + } + else + { + WRITE_4BYTES( 0 ); // BI_RGB + WRITE_4BYTES( afd.width * + afd.height * 3 ); //biSizeImage + } + + WRITE_4BYTES( 0 ); //biXPelsPetMeter + WRITE_4BYTES( 0 ); //biYPelsPetMeter + WRITE_4BYTES( 0 ); //biClrUsed + WRITE_4BYTES( 0 ); //biClrImportant + } + END_CHUNK( ); + + if( afd.audio ) + { + START_CHUNK( "LIST" ); + { + WRITE_STRING( "strl" ); + WRITE_STRING( "strh" ); + WRITE_4BYTES( 56 ); //"strh" "chunk" size + WRITE_STRING( "auds" ); + WRITE_4BYTES( 0 ); //FCC + WRITE_4BYTES( 0 ); //dwFlags + WRITE_4BYTES( 0 ); //dwPriority + WRITE_4BYTES( 0 ); //dwInitialFrame + + WRITE_4BYTES( afd.a.sampleSize ); //dwTimescale + WRITE_4BYTES( afd.a.sampleSize * + afd.a.rate ); //dwDataRate + WRITE_4BYTES( 0 ); //dwStartTime + WRITE_4BYTES( afd.a.totalBytes / + afd.a.sampleSize ); //dwDataLength + + WRITE_4BYTES( 0 ); //dwSuggestedBufferSize + WRITE_4BYTES( -1 ); //dwQuality + WRITE_4BYTES( afd.a.sampleSize ); //dwSampleSize + WRITE_2BYTES( 0 ); //rcFrame + WRITE_2BYTES( 0 ); //rcFrame + WRITE_2BYTES( 0 ); //rcFrame + WRITE_2BYTES( 0 ); //rcFrame + + WRITE_STRING( "strf" ); + WRITE_4BYTES( 18 ); //"strf" "chunk" size + WRITE_2BYTES( afd.a.format ); //wFormatTag + WRITE_2BYTES( afd.a.channels ); //nChannels + WRITE_4BYTES( afd.a.rate ); //nSamplesPerSec + WRITE_4BYTES( afd.a.sampleSize * + afd.a.rate ); //nAvgBytesPerSec + WRITE_2BYTES( afd.a.sampleSize ); //nBlockAlign + WRITE_2BYTES( afd.a.bits ); //wBitsPerSample + WRITE_2BYTES( 0 ); //cbSize + } + END_CHUNK( ); + } + } + END_CHUNK( ); + + afd.moviOffset = bufIndex; + + START_CHUNK( "LIST" ); + { + WRITE_STRING( "movi" ); + } + } + } +} + +/* +=============== +CL_OpenAVIForWriting + +Creates an AVI file and gets it into a state where +writing the actual data can begin +=============== +*/ +qboolean CL_OpenAVIForWriting( const char *fileName ) +{ + if( afd.fileOpen ) + return qfalse; + + Com_Memset( &afd, 0, sizeof( aviFileData_t ) ); + + // Don't start if a framerate has not been chosen + if( cl_aviFrameRate->integer <= 0 ) + { + Com_Printf( S_COLOR_RED "cl_aviFrameRate must be >= 1\n" ); + return qfalse; + } + + if( ( afd.f = FS_FOpenFileWrite( fileName ) ) <= 0 ) + return qfalse; + + if( ( afd.idxF = FS_FOpenFileWrite( + va( "%s" INDEX_FILE_EXTENSION, fileName ) ) ) <= 0 ) + { + FS_FCloseFile( afd.f ); + return qfalse; + } + + Q_strncpyz( afd.fileName, fileName, MAX_QPATH ); + + afd.frameRate = cl_aviFrameRate->integer; + afd.framePeriod = (int)( 1000000.0f / afd.frameRate ); + afd.width = cls.glconfig.vidWidth; + afd.height = cls.glconfig.vidHeight; + + if( cl_aviMotionJpeg->integer ) + afd.motionJpeg = qtrue; + else + afd.motionJpeg = qfalse; + + afd.cBuffer = ( byte * )Z_Malloc( afd.width * afd.height * 4 ); + afd.eBuffer = ( byte * )Z_Malloc( afd.width * afd.height * 4 ); + + afd.a.rate = dma.speed; + afd.a.format = WAV_FORMAT_PCM; + afd.a.channels = dma.channels; + afd.a.bits = dma.samplebits; + afd.a.sampleSize = ( afd.a.bits / 8 ) * afd.a.channels; + + if( afd.a.rate % afd.frameRate ) + { + int suggestRate = afd.frameRate; + + while( ( afd.a.rate % suggestRate ) && suggestRate >= 1 ) + suggestRate--; + + Com_Printf( S_COLOR_YELLOW "WARNING: cl_aviFrameRate is not a divisor " + "of the audio rate, suggest %d\n", suggestRate ); + } + + if( !Cvar_VariableIntegerValue( "s_initsound" ) ) + { + afd.audio = qfalse; + } + else if( Q_stricmp( Cvar_VariableString( "s_backend" ), "OpenAL" ) ) + { + if( afd.a.bits != 16 || afd.a.channels != 2 ) + { + Com_Printf( S_COLOR_YELLOW "WARNING: Audio format of %d bit/%d channels not supported", + afd.a.bits, afd.a.channels ); + afd.audio = qfalse; + } + else + afd.audio = qtrue; + } + else + { + afd.audio = qfalse; + Com_Printf( S_COLOR_YELLOW "WARNING: Audio capture is not supported " + "with OpenAL. Set s_useOpenAL to 0 for audio capture\n" ); + } + + // This doesn't write a real header, but allocates the + // correct amount of space at the beginning of the file + CL_WriteAVIHeader( ); + + SafeFS_Write( buffer, bufIndex, afd.f ); + afd.fileSize = bufIndex; + + bufIndex = 0; + START_CHUNK( "idx1" ); + SafeFS_Write( buffer, bufIndex, afd.idxF ); + + afd.moviSize = 4; // For the "movi" + afd.fileOpen = qtrue; + + return qtrue; +} + +/* +=============== +CL_CheckFileSize +=============== +*/ +static qboolean CL_CheckFileSize( int bytesToAdd ) +{ + unsigned int newFileSize; + + newFileSize = + afd.fileSize + // Current file size + bytesToAdd + // What we want to add + ( afd.numIndices * 16 ) + // The index + 4; // The index size + + // I assume all the operating systems + // we target can handle a 2Gb file + if( newFileSize > INT_MAX ) + { + // Close the current file... + CL_CloseAVI( ); + + // ...And open a new one + CL_OpenAVIForWriting( va( "%s_", afd.fileName ) ); + + return qtrue; + } + + return qfalse; +} + +/* +=============== +CL_WriteAVIVideoFrame +=============== +*/ +void CL_WriteAVIVideoFrame( const byte *imageBuffer, int size ) +{ + int chunkOffset = afd.fileSize - afd.moviOffset - 8; + int chunkSize = 8 + size; + int paddingSize = PAD( size, 2 ) - size; + byte padding[ 4 ] = { 0 }; + + if( !afd.fileOpen ) + return; + + // Chunk header + contents + padding + if( CL_CheckFileSize( 8 + size + 2 ) ) + return; + + bufIndex = 0; + WRITE_STRING( "00dc" ); + WRITE_4BYTES( size ); + + SafeFS_Write( buffer, 8, afd.f ); + SafeFS_Write( imageBuffer, size, afd.f ); + SafeFS_Write( padding, paddingSize, afd.f ); + afd.fileSize += ( chunkSize + paddingSize ); + + afd.numVideoFrames++; + afd.moviSize += ( chunkSize + paddingSize ); + + if( size > afd.maxRecordSize ) + afd.maxRecordSize = size; + + // Index + bufIndex = 0; + WRITE_STRING( "00dc" ); //dwIdentifier + WRITE_4BYTES( 0x00000010 ); //dwFlags (all frames are KeyFrames) + WRITE_4BYTES( chunkOffset ); //dwOffset + WRITE_4BYTES( size ); //dwLength + SafeFS_Write( buffer, 16, afd.idxF ); + + afd.numIndices++; +} + +#define PCM_BUFFER_SIZE 44100 + +/* +=============== +CL_WriteAVIAudioFrame +=============== +*/ +void CL_WriteAVIAudioFrame( const byte *pcmBuffer, int size ) +{ + static byte pcmCaptureBuffer[ PCM_BUFFER_SIZE ] = { 0 }; + static int bytesInBuffer = 0; + + if( !afd.audio ) + return; + + if( !afd.fileOpen ) + return; + + // Chunk header + contents + padding + if( CL_CheckFileSize( 8 + bytesInBuffer + size + 2 ) ) + return; + + if( bytesInBuffer + size > PCM_BUFFER_SIZE ) + { + Com_Printf( S_COLOR_YELLOW + "WARNING: Audio capture buffer overflow -- truncating\n" ); + size = PCM_BUFFER_SIZE - bytesInBuffer; + } + + Com_Memcpy( &pcmCaptureBuffer[ bytesInBuffer ], pcmBuffer, size ); + bytesInBuffer += size; + + // Only write if we have a frame's worth of audio + if( bytesInBuffer >= (int)ceil( (float)afd.a.rate / (float)afd.frameRate ) * + afd.a.sampleSize ) + { + int chunkOffset = afd.fileSize - afd.moviOffset - 8; + int chunkSize = 8 + bytesInBuffer; + int paddingSize = PAD( bytesInBuffer, 2 ) - bytesInBuffer; + byte padding[ 4 ] = { 0 }; + + bufIndex = 0; + WRITE_STRING( "01wb" ); + WRITE_4BYTES( bytesInBuffer ); + + SafeFS_Write( buffer, 8, afd.f ); + SafeFS_Write( pcmCaptureBuffer, bytesInBuffer, afd.f ); + SafeFS_Write( padding, paddingSize, afd.f ); + afd.fileSize += ( chunkSize + paddingSize ); + + afd.numAudioFrames++; + afd.moviSize += ( chunkSize + paddingSize ); + afd.a.totalBytes =+ bytesInBuffer; + + // Index + bufIndex = 0; + WRITE_STRING( "01wb" ); //dwIdentifier + WRITE_4BYTES( 0 ); //dwFlags + WRITE_4BYTES( chunkOffset ); //dwOffset + WRITE_4BYTES( bytesInBuffer ); //dwLength + SafeFS_Write( buffer, 16, afd.idxF ); + + afd.numIndices++; + + bytesInBuffer = 0; + } +} + +/* +=============== +CL_TakeVideoFrame +=============== +*/ +void CL_TakeVideoFrame( void ) +{ + // AVI file isn't open + if( !afd.fileOpen ) + return; + +// RE_TakeVideoFrame( afd.width, afd.height, +// afd.cBuffer, afd.eBuffer, afd.motionJpeg ); +} + +/* +=============== +CL_CloseAVI + +Closes the AVI file and writes an index chunk +=============== +*/ +qboolean CL_CloseAVI( void ) +{ + int indexRemainder; + int indexSize = afd.numIndices * 16; + const char *idxFileName = va( "%s" INDEX_FILE_EXTENSION, afd.fileName ); + + // AVI file isn't open + if( !afd.fileOpen ) + return qfalse; + + afd.fileOpen = qfalse; + + FS_Seek( afd.idxF, 4, FS_SEEK_SET ); + bufIndex = 0; + WRITE_4BYTES( indexSize ); + SafeFS_Write( buffer, bufIndex, afd.idxF ); + FS_FCloseFile( afd.idxF ); + + // Write index + + // Open the temp index file + if( ( indexSize = FS_FOpenFileRead( idxFileName, + &afd.idxF, qtrue, qtrue ) ) <= 0 ) + { + FS_FCloseFile( afd.f ); + return qfalse; + } + + indexRemainder = indexSize; + + // Append index to end of avi file + while( indexRemainder > MAX_AVI_BUFFER ) + { + FS_Read( buffer, MAX_AVI_BUFFER, afd.idxF ); + SafeFS_Write( buffer, MAX_AVI_BUFFER, afd.f ); + afd.fileSize += MAX_AVI_BUFFER; + indexRemainder -= MAX_AVI_BUFFER; + } + FS_Read( buffer, indexRemainder, afd.idxF ); + SafeFS_Write( buffer, indexRemainder, afd.f ); + afd.fileSize += indexRemainder; + FS_FCloseFile( afd.idxF ); + + // Remove temp index file + FS_Remove( idxFileName ); + + // Write the real header + FS_Seek( afd.f, 0, FS_SEEK_SET ); + CL_WriteAVIHeader( ); + + bufIndex = 4; + WRITE_4BYTES( afd.fileSize - 8 ); // "RIFF" size + + bufIndex = afd.moviOffset + 4; // Skip "LIST" + WRITE_4BYTES( afd.moviSize ); + + SafeFS_Write( buffer, bufIndex, afd.f ); + + Z_Free( afd.cBuffer ); + Z_Free( afd.eBuffer ); + FS_FCloseFile( afd.f ); + + Com_Printf( "Wrote %d:%d frames to %s\n", afd.numVideoFrames, afd.numAudioFrames, afd.fileName ); + + return qtrue; +} + +/* +=============== +CL_VideoRecording +=============== +*/ +qboolean CL_VideoRecording( void ) +{ + return afd.fileOpen; +} diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp new file mode 100644 index 00000000..8d4b0cd2 --- /dev/null +++ b/code/client/cl_cgame.cpp @@ -0,0 +1,1202 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// cl_cgame.c -- client system interaction with client game + +#include "client.h" +#include "cl_ui.h" +#include "../botlib/botlib.h" +#include + +extern botlib_export_t *botlib_export; + +extern qboolean loadCamera(const char *name); +extern void startCamera(int time); +extern qboolean getCameraInfo(int time, vec3_t *origin, vec3_t *angles); + +/* +==================== +CL_GetGameState +==================== +*/ +void CL_GetGameState( gameState_t *gs ) { + *gs = cl.gameState; +} + +/* +==================== +CL_GetGlconfig +==================== +*/ +void CL_GetGlconfig( glconfig_t *glconfig ) { + glconfig_ver19_t *pgl = ( glconfig_ver19_t * )glconfig; + + strncpy( pgl->renderer_string, cls.glconfig.renderer_string, sizeof( pgl->renderer_string ) ); + strncpy( pgl->vendor_string, cls.glconfig.vendor_string, sizeof( pgl->vendor_string ) ); + strncpy( pgl->version_string, cls.glconfig.version_string, sizeof( pgl->version_string ) ); + strncpy( pgl->extensions_string, cls.glconfig.extensions_string, sizeof( pgl->extensions_string ) ); + pgl->maxTextureSize = cls.glconfig.maxTextureSize; + pgl->numTextureUnits = cls.glconfig.numTextureUnits; + pgl->colorBits = cls.glconfig.colorBits; + pgl->depthBits = cls.glconfig.depthBits; + pgl->stencilBits = cls.glconfig.stencilBits; + pgl->driverType = cls.glconfig.driverType; + pgl->hardwareType = cls.glconfig.hardwareType; + pgl->deviceSupportsGamma = cls.glconfig.deviceSupportsGamma; + pgl->textureCompression = cls.glconfig.textureCompression; + pgl->textureEnvAddAvailable = cls.glconfig.textureEnvAddAvailable; + pgl->vidWidth = cls.glconfig.vidWidth; + pgl->vidHeight = cls.glconfig.vidHeight; + pgl->windowAspect = cls.glconfig.windowAspect; + pgl->displayFrequency = cls.glconfig.displayFrequency; + pgl->isFullscreen = cls.glconfig.isFullscreen; + pgl->stereoEnabled = cls.glconfig.stereoEnabled; + pgl->smpActive = cls.glconfig.smpActive; + pgl->registerCombinerAvailable = cls.glconfig.registerCombinerAvailable; + pgl->secondaryColorAvailable = cls.glconfig.secondaryColorAvailable; + pgl->VAR = cls.glconfig.VAR; + pgl->fence = cls.glconfig.fence; +} + + +/* +==================== +CL_GetUserCmd +==================== +*/ +qboolean CL_GetUserCmd( int cmdNumber, usercmd_t *ucmd ) { + // cmds[cmdNumber] is the last properly generated command + + // can't return anything that we haven't created yet + if ( cmdNumber > cl.cmdNumber ) { + Com_Error( ERR_DROP, "CL_GetUserCmd: %i >= %i", cmdNumber, cl.cmdNumber ); + } + + // the usercmd has been overwritten in the wrapping + // buffer because it is too far out of date + if ( cmdNumber <= cl.cmdNumber - CMD_BACKUP ) { + return qfalse; + } + + *ucmd = cl.cmds[ cmdNumber & CMD_MASK ]; + + return qtrue; +} + +int CL_GetCurrentCmdNumber( void ) { + return cl.cmdNumber; +} + + +/* +==================== +CL_GetParseEntityState +==================== +*/ +qboolean CL_GetParseEntityState( int parseEntityNumber, entityState_t *state ) { + // can't return anything that hasn't been parsed yet + if ( parseEntityNumber >= cl.parseEntitiesNum ) { + Com_Error( ERR_DROP, "CL_GetParseEntityState: %i >= %i", + parseEntityNumber, cl.parseEntitiesNum ); + } + + // can't return anything that has been overwritten in the circular buffer + if ( parseEntityNumber <= cl.parseEntitiesNum - MAX_PARSE_ENTITIES ) { + return qfalse; + } + + *state = cl.parseEntities[ parseEntityNumber & ( MAX_PARSE_ENTITIES - 1 ) ]; + return qtrue; +} + +/* +==================== +CL_GetCurrentSnapshotNumber +==================== +*/ +void CL_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime ) { + *snapshotNumber = cl.snap.messageNum; + *serverTime = cl.snap.serverTime; +} + +/* +==================== +CL_GetServerStartTime +==================== +*/ +int CL_GetServerStartTime( void ) { + return cl.serverStartTime; +} + +/* +==================== +CL_SetTime +==================== +*/ +void CL_SetTime( int time ) { + cl.serverTime = time; +} + +/* +==================== +CL_GetSnapshot +==================== +*/ +qboolean CL_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) { + clSnapshot_t *clSnap; + int i, count; + + if ( snapshotNumber > cl.snap.messageNum ) { + Com_Error( ERR_DROP, "CL_GetSnapshot: snapshotNumber > cl.snapshot.messageNum" ); + } + + // if the frame has fallen out of the circular buffer, we can't return it + if ( cl.snap.messageNum - snapshotNumber >= PACKET_BACKUP ) { + return qfalse; + } + + // if the frame is not valid, we can't return it + clSnap = &cl.snapshots[snapshotNumber & PACKET_MASK]; + if ( !clSnap->valid ) { + return qfalse; + } + + // if the entities in the frame have fallen out of their + // circular buffer, we can't return it + if ( cl.parseEntitiesNum - clSnap->parseEntitiesNum >= MAX_PARSE_ENTITIES ) { + return qfalse; + } + + // write the snapshot + snapshot->snapFlags = clSnap->snapFlags; + snapshot->serverCommandSequence = clSnap->serverCommandNum; + snapshot->ping = clSnap->ping; + snapshot->serverTime = clSnap->serverTime; + Com_Memcpy( snapshot->areamask, clSnap->areamask, sizeof( snapshot->areamask ) ); + snapshot->ps = clSnap->ps; + count = clSnap->numEntities; + if ( count > MAX_ENTITIES_IN_SNAPSHOT ) { + Com_DPrintf( "CL_GetSnapshot: truncated %i entities to %i\n", count, MAX_ENTITIES_IN_SNAPSHOT ); + count = MAX_ENTITIES_IN_SNAPSHOT; + } + snapshot->numEntities = count; + for ( i = 0 ; i < count ; i++ ) { + snapshot->entities[i] = + cl.parseEntities[ ( clSnap->parseEntitiesNum + i ) & (MAX_PARSE_ENTITIES-1) ]; + } + + // wombat: sounds + count = clSnap->number_of_sounds; + if ( snapshot->number_of_sounds > MAX_SOUNDS_IN_SNAPSHOT ) { + Com_DPrintf( "CL_GetSnapshot: truncated %i sounds to %i\n", count, MAX_SOUNDS_IN_SNAPSHOT ); + count = MAX_SOUNDS_IN_SNAPSHOT; + } + snapshot->number_of_sounds = count; + Com_Memcpy( snapshot->sounds, clSnap->sounds, sizeof(snapshot->sounds[0])*count ); + + // FIXME: configstring changes and server commands!!! + + return qtrue; +} + +/* +===================== +CL_SetUserCmdValue +===================== +*/ +void CL_SetUserCmdValue( int userCmdValue, float sensitivityScale ) { + cl.cgameUserCmdValue = userCmdValue; + cl.cgameSensitivity = sensitivityScale; +} + +/* +===================== +CL_AddCgameCommand +===================== +*/ +void CL_AddCgameCommand( const char *cmdName ) { + Cmd_AddCommand( cmdName, NULL ); +} + +/* +===================== +CL_CgameError +===================== +*/ +void CL_CgameError( const char *string ) { + Com_Error( ERR_DROP, "%s", string ); +} + + +/* +===================== +CL_ConfigstringModified +===================== +*/ +void CL_ConfigstringModified( void ) { + char *old, *s; + int i, index; + char *dup; + gameState_t oldGs; + int len; + + index = atoi( Cmd_Argv(1) ); + if ( index < 0 || index >= MAX_CONFIGSTRINGS ) { + Com_Error( ERR_DROP, "configstring > MAX_CONFIGSTRINGS" ); + } + // get everything after "cs " + s = Cmd_ArgsFrom(2); + + old = cl.gameState.stringData + cl.gameState.stringOffsets[ index ]; + if ( !strcmp( old, s ) ) { + return; // unchanged + } + + // build the new gameState_t + oldGs = cl.gameState; + + Com_Memset( &cl.gameState, 0, sizeof( cl.gameState ) ); + + // leave the first 0 for uninitialized strings + cl.gameState.dataCount = 1; + + for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { + if ( i == index ) { + dup = s; + } else { + dup = oldGs.stringData + oldGs.stringOffsets[ i ]; + } + if ( !dup[0] ) { + continue; // leave with the default empty string + } + + len = strlen( dup ); + + if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) { + Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" ); + } + + // append it to the gameState string buffer + cl.gameState.stringOffsets[ i ] = cl.gameState.dataCount; + Com_Memcpy( cl.gameState.stringData + cl.gameState.dataCount, dup, len + 1 ); + cl.gameState.dataCount += len + 1; + } + + if ( index == CS_SYSTEMINFO ) { + // parse serverId and other cvars + CL_SystemInfoChanged(); + } + +} + + +/* +=================== +CL_GetServerCommand + +Set up argc/argv for the given command +=================== +*/ +qboolean CL_GetServerCommand( int serverCommandNumber, qboolean differentServer ) { + char *s; + char *cmd; + static char bigConfigString[BIG_INFO_STRING]; + int argc; + + // if we have irretrievably lost a reliable command, drop the connection + if ( serverCommandNumber <= clc.serverCommandSequence - MAX_RELIABLE_COMMANDS ) { + // when a demo record was started after the client got a whole bunch of + // reliable commands then the client never got those first reliable commands + if ( clc.demoplaying ) + return qfalse; + Com_Error( ERR_DROP, "CL_GetServerCommand: a reliable command was cycled out" ); + return qfalse; + } + + if ( serverCommandNumber > clc.serverCommandSequence ) { + Com_Error( ERR_DROP, "CL_GetServerCommand: requested a command not received" ); + return qfalse; + } + + s = clc.serverCommands[ serverCommandNumber & ( MAX_RELIABLE_COMMANDS - 1 ) ]; + clc.lastExecutedServerCommand = serverCommandNumber; + + if( developer->integer == 2 ) { + Com_DPrintf( "serverCommand: %i : %s\n", serverCommandNumber, s ); + } + +rescan: + Cmd_TokenizeString( s ); + cmd = Cmd_Argv(0); + argc = Cmd_Argc(); + + if ( !strcmp( cmd, "disconnect" ) ) { + // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=552 + // allow server to indicate why they were disconnected + if ( argc >= 2 ) + Com_Error( ERR_SERVERDISCONNECT, "Server disconnected - %s", Cmd_Argv( 1 ) ); + else + Com_Error( ERR_SERVERDISCONNECT, "Server disconnected\n" ); + } + + if ( !strcmp( cmd, "bcs0" ) ) { + Com_sprintf( bigConfigString, BIG_INFO_STRING, "cs %s \"%s", Cmd_Argv(1), Cmd_Argv(2) ); + return qfalse; + } + + if ( !strcmp( cmd, "bcs1" ) ) { + s = Cmd_Argv(2); + if( strlen(bigConfigString) + strlen(s) >= BIG_INFO_STRING ) { + Com_Error( ERR_DROP, "bcs exceeded BIG_INFO_STRING" ); + } + strcat( bigConfigString, s ); + return qfalse; + } + + if ( !strcmp( cmd, "bcs2" ) ) { + s = Cmd_Argv(2); + if( strlen(bigConfigString) + strlen(s) + 1 >= BIG_INFO_STRING ) { + Com_Error( ERR_DROP, "bcs exceeded BIG_INFO_STRING" ); + } + strcat( bigConfigString, s ); + strcat( bigConfigString, "\"" ); + s = bigConfigString; + goto rescan; + } + + if ( !strcmp( cmd, "cs" ) ) { + CL_ConfigstringModified(); + // reparse the string, because CL_ConfigstringModified may have done another Cmd_TokenizeString() + Cmd_TokenizeString( s ); + return qtrue; + } + + if ( !strcmp( cmd, "map_restart" ) ) { + // clear notify lines and outgoing commands before passing + // the restart to the cgame + Con_ClearNotify(); + Com_Memset( cl.cmds, 0, sizeof( cl.cmds ) ); + return qtrue; + } + + // the clientLevelShot command is used during development + // to generate 128*128 screenshots from the intermission + // point of levels for the menu system to use + // we pass it along to the cgame to make apropriate adjustments, + // but we also clear the console and notify lines here + if ( !strcmp( cmd, "clientLevelShot" ) ) { + // don't do it if we aren't running the server locally, + // otherwise malicious remote servers could overwrite + // the existing thumbnails + if ( !com_sv_running->integer ) { + return qfalse; + } + // close the console + Con_Close(); + // take a special screenshot next frame + Cbuf_AddText( "wait ; wait ; wait ; wait ; screenshot levelshot\n" ); + return qtrue; + } + + // we may want to put a "connect to other server" command here + + // cgame can now act on the command + return qtrue; +} + + +/* +==================== +CL_CM_LoadMap + +Just adds default parameters that cgame doesn't need to know about +==================== +*/ +void CL_CM_LoadMap( const char *mapname ) { + int checksum; + + CM_LoadMap( mapname, qtrue, &checksum ); +} + +/* +==================== +CL_CG_Malloc +==================== +*/ +void *CL_CG_Malloc( int size ) +{ + return Z_TagMalloc( size, TAG_CGAME ); +} + +/* +==================== +CL_CG_Free +==================== +*/ +void CL_CG_Free( void *ptr ) +{ + Z_Free( ptr ); +} + +/* +==================== +CL_R_AddPolyToScene +==================== +*/ +void CL_R_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts ) +{ + re.AddPolyToScene( hShader, numVerts, verts, 1 ); +} + +/* +==================== +CL_GetShaderPointer +==================== +*/ +baseshader_t *CL_GetShaderPointer( int iShaderNum ) +{ + return CM_ShaderPointer( iShaderNum ); +} + +/* +==================== +CL_ShutdownCGame + +==================== +*/ +void CL_ShutdownCGame( void ) { + Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CGAME ); + cls.cgameStarted = qfalse; + + if( cge ) + { + cge->CG_Shutdown(); + cge = NULL; + } + + Sys_UnloadCGame(); + + if( re.FreeModels ) { + re.FreeModels(); + } + + Z_FreeTags( TAG_CGAME ); +} + +static int FloatAsInt( float f ) { + int temp; + + *(float *)&temp = f; + + return temp; +} + +/* +==================== +CL_RegisterSound +==================== +*/ +sfxHandle_t CL_RegisterSound( const char *sample, qboolean streamed ) { + return S_RegisterSound( sample, streamed, qfalse ); +} + +/* +==================== +CL_StartLocalSound +==================== +*/ +void CL_StartLocalSound( const char *sound_name ) { + S_StartLocalSound( sound_name, qfalse ); +} + +/* +==================== +CL_InitCGameDLL +==================== +*/ +void CL_InitCGameDLL( clientGameImport_t *cgi, clientGameExport_t **cge ) { + + *cge = ( clientGameExport_t * )Sys_GetCGameAPI( cgi ); + if( !*cge ) { + Com_Error( ERR_DROP, "CL_InitCGameImport failed" ); + } + + memset( cgi, 0, sizeof( clientGameImport_t ) ); + + cgi->Printf = Com_Printf; + cgi->DPrintf = Com_DPrintf; + + cgi->Malloc = CL_CG_Malloc; + cgi->Free = CL_CG_Free; + + cgi->Error = Com_Error; + cgi->Milliseconds = Sys_Milliseconds; + + cgi->LV_ConvertString = Sys_LV_CL_ConvertString; + + cgi->Cvar_Get = Cvar_Get; + cgi->Cvar_Set = Cvar_Set; + + cgi->Argc = Cmd_Argc; + cgi->Args = Cmd_Args; + cgi->Argv = Cmd_Argv; + + cgi->AddCommand = CL_AddCgameCommand; + cgi->Cmd_Stuff = Cbuf_AddText; + cgi->Cmd_Execute = Cbuf_ExecuteText; + cgi->Cmd_TokenizeString = Cmd_TokenizeString; + + cgi->FS_ReadFile = FS_ReadFileEx; + cgi->FS_FreeFile = FS_FreeFile; + cgi->FS_WriteFile = FS_WriteFile; + cgi->FS_WriteTextFile = FS_WriteTextFile; + + cgi->SendConsoleCommand = Cbuf_AddText; + + cgi->MSG_ReadBits = CL_MSG_ReadBits; + cgi->MSG_ReadChar = CL_MSG_ReadChar; + cgi->MSG_ReadByte = CL_MSG_ReadByte; + cgi->MSG_ReadSVC = CL_MSG_ReadSVC; + cgi->MSG_ReadShort = CL_MSG_ReadShort; + cgi->MSG_ReadLong = CL_MSG_ReadLong; + cgi->MSG_ReadFloat = CL_MSG_ReadFloat; + cgi->MSG_ReadString = CL_MSG_ReadString; + cgi->MSG_ReadStringLine = CL_MSG_ReadStringLine; + cgi->MSG_ReadAngle8 = CL_MSG_ReadAngle8; + cgi->MSG_ReadAngle16 = CL_MSG_ReadAngle16; + cgi->MSG_ReadData = CL_MSG_ReadData; + cgi->MSG_ReadCoord = CL_MSG_ReadCoord; + cgi->MSG_ReadDir = CL_MSG_ReadDir; + + cgi->SendClientCommand = CL_AddReliableCommand; + + cgi->CM_LoadMap = CL_CM_LoadMap; + cgi->CM_NumInlineModels = CM_NumInlineModels; + cgi->CM_PointContents = CM_PointContents; + cgi->CM_TransformedPointContents = CM_TransformedPointContents; + cgi->CM_BoxTrace = CM_BoxTrace; + cgi->CM_TransformedBoxTrace = CM_TransformedBoxTrace; + cgi->CM_TempBoxModel = CM_TempBoxModel; + cgi->CM_InlineModel = CM_InlineModel; + cgi->CM_PrintBSPFileSizes = CM_PrintBSPFileSizes; + cgi->CM_PointLeafnum = CM_PointLeafnum; + cgi->CM_LeafInPVS = CM_LeafInPVS; + + cgi->R_MarkFragments = re.MarkFragments; + cgi->R_MarkFragmentsForInlineModel = re.MarkFragmentsForInlineModel; + cgi->R_GetInlineModelBounds = re.GetInlineModelBounds; + cgi->R_GetLightingForDecal = re.GetLightingForDecal; + cgi->R_GetLightingForSmoke = re.GetLightingForSmoke; + cgi->R_GatherLightSources = re.R_GatherLightSources; + + cgi->S_StartSound = S_StartSound; + cgi->S_StartLocalSound = CL_StartLocalSound; + cgi->S_StopSound = S_StopSound; + cgi->S_AddLoopingSound = S_AddLoopingSound; + cgi->S_ClearLoopingSounds = S_ClearLoopingSounds; + cgi->S_Respatialize = S_Respatialize; + cgi->S_BeginRegistration = S_BeginRegistration; + cgi->S_EndRegistration = S_EndRegistration; + cgi->S_UpdateEntity = S_UpdateEntity; + cgi->S_SetReverb = S_SetReverb; + cgi->S_SetGlobalAmbientVolumeLevel = S_SetGlobalAmbientVolumeLevel; + cgi->S_RegisterSound = CL_RegisterSound; + cgi->S_GetSoundTime = S_GetSoundTime; + cgi->S_ChannelNameToNum = S_ChannelNameToNum; + cgi->S_ChannelNumToName = S_ChannelNumToName; + cgi->S_IsSoundPlaying = S_IsSoundPlaying; + + cgi->MUSIC_NewSoundtrack = MUSIC_NewSoundtrack; + cgi->MUSIC_UpdateMood = MUSIC_UpdateMood; + cgi->MUSIC_UpdateVolume = MUSIC_UpdateVolume; + + cgi->get_camera_offset = get_camera_offset; + + cgi->R_ClearScene = re.ClearScene; + cgi->R_RenderScene = re.RenderScene; + + cgi->R_LoadWorldMap = re.LoadWorld; + cgi->R_PrintBSPFileSizes = re.PrintBSPFileSizes; + cgi->R_MapVersion = re.MapVersion; + cgi->R_RegisterModel = re.RegisterModel; + cgi->R_SpawnEffectModel = re.SpawnEffectModel; + cgi->R_RegisterServerModel = re.RegisterServerModel; + cgi->R_UnregisterServerModel = re.UnregisterServerModel; + cgi->R_RegisterShader = re.RegisterShader; + cgi->R_RegisterShaderNoMip = re.RegisterShaderNoMip; + + cgi->R_AddRefEntityToScene = re.AddRefEntityToScene; + cgi->R_AddRefSpriteToScene = re.AddRefSpriteToScene; + + cgi->R_AddLightToScene = re.AddLightToScene; + cgi->R_AddPolyToScene = re.AddPolyToScene; + cgi->R_AddTerrainMarkToScene = re.AddTerrainMarkToScene; + cgi->R_SetColor = re.SetColor; + cgi->R_DrawStretchPic = re.DrawStretchPic; + cgi->R_LoadFont = re.LoadFont; + cgi->R_DrawString = re.DrawString; + cgi->R_ModelBounds = re.ModelBounds; + cgi->R_ModelRadius = re.ModelRadius; + cgi->R_GetRenderEntity = re.GetRenderEntity; + cgi->R_Noise = re.Noise; + cgi->R_DebugLine = re.DebugLine; + + cgi->GetShader = CL_GetShaderPointer; + cgi->R_GetShaderWidth = re.GetShaderWidth; + cgi->R_GetShaderHeight = re.GetShaderHeight; + + cgi->R_DrawBox = re.DrawBox; + cgi->R_SwipeBegin = re.SwipeBegin; + cgi->R_SwipePoint = re.SwipePoint; + cgi->R_SwipeEnd = re.SwipeEnd; + + cgi->GetGameState = CL_GetGameState; + cgi->GetSnapshot = CL_GetSnapshot; + cgi->GetServerStartTime = CL_GetServerStartTime; + cgi->SetTime = CL_SetTime; + cgi->GetCurrentSnapshotNumber = CL_GetCurrentSnapshotNumber; + + cgi->GetGlconfig = CL_GetGlconfig; + + cgi->GetParseEntityState = CL_GetParseEntityState; + cgi->GetCurrentCmdNumber = CL_GetCurrentCmdNumber; + cgi->GetUserCmd = CL_GetUserCmd; + cgi->GetServerCommand = CL_GetServerCommand; + + cgi->Alias_Add = Alias_Add; + cgi->Alias_ListAdd = Alias_ListAdd; + cgi->Alias_FindRandom = Alias_FindRandom; + cgi->Alias_ListFindRandom = Alias_ListFindRandom; + cgi->Alias_Dump = Alias_Dump; + cgi->Alias_Clear = Alias_Clear; + cgi->AliasList_New = AliasList_New; + cgi->Alias_ListFindRandomRange = Alias_ListFindRandomRange; + cgi->Alias_GetGlobalList = Alias_GetGlobalList; + + cgi->UI_ShowMenu = UI_ShowMenu; + cgi->UI_HideMenu = UI_HideMenu; + cgi->UI_FontStringWidth = uie.FontStringWidth; + cgi->Key_StringToKeynum = Key_StringToKeynum; + cgi->Key_KeynumToBindString = Key_KeynumToBindString; + cgi->Key_GetKeysForCommand = Key_GetKeysForCommand; + + cgi->R_Model_GetHandle = re.R_Model_GetHandle; + + cgi->TIKI_NumAnims = TIKI_NumAnims; + cgi->TIKI_CalculateBounds = TIKI_CalculateBounds; + cgi->TIKI_Name = TIKI_Name; + cgi->TIKI_GetSkeletor = TIKI_GetSkeletor; + cgi->TIKI_SetEyeTargetPos = TIKI_SetEyeTargetPos; + + cgi->Anim_NameForNum = TIKI_Anim_NameForNum; + cgi->Anim_NumForName = TIKI_Anim_NumForName; + cgi->Anim_Random = TIKI_Anim_Random; + cgi->Anim_NumFrames = TIKI_Anim_NumFrames; + cgi->Anim_Time = TIKI_Anim_Time; + cgi->Anim_Frametime = TIKI_Anim_Frametime; + cgi->Anim_Flags = TIKI_Anim_Flags; + cgi->Anim_FlagsSkel = TIKI_Anim_FlagsSkel; + cgi->Anim_CrossblendTime = TIKI_Anim_CrossblendTime; + cgi->Anim_HasCommands = TIKI_Anim_HasClientCommands; + cgi->Frame_Commands = TIKI_Frame_Commands_Client; + cgi->Frame_CommandsTime = TIKI_Frame_Commands_ClientTime; + + cgi->Surface_NameToNum = TIKI_Surface_NameToNum; + cgi->Tag_NumForName = TIKI_Tag_NameToNum; + cgi->Tag_NameForNum = TIKI_Tag_NumToName; + + cgi->ForceUpdatePose = re.ForceUpdatePose; + cgi->TIKI_Orientation = re.TIKI_Orientation; + cgi->TIKI_IsOnGround = re.TIKI_IsOnGround; + + cgi->UI_ShowScoreBoard = UI_ShowScoreboard_f; + cgi->UI_HideScoreBoard = UI_HideScoreboard_f; + cgi->UI_SetScoreBoardItem = UI_SetScoreBoardItem; + cgi->UI_DeleteScoreBoardItems = UI_DeleteScoreBoardItems; + cgi->UI_ToggleDMMessageConsole = UI_ToggleDMConsole; + + cgi->TIKI_FindTiki = TIKI_FindTiki; + + cgi->LoadResource = UI_LoadResource; + cgi->FS_CanonicalFilename = FS_CanonicalFilename; + + cgi->fsDebug = fs_debug; + cgi->hudDrawElements = cls.HudDrawElements; + cgi->anim = &cls.anim; + cgi->stopWatch = &cls.stopwatch; + cgi->pUnknownVar = NULL; + + cls.cgameStarted = qtrue; +} + +/* +==================== +CL_ViewModelAnimation_Init +==================== +*/ +static void CL_ViewModelAnimation_Init() { + int i; + + for( i = 0; i < MAX_FRAMEINFOS; i++ ) { + cls.anim.vmFrameInfo[ i ].index = 0; + cls.anim.vmFrameInfo[ i ].time = 0.0; + cls.anim.vmFrameInfo[ i ].weight = 0.0; + } + + VectorClear( cls.anim.currentVMPosOffset ); + cls.anim.lastVMAnim = -1; + cls.anim.lastVMAnimChanged = -1; + cls.anim.currentVMAnimSlot = 0; + cls.anim.currentVMDuration = 9999; + cls.anim.crossBlending = qfalse; + cls.anim.lastEquippedWeaponStat = -1; + cls.anim.lastActiveItem[ 0 ] = 0; + cls.anim.lastAnimPrefixIndex = 0; +} + +/* +==================== +CL_InitializeHudDrawElements +==================== +*/ +static void CL_InitializeHudDrawElements() { + int i; + + for( i = 0; i < MAX_HUDDRAW_ELEMENTS; i++ ) { + cls.HudDrawElements[ i ].shaderName[ 0 ] = 0; + VectorSet4( cls.HudDrawElements[ i ].vColor, 1, 1, 1, 0 ); + cls.HudDrawElements[ i ].hShader = 0; + cls.HudDrawElements[ i ].iX = 0; + cls.HudDrawElements[ i ].iY = 0; + cls.HudDrawElements[ i ].iWidth = 0; + cls.HudDrawElements[ i ].iHeight = 0; + cls.HudDrawElements[ i ].iHorizontalAlign = 1; + cls.HudDrawElements[ i ].iVerticalAlign = 1; + cls.HudDrawElements[ i ].bVirtualScreen = qfalse; + cls.HudDrawElements[ i ].string[ 0 ] = 0; + cls.HudDrawElements[ i ].fontName[ 0 ] = 0; + cls.HudDrawElements[ i ].pFont = NULL; + } +} + +/* +==================== +CL_InitializeStopwatch +==================== +*/ +static void CL_InitializeStopwatch() { + cls.stopwatch.iStartTime = 0; + cls.stopwatch.iEndTime = 0; +} + +/* +==================== +CL_InitClientSavedData +==================== +*/ +void CL_InitClientSavedData( void ) { + CL_ViewModelAnimation_Init(); + CL_InitializeHudDrawElements(); + CL_InitializeStopwatch(); +} + +/* +==================== +CL_InitCGame + +Should only be called by CL_StartHunkUsers +==================== +*/ +void CL_InitCGame( void ) { + const char *info; + const char *mapname; + int t1, t2; + clientGameImport_t cgi; + + t1 = Sys_Milliseconds(); + + // put away the console + Con_Close(); + + // find the current mapname + info = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ]; + mapname = Info_ValueForKey( info, "mapname" ); + Com_sprintf( cl.mapname, sizeof( cl.mapname ), "maps/%s.bsp", mapname ); + + S_BeginRegistration(); + CL_ShutdownCGame(); + CL_InitCGameDLL( &cgi, &cge ); + cls.state = CA_LOADING; + + if( !com_sv_running->integer && !cls.vid_restart ) + { + TIKI_End(); + TIKI_Begin(); + TIKI_FreeAll(); + CL_InitClientSavedData(); + } + + // init for this gamestate + // use the lastExecutedServerCommand instead of the serverCommandSequence + // otherwise server commands sent just before a gamestate are dropped + cge->CG_Init( &cgi, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum ); + + ClearNewConfigFlag(); + TIKI_FinishLoad(); + + // reset any CVAR_CHEAT cvars registered by cgame + if( !clc.demoplaying && !cl_connectedToCheatServer ) + Cvar_SetCheatState(); + + // we will send a usercmd this frame, which + // will cause the server to send us the first snapshot + cls.state = CA_PRIMED; + + CL_EndRegistration(); + + t2 = Sys_Milliseconds(); + + // clear anything that got printed + Con_ClearNotify(); + + Com_Printf( "CL_InitCGame: %5.2f seconds\n", ( t2 - t1 ) / 1000.0 ); +} + + +/* +==================== +CL_GameCommand + +See if the current console command is claimed by the cgame +==================== +*/ +qboolean CL_GameCommand( void ) { + if ( !cge ) { + return qfalse; + } + + return cge->CG_ConsoleCommand(); +} + + + +/* +===================== +CL_CGameRendering +===================== +*/ +void CL_CGameRendering( stereoFrame_t stereo ) { + if( cl.oldServerTime < cl.serverStartTime ) { + cl.serverTime = cl.serverStartTime; + cl.oldServerTime = cl.serverStartTime; + } + + cge->CG_DrawActiveFrame( cl.serverTime, cl.serverTime - cl.oldServerTime, stereo, clc.demoplaying ); + + cl.oldServerTime = cl.serverTime; +} + +/* +===================== +CL_CGame2D +===================== +*/ +void CL_CGame2D( stereoFrame_t stereo ) { + cge->CG_Draw2D(); +} + + +/* +================= +CL_AdjustTimeDelta + +Adjust the clients view of server time. + +We attempt to have cl.serverTime exactly equal the server's view +of time plus the timeNudge, but with variable latencies over +the internet it will often need to drift a bit to match conditions. + +Our ideal time would be to have the adjusted time approach, but not pass, +the very latest snapshot. + +Adjustments are only made when a new snapshot arrives with a rational +latency, which keeps the adjustment process framerate independent and +prevents massive overadjustment during times of significant packet loss +or bursted delayed packets. +================= +*/ + +#define RESET_TIME 500 + +void CL_AdjustTimeDelta( void ) { + int resetTime; + int newDelta; + int deltaDelta; + + cl.newSnapshots = qfalse; + + // the delta never drifts when replaying a demo + if ( clc.demoplaying ) { + return; + } + + // if the current time is WAY off, just correct to the current value + if ( com_sv_running->integer ) { + resetTime = 100; + } else { + resetTime = RESET_TIME; + } + + newDelta = cl.snap.serverTime - cls.realtime; + deltaDelta = abs( newDelta - cl.serverTimeDelta ); + + if ( deltaDelta > RESET_TIME ) { + cl.serverTimeDelta = newDelta; + cl.oldServerTime = cl.snap.serverTime; // FIXME: is this a problem for cgame? + cl.serverTime = cl.snap.serverTime; + if ( cl_showTimeDelta->integer ) { + Com_Printf( " " ); + } + } else if ( deltaDelta > 100 ) { + // fast adjust, cut the difference in half + if ( cl_showTimeDelta->integer ) { + Com_Printf( " " ); + } + cl.serverTimeDelta = ( cl.serverTimeDelta + newDelta ) >> 1; + } else { + // slow drift adjust, only move 1 or 2 msec + + // if any of the frames between this and the previous snapshot + // had to be extrapolated, nudge our sense of time back a little + // the granularity of +1 / -2 is too high for timescale modified frametimes + if ( !cls.timeScaled ) { + if ( cl.extrapolatedSnapshot ) { + cl.extrapolatedSnapshot = qfalse; + cl.serverTimeDelta -= 2; + } else { + // otherwise, move our sense of time forward to minimize total latency + cl.serverTimeDelta++; + } + } + } + + if ( cl_showTimeDelta->integer ) { + Com_Printf( "%i ", cl.serverTimeDelta ); + } +} + + +/* +================== +CL_FirstSnapshot +================== +*/ +void CL_FirstSnapshot( void ) { + // ignore snapshots that don't have entities + if ( cl.snap.snapFlags & SNAPFLAG_NOT_ACTIVE ) { + return; + } + cls.state = CA_ACTIVE; + + // notify the UI + UI_ServerLoaded(); + + // set the timedelta so we are exactly on this first frame + cl.serverStartTime = cl.snap.serverTime; + cl.serverTimeDelta = cl.snap.serverTime - cls.realtime; + + clc.timeDemoBaseTime = cl.snap.serverTime; + + // if this is the first frame of active play, + // execute the contents of activeAction now + // this is to allow scripting a timedemo to start right + // after loading + if ( cl_activeAction->string[0] ) { + Cbuf_AddText( cl_activeAction->string ); + Cvar_Set( "activeAction", "" ); + } +} + +static int lastSnapFlags; +/* +================== +CL_UpdateSnapFlags +================== +*/ +void CL_UpdateSnapFlags( void ) { + lastSnapFlags = cl.snap.snapFlags; +} + +/* +================== +CL_SetCGameTime +================== +*/ +void CL_SetCGameTime( void ) { + // getting a valid frame message ends the connection process + if ( cls.state != CA_ACTIVE ) { + if ( cls.state != CA_PRIMED ) { + return; + } + if ( clc.demoplaying ) { + // we shouldn't get the first snapshot on the same frame + // as the gamestate, because it causes a bad time skip + if ( !clc.firstDemoFrameSkipped ) { + clc.firstDemoFrameSkipped = qtrue; + return; + } + CL_ReadDemoMessage(); + } + if ( cl.newSnapshots ) { + cl.newSnapshots = qfalse; + CL_FirstSnapshot(); + } + if ( cls.state != CA_ACTIVE ) { + return; + } + } + + // if we have gotten to this point, cl.snap is guaranteed to be valid + if ( !cl.snap.valid ) { + assert( 0 ); + Com_Error( ERR_DROP, "CL_SetCGameTime: !cl.snap.valid" ); + } + + // allow pause in single player + if ( paused->integer && com_sv_running->integer ) { + // paused + CL_AdjustTimeDelta(); + return; + } + + // FIXME + //if( ( cl.snap.snapFlags ^ lastSnapFlags ) & SNAPFLAG_SERVERCOUNT ) { + // CL_ServerRestarted(); + //} else { + + if( cl.snap.serverTime < cl.oldFrameServerTime ) { + assert( 0 ); + Com_Error( ERR_DROP, "cl.snap.serverTime < cl.oldFrameServerTime" ); + } + //} + + cl.oldFrameServerTime = cl.snap.serverTime; + + + // get our current view of time + + if ( clc.demoplaying && cl_freezeDemo->integer ) { + // cl_freezeDemo is used to lock a demo in place for single frame advances + + } else { + // cl_timeNudge is a user adjustable cvar that allows more + // or less latency to be added in the interest of better + // smoothness or better responsiveness. + int tn; + + tn = cl_timeNudge->integer; + if (tn<-30) { + tn = -30; + } else if (tn>30) { + tn = 30; + } + + cl.serverTime = cls.realtime + cl.serverTimeDelta - tn; + + // guarantee that time will never flow backwards, even if + // serverTimeDelta made an adjustment or cl_timeNudge was changed + if ( cl.serverTime < cl.oldServerTime ) { + cl.serverTime = cl.oldServerTime; + } + + // note if we are almost past the latest frame (without timeNudge), + // so we will try and adjust back a bit when the next snapshot arrives + if ( cls.realtime + cl.serverTimeDelta >= cl.snap.serverTime - 5 ) { + cl.extrapolatedSnapshot = qtrue; + } + } + + // if we have gotten new snapshots, drift serverTimeDelta + // don't do this every frame, or a period of packet loss would + // make a huge adjustment + if ( cl.newSnapshots ) { + CL_AdjustTimeDelta(); + } + + if ( !clc.demoplaying ) { + return; + } + + // if we are playing a demo back, we can just keep reading + // messages from the demo file until the cgame definately + // has valid snapshots to interpolate between + + // a timedemo will always use a deterministic set of time samples + // no matter what speed machine it is run on, + // while a normal demo may have different time samples + // each time it is played back + if ( cl_timedemo->integer ) { + int now = Sys_Milliseconds( ); + int frameDuration; + + if (!clc.timeDemoStart) { + clc.timeDemoStart = clc.timeDemoLastFrame = now; + clc.timeDemoMinDuration = INT_MAX; + clc.timeDemoMaxDuration = 0; + } + + frameDuration = now - clc.timeDemoLastFrame; + clc.timeDemoLastFrame = now; + + // Ignore the first measurement as it'll always be 0 + if( clc.timeDemoFrames > 0 ) + { + if( frameDuration > clc.timeDemoMaxDuration ) + clc.timeDemoMaxDuration = frameDuration; + + if( frameDuration < clc.timeDemoMinDuration ) + clc.timeDemoMinDuration = frameDuration; + + // 255 ms = about 4fps + if( frameDuration > UCHAR_MAX ) + frameDuration = UCHAR_MAX; + + clc.timeDemoDurations[ ( clc.timeDemoFrames - 1 ) % + MAX_TIMEDEMO_DURATIONS ] = frameDuration; + } + + clc.timeDemoFrames++; + cl.serverTime = clc.timeDemoBaseTime + clc.timeDemoFrames * 50; + } + + while ( cl.serverTime >= cl.snap.serverTime ) { + // feed another messag, which should change + // the contents of cl.snap + CL_ReadDemoMessage(); + if ( cls.state != CA_ACTIVE ) { + return; // end of demo + } + } + +} + + + diff --git a/code/client/cl_cin.cpp b/code/client/cl_cin.cpp new file mode 100644 index 00000000..a8f6dfd1 --- /dev/null +++ b/code/client/cl_cin.cpp @@ -0,0 +1,1692 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** + * name: cl_cin.c + * + * desc: video and cinematic playback + * + * $Archive: /MissionPack/code/client/cl_cin.c $ + * + * cl_glconfig.hwtype trtypes 3dfx/ragepro need 256x256 + * + *****************************************************************************/ + +#include "client.h" +#include "../uilib/ui_public.h" +#include "snd_local.h" + +#define MAXSIZE 8 +#define MINSIZE 4 + +#define DEFAULT_CIN_WIDTH 512 +#define DEFAULT_CIN_HEIGHT 512 + +#define ROQ_QUAD 0x1000 +#define ROQ_QUAD_INFO 0x1001 +#define ROQ_CODEBOOK 0x1002 +#define ROQ_QUAD_VQ 0x1011 +#define ROQ_QUAD_JPEG 0x1012 +#define ROQ_QUAD_HANG 0x1013 +#define ROQ_PACKET 0x1030 +#define ZA_SOUND_MONO 0x1020 +#define ZA_SOUND_STEREO 0x1021 + +#define MAX_VIDEO_HANDLES 16 + + +static void RoQ_init( void ); + +/****************************************************************************** +* +* Class: trFMV +* +* Description: RoQ/RnR manipulation routines +* not entirely complete for first run +* +******************************************************************************/ + +static long ROQ_YY_tab[256]; +static long ROQ_UB_tab[256]; +static long ROQ_UG_tab[256]; +static long ROQ_VG_tab[256]; +static long ROQ_VR_tab[256]; +static unsigned short vq2[256*16*4]; +static unsigned short vq4[256*64*4]; +static unsigned short vq8[256*256*4]; + + +typedef struct { + byte linbuf[DEFAULT_CIN_WIDTH*DEFAULT_CIN_HEIGHT*4*2]; + byte file[65536]; + short sqrTable[256]; + + int mcomp[256]; + byte *qStatus[2][32768]; + + long oldXOff, oldYOff, oldysize, oldxsize; + + int currentHandle; +} cinematics_t; + +typedef struct { + char fileName[MAX_OSPATH]; + int CIN_WIDTH, CIN_HEIGHT; + int xpos, ypos, width, height; + qboolean looping, holdAtEnd, dirty, alterGameState, silent, shader; + fileHandle_t iFile; + e_status status; + int startTime; + int lastTime; + long tfps; + long RoQPlayed; + long ROQSize; + unsigned int RoQFrameSize; + long onQuad; + long numQuads; + long samplesPerLine; + unsigned int roq_id; + long screenDelta; + + void ( *VQ0)(byte *status, void *qdata ); + void ( *VQ1)(byte *status, void *qdata ); + void ( *VQNormal)(byte *status, void *qdata ); + void ( *VQBuffer)(byte *status, void *qdata ); + + long samplesPerPixel; // defaults to 2 + byte* gray; + unsigned int xsize, ysize, maxsize, minsize; + + qboolean half, smootheddouble, inMemory; + long normalBuffer0; + long roq_flags; + long roqF0; + long roqF1; + long t[2]; + long roqFPS; + int playonwalls; + byte* buf; + long drawX, drawY; +} cin_cache; + +static cinematics_t cin; +static cin_cache cinTable[MAX_VIDEO_HANDLES]; +static int currentHandle = -1; +static int CL_handle = -1; + +extern int s_soundtime; // sample PAIRS + + +void CIN_CloseAllVideos(void) { + int i; + + for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) { + if (cinTable[i].fileName[0] != 0 ) { + CIN_StopCinematic(i); + } + } +} + + +static int CIN_HandleForVideo(void) { + int i; + + for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) { + if ( cinTable[i].fileName[0] == 0 ) { + return i; + } + } + Com_Error( ERR_DROP, "CIN_HandleForVideo: none free" ); + return -1; +} + + +extern "C" int CL_ScaledMilliseconds(void); + +//----------------------------------------------------------------------------- +// RllSetupTable +// +// Allocates and initializes the square table. +// +// Parameters: None +// +// Returns: Nothing +//----------------------------------------------------------------------------- +static void RllSetupTable( void ) +{ + int z; + + for (z=0;z<128;z++) { + cin.sqrTable[z] = (short)(z*z); + cin.sqrTable[z+128] = (short)(-cin.sqrTable[z]); + } +} + + + +//----------------------------------------------------------------------------- +// RllDecodeMonoToMono +// +// Decode mono source data into a mono buffer. +// +// Parameters: from -> buffer holding encoded data +// to -> buffer to hold decoded data +// size = number of bytes of input (= # of shorts of output) +// signedOutput = 0 for unsigned output, non-zero for signed output +// flag = flags from asset header +// +// Returns: Number of samples placed in output buffer +//----------------------------------------------------------------------------- +long RllDecodeMonoToMono(unsigned char *from,short *to,unsigned int size,char signedOutput ,unsigned short flag) +{ + unsigned int z; + int prev; + + if (signedOutput) + prev = flag - 0x8000; + else + prev = flag; + + for (z=0;z buffer holding encoded data +// to -> buffer to hold decoded data +// size = number of bytes of input (= 1/4 # of bytes of output) +// signedOutput = 0 for unsigned output, non-zero for signed output +// flag = flags from asset header +// +// Returns: Number of samples placed in output buffer +//----------------------------------------------------------------------------- +long RllDecodeMonoToStereo(unsigned char *from,short *to,unsigned int size,char signedOutput,unsigned short flag) +{ + unsigned int z; + int prev; + + if (signedOutput) + prev = flag - 0x8000; + else + prev = flag; + + for (z = 0; z < size; z++) { + prev = (short)(prev + cin.sqrTable[from[z]]); + to[z*2+0] = to[z*2+1] = (short)(prev); + } + + return size; // * 2 * sizeof(short)); +} + + +//----------------------------------------------------------------------------- +// RllDecodeStereoToStereo +// +// Decode stereo source data into a stereo buffer. +// +// Parameters: from -> buffer holding encoded data +// to -> buffer to hold decoded data +// size = number of bytes of input (= 1/2 # of bytes of output) +// signedOutput = 0 for unsigned output, non-zero for signed output +// flag = flags from asset header +// +// Returns: Number of samples placed in output buffer +//----------------------------------------------------------------------------- +long RllDecodeStereoToStereo(unsigned char *from,short *to,unsigned int size,char signedOutput, unsigned short flag) +{ + unsigned int z; + unsigned char *zz = from; + int prevL, prevR; + + if (signedOutput) { + prevL = (flag & 0xff00) - 0x8000; + prevR = ((flag & 0x00ff) << 8) - 0x8000; + } else { + prevL = flag & 0xff00; + prevR = (flag & 0x00ff) << 8; + } + + for (z=0;z>1); //*sizeof(short)); +} + + +//----------------------------------------------------------------------------- +// RllDecodeStereoToMono +// +// Decode stereo source data into a mono buffer. +// +// Parameters: from -> buffer holding encoded data +// to -> buffer to hold decoded data +// size = number of bytes of input (= # of bytes of output) +// signedOutput = 0 for unsigned output, non-zero for signed output +// flag = flags from asset header +// +// Returns: Number of samples placed in output buffer +//----------------------------------------------------------------------------- +long RllDecodeStereoToMono(unsigned char *from,short *to,unsigned int size,char signedOutput, unsigned short flag) +{ + unsigned int z; + int prevL,prevR; + + if (signedOutput) { + prevL = (flag & 0xff00) - 0x8000; + prevR = ((flag & 0x00ff) << 8) -0x8000; + } else { + prevL = flag & 0xff00; + prevR = (flag & 0x00ff) << 8; + } + + for (z=0;z> 2) ); + } +} + +#define VQ2TO4(a,b,c,d) { \ + *c++ = a[0]; \ + *d++ = a[0]; \ + *d++ = a[0]; \ + *c++ = a[1]; \ + *d++ = a[1]; \ + *d++ = a[1]; \ + *c++ = b[0]; \ + *d++ = b[0]; \ + *d++ = b[0]; \ + *c++ = b[1]; \ + *d++ = b[1]; \ + *d++ = b[1]; \ + *d++ = a[0]; \ + *d++ = a[0]; \ + *d++ = a[1]; \ + *d++ = a[1]; \ + *d++ = b[0]; \ + *d++ = b[0]; \ + *d++ = b[1]; \ + *d++ = b[1]; \ + a += 2; b += 2; } + +#define VQ2TO2(a,b,c,d) { \ + *c++ = *a; \ + *d++ = *a; \ + *d++ = *a; \ + *c++ = *b; \ + *d++ = *b; \ + *d++ = *b; \ + *d++ = *a; \ + *d++ = *a; \ + *d++ = *b; \ + *d++ = *b; \ + a++; b++; } + +/****************************************************************************** +* +* Function: +* +* Description: +* +******************************************************************************/ + +static unsigned short yuv_to_rgb( long y, long u, long v ) +{ + long r,g,b,YY = (long)(ROQ_YY_tab[(y)]); + + r = (YY + ROQ_VR_tab[v]) >> 9; + g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 8; + b = (YY + ROQ_UB_tab[u]) >> 9; + + if (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0; + if (r > 31) r = 31; if (g > 63) g = 63; if (b > 31) b = 31; + + return (unsigned short)((r<<11)+(g<<5)+(b)); +} + +/****************************************************************************** +* +* Function: +* +* Description: +* +******************************************************************************/ +static unsigned int yuv_to_rgb24( long y, long u, long v ) +{ + long r,g,b,YY = (long)(ROQ_YY_tab[(y)]); + + r = (YY + ROQ_VR_tab[v]) >> 6; + g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 6; + b = (YY + ROQ_UB_tab[u]) >> 6; + + if (r<0) r = 0; if (g<0) g = 0; if (b<0) b = 0; + if (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255; + + return LittleLong ((r)|(g<<8)|(b<<16)|(255<<24)); +} + +/****************************************************************************** +* +* Function: +* +* Description: +* +******************************************************************************/ + +static void decodeCodeBook( byte *input, unsigned short roq_flags ) +{ + long i, j, two, four; + unsigned short *aptr, *bptr, *cptr, *dptr; + long y0,y1,y2,y3,cr,cb; + byte *bbptr, *baptr, *bcptr, *bdptr; + union { + unsigned int *i; + unsigned short *s; + } iaptr, ibptr, icptr, idptr; + + if (!roq_flags) { + two = four = 256; + } else { + two = roq_flags>>8; + if (!two) two = 256; + four = roq_flags&0xff; + } + + four *= 2; + + bptr = (unsigned short *)vq2; + + if (!cinTable[currentHandle].half) { + if (!cinTable[currentHandle].smootheddouble) { +// +// normal height +// + if (cinTable[currentHandle].samplesPerPixel==2) { + for(i=0;i cinTable[currentHandle].CIN_WIDTH) bigx = cinTable[currentHandle].CIN_WIDTH; + if (bigy > cinTable[currentHandle].CIN_HEIGHT) bigy = cinTable[currentHandle].CIN_HEIGHT; + + if ( (startX >= lowx) && (startX+quadSize) <= (bigx) && (startY+quadSize) <= (bigy) && (startY >= lowy) && quadSize <= MAXSIZE) { + useY = startY; + scroff = cin.linbuf + (useY+((cinTable[currentHandle].CIN_HEIGHT-bigy)>>1)+yOff)*(cinTable[currentHandle].samplesPerLine) + (((startX+xOff))*cinTable[currentHandle].samplesPerPixel); + + cin.qStatus[0][cinTable[currentHandle].onQuad ] = scroff; + cin.qStatus[1][cinTable[currentHandle].onQuad++] = scroff+offset; + } + + if ( quadSize != MINSIZE ) { + quadSize >>= 1; + recurseQuad( startX, startY , quadSize, xOff, yOff ); + recurseQuad( startX+quadSize, startY , quadSize, xOff, yOff ); + recurseQuad( startX, startY+quadSize , quadSize, xOff, yOff ); + recurseQuad( startX+quadSize, startY+quadSize , quadSize, xOff, yOff ); + } +} + + +/****************************************************************************** +* +* Function: +* +* Description: +* +******************************************************************************/ + +static void setupQuad( long xOff, long yOff ) +{ + long numQuadCels, i,x,y; + byte *temp; + + if (xOff == cin.oldXOff && yOff == cin.oldYOff && cinTable[currentHandle].ysize == cin.oldysize && cinTable[currentHandle].xsize == cin.oldxsize) { + return; + } + + cin.oldXOff = xOff; + cin.oldYOff = yOff; + cin.oldysize = cinTable[currentHandle].ysize; + cin.oldxsize = cinTable[currentHandle].xsize; + + numQuadCels = (cinTable[currentHandle].xsize*cinTable[currentHandle].ysize) / (16); + numQuadCels += numQuadCels/4; + numQuadCels += 64; // for overflow + + cinTable[currentHandle].onQuad = 0; + + for(y=0;y<(long)cinTable[currentHandle].ysize;y+=16) + for(x=0;x<(long)cinTable[currentHandle].xsize;x+=16) + recurseQuad( x, y, 16, xOff, yOff ); + + temp = NULL; + + for(i=(numQuadCels-64);i256) { + cinTable[currentHandle].drawX = 256; + } + if (cinTable[currentHandle].drawY>256) { + cinTable[currentHandle].drawY = 256; + } + if (cinTable[currentHandle].CIN_WIDTH != 256 || cinTable[currentHandle].CIN_HEIGHT != 256) { + Com_Printf("HACK: approxmimating cinematic for Rage Pro or Voodoo\n"); + } + } +} + +/****************************************************************************** +* +* Function: +* +* Description: +* +******************************************************************************/ + +static void RoQPrepMcomp( long xoff, long yoff ) +{ + long i, j, x, y, temp, temp2; + + i=cinTable[currentHandle].samplesPerLine; j=cinTable[currentHandle].samplesPerPixel; + if ( cinTable[currentHandle].xsize == (cinTable[currentHandle].ysize*4) && !cinTable[currentHandle].half ) { j = j+j; i = i+i; } + + for(y=0;y<16;y++) { + temp2 = (y+yoff-8)*i; + for(x=0;x<16;x++) { + temp = (x+xoff-8)*j; + cin.mcomp[(x*16)+y] = cinTable[currentHandle].normalBuffer0-(temp2+temp); + } + } +} + +/****************************************************************************** +* +* Function: +* +* Description: +* +******************************************************************************/ + +static void initRoQ( void ) +{ + if (currentHandle < 0) return; + + cinTable[currentHandle].VQNormal = (void (*)(byte *, void *))blitVQQuad32fs; + cinTable[currentHandle].VQBuffer = (void (*)(byte *, void *))blitVQQuad32fs; + cinTable[currentHandle].samplesPerPixel = 4; + ROQ_GenYUVTables(); + RllSetupTable(); +} + +/****************************************************************************** +* +* Function: +* +* Description: +* +******************************************************************************/ +/* +static byte* RoQFetchInterlaced( byte *source ) { + int x, *src, *dst; + + if (currentHandle < 0) return NULL; + + src = (int *)source; + dst = (int *)cinTable[currentHandle].buf2; + + for(x=0;x<256*256;x++) { + *dst = *src; + dst++; src += 2; + } + return cinTable[currentHandle].buf2; +} +*/ +static void RoQReset( void ) { + + if (currentHandle < 0) return; + + FS_FCloseFile( cinTable[currentHandle].iFile ); + FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue, qtrue); + // let the background thread start reading ahead + FS_Read (cin.file, 16, cinTable[currentHandle].iFile); + RoQ_init(); + cinTable[currentHandle].status = FMV_LOOPED; +} + +/****************************************************************************** +* +* Function: +* +* Description: +* +******************************************************************************/ + +static void RoQInterrupt(void) +{ + byte *framedata; + short sbuf[32768]; + int ssize; + + if (currentHandle < 0) return; + + FS_Read( cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile ); + if ( cinTable[currentHandle].RoQPlayed >= cinTable[currentHandle].ROQSize ) { + if (cinTable[currentHandle].holdAtEnd==qfalse) { + if (cinTable[currentHandle].looping) { + RoQReset(); + } else { + cinTable[currentHandle].status = FMV_EOF; + } + } else { + cinTable[currentHandle].status = FMV_IDLE; + } + return; + } + + framedata = cin.file; +// +// new frame is ready +// +redump: + switch(cinTable[currentHandle].roq_id) + { + case ROQ_QUAD_VQ: + if ((cinTable[currentHandle].numQuads&1)) { + cinTable[currentHandle].normalBuffer0 = cinTable[currentHandle].t[1]; + RoQPrepMcomp( cinTable[currentHandle].roqF0, cinTable[currentHandle].roqF1 ); + cinTable[currentHandle].VQ1( (byte *)cin.qStatus[1], framedata); + cinTable[currentHandle].buf = cin.linbuf + cinTable[currentHandle].screenDelta; + } else { + cinTable[currentHandle].normalBuffer0 = cinTable[currentHandle].t[0]; + RoQPrepMcomp( cinTable[currentHandle].roqF0, cinTable[currentHandle].roqF1 ); + cinTable[currentHandle].VQ0( (byte *)cin.qStatus[0], framedata ); + cinTable[currentHandle].buf = cin.linbuf; + } + if (cinTable[currentHandle].numQuads == 0) { // first frame + Com_Memcpy(cin.linbuf+cinTable[currentHandle].screenDelta, cin.linbuf, cinTable[currentHandle].samplesPerLine*cinTable[currentHandle].ysize); + } + cinTable[currentHandle].numQuads++; + cinTable[currentHandle].dirty = qtrue; + break; + case ROQ_CODEBOOK: + decodeCodeBook( framedata, (unsigned short)cinTable[currentHandle].roq_flags ); + break; + case ZA_SOUND_MONO: + if (!cinTable[currentHandle].silent) { + ssize = RllDecodeMonoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags); + S_RawSamples(0, ssize, 22050, 2, 1, (byte *)sbuf, 1.0f, -1); + } + break; + case ZA_SOUND_STEREO: + if (!cinTable[currentHandle].silent) { + if (cinTable[currentHandle].numQuads == -1) { + S_Update(); + s_rawend[0] = s_soundtime; + } + ssize = RllDecodeStereoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags); + S_RawSamples(0, ssize, 22050, 2, 2, (byte *)sbuf, 1.0f, -1); + } + break; + case ROQ_QUAD_INFO: + if (cinTable[currentHandle].numQuads == -1) { + readQuadInfo( framedata ); + setupQuad( 0, 0 ); + cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds(); + } + if (cinTable[currentHandle].numQuads != 1) cinTable[currentHandle].numQuads = 0; + break; + case ROQ_PACKET: + cinTable[currentHandle].inMemory = cinTable[currentHandle].roq_flags; + cinTable[currentHandle].RoQFrameSize = 0; // for header + break; + case ROQ_QUAD_HANG: + cinTable[currentHandle].RoQFrameSize = 0; + break; + case ROQ_QUAD_JPEG: + break; + default: + cinTable[currentHandle].status = FMV_EOF; + break; + } +// +// read in next frame data +// + if ( cinTable[currentHandle].RoQPlayed >= cinTable[currentHandle].ROQSize ) { + if (cinTable[currentHandle].holdAtEnd==qfalse) { + if (cinTable[currentHandle].looping) { + RoQReset(); + } else { + cinTable[currentHandle].status = FMV_EOF; + } + } else { + cinTable[currentHandle].status = FMV_IDLE; + } + return; + } + + framedata += cinTable[currentHandle].RoQFrameSize; + cinTable[currentHandle].roq_id = framedata[0] + framedata[1]*256; + cinTable[currentHandle].RoQFrameSize = framedata[2] + framedata[3]*256 + framedata[4]*65536; + cinTable[currentHandle].roq_flags = framedata[6] + framedata[7]*256; + cinTable[currentHandle].roqF0 = (signed char)framedata[7]; + cinTable[currentHandle].roqF1 = (signed char)framedata[6]; + + if (cinTable[currentHandle].RoQFrameSize>65536||cinTable[currentHandle].roq_id==0x1084) { + Com_DPrintf("roq_size>65536||roq_id==0x1084\n"); + cinTable[currentHandle].status = FMV_EOF; + if (cinTable[currentHandle].looping) { + RoQReset(); + } + return; + } + if (cinTable[currentHandle].inMemory && (cinTable[currentHandle].status != FMV_EOF)) { cinTable[currentHandle].inMemory--; framedata += 8; goto redump; } +// +// one more frame hits the dust +// +// assert(cinTable[currentHandle].RoQFrameSize <= 65536); +// r = FS_Read( cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile ); + cinTable[currentHandle].RoQPlayed += cinTable[currentHandle].RoQFrameSize+8; +} + +/****************************************************************************** +* +* Function: +* +* Description: +* +******************************************************************************/ + +static void RoQ_init( void ) +{ + cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds(); + + cinTable[currentHandle].RoQPlayed = 24; + +/* get frame rate */ + cinTable[currentHandle].roqFPS = cin.file[ 6] + cin.file[ 7]*256; + + if (!cinTable[currentHandle].roqFPS) cinTable[currentHandle].roqFPS = 30; + + cinTable[currentHandle].numQuads = -1; + + cinTable[currentHandle].roq_id = cin.file[ 8] + cin.file[ 9]*256; + cinTable[currentHandle].RoQFrameSize = cin.file[10] + cin.file[11]*256 + cin.file[12]*65536; + cinTable[currentHandle].roq_flags = cin.file[14] + cin.file[15]*256; + + if (cinTable[currentHandle].RoQFrameSize > 65536 || !cinTable[currentHandle].RoQFrameSize) { + return; + } + +} + +/****************************************************************************** +* +* Function: +* +* Description: +* +******************************************************************************/ + +static void RoQShutdown( void ) { + const char *s; + + if (!cinTable[currentHandle].buf) { + return; + } + + if ( cinTable[currentHandle].status == FMV_IDLE ) { + return; + } + Com_DPrintf("finished cinematic\n"); + cinTable[currentHandle].status = FMV_IDLE; + + if (cinTable[currentHandle].iFile) { + FS_FCloseFile( cinTable[currentHandle].iFile ); + cinTable[currentHandle].iFile = 0; + } + + if (cinTable[currentHandle].alterGameState) { + cls.state = CA_DISCONNECTED; + // we can't just do a vstr nextmap, because + // if we are aborting the intro cinematic with + // a devmap command, nextmap would be valid by + // the time it was referenced + s = Cvar_VariableString( "nextmap" ); + if ( s[0] ) { + Cbuf_ExecuteText( EXEC_APPEND, va("%s\n", s) ); + Cvar_Set( "nextmap", "" ); + } + CL_handle = -1; + } + cinTable[currentHandle].fileName[0] = 0; + currentHandle = -1; +} + +/* +================== +CIN_StopCinematic +================== +*/ +e_status CIN_StopCinematic(int handle) { + + if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF; + currentHandle = handle; + + Com_DPrintf("trFMV::stop(), closing %s\n", cinTable[currentHandle].fileName); + + if (!cinTable[currentHandle].buf) { + return FMV_EOF; + } + + if (cinTable[currentHandle].alterGameState) { + if ( cls.state != CA_CINEMATIC ) { + return cinTable[currentHandle].status; + } + } + cinTable[currentHandle].status = FMV_EOF; + RoQShutdown(); + + return FMV_EOF; +} + +/* +================== +CIN_RunCinematic + +Fetch and decompress the pending frame +================== +*/ + + +e_status CIN_RunCinematic (int handle) +{ + int start = 0; + int thisTime = 0; + + if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF; + + if (cin.currentHandle != handle) { + currentHandle = handle; + cin.currentHandle = currentHandle; + cinTable[currentHandle].status = FMV_EOF; + RoQReset(); + } + + if (cinTable[handle].playonwalls < -1) + { + return cinTable[handle].status; + } + + currentHandle = handle; + + if (cinTable[currentHandle].alterGameState) { + if ( cls.state != CA_CINEMATIC ) { + return cinTable[currentHandle].status; + } + } + + if (cinTable[currentHandle].status == FMV_IDLE) { + return cinTable[currentHandle].status; + } + + thisTime = CL_ScaledMilliseconds(); + if (cinTable[currentHandle].shader && (abs(thisTime - cinTable[currentHandle].lastTime))>100) { + cinTable[currentHandle].startTime += thisTime - cinTable[currentHandle].lastTime; + } + cinTable[currentHandle].tfps = (((CL_ScaledMilliseconds() - cinTable[currentHandle].startTime)*3)/100); + + start = cinTable[currentHandle].startTime; + while( (cinTable[currentHandle].tfps != cinTable[currentHandle].numQuads) + && (cinTable[currentHandle].status == FMV_PLAY) ) + { + RoQInterrupt(); + if (start != cinTable[currentHandle].startTime) { + cinTable[currentHandle].tfps = (((CL_ScaledMilliseconds() - cinTable[currentHandle].startTime)*3)/100); + start = cinTable[currentHandle].startTime; + } + } + + cinTable[currentHandle].lastTime = thisTime; + + if (cinTable[currentHandle].status == FMV_LOOPED) { + cinTable[currentHandle].status = FMV_PLAY; + } + + if (cinTable[currentHandle].status == FMV_EOF) { + if (cinTable[currentHandle].looping) { + RoQReset(); + } else { + RoQShutdown(); + } + } + + return cinTable[currentHandle].status; +} + +/* +================== +CIN_PlayCinematic +================== +*/ +int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBits ) { + unsigned short RoQID; + char name[MAX_OSPATH]; + int i; + + if (strstr(arg, "/") == NULL && strstr(arg, "\\") == NULL) { + Com_sprintf (name, sizeof(name), "video/%s", arg); + } else { + Com_sprintf (name, sizeof(name), "%s", arg); + } + + if (!(systemBits & CIN_system)) { + for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) { + if (!strcmp(cinTable[i].fileName, name) ) { + return i; + } + } + } + + Com_DPrintf("CIN_PlayCinematic( %s )\n", arg); + + Com_Memset(&cin, 0, sizeof(cinematics_t) ); + currentHandle = CIN_HandleForVideo(); + + cin.currentHandle = currentHandle; + + strcpy(cinTable[currentHandle].fileName, name); + + cinTable[currentHandle].ROQSize = 0; + cinTable[currentHandle].ROQSize = FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue, qtrue); + + if (cinTable[currentHandle].ROQSize<=0) { + Com_DPrintf("play(%s), ROQSize<=0\n", arg); + cinTable[currentHandle].fileName[0] = 0; + return -1; + } + + CIN_SetExtents(currentHandle, x, y, w, h); + CIN_SetLooping(currentHandle, (systemBits & CIN_loop)!=0); + + cinTable[currentHandle].CIN_HEIGHT = DEFAULT_CIN_HEIGHT; + cinTable[currentHandle].CIN_WIDTH = DEFAULT_CIN_WIDTH; + cinTable[currentHandle].holdAtEnd = (systemBits & CIN_hold) != 0; + cinTable[currentHandle].alterGameState = (systemBits & CIN_system) != 0; + cinTable[currentHandle].playonwalls = 1; + cinTable[currentHandle].silent = (systemBits & CIN_silent) != 0; + cinTable[currentHandle].shader = (systemBits & CIN_shader) != 0; + + if (cinTable[currentHandle].alterGameState) { + // close the menu + //uie.SetActiveMenu( UIMENU_NONE ); + } else { + cinTable[currentHandle].playonwalls = cl_inGameVideo->integer; + } + + initRoQ(); + + FS_Read (cin.file, 16, cinTable[currentHandle].iFile); + + RoQID = (unsigned short)(cin.file[0]) + (unsigned short)(cin.file[1])*256; + if (RoQID == 0x1084) + { + RoQ_init(); +// FS_Read (cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile); + + cinTable[currentHandle].status = FMV_PLAY; + Com_DPrintf("trFMV::play(), playing %s\n", arg); + + if (cinTable[currentHandle].alterGameState) { + cls.state = CA_CINEMATIC; + } + + Con_Close(); + + if (!cinTable[currentHandle].silent) { + s_rawend[0] = s_soundtime; + } + + return currentHandle; + } + Com_DPrintf("trFMV::play(), invalid RoQ ID\n"); + + RoQShutdown(); + return -1; +} + +void CIN_SetExtents (int handle, int x, int y, int w, int h) { + if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return; + cinTable[handle].xpos = x; + cinTable[handle].ypos = y; + cinTable[handle].width = w; + cinTable[handle].height = h; + cinTable[handle].dirty = qtrue; +} + +void CIN_SetLooping(int handle, qboolean loop) { + if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return; + cinTable[handle].looping = loop; +} + +/* +================== +CIN_ResampleCinematic + +Resample cinematic to 256x256 and store in buf2 +================== +*/ +void CIN_ResampleCinematic(int handle, int *buf2) { + int ix, iy, *buf3, xm, ym, ll; + byte *buf; + + buf = cinTable[handle].buf; + + xm = cinTable[handle].CIN_WIDTH/256; + ym = cinTable[handle].CIN_HEIGHT/256; + ll = 8; + if (cinTable[handle].CIN_WIDTH==512) { + ll = 9; + } + + buf3 = (int*)buf; + if (xm==2 && ym==2) { + byte *bc2, *bc3; + int ic, iiy; + + bc2 = (byte *)buf2; + bc3 = (byte *)buf3; + for (iy = 0; iy<256; iy++) { + iiy = iy<<12; + for (ix = 0; ix<2048; ix+=8) { + for(ic = ix;ic<(ix+4);ic++) { + *bc2=(bc3[iiy+ic]+bc3[iiy+4+ic]+bc3[iiy+2048+ic]+bc3[iiy+2048+4+ic])>>2; + bc2++; + } + } + } + } else if (xm==2 && ym==1) { + byte *bc2, *bc3; + int ic, iiy; + + bc2 = (byte *)buf2; + bc3 = (byte *)buf3; + for (iy = 0; iy<256; iy++) { + iiy = iy<<11; + for (ix = 0; ix<2048; ix+=8) { + for(ic = ix;ic<(ix+4);ic++) { + *bc2=(bc3[iiy+ic]+bc3[iiy+4+ic])>>1; + bc2++; + } + } + } + } else { + for (iy = 0; iy<256; iy++) { + for (ix = 0; ix<256; ix++) { + buf2[(iy<<8)+ix] = buf3[((iy*ym)<= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return; + + if (!cinTable[handle].buf) { + return; + } + + x = cinTable[handle].xpos; + y = cinTable[handle].ypos; + w = cinTable[handle].width; + h = cinTable[handle].height; + buf = cinTable[handle].buf; + SCR_AdjustFrom640( &x, &y, &w, &h ); + + if (cinTable[handle].dirty && (cinTable[handle].CIN_WIDTH != cinTable[handle].drawX || cinTable[handle].CIN_HEIGHT != cinTable[handle].drawY)) { + int *buf2; + + buf2 = ( int * )Hunk_AllocateTempMemory( 256*256*4 ); + + CIN_ResampleCinematic(handle, buf2); + + re.DrawStretchRaw( x, y, w, h, 256, 256, 0, (byte *)buf2); + cinTable[handle].dirty = qfalse; + Hunk_FreeTempMemory(buf2); + return; + } + + re.DrawStretchRaw( x, y, w, h, cinTable[handle].drawX, cinTable[handle].drawY, 0, buf); + cinTable[handle].dirty = qfalse; +} + +void CL_PlayCinematic_f(void) { + char *arg, *s; + int bits = CIN_system; + + Com_DPrintf("CL_PlayCinematic_f\n"); + if (cls.state == CA_CINEMATIC) { + SCR_StopCinematic(); + } + + arg = Cmd_Argv( 1 ); + s = Cmd_Argv(2); + + if ((s && s[0] == '1') || Q_stricmp(arg,"demoend.roq")==0 || Q_stricmp(arg,"end.roq")==0) { + bits |= CIN_hold; + } + if (s && s[0] == '2') { + bits |= CIN_loop; + } + + S_StopAllSounds( qtrue ); + + CL_handle = CIN_PlayCinematic( arg, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, bits ); + if (CL_handle >= 0) { + do { + SCR_RunCinematic(); + } while (cinTable[currentHandle].buf == NULL && cinTable[currentHandle].status == FMV_PLAY); // wait for first frame (load codebook and sound) + } +} + + +void SCR_DrawCinematic (void) { + if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) { + CIN_DrawCinematic(CL_handle); + } +} + +void SCR_RunCinematic (void) +{ + if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) { + CIN_RunCinematic(CL_handle); + } +} + +void SCR_StopCinematic(void) { + if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) { + CIN_StopCinematic(CL_handle); + S_StopAllSounds( qtrue ); + CL_handle = -1; + } +} + +void CIN_UploadCinematic(int handle) { + if (handle >= 0 && handle < MAX_VIDEO_HANDLES) { + if (!cinTable[handle].buf) { + return; + } + if (cinTable[handle].playonwalls <= 0 && cinTable[handle].dirty) { + if (cinTable[handle].playonwalls == 0) { + cinTable[handle].playonwalls = -1; + } else { + if (cinTable[handle].playonwalls == -1) { + cinTable[handle].playonwalls = -2; + } else { + cinTable[handle].dirty = qfalse; + } + } + } + + // Resample the video if needed + if (cinTable[handle].dirty && (cinTable[handle].CIN_WIDTH != cinTable[handle].drawX || cinTable[handle].CIN_HEIGHT != cinTable[handle].drawY)) { + int *buf2; + + buf2 = ( int * )Hunk_AllocateTempMemory( 256*256*4 ); + + CIN_ResampleCinematic(handle, buf2); + + re.UploadCinematic( cinTable[handle].CIN_WIDTH, cinTable[handle].CIN_HEIGHT, 256, 256, (byte *)buf2, handle, qtrue); + cinTable[handle].dirty = qfalse; + Hunk_FreeTempMemory(buf2); + } else { + // Upload video at normal resolution + re.UploadCinematic( cinTable[handle].CIN_WIDTH, cinTable[handle].CIN_HEIGHT, cinTable[handle].drawX, cinTable[handle].drawY, + cinTable[handle].buf, handle, cinTable[handle].dirty); + cinTable[handle].dirty = qfalse; + } + + if (cl_inGameVideo->integer == 0 && cinTable[handle].playonwalls == 1) { + cinTable[handle].playonwalls--; + } + else if (cl_inGameVideo->integer != 0 && cinTable[handle].playonwalls != 1) { + cinTable[handle].playonwalls = 1; + } + } +} + diff --git a/code/client/cl_console.cpp b/code/client/cl_console.cpp new file mode 100644 index 00000000..be1c5ff6 --- /dev/null +++ b/code/client/cl_console.cpp @@ -0,0 +1,789 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// console.c + +#include "client.h" + + +int g_console_field_width = 78; +int g_console_charWidth = SMALLCHAR_WIDTH, g_console_charHeight = SMALLCHAR_HEIGHT; + +#define NUM_CON_TIMES 4 + +#define CON_TEXTSIZE 32768 +typedef struct { + qboolean initialized; + + short text[CON_TEXTSIZE]; + int current; // line where next message will be printed + int x; // offset in current line for next print + int display; // bottom of console displays this line + + int linewidth; // characters across screen + int totallines; // total lines in console scrollback + + float xadjust; // for wide aspect screens + + float displayFrac; // aproaches finalFrac at scr_conspeed + float finalFrac; // 0.0 to 1.0 lines of console to display + + int vislines; // in scanlines + + int times[NUM_CON_TIMES]; // cls.realtime time the line was generated + // for transparent notify lines + vec4_t color; +} console_t; + +extern console_t con; + +console_t con; + +cvar_t *con_conspeed; +cvar_t *con_notifytime; +cvar_t *con_drawnotify; + +#define DEFAULT_CONSOLE_WIDTH 78 + +vec4_t console_color = {1.0, 1.0, 1.0, 1.0}; + + +/* +================ +Con_ToggleConsole_f +================ +*/ +void Con_ToggleConsole_f (void) { + // Can't toggle the console when it's the only thing available + if ( cls.state == CA_DISCONNECTED && Key_GetCatcher( ) == KEYCATCH_CONSOLE ) { + return; + } + + Field_Clear( &g_consoleField ); + g_consoleField.widthInChars = g_console_field_width; + + Con_ClearNotify (); + Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_CONSOLE ); +} + +/* +================ +Con_MessageMode_f +================ +*/ +void Con_MessageMode_f (void) { + chat_playerNum = -1; + chat_team = qfalse; + Field_Clear( &chatField ); + chatField.widthInChars = 30; + + Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); +} + +/* +================ +Con_MessageMode2_f +================ +*/ +void Con_MessageMode2_f (void) { + chat_playerNum = -1; + chat_team = qtrue; + Field_Clear( &chatField ); + chatField.widthInChars = 25; + Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); +} + +/* +================ +Con_MessageMode3_f +================ +*/ +void Con_MessageMode3_f (void) { + chat_team = qfalse; + Field_Clear( &chatField ); + chatField.widthInChars = 30; + Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); +} + +/* +================ +Con_MessageMode4_f +================ +*/ +void Con_MessageMode4_f (void) { + chat_team = qfalse; + Field_Clear( &chatField ); + chatField.widthInChars = 30; + Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); +} + +/* +================ +Con_Clear_f +================ +*/ +void Con_Clear_f (void) { + int i; + + for ( i = 0 ; i < CON_TEXTSIZE ; i++ ) { + con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' '; + } + + Con_Bottom(); // go to end +} + + +/* +================ +Con_Dump_f + +Save the console contents out to a file +================ +*/ +void Con_Dump_f (void) +{ + int l, x, i; + short *line; + fileHandle_t f; + char buffer[1024]; + + if (Cmd_Argc() != 2) + { + Com_Printf ("usage: condump \n"); + return; + } + + Com_Printf ("Dumped console text to %s.\n", Cmd_Argv(1) ); + + f = FS_FOpenFileWrite( Cmd_Argv( 1 ) ); + if (!f) + { + Com_Printf ("ERROR: couldn't open.\n"); + return; + } + + // skip empty lines + for (l = con.current - con.totallines + 1 ; l <= con.current ; l++) + { + line = con.text + (l%con.totallines)*con.linewidth; + for (x=0 ; x=0 ; x--) + { + if (buffer[x] == ' ') + buffer[x] = 0; + else + break; + } + strcat( buffer, "\n" ); + FS_Write(buffer, strlen(buffer), f); + } + + FS_FCloseFile( f ); +} + + +/* +================ +Con_ClearNotify +================ +*/ +void Con_ClearNotify( void ) { + int i; + + for ( i = 0 ; i < NUM_CON_TIMES ; i++ ) { + con.times[i] = 0; + } +} + + + +/* +================ +Con_CheckResize + +If the line width has changed, reformat the buffer. +================ +*/ +void Con_CheckResize (void) +{ + int i, j, width, oldwidth, oldtotallines, numlines, numchars; + short tbuf[CON_TEXTSIZE]; + + width = (SCREEN_WIDTH / g_console_charWidth) - 2; + + if (width == con.linewidth) + return; + + if (width < 1) // video hasn't been initialized yet + { + width = DEFAULT_CONSOLE_WIDTH; + con.linewidth = width; + con.totallines = CON_TEXTSIZE / con.linewidth; + for(i=0; i= 0) + { + if (skipnotify) + con.times[con.current % NUM_CON_TIMES] = 0; + else + con.times[con.current % NUM_CON_TIMES] = cls.realtime; + } + + con.x = 0; + if (con.display == con.current) + con.display++; + con.current++; + for(i=0; iinteger ) { + return; + } + + if (!con.initialized) { + con.color[0] = + con.color[1] = + con.color[2] = + con.color[3] = 1.0f; + con.linewidth = -1; + Con_CheckResize (); + con.initialized = qtrue; + } + + color = ColorIndex(COLOR_WHITE); + + while ( (c = *txt) != 0 ) { + if ( Q_IsColorString( txt ) ) { + color = ColorIndex( *(txt+1) ); + txt += 2; + continue; + } + + // count word length + for (l=0 ; l< con.linewidth ; l++) { + if ( txt[l] <= ' ') { + break; + } + + } + + // word wrap + if (l != con.linewidth && (con.x + l >= con.linewidth) ) { + Con_Linefeed(skipnotify); + + } + + txt++; + + switch (c) + { + case '\n': + Con_Linefeed (skipnotify); + break; + case '\r': + con.x = 0; + break; + default: // display character and advance + y = con.current % con.totallines; + con.text[y*con.linewidth+con.x] = (color << 8) | c; + con.x++; + if (con.x >= con.linewidth) { + Con_Linefeed(skipnotify); + con.x = 0; + } + break; + } + } + + + // mark time for transparent overlay + if (con.current >= 0) { + // NERVE - SMF + if ( skipnotify ) { + prev = con.current % NUM_CON_TIMES - 1; + if ( prev < 0 ) + prev = NUM_CON_TIMES - 1; + con.times[prev] = 0; + } + else + // -NERVE - SMF + con.times[con.current % NUM_CON_TIMES] = cls.realtime; + } +} + + +/* +============================================================================== + +DRAWING + +============================================================================== +*/ + + +/* +================ +Con_DrawInput + +Draw the editline after a ] prompt +================ +*/ +void Con_DrawInput (void) { + int y; + + if ( cls.state != CA_DISCONNECTED && !(Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) { + return; + } + + y = con.vislines - ( g_console_charHeight * 2 ); + + re.SetColor( con.color ); + + re.Text_PaintChar(&cls.consoleFont, con.xadjust + 1 * g_console_charWidth, y, 1.f, ']', 0); + + Field_Draw(&cls.consoleFont, &g_consoleField, con.xadjust + 2 * g_console_charWidth, y, + SCREEN_WIDTH - 3 * g_console_charWidth, qtrue, qtrue); +} + + +/* +================ +Con_DrawNotify + +Draws the last few lines of output transparently over the game top +================ +*/ +void Con_DrawNotify (void) +{ + int x, v; + short *text; + int i; + int time; + int skip; + int currentColor; + + currentColor = 7; + re.SetColor( g_color_table[currentColor] ); + + v = 0; + for (i= con.current-NUM_CON_TIMES+1 ; i<=con.current ; i++) + { + if (i < 0) + continue; + time = con.times[i % NUM_CON_TIMES]; + if (time == 0) + continue; + time = cls.realtime - time; + if (time > con_notifytime->value*1000) + continue; + text = con.text + (i % con.totallines)*con.linewidth; + + if (Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME) ) { + continue; + } + + for (x = 0 ; x < con.linewidth ; x++) { + if ( ( text[x] & 0xff ) == ' ' ) { + continue; + } + if ( ( (text[x]>>8)&7 ) != currentColor ) { + currentColor = (text[x]>>8)&7; + re.SetColor( g_color_table[currentColor] ); + } + re.Text_PaintChar(&cls.consoleFont, cl_conXOffset->integer + con.xadjust + (x+1)*g_console_charWidth, v, 1.f, text[x] & 0xff,0); + } + + v += g_console_charHeight; + } + + re.SetColor( NULL ); + + if (Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME) ) { + return; + } + + // draw the chat line + if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE ) + { + if (chat_team) + { + //SCR_DrawBigString (8, v, "say_team:", 1.0f, qfalse ); + re.Text_Paint(&cls.consoleFont, 8, v, 1.f, 1.f, "say_team:", 0, 0, qtrue,qfalse); + skip = 10; + } + else + { + //SCR_DrawBigString (8, v, "say:", 1.0f, qfalse ); + re.Text_Paint(&cls.consoleFont, 8, v, 1.f, 1.f, "say:", 0, 0, qtrue,qfalse); + skip = 5; + } + + // TODO: make this use facfont? + Field_BigDraw(&cls.consoleFont, &chatField, skip * g_console_charWidth, v, + SCREEN_WIDTH - ( skip + 1 ) * g_console_charWidth, qtrue, qtrue ); + + v += g_console_charHeight; + } + +} + +/* +================ +Con_DrawSolidConsole + +Draws the console with the solid background +================ +*/ +void Con_DrawSolidConsole( float frac ) { + int i, x, y; + int rows; + short *text; + int row; + int lines; +// qhandle_t conShader; + int currentColor; + vec4_t color; + + lines = cls.glconfig.vidHeight * frac; + if (lines <= 0) + return; + + if (lines > cls.glconfig.vidHeight ) + lines = cls.glconfig.vidHeight; + + // on wide screens, we will center the text + con.xadjust = 0; + SCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL ); + + // draw the background + y = frac * SCREEN_HEIGHT - 2; + if ( y < 1 ) { + y = 0; + } + else { + //SCR_DrawPic( 0, 0, SCREEN_WIDTH, y, cls.consoleShader ); + // IneQuation: transparent MoHAA-style console + color[0] = 0.1125f; + color[1] = 0.15f; + color[2] = 0.21f; + color[3] = 0.85f; + SCR_FillRect(0, 0, SCREEN_WIDTH, y, color); + } + + color[0] = 0.7f; + color[1] = 0.6f; + color[2] = 0.05f; + color[3] = 1; + SCR_FillRect( 0, y, SCREEN_WIDTH, 2, color ); + + + // draw the version number + + /*color[0] = 0.7; + color[1] = 0.6; + color[2] = 0.05; + color[3] = 1;*/ + re.SetColor( color/*g_color_table[ColorIndex(COLOR_RED)]*/ ); + + i = strlen( Q3_VERSION ); + + for (x=0 ; x= con.totallines) { + // past scrollback wrap point + continue; + } + + text = con.text + (row % con.totallines)*con.linewidth; + + for (x=0 ; x>8)&7 ) != currentColor ) { + currentColor = (text[x]>>8)&7; + re.SetColor(g_color_table[currentColor]); + } + re.Text_PaintChar(&cls.consoleFont, con.xadjust + (x+1)*g_console_charWidth, y, 1.f, text[x] & 0xff,0); + } + } + + // draw the input prompt, user text, and cursor if desired + Con_DrawInput (); + + re.SetColor( NULL ); +} + + + +/* +================== +Con_DrawConsole +================== +*/ +void Con_DrawConsole( void ) { + // check for console width changes from a vid mode change + Con_CheckResize (); + + // if disconnected, render console full screen + if ( cls.state == CA_DISCONNECTED ) { + if ( !( Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME)) ) { + Con_DrawSolidConsole( 1.0 ); + return; + } + } + + if ( con.displayFrac ) { + Con_DrawSolidConsole( con.displayFrac ); + } else { + // draw notify lines + if ( cls.state == CA_ACTIVE && con_drawnotify->integer ) { + Con_DrawNotify (); + } + } +} + +//================================================================ + +/* +================== +Con_RunConsole + +Scroll it up or down +================== +*/ +void Con_RunConsole (void) { + // decide on the destination height of the console + if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) + con.finalFrac = 0.5; // half screen + else + con.finalFrac = 0; // none visible + + // scroll towards the destination height + if (con.finalFrac < con.displayFrac) + { + con.displayFrac -= con_conspeed->value*cls.realFrametime*0.001; + if (con.finalFrac > con.displayFrac) + con.displayFrac = con.finalFrac; + + } + else if (con.finalFrac > con.displayFrac) + { + con.displayFrac += con_conspeed->value*cls.realFrametime*0.001; + if (con.finalFrac < con.displayFrac) + con.displayFrac = con.finalFrac; + } + +} + + +void Con_PageUp( void ) { + con.display -= 2; + if ( con.current - con.display >= con.totallines ) { + con.display = con.current - con.totallines + 1; + } +} + +void Con_PageDown( void ) { + con.display += 2; + if (con.display > con.current) { + con.display = con.current; + } +} + +void Con_Top( void ) { + con.display = con.totallines; + if ( con.current - con.display >= con.totallines ) { + con.display = con.current - con.totallines + 1; + } +} + +void Con_Bottom( void ) { + con.display = con.current; +} + + +void Con_Close( void ) { + if ( !com_cl_running->integer ) { + return; + } + Field_Clear( &g_consoleField ); + Con_ClearNotify (); + Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CONSOLE ); + con.finalFrac = 0; // none visible + con.displayFrac = 0; +} diff --git a/code/client/cl_consolecmds.cpp b/code/client/cl_consolecmds.cpp new file mode 100644 index 00000000..2e39f3b4 --- /dev/null +++ b/code/client/cl_consolecmds.cpp @@ -0,0 +1,173 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// cl_consolecmds.cpp : New client console commands. + +#include "client.h" +#include "glb_local.h" + +/* +=============== +CL_EventList_f +=============== +*/ +void CL_EventList_f( void ) +{ + const char *mask = NULL; + + if( Cmd_Argc() > 1 ) { + mask = Cmd_Argv( 1 ); + } + + Event::ListCommands( mask ); +} + +/* +=============== +CL_EventHelp_f +=============== +*/ +void CL_EventHelp_f( void ) +{ + const char *mask = NULL; + + if( Cmd_Argc() > 1 ) { + mask = Cmd_Argv( 1 ); + } + + Event::ListDocumentation( mask, qfalse ); +} + +/* +=============== +CL_DumpEventHelp_f +=============== +*/ +void CL_DumpEventHelp_f( void ) +{ + const char *mask = NULL; + + if( Cmd_Argc() > 1 ) { + mask = Cmd_Argv( 1 ); + } + + Event::ListDocumentation( mask, qtrue ); +} + +/* +=============== +CL_PendingEvents_f +=============== +*/ +void CL_PendingEvents_f( void ) +{ + const char *mask = NULL; + + if( Cmd_Argc() > 1 ) { + mask = Cmd_Argv( 1 ); + } + + Event::PendingEvents( mask ); +} + +/* +=============== +CL_ClassList_f +=============== +*/ +void CL_ClassList_f( void ) +{ + listAllClasses(); +} + +/* +=============== +CL_ClassTree_f +=============== +*/ +void CL_ClassTree_f( void ) +{ + if( Cmd_Argc() < 2 ) { + Com_Printf( "Syntax: cl_classtree [classname].\n" ); + return; + } + + listInheritanceOrder( Cmd_Argv( 1 ) ); +} + +/* +=============== +CL_ClassEvents_f +=============== +*/ +void CL_ClassEvents_f( void ) +{ + if( Cmd_Argc() < 2 ) { + Com_Printf( "Syntax: cl_classevents [classname].\n" ); + return; + } + + ClassEvents( Cmd_Argv( 1 ), qfalse ); +} + +/* +=============== +CL_DumpClassEvents_f +=============== +*/ +void CL_DumpClassEvents_f( void ) +{ + if( Cmd_Argc() < 2 ) { + Com_Printf( "Syntax: cl_dumpclassevents [classname].\n" ); + return; + } + + ClassEvents( Cmd_Argv( 1 ), qtrue ); +} + +/* +=============== +CL_DumpAllClasses_f +=============== +*/ +void CL_DumpAllClasses_f( void ) +{ + DumpAllClasses(); +} + +/* +=============== +CL_InitConsoleCommands +=============== +*/ +void CL_InitConsoleCommands( void ) +{ + Cmd_AddCommand( "cl_eventlist", CL_EventList_f ); + Cmd_AddCommand( "cl_eventhelp", CL_EventHelp_f ); + Cmd_AddCommand( "cl_dumpevents", CL_DumpEventHelp_f ); + Cmd_AddCommand( "cl_pendingevents", CL_PendingEvents_f ); + Cmd_AddCommand( "cl_classlist", CL_ClassList_f ); + Cmd_AddCommand( "cl_classtree", CL_ClassTree_f ); + Cmd_AddCommand( "cl_classevents", CL_ClassEvents_f ); + Cmd_AddCommand( "cl_dumpclassevents", CL_DumpClassEvents_f ); + Cmd_AddCommand( "cl_dumpallclasses", CL_DumpAllClasses_f ); +} diff --git a/code/client/cl_curl.cpp b/code/client/cl_curl.cpp new file mode 100644 index 00000000..4d933053 --- /dev/null +++ b/code/client/cl_curl.cpp @@ -0,0 +1,330 @@ +/* +=========================================================================== +Copyright (C) 2006 Tony J. White (tjw@tjw.org) + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifdef USE_CURL +#include "client.h" +cvar_t *cl_cURLLib; + +#ifdef USE_CURL_DLOPEN +#include "../sys/sys_loadlib.h" + +char* (*qcurl_version)(void); + +CURL* (*qcurl_easy_init)(void); +CURLcode (*qcurl_easy_setopt)(CURL *curl, CURLoption option, ...); +CURLcode (*qcurl_easy_perform)(CURL *curl); +void (*qcurl_easy_cleanup)(CURL *curl); +CURLcode (*qcurl_easy_getinfo)(CURL *curl, CURLINFO info, ...); +CURL* (*qcurl_easy_duphandle)(CURL *curl); +void (*qcurl_easy_reset)(CURL *curl); +const char *(*qcurl_easy_strerror)(CURLcode); + +CURLM* (*qcurl_multi_init)(void); +CURLMcode (*qcurl_multi_add_handle)(CURLM *multi_handle, + CURL *curl_handle); +CURLMcode (*qcurl_multi_remove_handle)(CURLM *multi_handle, + CURL *curl_handle); +CURLMcode (*qcurl_multi_fdset)(CURLM *multi_handle, + fd_set *read_fd_set, + fd_set *write_fd_set, + fd_set *exc_fd_set, + int *max_fd); +CURLMcode (*qcurl_multi_perform)(CURLM *multi_handle, + int *running_handles); +CURLMcode (*qcurl_multi_cleanup)(CURLM *multi_handle); +CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle, + int *msgs_in_queue); +const char *(*qcurl_multi_strerror)(CURLMcode); + +static void *cURLLib = NULL; + +/* +================= +GPA +================= +*/ +static void *GPA(char *str) +{ + void *rv; + + rv = Sys_LoadFunction(cURLLib, str); + if(!rv) + { + Com_Printf("Can't load symbol %s\n", str); + clc.cURLEnabled = qfalse; + return NULL; + } + else + { + Com_DPrintf("Loaded symbol %s (0x%p)\n", str, rv); + return rv; + } +} +#endif /* USE_CURL_DLOPEN */ + +/* +================= +CL_cURL_Init +================= +*/ +qboolean CL_cURL_Init() +{ +#ifdef USE_CURL_DLOPEN + if(cURLLib) + return qtrue; + + + Com_Printf("Loading \"%s\"...", cl_cURLLib->string); + if( (cURLLib = Sys_LoadLibrary(cl_cURLLib->string)) == 0 ) + { +#ifdef _WIN32 + return qfalse; +#else + char fn[1024]; + Q_strncpyz( fn, Sys_Cwd( ), sizeof( fn ) ); + strncat(fn, "/", sizeof(fn)-strlen(fn)-1); + strncat(fn, cl_cURLLib->string, sizeof(fn)-strlen(fn)-1); + + if( (cURLLib = Sys_LoadLibrary(fn)) == 0 ) + { + return qfalse; + } +#endif /* _WIN32 */ + } + + clc.cURLEnabled = qtrue; + + qcurl_version = GPA("curl_version"); + + qcurl_easy_init = GPA("curl_easy_init"); + qcurl_easy_setopt = GPA("curl_easy_setopt"); + qcurl_easy_perform = GPA("curl_easy_perform"); + qcurl_easy_cleanup = GPA("curl_easy_cleanup"); + qcurl_easy_getinfo = GPA("curl_easy_getinfo"); + qcurl_easy_duphandle = GPA("curl_easy_duphandle"); + qcurl_easy_reset = GPA("curl_easy_reset"); + qcurl_easy_strerror = GPA("curl_easy_strerror"); + + qcurl_multi_init = GPA("curl_multi_init"); + qcurl_multi_add_handle = GPA("curl_multi_add_handle"); + qcurl_multi_remove_handle = GPA("curl_multi_remove_handle"); + qcurl_multi_fdset = GPA("curl_multi_fdset"); + qcurl_multi_perform = GPA("curl_multi_perform"); + qcurl_multi_cleanup = GPA("curl_multi_cleanup"); + qcurl_multi_info_read = GPA("curl_multi_info_read"); + qcurl_multi_strerror = GPA("curl_multi_strerror"); + + if(!clc.cURLEnabled) + { + CL_cURL_Shutdown(); + Com_Printf("FAIL One or more symbols not found\n"); + return qfalse; + } + Com_Printf("OK\n"); + + return qtrue; +#else + clc.cURLEnabled = qtrue; + return qtrue; +#endif /* USE_CURL_DLOPEN */ +} + +/* +================= +CL_cURL_Shutdown +================= +*/ +void CL_cURL_Shutdown( void ) +{ + CL_cURL_Cleanup(); +#ifdef USE_CURL_DLOPEN + if(cURLLib) + { + Sys_UnloadLibrary(cURLLib); + cURLLib = NULL; + } + qcurl_easy_init = NULL; + qcurl_easy_setopt = NULL; + qcurl_easy_perform = NULL; + qcurl_easy_cleanup = NULL; + qcurl_easy_getinfo = NULL; + qcurl_easy_duphandle = NULL; + qcurl_easy_reset = NULL; + + qcurl_multi_init = NULL; + qcurl_multi_add_handle = NULL; + qcurl_multi_remove_handle = NULL; + qcurl_multi_fdset = NULL; + qcurl_multi_perform = NULL; + qcurl_multi_cleanup = NULL; + qcurl_multi_info_read = NULL; + qcurl_multi_strerror = NULL; +#endif /* USE_CURL_DLOPEN */ +} + +void CL_cURL_Cleanup(void) +{ + if(clc.downloadCURLM) { + if(clc.downloadCURL) { + qcurl_multi_remove_handle(clc.downloadCURLM, + clc.downloadCURL); + qcurl_easy_cleanup(clc.downloadCURL); + } + qcurl_multi_cleanup(clc.downloadCURLM); + clc.downloadCURLM = NULL; + clc.downloadCURL = NULL; + } + else if(clc.downloadCURL) { + qcurl_easy_cleanup(clc.downloadCURL); + clc.downloadCURL = NULL; + } +} + +static int CL_cURL_CallbackProgress( void *dummy, double dltotal, double dlnow, + double ultotal, double ulnow ) +{ + clc.downloadSize = (int)dltotal; + Cvar_SetValue( "cl_downloadSize", clc.downloadSize ); + clc.downloadCount = (int)dlnow; + Cvar_SetValue( "cl_downloadCount", clc.downloadCount ); + return 0; +} + +static int CL_cURL_CallbackWrite(void *buffer, size_t size, size_t nmemb, + void *stream) +{ + FS_Write( buffer, size*nmemb, ((fileHandle_t*)stream)[0] ); + return size*nmemb; +} + +void CL_cURL_BeginDownload( const char *localName, const char *remoteURL ) +{ + clc.cURLUsed = qtrue; + Com_Printf("URL: %s\n", remoteURL); + Com_DPrintf("***** CL_cURL_BeginDownload *****\n" + "Localname: %s\n" + "RemoteURL: %s\n" + "****************************\n", localName, remoteURL); + CL_cURL_Cleanup(); + Q_strncpyz(clc.downloadURL, remoteURL, sizeof(clc.downloadURL)); + Q_strncpyz(clc.downloadName, localName, sizeof(clc.downloadName)); + Com_sprintf(clc.downloadTempName, sizeof(clc.downloadTempName), + "%s.tmp", localName); + + // Set so UI gets access to it + Cvar_Set("cl_downloadName", localName); + Cvar_Set("cl_downloadSize", "0"); + Cvar_Set("cl_downloadCount", "0"); + Cvar_SetValue("cl_downloadTime", cls.realtime); + + clc.downloadBlock = 0; // Starting new file + clc.downloadCount = 0; + + clc.downloadCURL = qcurl_easy_init(); + if(!clc.downloadCURL) { + Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_easy_init() " + "failed\n"); + return; + } + clc.download = FS_SV_FOpenFileWrite(clc.downloadTempName); + if(!clc.download) { + Com_Error(ERR_DROP, "CL_cURL_BeginDownload: failed to open " + "%s for writing\n", clc.downloadTempName); + return; + } + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEDATA, clc.download); + if(developer->integer) + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_VERBOSE, 1); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_URL, clc.downloadURL); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_TRANSFERTEXT, 0); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_REFERER, va("ioQ3://%s", + NET_AdrToString(clc.serverAddress))); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_USERAGENT, va("%s %s", + Q3_VERSION, qcurl_version())); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEFUNCTION, + CL_cURL_CallbackWrite); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEDATA, &clc.download); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_NOPROGRESS, 0); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_PROGRESSFUNCTION, + CL_cURL_CallbackProgress); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_PROGRESSDATA, NULL); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_FAILONERROR, 1); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_FOLLOWLOCATION, 1); + qcurl_easy_setopt(clc.downloadCURL, CURLOPT_MAXREDIRS, 5); + clc.downloadCURLM = qcurl_multi_init(); + if(!clc.downloadCURLM) { + qcurl_easy_cleanup(clc.downloadCURL); + clc.downloadCURL = NULL; + Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_multi_init() " + "failed\n"); + return; + } + qcurl_multi_add_handle(clc.downloadCURLM, clc.downloadCURL); + + if(!(clc.sv_allowDownload & DLF_NO_DISCONNECT) && + !clc.cURLDisconnected) { + + CL_AddReliableCommand("disconnect"); + CL_WritePacket(); + CL_WritePacket(); + CL_WritePacket(); + clc.cURLDisconnected = qtrue; + } +} + +void CL_cURL_PerformDownload(void) +{ + CURLMcode res; + CURLMsg *msg; + int c; + int i = 0; + + res = qcurl_multi_perform(clc.downloadCURLM, &c); + while(res == CURLM_CALL_MULTI_PERFORM && i < 100) { + res = qcurl_multi_perform(clc.downloadCURLM, &c); + i++; + } + if(res == CURLM_CALL_MULTI_PERFORM) + return; + msg = qcurl_multi_info_read(clc.downloadCURLM, &c); + if(msg == NULL) { + return; + } + FS_FCloseFile(clc.download); + if(msg->msg == CURLMSG_DONE && msg->data.result == CURLE_OK) { + FS_SV_Rename(clc.downloadTempName, clc.downloadName); + clc.downloadRestart = qtrue; + } + else { + long code; + + qcurl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, + &code); + Com_Error(ERR_DROP, "Download Error: %s Code: %ld URL: %s", + qcurl_easy_strerror(msg->data.result), + code, clc.downloadURL); + } + *clc.downloadTempName = *clc.downloadName = 0; + Cvar_Set( "cl_downloadName", "" ); + CL_NextDownload(); +} +#endif /* USE_CURL */ diff --git a/code/client/cl_curl.h b/code/client/cl_curl.h new file mode 100644 index 00000000..1cfd3f1e --- /dev/null +++ b/code/client/cl_curl.h @@ -0,0 +1,101 @@ +/* +=========================================================================== +Copyright (C) 2006 Tony J. White (tjw@tjw.org) + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + + +#ifndef __QCURL_H__ +#define __QCURL_H__ + +extern cvar_t *cl_cURLLib; + +#include "../qcommon/q_shared.h" +#include "../qcommon/qcommon.h" + +#ifdef WIN32 +#define DEFAULT_CURL_LIB "libcurl-3.dll" +#elif defined(MACOS_X) +#define DEFAULT_CURL_LIB "libcurl.dylib" +#else +#define DEFAULT_CURL_LIB "libcurl.so.3" +#endif + +#ifdef USE_LOCAL_HEADERS + #include "../libcurl/curl/curl.h" +#else + #include +#endif + + +#ifdef USE_CURL_DLOPEN +extern char* (*qcurl_version)(void); + +extern CURL* (*qcurl_easy_init)(void); +extern CURLcode (*qcurl_easy_setopt)(CURL *curl, CURLoption option, ...); +extern CURLcode (*qcurl_easy_perform)(CURL *curl); +extern void (*qcurl_easy_cleanup)(CURL *curl); +extern CURLcode (*qcurl_easy_getinfo)(CURL *curl, CURLINFO info, ...); +extern void (*qcurl_easy_reset)(CURL *curl); +extern const char *(*qcurl_easy_strerror)(CURLcode); + +extern CURLM* (*qcurl_multi_init)(void); +extern CURLMcode (*qcurl_multi_add_handle)(CURLM *multi_handle, + CURL *curl_handle); +extern CURLMcode (*qcurl_multi_remove_handle)(CURLM *multi_handle, + CURL *curl_handle); +extern CURLMcode (*qcurl_multi_fdset)(CURLM *multi_handle, + fd_set *read_fd_set, + fd_set *write_fd_set, + fd_set *exc_fd_set, + int *max_fd); +extern CURLMcode (*qcurl_multi_perform)(CURLM *multi_handle, + int *running_handles); +extern CURLMcode (*qcurl_multi_cleanup)(CURLM *multi_handle); +extern CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle, + int *msgs_in_queue); +extern const char *(*qcurl_multi_strerror)(CURLMcode); +#else +#define qcurl_version curl_version + +#define qcurl_easy_init curl_easy_init +#define qcurl_easy_setopt curl_easy_setopt +#define qcurl_easy_perform curl_easy_perform +#define qcurl_easy_cleanup curl_easy_cleanup +#define qcurl_easy_getinfo curl_easy_getinfo +#define qcurl_easy_duphandle curl_easy_duphandle +#define qcurl_easy_reset curl_easy_reset +#define qcurl_easy_strerror curl_easy_strerror + +#define qcurl_multi_init curl_multi_init +#define qcurl_multi_add_handle curl_multi_add_handle +#define qcurl_multi_remove_handle curl_multi_remove_handle +#define qcurl_multi_fdset curl_multi_fdset +#define qcurl_multi_perform curl_multi_perform +#define qcurl_multi_cleanup curl_multi_cleanup +#define qcurl_multi_info_read curl_multi_info_read +#define qcurl_multi_strerror curl_multi_strerror +#endif + +qboolean CL_cURL_Init( void ); +void CL_cURL_Shutdown( void ); +void CL_cURL_BeginDownload( const char *localName, const char *remoteURL ); +void CL_cURL_PerformDownload( void ); +void CL_cURL_Cleanup( void ); +#endif // __QCURL_H__ diff --git a/code/client/cl_input.cpp b/code/client/cl_input.cpp new file mode 100644 index 00000000..b641f849 --- /dev/null +++ b/code/client/cl_input.cpp @@ -0,0 +1,1019 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// cl.input.c -- builds an intended movement command to send to the server + +#include "client.h" +#include "cl_ui.h" + +unsigned frame_msec; +int old_com_frameTime; + +/* +=============================================================================== + +KEY BUTTONS + +Continuous button event tracking is complicated by the fact that two different +input sources (say, mouse button 1 and the control key) can both press the +same button, but the button should only be released when both of the +pressing key have been released. + +When a key event issues a button command (+forward, +attackprimary, etc), it appends +its key number as argv(1) so it can be matched up with the release. + +argv(2) will be set to the time the event happened, which allows exact +control even at low framerates when the down and up events may both get qued +at the same time. + +=============================================================================== +*/ + + +kbutton_t in_left, in_right, in_forward, in_back; +kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright; +kbutton_t in_strafe, in_speed; + +qboolean in_guimouse; + +kbutton_t in_up, in_down; + +kbutton_t in_buttons[16]; + +qboolean in_mlooking; + +void IN_ToggleMouse( void ) { + if( in_guimouse ) + { + IN_MouseOff(); + } + else + { + IN_MouseOn(); + } +} + +void IN_MouseOn( void ) { + if( !in_guimouse ) + { + for( int k = 0; k <= K_MWHEELUP; k++ ) + { + if( keys[ k ].down ) + { + CL_KeyEvent( k, qfalse, 0 ); + } + } + } + + in_guimouse = qtrue; +} + +void IN_MouseOff( void ) { + in_guimouse = qfalse; +} + +void IN_MLookDown( void ) { + in_mlooking = qtrue; +} + +void IN_MLookUp( void ) { + in_mlooking = qfalse; + if ( !cl_freelook->integer ) { + IN_CenterView (); + } +} + +void IN_KeyDown( kbutton_t *b ) { + int k; + char *c; + + c = Cmd_Argv(1); + if ( c[0] ) { + k = atoi(c); + } else { + k = -1; // typed manually at the console for continuous down + } + + if ( k == b->down[0] || k == b->down[1] ) { + return; // repeating key + } + + if ( !b->down[0] ) { + b->down[0] = k; + } else if ( !b->down[1] ) { + b->down[1] = k; + } else { + Com_Printf ("Three keys down for a button!\n"); + return; + } + + if ( b->active ) { + return; // still down + } + + // save timestamp for partial frame summing + c = Cmd_Argv(2); + b->downtime = atoi(c); + + b->active = qtrue; + b->wasPressed = qtrue; +} + +void IN_KeyUp( kbutton_t *b ) { + int k; + char *c; + unsigned uptime; + + c = Cmd_Argv(1); + if ( c[0] ) { + k = atoi(c); + } else { + // typed manually at the console, assume for unsticking, so clear all + b->down[0] = b->down[1] = 0; + b->active = qfalse; + return; + } + + if ( b->down[0] == k ) { + b->down[0] = 0; + } else if ( b->down[1] == k ) { + b->down[1] = 0; + } else { + return; // key up without coresponding down (menu pass through) + } + if ( b->down[0] || b->down[1] ) { + return; // some other key is still holding it down + } + + b->active = qfalse; + + // save timestamp for partial frame summing + c = Cmd_Argv(2); + uptime = atoi(c); + if ( uptime ) { + b->msec += uptime - b->downtime; + } else { + b->msec += frame_msec / 2; + } + + b->active = qfalse; +} + + + +/* +=============== +CL_KeyState + +Returns the fraction of the frame that the key was down +=============== +*/ +float CL_KeyState( kbutton_t *key ) { + float val; + int msec; + + msec = key->msec; + key->msec = 0; + + if ( key->active ) { + // still down + if ( !key->downtime ) { + msec = com_frameTime; + } else { + msec += com_frameTime - key->downtime; + } + key->downtime = com_frameTime; + } + +#if 0 + if (msec) { + Com_Printf ("%i ", msec); + } +#endif + + val = (float)msec / frame_msec; + if ( val < 0 ) { + val = 0; + } + if ( val > 1 ) { + val = 1; + } + + return val; +} + + + +void IN_UpDown(void) {IN_KeyDown(&in_up);} +void IN_UpUp(void) {IN_KeyUp(&in_up);} +void IN_DownDown(void) {IN_KeyDown(&in_down);} +void IN_DownUp(void) {IN_KeyUp(&in_down);} +void IN_LeftDown(void) {IN_KeyDown(&in_left);} +void IN_LeftUp(void) {IN_KeyUp(&in_left);} +void IN_RightDown(void) {IN_KeyDown(&in_right);} +void IN_RightUp(void) {IN_KeyUp(&in_right);} +void IN_ForwardDown(void) {IN_KeyDown(&in_forward);} +void IN_ForwardUp(void) {IN_KeyUp(&in_forward);} +void IN_BackDown(void) {IN_KeyDown(&in_back);} +void IN_BackUp(void) {IN_KeyUp(&in_back);} +void IN_LookupDown(void) {IN_KeyDown(&in_lookup);} +void IN_LookupUp(void) {IN_KeyUp(&in_lookup);} +void IN_LookdownDown(void) {IN_KeyDown(&in_lookdown);} +void IN_LookdownUp(void) {IN_KeyUp(&in_lookdown);} +void IN_MoveleftDown(void) {IN_KeyDown(&in_moveleft);} +void IN_MoveleftUp(void) {IN_KeyUp(&in_moveleft);} +void IN_MoverightDown(void) {IN_KeyDown(&in_moveright);} +void IN_MoverightUp(void) {IN_KeyUp(&in_moveright);} + +void IN_SpeedDown(void) {IN_KeyDown(&in_speed);} +void IN_SpeedUp(void) {IN_KeyUp(&in_speed);} +void IN_StrafeDown(void) {IN_KeyDown(&in_strafe);} +void IN_StrafeUp(void) {IN_KeyUp(&in_strafe);} + +void IN_Button0Down(void) {IN_KeyDown(&in_buttons[0]);} +void IN_Button0Up(void) {IN_KeyUp(&in_buttons[0]);} +void IN_Button1Down(void) {IN_KeyDown(&in_buttons[1]);} +void IN_Button1Up(void) {IN_KeyUp(&in_buttons[1]);} +void IN_Button2Down(void) {IN_KeyDown(&in_buttons[2]);} +void IN_Button2Up(void) {IN_KeyUp(&in_buttons[2]);} +void IN_Button3Down(void) {IN_KeyDown(&in_buttons[3]);} +void IN_Button3Up(void) {IN_KeyUp(&in_buttons[3]);} +void IN_Button4Down(void) {IN_KeyDown(&in_buttons[4]);} +void IN_Button4Up(void) {IN_KeyUp(&in_buttons[4]);} +void IN_Button5Down(void) {IN_KeyDown(&in_buttons[5]);} +void IN_Button5Up(void) {IN_KeyUp(&in_buttons[5]);} +void IN_Button6Down(void) {IN_KeyDown(&in_buttons[6]);} +void IN_Button6Up(void) {IN_KeyUp(&in_buttons[6]);} +void IN_Button7Down(void) {IN_KeyDown(&in_buttons[7]);} +void IN_Button7Up(void) {IN_KeyUp(&in_buttons[7]);} +void IN_Button8Down(void) {IN_KeyDown(&in_buttons[8]);} +void IN_Button8Up(void) {IN_KeyUp(&in_buttons[8]);} +void IN_Button9Down(void) {IN_KeyDown(&in_buttons[9]);} +void IN_Button9Up(void) {IN_KeyUp(&in_buttons[9]);} +void IN_Button10Down(void) {IN_KeyDown(&in_buttons[10]);} +void IN_Button10Up(void) {IN_KeyUp(&in_buttons[10]);} +void IN_Button11Down(void) {IN_KeyDown(&in_buttons[11]);} +void IN_Button11Up(void) {IN_KeyUp(&in_buttons[11]);} +void IN_Button12Down(void) {IN_KeyDown(&in_buttons[12]);} +void IN_Button12Up(void) {IN_KeyUp(&in_buttons[12]);} +void IN_Button13Down(void) {IN_KeyDown(&in_buttons[13]);} +void IN_Button13Up(void) {IN_KeyUp(&in_buttons[13]);} +void IN_Button14Down(void) {IN_KeyDown(&in_buttons[14]);} +void IN_Button14Up(void) {IN_KeyUp(&in_buttons[14]);} +void IN_Button15Down(void) {IN_KeyDown(&in_buttons[15]);} +void IN_Button15Up(void) {IN_KeyUp(&in_buttons[15]);} + +void IN_ButtonDown (void) { + IN_KeyDown(&in_buttons[1]);} +void IN_ButtonUp (void) { + IN_KeyUp(&in_buttons[1]);} + +void IN_CenterView (void) { + cl.viewangles[PITCH] = -SHORT2ANGLE(cl.snap.ps.delta_angles[PITCH]); +} + + +//========================================================================== + +cvar_t *cl_upspeed; +cvar_t *cl_forwardspeed; +cvar_t *cl_sidespeed; + +cvar_t *cl_yawspeed; +cvar_t *cl_pitchspeed; + +cvar_t *cl_run; + +cvar_t *cl_anglespeedkey; + + +/* +================ +CL_AdjustAngles + +Moves the local angle positions +================ +*/ +void CL_AdjustAngles( void ) { + float speed; + + if ( in_speed.active ) { + speed = 0.001 * cls.frametime * cl_anglespeedkey->value; + } else { + speed = 0.001 * cls.frametime; + } + + if ( !in_strafe.active ) { + cl.viewangles[YAW] -= speed*cl_yawspeed->value*CL_KeyState (&in_right); + cl.viewangles[YAW] += speed*cl_yawspeed->value*CL_KeyState (&in_left); + } + + cl.viewangles[PITCH] -= speed*cl_pitchspeed->value * CL_KeyState (&in_lookup); + cl.viewangles[PITCH] += speed*cl_pitchspeed->value * CL_KeyState (&in_lookdown); +} + +/* +================ +CL_KeyMove + +Sets the usercmd_t based on key states +================ +*/ +void CL_KeyMove( usercmd_t *cmd ) { + int movespeed; + int forward, side, up; + + // + // adjust for speed key / running + // the walking flag is to keep animations consistant + // even during acceleration and develeration + // + if ( in_speed.active ^ cl_run->integer ) { + movespeed = 127; + cmd->buttons |= BUTTON_RUN; + } else { + cmd->buttons &= ~BUTTON_RUN; + movespeed = 64; + } + + forward = 0; + side = 0; + up = 0; + if ( in_strafe.active ) { + side += movespeed * CL_KeyState (&in_right); + side -= movespeed * CL_KeyState (&in_left); + } + + side += movespeed * CL_KeyState (&in_moveright); + side -= movespeed * CL_KeyState (&in_moveleft); + + + up += movespeed * CL_KeyState (&in_up); + up -= movespeed * CL_KeyState (&in_down); + + forward += movespeed * CL_KeyState (&in_forward); + forward -= movespeed * CL_KeyState (&in_back); + + cmd->forwardmove = ClampChar( forward ); + cmd->rightmove = ClampChar( side ); + cmd->upmove = ClampChar( up ); +} + +/* +================= +CL_GetMouseState +================= +*/ +void CL_GetMouseState( int *x, int *y, unsigned int *buttons ) +{ + if( x ) + *x = cl.mousex; + + if( y ) + *y = cl.mousey; + + if( buttons ) + { + if( in_guimouse ) { + *buttons = cl.mouseButtons; + } else { + *buttons = 0; + } + } +} + +/* +================= +CL_SetMousePos +================= +*/ +void CL_SetMousePos( int x, int y ) +{ + cl.mousex = x; + cl.mousey = y; +} + +/* +================= +CL_MouseEvent +================= +*/ +void CL_MouseEvent( int dx, int dy, int time ) { + if( in_guimouse ) + { + cl.mousex += dx; + cl.mousey += dy; + + if( cl.mousex < 0 ) + cl.mousex = 0; + + if( cl.mousex > cls.glconfig.vidWidth ) + cl.mousex = cls.glconfig.vidWidth; + + if( cl.mousey < 0 ) + cl.mousey = 0; + + if( cl.mousey > cls.glconfig.vidHeight ) + cl.mousey = cls.glconfig.vidHeight; + } + else + { + cl.mouseDx[cl.mouseIndex] += dx; + cl.mouseDy[cl.mouseIndex] += dy; + } +} + +/* +================= +CL_JoystickEvent + +Joystick values stay set until changed +================= +*/ +void CL_JoystickEvent( int axis, int value, int time ) { + if ( axis < 0 || axis >= MAX_JOYSTICK_AXIS ) { + Com_Error( ERR_DROP, "CL_JoystickEvent: bad axis %i", axis ); + } + cl.joystickAxis[axis] = value; +} + +/* +================= +CL_JoystickMove +================= +*/ +void CL_JoystickMove( usercmd_t *cmd ) { + int movespeed; + float anglespeed; + + if ( in_speed.active ^ cl_run->integer ) { + movespeed = 2; + } else { + movespeed = 1; + cmd->buttons |= BUTTON_RUN; + } + + if ( in_speed.active ) { + anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value; + } else { + anglespeed = 0.001 * cls.frametime; + } + + if ( !in_strafe.active ) { + cl.viewangles[YAW] += anglespeed * cl_yawspeed->value * cl.joystickAxis[AXIS_SIDE]; + } else { + cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] ); + } + + if ( in_mlooking ) { + cl.viewangles[PITCH] += anglespeed * cl_pitchspeed->value * cl.joystickAxis[AXIS_FORWARD]; + } else { + cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] ); + } + + cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] ); +} + +/* +================= +CL_MouseMove +================= +*/ +void CL_MouseMove( usercmd_t *cmd ) { + float mx, my; + float accelSensitivity; + float rate; + + // allow mouse smoothing + if ( m_filter->integer ) { + mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5; + my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5; + } else { + mx = cl.mouseDx[cl.mouseIndex]; + my = cl.mouseDy[cl.mouseIndex]; + } + cl.mouseIndex ^= 1; + cl.mouseDx[cl.mouseIndex] = 0; + cl.mouseDy[cl.mouseIndex] = 0; + + rate = sqrt( mx * mx + my * my ) / (float)frame_msec; + accelSensitivity = ( cl_sensitivity->value * + cl_platformSensitivity->value ) + rate * cl_mouseAccel->value; + + if( cge && UI_MenuActive() ) + { + if( cge->CG_SensitivityScale() >= 0.0 ) { + accelSensitivity *= cge->CG_SensitivityScale(); + } + } + + if ( rate && cl_showMouseRate->integer ) { + Com_Printf( "%f : %f\n", rate, accelSensitivity ); + } + + mx *= accelSensitivity; + my *= accelSensitivity; + + if (!mx && !my) { + return; + } + + // add mouse X/Y movement to cmd + if ( in_strafe.active ) { + cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx ); + } else { + cl.viewangles[YAW] -= m_yaw->value * mx; + } + + if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) { + cl.viewangles[PITCH] += m_pitch->value * my; + } else { + cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my ); + } +} + +/* +============== +CL_ClearButtons +============== +*/ +void CL_ClearButtons( void ) { + memset( in_buttons, 0, sizeof( in_buttons ) ); +} + +/* +============== +CL_CmdButtons +============== +*/ +void CL_CmdButtons( usercmd_t *cmd ) { + int i; + + // + // figure button bits + // send a button bit even if the key was pressed and released in + // less than a frame + // + for (i = 0 ; i < 15 ; i++) { + if ( in_buttons[i].active || in_buttons[i].wasPressed ) { + cmd->buttons |= 1 << i; + } + in_buttons[i].wasPressed = qfalse; + } + +// if ( Key_GetCatcher( ) ) { +// cmd->buttons |= BUTTON_TALK; // su44: is there a TALK button in MoHAA? +// } + + // allow the game to know if any key at all is + // currently pressed, even if it isn't bound to anything + if ( anykeydown && Key_GetCatcher( ) == 0 ) { + cmd->buttons |= BUTTON_ANY; + } + + // su44: add weapon command bits + cmd->buttons |= cl.cgameUserCmdValue; +} + + +/* +============== +CL_FinishMove +============== +*/ +void CL_FinishMove( usercmd_t *cmd ) { + int i; + + // send the current server time so the amount of movement + // can be determined without allowing cheating + cmd->serverTime = cl.serverTime; + + for (i=0 ; i<3 ; i++) { + cmd->angles[i] = ANGLE2SHORT(cl.viewangles[i]); + } +} + + +/* +================= +CL_CreateCmd +================= +*/ +usercmd_t CL_CreateCmd( void ) { + usercmd_t cmd; + vec3_t oldAngles; + + VectorCopy( cl.viewangles, oldAngles ); + + // keyboard angle adjustment + CL_AdjustAngles (); + + Com_Memset( &cmd, 0, sizeof( cmd ) ); + + CL_CmdButtons( &cmd ); + + // get basic movement from keyboard + CL_KeyMove( &cmd ); + + // get basic movement from mouse + CL_MouseMove( &cmd ); + + // get basic movement from joystick + CL_JoystickMove( &cmd ); + + // check to make sure the angles haven't wrapped + if ( cl.viewangles[PITCH] - oldAngles[PITCH] > 90 ) { + cl.viewangles[PITCH] = oldAngles[PITCH] + 90; + } else if ( oldAngles[PITCH] - cl.viewangles[PITCH] > 90 ) { + cl.viewangles[PITCH] = oldAngles[PITCH] - 90; + } + + // store out the final values + CL_FinishMove( &cmd ); + + // draw debug graphs of turning for mouse testing + if ( cl_debugMove->integer ) { + if ( cl_debugMove->integer == 1 ) { + SCR_DebugGraph( abs(cl.viewangles[YAW] - oldAngles[YAW]), 0 ); + } + if ( cl_debugMove->integer == 2 ) { + SCR_DebugGraph( abs(cl.viewangles[PITCH] - oldAngles[PITCH]), 0 ); + } + } + + return cmd; +} + + +/* +================= +CL_CreateNewCommands + +Create a new usercmd_t structure for this frame +================= +*/ +void CL_CreateNewCommands( void ) { + usercmd_t *cmd; + int cmdNum; + + // no need to create usercmds until we have a gamestate + if ( cls.state < CA_PRIMED ) { + return; + } + + frame_msec = com_frameTime - old_com_frameTime; + + // if running less than 5fps, truncate the extra time to prevent + // unexpected moves after a hitch + if ( frame_msec > 200 ) { + frame_msec = 200; + } + old_com_frameTime = com_frameTime; + + + // generate a command for this frame + cl.cmdNumber++; + cmdNum = cl.cmdNumber & CMD_MASK; + cl.cmds[cmdNum] = CL_CreateCmd (); + cmd = &cl.cmds[cmdNum]; +} + + +/* +================= +CL_GetEyeInfo + +Create a new usereyes_t structure for this frame +================= +*/ +void CL_GetEyeInfo(usereyes_t *info) { + info->angles[0] = cl.eyeAngles[0]; + info->angles[1] = cl.eyeAngles[1]; + VectorCopy(cl.eyeOrigin,info->ofs); +} +/* +================= +CL_SetEyeInfo +================= +*/ +void CL_SetEyeInfo(vec3_t origin, vec3_t angles) { + VectorCopy(angles,cl.eyeAngles); + VectorCopy(origin,cl.eyeOrigin); +} + +/* +================= +CL_ReadyToSendPacket + +Returns qfalse if we are over the maxpackets limit +and should choke back the bandwidth a bit by not sending +a packet this frame. All the commands will still get +delivered in the next packet, but saving a header and +getting more delta compression will reduce total bandwidth. +================= +*/ +qboolean CL_ReadyToSendPacket( void ) { + int oldPacketNum; + int delta; + + // don't send anything if playing back a demo + if ( clc.demoplaying || cls.state == CA_CINEMATIC ) { + return qfalse; + } + + // If we are downloading, we send no less than 50ms between packets + if ( *clc.downloadTempName && + cls.realtime - clc.lastPacketSentTime < 50 ) { + return qfalse; + } + + // if we don't have a valid gamestate yet, only send + // one packet a second + if ( cls.state != CA_ACTIVE && + cls.state != CA_PRIMED && + !*clc.downloadTempName && + cls.realtime - clc.lastPacketSentTime < 1000 ) { + return qfalse; + } + + // send every frame for loopbacks + if ( clc.netchan.remoteAddress.type == NA_LOOPBACK ) { + return qtrue; + } + + // send every frame for LAN + if ( cl_lanForcePackets->integer && Sys_IsLANAddress( clc.netchan.remoteAddress ) ) { + return qtrue; + } + + // check for exceeding cl_maxpackets + if ( cl_maxpackets->integer < 15 ) { + Cvar_Set( "cl_maxpackets", "15" ); + } else if ( cl_maxpackets->integer > 125 ) { + Cvar_Set( "cl_maxpackets", "125" ); + } + oldPacketNum = (clc.netchan.outgoingSequence - 1) & PACKET_MASK; + delta = cls.realtime - cl.outPackets[ oldPacketNum ].p_realtime; + if ( delta < 1000 / cl_maxpackets->integer ) { + // the accumulated commands will go out in the next packet + return qfalse; + } + + return qtrue; +} + +/* +=================== +CL_WritePacket + +Create and send the command packet to the server +Including both the reliable commands and the usercmds + +During normal gameplay, a client packet will contain something like: + +4 sequence number +2 qport +4 serverid +4 acknowledged sequence number +4 clc.serverCommandSequence + +1 clc_move or clc_moveNoDelta +1 command count + + +=================== +*/ +void CL_WritePacket( void ) { + msg_t buf; + byte data[MAX_MSGLEN]; + int i, j; + usercmd_t *cmd, *oldcmd; + usercmd_t nullcmd; + int packetNum; + int oldPacketNum; + int count, key; + usereyes_t eyeInfo; + + // don't send anything if playing back a demo + if ( clc.demoplaying || cls.state == CA_CINEMATIC ) { + return; + } + + Com_Memset( &nullcmd, 0, sizeof(nullcmd) ); + oldcmd = &nullcmd; + + MSG_Init( &buf, data, sizeof(data) ); + + MSG_Bitstream( &buf ); + // write the current serverId so the server + // can tell if this is from the current gameState + MSG_WriteLong( &buf, cl.serverId ); + + // write the last message we received, which can + // be used for delta compression, and is also used + // to tell if we dropped a gamestate + MSG_WriteLong( &buf, clc.serverMessageSequence ); + + // write the last reliable message we received + MSG_WriteLong( &buf, clc.serverCommandSequence ); + + // write any unacknowledged clientCommands + for ( i = clc.reliableAcknowledge + 1 ; i <= clc.reliableSequence ; i++ ) { + MSG_WriteByte( &buf, clc_clientCommand ); + MSG_WriteLong( &buf, i ); + MSG_WriteString( &buf, clc.reliableCommands[ i & (MAX_RELIABLE_COMMANDS-1) ] ); + } + + // we want to send all the usercmds that were generated in the last + // few packet, so even if a couple packets are dropped in a row, + // all the cmds will make it to the server + if ( cl_packetdup->integer < 0 ) { + Cvar_Set( "cl_packetdup", "0" ); + } else if ( cl_packetdup->integer > 5 ) { + Cvar_Set( "cl_packetdup", "5" ); + } + oldPacketNum = (clc.netchan.outgoingSequence - 1 - cl_packetdup->integer) & PACKET_MASK; + count = cl.cmdNumber - cl.outPackets[ oldPacketNum ].p_cmdNumber; + if ( count > MAX_PACKET_USERCMDS ) { + count = MAX_PACKET_USERCMDS; + Com_Printf("MAX_PACKET_USERCMDS\n"); + } + if ( count >= 1 ) { + if ( cl_showSend->integer ) { + Com_Printf( "(%i)", count ); + } + + // begin a client move command + if ( cl_nodelta->integer || !cl.snap.valid || clc.demowaiting + || clc.serverMessageSequence != cl.snap.messageNum ) { + MSG_WriteByte (&buf, clc_moveNoDelta); + } else { + MSG_WriteByte (&buf, clc_move); + } + + // write the command count + MSG_WriteByte( &buf, count ); + + CL_GetEyeInfo( &eyeInfo ); + MSG_WriteDeltaEyeInfo( &buf, &cl.outPackets[ oldPacketNum ].p_eyeinfo, &eyeInfo ); + // use the checksum feed in the key + key = clc.checksumFeed; + // also use the message acknowledge + key ^= clc.serverMessageSequence; + // also use the last acknowledged server command in the key + key ^= Com_HashKey(clc.serverCommands[ clc.serverCommandSequence & (MAX_RELIABLE_COMMANDS-1) ], 32); + + // write all the commands, including the predicted command + for ( i = 0 ; i < count ; i++ ) { + j = (cl.cmdNumber - count + i + 1) & CMD_MASK; + cmd = &cl.cmds[j]; + MSG_WriteDeltaUsercmdKey (&buf, key, oldcmd, cmd); + oldcmd = cmd; + } + } + + // + // deliver the message + // + packetNum = clc.netchan.outgoingSequence & PACKET_MASK; + cl.outPackets[ packetNum ].p_realtime = cls.realtime; + cl.outPackets[ packetNum ].p_serverTime = oldcmd->serverTime; + cl.outPackets[ packetNum ].p_cmdNumber = cl.cmdNumber; + cl.outPackets[ packetNum ].p_eyeinfo = eyeInfo; + clc.lastPacketSentTime = cls.realtime; + + if ( cl_showSend->integer ) { + Com_Printf( "%i ", buf.cursize ); + } + + CL_Netchan_Transmit (&clc.netchan, &buf); + + // clients never really should have messages large enough + // to fragment, but in case they do, fire them all off + // at once + // TTimo: this causes a packet burst, which is bad karma for winsock + // added a WARNING message, we'll see if there are legit situations where this happens + while ( clc.netchan.unsentFragments ) { + Com_DPrintf( "WARNING: #462 unsent fragments (not supposed to happen!)\n" ); + CL_Netchan_TransmitNextFragment( &clc.netchan ); + } +} + +/* +================= +CL_SendCmd + +Called every frame to builds and sends a command packet to the server. +================= +*/ +void CL_SendCmd( void ) { + // don't send any message if not connected + if ( cls.state < CA_CONNECTED ) { + return; + } + + // don't send commands if paused + if ( com_sv_running->integer && paused->integer && paused->integer ) { + return; + } + + // we create commands even if a demo is playing, + CL_CreateNewCommands(); + + // don't send a packet if the last packet was sent too recently + if ( !CL_ReadyToSendPacket() ) { + if ( cl_showSend->integer ) { + Com_Printf( ". " ); + } + return; + } + + CL_WritePacket(); +} + +/* +============ +CL_InitInput +============ +*/ +void CL_InitInput( void ) { + Cmd_AddCommand ("centerview",IN_CenterView); + + Cmd_AddCommand ("+moveup",IN_UpDown); + Cmd_AddCommand ("-moveup",IN_UpUp); + Cmd_AddCommand ("+movedown",IN_DownDown); + Cmd_AddCommand ("-movedown",IN_DownUp); + Cmd_AddCommand ("+left",IN_LeftDown); + Cmd_AddCommand ("-left",IN_LeftUp); + Cmd_AddCommand ("+right",IN_RightDown); + Cmd_AddCommand ("-right",IN_RightUp); + Cmd_AddCommand ("+forward",IN_ForwardDown); + Cmd_AddCommand ("-forward",IN_ForwardUp); + Cmd_AddCommand ("+back",IN_BackDown); + Cmd_AddCommand ("-back",IN_BackUp); + Cmd_AddCommand ("+lookup", IN_LookupDown); + Cmd_AddCommand ("-lookup", IN_LookupUp); + Cmd_AddCommand ("+lookdown", IN_LookdownDown); + Cmd_AddCommand ("-lookdown", IN_LookdownUp); + Cmd_AddCommand ("+strafe", IN_StrafeDown); + Cmd_AddCommand ("-strafe", IN_StrafeUp); + Cmd_AddCommand ("+moveleft", IN_MoveleftDown); + Cmd_AddCommand ("-moveleft", IN_MoveleftUp); + Cmd_AddCommand ("+moveright", IN_MoverightDown); + Cmd_AddCommand ("-moveright", IN_MoverightUp); + Cmd_AddCommand ("+speed", IN_SpeedDown); + Cmd_AddCommand ("-speed", IN_SpeedUp); + Cmd_AddCommand ("+attackprimary", IN_Button0Down); + Cmd_AddCommand ("-attackprimary", IN_Button0Up); + Cmd_AddCommand ("+attacksecondary", IN_Button1Down); + Cmd_AddCommand ("-attacksecondary", IN_Button1Up); +// Cmd_AddCommand ("+speed", IN_Button2Down); +// Cmd_AddCommand ("-speed", IN_Button2Up); + Cmd_AddCommand ("+use", IN_Button3Down); + Cmd_AddCommand ("-use", IN_Button3Up); + Cmd_AddCommand ("+leanleft", IN_Button4Down); + Cmd_AddCommand ("-leanleft", IN_Button4Up); + Cmd_AddCommand ("+leanright", IN_Button5Down); + Cmd_AddCommand ("-leanright", IN_Button5Up); + Cmd_AddCommand ("+button6", IN_Button6Down); + Cmd_AddCommand ("-button6", IN_Button6Up); + Cmd_AddCommand ("+button7", IN_Button7Down); + Cmd_AddCommand ("-button7", IN_Button7Up); + Cmd_AddCommand ("+button8", IN_Button8Down); + Cmd_AddCommand ("-button8", IN_Button8Up); + Cmd_AddCommand ("+button9", IN_Button9Down); + Cmd_AddCommand ("-button9", IN_Button9Up); + Cmd_AddCommand ("+button10", IN_Button10Down); + Cmd_AddCommand ("-button10", IN_Button10Up); + Cmd_AddCommand ("+button11", IN_Button11Down); + Cmd_AddCommand ("-button11", IN_Button11Up); + Cmd_AddCommand ("+button12", IN_Button12Down); + Cmd_AddCommand ("-button12", IN_Button12Up); + Cmd_AddCommand ("+button13", IN_Button13Down); + Cmd_AddCommand ("-button13", IN_Button13Up); + Cmd_AddCommand ("+button14", IN_Button14Down); + Cmd_AddCommand ("-button14", IN_Button14Up); + Cmd_AddCommand ("+mlook", IN_MLookDown); + Cmd_AddCommand ("-mlook", IN_MLookUp); + + cl_nodelta = Cvar_Get ("cl_nodelta", "0", 0); + cl_debugMove = Cvar_Get ("cl_debugMove", "0", 0); +} diff --git a/code/client/cl_inv.cpp b/code/client/cl_inv.cpp new file mode 100644 index 00000000..1fbdda1a --- /dev/null +++ b/code/client/cl_inv.cpp @@ -0,0 +1,337 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( Listener, invlistener, NULL ) +{ + { NULL, NULL } +}; + +invlistener::invlistener( inventory_t *i ) +{ + // FIXME: stub +} + +invlistener::invlistener() +{ + // FIXME: stub +} + +void invlistener::verify_curitem( void ) +{ + // FIXME: stub +} + +void invlistener::verify_curtype( void ) +{ + // FIXME: stub +} + +void invlistener::verify_one_arg( Event *ev ) +{ + // FIXME: stub +} + +bool invlistener::Load( Script& script ) +{ + // FIXME: stub + return false; +} + +void invlistener::InvSelectSound( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::InvRejectSound( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::InvChangeSound( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::InvWidth( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::InvHeight( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::InvHorizOffset( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::InvVertOffset( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::InvAlign( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::InvCascade( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Typedef( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::OpenBrace( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::CloseBrace( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::ButtonShader( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HoverShader( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::SelShader( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Background( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::BackgroundTile( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Width( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Height( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::BarWidth( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::BarHeight( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::BarOffsetX( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::BarOffsetY( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Item( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Ammo( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Equip( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::CheckAmmo( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Command( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::BGShader( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::BarShader( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::SelItemShader( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::SelItemShaderOnTop( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::RotateOffset( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Offset( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Model( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Anim( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Scale( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Angles( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::AngleDeltas( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::Move( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::ModelWindow( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HudRotateOffset( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HudOffset( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HudModel( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HudAnim( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HudScale( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HudAngles( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HudAngleDeltas( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HudMove( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HudCompassAngles( Event *ev ) +{ + // FIXME: stub +} + +void invlistener::HudCompassNeedleAngles( Event *ev ) +{ + // FIXME: stub +} + +bool CL_LoadInventory( const char *filename, inventory_t *inv ) +{ + // FIXME: stub + return false; +} + +inventory_item_t *CL_GetInvItemByName( inventory_t *inv, const char *name ) +{ + // FIXME: stub + return NULL; +} + +qboolean CL_HasInventoryItem( const char *name ) +{ + // FIXME: stub + return qfalse; +} + +void CL_AmmoCount( const char *name, int *ammo_count, int *max_ammo_count ) +{ + // FIXME: stub +} diff --git a/code/client/cl_inv.h b/code/client/cl_inv.h new file mode 100644 index 00000000..fef74f34 --- /dev/null +++ b/code/client/cl_inv.h @@ -0,0 +1,194 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_INV_H__ +#define __CL_INV_H__ + +typedef enum { INV_MOVE_NONE, INV_MOVE_BOB, INV_MOVE_SPIN } inv_move_type; +typedef enum { INV_CASCADE_LEFT, INV_CASCADE_RIGHT } inv_cascade_type; +typedef enum { INV_HUDANGLES_BASE, INV_HUDANGLES_COMPASS, INV_HUDANGLES_COMPASS_NEEDLE } inv_hudangles_type; + +class item_properties_t : public Class { +public: + float scale; + Vector angles; + Vector angledeltas; + Vector rotateoffset; + Vector offset; + inv_move_type move; + str model; + str anim; +}; + +class inventory_item_t : public Class { +public: + str name; + str ammoname; + int equip; + int width; + int height; + int barwidth; + int barheight; + int baroffsetY; + int baroffsetX; + float modelWindowX; + float modelWindowY; + float modelWindowWidth; + float modelWindowHeight; + bool selShaderOnTop; + bool checkammo; + str command; + inv_hudangles_type anglesType; + item_properties_t hudprops; + item_properties_t invprops; + UIReggedMaterial *bgshader; + UIReggedMaterial *barshader; + UIReggedMaterial *selshader; +}; + +class inventory_type_t { +public: + str name; + bool bg_tile; + UIReggedMaterial *texture; + UIReggedMaterial *bg; + UIReggedMaterial *hoverTexture; + UIReggedMaterial *selTexture; + Container items; + + int IndexOfItemPtr( inventory_item_t *item ); +}; + +inline +int inventory_type_t::IndexOfItemPtr( inventory_item_t *item ) +{ + for( int i = items.NumObjects(); i > 0; i-- ) + { + if( items.ObjectAt( i ) == item ) + { + return i; + } + } + + return 0; +} + +class inventory_t { +public: + int typewidth; + int typeheight; + int horizoffset; + int vertoffset; + int align; + inv_cascade_type cascade; + str selectsound; + str rejectsound; + str changesound; + Container types; + + void Clear() { types.ClearObjectList(); } +}; + +class invlistener : public Listener { +protected: + inventory_t *inv; + inventory_type_t *curtype; + inventory_item_t *curitem; + int defaultWidth; + int defaultHeight; + int defaultBarWidth; + int defaultBarHeight; + int defaultBarOffsetX; + int defaultBarOffsetY; + +public: + CLASS_PROTOTYPE( invlistener ); + +protected: + void verify_curitem( void ); + void verify_curtype( void ); + void verify_one_arg( Event *ev ); + +public: + invlistener( inventory_t *i ); + invlistener(); + + bool Load( Script& script ); + void InvSelectSound( Event *ev ); + void InvRejectSound( Event *ev ); + void InvChangeSound( Event *ev ); + void InvWidth( Event *ev ); + void InvHeight( Event *ev ); + void InvHorizOffset( Event *ev ); + void InvVertOffset( Event *ev ); + void InvAlign( Event *ev ); + void InvCascade( Event *ev ); + void Typedef( Event *ev ); + void OpenBrace( Event *ev ); + void CloseBrace( Event *ev ); + void ButtonShader( Event *ev ); + void HoverShader( Event *ev ); + void SelShader( Event *ev ); + void Background( Event *ev ); + void BackgroundTile( Event *ev ); + void Width( Event *ev ); + void Height( Event *ev ); + void BarWidth( Event *ev ); + void BarHeight( Event *ev ); + void BarOffsetX( Event *ev ); + void BarOffsetY( Event *ev ); + void Item( Event *ev ); + void Ammo( Event *ev ); + void Equip( Event *ev ); + void CheckAmmo( Event *ev ); + void Command( Event *ev ); + void BGShader( Event *ev ); + void BarShader( Event *ev ); + void SelItemShader( Event *ev ); + void SelItemShaderOnTop( Event *ev ); + void RotateOffset( Event *ev ); + void Offset( Event *ev ); + void Model( Event *ev ); + void Anim( Event *ev ); + void Scale( Event *ev ); + void Angles( Event *ev ); + void AngleDeltas( Event *ev ); + void Move( Event *ev ); + void ModelWindow( Event *ev ); + void HudRotateOffset( Event *ev ); + void HudOffset( Event *ev ); + void HudModel( Event *ev ); + void HudAnim( Event *ev ); + void HudScale( Event *ev ); + void HudAngles( Event *ev ); + void HudAngleDeltas( Event *ev ); + void HudMove( Event *ev ); + void HudCompassAngles( Event *ev ); + void HudCompassNeedleAngles( Event *ev ); +}; + +bool CL_LoadInventory( const char *filename, inventory_t *inv ); +inventory_item_t *CL_GetInvItemByName( inventory_t *inv, const char *name ); +qboolean CL_HasInventoryItem( const char *name ); +void CL_AmmoCount( const char *name, int *ammo_count, int *max_ammo_count ); + +#endif // __CL_INV_H__ diff --git a/code/client/cl_invrender.cpp b/code/client/cl_invrender.cpp new file mode 100644 index 00000000..bcb5125b --- /dev/null +++ b/code/client/cl_invrender.cpp @@ -0,0 +1,224 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( UIWidget, FakkItemList, NULL ) +{ + { NULL, NULL } +}; + +FakkItemList::FakkItemList() +{ + // FIXME: stub +} + +FakkItemList::~FakkItemList() +{ + // FIXME: stub +} + +void FakkItemList::VerifyItemUp( inventory_item_t *item, qboolean warpmouse ) +{ + // FIXME: stub +} + +void FakkItemList::setType( inventory_type_t *t ) +{ + // FIXME: stub +} + +void FakkItemList::Create( float x, float y, FakkInventory *parent ) +{ + // FIXME: stub +} + +bool FakkItemList::HasAnyItems( void ) +{ + // FIXME: stub + return false; +} + +void FakkItemList::Draw( void ) +{ + // FIXME: stub +} + +void FakkItemList::OnLeftMouseDown( Event *ev ) +{ + // FIXME: stub +} + +void FakkItemList::OnRightMouseDown( Event *ev ) +{ + // FIXME: stub +} + +void FakkItemList::OnLeftMouseUp( Event *ev ) +{ + // FIXME: stub +} + +void FakkItemList::OnRightMouseUp( Event *ev ) +{ + // FIXME: stub +} + +void FakkItemList::OnMouseMove( Event *ev ) +{ + // FIXME: stub +} + +void FakkItemList::OnMouseEnter( Event *ev ) +{ + // FIXME: stub +} + +void FakkItemList::OnMouseLeave( Event *ev ) +{ + // FIXME: stub +} + +void FakkItemList::OnMenuKilled( Event *ev ) +{ + // FIXME: stub +} + +void FakkItemList::EquipItem( Event *ev ) +{ + // FIXME: stub +} + +CLASS_DECLARATION( UIWidget, FakkInventory, NULL ) +{ + { NULL, NULL } +}; + + +FakkInventory::FakkInventory() +{ + // FIXME: stub +} + +FakkInventory::~FakkInventory() +{ + // FIXME: stub +} + +void FakkInventory::VerifyItemUp( inventory_item_t *item, qboolean warpmouse ) +{ + // FIXME: stub +} + +void FakkInventory::setInventory( inventory_t *i ) +{ + // FIXME: stub +} + +void FakkInventory::Draw( void ) +{ + // FIXME: stub +} + +void FakkInventory::OnMouseMove( Event *ev ) +{ + // FIXME: stub +} + +void FakkInventory::OnMouseLeave( Event *ev ) +{ + // FIXME: stub +} + +void FakkInventory::OnMouseEnter( Event *ev ) +{ + // FIXME: stub +} + +void FakkInventory::OnMouseDown( Event *ev ) +{ + // FIXME: stub +} + +void FakkInventory::WarpTo( const char *name ) +{ + // FIXME: stub +} + +void FakkInventory::WarpTo( int slotnum ) +{ + // FIXME: stub +} + +void FakkInventory::NextItem( void ) +{ + // FIXME: stub +} + +void FakkInventory::PrevItem( void ) +{ + // FIXME: stub +} + +qboolean FakkInventory::isDying( void ) +{ + // FIXME: stub + return qfalse; +} + +qboolean FakkInventory::KeyEvent( int key, unsigned int time ) +{ + // FIXME: stub + return qfalse; +} + +void FakkInventory::PlaySound( invsound_t type ) +{ + // FIXME: stub +} + +void FakkInventory::Timeout( Event *ev ) +{ + // FIXME: stub +} + +void FakkInventory::ChangeItem( int sign ) +{ + // FIXME: stub +} + +int FakkInventory::FindFirstItem( int itemindex, int sign ) +{ + // FIXME: stub + return 0; +} + +void CL_Draw3DModel( float x, float y, float w, float h, qhandle_t model, vec3_t origin, vec3_t rotateoffset, vec3_t offset, vec3_t angle, vec3_t color, str anim ) +{ + // FIXME: stub +} + +qboolean UI_CloseInventory( void ) +{ + // FIXME/ stub + return qfalse; +} diff --git a/code/client/cl_invrender.h b/code/client/cl_invrender.h new file mode 100644 index 00000000..48c602b9 --- /dev/null +++ b/code/client/cl_invrender.h @@ -0,0 +1,98 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_INVRENDER_H__ +#define __CL_INVRENDER_H__ + +class FakkInventory; + +typedef enum { selectsound, rejectsound, changesound } invsound_t; +class FakkItemList : public UIWidget { +protected: + inventory_type_t *type; + uipopup_describe m_describe[ 10 ]; + inventory_item_t *m_hoveritem; + inventory_item_t *m_lastmenuitem; + FakkInventory *m_parent; + float m_hovertop; + +public: + CLASS_PROTOTYPE( FakkItemList ); + + FakkItemList(); + ~FakkItemList(); + + void VerifyItemUp( inventory_item_t *item, qboolean warpmouse ); + void setType( inventory_type_t *t ); + void Create( float x, float y, FakkInventory *parent ); + bool HasAnyItems( void ); + void Draw( void ); + void OnLeftMouseDown( Event *ev ); + void OnRightMouseDown( Event *ev ); + void OnLeftMouseUp( Event *ev ); + void OnRightMouseUp( Event *ev ); + void OnMouseMove( Event *ev ); + void OnMouseEnter( Event *ev ); + void OnMouseLeave( Event *ev ); + void OnMenuKilled( Event *ev ); + void EquipItem( Event *ev ); +}; + +class FakkInventory : public UIWidget { +protected: + inventory_t *m_inv; + SafePtr m_currentlist; + inventory_type_t *m_currenttype; + int m_currentitemnum; + +public: + CLASS_PROTOTYPE( FakkInventory ); + +protected: + void VerifyItemUp( inventory_item_t *item, qboolean warpmouse ); + +public: + FakkInventory(); + ~FakkInventory(); + + void setInventory( inventory_t *i ); + void Draw( void ); + void OnMouseMove( Event *ev ); + void OnMouseLeave( Event *ev ); + void OnMouseEnter( Event *ev ); + void OnMouseDown( Event *ev ); + void WarpTo( const char *name ); + void WarpTo( int slotnum ); + void NextItem( void ); + void PrevItem( void ); + qboolean isDying( void ); + qboolean KeyEvent( int key, unsigned int time ); + void PlaySound( invsound_t type ); + void Timeout( Event *ev ); + void ChangeItem( int sign ); + int FindFirstItem( int itemindex, int sign ); +}; + +void CL_Draw3DModel( float x, float y, float w, float h, qhandle_t model, vec3_t origin, vec3_t rotateoffset, vec3_t offset, vec3_t angle, vec3_t color, str anim ); +qboolean UI_CloseInventory( void ); + +#endif // __CL_INVRENDER_H__ diff --git a/code/client/cl_keys.cpp b/code/client/cl_keys.cpp new file mode 100644 index 00000000..e27f050b --- /dev/null +++ b/code/client/cl_keys.cpp @@ -0,0 +1,1881 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#include "client.h" +#include "cl_ui.h" +#include "../uilib/ui_public.h" + +/* + +key up events are sent even if in console mode + +*/ + +field_t historyEditLines[COMMAND_HISTORY]; + +int nextHistoryLine; // the last line in the history buffer, not masked +int historyLine; // the line being displayed from history buffer + // will be <= nextHistoryLine + +field_t g_consoleField; +field_t chatField; +qboolean chat_team; + +int chat_playerNum; + + +qboolean key_overstrikeMode; + +int anykeydown; +qkey_t keys[MAX_KEYS]; +qkey_t altkeys[MAX_KEYS]; +qkey_t ctrlkeys[MAX_KEYS]; + +qboolean menubound[MAX_KEYS]; + +qboolean alt_down; +qboolean ctrl_down; + +typedef struct { + char *name; + int keynum; +} keyname_t; + + +// names not in this list can either be lowercase ascii, or '0xnn' hex sequences +keyname_t keynames[] = +{ + {"TAB", K_TAB}, + {"ENTER", K_ENTER}, + {"ESCAPE", K_ESCAPE}, + {"SPACE", K_SPACE}, + {"BACKSPACE", K_BACKSPACE}, + {"UPARROW", K_UPARROW}, + {"DOWNARROW", K_DOWNARROW}, + {"LEFTARROW", K_LEFTARROW}, + {"RIGHTARROW", K_RIGHTARROW}, + + {"ALT", K_ALT}, + // wombat: mohaa knows LCTRL and RCTRL, LSHIFT, RSHIFT + {"CTRL", K_CTRL}, + {"LCTRL", K_CTRL}, + {"RCTRL", K_CTRL}, + + {"SHIFT", K_SHIFT}, + {"LSHIFT", K_SHIFT}, + {"RSHIFT", K_SHIFT}, + + {"COMMAND", K_COMMAND}, + + {"CAPSLOCK", K_CAPSLOCK}, + + + {"F1", K_F1}, + {"F2", K_F2}, + {"F3", K_F3}, + {"F4", K_F4}, + {"F5", K_F5}, + {"F6", K_F6}, + {"F7", K_F7}, + {"F8", K_F8}, + {"F9", K_F9}, + {"F10", K_F10}, + {"F11", K_F11}, + {"F12", K_F12}, + {"F13", K_F13}, + {"F14", K_F14}, + {"F15", K_F15}, + + {"INS", K_INS}, + {"DEL", K_DEL}, + {"PGDN", K_PGDN}, + {"PGUP", K_PGUP}, + {"HOME", K_HOME}, + {"END", K_END}, + + {"MOUSE1", K_MOUSE1}, + {"MOUSE2", K_MOUSE2}, + {"MOUSE3", K_MOUSE3}, + {"MOUSE4", K_MOUSE4}, + {"MOUSE5", K_MOUSE5}, + + {"MWHEELUP", K_MWHEELUP }, + {"MWHEELDOWN", K_MWHEELDOWN }, + + {"JOY1", K_JOY1}, + {"JOY2", K_JOY2}, + {"JOY3", K_JOY3}, + {"JOY4", K_JOY4}, + {"JOY5", K_JOY5}, + {"JOY6", K_JOY6}, + {"JOY7", K_JOY7}, + {"JOY8", K_JOY8}, + {"JOY9", K_JOY9}, + {"JOY10", K_JOY10}, + {"JOY11", K_JOY11}, + {"JOY12", K_JOY12}, + {"JOY13", K_JOY13}, + {"JOY14", K_JOY14}, + {"JOY15", K_JOY15}, + {"JOY16", K_JOY16}, + {"JOY17", K_JOY17}, + {"JOY18", K_JOY18}, + {"JOY19", K_JOY19}, + {"JOY20", K_JOY20}, + {"JOY21", K_JOY21}, + {"JOY22", K_JOY22}, + {"JOY23", K_JOY23}, + {"JOY24", K_JOY24}, + {"JOY25", K_JOY25}, + {"JOY26", K_JOY26}, + {"JOY27", K_JOY27}, + {"JOY28", K_JOY28}, + {"JOY29", K_JOY29}, + {"JOY30", K_JOY30}, + {"JOY31", K_JOY31}, + {"JOY32", K_JOY32}, + + {"AUX1", K_AUX1}, + {"AUX2", K_AUX2}, + {"AUX3", K_AUX3}, + {"AUX4", K_AUX4}, + {"AUX5", K_AUX5}, + {"AUX6", K_AUX6}, + {"AUX7", K_AUX7}, + {"AUX8", K_AUX8}, + {"AUX9", K_AUX9}, + {"AUX10", K_AUX10}, + {"AUX11", K_AUX11}, + {"AUX12", K_AUX12}, + {"AUX13", K_AUX13}, + {"AUX14", K_AUX14}, + {"AUX15", K_AUX15}, + {"AUX16", K_AUX16}, + + {"KP_HOME", K_KP_HOME }, + {"KP_UPARROW", K_KP_UPARROW }, + {"KP_PGUP", K_KP_PGUP }, + {"KP_LEFTARROW", K_KP_LEFTARROW }, + {"KP_5", K_KP_5 }, + {"KP_RIGHTARROW", K_KP_RIGHTARROW }, + {"KP_END", K_KP_END }, + {"KP_DOWNARROW", K_KP_DOWNARROW }, + {"KP_PGDN", K_KP_PGDN }, + {"KP_ENTER", K_KP_ENTER }, + {"KP_INS", K_KP_INS }, + {"KP_DEL", K_KP_DEL }, + {"KP_SLASH", K_KP_SLASH }, + {"KP_MINUS", K_KP_MINUS }, + {"KP_PLUS", K_KP_PLUS }, + {"KP_NUMLOCK", K_KP_NUMLOCK }, + {"KP_STAR", K_KP_STAR }, + {"KP_EQUALS", K_KP_EQUALS }, + + {"PAUSE", K_PAUSE}, + + {"SEMICOLON", ';'}, // because a raw semicolon seperates commands + + {"WORLD_0", K_WORLD_0}, + {"WORLD_1", K_WORLD_1}, + {"WORLD_2", K_WORLD_2}, + {"WORLD_3", K_WORLD_3}, + {"WORLD_4", K_WORLD_4}, + {"WORLD_5", K_WORLD_5}, + {"WORLD_6", K_WORLD_6}, + {"WORLD_7", K_WORLD_7}, + {"WORLD_8", K_WORLD_8}, + {"WORLD_9", K_WORLD_9}, + {"WORLD_10", K_WORLD_10}, + {"WORLD_11", K_WORLD_11}, + {"WORLD_12", K_WORLD_12}, + {"WORLD_13", K_WORLD_13}, + {"WORLD_14", K_WORLD_14}, + {"WORLD_15", K_WORLD_15}, + {"WORLD_16", K_WORLD_16}, + {"WORLD_17", K_WORLD_17}, + {"WORLD_18", K_WORLD_18}, + {"WORLD_19", K_WORLD_19}, + {"WORLD_20", K_WORLD_20}, + {"WORLD_21", K_WORLD_21}, + {"WORLD_22", K_WORLD_22}, + {"WORLD_23", K_WORLD_23}, + {"WORLD_24", K_WORLD_24}, + {"WORLD_25", K_WORLD_25}, + {"WORLD_26", K_WORLD_26}, + {"WORLD_27", K_WORLD_27}, + {"WORLD_28", K_WORLD_28}, + {"WORLD_29", K_WORLD_29}, + {"WORLD_30", K_WORLD_30}, + {"WORLD_31", K_WORLD_31}, + {"WORLD_32", K_WORLD_32}, + {"WORLD_33", K_WORLD_33}, + {"WORLD_34", K_WORLD_34}, + {"WORLD_35", K_WORLD_35}, + {"WORLD_36", K_WORLD_36}, + {"WORLD_37", K_WORLD_37}, + {"WORLD_38", K_WORLD_38}, + {"WORLD_39", K_WORLD_39}, + {"WORLD_40", K_WORLD_40}, + {"WORLD_41", K_WORLD_41}, + {"WORLD_42", K_WORLD_42}, + {"WORLD_43", K_WORLD_43}, + {"WORLD_44", K_WORLD_44}, + {"WORLD_45", K_WORLD_45}, + {"WORLD_46", K_WORLD_46}, + {"WORLD_47", K_WORLD_47}, + {"WORLD_48", K_WORLD_48}, + {"WORLD_49", K_WORLD_49}, + {"WORLD_50", K_WORLD_50}, + {"WORLD_51", K_WORLD_51}, + {"WORLD_52", K_WORLD_52}, + {"WORLD_53", K_WORLD_53}, + {"WORLD_54", K_WORLD_54}, + {"WORLD_55", K_WORLD_55}, + {"WORLD_56", K_WORLD_56}, + {"WORLD_57", K_WORLD_57}, + {"WORLD_58", K_WORLD_58}, + {"WORLD_59", K_WORLD_59}, + {"WORLD_60", K_WORLD_60}, + {"WORLD_61", K_WORLD_61}, + {"WORLD_62", K_WORLD_62}, + {"WORLD_63", K_WORLD_63}, + {"WORLD_64", K_WORLD_64}, + {"WORLD_65", K_WORLD_65}, + {"WORLD_66", K_WORLD_66}, + {"WORLD_67", K_WORLD_67}, + {"WORLD_68", K_WORLD_68}, + {"WORLD_69", K_WORLD_69}, + {"WORLD_70", K_WORLD_70}, + {"WORLD_71", K_WORLD_71}, + {"WORLD_72", K_WORLD_72}, + {"WORLD_73", K_WORLD_73}, + {"WORLD_74", K_WORLD_74}, + {"WORLD_75", K_WORLD_75}, + {"WORLD_76", K_WORLD_76}, + {"WORLD_77", K_WORLD_77}, + {"WORLD_78", K_WORLD_78}, + {"WORLD_79", K_WORLD_79}, + {"WORLD_80", K_WORLD_80}, + {"WORLD_81", K_WORLD_81}, + {"WORLD_82", K_WORLD_82}, + {"WORLD_83", K_WORLD_83}, + {"WORLD_84", K_WORLD_84}, + {"WORLD_85", K_WORLD_85}, + {"WORLD_86", K_WORLD_86}, + {"WORLD_87", K_WORLD_87}, + {"WORLD_88", K_WORLD_88}, + {"WORLD_89", K_WORLD_89}, + {"WORLD_90", K_WORLD_90}, + {"WORLD_91", K_WORLD_91}, + {"WORLD_92", K_WORLD_92}, + {"WORLD_93", K_WORLD_93}, + {"WORLD_94", K_WORLD_94}, + {"WORLD_95", K_WORLD_95}, + + {"WINDOWS", K_SUPER}, + {"COMPOSE", K_COMPOSE}, + {"MODE", K_MODE}, + {"HELP", K_HELP}, + {"PRINT", K_PRINT}, + {"SYSREQ", K_SYSREQ}, + {"SCROLLOCK", K_SCROLLOCK }, + {"BREAK", K_BREAK}, + {"MENU", K_MENU}, + {"POWER", K_POWER}, + {"EURO", K_EURO}, + {"UNDO", K_UNDO}, + + {NULL,0} +}; + +/* +============================================================================= + +EDIT FIELDS + +============================================================================= +*/ + + +/* +=================== +Field_Draw + +Handles horizontal scrolling and cursor blinking +x, y, and width are in pixels +=================== +*/ +void Field_VariableSizeDraw(fontInfo_t *font, field_t *edit, int x, int y, int width, qboolean showCursor, + qboolean noColorEscape ) { + int len; + int drawLen; + int prestep; + int cursorChar; + char str[MAX_STRING_CHARS]; +// int i; + + drawLen = edit->widthInChars - 1; // - 1 so there is always a space for the cursor + len = strlen( edit->buffer ); + + // guarantee that cursor will be visible + if ( len <= drawLen ) { + prestep = 0; + } else { + if ( edit->scroll + drawLen > len ) { + edit->scroll = len - drawLen; + if ( edit->scroll < 0 ) { + edit->scroll = 0; + } + } + prestep = edit->scroll; + } + + if ( prestep + drawLen > len ) { + drawLen = len - prestep; + } + + // extract characters from the field at + if ( drawLen >= MAX_STRING_CHARS ) { + Com_Error( ERR_DROP, "drawLen >= MAX_STRING_CHARS" ); + } + + Com_Memcpy( str, edit->buffer + prestep, drawLen ); + str[ drawLen ] = 0; + + // draw it + /*if ( size == SMALLCHAR_WIDTH ) { + float color[4]; + + color[0] = color[1] = color[2] = color[3] = 1.0; + SCR_DrawSmallStringExt( x, y, str, color, qfalse, noColorEscape ); + } else { + // draw big string with drop shadow + SCR_DrawBigString( x, y, str, 1.0, noColorEscape ); + }*/ + re.Text_Paint(font, x, y, 1.f, 1.f, str, 0, 0, !noColorEscape,0); + + // draw the cursor + if ( showCursor ) { + if ( (int)( cls.realtime >> 8 ) & 1 ) { + return; // off blink + } + + if ( key_overstrikeMode ) { + cursorChar = '|'; + } else { + cursorChar = '_'; + } + +// i = drawLen - strlen( str ); + str[edit->cursor] = 0; + + /*if ( size == SMALLCHAR_WIDTH ) { + SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar ); + } else { + str[0] = cursorChar; + str[1] = 0; + SCR_DrawBigString( x + ( edit->cursor - prestep - i ) * size, y, str, 1.0, qfalse ); + + }*/ + //str[edit->cursor - prestep - i] = cursorChar; + //str[edit->cursor - prestep - i + 1] = 0; + re.Text_PaintChar(&cls.consoleFont, x + re.Text_Width(&cls.consoleFont, str, 0, !noColorEscape), y, 1.f, cursorChar,0); + } +} + +void Field_Draw(fontInfo_t *font, field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ) +{ + Field_VariableSizeDraw(font, edit, x, y, width, showCursor, noColorEscape ); +} + +void Field_BigDraw(fontInfo_t *font, field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ) +{ + Field_VariableSizeDraw(font, edit, x, y, width, showCursor, noColorEscape ); +} + +/* +================ +Field_Paste +================ +*/ +void Field_Paste( field_t *edit ) { + char *cbd; + int pasteLen, i; + + cbd = Sys_GetClipboardData(); + + if ( !cbd ) { + return; + } + + // send as if typed, so insert / overstrike works properly + pasteLen = strlen( cbd ); + for ( i = 0 ; i < pasteLen ; i++ ) { + Field_CharEvent( edit, cbd[i] ); + } + + Z_Free( cbd ); +} + +/* +================= +Field_KeyDownEvent + +Performs the basic line editing functions for the console, +in-game talk, and menu fields + +Key events are used for non-printable characters, others are gotten from char events. +================= +*/ +void Field_KeyDownEvent( field_t *edit, int key ) { + int len; + + // shift-insert is paste + if ( ( ( key == K_INS ) || ( key == K_KP_INS ) ) && keys[K_SHIFT].down ) { + Field_Paste( edit ); + return; + } + + key = tolower( key ); + len = strlen( edit->buffer ); + + switch ( key ) { + case K_DEL: + if ( edit->cursor < len ) { + memmove( edit->buffer + edit->cursor, + edit->buffer + edit->cursor + 1, len - edit->cursor ); + } + break; + + case K_RIGHTARROW: + if ( edit->cursor < len ) { + edit->cursor++; + } + break; + + case K_LEFTARROW: + if ( edit->cursor > 0 ) { + edit->cursor--; + } + break; + + case K_HOME: + edit->cursor = 0; + break; + + case K_END: + edit->cursor = len; + break; + + case K_INS: + key_overstrikeMode = !key_overstrikeMode; + break; + + default: + break; + } + + // Change scroll if cursor is no longer visible + if ( edit->cursor < edit->scroll ) { + edit->scroll = edit->cursor; + } else if ( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len ) { + edit->scroll = edit->cursor - edit->widthInChars + 1; + } +} + +/* +================== +Field_CharEvent +================== +*/ +void Field_CharEvent( field_t *edit, int ch ) { + int len; + + if ( ch == 'v' - 'a' + 1 ) { // ctrl-v is paste + Field_Paste( edit ); + return; + } + + if ( ch == 'c' - 'a' + 1 ) { // ctrl-c clears the field + Field_Clear( edit ); + return; + } + + len = strlen( edit->buffer ); + + if ( ch == 'h' - 'a' + 1 ) { // ctrl-h is backspace + if ( edit->cursor > 0 ) { + memmove( edit->buffer + edit->cursor - 1, + edit->buffer + edit->cursor, len + 1 - edit->cursor ); + edit->cursor--; + if ( edit->cursor < edit->scroll ) + { + edit->scroll--; + } + } + return; + } + + if ( ch == 'a' - 'a' + 1 ) { // ctrl-a is home + edit->cursor = 0; + edit->scroll = 0; + return; + } + + if ( ch == 'e' - 'a' + 1 ) { // ctrl-e is end + edit->cursor = len; + edit->scroll = edit->cursor - edit->widthInChars; + return; + } + + // + // ignore any other non printable chars + // + if ( ch < 32 ) { + return; + } + + if ( key_overstrikeMode ) { + if ( edit->cursor == MAX_EDIT_LINE - 1 ) + return; + edit->buffer[edit->cursor] = ch; + edit->cursor++; + } else { // insert mode + if ( len == MAX_EDIT_LINE - 1 ) { + return; // all full + } + memmove( edit->buffer + edit->cursor + 1, + edit->buffer + edit->cursor, len + 1 - edit->cursor ); + edit->buffer[edit->cursor] = ch; + edit->cursor++; + } + + + if ( edit->cursor >= edit->widthInChars ) { + edit->scroll++; + } + + if ( edit->cursor == len + 1) { + edit->buffer[edit->cursor] = 0; + } +} + +/* +============================================================================= + +CONSOLE LINE EDITING + +============================================================================== +*/ + +/* +==================== +Console_Key + +Handles history and console scrollback +==================== +*/ +void Console_Key (int key) { + // ctrl-L clears screen + if ( key == 'l' && keys[K_CTRL].down ) { + Cbuf_AddText ("clear\n"); + return; + } + + // enter finishes the line + if ( key == K_ENTER || key == K_KP_ENTER ) { + // if not in the game explicitly prepend a slash if needed + if ( cls.state != CA_ACTIVE && g_consoleField.buffer[0] != '\\' + && g_consoleField.buffer[0] != '/' ) { + char temp[MAX_EDIT_LINE-1]; + + Q_strncpyz( temp, g_consoleField.buffer, sizeof( temp ) ); + Com_sprintf( g_consoleField.buffer, sizeof( g_consoleField.buffer ), "\\%s", temp ); + g_consoleField.cursor++; + } + + Com_Printf ( "]%s\n", g_consoleField.buffer ); + + // leading slash is an explicit command + if ( g_consoleField.buffer[0] == '\\' || g_consoleField.buffer[0] == '/' ) { + Cbuf_AddText( g_consoleField.buffer+1 ); // valid command + Cbuf_AddText ("\n"); + } else { + // other text will be chat messages + if ( !g_consoleField.buffer[0] ) { + return; // empty lines just scroll the console without adding to history + } else { + Cbuf_AddText ("cmd say "); + Cbuf_AddText( g_consoleField.buffer ); + Cbuf_AddText ("\n"); + } + } + + // copy line to history buffer + historyEditLines[nextHistoryLine % COMMAND_HISTORY] = g_consoleField; + nextHistoryLine++; + historyLine = nextHistoryLine; + + Field_Clear( &g_consoleField ); + + g_consoleField.widthInChars = g_console_field_width; + + CL_SaveConsoleHistory( ); + + if ( cls.state == CA_DISCONNECTED ) { + SCR_UpdateScreen (); // force an update, because the command + } // may take some time + return; + } + + // command completion + + if (key == K_TAB) { + Field_AutoComplete(&g_consoleField); + return; + } + + // command history (ctrl-p ctrl-n for unix style) + + if ( (key == K_MWHEELUP && keys[K_SHIFT].down) || ( key == K_UPARROW ) || ( key == K_KP_UPARROW ) || + ( ( tolower(key) == 'p' ) && keys[K_CTRL].down ) ) { + if ( nextHistoryLine - historyLine < COMMAND_HISTORY + && historyLine > 0 ) { + historyLine--; + } + g_consoleField = historyEditLines[ historyLine % COMMAND_HISTORY ]; + return; + } + + if ( (key == K_MWHEELDOWN && keys[K_SHIFT].down) || ( key == K_DOWNARROW ) || ( key == K_KP_DOWNARROW ) || + ( ( tolower(key) == 'n' ) && keys[K_CTRL].down ) ) { + historyLine++; + if (historyLine >= nextHistoryLine) { + historyLine = nextHistoryLine; + Field_Clear( &g_consoleField ); + g_consoleField.widthInChars = g_console_field_width; + return; + } + g_consoleField = historyEditLines[ historyLine % COMMAND_HISTORY ]; + return; + } + + // console scrolling + if ( key == K_PGUP ) { + Con_PageUp(); + return; + } + + if ( key == K_PGDN) { + Con_PageDown(); + return; + } + + if ( key == K_MWHEELUP) { //----(SA) added some mousewheel functionality to the console + Con_PageUp(); + if(keys[K_CTRL].down) { // hold to accelerate scrolling + Con_PageUp(); + Con_PageUp(); + } + return; + } + + if ( key == K_MWHEELDOWN) { //----(SA) added some mousewheel functionality to the console + Con_PageDown(); + if(keys[K_CTRL].down) { // hold to accelerate scrolling + Con_PageDown(); + Con_PageDown(); + } + return; + } + + // ctrl-home = top of console + if ( key == K_HOME && keys[K_CTRL].down ) { + Con_Top(); + return; + } + + // ctrl-end = bottom of console + if ( key == K_END && keys[K_CTRL].down ) { + Con_Bottom(); + return; + } + + // pass to the normal editline routine + Field_KeyDownEvent( &g_consoleField, key ); +} + +//============================================================================ + + +/* +================ +Message_Key + +In game talk message +================ +*/ +void Message_Key( int key ) { + + char buffer[MAX_STRING_CHARS]; + + + if (key == K_ESCAPE) { + Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_MESSAGE ); + Field_Clear( &chatField ); + return; + } + + if ( key == K_ENTER || key == K_KP_ENTER ) + { + if ( chatField.buffer[0] && cls.state == CA_ACTIVE ) { + if (chat_playerNum != -1 ) + + Com_sprintf( buffer, sizeof( buffer ), "tell %i \"%s\"\n", chat_playerNum, chatField.buffer ); + + else if (chat_team) + + Com_sprintf( buffer, sizeof( buffer ), "say_team \"%s\"\n", chatField.buffer ); + else + Com_sprintf( buffer, sizeof( buffer ), "say \"%s\"\n", chatField.buffer ); + + + + CL_AddReliableCommand( buffer ); + } + Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_MESSAGE ); + Field_Clear( &chatField ); + return; + } + + Field_KeyDownEvent( &chatField, key ); +} + +//============================================================================ + + +qboolean Key_GetOverstrikeMode( void ) { + return key_overstrikeMode; +} + + +void Key_SetOverstrikeMode( qboolean state ) { + key_overstrikeMode = state; +} + + +/* +=================== +Key_IsDown +=================== +*/ +qboolean Key_IsDown( int keynum ) { + if ( keynum < 0 || keynum >= MAX_KEYS ) { + return qfalse; + } + + return keys[keynum].down; +} + + +/* +=================== +Key_StringToKeynum + +Returns a key number to be used to index keys[] by looking at +the given string. Single ascii characters return themselves, while +the K_* names are matched up. + +0x11 will be interpreted as raw hex, which will allow new controlers + +to be configured even if they don't have defined names. +=================== +*/ +int Key_StringToKeynum( const char *str ) { + keyname_t *kn; + + if ( !str || !str[0] ) { + return -1; + } + if ( !str[1] ) { + return str[0]; + } + + // check for hex code + if ( str[0] == '0' && str[1] == 'x' && strlen( str ) == 4) { + int n1, n2; + + n1 = str[2]; + if ( n1 >= '0' && n1 <= '9' ) { + n1 -= '0'; + } else if ( n1 >= 'a' && n1 <= 'f' ) { + n1 = n1 - 'a' + 10; + } else { + n1 = 0; + } + + n2 = str[3]; + if ( n2 >= '0' && n2 <= '9' ) { + n2 -= '0'; + } else if ( n2 >= 'a' && n2 <= 'f' ) { + n2 = n2 - 'a' + 10; + } else { + n2 = 0; + } + + return n1 * 16 + n2; + } + + // scan for a text match + for ( kn=keynames ; kn->name ; kn++ ) { + if ( !Q_stricmp( str,kn->name ) ) + return kn->keynum; + } + + return -1; +} + +/* +=================== +Key_KeynumToString + +Returns a string (either a single ascii char, a K_* name, or a 0x11 hex string) for the +given keynum. +=================== +*/ +const char *Key_KeynumToString( int keynum ) { + keyname_t *kn; + static char tinystr[5]; + int i, j; + + if ( keynum == -1 ) { + return ""; + } + + if ( keynum < 0 || keynum >= MAX_KEYS ) { + return ""; + } + + // check for printable ascii (don't use quote) + if ( keynum > 32 && keynum < 127 && keynum != '"' && keynum != ';' ) { + tinystr[0] = keynum; + tinystr[1] = 0; + return tinystr; + } + + // check for a key string + for ( kn=keynames ; kn->name ; kn++ ) { + if (keynum == kn->keynum) { + return kn->name; + } + } + + // make a hex string + i = keynum >> 4; + j = keynum & 15; + + tinystr[0] = '0'; + tinystr[1] = 'x'; + tinystr[2] = i > 9 ? i - 10 + 'a' : i + '0'; + tinystr[3] = j > 9 ? j - 10 + 'a' : j + '0'; + tinystr[4] = 0; + + return tinystr; +} + +/* +=================== +Key_KeynumToString + +Returns a string (either a single ascii char, a K_* name, or a 0x11 hex string) for the +given keynum. +=================== +*/ +const char *Key_KeynumToBindString( int keynum ) { + keyname_t *kn; + static char tinystr[5]; + + if ( keynum == -1 ) { + return "Not Bound"; + } + + if ( keynum < 0 || keynum >= MAX_KEYS ) { + return "Out of Range"; + } + + // check for printable ascii (don't use quote) + if ( keynum > 32 && keynum < 127 && keynum != '"' && keynum != ';' ) { + tinystr[0] = keynum; + tinystr[1] = 0; + return tinystr; + } + + // check for a key string + for ( kn=keynames ; kn->name ; kn++ ) { + if (keynum == kn->keynum) { + return kn->name; + } + } + + return "Unknown Key"; +} + + +/* +=================== +Key_SetBinding +=================== +*/ +void Key_SetBinding( int keynum, const char *binding ) { + if ( keynum < 0 || keynum >= MAX_KEYS ) { + return; + } + + // free old bindings + if ( keys[ keynum ].binding ) { + Z_Free( keys[ keynum ].binding ); + } + + // allocate memory for new binding + keys[keynum].binding = CopyString( binding ); + + // consider this like modifying an archived cvar, so the + // file write will be triggered at the next oportunity + cvar_modifiedFlags |= CVAR_ARCHIVE; +} + +/* +=================== +Key_SetAltBinding +=================== +*/ +void Key_SetAltBinding( int keynum, const char *binding ) { + if ( keynum < 0 || keynum >= MAX_KEYS ) { + return; + } + + // free old bindings + if ( altkeys[ keynum ].binding ) { + Z_Free( altkeys[ keynum ].binding ); + } + + // allocate memory for new binding + altkeys[keynum].binding = CopyString( binding ); + + // consider this like modifying an archived cvar, so the + // file write will be triggered at the next oportunity + cvar_modifiedFlags |= CVAR_ARCHIVE; +} + +/* +=================== +Key_SetCtrlBinding +=================== +*/ +void Key_SetCtrlBinding( int keynum, const char *binding ) { + if ( keynum < 0 || keynum >= MAX_KEYS ) { + return; + } + + // free old bindings + if ( ctrlkeys[ keynum ].binding ) { + Z_Free( ctrlkeys[ keynum ].binding ); + } + + // allocate memory for new binding + ctrlkeys[ keynum ].binding = CopyString( binding ); + + // consider this like modifying an archived cvar, so the + // file write will be triggered at the next oportunity + cvar_modifiedFlags |= CVAR_ARCHIVE; +} + + +/* +=================== +Key_GetBinding +=================== +*/ +char *Key_GetBinding( int keynum ) { + if ( keynum < 0 || keynum >= MAX_KEYS ) { + return ""; + } + + return keys[ keynum ].binding; +} + +/* +=================== +Key_GetKey +=================== +*/ + +int Key_GetKey(const char *binding) { + int i; + + if (binding) { + for (i=0 ; i < MAX_KEYS ; i++) { + if (keys[i].binding && Q_stricmp(binding, keys[i].binding) == 0) { + return i; + } + } + } + return -1; +} + +/* +=================== +Key_GetKeynameForCommand +=================== +*/ +const char *Key_GetKeynameForCommand( const char *command ) { + int i; + + for( i = 0; i < MAX_KEYS; i++ ) { + if( !keys[ i ].binding ) { + continue; + } + if( keys[ i ].down && !stricmp( command, keys[ i ].binding ) ) { + return Key_KeynumToString( i ); + } + } + + return "Unknown Command"; +} + +/* +=================== +Key_GetKeysForCommand +=================== +*/ +void Key_GetKeysForCommand( const char *command, int *key1, int *key2 ) { + int i; + + *key1 = *key2 = 0; + + for( i = 0; i < MAX_KEYS; i++ ) { + if( !keys[ i ].binding ) { + continue; + } + if( !stricmp( command, keys[ i ].binding ) ) { + if( *key1 == -1 ) { + *key1 = i; + } else { + *key2 = i; + return; + } + } + } +} + +/* +=================== +Key_Unbind_f +=================== +*/ +void Key_Unbind_f (void) +{ + int b; + + if (Cmd_Argc() != 2) + { + Com_Printf ("unbind : remove commands from a key\n"); + return; + } + + b = Key_StringToKeynum (Cmd_Argv(1)); + if (b==-1) + { + Com_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); + return; + } + + Key_SetBinding (b, ""); +} + +/* +=================== +Key_Unaltbind_f +=================== +*/ +void Key_Unaltbind_f (void) +{ + int b; + + if (Cmd_Argc() != 2) + { + Com_Printf ("unaltbind : remove commands from a key\n"); + return; + } + + b = Key_StringToKeynum (Cmd_Argv(1)); + if (b==-1) + { + Com_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); + return; + } + + Key_SetAltBinding (b, ""); +} + +/* +=================== +Key_Unctrlbind_f +=================== +*/ +void Key_Unctrlbind_f (void) +{ + int b; + + if (Cmd_Argc() != 2) + { + Com_Printf ("unctrlbind : remove commands from a key\n"); + return; + } + + b = Key_StringToKeynum (Cmd_Argv(1)); + if (b==-1) + { + Com_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); + return; + } + + Key_SetCtrlBinding (b, ""); +} + +/* +=================== +Key_Unbindall_f +=================== +*/ +void Key_Unbindall_f (void) +{ + int i; + + for (i=0 ; i < MAX_KEYS; i++) + if (keys[i].binding) + Key_SetBinding (i, ""); +} + + +/* +=================== +Key_Bind_f +=================== +*/ +void Key_Bind_f (void) +{ + int i, c, b; + char cmd[1024]; + + c = Cmd_Argc(); + + if (c < 2) + { + Com_Printf ("bind [command] : attach a command to a key\n"); + return; + } + b = Key_StringToKeynum (Cmd_Argv(1)); + if (b==-1) + { + Com_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); + return; + } + + if (c == 2) + { + if (keys[b].binding) + Com_Printf ("\"%s\" = \"%s\"\n", Cmd_Argv(1), keys[b].binding ); + else + Com_Printf ("\"%s\" is not bound\n", Cmd_Argv(1) ); + return; + } + +// copy the rest of the command line + cmd[0] = 0; // start out with a null string + for (i=2 ; i< c ; i++) + { + strcat (cmd, Cmd_Argv(i)); + if (i != (c-1)) + strcat (cmd, " "); + } + + Key_SetBinding (b, cmd); +} + +/* +=================== +Key_AltBind_f +=================== +*/ +void Key_AltBind_f (void) +{ + int i, c, b; + char cmd[1024]; + + c = Cmd_Argc(); + + if (c < 2) + { + Com_Printf ("altbind [command] : attach a command to a key\n"); + return; + } + b = Key_StringToKeynum (Cmd_Argv(1)); + if (b==-1) + { + Com_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); + return; + } + + if (c == 2) + { + if (altkeys[b].binding) + Com_Printf ("\"%s\" = \"%s\"\n", Cmd_Argv(1), altkeys[b].binding ); + else + Com_Printf ("\"%s\" is not bound\n", Cmd_Argv(1) ); + return; + } + +// copy the rest of the command line + cmd[0] = 0; // start out with a null string + for (i=2 ; i< c ; i++) + { + strcat (cmd, Cmd_Argv(i)); + if (i != (c-1)) + strcat (cmd, " "); + } + + Key_SetAltBinding (b, cmd); +} + +/* +=================== +Key_AltBind_f +=================== +*/ +void Key_CtrlBind_f (void) +{ + int i, c, b; + char cmd[1024]; + + c = Cmd_Argc(); + + if (c < 2) + { + Com_Printf ("ctrlbind [command] : attach a command to a key\n"); + return; + } + b = Key_StringToKeynum (Cmd_Argv(1)); + if (b==-1) + { + Com_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); + return; + } + + if (c == 2) + { + if (ctrlkeys[b].binding) + Com_Printf ("\"%s\" = \"%s\"\n", Cmd_Argv(1), ctrlkeys[b].binding ); + else + Com_Printf ("\"%s\" is not bound\n", Cmd_Argv(1) ); + return; + } + +// copy the rest of the command line + cmd[0] = 0; // start out with a null string + for (i=2 ; i< c ; i++) + { + strcat (cmd, Cmd_Argv(i)); + if (i != (c-1)) + strcat (cmd, " "); + } + + Key_SetCtrlBinding (b, cmd); +} + +/* +============ +Key_WriteBindings + +Writes lines containing "bind key value" +============ +*/ +void Key_WriteBindings( fileHandle_t f ) { + int i; + + FS_Printf (f, "unbindall\n" ); + + for (i=0 ; iinteger ) { + alt_down = down; + } + + if( ( key == K_CTRL || key == K_DEL ) && cl_ctrlbindings->integer ) { + ctrl_down = down; + } + + if( cls.state > CA_DISCONNECTED && cge && !cls.keyCatchers && cge->CG_CheckCaptureKey( key, down, time ) && key != K_ESCAPE ) + { + if( key != '`' && key != '~' ) + return; + } + + if( key == '`' || key == '~' ) + { + if( !down ) { + return; + } + if( Cvar_VariableIntegerValue( "ui_console" ) ) + { + UI_ToggleConsole(); + } + else if( cls.state == CA_ACTIVE ) + { + if( cg_gametype->integer ) { + UI_ToggleDMConsole( 300 ); + } + } + return; + } + + if( down ) + { + if( alt_down && key != K_ALT && key != K_INS ) { + altkeys[ key ].down = down; + } + if( down && ctrl_down && key != K_CTRL ) { + ctrlkeys[ key ].down = down; + } + } + + if( key != K_DEL ) { + ctrlkeys[ key ].down = down; + } + + if (key == K_ENTER) + { + if (down) + { + if (keys[K_ALT].down) + { + Key_ClearStates(); + Cvar_SetValue( "r_fullscreen", + !Cvar_VariableIntegerValue( "r_fullscreen" ) ); + return; + } + } + } + + + if( key == K_MOUSE1 || key == K_MOUSE2 + || key == K_MOUSE3 || key == K_MOUSE4 + || key == K_MOUSE5 ) + { + if( down ) { + cl.mouseButtons |= ( 1 << ( key + 75 ) ); + } else { + cl.mouseButtons &= ~( 1 << ( key + 75 ) ); + } + } + + if( in_guimouse || key <= K_MOUSE3 || key > K_JOY1 ) + { + // keys can still be used for bound actions + if( down && ( key < 128 || key == K_MOUSE4 ) && + ( clc.demoplaying || cls.state == CA_CINEMATIC ) && Key_GetCatcher() == 0 ) { + Cvar_Set( "nextdemo", "" ); + key = K_ESCAPE; + } + + // escape is always handled special + if( key == K_ESCAPE ) { + if( down ) { + qboolean wasup = UI_MenuUp(); + UI_DeactiveFloatingWindows(); + + if( cls.state == CA_CINEMATIC ) + { + SCR_StopCinematic(); + return; + } + + if( cls.realFrametime - last_escape_time <= 1000 ) { + UI_MenuEscape( "main" ); + return; + } + + if( wasup ) { + UI_MenuEscape( "main" ); + return; + } + + if( cl.snap.ps.stats[ STAT_CINEMATIC ] & 1 && cls.state == CA_ACTIVE ) { + Cbuf_AddText( "skipcinematic\n" ); + return; + } + + if( cls.state <= CA_DISCONNECTED || cls.state == CA_ACTIVE ) { + UI_MenuEscape( "main" ); + } + return; + } + } else if( down ) { + if ( ( Key_GetCatcher( ) & KEYCATCH_UI && !menubound[ key ] ) || UI_BindActive() ) { + UI_KeyEvent( key, time ); + } else if( cls.loading & KEYCATCH_MESSAGE ) { + Message_Key( key ); + } else if( cls.state != CA_DISCONNECTED ) { + // send the bound action + kb = altkeys[ key ].binding; + if( !kb || !altkeys[ key ].down ) { + kb = ctrlkeys[ key ].binding; + if( !kb || !ctrlkeys[ key ].down ) { + kb = keys[ key ].binding; + } + } + if( !kb ) { + if( key >= 200 ) { + Com_Printf( "%s is unbound, use controls menu to set.\n" + , Key_KeynumToString( key ) ); + } + } else if( kb[ 0 ] == '+' ) { + int i; + char button[ 1024 ], *buttonPtr; + buttonPtr = button; + for( i = 0;; i++ ) { + if( kb[ i ] == ';' || !kb[ i ] ) { + *buttonPtr = '\0'; + if( button[ 0 ] == '+' ) { + // button commands add keynum and time as parms so that multiple + // sources can be discriminated and subframe corrected + Com_sprintf( cmd, sizeof( cmd ), "%s %i %i\n", button, key, time ); + Cbuf_AddText( cmd ); + } + else { + // down-only command + Cbuf_AddText( button ); + Cbuf_AddText( "\n" ); + } + buttonPtr = button; + while( ( kb[ i ] <= ' ' || kb[ i ] == ';' ) && kb[ i ] != 0 ) { + i++; + } + } + *buttonPtr++ = kb[ i ]; + if( !kb[ i ] ) { + break; + } + } + } else { + // down-only command + Cbuf_AddText( kb ); + Cbuf_AddText( "\n" ); + } + } + return; + } + + if( altkeys[ key ].down ) { + kb = altkeys[ key ].binding; + altkeys[ key ].down = false; + CL_AddKeyUpCommands( key, kb, time ); + } + if( ctrlkeys[ key ].down ) { + kb = ctrlkeys[ key ].binding; + ctrlkeys[ key ].down = false; + CL_AddKeyUpCommands( key, kb, time ); + } + + CL_AddKeyUpCommands( key, keys[ key ].binding, time ); + } +} + + +/* +=================== +CL_CharEvent + +Normal keyboard characters, already shifted / capslocked / etc +=================== +*/ +void CL_CharEvent( int key ) { + // the console key should never be used as a char + if ( key == '`' || key == '~' ) { + return; + } + + // delete is not a printable character and is + // otherwise handled by Field_KeyDownEvent + if ( key == 127 ) { + return; + } + + // distribute the key down event to the apropriate handler + if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) { + return; + } + + if ( Key_GetCatcher( ) & KEYCATCH_UI ) { + UI_CharEvent( key ); + } +} + + +/* +=================== +Key_ClearStates +=================== +*/ +void Key_ClearStates (void) +{ + int i; + + anykeydown = 0; + + for ( i=0 ; i < MAX_KEYS ; i++ ) { + if ( keys[i].down ) { + CL_KeyEvent( i, qfalse, 0 ); + + } + keys[i].down = 0; + keys[i].repeats = 0; + } +} + +static int keyCatchers = 0; + +/* +==================== +Key_GetCatcher +==================== +*/ +int Key_GetCatcher( void ) { + return cls.keyCatchers; +} + +/* +==================== +Key_SetCatcher +==================== +*/ +void Key_SetCatcher( int catcher ) { + // If the catcher state is changing, clear all key states + if( catcher != keyCatchers ) + Key_ClearStates( ); + + keyCatchers = catcher; +} + +// This must not exceed MAX_CMD_LINE +#define MAX_CONSOLE_SAVE_BUFFER 1024 +#define CONSOLE_HISTORY_FILE "omhistory" +static char consoleSaveBuffer[ MAX_CONSOLE_SAVE_BUFFER ]; +static int consoleSaveBufferSize = 0; + +/* +================ +CL_LoadConsoleHistory + +Load the console history from cl_consoleHistory +================ +*/ +void CL_LoadConsoleHistory( void ) +{ + const char *token; + char *text_p; + int i, numChars, numLines = 0; + fileHandle_t f; + + consoleSaveBufferSize = FS_FOpenFileRead( CONSOLE_HISTORY_FILE, &f, qfalse, qtrue ); + if( !f ) + { + Com_Printf( "Couldn't read %s.\n", CONSOLE_HISTORY_FILE ); + return; + } + + if( consoleSaveBufferSize <= MAX_CONSOLE_SAVE_BUFFER && + FS_Read( consoleSaveBuffer, consoleSaveBufferSize, f ) == consoleSaveBufferSize ) + { + text_p = consoleSaveBuffer; + + for( i = COMMAND_HISTORY - 1; i >= 0; i-- ) + { + if( !*( token = COM_Parse( &text_p ) ) ) + break; + + historyEditLines[ i ].cursor = atoi( token ); + + if( !*( token = COM_Parse( &text_p ) ) ) + break; + + historyEditLines[ i ].scroll = atoi( token ); + + if( !*( token = COM_Parse( &text_p ) ) ) + break; + + numChars = atoi( token ); + text_p++; + if( numChars > ( strlen( consoleSaveBuffer ) - ( text_p - consoleSaveBuffer ) ) ) + { + Com_DPrintf( S_COLOR_YELLOW "WARNING: probable corrupt history\n" ); + break; + } + Com_Memcpy( historyEditLines[ i ].buffer, + text_p, numChars ); + historyEditLines[ i ].buffer[ numChars ] = '\0'; + text_p += numChars; + + numLines++; + } + + memmove( &historyEditLines[ 0 ], &historyEditLines[ i + 1 ], + numLines * sizeof( field_t ) ); + for( i = numLines; i < COMMAND_HISTORY; i++ ) + Field_Clear( &historyEditLines[ i ] ); + + historyLine = nextHistoryLine = numLines; + } + else + Com_Printf( "Couldn't read %s.\n", CONSOLE_HISTORY_FILE ); + + FS_FCloseFile( f ); +} + +/* +================ +CL_SaveConsoleHistory + +Save the console history into the cvar cl_consoleHistory +so that it persists across invocations of q3 +================ +*/ +void CL_SaveConsoleHistory( void ) +{ + int i; + int lineLength, saveBufferLength, additionalLength; + fileHandle_t f; + + consoleSaveBuffer[ 0 ] = '\0'; + + i = ( nextHistoryLine - 1 ) % COMMAND_HISTORY; + do + { + if( historyEditLines[ i ].buffer[ 0 ] ) + { + lineLength = strlen( historyEditLines[ i ].buffer ); + saveBufferLength = strlen( consoleSaveBuffer ); + + //ICK + additionalLength = lineLength + strlen( "999 999 999 " ); + + if( saveBufferLength + additionalLength < MAX_CONSOLE_SAVE_BUFFER ) + { + Q_strcat( consoleSaveBuffer, MAX_CONSOLE_SAVE_BUFFER, + va( "%d %d %d %s ", + historyEditLines[ i ].cursor, + historyEditLines[ i ].scroll, + lineLength, + historyEditLines[ i ].buffer ) ); + } + else + break; + } + i = ( i - 1 + COMMAND_HISTORY ) % COMMAND_HISTORY; + } + while( i != ( nextHistoryLine - 1 ) % COMMAND_HISTORY ); + + consoleSaveBufferSize = strlen( consoleSaveBuffer ); + + f = FS_FOpenFileWrite( CONSOLE_HISTORY_FILE ); + if( !f ) + { + Com_Printf( "Couldn't write %s.\n", CONSOLE_HISTORY_FILE ); + return; + } + + if( FS_Write( consoleSaveBuffer, consoleSaveBufferSize, f ) < consoleSaveBufferSize ) + Com_Printf( "Couldn't write %s.\n", CONSOLE_HISTORY_FILE ); + + FS_FCloseFile( f ); +} diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp new file mode 100644 index 00000000..0092cb40 --- /dev/null +++ b/code/client/cl_main.cpp @@ -0,0 +1,4366 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// cl_main.c -- client main loop + +#include "client.h" +#include "server.h" +#include "cl_ui.h" +#include +#include "../sys/sys_local.h" +#include +#ifdef USE_RENDERER_DLL +#include "../sys/sys_loadlib.h" +#endif + +cvar_t *cl_nodelta; +cvar_t *cl_debugMove; + +cvar_t *cl_noprint; +cvar_t *cl_motd; + +cvar_t *rcon_client_password; +cvar_t *rconAddress; + +cvar_t *cl_timeout; +cvar_t *cl_connect_timeout; +cvar_t *cl_maxpackets; +cvar_t *cl_packetdup; +cvar_t *cl_master; +cvar_t *cl_timeNudge; +cvar_t *cl_showTimeDelta; +cvar_t *cl_freezeDemo; + +cvar_t *cl_shownet; +cvar_t *cl_showSend; +cvar_t *cl_timedemo; +cvar_t *cl_timedemoLog; +cvar_t *cl_autoRecordDemo; +cvar_t *cl_aviFrameRate; +cvar_t *cl_aviMotionJpeg; +cvar_t *cl_forceavidemo; + +cvar_t *cl_freelook; +cvar_t *cl_sensitivity; +cvar_t *cl_platformSensitivity; + +cvar_t *cl_mouseAccel; +cvar_t *cl_showMouseRate; + +cvar_t *cl_altbindings; +cvar_t *cl_ctrlbindings; + +cvar_t *m_pitch; +cvar_t *m_yaw; +cvar_t *m_forward; +cvar_t *m_side; +cvar_t *m_filter; + +cvar_t *cl_activeAction; + +cvar_t *cl_motdString; + +cvar_t *cl_allowDownload; +cvar_t *cg_gametype; +cvar_t *cl_conXOffset; +cvar_t *cl_inGameVideo; + +cvar_t *cl_serverStatusResendTime; +cvar_t *cl_trn; +cvar_t *cl_langamerefreshstatus; + +cvar_t *cl_lanForcePackets; + +cvar_t *cl_guidServerUniq; + +cvar_t *wombat; + +cvar_t *cl_r_fullscreen; + +cvar_t *cl_consoleKeys; + +clientActive_t cl; +clientConnection_t clc; +clientStatic_t cls; +clientGameExport_t *cge; +//vm_t *cgvm; + +// Structure containing functions exported from refresh DLL +refexport_t re; + +qboolean camera_reset; +qboolean camera_active; +vec3_t camera_offset; + +#ifdef USE_RENDERER_DLL +// su44: for plugable renderer system +refexport_t* (*DGetRefAPI)(int apiVersion, refimport_t * rimp) = NULL; +static cvar_t *cl_renderer = NULL; +static void *rendererLib = NULL; +#endif // USE_RENDERER_DLL + + +ping_t cl_pinglist[MAX_PINGREQUESTS]; + +typedef struct serverStatus_s +{ + char string[BIG_INFO_STRING]; + netadr_t address; + int time, startTime; + qboolean pending; + qboolean print; + qboolean retrieved; +} serverStatus_t; + +serverStatus_t cl_serverStatusList[MAX_SERVERSTATUSREQUESTS]; +int serverStatusCount; + +#if defined __USEA3D && defined __A3D_GEOM + void hA3Dg_ExportRenderGeom (refexport_t *incoming_re); +#endif + +extern void SV_BotFrame( int time ); +void CL_CheckForResend( void ); +void CL_ShowIP_f(void); +void CL_ServerStatus_f(void); +void CL_ServerStatusResponse( netadr_t from, msg_t *msg ); + +void CL_GamespyServers_f( void ); + +static qboolean cl_bCLSystemStarted = qfalse; + +/* +=============== +CL_CDDialog + +Called by Com_Error when a cd is needed +=============== +*/ +void CL_CDDialog( void ) { + cls.cddialog = qtrue; // start it next frame +} + +/* +====================== +get_camera_offset +====================== +*/ +float *get_camera_offset( qboolean *lookactive, qboolean *resetview ) +{ + *resetview = camera_reset; + *lookactive = camera_active; + return camera_offset; +} + + +/* +======================================================================= + +CLIENT RELIABLE COMMAND COMMUNICATION + +======================================================================= +*/ + +/* +====================== +CL_AddReliableCommand + +The given command will be transmitted to the server, and is gauranteed to +not have future usercmd_t executed before it is executed +====================== +*/ +void CL_AddReliableCommand( const char *cmd ) { + int index; + + // if we would be losing an old command that hasn't been acknowledged, + // we must drop the connection + if ( clc.reliableSequence - clc.reliableAcknowledge > MAX_RELIABLE_COMMANDS ) { + Com_Error( ERR_DROP, "Client command overflow" ); + } + clc.reliableSequence++; + index = clc.reliableSequence & ( MAX_RELIABLE_COMMANDS - 1 ); + Q_strncpyz( clc.reliableCommands[ index ], cmd, sizeof( clc.reliableCommands[ index ] ) ); +} + +/* +====================== +CL_ChangeReliableCommand +====================== +*/ +void CL_ChangeReliableCommand( void ) { + int r, index, l; + + r = clc.reliableSequence - (random() * 5); + index = clc.reliableSequence & ( MAX_RELIABLE_COMMANDS - 1 ); + l = strlen(clc.reliableCommands[ index ]); + if ( l >= MAX_STRING_CHARS - 1 ) { + l = MAX_STRING_CHARS - 2; + } + clc.reliableCommands[ index ][ l ] = '\n'; + clc.reliableCommands[ index ][ l+1 ] = '\0'; +} + +/* +======================================================================= + +CLIENT SIDE DEMO RECORDING + +======================================================================= +*/ + +/* +==================== +CL_WriteDemoMessage + +Dumps the current net message, prefixed by the length +==================== +*/ +void CL_WriteDemoMessage ( msg_t *msg, int headerBytes ) { + int len, swlen; + + // write the packet sequence + len = clc.serverMessageSequence; + swlen = LittleLong( len ); + FS_Write (&swlen, 4, clc.demofile); + + // skip the packet sequencing information + len = msg->cursize - headerBytes; + swlen = LittleLong(len); + FS_Write (&swlen, 4, clc.demofile); + FS_Write ( msg->data + headerBytes, len, clc.demofile ); +} + + +/* +==================== +CL_StopRecording_f + +stop recording a demo +==================== +*/ +void CL_StopRecord_f( void ) { + int len; + + if ( !clc.demorecording ) { + Com_Printf ("Not recording a demo.\n"); + return; + } + + // finish up + len = -1; + FS_Write (&len, 4, clc.demofile); + FS_Write (&len, 4, clc.demofile); + FS_FCloseFile (clc.demofile); + clc.demofile = 0; + clc.demorecording = qfalse; + clc.spDemoRecording = qfalse; + Com_Printf ("Stopped demo.\n"); +} + +/* +================== +CL_DemoFilename +================== +*/ +void CL_DemoFilename( int number, char *fileName ) { + int a,b,c,d; + + if(number < 0 || number > 9999) + number = 9999; + + a = number / 1000; + number -= a*1000; + b = number / 100; + number -= b*100; + c = number / 10; + number -= c*10; + d = number; + + Com_sprintf( fileName, MAX_OSPATH, "demo%i%i%i%i" + , a, b, c, d ); +} + +/* +==================== +CL_Record_f + +record + +Begins recording a demo from the current position +==================== +*/ +static char demoName[MAX_QPATH]; // compiler bug workaround +void CL_Record_f( void ) { + char name[MAX_OSPATH]; + byte bufData[MAX_MSGLEN]; + msg_t buf; + int i; + int len; + entityState_t *ent; + entityState_t nullstate; + char *s; + + if ( Cmd_Argc() > 2 ) { + Com_Printf ("record \n"); + return; + } + + if ( clc.demorecording ) { + if (!clc.spDemoRecording) { + Com_Printf ("Already recording.\n"); + } + return; + } + + if ( cls.state != CA_ACTIVE ) { + Com_Printf ("You must be in a level to record.\n"); + return; + } + + // sync 0 doesn't prevent recording, so not forcing it off .. everyone does g_sync 1 ; record ; g_sync 0 .. + if ( NET_IsLocalAddress( clc.serverAddress ) && !Cvar_VariableValue( "g_synchronousClients" ) ) { + Com_Printf (S_COLOR_YELLOW "WARNING: You should set 'g_synchronousClients 1' for smoother demo recording\n"); + } + + if ( Cmd_Argc() == 2 ) { + s = Cmd_Argv(1); + Q_strncpyz( demoName, s, sizeof( demoName ) ); + Com_sprintf (name, sizeof(name), "demos/%s.dm_%d", demoName, PROTOCOL_VERSION ); + } else { + int number; + + // scan for a free demo name + for ( number = 0 ; number <= 9999 ; number++ ) { + CL_DemoFilename( number, demoName ); + Com_sprintf (name, sizeof(name), "demos/%s.dm_%d", demoName, PROTOCOL_VERSION ); + + if (!FS_FileExists(name)) + break; // file doesn't exist + } + } + + // open the demo file + + Com_Printf ("recording to %s.\n", name); + clc.demofile = FS_FOpenFileWrite( name ); + if ( !clc.demofile ) { + Com_Printf ("ERROR: couldn't open.\n"); + return; + } + clc.demorecording = qtrue; + if (Cvar_VariableValue("ui_recordSPDemo")) { + clc.spDemoRecording = qtrue; + } else { + clc.spDemoRecording = qfalse; + } + + + Q_strncpyz( clc.demoName, demoName, sizeof( clc.demoName ) ); + + // don't start saving messages until a non-delta compressed message is received + clc.demowaiting = qtrue; + + // write out the gamestate message + MSG_Init (&buf, bufData, sizeof(bufData)); + MSG_Bitstream(&buf); + + // NOTE, MRE: all server->client messages now acknowledge + MSG_WriteLong( &buf, clc.reliableSequence ); + + MSG_WriteByte (&buf, svc_gamestate); + MSG_WriteLong (&buf, clc.serverCommandSequence ); + + // configstrings + for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { + if ( !cl.gameState.stringOffsets[i] ) { + continue; + } + s = cl.gameState.stringData + cl.gameState.stringOffsets[i]; + MSG_WriteByte (&buf, svc_configstring); + MSG_WriteShort (&buf, i); + MSG_WriteBigString (&buf, s); + } + + // baselines + Com_Memset (&nullstate, 0, sizeof(nullstate)); + for ( i = 0; i < MAX_GENTITIES ; i++ ) { + ent = &cl.entityBaselines[i]; + if ( !ent->number ) { + continue; + } + MSG_WriteByte (&buf, svc_baseline); + MSG_WriteDeltaEntity (&buf, &nullstate, ent, qtrue ); + } + + MSG_WriteByte( &buf, svc_EOF ); + + // finished writing the gamestate stuff + + // write the client num + MSG_WriteLong(&buf, clc.clientNum); + // write the checksum feed + MSG_WriteLong(&buf, clc.checksumFeed); + + // finished writing the client packet + MSG_WriteByte( &buf, svc_EOF ); + + // write it to the demo file + len = LittleLong( clc.serverMessageSequence - 1 ); + FS_Write (&len, 4, clc.demofile); + + len = LittleLong (buf.cursize); + FS_Write (&len, 4, clc.demofile); + FS_Write (buf.data, buf.cursize, clc.demofile); + + // the rest of the demo file will be copied from net messages +} + +/* +======================================================================= + +CLIENT SIDE DEMO PLAYBACK + +======================================================================= +*/ + +/* +================= +CL_DemoFrameDurationSDev +================= +*/ +static float CL_DemoFrameDurationSDev( void ) +{ + int i; + int numFrames; + float mean = 0.0f; + float variance = 0.0f; + + if( ( clc.timeDemoFrames - 1 ) > MAX_TIMEDEMO_DURATIONS ) + numFrames = MAX_TIMEDEMO_DURATIONS; + else + numFrames = clc.timeDemoFrames - 1; + + for( i = 0; i < numFrames; i++ ) + mean += clc.timeDemoDurations[ i ]; + mean /= numFrames; + + for( i = 0; i < numFrames; i++ ) + { + float x = clc.timeDemoDurations[ i ]; + + variance += ( ( x - mean ) * ( x - mean ) ); + } + variance /= numFrames; + + return sqrt( variance ); +} + +/* +================= +CL_DemoCompleted +================= +*/ +void CL_DemoCompleted( void ) +{ + char buffer[ MAX_STRING_CHARS ]; + + if( cl_timedemo && cl_timedemo->integer ) + { + int time; + + time = Sys_Milliseconds() - clc.timeDemoStart; + if( time > 0 ) + { + // Millisecond times are frame durations: + // minimum/average/maximum/std deviation + Com_sprintf( buffer, sizeof( buffer ), + "%i frames %3.1f seconds %3.1f fps %d.0/%.1f/%d.0/%.1f ms\n", + clc.timeDemoFrames, + time/1000.0, + clc.timeDemoFrames*1000.0 / time, + clc.timeDemoMinDuration, + time / (float)clc.timeDemoFrames, + clc.timeDemoMaxDuration, + CL_DemoFrameDurationSDev( ) ); + Com_Printf( "%s", buffer ); + + // Write a log of all the frame durations + if( cl_timedemoLog && strlen( cl_timedemoLog->string ) > 0 ) + { + int i; + int numFrames; + fileHandle_t f; + + if( ( clc.timeDemoFrames - 1 ) > MAX_TIMEDEMO_DURATIONS ) + numFrames = MAX_TIMEDEMO_DURATIONS; + else + numFrames = clc.timeDemoFrames - 1; + + f = FS_FOpenFileWrite( cl_timedemoLog->string ); + if( f ) + { + FS_Printf( f, "# %s", buffer ); + + for( i = 0; i < numFrames; i++ ) + FS_Printf( f, "%d\n", clc.timeDemoDurations[ i ] ); + + FS_FCloseFile( f ); + Com_Printf( "%s written\n", cl_timedemoLog->string ); + } + else + { + Com_Printf( "Couldn't open %s for writing\n", + cl_timedemoLog->string ); + } + } + } + } + + CL_Disconnect( qtrue ); + CL_NextDemo(); +} + +/* +================= +CL_ReadDemoMessage +================= +*/ +void CL_ReadDemoMessage( void ) { + int r; + msg_t buf; + byte bufData[ MAX_MSGLEN ]; + int s; + + if ( !clc.demofile ) { + CL_DemoCompleted (); + return; + } + + // get the sequence number + r = FS_Read( &s, 4, clc.demofile); + if ( r != 4 ) { + CL_DemoCompleted (); + return; + } + clc.serverMessageSequence = LittleLong( s ); + + // init the message + MSG_Init( &buf, bufData, sizeof( bufData ) ); + + // get the length + r = FS_Read (&buf.cursize, 4, clc.demofile); + if ( r != 4 ) { + CL_DemoCompleted (); + return; + } + buf.cursize = LittleLong( buf.cursize ); + if ( buf.cursize == -1 ) { + CL_DemoCompleted (); + return; + } + if ( buf.cursize > buf.maxsize ) { + Com_Error (ERR_DROP, "CL_ReadDemoMessage: demoMsglen > MAX_MSGLEN"); + } + r = FS_Read( buf.data, buf.cursize, clc.demofile ); + if ( r != buf.cursize ) { + Com_Printf( "Demo file was truncated.\n"); + CL_DemoCompleted (); + return; + } + + clc.lastPacketTime = cls.realtime; + buf.readcount = 0; + CL_ParseServerMessage( &buf ); +} + +/* +==================== +CL_WalkDemoExt +==================== +*/ +static void CL_WalkDemoExt(char *arg, char *name, int *demofile) +{ + int i = 0; + *demofile = 0; + while(demo_protocols[i]) + { + Com_sprintf (name, MAX_OSPATH, "demos/%s.dm_%d", arg, demo_protocols[i]); + FS_FOpenFileRead( name, demofile, qtrue, qtrue ); + if (*demofile) + { + Com_Printf("Demo file: %s\n", name); + break; + } + else + Com_Printf("Not found: %s\n", name); + i++; + } +} + +/* +==================== +CL_PlayDemo_f + +demo + +==================== +*/ +void CL_PlayDemo_f( void ) { + char name[MAX_OSPATH]; + char *arg, *ext_test; + int protocol, i; + char retry[MAX_OSPATH]; + + if (Cmd_Argc() != 2) { + Com_Printf ("playdemo \n"); + return; + } + + // make sure a local server is killed + // 2 means don't force disconnect of local client + Cvar_Set( "sv_killserver", "2" ); + + CL_Disconnect( qtrue ); + + // open the demo file + arg = Cmd_Argv(1); + + // check for an extension .dm_?? (?? is protocol) + ext_test = arg + strlen(arg) - 6; + if ((strlen(arg) > 6) && (ext_test[0] == '.') && ((ext_test[1] == 'd') || (ext_test[1] == 'D')) && ((ext_test[2] == 'm') || (ext_test[2] == 'M')) && (ext_test[3] == '_')) + { + protocol = atoi(ext_test+4); + i=0; + while(demo_protocols[i]) + { + if (demo_protocols[i] == protocol) + break; + i++; + } + if (demo_protocols[i]) + { + Com_sprintf (name, sizeof(name), "demos/%s", arg); + FS_FOpenFileRead( name, &clc.demofile, qtrue, qtrue ); + } else { + Com_Printf("Protocol %d not supported for demos\n", protocol); + Q_strncpyz(retry, arg, sizeof(retry)); + retry[strlen(retry)-6] = 0; + CL_WalkDemoExt( retry, name, &clc.demofile ); + } + } else { + CL_WalkDemoExt( arg, name, &clc.demofile ); + } + + if (!clc.demofile) { + Com_Error( ERR_DROP, "couldn't open %s", name); + return; + } + Q_strncpyz( clc.demoName, Cmd_Argv(1), sizeof( clc.demoName ) ); + + Con_Close(); + + cls.state = CA_CONNECTED; + clc.demoplaying = qtrue; + Q_strncpyz( cls.servername, Cmd_Argv(1), sizeof( cls.servername ) ); + + // read demo messages until connected + while ( cls.state >= CA_CONNECTED && cls.state < CA_PRIMED ) { + CL_ReadDemoMessage(); + } + // don't get the first snapshot this frame, to prevent the long + // time from the gamestate load from messing causing a time skip + clc.firstDemoFrameSkipped = qfalse; +} + + +/* +==================== +CL_StartDemoLoop + +Closing the main menu will restart the demo loop +==================== +*/ +void CL_StartDemoLoop( void ) { + // start the demo loop again + Cbuf_AddText ("d1\n"); + Key_SetCatcher( 0 ); +} + +/* +================== +CL_NextDemo + +Called when a demo or cinematic finishes +If the "nextdemo" cvar is set, that command will be issued +================== +*/ +void CL_NextDemo( void ) { + char v[MAX_STRING_CHARS]; + + Q_strncpyz( v, Cvar_VariableString ("nextdemo"), sizeof(v) ); + v[MAX_STRING_CHARS-1] = 0; + Com_DPrintf("CL_NextDemo: %s\n", v ); + if (!v[0]) { + return; + } + + Cvar_Set ("nextdemo",""); + Cbuf_AddText (v); + Cbuf_AddText ("\n"); + Cbuf_Execute(0); +} + + +//====================================================================== + +/* +===================== +CL_ShutdownAll +===================== +*/ +void CL_ShutdownAll(void) { + +#ifdef USE_CURL + CL_cURL_Shutdown(); +#endif + // clear sounds + S_DisableSounds(); + // shutdown CGame + CL_ShutdownCGame(); + // shutdown UI + CL_ShutdownUI(); + + // su44: shutdown TIKI system, because it's dependent on renderer + TIKI_FreeAll(); + + // shutdown the renderer + if ( re.Shutdown ) { + re.Shutdown( qfalse ); // don't destroy window or context + } + + cls.uiStarted = qfalse; + cls.cgameStarted = qfalse; + cls.rendererRegistered = qfalse; +} + +/* +================= +CL_FlushMemory + +Called by CL_MapLoading, CL_Connect_f, CL_PlayDemo_f, and CL_ParseGamestate the only +ways a client gets into a game +Also called by Com_Error +================= +*/ +void CL_FlushMemory( void ) { + + // shutdown all the client stuff + CL_ShutdownCGame(); + S_StopAllSounds( qtrue ); + UI_ClearState(); + cls.rendererRegistered = qfalse; +} + +/* +===================== +CL_MapLoading + +A local server is starting to load a map, so update the +screen to let the user know about it, then dump all client +memory on the hunk from cgame, ui, and renderer +===================== +*/ +void CL_MapLoading( qboolean flush, const char *pszMapName ) { + if ( com_dedicated->integer ) { + cls.state = CA_DISCONNECTED; + Key_SetCatcher( KEYCATCH_CONSOLE ); + return; + } + + if ( !com_cl_running->integer ) { + return; + } + + Con_Close(); + Key_SetCatcher( 0 ); + + // if we are already connected to the local host, stay connected + if ( cls.state >= CA_CONNECTED && !Q_stricmp( cls.servername, "localhost" ) ) { + cls.state = CA_CONNECTED; // so the connect screen is drawn + Com_Memset( cls.updateInfoString, 0, sizeof( cls.updateInfoString ) ); + Com_Memset( clc.serverMessage, 0, sizeof( clc.serverMessage ) ); + Com_Memset( &cl.gameState, 0, sizeof( cl.gameState ) ); + clc.lastPacketSentTime = -9999; + SCR_UpdateScreen(); + } else { + // clear nextmap so the cinematic shutdown doesn't execute it + Cvar_Set( "nextmap", "" ); + CL_Disconnect( qtrue ); + Q_strncpyz( cls.servername, "localhost", sizeof(cls.servername) ); + cls.state = CA_CHALLENGING; // so the connect screen is drawn + Key_SetCatcher( 0 ); + SCR_UpdateScreen(); + clc.connectTime = -RETRANSMIT_TIMEOUT; + NET_StringToAdr( cls.servername, &clc.serverAddress); + // we don't need a challenge on the localhost + + CL_CheckForResend(); + } +} + +/* +===================== +CL_ClearState + +Called before parsing a gamestate +===================== +*/ +void CL_ClearState( void ) +{ + CL_ShutdownCGame(); + + if( !com_sv_running->integer ) { + S_StopAllSounds( qtrue ); + } + + UI_ClearState(); + + Com_Memset( &cl, 0, sizeof( clientActive_t ) ); +} + +/* +==================== +CL_UpdateGUID + +update cl_guid using QKEY_FILE and optional prefix +==================== +*/ +static void CL_UpdateGUID( char *prefix, int prefix_len ) +{ + fileHandle_t f; + int len; + + len = FS_SV_FOpenFileRead( QKEY_FILE, &f ); + FS_FCloseFile( f ); + + if( len != QKEY_SIZE ) + Cvar_Set( "cl_guid", "" ); + else + Cvar_Set( "cl_guid", Com_MD5File( QKEY_FILE, QKEY_SIZE, + prefix, prefix_len ) ); +} + + +/* +===================== +CL_Disconnect + +Called when a connection, demo, or cinematic is being terminated. +Goes from a connected state to either a menu state or a console state +Sends a disconnect message to the server +This is also called on Com_Error and Com_Quit, so it shouldn't cause any errors +===================== +*/ +void CL_Disconnect( qboolean showMainMenu ) { + if ( !com_cl_running || !com_cl_running->integer ) { + return; + } + + // shutting down the client so enter full screen ui mode + Cvar_Set("r_uiFullScreen", "1"); + + if ( clc.demorecording ) { + CL_StopRecord_f (); + } + + if (clc.download) { + FS_FCloseFile( clc.download ); + clc.download = 0; + } + *clc.downloadTempName = *clc.downloadName = 0; + Cvar_Set( "cl_downloadName", "" ); + + if ( clc.demofile ) { + FS_FCloseFile( clc.demofile ); + clc.demofile = 0; + } + + SCR_StopCinematic (); + S_ClearSoundBuffer(); + + // send a disconnect message to the server + // send it a few times in case one is dropped + if ( cls.state >= CA_CONNECTED ) { + CL_AddReliableCommand( "disconnect" ); + CL_WritePacket(); + CL_WritePacket(); + CL_WritePacket(); + } + + CL_ClearState (); + + // wipe the client connection + Com_Memset( &clc, 0, sizeof( clientConnection_t ) ); + + cls.state = CA_DISCONNECTED; + + // allow cheats locally + Cvar_Set( "sv_cheats", "1" ); + + // not connected to a pure server anymore + cl_connectedToPureServer = qfalse; + + // Stop recording any video + if( CL_VideoRecording( ) ) { + // Finish rendering current frame + SCR_UpdateScreen( ); + CL_CloseAVI( ); + } + CL_UpdateGUID( NULL, 0 ); +} + + +/* +=================== +CL_ForwardCommandToServer + +adds the current command line as a clientCommand +things like godmode, noclip, etc, are commands directed to the server, +so when they are typed in at the console, they will need to be forwarded. +=================== +*/ +void CL_ForwardCommandToServer( const char *string ) { + char *cmd; + + cmd = Cmd_Argv(0); + + // ignore key up commands + if ( cmd[0] == '-' ) { + return; + } + + if ( clc.demoplaying || cls.state < CA_CONNECTED || cmd[0] == '+' ) { + Com_Printf ("Unknown command \"%s" S_COLOR_WHITE "\"\n", cmd); + return; + } + + if ( Cmd_Argc() > 1 ) { + CL_AddReliableCommand( string ); + } else { + CL_AddReliableCommand( cmd ); + } +} + +/* +=================== +CL_RequestMotd + +=================== +*/ +void CL_RequestMotd( void ) { + char info[MAX_INFO_STRING]; + + if ( !cl_motd->integer ) { + return; + } + Com_Printf( "Resolving %s\n", UPDATE_SERVER_NAME ); + if ( !NET_StringToAdr( UPDATE_SERVER_NAME, &cls.updateServer ) ) { + Com_Printf( "Couldn't resolve address\n" ); + return; + } + cls.updateServer.port = BigShort( PORT_UPDATE ); + Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", UPDATE_SERVER_NAME, + cls.updateServer.ip[0], cls.updateServer.ip[1], + cls.updateServer.ip[2], cls.updateServer.ip[3], + BigShort( cls.updateServer.port ) ); + + info[0] = 0; + // NOTE TTimo xoring against Com_Milliseconds, otherwise we may not have a true randomization + // only srand I could catch before here is tr_noise.c l:26 srand(1001) + // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=382 + // NOTE: the Com_Milliseconds xoring only affects the lower 16-bit word, + // but I decided it was enough randomization + Com_sprintf( cls.updateChallenge, sizeof( cls.updateChallenge ), "%i", ((rand() << 16) ^ rand()) ^ Com_Milliseconds()); + + Info_SetValueForKey( info, "challenge", cls.updateChallenge ); + Info_SetValueForKey( info, "renderer", cls.glconfig.renderer_string ); + Info_SetValueForKey( info, "version", com_version->string ); + + NET_OutOfBandPrint( NS_CLIENT, cls.updateServer, "getmotd \"%s\"\n", info ); +} + +/* +=================== +CL_RequestAuthorization + +Authorization server protocol +----------------------------- + +All commands are text in Q3 out of band packets (leading 0xff 0xff 0xff 0xff). + +Whenever the client tries to get a challenge from the server it wants to +connect to, it also blindly fires off a packet to the authorize server: + +getKeyAuthorize + +cdkey may be "demo" + + +#OLD The authorize server returns a: +#OLD +#OLD keyAthorize +#OLD +#OLD A client will be accepted if the cdkey is valid and it has not been used by any other IP +#OLD address in the last 15 minutes. + + +The server sends a: + +getIpAuthorize + +The authorize server returns a: + +ipAuthorize + +A client will be accepted if a valid cdkey was sent by that ip (only) in the last 15 minutes. +If no response is received from the authorize server after two tries, the client will be let +in anyway. +=================== +*/ +void CL_RequestAuthorization( void ) { + char nums[64]; + int i, j, l; + cvar_t *fs; + + if ( !cls.authorizeServer.port ) { + Com_Printf( "Resolving %s\n", AUTHORIZE_SERVER_NAME ); + if ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &cls.authorizeServer ) ) { + Com_Printf( "Couldn't resolve address\n" ); + return; + } + + cls.authorizeServer.port = BigShort( PORT_AUTHORIZE ); + Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", AUTHORIZE_SERVER_NAME, + cls.authorizeServer.ip[0], cls.authorizeServer.ip[1], + cls.authorizeServer.ip[2], cls.authorizeServer.ip[3], + BigShort( cls.authorizeServer.port ) ); + } + if ( cls.authorizeServer.type == NA_BAD ) { + return; + } + + // only grab the alphanumeric values from the cdkey, to avoid any dashes or spaces + j = 0; + l = strlen( cl_cdkey ); + if ( l > 32 ) { + l = 32; + } + for ( i = 0 ; i < l ; i++ ) { + if ( ( cl_cdkey[i] >= '0' && cl_cdkey[i] <= '9' ) + || ( cl_cdkey[i] >= 'a' && cl_cdkey[i] <= 'z' ) + || ( cl_cdkey[i] >= 'A' && cl_cdkey[i] <= 'Z' ) + ) { + nums[j] = cl_cdkey[i]; + j++; + } + } + nums[j] = 0; + + fs = Cvar_Get ("cl_anonymous", "0", CVAR_INIT|CVAR_SYSTEMINFO ); + + NET_OutOfBandPrint(NS_CLIENT, cls.authorizeServer, "getKeyAuthorize %i %s", fs->integer, nums ); +} + +/* +====================================================================== + +CONSOLE COMMANDS + +====================================================================== +*/ + +/* +================== +CL_ForwardToServer_f +================== +*/ +void CL_ForwardToServer_f( void ) { + if ( cls.state != CA_ACTIVE || clc.demoplaying ) { + Com_Printf ("Not connected to a server.\n"); + return; + } + + // don't forward the first argument + if ( Cmd_Argc() > 1 ) { + CL_AddReliableCommand( Cmd_Args() ); + } +} + +/* +================== +CL_Setenv_f + +Mostly for controlling voodoo environment variables +================== +*/ +void CL_Setenv_f( void ) { + int argc = Cmd_Argc(); + + if ( argc > 2 ) { + char buffer[1024]; + int i; + + strcpy( buffer, Cmd_Argv(1) ); + strcat( buffer, "=" ); + + for ( i = 2; i < argc; i++ ) { + strcat( buffer, Cmd_Argv( i ) ); + strcat( buffer, " " ); + } + + putenv( buffer ); + } else if ( argc == 2 ) { + char *env = getenv( Cmd_Argv(1) ); + + if ( env ) { + Com_Printf( "%s=%s\n", Cmd_Argv(1), env ); + } else { + Com_Printf( "%s undefined\n", Cmd_Argv(1)); + } + } +} + + +/* +================== +CL_Disconnect_f +================== +*/ +void CL_Disconnect_f( void ) { + SCR_StopCinematic(); + Cvar_Set("ui_singlePlayerActive", "0"); + if ( cls.state != CA_DISCONNECTED && cls.state != CA_CINEMATIC ) { + Com_Error (ERR_DISCONNECT, "Disconnected from server"); + } +} + + +/* +================ +CL_Reconnect_f + +================ +*/ +void CL_Reconnect_f( void ) { + if ( !strlen( cls.servername ) || !strcmp( cls.servername, "localhost" ) ) { + Com_Printf( "Can't reconnect to localhost.\n" ); + return; + } + Cvar_Set("ui_singlePlayerActive", "0"); + Cbuf_AddText( va("connect %s\n", cls.servername ) ); +} + +/* +================ +CL_Connect_f + +================ +*/ +void CL_Connect( const char *server ) { + char serverString[ 22 ]; + + Cvar_Set( "ui_singlePlayerActive", "0" ); + + // fire a message off to the motd server + CL_RequestMotd(); + + // clear any previous "server full" type messages + clc.serverMessage[ 0 ] = 0; + + if( com_sv_running->integer && !strcmp( server, "localhost" ) ) { + // if running a local server, kill it + SV_Shutdown( "Server quit" ); + } + + // make sure a local server is killed + Cvar_Set( "sv_killserver", "1" ); + SV_Frame( 0 ); + + CL_Disconnect( qtrue ); + Con_Close(); + + /* MrE: 2000-09-13: now called in CL_DownloadsComplete + CL_FlushMemory( ); + */ + + Q_strncpyz( cls.servername, server, sizeof( cls.servername ) ); + + if( !NET_StringToAdr( cls.servername, &clc.serverAddress ) ) { + Com_Printf( "Bad server address\n" ); + cls.state = CA_DISCONNECTED; + return; + } + if( clc.serverAddress.port == 0 ) { + clc.serverAddress.port = BigShort( PORT_SERVER ); + } + Com_sprintf( serverString, sizeof( serverString ), "%i.%i.%i.%i:%i", + clc.serverAddress.ip[ 0 ], clc.serverAddress.ip[ 1 ], + clc.serverAddress.ip[ 2 ], clc.serverAddress.ip[ 3 ], + BigShort( clc.serverAddress.port ) ); + + Com_Printf( "%s resolved to %s\n", cls.servername, serverString ); + + if( cl_guidServerUniq->integer ) + CL_UpdateGUID( serverString, strlen( serverString ) ); + else + CL_UpdateGUID( NULL, 0 ); + + // if we aren't playing on a lan, we need to authenticate + // with the cd key + // wombat: no authorization in mohaa. need to send challenge to server though + if( NET_IsLocalAddress( clc.serverAddress ) ) { + cls.state = CA_CHALLENGING; + } + else { + cls.state = CA_CONNECTING; + } + + Key_SetCatcher( 0 ); + clc.connectTime = -99999; // CL_CheckForResend() will fire immediately + clc.connectPacketCount = 0; + + // server connection string + Cvar_Set( "cl_currentServerAddress", server ); +} + +/* +================ +CL_Connect_f + +================ +*/ +// we have our own server provided to us by mohaaaa.co.uk +void CL_Connect_f( void ) { + char *server; + + if ( Cmd_Argc() != 2 ) { + Com_Printf( "usage: connect [server]\n"); + return; + } + + server = Cmd_Argv (1); + + CL_Connect( server ); +} + +/* +================ +CL_MenuConnect_f + +================ +*/ +void CL_MenuConnect_f( void ) { + char *server; + + if( Cmd_Argc() != 2 ) { + return; + } + + server = Cmd_Argv( 1 ); + + CL_Connect( Cvar_VariableString( server ) ); +} + +/* +================ +CL_FastConnect_f +================ +*/ +void CL_FastConnect_f( void ) { + static int endTime; + int i; + + if( cls.numlocalservers ) + { + Com_Printf( "Done.\n Connecting To Server\n" ); + + for( i = 0; i < cls.numlocalservers; i++ ) { + Com_Printf( "Server %i - '%s'\n", i, NET_AdrToString( cls.localServers[ i ].adr ) ); + } + + CL_Connect( cls.localServers[ 0 ].hostName ); + Cbuf_AddText( "popmenu 0 ; wait 500 ; popmenu 0 ; wait 500 ; popmenu 0\n" ); + endTime = 123456789; + } + else if( cls.realtime <= endTime || endTime == 123456789 ) + { + if( endTime == 123456789 ) + { + endTime = cls.realtime + 10000; + CL_LocalServers_f(); + Com_Printf( "Searching..." ); + } + + Com_Printf( "." ); + Cbuf_AddText( "wait 500 ; fastconnect\n" ); + } + else + { + Com_Printf( "Done. !Server Not Found!\n" ); + endTime = 123456789; + } +} + +#define MAX_RCON_MESSAGE 1024 + +/* +===================== +CL_Rcon_f + + Send the rest of the command line over as + an unconnected command. +===================== +*/ +void CL_Rcon_f( void ) { + char message[MAX_RCON_MESSAGE]; + netadr_t to; + + if ( !rcon_client_password->string ) { + Com_Printf ("You must set 'rconpassword' before\n" + "issuing an rcon command.\n"); + return; + } + + message[0] = -1; + message[1] = -1; + message[2] = -1; + message[3] = -1; + message[4] = 0; + + Q_strcat (message, MAX_RCON_MESSAGE, "rcon "); + + Q_strcat (message, MAX_RCON_MESSAGE, rcon_client_password->string); + Q_strcat (message, MAX_RCON_MESSAGE, " "); + + // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=543 + Q_strcat (message, MAX_RCON_MESSAGE, Cmd_Cmd()+5); + + if ( cls.state >= CA_CONNECTED ) { + to = clc.netchan.remoteAddress; + } else { + if (!strlen(rconAddress->string)) { + Com_Printf ("You must either be connected,\n" + "or set the 'rconAddress' cvar\n" + "to issue rcon commands\n"); + + return; + } + NET_StringToAdr (rconAddress->string, &to); + if (to.port == 0) { + to.port = BigShort (PORT_SERVER); + } + } + + NET_SendPacket (NS_CLIENT, strlen(message)+1, message, to); +} + +/* +================= +CL_SendPureChecksums +================= +*/ +void CL_SendPureChecksums( void ) { + const char *pChecksums; + char cMsg[MAX_INFO_VALUE]; + int i; + + // if we are pure we need to send back a command with our referenced pk3 checksums + pChecksums = FS_ReferencedPakPureChecksums(); + + // "cp" + // "Yf" + Com_sprintf(cMsg, sizeof(cMsg), "Yf "); + Q_strcat(cMsg, sizeof(cMsg), va("%d ", cl.serverId) ); + Q_strcat(cMsg, sizeof(cMsg), pChecksums); + for (i = 0; i < 2; i++) { + cMsg[i] += 10; + } + CL_AddReliableCommand( cMsg ); +} + +/* +================= +CL_ResetPureClientAtServer +================= +*/ +void CL_ResetPureClientAtServer( void ) { + CL_AddReliableCommand( va("vdr") ); +} + +/* +================= +CL_Vid_Restart_f + +Restart the video subsystem + +we also have to reload the UI, CGame and TIKI system +because the renderer doesn't know what graphics to reload +================= +*/ +void CL_Vid_Restart_f( void ) { + + // Settings may have changed so stop recording now + if( CL_VideoRecording( ) ) { + CL_CloseAVI( ); + } + + if(clc.demorecording) + CL_StopRecord_f(); + + // don't let them loop during the restart + S_StopAllSounds( qtrue ); + // shutdown the renderer and clear the renderer interface + CL_ShutdownRef(); + // shutdown the CGame + CL_ShutdownCGame(); + // initialize the renderer interface + CL_InitRef(); + // client is no longer pure untill new checksums are sent + CL_ResetPureClientAtServer(); + // clear pak references + FS_ClearPakReferences( FS_UI_REF | FS_CGAME_REF ); + // reinitialize the filesystem if the game directory or checksum has changed + FS_ConditionalRestart( clc.checksumFeed ); + + cls.rendererRegistered = qfalse; + cls.uiStarted = qfalse; + cls.cgameStarted = qfalse; + + // unpause so the cgame definately gets a snapshot and renders a frame + Com_Unpause(); + + CL_StartHunkUsers(); + + SV_FinishSvsTimeFixups(); + + S_Init(); + +} + +/* +================= +CL_Snd_Restart_f + +Restart the sound subsystem +The cgame and game must also be forced to restart because +handles will be invalid +================= +*/ +void CL_Snd_Restart_f( void ) { + S_Shutdown(); + S_Init(); + + CL_Vid_Restart_f(); +} + + +/* +================== +CL_PK3List_f +================== +*/ +void CL_OpenedPK3List_f( void ) { + Com_Printf("Opened PK3 Names: %s\n", FS_LoadedPakNames()); +} + +/* +================== +CL_PureList_f +================== +*/ +void CL_ReferencedPK3List_f( void ) { + Com_Printf("Referenced PK3 Names: %s\n", FS_ReferencedPakNames()); +} + +/* +================== +CL_ConfigString +================== +*/ +const char *CL_ConfigString( int index ) { + if( index > MAX_CONFIGSTRINGS ) { + Com_Error( ERR_DROP, "CL_ConfigString: bad index: %i", index ); + } + return &cl.gameState.stringData[ cl.gameState.stringOffsets[ index ] ]; +} + +/* +================== +CL_Configstrings_f +================== +*/ +void CL_Configstrings_f( void ) { + int i; + int ofs; + + if ( cls.state != CA_ACTIVE ) { + Com_Printf( "Not connected to a server.\n"); + return; + } + + for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { + ofs = cl.gameState.stringOffsets[ i ]; + if ( !ofs ) { + continue; + } + Com_Printf( "%4i: %s\n", i, cl.gameState.stringData + ofs ); + } +} + +/* +============== +CL_Clientinfo_f +============== +*/ +void CL_Clientinfo_f( void ) { + Com_Printf( "--------- Client Information ---------\n" ); + Com_Printf( "state: %i\n", cls.state ); + Com_Printf( "Server: %s\n", cls.servername ); + Com_Printf ("User info settings:\n"); + Info_Print( Cvar_InfoString( CVAR_USERINFO ) ); + Com_Printf( "--------------------------------------\n" ); +} + + +//==================================================================== + +/* +================= +CL_DownloadsComplete + +Called when all downloading has been completed +================= +*/ +void CL_DownloadsComplete( void ) { + +#ifdef USE_CURL + // if we downloaded with cURL + if(clc.cURLUsed) { + clc.cURLUsed = qfalse; + CL_cURL_Shutdown(); + if( clc.cURLDisconnected ) { + if(clc.downloadRestart) { + FS_Restart(clc.checksumFeed); + clc.downloadRestart = qfalse; + } + clc.cURLDisconnected = qfalse; + CL_Reconnect_f(); + return; + } + } +#endif + + // if we downloaded files we need to restart the file system + if (clc.downloadRestart) { + clc.downloadRestart = qfalse; + + FS_Restart(clc.checksumFeed); // We possibly downloaded a pak, restart the file system to load it + + // inform the server so we get new gamestate info + CL_AddReliableCommand( "donedl" ); + + // by sending the donedl command we request a new gamestate + // so we don't want to load stuff yet + return; + } + + // let the client game init and load data + cls.state = CA_LOADING; + + // Pump the loop, this may change gamestate! + Com_EventLoop(); + + // if the gamestate was changed by calling Com_EventLoop + // then we loaded everything already and we don't want to do it again. + if ( cls.state != CA_LOADING ) { + return; + } + + // starting to load a map so we get out of full screen ui mode + Cvar_Set("r_uiFullScreen", "0"); + + // flush client memory and start loading stuff + // this will also (re)load the UI + // if this is a local client then only the client part of the hunk + // will be cleared, note that this is done after the hunk mark has been set + CL_FlushMemory(); + + // initialize the CGame + cls.cgameStarted = qtrue; + CL_InitCGame(); + + // set pure checksums + CL_SendPureChecksums(); + + CL_WritePacket(); + CL_WritePacket(); + CL_WritePacket(); +} + +/* +================= +CL_BeginDownload + +Requests a file to download from the server. Stores it in the current +game directory. +================= +*/ +void CL_BeginDownload( const char *localName, const char *remoteName ) { + + Com_DPrintf("***** CL_BeginDownload *****\n" + "Localname: %s\n" + "Remotename: %s\n" + "****************************\n", localName, remoteName); + + Q_strncpyz ( clc.downloadName, localName, sizeof(clc.downloadName) ); + Com_sprintf( clc.downloadTempName, sizeof(clc.downloadTempName), "%s.tmp", localName ); + + // Set so UI gets access to it + Cvar_Set( "cl_downloadName", remoteName ); + Cvar_Set( "cl_downloadSize", "0" ); + Cvar_Set( "cl_downloadCount", "0" ); + Cvar_SetValue( "cl_downloadTime", cls.realtime ); + + clc.downloadBlock = 0; // Starting new file + clc.downloadCount = 0; + + CL_AddReliableCommand( va("download %s", remoteName) ); +} + +/* +================= +CL_NextDownload + +A download completed or failed +================= +*/ +void CL_NextDownload(void) { + char *s; + char *remoteName, *localName; + qboolean useCURL = qfalse; + + // We are looking to start a download here + if (*clc.downloadList) { + s = clc.downloadList; + + // format is: + // @remotename@localname@remotename@localname, etc. + + if (*s == '@') + s++; + remoteName = s; + + if ( (s = strchr(s, '@')) == NULL ) { + CL_DownloadsComplete(); + return; + } + + *s++ = 0; + localName = s; + if ( (s = strchr(s, '@')) != NULL ) + *s++ = 0; + else + s = localName + strlen(localName); // point at the nul byte +#ifdef USE_CURL + if(!(cl_allowDownload->integer & DLF_NO_REDIRECT)) { + if(clc.sv_allowDownload & DLF_NO_REDIRECT) { + Com_Printf("WARNING: server does not " + "allow download redirection " + "(sv_allowDownload is %d)\n", + clc.sv_allowDownload); + } + else if(!*clc.sv_dlURL) { + Com_Printf("WARNING: server allows " + "download redirection, but does not " + "have sv_dlURL set\n"); + } + else if(!CL_cURL_Init()) { + Com_Printf("WARNING: could not load " + "cURL library\n"); + } + else { + CL_cURL_BeginDownload(localName, va("%s/%s", + clc.sv_dlURL, remoteName)); + useCURL = qtrue; + } + } + else if(!(clc.sv_allowDownload & DLF_NO_REDIRECT)) { + Com_Printf("WARNING: server allows download " + "redirection, but it disabled by client " + "configuration (cl_allowDownload is %d)\n", + cl_allowDownload->integer); + } +#endif /* USE_CURL */ + if(!useCURL) { + if((cl_allowDownload->integer & DLF_NO_UDP)) { + Com_Error(ERR_DROP, "UDP Downloads are " + "disabled on your client. " + "(cl_allowDownload is %d)", + cl_allowDownload->integer); + return; + } + else { + CL_BeginDownload( localName, remoteName ); + } + } + clc.downloadRestart = qtrue; + + // move over the rest + memmove( clc.downloadList, s, strlen(s) + 1); + + return; + } + + CL_DownloadsComplete(); +} + +/* +================= +CL_InitDownloads + +After receiving a valid game state, we valid the cgame and local zip files here +and determine if we need to download them +================= +*/ +void CL_InitDownloads(void) { + char missingfiles[1024]; + + if ( !(cl_allowDownload->integer & DLF_ENABLE) ) + { + // autodownload is disabled on the client + // but it's possible that some referenced files on the server are missing + if (FS_ComparePaks( missingfiles, sizeof( missingfiles ), qfalse ) ) + { + // NOTE TTimo I would rather have that printed as a modal message box + // but at this point while joining the game we don't know wether we will successfully join or not + Com_Printf( "\nWARNING: You are missing some files referenced by the server:\n%s" + "You might not be able to join the game\n" + "Go to the setting menu to turn on autodownload, or get the file elsewhere\n\n", missingfiles ); + } + } + else if ( FS_ComparePaks( clc.downloadList, sizeof( clc.downloadList ) , qtrue ) ) { + + Com_Printf("Need paks: %s\n", clc.downloadList ); + + if ( *clc.downloadList ) { + // if autodownloading is not enabled on the server + cls.state = CA_CONNECTED; + CL_NextDownload(); + return; + } + + } + + CL_DownloadsComplete(); +} + +/* +================= +CL_CheckForResend + +Resend a connect message if the last one has timed out +================= +*/ +void CL_CheckForResend( void ) { + int port, i; + char info[MAX_INFO_STRING]; + char data[MAX_INFO_STRING]; + + // don't send anything if playing back a demo + if ( clc.demoplaying ) { + return; + } + + // resend if we haven't gotten a reply yet + if ( cls.state != CA_CONNECTING && cls.state != CA_CHALLENGING ) { + return; + } + + if ( cls.realtime - clc.connectTime < RETRANSMIT_TIMEOUT ) { + return; + } + + clc.connectTime = cls.realtime; // for retransmit requests + clc.connectPacketCount++; + + + switch ( cls.state ) { + case CA_CONNECTING: + // requesting a challenge + //wombat: not authorization in mohaa +// if ( !Sys_IsLANAddress( clc.serverAddress ) ) { +// CL_RequestAuthorization(); +// } + NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "getchallenge"); + break; + + case CA_CHALLENGING: +/* +wombat: sending conect here: an example connect string from MOHAA looks like this: +"connect "\challenge\-1629263210\qport\9683\protocol\8\name\wombat\rate\25000\dm_playermodel\american_ranger\snaps\20\dm_playergermanmodel\german_wehrmacht_soldier"" +*/ + + // sending back the challenge + port = Cvar_VariableValue ("net_qport"); + + Q_strncpyz( info, Cvar_InfoString( CVAR_USERINFO ), sizeof( info ) ); + Info_SetValueForKey( info, "protocol", va("%i", PROTOCOL_VERSION ) ); + Info_SetValueForKey( info, "qport", va("%i", port ) ); + Info_SetValueForKey( info, "challenge", va("%i", clc.challenge ) ); + + strcpy(data, "connect "); + // TTimo adding " " around the userinfo string to avoid truncated userinfo on the server + // (Com_TokenizeString tokenizes around spaces) + data[8] = '"'; + + for(i=0;iadr.type = NA_IP; + server->adr.ip[0] = address->ip[0]; + server->adr.ip[1] = address->ip[1]; + server->adr.ip[2] = address->ip[2]; + server->adr.ip[3] = address->ip[3]; + server->adr.port = address->port; + server->clients = 0; + server->hostName[0] = '\0'; + server->mapName[0] = '\0'; + server->maxClients = 0; + server->maxPing = 0; + server->minPing = 0; + server->ping = -1; + server->game[0] = '\0'; + server->gameType = 0; + server->netType = 0; +} + +#define MAX_SERVERSPERPACKET 256 + +/* +=================== +CL_ServersResponsePacket +=================== +*/ +void CL_ServersResponsePacket( netadr_t from, msg_t *msg ) { + int i, count, max, total; + serverAddress_t addresses[MAX_SERVERSPERPACKET]; + int numservers; + byte* buffptr; + byte* buffend; + + Com_Printf("CL_ServersResponsePacket\n"); + + if (cls.numglobalservers == -1) { + // state to detect lack of servers or lack of response + cls.numglobalservers = 0; + cls.numGlobalServerAddresses = 0; + } + + if (cls.nummplayerservers == -1) { + cls.nummplayerservers = 0; + } + + // parse through server response string + numservers = 0; + buffptr = msg->data; + buffend = buffptr + msg->cursize; + while (buffptr+1 < buffend) { + // advance to initial token + do { + if (*buffptr++ == '\\') + break; + } + while (buffptr < buffend); + + if ( buffptr >= buffend - 6 ) { + break; + } + + // parse out ip + addresses[numservers].ip[0] = *buffptr++; + addresses[numservers].ip[1] = *buffptr++; + addresses[numservers].ip[2] = *buffptr++; + addresses[numservers].ip[3] = *buffptr++; + + // parse out port + addresses[numservers].port = (*buffptr++)<<8; + addresses[numservers].port += *buffptr++; + addresses[numservers].port = BigShort( addresses[numservers].port ); + + // syntax check + if (*buffptr != '\\') { + break; + } + + Com_DPrintf( "server: %d ip: %d.%d.%d.%d:%d\n",numservers, + addresses[numservers].ip[0], + addresses[numservers].ip[1], + addresses[numservers].ip[2], + addresses[numservers].ip[3], + addresses[numservers].port ); + + numservers++; + if (numservers >= MAX_SERVERSPERPACKET) { + break; + } + + // parse out EOT + if (buffptr[1] == 'E' && buffptr[2] == 'O' && buffptr[3] == 'T') { + break; + } + } + + if (cls.masterNum == 0) { + count = cls.numglobalservers; + max = MAX_GLOBAL_SERVERS; + } else { + count = cls.nummplayerservers; + max = MAX_OTHER_SERVERS; + } + + for (i = 0; i < numservers && count < max; i++) { + // build net address + serverInfo_t *server = (cls.masterNum == 0) ? &cls.globalServers[count] : &cls.mplayerServers[count]; + + CL_InitServerInfo( server, &addresses[i] ); + // advance to next slot + count++; + } + + // if getting the global list + if (cls.masterNum == 0) { + if ( cls.numGlobalServerAddresses < MAX_GLOBAL_SERVERS ) { + // if we couldn't store the servers in the main list anymore + for (; i < numservers && count >= max; i++) { + serverAddress_t *addr; + // just store the addresses in an additional list + addr = &cls.globalServerAddresses[cls.numGlobalServerAddresses++]; + addr->ip[0] = addresses[i].ip[0]; + addr->ip[1] = addresses[i].ip[1]; + addr->ip[2] = addresses[i].ip[2]; + addr->ip[3] = addresses[i].ip[3]; + addr->port = addresses[i].port; + } + } + } + + if (cls.masterNum == 0) { + cls.numglobalservers = count; + total = count + cls.numGlobalServerAddresses; + } else { + cls.nummplayerservers = count; + total = count; + } + + Com_Printf("%d servers parsed (total %d)\n", numservers, total); +} + +/* +================= +CL_ConnectionlessPacket + +Responses to broadcasts, etc +================= +*/ +void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { + char *s; + char *c; + const char *reason; + + MSG_BeginReadingOOB( msg ); + MSG_ReadLong( msg ); // skip the -1 + + MSG_ReadByte( msg ); // wombat: skip the direction byte + + s = MSG_ReadStringLine( msg ); + + Cmd_TokenizeString( s ); + + c = Cmd_Argv(0); + + Com_DPrintf ("CL packet %s: %s\n", NET_AdrToString(from), c); + + // challenge from the server we are connecting to + if ( !Q_stricmp(c, "challengeResponse") ) { + if ( cls.state != CA_CONNECTING ) { + Com_Printf( "Unwanted challenge response received. Ignored.\n" ); + } else { + // start sending challenge repsonse instead of challenge request packets + clc.challenge = atoi(Cmd_Argv(1)); + cls.state = CA_CHALLENGING; + clc.connectPacketCount = 0; + clc.connectTime = -99999; + + // take this address as the new server address. This allows + // a server proxy to hand off connections to multiple servers + clc.serverAddress = from; + Com_DPrintf ("challengeResponse: %d\n", clc.challenge); + } + return; + } + + // server connection + if ( !Q_stricmp(c, "connectResponse") ) { + if ( cls.state >= CA_CONNECTED ) { + Com_Printf ("Dup connect received. Ignored.\n"); + return; + } + if ( cls.state != CA_CHALLENGING ) { + Com_Printf ("connectResponse packet while not connecting. Ignored.\n"); + return; + } + if ( !NET_CompareBaseAdr( from, clc.serverAddress ) ) { + Com_Printf( "connectResponse from a different address. Ignored.\n" ); + Com_Printf( "%s should have been %s\n", NET_AdrToString( from ), + NET_AdrToString( clc.serverAddress ) ); + return; + } + Netchan_Setup (NS_CLIENT, &clc.netchan, from, Cvar_VariableValue( "net_qport" ) ); + cls.state = CA_CONNECTED; + clc.lastPacketSentTime = -9999; // send first packet immediately + return; + } + + // server responding to an info broadcast + if ( !Q_stricmp(c, "infoResponse") ) { + CL_ServerInfoPacket( from, msg ); + return; + } + + // server responding to a get playerlist + if ( !Q_stricmp(c, "statusResponse") ) { + CL_ServerStatusResponse( from, msg ); + return; + } + + // a disconnect message from the server, which will happen if the server + // dropped the connection but it is still getting packets from us + if (!Q_stricmp(c, "disconnect")) { + CL_DisconnectPacket( from ); + return; + } + + // echo request from server + if ( !Q_stricmp(c, "echo") ) { + NET_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv(1) ); + return; + } + + // cd check + if ( !Q_stricmp(c, "keyAuthorize") ) { + // we don't use these now, so dump them on the floor + return; + } + + // global MOTD from id + if ( !Q_stricmp(c, "motd") ) { + CL_MotdPacket( from ); + return; + } + + // echo request from server + if ( !Q_stricmp(c, "print") ) { + s = MSG_ReadString( msg ); + Q_strncpyz( clc.serverMessage, s, sizeof( clc.serverMessage ) ); + Com_Printf( "%s", s ); + return; + } + + // echo request from server + if ( !Q_strncmp(c, "getserversResponse", 18) ) { + CL_ServersResponsePacket( from, msg ); + return; + } + // wombat: mohaa servers send this to reject clients + // TODO: tell the UI to draw serverdisconnect.urc serverfull.urc or servertimeout.urc + if ( !Q_stricmp(c, "droperror") ) { + reason = MSG_ReadString( msg ); + Com_Printf( "Server dropped connection. Reason: %s", reason ); + Cvar_Set("com_errorMessage", reason ); + CL_Disconnect( qtrue ); + return; + } + + Com_DPrintf ("Unknown connectionless packet command: \"%s\".\n", c); +} + + +/* +================= +CL_PacketEvent + +A packet has arrived from the main event loop +================= +*/ +void CL_PacketEvent( netadr_t from, msg_t *msg ) { + int headerBytes; + + clc.lastPacketTime = cls.realtime; + + if ( msg->cursize >= 4 && *(int *)msg->data == -1 ) { + CL_ConnectionlessPacket( from, msg ); + return; + } + + if ( cls.state < CA_CONNECTED ) { + return; // can't be a valid sequenced packet + } + + if ( msg->cursize < 4 ) { + Com_Printf ("%s: Runt packet\n",NET_AdrToString( from )); + return; + } + + // + // packet from server + // + if ( !NET_CompareAdr( from, clc.netchan.remoteAddress ) ) { + Com_DPrintf ("%s:sequenced packet without connection\n" + ,NET_AdrToString( from ) ); + // FIXME: send a client disconnect? + return; + } + + if (!CL_Netchan_Process( &clc.netchan, msg) ) { + return; // out of order, duplicated, etc + } + + // the header is different lengths for reliable and unreliable messages + headerBytes = msg->readcount; + + // track the last message received so it can be returned in + // client messages, allowing the server to detect a dropped + // gamestate + clc.serverMessageSequence = LittleLong( *(int *)msg->data ); + + clc.lastPacketTime = cls.realtime; + CL_ParseServerMessage( msg ); + + // + // we don't know if it is ok to save a demo message until + // after we have parsed the frame + // + if ( clc.demorecording && !clc.demowaiting ) { + CL_WriteDemoMessage( msg, headerBytes ); + } +} + +/* +================== +CL_CheckTimeout + +================== +*/ +void CL_CheckTimeout( void ) { + // + // check timeout + // + if ( ( !CL_CheckPaused() || !paused->integer ) + && cls.state >= CA_CONNECTED && cls.state != CA_CINEMATIC + && cls.realtime - clc.lastPacketTime > cl_timeout->value*1000) { + if (++cl.timeoutcount > 5) { // timeoutcount saves debugger + Com_Printf ("\nServer connection timed out.\n"); + Cbuf_AddText( "pushmenu servertimeout\n" ); + CL_Disconnect( qtrue ); + return; + } + } else { + cl.timeoutcount = 0; + } +} + +/* +================== +CL_CheckPaused +Check whether client has been paused. +================== +*/ +qboolean CL_CheckPaused(void) +{ + // if paused->modified is set, the cvar has only been changed in + // this frame. Keep paused in this frame to ensure the server doesn't + // lag behind. + if(paused->integer || paused->modified) + return qtrue; + + return qfalse; +} + +//============================================================================ + +/* +================== +CL_CheckUserinfo + +================== +*/ +void CL_CheckUserinfo( void ) { + // don't add reliable commands when not yet connected + if(cls.state < CA_CHALLENGING) + return; + + // don't overflow the reliable command buffer when paused + if(CL_CheckPaused()) + return; + + // send a reliable userinfo update if needed + if(cvar_modifiedFlags & CVAR_USERINFO) + { + cvar_modifiedFlags &= ~CVAR_USERINFO; + CL_AddReliableCommand( va("userinfo \"%s\"", Cvar_InfoString( CVAR_USERINFO ) ) ); + } +} + +/* +================== +CL_Frame + +================== +*/ +void CL_Frame ( int msec ) { + + if ( !com_cl_running->integer ) { + return; + } + +#ifdef USE_CURL + if(clc.downloadCURLM) { + CL_cURL_PerformDownload(); + // we can't process frames normally when in disconnected + // download mode since the ui vm expects cls.state to be + // CA_CONNECTED + if(clc.cURLDisconnected) { + cls.realFrametime = msec; + cls.frametime = msec; + cls.realtime += cls.frametime; + SCR_UpdateScreen(); + S_Update(); + Con_RunConsole(); + cls.framecount++; + return; + } + } +#endif + + if ( cls.state == CA_DISCONNECTED && !( Key_GetCatcher( ) & KEYCATCH_UI ) + && !com_sv_running->integer ) { + // if disconnected, bring up the menu + S_StopAllSounds( qtrue ); + UI_MenuEscape( "main" ); + } + + // if recording an avi, lock to a fixed fps + if ( CL_VideoRecording( ) && cl_aviFrameRate->integer && msec) { + // save the current screen + if ( cls.state == CA_ACTIVE || cl_forceavidemo->integer) { + CL_TakeVideoFrame( ); + + // fixed time for next frame' + msec = (int)ceil( (1000.0f / cl_aviFrameRate->value) * com_timescale->value ); + if (msec == 0) { + msec = 1; + } + } + } + + if( cl_autoRecordDemo->integer ) { + if( cls.state == CA_ACTIVE && !clc.demorecording && !clc.demoplaying ) { + // If not recording a demo, and we should be, start one + qtime_t now; + const char *nowString; + char *p; + char mapName[ MAX_QPATH ]; + char serverName[ MAX_OSPATH ]; + + Com_RealTime( &now ); + nowString = va( "%04d%02d%02d%02d%02d%02d", + 1900 + now.tm_year, + 1 + now.tm_mon, + now.tm_mday, + now.tm_hour, + now.tm_min, + now.tm_sec ); + + Q_strncpyz( serverName, cls.servername, MAX_OSPATH ); + // Replace the ":" in the address as it is not a valid + // file name character + p = strstr( serverName, ":" ); + if( p ) { + *p = '.'; + } + + Q_strncpyz( mapName, COM_SkipPath( cl.mapname ), sizeof( cl.mapname ) ); + COM_StripExtension(mapName, mapName, sizeof(mapName)); + + Cbuf_ExecuteText( EXEC_NOW, + va( "record %s-%s-%s", nowString, serverName, mapName ) ); + } + else if( cls.state != CA_ACTIVE && clc.demorecording ) { + // Recording, but not CA_ACTIVE, so stop recording + CL_StopRecord_f( ); + } + } + + // save the msec before checking pause + cls.realFrametime = msec; + + // decide the simulation time + cls.frametime = msec; + + cls.realtime += cls.frametime; + + if ( cl_timegraph->integer ) { + SCR_DebugGraph ( cls.realFrametime * 0.25, 0 ); + } + + cls.timeScaled = com_timescale->integer != 1; + + // see if we need to update any userinfo + CL_CheckUserinfo(); + + // if we haven't gotten a packet in a long time, + // drop the connection + CL_CheckTimeout(); + + // send intentions now + CL_SendCmd(); + + // resend a connection request if necessary + CL_CheckForResend(); + + // decide on the serverTime to render + CL_SetCGameTime(); + + // set the time if we loaded a save + if( SV_DoSaveGame() ) + { + if( cl.serverTime < svs.time ) { + cl.serverTime = svs.time; + } + } + + L_ProcessPendingEvents(); + + // update the screen + SCR_UpdateScreen(); + + // update audio + S_Update(); + + // advance local effects for next frame + SCR_RunCinematic(); + + Con_RunConsole(); + + cls.framecount++; +} + + +//============================================================================ + +/* +================ +CL_RefPrintf + +DLL glue +================ +*/ +void QDECL CL_RefPrintf( int print_level, const char *fmt, ...) { + va_list argptr; + char msg[MAXPRINTMSG]; + + va_start (argptr,fmt); + Q_vsnprintf (msg, sizeof(msg), fmt, argptr); + va_end (argptr); + + if ( print_level == PRINT_ALL ) { + Com_Printf ("%s", msg); + } else if ( print_level == PRINT_WARNING ) { + Com_Printf (S_COLOR_YELLOW "%s", msg); // yellow + } else if ( print_level == PRINT_DEVELOPER ) { + Com_DPrintf (S_COLOR_RED "%s", msg); // red + } +} + +/* +============ +CL_RefSetPerformanceCounters +============ +*/ +void CL_RefSetPerformanceCounters( int total_tris, int total_verts, int total_texels, int world_tris, int world_verts, int character_lights ) +{ + cls.total_tris = total_tris; + cls.total_verts = total_verts; + cls.total_texels = total_texels; + cls.world_tris = world_tris; + cls.world_verts = world_verts; + cls.character_lights = character_lights; +} + +/* +============ +CL_ShutdownRef +============ +*/ +void CL_ShutdownRef( void ) { + if ( !re.Shutdown ) { + return; + } + re.Shutdown( qtrue ); + Com_Memset( &re, 0, sizeof( re ) ); +#ifdef USE_RENDERER_DLL + // su44: remember to unload renderer library + if(rendererLib) { + Sys_UnloadLibrary(rendererLib); + rendererLib = NULL; + } +#endif +} + +/* +============ +CL_InitRenderer +============ +*/ +void CL_InitRenderer( void ) { + // this sets up the renderer and calls R_Init + re.BeginRegistration( &cls.glconfig ); + + // load character sets + cls.charSetShader = re.RegisterShader( "gfx/2d/bigchars" ); + cls.whiteShader = re.RegisterShader( "*white" ); +// cls.consoleShader = re.RegisterShader( "console" ); + re.RegisterFont("courier-16", 0, &cls.consoleFont); + g_console_field_width = cls.glconfig.vidWidth / SMALLCHAR_WIDTH - 2; + g_consoleField.widthInChars = g_console_field_width; + // IneQuation + g_console_charWidth = re.Text_Width(&cls.consoleFont, "=", 0, qfalse); + g_console_charHeight = re.Text_Height(&cls.consoleFont, "|", 0, qfalse); +} + +/* +============================ +CL_StartHunkUsers + +After the server has cleared the hunk, these will need to be restarted +This is the only place that any of these functions are called from +============================ +*/ +void CL_StartHunkUsers( void ) { + if( !com_cl_running ) { + return; + } + + if ( !com_cl_running->integer ) { + return; + } + + if ( !cls.rendererRegistered ) { + cls.rendererRegistered = qtrue; + CL_BeginRegistration(); + } + + if( !cls.cgameStarted ) { + if( cls.state >= CA_LOADING && cls.state != CA_CINEMATIC ) { + CL_InitCGame(); + } + } + + if ( !cls.uiStarted ) { + cls.uiStarted = qtrue; + CL_InitializeUI(); + } +} + +/* +============ +CL_RefMalloc +============ +*/ +void *CL_RefMalloc( int size ) { + return Z_TagMalloc( size, TAG_RENDERER ); +} + +/* +============ +CL_RefClear +============ +*/ +void CL_RefClear( void ) +{ + Z_FreeTags( TAG_RENDERER ); +} + +/* +============ +CL_RefStaticMalloc +============ +*/ +void *CL_RefStaticMalloc( int size ) { + void *ptr = Z_TagMalloc( size, TAG_STATIC_RENDERER ); + Com_Memset( ptr, 0, size ); + return ptr; +} + +/* +============ +CL_RefStaticClear +============ +*/ +void CL_RefStaticClear( void ) { + Z_FreeTags( TAG_STATIC_RENDERER ); +} + +/* +============ +CL_CG_PermanentMark +============ +*/ +int CL_CG_PermanentMark( vec3_t origin, vec3_t dir, float orientation, + float fSScale, float fTScale, float red, float green, float blue, float alpha, + qboolean dolighting, float fSCenter, float fTCenter, + markFragment_t *pMarkFragments, void *pPolyVerts ) +{ + if( cge ) { + return cge->CG_PermanentMark( origin, dir, orientation, + fSScale, fTScale, red, green, blue, alpha, + dolighting, fSCenter, fTCenter, + pMarkFragments, pPolyVerts ); + } + + return 0; +} + +/* +============ +CL_CG_PermanentTreadMarkDecal +============ +*/ +int CL_CG_PermanentTreadMarkDecal( treadMark_t *pTread, qboolean bStartSegment, qboolean dolighting, markFragment_t *pMarkFragments, void *pVoidPolyVerts ) { + if( cge ) { + return cge->CG_PermanentTreadMarkDecal( pTread, bStartSegment, dolighting, pMarkFragments, pVoidPolyVerts ); + } + + return 0; +} + +/* +============ +CL_CG_PermanentUpdateTreadMark +============ +*/ +int CL_CG_PermanentUpdateTreadMark( treadMark_t *pTread, float fAlpha, float fMinSegment, float fMaxSegment, float fMaxOffset, float fTexScale ) { + if( cge ) { + return cge->CG_PermanentUpdateTreadMark( pTread, fAlpha, fMinSegment, fMaxSegment, fMaxOffset, fTexScale ); + } + + return 0; +} + +/* +============ +CL_CG_ProcessInitCommands +============ +*/ +void CL_CG_ProcessInitCommands( dtiki_t *tiki, refEntity_t *ent ) { + if( cge ) { + return cge->CG_ProcessInitCommands( tiki, ent ); + } +} + +/* +============ +CL_CG_EndTiki +============ +*/ +void CL_CG_EndTiki( dtiki_t *tiki ) { + if( cge ) { + return cge->CG_EndTiki( tiki ); + } +} + +extern "C" +int CL_ScaledMilliseconds(void) { + return Sys_Milliseconds()*com_timescale->value; +} + +/* +============ +CL_InitRef +============ +*/ +void CL_InitRef( void ) { + refimport_t ri; + refexport_t *ret; +#ifdef USE_RENDERER_DLL + char dllName[256]; +#endif + + Com_Printf( "----- Initializing Renderer ----\n" ); + + ri.Cmd_AddCommand = Cmd_AddCommand; + ri.Cmd_RemoveCommand = Cmd_RemoveCommand; + ri.Cmd_Argc = Cmd_Argc; + ri.Cmd_Argv = Cmd_Argv; + ri.Cmd_ExecuteText = Cbuf_ExecuteText; + ri.Printf = CL_RefPrintf; + ri.Error = Com_Error; + ri.Milliseconds = CL_ScaledMilliseconds; + ri.Malloc = CL_RefMalloc; + ri.Free = Z_Free; + ri.Clear = CL_RefClear; + ri.Hunk_Clear = CL_RefStaticClear; + ri.Hunk_Alloc = Hunk_Alloc; + ri.Hunk_AllocateTempMemory = Hunk_AllocateTempMemory; + ri.Hunk_FreeTempMemory = Hunk_FreeTempMemory; + ri.CM_DrawDebugSurface = CM_DrawDebugSurface; + ri.CM_ClusterPVS = CM_ClusterPVS; + + ri.FS_FOpenFile = FS_FOpenFileRead; + ri.FS_CloseFile = FS_FCloseFile; + ri.FS_Read = FS_Read; + ri.FS_Seek = FS_Seek; + ri.FS_ReadFile = FS_ReadFile; + ri.FS_ReadFileEx = FS_ReadFileEx; + ri.FS_FreeFile = FS_FreeFile; + ri.FS_WriteFile = FS_WriteFile; + ri.FS_FreeFileList = FS_FreeFileList; + ri.FS_ListFiles = FS_ListFiles; + ri.FS_FileIsInPAK = FS_FileIsInPAK; + ri.FS_FileExists = FS_FileExists; + ri.Cvar_Get = Cvar_Get; + ri.Cvar_Set = Cvar_Set; + ri.Cvar_SetDefault = Cvar_SetDefault; + + ri.CM_EntityString = CM_EntityString; + ri.CM_MapTime = CM_MapTime; + ri.CM_BoxTrace = CM_BoxTrace; + ri.CG_PermanentMark = CL_CG_PermanentMark; + ri.CG_PermanentTreadMarkDecal = CL_CG_PermanentTreadMarkDecal; + ri.CG_PermanentUpdateTreadMark = CL_CG_PermanentUpdateTreadMark; + ri.CM_TerrainSquareType = CM_TerrainSquareType; + ri.CG_ProcessInitCommands = CL_CG_ProcessInitCommands; + ri.CG_EndTiki = CL_CG_EndTiki; + ri.SetPerformanceCounters = CL_RefSetPerformanceCounters; + + ri.DebugLines = &DebugLines; + ri.numDebugLines = &numDebugLines; + ri.DebugStrings = &DebugStrings; + ri.numDebugStrings = &numDebugStrings; + + ri.TIKI_OrientationInternal = TIKI_OrientationInternal; + ri.TIKI_IsOnGroundInternal = TIKI_IsOnGroundInternal; + ri.TIKI_SetPoseInternal = TIKI_SetPoseInternal; + ri.TIKI_Alloc = TIKI_Alloc; + ri.GetRadiusInternal = TIKI_GetRadiusInternal; + ri.GetCentroidRadiusInternal = TIKI_GetCentroidRadiusInternal; + ri.GetFrameInternal = TIKI_GetFrameInternal; + + // cinematic stuff + + ri.CIN_UploadCinematic = CIN_UploadCinematic; + ri.CIN_PlayCinematic = CIN_PlayCinematic; + ri.CIN_RunCinematic = CIN_RunCinematic; + + ri.CL_WriteAVIVideoFrame = CL_WriteAVIVideoFrame; + + ri.IN_Init = IN_Init; + ri.IN_Shutdown = IN_Shutdown; + //ri.IN_Restart = IN_Restart; + +#ifdef USE_RENDERER_DLL + // su44: load renderer dll + cl_renderer = Cvar_Get("cl_renderer", "glom", CVAR_ARCHIVE); + Q_snprintf(dllName, sizeof(dllName), "renderer_%s" ARCH_STRING DLL_EXT, cl_renderer->string); + Com_Printf("Loading \"%s\"...", dllName); + if((rendererLib = Sys_LoadLibrary(dllName)) == 0) { +#ifdef _WIN32 + Com_Error(ERR_FATAL, "failed:\n\"%s\"\n", Sys_LibraryError()); +#else + char fn[1024]; + + Q_strncpyz(fn, Sys_Cwd(), sizeof(fn)); + strncat(fn, "/", sizeof(fn) - strlen(fn) - 1); + strncat(fn, dllName, sizeof(fn) - strlen(fn) - 1); + + Com_Printf("Loading \"%s\"...", fn); + if((rendererLib = Sys_LoadLibrary(fn)) == 0) + { + Com_Error(ERR_FATAL, "failed:\n\"%s\"", Sys_LibraryError()); + } +#endif /* _WIN32 */ + } + + Com_Printf("done\n"); + + DGetRefAPI = Sys_LoadFunction(rendererLib, "GetRefAPI"); + if(!DGetRefAPI) + { + Com_Error(ERR_FATAL, "Can't load symbol GetRefAPI: '%s'", Sys_LibraryError()); + } + ret = DGetRefAPI( REF_API_VERSION, &ri ); +#else + ret = GetRefAPI( REF_API_VERSION, &ri ); +#endif + +#if defined __USEA3D && defined __A3D_GEOM + hA3Dg_ExportRenderGeom (ret); +#endif + + Com_Printf( "-------------------------------\n"); + + if ( !ret ) { + Com_Error (ERR_FATAL, "Couldn't initialize refresh" ); + } + + re = *ret; + + // unpause so the cgame definately gets a snapshot and renders a frame + Cvar_Set( "cl_paused", "0" ); +} + + +//=========================================================================================== + +qboolean CL_SetVidMode( int mode ) { + qboolean ret; + + ret = re.SetMode( mode, &cls.glconfig ); + + if( cge ) { + cge->CG_GetRendererConfig(); + } + + UI_ResolutionChange(); + return ret; +} + +void CL_SetFullscreen( qboolean fullscreen ) { + re.SetFullscreen( fullscreen, &cls.glconfig ); + + if( cge ) { + cge->CG_GetRendererConfig(); + } +} + +void CL_SetModel_f( void ) { + char *arg; + char name[256]; + + arg = Cmd_Argv( 1 ); + if (arg[0]) { + Cvar_Set( "model", arg ); + Cvar_Set( "headmodel", arg ); + } else { + Cvar_VariableStringBuffer( "model", name, sizeof(name) ); + Com_Printf("model is set to %s\n", name); + } +} + +void CL_VidMode_f( void ) { + char text[ 16 ]; + int mode; + + if( Cmd_Argc() != 2 ) { + Com_Printf( "Usage: vidmode [modenum]\n" ); + return; + } + + mode = atoi( Cmd_Argv( 1 ) ); + + if( CL_SetVidMode( mode ) ) { + sprintf( text, "%d", mode ); + Cvar_Set( "r_mode", text ); + } +} + +void CL_TikiInfoCommand_f( void ) { + dtiki_t *tiki; + qhandle_t hModel; + const char *name; + char modelname[ 128 ]; + + if( Cmd_Argc() != 2 ) { + Com_Printf( "usage: tiki tikiname\n" ); + return; + } + + name = Cmd_Argv( 1 ); + + if( strchr( name, '/' ) ) { + strcpy( modelname, name ); + } else { + strcpy( modelname, "models/" ); + strcat( modelname, name ); + } + + COM_DefaultExtension( modelname, sizeof( modelname ), ".tik" ); + hModel = re.RegisterModel( modelname ); + tiki = re.R_Model_GetHandle( hModel ); + + TIKI_ModelInfo( tiki ); +} + + +//=========================================================================================== + + +/* +=============== +CL_Video_f + +video +video [filename] +=============== +*/ +void CL_Video_f( void ) +{ + char filename[ MAX_OSPATH ]; + int i, last; + + if( !clc.demoplaying ) + { + Com_Printf( "The video command can only be used when playing back demos\n" ); + return; + } + + if( Cmd_Argc( ) == 2 ) + { + // explicit filename + Com_sprintf( filename, MAX_OSPATH, "videos/%s.avi", Cmd_Argv( 1 ) ); + } + else + { + // scan for a free filename + for( i = 0; i <= 9999; i++ ) + { + int a, b, c, d; + + last = i; + + a = last / 1000; + last -= a * 1000; + b = last / 100; + last -= b * 100; + c = last / 10; + last -= c * 10; + d = last; + + Com_sprintf( filename, MAX_OSPATH, "videos/video%d%d%d%d.avi", + a, b, c, d ); + + if( !FS_FileExists( filename ) ) + break; // file doesn't exist + } + + if( i > 9999 ) + { + Com_Printf( S_COLOR_RED "ERROR: no free file names to create video\n" ); + return; + } + } + + CL_OpenAVIForWriting( filename ); +} + +/* +=============== +CL_StopVideo_f +=============== +*/ +void CL_StopVideo_f( void ) +{ + CL_CloseAVI( ); +} + +/* +=============== +CL_GenerateQKey + +test to see if a valid QKEY_FILE exists. If one does not, try to generate +it by filling it with 2048 bytes of random data. +=============== +*/ +static void CL_GenerateQKey(void) +{ + int len = 0; + unsigned char buff[ QKEY_SIZE ]; + fileHandle_t f; + + len = FS_SV_FOpenFileRead( QKEY_FILE, &f ); + FS_FCloseFile( f ); + if( len == QKEY_SIZE ) { + Com_Printf( "QKEY found.\n" ); + return; + } + else { + if( len > 0 ) { + Com_Printf( "QKEY file size != %d, regenerating\n", + QKEY_SIZE ); + } + + Com_Printf( "QKEY building random string\n" ); + Com_RandomBytes( buff, sizeof(buff) ); + + f = FS_SV_FOpenFileWrite( QKEY_FILE ); + if( !f ) { + Com_Printf( "QKEY could not open %s for write\n", + QKEY_FILE ); + return; + } + FS_Write( buff, sizeof(buff), f ); + FS_FCloseFile( f ); + Com_Printf( "QKEY generated\n" ); + } +} + +/* +==================== +CL_Init +==================== +*/ +void CL_Init( void ) { + int start, end; + + if( cl_bCLSystemStarted ) { + return; + } + + cl_bCLSystemStarted = qtrue; + + Com_Printf( "----- Client Initialization -----\n" ); + + start = Sys_Milliseconds(); + + Con_Init (); + + CL_ClearState (); + S_StopAllSounds( qtrue ); + + cls.state = CA_DISCONNECTED; // no longer CA_UNINITIALIZED + cls.keyCatchers = 2; + cls.realtime = 0; + + CL_InitInput (); + + if( !L_EventSystemStarted() ) { + L_InitEvents(); + } + + // + // register our variables + // + wombat = Cvar_Get( "wombat", "0", 0 ); + cl_noprint = Cvar_Get( "cl_noprint", "0", 0 ); + // maybe we can set up our own motd server once :) + cl_motd = Cvar_Get ("cl_motd", "0", 0); + + cl_timeout = Cvar_Get ("cl_timeout", "200", 0); + cl_connect_timeout = Cvar_Get( "cl_connect_timeout", "15", 0 ); + + cl_master = Cvar_Get ("cl_master", MASTER_SERVER_NAME, CVAR_ARCHIVE); + cl_timeNudge = Cvar_Get ("cl_timeNudge", "0", CVAR_TEMP ); + cl_shownet = Cvar_Get ("cl_shownet", "0", CVAR_TEMP ); + cl_showSend = Cvar_Get ("cl_showSend", "0", CVAR_TEMP ); + cl_showTimeDelta = Cvar_Get ("cl_showTimeDelta", "0", CVAR_TEMP ); + cl_freezeDemo = Cvar_Get ("cl_freezeDemo", "0", CVAR_TEMP ); + rcon_client_password = Cvar_Get ("rconPassword", "", CVAR_TEMP ); + cl_activeAction = Cvar_Get( "activeAction", "", CVAR_TEMP ); + + cl_timedemo = Cvar_Get ("timedemo", "0", 0); + cl_timedemoLog = Cvar_Get ("cl_timedemoLog", "", CVAR_ARCHIVE); + cl_autoRecordDemo = Cvar_Get ("cl_autoRecordDemo", "0", CVAR_ARCHIVE); + cl_aviFrameRate = Cvar_Get ("cl_aviFrameRate", "25", CVAR_ARCHIVE); + cl_aviMotionJpeg = Cvar_Get ("cl_aviMotionJpeg", "1", CVAR_ARCHIVE); + cl_forceavidemo = Cvar_Get ("cl_forceavidemo", "0", 0); + + rconAddress = Cvar_Get ("rconAddress", "", 0); + + cl_yawspeed = Cvar_Get ("cl_yawspeed", "140", CVAR_ARCHIVE); + cl_pitchspeed = Cvar_Get ("cl_pitchspeed", "140", CVAR_ARCHIVE); + cl_anglespeedkey = Cvar_Get ("cl_anglespeedkey", "1.5", 0); + + cl_maxpackets = Cvar_Get ("cl_maxpackets", "30", CVAR_ARCHIVE ); + cl_packetdup = Cvar_Get ("cl_packetdup", "1", CVAR_ARCHIVE ); + + cl_run = Cvar_Get( "cl_run", "1", CVAR_ARCHIVE ); + cl_freelook = Cvar_Get( "cl_freelook", "1", CVAR_ARCHIVE ); + cl_sensitivity = Cvar_Get( "sensitivity", "5", CVAR_ARCHIVE ); + cl_mouseAccel = Cvar_Get( "cl_mouseAccel", "0", CVAR_ARCHIVE ); + cl_showMouseRate = Cvar_Get( "cl_showmouserate", "0", 0 ); + cl_platformSensitivity = Cvar_Get ("cl_platformSensitivity", "1.0", CVAR_ROM); + + cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE); +#ifdef USE_CURL + cl_cURLLib = Cvar_Get("cl_cURLLib", DEFAULT_CURL_LIB, CVAR_ARCHIVE); +#endif + + cl_altbindings = Cvar_Get( "cl_altbindings", "0", CVAR_ARCHIVE ); + cl_ctrlbindings = Cvar_Get( "cl_altbindings", "0", CVAR_ARCHIVE ); + + cl_conXOffset = Cvar_Get ("cl_conXOffset", "0", 0); +#ifdef MACOS_X + // In game video is REALLY slow in Mac OS X right now due to driver slowness + cl_inGameVideo = Cvar_Get ("r_inGameVideo", "0", CVAR_ARCHIVE); +#else + cl_inGameVideo = Cvar_Get ("r_inGameVideo", "1", CVAR_ARCHIVE); +#endif + + cl_serverStatusResendTime = Cvar_Get ("cl_serverStatusResendTime", "750", 0); + + cl_r_fullscreen = Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE ); + + m_pitch = Cvar_Get ("m_pitch", "0.022", CVAR_ARCHIVE); + m_yaw = Cvar_Get ("m_yaw", "0.022", CVAR_ARCHIVE); + m_forward = Cvar_Get ("m_forward", "0.25", CVAR_ARCHIVE); + m_side = Cvar_Get ("m_side", "0.25", CVAR_ARCHIVE); +#ifdef MACOS_X + // Input is jittery on OS X w/o this + m_filter = Cvar_Get ("m_filter", "1", CVAR_ARCHIVE); +#else + m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE); +#endif + + cl_motdString = Cvar_Get( "cl_motdString", "", CVAR_ROM ); + + cl_langamerefreshstatus = Cvar_Get( "cl_langamerefreshstatus", "Ready", 0 ); + cg_gametype = Cvar_Get( "cg_gametype", "0", 0 ); + + cl_lanForcePackets = Cvar_Get ("cl_lanForcePackets", "1", CVAR_ARCHIVE); + + cl_guidServerUniq = Cvar_Get ("cl_guidServerUniq", "1", CVAR_ARCHIVE); + + // init autoswitch so the ui will have it correctly even + // if the cgame hasn't been started + Cvar_Get( "cg_autoswitch", "1", CVAR_ARCHIVE ); + + Cvar_Get( "cl_maxPing", "800", CVAR_ARCHIVE ); + Cvar_Get( "cl_forceModel", "0", CVAR_ARCHIVE ); + + if( m_pitch->value >= 0.0 ) { + Cvar_Set( "m_invert_pitch", "0" ); + } else { + Cvar_Set( "m_invert_pitch", "1" ); + } + + // ~ and `, as keys and characters + cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE ); + + // userinfo + Cvar_Get ("name", "UnnamedSoldier", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get ("rate", "5000", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get ("snaps", "20", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get ("password", "", CVAR_USERINFO); + Cvar_Get ("dm_playermodel", "american_army", CVAR_USERINFO | CVAR_ARCHIVE ); + Cvar_Get ("dm_playergermanmodel", "german_wehrmacht_soldier", CVAR_USERINFO | CVAR_ARCHIVE ); + + Cvar_Get ("cg_predictItems", "1", CVAR_USERINFO | CVAR_ARCHIVE ); + + + // cgame might not be initialized before menu is used + Cvar_Get ("cg_viewsize", "100", CVAR_ARCHIVE ); + + Cvar_Get ("cg_running", "0", CVAR_ROM ); + + // + // register our commands + // + Cmd_AddCommand ("cmd", CL_ForwardToServer_f); + Cmd_AddCommand ("configstrings", CL_Configstrings_f); + Cmd_AddCommand ("clientinfo", CL_Clientinfo_f); + Cmd_AddCommand ("snd_restart", CL_Snd_Restart_f); + Cmd_AddCommand ("vid_restart", CL_Vid_Restart_f); + Cmd_AddCommand ("disconnect", CL_Disconnect_f); + Cmd_AddCommand ("record", CL_Record_f); + Cmd_AddCommand ("demo", CL_PlayDemo_f); + Cmd_AddCommand ("cinematic", CL_PlayCinematic_f); + Cmd_AddCommand ("stoprecord", CL_StopRecord_f); + Cmd_AddCommand ("connect", CL_Connect_f); + Cmd_AddCommand ("menuconnect", CL_MenuConnect_f); + Cmd_AddCommand ("reconnect", CL_Reconnect_f); + Cmd_AddCommand ("localservers", CL_LocalServers_f); + Cmd_AddCommand ("globalservers", CL_GlobalServers_f); + Cmd_AddCommand ("refreshserverlist", CL_GamespyServers_f); // wombat: gamespy query + Cmd_AddCommand ("rcon", CL_Rcon_f); + Cmd_AddCommand ("setenv", CL_Setenv_f ); + Cmd_AddCommand ("ping", CL_Ping_f ); + Cmd_AddCommand ("tikianimlist", TIKI_TikiAnimList_f ); + Cmd_AddCommand ("tikilist", TIKI_TikiList_f ); + Cmd_AddCommand ("animlist", TIKI_AnimList_f ); + Cmd_AddCommand ("tiki", CL_TikiInfoCommand_f ); + Cmd_AddCommand ("vidmode", CL_VidMode_f ); + Cmd_AddCommand ("saveshot", CL_SaveShot_f ); + Cmd_AddCommand ("dialog", CL_Dialog_f ); + Cmd_AddCommand ("aliasdump", Alias_Dump ); + Cmd_AddCommand ("fastconnect", CL_FastConnect_f ); + Cmd_AddCommand ("serverstatus", CL_ServerStatus_f ); + Cmd_AddCommand ("showip", CL_ShowIP_f ); + Cmd_AddCommand ("fs_openedList", CL_OpenedPK3List_f ); + Cmd_AddCommand ("fs_referencedList", CL_ReferencedPK3List_f ); + Cmd_AddCommand ("model", CL_SetModel_f ); + Cmd_AddCommand ("video", CL_Video_f ); + Cmd_AddCommand ("stopvideo", CL_StopVideo_f ); + CL_InitConsoleCommands(); + CL_InitRef(); + CL_StartHunkUsers(); + + SCR_Init (); + + Cbuf_Execute (0); + + Cvar_Set( "cl_running", "1" ); + + NET_Init(); + S_Init(); + + // fixme: should we leave it? + CL_GenerateQKey(); + Cvar_Get( "cl_guid", "", CVAR_USERINFO | CVAR_ROM ); + CL_UpdateGUID( NULL, 0 ); + + CL_StartHunkUsers(); + + end = Sys_Milliseconds(); + + Com_Printf( "----- Client Initialization Complete ----- %i ms\n", start - end ); +} + + +/* +=============== +CL_Shutdown + +=============== +*/ +void CL_Shutdown( void ) { + static qboolean recursive = qfalse; + + // check whether the client is running at all. + if(!(com_cl_running && com_cl_running->integer)) + return; + + Com_Printf( "----- CL_Shutdown -----\n" ); + + if ( recursive ) { + printf ("recursive shutdown\n"); + return; + } + recursive = qtrue; + + CL_Disconnect( qtrue ); + + S_Shutdown(); + CL_ShutdownRef(); + + CL_ShutdownUI(); + + Cmd_RemoveCommand ("cmd"); + Cmd_RemoveCommand ("configstrings"); + Cmd_RemoveCommand ("userinfo"); + Cmd_RemoveCommand ("snd_restart"); + Cmd_RemoveCommand ("vid_restart"); + Cmd_RemoveCommand ("disconnect"); + Cmd_RemoveCommand ("record"); + Cmd_RemoveCommand ("demo"); + Cmd_RemoveCommand ("cinematic"); + Cmd_RemoveCommand ("stoprecord"); + Cmd_RemoveCommand ("connect"); + Cmd_RemoveCommand ("localservers"); + Cmd_RemoveCommand ("globalservers"); + Cmd_RemoveCommand ("refreshserverlist"); + Cmd_RemoveCommand ("rcon"); + Cmd_RemoveCommand ("setenv"); + Cmd_RemoveCommand ("ping"); + Cmd_RemoveCommand ("serverstatus"); + Cmd_RemoveCommand ("showip"); + Cmd_RemoveCommand ("model"); + Cmd_RemoveCommand ("video"); + Cmd_RemoveCommand ("stopvideo"); + + Cvar_Set( "cl_running", "0" ); + + recursive = qfalse; + + Com_Memset( &cls, 0, sizeof( cls ) ); + Key_SetCatcher( 0 ); + + Com_Printf( "-----------------------\n" ); + +} + +static void CL_SetServerInfo(serverInfo_t *server, const char *info, int ping) { + if (server) { + if (info) { + server->clients = atoi(Info_ValueForKey(info, "clients")); + Q_strncpyz(server->hostName,Info_ValueForKey(info, "hostname"), MAX_NAME_LENGTH); + Q_strncpyz(server->mapName, Info_ValueForKey(info, "mapname"), MAX_NAME_LENGTH); + server->maxClients = atoi(Info_ValueForKey(info, "sv_maxclients")); + Q_strncpyz(server->game,Info_ValueForKey(info, "game"), MAX_NAME_LENGTH); + server->gameType = atoi(Info_ValueForKey(info, "gametype")); + server->netType = atoi(Info_ValueForKey(info, "nettype")); + server->minPing = atoi(Info_ValueForKey(info, "minping")); + server->maxPing = atoi(Info_ValueForKey(info, "maxping")); + } + server->ping = ping; + } +} + +static void CL_SetServerInfoByAddress(netadr_t from, const char *info, int ping) { + int i; + + for (i = 0; i < MAX_OTHER_SERVERS; i++) { + if (NET_CompareAdr(from, cls.localServers[i].adr)) { + CL_SetServerInfo(&cls.localServers[i], info, ping); + } + } + + for (i = 0; i < MAX_OTHER_SERVERS; i++) { + if (NET_CompareAdr(from, cls.mplayerServers[i].adr)) { + CL_SetServerInfo(&cls.mplayerServers[i], info, ping); + } + } + + for (i = 0; i < MAX_GLOBAL_SERVERS; i++) { + if (NET_CompareAdr(from, cls.globalServers[i].adr)) { + CL_SetServerInfo(&cls.globalServers[i], info, ping); + } + } + + for (i = 0; i < MAX_OTHER_SERVERS; i++) { + if (NET_CompareAdr(from, cls.favoriteServers[i].adr)) { + CL_SetServerInfo(&cls.favoriteServers[i], info, ping); + } + } + +} + +/* +=================== +CL_ServerInfoPacket +=================== +*/ +void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { + int i, type; + char info[MAX_INFO_STRING]; + char* str; + char *infoString; + int prot; + + infoString = MSG_ReadString( msg ); + + // if this isn't the correct protocol version, ignore it + prot = atoi( Info_ValueForKey( infoString, "protocol" ) ); + if ( prot != PROTOCOL_VERSION ) { + Com_DPrintf( "Different protocol info packet: %s\n", infoString ); + return; + } + + // iterate servers waiting for ping response + for (i=0; iretrieved = qtrue; + return qfalse; + } + + // if this server status request has the same address + if ( NET_CompareAdr( to, serverStatus->address) ) { + // if we recieved an response for this server status request + if (!serverStatus->pending) { + Q_strncpyz(serverStatusString, serverStatus->string, maxLen); + serverStatus->retrieved = qtrue; + serverStatus->startTime = 0; + return qtrue; + } + // resend the request regularly + else if ( serverStatus->startTime < Com_Milliseconds() - cl_serverStatusResendTime->integer ) { + serverStatus->print = qfalse; + serverStatus->pending = qtrue; + serverStatus->retrieved = qfalse; + serverStatus->time = 0; + serverStatus->startTime = Com_Milliseconds(); + NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" ); + return qfalse; + } + } + // if retrieved + else if ( serverStatus->retrieved ) { + serverStatus->address = to; + serverStatus->print = qfalse; + serverStatus->pending = qtrue; + serverStatus->retrieved = qfalse; + serverStatus->startTime = Com_Milliseconds(); + serverStatus->time = 0; + NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" ); + return qfalse; + } + return qfalse; +} + +/* +=================== +CL_ServerStatusResponse +=================== +*/ +void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { + char *s; + char info[MAX_INFO_STRING]; + int i, l, score, ping; + int len; + serverStatus_t *serverStatus; + + serverStatus = NULL; + for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) { + if ( NET_CompareAdr( from, cl_serverStatusList[i].address ) ) { + serverStatus = &cl_serverStatusList[i]; + break; + } + } + // if we didn't request this server status + if (!serverStatus) { + return; + } + + s = MSG_ReadStringLine( msg ); + + len = 0; + Com_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, "%s", s); + + if (serverStatus->print) { + Com_Printf("Server settings:\n"); + // print cvars + while (*s) { + for (i = 0; i < 2 && *s; i++) { + if (*s == '\\') + s++; + l = 0; + while (*s) { + info[l++] = *s; + if (l >= MAX_INFO_STRING-1) + break; + s++; + if (*s == '\\') { + break; + } + } + info[l] = '\0'; + if (i) { + Com_Printf("%s\n", info); + } + else { + Com_Printf("%-24s", info); + } + } + } + } + + len = strlen(serverStatus->string); + Com_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, "\\"); + + if (serverStatus->print) { + Com_Printf("\nPlayers:\n"); + Com_Printf("num: score: ping: name:\n"); + } + for (i = 0, s = MSG_ReadStringLine( msg ); *s; s = MSG_ReadStringLine( msg ), i++) { + + len = strlen(serverStatus->string); + Com_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, "\\%s", s); + + if (serverStatus->print) { + score = ping = 0; + sscanf(s, "%d %d", &score, &ping); + s = strchr(s, ' '); + if (s) + s = strchr(s+1, ' '); + if (s) + s++; + else + s = "unknown"; + Com_Printf("%-2d %-3d %-3d %s\n", i, score, ping, s ); + } + } + len = strlen(serverStatus->string); + Com_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, "\\"); + + serverStatus->time = Com_Milliseconds(); + serverStatus->address = from; + serverStatus->pending = qfalse; + if (serverStatus->print) { + serverStatus->retrieved = qtrue; + } +} + +/* +================== +CL_LocalServers_f +================== +*/ +void CL_LocalServers_f( void ) { + char *message; + int i, j; + netadr_t to; + + Com_Printf( "Scanning for servers on the local network...\n"); + Cvar_Set( "cl_langamerefreshstatus", "Scanning for servers on the local network...\n" ); + + // reset the list, waiting for response + cls.numlocalservers = 0; + cls.pingUpdateSource = AS_LOCAL; + + for (i = 0; i < MAX_OTHER_SERVERS; i++) { + qboolean b = cls.localServers[i].visible; + Com_Memset(&cls.localServers[i], 0, sizeof(cls.localServers[i])); + cls.localServers[i].visible = b; + } + Com_Memset( &to, 0, sizeof( to ) ); + + // The 'xxx' in the message is a challenge that will be echoed back + // by the server. We don't care about that here, but master servers + // can use that to prevent spoofed server responses from invalid ip + message = "\377\377\377\377\x02getinfo xxx"; + + // send each message twice in case one is dropped + for ( i = 0 ; i < 2 ; i++ ) { + // send a broadcast packet on each server port + // we support multiple server ports so a single machine + // can nicely run multiple servers + for ( j = 0 ; j < NUM_SERVER_PORTS ; j++ ) { + to.port = BigShort( (short)(PORT_SERVER + j) ); + + to.type = NA_BROADCAST; + NET_SendPacket( NS_CLIENT, strlen( message ), message, to ); + } + } +} + +/* +================== +CL_GamespyServers_f +================== +*/ +// currently about 1000 mohaa servers at a time. when set higher, buffer must be increased! +#define MAX_GAMESPYSERVERS 16 + +void CL_GamespyServers_f( void ) { + char buffer[10240]; + int bytesRead; + + int i, count, max, total; + serverAddress_t addresses[MAX_GAMESPYSERVERS]; + int numservers; + byte* buffptr; + byte* buffend; + +// if ( Cmd_Argc() < 1) { +// Com_Printf( "usage: gamespyservers [keywords]\n"); +// return; +// } + + Com_Printf( "Requesting servers from the GameSpy master...\n" ); + Cvar_Set( "dm_serverstatus", "Getting List."); + + + if (!NETGS_CreateMasterSocket()) { + Com_Printf( "CL_GamespyServers_f: could not create socket.\n" ); + return; + } + if (!NETGS_SendMasterRequest()) { + Com_Printf( "CL_GamespyServers_f: could not send master request.\n" ); + return; + } + bytesRead = NETGS_ReceiveMasterResponse( buffer, sizeof(buffer) ); + if (!bytesRead) { + Com_Printf( "CL_GamespyServers_f: Error in Response.\n" ); + return; + } + + // parse through server response string + numservers = 0; + buffptr = ( byte * )buffer; + buffend = buffptr + bytesRead; + + while (buffptr+1 < buffend) { + if ( buffptr >= buffend - 6 ) { + break; + } + + // parse out ip + addresses[numservers].ip[0] = *buffptr++; + addresses[numservers].ip[1] = *buffptr++; + addresses[numservers].ip[2] = *buffptr++; + addresses[numservers].ip[3] = *buffptr++; + + // parse out port + addresses[numservers].port = *buffptr++; + addresses[numservers].port += (*buffptr++) << 8; + + Com_DPrintf( "server: %d ip: %d.%d.%d.%d:%d\n",numservers, + addresses[numservers].ip[0], + addresses[numservers].ip[1], + addresses[numservers].ip[2], + addresses[numservers].ip[3], + BigShort(addresses[numservers].port) ); + + numservers++; + if (numservers >= MAX_GAMESPYSERVERS) { + break; + } + + // parse out "\\final\\" + if (buffptr[0] == '\\' && buffptr[1] == 'f' && buffptr[2] == 'i' && buffptr[3] == 'n' && buffptr[4] == 'a' && buffptr[6] == 'l' && buffptr[6] == '\\') { + break; + } + } + + cls.numglobalservers = 0; + cls.numGlobalServerAddresses = 0; + + count = cls.numglobalservers; + max = MAX_GLOBAL_SERVERS; + for (i = 0; i < numservers && count < max; i++) { + // build net address + serverInfo_t *server = &cls.globalServers[count]; + + CL_InitServerInfo( server, &addresses[i] ); + // advance to next slot + count++; + } + + + if ( cls.numGlobalServerAddresses < MAX_GLOBAL_SERVERS ) { + // if we couldn't store the servers in the main list anymore + for (; i < numservers && count >= max; i++) { + serverAddress_t *addr; + // just store the addresses in an additional list + addr = &cls.globalServerAddresses[cls.numGlobalServerAddresses++]; + addr->ip[0] = addresses[i].ip[0]; + addr->ip[1] = addresses[i].ip[1]; + addr->ip[2] = addresses[i].ip[2]; + addr->ip[3] = addresses[i].ip[3]; + addr->port = addresses[i].port; + } + } + + cls.numglobalservers = count; + total = count + cls.numGlobalServerAddresses; + + Com_Printf("%d servers parsed (total %d)\n", numservers, total); + Cvar_Set( "dm_serverstatus", "Server List Received."); + Cvar_SetValue( "dm_servercount", total ); +} + + +/* +================== +CL_GlobalServers_f +================== +*/ +void CL_GlobalServers_f( void ) { + netadr_t to; + int i; + int count; + char *buffptr; + char command[1024]; + + if ( Cmd_Argc() < 3) { + Com_Printf( "usage: globalservers [keywords]\n"); + return; + } + + cls.masterNum = atoi( Cmd_Argv(1) ); + + Com_Printf( "Requesting servers from the master...\n"); + + // reset the list, waiting for response + // -1 is used to distinguish a "no response" + + NET_StringToAdr( cl_master->string, &to ); + + if( cls.masterNum == 1 ) { + cls.nummplayerservers = -1; + cls.pingUpdateSource = AS_MPLAYER; + } + else { + cls.numglobalservers = -1; + cls.pingUpdateSource = AS_GLOBAL; + } + to.type = NA_IP; + to.port = BigShort(PORT_MASTER); + + sprintf( command, "getservers %s", Cmd_Argv(2) ); + + // tack on keywords + buffptr = command + strlen( command ); + count = Cmd_Argc(); + for (i=3; i= MAX_PINGREQUESTS) + return; + + cl_pinglist[n].adr.port = 0; +} + +/* +================== +CL_GetPingQueueCount +================== +*/ +int CL_GetPingQueueCount( void ) +{ + int i; + int count; + ping_t* pingptr; + + count = 0; + pingptr = cl_pinglist; + + for (i=0; iadr.port) { + count++; + } + } + + return (count); +} + +/* +================== +CL_GetFreePing +================== +*/ +ping_t* CL_GetFreePing( void ) +{ + ping_t* pingptr; + ping_t* best; + int oldest; + int i; + int time; + + pingptr = cl_pinglist; + for (i=0; iadr.port) + { + if (!pingptr->time) + { + if (cls.realtime - pingptr->start < 500) + { + // still waiting for response + continue; + } + } + else if (pingptr->time < 500) + { + // results have not been queried + continue; + } + } + + // clear it + pingptr->adr.port = 0; + return (pingptr); + } + + // use oldest entry + pingptr = cl_pinglist; + best = cl_pinglist; + oldest = INT_MIN; + for (i=0; istart; + if (time > oldest) + { + oldest = time; + best = pingptr; + } + } + + return (best); +} + +/* +================== +CL_Ping_f +================== +*/ +void CL_Ping_f( void ) { + netadr_t to; + ping_t* pingptr; + char* server; + + if ( Cmd_Argc() != 2 ) { + Com_Printf( "usage: ping [server]\n"); + return; + } + + Com_Memset( &to, 0, sizeof(netadr_t) ); + + server = Cmd_Argv(1); + + if ( !NET_StringToAdr( server, &to ) ) { + return; + } + + pingptr = CL_GetFreePing(); + + memcpy( &pingptr->adr, &to, sizeof (netadr_t) ); + pingptr->start = cls.realtime; + pingptr->time = 0; + + CL_SetServerInfoByAddress(pingptr->adr, NULL, 0); + + NET_OutOfBandPrint( NS_CLIENT, to, "\x02getinfo" ); +} + +/* +================== +CL_SaveShot_f +================== +*/ +void CL_SaveShot_f( void ) { + int i; + char expanded[ 1024 ]; + + if( !cls.rendererRegistered ) { + return; + } + + memcpy( expanded, "screenshot", 11 ); + + for( i = 1; i < Cmd_Argc(); i++ ) + { + strcat( expanded, " " ); + strcat( expanded, Cmd_Argv( i ) ); + } + + strcat( expanded, "\n" ); + + // hide menus + cls.no_menus = qtrue; + UpdateStereoSide( STEREO_CENTER ); + Cbuf_ExecuteText( EXEC_NOW, expanded ); + cls.no_menus = qfalse; +} + +/* +================== +CL_Dialog_f +================== +*/ +void CL_Dialog_f( void ) { + char title[ 64 ]; + char cvar[ 64 ]; + char command[ 64 ]; + char cancelCommand[ 64 ]; + char shader[ 64 ]; + char okshader[ 64 ]; + char cancelshader[ 64 ]; + int width, height; + + if( Cmd_Argc() <= 3 ) { + Com_Printf( "usage: dialog title cvar_name command [width] [height]\n" ); + return; + } + + strcpy( title, Cmd_Argv( 1 ) ); + strcpy( cvar, Cmd_Argv( 2 ) ); + strcpy( command, Cmd_Argv( 3 ) ); + strcpy( cancelCommand, Cmd_Argv( 4 ) ); + + if( Cmd_Argc() > 5 ) { + width = atoi( Cmd_Argv( 5 ) ); + } else { + width = 300; + } + if( Cmd_Argc() > 6 ) { + height = atoi( Cmd_Argv( 6 ) ); + } else { + height = 200; + } + + if( Cmd_Argc() > 7 ) { + strcpy( shader, Cmd_Argv( 7 ) ); + } else { + shader[ 0 ] = 0; + } + if( Cmd_Argc() > 8 ) { + strcpy( okshader, Cmd_Argv( 8 ) ); + } else { + okshader[ 0 ] = 0; + } + if( Cmd_Argc() > 9 ) { + strcpy( cancelshader, Cmd_Argv( 9 ) ); + } else { + cancelshader[ 0 ] = 0; + } + + UI_CreateDialog( title, cvar, command, cancelCommand, width, height, shader, okshader, cancelshader ); +} + +/* +================== +CL_ServerRestarted +================== +*/ +void CL_ServerRestarted( void ) { + S_StopAllSounds( qfalse ); + + UI_ServerLoaded(); + UI_ClearState(); + + VectorClear( cl.viewangles ); +} + +/* +================== +CL_UpdateVisiblePings_f +================== +*/ +qboolean CL_UpdateVisiblePings_f(int source) { + int slots, i; + char buff[MAX_STRING_CHARS]; + int pingTime; + int max; + qboolean status = qfalse; + + if (source < 0 || source > AS_FAVORITES) { + return qfalse; + } + + cls.pingUpdateSource = source; + + slots = CL_GetPingQueueCount(); + if (slots < MAX_PINGREQUESTS) { + serverInfo_t *server = NULL; + + max = (source == AS_GLOBAL) ? MAX_GLOBAL_SERVERS : MAX_OTHER_SERVERS; + switch (source) { + case AS_LOCAL : + server = &cls.localServers[0]; + max = cls.numlocalservers; + break; + case AS_MPLAYER : + server = &cls.mplayerServers[0]; + max = cls.nummplayerservers; + break; + case AS_GLOBAL : + server = &cls.globalServers[0]; + max = cls.numglobalservers; + break; + case AS_FAVORITES : + server = &cls.favoriteServers[0]; + max = cls.numfavoriteservers; + break; + } + for (i = 0; i < max; i++) { + if (server[i].visible) { + if (server[i].ping == -1) { + int j; + + if (slots >= MAX_PINGREQUESTS) { + break; + } + for (j = 0; j < MAX_PINGREQUESTS; j++) { + if (!cl_pinglist[j].adr.port) { + continue; + } + if (NET_CompareAdr( cl_pinglist[j].adr, server[i].adr)) { + // already on the list + break; + } + } + if (j >= MAX_PINGREQUESTS) { + status = qtrue; + for (j = 0; j < MAX_PINGREQUESTS; j++) { + if (!cl_pinglist[j].adr.port) { + break; + } + } + memcpy(&cl_pinglist[j].adr, &server[i].adr, sizeof(netadr_t)); + cl_pinglist[j].start = cls.realtime; + cl_pinglist[j].time = 0; + NET_OutOfBandPrint( NS_CLIENT, cl_pinglist[j].adr, "getinfo xxx" ); + slots++; + } + } + // if the server has a ping higher than cl_maxPing or + // the ping packet got lost + else if (server[i].ping == 0) { + // if we are updating global servers + if (source == AS_GLOBAL) { + // + if ( cls.numGlobalServerAddresses > 0 ) { + // overwrite this server with one from the additional global servers + cls.numGlobalServerAddresses--; + CL_InitServerInfo(&server[i], &cls.globalServerAddresses[cls.numGlobalServerAddresses]); + // NOTE: the server[i].visible flag stays untouched + } + } + } + } + } + } + + if (slots) { + status = qtrue; + } + for (i = 0; i < MAX_PINGREQUESTS; i++) { + if (!cl_pinglist[i].adr.port) { + continue; + } + CL_GetPing( i, buff, MAX_STRING_CHARS, &pingTime ); + if (pingTime != 0) { + CL_ClearPing(i); + status = qtrue; + } + } + + return status; +} + +/* +================== +CL_ServerStatus_f +================== +*/ +void CL_ServerStatus_f(void) { + netadr_t to; + char *server; + serverStatus_t *serverStatus; + + Com_Memset( &to, 0, sizeof(netadr_t) ); + + if ( Cmd_Argc() != 2 ) { + if ( cls.state != CA_ACTIVE || clc.demoplaying ) { + Com_Printf ("Not connected to a server.\n"); + Com_Printf( "Usage: serverstatus [server]\n"); + return; + } + server = cls.servername; + } + else { + server = Cmd_Argv(1); + } + + if ( !NET_StringToAdr( server, &to ) ) { + return; + } + + NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" ); + + serverStatus = CL_GetServerStatus( to ); + serverStatus->address = to; + serverStatus->print = qtrue; + serverStatus->pending = qtrue; +} + +/* +================== +CL_ShowIP_f +================== +*/ +void CL_ShowIP_f(void) { + Sys_ShowIP(); +} + +/* +================= +bool CL_CDKeyValidate +================= +*/ +qboolean CL_CDKeyValidate( const char *key, const char *checksum ) { + char ch; + byte sum; + char chs[3]; + int i, len; + + len = strlen(key); + if( len != CDKEY_LEN ) { + return qfalse; + } + + if( checksum && strlen( checksum ) != CDCHKSUM_LEN ) { + return qfalse; + } + + sum = 0; + // for loop gets rid of conditional assignment warning + for (i = 0; i < len; i++) { + ch = *key++; + if (ch>='a' && ch<='z') { + ch -= 32; + } + switch( ch ) { + case '2': + case '3': + case '7': + case 'A': + case 'B': + case 'C': + case 'D': + case 'G': + case 'H': + case 'J': + case 'L': + case 'P': + case 'R': + case 'S': + case 'T': + case 'W': + sum += ch; + continue; + default: + return qfalse; + } + } + + sprintf(chs, "%02x", sum); + + if (checksum && !Q_stricmp(chs, checksum)) { + return qtrue; + } + + if (!checksum) { + return qtrue; + } + + return qfalse; +} + + diff --git a/code/client/cl_net_chan.cpp b/code/client/cl_net_chan.cpp new file mode 100644 index 00000000..1433c434 --- /dev/null +++ b/code/client/cl_net_chan.cpp @@ -0,0 +1,167 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "../qcommon/q_shared.h" +#include "../qcommon/qcommon.h" +#include "client.h" + +/* +============== +CL_Netchan_Encode + + // first 12 bytes of the data are always: + long serverId; + long messageAcknowledge; + long reliableAcknowledge; + +============== +*/ +static void CL_Netchan_Encode( msg_t *msg ) { + int serverId, messageAcknowledge, reliableAcknowledge; + int i, index, srdc, sbit, soob; + byte key, *string; + + if ( msg->cursize <= CL_ENCODE_START ) { + return; + } + + srdc = msg->readcount; + sbit = msg->bit; + soob = msg->oob; + + msg->bit = 0; + msg->readcount = 0; + msg->oob = 0; + + serverId = MSG_ReadLong(msg); + messageAcknowledge = MSG_ReadLong(msg); + reliableAcknowledge = MSG_ReadLong(msg); + + msg->oob = soob; + msg->bit = sbit; + msg->readcount = srdc; + + string = (byte *)clc.serverCommands[ reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ]; + index = 0; + // + key = clc.challenge ^ serverId ^ messageAcknowledge; + for (i = CL_ENCODE_START; i < msg->cursize; i++) { + // modify the key with the last received now acknowledged server command + if (!string[index]) + index = 0; + if (string[index] > 127 || string[index] == '%') { + key ^= '.' << (i & 1); + } + else { + key ^= string[index] << (i & 1); + } + index++; + // encode the data with this key + *(msg->data + i) = (*(msg->data + i)) ^ key; + } +} + +/* +============== +CL_Netchan_Decode + + // first four bytes of the data are always: + long reliableAcknowledge; + +============== +*/ +static void CL_Netchan_Decode( msg_t *msg ) { + long reliableAcknowledge, i, index; + byte key, *string; + int srdc, sbit, soob; + + srdc = msg->readcount; + sbit = msg->bit; + soob = msg->oob; + + msg->oob = 0; + + reliableAcknowledge = MSG_ReadLong(msg); + + msg->oob = soob; + msg->bit = sbit; + msg->readcount = srdc; + + string = (byte *) clc.reliableCommands[ reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ]; + index = 0; + // xor the client challenge with the netchan sequence number (need something that changes every message) + key = clc.challenge ^ LittleLong( *(unsigned *)msg->data ); + for (i = msg->readcount + CL_DECODE_START; i < msg->cursize; i++) { + // modify the key with the last sent and with this message acknowledged client command + if (!string[index]) + index = 0; + if (string[index] > 127 || string[index] == '%') { + key ^= '.' << (i & 1); + } + else { + key ^= string[index] << (i & 1); + } + index++; + // decode the data with this key + *(msg->data + i) = *(msg->data + i) ^ key; + } +} + +/* +================= +CL_Netchan_TransmitNextFragment +================= +*/ +void CL_Netchan_TransmitNextFragment( netchan_t *chan ) { + Netchan_TransmitNextFragment( chan ); +} + +/* +=============== +CL_Netchan_Transmit +================ +*/ +void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg ) { + MSG_WriteByte( msg, clc_EOF ); + + CL_Netchan_Encode( msg ); + Netchan_Transmit( chan, msg->cursize, msg->data ); +} + +extern int oldsize; +int newsize = 0; + +/* +================= +CL_Netchan_Process +================= +*/ +qboolean CL_Netchan_Process( netchan_t *chan, msg_t *msg ) { + int ret; + + ret = Netchan_Process( chan, msg ); + if (!ret) + return qfalse; + CL_Netchan_Decode( msg ); + newsize += msg->cursize; + return qtrue; +} diff --git a/code/client/cl_parse.cpp b/code/client/cl_parse.cpp new file mode 100644 index 00000000..ead29765 --- /dev/null +++ b/code/client/cl_parse.cpp @@ -0,0 +1,857 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// cl_parse.c -- parse a message received from the server + +#include "client.h" + +char *svc_strings[256] = { + "svc_bad", + + "svc_nop", + "svc_gamestate", + "svc_configstring", + "svc_baseline", + "svc_serverCommand", + "svc_download", + "svc_snapshot", + "svc_centerprint", + "svc_locprint", + "svc_cgameMessage" +}; + +msg_t *cl_currentMSG; + +void SHOWNET( msg_t *msg, char *s) { + if ( cl_shownet->integer >= 2) { + Com_Printf ("%3i:%s\n", msg->readcount-1, s); + } +} + + +/* +========================================================================= + +MESSAGE PARSING + +========================================================================= +*/ + +/* +================== +CL_DeltaEntity + +Parses deltas from the given base and adds the resulting entity +to the current frame +================== +*/ +void CL_DeltaEntity (msg_t *msg, clSnapshot_t *frame, int newnum, entityState_t *old, + qboolean unchanged) { + entityState_t *state; + + // save the parsed entity state into the big circular buffer so + // it can be used as the source for a later delta + state = &cl.parseEntities[cl.parseEntitiesNum & (MAX_PARSE_ENTITIES-1)]; + + if ( unchanged ) { + *state = *old; + } else { + MSG_ReadDeltaEntity( msg, old, state, newnum ); + } + + if ( state->number == (MAX_GENTITIES-1) ) { + return; // entity was delta removed + } + cl.parseEntitiesNum++; + frame->numEntities++; +} + +/* +================== +CL_ParsePacketEntities + +================== +*/ +void CL_ParsePacketEntities( msg_t *msg, clSnapshot_t *oldframe, clSnapshot_t *newframe) { + int newnum; + entityState_t *oldstate; + int oldindex, oldnum; + + newframe->parseEntitiesNum = cl.parseEntitiesNum; + newframe->numEntities = 0; + + // delta from the entities present in oldframe + oldindex = 0; + oldstate = NULL; + if (!oldframe) { + oldnum = 99999; + } else { + if ( oldindex >= oldframe->numEntities ) { + oldnum = 99999; + } else { + oldstate = &cl.parseEntities[ + (oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)]; + oldnum = oldstate->number; + } + } + + while ( 1 ) { + // read the entity index number + newnum = MSG_ReadBits( msg, GENTITYNUM_BITS ); + + if ( newnum == (MAX_GENTITIES-1) ) { + break; + } + + if ( msg->readcount > msg->cursize ) { + Com_Error (ERR_DROP,"CL_ParsePacketEntities: end of message"); + } + + while ( oldnum < newnum ) { + // one or more entities from the old packet are unchanged + if ( cl_shownet->integer == 3 ) { + Com_Printf ("%3i: unchanged: %i\n", msg->readcount, oldnum); + } + CL_DeltaEntity( msg, newframe, oldnum, oldstate, qtrue ); + + oldindex++; + + if ( oldindex >= oldframe->numEntities ) { + oldnum = 99999; + } else { + oldstate = &cl.parseEntities[ + (oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)]; + oldnum = oldstate->number; + } + } + if (oldnum == newnum) { + // delta from previous state + if ( cl_shownet->integer == 3 ) { + Com_Printf ("%3i: delta: %i\n", msg->readcount, newnum); + } + CL_DeltaEntity( msg, newframe, newnum, oldstate, qfalse ); + + oldindex++; + + if ( oldindex >= oldframe->numEntities ) { + oldnum = 99999; + } else { + oldstate = &cl.parseEntities[ + (oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)]; + oldnum = oldstate->number; + } + continue; + } + + if ( oldnum > newnum ) { + // delta from baseline + if ( cl_shownet->integer == 3 ) { + Com_Printf ("%3i: baseline: %i\n", msg->readcount, newnum); + } + CL_DeltaEntity( msg, newframe, newnum, &cl.entityBaselines[newnum], qfalse ); + continue; + } + + } + + // any remaining entities in the old frame are copied over + while ( oldnum != 99999 ) { + // one or more entities from the old packet are unchanged + if ( cl_shownet->integer == 3 ) { + Com_Printf ("%3i: unchanged: %i\n", msg->readcount, oldnum); + } + CL_DeltaEntity( msg, newframe, oldnum, oldstate, qtrue ); + + oldindex++; + + if ( oldindex >= oldframe->numEntities ) { + oldnum = 99999; + } else { + oldstate = &cl.parseEntities[ + (oldframe->parseEntitiesNum + oldindex) & (MAX_PARSE_ENTITIES-1)]; + oldnum = oldstate->number; + } + } +} + + +/* +================ +CL_ParseSnapshot + +If the snapshot is parsed properly, it will be copied to +cl.snap and saved in cl.snapshots[]. If the snapshot is invalid +for any reason, no changes to the state will be made at all. +================ +*/ +void CL_ParseSnapshot( msg_t *msg ) { + int len; + clSnapshot_t *old; + clSnapshot_t newSnap; + int deltaNum; + int oldMessageNum; + int i, packetNum; + + // get the reliable sequence acknowledge number + // NOTE: now sent with all server to client messages + //clc.reliableAcknowledge = MSG_ReadLong( msg ); + + // read in the new snapshot to a temporary buffer + // we will only copy to cl.snap if it is valid + Com_Memset (&newSnap, 0, sizeof(newSnap)); + + // we will have read any new server commands in this + // message before we got to svc_snapshot + newSnap.serverCommandNum = clc.serverCommandSequence; + + newSnap.serverTime = MSG_ReadLong( msg ); + newSnap.serverTimeResidual = MSG_ReadByte( msg ); + + newSnap.messageNum = clc.serverMessageSequence; + + deltaNum = MSG_ReadByte( msg ); + if ( !deltaNum ) { + newSnap.deltaNum = -1; + } else { + newSnap.deltaNum = newSnap.messageNum - deltaNum; + } + newSnap.snapFlags = MSG_ReadByte( msg ); + + // If the frame is delta compressed from data that we + // no longer have available, we must suck up the rest of + // the frame, but not use it, then ask for a non-compressed + // message + if ( newSnap.deltaNum <= 0 ) { + newSnap.valid = qtrue; // uncompressed frame + old = NULL; + clc.demowaiting = qfalse; // we can start recording now + } else { + old = &cl.snapshots[newSnap.deltaNum & PACKET_MASK]; + if ( !old->valid ) { + // should never happen + Com_Printf ("Delta from invalid frame (not supposed to happen!).\n"); + } else if ( old->messageNum != newSnap.deltaNum ) { + // The frame that the server did the delta from + // is too old, so we can't reconstruct it properly. + Com_Printf ("Delta frame too old.\n"); + } else if ( cl.parseEntitiesNum - old->parseEntitiesNum > MAX_PARSE_ENTITIES-128 ) { + Com_Printf ("Delta parseEntitiesNum too old.\n"); + } else { + newSnap.valid = qtrue; // valid delta parse + } + } + + // read areamask + len = MSG_ReadByte( msg ); + + if(len > sizeof(newSnap.areamask)) + { + Com_Error (ERR_DROP,"CL_ParseSnapshot: Invalid size %d for areamask.", len); + return; + } + + MSG_ReadData( msg, &newSnap.areamask, len); + + // read playerinfo + SHOWNET( msg, "playerstate" ); + if ( old ) { + MSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps ); + } else { + MSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps ); + } + + // read packet entities + SHOWNET( msg, "packet entities" ); + CL_ParsePacketEntities( msg, old, &newSnap ); + + MSG_ReadSounds( msg, newSnap.sounds, &newSnap.number_of_sounds ); + + // if not valid, dump the entire thing now that it has + // been properly read + if ( !newSnap.valid ) { + return; + } + + // clear the valid flags of any snapshots between the last + // received and this one, so if there was a dropped packet + // it won't look like something valid to delta from next + // time we wrap around in the buffer + oldMessageNum = cl.snap.messageNum + 1; + + if ( newSnap.messageNum - oldMessageNum >= PACKET_BACKUP ) { + oldMessageNum = newSnap.messageNum - ( PACKET_BACKUP - 1 ); + } + for ( ; oldMessageNum < newSnap.messageNum ; oldMessageNum++ ) { + cl.snapshots[oldMessageNum & PACKET_MASK].valid = qfalse; + } + + if( cl.snap.valid && ( newSnap.snapFlags ^ cl.snap.snapFlags ) & SNAPFLAG_SERVERCOUNT ) { + cl.serverStartTime = newSnap.serverTime; + } + + // copy to the current good spot + cl.snap = newSnap; + cl.snap.ping = 999; + // calculate ping time + for ( i = 0 ; i < PACKET_BACKUP ; i++ ) { + packetNum = ( clc.netchan.outgoingSequence - 1 - i ) & PACKET_MASK; + if ( cl.snap.ps.commandTime >= cl.outPackets[ packetNum ].p_serverTime ) { + cl.snap.ping = cls.realtime - cl.outPackets[ packetNum ].p_realtime; + break; + } + } + // save the frame off in the backup array for later delta comparisons + cl.snapshots[cl.snap.messageNum & PACKET_MASK] = cl.snap; + + if (cl_shownet->integer == 3) { + Com_Printf( " snapshot:%i delta:%i ping:%i\n", cl.snap.messageNum, + cl.snap.deltaNum, cl.snap.ping ); + } + + cl.newSnapshots = qtrue; +} + + +//===================================================================== + +int cl_connectedToPureServer; +int cl_connectedToCheatServer; + +/* +================== +CL_SystemInfoChanged + +The systeminfo configstring has been changed, so parse +new information out of it. This will happen at every +gamestate, and possibly during gameplay. +================== +*/ +void CL_SystemInfoChanged( void ) { + char *systemInfo; + const char *s, *t; + char key[BIG_INFO_KEY]; + char value[BIG_INFO_VALUE]; + qboolean gameSet; + + systemInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SYSTEMINFO ]; + // NOTE TTimo: + // when the serverId changes, any further messages we send to the server will use this new serverId + // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475 + // in some cases, outdated cp commands might get sent with this news serverId + cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) ); + + // don't set any vars when playing a demo + if ( clc.demoplaying ) { + return; + } + + s = Info_ValueForKey( systemInfo, "sv_cheats" ); + cl_connectedToCheatServer = atoi( s ); + if ( !cl_connectedToCheatServer ) { + Cvar_SetCheatState(); + } + + // check pure server string + s = Info_ValueForKey( systemInfo, "sv_paks" ); + t = Info_ValueForKey( systemInfo, "sv_pakNames" ); + FS_PureServerSetLoadedPaks( s, t ); + + s = Info_ValueForKey( systemInfo, "sv_referencedPaks" ); + t = Info_ValueForKey( systemInfo, "sv_referencedPakNames" ); + FS_PureServerSetReferencedPaks( s, t ); + + gameSet = qfalse; + // scan through all the variables in the systeminfo and locally set cvars to match + s = systemInfo; + while ( s ) { + int cvar_flags; + + Info_NextPair( &s, key, value ); + if ( !key[0] ) { + break; + } + + // ehw! + if (!Q_stricmp(key, "fs_game")) + { + if(FS_CheckDirTraversal(value)) + { + Com_Printf(S_COLOR_YELLOW "WARNING: Server sent invalid fs_game value %s\n", value); + continue; + } + + gameSet = qtrue; + } + + if((cvar_flags = Cvar_Flags(key)) == CVAR_NONEXISTENT) + Cvar_Get(key, value, CVAR_SERVER_CREATED | CVAR_ROM); + else + { + // If this cvar may not be modified by a server discard the value. + if(!(cvar_flags & (CVAR_SYSTEMINFO | CVAR_SERVER_CREATED))) + { + Com_Printf(S_COLOR_YELLOW "WARNING: server is not allowed to set %s=%s\n", key, value); + continue; + } + + Cvar_Set(key, value); + } + } + // if game folder should not be set and it is set at the client side + if ( !gameSet && *Cvar_VariableString("fs_game") ) { + Cvar_Set( "fs_game", "" ); + } + // wombat: we ignore server's sv_pure for now + //cl_connectedToPureServer = Cvar_VariableValue( "sv_pure" ); + cl_connectedToPureServer = 0; +} + +/* +================== +CL_ParseServerInfo +================== +*/ +static void CL_ParseServerInfo(void) +{ + const char *serverInfo; + + serverInfo = cl.gameState.stringData + + cl.gameState.stringOffsets[ CS_SERVERINFO ]; + + clc.sv_allowDownload = atoi(Info_ValueForKey(serverInfo, + "sv_allowDownload")); + Q_strncpyz(clc.sv_dlURL, + Info_ValueForKey(serverInfo, "sv_dlURL"), + sizeof(clc.sv_dlURL)); +} + +/* +================== +CL_ParseGamestate +================== +*/ +void CL_ParseGamestate( msg_t *msg ) { + int i; + entityState_t *es; + int newnum; + entityState_t nullstate; + int cmd; + char *s; + + Con_Close(); + + clc.connectPacketCount = 0; + + // wipe local client state + CL_ClearState(); + + // a gamestate always marks a server command sequence + clc.serverCommandSequence = MSG_ReadLong( msg ); + + // parse all the configstrings and baselines + cl.gameState.dataCount = 1; // leave a 0 at the beginning for uninitialized configstrings + while ( 1 ) { + cmd = MSG_ReadByte( msg ); + + if ( cmd == svc_EOF ) { + break; + } + + if ( cmd == svc_configstring ) { + int len; + + i = MSG_ReadShort( msg ); + if ( i < 0 || i >= MAX_CONFIGSTRINGS ) { + Com_Error( ERR_DROP, "configstring > MAX_CONFIGSTRINGS" ); + } + s = MSG_ReadString( msg ); + len = strlen( s ); + + if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) { + Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" ); + } + // append it to the gameState string buffer + cl.gameState.stringOffsets[ i ] = cl.gameState.dataCount; + Com_Memcpy( cl.gameState.stringData + cl.gameState.dataCount, s, len + 1 ); + cl.gameState.dataCount += len + 1; + } else if ( cmd == svc_baseline ) { + newnum = MSG_ReadBits( msg, GENTITYNUM_BITS ); + if ( newnum < 0 || newnum >= MAX_GENTITIES ) { + Com_Error( ERR_DROP, "Baseline number out of range: %i", newnum ); + } + //Com_Memset (&nullstate, 0, sizeof(nullstate)); + MSG_GetNullEntityState(&nullstate); + es = &cl.entityBaselines[ newnum ]; + MSG_ReadDeltaEntity( msg, &nullstate, es, newnum ); + } else { + Com_Error( ERR_DROP, "CL_ParseGamestate: bad command byte %i", cmd ); + } + } + + clc.clientNum = MSG_ReadLong(msg); + // read the checksum feed + clc.checksumFeed = MSG_ReadLong( msg ); + + // parse useful values out of CS_SERVERINFO + CL_ParseServerInfo(); + + // parse serverId and other cvars + CL_SystemInfoChanged(); + + // stop recording now so the demo won't have an unnecessary level load at the end. + if(cl_autoRecordDemo->integer && clc.demorecording) + CL_StopRecord_f(); + + // reinitialize the filesystem if the game directory has changed + FS_ConditionalRestart( clc.checksumFeed ); + + // This used to call CL_StartHunkUsers, but now we enter the download state before loading the + // cgame + CL_InitDownloads(); + + // make sure the game starts + Com_Unpause(); +} + + +//===================================================================== + +int CL_MSG_ReadBits( int bits ) +{ + return MSG_ReadBits( cl_currentMSG, bits ); +} + +int CL_MSG_ReadChar( void ) +{ + return MSG_ReadChar( cl_currentMSG ); +} + +int CL_MSG_ReadByte( void ) +{ + return MSG_ReadByte( cl_currentMSG ); +} + +int CL_MSG_ReadSVC( void ) +{ + return MSG_ReadSVC( cl_currentMSG ); +} + +int CL_MSG_ReadShort( void ) +{ + return MSG_ReadShort( cl_currentMSG ); +} + +int CL_MSG_ReadLong( void ) +{ + return MSG_ReadLong( cl_currentMSG ); +} + +float CL_MSG_ReadFloat( void ) +{ + return MSG_ReadFloat( cl_currentMSG ); +} + +char *CL_MSG_ReadString( void ) +{ + return MSG_ReadString( cl_currentMSG ); +} + +char *CL_MSG_ReadStringLine( void ) +{ + return MSG_ReadStringLine( cl_currentMSG ); +} + +float CL_MSG_ReadAngle8( void ) +{ + return MSG_ReadAngle8( cl_currentMSG ); +} + +float CL_MSG_ReadAngle16( void ) +{ + return MSG_ReadAngle16( cl_currentMSG ); +} + +void CL_MSG_ReadData( void *data, int len ) +{ + return MSG_ReadData( cl_currentMSG, data, len ); +} + +float CL_MSG_ReadCoord( void ) +{ + return MSG_ReadCoord( cl_currentMSG ); +} + +void CL_MSG_ReadDir( vec3_t dir ) +{ + MSG_ReadDir( cl_currentMSG, dir ); +} + +/* +===================== +CL_ParseDownload + +A download message has been received from the server +===================== +*/ +void CL_ParseDownload ( msg_t *msg ) { + int size; + unsigned char data[MAX_MSGLEN]; + int block; + + if (!*clc.downloadTempName) { + Com_Printf("Server sending download, but no download was requested\n"); + CL_AddReliableCommand( "stopdl" ); + return; + } + + // read the data + block = MSG_ReadShort ( msg ); + + if ( !block ) + { + // block zero is special, contains file size + clc.downloadSize = MSG_ReadLong ( msg ); + + Cvar_SetValue( "cl_downloadSize", clc.downloadSize ); + + if (clc.downloadSize < 0) + { + Com_Error( ERR_DROP, "%s", MSG_ReadString( msg ) ); + return; + } + } + + size = MSG_ReadShort ( msg ); + if (size < 0 || size > sizeof(data)) + { + Com_Error(ERR_DROP, "CL_ParseDownload: Invalid size %d for download chunk.", size); + return; + } + + MSG_ReadData(msg, data, size); + + if (clc.downloadBlock != block) { + Com_DPrintf( "CL_ParseDownload: Expected block %d, got %d\n", clc.downloadBlock, block); + return; + } + + // open the file if not opened yet + if (!clc.download) + { + clc.download = FS_SV_FOpenFileWrite( clc.downloadTempName ); + + if (!clc.download) { + Com_Printf( "Could not create %s\n", clc.downloadTempName ); + CL_AddReliableCommand( "stopdl" ); + CL_NextDownload(); + return; + } + } + + if (size) + FS_Write( data, size, clc.download ); + + CL_AddReliableCommand( va("nextdl %d", clc.downloadBlock) ); + clc.downloadBlock++; + + clc.downloadCount += size; + + // So UI gets access to it + Cvar_SetValue( "cl_downloadCount", clc.downloadCount ); + + if (!size) { // A zero length block means EOF + if (clc.download) { + FS_FCloseFile( clc.download ); + clc.download = 0; + + // rename the file + FS_SV_Rename ( clc.downloadTempName, clc.downloadName ); + } + *clc.downloadTempName = *clc.downloadName = 0; + Cvar_Set( "cl_downloadName", "" ); + + // send intentions now + // We need this because without it, we would hold the last nextdl and then start + // loading right away. If we take a while to load, the server is happily trying + // to send us that last block over and over. + // Write it twice to help make sure we acknowledge the download + CL_WritePacket(); + CL_WritePacket(); + + // get another file if needed + CL_NextDownload (); + } +} + +/* +===================== +CL_ParseCommandString + +Command strings are just saved off until cgame asks for them +when it transitions a snapshot +===================== +*/ +void CL_ParseCommandString( msg_t *msg ) { + char *s; + int seq; + int index; + + seq = MSG_ReadLong( msg ); + s = MSG_ReadString( msg ); + + // see if we have already executed stored it off + if ( clc.serverCommandSequence >= seq ) { + return; + } + clc.serverCommandSequence = seq; + + index = seq & (MAX_RELIABLE_COMMANDS-1); + Q_strncpyz( clc.serverCommands[ index ], s, sizeof( clc.serverCommands[ index ] ) ); +} + +/* +===================== +CL_ParseCGMessage + +MOHAA does this inside its cgame. its some big function with a 37-switch case +but unless we properly read the CG message, we don't know when the message +hase finished +===================== +*/ +void CL_ParseCGMessage( msg_t *msg ) { + cl_currentMSG = msg; + cge->CG_ParseCGMessage(); +} + +/* +===================== +CL_ParseLocationprint +===================== +*/ +void CL_ParseLocationprint( msg_t *msg ) { + int x, y; + char *string; + + x = MSG_ReadShort( msg ); + y = MSG_ReadShort( msg ); + string = MSG_ReadString(msg); + + // FIXME + //UI_UpdateLocationPrint( x, y, string, 1.0 ); +} + +/* +===================== +CL_ParseCenterprint +===================== +*/ +void CL_ParseCenterprint( msg_t *msg ) { + char *string; + + string = MSG_ReadString( msg ); + + // FIXME + //UI_UpdateCenterPrintf( string, 1.0 ); +} + +/* +===================== +CL_ParseServerMessage +===================== +*/ +void CL_ParseServerMessage( msg_t *msg ) { + int cmd; +//Com_Printf( "ParseServerMessage: %i\n", msg->cursize ); + if ( cl_shownet->integer == 1 ) { + Com_Printf ("%i ",msg->cursize); + } else if ( cl_shownet->integer >= 2 ) { + Com_Printf ("------------------\n"); + } + + MSG_Bitstream(msg); + + // get the reliable sequence acknowledge number + clc.reliableAcknowledge = MSG_ReadLong( msg ); + // + if ( clc.reliableAcknowledge < clc.reliableSequence - MAX_RELIABLE_COMMANDS ) { + clc.reliableAcknowledge = clc.reliableSequence; + } + + // + // parse the message + // + while ( 1 ) { + if ( msg->readcount > msg->cursize ) { + Com_Error (ERR_DROP,"CL_ParseServerMessage: read past end of server message"); + break; + } + + cmd = MSG_ReadByte( msg ); + // Com_Printf( "CL_ParseServerMessage: cmd %i\n", cmd ); + if ( cmd == svc_EOF) { + SHOWNET( msg, "END OF MESSAGE" ); + break; + } + + if ( cl_shownet->integer >= 2 ) { + if ( !svc_strings[cmd] ) { + Com_Printf( "%3i:BAD CMD %i\n", msg->readcount-1, cmd ); + } else { + SHOWNET( msg, svc_strings[cmd] ); + } + } + + // other commands + switch ( cmd ) { + default: + Com_Error (ERR_DROP,"CL_ParseServerMessage: Illegible server message\n"); + break; + case svc_nop: + break; + case svc_serverCommand: + CL_ParseCommandString( msg ); + break; + case svc_gamestate: + CL_ParseGamestate( msg ); + break; + case svc_snapshot: + CL_ParseSnapshot( msg ); + break; + case svc_download: + CL_ParseDownload( msg ); + break; + case svc_centerprint: + CL_ParseCenterprint( msg ); + break; + case svc_locprint: + CL_ParseLocationprint( msg ); + break; + case svc_cgameMessage: + if( !cge ) { + Com_Error(ERR_DROP,"CL_ParseServerMessage: tried to parse cg message without cgame loaded\n"); + } + CL_ParseCGMessage( msg ); + break; + } + } +} + + diff --git a/code/client/cl_scrn.cpp b/code/client/cl_scrn.cpp new file mode 100644 index 00000000..2f7833b4 --- /dev/null +++ b/code/client/cl_scrn.cpp @@ -0,0 +1,563 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc + +#include "client.h" +#include "cl_ui.h" + +qboolean scr_initialized; // ready to draw +stereoFrame_t s_scr_stereoFrame; + +cvar_t *cl_timegraph; +cvar_t *cl_debuggraph; +cvar_t *cl_graphheight; +cvar_t *cl_graphscale; +cvar_t *cl_graphshift; + +/* +================ +SCR_DrawNamedPic + +Coordinates are 640*480 virtual values +================= +*/ +void SCR_DrawNamedPic( float x, float y, float width, float height, const char *picname ) { + qhandle_t hShader; + + assert( width != 0 ); + + hShader = re.RegisterShader( picname ); + SCR_AdjustFrom640( &x, &y, &width, &height ); + re.DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader ); +} + + +/* +================ +SCR_AdjustFrom640 + +Adjusted for resolution and screen aspect ratio +================ +*/ +void SCR_AdjustFrom640( float *x, float *y, float *w, float *h ) { + float xscale; + float yscale; + +#if 0 + // adjust for wide screens + if ( cls.glconfig.vidWidth * 480 > cls.glconfig.vidHeight * 640 ) { + *x += 0.5 * ( cls.glconfig.vidWidth - ( cls.glconfig.vidHeight * 640 / 480 ) ); + } +#endif + + // scale for screen sizes + xscale = cls.glconfig.vidWidth / 640.0; + yscale = cls.glconfig.vidHeight / 480.0; + if ( x ) { + *x *= xscale; + } + if ( y ) { + *y *= yscale; + } + if ( w ) { + *w *= xscale; + } + if ( h ) { + *h *= yscale; + } +} + +/* +================ +SCR_FillRect + +Coordinates are 640*480 virtual values +================= +*/ +void SCR_FillRect( float x, float y, float width, float height, const float *color ) { + re.SetColor( color ); + + SCR_AdjustFrom640( &x, &y, &width, &height ); + re.DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cls.whiteShader ); + + re.SetColor( NULL ); +} + + +/* +================ +SCR_DrawPic + +Coordinates are 640*480 virtual values +================= +*/ +void SCR_DrawPic( float x, float y, float width, float height, qhandle_t hShader ) { + SCR_AdjustFrom640( &x, &y, &width, &height ); + re.DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader ); +} + + + +/* +** SCR_DrawChar +** chars are drawn at 640*480 virtual screen size +*/ +static void SCR_DrawChar( int x, int y, float size, int ch ) { + int row, col; + float frow, fcol; + float ax, ay, aw, ah; + + ch &= 255; + + if ( ch == ' ' ) { + return; + } + + if ( y < -size ) { + return; + } + + ax = x; + ay = y; + aw = size; + ah = size; + SCR_AdjustFrom640( &ax, &ay, &aw, &ah ); + + row = ch>>4; + col = ch&15; + + frow = row*0.0625; + fcol = col*0.0625; + size = 0.0625; + + re.DrawStretchPic( ax, ay, aw, ah, + fcol, frow, + fcol + size, frow + size, + cls.charSetShader ); +} + +/* +** SCR_DrawSmallChar +** small chars are drawn at native screen resolution +*/ +void SCR_DrawSmallChar( int x, int y, int ch ) { + int row, col; + float frow, fcol; + float size; + + ch &= 255; + + if ( ch == ' ' ) { + return; + } + + if ( y < -SMALLCHAR_HEIGHT ) { + return; + } + + row = ch>>4; + col = ch&15; + + frow = row*0.0625; + fcol = col*0.0625; + size = 0.0625; + + re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, + fcol, frow, + fcol + size, frow + size, + cls.charSetShader ); +} + + +/* +================== +SCR_DrawBigString[Color] + +Draws a multi-colored string with a drop shadow, optionally forcing +to a fixed color. + +Coordinates are at 640 by 480 virtual resolution +================== +*/ +void SCR_DrawStringExt( int x, int y, float size, const char *string, float *setColor, qboolean forceColor, + qboolean noColorEscape ) { + vec4_t color; + const char *s; + int xx; + + // draw the drop shadow + color[0] = color[1] = color[2] = 0; + color[3] = setColor[3]; + re.SetColor( color ); + s = string; + xx = x; + while ( *s ) { + if ( !noColorEscape && Q_IsColorString( s ) ) { + s += 2; + continue; + } + SCR_DrawChar( xx+2, y+2, size, *s ); + xx += size; + s++; + } + + + // draw the colored text + s = string; + xx = x; + re.SetColor( setColor ); + while ( *s ) { + if ( !noColorEscape && Q_IsColorString( s ) ) { + if ( !forceColor ) { + Com_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) ); + color[3] = setColor[3]; + re.SetColor( color ); + } + s += 2; + continue; + } + SCR_DrawChar( xx, y, size, *s ); + xx += size; + s++; + } + re.SetColor( NULL ); +} + + +void SCR_DrawBigString( int x, int y, const char *s, float alpha, qboolean noColorEscape ) { + float color[4]; + + color[0] = color[1] = color[2] = 1.0; + color[3] = alpha; + SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, qfalse, noColorEscape ); +} + +void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color, qboolean noColorEscape ) { + SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, qtrue, noColorEscape ); +} + + +/* +================== +SCR_DrawSmallString[Color] + +Draws a multi-colored string with a drop shadow, optionally forcing +to a fixed color. +================== +*/ +void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor, + qboolean noColorEscape ) { + vec4_t color; + const char *s; + int xx; + + // draw the colored text + s = string; + xx = x; + re.SetColor( setColor ); + while ( *s ) { + if ( !noColorEscape && Q_IsColorString( s ) ) { + if ( !forceColor ) { + Com_Memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) ); + color[3] = setColor[3]; + re.SetColor( color ); + } + s += 2; + continue; + } + SCR_DrawSmallChar( xx, y, *s ); + xx += SMALLCHAR_WIDTH; + s++; + } + re.SetColor( NULL ); +} + + + +/* +** SCR_Strlen -- skips color escape codes +*/ +static int SCR_Strlen( const char *str ) { + const char *s = str; + int count = 0; + + while ( *s ) { + if ( Q_IsColorString( s ) ) { + s += 2; + } else { + count++; + s++; + } + } + + return count; +} + +/* +** SCR_GetBigStringWidth +*/ +int SCR_GetBigStringWidth( const char *str ) { + return SCR_Strlen( str ) * 16; +} + + +//=============================================================================== + +/* +================= +SCR_DrawDemoRecording +================= +*/ +void SCR_DrawDemoRecording( void ) { + char string[1024]; + int pos; + + if ( !clc.demorecording ) { + return; + } + if ( clc.spDemoRecording ) { + return; + } + + pos = FS_FTell( clc.demofile ); + sprintf( string, "RECORDING %s: %ik", clc.demoName, pos / 1024 ); + + SCR_DrawStringExt( 320 - strlen( string ) * 4, 20, 8, string, g_color_table[7], qtrue, qfalse ); +} + + +/* +=============================================================================== + +DEBUG GRAPH + +=============================================================================== +*/ + +typedef struct +{ + float value; + int color; +} graphsamp_t; + +static int current; +static graphsamp_t values[1024]; + +/* +============== +SCR_DebugGraph +============== +*/ +void SCR_DebugGraph (float value, int color) +{ + values[current&1023].value = value; + values[current&1023].color = color; + current++; +} + +/* +============== +SCR_DrawDebugGraph +============== +*/ +void SCR_DrawDebugGraph (void) +{ + int a, x, y, w, i, h; + float v; + int color; + + // + // draw the graph + // + w = cls.glconfig.vidWidth; + x = 0; + y = cls.glconfig.vidHeight; + re.SetColor( g_color_table[0] ); + re.DrawStretchPic(x, y - cl_graphheight->integer, + w, cl_graphheight->integer, 0, 0, 0, 0, cls.whiteShader ); + re.SetColor( NULL ); + + for (a=0 ; ainteger + cl_graphshift->integer; + + if (v < 0) + v += cl_graphheight->integer * (1+(int)(-v / cl_graphheight->integer)); + h = (int)v % cl_graphheight->integer; + re.DrawStretchPic( x+w-1-a, y - h, 1, h, 0, 0, 0, 0, cls.whiteShader ); + } +} + +//============================================================================= + +/* +================== +SCR_Init +================== +*/ +void SCR_Init( void ) { + cl_timegraph = Cvar_Get ("timegraph", "0", CVAR_CHEAT); + cl_debuggraph = Cvar_Get ("debuggraph", "0", CVAR_CHEAT); + cl_graphheight = Cvar_Get ("graphheight", "32", CVAR_CHEAT); + cl_graphscale = Cvar_Get ("graphscale", "1", CVAR_CHEAT); + cl_graphshift = Cvar_Get ("graphshift", "0", CVAR_CHEAT); + + scr_initialized = qtrue; +} + + +//======================================================= + +/* +================== +SCR_DrawScreenField + +This will be called twice if rendering in stereo mode +================== +*/ +void SCR_DrawScreenField( stereoFrame_t stereoFrame ) { + // wide aspect ratio screens need to have the sides cleared + // unless they are displaying game renderings + if ( cls.state != CA_ACTIVE && cls.state != CA_CINEMATIC ) { + if ( cls.glconfig.vidWidth * 480 > cls.glconfig.vidHeight * 640 ) { + re.SetColor( g_color_table[0] ); + //re.DrawStretchPic( 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, 0, 0, 0, 0, cls.whiteShader ); + re.DrawBox( 0, 0, cls.glconfig.vidHeight, cls.glconfig.vidWidth ); + re.SetColor( NULL ); + } + } + + switch( cls.state ) { + case CA_UNINITIALIZED: + Com_Error( ERR_FATAL, "SCR_DrawScreenField: cls.state == CA_UNINITIALIZED" ); + break; + case CA_LOADING: + case CA_PRIMED: + // draw the game information screen and loading progress + CL_CGameRendering( stereoFrame ); + + // also draw the connection information, so it doesn't + // flash away too briefly on local or lan games + // refresh to update the time + case CA_CONNECTING: + case CA_CHALLENGING: + case CA_CONNECTED: + // connecting clients will only show the connection dialog + // refresh to update the time + UI_DrawConnect(); + break; + case CA_CINEMATIC: + SCR_DrawCinematic(); + break; + case CA_ACTIVE: + CL_CGameRendering( stereoFrame ); + break; + default: + break; + } +} + +/* +================== +UpdateStereoSide +================== +*/ +void UpdateStereoSide( stereoFrame_t s ) { + s_scr_stereoFrame = s; + re.BeginFrame( s ); + if( cls.state == CA_CINEMATIC ) { + SCR_DrawCinematic(); + } + //UI_Update(); +} + +/* +================== +SCR_SimpleUpdateScreen +================== +*/ +void SCR_SimpleUpdateScreen( void ) { + // if running in stereo, we need to draw the frame twice + if( cls.glconfig.stereoEnabled ) { + UpdateStereoSide( STEREO_LEFT ); + UpdateStereoSide( STEREO_RIGHT ); + } + else { + UpdateStereoSide( STEREO_CENTER ); + } + + if( com_speeds->integer ) { + re.EndFrame( &time_frontend, &time_backend ); + } + else { + re.EndFrame( NULL, NULL ); + } +} + +/* +================== +SCR_UpdateScreen + +This is called every frame, and can also be called explicitly to flush +text to the screen. +================== +*/ +void SCR_UpdateScreen( void ) { + static int recursive; + + if ( !scr_initialized ) { + return; // not initialized yet + } + + if ( recursive ) { + return; + } + recursive = 1; + + CL_StartHunkUsers(); + SCR_SimpleUpdateScreen(); + + // set the fps value + if( fps->integer && cls.state == CA_ACTIVE ) { + static int belowlastplaytime = 0; + static qboolean belowframerate = qfalse; + + if( currentfps > 19.8 ) { + belowframerate = qfalse; + } else if( !belowframerate ) { + if( currentfps < 18.0 ) { + belowlastplaytime = 10000; + belowframerate = qtrue; + } + } + + if( belowframerate && cls.realtime > belowlastplaytime ) { + belowlastplaytime = cls.realtime + 4000; + } + } + + recursive = 0; +} + diff --git a/code/client/cl_ui.c b/code/client/cl_ui.c new file mode 100644 index 00000000..7e663095 --- /dev/null +++ b/code/client/cl_ui.c @@ -0,0 +1,1212 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "client.h" + +#include "../botlib/botlib.h" +#include "../qcommon/tiki_local.h" +#include "../uilib/ui_public.h" + +extern botlib_export_t *botlib_export; + +vm_t *uivm; + +uiexport_t uie; + +/* +==================== +GetClientState +==================== +*/ +static void GetClientState( uiClientState_t *state ) { + state->connectPacketCount = clc.connectPacketCount; + state->connState = cls.state; + Q_strncpyz( state->servername, cls.servername, sizeof( state->servername ) ); + Q_strncpyz( state->updateInfoString, cls.updateInfoString, sizeof( state->updateInfoString ) ); + Q_strncpyz( state->messageString, clc.serverMessage, sizeof( state->messageString ) ); + state->clientNum = cl.snap.ps.clientNum; +} + +/* +==================== +LAN_LoadCachedServers +==================== +*/ +void LAN_LoadCachedServers( void ) { + int size; + fileHandle_t fileIn; + cls.numglobalservers = cls.nummplayerservers = cls.numfavoriteservers = 0; + cls.numGlobalServerAddresses = 0; + if (FS_SV_FOpenFileRead("servercache.dat", &fileIn)) { + FS_Read(&cls.numglobalservers, sizeof(int), fileIn); + FS_Read(&cls.nummplayerservers, sizeof(int), fileIn); + FS_Read(&cls.numfavoriteservers, sizeof(int), fileIn); + FS_Read(&size, sizeof(int), fileIn); + if (size == sizeof(cls.globalServers) + sizeof(cls.favoriteServers) + sizeof(cls.mplayerServers)) { + FS_Read(&cls.globalServers, sizeof(cls.globalServers), fileIn); + FS_Read(&cls.mplayerServers, sizeof(cls.mplayerServers), fileIn); + FS_Read(&cls.favoriteServers, sizeof(cls.favoriteServers), fileIn); + } else { + cls.numglobalservers = cls.nummplayerservers = cls.numfavoriteservers = 0; + cls.numGlobalServerAddresses = 0; + } + FS_FCloseFile(fileIn); + } +} + +/* +==================== +LAN_SaveServersToCache +==================== +*/ +void LAN_SaveServersToCache( void ) { + int size; + fileHandle_t fileOut = FS_SV_FOpenFileWrite("servercache.dat"); + FS_Write(&cls.numglobalservers, sizeof(int), fileOut); + FS_Write(&cls.nummplayerservers, sizeof(int), fileOut); + FS_Write(&cls.numfavoriteservers, sizeof(int), fileOut); + size = sizeof(cls.globalServers) + sizeof(cls.favoriteServers) + sizeof(cls.mplayerServers); + FS_Write(&size, sizeof(int), fileOut); + FS_Write(&cls.globalServers, sizeof(cls.globalServers), fileOut); + FS_Write(&cls.mplayerServers, sizeof(cls.mplayerServers), fileOut); + FS_Write(&cls.favoriteServers, sizeof(cls.favoriteServers), fileOut); + FS_FCloseFile(fileOut); +} + + +/* +==================== +LAN_ResetPings +==================== +*/ +static void LAN_ResetPings(int source) { + int count,i; + serverInfo_t *servers = NULL; + count = 0; + + switch (source) { + case AS_LOCAL : + servers = &cls.localServers[0]; + count = MAX_OTHER_SERVERS; + break; + case AS_MPLAYER : + servers = &cls.mplayerServers[0]; + count = MAX_OTHER_SERVERS; + break; + case AS_GLOBAL : + servers = &cls.globalServers[0]; + count = MAX_GLOBAL_SERVERS; + break; + case AS_FAVORITES : + servers = &cls.favoriteServers[0]; + count = MAX_OTHER_SERVERS; + break; + } + if (servers) { + for (i = 0; i < count; i++) { + servers[i].ping = -1; + } + } +} + +/* +==================== +LAN_AddServer +==================== +*/ +static int LAN_AddServer(int source, const char *name, const char *address) { + int max, *count, i; + netadr_t adr; + serverInfo_t *servers = NULL; + max = MAX_OTHER_SERVERS; + count = NULL; + + switch (source) { + case AS_LOCAL : + count = &cls.numlocalservers; + servers = &cls.localServers[0]; + break; + case AS_MPLAYER : + count = &cls.nummplayerservers; + servers = &cls.mplayerServers[0]; + break; + case AS_GLOBAL : + max = MAX_GLOBAL_SERVERS; + count = &cls.numglobalservers; + servers = &cls.globalServers[0]; + break; + case AS_FAVORITES : + count = &cls.numfavoriteservers; + servers = &cls.favoriteServers[0]; + break; + } + if (servers && *count < max) { + NET_StringToAdr( address, &adr ); + for ( i = 0; i < *count; i++ ) { + if (NET_CompareAdr(servers[i].adr, adr)) { + break; + } + } + if (i >= *count) { + servers[*count].adr = adr; + Q_strncpyz(servers[*count].hostName, name, sizeof(servers[*count].hostName)); + servers[*count].visible = qtrue; + (*count)++; + return 1; + } + return 0; + } + return -1; +} + +/* +==================== +LAN_RemoveServer +==================== +*/ +static void LAN_RemoveServer(int source, const char *addr) { + int *count, i; + serverInfo_t *servers = NULL; + count = NULL; + switch (source) { + case AS_LOCAL : + count = &cls.numlocalservers; + servers = &cls.localServers[0]; + break; + case AS_MPLAYER : + count = &cls.nummplayerservers; + servers = &cls.mplayerServers[0]; + break; + case AS_GLOBAL : + count = &cls.numglobalservers; + servers = &cls.globalServers[0]; + break; + case AS_FAVORITES : + count = &cls.numfavoriteservers; + servers = &cls.favoriteServers[0]; + break; + } + if (servers) { + netadr_t comp; + NET_StringToAdr( addr, &comp ); + for (i = 0; i < *count; i++) { + if (NET_CompareAdr( comp, servers[i].adr)) { + int j = i; + while (j < *count - 1) { + Com_Memcpy(&servers[j], &servers[j+1], sizeof(servers[j])); + j++; + } + (*count)--; + break; + } + } + } +} + + +/* +==================== +LAN_GetServerCount +==================== +*/ +static int LAN_GetServerCount( int source ) { + switch (source) { + case AS_LOCAL : + return cls.numlocalservers; + break; + case AS_MPLAYER : + return cls.nummplayerservers; + break; + case AS_GLOBAL : + return cls.numglobalservers; + break; + case AS_FAVORITES : + return cls.numfavoriteservers; + break; + } + return 0; +} + +/* +==================== +LAN_GetLocalServerAddressString +==================== +*/ +static void LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) { + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + Q_strncpyz(buf, NET_AdrToString( cls.localServers[n].adr) , buflen ); + return; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + Q_strncpyz(buf, NET_AdrToString( cls.mplayerServers[n].adr) , buflen ); + return; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + Q_strncpyz(buf, NET_AdrToString( cls.globalServers[n].adr) , buflen ); + return; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + Q_strncpyz(buf, NET_AdrToString( cls.favoriteServers[n].adr) , buflen ); + return; + } + break; + } + buf[0] = '\0'; +} + +/* +==================== +LAN_GetServerInfo +==================== +*/ +static void LAN_GetServerInfo( int source, int n, char *buf, int buflen ) { + char info[MAX_STRING_CHARS]; + serverInfo_t *server = NULL; + info[0] = '\0'; + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.localServers[n]; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.mplayerServers[n]; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + server = &cls.globalServers[n]; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.favoriteServers[n]; + } + break; + } + if (server && buf) { + buf[0] = '\0'; + Info_SetValueForKey( info, "hostname", server->hostName); + Info_SetValueForKey( info, "mapname", server->mapName); + Info_SetValueForKey( info, "clients", va("%i",server->clients)); + Info_SetValueForKey( info, "sv_maxclients", va("%i",server->maxClients)); + Info_SetValueForKey( info, "ping", va("%i",server->ping)); + Info_SetValueForKey( info, "minping", va("%i",server->minPing)); + Info_SetValueForKey( info, "maxping", va("%i",server->maxPing)); + Info_SetValueForKey( info, "game", server->game); + Info_SetValueForKey( info, "gametype", va("%i",server->gameType)); + Info_SetValueForKey( info, "nettype", va("%i",server->netType)); + Info_SetValueForKey( info, "addr", NET_AdrToString(server->adr)); + Info_SetValueForKey( info, "punkbuster", va("%i", server->punkbuster)); + Q_strncpyz(buf, info, buflen); + } else { + if (buf) { + buf[0] = '\0'; + } + } +} + +/* +==================== +LAN_GetServerPing +==================== +*/ +static int LAN_GetServerPing( int source, int n ) { + serverInfo_t *server = NULL; + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.localServers[n]; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.mplayerServers[n]; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + server = &cls.globalServers[n]; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.favoriteServers[n]; + } + break; + } + if (server) { + return server->ping; + } + return -1; +} + +/* +==================== +LAN_GetServerPtr +==================== +*/ +static serverInfo_t *LAN_GetServerPtr( int source, int n ) { + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return &cls.localServers[n]; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return &cls.mplayerServers[n]; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + return &cls.globalServers[n]; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return &cls.favoriteServers[n]; + } + break; + } + return NULL; +} + +/* +==================== +LAN_CompareServers +==================== +*/ +static int LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ) { + int res; + serverInfo_t *server1, *server2; + + server1 = LAN_GetServerPtr(source, s1); + server2 = LAN_GetServerPtr(source, s2); + if (!server1 || !server2) { + return 0; + } + + res = 0; + switch( sortKey ) { + case SORT_HOST: + res = Q_stricmp( server1->hostName, server2->hostName ); + break; + + case SORT_MAP: + res = Q_stricmp( server1->mapName, server2->mapName ); + break; + case SORT_CLIENTS: + if (server1->clients < server2->clients) { + res = -1; + } + else if (server1->clients > server2->clients) { + res = 1; + } + else { + res = 0; + } + break; + case SORT_GAME: + if (server1->gameType < server2->gameType) { + res = -1; + } + else if (server1->gameType > server2->gameType) { + res = 1; + } + else { + res = 0; + } + break; + case SORT_PING: + if (server1->ping < server2->ping) { + res = -1; + } + else if (server1->ping > server2->ping) { + res = 1; + } + else { + res = 0; + } + break; + } + + if (sortDir) { + if (res < 0) + return 1; + if (res > 0) + return -1; + return 0; + } + return res; +} + +/* +==================== +LAN_GetPingQueueCount +==================== +*/ +static int LAN_GetPingQueueCount( void ) { + return (CL_GetPingQueueCount()); +} + +/* +==================== +LAN_ClearPing +==================== +*/ +static void LAN_ClearPing( int n ) { + CL_ClearPing( n ); +} + +/* +==================== +LAN_GetPing +==================== +*/ +static void LAN_GetPing( int n, char *buf, int buflen, int *pingtime ) { + CL_GetPing( n, buf, buflen, pingtime ); +} + +/* +==================== +LAN_GetPingInfo +==================== +*/ +static void LAN_GetPingInfo( int n, char *buf, int buflen ) { + CL_GetPingInfo( n, buf, buflen ); +} + +/* +==================== +LAN_MarkServerVisible +==================== +*/ +static void LAN_MarkServerVisible(int source, int n, qboolean visible ) { + if (n == -1) { + int count = MAX_OTHER_SERVERS; + serverInfo_t *server = NULL; + switch (source) { + case AS_LOCAL : + server = &cls.localServers[0]; + break; + case AS_MPLAYER : + server = &cls.mplayerServers[0]; + break; + case AS_GLOBAL : + server = &cls.globalServers[0]; + count = MAX_GLOBAL_SERVERS; + break; + case AS_FAVORITES : + server = &cls.favoriteServers[0]; + break; + } + if (server) { + for (n = 0; n < count; n++) { + server[n].visible = visible; + } + } + + } else { + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + cls.localServers[n].visible = visible; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + cls.mplayerServers[n].visible = visible; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + cls.globalServers[n].visible = visible; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + cls.favoriteServers[n].visible = visible; + } + break; + } + } +} + + +/* +======================= +LAN_ServerIsVisible +======================= +*/ +static int LAN_ServerIsVisible(int source, int n ) { + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return cls.localServers[n].visible; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return cls.mplayerServers[n].visible; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + return cls.globalServers[n].visible; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return cls.favoriteServers[n].visible; + } + break; + } + return qfalse; +} + +/* +======================= +LAN_UpdateVisiblePings +======================= +*/ +qboolean LAN_UpdateVisiblePings(int source ) { + return CL_UpdateVisiblePings_f(source); +} + +/* +==================== +LAN_GetServerStatus +==================== +*/ +int LAN_GetServerStatus( char *serverAddress, char *serverStatus, int maxLen ) { + return CL_ServerStatus( serverAddress, serverStatus, maxLen ); +} + +/* +==================== +CL_GetGlConfig +==================== +*/ +static void CL_GetGlconfig( glconfig_t *config ) { + *config = cls.glconfig; +} + +/* +==================== +CL_GetClipboardData +==================== +*/ +static void CL_GetClipboardData( char *buf, int buflen ) { + char *cbd; + + cbd = Sys_GetClipboardData(); + + if ( !cbd ) { + *buf = 0; + return; + } + + Q_strncpyz( buf, cbd, buflen ); + + Z_Free( cbd ); +} + +/* +==================== +Key_KeynumToStringBuf +==================== +*/ +static void Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) { + Q_strncpyz( buf, Key_KeynumToString( keynum ), buflen ); +} + +/* +==================== +Key_GetBindingBuf +==================== +*/ +static void Key_GetBindingBuf( int keynum, char *buf, int buflen ) { + char *value; + + value = Key_GetBinding( keynum ); + if ( value ) { + Q_strncpyz( buf, value, buflen ); + } + else { + *buf = 0; + } +} + +/* +==================== +CLUI_GetCDKey +==================== +*/ +static void CLUI_GetCDKey( char *buf, int buflen ) { + cvar_t *fs; + fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO ); + if (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) { + Com_Memcpy( buf, &cl_cdkey[16], 16); + buf[16] = 0; + } else { + Com_Memcpy( buf, cl_cdkey, 16); + buf[16] = 0; + } +} + + +/* +==================== +CLUI_SetCDKey +==================== +*/ +static void CLUI_SetCDKey( char *buf ) { + cvar_t *fs; + fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO ); + if (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) { + Com_Memcpy( &cl_cdkey[16], buf, 16 ); + cl_cdkey[32] = 0; + // set the flag so the fle will be written at the next opportunity + cvar_modifiedFlags |= CVAR_ARCHIVE; + } else { + Com_Memcpy( cl_cdkey, buf, 16 ); + // set the flag so the fle will be written at the next opportunity + cvar_modifiedFlags |= CVAR_ARCHIVE; + } +} + +/* +==================== +GetConfigString +==================== +*/ +static int GetConfigString(int index, char *buf, int size) +{ + int offset; + + if (index < 0 || index >= MAX_CONFIGSTRINGS) + return qfalse; + + offset = cl.gameState.stringOffsets[index]; + if (!offset) { + if( size ) { + buf[0] = 0; + } + return qfalse; + } + + Q_strncpyz( buf, cl.gameState.stringData+offset, size); + + return qtrue; +} + +/* +==================== +FloatAsInt +==================== +*/ +static int FloatAsInt( float f ) { + int temp; + + *(float *)&temp = f; + + return temp; +} + +/* +==================== +CL_UISystemCalls + +The ui module is making a system call +==================== +*/ +intptr_t CL_UISystemCalls( intptr_t *args ) { + switch( args[0] ) { + case UI_ERROR: + Com_Error( ERR_DROP, "%s", (const char*)VMA(1) ); + return 0; + + case UI_PRINT: + Com_Printf( "%s", (const char*)VMA(1) ); + return 0; + + case UI_MILLISECONDS: + return Sys_Milliseconds(); + + case UI_CVAR_REGISTER: + Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); + return 0; + + case UI_CVAR_UPDATE: + Cvar_Update( VMA(1) ); + return 0; + + case UI_CVAR_SET: + Cvar_Set( VMA(1), VMA(2) ); + return 0; + + case UI_CVAR_VARIABLEVALUE: + return FloatAsInt( Cvar_VariableValue( VMA(1) ) ); + + case UI_CVAR_VARIABLESTRINGBUFFER: + Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] ); + return 0; + + case UI_CVAR_SETVALUE: + Cvar_SetValue( VMA(1), VMF(2) ); + return 0; + + case UI_CVAR_RESET: + Cvar_Reset( VMA(1) ); + return 0; + + case UI_CVAR_CREATE: + Cvar_Get( VMA(1), VMA(2), args[3] ); + return 0; + + case UI_CVAR_INFOSTRINGBUFFER: + Cvar_InfoStringBuffer( args[1], VMA(2), args[3] ); + return 0; + + case UI_ARGC: + return Cmd_Argc(); + + case UI_ARGV: + Cmd_ArgvBuffer( args[1], VMA(2), args[3] ); + return 0; + + case UI_CMD_EXECUTETEXT: + Cbuf_ExecuteText( args[1], VMA(2) ); + return 0; + + case UI_FS_FOPENFILE: + return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] ); + + case UI_FS_READ: + FS_Read2( VMA(1), args[2], args[3] ); + return 0; + + case UI_FS_WRITE: + FS_Write( VMA(1), args[2], args[3] ); + return 0; + + case UI_FS_FCLOSEFILE: + FS_FCloseFile( args[1] ); + return 0; + + case UI_FS_GETFILELIST: + return FS_GetFileList( VMA(1), VMA(2), VMA(3), args[4] ); + + case UI_FS_SEEK: + return FS_Seek( args[1], args[2], args[3] ); + + case UI_R_REGISTERMODEL: + return re.RegisterModel( VMA(1) ); + + case UI_R_REGISTERSHADER: + return re.RegisterShader( VMA(1) ); + + case UI_R_REGISTERSHADERNOMIP: + return re.RegisterShaderNoMip( VMA(1) ); + + case UI_R_CLEARSCENE: + re.ClearScene(); + return 0; + + case UI_R_ADDREFENTITYTOSCENE: + re.AddRefEntityToScene( VMA(1) ); + return 0; + + case UI_R_ADDPOLYTOSCENE: + re.AddPolyToScene( args[1], args[2], VMA(3), 1 ); + return 0; + + case UI_R_ADDLIGHTTOSCENE: + re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); + return 0; + + case UI_R_RENDERSCENE: + re.RenderScene( VMA(1) ); + return 0; + + case UI_R_SETCOLOR: + re.SetColor( VMA(1) ); + return 0; + + case UI_R_DRAWSTRETCHPIC: + re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] ); + return 0; + + case UI_R_MODELBOUNDS: + re.ModelBounds( args[1], VMA(2), VMA(3) ); + return 0; + + case UI_UPDATESCREEN: + SCR_UpdateScreen(); + return 0; + + case UI_S_REGISTERSOUND: + return S_RegisterSound( VMA(1), args[2] ); + + case UI_S_STARTLOCALSOUND: + S_StartLocalSound( args[1], args[2] ); + return 0; + + case UI_KEY_KEYNUMTOSTRINGBUF: + Key_KeynumToStringBuf( args[1], VMA(2), args[3] ); + return 0; + + case UI_KEY_GETBINDINGBUF: + Key_GetBindingBuf( args[1], VMA(2), args[3] ); + return 0; + + case UI_KEY_SETBINDING: + Key_SetBinding( args[1], VMA(2) ); + return 0; + + case UI_KEY_ISDOWN: + return Key_IsDown( args[1] ); + + case UI_KEY_GETOVERSTRIKEMODE: + return Key_GetOverstrikeMode(); + + case UI_KEY_SETOVERSTRIKEMODE: + Key_SetOverstrikeMode( args[1] ); + return 0; + + case UI_KEY_CLEARSTATES: + Key_ClearStates(); + return 0; + + case UI_KEY_GETCATCHER: + return Key_GetCatcher(); + + case UI_KEY_SETCATCHER: + // Don't allow the ui module to close the console + Key_SetCatcher( args[1] | ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ); + return 0; + + case UI_GETCLIPBOARDDATA: + CL_GetClipboardData( VMA(1), args[2] ); + return 0; + + case UI_GETCLIENTSTATE: + GetClientState( VMA(1) ); + return 0; + + case UI_GETGLCONFIG: + CL_GetGlconfig( VMA(1) ); + return 0; + + case UI_GETCONFIGSTRING: + return GetConfigString( args[1], VMA(2), args[3] ); + + case UI_LAN_LOADCACHEDSERVERS: + LAN_LoadCachedServers(); + return 0; + + case UI_LAN_SAVECACHEDSERVERS: + LAN_SaveServersToCache(); + return 0; + + case UI_LAN_ADDSERVER: + return LAN_AddServer(args[1], VMA(2), VMA(3)); + + case UI_LAN_REMOVESERVER: + LAN_RemoveServer(args[1], VMA(2)); + return 0; + + case UI_LAN_GETPINGQUEUECOUNT: + return LAN_GetPingQueueCount(); + + case UI_LAN_CLEARPING: + LAN_ClearPing( args[1] ); + return 0; + + case UI_LAN_GETPING: + LAN_GetPing( args[1], VMA(2), args[3], VMA(4) ); + return 0; + + case UI_LAN_GETPINGINFO: + LAN_GetPingInfo( args[1], VMA(2), args[3] ); + return 0; + + case UI_LAN_GETSERVERCOUNT: + return LAN_GetServerCount(args[1]); + + case UI_LAN_GETSERVERADDRESSSTRING: + LAN_GetServerAddressString( args[1], args[2], VMA(3), args[4] ); + return 0; + + case UI_LAN_GETSERVERINFO: + LAN_GetServerInfo( args[1], args[2], VMA(3), args[4] ); + return 0; + + case UI_LAN_GETSERVERPING: + return LAN_GetServerPing( args[1], args[2] ); + + case UI_LAN_MARKSERVERVISIBLE: + LAN_MarkServerVisible( args[1], args[2], args[3] ); + return 0; + + case UI_LAN_SERVERISVISIBLE: + return LAN_ServerIsVisible( args[1], args[2] ); + + case UI_LAN_UPDATEVISIBLEPINGS: + return LAN_UpdateVisiblePings( args[1] ); + + case UI_LAN_RESETPINGS: + LAN_ResetPings( args[1] ); + return 0; + + case UI_LAN_SERVERSTATUS: + return LAN_GetServerStatus( VMA(1), VMA(2), args[3] ); + + case UI_LAN_COMPARESERVERS: + return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] ); + + case UI_MEMORY_REMAINING: + return Hunk_MemoryRemaining(); + + case UI_GET_CDKEY: + CLUI_GetCDKey( VMA(1), args[2] ); + return 0; + + case UI_SET_CDKEY: + CLUI_SetCDKey( VMA(1) ); + return 0; + + case UI_SET_PBCLSTATUS: + return 0; + + case UI_R_REGISTERFONT: + re.RegisterFont( VMA(1), args[2], VMA(3)); + return 0; + + case UI_MEMSET: + Com_Memset( VMA(1), args[2], args[3] ); + return 0; + + case UI_MEMCPY: + Com_Memcpy( VMA(1), VMA(2), args[3] ); + return 0; + + case UI_STRNCPY: + strncpy( VMA(1), VMA(2), args[3] ); + return args[1]; + + case UI_SIN: + return FloatAsInt( sin( VMF(1) ) ); + + case UI_COS: + return FloatAsInt( cos( VMF(1) ) ); + + case UI_ATAN2: + return FloatAsInt( atan2( VMF(1), VMF(2) ) ); + + case UI_SQRT: + return FloatAsInt( sqrt( VMF(1) ) ); + + case UI_FLOOR: + return FloatAsInt( floor( VMF(1) ) ); + + case UI_CEIL: + return FloatAsInt( ceil( VMF(1) ) ); + + case UI_PC_ADD_GLOBAL_DEFINE: + return botlib_export->PC_AddGlobalDefine( VMA(1) ); + case UI_PC_LOAD_SOURCE: + return botlib_export->PC_LoadSourceHandle( VMA(1) ); + case UI_PC_FREE_SOURCE: + return botlib_export->PC_FreeSourceHandle( args[1] ); + case UI_PC_READ_TOKEN: + return botlib_export->PC_ReadTokenHandle( args[1], VMA(2) ); + case UI_PC_SOURCE_FILE_AND_LINE: + return botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) ); + + case UI_S_STOPBACKGROUNDTRACK: + S_StopBackgroundTrack(); + return 0; + case UI_S_STARTBACKGROUNDTRACK: + S_StartBackgroundTrack( VMA(1), VMA(2)); + return 0; + + case UI_REAL_TIME: + return Com_RealTime( VMA(1) ); + + case UI_CIN_PLAYCINEMATIC: + Com_DPrintf("UI_CIN_PlayCinematic\n"); + return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]); + + case UI_CIN_STOPCINEMATIC: + return CIN_StopCinematic(args[1]); + + case UI_CIN_RUNCINEMATIC: + return CIN_RunCinematic(args[1]); + + case UI_CIN_DRAWCINEMATIC: + CIN_DrawCinematic(args[1]); + return 0; + + case UI_CIN_SETEXTENTS: + CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); + return 0; + + case UI_VERIFY_CDKEY: + return CL_CDKeyValidate(VMA(1), VMA(2)); + + // IneQuation + case UI_R_TEXT_WIDTH: + return re.Text_Width(VMA(1), VMA(2), args[3], args[4]); + case UI_R_TEXT_HEIGHT: + return re.Text_Height(VMA(1), VMA(2), args[3], args[4]); + case UI_R_TEXT_PAINT: + re.Text_Paint(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMA(6), VMF(7), args[8], args[9], args[10]); + return 0; + case UI_R_TEXT_PAINTCHAR: + re.Text_PaintChar(VMA(1), VMF(2), VMF(3), VMF(4), args[5], args[6]); + return 0; + + // su44 + case UI_TIKI_REGISTERMODEL: + return TIKI_RegisterModel(VMA(1)); + case UI_TIKI_GETBONES: + return TIKI_GetBones(VMA(1)); + case UI_TIKI_SETCHANNELS: + TIKI_SetChannels(VMA(1),args[2],VMF(3),VMF(4),VMA(5)); + return 0; + case UI_TIKI_APPENDFRAMEBOUNDSANDRADIUS: + TIKI_AppendFrameBoundsAndRadius(VMA(1),args[2],VMF(3),(void*)args[4],(void*)args[5]); + return 0; + case UI_TIKI_ANIMATE: + TIKI_Animate(VMA(1),VMA(2)); + return 0; + case UI_TIKI_GETBONENAMEINDEX: + return TIKI_RegisterBoneName(args[1]); + case UI_GETSHADERNAME: + return re.GetShaderName(args[1]); + + + + default: + Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] ); + + } + + return 0; +} + +/* +==================== +CL_ShutdownUI +==================== +*/ +void CL_ShutdownUI( void ) { + Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_UI ); + cls.uiStarted = qfalse; + if ( !uivm ) { + return; + } + VM_Call( uivm, UI_SHUTDOWN ); + VM_Free( uivm ); + uivm = NULL; +} + +/* +==================== +CL_InitializeUI +==================== +*/ +#define UI_OLD_API_VERSION 4 + +void CL_InitializeUI( void ) { + int v; + vmInterpret_t interpret; + + // load the dll or bytecode + if ( cl_connectedToPureServer != 0 ) { + // if sv_pure is set we only allow qvms to be loaded + interpret = VMI_COMPILED; + } + else { + interpret = Cvar_VariableValue( "vm_ui" ); + } + + uivm = VM_Create( "ui", CL_UISystemCalls, interpret ); + + if ( !uivm ) { + Com_Error( ERR_FATAL, "VM_Create on UI failed" ); + } + + // sanity check + v = VM_Call( uivm, UI_GETAPIVERSION ); + if (v == UI_OLD_API_VERSION) { +// Com_Printf(S_COLOR_YELLOW "WARNING: loading old Quake III Arena User Interface version %d\n", v ); + // init for this gamestate + VM_Call( uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE)); + } + else if (v != UI_API_VERSION) { + Com_Error( ERR_DROP, "User Interface is version %d, expected %d", v, UI_API_VERSION ); + cls.uiStarted = qfalse; + } + else { + // init for this gamestate + VM_Call( uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE) ); + } + + // reset any CVAR_CHEAT cvars registered by ui + if ( !clc.demoplaying && !cl_connectedToCheatServer ) + Cvar_SetCheatState(); +} + +qboolean UI_usesUniqueCDKey( void ) { + if (uivm) { + return (VM_Call( uivm, UI_HASUNIQUECDKEY) == qtrue); + } else { + return qfalse; + } +} + +/* +==================== +UI_GameCommand + +See if the current console command is claimed by the ui +==================== +*/ +qboolean UI_GameCommand( void ) { + if ( !uivm ) { + return qfalse; + } + + return VM_Call( uivm, UI_CONSOLE_COMMAND, cls.realtime ); +} diff --git a/code/client/cl_ui.cpp b/code/client/cl_ui.cpp new file mode 100644 index 00000000..caf3aab5 --- /dev/null +++ b/code/client/cl_ui.cpp @@ -0,0 +1,5972 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "client.h" + +#include "../botlib/botlib.h" +#include "../server/server.h" +#include "../renderercommon/tr_common.h" +#include + +#include "cl_ui.h" + +extern botlib_export_t *botlib_export; + +typedef struct { + float fadetime; + float starttime; + float endtime; + float alpha_start; + float alpha_end; + UIReggedMaterial *material; +} intro_stage_t; + +static qboolean ui_hud; +static class UIFont *globalFont; +static UIFloatingConsole *fakk_console; +static UIFloatingDMConsole *dm_console; +static UIFloatingConsole *developer_console; +static FakkMiniconsole *mini_console; +static UIGMBox *gmbox; +static UIDMBox *dmbox; +static View3D *view3d; +static Menu *mainmenu; +static Menu *hud_weapons; +static Menu *hud_items; +static Menu *hud_health; +static Menu *hud_ammo; +static Menu *hud_compass; +static Menu *hud_boss; +static Menu *crosshairhud; +static Menu *missionLog; +qboolean server_loading; +static qboolean server_loading_waiting; +static str *s_intermediateconsole; +static int ui_lastWeapHudState_Owned; +static int ui_lastWeapHudState_Equipped; +static int ui_weapHudTime; +static int ui_itemHudTime; +Menu *ui_pLoadingMenu; +static Menu *ui_pConnectingMenu; + +static_media_t ui_static_materials; +cvar_t *cl_greenfps; +cvar_t *ui_GunneryEvaluation; +cvar_t *ui_GroinShots; +cvar_t *ui_RightArmShots; +cvar_t *ui_LeftArmShots; +cvar_t *ui_RightLegShots; +cvar_t *ui_LeftLegShots; +cvar_t *ui_TorsoShots; +cvar_t *ui_HeadShots; +cvar_t *ui_NumEnemysKilled; +cvar_t *ui_NumObjectsDestroyed; +cvar_t *ui_NumHitsTaken; +cvar_t *ui_PreferredWeapon; +cvar_t *ui_Accuracy; +cvar_t *ui_NumObjectives; +cvar_t *ui_NumComplete; +cvar_t *ui_NumHits; +cvar_t *ui_NumShotsFired; +cvar_t *ui_gotmedal; +cvar_t *ui_success; +cvar_t *ui_failed; +cvar_t *ui_returnmenu; +cvar_t *ui_skip_eamovie; +cvar_t *ui_skip_titlescreen; +cvar_t *ui_skip_legalscreen; +cvar_t *ui_titlescreen_fadein; +cvar_t *ui_titlescreen_fadeout; +cvar_t *ui_titlescreen_stay; +cvar_t *ui_legalscreen_fadein; +cvar_t *ui_legalscreen_fadeout; +cvar_t *ui_legalscreen_stay; +cvar_t *ui_drawcoords; +cvar_t *ui_minicon; +cvar_t *ui_gmbox; +cvar_t *ui_consoleposition; +cvar_t *ui_inventoryfile; +cvar_t *ui_console; +cvar_t *ui_newvidmode; +cvar_t *ui_crosshair; +cvar_t *ui_compass; +cvar_t *ui_weaponsbar; +cvar_t *ui_weaponsbartime; +cvar_t *ui_itemsbar; +cvar_t *ui_health_start; +cvar_t *ui_health_end; +cvar_t *ui_gmboxspam; +cvar_t *ui_debugload; +cvar_t *sound_overlay; +static intro_stage_t intro_stage; +static char server_mapname[ 64 ]; +static UIListCtrl *scoreboardlist; +static Menu *scoreboard_menu; +static float scoreboard_x; +static float scoreboard_y; +static float scoreboard_w; +static float scoreboard_h; +static qboolean scoreboard_header; +cvar_t *cl_playintro; +cvar_t *cl_movieaudio; +static unsigned int startCountLow; +static unsigned int startCountHigh; +static unsigned int loadCountLow; +static unsigned int loadCountHigh; +static unsigned int loadCount; +static unsigned int lastTime; +static unsigned int loadNumber; +static unsigned int totalLoadTime; +static unsigned int currentLoadTime; +unsigned char UIListCtrlItem[ 8 ]; + +inventory_t client_inv; +bind_t client_bind; +static str scoreboard_menuname; +static str ui_sCurrentLoadingMenu; +static Container

hudList; + +#define HUD_WINDOW_COLOR 0.15f, 0.195f, 0.278f, 1 + +class ConsoleHider : public Listener { +public: + CLASS_PROTOTYPE( ConsoleHider ); + + void HideConsole( Event *ev ); + void DeadConsole( Event *ev ); +}; + + +CLASS_DECLARATION( Listener, ConsoleHider, NULL ) +{ + { NULL, NULL } +}; + +void ConsoleHider::HideConsole( Event *ev ) +{ + UI_CloseConsole(); +} + +void ConsoleHider::DeadConsole( Event *ev ) +{ + if( fakk_console && !fakk_console->IsDying() ) + { + delete fakk_console; + fakk_console = NULL; + } +} + +/* +==================== +ConsoleCommandHandler +==================== +*/ +static void ConsoleCommandHandler( const char *txt ) { + Cbuf_AddText( txt ); +} + +/* +==================== +getDefaultConsoleRectangle +==================== +*/ +static UIRect2D getDefaultConsoleRectangle( void ) { + float f[ 4 ]; + int i; + UIRect2D rect; + + if( sscanf( ui_consoleposition->string, "%f %f %f %f", &f[ 0 ], &f[ 1 ], &f[ 2 ], &f[ 3 ] ) == 4 ) + { + for( i = 0; i < 4; i++ ) { + f[ i ] = floor( f[ i ] ); + } + + rect.pos.x = f[ 0 ] - cls.glconfig.vidWidth; + rect.pos.y = f[ 1 ] - cls.glconfig.vidHeight; + rect.size.width = f[ 2 ] + 50.0; + rect.size.height = f[ 3 ] + 50.0; + } + else + { + rect.pos.x = 25.0; + rect.pos.y = 25.0; + rect.size.width = ( cls.glconfig.vidWidth - 50 ); + rect.size.height = ( cls.glconfig.vidHeight / 2 ); + } + + return rect; +} + +static ConsoleHider s_consolehider; + +class DMConsoleHider : public Listener { +public: + CLASS_PROTOTYPE( DMConsoleHider ); + + void HideDMConsole( Event *ev ); + void DeadDMConsole( Event *ev ); +}; + +CLASS_DECLARATION( Listener, DMConsoleHider, NULL ) +{ + { NULL, NULL } +}; + +void DMConsoleHider::HideDMConsole( Event *ev ) +{ + UI_CloseDMConsole(); +} + +void DMConsoleHider::DeadDMConsole( Event *ev ) +{ + if( dm_console && !dm_console->IsDying() ) + { + delete dm_console; + dm_console = NULL; + } +} + +static DMConsoleHider s_dmconsolehider; + +/* +==================== +GetClientState +==================== +*/ +static void GetClientState( uiClientState_t *state ) { + state->connectPacketCount = clc.connectPacketCount; + state->connState = cls.state; + Q_strncpyz( state->servername, cls.servername, sizeof( state->servername ) ); + Q_strncpyz( state->updateInfoString, cls.updateInfoString, sizeof( state->updateInfoString ) ); + Q_strncpyz( state->messageString, clc.serverMessage, sizeof( state->messageString ) ); + state->clientNum = cl.snap.ps.clientNum; +} + +/* +==================== +LAN_LoadCachedServers +==================== +*/ +void LAN_LoadCachedServers( void ) { + int size; + fileHandle_t fileIn; + cls.numglobalservers = cls.nummplayerservers = cls.numfavoriteservers = 0; + cls.numGlobalServerAddresses = 0; + if (FS_SV_FOpenFileRead("servercache.dat", &fileIn)) { + FS_Read(&cls.numglobalservers, sizeof(int), fileIn); + FS_Read(&cls.nummplayerservers, sizeof(int), fileIn); + FS_Read(&cls.numfavoriteservers, sizeof(int), fileIn); + FS_Read(&size, sizeof(int), fileIn); + if (size == sizeof(cls.globalServers) + sizeof(cls.favoriteServers) + sizeof(cls.mplayerServers)) { + FS_Read(&cls.globalServers, sizeof(cls.globalServers), fileIn); + FS_Read(&cls.mplayerServers, sizeof(cls.mplayerServers), fileIn); + FS_Read(&cls.favoriteServers, sizeof(cls.favoriteServers), fileIn); + } else { + cls.numglobalservers = cls.nummplayerservers = cls.numfavoriteservers = 0; + cls.numGlobalServerAddresses = 0; + } + FS_FCloseFile(fileIn); + } +} + +/* +==================== +LAN_SaveServersToCache +==================== +*/ +void LAN_SaveServersToCache( void ) { + int size; + fileHandle_t fileOut = FS_SV_FOpenFileWrite("servercache.dat"); + FS_Write(&cls.numglobalservers, sizeof(int), fileOut); + FS_Write(&cls.nummplayerservers, sizeof(int), fileOut); + FS_Write(&cls.numfavoriteservers, sizeof(int), fileOut); + size = sizeof(cls.globalServers) + sizeof(cls.favoriteServers) + sizeof(cls.mplayerServers); + FS_Write(&size, sizeof(int), fileOut); + FS_Write(&cls.globalServers, sizeof(cls.globalServers), fileOut); + FS_Write(&cls.mplayerServers, sizeof(cls.mplayerServers), fileOut); + FS_Write(&cls.favoriteServers, sizeof(cls.favoriteServers), fileOut); + FS_FCloseFile(fileOut); +} + + +/* +==================== +LAN_ResetPings +==================== +*/ +static void LAN_ResetPings(int source) { + int count,i; + serverInfo_t *servers = NULL; + count = 0; + + switch (source) { + case AS_LOCAL : + servers = &cls.localServers[0]; + count = MAX_OTHER_SERVERS; + break; + case AS_MPLAYER : + servers = &cls.mplayerServers[0]; + count = MAX_OTHER_SERVERS; + break; + case AS_GLOBAL : + servers = &cls.globalServers[0]; + count = MAX_GLOBAL_SERVERS; + break; + case AS_FAVORITES : + servers = &cls.favoriteServers[0]; + count = MAX_OTHER_SERVERS; + break; + } + if (servers) { + for (i = 0; i < count; i++) { + servers[i].ping = -1; + } + } +} + +/* +==================== +LAN_AddServer +==================== +*/ +static int LAN_AddServer(int source, const char *name, const char *address) { + int max, *count, i; + netadr_t adr; + serverInfo_t *servers = NULL; + max = MAX_OTHER_SERVERS; + count = NULL; + + switch (source) { + case AS_LOCAL : + count = &cls.numlocalservers; + servers = &cls.localServers[0]; + break; + case AS_MPLAYER : + count = &cls.nummplayerservers; + servers = &cls.mplayerServers[0]; + break; + case AS_GLOBAL : + max = MAX_GLOBAL_SERVERS; + count = &cls.numglobalservers; + servers = &cls.globalServers[0]; + break; + case AS_FAVORITES : + count = &cls.numfavoriteservers; + servers = &cls.favoriteServers[0]; + break; + } + if (servers && *count < max) { + NET_StringToAdr( address, &adr ); + for ( i = 0; i < *count; i++ ) { + if (NET_CompareAdr(servers[i].adr, adr)) { + break; + } + } + if (i >= *count) { + servers[*count].adr = adr; + Q_strncpyz(servers[*count].hostName, name, sizeof(servers[*count].hostName)); + servers[*count].visible = qtrue; + (*count)++; + return 1; + } + return 0; + } + return -1; +} + +/* +==================== +LAN_RemoveServer +==================== +*/ +static void LAN_RemoveServer(int source, const char *addr) { + int *count, i; + serverInfo_t *servers = NULL; + count = NULL; + switch (source) { + case AS_LOCAL : + count = &cls.numlocalservers; + servers = &cls.localServers[0]; + break; + case AS_MPLAYER : + count = &cls.nummplayerservers; + servers = &cls.mplayerServers[0]; + break; + case AS_GLOBAL : + count = &cls.numglobalservers; + servers = &cls.globalServers[0]; + break; + case AS_FAVORITES : + count = &cls.numfavoriteservers; + servers = &cls.favoriteServers[0]; + break; + } + if (servers) { + netadr_t comp; + NET_StringToAdr( addr, &comp ); + for (i = 0; i < *count; i++) { + if (NET_CompareAdr( comp, servers[i].adr)) { + int j = i; + while (j < *count - 1) { + Com_Memcpy(&servers[j], &servers[j+1], sizeof(servers[j])); + j++; + } + (*count)--; + break; + } + } + } +} + + +/* +==================== +LAN_GetServerCount +==================== +*/ +static int LAN_GetServerCount( int source ) { + switch (source) { + case AS_LOCAL : + return cls.numlocalservers; + break; + case AS_MPLAYER : + return cls.nummplayerservers; + break; + case AS_GLOBAL : + return cls.numglobalservers; + break; + case AS_FAVORITES : + return cls.numfavoriteservers; + break; + } + return 0; +} + +/* +==================== +LAN_GetLocalServerAddressString +==================== +*/ +static void LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) { + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + Q_strncpyz(buf, NET_AdrToString( cls.localServers[n].adr) , buflen ); + return; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + Q_strncpyz(buf, NET_AdrToString( cls.mplayerServers[n].adr) , buflen ); + return; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + Q_strncpyz(buf, NET_AdrToString( cls.globalServers[n].adr) , buflen ); + return; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + Q_strncpyz(buf, NET_AdrToString( cls.favoriteServers[n].adr) , buflen ); + return; + } + break; + } + buf[0] = '\0'; +} + +/* +==================== +LAN_GetServerInfo +==================== +*/ +static void LAN_GetServerInfo( int source, int n, char *buf, int buflen ) { + char info[MAX_STRING_CHARS]; + serverInfo_t *server = NULL; + info[0] = '\0'; + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.localServers[n]; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.mplayerServers[n]; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + server = &cls.globalServers[n]; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.favoriteServers[n]; + } + break; + } + if (server && buf) { + buf[0] = '\0'; + Info_SetValueForKey( info, "hostname", server->hostName); + Info_SetValueForKey( info, "mapname", server->mapName); + Info_SetValueForKey( info, "clients", va("%i",server->clients)); + Info_SetValueForKey( info, "sv_maxclients", va("%i",server->maxClients)); + Info_SetValueForKey( info, "ping", va("%i",server->ping)); + Info_SetValueForKey( info, "minping", va("%i",server->minPing)); + Info_SetValueForKey( info, "maxping", va("%i",server->maxPing)); + Info_SetValueForKey( info, "game", server->game); + Info_SetValueForKey( info, "gametype", va("%i",server->gameType)); + Info_SetValueForKey( info, "nettype", va("%i",server->netType)); + Info_SetValueForKey( info, "addr", NET_AdrToString(server->adr)); + Q_strncpyz(buf, info, buflen); + } else { + if (buf) { + buf[0] = '\0'; + } + } +} + +/* +==================== +LAN_GetServerPing +==================== +*/ +static int LAN_GetServerPing( int source, int n ) { + serverInfo_t *server = NULL; + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.localServers[n]; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.mplayerServers[n]; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + server = &cls.globalServers[n]; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + server = &cls.favoriteServers[n]; + } + break; + } + if (server) { + return server->ping; + } + return -1; +} + +/* +==================== +LAN_GetServerPtr +==================== +*/ +static serverInfo_t *LAN_GetServerPtr( int source, int n ) { + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return &cls.localServers[n]; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return &cls.mplayerServers[n]; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + return &cls.globalServers[n]; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return &cls.favoriteServers[n]; + } + break; + } + return NULL; +} + +/* +==================== +LAN_CompareServers +==================== +*/ +static int LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ) { + int res; + serverInfo_t *server1, *server2; + + server1 = LAN_GetServerPtr(source, s1); + server2 = LAN_GetServerPtr(source, s2); + if (!server1 || !server2) { + return 0; + } + + res = 0; + switch( sortKey ) { + case SORT_HOST: + res = Q_stricmp( server1->hostName, server2->hostName ); + break; + + case SORT_MAP: + res = Q_stricmp( server1->mapName, server2->mapName ); + break; + case SORT_CLIENTS: + if (server1->clients < server2->clients) { + res = -1; + } + else if (server1->clients > server2->clients) { + res = 1; + } + else { + res = 0; + } + break; + case SORT_GAME: + if (server1->gameType < server2->gameType) { + res = -1; + } + else if (server1->gameType > server2->gameType) { + res = 1; + } + else { + res = 0; + } + break; + case SORT_PING: + if (server1->ping < server2->ping) { + res = -1; + } + else if (server1->ping > server2->ping) { + res = 1; + } + else { + res = 0; + } + break; + } + + if (sortDir) { + if (res < 0) + return 1; + if (res > 0) + return -1; + return 0; + } + return res; +} + +/* +==================== +LAN_GetPingQueueCount +==================== +*/ +static int LAN_GetPingQueueCount( void ) { + return (CL_GetPingQueueCount()); +} + +/* +==================== +LAN_ClearPing +==================== +*/ +static void LAN_ClearPing( int n ) { + CL_ClearPing( n ); +} + +/* +==================== +LAN_GetPing +==================== +*/ +static void LAN_GetPing( int n, char *buf, int buflen, int *pingtime ) { + CL_GetPing( n, buf, buflen, pingtime ); +} + +/* +==================== +LAN_GetPingInfo +==================== +*/ +static void LAN_GetPingInfo( int n, char *buf, int buflen ) { + CL_GetPingInfo( n, buf, buflen ); +} + +/* +==================== +LAN_MarkServerVisible +==================== +*/ +static void LAN_MarkServerVisible(int source, int n, qboolean visible ) { + if (n == -1) { + int count = MAX_OTHER_SERVERS; + serverInfo_t *server = NULL; + switch (source) { + case AS_LOCAL : + server = &cls.localServers[0]; + break; + case AS_MPLAYER : + server = &cls.mplayerServers[0]; + break; + case AS_GLOBAL : + server = &cls.globalServers[0]; + count = MAX_GLOBAL_SERVERS; + break; + case AS_FAVORITES : + server = &cls.favoriteServers[0]; + break; + } + if (server) { + for (n = 0; n < count; n++) { + server[n].visible = visible; + } + } + + } else { + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + cls.localServers[n].visible = visible; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + cls.mplayerServers[n].visible = visible; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + cls.globalServers[n].visible = visible; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + cls.favoriteServers[n].visible = visible; + } + break; + } + } +} + + +/* +======================= +LAN_ServerIsVisible +======================= +*/ +static int LAN_ServerIsVisible(int source, int n ) { + switch (source) { + case AS_LOCAL : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return cls.localServers[n].visible; + } + break; + case AS_MPLAYER : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return cls.mplayerServers[n].visible; + } + break; + case AS_GLOBAL : + if (n >= 0 && n < MAX_GLOBAL_SERVERS) { + return cls.globalServers[n].visible; + } + break; + case AS_FAVORITES : + if (n >= 0 && n < MAX_OTHER_SERVERS) { + return cls.favoriteServers[n].visible; + } + break; + } + return qfalse; +} + +/* +======================= +LAN_UpdateVisiblePings +======================= +*/ +qboolean LAN_UpdateVisiblePings(int source ) { + return CL_UpdateVisiblePings_f(source); +} + +/* +==================== +LAN_GetServerStatus +==================== +*/ +int LAN_GetServerStatus( const char *serverAddress, char *serverStatus, int maxLen ) { + return CL_ServerStatus( serverAddress, serverStatus, maxLen ); +} + +/* +==================== +CL_GetGlConfig +==================== +*/ +static void CL_GetGlconfig( glconfig_t *config ) { + *config = cls.glconfig; +} + +/* +==================== +CL_GetClipboardData +==================== +*/ +static void CL_GetClipboardData( char *buf, int buflen ) { + char *cbd; + + cbd = Sys_GetClipboardData(); + + if ( !cbd ) { + *buf = 0; + return; + } + + Q_strncpyz( buf, cbd, buflen ); + + Z_Free( cbd ); +} + +/* +==================== +Key_KeynumToStringBuf +==================== +*/ +static void Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) { + Q_strncpyz( buf, Key_KeynumToString( keynum ), buflen ); +} + +/* +==================== +Key_GetBindingBuf +==================== +*/ +static void Key_GetBindingBuf( int keynum, char *buf, int buflen ) { + char *value; + + value = Key_GetBinding( keynum ); + if ( value ) { + Q_strncpyz( buf, value, buflen ); + } + else { + *buf = 0; + } +} + +/* +==================== +GetConfigString +==================== +*/ +static int GetConfigString(int index, char *buf, int size) +{ + int offset; + + if (index < 0 || index >= MAX_CONFIGSTRINGS) + return qfalse; + + offset = cl.gameState.stringOffsets[index]; + if (!offset) { + if( size ) { + buf[0] = 0; + } + return qfalse; + } + + Q_strncpyz( buf, cl.gameState.stringData+offset, size); + + return qtrue; +} + +/* +==================== +FloatAsInt +==================== +*/ +static int FloatAsInt( float f ) { + int temp; + + *(float *)&temp = f; + + return temp; +} + +qboolean UI_usesUniqueCDKey( void ) { + return qfalse; +} + +/* +==================== +getDefaultConsoleRectangle +==================== +*/ +static UIRect2D getDefaultDMConsoleRectangle( void ) { + float f[ 4 ]; + int i; + UIRect2D rect; + + if( sscanf( ui_consoleposition->string, "%f %f %f %f", &f[ 0 ], &f[ 1 ], &f[ 2 ], &f[ 3 ] ) == 4 ) + { + for( i = 0; i < 4; i++ ) { + f[ i ] = floor( f[ i ] ); + } + + rect.pos.x = f[ 0 ] - cls.glconfig.vidWidth; + rect.pos.y = f[ 1 ] - cls.glconfig.vidHeight; + rect.size.width = f[ 2 ] + 50.0; + rect.size.height = f[ 3 ] + 50.0; + } + else + { + rect.pos.x = 0; + rect.pos.y = cls.glconfig.vidHeight * 0.58; + rect.size.width = cls.glconfig.vidWidth; + rect.size.height = cls.glconfig.vidHeight * 0.415; + } + + return rect; +} + +/* +==================== +getDefaultConsoleRectangle +==================== +*/ +static UIRect2D getQuickMessageDMConsoleRectangle( void ) { + float f[ 4 ]; + int i; + UIRect2D rect; + + if( sscanf( ui_consoleposition->string, "%f %f %f %f", &f[ 0 ], &f[ 1 ], &f[ 2 ], &f[ 3 ] ) == 4 ) + { + for( i = 0; i < 4; i++ ) { + f[ i ] = floor( f[ i ] ); + } + + rect.pos.x = f[ 0 ] - cls.glconfig.vidWidth; + rect.pos.y = f[ 1 ] - cls.glconfig.vidHeight; + rect.size.width = f[ 2 ] + 50.0; + rect.size.height = f[ 3 ] + 50.0; + } + else + { + rect.pos.x = 0; + rect.pos.y = cls.glconfig.vidHeight * 0.65; + rect.size.width = cls.glconfig.vidWidth; + rect.size.height = 38.0; + } + + return rect; +} + +/* +==================== +UI_DMMessageModesMatch +==================== +*/ +static qboolean UI_DMMessageModesMatch( int iMode ) { + qboolean bQuickMessage; + + if( iMode && ( iMode != 300 || dm_console->GetQuickMessageMode() ) ) + { + if( iMode < 0 ) + { + bQuickMessage = qtrue; + iMode = -iMode; + } + + if( dm_console->GetQuickMessageMode() == bQuickMessage ) { + return dm_console->GetMessageMode() == iMode; + } else { + return qfalse; + } + } else { + return qtrue; + } +} + +/* +==================== +UI_SetDMConsoleMode +==================== +*/ +static void UI_SetDMConsoleMode( int iMode ) { + qboolean bQuickMessage; + + if( UI_DMMessageModesMatch( iMode ) ) { + return; + } + + if( iMode < 0 ) + { + bQuickMessage = qtrue; + iMode = -iMode; + } + + if( iMode == 300 ) { + bQuickMessage = dm_console->GetMessageMode(); + } + + if( dm_console->GetQuickMessageMode() ) + { + if( !bQuickMessage ) + { + dm_console->setFrame( getDefaultDMConsoleRectangle() ); + dm_console->SetQuickMessageMode( qfalse ); + } + } + else + { + if( bQuickMessage ) + { + dm_console->setFrame( getDefaultDMConsoleRectangle() ); + dm_console->SetQuickMessageMode( qfalse ); + } + } + + dm_console->SetMessageMode( iMode ); + + if( bQuickMessage ) + { + if( iMode == 100 ) + { + dm_console->setTitle( Sys_LV_CL_ConvertString( "Quick Chat (Press Enter to send) : Messaging to All" ) ); + } + else if( iMode == 200 ) + { + dm_console->setTitle( Sys_LV_CL_ConvertString( "Quick Chat (Press Enter to send) : Messaging to Team" ) ); + } + else + { + dm_console->setTitle( va( "%s %i", Sys_LV_CL_ConvertString( "Quick Chat (Press Enter to send) : Messaging to Client" ), iMode ) ); + } + } + else + { + if( iMode == 100 ) + { + dm_console->setTitle( Sys_LV_CL_ConvertString( "Chat Window (Enter to send/close) (all|team|private to change mode) : Messaging to All" ) ); + } + else if( iMode == 100 ) + { + dm_console->setTitle( Sys_LV_CL_ConvertString( "Chat Window (Enter to send/close) (all|team|private to change mode) : Messaging to Team" ) ); + } + else + { + dm_console->setTitle( va( "%s %i", Sys_LV_CL_ConvertString( "Chat Window (Enter to send/close) (all|team|private to change mode) : Messaging to Client" ), iMode ) ); + } + } +} + +static void DMConsoleCommandHandler( const char *txt ) { + int iMode; + char szStringOut[ 1024 ]; + + if( dm_console->GetMessageMode() != 100 ) + { + if( dm_console->GetMessageMode() == 200 ) { + iMode = -1; + } else { + iMode = dm_console->GetMessageMode(); + } + } + + Com_sprintf( szStringOut, sizeof( szStringOut ), "dmmessage %i %s\n", iMode ); + CL_AddReliableCommand( szStringOut ); +} + +/* +==================== +getNewDMConsole +==================== +*/ +UIFloatingDMConsole *getNewDMConsole() { + UIFloatingDMConsole *console = new UIFloatingDMConsole; + Event *event; + + console->Create( NULL, getDefaultDMConsoleRectangle(), + "Chat Window (Enter to send/close) (all|team|private to change message mode) : Messaging to All", + UColor( HUD_WINDOW_COLOR ), UHudColor ); + + console->setConsoleHandler( DMConsoleCommandHandler ); + console->setConsoleBackground( UBlack, 0.8f ); + console->setShow( false ); + console->Connect( &s_dmconsolehider, UIFloatingWindow::W_ClosePressed, UIFloatingWindow::W_ClosePressed ); + console->Connect( &s_dmconsolehider, W_Destroyed, W_Destroyed ); + + event = new Event( EV_Widget_Disable ); + console->PassEventToWidget( "closebutton", event ); + + event = new Event( EV_Widget_Disable ); + console->PassEventToWidget( "minimizebutton", event ); + + return console; +} + +/* +==================== +getDefaultGMBoxRectangle +==================== +*/ +static UIRect2D getDefaultGMBoxRectangle( void ) { + return UIRect2D( 20, 0, cls.glconfig.vidWidth - 20, 248 ); +} + +/* +==================== +getDefaultDMBoxRectangle +==================== +*/ +static UIRect2D getDefaultDMBoxRectangle( void ) { + return UIRect2D( 128, 0, cls.glconfig.vidWidth - 320, 128 ); +} + +/* +==================== +UI_ShowHudList +==================== +*/ +void UI_ShowHudList( void ) { + for( int i = 1; i <= hudList.NumObjects(); i++ ) + { + hudList.ObjectAt( i )->ForceShow(); + } +} + +/* +==================== +UI_HideHudList +==================== +*/ +void UI_HideHudList( void ) { + for( int i = 1; i <= hudList.NumObjects(); i++ ) + { + hudList.ObjectAt( i )->ForceHide(); + } +} + +/* +==================== +UI_DisplayHudList +==================== +*/ +void UI_DisplayHudList( void ) { + for( int i = 1; i <= hudList.NumObjects(); i++ ) + { + Menu *pMenu = hudList.ObjectAt( i ); + UIWidget *pWidget = pMenu->GetContainerWidget(); + + pMenu->ForceShow(); + pWidget->Display( uWinMan.getFrame(), 1.0 ); + } +} + +/* +==================== +UI_PrintConsole +==================== +*/ +void UI_PrintConsole( const char *msg ) +{ + UColor *pColor = NULL; + char szString[ 1024 ]; + char szBlah[ 1024 ]; + + memcpy( szString, msg, sizeof( szString ) ); + + if( *szString < MESSAGE_MAX ) + { + qboolean bNormalMessage = qfalse; + qboolean bDMMessage = qfalse; + qboolean bBold = qfalse; + qboolean bDeathMessage = qfalse; + + switch( *szString ) + { + case MESSAGE_YELLOW: + pColor = &UHudColor; + break; + case MESSAGE_CHAT_WHITE: + pColor = &UGrey; + break; + case MESSAGE_WHITE: + pColor = &UWhite; + break; + case MESSAGE_CHAT_RED: + pColor = &ULightRed; + break; + } + + // + // print to the deathmatch console + // + if( dm_console && !bNormalMessage ) + { + if( bDMMessage ) + { + dm_console->AddDMMessageText( szString + 1, pColor ); + } + else + { + dm_console->AddText( szString + 1, pColor ); + } + } + + // + // print to the deathmatch message box + // + if( dmbox ) + { + if( bDMMessage ) + { + *szString = MESSAGE_CHAT_WHITE; + dmbox->Print( szString ); + return; + } + else if( bDeathMessage ) + { + dmbox->Print( szString ); + *szString = MESSAGE_CHAT_RED; + return; + } + } + + // + // print to the game message box + // + if( gmbox ) + { + if( bBold ) + { + *szString = MESSAGE_WHITE; + gmbox->Print( szString ); + uii.Snd_PlaySound( "objective_text" ); + } + else + { + gmbox->Print( szString + 1 ); + } + + if( !ui_gmboxspam->integer ) { + return; + } + + memcpy( szBlah, "Game Message: ", 15 ); + strcat( szBlah, szString + 1 ); + } + } + + if( *msg == 7 ) + { + if( mini_console ) + { + mini_console->Print( msg + 1 ); + return; + } + } + + if( fakk_console ) + { + if( s_intermediateconsole ) + { + fakk_console->AddText( *s_intermediateconsole, NULL ); + delete s_intermediateconsole; + s_intermediateconsole = NULL; + } + + fakk_console->AddText( msg + 1, pColor ); + + if( mini_console ) { + mini_console->Print( msg + 1 ); + } + } + else + { + if( !s_intermediateconsole ) { + s_intermediateconsole = new str; + } + + *s_intermediateconsole = ( msg + 1 ); + } +} + +/* +==================== +UI_PrintDeveloperConsole +==================== +*/ +void UI_PrintDeveloperConsole( const char *msg ) +{ + if( !developer_console ) { + return; + } + + developer_console->AddText( msg, NULL ); +} + +/* +==================== +UI_UpdateContinueGame +==================== +*/ +void UI_UpdateContinueGame( void ) { + cvar_t *var; + const char *name; + const char *archive_name; + int length; + Event *event; + + var = Cvar_Get( "g_lastsave", "", 0 ); + name = var->string; + + if( *name ) + { + archive_name = Com_GetArchiveFileName( name, "sav" ); + length = FS_ReadFileEx( archive_name, NULL, qtrue ); + + if( length != -1 ) + { + event = new Event( EV_Widget_Enable ); + menuManager.PassEventToWidget( "continue game", event ); + + event = new Event( EV_Widget_Disable ); + menuManager.PassEventToWidget( "new game", event ); + return; + } + + Cvar_Set( "g_lastsave", "" ); + } + + event = new Event( EV_Widget_Disable ); + menuManager.PassEventToWidget( "continue game", event ); + + event = new Event( EV_Widget_Enable ); + menuManager.PassEventToWidget( "new game", event ); +} + +/* +==================== +UI_MenuActive +==================== +*/ +qboolean UI_MenuActive( void ) { + return menuManager.CurrentMenu() != NULL; +} + +/* +==================== +UI_FocusMenuIfExists +==================== +*/ +void UI_FocusMenuIfExists( void ) { + Menu *currentMenu; + int r_mode; + + currentMenu = menuManager.CurrentMenu(); + r_mode = Cvar_VariableValue( "r_mode" ); + + if( currentMenu ) + { + IN_MouseOn(); + + if( view3d->IsActive() ) { + uWinMan.DeactivateCurrentControl(); + } + + currentMenu->ActivateMenu(); + + if( ui_newvidmode->integer == -1 ) + { + Cvar_Get( "ui_newvidmode", va( "%d", r_mode ), CVAR_SERVER_CREATED ); + Cvar_SetValue( "ui_newvidmode", r_mode ); + } + } + else + { + UI_ActivateView3D(); + IN_MouseOff(); + Cvar_SetValue( "ui_newvidmode", -1 ); + } +} + +/* +==================== +UI_OpenConsole +==================== +*/ +void UI_OpenConsole( void ) { + if( !fakk_console ) { + return; + } + + fakk_console->setShow( true ); + uWinMan.ActivateControl( fakk_console ); + IN_MouseOn(); +} + +/* +==================== +UI_OpenConsole +==================== +*/ +qboolean UI_ConsoleIsVisible( void ) { + return fakk_console && fakk_console->IsVisible(); +} + +/* +==================== +UI_ConsoleIsOpen +==================== +*/ +qboolean UI_ConsoleIsOpen( void ) { + return fakk_console && fakk_console->IsVisible() && fakk_console->IsActive(); +} + +/* +==================== +UI_CloseConsole +==================== +*/ +void UI_CloseConsole( void ) { + if( fakk_console && fakk_console->getShow() ) { + fakk_console->setShow( false ); + } + UI_FocusMenuIfExists(); +} + +/* +==================== +UI_ToggleConsole +==================== +*/ +void UI_ToggleConsole( void ) { + if( !fakk_console ) { + return; + } + + if( fakk_console->IsVisible() ) { + UI_CloseConsole(); + } else { + UI_OpenConsole(); + } +} + +/* +==================== +UI_OpenDMConsole +==================== +*/ +void UI_OpenDMConsole( int iMode ) { + if( !dm_console ) { + return; + } + + UI_SetDMConsoleMode( iMode ); + dm_console->setShow( true ); + uWinMan.ActivateControl( dm_console ); + IN_MouseOff(); +} + +/* +==================== +UI_CloseDMConsole +==================== +*/ +void UI_CloseDMConsole( void ) { + if( dm_console && dm_console->getShow() ) { + dm_console->setShow( false ); + } + UI_FocusMenuIfExists(); +} + +/* +==================== +UI_ToggleDMConsole +==================== +*/ +void UI_ToggleDMConsole( int iMode ) { + if( !dm_console ) { + return; + } + + if( dm_console->IsVisible() ) + { + if( UI_DMMessageModesMatch( iMode ) ) { + UI_CloseDMConsole(); + } else { + UI_OpenDMConsole( iMode ); + } + } + else + { + UI_OpenDMConsole( iMode ); + } +} + +/* +==================== +UI_OpenDeveloperConsole +==================== +*/ +void UI_OpenDeveloperConsole( void ) { + if( !developer_console ) { + return; + } + + developer_console->setShow( true ); + uWinMan.ActivateControl( developer_console ); + IN_MouseOn(); +} + +/* +==================== +UI_CloseDeveloperConsole +==================== +*/ +void UI_CloseDeveloperConsole( void ) { + if( developer_console && developer_console->getShow() ) { + developer_console->setShow( false ); + } + UI_FocusMenuIfExists(); +} + +/* +==================== +UI_ToggleDeveloperConsole_f +==================== +*/ +void UI_ToggleDeveloperConsole_f( void ) { + if( !developer_console ) { + return; + } + + if( developer_console->IsThisOrChildActive() ) { + UI_CloseDeveloperConsole(); + } else { + UI_OpenDeveloperConsole(); + } +} + +/* +==================== +UI_KeyEvent +==================== +*/ +void UI_KeyEvent( int key, unsigned int time ) { + uWinMan.KeyEvent( key, time ); +} + +/* +==================== +UI_CharEvent +==================== +*/ +void UI_CharEvent( int ch ) { + uWinMan.CharEvent( ch ); +} + +/* +==================== +UI_ClearBackground +==================== +*/ +void UI_ClearBackground( void ) { + re.Set2DWindow( 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, 0, -1, -1 ); + re.Scissor( 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight ); + re.SetColor( g_color_table[ 0 ] ); + re.DrawBox( 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight ); + re.SetColor( NULL ); +} + +/* +==================== +UI_ActivateView3D +==================== +*/ +void UI_ActivateView3D( void ) { + if( !view3d ) { + return; + } + + view3d->setShow( true ); + uWinMan.ActivateControl( view3d ); +} + +/* +==================== +UI_DrawIntro +==================== +*/ +void UI_DrawIntro( void ) { + if( cls.state == CA_CINEMATIC ) + { + view3d->setShow( true ); + return; + } + + view3d->setShow( false ); + UI_ClearBackground(); + + // FIXME: draw intro +} + +/* +==================== +UI_MenuUp +==================== +*/ +qboolean UI_MenuUp() { + return menuManager.CurrentMenu() != NULL; +} + +/* +==================== +UI_FullscreenMenuUp +==================== +*/ +qboolean UI_FullscreenMenuUp() +{ + Menu *currentMenu = menuManager.CurrentMenu(); + + if( currentMenu ) { + return currentMenu->isFullscreen(); + } + + return qfalse; +} + +void UI_MainMenuWidgetsUpdate( void ); + +/* +==================== +UI_Update + +Updates the UI. +==================== +*/ +void UI_Update( void ) { + Menu *currentMenu; + UIRect2D frame; + + re.SetRenderTime( cls.realtime ); + CL_FillUIDef(); + uWinMan.ServiceEvents(); + + // + // draw the base HUD when in-game + // + if( cls.no_menus && cls.state == CA_ACTIVE ) + { + view3d->setShow( true ); + frame = uWinMan.getFrame(); + view3d->Display( frame, 1.0 ); + + if( ui_hud && !view3d->LetterboxActive() ) + { + // draw the health hud + if( hud_health ) + { + hud_health->ForceShow(); + frame = uWinMan.getFrame(); + hud_health->GetContainerWidget()->Display( frame, 1.0 ); + } + + // draw the ammo hud + if( hud_ammo ) + { + hud_ammo->ForceShow(); + frame = uWinMan.getFrame(); + hud_ammo->GetContainerWidget()->Display( frame, 1.0 ); + } + + // draw the compass hud + if( hud_compass ) + { + hud_compass->ForceShow(); + frame = uWinMan.getFrame(); + hud_compass->GetContainerWidget()->Display( frame, 1.0 ); + } + } + } + + if( fakk_console ) + { + if( ui_minicon->integer ) + { + // toggle the mini-console + if( mini_console ) { + mini_console->setRealShow( fakk_console->getShow() ^ 1 ); + } + } else if( mini_console ) { + mini_console->setRealShow( false ); + } + } + + if( gmbox ) { + gmbox->setRealShow( true ); + } + + if( dmbox ) { + dmbox->setRealShow( true ); + } + + currentMenu = menuManager.CurrentMenu(); + + if( currentMenu == menuManager.FindMenu( "main" ) ) { + UI_MainMenuWidgetsUpdate(); + } + + // don't care about the intro + /* + if( CL_FinishedIntro() ) + { + } + else + { + UI_DrawIntro(); + } + */ + + if( !server_loading && ( cls.state == CA_CONNECTING || cls.state == CA_CHALLENGING ) && ui_pConnectingMenu ) + { + view3d->setShow( false ); + UI_ClearBackground(); + + if( UI_BindActive() ) + { + Menu *bindMenu = menuManager.FindMenu( "controls" ); + + if( bindMenu ) + { + Event *event = new Event( EV_UIFakkBindList_StopBind ); + bindMenu->PassEventToWidget( "bindlist", event ); + } + else + { + uWinMan.SetBindActive( NULL ); + } + } + + if( clc.connectTime >= cls.realtime - 1000 * cl_connect_timeout->integer ) + { + if( currentMenu != ui_pConnectingMenu ) + { + UI_ForceMenuOff( true ); + UI_DeactiveFloatingWindows(); + UI_ForceMenu( "connecting" ); + uWinMan.showCursor( true ); + } + } + else + { + Com_Printf( "\nConnect to server timed out\n" ); + UI_ForceMenuOff( true ); + Cbuf_AddText( "disconnect;pushmenu servertimeout" ); + } + } + else + { + if( currentMenu && currentMenu->isFullscreen() && ( !server_loading || !ui_pLoadingMenu ) ) + { + if( com_sv_running->integer && cls.state == CA_ACTIVE ) { + Com_FakePause(); + } + + view3d->setShow( false ); + } + else if( !server_loading ) + { + if( cls.state <= CA_PRIMED ) + { + view3d->setShow( false ); + UI_ClearBackground(); + } + else if( cls.state == CA_PRIMED || cls.state == CA_ACTIVE ) + { + Com_FakeUnpause(); + view3d->setShow( true ); + } + else + { + UI_ClearBackground(); + view3d->setShow( false ); + } + } + else + { + view3d->setShow( false ); + UI_ClearBackground(); + + if( UI_BindActive() ) + { + Menu *bindMenu = menuManager.FindMenu( "controls" ); + + if( bindMenu ) + { + Event *event = new Event( EV_UIFakkBindList_StopBind ); + bindMenu->PassEventToWidget( "bindlist", event ); + } + } + else + { + uWinMan.SetBindActive( NULL ); + } + + if( ui_pLoadingMenu ) + { + if( currentMenu != ui_pLoadingMenu ) + { + UI_ForceMenuOff( true ); + UI_DeactiveFloatingWindows(); + UI_ForceMenu( "" ); + uWinMan.showCursor( false ); + } + + if( !developer->integer && UI_ConsoleIsVisible() ) { + UI_CloseConsole(); + } + } + else if( ui_static_materials.loading ) + { + ui_static_materials.loading->ReregisterMaterial(); + } + } + + // Hide the HUD when necessary + if( !ui_hud || cls.state != CA_ACTIVE || view3d->LetterboxActive() + || ( currentMenu && currentMenu->isFullscreen() ) + || server_loading + || ( ( cl.snap.ps.pm_flags & PMF_NO_HUD ) || ( cl.snap.ps.pm_flags & PMF_SPECTATE_FOLLOW ) ) ) + { + if( crosshairhud ) + { + crosshairhud->ForceHide(); + } + if( hud_weapons ) + { + hud_weapons->ForceHide(); + ui_weapHudTime = 0; + } + if( hud_items ) + { + hud_items->ForceHide(); + ui_itemHudTime = 0; + } + if( hud_health ) + { + hud_health->ForceHide(); + } + if( hud_ammo ) + { + hud_ammo->ForceHide(); + } + if( hud_compass ) + { + hud_compass->ForceHide(); + } + if( hud_boss ) + { + hud_boss->ForceHide(); + } + + UI_HideHudList(); + } + else + { + if( crosshairhud ) + { + if( ui_crosshair->integer && cl.snap.ps.stats[ STAT_CROSSHAIR ] ) { + crosshairhud->ForceShow(); + } else { + crosshairhud->ForceHide(); + } + } + + // + // show and highlight all weapons that the player holds + // + + // + // try to show the weapons bar + // + if( hud_weapons ) + { + if( ui_weaponsbar->integer ) + { + int iEquippedDiff = 0; + int iOwnedDiff = 0; + + if( ui_weaponsbar->integer == 2 ) { + ui_weapHudTime = cls.realtime + ui_weaponsbartime->value; + } else if( ui_weaponsbar->integer != 3 && ui_itemHudTime && hud_items->isVisible() ) { + ui_weapHudTime = 0; + } + + if( ui_lastWeapHudState_Owned != cl.snap.ps.stats[ STAT_WEAPONS ] + || ui_lastWeapHudState_Equipped != cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] ) + { + iOwnedDiff = cl.snap.ps.stats[ STAT_WEAPONS ] ^ ui_lastWeapHudState_Owned & 0x3F; + iEquippedDiff = ( ui_lastWeapHudState_Equipped ^ cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] ) & 0x3F; + + // if we have different equipment, reset the weapons hud time + if( iOwnedDiff || iEquippedDiff ) { + ui_weapHudTime = cls.realtime + ui_weaponsbartime->integer; + } + } + + // + // show weapons that the player holds + // + if( iOwnedDiff ) + { + if( iOwnedDiff & 1 ) + { + if( cl.snap.ps.stats[ STAT_WEAPONS ] & 1 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "pistol_empty", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "pistol_empty", event ); + } + } + else if( iOwnedDiff & 2 ) + { + if( cl.snap.ps.stats[ STAT_WEAPONS ] & 2 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "rifle_empty", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "rifle_empty", event ); + } + } + else if( iOwnedDiff & 4 ) + { + if( cl.snap.ps.stats[ STAT_WEAPONS ] & 4 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "smg_empty", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "smg_empty", event ); + } + } + else if( iOwnedDiff & 8 ) + { + if( cl.snap.ps.stats[ STAT_WEAPONS ] & 8 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "mg_empty", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "mg_empty", event ); + } + } + else if( iOwnedDiff & 16 ) + { + if( cl.snap.ps.stats[ STAT_WEAPONS ] & 16 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "grenade_empty", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "grenade_empty", event ); + } + } + else if( iOwnedDiff & 32 ) + { + if( cl.snap.ps.stats[ STAT_WEAPONS ] & 32 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "heavy_empty", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "heavy_empty", event ); + } + } + else + { + ui_lastWeapHudState_Owned = cl.snap.ps.stats[ STAT_WEAPONS ] & 0x3F | ui_lastWeapHudState_Owned & -0x40; + } + } + // + // highlight currently equipped weapons + // + else if( iEquippedDiff ) + { + if( iEquippedDiff & 1 ) + { + if( cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 1 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "pistol_equipped", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "pistol_equipped", event ); + } + } + else if( iEquippedDiff & 2 ) + { + if( cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 2 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "rifle_equipped", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "rifle_equipped", event ); + } + } + else if( iEquippedDiff & 4 ) + { + if( cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 4 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "smg_equipped", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "smg_equipped", event ); + } + } + else if( iEquippedDiff & 8 ) + { + if( cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 8 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "mg_equipped", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "mg_equipped", event ); + } + } + else if( iEquippedDiff & 16 ) + { + if( cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 16 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "grenade_equipped", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "grenade_equipped", event ); + } + } + else if( iEquippedDiff & 32 ) + { + if( cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 32 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "heavy_equipped", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "heavy_equipped", event ); + } + } + else + { + ui_lastWeapHudState_Equipped = cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 0x3F | ui_lastWeapHudState_Equipped & -0x40; + } + } + + if( !ui_weapHudTime ) + { + if( hud_weapons->isVisible() ) { + hud_weapons->ProcessEvent( EV_HideMenu ); + } + } + else if( ui_weapHudTime < cls.realtime || ui_itemHudTime > ui_weapHudTime ) + { + ui_weapHudTime = 0; + + if( hud_weapons->isVisible() ) { + hud_weapons->ProcessEvent( EV_HideMenu ); + } + } + else if( !hud_weapons->isVisible() ) + { + Event *event = new Event( EV_ShowMenu ); + event->AddInteger( false ); + hud_weapons->ProcessEvent( event ); + + if( hud_items->isVisible() ) { + hud_items->ProcessEvent( EV_HideMenu ); + } + } + } + else + { + hud_weapons->ForceHide(); + ui_weapHudTime = 0; + } + } + + // + // try to show the item bar + // + if( hud_items ) + { + if( ui_weaponsbar->integer && ui_itemsbar->integer ) + { + int iEquippedDiff = 0; + int iOwnedDiff = 0; + + if( ui_weaponsbar->integer == 3 ) + { + ui_itemHudTime = cls.realtime + ui_weaponsbartime->integer; + + if( ui_weapHudTime && hud_weapons->isVisible() ) { + ui_itemHudTime = 0; + } + } + + if( ui_lastWeapHudState_Owned != cl.snap.ps.stats[ STAT_WEAPONS ] + || ui_lastWeapHudState_Equipped != cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] ) + { + iOwnedDiff = cl.snap.ps.stats[ STAT_WEAPONS ] ^ ui_lastWeapHudState_Owned & 0xF00; + iEquippedDiff = ( ui_lastWeapHudState_Equipped ^ cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] ) & 0xF00; + + // if we have different equipment, reset the weapons hud time + if( iOwnedDiff || iEquippedDiff ) { + ui_weapHudTime = cls.realtime + ui_weaponsbartime->integer; + } + } + + // + // show items that the player holds + // + if( iOwnedDiff ) + { + if( iOwnedDiff & 0x100 ) + { + if( cl.snap.ps.stats[ STAT_WEAPONS ] & 1 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "slot1_icon", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "slot1_icon", event ); + } + } + else if( iOwnedDiff & 0x200 ) + { + if( cl.snap.ps.stats[ STAT_WEAPONS ] & 2 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "slot2_icon", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "slot2_icon", event ); + } + } + else if( iOwnedDiff & 0x400 ) + { + if( cl.snap.ps.stats[ STAT_WEAPONS ] & 4 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "slot3_icon", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "slot3_icon", event ); + } + } + else if( iOwnedDiff & 0x800 ) + { + if( cl.snap.ps.stats[ STAT_WEAPONS ] & 8 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "slot4_icon", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "slot4_icon", event ); + } + } + else + { + ui_lastWeapHudState_Owned = cl.snap.ps.stats[ STAT_WEAPONS ] & 0xF00 | ( ui_lastWeapHudState_Owned & 0xF0 ); + } + } + // + // highlight currently equipped weapons + // + else if( iEquippedDiff ) + { + if( iEquippedDiff & 0x100 ) + { + if( cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 1 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "slot1_highlight", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "slot1_highlight", event ); + } + } + else if( iEquippedDiff & 0x200 ) + { + if( cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 2 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "slot2_highlight", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "slot2_highlight", event ); + } + } + else if( iEquippedDiff & 0x400 ) + { + if( cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 4 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "slot3_highlight", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "slot3_highlight", event ); + } + } + else if( iEquippedDiff & 0x800 ) + { + if( cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 8 ) + { + Event *event = new Event( EV_Widget_Disable ); + hud_weapons->PassEventToWidget( "slot4_highlight", event ); + } + else + { + Event *event = new Event( EV_Widget_Enable ); + hud_weapons->PassEventToWidget( "slot4_highlight", event ); + } + } + else + { + ui_lastWeapHudState_Equipped = cl.snap.ps.stats[ STAT_EQUIPPED_WEAPON ] & 0xF00 | ( ui_lastWeapHudState_Equipped & 0xF0 ); + } + } + + if( !ui_itemHudTime ) + { + if( hud_items->isVisible() ) { + hud_items->ProcessEvent( EV_HideMenu ); + } + } + else if( ui_itemHudTime < cls.realtime || ui_weapHudTime > ui_itemHudTime ) + { + ui_itemHudTime = 0; + + if( hud_items->isVisible() ) { + hud_items->ProcessEvent( EV_HideMenu ); + } + } + else if( !hud_items->isVisible() ) + { + Event *event = new Event( EV_ShowMenu ); + event->AddInteger( false ); + hud_items->ProcessEvent( event ); + + if( hud_weapons->isVisible() ) { + hud_weapons->ProcessEvent( EV_HideMenu ); + } + } + } + else + { + hud_items->ForceHide(); + ui_itemHudTime = 0; + } + } + + if( hud_health ) { + hud_health->ForceShow(); + } + + // + // show the ammo hud + // + str ammo = "hud_ammo_"; + ammo += CL_ConfigString( CS_WEAPONS + cl.snap.ps.activeItems[ ITEM_WEAPON ] ); + + if( !hud_ammo || hud_ammo->m_name.icmp( ammo ) ) + { + Menu *ammoMenu = menuManager.FindMenu( ammo ); + if( ammoMenu ) + { + if( ammoMenu != hud_ammo ) + { + if( hud_ammo ) { + hud_ammo->ForceHide(); + } + hud_ammo = ammoMenu; + } + } + else + { + ammoMenu = menuManager.FindMenu( "hud_ammo_" ); + if( ammoMenu ) + { + if( ammoMenu != hud_ammo ) + { + if( hud_ammo ) { + hud_ammo->ForceHide(); + } + hud_ammo = ammoMenu; + } + } + } + } + + if( hud_ammo ) { + hud_ammo->ForceShow(); + } + + // + // show the compass + // + if( hud_compass ) + { + if( ui_compass->integer ) { + hud_compass->ForceShow(); + } else { + hud_compass->ForceHide(); + } + } + + // + // show the boss health + // + if( hud_boss ) + { + if( cl.snap.ps.stats[ STAT_BOSSHEALTH ] > 0 && !hud_boss->isVisible() ) + { + Event *event = new Event( EV_ShowMenu ); + event->AddInteger( false ); + hud_boss->ProcessEvent( event ); + } + else if( hud_boss->isVisible() ) + { + hud_boss->ProcessEvent( EV_HideMenu ); + } + } + + UI_ShowHudList(); + } + + // + // show the scoreboard + // + if( scoreboard_menu ) + { + if( scoreboardlist && scoreboardlist->IsVisible() ) { + scoreboard_menu->ForceShow(); + } else { + scoreboard_menu->ForceHide(); + } + } + + uWinMan.UpdateViews(); + } +} + +/* +==================== +UI_MultiplayerMenuWidgetsUpdate +==================== +*/ +static void UI_MultiplayerMenuWidgetsUpdate( void ) { + Event *event; + + // allow the map change widget when running in-game + if( com_sv_running->integer ) + { + event = new Event( EV_Widget_Disable ); + menuManager.PassEventToWidget( "startnew", event ); + + if( cls.state > CA_PRIMED && !cg_gametype->integer ) + { + event = new Event( EV_Widget_Disable ); + menuManager.PassEventToWidget( "changemap", event ); + } + else + { + event = new Event( EV_Widget_Enable ); + menuManager.PassEventToWidget( "changemap", event ); + } + } + else + { + event = new Event( EV_Widget_Disable ); + menuManager.PassEventToWidget( "changemap", event ); + + event = new Event( EV_Widget_Enable ); + menuManager.PassEventToWidget( "startnew", event ); + } + + // allow the disconnect widget when in-game + if( cls.state > CA_PRIMED ) + { + event = new Event( EV_Widget_Enable ); + menuManager.PassEventToWidget( "disconnect", event ); + } + else + { + event = new Event( EV_Widget_Disable ); + menuManager.PassEventToWidget( "disconnect", event ); + } + + // allow the join widget when in-game + if( com_sv_running->integer || cls.state > CA_PRIMED ) + { + event = new Event( EV_Widget_Disable ); + menuManager.PassEventToWidget( "joinlan", event ); + + event = new Event( EV_Widget_Disable ); + menuManager.PassEventToWidget( "joininternet", event ); + } + else + { + event = new Event( EV_Widget_Enable ); + menuManager.PassEventToWidget( "joinlan", event ); + + event = new Event( EV_Widget_Enable ); + menuManager.PassEventToWidget( "joininternet", event ); + } +} + +/* +==================== +UI_MainMenuWidgetsUpdate +==================== +*/ +static void UI_MainMenuWidgetsUpdate( void ) { + if( cls.state > CA_PRIMED ) + { + Event *event = new Event( EV_Widget_Enable ); + menuManager.PassEventToWidget( "backtogame", event ); + } + else + { + Event *event = new Event( EV_Widget_Disable ); + menuManager.PassEventToWidget( "backtogame", event ); + } + + UI_UpdateContinueGame(); +} + +/* +==================== +UI_ToggleMenu + +Toggle a menu +==================== +*/ +void UI_ToggleMenu( str name ) { + Menu *menu; + + menu = menuManager.CurrentMenu(); + + if( menu ) + { + UI_ForceMenuOff( false ); + + if( menu->m_name != name ) + { + UI_PushMenu( name ); + } + } + else + { + UI_PushMenu( name ); + } + + UI_FocusMenuIfExists(); +} + +/* +==================== +UI_ToggleMenu_f +==================== +*/ +void UI_ToggleMenu_f() { + if( Cmd_Argc() <= 1 ) { + Com_Printf( "Usage: togglemenu \n" ); + return; + } + + UI_ToggleMenu( Cmd_Argv( 1 ) ); +} + +/* +==================== +UI_PopMenu +==================== +*/ +void UI_PopMenu( qboolean restore_cvars ) { + Menu *menu; + + if( uWinMan.DialogExists() ) { + uWinMan.RemoveAllDialogBoxes(); + return; + } + + if( menuManager.CurrentMenu() ) { + menuManager.PopMenu( restore_cvars ); + } + + UI_FocusMenuIfExists(); + + menu = menuManager.CurrentMenu(); + + if( menu ) + { + if( !memcmp( menu->m_name.c_str(), "main", 5 ) ) + { + UI_MainMenuWidgetsUpdate(); + } + else if( !memcmp(menu->m_name.c_str(), "multiplayer", 12 ) ) + { + UI_MultiplayerMenuWidgetsUpdate(); + } + } +} + +/* +==================== +UI_DeactiveFloatingWindows +==================== +*/ +void UI_DeactiveFloatingWindows( void ) { + uWinMan.DeactiveFloatingWindows(); +} + +/* +==================== +UI_PushMenu +==================== +*/ +void UI_PushMenu( const char *name ) { + Menu *menu = menuManager.CurrentMenu(); + qboolean bDiff = qfalse; + + if( menu ) + { + bDiff = strcmp( menu->m_name, name ) != 0; + } + + if( !bDiff || !ui_pLoadingMenu || menu != ui_pLoadingMenu ) + { + menuManager.PushMenu( name ); + } + + UI_FocusMenuIfExists(); + + if( !memcmp( name, "main", 5 ) ) + { + UI_MainMenuWidgetsUpdate(); + } + else if( !memcmp( name, "multiplayer", 12 ) ) + { + UI_MultiplayerMenuWidgetsUpdate(); + } +} + +/* +==================== +UI_ForceMenu +==================== +*/ +void UI_ForceMenu( const char *name ) { + Menu *menu = menuManager.CurrentMenu(); + qboolean bDiff = qfalse; + + if( menu ) + { + bDiff = strcmp( menu->m_name, name ) != 0; + } + + if( !menu || bDiff ) + { + menuManager.ForceMenu( name ); + } + + UI_FocusMenuIfExists(); +} + +/* +==================== +UI_ShowMenu +==================== +*/ +void UI_ShowMenu( const char *name, qboolean bForce ) { + Menu *pMenu; + + pMenu = menuManager.FindMenu( name ); + + if( pMenu ) + { + if( bForce ) { + pMenu->ForceShow(); + } else if( !pMenu->isVisible() ) { + Event *event = new Event( EV_ShowMenu ); + event->AddInteger( false ); + pMenu->ProcessEvent( event ); + } + } +} + +/* +==================== +UI_HideMenu +==================== +*/ +void UI_HideMenu( const char *name, qboolean bForce ) { + Menu *pMenu; + + pMenu = menuManager.FindMenu( name ); + + if( pMenu ) + { + if( bForce ) { + pMenu->ForceHide(); + } else if( pMenu->isVisible() ) { + pMenu->ProcessEvent( EV_HideMenu ); + } + } +} + +/* +==================== +UI_PushMenu_f +==================== +*/ +void UI_PushMenu_f( void ) { + if( Cmd_Argc() <= 1 ) { + Com_Printf( "Usage: pushmenu \n" ); + return; + } + + UI_PushMenu( Cmd_Argv( 1 ) ); +} + +/* +==================== +UI_PushMenuSP_f +==================== +*/ +void UI_PushMenuSP_f( void ) { + if( Cmd_Argc() <= 1 ) { + Com_Printf( "Usage: pushmenu_sp \n" ); + return; + } + + if( ( !com_cl_running || !com_cl_running->integer + || cls.state == CA_DISCONNECTED || !cg_gametype->integer ) + && ( !com_sv_running || !com_sv_running->integer || !g_gametype->integer ) ) + { + UI_PushMenu( Cmd_Argv( 1 ) ); + } +} +/* + +==================== +UI_PushMenuMP_f +==================== +*/ +void UI_PushMenuMP_f( void ) { + const char *cmd; + + if( Cmd_Argc() <= 1 ) { + Com_Printf( "Usage: pushmenu_mp \n" ); + return; + } + + if( com_cl_running && com_cl_running->integer + && cls.state != CA_DISCONNECTED && cg_gametype->integer + && com_sv_running && com_sv_running->integer && g_gametype->integer ) + { + cmd = Cmd_Argv( 1 ); + + // + // Push the right menu depending on the gametype + // + if( !Q_stricmp( cmd, "SelectTeam" ) ) + { + switch( cg_gametype->integer ) + { + case GT_FFA: + UI_PushMenu( "SelectFFAModel" ); + break; + case GT_OBJECTIVE: + UI_PushMenu( "ObjSelectTeam" ); + break; + default: + UI_PushMenu( "SelectTeam" ); + } + } else { + UI_PushMenu( cmd ); + } + } +} + +/* +==================== +UI_ForceMenu_f +==================== +*/ +void UI_ForceMenu_f( void ) { + if( Cmd_Argc() <= 1 ) { + Com_Printf( "Usage: forcemenu \n" ); + return; + } + + UI_ForceMenu( Cmd_Argv( 1 ) ); +} + +/* +==================== +UI_PopMenu_f +==================== +*/ +void UI_PopMenu_f( void ) { + if( Cmd_Argc() <= 1 ) { + Com_Printf( "Usage: popmenu " ); + return; + } + + UI_PopMenu( atoi( Cmd_Argv( 1 ) ) ); +} + +/* +==================== +UI_ShowMenu_f +==================== +*/ +void UI_ShowMenu_f( void ) { + qboolean bForce; + const char *name; + + if( Cmd_Argc() <= 1 ) { + Com_Printf( "Usage: showmenu \n" ); + return; + } + + name = Cmd_Argv( 1 ); + + if( Cmd_Argc() > 2 ) { + bForce = atoi( Cmd_Argv( 2 ) ); + } else { + bForce = qfalse; + } + + UI_ShowMenu( name, bForce ); +} + +/* +==================== +UI_HideMenu_f +==================== +*/ +void UI_HideMenu_f( void ) { + qboolean bForce; + const char *name; + + if( Cmd_Argc() <= 1 ) { + Com_Printf( "Usage: hidemenu \n" ); + return; + } + + name = Cmd_Argv( 1 ); + + if( Cmd_Argc() > 2 ) { + bForce = atoi( Cmd_Argv( 2 ) ); + } else { + bForce = qfalse; + } + + UI_HideMenu( name, bForce ); +} + +/* +==================== +UI_WidgetCommand_f +==================== +*/ +void UI_WidgetCommand_f( void ) { + str name; + str commandstring; + + if( Cmd_Argc() <= 2 ) { + Com_Printf( "Usage: widgetcommand \n" ); + return; + } + + name = Cmd_Argv( 1 ); + commandstring = Cmd_Argv( 2 ); + Event *event = new Event( commandstring ); + + for( int i = 3; i < Cmd_Argc(); i++ ) + { + event->AddToken( Cmd_Argv( i ) ); + } + + menuManager.PassEventToWidget( name, event ); +} + +/* +==================== +UI_GlobalWidgetCommand_f +==================== +*/ +void UI_GlobalWidgetCommand_f( void ) { + str name; + str commandstring; + + if( Cmd_Argc() <= 2 ) { + Com_Printf( "Usage: globalwidgetcommand \n" ); + return; + } + + name = Cmd_Argv( 1 ); + commandstring = Cmd_Argv( 2 ); + Event *event = new Event( commandstring ); + + for( int i = 3; i < Cmd_Argc(); i++ ) + { + event->AddToken( Cmd_Argv( i ) ); + } + + uWinMan.PassEventToWidget( name, event ); +} + +/* +==================== +UI_ListMenus_f +==================== +*/ +void UI_ListMenus_f() { + menuManager.ListMenus(); +} + +/* +==================== +UI_BindActive +==================== +*/ +qboolean UI_BindActive( void ) { + return uWinMan.BindActive() != NULL; +} + +/* +==================== +UI_SetReturnMenuToCurrent +==================== +*/ +void UI_SetReturnMenuToCurrent( void ) { + Menu *currentMenu = menuManager.CurrentMenu(); + + if( currentMenu ) { + Cvar_Set( "ui_returnmenu", currentMenu->m_name ); + } else { + Cvar_Set( "ui_returnmenu", "" ); + } +} + +/* +==================== +UI_PushReturnMenu +==================== +*/ +qboolean UI_PushReturnMenu() { + str sMenuName; + + if( !ui_returnmenu->string || !*ui_returnmenu->string ) { + return qfalse; + } + + sMenuName = ui_returnmenu->string; + + UI_PushMenu( sMenuName ); + Cvar_Set( "ui_returnmenu", "" ); + UI_FocusMenuIfExists(); + + if( !menuManager.CurrentMenu() ) { + return qfalse; + } + + if( !memcmp( sMenuName.c_str(), "main", 5 ) ) + { + UI_MainMenuWidgetsUpdate(); + } + else if( !memcmp( sMenuName.c_str(), "multiplayer", 12 ) ) + { + UI_MultiplayerMenuWidgetsUpdate(); + } + + return qtrue; +} + +/* +==================== +UI_PushReturnMenu_f +==================== +*/ +void UI_PushReturnMenu_f( void ) { + UI_PushReturnMenu(); +} + +/* +==================== +UI_MenuEscape +==================== +*/ +void UI_MenuEscape( const char *name ) { + if( server_loading ) { + return; + } + + if( uWinMan.BindActive() ) + { + UI_KeyEvent( K_ESCAPE, qfalse ); + } + else if( menuManager.CurrentMenu() != mainmenu || cls.state != CA_DISCONNECTED ) + { + if( uWinMan.DialogExists() ) + { + uWinMan.RemoveAllDialogBoxes(); + } + else + { + if( menuManager.CurrentMenu() ) + { + menuManager.PopMenu( qtrue ); + } + else if( !Q_stricmp( name, "main" ) && cls.state > CA_PRIMED && cg_gametype->integer > 0 ) + { + UI_PushMenu( "dm_main" ); + } + else + { + UI_PushMenu( name ); + } + + UI_FocusMenuIfExists(); + + if( menuManager.CurrentMenu() ) + { + if( !memcmp( name, "main", 5 ) ) + { + UI_MainMenuWidgetsUpdate(); + } + else if( !memcmp( name, "multiplayer", 12 ) ) + { + UI_MultiplayerMenuWidgetsUpdate(); + } + } + } + } + else if( developer->integer ) + { + if( UI_ConsoleIsVisible() ) { + UI_CloseConsole(); + } else { + UI_OpenConsole(); + } + } +} + +/* +==================== +UI_ForceMenuOff +==================== +*/ +void UI_ForceMenuOff( bool force ) { + menuManager.ClearMenus( force ); + UI_FocusMenuIfExists(); +} + +/* +==================== +UI_UpdateConnectionString +==================== +*/ +void UI_UpdateConnectionString( void ) { +} + +/* +==================== +UI_ParseServerInfoMessage +==================== +*/ +void UI_ParseServerInfoMessage( msg_t *msg ) { + +} + +/* +==================== +UI_DrawConnectText +==================== +*/ +void UI_DrawConnectText( void ) { + +} + +/* +==================== +UI_DrawConnect +==================== +*/ +void UI_DrawConnect( void ) { + Com_Printf( "UI_DrawConnect called\n" ); +} + +/* +==================== +CL_PingServers_f +==================== +*/ +void CL_PingServers_f( void ) { + int i; + netadr_t adr; + char name[ 32 ]; + const char *adrstring; + cvar_t *noudp; + cvar_t *noipx; + + Com_Printf( "pinging broadcast...\n" ); + + noudp = Cvar_Get( "noudp", "0", CVAR_INIT ); + if( !noudp->integer ) + { + adr.type = NA_BROADCAST; + adr.port = BigShort( 12203 ); + NET_OutOfBandPrint( NS_SERVER, adr, "info %i", 8 ); + } + + noipx = Cvar_Get( "noipx", "0", CVAR_INIT ); + if( !noipx->integer ) + { + adr.type = NA_BROADCAST_IPX; + adr.port = BigShort( 12203 ); + NET_OutOfBandPrint( NS_SERVER, adr, "info %i", 8 ); + } + + for( i = 0; i < 16; i++ ) + { + Com_sprintf( name, sizeof( name ), "adr%i", i ); + adrstring = Cvar_VariableString( name ); + + if( adrstring && *adrstring ) + { + Com_Printf( "pinging %s...\n", adrstring ); + + if( NET_StringToAdr( adrstring, &adr ) ) + { + if( !adr.port ) { + adr.port = BigShort( 12203 ); + } + + NET_OutOfBandPrint( NS_SERVER, adr, "info %i", 8 ); + } + else + { + Com_Printf( "Bad address: %s\n", adrstring ); + } + } + } +} + +/* +==================== +UI_MapList_f +==================== +*/ +void UI_MapList_f( void ) { + str mappath = "maps"; + + if( Cmd_Argc() == 2 ) + { + mappath += "/"; + mappath += Cmd_Argv( 1 ); + } + + MapRunnerClass *map = new MapRunnerClass; + map->Setup( "maps", mappath, ".bsp" ); + + CL_SetMousePos( cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2 ); +} + +/* +==================== +UI_DMMapSelect_f +==================== +*/ +void UI_DMMapSelect_f( void ) { + str basepath = "maps"; + str mappath = "maps"; + + if( Cmd_Argc() > 1 ) + { + mappath += "/"; + mappath += Cmd_Argv( 1 ); + } + + if( Cmd_Argc() > 2 ) + { + basepath += "/"; + basepath += Cmd_Argv( 2 ); + } + + MpMapPickerClass *map = new MpMapPickerClass; + map->Setup( basepath, mappath ); + + CL_SetMousePos( cls.glconfig.vidWidth / 2, cls.glconfig.vidHeight / 2 ); +} + +/* +==================== +UI_StartDMMap_f +==================== +*/ +void UI_StartDMMap_f( void ) { + int iDedicated; + int iMaxClients; + int iUseGameSpy; + int iGameType = GT_FFA; + int iFragLimit; + int iTimeLimit; + int iTeamDamage; + int iInactiveSpectate; + int iInactiveKick; + const char *pszTemp; + const char *pszGameTypeString = "Free-For-All"; + const char *pszMapName; + const char *pszMapListCvar = "sv_maplist"; + const char *pszMapListString; + char szHostName[ 32 ]; + + if( Cmd_Argc() > 1 ) + { + iGameType = atoi( Cmd_Argv( 1 ) ); + if( Cmd_Argc() > 2 ) { + pszGameTypeString = Cmd_Argv( 2 ); + + if( Cmd_Argc() > 3 ) { + pszMapListCvar = Cmd_Argv( 3 ); + } + } + } + + pszMapName = CvarGetForUI( "ui_dmmap", "" ); + + if( !*pszMapName ) { + return; + } + + iDedicated = atoi( CvarGetForUI( "ui_dedicated", "0" ) ); + + if( iDedicated < 0 ) { + iDedicated = 0; + } else if( iDedicated > 1 ) { + iDedicated = 1; + } + + Cvar_SetValue( "ui_dedicated", iDedicated ); + + iMaxClients = atoi( CvarGetForUI( "ui_maxclients", "0" ) ); + + if( iMaxClients < 1 ) { + iMaxClients = 1; + } else if( iMaxClients > MAX_CLIENTS ) { + iMaxClients = MAX_CLIENTS; + } + + Cvar_SetValue( "ui_maxclients", iMaxClients ); + + iUseGameSpy = atoi( CvarGetForUI( "ui_gamespy", "0" ) ); + + if( iUseGameSpy < 0 ) { + iUseGameSpy = 0; + } else if( iUseGameSpy > 1 ) { + iUseGameSpy = 1; + } + + Cvar_SetValue( "ui_gamespy", iUseGameSpy ); + + iFragLimit = atoi( CvarGetForUI( "ui_fraglimit", "0" ) ); + + if( iFragLimit < 0 ) { + iFragLimit = 0; + } + + Cvar_SetValue( "ui_fraglimit", iFragLimit ); + + iTimeLimit = atoi( CvarGetForUI( "ui_timelimit", "0" ) ); + + if( iTimeLimit < 0 ) { + iTimeLimit = 0; + } + + Cvar_SetValue( "ui_timelimit", iTimeLimit ); + + iTeamDamage = atoi( CvarGetForUI( "ui_teamdamage", "0" ) ); + + if( iTeamDamage < 0 ) { + iTeamDamage = 0; + } else if( iTeamDamage > 1 ) { + iTeamDamage = 1; + } + + Cvar_SetValue( "ui_teamdamage", iTeamDamage ); + + iInactiveSpectate = atoi( CvarGetForUI( "ui_inactivespectate", "0" ) ); + + if( iInactiveSpectate < 0 ) { + iInactiveSpectate = 0; + } + + Cvar_SetValue( "ui_inactivespectate", iInactiveSpectate ); + + iInactiveKick = atoi( CvarGetForUI( "ui_inactivekick", "0" ) ); + + if( iInactiveKick < 0 ) { + iInactiveKick = 0; + } + + Cvar_SetValue( "ui_inactivekick", iInactiveKick ); + + pszMapListString = CvarGetForUI( pszMapListCvar, "" ); + + pszTemp = CvarGetForUI( "ui_hostname", "Nameless Battle" ); + Q_strncpyz( szHostName, pszTemp, sizeof( szHostName ) ); + + for( int i = 0; i < sizeof( szHostName ); i++ ) + { + if( szHostName[ i ] == ';' || szHostName[ i ] == '"' || szHostName[ i ] == '\\' ) { + szHostName[ i ] = '_'; + } + } + + Cvar_Set( "ui_hostname", szHostName ); + + Cbuf_AddText( + va( "set dedicated %i;" + "set sv_maxclients %i;" + "set sv_gamespy %i;" + "set g_gametype %i;" + "set g_gametypestring \"%s\";" + "set fraglimit %i;" + "set timelimit %i;" + "set g_teamdamage %i;" + "set g_inactivespectate %i;" + "set g_inactivekick %i;" + "set sv_maplist \"%s\";" + "set sv_hostname \"%s\";" + "set cheats 0;" + "wait;" + "map \"%s\"\n", + iDedicated, iMaxClients, iUseGameSpy, iGameType, pszGameTypeString, + iFragLimit, iTimeLimit, iTeamDamage, + iInactiveSpectate, iInactiveKick, + pszMapListString, szHostName, pszMapName ) ); +} + +/* +==================== +UI_PlayerModel_f +==================== +*/ +void UI_PlayerModel_f( void ) { + qboolean bGermanModel; + str modelpath = "models/player"; + + bGermanModel = qfalse; + + if( Cmd_Argc() > 1 ) + { + bGermanModel = atoi( Cmd_Argv( 1 ) ) ? qtrue : qfalse; + + if( Cmd_Argc() == 3 ) + { + modelpath += "/"; + modelpath += Cmd_Argv( 2 ); + } + } + + PlayerModelPickerClass *picker = new PlayerModelPickerClass; + picker->Setup( "models/player", modelpath, bGermanModel ); +} + +/* +==================== +UI_ApplyPlayerModel_f +==================== +*/ +void UI_ApplyPlayerModel_f( void ) { + const char *pszUIPlayerModel; + + pszUIPlayerModel = CvarGetForUI( "ui_dm_playermodel", "american_army" ); + Cvar_Set( "dm_playermodel", pszUIPlayerModel ); + + pszUIPlayerModel = CvarGetForUI( "ui_dm_playergermanmodel", "german_wehrmacht_soldier" ); + Cvar_Set( "ui_dm_playergermanmodel", pszUIPlayerModel ); + + Cvar_Set( "name", CvarGetForUI( "ui_name", "*** Blank Name ***" ) ); +} + +/* +==================== +UI_GetPlayerModel_f +==================== +*/ +void UI_GetPlayerModel_f( void ) { + const char *pszUIPlayerModel; + char donotshowssindeorfr[ 64 ]; + + pszUIPlayerModel = CvarGetForUI( "dm_playermodel", "american_army" ); + Cvar_Set( "ui_dm_playermodel", pszUIPlayerModel ); + + Cvar_Set( "ui_disp_playermodel", va( "models/player/%s.tik", pszUIPlayerModel ) ); + + pszUIPlayerModel = CvarGetForUI( "dm_playergermanmodel", "german_wehrmacht_soldier" ); + Cvar_Set( "ui_dm_playergermanmodel", pszUIPlayerModel ); + + if( !strncmp( pszUIPlayerModel, "german_waffen_", 14 ) ) + { + memcpy( donotshowssindeorfr, "german_waffenss_", 17 ); + strncat( donotshowssindeorfr, pszUIPlayerModel + 14, 48 ); + } + else + { + strncpy( donotshowssindeorfr, pszUIPlayerModel, sizeof( donotshowssindeorfr ) ); + } + + Cvar_Set( "ui_disp_playergermanmodel", va( "models/player/%s.tik", donotshowssindeorfr ) ); + + Cvar_Set( "ui_name", CvarGetForUI( "name", "*** Blank Name ***" ) ); +} + +/* +==================== +UI_SoundPicker_f +==================== +*/ +void UI_SoundPicker_f( void ) { + new SoundPickerClass; +} + +/* +==================== +UI_ViewSpawnList_f +==================== +*/ +void UI_ViewSpawnList_f( void ) { + str modelpath = "models"; + + ViewSpawnerClass *picker = new ViewSpawnerClass; + picker->Setup( "models", modelpath, ".tik" ); +} + +/* +==================== +UI_LODSpawnList_f +==================== +*/ +void UI_LODSpawnList_f( void ) { + str modelpath = "models"; + + LODSpawnerClass *picker = new LODSpawnerClass; + picker->Setup( "models", modelpath, ".tik" ); +} + +/* +==================== +UI_Notepad_f +==================== +*/ +void UI_Notepad_f( void ) { + if( Cmd_Argc() > 1 ) { + UI_LoadNotepadFile( Cmd_Argv( 1 ) ); + } else { + UI_LoadNotepadFile( NULL ); + } +} + +/* +==================== +UI_EditScript_f +==================== +*/ +void UI_EditScript_f( void ) { + const char *info; + const char *mname; + str mapname; + str mappath; + + // editscript only works in-game + if( cls.state != CA_ACTIVE ) + { + Com_Printf( "You need to load a map to edit its script\n" ); + return; + } + + mname = Info_ValueForKey( &cl.gameState.stringData[ cl.gameState.stringOffsets[ CS_SERVERINFO ] ], "mapname" ); + mapname = mname; + + // remove the spawnpoint name + if( strchr( mname, '$' ) ) + { + info = strchr( mname, '$' ); + mapname[ info - mname ] = 0; + } + + // make sure the map is loaded + if( !strcmp( mapname, "" ) ) + { + Com_Printf( "No map loaded?\n" ); + return; + } + + mappath = "maps/" + mapname + ".scr"; + + if( !UI_LoadNotepadFile( mappath ) ) { + Com_Printf( "Couldn't load/find script file for %s\n", mappath.c_str() ); + } +} + +/* +==================== +UI_EditShader_f +==================== +*/ +void UI_EditShader_f( void ) { + str shaderpath; + + if( Cmd_Argc() != 2 ) { + Com_Printf( "Usage: Editshader \n" ); + return; + } + + shaderpath = "scripts/" + str( Cmd_Argv( 1 ) ) + ".shader"; + + if( !UI_LoadNotepadFile( shaderpath ) ) { + Com_Printf( "Couldn't open shader named %s\n", shaderpath.c_str() ); + } +} + +/* +==================== +UI_EditSpecificShader_f +==================== +*/ +void UI_EditSpecificShader_f( void ) { +} + +/* +==================== +UI_LoadMenu +==================== +*/ +void UI_LoadMenu( const char *name ) { + char buffer[ 256 ]; + + Com_sprintf( buffer, sizeof( buffer ), "ui/%s", name ); + COM_StripExtension( buffer, buffer, sizeof( buffer ) ); + Q_strcat( buffer, 256, ".urc" ); + + new UILayout( buffer ); + uWinMan.CreateMenus(); + UI_FocusMenuIfExists(); +} + +/* +==================== +UI_LoadMenu_f +==================== +*/ +void UI_LoadMenu_f( void ) { + UI_LoadMenu( Cmd_Argv( 1 ) ); +} + +/* +==================== +CvarGetForUI +==================== +*/ +const char *CvarGetForUI( const char *name, const char *defval ) { + cvar_t *cvar = Cvar_FindVar( name ); + + if( cvar ) { + if( cvar->latchedString && *cvar->latchedString ) { + return cvar->latchedString; + } else { + return cvar->string; + } + } + else + { + return defval; + } +} + +/* +==================== +ListFilesForUI +==================== +*/ +void ListFilesForUI( const char *filespec ) +{ + int nfiles; + char **filenames; + + filenames = FS_ListFiles( "", filespec, qfalse, &nfiles ); + + for( int i = 0; i < nfiles; i++ ) { + uie.AddFileToList( filenames[ i ] ); + } + + FS_FreeFileList( filenames ); +} + +/* +==================== +IsKeyDown +==================== +*/ +int IsKeyDown( int key ) { + return keys[ key ].down; +} + +/* +==================== +UI_WantsKeyboard +==================== +*/ +void UI_WantsKeyboard() { + cls.keyCatchers |= KEYCATCH_UI; +} + +struct widgettrans_s { + char *src; + char *dst; +}; + +static widgettrans_s s_widgettrans[ 2 ] = +{ + { "Label", "FakkLabel" }, + { NULL, NULL } +}; + +/* +==================== +TranslateWidgetName +==================== +*/ +const char *TranslateWidgetName( const char *widget ) { + widgettrans_s *trans = &s_widgettrans[ 0 ]; + + for( int i = 0; trans->src != NULL; i++, trans++ ) + { + if( !strcmp( trans->src, widget ) ) { + return trans->dst; + } + } + + return NULL; +} + +/* +==================== +UI_Cvar_Set +==================== +*/ +void UI_Cvar_Set( const char *var_name, const char *value ) { + Cvar_Set2( var_name, value, qfalse ); +} + +/* +==================== +CL_FillUIDef +==================== +*/ +void CL_FillUIDef( void ) { + CL_GetMouseState( &uid.mouseX, &uid.mouseY, &uid.mouseFlags ); + uid.time = cls.realtime; + uid.vidHeight = cls.glconfig.vidHeight; + uid.vidWidth = cls.glconfig.vidWidth; + uid.uiHasMouse = in_guimouse != qfalse; +} + +sfxHandle_t UI_RegisterSound( const char *sample, qboolean streamed ) { + return S_RegisterSound( sample, streamed, qfalse ); +} + +void UI_StartLocalSound( const char *sound_name ) { + S_StartLocalSound( sound_name, qtrue ); +} + +/* +==================== +CL_FillUIImports +==================== +*/ +void CL_FillUIImports( void ) { + uii.Rend_DrawBox = re.DrawBox; + uii.Rend_DrawPicStretched = re.DrawStretchPic; + uii.Rend_DrawPicTiled = re.DrawTilePic; + uii.Rend_GetShaderHeight = re.GetShaderHeight; + uii.Rend_GetShaderWidth = re.GetShaderWidth; + uii.Rend_DrawString = re.DrawString; + uii.Rend_LoadFont = re.LoadFont; + uii.Rend_RegisterMaterial = re.RegisterShaderNoMip; + uii.Rend_RefreshMaterial = re.RefreshShaderNoMip; + uii.Rend_Scissor = re.Scissor; + uii.Rend_Set2D = re.Set2DWindow; + uii.Rend_SetColor = re.SetColor; + + uii.Cmd_Stuff = Cbuf_AddText; + uii.Cvar_GetString = CvarGetForUI; + uii.Cvar_Reset = Cvar_Reset; + uii.Cvar_Find = Cvar_FindVar; + uii.Cvar_Set = Cvar_Set; + uii.File_PickFile = PickFile; + uii.File_FreeFile = FS_FreeFile; + uii.File_ListFiles = ListFilesForUI; + uii.File_OpenFile = FS_ReadFile; + uii.File_WriteFile = FS_WriteTextFile; + uii.Snd_PlaySound = UI_StartLocalSound; + uii.Snd_RegisterSound = UI_RegisterSound; + uii.Alias_Add = Alias_Add; + uii.Alias_FindRandom = Alias_FindRandom; + uii.Sys_Error = Com_Error; + uii.Sys_IsKeyDown = IsKeyDown; + uii.Sys_Milliseconds = Sys_Milliseconds; + uii.Sys_Printf = Com_Printf; + uii.Sys_DPrintf = Com_DPrintf; + uii.Sys_GetClipboard = Sys_GetWholeClipboard; + uii.Sys_SetClipboard = Sys_SetClipboard; + uii.Cmd_CompleteCommandByNumber = Cmd_CompleteCommandByNumber; + uii.Cvar_CompleteCvarByNumber = Cvar_CompleteVariableByNumber; + uii.UI_WantsKeyboard = UI_WantsKeyboard; + uii.Client_TranslateWidgetName = TranslateWidgetName; + uii.Connect = CL_Connect; + uii.Key_GetKeynameForCommand = Key_GetKeynameForCommand; + uii.Key_GetCommandForKey = Key_GetBinding; + uii.Key_SetBinding = Key_SetBinding; + uii.Key_GetKeysForCommand = Key_GetKeysForCommand; + uii.Key_KeynumToString = Key_KeynumToBindString; + + uii.GetConfigstring = CL_ConfigString; + uii.UI_CloseDMConsole = UI_CloseDMConsole; + +#if 0 + uii.TIKI_RegisterModel = TIKI_RegisterTiki; + + uii.Cvar_Get = Cvar_Get; + uii.Argc = Cmd_Argc; + uii.Argv = Cmd_Argv; + uii.Cmd_ExecuteText = Cbuf_ExecuteText; + uii.FS_FOpenFile = FS_FOpenFileByMode; + uii.FS_Read = FS_Read; + uii.FS_Write = FS_Write; + uii.FS_FCloseFile = FS_FCloseFile; + uii.FS_GetFileList = FS_GetFileList; + uii.FS_Seek = FS_Seek; + uii.R_RegisterModel = re.RegisterModel; + uii.R_RegisterSkin = re.RegisterShader; + uii.R_RegisterShader = re.RegisterShader; + uii.R_RegisterShaderNoMip = re.RegisterShaderNoMip; + uii.R_ClearScene = re.ClearScene; + uii.R_AddRefEntityToScene = re.AddRefEntityToScene; + uii.R_AddPolyToScene = re.AddPolyToScene; + uii.R_AddLightToScene = re.AddLightToScene; + uii.R_RenderScene = re.RenderScene; + uii.R_SetColor = re.SetColor; + uii.R_DrawStretchPic = re.DrawStretchPic; + uii.UpdateScreen = SCR_UpdateScreen; + uii.S_StartLocalSound = S_StartLocalSound; + uii.S_RegisterSound = S_RegisterSound; + uii.Key_KeynumToStringBuf = Key_KeynumToStringBuf; + uii.Key_KeynumToString = Key_KeynumToString; + uii.Key_GetBindingBuf = Key_GetBindingBuf; + uii.Key_IsDown = Key_IsDown; + uii.Key_GetOverstrikeMode = Key_GetOverstrikeMode; + uii.Key_SetOverstrikeMode = Key_SetOverstrikeMode; + uii.Key_ClearStates = Key_ClearStates; + uii.Key_GetCatcher = Key_GetCatcher; + uii.Key_SetCatcher = Key_SetCatcher; + uii.GetClipboardData = CL_GetClipboardData; + uii.GetClientState = GetClientState; + uii.GetGlconfig = CL_GetGlconfig; + uii.GetConfigString = GetConfigString; + uii.LAN_GetServerCount = LAN_GetServerCount; + uii.LAN_GetServerAddressString = LAN_GetServerAddressString; + uii.LAN_GetServerInfo = LAN_GetServerInfo; + uii.LAN_GetPingQueueCount = LAN_GetPingQueueCount; + uii.LAN_ServerStatus = LAN_GetServerStatus; + uii.LAN_ClearPing = LAN_ClearPing; + uii.LAN_GetPing = LAN_GetPing; + uii.LAN_GetPingInfo = LAN_GetPingInfo; + uii.LAN_GetServerPing = LAN_GetServerPing; + uii.LAN_MarkServerVisible = LAN_MarkServerVisible; + uii.LAN_UpdateVisiblePings = LAN_UpdateVisiblePings; + uii.GetCDKey = CLUI_GetCDKey; + uii.SetCDKey = CLUI_SetCDKey; + uii.R_RegisterFont = re.RegisterFont; + uii.R_Text_Width = re.Text_Width; + uii.R_Text_Height = re.Text_Height; + uii.R_Text_Paint = re.Text_Paint; + uii.R_Text_PaintChar = re.Text_PaintChar; + uii.R_GetShaderName = re.GetShaderName; + + uii.Cmd_Stuff = Cbuf_AddText; + uii.Cvar_GetString = CvarGetForUI; + uii.Cvar_Reset = Cvar_Reset; + uii.Cvar_Find = Cvar_FindVar; + uii.Cvar_Set = UI_Cvar_Set; + uii.File_PickFile = PickFile; + uii.File_FreeFile = FS_FreeFile; + uii.File_ListFiles = ListFilesForUI; + uii.File_OpenFile = FS_ReadFile; + uii.File_WriteFile = FS_WriteTextFile; + uii.Rend_SetColor = re.SetColor; + uii.Snd_PlaySound = UI_StartLocalSound; + uii.Snd_RegisterSound = UI_RegisterSound; + uii.Alias_Add = Alias_Add; + uii.Alias_FindRandom = Alias_FindRandom; + uii.Sys_Error = Com_Error; + uii.Sys_IsKeyDown = IsKeyDown; + uii.Sys_Milliseconds = Sys_Milliseconds; + uii.Sys_Printf = Com_Printf; + uii.Sys_DPrintf = Com_DPrintf; + uii.Sys_GetClipboard = Sys_GetWholeClipboard; + uii.Sys_SetClipboard = Sys_SetClipboard; + uii.Cmd_CompleteCommandByNumber = Cmd_CompleteCommandByNumber; + uii.Cvar_CompleteCvarByNumber = Cvar_CompleteVariableByNumber; + uii.UI_WantsKeyboard = UI_WantsKeyboard; + uii.Client_TranslateWidgetName = TranslateWidgetName; + uii.Connect = CL_Connect; + uii.Key_GetKeynameForCommand = Key_GetKeynameForCommand; + uii.Key_GetCommandForKey = Key_GetBinding; + uii.Key_SetBinding = Key_SetBinding; + uii.Key_GetKeysForCommand = Key_GetKeysForCommand; + uii.Key_KeynumToString = Key_KeynumToBindString; + uii.GetConfigstring = CL_ConfigString; + uii.UI_CloseDMConsole = UI_CloseDMConsole; +#endif +} + + +/* +==================== +CL_BeginRegistration +==================== +*/ +void CL_BeginRegistration( void ) +{ + // init console stuff + CL_InitRenderer(); + re.BeginRegistration( &cls.glconfig ); + uWinMan.CleanupShadersFromList(); +} + +/* +==================== +CL_EndRegistration +==================== +*/ +void CL_EndRegistration( void ) +{ + int start, end; + + start = Sys_Milliseconds(); + + S_EndRegistration(); + re.EndRegistration(); + + if( !Sys_LowPhysicalMemory() ) { + Com_TouchMemory(); + } + + end = Sys_Milliseconds(); + + Com_Printf( "CL_EndRegistration: %5.2f seconds\n", ( float )( start - end ) / 1000.0 ); +} + +/* +==================== +UI_CreateDialog +==================== +*/ +void UI_CreateDialog( const char *title, char *cvarname, const char *command, const char *cancelCommand, int width, int height, const char *shader, const char *okshader, const char *cancelshader ) { + UIDialog *dlg = new UIDialog; + UIRect2D rect = UIRect2D( ( cls.glconfig.vidWidth - width ) >> 1, ( cls.glconfig.vidHeight - height ) >> 1, width, height ); + UColor bgColor = UColor( HUD_WINDOW_COLOR ); + + dlg->Create( NULL, rect, title, bgColor, UHudColor ); + dlg->LinkCvar( cvarname ); + dlg->SetOKCommand( command ); + dlg->SetCancelCommand( command ); + dlg->SetLabelMaterial( uWinMan.RegisterShader( shader ) ); + dlg->SetOkMaterial( uWinMan.RegisterShader( okshader ) ); + + if( cancelshader ) { + dlg->SetCancelMaterial( uWinMan.RegisterShader( cancelshader ) ); + } + + uWinMan.ActivateControl( dlg ); +} + +/* +==================== +UI_ResolutionChange +==================== +*/ +void UI_ResolutionChange( void ) { + UIRect2D frame; + + CL_FillUIImports(); + CL_FillUIDef(); + + if( !uie.ResolutionChange ) { + return; + } + + if( fakk_console ) + { + frame = getDefaultConsoleRectangle(); + fakk_console->setFrame( frame ); + } + + if( dm_console ) + { + if( dm_console->GetQuickMessageMode() ) { + frame = getQuickMessageDMConsoleRectangle(); + } else { + frame = getDefaultDMConsoleRectangle(); + } + + dm_console->setFrame( frame ); + } + + if( developer_console ) + { + frame = getDefaultConsoleRectangle(); + developer_console->setFrame( frame ); + } + + if( scoreboardlist ) + { + delete scoreboardlist; + scoreboardlist = NULL; + UI_CreateScoreboard(); + } + + uie.ResolutionChange(); + menuManager.RealignMenus(); + + if( view3d ) + { + frame = UIRect2D( 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight ); + view3d->setFrame( frame ); + } + + if( gmbox ) + { + frame = getDefaultGMBoxRectangle(); + gmbox->setFrame( frame ); + } + + if( dmbox ) + { + frame = getDefaultDMBoxRectangle(); + dmbox->setFrame( frame ); + } +} + +/* +==================== +UI_FinishLoadingScreen_f +==================== +*/ +void UI_FinishLoadingScreen_f( void ) { + Com_Unpause(); + UI_ForceMenuOff( qtrue ); + + ui_pLoadingMenu = NULL; + ui_sCurrentLoadingMenu = ""; + server_loading = qfalse; + server_loading_waiting = qfalse; + + UI_ActivateView3D(); +} + +/* +==================== +S_ServerLoaded +==================== +*/ +void S_ServerLoaded( void ) { + if( !svs.soundsNeedLoad ) { + return; + } + svs.soundsNeedLoad = qfalse; + + Com_DPrintf( "Loading Previous Sound State.\n" ); + S_StopAllSounds( qfalse ); + + //S_TriggeredMusic_Stop(); + //s_bSoundPaused = qtrue; + //S_ReLoad( &svs.soundSystem ); + // + //if( svs.tm_filename[ 0 ] ) { + // S_TriggeredMusic_SetupHandle( svs.tm_filename, svs.tm_loopcount, svs.tm_offset, 0 ); + //} +} + +/* +==================== +UI_ServerLoaded +==================== +*/ +void UI_ServerLoaded( void ) { + Menu *pCurrentMenu; + cvar_t *pMaxClients; + Event *event; + + CL_UpdateSnapFlags(); + SV_ServerLoaded(); + S_FadeSound( 0 ); + S_ServerLoaded(); + + if( !server_loading ) { + return; + } + + UI_EndLoad(); + pMaxClients = Cvar_Get( "sv_maxclients", "1", 0 ); + + if( com_sv_running->integer && pMaxClients->integer > 1 ) { + SV_Heartbeat_f(); + } + + uWinMan.showCursor( true ); + + if( !ui_pLoadingMenu ) + { + UI_FinishLoadingScreen_f(); + return; + } + + pCurrentMenu = menuManager.CurrentMenu(); + + if( pCurrentMenu != ui_pLoadingMenu + || !pCurrentMenu->GetNamedWidget( "continuebutton" ) + || !com_sv_running->integer + || pMaxClients->integer > 1 ) + { + UI_FinishLoadingScreen_f(); + return; + } + + server_loading_waiting = qtrue; + + event = new Event( EV_Widget_Enable ); + ui_pLoadingMenu->PassEventToWidget( "continuebutton", event ); + + event = new Event( EV_Widget_Disable ); + ui_pLoadingMenu->PassEventToWidget( "loadingflasher", event ); + + event = new Event( EV_Widget_Disable ); + ui_pLoadingMenu->PassEventToWidget( "loadingbar", event ); + + event = new Event( EV_Widget_Disable ); + ui_pLoadingMenu->PassEventToWidget( "loadingbar_border", event ); + + event = new Event( EV_Widget_Activate ); + ui_pLoadingMenu->PassEventToWidget( "continuebutton", event ); + + Com_FakePause(); +} + +/* +==================== +UI_ClearCenterPrint +==================== +*/ +void UI_ClearCenterPrint( void ) { + if( view3d ) { + view3d->ClearCenterPrint(); + } +} + +/* +==================== +UI_UpdateCenterPrint +==================== +*/ +void UI_UpdateCenterPrint( const char *s, float alpha ) { + view3d->UpdateCenterPrint( s, alpha ); +} + +/* +==================== +UI_UpdateLocationPrint +==================== +*/ +void UI_UpdateLocationPrint( int x, int y, const char *s, float alpha ) { + view3d->UpdateLocationPrint( x, y, s, alpha ); +} + +/* +==================== +UI_CenterPrint_f +==================== +*/ +void UI_CenterPrint_f( void ) { + const char *s; + float alpha; + + if( Cmd_Argc() <= 1 ) { + Com_Printf( "Usage: centerprintf string [alpha]\n" ); + return; + } + + s = Cmd_Argv( 1 ); + + if( Cmd_Argc() > 2 ) { + alpha = atof( Cmd_Argv( 2 ) ); + } else { + alpha = 1.0; + } + + + UI_UpdateCenterPrint( s, alpha ); +} + +/* +==================== +UI_LocationPrint_f +==================== +*/ +void UI_LocationPrint_f( void ) { + int x, y; + const char *s; + float alpha; + + if( Cmd_Argc() <= 3 ) { + Com_Printf( "Usage: locatinprint x y string [alpha]\n" ); + return; + } + + x = atoi( Cmd_Argv( 1 ) ); + y = atoi( Cmd_Argv( 2 ) ); + + s = Cmd_Argv( 3 ); + + if( Cmd_Argc() > 4 ) { + alpha = atof( Cmd_Argv( 4 ) ); + } else { + alpha = 1.0; + } + + + UI_UpdateLocationPrint( x, y, s, alpha ); +} + +/* +==================== +UI_LoadInventory_f +==================== +*/ +void UI_LoadInventory_f( void ) { + UI_CloseInventory(); + CL_LoadInventory( ui_inventoryfile->string, &client_inv ); +} + +/* +==================== +UI_ClearState +==================== +*/ +void UI_ClearState( void ) { + S_FadeSound( 0.0 ); + UI_ClearCenterPrint(); + + if( gmbox ) { + gmbox->Clear(); + } + + if( dmbox ) { + dmbox->Clear(); + } +} + +/* +==================== +UI_CheckRestart +==================== +*/ +void UI_CheckRestart( void ) { + if( ui_console->integer && !fakk_console ) + { + UIRect2D frame; + UColor bgColor; + + fakk_console = new UIFloatingConsole; + frame = getDefaultConsoleRectangle(); + + bgColor = UColor( HUD_WINDOW_COLOR ); + + fakk_console->Create( NULL, frame, "MOHAA Console", bgColor, UHudColor ); + fakk_console->setConsoleBackground( UBlack, 0.8f ); + fakk_console->setShow( false ); + fakk_console->Connect( &s_consolehider, UIFloatingWindow::W_ClosePressed, UIFloatingWindow::W_ClosePressed ); + fakk_console->Connect( &s_consolehider, W_Destroyed, W_Destroyed ); + } + + if( !dm_console ) { + dm_console = getNewDMConsole(); + } + + if( !ui_console->integer && fakk_console ) { + fakk_console->SendSignal( W_Destroyed ); + } + + if( ui_minicon->integer ) + { + if( !mini_console ) + { + UISize2D size; + UColor back = UColor( 0.0, 0.5, 1.0, 1.0 ); + + size.width = 500; + size.height = 100; + + mini_console = new FakkMiniconsole; + mini_console->Create( size, UHudColor, back, 0.3f ); + mini_console->setAlwaysOnBottom( true ); + mini_console->setBorderStyle( border_none ); + } + } + else if( mini_console ) + { + delete mini_console; + mini_console = NULL; + } + + if( ui_gmbox->integer ) + { + if( !gmbox ) + { + UIRect2D frame; + + gmbox = new UIGMBox; + frame = getDefaultGMBoxRectangle(); + + gmbox->Create( frame, UHudColor, UHudColor, 0 ); + gmbox->setAlwaysOnBottom( true ); + gmbox->setBorderStyle( border_none ); + } + } + else if( gmbox ) + { + delete gmbox; + gmbox = NULL; + } + + if( !dmbox ) + { + UIRect2D frame; + + dmbox = new UIDMBox; + frame = getDefaultDMBoxRectangle(); + + dmbox->Create( frame, UHudColor, UHudColor, 0 ); + dmbox->setAlwaysOnBottom( true ); + dmbox->setBorderStyle( border_outline ); + } + + menuManager.CheckRestart(); +} + +/* +==================== +UI_ResetCvars +==================== +*/ +void UI_ResetCvars( void ) { + menuManager.ResetCVars(); +} + +/* +==================== +UI_ShowMouse_f +==================== +*/ +void UI_ShowMouse_f( void ) { + if( view3d->IsActive() ) { + uWinMan.DeactivateCurrentControl(); + } +} + +/* +==================== +UI_HideMouse_f +==================== +*/ +void UI_HideMouse_f( void ) { + if( !view3d->IsActive() ) + { + uWinMan.ActivateControl( view3d); + IN_MouseOff(); + } +} + +class TestListItem : public UIListCtrlItem { + str strings[ 3 ]; + +public: + virtual griditemtype_t getListItemType( int which ) const; + virtual str getListItemString( int i ) const; + virtual int getListItemValue( int which ) const; + virtual void DrawListItem( int iColumn, const UIRect2D &drawRect, bool bSelected, UIFont *pFont ); + virtual qboolean IsHeaderEntry( void ) const; +}; + +/* +==================== +UI_TestListCtrl_f +==================== +*/ +void UI_TestListCtrl_f( void ) { + UIFloatingWindow *wnd = new UIFloatingWindow; + UIListCtrl *control; + UIRect2D frame = UIRect2D( 20, 20, 400, 300 ); + TestListItem *i1, *i2, *i3; + + wnd->Create( NULL, frame, "Test list control", UColor( HUD_WINDOW_COLOR ), UHudColor ); + + control = new UIListCtrl; + control->InitFrame( wnd->getChildSpace(), frame.pos.x, frame.pos.y, frame.size.width, frame.size.height, border_none, "verdana-12" ); + control->setBackgroundColor( UWhite, true ); + control->AddColumn( "name", 0, 100, false, false ); + control->AddColumn( "ping", 1, 64, false, false ); + control->AddColumn( "IP", 2, 64, false, false ); + + for( int i = 0; i < 100; i++ ) + { + i1 = new TestListItem; + control->AddItem( i1 ); + + i2 = new TestListItem; + control->AddItem( i2 ); + + i3 = new TestListItem; + control->AddItem( i3 ); + } +} + +class StatsUpdater : public Listener { +public: + CLASS_PROTOTYPE( StatsUpdater ); + + void UpdateStats( Event *ev ); +}; + +Event EV_StatsUpdater_UpdateStats; + +CLASS_DECLARATION( Listener, StatsUpdater, NULL ) +{ + { NULL, NULL } +}; + +static StatsUpdater statsUpdater; +static str loadName; + +void StatsUpdater::UpdateStats( Event *ev ) +{ + cvar_t *pMaxClients = Cvar_Get( "sv_maxclients", "1", 0 ); + + if( !com_sv_running->integer || pMaxClients->integer > 1 ) { + return; + } + + if( paused && !paused->integer ) { + CL_AddReliableCommand( "stats" ); + } + + Event *event = new Event( EV_StatsUpdater_UpdateStats ); + PostEvent( event, 2.0 ); +} + +static int statsRequestTime; +static bool intermission_stats_up; +static bool isMissionLogVisible; + +/* +==================== +UI_ShowScoreboard_f +==================== +*/ +void UI_ShowScoreboard_f( const char *pszMenuName ) { + if( pszMenuName ) + { + if( scoreboard_menuname.length() ) + { + if( str::icmp( scoreboard_menuname, pszMenuName ) ) { + scoreboard_menu->ForceHide(); + } + } + + scoreboard_menuname = pszMenuName; + } + + if( UI_MenuActive() ) + { + if( scoreboard_menuname.length() ) + { + scoreboard_menu = menuManager.FindMenu( scoreboard_menuname ); + + if( scoreboard_menu ) { + scoreboard_menu->ForceHide(); + } + } + + if( scoreboardlist && scoreboardlist->IsVisible() ) + { + scoreboardlist->setShow( false ); + } + } + else + { + if( scoreboard_menuname.length() ) + { + scoreboard_menu = menuManager.FindMenu( scoreboard_menuname ); + + if( scoreboard_menu ) + { + UIWidget *widget = scoreboard_menu->GetContainerWidget(); + if( widget ) { + widget->BringToFrontPropogated(); + } + scoreboard_menu->ForceShow(); + } + } + + if( scoreboardlist && !scoreboardlist->IsVisible() ) + { + scoreboardlist->setShow( true ); + } + } +} + +/* +==================== +UI_HideScoreboard_f +==================== +*/ +void UI_HideScoreboard_f( void ) { + if( scoreboardlist ) + { + scoreboardlist->setShow( false ); + } + + if( scoreboard_menuname.length() ) + { + scoreboard_menu->ForceHide(); + } +} + +class ScoreboardListItem : public UIListCtrlItem { + str strings[ 8 ]; + qboolean bColorSet; + UColor backColor; + UColor textColor; + qboolean bTitleItem; + +public: + ScoreboardListItem(); + + void SetListItemStrings( const char *string1, const char *string2, const char *string3, const char *string4, const char *string5, const char *string6, const char *string7, const char *string8 ); + virtual griditemtype_t getListItemType( int which ) const; + virtual str getListItemString( int i ) const; + virtual int getListItemValue( int which ) const; + virtual void DrawListItem( int iColumn, const UIRect2D &drawRect, bool bSelected, UIFont *pFont ); + void SetColors( const UColor& newTextColor, const UColor& newBackColor ); + void ClearColors( void ); + void SetTitleItem( qboolean bSet ); + virtual qboolean IsHeaderEntry( void ) const; +}; + +ScoreboardListItem::ScoreboardListItem() +{ + bColorSet = false; + bTitleItem = false; +} + +void ScoreboardListItem::DrawListItem( int iColumn, const UIRect2D& drawRect, bool bSelected, UIFont *pFont ) +{ + DrawBox( drawRect, backColor, 1.0 ); + pFont->setColor( textColor ); + pFont->Print( drawRect.pos.x + 1, drawRect.pos.y, Sys_LV_CL_ConvertString( getListItemString( iColumn ) ), iColumn, -1 ); + + if( bTitleItem ) + { + UIRect2D lineRect; + UColor lineColor = backColor; + + lineRect = drawRect; + lineRect.pos.y += lineRect.size.height - 2.0; + lineRect.size.height = 2.0; + + DrawBox( lineRect, lineColor, 1.0 ); + } +} + +void ScoreboardListItem::SetColors( const UColor& newTextColor, const UColor& newBackColor ) +{ + textColor = newTextColor; + backColor = newBackColor; + bColorSet = true; +} + +void ScoreboardListItem::ClearColors( void ) +{ + bColorSet = false; +} + +/* +==================== +UI_CreateScoreboard +==================== +*/ +void UI_CreateScoreboard( void ) { + int i; + int iColumnWidth; + float w, h, x, y; + float fColumnScale; + float fR, fG, fB, fA; + float fFontR, fFontG, fFontB, fFontA; + const char *pszColumnName; + + if( !cge ) { + return; + } + + scoreboardlist = new UIListCtrl; + cge->CG_GetScoreBoardPosition( &x, &y, &w, &h ); + scoreboard_x = x; + scoreboard_y = y; + scoreboard_w = w; + scoreboard_h = h; + + SCR_AdjustFrom640( &x, &y, &w, &h ); + fColumnScale = cls.glconfig.vidWidth / 640.0; + cge->CG_GetScoreBoardColor( &fR, &fG, &fB, &fA ); + cge->CG_GetScoreBoardFontColor( &fFontR, &fFontG, &fFontB, &fFontA ); + + scoreboardlist->InitFrame( NULL, x, y, w, h, -1, "verdana-12" ); + scoreboardlist->setBackgroundColor( UColor( fR, fG, fB, fA ), true ); + scoreboardlist->setForegroundColor( UColor( fFontR, fFontG, fFontB, fFontA ) ); + + for( i = 0; i < 8; i++ ) + { + pszColumnName = cge->CG_GetColumnName( i, &iColumnWidth ); + if( !pszColumnName ) { + break; + } + + scoreboardlist->AddColumn( pszColumnName, i, iColumnWidth * fColumnScale + 0.5, false, false ); + } + + scoreboard_header = cge->CG_GetScoreBoardDrawHeader(); + scoreboardlist->setShow( false ); + scoreboardlist->AllowActivate( false ); + scoreboardlist->setAlwaysOnBottom( true ); + scoreboardlist->SetUseScrollBar( false ); + scoreboardlist->SetDrawHeader( scoreboard_header ); + scoreboardlist->setHeaderFont( "facfont-20" ); +} + +/* +==================== +UI_SetScoreBoardItem +==================== +*/ +void UI_SetScoreBoardItem( int iItemNumber, + const char *pszData1, const char *pszData2, const char *pszData3, const char *pszData4, + const char *pszData5, const char *pszData6, const char *pszData7, const char *pszData8, + vec4_t pTextColor, vec4_t pBackColor, qboolean bIsHeader ) +{ + int i; + float x, y, w, h; + ScoreboardListItem *pItem; + + if( iItemNumber >= 64 ) { + return; + } + + if( scoreboardlist ) + { + cge->CG_GetScoreBoardPosition( &x, &y, &w, &h ); + + if( scoreboard_x == x + || scoreboard_y == y + || scoreboard_w == w + || scoreboard_h == h + || scoreboard_header != cge->CG_GetScoreBoardDrawHeader() ) + { + delete scoreboardlist; + scoreboardlist = NULL; + UI_CreateScoreboard(); + } + } + else + { + UI_CreateScoreboard(); + } + + if( scoreboardlist ) + { + if( iItemNumber + 1 > scoreboardlist->getNumItems() ) { + pItem = new ScoreboardListItem; + scoreboardlist->AddItem( pItem ); + } else { + pItem = ( ScoreboardListItem * )scoreboardlist->GetItem( iItemNumber ); + } + + if( pItem ) + { + if( !pszData1 ) { + pszData1 = ""; + } + if( !pszData2 ) { + pszData2 = ""; + } + if( !pszData3 ) { + pszData3 = ""; + } + if( !pszData4 ) { + pszData4 = ""; + } + if( !pszData5 ) { + pszData5 = ""; + } + if( !pszData6 ) { + pszData6 = ""; + } + if( !pszData7 ) { + pszData7 = ""; + } + if( !pszData8 ) { + pszData8 = ""; + } + + pItem->SetListItemStrings( pszData1, pszData2, pszData3, pszData4, pszData5, pszData6, pszData7, pszData8 ); + + if( pTextColor && pBackColor ) + { + UColor textColor, backColor; + + textColor = UColor( pTextColor[ 0 ], pTextColor[ 1 ], pTextColor[ 2 ], pTextColor[ 3 ] ); + backColor = UColor( pBackColor[ 0 ], pBackColor[ 1 ], pBackColor[ 2 ], pBackColor[ 3 ] ); + pItem->SetColors( textColor, backColor ); + } + else + { + pItem->ClearColors(); + } + + for( i = 0; i < 8; i++ ) + { + pItem->getListItemString( i ); + } + + pItem->SetTitleItem( bIsHeader ); + } + } +} + +/* +==================== +UI_DeleteScoreBoardItems +==================== +*/ +void UI_DeleteScoreBoardItems( int iMaxIndex ) { + while( iMaxIndex + 1 <= scoreboardlist->getNumItems() ) + { + scoreboardlist->DeleteItem( scoreboardlist->getNumItems() ); + } +} + +/* +==================== +UI_Hud_f +==================== +*/ +void UI_Hud_f( void ) { + qboolean hide; + + if( Cmd_Argc() != 2 ) { + Com_Printf( "Usage: ui_hud [1|0]" ); + return; + } + + ui_hud = atoi( Cmd_Argv( 1 ) ); + hide = !ui_hud; + + if( hud_weapons && hide ) + { + hud_weapons->ForceHide(); + ui_weapHudTime = 0; + } + + if( hud_items && hide ) + { + hud_items->ForceHide(); + ui_itemHudTime = 0; + } + + if( hud_health ) + { + if( hide ) { + hud_health->ForceHide(); + } else { + hud_health->ForceShow(); + } + } + if( hud_ammo ) + { + if( hide ) { + hud_ammo->ForceHide(); + } else { + hud_ammo->ForceShow(); + } + } + if( hud_compass ) + { + if( hide ) { + hud_compass->ForceHide(); + } else { + hud_compass->ForceShow(); + } + } + + if( hide ) { + UI_HideHudList(); + } else { + UI_ShowHudList(); + } + + if( ui_hud ) { + Cvar_Set( "cg_hud", "1" ); + } else { + Cvar_Set( "cg_hud", "0" ); + } +} + +/* +==================== +UI_ClearConsole_f +==================== +*/ +void UI_ClearConsole_f( void ) { + if( fakk_console ) { + fakk_console->Clear(); + } + + if( dm_console ) { + dm_console->Clear(); + } + + if( developer_console ) { + developer_console->Clear(); + } +} + +/* +==================== +CL_FinishedIntro +==================== +*/ +qboolean CL_FinishedIntro( void ) { + return !cls.startStage; +} + +/* +==================== +CL_FinishedStartStage +==================== +*/ +void CL_FinishedStartStage( void ) { + // FIXME: stub +} + +/* +==================== +UI_StartStageKeyEvent +==================== +*/ +void UI_StartStageKeyEvent( void ) { + switch( cls.startStage ) + { + case 2: + if( ui_skip_eamovie->integer ) { + SCR_StopCinematic(); + } + break; + case 12: + SCR_StopCinematic(); + break; + case 3: + case 4: + case 5: + if( ui_skip_titlescreen->integer ) + { + cls.startStage = 5; + CL_FinishedStartStage(); + } + break; + case 6: + case 7: + case 8: + if( ui_skip_legalscreen->integer ) + { + cls.startStage = 8; + CL_FinishedStartStage(); + } + break; + case 9: + case 10: + case 11: + if( ui_skip_legalscreen->integer ) + { + cls.startStage = 11; + CL_FinishedStartStage(); + } + break; + } +} + +/* +==================== +UI_StartIntro_f +==================== +*/ +void UI_StartIntro_f( void ) { + cls.startStage = 1; + IN_MouseOff(); + CL_FinishedStartStage(); +} + +/* +==================== +CL_TryStartIntro +==================== +*/ +void CL_TryStartIntro( void ) { + if( developer->integer || !cl_playintro->integer ) + { + UI_ToggleConsole(); + } + else + { + // FIXME: no intro from now + //Cvar_Set( cl_playintro->name, "0" ); + //UI_StartIntro_f(); + } +} + +/* +==================== +SaveConsoleRectangle +==================== +*/ +static void SaveConsoleRectangle( void ) { + bool wasMinimized; + UIRect2D r; + + if( !fakk_console ) { + return; + } + + wasMinimized = fakk_console->IsMinimized(); + + if( wasMinimized ) { + fakk_console->ProcessEvent( UIFloatingWindow::W_MinimizePressed ); + } + + if( !fakk_console->IsMinimized() ) { + r = fakk_console->getFrame(); + + Cvar_Set( "ui_consoleposition", va( "%d %d %d %d", r.pos.x, r.pos.y, r.size.width, r.size.height ) ); + + if( wasMinimized ) { + fakk_console->ProcessEvent( UIFloatingWindow::W_MinimizePressed ); + } + } +} + +/* +==================== +LoadConsoleRectangle +==================== +*/ +static void LoadConsoleRectangle( void ) { + bool wasMinimized; + + if( !fakk_console ) { + return; + } + + wasMinimized = fakk_console->IsMinimized(); + + if( wasMinimized ) { + fakk_console->ProcessEvent( UIFloatingWindow::W_MinimizePressed ); + } + + if( !fakk_console->IsMinimized() && wasMinimized ) { + fakk_console->ProcessEvent( UIFloatingWindow::W_MinimizePressed ); + } +} + +/* +==================== +UI_AddHud_f +==================== +*/ +void UI_AddHud_f( void ) { + Menu *hud = menuManager.FindMenu( Cmd_Argv( 1 ) ); + + if( hud ) + { + if( !hudList.ObjectInList( hud ) ) { + hudList.AddObject( hud ); + } + + hud->ShowMenu( NULL ); + } + else + { + Com_DPrintf( "Hud %s not found in menu system.\n", Cmd_Argv( 1 ) ); + } +} + +/* +==================== +UI_RemoveHud_f +==================== +*/ +void UI_RemoveHud_f( void ) { + Menu *hud = menuManager.FindMenu( Cmd_Argv( 1 ) ); + + if( hud && hudList.ObjectInList( hud ) ) + { + hud->ShowMenu( NULL ); + hudList.RemoveObject( hud ); + } +} + +/* +==================== +UI_StartServer_f +==================== +*/ +void UI_StartServer_f( void ) { + const char *map = Cmd_Argv( 1 ); + + if( strlen( map ) ) { + Cbuf_AddText( va( "map %s\n", map ) ); + } +} + +/* +==================== +UI_ShowStatistics_f +==================== +*/ +void UI_ShowStatistics_f() { + cvar_t *pMaxClients = Cvar_Get( "sv_maxclients", "1", 0 ); + + if( !com_sv_running->integer || pMaxClients->integer > 1 ) { + return; + } + + if( missionLog && !isMissionLogVisible ) + { + isMissionLogVisible = true; + missionLog->ShowMenu( NULL ); + IN_MouseOn(); + } + + if( statsRequestTime + 2000 <= cls.realtime ) + { + if( paused && !paused->integer ) + { + statsRequestTime = cls.realtime; + CL_AddReliableCommand( "stats" ); + Event *event = new Event( EV_StatsUpdater_UpdateStats ); + statsUpdater.PostEvent( event, 2.0 ); + } + } +} + +/* +==================== +UI_HideStatistics_f +==================== +*/ +void UI_HideStatistics_f() { + cvar_t *pMaxClients = Cvar_Get( "sv_maxclients", "1", 0 ); + + if( !com_sv_running->integer || pMaxClients->integer > 1 ) { + return; + } + + if( missionLog ) + { + isMissionLogVisible = false; + missionLog->HideMenu( &EV_HideMenu ); + IN_MouseOff(); + } + + statsUpdater.CancelEventsOfType( EV_StatsUpdater_UpdateStats ); +} + + +/* +==================== +CL_ShutdownUI +==================== +*/ +void CL_ShutdownUI( void ) { + if( !cls.uiStarted ) { + return; + } + + if( s_intermediateconsole ) + { + delete s_intermediateconsole; + s_intermediateconsole = NULL; + } + + // remove all UI commands + Cmd_RemoveCommand( "pushmenu" ); + Cmd_RemoveCommand( "forcemenu" ); + Cmd_RemoveCommand( "popmenu" ); + Cmd_RemoveCommand( "showmenu" ); + Cmd_RemoveCommand( "widgetcommand" ); + Cmd_RemoveCommand( "listmenus" ); + Cmd_RemoveCommand( "togglemenu" ); + Cmd_RemoveCommand( "loadmenu" ); + Cmd_RemoveCommand( "maplist" ); + Cmd_RemoveCommand( "dmmapselect" ); + Cmd_RemoveCommand( "ui_startdmmap" ); + Cmd_RemoveCommand( "viewspawnlist" ); + Cmd_RemoveCommand( "lod_spawnlist" ); + Cmd_RemoveCommand( "soundpicker" ); + Cmd_RemoveCommand( "notepad" ); + Cmd_RemoveCommand( "editscript" ); + Cmd_RemoveCommand( "editshader" ); + Cmd_RemoveCommand( "inv_restart" ); + Cmd_RemoveCommand( "ui_showmouse" ); + Cmd_RemoveCommand( "ui_hidemouse" ); + Cmd_RemoveCommand( "ui_saveconsolepos" ); + Cmd_RemoveCommand( "ui_loadconsolepos" ); + Cmd_RemoveCommand( "ui_testlist" ); + Cmd_RemoveCommand( "clear" ); + Cmd_RemoveCommand( "ui_hud" ); + Cmd_RemoveCommand( "ui_resetcvars" ); + Cmd_RemoveCommand( "ui_checkrestart" ); + Cmd_RemoveCommand( "ui_addhud" ); + Cmd_RemoveCommand( "ui_removehud" ); + Cmd_RemoveCommand( "centerprint" ); + Cmd_RemoveCommand( "locationprint" ); + Cmd_RemoveCommand( "startserver" ); + Cmd_RemoveCommand( "finishloadingscreen" ); + Cmd_RemoveCommand( "playermodel" ); + Cmd_RemoveCommand( "ui_applyplayermodel" ); + Cmd_RemoveCommand( "ui_getplayermodel" ); + Cmd_RemoveCommand( "devcon" ); + Cmd_RemoveCommand( "+statistics" ); + Cmd_RemoveCommand( "-statistics" ); + + for( int i = 0; i < hudList.NumObjects(); i++ ) { + hudList.RemoveObjectAt( i ); + } + + crosshairhud = menuManager.FindMenu( "crosshair" ); + hud_weapons = menuManager.FindMenu( "hud_weapons" ); + hud_items = menuManager.FindMenu( "hud_items" ); + hud_health = menuManager.FindMenu( "hud_health" ); + hud_compass = menuManager.FindMenu( "hud_compass" ); + hud_boss = menuManager.FindMenu( "hud_boss" ); + ui_pConnectingMenu = menuManager.FindMenu( "connecting" ); + + // delete base hud + if( view3d ) + { + delete view3d; + view3d = NULL; + } + if( fakk_console ) + { + delete fakk_console; + fakk_console = NULL; + } + if( dm_console ) + { + delete dm_console; + dm_console = NULL; + } + if( developer ) + { + delete developer; + developer = NULL; + } + if( mini_console ) + { + delete mini_console; + mini_console = NULL; + } + + // delete game hud + if( crosshairhud ) { + crosshairhud = NULL; + } + if( hud_weapons ) { + hud_weapons = NULL; + } + if( hud_items ) { + hud_items = NULL; + } + if( hud_health ) { + hud_health = NULL; + } + if( hud_ammo ) { + hud_ammo = NULL; + } + if( hud_compass ) { + hud_compass = NULL; + } + if( hud_boss ) { + hud_boss = NULL; + } + + // delete informations hud + if( scoreboardlist ) + { + delete scoreboardlist; + scoreboardlist = NULL; + } + if( gmbox ) + { + delete gmbox; + gmbox = NULL; + } + if( dmbox ) + { + delete dmbox; + dmbox = NULL; + } + + // clear inventory + client_inv.Clear(); + + // shutdown the UI + uie.Shutdown(); + + // delete all menus + menuManager.DeleteAllMenus(); + + cls.uiStarted = false; +} + +/* +==================== +CL_InitUI +==================== +*/ +#define UI_OLD_API_VERSION 4 + +void CL_InitializeUI( void ) { + int nfiles; + char **filenames; + int i; + + // Register all variables + ui_minicon = Cvar_Get( "ui_minicon", "0", 1 ); + ui_gmbox = Cvar_Get( "ui_gmbox", "1", 1 ); + ui_consoleposition = Cvar_Get( "ui_consoleposition", "", 1 ); + ui_console = Cvar_Get("ui_console", "0", 1); + ui_crosshair = Cvar_Get("ui_crosshair", "1", 1); + ui_weaponsbar = Cvar_Get("ui_weaponsbar", "1", 1); + ui_weaponsbartime = Cvar_Get("ui_weaponsbartime", "2500", 1); + ui_itemsbar = Cvar_Get("ui_itemsbar", "0", 1); + sound_overlay = Cvar_Get("soundoverlay", "0", 0); + ui_debugload = Cvar_Get("ui_debugload", "0", 0); + Cvar_Get("ui_signshader", "", 0); + ui_compass = Cvar_Get("ui_compass", "1", 0); + ui_newvidmode = Cvar_Get("ui_newvidmode", "-1", 0); + ui_inventoryfile = Cvar_Get("ui_inventoryfile", "global/inventory.txt", 0); + ui_drawcoords = Cvar_Get("ui_drawcoords", "0", 0); + ui_health_start = Cvar_Get("ui_health_start", "0", 0); + ui_health_end = Cvar_Get("ui_health_end", "0", 0); + ui_GunneryEvaluation = Cvar_Get("ui_GunneryEvaluation", "0", 0); + ui_GroinShots = Cvar_Get("ui_GroinShots", "0", 0); + ui_RightArmShots = Cvar_Get("ui_RightArmShots", "0", 0); + ui_LeftArmShots = Cvar_Get("ui_LeftArmShots", "0", 0); + ui_RightLegShots = Cvar_Get("ui_RightLegShots", "0", 0); + ui_LeftLegShots = Cvar_Get("ui_LeftLegShots", "0", 0); + ui_TorsoShots = Cvar_Get("ui_TorsoShots", "0", 0); + ui_HeadShots = Cvar_Get("ui_HeadShots", "0", 0); + ui_NumEnemysKilled = Cvar_Get("ui_NumEnemysKilled", "0", 0); + ui_NumObjectsDestroyed = Cvar_Get("ui_NumObjectsDestroyed", "0", 0); + ui_NumHitsTaken = Cvar_Get("ui_NumHitsTaken", "0", 0); + ui_PreferredWeapon = Cvar_Get("ui_PreferredWeapon", "none", 0); + ui_Accuracy = Cvar_Get("ui_Accuracy", "0", 0); + ui_NumObjectives = Cvar_Get("ui_NumObjectives", "0", 0); + ui_NumComplete = Cvar_Get("ui_NumComplete", "0", 0); + ui_NumHits = Cvar_Get("ui_NumHits", "0", 0); + ui_NumShotsFired = Cvar_Get("ui_NumShotsFired", "0", 0); + ui_gmboxspam = Cvar_Get("ui_gmboxspam", "1", 0); + ui_gotmedal = Cvar_Get("ui_gotmedal", "0", 0); + ui_success = Cvar_Get("ui_success", "0", 0); + ui_failed = Cvar_Get("ui_failed", "0", 0); + ui_returnmenu = Cvar_Get("ui_returnmenu", "0", 0); + ui_skip_eamovie = Cvar_Get("ui_skip_eamovie", "0", 0); + ui_skip_titlescreen = Cvar_Get("ui_skip_titlescreen", "1", 0); + ui_skip_legalscreen = Cvar_Get("ui_skip_legalscreen", "1", 0); + ui_titlescreen_fadein = Cvar_Get("ui_titlescreen_fadein", "1", 0); + ui_titlescreen_fadeout = Cvar_Get( "ui_titlescreen_fadeout", "1", 0 ); + ui_titlescreen_stay = Cvar_Get( "ui_titlescreen_stay", "3", 0 ); + ui_legalscreen_fadein = Cvar_Get( "ui_legalscreen_fadein", "1", 0 ); + ui_legalscreen_fadeout = Cvar_Get( "ui_legalscreen_fadeout", "1", 0 ); + ui_legalscreen_stay = Cvar_Get( "ui_legalscreen_stay", "3", 0 ); + cl_greenfps = Cvar_Get( "cl_greenfps", "0", 1 ); + cl_playintro = Cvar_Get( "cl_playintro", "1", 0 ); + cl_movieaudio = Cvar_Get( "cl_movieaudio", "1", 0 ); + Cvar_Get( "ui_startmap", "", 1 ); + Cvar_Get( "dlg_badsave", "This save game is invalid", 0 ); + + Cvar_Set( "cg_hud", ui_hud ? "1" : "0" ); + + CL_FillUIDef(); + CL_FillUIImports(); + UI_InitExports(); + uie.Init(); + + UI_LoadInventory_f(); + UI_CreateScoreboard(); + + // Add all commands + Cmd_AddCommand( "pushmenu", UI_PushMenu_f ); + Cmd_AddCommand( "pushmenu_sp", UI_PushMenuSP_f ); + Cmd_AddCommand( "pushmenu_dm", UI_PushMenuMP_f ); + Cmd_AddCommand( "forcemenu", UI_ForceMenu_f ); + Cmd_AddCommand( "popmenu", UI_PopMenu_f ); + Cmd_AddCommand( "showmenu", UI_ShowMenu_f ); + Cmd_AddCommand( "hidemenu", UI_HideMenu_f ); + Cmd_AddCommand( "widgetcommand", UI_WidgetCommand_f ); + Cmd_AddCommand( "globalwidgetcommand", UI_GlobalWidgetCommand_f ); + Cmd_AddCommand( "listmenus", UI_ListMenus_f ); + Cmd_AddCommand( "togglemenu", UI_ToggleMenu_f ); + Cmd_AddCommand( "loadmenu", UI_LoadMenu_f ); + Cmd_AddCommand( "maplist", UI_MapList_f ); + Cmd_AddCommand( "dmmapselect", UI_DMMapSelect_f ); + Cmd_AddCommand( "ui_startdmmap", UI_StartDMMap_f ); + Cmd_AddCommand( "viewspawnlist", UI_ViewSpawnList_f ); + Cmd_AddCommand( "lod_spawnlist", UI_LODSpawnList_f ); + Cmd_AddCommand( "soundpicker", UI_SoundPicker_f ); + Cmd_AddCommand( "notepad", UI_Notepad_f ); + Cmd_AddCommand( "editscript", UI_EditScript_f ); + Cmd_AddCommand( "editshader", UI_EditShader_f ); + Cmd_AddCommand( "editspecificshader", UI_EditSpecificShader_f ); + Cmd_AddCommand( "inv_restart", UI_LoadInventory_f ); + Cmd_AddCommand( "ui_showmouse", UI_ShowMouse_f ); + Cmd_AddCommand( "ui_hidemouse", UI_HideMouse_f ); + Cmd_AddCommand( "ui_saveconsolepos", SaveConsoleRectangle ); + Cmd_AddCommand( "ui_loadconsolepos", LoadConsoleRectangle ); + Cmd_AddCommand( "ui_testlist", UI_TestListCtrl_f ); + Cmd_AddCommand( "clear", UI_ClearConsole_f ); + Cmd_AddCommand( "ui_hud", UI_Hud_f ); + Cmd_AddCommand( "ui_resetcvars", UI_ResetCvars ); + Cmd_AddCommand( "ui_checkrestart", UI_CheckRestart ); + Cmd_AddCommand( "centerprint", UI_CenterPrint_f ); + Cmd_AddCommand( "locationprint", UI_LocationPrint_f ); + Cmd_AddCommand( "ui_addhud", UI_AddHud_f ); + Cmd_AddCommand( "ui_removehud", UI_RemoveHud_f ); + Cmd_AddCommand( "startserver", UI_StartServer_f ); + Cmd_AddCommand( "finishloadingscreen", UI_FinishLoadingScreen_f ); + Cmd_AddCommand( "playermodel", UI_PlayerModel_f ); + Cmd_AddCommand( "ui_applyplayermodel", UI_ApplyPlayerModel_f ); + Cmd_AddCommand( "ui_getplayermodel", UI_GetPlayerModel_f ); + Cmd_AddCommand( "+statistics", UI_ShowStatistics_f ); + Cmd_AddCommand( "-statistics", UI_HideStatistics_f ); + Cmd_AddCommand( "setreturnmenu", UI_SetReturnMenuToCurrent ); + Cmd_AddCommand( "gotoreturnmenu", UI_PushReturnMenu_f ); + + if( developer->integer ) + { + UColor bgColor; + + Cmd_AddCommand( "devcon", UI_ToggleDeveloperConsole_f ); + + developer_console = new UIFloatingConsole; + + bgColor = UColor( HUD_WINDOW_COLOR ); + + developer_console->Create( NULL, getDefaultConsoleRectangle(), "Developer Console", bgColor, UHudColor ); + developer_console->setConsoleHandler( ConsoleCommandHandler ); + developer_console->setConsoleBackground( UBlack, 0.800000011920929 ); + developer_console->setShow( false ); + developer_console->Connect( &s_consolehider, UIFloatingWindow::W_ClosePressed, UIFloatingWindow::W_ClosePressed ); + developer_console->Connect( &s_consolehider, W_Destroyed, W_Destroyed ); + } + + // Create the 3D view + view3d = new View3D; + view3d->setAlwaysOnBottom( true ); + view3d->InitFrame( NULL, 0, 0, cls.glconfig.vidWidth, cls.glconfig.vidHeight, -1, "facfont-20" ); + view3d->setName( "view3d" ); + view3d->InitSubtitle(); + + memset( &intro_stage, 0, sizeof( intro_stage ) ); + + // Register the loading material + ui_static_materials.loading = uWinMan.RegisterShader( "textures/menu/loading" ); + + if( ui_console->integer || developer->integer > 0 ) + { + UColor bgColor = UColor( HUD_WINDOW_COLOR ); + + // Create the console + fakk_console = new UIFloatingConsole; + fakk_console->Create( NULL, getDefaultConsoleRectangle(), "MOHAA Console", bgColor, UHudColor ); + fakk_console->setConsoleHandler( ConsoleCommandHandler ); + fakk_console->setConsoleBackground( UBlack, 0.8f ); + fakk_console->setShow( false ); + fakk_console->Connect( &s_consolehider, UIFloatingWindow::W_ClosePressed, UIFloatingWindow::W_ClosePressed ); + fakk_console->Connect( &s_consolehider, W_Destroyed, W_Destroyed ); + + bgColor = UColor( 0.0, 0.5, 1.0, 1.0 ); + + // Create the mini console + mini_console = new FakkMiniconsole; + mini_console->Create( UISize2D( 500, 100 ), UWhite, bgColor, 0.2f ); + mini_console->setAlwaysOnBottom( true ); + mini_console->setBorderStyle( border_none ); + } + + // Create the dm console + if( !dm_console ) { + dm_console = getNewDMConsole(); + } + + // Create the game message box + if( ui_gmbox->integer && !gmbox ) + { + gmbox = new UIGMBox; + gmbox->Create( getDefaultGMBoxRectangle(), UHudColor, UHudColor, 0.0 ); + gmbox->setAlwaysOnBottom( true ); + gmbox->setBorderStyle( border_none ); + } + + // Create the deathmatch message box + if( !dmbox ) + { + dmbox = new UIDMBox; + dmbox->Create( getDefaultDMBoxRectangle(), UHudColor, UHudColor, 0.0 ); + dmbox->setAlwaysOnBottom( true ); + dmbox->setBorderStyle( border_outline ); + } + + // Load all urc files + filenames = FS_ListFiles( "ui/", "urc", qfalse, &nfiles ); + + for( i = 0; i < nfiles; i++ ) + { + char szFilename[ MAX_QPATH ]; + + Com_sprintf( szFilename, sizeof( szFilename ), "ui/%s", filenames[ i ] ); + new UILayout( szFilename ); + } + + FS_FreeFileList( filenames ); + + uWinMan.CreateMenus(); + + // find the crosshair + crosshairhud = menuManager.FindMenu( "crosshair" ); + // find weapons hud + hud_weapons = menuManager.FindMenu( "hud_weapons" ); + // find items hud + hud_items = menuManager.FindMenu( "hud_items" ); + // find the health hud + hud_health = menuManager.FindMenu( "hud_health" ); + // find the compass hud + hud_compass = menuManager.FindMenu( "hud_compass" ); + // find the boss health hud + hud_boss = menuManager.FindMenu( "hud_boss" ); + // find the stats screen + missionLog = menuManager.FindMenu( "StatsScreen" ); + // find the connection menu + ui_pConnectingMenu = menuManager.FindMenu( "connecting" ); + + if( crosshairhud ) { + crosshairhud->ShowMenu( NULL ); + } + if( hud_health ) { + hud_health->ShowMenu( NULL ); + } + if( hud_compass ) { + hud_compass->ShowMenu( NULL ); + } + + // find the main menu + mainmenu = menuManager.FindMenu( "main" ); + + IN_MouseOn(); + + // realign menus + menuManager.RealignMenus(); + + // clear input + CL_ClearButtons(); + + cls.uiStarted = qtrue; +} + +static char **loadStrings; +static unsigned int *loadTimes; +static char *loadStringsBuffer; + +class LoadResourceInfo { +public: + class LoadResourceInfo *next; + unsigned int loadCount; + char name[ 1 ]; + +public: + LoadResourceInfo(); +}; + +static LoadResourceInfo *loadHead; + +/* +==================== +UI_BeginLoadResource +==================== +*/ +void UI_BeginLoadResource( void ) { + uint64_t time = rdtsc(); + + startCountHigh = time >> 32; + startCountLow = time; +} + +/* +==================== +UI_EndLoadResource +==================== +*/ +void UI_EndLoadResource( void ) { +} + +/* +==================== +UI_EndLoadResource +==================== +*/ +void UI_EndLoadResource( const char *name ) { + LoadResourceInfo *newLoadHead; + + if( !loadCount ) { + return; + } + + newLoadHead = ( LoadResourceInfo * )Z_Malloc( sizeof( LoadResourceInfo ) + strlen( name ) ); + newLoadHead->next = loadHead; + newLoadHead->loadCount = loadCount; + strcpy( newLoadHead->name, name ); + loadHead = newLoadHead; + + loadNumber++; + loadCountLow = 0; + loadCountHigh = 0; +} + +/* +==================== +UI_IsResourceLoaded +==================== +*/ +qboolean UI_IsResourceLoaded( const char *name ) { + switch( *name ) + { + case 97: + case 98: + case 99: + case 100: + case 101: + case 104: + return TIKI_FindTikiAnim( name + 1 ) != NULL; + case 103: + return SkeletorCacheFindFilename( name + 1, NULL ) != NULL; + case 107: + return S_IsSoundRegistered( name + 1 ); + case 110: + return R_ImageExists( name + 1 ); + default: + return qfalse; + } +} + +/* +==================== +UI_RegisterLoadResource +==================== +*/ +void UI_RegisterLoadResource( const char *name ) { + int i, j; + int low, high; + + low = 0; + high = loadNumber - 1; + + while( low <= high ) + { + i = ( high + low ) / 2; + j = strcmp( name, loadStrings[ i ] ); + + if( j >= 0 ) + { + if( j <= 0 ) + { + currentLoadTime += loadTimes[ i ]; + loadTimes[ i ] = 0; + return; + } + + low = i + 1; + } + else + { + high = i - 1; + } + } +} + +/* +==================== +UI_TestUpdateScreen +==================== +*/ +void UI_TestUpdateScreen( unsigned int timeout ) { + unsigned int newTime = Sys_Milliseconds(); + + if( newTime - lastTime >= timeout ) + { + lastTime = newTime; + Sys_PumpMessageLoop(); + SCR_UpdateScreen(); + } +} + +/* +==================== +UI_ClearResource +==================== +*/ +void UI_ClearResource( void ) { + if( cls.loading == SS_DEAD || cls.loading != SS_GAME ) { + return; + } + + UI_BeginLoadResource(); + UI_TestUpdateScreen( 0 ); +} + +/* +==================== +UI_LoadResource +==================== +*/ +void UI_LoadResource( const char *name ) { + if( cls.loading == SS_DEAD ) { + return; + } + + if( cls.loading == 3 ) + { + UI_EndLoadResource(); + UI_EndLoadResource( name ); + UI_BeginLoadResource(); + } + else if( cls.loading == 2 ) + { + UI_RegisterLoadResource( name ); + Cvar_SetValue( "loadingbar", currentLoadTime / totalLoadTime ); + } + + UI_TestUpdateScreen( 333u ); +} + +/* +==================== +UI_FreeLoadStrings +==================== +*/ +void UI_FreeLoadStrings() { + if( loadStrings ) + { + Z_Free( loadStrings ); + loadStrings = NULL; + } +} + +/* +==================== +UI_DeleteLoadInfo +==================== +*/ +void UI_DeleteLoadInfo() { + LoadResourceInfo *ptr; + LoadResourceInfo *nextPtr; + + for( ptr = loadHead; ptr != NULL; ptr = nextPtr ) + { + nextPtr = ptr->next; + Z_Free( ptr ); + } +} + +/* +==================== +UI_ParseLoadMapinfo +==================== +*/ +bool UI_ParseLoadMapinfo( Script *scr ) { + int size, index; + char *pos; + const char *token; + char *newPos; + int time; + + loadNumber = scr->GetInteger( false ); + size = scr->GetInteger( false ); + scr->SkipWhiteSpace( true ); + + loadStrings = ( char ** )Z_Malloc( size + ( sizeof( char * ) + sizeof( unsigned int ) ) * loadNumber ); + loadTimes = ( unsigned int * )( loadStrings + loadNumber ); + loadStringsBuffer = ( char * )( loadTimes + loadNumber ); + pos = ( char * )( loadTimes + loadNumber ); + + totalLoadTime = 0; + index = 0; + + do + { + token = scr->GetToken( true ); + newPos = &pos[ strlen( token ) + 1 ]; + strcpy( newPos, token ); + + time = scr->GetInteger( true ); + + if( UI_IsResourceLoaded( newPos ) ) + { + loadTimes[ index ] = 0; + } + else + { + loadTimes[ index ] = time; + totalLoadTime += time; + } + + pos = newPos; + index++; + } while( index != loadNumber ); + + if( newPos == loadStringsBuffer + size ) + { + return true; + } + else + { + UI_FreeLoadStrings(); + return false; + } +} + +/* +==================== +UI_ArchiveLoadMapinfo +==================== +*/ +bool UI_ArchiveLoadMapinfo( const char *mapname ) { + Script scr; + int version; + byte *tempbuf; + int length; + bool success; + + length = FS_ReadFile( loadName, ( void ** )&tempbuf ); + + if( length <= 0 ) { + return false; + } + + scr.LoadFile( loadName, length, ( const char * )tempbuf ); + FS_FreeFile( tempbuf ); + + version = scr.GetInteger( false ); + scr.SkipWhiteSpace( true ); + + if( version == 3 ) + { + success = UI_ParseLoadMapinfo( &scr ); + } else { + Com_Printf( "Expecting version %d map info file. Map info is version %d.\n", 3, version ); + success = false; + } + + scr.Close(); + return success; +} + +/* +==================== +UI_BeginLoad +==================== +*/ +void UI_BeginLoad( const char *pszMapName ) { + str mapfile; + + if( cls.loading ) + { + if( cls.loading == SS_GAME ) { + UI_DeleteLoadInfo(); + } + + UI_FreeLoadStrings(); + cls.loading = SS_DEAD; + } + + server_loading = qtrue; + server_loading_waiting = qfalse; + strcpy( server_mapname, pszMapName ); + + if( str::icmp( ui_sCurrentLoadingMenu, server_mapname ) ) + { + ui_sCurrentLoadingMenu = server_mapname; + ui_pLoadingMenu = menuManager.FindMenu( ui_sCurrentLoadingMenu ); + } + + if( !ui_pLoadingMenu ) + { + ui_sCurrentLoadingMenu = "loading_default"; + ui_pLoadingMenu = menuManager.FindMenu( ui_sCurrentLoadingMenu ); + } + + UI_ForceMenuOff( true ); + UI_DeactiveFloatingWindows(); + + if( !ui_pLoadingMenu ) + { + cls.loading = SS_LOADING; + + // process all events + L_ProcessPendingEvents(); + + lastTime = Sys_Milliseconds(); + + if( com_sv_running->integer ) { + SCR_UpdateScreen(); + } + return; + } + + if( !developer->integer && UI_ConsoleIsVisible() ) { + UI_CloseConsole(); + } + + ui_pLoadingMenu->PassEventToWidget( "continuebutton", new Event( EV_Widget_Disable ) ); + + loadName = "maps/"; + loadName += pszMapName; + loadName += ".min"; + mapfile = loadName + ".bsp"; + + if( UI_ArchiveLoadMapinfo( mapfile ) ) { + cls.loading = SS_LOADING2; + } else { + cls.loading = SS_GAME; + } + + if( cls.loading != SS_LOADING2 ) + { + ui_pLoadingMenu->PassEventToWidget( "loadingflasher", new Event( EV_Widget_Enable ) ); + ui_pLoadingMenu->PassEventToWidget( "loadingbar", new Event( EV_Widget_Disable ) ); + ui_pLoadingMenu->PassEventToWidget( "loadingbar_border", new Event( EV_Widget_Disable ) ); + + UI_BeginLoadResource(); + loadCountLow = 0; + loadCountHigh = 0; + loadHead = NULL; + loadNumber = 0; + } + else + { + ui_pLoadingMenu->PassEventToWidget( "loadingflasher", new Event( EV_Widget_Disable ) ); + ui_pLoadingMenu->PassEventToWidget( "loadingbar", new Event( EV_Widget_Enable ) ); + ui_pLoadingMenu->PassEventToWidget( "loadingbar_border", new Event( EV_Widget_Enable ) ); + + currentLoadTime = 0; + Cvar_SetValue( "loadingbar", 0 ); + } + + L_ProcessPendingEvents(); + lastTime = Sys_Milliseconds(); + + if( com_sv_running->integer ) { + SCR_UpdateScreen(); + } +} + +/* +==================== +UI_CompareLoadResources +==================== +*/ +int UI_CompareLoadResources( const void *elem1, const void *elem2 ) { + LoadResourceInfo *e1 = *( LoadResourceInfo ** )elem1; + LoadResourceInfo *e2 = *( LoadResourceInfo ** )elem2; + + return strcmp( e1->name, e2->name ); +} + +/* +==================== +UI_EndLoad +==================== +*/ +void UI_EndLoad( void ) { + LoadResourceInfo *ptr; + LoadResourceInfo **base; + int i; + fileHandle_t file; + int size; + char buf[ 1024 ]; + + if( !cls.loading ) { + return; + } + + UI_LoadResource( "*end" ); + + if( cls.loading == SS_GAME ) + { + base = ( LoadResourceInfo ** )Z_Malloc( loadNumber * sizeof( LoadResourceInfo * ) ); + + i = 0; + for( ptr = loadHead; ptr != NULL; ptr = ptr->next ) + { + base[ i ] = ptr; + i++; + } + + qsort( base, loadNumber, sizeof( LoadResourceInfo * ), UI_CompareLoadResources ); + + size = 0; + for( i = 0; i < loadNumber; i++ ) + { + ptr = base[ i ]; + size += strlen( ptr->name ) + 1; + } + + file = FS_FOpenFileWrite( loadName ); + sprintf( buf, "%d\n%d %d\n", 3, loadNumber, size ); + + FS_Write( buf, strlen( buf ), file ); + + for( i = 0; i < loadNumber; i++ ) + { + sprintf( buf, "%s\n%d\n", base[ i ]->name, base[ i ]->loadCount ); + FS_Write( buf, strlen( buf ), file ); + } + + FS_FCloseFile( file ); + Z_Free( base ); + UI_DeleteLoadInfo(); + } + else if( cls.loading == SS_LOADING2 ) + { + if( ui_debugload->integer ) { + Com_Printf( "Following resources not accounted for on load:\n" ); + } + + for( i = 0; i < loadNumber; i++ ) + { + if( loadTimes[ i ] ) + { + if( ui_debugload->integer ) { + Com_Printf( "%s\n", loadStrings[ i ] ); + } + + loadTimes[ i ] = 0; + } + } + + currentLoadTime = totalLoadTime; + } + + UI_FreeLoadStrings(); + + cls.loading = SS_DEAD; +} + +/* +==================== +UI_AbortLoad +==================== +*/ +void UI_AbortLoad( void ) { + if( cls.loading ) + { + if( cls.loading == SS_GAME ) { + UI_DeleteLoadInfo(); + } + cls.loading = SS_DEAD; + } +} + +/* +==================== +CL_FontStringWidth +==================== +*/ +int CL_FontStringWidth( fontheader_t *pFont, const char *pszString, int iMaxLen ) { + return uie.FontStringWidth( pFont, pszString, iMaxLen ); +} + +griditemtype_t TestListItem::getListItemType( int which ) const +{ + return TYPE_STRING; +} + +str TestListItem::getListItemString( int i ) const +{ + return strings[ i ]; +} + +int TestListItem::getListItemValue( int i ) const +{ + return atoi( strings[ i ] ); +} + +void TestListItem::DrawListItem( int iColumn, const UIRect2D &drawRect, bool bSelected, UIFont *pFont ) +{ +} + +qboolean TestListItem::IsHeaderEntry( void ) const +{ + return qfalse; +} + +void ScoreboardListItem::SetListItemStrings( const char *string1, const char *string2, const char *string3, const char *string4, const char *string5, const char *string6, const char *string7, const char *string8 ) +{ + strings[ 0 ] = string1; + strings[ 1 ] = string2; + strings[ 2 ] = string3; + strings[ 3 ] = string4; + strings[ 4 ] = string5; + strings[ 5 ] = string6; + strings[ 6 ] = string7; + strings[ 7 ] = string8; +} + +griditemtype_t ScoreboardListItem::getListItemType( int i ) const +{ + return bColorSet != 0 ? TYPE_OWNERDRAW : TYPE_STRING; +} + +str ScoreboardListItem::getListItemString( int i ) const +{ + return strings[ i ]; +} + +int ScoreboardListItem::getListItemValue( int i ) const +{ + return atoi( strings[ i ] ); +} + +void ScoreboardListItem::SetTitleItem( qboolean bSet ) +{ + bTitleItem = bSet; +} + +qboolean ScoreboardListItem::IsHeaderEntry( void ) const +{ + return bTitleItem; +} diff --git a/code/client/cl_ui.h b/code/client/cl_ui.h new file mode 100644 index 00000000..94eb2424 --- /dev/null +++ b/code/client/cl_ui.h @@ -0,0 +1,120 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UI_H__ +#define __CL_UI_H__ + +#include "ui_extern.h" +#include "uiwidget.h" + +typedef struct { + UIReggedMaterial *loading; +} static_media_t; + +// +// initialization +// +void CL_FillUIDef( void ); +void CL_InitializeUI( void ); +void CL_ShutdownUI( void ); + +// +// general ui stuff +// +extern inventory_t client_inv; +extern bind_t client_bind; + +const char *CvarGetForUI( const char *name, const char *defval ); +void UI_ClearState( void ); +void CL_BeginRegistration( void ); +void CL_EndRegistration( void ); + +// +// menu +// +extern Menu *ui_pLoadingMenu; + +void UI_ShowMenu( const char *name, qboolean bForce ); +void UI_HideMenu( const char *name, qboolean bForce ); +void UI_ForceMenuOff( bool force ); +void UI_PushMenu( const char *name ); +void UI_ForceMenu( const char *name ); +qboolean UI_BindActive( void ); +void UI_ActivateView3D( void ); +void UI_MenuEscape( const char *name ); +void UI_CreateScoreboard( void ); +qboolean UI_MenuActive( void ); +qboolean UI_MenuUp( void ); +void UI_DrawConnect( void ); +void UI_CreateDialog( const char *title, char *cvarname, const char *command, const char *cancelCommand, int width, int height, const char *shader, const char *okshader, const char *cancelshader ); +void UI_ToggleDMConsole( int iMode ); +void UI_ShowScoreboard_f( const char *pszMenuName ); +void UI_HideScoreboard_f( void ); +void UI_SetScoreBoardItem( int iItemNumber, + const char *pszData1, const char *pszData2, const char *pszData3, const char *pszData4, + const char *pszData5, const char *pszData6, const char *pszData7, const char *pszData8, + vec4_t pTextColor, vec4_t pBackColor, qboolean bIsHeader ); +void UI_DeleteScoreBoardItems( int iMaxIndex ); + +// +// ressources +// +void UI_BeginLoad( const char *pszMapName ); +void UI_EndLoad( void ); +void UI_AbortLoad( void ); +void UI_BeginLoadResource( void ); +void UI_EndLoadResource( void ); +void UI_EndLoadResource( const char *name ); +qboolean UI_IsResourceLoaded( const char *name ); +void UI_RegisterLoadResource( const char *name ); +void UI_ClearResource( void ); +void UI_LoadResource( const char *name ); + +// +// windows +// +void UI_DeactiveFloatingWindows( void ); + +// +// console +// +void UI_OpenConsole( void ); +qboolean UI_ConsoleIsVisible( void ); +qboolean UI_ConsoleIsOpen( void ); +void UI_CloseConsole( void ); +void UI_ToggleConsole( void ); +void UI_OpenDMConsole( int iMode ); +void UI_CloseDMConsole( void ); +void UI_ToggleDMConsole( int iMode ); +void UI_OpenDeveloperConsole( void ); +void UI_CloseDeveloperConsole( void ); + +// +// callbacks +// +void UI_Update( void ); +void UI_ServerLoaded( void ); +void UI_ResolutionChange( void ); +void UI_KeyEvent( int key, unsigned int time ); +void UI_CharEvent( int ch ); + +#endif /* __CL_UI_H__ */ diff --git a/code/client/cl_uibind.cpp b/code/client/cl_uibind.cpp new file mode 100644 index 00000000..22ae1e58 --- /dev/null +++ b/code/client/cl_uibind.cpp @@ -0,0 +1,304 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +bind_t::bind_t() +{ + // FIXME: stub +} + +bind_t::~bind_t() +{ + Clear(); +} + +void bind_t::Clear + ( + void + ) + +{ + // FIXME: stub +} + +CLASS_DECLARATION( Listener, bindlistener, NULL ) +{ + { NULL, NULL } +}; + +bindlistener::bindlistener() +{ +} + +bindlistener::bindlistener + ( + bind_t *b + ) + +{ + bind = b; +} + +bool bindlistener::Load + ( + Script& script + ) + +{ + // FIXME: stub + return false; +} + +void bindlistener::Header + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::Width + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::FillWidth + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::Height + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::CommandWidth + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::CommandHeight + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::PrimaryKeyWidth + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::PrimaryKeyHeight + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::AlternateKeyWidth + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::AlternateKeyHeight + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::NewItem + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::Align + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::TitleForegroundColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::TitleBackgroundColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::InactiveForegroundColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::InactiveBackgroundColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::ActiveForegroundColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::ActiveBackgroundColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::ActiveBorderColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::HighlightForegroundColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::HighlightBackgroundColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::SelectForegroundColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::SelectBackgroundColor + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::ChangeSound + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::ActiveSound + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void bindlistener::EnterSound + ( + Event *ev + ) + +{ + // FIXME: stub +} diff --git a/code/client/cl_uibind.h b/code/client/cl_uibind.h new file mode 100644 index 00000000..a1a3a41b --- /dev/null +++ b/code/client/cl_uibind.h @@ -0,0 +1,134 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UIBIND_H__ +#define __CL_UIBIND_H__ + +class bind_item_t { +public: + str name; + str command; + UIReggedMaterial *nameMaterial; + + bind_item_t(); + bind_item_t( str name, str command, UIReggedMaterial *nameMaterial ); +}; + +inline +bind_item_t::bind_item_t() +{ + nameMaterial = NULL; +} + +inline +bind_item_t::bind_item_t + ( + str name, + str command, + UIReggedMaterial *nameMaterial + ) + +{ + this->name = name; + this->command = command; + this->nameMaterial = nameMaterial; +} + +class bind_t { +public: + int width; + int height; + int fillwidth; + int commandwidth; + int commandheight; + int primarykeywidth; + int primarykeyheight; + int alternatekeywidth; + int alternatekeyheight; + int align; + UColor titlebgcolor; + UColor titlefgcolor; + UColor activefgcolor; + UColor activebgcolor; + UColor activebordercolor; + UColor inactivefgcolor; + UColor inactivebgcolor; + UColor highlightfgcolor; + UColor highlightbgcolor; + UColor selectfgcolor; + UColor selectbgcolor; + str changesound; + str activesound; + str entersound; + str headers[ 3 ]; + UIReggedMaterial *headermats[ 3 ]; + UIReggedMaterial *fillmaterial; + Container binds; + +public: + bind_t(); + ~bind_t(); + + void Clear( void ); +}; + +class bindlistener : public Listener { +protected: + bind_t *bind; + +public: + CLASS_PROTOTYPE( bindlistener ); + +public: + bindlistener(); + bindlistener( bind_t *b ); + + bool Load( Script& script ); + void Header( Event *ev ); + void Width( Event *ev ); + void FillWidth( Event *ev ); + void Height( Event *ev ); + void CommandWidth( Event *ev ); + void CommandHeight( Event *ev ); + void PrimaryKeyWidth( Event *ev ); + void PrimaryKeyHeight( Event *ev ); + void AlternateKeyWidth( Event *ev ); + void AlternateKeyHeight( Event *ev ); + void NewItem( Event *ev ); + void Align( Event *ev ); + void TitleForegroundColor( Event *ev ); + void TitleBackgroundColor( Event *ev ); + void InactiveForegroundColor( Event *ev ); + void InactiveBackgroundColor( Event *ev ); + void ActiveForegroundColor( Event *ev ); + void ActiveBackgroundColor( Event *ev ); + void ActiveBorderColor( Event *ev ); + void HighlightForegroundColor( Event *ev ); + void HighlightBackgroundColor( Event *ev ); + void SelectForegroundColor( Event *ev ); + void SelectBackgroundColor( Event *ev ); + void ChangeSound( Event *ev ); + void ActiveSound( Event *ev ); + void EnterSound( Event *ev ); +}; + +#endif diff --git a/code/client/cl_uidmbox.cpp b/code/client/cl_uidmbox.cpp new file mode 100644 index 00000000..fcadb741 --- /dev/null +++ b/code/client/cl_uidmbox.cpp @@ -0,0 +1,121 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( UIWidget, UIDMBox, NULL ) +{ + { NULL, NULL } +}; + +void UIDMBox::VerifyBoxOut( void ) +{ + // FIXME: stub +} + +void UIDMBox::ChangeBoxState( boxstate_t state ) +{ + // FIXME: stub +} + +void UIDMBox::HandleBoxMoving( void ) +{ + // FIXME: stub +} + +void UIDMBox::PostMoveinEvent( void ) +{ + // FIXME: stub +} + +void UIDMBox::PostDecayEvent( void ) +{ + // FIXME: stub +} + +void UIDMBox::setShowState( void ) +{ + // FIXME: stub +} + +void UIDMBox::RemoveTopItem( void ) +{ + // FIXME: stub +} + +str UIDMBox::CalculateBreaks( UIFont *font, str text, float max_width ) +{ + // FIXME: stub + return ""; +} + +float UIDMBox::PrintWrap( UIFont *font, float x, float y, str text ) +{ + // FIXME: stub + return 0.0f; +} + +float UIDMBox::DrawItem( item_t *in, float x, float y, float alpha ) +{ + // FIXME: stub + return 0.0f; +} + +void UIDMBox::Print( const char *text ) +{ + // FIXME: stub +} + +void UIDMBox::OnSizeChanged( Event *ev ) +{ + // FIXME: stub +} + +void UIDMBox::Create( const UIRect2D& rect, const UColor& fore, const UColor& back, float alpha ) +{ + // FIXME: stub +} + +void UIDMBox::MoveInEvent( Event *ev ) +{ + // FIXME: stub +} + +void UIDMBox::DecayEvent( Event *ev ) +{ + // FIXME: stub +} + +void UIDMBox::Draw( void ) +{ + // FIXME: stub +} + +void UIDMBox::setRealShow( bool b ) +{ + // FIXME: stub +} + +void UIDMBox::Clear( void ) +{ + // FIXME: stub +} diff --git a/code/client/cl_uidmbox.h b/code/client/cl_uidmbox.h new file mode 100644 index 00000000..418bf1a0 --- /dev/null +++ b/code/client/cl_uidmbox.h @@ -0,0 +1,67 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UIDMBOX_H__ +#define __CL_UIDMBOX_H__ + +typedef enum { box_moving_out, box_moving_in, box_out, box_in } boxstate_t; + +class UIDMBox : public UIWidget { +protected: + item_t m_items[ 10 ]; + int m_numitems; + bool m_reallyshown; + UIFont *m_fontbold; + bool m_boxmovingout; + boxstate_t m_boxstate; + int m_boxtime; + int m_movespeed; + int m_iBeginDecay; + int m_iEndDecay; + +public: + CLASS_PROTOTYPE( UIDMBox ); + +protected: + void VerifyBoxOut( void ); + void ChangeBoxState( boxstate_t state ); + void HandleBoxMoving( void ); + void PostMoveinEvent( void ); + void PostDecayEvent( void ); + void setShowState( void ); + void RemoveTopItem( void ); + str CalculateBreaks( UIFont *font, str text, float max_width ); + float PrintWrap( UIFont *font, float x, float y , str text ); + float DrawItem( item_t *in, float x, float y, float alpha ); + +public: + void Print( const char *text ); + void OnSizeChanged( Event *ev ); + void Create( const UIRect2D& rect, const UColor& fore, const UColor& back, float alpha ); + void MoveInEvent( Event *ev ); + void DecayEvent( Event *ev ); + void Draw( void ); + void setRealShow( bool b ); + void Clear( void ); +}; + +#endif /* __CL_UIDMBOX_H__ */ diff --git a/code/client/cl_uifilepicker.cpp b/code/client/cl_uifilepicker.cpp new file mode 100644 index 00000000..9ccadb61 --- /dev/null +++ b/code/client/cl_uifilepicker.cpp @@ -0,0 +1,93 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( USignal, FilePickerClass, NULL ) +{ + { NULL, NULL } +}; + +FilePickerClass::FilePickerClass() +{ + // FIXME: stub +} + +FilePickerClass::~FilePickerClass() +{ + // FIXME: stub +} + +void FilePickerClass::SetupFiles( void ) +{ + // FIXME: stub +} + +void FilePickerClass::GotoParentDirectory( void ) +{ + // FIXME: stub +} + +void FilePickerClass::GotoSubDirectory( str subdir ) +{ + // FIXME: stub +} + +void FilePickerClass::Initialize( const char *root_directory, const char *current_directory, const char *ext ) +{ + // FIXME: stub +} + +void FilePickerClass::CloseWindow( void ) +{ + // FIXME: stub +} + +void FilePickerClass::FileSelected( Event *ev ) +{ + // FIXME: stub +} + +void FilePickerClass::FileSelected( str ¤tDirectory, str &partialName, str &fullname ) +{ + // FIXME: stub +} + +void FilePickerClass::FileChosen( Event *ev ) +{ + // FIXME: stub +} + +void FilePickerClass::FileChosen( str ¤tDirectory, str &partialName, str &fullname ) +{ + // FIXME: stub +} + +void FilePickerClass::OnDeactivated( Event *ev ) +{ + // FIXME: stub +} + +void FilePickerClass::Setup( const char *root_directory, const char *current_directory, const char *ext ) +{ + // FIXME: stub +} diff --git a/code/client/cl_uifilepicker.h b/code/client/cl_uifilepicker.h new file mode 100644 index 00000000..db726ea4 --- /dev/null +++ b/code/client/cl_uifilepicker.h @@ -0,0 +1,59 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UIFILEPICKER_H__ +#define __CL_UIFILEPICKER_H__ + +class UIListCtrl; + +class FilePickerClass : public USignal { + UIFloatingWindow *window; + UIListCtrl *listbox; + str currentDirectory; + str rootDirectory; + str extension; + +public: + CLASS_PROTOTYPE( FilePickerClass ); + +private: + void SetupFiles( void ); + void GotoParentDirectory( void ); + void GotoSubDirectory( str subdir ); + void Initialize( const char *root_directory, const char *current_directory, const char *ext ); + +protected: + void CloseWindow( void ); + void FileSelected( Event *ev ); + virtual void FileSelected( str ¤tDirectory, str &partialName, str &fullname ); + void FileChosen( Event *ev ); + virtual void FileChosen( str ¤tDirectory, str &partialName, str &fullname ); + void OnDeactivated( Event *ev ); + +public: + FilePickerClass(); + ~FilePickerClass(); + + void Setup( const char *root_directory, const char *current_directory, const char *ext ); +}; + +#endif /* __CL_UIFILEPICKER_H__ */ diff --git a/code/client/cl_uigmbox.cpp b/code/client/cl_uigmbox.cpp new file mode 100644 index 00000000..0d635511 --- /dev/null +++ b/code/client/cl_uigmbox.cpp @@ -0,0 +1,127 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( UIWidget, UIGMBox, NULL ) +{ + { NULL, NULL } +}; + +UIGMBox::UIGMBox() +{ + // FIXME: stub +} + +void UIGMBox::VerifyBoxOut( void ) +{ + // FIXME: stub +} + +void UIGMBox::ChangeBoxState( boxstate_t state ) +{ + // FIXME: stub +} + +void UIGMBox::HandleBoxMoving( void ) +{ + // FIXME: stub +} + +void UIGMBox::PostMoveinEvent( void ) +{ + // FIXME: stub +} + +void UIGMBox::PostDecayEvent( void ) +{ + // FIXME: stub +} + +void UIGMBox::setShowState( void ) +{ + // FIXME: stub +} + +void UIGMBox::RemoveTopItem( void ) +{ + // FIXME: stub +} + +str UIGMBox::CalculateBreaks( UIFont *font, str text, float max_width ) +{ + // FIXME: stub + return ""; +} + +float UIGMBox::PrintWrap( UIFont *font, float x, float y, str text ) +{ + // FIXME: stub + return 0.0f; +} + +float UIGMBox::DrawItem( item_t *in, float x, float y, float alpha ) +{ + // FIXME: stub + return 0.0f; +} + +void UIGMBox::Print( const char *text ) +{ + // FIXME: stub +} + +void UIGMBox::OnSizeChanged( Event *ev ) +{ + // FIXME: stub +} + +void UIGMBox::Create( const UIRect2D& rect, const UColor& fore, const UColor& back, float alpha ) +{ + // FIXME: stub +} + +void UIGMBox::MoveInEvent( Event *ev ) +{ + // FIXME: stub +} + +void UIGMBox::DecayEvent( Event *ev ) +{ + // FIXME: stub +} + +void UIGMBox::Draw( void ) +{ + // FIXME: stub +} + +void UIGMBox::setRealShow( bool b ) +{ + // FIXME: stub +} + +void UIGMBox::Clear( void ) +{ + // FIXME: stub +} + diff --git a/code/client/cl_uigmbox.h b/code/client/cl_uigmbox.h new file mode 100644 index 00000000..93bba2e0 --- /dev/null +++ b/code/client/cl_uigmbox.h @@ -0,0 +1,67 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UIGMBOX_H__ +#define __CL_UIGMBOX_H__ + +class UIGMBox : public UIWidget { +protected: + item_t m_items[ 5 ]; + int m_numitems; + bool m_reallyshown; + class UIFont *m_fontbold; + bool m_boxmovingout; + boxstate_t m_boxstate; + int m_boxtime; + int m_movespeed; + int m_iBeginDecay; + int m_iEndDecay; + +public: + CLASS_PROTOTYPE( UIGMBox ); + +protected: + void VerifyBoxOut( void ); + void ChangeBoxState( boxstate_t state ); + void HandleBoxMoving( void ); + void PostMoveinEvent( void ); + void PostDecayEvent( void ); + void setShowState( void ); + void RemoveTopItem( void ); + str CalculateBreaks( UIFont *font, str text, float max_width ); + float PrintWrap( UIFont *font, float x, float y, str text ); + float DrawItem( item_t *in, float x, float y, float alpha ); + +public: + UIGMBox(); + + void Print( const char *text ); + void OnSizeChanged( Event *ev ); + void Create( const UIRect2D& rect, const UColor& fore, const UColor& back, float alpha ); + void MoveInEvent( Event *ev ); + void DecayEvent( Event *ev ); + void Draw( void ); + void setRealShow( bool b ); + void Clear( void ); +}; + +#endif diff --git a/code/client/cl_uilangame.cpp b/code/client/cl_uilangame.cpp new file mode 100644 index 00000000..70d788d2 --- /dev/null +++ b/code/client/cl_uilangame.cpp @@ -0,0 +1,64 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( UIListCtrl, UILANGameClass, NULL ) +{ + { NULL, NULL } +}; + +UILANGameClass::UILANGameClass() +{ + // FIXME: stub +} + +void UILANGameClass::SetupServers( void ) +{ + // FIXME: stub +} + +void UILANGameClass::Draw( void ) +{ + // FIXME: stub +} + +void UILANGameClass::SelectServer( Event *ev ) +{ + // FIXME: stub +} + +void UILANGameClass::JoinServer( Event *ev ) +{ + // FIXME: stub +} + +qboolean UILANGameClass::KeyEvent( int key, unsigned int time ) +{ + // FIXME: stub + return qfalse; +} + +void UILANGameClass::UpdateUIElement( void ) +{ + // FIXME: stub +} diff --git a/code/client/cl_uilangame.h b/code/client/cl_uilangame.h new file mode 100644 index 00000000..9c4a44eb --- /dev/null +++ b/code/client/cl_uilangame.h @@ -0,0 +1,48 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UILANGAME_H__ +#define __CL_UILANGAME_H__ + +class UILANGameClass : public UIListCtrl { +protected: + int m_iLastUpdateTime; + UIReggedMaterial *m_noservers_mat; + +public: + CLASS_PROTOTYPE( UILANGameClass ); + +private: + void SetupServers( void ); + +protected: + void Draw( void ); + void SelectServer( Event *ev ); + void JoinServer( Event *ev ); + qboolean KeyEvent( int key, unsigned int time ); + void UpdateUIElement( void ); + +public: + UILANGameClass(); +}; + +#endif /* __CL_UILANGAME_H__ */ diff --git a/code/client/cl_uiloadsave.cpp b/code/client/cl_uiloadsave.cpp new file mode 100644 index 00000000..f0e9c9f1 --- /dev/null +++ b/code/client/cl_uiloadsave.cpp @@ -0,0 +1,83 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( UIListCtrl, UIFAKKLoadGameClass, NULL ) +{ + { NULL, NULL } +}; + +UIFAKKLoadGameClass::UIFAKKLoadGameClass() +{ + // FIXME: stub +} + +void UIFAKKLoadGameClass::SelectGame( Event *ev ) +{ + // FIXME: stub +} + +void UIFAKKLoadGameClass::LoadGame( Event *ev ) +{ + // FIXME: stub +} + +void UIFAKKLoadGameClass::SaveGame( Event *ev ) +{ + // FIXME: stub +} + +void UIFAKKLoadGameClass::RemoveGame( Event *ev ) +{ + // FIXME: stub +} + +void UIFAKKLoadGameClass::DeleteGame( Event *ev ) +{ + // FIXME: stub +} + +void UIFAKKLoadGameClass::NoDeleteGame( Event *ev ) +{ + // FIXME: stub +} + +qboolean UIFAKKLoadGameClass::KeyEvent( int key, unsigned int time ) +{ + // FIXME: stub + return qfalse; +} + +void UIFAKKLoadGameClass::UpdateUIElement( void ) +{ + // FIXME: stub +} + +void UIFAKKLoadGameClass::SetupFiles( void ) +{ + // FIXME: stub +} + +void UI_SetupFiles( void ) { + // FIXME: stub +} diff --git a/code/client/cl_uiloadsave.h b/code/client/cl_uiloadsave.h new file mode 100644 index 00000000..8d42c42c --- /dev/null +++ b/code/client/cl_uiloadsave.h @@ -0,0 +1,57 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UILOADSAVE_H__ +#define __CL_UILOADSAVE_H__ + +class UIFAKKLoadGameClass : public UIListCtrl { + bool m_bRemovePending; + +public: + CLASS_PROTOTYPE( UIFAKKLoadGameClass ); + +protected: + void SelectGame( Event *ev ); + void LoadGame( Event *ev ); + void SaveGame( Event *ev ); + void RemoveGame( Event *ev ); + void DeleteGame( Event *ev ); + void NoDeleteGame( Event *ev ); + qboolean KeyEvent( int key, unsigned int time ); + void UpdateUIElement( void ); +public: + UIFAKKLoadGameClass(); + + void SetupFiles( void ); +}; + +#ifdef __cplusplus +extern "C" { +#endif + +void UI_SetupFiles( void ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/code/client/cl_uimaprunner.cpp b/code/client/cl_uimaprunner.cpp new file mode 100644 index 00000000..11f33873 --- /dev/null +++ b/code/client/cl_uimaprunner.cpp @@ -0,0 +1,68 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( FilePickerClass, MapRunnerClass, NULL ) +{ + { NULL, NULL } +}; + +void MapRunnerClass::FileChosen( str ¤tDirectory, str &partialName, str &fullname ) +{ + // FIXME: stub +} + +CLASS_DECLARATION( FilePickerClass, ViewSpawnerClass, NULL ) +{ + { NULL, NULL } +}; + +void ViewSpawnerClass::FileChosen( str ¤tDirectory, str &partialName, str &fullname ) +{ + // FIXME: stub +} + +CLASS_DECLARATION( FilePickerClass, LODSpawnerClass, NULL ) +{ + { NULL, NULL } +}; + +void LODSpawnerClass::FileChosen( str ¤tDirectory, str &partialName, str &fullname ) +{ + // FIXME: stub +} + +CLASS_DECLARATION( FilePickerClass, UIPickFileClass, NULL ) +{ + { NULL, NULL } +}; + +void UIPickFileClass::FileChosen( str ¤tDirectory, str &partialName, str &fullname ) +{ + // FIXME: stub +} + +void PickFile( const char *name, Listener *obj, Event& event ) +{ + // FIXME: stub +} diff --git a/code/client/cl_uimaprunner.h b/code/client/cl_uimaprunner.h new file mode 100644 index 00000000..4bb30390 --- /dev/null +++ b/code/client/cl_uimaprunner.h @@ -0,0 +1,59 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UIMAPRUNNER_H__ +#define __CL_UIMAPRUNNER_H__ + +class MapRunnerClass : public FilePickerClass { +public: + CLASS_PROTOTYPE( MapRunnerClass ); + + void FileChosen( str ¤tDirectory, str &partialName, str &fullname ); +}; + +class ViewSpawnerClass : public FilePickerClass { +public: + CLASS_PROTOTYPE( ViewSpawnerClass ); + + void FileChosen( str ¤tDirectory, str &partialName, str &fullname ); +}; + +class LODSpawnerClass : public FilePickerClass { +public: + CLASS_PROTOTYPE( LODSpawnerClass ); + + void FileChosen( str ¤tDirectory, str &partialName, str &fullname ); +}; + +class UIPickFileClass : public FilePickerClass { +public: + Listener *retobj; + Event *retevent; + + CLASS_PROTOTYPE( UIPickFileClass ); + + void FileChosen( str ¤tDirectory, str &partialName, str &fullname ); +}; + +void PickFile( const char *name, Listener *obj, Event& event ); + +#endif /* __CL_UIMAPRUNNER_H__ */ diff --git a/code/client/cl_uiminicon.cpp b/code/client/cl_uiminicon.cpp new file mode 100644 index 00000000..dcfbce1a --- /dev/null +++ b/code/client/cl_uiminicon.cpp @@ -0,0 +1,89 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( UIWidget, FakkMiniconsole, NULL ) +{ + { NULL, NULL } +}; + +FakkMiniconsole::FakkMiniconsole() +{ + // FIXME: stub +} + + +void FakkMiniconsole::VerifyBoxOut( void ) +{ + // FIXME: stub +} + +void FakkMiniconsole::ChangeBoxState( boxstate_t state ) +{ + // FIXME: stub +} + +void FakkMiniconsole::HandleBoxMoving( void ) +{ + // FIXME: stub +} + +void FakkMiniconsole::PostMoveinEvent( void ) +{ + // FIXME: stub +} + +void FakkMiniconsole::setShowState( void ) +{ + // FIXME: stub +} + +void FakkMiniconsole::OnSizeChanged( Event *ev ) +{ + // FIXME: stub +} + +void FakkMiniconsole::Print( const char *text ) +{ + // FIXME: stub +} + +void FakkMiniconsole::Create( const UISize2D& size, const UColor& fore, const UColor& back, float alpha ) +{ + // FIXME: stub +} + +void FakkMiniconsole::MoveInEvent( Event *ev ) +{ + // FIXME: stub +} + +void FakkMiniconsole::Draw( void ) +{ + // FIXME: stub +} + +void FakkMiniconsole::setRealShow( bool b ) +{ + // FIXME: stub +} diff --git a/code/client/cl_uiminicon.h b/code/client/cl_uiminicon.h new file mode 100644 index 00000000..84f84fd0 --- /dev/null +++ b/code/client/cl_uiminicon.h @@ -0,0 +1,57 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UIMINICON_H__ +#define __CL_UIMINICON_H__ + +class FakkMiniconsole : public UIWidget { +protected: + Container m_lines; + int m_maxlines; + bool m_reallyshown; + bool m_boxmovingout; + boxstate_t m_boxstate; + int m_boxtime; + int m_movespeed; + +public: + CLASS_PROTOTYPE( FakkMiniconsole ); + +protected: + void VerifyBoxOut( void ); + void ChangeBoxState( boxstate_t state ); + void HandleBoxMoving( void ); + void PostMoveinEvent( void ); + void setShowState( void ); + +public: + FakkMiniconsole(); + + void OnSizeChanged( Event *ev ); + void Print( const char *text ); + void Create( const UISize2D& size, const UColor& fore, const UColor& back, float alpha ); + void MoveInEvent( Event *ev ); + void Draw( void ); + void setRealShow( bool b ); +}; + +#endif diff --git a/code/client/cl_uimpmappicker.cpp b/code/client/cl_uimpmappicker.cpp new file mode 100644 index 00000000..2db4ac26 --- /dev/null +++ b/code/client/cl_uimpmappicker.cpp @@ -0,0 +1,93 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( USignal, MpMapPickerClass, NULL ) +{ + { NULL, NULL } +}; + +MpMapPickerClass::MpMapPickerClass() +{ + // FIXME: stub +} + +MpMapPickerClass::~MpMapPickerClass() +{ + // FIXME: stub +} + +void MpMapPickerClass::SetupFiles( void ) +{ + // FIXME: stub +} + +void MpMapPickerClass::GotoParentDirectory( void ) +{ + // FIXME: stub +} + +void MpMapPickerClass::GotoSubDirectory( str subdir ) +{ + // FIXME: stub +} + +void MpMapPickerClass::Initialize( const char *root_directory, const char *current_directory ) +{ + // FIXME: stub +} + +void MpMapPickerClass::CloseWindow( void ) +{ + // FIXME: stub +} + +void MpMapPickerClass::FileSelected( Event *ev ) +{ + // FIXME: stub +} + +void MpMapPickerClass::FileSelected( str& currentDirectory, str& partialName, str& fullname ) +{ + // FIXME: stub +} + +void MpMapPickerClass::FileChosen( Event *ev ) +{ + // FIXME: stub +} + +void MpMapPickerClass::FileChosen( str& currentDirectory, str& partialName, str& fullname ) +{ + // FIXME: stub +} + +void MpMapPickerClass::OnDeactivated( Event *ev ) +{ + // FIXME: stub +} + +void MpMapPickerClass::Setup( const char *root_directory, const char *current_directory ) +{ + // FIXME: stub +} diff --git a/code/client/cl_uimpmappicker.h b/code/client/cl_uimpmappicker.h new file mode 100644 index 00000000..cfc85e64 --- /dev/null +++ b/code/client/cl_uimpmappicker.h @@ -0,0 +1,58 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UIMPMAPPICKER_H__ +#define __CL_UIMPMAPPICKER_H__ + +class UIFloatingWindow; + +class MpMapPickerClass : public USignal { + UIFloatingWindow *window; + UIListCtrl *listbox; + str currentDirectory; + str rootDirectory; + +public: + CLASS_PROTOTYPE( MpMapPickerClass ); + +private: + void SetupFiles( void ); + void GotoParentDirectory( void ); + void GotoSubDirectory( str subdir ); + void Initialize( const char *root_directory, const char *current_directory ); + +protected: + void CloseWindow( void ); + void FileSelected( Event *ev ); + virtual void FileSelected( str& currentDirectory, str& partialName, str& fullname ); + void FileChosen( Event *ev ); + virtual void FileChosen( str& currentDirectory, str& partialName, str& fullname ); + void OnDeactivated( Event *ev ); + +public: + MpMapPickerClass(); + ~MpMapPickerClass(); + + void Setup( const char *root_directory, const char *current_directory ); +}; + +#endif /* __CL_UIMPMAPPICKER_H__ */ diff --git a/code/client/cl_uiplayermodelpicker.cpp b/code/client/cl_uiplayermodelpicker.cpp new file mode 100644 index 00000000..6aa7b336 --- /dev/null +++ b/code/client/cl_uiplayermodelpicker.cpp @@ -0,0 +1,83 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( USignal, PlayerModelPickerClass, NULL ) +{ + { NULL, NULL } +}; + +PlayerModelPickerClass::PlayerModelPickerClass() +{ + // FIXME: stub +} + +PlayerModelPickerClass::~PlayerModelPickerClass() +{ + // FIXME: stub +} + +void PlayerModelPickerClass::SetupFiles( void ) +{ + // FIXME: stub +} + +void PlayerModelPickerClass::Initialize( const char *root_directory, const char *current_directory, qboolean bGermanModels ) +{ + // FIXME: stub +} + +void PlayerModelPickerClass::CloseWindow( void ) +{ + // FIXME: stub +} + +void PlayerModelPickerClass::FileSelected( Event *ev ) +{ + // FIXME: stub +} + +void PlayerModelPickerClass::FileSelected( str& currentDirectory, str& partialName, str& fullname ) +{ + // FIXME: stub +} + +void PlayerModelPickerClass::FileChosen( Event *ev ) +{ + // FIXME: stub +} + +void PlayerModelPickerClass::FileChosen( str& currentDirectory, str& partialName, str& fullname ) +{ + // FIXME: stub +} + +void PlayerModelPickerClass::OnDeactivated( Event *ev ) +{ + // FIXME: stub +} + +void PlayerModelPickerClass::Setup( const char *root_directory, const char *current_directory, qboolean bGermanModels ) +{ + // FIXME: stub +} diff --git a/code/client/cl_uiplayermodelpicker.h b/code/client/cl_uiplayermodelpicker.h new file mode 100644 index 00000000..d33f53e4 --- /dev/null +++ b/code/client/cl_uiplayermodelpicker.h @@ -0,0 +1,56 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UIPLAYERMODELPICKER_H__ +#define __CL_UIPLAYERMODELPICKER_H__ + +class UIFloatingWindow; + +class PlayerModelPickerClass : public USignal { + UIFloatingWindow *window; + UIListCtrl *listbox; + str currentDirectory; + str rootDirectory; + qboolean m_bGermanModels; +public: + CLASS_PROTOTYPE( PlayerModelPickerClass ); + +private: + void SetupFiles( void ); + void Initialize( const char *root_directory, const char *current_directory, qboolean bGermanModels ); + +protected: + void CloseWindow( void ); + void FileSelected( Event *ev ); + virtual void FileSelected( str& currentDirectory, str& partialName, str& fullname ); + void FileChosen( Event *ev ); + virtual void FileChosen( str& currentDirectory, str& partialName, str& fullname ); + void OnDeactivated( Event *ev ); + +public: + PlayerModelPickerClass(); + ~PlayerModelPickerClass(); + + void Setup( const char *root_directory, const char *current_directory, qboolean bGermanModels ); +}; + +#endif /* __CL_UIPLAYERMODELPICKER_H__ */ diff --git a/code/client/cl_uiserverlist.cpp b/code/client/cl_uiserverlist.cpp new file mode 100644 index 00000000..d1bf928e --- /dev/null +++ b/code/client/cl_uiserverlist.cpp @@ -0,0 +1,100 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( UIListCtrl, UIFAKKServerList, NULL ) +{ + { NULL, NULL } +}; + +UIFAKKServerList::UIFAKKServerList() +{ + // FIXME: stub +} + +void UIFAKKServerList::SelectServer( Event *ev ) +{ + // FIXME: stub +} + +void UIFAKKServerList::ConnectServer( Event *ev ) +{ + // FIXME: stub +} + +qboolean UIFAKKServerList::KeyEvent( int key, unsigned int time ) +{ + // FIXME: stub + return qfalse; +} + +void UIFAKKServerList::UpdateUIElement( void ) +{ + // FIXME: stub +} + +void UIFAKKServerList::RefreshServerList( Event *ev ) +{ + // FIXME: stub +} + +void UIFAKKServerList::RefreshLANServerList( Event *ev ) +{ + // FIXME: stub +} + +void UIFAKKServerList::CancelRefresh( Event *ev ) +{ + // FIXME: stub +} + +void UIFAKKServerList::NewServerList( void ) +{ + // FIXME: stub +} + +void UIFAKKServerList::MakeLANListing( Event *ev ) +{ + // FIXME: stub +} + +void UIFAKKServerList::UpdateServer( Event *ev ) +{ + // FIXME: stub +} + +int UIFAKKServerList::ServerCompareFunction( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname ) +{ + // FIXME: stub + return 0; +} + +void UIFAKKServerList::Draw( void ) +{ + // FIXME: stub +} + +void UIFAKKServerList::SortByColumn( int column ) +{ + // FIXME: stub +} diff --git a/code/client/cl_uiserverlist.h b/code/client/cl_uiserverlist.h new file mode 100644 index 00000000..fe85612a --- /dev/null +++ b/code/client/cl_uiserverlist.h @@ -0,0 +1,58 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UISERVERLIST_H__ +#define __CL_UISERVERLIST_H__ + +class UIFAKKServerList : public UIListCtrl { +protected: + // need a new struct instead of gamespy + void *m_serverList; + bool m_bHasList; + bool m_bLANListing; + +public: + CLASS_PROTOTYPE( UIFAKKServerList ); + + bool m_bGettingList; + bool m_bUpdatingList; + +protected: + void SelectServer( Event *ev ); + void ConnectServer( Event *ev ); + qboolean KeyEvent( int key, unsigned int time ); + void UpdateUIElement( void ); + void RefreshServerList( Event *ev ); + void RefreshLANServerList( Event *ev ); + void CancelRefresh( Event *ev ); + void NewServerList( void ); + void MakeLANListing( Event *ev ); + void UpdateServer( Event *ev ); + static int ServerCompareFunction( const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname ); +public: + UIFAKKServerList(); + + void Draw( void ); + void SortByColumn( int column ); +}; + +#endif /* __CL_UISERVERLIST_H__ */ diff --git a/code/client/cl_uisoundpicker.cpp b/code/client/cl_uisoundpicker.cpp new file mode 100644 index 00000000..a45c434c --- /dev/null +++ b/code/client/cl_uisoundpicker.cpp @@ -0,0 +1,43 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( FilePickerClass, SoundPickerClass, NULL ) +{ + { NULL, NULL } +}; + +SoundPickerClass::SoundPickerClass() +{ + // FIXME: stub +} + +void SoundPickerClass::FileSelected( str ¤tDirectory, str &partialName, str &fullname ) +{ + +} + +void SoundPickerClass::FileChosen( str ¤tDirectory, str &partialName, str &fullname ) +{ + +} diff --git a/code/client/cl_uisoundpicker.h b/code/client/cl_uisoundpicker.h new file mode 100644 index 00000000..d42471a7 --- /dev/null +++ b/code/client/cl_uisoundpicker.h @@ -0,0 +1,36 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UISOUNDPICKER_H__ +#define __CL_UISOUNDPICKER_H__ + +class SoundPickerClass : public FilePickerClass { +public: + CLASS_PROTOTYPE( SoundPickerClass ); + + SoundPickerClass(); + + void FileSelected( str ¤tDirectory, str &partialName, str &fullname ); + void FileChosen( str ¤tDirectory, str &partialName, str &fullname ); +}; + +#endif /* __CL_UISOUNDPICKER_H__ */ diff --git a/code/client/cl_uistd.cpp b/code/client/cl_uistd.cpp new file mode 100644 index 00000000..39dbf5c7 --- /dev/null +++ b/code/client/cl_uistd.cpp @@ -0,0 +1,715 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110EV_DEFAULT301 USA +=========================================================================== +*/ + +#include "cl_ui.h" +#include + +Event EV_Layout_PlayerStat + ( + "playerstat", + EV_DEFAULT, + "i", + "playerstatValue", + "set playerstat for layout\n" + ); +Event EV_Layout_PlayerStatConfigstring + ( + "playerstatconfigstring", + EV_DEFAULT, + "i", + "playerstatValue", + "set playerstat for layout - will print out the corresponding configstring\n" + ); +Event EV_Layout_MaxPlayerStat + ( + "maxplayerstat", + EV_DEFAULT, + "i", + "maxPlayerstatValue", + "set the playerstat that holds the max value for that stat. Used for statbars\n" + ); +Event EV_Layout_ItemIndex + ( + "itemstat", + EV_DEFAULT, + "i", + "itemstatValue", + "set itemstat for layout\n" + ); +Event EV_Layout_InventoryRenderModelIndex + ( + "invmodelhand", + EV_DEFAULT, + "i", + "handindex", + "set the specified hand index to render a 3d model from\n" + ); +Event EV_Layout_Statbar + ( + "statbar", + EV_DEFAULT, + "sII", + "orientation min max", + "make this label present the stat using a graphical bar. Optionally specify a min and max value" + ); +Event EV_Layout_StatbarTileShader + ( + "statbar_tileshader", + EV_DEFAULT, + "s", + "shader", + "set the tile shader for this statbar" + ); +Event EV_Layout_StatbarTileShader_Flash + ( + "statbar_tileshader_flash", + EV_DEFAULT, + "s", + "shader", + "set the flash tile shader for this statbar" + ); +Event EV_Layout_StatbarShader + ( + "statbar_shader", + EV_DEFAULT, + "s", + "shader", + "set the shader for this statbar" + ); +Event EV_Layout_StatbarShader_Flash + ( + "statbar_shader_flash", + EV_DEFAULT, + "s", + "shader", + "set the flash shader for this statbar" + ); +Event EV_Layout_Statbar_EndAngles + ( + "statbar_endangles", + EV_DEFAULT, + "ff", + "startang endang", + "Sets the start and end angles for a circular stat bar" + ); +Event EV_Layout_Statbar_NeedleWidth + ( + "statbar_needlewidth", + EV_DEFAULT, + "f", + "width", + "Sets the width of the needle for a needle statbar" + ); +Event EV_Layout_Statbar_RotatorSize + ( + "statbar_rotatorsize", + EV_DEFAULT, + "f", + "width", + "Sets the width of the needle for a needle statbar" + ); +Event EV_Layout_DrawModelName + ( + "invmodelname", + EV_DEFAULT, + "s", + "name", + "set the name of the 3d model to render\n" + ); +Event EV_Layout_RenderModel + ( + "rendermodel", + EV_DEFAULT, + "b", + "bool", + "Render the model specified by the cvar." + ); +Event EV_Layout_RenderModelOffset + ( + "modeloffset", + EV_DEFAULT, + "v", + "offset", + "Render model offset" + ); +Event EV_Layout_RenderModelRotateOffset + ( + "modelrotateoffset", + EV_DEFAULT, + "v", + "offset", + "Render model rotation offset" + ); +Event EV_Layout_RenderModelAngles + ( + "modelangles", + EV_DEFAULT, + "v", + "angles", + "Render model angles" + ); +Event EV_Layout_RenderModelScale + ( + "modelscale", + EV_DEFAULT, + "f", + "scale", + "Render model scale" + ); +Event EV_Layout_RenderModelAnim + ( + "modelanim", + EV_DEFAULT, + "s", + "anim", + "Render model anim" + ); +Event EV_ClearInvItemReference + ( + "clearinvitemref", + EV_DEFAULT, + NULL, + NULL, + "used internally when the inventory is reset\n" + ); + +CLASS_DECLARATION( UILabel, UIFakkLabel, NULL ) +{ + { &EV_Layout_PlayerStat, &UIFakkLabel::LayoutPlayerStat }, + { &EV_Layout_PlayerStatConfigstring, &UIFakkLabel::LayoutPlayerStatConfigstring }, + { &EV_Layout_MaxPlayerStat, &UIFakkLabel::LayoutMaxPlayerStat }, + { &EV_Layout_ItemIndex, &UIFakkLabel::LayoutItemIndex }, + { &EV_Layout_InventoryRenderModelIndex, &UIFakkLabel::InventoryRenderModelIndex }, + { &EV_Layout_Statbar, &UIFakkLabel::LayoutStatbar }, + { &EV_Layout_StatbarTileShader, &UIFakkLabel::LayoutStatbarTileShader }, + { &EV_Layout_StatbarShader, &UIFakkLabel::LayoutStatbarShader }, + { &EV_Layout_StatbarTileShader_Flash, &UIFakkLabel::LayoutStatbarTileShader_Flash }, + { &EV_Layout_StatbarShader_Flash, &UIFakkLabel::LayoutStatbarShader_Flash }, + { &EV_Layout_Statbar_EndAngles, &UIFakkLabel::LayoutStatbarEndAngles }, + { &EV_Layout_Statbar_NeedleWidth, &UIFakkLabel::LayoutStatbarNeedleWidth }, + { &EV_Layout_Statbar_RotatorSize, &UIFakkLabel::LayoutStatbarRotatorSize }, + { &EV_Layout_DrawModelName, &UIFakkLabel::LayoutModelName }, + { &EV_Layout_RenderModel, &UIFakkLabel::LayoutRenderModel }, + { &EV_Layout_RenderModelOffset, &UIFakkLabel::LayoutRenderModelOffset }, + { &EV_Layout_RenderModelRotateOffset, &UIFakkLabel::LayoutRenderModelRotateOffset }, + { &EV_Layout_RenderModelAngles, &UIFakkLabel::LayoutRenderModelAngles }, + { &EV_Layout_RenderModelScale, &UIFakkLabel::LayoutRenderModelScale }, + { &EV_Layout_RenderModelAnim, &UIFakkLabel::LayoutRenderModelAnim }, + { &EV_ClearInvItemReference, &UIFakkLabel::ClearInvItemReference }, + { NULL, NULL } +}; + +UIFakkLabel::UIFakkLabel() +{ + m_statbar_min = m_statbar_max = -1.0; + m_stat = -1; + m_stat_configstring = -1; + m_maxstat = -1; + m_itemindex = -1; + m_inventoryrendermodelindex = -1; + m_rendermodel = false; + m_statbar_or = L_STATBAR_NONE; + m_statbar_material = NULL; + m_statbar_material_flash = NULL; + m_lastitemindex = -1; +} + +void UIFakkLabel::LayoutPlayerStat( Event *ev ) +{ + m_stat = ev->GetInteger( 1 ); +} + +void UIFakkLabel::LayoutPlayerStatConfigstring( Event *ev ) +{ + m_stat_configstring = ev->GetInteger( 1 ); +} + +void UIFakkLabel::LayoutMaxPlayerStat( Event *ev ) +{ + m_maxstat = ev->GetInteger( 1 ); +} + +void UIFakkLabel::LayoutItemIndex( Event *ev ) +{ + m_itemindex = ev->GetInteger( 1 ); +} + +void UIFakkLabel::InventoryRenderModelIndex( Event *ev ) +{ + m_inventoryrendermodelindex = ev->GetInteger( 1 ); +} + +void UIFakkLabel::LayoutModelName( Event *ev ) +{ + m_sDrawModelName = ev->GetString( 1 ); +} + +void UIFakkLabel::ClearInvItemReference( Event *ev ) +{ + m_lastitem = NULL; + m_lastitemindex = -1; +} + +void UIFakkLabel::LayoutStatbar( Event *ev ) +{ + str or = ev->GetString( 1 ); + + if( ev->NumArgs() > 1 ) + { + m_statbar_min = ev->GetFloat( 2 ); + m_statbar_max = ev->GetFloat( 3 ); + } + + if( !str::icmp( or, "horizontal" ) ) + { + m_statbar_or = L_STATBAR_HORIZONTAL; + } + else if( !str::icmp( or, "vertical_stagger_even" ) ) + { + m_statbar_or = L_STATBAR_VERTICAL_STAGGER_EVEN; + } + else if( !str::icmp( or, "vertical_stagger_odd" ) ) + { + m_statbar_or = L_STATBAR_VERTICAL_STAGGER_ODD; + } + else if( !str::icmp( or, "vertical" ) ) + { + m_statbar_or = L_STATBAR_VERTICAL; + } + else if( !str::icmp( or, "vertical_reverse" ) ) + { + m_statbar_or = L_STATBAR_VERTICAL_REVERSE; + } + else if( !str::icmp( or, "circular" ) ) + { + m_statbar_or = L_STATBAR_CIRCULAR; + + if( !m_statbar_material ) + { + m_statbar_material = uWinMan.RegisterShader( "blank" ); + } + } + else if( !str::icmp( or, "needle" ) ) + { + m_statbar_or = L_STATBAR_NEEDLE; + + if( !m_statbar_material ) + { + m_statbar_material = uWinMan.RegisterShader( "blank" ); + } + } + else if( !str::icmp( or, "rotator" ) ) + { + m_statbar_or = L_STATBAR_ROTATOR; + + if( !m_statbar_material ) + { + m_statbar_material = uWinMan.RegisterShader( "blank" ); + } + } + else if( !str::icmp( or, "compass" ) ) + { + m_statbar_or = L_STATBAR_COMPASS; + + if( !m_statbar_material ) + { + m_statbar_material = uWinMan.RegisterShader( "blank" ); + } + } + else if( !str::icmp( or, "spinner" ) ) + { + m_statbar_or = L_STATBAR_SPINNER; + + if( !m_statbar_material ) + { + m_statbar_material = uWinMan.RegisterShader( "blank" ); + } + } + else if( !str::icmp( or, "headingspinner" ) ) + { + m_statbar_or = L_STATBAR_HEADING_SPINNER; + + if( !m_statbar_material ) + { + m_statbar_material = uWinMan.RegisterShader( "blank" ); + } + } + else + { + warning( "LayoutPlayerStat", "Invalid statbar orientation: \"%s\"", or.c_str() ); + } +} + +void UIFakkLabel::LayoutStatbarShader( Event *ev ) +{ + m_statbar_material = uWinMan.RegisterShader( ev->GetString( 1 ) ); +} + +void UIFakkLabel::LayoutStatbarTileShader( Event *ev ) +{ + m_statbar_material = uWinMan.RegisterShader( ev->GetString( 1 ) ); + AddFlag( WF_TILESHADER ); +} + +void UIFakkLabel::LayoutStatbarShader_Flash( Event *ev ) +{ + m_statbar_material_flash = uWinMan.RegisterShader( ev->GetString( 1 ) ); +} + +void UIFakkLabel::LayoutStatbarEndAngles( Event *ev ) +{ + m_angles[ 0 ] = ev->GetFloat( 1 ); + m_angles[ 1 ] = ev->GetFloat( 2 ); +} + +void UIFakkLabel::LayoutStatbarNeedleWidth( Event *ev ) +{ + m_angles[ 2 ] = ev->GetFloat( 1 ); +} + +void UIFakkLabel::LayoutStatbarRotatorSize( Event *ev ) +{ + m_angles[ 2 ] = ev->GetFloat( 1 ); + + if( ev->NumArgs() > 1 ) { + m_scale = ev->GetFloat( 2 ); + } else { + m_scale = m_angles[ 2 ]; + } +} + +void UIFakkLabel::LayoutStatbarTileShader_Flash( Event *ev ) +{ + m_statbar_material_flash = uWinMan.RegisterShader( ev->GetString( 1 ) ); + AddFlag( WF_TILESHADER ); +} + +void UIFakkLabel::LayoutRenderModel( Event *ev ) +{ + m_rendermodel = ev->GetBoolean( 1 ); +} + +void UIFakkLabel::LayoutRenderModelOffset( Event *ev ) +{ + Vector vec = ev->GetVector( 1 ); + VectorCopy( vec, m_offset ); +} + +void UIFakkLabel::LayoutRenderModelRotateOffset( Event *ev ) +{ + Vector vec = ev->GetVector( 1 ); + VectorCopy( vec, m_rotateoffset ); +} + +void UIFakkLabel::LayoutRenderModelAngles( Event *ev ) +{ + Vector vec = ev->GetVector( 1 ); + VectorCopy( vec, m_angles ); +} + +void UIFakkLabel::LayoutRenderModelScale( Event *ev ) +{ + m_scale = ev->GetFloat( 1 ); +} + +void UIFakkLabel::LayoutRenderModelAnim( Event *ev ) +{ + m_anim = ev->GetString( 1 ); +} + +void UIFakkLabel::DrawStatbar( float frac ) +{ + // FIXME: stub +} + +void UIFakkLabel::DrawStatCircle( float frac ) +{ + // FIXME: stub +} + +void UIFakkLabel::DrawStatNeedle( float frac ) +{ + // FIXME: stub +} + +void UIFakkLabel::DrawStatRotator( float frac ) +{ + // FIXME: stub +} + +void UIFakkLabel::DrawStatCompass( float frac ) +{ + // FIXME: stub +} + +void UIFakkLabel::DrawStatSpinner( float frac ) +{ + // FIXME: stub +} + +void UIFakkLabel::StatCircleTexCoord( float fAng, vec3_t vTexCoord ) +{ + // FIXME: stub +} + +void UIFakkLabel::Draw( void ) +{ + if( m_stat == -1 && m_itemindex == -1 && m_inventoryrendermodelindex == -1 ) + { + if( m_stat_configstring != -1 ) + { + m_font->setColor( m_foreground_color ); + m_font->PrintJustified( getClientFrame(), + m_iFontAlignmentHorizontal, + m_iFontAlignmentVertical, + Sys_LV_CL_ConvertString( va( "%s", CL_ConfigString( cl.snap.ps.stats[ m_stat_configstring ] ) ) ), + m_bVirtual ? m_vVirtualScale : NULL ); + + return; + } + + if( !m_rendermodel && m_statbar_or == L_STATBAR_NONE && !m_sDrawModelName.length() ) + { + UILabel::Draw(); + return; + } + } + + if( m_stat_configstring != -1 ) + { + m_font->setColor( m_foreground_color ); + m_font->PrintJustified( getClientFrame(), + m_iFontAlignmentHorizontal, + m_iFontAlignmentVertical, + Sys_LV_CL_ConvertString( va( "%s", CL_ConfigString( cl.snap.ps.stats[ m_stat_configstring ] ) ) ), + m_bVirtual ? m_vVirtualScale : NULL ); + + return; + } + + if( m_stat != -1 ) + { + float scale; + qhandle_t handle; + vec3_t origin; + vec3_t mins; + vec3_t maxs; + vec3_t angles; + vec3_t offset; + vec3_t rotateoffset; + vec3_t color; + str sAnimName; + float height; + + if( m_itemindex != -1 ) + { + if( m_itemindex < 0 ) + return; + + m_font->setColor( m_foreground_color ); + m_font->PrintJustified( getClientFrame(), + m_iFontAlignmentHorizontal, + m_iFontAlignmentVertical, + Sys_LV_CL_ConvertString( va( "%s", CL_ConfigString( CS_WEAPONS + cl.snap.ps.activeItems[ m_itemindex ] ) ) ), + m_bVirtual ? m_vVirtualScale : NULL ); + + return; + } + + if( m_inventoryrendermodelindex == -1 && !m_sDrawModelName.length() || !m_rendermodel ) + { + float frac = 0.0; + + if( m_statbar_or == L_STATBAR_NONE ) + return; + + if( m_cvarname.length() ) + { + frac = Cvar_VariableValue( m_cvarname ) / ( m_statbar_max - m_statbar_min ); + } + + if( frac > 1.0 ) + frac = 1.0; + if( frac < 0.0 ) + frac = 0.0; + + DrawStatbar( frac ); + return; + } + + VectorSet4( color, 255, 255, 255, 255 ); + + if( m_rendermodel ) + { + if( !m_cvarname.length() ) + return; + + handle = re.RegisterModel( Cvar_VariableString( m_cvarname ) ); + if( !handle ) + return; + + VectorCopy( m_angles, angles ); + VectorCopy( m_rotateoffset, rotateoffset ); + VectorCopy( m_offset, offset ); + scale = m_scale; + sAnimName = m_anim; + } + else if( m_sDrawModelName.length() ) + { + if( m_lastitemindex != cl.snap.ps.activeItems[ m_inventoryrendermodelindex ] ) + { + if( !m_lastitem ) + m_lastitem = CL_GetInvItemByName( &client_inv, m_sDrawModelName ); + } + +_shitlabel01: + if( !m_lastitem ) + return; + + VectorCopy( m_lastitem->hudprops.rotateoffset, rotateoffset ); + VectorCopy( m_lastitem->hudprops.offset, offset ); + + handle = re.RegisterModel( m_lastitem->hudprops.model ); + + VectorCopy( m_lastitem->hudprops.angledeltas, angles ); + + if( m_lastitem->hudprops.move == INV_MOVE_BOB ) + { + float frac = uid.time / 600.0; + angles[ 0 ] += sin( frac ) * m_lastitem->hudprops.angledeltas[ 0 ]; + angles[ 1 ] += sin( frac ) * m_lastitem->hudprops.angledeltas[ 1 ]; + angles[ 2 ] += sin( frac ) * m_lastitem->hudprops.angledeltas[ 2 ]; + } + else if( m_lastitem->hudprops.model == INV_MOVE_SPIN ) + { + float frac = uid.time / 600.0; + angles[ 0 ] += frac * m_lastitem->hudprops.angledeltas[ 0 ]; + angles[ 1 ] += frac * m_lastitem->hudprops.angledeltas[ 1 ]; + angles[ 2 ] += frac * m_lastitem->hudprops.angledeltas[ 2 ]; + } + + if( m_rendermodel ) + { + VectorSet( mins, -16, -16, 0 ); + VectorSet( maxs, 16, 16, 96 ); + } + else + { + re.ModelBounds( handle, mins, maxs ); + } + + origin[ 1 ] = ( mins[ 1 ] + maxs[ 1 ] ) * 0.5; + origin[ 2 ] = ( mins[ 1 ] + maxs[ 1 ] ) * -0.5; + + height = maxs[ 2 ] - mins[ 2 ]; + + if( height < maxs[ 1 ] - mins[ 1 ] ) + height = maxs[ 1 ] - mins[ 1 ]; + + if( height <= maxs[ 0 ] - mins[ 0 ] ) + height = maxs[ 0 ] - mins[ 0 ]; + + origin[ 0 ] = height * scale * 0.5 / 0.268f; + + CL_Draw3DModel( m_screenframe.pos.x, m_screenframe.pos.y, m_screenframe.size.width, m_screenframe.size.height, handle, origin, rotateoffset, offset, angles, color, sAnimName ); + return; + } + + if( m_lastitemindex == cl.snap.ps.activeItems[ m_inventoryrendermodelindex ] ) + goto _shitlabel01; + + if( m_lastitem == CL_GetInvItemByName( &client_inv, CL_ConfigString( CS_WEAPONS + cl.snap.ps.activeItems[ m_inventoryrendermodelindex ] ) ) ) + { + m_lastitemindex = cl.snap.ps.activeItems[ m_inventoryrendermodelindex ]; + goto _shitlabel01; + } + + m_lastitem = CL_GetInvItemByName( &client_inv, CL_ConfigString( CS_WEAPONS + cl.snap.ps.activeItems[ m_inventoryrendermodelindex ] ) ); + goto _shitlabel01; + } + + int delta = cl.snap.ps.stats[ m_stat ]; + + if( m_statbar_or ) + { + if( m_statbar_or == L_STATBAR_VERTICAL_STAGGER_EVEN || m_statbar_or == L_STATBAR_VERTICAL_STAGGER_ODD ) + { + int stat; + + if( m_maxstat < 0 ) { + stat = m_statbar_max; + } else { + stat = cl.snap.ps.stats[ m_maxstat ]; + } + + delta = stat - cl.snap.ps.stats[ m_stat ]; + + if( delta & 1 ) + { + if( m_statbar_or == L_STATBAR_VERTICAL_STAGGER_EVEN ) + delta--; + else + delta++; + } + + delta = stat - delta; + + if( m_maxstat >= 0 || m_statbar_min <= delta ) + { + if( delta < 0 ) + delta = 0; + } + else + { + delta = m_statbar_min; + } + } + + float frac; + + if( m_maxstat ) + { + frac = delta / ( m_statbar_max - m_statbar_min ); + } + else + { + frac = delta / cl.snap.ps.stats[ m_maxstat ]; + } + + if( frac > 1.0 ) + frac = 1.0; + if( frac < 0.0 ) + frac = 0.0; + + DrawStatbar( frac ); + + + return; + } + + m_font->setColor( m_foreground_color ); + m_font->PrintJustified( getClientFrame(), + m_iFontAlignmentHorizontal, + m_iFontAlignmentVertical, + va( "%d", delta ), + m_bVirtual ? m_vVirtualScale : NULL ); +} diff --git a/code/client/cl_uistd.h b/code/client/cl_uistd.h new file mode 100644 index 00000000..a6aac766 --- /dev/null +++ b/code/client/cl_uistd.h @@ -0,0 +1,104 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UISTD_H__ +#define __CL_UISTD_H__ + +typedef enum { + L_STATBAR_NONE, + L_STATBAR_HORIZONTAL, + L_STATBAR_VERTICAL, + L_STATBAR_VERTICAL_REVERSE, + L_STATBAR_VERTICAL_STAGGER_EVEN, + L_STATBAR_VERTICAL_STAGGER_ODD, + L_STATBAR_CIRCULAR, + L_STATBAR_NEEDLE, + L_STATBAR_ROTATOR, + L_STATBAR_COMPASS, + L_STATBAR_SPINNER, + L_STATBAR_HEADING_SPINNER +} statbar_orientation_t; + +class UIFakkLabel : public UILabel { +protected: + SafePtr m_lastitem; + int m_lastitemindex; + int m_stat; + int m_stat_configstring; + int m_maxstat; + int m_itemindex; + int m_inventoryrendermodelindex; + str m_sDrawModelName; + qboolean m_rendermodel; + statbar_orientation_t m_statbar_or; + float m_statbar_min; + float m_statbar_max; + float m_lastfrac; + float m_flashtime; + vec3_t m_offset; + vec3_t m_rotateoffset; + vec3_t m_angles; + float m_scale; + str m_anim; + UIReggedMaterial *m_statbar_material; + UIReggedMaterial *m_statbar_material_flash; + +public: + CLASS_PROTOTYPE( UIFakkLabel ); + + UIFakkLabel(); + + void LayoutPlayerStat( Event *ev ); + void LayoutPlayerStatConfigstring( Event *ev ); + void LayoutMaxPlayerStat( Event *ev ); + void LayoutItemIndex( Event *ev ); + void InventoryRenderModelIndex( Event *ev ); + void LayoutModelName( Event *ev ); + void ClearInvItemReference( Event *ev ); + void LayoutStatbar( Event *ev ); + void LayoutStatbarShader( Event *ev ); + void LayoutStatbarTileShader( Event *ev ); + void LayoutStatbarShader_Flash( Event *ev ); + void LayoutStatbarEndAngles( Event *ev ); + void LayoutStatbarNeedleWidth( Event *ev ); + void LayoutStatbarRotatorSize( Event *ev ); + void LayoutStatbarTileShader_Flash( Event *ev ); + void LayoutRenderModel( Event *ev ); + void LayoutRenderModelOffset( Event *ev ); + void LayoutRenderModelRotateOffset( Event *ev ); + void LayoutRenderModelAngles( Event *ev ); + void LayoutRenderModelScale( Event *ev ); + void LayoutRenderModelAnim( Event *ev ); + + void DrawStatbar( float frac ); + void DrawStatCircle( float frac ); + void DrawStatNeedle( float frac ); + void DrawStatRotator( float frac ); + void DrawStatCompass( float frac ); + void DrawStatSpinner( float frac ); + void StatCircleTexCoord( float fAng, vec3_t vTexCoord ); + + void Draw( void ); +}; + +#endif + diff --git a/code/client/cl_uiview3d.cpp b/code/client/cl_uiview3d.cpp new file mode 100644 index 00000000..17c45251 --- /dev/null +++ b/code/client/cl_uiview3d.cpp @@ -0,0 +1,238 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "cl_ui.h" + +CLASS_DECLARATION( UIWidget, View3D, NULL ) +{ + { NULL, NULL } +}; + +View3D::View3D() +{ + // FIXME: stub +} + +void View3D::Draw + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::DrawLetterbox + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::DrawFades + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::Draw2D + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::DrawFPS + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::DrawProf + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::PrintSound + ( + int channel, + const char *name, + float vol, + int rvol, + float pitch, + float base, + int& line + ) + +{ + // FIXME: stub +} + +void View3D::DrawSoundOverlay + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::CenterPrint + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::LocationPrint + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::OnActivate + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void View3D::OnDeactivate + ( + Event *ev + ) + +{ + // FIXME: stub +} + +void View3D::DrawSubtitleOverlay + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::ClearCenterPrint + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::UpdateCenterPrint + ( + const char *s, + float alpha + ) + +{ + // FIXME: stub +} + +void View3D::UpdateLocationPrint + ( + int x, + int y, + const char *s, + float alpha + ) + +{ + // FIXME: stub +} + +qboolean View3D::LetterboxActive + ( + void + ) + +{ + return m_letterbox_active; +} + +void View3D::InitSubtitle + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::FrameInitialized + ( + void + ) + +{ + // FIXME: stub +} + +void View3D::Pressed + ( + Event *ev + ) + +{ + // FIXME: stub +} + +CLASS_DECLARATION( UIWidget, ConsoleView, NULL ) +{ + { NULL, NULL } +}; + +void ConsoleView::Draw + ( + void + ) + +{ + // FIXME: stub +} + diff --git a/code/client/cl_uiview3d.h b/code/client/cl_uiview3d.h new file mode 100644 index 00000000..52db1e38 --- /dev/null +++ b/code/client/cl_uiview3d.h @@ -0,0 +1,74 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __CL_UIVIEW3D__ +#define __CL_UIVIEW3D__ + +class View3D : public UIWidget { + float m_printfadetime; + float m_printalpha; + str m_printstring; + UIReggedMaterial *m_print_mat; + qboolean m_locationprint; + int m_x_coord; + int m_y_coord; + qboolean m_letterbox_active; + +public: + CLASS_PROTOTYPE( View3D ); + +protected: + void Draw( void ); + void DrawLetterbox( void ); + void DrawFades( void ); + void Draw2D( void ); + void DrawFPS( void ); + void DrawProf( void ); + void PrintSound( int channel, const char *name, float vol, int rvol, float pitch, float base, int& line ); + void DrawSoundOverlay( void ); + void CenterPrint( void ); + void LocationPrint( void ); + void OnActivate( Event *ev ); + void OnDeactivate( Event *ev ); + void DrawSubtitleOverlay( void ); + +public: + View3D(); + + void ClearCenterPrint( void ); + void UpdateCenterPrint( const char *s, float alpha ); + void UpdateLocationPrint( int x, int y, const char *s, float alpha ); + qboolean LetterboxActive( void ); + void InitSubtitle( void ); + void FrameInitialized( void ); + virtual void Pressed( Event *ev ); +}; + +class ConsoleView : public UIWidget { +public: + CLASS_PROTOTYPE( ConsoleView ); + +protected: + void Draw( void ); +}; + +#endif /* __CL_UIVIEW3D__ */ diff --git a/code/client/client.h b/code/client/client.h new file mode 100644 index 00000000..9f28d05e --- /dev/null +++ b/code/client/client.h @@ -0,0 +1,662 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// client.h -- primary header for client + +#ifndef __CLIENT_H__ +#define __CLIENT_H__ + +#include "../qcommon/q_shared.h" +#include "../qcommon/qcommon.h" +#include "../renderercommon/tr_public.h" +#include "keys.h" +#include "snd_public.h" +#include "../cgame/cg_public.h" +#include "../game/bg_public.h" + +#ifdef USE_CURL +#include "cl_curl.h" +#endif /* USE_CURL */ + +// file full of random crap that gets used to create cl_guid +#define QKEY_FILE "qkey" +#define QKEY_SIZE 2048 + +#define RETRANSMIT_TIMEOUT 3000 // time between connection packet retransmits + +#ifdef __cplusplus +extern "C" { +#endif + +// snapshots are a view of the server at a given time +typedef struct { + qboolean valid; // cleared if delta parsing was invalid + int snapFlags; // rate delayed and dropped commands + + int serverTime; // server time the message is valid for (in msec) +int serverTimeResidual; + int messageNum; // copied from netchan->incoming_sequence + int deltaNum; // messageNum the delta is from + int ping; // time from when cmdNum-1 was sent to time packet was reeceived + byte areamask[MAX_MAP_AREA_BYTES]; // portalarea visibility bits + + int cmdNum; // the next cmdNum the server is expecting + playerState_t ps; // complete information about the current player at this time + + int numEntities; // all of the entities that need to be presented + int parseEntitiesNum; // at the time of this snapshot + + int serverCommandNum; // execute all commands up to this before + // making the snapshot current + int number_of_sounds; + server_sound_t sounds[64]; +} clSnapshot_t; + + + +/* +============================================================================= + +the clientActive_t structure is wiped completely at every +new gamestate_t, potentially several times during an established connection + +============================================================================= +*/ + +typedef struct { + int p_cmdNumber; // cl.cmdNumber when packet was sent + int p_serverTime; // usercmd->serverTime when packet was sent + int p_realtime; // cls.realtime when packet was sent + usereyes_t p_eyeinfo; // eyeInfo when packet was sent +} outPacket_t; + +// the parseEntities array must be large enough to hold PACKET_BACKUP frames of +// entities, so that when a delta compressed message arives from the server +// it can be un-deltad from the original +#define MAX_PARSE_ENTITIES 2048 + +extern int g_console_field_width; +extern int g_console_charWidth; +extern int g_console_charHeight; + +typedef struct { + int timeoutcount; // it requres several frames in a timeout condition + // to disconnect, preventing debugging breaks from + // causing immediate disconnects on continue + clSnapshot_t snap; // latest received from server + + int serverTime; // may be paused during play + int oldServerTime; // to prevent time from flowing bakcwards + int serverStartTime; + int oldFrameServerTime; // to check tournament restarts + int serverTimeDelta; // cl.serverTime = cls.realtime + cl.serverTimeDelta + // this value changes as net lag varies + qboolean extrapolatedSnapshot; // set if any cgame frame has been forced to extrapolate + // cleared when CL_AdjustTimeDelta looks at it + qboolean newSnapshots; // set on parse of any valid packet + + gameState_t gameState; // configstrings + char mapname[MAX_QPATH]; // extracted from CS_SERVERINFO + + int parseEntitiesNum; // index (not anded off) into cl_parse_entities[] + + int mouseDx[2], mouseDy[2]; // added to by mouse events + int mouseIndex; + + int mousex, mousey; + unsigned int mouseButtons; + + int joystickAxis[MAX_JOYSTICK_AXIS]; // set by joystick events + + // cgame communicates a few values to the client system + int cgameUserCmdValue; // current weapon to add to usercmd_t + float cgameSensitivity; + + // cmds[cmdNumber] is the predicted command, [cmdNumber-1] is the last + // properly generated command + usercmd_t cmds[CMD_BACKUP]; // each mesage will send several old cmds + int cmdNumber; // incremented each frame, because multiple + // frames may need to be packed into a single packet + + outPacket_t outPackets[PACKET_BACKUP]; // information about each packet we have sent out + + // the client maintains its own idea of view angles, which are + // sent to the server each frame. It is cleared to 0 upon entering each level. + // the server sends a delta each frame which is added to the locally + // tracked view angles to account for standing on rotating objects, + // and teleport direction changes + vec3_t viewangles; + + vec3_t eyeAngles; + vec3_t eyeOrigin; + + int serverId; // included in each client message so the server + // can tell if it is for a prior map_restart + // big stuff at end of structure so most offsets are 15 bits or less + clSnapshot_t snapshots[PACKET_BACKUP]; + + entityState_t entityBaselines[MAX_GENTITIES]; // for delta compression when not in previous frame + + entityState_t parseEntities[MAX_PARSE_ENTITIES]; +} clientActive_t; + +extern clientActive_t cl; + +/* +============================================================================= + +the clientConnection_t structure is wiped when disconnecting from a server, +either to go to a full screen console, play a demo, or connect to a different server + +A connection can be to either a server through the network layer or a +demo through a file. + +============================================================================= +*/ + +#define MAX_TIMEDEMO_DURATIONS 4096 + +typedef struct { + + int clientNum; + int lastPacketSentTime; // for retransmits during connection + int lastPacketTime; // for timeouts + + netadr_t serverAddress; + int connectTime; // for connection retransmits + int connectPacketCount; // for display on connection dialog + char serverMessage[MAX_STRING_TOKENS]; // for display on connection dialog + + int challenge; // from the server to use for connecting + int checksumFeed; // from the server for checksum calculations + + // these are our reliable messages that go to the server + int reliableSequence; + int reliableAcknowledge; // the last one the server has executed + char reliableCommands[MAX_RELIABLE_COMMANDS][MAX_STRING_CHARS]; + + // server message (unreliable) and command (reliable) sequence + // numbers are NOT cleared at level changes, but continue to + // increase as long as the connection is valid + + // message sequence is used by both the network layer and the + // delta compression layer + int serverMessageSequence; + + // reliable messages received from server + int serverCommandSequence; + int lastExecutedServerCommand; // last server command grabbed or executed with CL_GetServerCommand + char serverCommands[MAX_RELIABLE_COMMANDS][MAX_STRING_CHARS]; + + // file transfer from server + fileHandle_t download; + char downloadTempName[MAX_OSPATH]; + char downloadName[MAX_OSPATH]; +#ifdef USE_CURL + qboolean cURLEnabled; + qboolean cURLUsed; + qboolean cURLDisconnected; + char downloadURL[MAX_OSPATH]; + CURL *downloadCURL; + CURLM *downloadCURLM; +#endif /* USE_CURL */ + int sv_allowDownload; + char sv_dlURL[MAX_CVAR_VALUE_STRING]; + int downloadNumber; + int downloadBlock; // block we are waiting for + int downloadCount; // how many bytes we got + int downloadSize; // how many bytes we got + char downloadList[MAX_INFO_STRING]; // list of paks we need to download + qboolean downloadRestart; // if true, we need to do another FS_Restart because we downloaded a pak + + // demo information + char demoName[MAX_QPATH]; + qboolean spDemoRecording; + qboolean demorecording; + qboolean demoplaying; + qboolean demowaiting; // don't record until a non-delta message is received + qboolean firstDemoFrameSkipped; + fileHandle_t demofile; + + int timeDemoFrames; // counter of rendered frames + int timeDemoStart; // cls.realtime before first frame + int timeDemoBaseTime; // each frame will be at this time + frameNum * 50 + int timeDemoLastFrame;// time the last frame was rendered + int timeDemoMinDuration; // minimum frame duration + int timeDemoMaxDuration; // maximum frame duration + unsigned char timeDemoDurations[ MAX_TIMEDEMO_DURATIONS ]; // log of frame durations + + // big stuff at end of structure so most offsets are 15 bits or less + netchan_t netchan; +} clientConnection_t; + +extern clientConnection_t clc; + +/* +================================================================== + +the clientStatic_t structure is never wiped, and is used even when +no client connection is active at all + +================================================================== +*/ + +typedef struct { + netadr_t adr; + int start; + int time; + char info[MAX_INFO_STRING]; +} ping_t; + +typedef struct { + netadr_t adr; + char hostName[ MAX_NAME_LENGTH ]; + char mapName[ MAX_NAME_LENGTH ]; + char game[ MAX_NAME_LENGTH ]; + char gameTypeString[ MAX_NAME_LENGTH ]; + int netType; + int gameType; + int clients; + int maxClients; + int minPing; + int maxPing; + int ping; + qboolean visible; +} serverInfo_t; + +typedef struct { + byte ip[4]; + unsigned short port; +} serverAddress_t; + +typedef struct { + int startStage; + connstate_t state; // connection status + int loading; + int keyCatchers; + qboolean vid_restart; + qboolean cddialog; // bring up the cd needed dialog next frame + qboolean no_menus; + + char servername[MAX_OSPATH]; // name of server from original connect (used by reconnect) + + // when the server clears the hunk, all of these must be restarted + qboolean rendererRegistered; + qboolean cgameStarted; + qboolean uiStarted; + qboolean timeScaled; + + int framecount; + int frametime; // msec since last frame + + int realtime; // ignores pause + int realFrametime; // ignoring pause, so console always works + + int numlocalservers; + serverInfo_t localServers[ MAX_OTHER_SERVERS ]; + qboolean bNewLocalServerInfo; + + int numglobalservers; + serverInfo_t globalServers[MAX_GLOBAL_SERVERS]; + // additional global servers + int numGlobalServerAddresses; + serverAddress_t globalServerAddresses[MAX_GLOBAL_SERVERS]; + + int numfavoriteservers; + serverInfo_t favoriteServers[MAX_OTHER_SERVERS]; + + int nummplayerservers; + serverInfo_t mplayerServers[MAX_OTHER_SERVERS]; + + int pingUpdateSource; // source currently pinging or updating + + int masterNum; + + // update server info + netadr_t updateServer; + char updateChallenge[MAX_TOKEN_CHARS]; + char updateInfoString[MAX_INFO_STRING]; + + netadr_t authorizeServer; + + // rendering info + glconfig_t glconfig; + int total_tris; + int total_verts; + int total_texels; + int world_tris; + int world_verts; + int character_lights; + hdelement_t HudDrawElements[ MAX_HUDDRAW_ELEMENTS ]; + clientAnim_t anim; + stopwatch_t stopwatch; + qhandle_t charSetShader; + qhandle_t whiteShader; + qhandle_t consoleShader; + fontInfo_t consoleFont; +} clientStatic_t; + +extern clientStatic_t cls; + +//============================================================================= + +//extern vm_t *cgvm; // interface to cgame dll or vm +extern clientGameExport_t *cge; +extern refexport_t re; // interface to refresh .dll + + +// +// cvars +// +extern cvar_t *cl_nodelta; +extern cvar_t *cl_debugMove; +extern cvar_t *cl_noprint; +extern cvar_t *cl_timegraph; +extern cvar_t *cl_timeout; +extern cvar_t *cl_connect_timeout; +extern cvar_t *cl_maxpackets; +extern cvar_t *cl_packetdup; +extern cvar_t *cl_shownet; +extern cvar_t *cl_showSend; +extern cvar_t *cl_timeNudge; +extern cvar_t *cl_showTimeDelta; +extern cvar_t *cl_freezeDemo; + +extern cvar_t *cl_yawspeed; +extern cvar_t *cl_pitchspeed; +extern cvar_t *cl_run; +extern cvar_t *cl_anglespeedkey; + +extern cvar_t *cl_sensitivity; +extern cvar_t *cl_platformSensitivity; +extern cvar_t *cl_freelook; + +extern cvar_t *cl_mouseAccel; +extern cvar_t *cl_showMouseRate; + +extern cvar_t *cl_altbindings; +extern cvar_t *cl_ctrlbindings; + +extern cvar_t *m_pitch; +extern cvar_t *m_yaw; +extern cvar_t *m_forward; +extern cvar_t *m_side; +extern cvar_t *m_filter; + +extern cvar_t *cl_timedemo; +extern cvar_t *cl_aviFrameRate; +extern cvar_t *cl_aviMotionJpeg; + +extern cvar_t *cl_activeAction; + +extern cvar_t *cl_allowDownload; +extern cvar_t *cl_downloadMethod; +extern cvar_t *cl_conXOffset; +extern cvar_t *cl_inGameVideo; + +extern cvar_t *cl_lanForcePackets; +extern cvar_t *cl_langamerefreshstatus; +extern cvar_t *cl_autoRecordDemo; + +extern cvar_t *cl_r_fullscreen; + +extern cvar_t *cl_consoleKeys; + +extern cvar_t *cg_gametype; + +//================================================= + +// +// cl_main +// + +void CL_Init (void); +void CL_InitClientSavedData( void ); +void CL_InitRef( void ); +void CL_FlushMemory(void); +void CL_ShutdownAll(void); +void CL_AddReliableCommand( const char *cmd ); + +void CL_StartHunkUsers( void ); + +void CL_Connect( const char *server ); + +void CL_Disconnect_f (void); +void CL_GetChallengePacket (void); +void CL_Vid_Restart_f( void ); +void CL_Snd_Restart_f (void); +const char *CL_ConfigString( int index ); +void CL_StartDemoLoop( void ); +void CL_NextDemo( void ); +void CL_ReadDemoMessage( void ); +void CL_StopRecord_f(void); + +void CL_InitDownloads(void); +void CL_NextDownload(void); + +void CL_GetPing( int n, char *buf, int buflen, int *pingtime ); +void CL_GetPingInfo( int n, char *buf, int buflen ); +void CL_ClearPing( int n ); +int CL_GetPingQueueCount( void ); + +void CL_ShutdownRef( void ); +void CL_InitRef( void ); +qboolean CL_CDKeyValidate( const char *key, const char *checksum ); +int CL_ServerStatus( const char *serverAddress, char *serverStatusString, int maxLen ); +void UI_ClearResource( void ); +void UI_LoadResource( const char *name ); + +qboolean CL_CheckPaused(void); + +// +// cl_input +// +typedef struct { + int down[2]; // key nums holding it down + unsigned downtime; // msec timestamp + unsigned msec; // msec down this frame if both a down and up happened + qboolean active; // current state + qboolean wasPressed; // set when down, not cleared when up +} kbutton_t; + +extern kbutton_t in_mlook, in_klook; +extern kbutton_t in_strafe; +extern kbutton_t in_speed; +extern qboolean in_guimouse; + +void IN_ToggleMouse( void ); +void IN_MouseOn( void ); +void IN_MouseOff( void ); + +void CL_InitInput (void); +void CL_SendCmd (void); +void CL_ClearState (void); +void CL_ReadPackets (void); + +void CL_WritePacket( void ); +void IN_CenterView (void); + +void CL_VerifyCode( void ); + +float CL_KeyState (kbutton_t *key); +const char *Key_KeynumToString( int keynum ); +const char *Key_KeynumToBindString( int keynum ); +void Key_GetKeysForCommand( const char *command, int *key1, int *key2 ); +int Key_GetCatcher( void ); +void Key_SetCatcher( int catcher ); + +void CL_GetEyeInfo(usereyes_t *info); //su44 +void CL_SetEyeInfo(vec3_t origin, vec3_t angles); //su44 + +// +// cl_parse.c +// +extern int cl_connectedToPureServer; +extern int cl_connectedToCheatServer; +extern msg_t *cl_currentMSG; + +void CL_SystemInfoChanged( void ); +void CL_ParseServerMessage( msg_t *msg ); + +int CL_MSG_ReadBits( int bits ); +int CL_MSG_ReadChar( void ); +int CL_MSG_ReadByte( void ); +int CL_MSG_ReadSVC( void ); +int CL_MSG_ReadShort( void ); +int CL_MSG_ReadLong( void ); +float CL_MSG_ReadFloat( void ); +char *CL_MSG_ReadString( void ); +char *CL_MSG_ReadStringLine( void ); +float CL_MSG_ReadAngle8( void ); +float CL_MSG_ReadAngle16( void ); +void CL_MSG_ReadData( void *data, int len ); +float CL_MSG_ReadCoord( void ); +void CL_MSG_ReadDir( vec3_t dir ); + +//==================================================================== + +void CL_ServerInfoPacket( netadr_t from, msg_t *msg ); +void CL_LocalServers_f( void ); +void CL_GlobalServers_f( void ); +void CL_FavoriteServers_f( void ); +void CL_Ping_f( void ); +void CL_SaveShot_f( void ); +void CL_Dialog_f( void ); +qboolean CL_UpdateVisiblePings_f( int source ); + + +// +// console +// +void Con_DrawCharacter (int cx, int line, int num); + +void Con_CheckResize (void); +void Con_Init (void); +void Con_Clear_f (void); +void Con_ToggleConsole_f (void); +void Con_DrawNotify (void); +void Con_ClearNotify (void); +void Con_RunConsole (void); +void Con_DrawConsole (void); +void Con_PageUp( void ); +void Con_PageDown( void ); +void Con_Top( void ); +void Con_Bottom( void ); +void Con_Close( void ); + +void CL_LoadConsoleHistory( void ); +void CL_SaveConsoleHistory( void ); + +// +// cl_scrn.c +// +void SCR_Init (void); +void SCR_UpdateScreen (void); + +void SCR_DebugGraph (float value, int color); + +int SCR_GetBigStringWidth( const char *str ); // returns in virtual 640x480 coordinates + +void SCR_AdjustFrom640( float *x, float *y, float *w, float *h ); +void SCR_FillRect( float x, float y, float width, float height, + const float *color ); +void SCR_DrawPic( float x, float y, float width, float height, qhandle_t hShader ); +void SCR_DrawNamedPic( float x, float y, float width, float height, const char *picname ); + +void SCR_DrawBigString( int x, int y, const char *s, float alpha, qboolean noColorEscape ); // draws a string with embedded color control characters with fade +void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color, qboolean noColorEscape ); // ignores embedded color control characters +void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, qboolean forceColor, qboolean noColorEscape ); +void SCR_DrawSmallChar( int x, int y, int ch ); + +void UpdateStereoSide( stereoFrame_t s ); + +// +// cl_cin.c +// + +void CL_PlayCinematic_f( void ); +void SCR_DrawCinematic (void); +void SCR_RunCinematic (void); +void SCR_StopCinematic (void); +int CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits); +e_status CIN_StopCinematic(int handle); +e_status CIN_RunCinematic (int handle); +void CIN_DrawCinematic (int handle); +void CIN_SetExtents (int handle, int x, int y, int w, int h); +void CIN_SetLooping (int handle, qboolean loop); +void CIN_UploadCinematic(int handle); +void CIN_CloseAllVideos(void); + +// +// cl_cgame.cpp +// +void CL_InitCGame( void ); +void CL_InitCGameDLL( void ); +void CL_ShutdownCGame( void ); +qboolean CL_GameCommand( void ); +void CL_CGameRendering( stereoFrame_t stereo ); +void CL_CGame2D( stereoFrame_t stereo ); +void CL_UpdateSnapFlags( void ); +void CL_SetCGameTime( void ); +void CL_FirstSnapshot( void ); +void CL_ShaderStateChanged( void ); +baseshader_t *CL_GetShaderPointer( int iShaderNum ); + +// +// cl_ui.c +// +/* +void CL_InitializeUI( void ); +void CL_ShutdownUI( void ); +int Key_GetCatcher( void ); +void Key_SetCatcher( int catcher ); +void LAN_LoadCachedServers( void ); +void LAN_SaveServersToCache( void ); +*/ + + +// +// cl_net_chan.c +// +void CL_Netchan_Transmit( netchan_t *chan, msg_t* msg); //int length, const byte *data ); +void CL_Netchan_TransmitNextFragment( netchan_t *chan ); +qboolean CL_Netchan_Process( netchan_t *chan, msg_t *msg ); + +// +// cl_avi.c +// +qboolean CL_OpenAVIForWriting( const char *filename ); +void CL_TakeVideoFrame( void ); +void CL_WriteAVIVideoFrame( const byte *imageBuffer, int size ); +void CL_WriteAVIAudioFrame( const byte *pcmBuffer, int size ); +qboolean CL_CloseAVI( void ); +qboolean CL_VideoRecording( void ); + +// +// cl_consolecmds.cpp +// +void CL_InitConsoleCommands( void ); + +#ifdef __cplusplus +} +#endif + +#endif // __CLIENT_H__ diff --git a/code/client/keycodes.h b/code/client/keycodes.h new file mode 100644 index 00000000..706ca1b0 --- /dev/null +++ b/code/client/keycodes.h @@ -0,0 +1,279 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +#ifndef __KEYCODES_H__ +#define __KEYCODES_H__ + +// +// these are the key numbers that should be passed to KeyEvent +// + +// normal keys should be passed as lowercased ascii + +typedef enum { + K_TAB = 9, + K_ENTER = 13, + K_ESCAPE = 27, + K_SPACE = 32, + + K_BACKSPACE = 127, + + K_COMMAND = 128, + K_CAPSLOCK, + K_POWER, + K_PAUSE, + + K_UPARROW, + K_DOWNARROW, + K_LEFTARROW, + K_RIGHTARROW, + + K_ALT, + K_CTRL, + K_SHIFT, + K_INS, + K_DEL, + K_PGDN, + K_PGUP, + K_HOME, + K_END, + + K_F1, + K_F2, + K_F3, + K_F4, + K_F5, + K_F6, + K_F7, + K_F8, + K_F9, + K_F10, + K_F11, + K_F12, + K_F13, + K_F14, + K_F15, + + K_KP_HOME, + K_KP_UPARROW, + K_KP_PGUP, + K_KP_LEFTARROW, + K_KP_5, + K_KP_RIGHTARROW, + K_KP_END, + K_KP_DOWNARROW, + K_KP_PGDN, + K_KP_ENTER, + K_KP_INS, + K_KP_DEL, + K_KP_SLASH, + K_KP_MINUS, + K_KP_PLUS, + K_KP_NUMLOCK, + K_KP_STAR, + K_KP_EQUALS, + + K_MOUSE1, + K_MOUSE2, + K_MOUSE3, + K_MOUSE4, + K_MOUSE5, + + K_MWHEELDOWN, + K_MWHEELUP, + + K_JOY1, + K_JOY2, + K_JOY3, + K_JOY4, + K_JOY5, + K_JOY6, + K_JOY7, + K_JOY8, + K_JOY9, + K_JOY10, + K_JOY11, + K_JOY12, + K_JOY13, + K_JOY14, + K_JOY15, + K_JOY16, + K_JOY17, + K_JOY18, + K_JOY19, + K_JOY20, + K_JOY21, + K_JOY22, + K_JOY23, + K_JOY24, + K_JOY25, + K_JOY26, + K_JOY27, + K_JOY28, + K_JOY29, + K_JOY30, + K_JOY31, + K_JOY32, + + K_AUX1, + K_AUX2, + K_AUX3, + K_AUX4, + K_AUX5, + K_AUX6, + K_AUX7, + K_AUX8, + K_AUX9, + K_AUX10, + K_AUX11, + K_AUX12, + K_AUX13, + K_AUX14, + K_AUX15, + K_AUX16, + + K_WORLD_0, + K_WORLD_1, + K_WORLD_2, + K_WORLD_3, + K_WORLD_4, + K_WORLD_5, + K_WORLD_6, + K_WORLD_7, + K_WORLD_8, + K_WORLD_9, + K_WORLD_10, + K_WORLD_11, + K_WORLD_12, + K_WORLD_13, + K_WORLD_14, + K_WORLD_15, + K_WORLD_16, + K_WORLD_17, + K_WORLD_18, + K_WORLD_19, + K_WORLD_20, + K_WORLD_21, + K_WORLD_22, + K_WORLD_23, + K_WORLD_24, + K_WORLD_25, + K_WORLD_26, + K_WORLD_27, + K_WORLD_28, + K_WORLD_29, + K_WORLD_30, + K_WORLD_31, + K_WORLD_32, + K_WORLD_33, + K_WORLD_34, + K_WORLD_35, + K_WORLD_36, + K_WORLD_37, + K_WORLD_38, + K_WORLD_39, + K_WORLD_40, + K_WORLD_41, + K_WORLD_42, + K_WORLD_43, + K_WORLD_44, + K_WORLD_45, + K_WORLD_46, + K_WORLD_47, + K_WORLD_48, + K_WORLD_49, + K_WORLD_50, + K_WORLD_51, + K_WORLD_52, + K_WORLD_53, + K_WORLD_54, + K_WORLD_55, + K_WORLD_56, + K_WORLD_57, + K_WORLD_58, + K_WORLD_59, + K_WORLD_60, + K_WORLD_61, + K_WORLD_62, + K_WORLD_63, + K_WORLD_64, + K_WORLD_65, + K_WORLD_66, + K_WORLD_67, + K_WORLD_68, + K_WORLD_69, + K_WORLD_70, + K_WORLD_71, + K_WORLD_72, + K_WORLD_73, + K_WORLD_74, + K_WORLD_75, + K_WORLD_76, + K_WORLD_77, + K_WORLD_78, + K_WORLD_79, + K_WORLD_80, + K_WORLD_81, + K_WORLD_82, + K_WORLD_83, + K_WORLD_84, + K_WORLD_85, + K_WORLD_86, + K_WORLD_87, + K_WORLD_88, + K_WORLD_89, + K_WORLD_90, + K_WORLD_91, + K_WORLD_92, + K_WORLD_93, + K_WORLD_94, + K_WORLD_95, + + K_SUPER, + K_COMPOSE, + K_MODE, + K_HELP, + K_PRINT, + K_SYSREQ, + K_SCROLLOCK, + K_BREAK, + K_MENU, + K_EURO, + K_UNDO, + + // Pseudo-key that brings the console down + K_CONSOLE, + + MAX_KEYS +} keyNum_t; + +// MAX_KEYS replaces K_LAST_KEY, however some mods may have used K_LAST_KEY +// in detecting binds, so we leave it defined to the old hardcoded value +// of maxiumum keys to prevent mods from crashing older versions of the engine +#define K_LAST_KEY 256 + +// The menu code needs to get both key and char events, but +// to avoid duplicating the paths, the char events are just +// distinguished by or'ing in K_CHAR_FLAG (ugly) +#define K_CHAR_FLAG 1024 + +#endif diff --git a/code/client/keys.h b/code/client/keys.h new file mode 100644 index 00000000..5fdfe01b --- /dev/null +++ b/code/client/keys.h @@ -0,0 +1,65 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#include "keycodes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + qboolean down; + int repeats; // if > 1, it is autorepeating + char *binding; +} qkey_t; + +extern qboolean key_overstrikeMode; +extern qkey_t keys[MAX_KEYS]; + +// NOTE TTimo the declaration of field_t and Field_Clear is now in qcommon/qcommon.h +void Field_KeyDownEvent( field_t *edit, int key ); +void Field_CharEvent( field_t *edit, int ch ); +void Field_Draw(fontInfo_t *font, field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ); +void Field_BigDraw(fontInfo_t *font, field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ); + +#define COMMAND_HISTORY 32 +extern field_t historyEditLines[COMMAND_HISTORY]; + +extern field_t g_consoleField; +extern field_t chatField; +extern int anykeydown; +extern qboolean chat_team; +extern int chat_playerNum; + +int Key_StringToKeynum( const char *str ); +void Key_WriteBindings( fileHandle_t f ); +void Key_SetBinding( int keynum, const char *binding ); +char *Key_GetBinding( int keynum ); +qboolean Key_IsDown( int keynum ); +qboolean Key_GetOverstrikeMode( void ); +void Key_SetOverstrikeMode( qboolean state ); +void Key_ClearStates( void ); +int Key_GetKey(const char *binding); +const char *Key_GetKeynameForCommand( const char *command ); + +#ifdef __cplusplus +} +#endif diff --git a/code/client/qal.c b/code/client/qal.c new file mode 100644 index 00000000..5cc40de2 --- /dev/null +++ b/code/client/qal.c @@ -0,0 +1,336 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// Dynamically loads OpenAL + +#ifdef USE_OPENAL + +#include "qal.h" + +#ifdef USE_OPENAL_DLOPEN + +#include "../sys/sys_loadlib.h" + +LPALENABLE qalEnable; +LPALDISABLE qalDisable; +LPALISENABLED qalIsEnabled; +LPALGETSTRING qalGetString; +LPALGETBOOLEANV qalGetBooleanv; +LPALGETINTEGERV qalGetIntegerv; +LPALGETFLOATV qalGetFloatv; +LPALGETDOUBLEV qalGetDoublev; +LPALGETBOOLEAN qalGetBoolean; +LPALGETINTEGER qalGetInteger; +LPALGETFLOAT qalGetFloat; +LPALGETDOUBLE qalGetDouble; +LPALGETERROR qalGetError; +LPALISEXTENSIONPRESENT qalIsExtensionPresent; +LPALGETPROCADDRESS qalGetProcAddress; +LPALGETENUMVALUE qalGetEnumValue; +LPALLISTENERF qalListenerf; +LPALLISTENER3F qalListener3f; +LPALLISTENERFV qalListenerfv; +LPALLISTENERI qalListeneri; +LPALGETLISTENERF qalGetListenerf; +LPALGETLISTENER3F qalGetListener3f; +LPALGETLISTENERFV qalGetListenerfv; +LPALGETLISTENERI qalGetListeneri; +LPALGENSOURCES qalGenSources; +LPALDELETESOURCES qalDeleteSources; +LPALISSOURCE qalIsSource; +LPALSOURCEF qalSourcef; +LPALSOURCE3F qalSource3f; +LPALSOURCEFV qalSourcefv; +LPALSOURCEI qalSourcei; +LPALGETSOURCEF qalGetSourcef; +LPALGETSOURCE3F qalGetSource3f; +LPALGETSOURCEFV qalGetSourcefv; +LPALGETSOURCEI qalGetSourcei; +LPALSOURCEPLAYV qalSourcePlayv; +LPALSOURCESTOPV qalSourceStopv; +LPALSOURCEREWINDV qalSourceRewindv; +LPALSOURCEPAUSEV qalSourcePausev; +LPALSOURCEPLAY qalSourcePlay; +LPALSOURCESTOP qalSourceStop; +LPALSOURCEREWIND qalSourceRewind; +LPALSOURCEPAUSE qalSourcePause; +LPALSOURCEQUEUEBUFFERS qalSourceQueueBuffers; +LPALSOURCEUNQUEUEBUFFERS qalSourceUnqueueBuffers; +LPALGENBUFFERS qalGenBuffers; +LPALDELETEBUFFERS qalDeleteBuffers; +LPALISBUFFER qalIsBuffer; +LPALBUFFERDATA qalBufferData; +LPALGETBUFFERF qalGetBufferf; +LPALGETBUFFERI qalGetBufferi; +LPALDOPPLERFACTOR qalDopplerFactor; +LPALSPEEDOFSOUND qalSpeedOfSound; +LPALDISTANCEMODEL qalDistanceModel; + +LPALCCREATECONTEXT qalcCreateContext; +LPALCMAKECONTEXTCURRENT qalcMakeContextCurrent; +LPALCPROCESSCONTEXT qalcProcessContext; +LPALCSUSPENDCONTEXT qalcSuspendContext; +LPALCDESTROYCONTEXT qalcDestroyContext; +LPALCGETCURRENTCONTEXT qalcGetCurrentContext; +LPALCGETCONTEXTSDEVICE qalcGetContextsDevice; +LPALCOPENDEVICE qalcOpenDevice; +LPALCCLOSEDEVICE qalcCloseDevice; +LPALCGETERROR qalcGetError; +LPALCISEXTENSIONPRESENT qalcIsExtensionPresent; +LPALCGETPROCADDRESS qalcGetProcAddress; +LPALCGETENUMVALUE qalcGetEnumValue; +LPALCGETSTRING qalcGetString; +LPALCGETINTEGERV qalcGetIntegerv; +LPALCCAPTUREOPENDEVICE qalcCaptureOpenDevice; +LPALCCAPTURECLOSEDEVICE qalcCaptureCloseDevice; +LPALCCAPTURESTART qalcCaptureStart; +LPALCCAPTURESTOP qalcCaptureStop; +LPALCCAPTURESAMPLES qalcCaptureSamples; + +static void *OpenALLib = NULL; + +static qboolean alinit_fail = qfalse; + +/* +================= +GPA +================= +*/ +static void *GPA(char *str) +{ + void *rv; + + rv = Sys_LoadFunction(OpenALLib, str); + if(!rv) + { + Com_Printf( " Can't load symbol %s\n", str); + alinit_fail = qtrue; + return NULL; + } + else + { + Com_DPrintf( " Loaded symbol %s (%p)\n", str, rv); + return rv; + } +} + +/* +================= +QAL_Init +================= +*/ +qboolean QAL_Init(const char *libname) +{ + if(OpenALLib) + return qtrue; + + if(!(OpenALLib = Sys_LoadDll(libname, qtrue))) + return qfalse; + + alinit_fail = qfalse; + + qalEnable = GPA("alEnable"); + qalDisable = GPA("alDisable"); + qalIsEnabled = GPA("alIsEnabled"); + qalGetString = GPA("alGetString"); + qalGetBooleanv = GPA("alGetBooleanv"); + qalGetIntegerv = GPA("alGetIntegerv"); + qalGetFloatv = GPA("alGetFloatv"); + qalGetDoublev = GPA("alGetDoublev"); + qalGetBoolean = GPA("alGetBoolean"); + qalGetInteger = GPA("alGetInteger"); + qalGetFloat = GPA("alGetFloat"); + qalGetDouble = GPA("alGetDouble"); + qalGetError = GPA("alGetError"); + qalIsExtensionPresent = GPA("alIsExtensionPresent"); + qalGetProcAddress = GPA("alGetProcAddress"); + qalGetEnumValue = GPA("alGetEnumValue"); + qalListenerf = GPA("alListenerf"); + qalListener3f = GPA("alListener3f"); + qalListenerfv = GPA("alListenerfv"); + qalListeneri = GPA("alListeneri"); + qalGetListenerf = GPA("alGetListenerf"); + qalGetListener3f = GPA("alGetListener3f"); + qalGetListenerfv = GPA("alGetListenerfv"); + qalGetListeneri = GPA("alGetListeneri"); + qalGenSources = GPA("alGenSources"); + qalDeleteSources = GPA("alDeleteSources"); + qalIsSource = GPA("alIsSource"); + qalSourcef = GPA("alSourcef"); + qalSource3f = GPA("alSource3f"); + qalSourcefv = GPA("alSourcefv"); + qalSourcei = GPA("alSourcei"); + qalGetSourcef = GPA("alGetSourcef"); + qalGetSource3f = GPA("alGetSource3f"); + qalGetSourcefv = GPA("alGetSourcefv"); + qalGetSourcei = GPA("alGetSourcei"); + qalSourcePlayv = GPA("alSourcePlayv"); + qalSourceStopv = GPA("alSourceStopv"); + qalSourceRewindv = GPA("alSourceRewindv"); + qalSourcePausev = GPA("alSourcePausev"); + qalSourcePlay = GPA("alSourcePlay"); + qalSourceStop = GPA("alSourceStop"); + qalSourceRewind = GPA("alSourceRewind"); + qalSourcePause = GPA("alSourcePause"); + qalSourceQueueBuffers = GPA("alSourceQueueBuffers"); + qalSourceUnqueueBuffers = GPA("alSourceUnqueueBuffers"); + qalGenBuffers = GPA("alGenBuffers"); + qalDeleteBuffers = GPA("alDeleteBuffers"); + qalIsBuffer = GPA("alIsBuffer"); + qalBufferData = GPA("alBufferData"); + qalGetBufferf = GPA("alGetBufferf"); + qalGetBufferi = GPA("alGetBufferi"); + qalDopplerFactor = GPA("alDopplerFactor"); + qalSpeedOfSound = GPA("alSpeedOfSound"); + qalDistanceModel = GPA("alDistanceModel"); + + qalcCreateContext = GPA("alcCreateContext"); + qalcMakeContextCurrent = GPA("alcMakeContextCurrent"); + qalcProcessContext = GPA("alcProcessContext"); + qalcSuspendContext = GPA("alcSuspendContext"); + qalcDestroyContext = GPA("alcDestroyContext"); + qalcGetCurrentContext = GPA("alcGetCurrentContext"); + qalcGetContextsDevice = GPA("alcGetContextsDevice"); + qalcOpenDevice = GPA("alcOpenDevice"); + qalcCloseDevice = GPA("alcCloseDevice"); + qalcGetError = GPA("alcGetError"); + qalcIsExtensionPresent = GPA("alcIsExtensionPresent"); + qalcGetProcAddress = GPA("alcGetProcAddress"); + qalcGetEnumValue = GPA("alcGetEnumValue"); + qalcGetString = GPA("alcGetString"); + qalcGetIntegerv = GPA("alcGetIntegerv"); + qalcCaptureOpenDevice = GPA("alcCaptureOpenDevice"); + qalcCaptureCloseDevice = GPA("alcCaptureCloseDevice"); + qalcCaptureStart = GPA("alcCaptureStart"); + qalcCaptureStop = GPA("alcCaptureStop"); + qalcCaptureSamples = GPA("alcCaptureSamples"); + + if(alinit_fail) + { + QAL_Shutdown(); + Com_Printf( " One or more symbols not found\n"); + return qfalse; + } + + return qtrue; +} + +/* +================= +QAL_Shutdown +================= +*/ +void QAL_Shutdown( void ) +{ + if(OpenALLib) + { + Sys_UnloadLibrary(OpenALLib); + OpenALLib = NULL; + } + + qalEnable = NULL; + qalDisable = NULL; + qalIsEnabled = NULL; + qalGetString = NULL; + qalGetBooleanv = NULL; + qalGetIntegerv = NULL; + qalGetFloatv = NULL; + qalGetDoublev = NULL; + qalGetBoolean = NULL; + qalGetInteger = NULL; + qalGetFloat = NULL; + qalGetDouble = NULL; + qalGetError = NULL; + qalIsExtensionPresent = NULL; + qalGetProcAddress = NULL; + qalGetEnumValue = NULL; + qalListenerf = NULL; + qalListener3f = NULL; + qalListenerfv = NULL; + qalListeneri = NULL; + qalGetListenerf = NULL; + qalGetListener3f = NULL; + qalGetListenerfv = NULL; + qalGetListeneri = NULL; + qalGenSources = NULL; + qalDeleteSources = NULL; + qalIsSource = NULL; + qalSourcef = NULL; + qalSource3f = NULL; + qalSourcefv = NULL; + qalSourcei = NULL; + qalGetSourcef = NULL; + qalGetSource3f = NULL; + qalGetSourcefv = NULL; + qalGetSourcei = NULL; + qalSourcePlayv = NULL; + qalSourceStopv = NULL; + qalSourceRewindv = NULL; + qalSourcePausev = NULL; + qalSourcePlay = NULL; + qalSourceStop = NULL; + qalSourceRewind = NULL; + qalSourcePause = NULL; + qalSourceQueueBuffers = NULL; + qalSourceUnqueueBuffers = NULL; + qalGenBuffers = NULL; + qalDeleteBuffers = NULL; + qalIsBuffer = NULL; + qalBufferData = NULL; + qalGetBufferf = NULL; + qalGetBufferi = NULL; + qalDopplerFactor = NULL; + qalSpeedOfSound = NULL; + qalDistanceModel = NULL; + + qalcCreateContext = NULL; + qalcMakeContextCurrent = NULL; + qalcProcessContext = NULL; + qalcSuspendContext = NULL; + qalcDestroyContext = NULL; + qalcGetCurrentContext = NULL; + qalcGetContextsDevice = NULL; + qalcOpenDevice = NULL; + qalcCloseDevice = NULL; + qalcGetError = NULL; + qalcIsExtensionPresent = NULL; + qalcGetProcAddress = NULL; + qalcGetEnumValue = NULL; + qalcGetString = NULL; + qalcGetIntegerv = NULL; + qalcCaptureOpenDevice = NULL; + qalcCaptureCloseDevice = NULL; + qalcCaptureStart = NULL; + qalcCaptureStop = NULL; + qalcCaptureSamples = NULL; +} +#else +qboolean QAL_Init(const char *libname) +{ + return qtrue; +} +void QAL_Shutdown( void ) +{ +} +#endif +#endif diff --git a/code/client/qal.h b/code/client/qal.h new file mode 100644 index 00000000..5a25ec40 --- /dev/null +++ b/code/client/qal.h @@ -0,0 +1,250 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + + +#ifndef __QAL_H__ +#define __QAL_H__ + +#include "../qcommon/q_shared.h" +#include "../qcommon/qcommon.h" + +#ifdef USE_OPENAL_DLOPEN +#define AL_NO_PROTOTYPES +#define ALC_NO_PROTOTYPES +#endif + +#ifdef USE_LOCAL_HEADERS +#include "../AL/al.h" +#include "../AL/alc.h" +#else +#ifdef _MSC_VER + // MSVC users must install the OpenAL SDK which doesn't use the AL/*.h scheme. + #include + #include +#else + #include + #include +#endif +#endif + +/* Hack to enable compiling both on OpenAL SDK and OpenAL-soft. */ +#ifndef ALC_ENUMERATE_ALL_EXT +# define ALC_ENUMERATE_ALL_EXT 1 +# define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 +# define ALC_ALL_DEVICES_SPECIFIER 0x1013 +#endif + +#ifdef USE_OPENAL_DLOPEN +extern LPALENABLE qalEnable; +extern LPALDISABLE qalDisable; +extern LPALISENABLED qalIsEnabled; +extern LPALGETSTRING qalGetString; +extern LPALGETBOOLEANV qalGetBooleanv; +extern LPALGETINTEGERV qalGetIntegerv; +extern LPALGETFLOATV qalGetFloatv; +extern LPALGETDOUBLEV qalGetDoublev; +extern LPALGETBOOLEAN qalGetBoolean; +extern LPALGETINTEGER qalGetInteger; +extern LPALGETFLOAT qalGetFloat; +extern LPALGETDOUBLE qalGetDouble; +extern LPALGETERROR qalGetError; +extern LPALISEXTENSIONPRESENT qalIsExtensionPresent; +extern LPALGETPROCADDRESS qalGetProcAddress; +extern LPALGETENUMVALUE qalGetEnumValue; +extern LPALLISTENERF qalListenerf; +extern LPALLISTENER3F qalListener3f; +extern LPALLISTENERFV qalListenerfv; +extern LPALLISTENERI qalListeneri; +extern LPALLISTENER3I qalListener3i; +extern LPALLISTENERIV qalListeneriv; +extern LPALGETLISTENERF qalGetListenerf; +extern LPALGETLISTENER3F qalGetListener3f; +extern LPALGETLISTENERFV qalGetListenerfv; +extern LPALGETLISTENERI qalGetListeneri; +extern LPALGETLISTENER3I qalGetListener3i; +extern LPALGETLISTENERIV qalGetListeneriv; +extern LPALGENSOURCES qalGenSources; +extern LPALDELETESOURCES qalDeleteSources; +extern LPALISSOURCE qalIsSource; +extern LPALSOURCEF qalSourcef; +extern LPALSOURCE3F qalSource3f; +extern LPALSOURCEFV qalSourcefv; +extern LPALSOURCEI qalSourcei; +extern LPALSOURCE3I qalSource3i; +extern LPALSOURCEIV qalSourceiv; +extern LPALGETSOURCEF qalGetSourcef; +extern LPALGETSOURCE3F qalGetSource3f; +extern LPALGETSOURCEFV qalGetSourcefv; +extern LPALGETSOURCEI qalGetSourcei; +extern LPALGETSOURCE3I qalGetSource3i; +extern LPALGETSOURCEIV qalGetSourceiv; +extern LPALSOURCEPLAYV qalSourcePlayv; +extern LPALSOURCESTOPV qalSourceStopv; +extern LPALSOURCEREWINDV qalSourceRewindv; +extern LPALSOURCEPAUSEV qalSourcePausev; +extern LPALSOURCEPLAY qalSourcePlay; +extern LPALSOURCESTOP qalSourceStop; +extern LPALSOURCEREWIND qalSourceRewind; +extern LPALSOURCEPAUSE qalSourcePause; +extern LPALSOURCEQUEUEBUFFERS qalSourceQueueBuffers; +extern LPALSOURCEUNQUEUEBUFFERS qalSourceUnqueueBuffers; +extern LPALGENBUFFERS qalGenBuffers; +extern LPALDELETEBUFFERS qalDeleteBuffers; +extern LPALISBUFFER qalIsBuffer; +extern LPALBUFFERDATA qalBufferData; +extern LPALBUFFERF qalBufferf; +extern LPALBUFFER3F qalBuffer3f; +extern LPALBUFFERFV qalBufferfv; +extern LPALBUFFERF qalBufferi; +extern LPALBUFFER3F qalBuffer3i; +extern LPALBUFFERFV qalBufferiv; +extern LPALGETBUFFERF qalGetBufferf; +extern LPALGETBUFFER3F qalGetBuffer3f; +extern LPALGETBUFFERFV qalGetBufferfv; +extern LPALGETBUFFERI qalGetBufferi; +extern LPALGETBUFFER3I qalGetBuffer3i; +extern LPALGETBUFFERIV qalGetBufferiv; +extern LPALDOPPLERFACTOR qalDopplerFactor; +extern LPALSPEEDOFSOUND qalSpeedOfSound; +extern LPALDISTANCEMODEL qalDistanceModel; + +extern LPALCCREATECONTEXT qalcCreateContext; +extern LPALCMAKECONTEXTCURRENT qalcMakeContextCurrent; +extern LPALCPROCESSCONTEXT qalcProcessContext; +extern LPALCSUSPENDCONTEXT qalcSuspendContext; +extern LPALCDESTROYCONTEXT qalcDestroyContext; +extern LPALCGETCURRENTCONTEXT qalcGetCurrentContext; +extern LPALCGETCONTEXTSDEVICE qalcGetContextsDevice; +extern LPALCOPENDEVICE qalcOpenDevice; +extern LPALCCLOSEDEVICE qalcCloseDevice; +extern LPALCGETERROR qalcGetError; +extern LPALCISEXTENSIONPRESENT qalcIsExtensionPresent; +extern LPALCGETPROCADDRESS qalcGetProcAddress; +extern LPALCGETENUMVALUE qalcGetEnumValue; +extern LPALCGETSTRING qalcGetString; +extern LPALCGETINTEGERV qalcGetIntegerv; +extern LPALCCAPTUREOPENDEVICE qalcCaptureOpenDevice; +extern LPALCCAPTURECLOSEDEVICE qalcCaptureCloseDevice; +extern LPALCCAPTURESTART qalcCaptureStart; +extern LPALCCAPTURESTOP qalcCaptureStop; +extern LPALCCAPTURESAMPLES qalcCaptureSamples; +#else +#define qalEnable alEnable +#define qalDisable alDisable +#define qalIsEnabled alIsEnabled +#define qalGetString alGetString +#define qalGetBooleanv alGetBooleanv +#define qalGetIntegerv alGetIntegerv +#define qalGetFloatv alGetFloatv +#define qalGetDoublev alGetDoublev +#define qalGetBoolean alGetBoolean +#define qalGetInteger alGetInteger +#define qalGetFloat alGetFloat +#define qalGetDouble alGetDouble +#define qalGetError alGetError +#define qalIsExtensionPresent alIsExtensionPresent +#define qalGetProcAddress alGetProcAddress +#define qalGetEnumValue alGetEnumValue +#define qalListenerf alListenerf +#define qalListener3f alListener3f +#define qalListenerfv alListenerfv +#define qalListeneri alListeneri +#define qalListener3i alListener3i +#define qalListeneriv alListeneriv +#define qalGetListenerf alGetListenerf +#define qalGetListener3f alGetListener3f +#define qalGetListenerfv alGetListenerfv +#define qalGetListeneri alGetListeneri +#define qalGetListener3i alGetListener3i +#define qalGetListeneriv alGetListeneriv +#define qalGenSources alGenSources +#define qalDeleteSources alDeleteSources +#define qalIsSource alIsSource +#define qalSourcef alSourcef +#define qalSource3f alSource3f +#define qalSourcefv alSourcefv +#define qalSourcei alSourcei +#define qalSource3i alSource3i +#define qalSourceiv alSourceiv +#define qalGetSourcef alGetSourcef +#define qalGetSource3f alGetSource3f +#define qalGetSourcefv alGetSourcefv +#define qalGetSourcei alGetSourcei +#define qalGetSource3i alGetSource3i +#define qalGetSourceiv alGetSourceiv +#define qalSourcePlayv alSourcePlayv +#define qalSourceStopv alSourceStopv +#define qalSourceRewindv alSourceRewindv +#define qalSourcePausev alSourcePausev +#define qalSourcePlay alSourcePlay +#define qalSourceStop alSourceStop +#define qalSourceRewind alSourceRewind +#define qalSourcePause alSourcePause +#define qalSourceQueueBuffers alSourceQueueBuffers +#define qalSourceUnqueueBuffers alSourceUnqueueBuffers +#define qalGenBuffers alGenBuffers +#define qalDeleteBuffers alDeleteBuffers +#define qalIsBuffer alIsBuffer +#define qalBufferData alBufferData +#define qalBufferf alBufferf +#define qalBuffer3f alBuffer3f +#define qalBufferfv alBufferfv +#define qalBufferi alBufferi +#define qalBuffer3i alBuffer3i +#define qalBufferiv alBufferiv +#define qalGetBufferf alGetBufferf +#define qalGetBuffer3f alGetBuffer3f +#define qalGetBufferfv alGetBufferfv +#define qalGetBufferi alGetBufferi +#define qalGetBuffer3i alGetBuffer3i +#define qalGetBufferiv alGetBufferiv +#define qalDopplerFactor alDopplerFactor +#define qalSpeedOfSound alSpeedOfSound +#define qalDistanceModel alDistanceModel + +#define qalcCreateContext alcCreateContext +#define qalcMakeContextCurrent alcMakeContextCurrent +#define qalcProcessContext alcProcessContext +#define qalcSuspendContext alcSuspendContext +#define qalcDestroyContext alcDestroyContext +#define qalcGetCurrentContext alcGetCurrentContext +#define qalcGetContextsDevice alcGetContextsDevice +#define qalcOpenDevice alcOpenDevice +#define qalcCloseDevice alcCloseDevice +#define qalcGetError alcGetError +#define qalcIsExtensionPresent alcIsExtensionPresent +#define qalcGetProcAddress alcGetProcAddress +#define qalcGetEnumValue alcGetEnumValue +#define qalcGetString alcGetString +#define qalcGetIntegerv alcGetIntegerv +#define qalcCaptureOpenDevice alcCaptureOpenDevice +#define qalcCaptureCloseDevice alcCaptureCloseDevice +#define qalcCaptureStart alcCaptureStart +#define qalcCaptureStop alcCaptureStop +#define qalcCaptureSamples alcCaptureSamples +#endif + +qboolean QAL_Init(const char *libname); +void QAL_Shutdown( void ); + +#endif // __QAL_H__ diff --git a/code/client/skeletor_imports.cpp b/code/client/skeletor_imports.cpp new file mode 100644 index 00000000..21fb61e1 --- /dev/null +++ b/code/client/skeletor_imports.cpp @@ -0,0 +1,58 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// skeletor_imports.cpp : Skeletor imports + +#include "q_shared.h" +#include "qcommon.h" + +void Skel_DPrintf( const char *fmt, ... ) +{ + char msg[ 4096 ]; + va_list va; + + va_start( va, fmt ); + vsprintf( msg, fmt, va ); + va_end( va ); + + Com_DPrintf( "%s", msg ); +} + +void Skel_Free( void *ptr ) +{ + Z_Free( ptr ); +} + +void *Skel_Alloc( size_t size ) +{ + return Z_TagMalloc( size, TAG_SKEL ); +} + +void Skel_FreeFile( void *buffer ) +{ + FS_FreeFile( buffer ); +} + +int Skel_ReadFileEx( const char *qpath, void **buffer, qboolean quiet ) +{ + return FS_ReadFileEx( qpath, buffer, quiet ); +} diff --git a/code/client/snd_adpcm.c b/code/client/snd_adpcm.c new file mode 100644 index 00000000..01aeff65 --- /dev/null +++ b/code/client/snd_adpcm.c @@ -0,0 +1,333 @@ +/*********************************************************** +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. + +******************************************************************/ + +/* +** Intel/DVI ADPCM coder/decoder. +** +** The algorithm for this coder was taken from the IMA Compatability Project +** proceedings, Vol 2, Number 2; May 1992. +** +** Version 1.2, 18-Dec-92. +*/ + +#include "snd_local.h" + + +/* Intel ADPCM step variation table */ +static int indexTable[ 16 ] = { + -1, -1, -1, -1, 2, 4, 6, 8, + -1, -1, -1, -1, 2, 4, 6, 8, +}; + +static int stepsizeTable[ 89 ] = { + 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, + 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, + 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, + 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, + 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, + 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, + 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, + 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, + 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 +}; + + +void S_AdpcmEncode( short indata[], char outdata[], int len, struct adpcm_state *state ) { + short *inp; /* Input buffer pointer */ + signed char *outp; /* output buffer pointer */ + int val; /* Current input sample value */ + int sign; /* Current adpcm sign bit */ + int delta; /* Current adpcm output value */ + int diff; /* Difference between val and sample */ + int step; /* Stepsize */ + int valpred; /* Predicted output value */ + int vpdiff; /* Current change to valpred */ + int index; /* Current step change index */ + int outputbuffer; /* place to keep previous 4-bit value */ + int bufferstep; /* toggle between outputbuffer/output */ + + outp = ( signed char * )outdata; + inp = indata; + + valpred = state->sample; + index = state->index; + step = stepsizeTable[ index ]; + + outputbuffer = 0; // quiet a compiler warning + bufferstep = 1; + + for( ; len > 0; len-- ) { + val = *inp++; + + /* Step 1 - compute difference with previous value */ + diff = val - valpred; + sign = ( diff < 0 ) ? 8 : 0; + if( sign ) diff = ( -diff ); + + /* Step 2 - Divide and clamp */ + /* Note: + ** This code *approximately* computes: + ** delta = diff*4/step; + ** vpdiff = (delta+0.5)*step/4; + ** but in shift step bits are dropped. The net result of this is + ** that even if you have fast mul/div hardware you cannot put it to + ** good use since the fixup would be too expensive. + */ + delta = 0; + vpdiff = ( step >> 3 ); + + if( diff >= step ) { + delta = 4; + diff -= step; + vpdiff += step; + } + step >>= 1; + if( diff >= step ) { + delta |= 2; + diff -= step; + vpdiff += step; + } + step >>= 1; + if( diff >= step ) { + delta |= 1; + vpdiff += step; + } + + /* Step 3 - Update previous value */ + if( sign ) + valpred -= vpdiff; + else + valpred += vpdiff; + + /* Step 4 - Clamp previous value to 16 bits */ + if( valpred > 32767 ) + valpred = 32767; + else if( valpred < -32768 ) + valpred = -32768; + + /* Step 5 - Assemble value, update index and step values */ + delta |= sign; + + index += indexTable[ delta ]; + if( index < 0 ) index = 0; + if( index > 88 ) index = 88; + step = stepsizeTable[ index ]; + + /* Step 6 - Output value */ + if( bufferstep ) { + outputbuffer = ( delta << 4 ) & 0xf0; + } + else { + *outp++ = ( delta & 0x0f ) | outputbuffer; + } + bufferstep = !bufferstep; + } + + /* Output last step, if needed */ + if( !bufferstep ) + *outp++ = outputbuffer; + + state->sample = valpred; + state->index = index; +} + + +/* static */ void S_AdpcmDecode( const char indata[], short *outdata, int len, struct adpcm_state *state ) { + signed char *inp; /* Input buffer pointer */ + int outp; /* output buffer pointer */ + int sign; /* Current adpcm sign bit */ + int delta; /* Current adpcm output value */ + int step; /* Stepsize */ + int valpred; /* Predicted value */ + int vpdiff; /* Current change to valpred */ + int index; /* Current step change index */ + int inputbuffer; /* place to keep next 4-bit value */ + int bufferstep; /* toggle between inputbuffer/input */ + + outp = 0; + inp = ( signed char * )indata; + + valpred = state->sample; + index = state->index; + step = stepsizeTable[ index ]; + + bufferstep = 0; + inputbuffer = 0; // quiet a compiler warning + for( ; len > 0; len-- ) { + + /* Step 1 - get the delta value */ + if( bufferstep ) { + delta = inputbuffer & 0xf; + } + else { + inputbuffer = *inp++; + delta = ( inputbuffer >> 4 ) & 0xf; + } + bufferstep = !bufferstep; + + /* Step 2 - Find new index value (for later) */ + index += indexTable[ delta ]; + if( index < 0 ) index = 0; + if( index > 88 ) index = 88; + + /* Step 3 - Separate sign and magnitude */ + sign = delta & 8; + delta = delta & 7; + + /* Step 4 - Compute difference and new predicted value */ + /* + ** Computes 'vpdiff = (delta+0.5)*step/4', but see comment + ** in adpcm_coder. + */ + vpdiff = step >> 3; + if( delta & 4 ) vpdiff += step; + if( delta & 2 ) vpdiff += step >> 1; + if( delta & 1 ) vpdiff += step >> 2; + + if( sign ) + valpred -= vpdiff; + else + valpred += vpdiff; + + /* Step 5 - clamp output value */ + if( valpred > 32767 ) + valpred = 32767; + else if( valpred < -32768 ) + valpred = -32768; + + /* Step 6 - Update step value */ + step = stepsizeTable[ index ]; + + /* Step 7 - Output value */ + outdata[ outp ] = valpred; + outp++; + } + + state->sample = valpred; + state->index = index; +} + + +/* +==================== +S_AdpcmMemoryNeeded + +Returns the amount of memory (in bytes) needed to store the samples in out internal adpcm format +==================== +*/ +int S_AdpcmMemoryNeeded( const wavinfo_t *info ) { + float scale; + int scaledSampleCount; + int sampleMemory; + int blockCount; + int headerMemory; + + // determine scale to convert from input sampling rate to desired sampling rate + scale = ( float )info->rate / dma.speed; + + // calc number of samples at playback sampling rate + scaledSampleCount = info->samples / scale; + + // calc memory need to store those samples using ADPCM at 4 bits per sample + sampleMemory = scaledSampleCount / 2; + + // calc number of sample blocks needed of PAINTBUFFER_SIZE + blockCount = scaledSampleCount / PAINTBUFFER_SIZE; + if( scaledSampleCount % PAINTBUFFER_SIZE ) { + blockCount++; + } + + // calc memory needed to store the block headers + headerMemory = blockCount * sizeof( adpcm_state_t ); + + return sampleMemory + headerMemory; +} + + +/* +==================== +S_AdpcmGetSamples +==================== +*/ +void S_AdpcmGetSamples( sndBuffer *chunk, short *to ) { + adpcm_state_t state; + byte *out; + + // get the starting state from the block header + state.index = chunk->adpcm.index; + state.sample = chunk->adpcm.sample; + + out = ( byte * )chunk->sndChunk; + // get samples + S_AdpcmDecode( ( char * )out, to, SND_CHUNK_SIZE_BYTE * 2, &state ); +} + + +/* +==================== +S_AdpcmEncodeSound +==================== +*/ +void S_AdpcmEncodeSound( sfx_t *sfx, short *samples ) { + adpcm_state_t state; + int inOffset; + int count; + int n; + sndBuffer *newchunk, *chunk; + byte *out; + + inOffset = 0; + count = sfx->soundLength; + state.index = 0; + state.sample = samples[ 0 ]; + + chunk = NULL; + while( count ) { + n = count; + if( n > SND_CHUNK_SIZE_BYTE * 2 ) { + n = SND_CHUNK_SIZE_BYTE * 2; + } + + newchunk = SND_malloc(); + if( sfx->soundData == NULL ) { + sfx->soundData = newchunk; + } + else if( chunk != NULL ) { + chunk->next = newchunk; + } + chunk = newchunk; + + // output the header + chunk->adpcm.index = state.index; + chunk->adpcm.sample = state.sample; + + out = ( byte * )chunk->sndChunk; + + // encode the samples + S_AdpcmEncode( samples + inOffset, ( char * )out, n, &state ); + + inOffset += n; + count -= n; + } +} diff --git a/code/client/snd_codec.c b/code/client/snd_codec.c new file mode 100644 index 00000000..bb7acb1b --- /dev/null +++ b/code/client/snd_codec.c @@ -0,0 +1,240 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "client.h" +#include "snd_codec.h" + +static snd_codec_t *codecs; + +/* +================= +S_FileExtension +================= +*/ +static char *S_FileExtension(const char *fni) +{ + // we should search from the ending to the last '/' + + char *fn = (char *) fni + strlen(fni) - 1; + char *eptr = NULL; + + while(*fn != '/' && fn != fni) + { + if(*fn == '.') + { + eptr = fn; + break; + } + fn--; + } + + return eptr; +} + +/* +================= +S_FindCodecForFile + +Select an appropriate codec for a file based on its extension +================= +*/ +static snd_codec_t *S_FindCodecForFile(const char *filename) +{ + char *ext = S_FileExtension(filename); + snd_codec_t *codec = codecs; + + if(!ext) + { + // No extension - auto-detect + while(codec) + { + char fn[MAX_QPATH]; + + // there is no extension so we do not need to subtract 4 chars + Q_strncpyz(fn, filename, MAX_QPATH); + COM_DefaultExtension(fn, MAX_QPATH, codec->ext); + + // Check it exists + if( FS_ReadFile( fn, NULL ) != -1 ) + return codec; + + // Nope. Next! + codec = codec->next; + } + + // Nothin' + return NULL; + } + + while(codec) + { + if(!Q_stricmp(ext, codec->ext)) + return codec; + codec = codec->next; + } + + return NULL; +} + +/* +================= +S_CodecInit +================= +*/ +void S_CodecInit() +{ + codecs = NULL; + S_CodecRegister(&wav_codec); +#ifdef USE_CODEC_VORBIS + S_CodecRegister(&ogg_codec); +#endif +#if USE_CODEC_MP3 + S_CodecRegister(&mp3_codec); +#endif +} + +/* +================= +S_CodecShutdown +================= +*/ +void S_CodecShutdown() +{ + codecs = NULL; +} + +/* +================= +S_CodecRegister +================= +*/ +void S_CodecRegister(snd_codec_t *codec) +{ + codec->next = codecs; + codecs = codec; +} + +/* +================= +S_CodecLoad +================= +*/ +void *S_CodecLoad(const char *filename, snd_info_t *info) +{ + snd_codec_t *codec; + char fn[MAX_QPATH]; + + codec = S_FindCodecForFile(filename); + if(!codec) + { + Com_Printf("Unknown extension for %s\n", filename); + return NULL; + } + + strncpy(fn, filename, sizeof(fn)); + COM_DefaultExtension(fn, sizeof(fn), codec->ext); + + return codec->load(fn, info); +} + +/* +================= +S_CodecOpenStream +================= +*/ +snd_stream_t *S_CodecOpenStream(const char *filename) +{ + snd_codec_t *codec; + char fn[MAX_QPATH]; + + codec = S_FindCodecForFile(filename); + if(!codec) + { + Com_Printf("Unknown extension for %s\n", filename); + return NULL; + } + + strncpy(fn, filename, sizeof(fn)); + COM_DefaultExtension(fn, sizeof(fn), codec->ext); + + return codec->open(fn); +} + +void S_CodecCloseStream(snd_stream_t *stream) +{ + stream->codec->close(stream); +} + +int S_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer) +{ + return stream->codec->read(stream, bytes, buffer); +} + +//======================================================================= +// Util functions (used by codecs) + +/* +================= +S_CodecUtilOpen +================= +*/ +snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec) +{ + snd_stream_t *stream; + fileHandle_t hnd; + int length; + + // Try to open the file + length = FS_FOpenFileRead(filename, &hnd, qtrue, qtrue); + if(!hnd) + { + Com_Printf("Can't read sound file %s\n", filename); + return NULL; + } + + // Allocate a stream + stream = Z_Malloc(sizeof(snd_stream_t)); + if(!stream) + { + FS_FCloseFile(hnd); + return NULL; + } + + // Copy over, return + stream->codec = codec; + stream->file = hnd; + stream->length = length; + return stream; +} + +/* +================= +S_CodecUtilClose +================= +*/ +void S_CodecUtilClose(snd_stream_t **stream) +{ + FS_FCloseFile((*stream)->file); + Z_Free(*stream); + *stream = NULL; +} diff --git a/code/client/snd_codec.h b/code/client/snd_codec.h new file mode 100644 index 00000000..ed6ae8d5 --- /dev/null +++ b/code/client/snd_codec.h @@ -0,0 +1,115 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef _SND_CODEC_H_ +#define _SND_CODEC_H_ + +#include "../qcommon/q_shared.h" +#include "../qcommon/qcommon.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct snd_info_s +{ + int rate; + int width; + int channels; + int samples; + int size; + int dataofs; +} snd_info_t; + +typedef struct snd_codec_s snd_codec_t; + +typedef struct snd_stream_s +{ + snd_codec_t *codec; + fileHandle_t file; + snd_info_t info; + int length; + int pos; + void *ptr; +} snd_stream_t; + +// Codec functions +typedef void *(*CODEC_LOAD)(const char *filename, snd_info_t *info); +typedef snd_stream_t *(*CODEC_OPEN)(const char *filename); +typedef int (*CODEC_READ)(snd_stream_t *stream, int bytes, void *buffer); +typedef void (*CODEC_CLOSE)(snd_stream_t *stream); + +// Codec data structure +struct snd_codec_s +{ + char *ext; + CODEC_LOAD load; + CODEC_OPEN open; + CODEC_READ read; + CODEC_CLOSE close; + snd_codec_t *next; +}; + +// Codec management +void S_CodecInit( void ); +void S_CodecShutdown( void ); +void S_CodecRegister(snd_codec_t *codec); +void *S_CodecLoad(const char *filename, snd_info_t *info); +snd_stream_t *S_CodecOpenStream(const char *filename); +void S_CodecCloseStream(snd_stream_t *stream); +int S_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); + +// Util functions (used by codecs) +snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec); +void S_CodecUtilClose(snd_stream_t **stream); + +// WAV Codec +extern snd_codec_t wav_codec; +void *S_WAV_CodecLoad(const char *filename, snd_info_t *info); +snd_stream_t *S_WAV_CodecOpenStream(const char *filename); +void S_WAV_CodecCloseStream(snd_stream_t *stream); +int S_WAV_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); + +// Ogg Vorbis codec +#ifdef USE_CODEC_VORBIS +extern snd_codec_t ogg_codec; +void *S_OGG_CodecLoad(const char *filename, snd_info_t *info); +snd_stream_t *S_OGG_CodecOpenStream(const char *filename); +void S_OGG_CodecCloseStream(snd_stream_t *stream); +int S_OGG_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); +#endif // USE_CODEC_VORBIS + +#if USE_CODEC_MP3 +// MP3 codec +extern snd_codec_t mp3_codec; +void *S_MP3_CodecLoad(const char *filename, snd_info_t *info); +snd_stream_t *S_MP3_CodecOpenStream(const char *filename); +void S_MP3_CodecCloseStream(snd_stream_t *stream); +int S_MP3_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); +#endif + +#ifdef __cplusplus +} +#endif + +#endif // !_SND_CODEC_H_ diff --git a/code/client/snd_codec_mp3.c b/code/client/snd_codec_mp3.c new file mode 100644 index 00000000..ba574577 --- /dev/null +++ b/code/client/snd_codec_mp3.c @@ -0,0 +1,717 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) +Copyright (C) 2005-2006 Joerg Dietrich +Copyright (C) 2006 Thilo Schulz + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#if USE_CODEC_MP3 + +// includes for the Q3 sound system +#include "client.h" +#include "snd_codec.h" + +// includes for the MP3 codec +#include + +#define MP3_SAMPLE_WIDTH 2 +#define MP3_PCMSAMPLES_PERSLICE 32 + +// buffer size used when reading through the mp3 +#define MP3_DATA_BUFSIZ 128*1024 + +// undefine this if you don't want any dithering. +#define MP3_DITHERING + +// Q3 MP3 codec +snd_codec_t mp3_codec = +{ + ".mp3", + S_MP3_CodecLoad, + S_MP3_CodecOpenStream, + S_MP3_CodecReadStream, + S_MP3_CodecCloseStream, + NULL +}; + +// structure used for info purposes +struct snd_codec_mp3_info +{ + byte encbuf[MP3_DATA_BUFSIZ]; // left over bytes not consumed + // by the decoder. + struct mad_stream madstream; // uses encbuf as buffer. + struct mad_frame madframe; // control structures for libmad. + struct mad_synth madsynth; + + byte *pcmbuf; // buffer for not-used samples. + int buflen; // length of buffer data. + int pcmbufsize; // amount of allocated memory for + // pcmbuf. This should have at least + // the size of a decoded mp3 frame. + + byte *dest; // copy decoded data here. + int destlen; // amount of already copied data. + int destsize; // amount of bytes we must decode. +}; + +/*************** MP3 utility functions ***************/ + +/* +================= +S_MP3_ReadData +================= +*/ + +// feed libmad with data +int S_MP3_ReadData(snd_stream_t *stream, struct mad_stream *madstream, byte *encbuf, int encbufsize) +{ + int retval; + int leftover; + + if(!stream) + return -1; + + leftover = madstream->bufend - madstream->next_frame; + if(leftover > 0) + memmove(encbuf, madstream->this_frame, leftover); + + + // Fill the buffer right to the end + + retval = FS_Read(&encbuf[leftover], encbufsize - leftover, stream->file); + + if(retval <= 0) + { + // EOF reached, that's ok. + return 0; + } + + mad_stream_buffer(madstream, encbuf, retval + leftover); + + return retval; +} + + +/* +================= +S_MP3_Scanfile + +to determine the samplecount, we apparently must get *all* headers :( +I basically used the xmms-mad plugin source to see how this stuff works. + +returns a value < 0 on error. +================= +*/ + +int S_MP3_Scanfile(snd_stream_t *stream) +{ + struct mad_stream madstream; + struct mad_header madheader; + int retval; + int samplecount; + byte encbuf[MP3_DATA_BUFSIZ]; + + // error out on invalid input. + if(!stream) + return -1; + + mad_stream_init(&madstream); + mad_header_init(&madheader); + + while(1) + { + retval = S_MP3_ReadData(stream, &madstream, encbuf, sizeof(encbuf)); + if(retval < 0) + return -1; + else if(retval == 0) + break; + + // Start decoding the headers. + while(1) + { + if((retval = mad_header_decode(&madheader, &madstream)) < 0) + { + if(madstream.error == MAD_ERROR_BUFLEN) + { + // We need to read more data + break; + } + + if(!MAD_RECOVERABLE (madstream.error)) + { + // unrecoverable error... we must bail out. + return retval; + } + + mad_stream_skip(&madstream, madstream.skiplen); + continue; + } + + // we got a valid header. + + if(madheader.layer != MAD_LAYER_III) + { + // we don't support non-mp3s + return -1; + } + + if(!stream->info.samples) + { + // This here is the very first frame. Set initial values now, + // that we expect to stay constant throughout the whole mp3. + + stream->info.rate = madheader.samplerate; + stream->info.width = MP3_SAMPLE_WIDTH; + stream->info.channels = MAD_NCHANNELS(&madheader); + stream->info.samples = 0; + stream->info.size = 0; // same here. + stream->info.dataofs = 0; + } + else + { + // Check whether something changed that shouldn't. + + if(stream->info.rate != madheader.samplerate || + stream->info.channels != MAD_NCHANNELS(&madheader)) + return -1; + } + + // Update the counters + samplecount = MAD_NSBSAMPLES(&madheader) * MP3_PCMSAMPLES_PERSLICE; + stream->info.samples += samplecount; + stream->info.size += samplecount * stream->info.channels * stream->info.width; + } + } + + // Reset the file pointer so we can do the real decoding. + FS_Seek(stream->file, 0, FS_SEEK_SET); + + return 0; +} + +/************************ dithering functions ***************************/ + +#ifdef MP3_DITHERING + +// All dithering done here is taken from the GPL'ed xmms-mad plugin. + +/* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. */ +/* Any feedback is very welcome. For any question, comments, */ +/* see http://www.math.keio.ac.jp/matumoto/emt.html or email */ +/* matumoto@math.keio.ac.jp */ + +/* Period parameters */ +#define MP3_DITH_N 624 +#define MP3_DITH_M 397 +#define MATRIX_A 0x9908b0df /* constant vector a */ +#define UPPER_MASK 0x80000000 /* most significant w-r bits */ +#define LOWER_MASK 0x7fffffff /* least significant r bits */ + +/* Tempering parameters */ +#define TEMPERING_MASK_B 0x9d2c5680 +#define TEMPERING_MASK_C 0xefc60000 +#define TEMPERING_SHIFT_U(y) (y >> 11) +#define TEMPERING_SHIFT_S(y) (y << 7) +#define TEMPERING_SHIFT_T(y) (y << 15) +#define TEMPERING_SHIFT_L(y) (y >> 18) + +static unsigned long mt[MP3_DITH_N]; /* the array for the state vector */ +static int mti=MP3_DITH_N+1; /* mti==MP3_DITH_N+1 means mt[MP3_DITH_N] is not initialized */ + +/* initializing the array with a NONZERO seed */ +void sgenrand(unsigned long seed) +{ + /* setting initial seeds to mt[MP3_DITH_N] using */ + /* the generator Line 25 of Table 1 in */ + /* [KNUTH 1981, The Art of Computer Programming */ + /* Vol. 2 (2nd Ed.), pp102] */ + mt[0]= seed & 0xffffffff; + for (mti=1; mti= MP3_DITH_N) { /* generate MP3_DITH_N words at one time */ + int kk; + + if (mti == MP3_DITH_N+1) /* if sgenrand() has not been called, */ + sgenrand(4357); /* a default initial seed is used */ + + for (kk=0;kk> 1) ^ mag01[y & 0x1]; + } + for (;kk> 1) ^ mag01[y & 0x1]; + } + y = (mt[MP3_DITH_N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); + mt[MP3_DITH_N-1] = mt[MP3_DITH_M-1] ^ (y >> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= TEMPERING_SHIFT_U(y); + y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; + y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C; + y ^= TEMPERING_SHIFT_L(y); + + return y; +} + +long triangular_dither_noise(int nbits) { + // parameter nbits : the peak-to-peak amplitude desired (in bits) + // use with nbits set to 2 + nber of bits to be trimmed. + // (because triangular is made from two uniformly distributed processes, + // it starts at 2 bits peak-to-peak amplitude) + // see The Theory of Dithered Quantization by Robert Alexander Wannamaker + // for complete proof of why that's optimal + + long v = (genrand()/2 - genrand()/2); // in ]-2^31, 2^31[ + //int signe = (v>0) ? 1 : -1; + long P = 1 << (32 - nbits); // the power of 2 + v /= P; + // now v in ]-2^(nbits-1), 2^(nbits-1) [ + + return v; +} + +#endif // MP3_DITHERING + +/************************ decoder functions ***************************/ + +/* +================= +S_MP3_Scale + +Converts the signal to 16 bit LE-PCM data and does dithering. + +- borrowed from xmms-mad plugin source. +================= +*/ + +/* + * xmms-mad - mp3 plugin for xmms + * Copyright (C) 2001-2002 Sam Clegg + */ + +signed int S_MP3_Scale(mad_fixed_t sample) +{ + int n_bits_to_loose = MAD_F_FRACBITS + 1 - 16; +#ifdef MP3_DITHERING + int dither; +#endif + + // round + sample += (1L << (n_bits_to_loose - 1)); + +#ifdef MP3_DITHERING + dither = triangular_dither_noise(n_bits_to_loose + 1); + sample += dither; +#endif + + /* clip */ + if (sample >= MAD_F_ONE) + sample = MAD_F_ONE - 1; + else if (sample < -MAD_F_ONE) + sample = -MAD_F_ONE; + + /* quantize */ + return sample >> n_bits_to_loose; +} + + + +/* +================= +S_MP3_PCMCopy + +Copy and convert pcm data until bytecount bytes have been written. +return the position in pcm->samples. +indicate the amount of actually written bytes in wrotecnt. +================= +*/ + +int S_MP3_PCMCopy(byte *buf, struct mad_pcm *pcm, int bufofs, + int sampleofs, int bytecount, int *wrotecnt) +{ + int written = 0; + signed int sample; + int framesize = pcm->channels * MP3_SAMPLE_WIDTH; + + // add new pcm data. + while(written < bytecount && sampleofs < pcm->length) + { + sample = S_MP3_Scale(pcm->samples[0][sampleofs]); + +#ifdef Q3_BIG_ENDIAN + // output to 16 bit big endian PCM + buf[bufofs++] = (sample >> 8) & 0xff; + buf[bufofs++] = sample & 0xff; +#else + // output to 16 bit little endian PCM + buf[bufofs++] = sample & 0xff; + buf[bufofs++] = (sample >> 8) & 0xff; +#endif + + if(pcm->channels == 2) + { + sample = S_MP3_Scale(pcm->samples[1][sampleofs]); + +#ifdef Q3_BIG_ENDIAN + buf[bufofs++] = (sample >> 8) & 0xff; + buf[bufofs++] = sample & 0xff; +#else + buf[bufofs++] = sample & 0xff; + buf[bufofs++] = (sample >> 8) & 0xff; +#endif + } + + sampleofs++; + written += framesize; + } + + if(wrotecnt) + *wrotecnt = written; + + return sampleofs; +} + + +/* +================= +S_MP3_Decode +================= +*/ + +// gets executed for every decoded frame. +int S_MP3_Decode(snd_stream_t *stream) +{ + struct snd_codec_mp3_info *mp3info; + struct mad_stream *madstream; + struct mad_frame *madframe; + struct mad_synth *madsynth; + struct mad_pcm *pcm; + int cursize; + int samplecount; + int needcount; + int wrote; + int retval; + + if(!stream) + return -1; + + mp3info = stream->ptr; + madstream = &mp3info->madstream; + madframe = &mp3info->madframe; + + if(mad_frame_decode(madframe, madstream)) + { + if(madstream->error == MAD_ERROR_BUFLEN) + { + // we need more data. Read another chunk. + retval = S_MP3_ReadData(stream, madstream, mp3info->encbuf, sizeof(mp3info->encbuf)); + + // call myself again now that buffer is full. + if(retval > 0) + retval = S_MP3_Decode(stream); + } + else if(MAD_RECOVERABLE(madstream->error)) + { + mad_stream_skip(madstream, madstream->skiplen); + return S_MP3_Decode(stream); + } + else + retval = -1; + + return retval; + } + + // check whether this really is an mp3 + if(madframe->header.layer != MAD_LAYER_III) + return -1; + + // generate pcm data + madsynth = &mp3info->madsynth; + mad_synth_frame(madsynth, madframe); + + pcm = &madsynth->pcm; + + // perform a few checks to see whether something changed that shouldn't. + + if(stream->info.rate != pcm->samplerate || + stream->info.channels != pcm->channels) + { + return -1; + } + // see whether we have got enough data now. + cursize = pcm->length * pcm->channels * stream->info.width; + needcount = mp3info->destsize - mp3info->destlen; + + // Copy exactly as many samples as required. + samplecount = S_MP3_PCMCopy(mp3info->dest, pcm, + mp3info->destlen, 0, needcount, &wrote); + mp3info->destlen += wrote; + + if(samplecount < pcm->length) + { + // Not all samples got copied. Copy the rest into the pcm buffer. + samplecount = S_MP3_PCMCopy(mp3info->pcmbuf, pcm, + mp3info->buflen, + samplecount, + mp3info->pcmbufsize - mp3info->buflen, + &wrote); + mp3info->buflen += wrote; + + + if(samplecount < pcm->length) + { + // The pcm buffer was not large enough. Make it bigger. + byte *newbuf = Z_Malloc(cursize); + + if(mp3info->pcmbuf) + { + memcpy(newbuf, mp3info->pcmbuf, mp3info->buflen); + Z_Free(mp3info->pcmbuf); + } + + mp3info->pcmbuf = newbuf; + mp3info->pcmbufsize = cursize; + + samplecount = S_MP3_PCMCopy(mp3info->pcmbuf, pcm, + mp3info->buflen, + samplecount, + mp3info->pcmbufsize - mp3info->buflen, + &wrote); + mp3info->buflen += wrote; + } + + // we're definitely done. + retval = 0; + } + else if(mp3info->destlen >= mp3info->destsize) + retval = 0; + else + retval = 1; + + return retval; +} + +/*************** Callback functions for quake3 ***************/ + +/* +================= +S_MP3_CodecOpenStream +================= +*/ + +snd_stream_t *S_MP3_CodecOpenStream(const char *filename) +{ + snd_stream_t *stream; + struct snd_codec_mp3_info *mp3info; + + // Open the stream + stream = S_CodecUtilOpen(filename, &mp3_codec); + if(!stream || stream->length <= 0) + return NULL; + + // We have to scan through the MP3 to determine the important mp3 info. + if(S_MP3_Scanfile(stream) < 0) + { + // scanning didn't work out... + S_CodecUtilClose(&stream); + return NULL; + } + + // Initialize the mp3 info structure we need for streaming + mp3info = Z_Malloc(sizeof(*mp3info)); + if(!mp3info) + { + S_CodecUtilClose(&stream); + return NULL; + } + + stream->ptr = mp3info; + + // initialize the libmad control structures. + mad_stream_init(&mp3info->madstream); + mad_frame_init(&mp3info->madframe); + mad_synth_init(&mp3info->madsynth); + + if(S_MP3_ReadData(stream, &mp3info->madstream, mp3info->encbuf, sizeof(mp3info->encbuf)) <= 0) + { + // we didnt read anything, that's bad. + S_MP3_CodecCloseStream(stream); + return NULL; + } + + return stream; +} + +/* +================= +S_MP3_CodecCloseStream +================= +*/ + +// free all memory we allocated. +void S_MP3_CodecCloseStream(snd_stream_t *stream) +{ + struct snd_codec_mp3_info *mp3info; + + if(!stream) + return; + + // free all data in our mp3info tree + + if(stream->ptr) + { + mp3info = stream->ptr; + + if(mp3info->pcmbuf) + Z_Free(mp3info->pcmbuf); + + mad_synth_finish(&mp3info->madsynth); + mad_frame_finish(&mp3info->madframe); + mad_stream_finish(&mp3info->madstream); + + Z_Free(stream->ptr); + } + + S_CodecUtilClose(&stream); +} + +/* +================= +S_MP3_CodecReadStream +================= +*/ +int S_MP3_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer) +{ + struct snd_codec_mp3_info *mp3info; + int retval; + + if(!stream) + return -1; + + mp3info = stream->ptr; + + // Make sure we get complete frames all the way through. + bytes -= bytes % (stream->info.channels * stream->info.width); + + if(mp3info->buflen) + { + if(bytes < mp3info->buflen) + { + // we still have enough bytes in our decoded pcm buffer + memcpy(buffer, mp3info->pcmbuf, bytes); + + // remove the portion from our buffer. + mp3info->buflen -= bytes; + memmove(mp3info->pcmbuf, &mp3info->pcmbuf[bytes], mp3info->buflen); + return bytes; + } + else + { + // copy over the samples we already have. + memcpy(buffer, mp3info->pcmbuf, mp3info->buflen); + mp3info->destlen = mp3info->buflen; + mp3info->buflen = 0; + } + } + else + mp3info->destlen = 0; + + mp3info->dest = buffer; + mp3info->destsize = bytes; + + do + { + retval = S_MP3_Decode(stream); + } while(retval > 0); + + // if there was an error return nothing. + if(retval < 0) + return 0; + + return mp3info->destlen; +} + +/* +===================================================================== +S_MP3_CodecLoad + +We handle S_MP3_CodecLoad as a special case of the streaming functions +where we read the whole stream at once. +====================================================================== +*/ +void *S_MP3_CodecLoad(const char *filename, snd_info_t *info) +{ + snd_stream_t *stream; + byte *pcmbuffer; + + // check if input is valid + if(!filename) + return NULL; + + stream = S_MP3_CodecOpenStream(filename); + + if(!stream) + return NULL; + + // copy over the info + info->rate = stream->info.rate; + info->width = stream->info.width; + info->channels = stream->info.channels; + info->samples = stream->info.samples; + info->dataofs = stream->info.dataofs; + + // allocate enough buffer for all pcm data +// pcmbuffer = Z_Malloc(stream->info.size); + pcmbuffer = Hunk_AllocateTempMemory(stream->info.size); + + if(!pcmbuffer) + { + S_MP3_CodecCloseStream(stream); + return NULL; + } + + info->size = S_MP3_CodecReadStream(stream, stream->info.size, pcmbuffer); + + if(info->size <= 0) + { + // we didn't read anything at all. darn. +// Z_Free(pcmbuffer); + Hunk_FreeTempMemory(pcmbuffer); + pcmbuffer = NULL; + } + + S_MP3_CodecCloseStream(stream); + + return pcmbuffer; +} +#endif diff --git a/code/client/snd_codec_ogg.c b/code/client/snd_codec_ogg.c new file mode 100644 index 00000000..3cc90623 --- /dev/null +++ b/code/client/snd_codec_ogg.c @@ -0,0 +1,474 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) +Copyright (C) 2005-2006 Joerg Dietrich + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// OGG support is enabled by this define +#ifdef USE_CODEC_VORBIS + +// includes for the Q3 sound system +#include "client.h" +#include "snd_codec.h" + +// includes for the OGG codec +#include +#include + +// The OGG codec can return the samples in a number of different formats, +// we use the standard signed short format. +#define OGG_SAMPLEWIDTH 2 + +// Q3 OGG codec +snd_codec_t ogg_codec = +{ + ".ogg", + S_OGG_CodecLoad, + S_OGG_CodecOpenStream, + S_OGG_CodecReadStream, + S_OGG_CodecCloseStream, + NULL +}; + +// callbacks for vobisfile + +// fread() replacement +size_t S_OGG_Callback_read(void *ptr, size_t size, size_t nmemb, void *datasource) +{ + snd_stream_t *stream; + int byteSize = 0; + int bytesRead = 0; + size_t nMembRead = 0; + + // check if input is valid + if(!ptr) + { + errno = EFAULT; + return 0; + } + + if(!(size && nmemb)) + { + // It's not an error, caller just wants zero bytes! + errno = 0; + return 0; + } + + if(!datasource) + { + errno = EBADF; + return 0; + } + + // we use a snd_stream_t in the generic pointer to pass around + stream = (snd_stream_t *) datasource; + + // FS_Read does not support multi-byte elements + byteSize = nmemb * size; + + // read it with the Q3 function FS_Read() + bytesRead = FS_Read(ptr, byteSize, stream->file); + + // update the file position + stream->pos += bytesRead; + + // this function returns the number of elements read not the number of bytes + nMembRead = bytesRead / size; + + // even if the last member is only read partially + // it is counted as a whole in the return value + if(bytesRead % size) + { + nMembRead++; + } + + return nMembRead; +} + +// fseek() replacement +int S_OGG_Callback_seek(void *datasource, ogg_int64_t offset, int whence) +{ + snd_stream_t *stream; + int retVal = 0; + + // check if input is valid + if(!datasource) + { + errno = EBADF; + return -1; + } + + // snd_stream_t in the generic pointer + stream = (snd_stream_t *) datasource; + + // we must map the whence to its Q3 counterpart + switch(whence) + { + case SEEK_SET : + { + // set the file position in the actual file with the Q3 function + retVal = FS_Seek(stream->file, (long) offset, FS_SEEK_SET); + + // something has gone wrong, so we return here + if(!(retVal == 0)) + { + return retVal; + } + + // keep track of file position + stream->pos = (int) offset; + break; + } + + case SEEK_CUR : + { + // set the file position in the actual file with the Q3 function + retVal = FS_Seek(stream->file, (long) offset, FS_SEEK_CUR); + + // something has gone wrong, so we return here + if(!(retVal == 0)) + { + return retVal; + } + + // keep track of file position + stream->pos += (int) offset; + break; + } + + case SEEK_END : + { + // Quake 3 seems to have trouble with FS_SEEK_END + // so we use the file length and FS_SEEK_SET + + // set the file position in the actual file with the Q3 function + retVal = FS_Seek(stream->file, (long) stream->length + (long) offset, FS_SEEK_SET); + + // something has gone wrong, so we return here + if(!(retVal == 0)) + { + return retVal; + } + + // keep track of file position + stream->pos = stream->length + (int) offset; + break; + } + + default : + { + // unknown whence, so we return an error + errno = EINVAL; + return -1; + } + } + + // stream->pos shouldn't be smaller than zero or bigger than the filesize + stream->pos = (stream->pos < 0) ? 0 : stream->pos; + stream->pos = (stream->pos > stream->length) ? stream->length : stream->pos; + + return 0; +} + +// fclose() replacement +int S_OGG_Callback_close(void *datasource) +{ + // we do nothing here and close all things manually in S_OGG_CodecCloseStream() + return 0; +} + +// ftell() replacement +long S_OGG_Callback_tell(void *datasource) +{ + // check if input is valid + if(!datasource) + { + errno = EBADF; + return -1; + } + + // we keep track of the file position in stream->pos + return (long) (((snd_stream_t *) datasource) -> pos); +} + +// the callback structure +const ov_callbacks S_OGG_Callbacks = +{ + &S_OGG_Callback_read, + &S_OGG_Callback_seek, + &S_OGG_Callback_close, + &S_OGG_Callback_tell +}; + +/* +================= +S_OGG_CodecOpenStream +================= +*/ +snd_stream_t *S_OGG_CodecOpenStream(const char *filename) +{ + snd_stream_t *stream; + + // OGG codec control structure + OggVorbis_File *vf; + + // some variables used to get informations about the OGG + vorbis_info *OGGInfo; + ogg_int64_t numSamples; + + // check if input is valid + if(!filename) + { + return NULL; + } + + // Open the stream + stream = S_CodecUtilOpen(filename, &ogg_codec); + if(!stream) + { + return NULL; + } + + // alloctate the OggVorbis_File + vf = Z_Malloc(sizeof(OggVorbis_File)); + if(!vf) + { + S_CodecUtilClose(&stream); + + return NULL; + } + + // open the codec with our callbacks and stream as the generic pointer + if(ov_open_callbacks(stream, vf, NULL, 0, S_OGG_Callbacks) != 0) + { + Z_Free(vf); + + S_CodecUtilClose(&stream); + + return NULL; + } + + // the stream must be seekable + if(!ov_seekable(vf)) + { + ov_clear(vf); + + Z_Free(vf); + + S_CodecUtilClose(&stream); + + return NULL; + } + + // we only support OGGs with one substream + if(ov_streams(vf) != 1) + { + ov_clear(vf); + + Z_Free(vf); + + S_CodecUtilClose(&stream); + + return NULL; + } + + // get the info about channels and rate + OGGInfo = ov_info(vf, 0); + if(!OGGInfo) + { + ov_clear(vf); + + Z_Free(vf); + + S_CodecUtilClose(&stream); + + return NULL; + } + + // get the number of sample-frames in the OGG + numSamples = ov_pcm_total(vf, 0); + + // fill in the info-structure in the stream + stream->info.rate = OGGInfo->rate; + stream->info.width = OGG_SAMPLEWIDTH; + stream->info.channels = OGGInfo->channels; + stream->info.samples = numSamples; + stream->info.size = stream->info.samples * stream->info.channels * stream->info.width; + stream->info.dataofs = 0; + + // We use stream->pos for the file pointer in the compressed ogg file + stream->pos = 0; + + // We use the generic pointer in stream for the OGG codec control structure + stream->ptr = vf; + + return stream; +} + +/* +================= +S_OGG_CodecCloseStream +================= +*/ +void S_OGG_CodecCloseStream(snd_stream_t *stream) +{ + // check if input is valid + if(!stream) + { + return; + } + + // let the OGG codec cleanup its stuff + ov_clear((OggVorbis_File *) stream->ptr); + + // free the OGG codec control struct + Z_Free(stream->ptr); + + // close the stream + S_CodecUtilClose(&stream); +} + +/* +================= +S_OGG_CodecReadStream +================= +*/ +int S_OGG_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer) +{ + // buffer handling + int bytesRead, bytesLeft, c; + char *bufPtr; + + // Bitstream for the decoder + int BS = 0; + + // big endian machines want their samples in big endian order + int IsBigEndian = 0; + +# ifdef Q3_BIG_ENDIAN + IsBigEndian = 1; +# endif // Q3_BIG_ENDIAN + + // check if input is valid + if(!(stream && buffer)) + { + return 0; + } + + if(bytes <= 0) + { + return 0; + } + + bytesRead = 0; + bytesLeft = bytes; + bufPtr = buffer; + + // cycle until we have the requested or all available bytes read + while(-1) + { + // read some bytes from the OGG codec + c = ov_read((OggVorbis_File *) stream->ptr, bufPtr, bytesLeft, IsBigEndian, OGG_SAMPLEWIDTH, 1, &BS); + + // no more bytes are left + if(c <= 0) + { + break; + } + + bytesRead += c; + bytesLeft -= c; + bufPtr += c; + + // we have enough bytes + if(bytesLeft <= 0) + { + break; + } + } + + return bytesRead; +} + +/* +===================================================================== +S_OGG_CodecLoad + +We handle S_OGG_CodecLoad as a special case of the streaming functions +where we read the whole stream at once. +====================================================================== +*/ +void *S_OGG_CodecLoad(const char *filename, snd_info_t *info) +{ + snd_stream_t *stream; + byte *buffer; + int bytesRead; + + // check if input is valid + if(!(filename && info)) + { + return NULL; + } + + // open the file as a stream + stream = S_OGG_CodecOpenStream(filename); + if(!stream) + { + return NULL; + } + + // copy over the info + info->rate = stream->info.rate; + info->width = stream->info.width; + info->channels = stream->info.channels; + info->samples = stream->info.samples; + info->size = stream->info.size; + info->dataofs = stream->info.dataofs; + + // allocate a buffer + // this buffer must be free-ed by the caller of this function +// buffer = Z_Malloc(info->size); + buffer = Hunk_AllocateTempMemory(info->size); + if(!buffer) + { + S_OGG_CodecCloseStream(stream); + + return NULL; + } + + // fill the buffer + bytesRead = S_OGG_CodecReadStream(stream, info->size, buffer); + + // we don't even have read a single byte + if(bytesRead <= 0) + { + Z_Free(buffer); + S_OGG_CodecCloseStream(stream); + + return NULL; + } + + S_OGG_CodecCloseStream(stream); + + return buffer; +} + +#endif // USE_CODEC_VORBIS diff --git a/code/client/snd_codec_wav.c b/code/client/snd_codec_wav.c new file mode 100644 index 00000000..e592dfcb --- /dev/null +++ b/code/client/snd_codec_wav.c @@ -0,0 +1,296 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "client.h" +#include "snd_codec.h" + +/* +================= +FGetLittleLong +================= +*/ +static int FGetLittleLong( fileHandle_t f ) { + int v; + + FS_Read( &v, sizeof(v), f ); + + return LittleLong( v); +} + +/* +================= +FGetLittleShort +================= +*/ +static short FGetLittleShort( fileHandle_t f ) { + short v; + + FS_Read( &v, sizeof(v), f ); + + return LittleShort( v); +} + +/* +================= +S_ReadChunkInfo +================= +*/ +static int S_ReadChunkInfo(fileHandle_t f, char *name) +{ + int len, r; + + name[4] = 0; + + r = FS_Read(name, 4, f); + if(r != 4) + return -1; + + len = FGetLittleLong(f); + if( len < 0 ) { + Com_Printf( S_COLOR_YELLOW "WARNING: Negative chunk length\n" ); + return -1; + } + + return len; +} + +/* +================= +S_FindRIFFChunk + +Returns the length of the data in the chunk, or -1 if not found +================= +*/ +static int S_FindRIFFChunk( fileHandle_t f, char *chunk ) { + char name[5]; + int len; + + while( ( len = S_ReadChunkInfo(f, name) ) >= 0 ) + { + // If this is the right chunk, return + if( !Q_strncmp( name, chunk, 4 ) ) + return len; + + len = PAD( len, 2 ); + + // Not the right chunk - skip it + FS_Seek( f, len, FS_SEEK_CUR ); + } + + return -1; +} + +/* +================= +S_ByteSwapRawSamples +================= +*/ +static void S_ByteSwapRawSamples( int samples, int width, int s_channels, const byte *data ) { + int i; + + if ( width != 2 ) { + return; + } + if ( LittleShort( 256 ) == 256 ) { + return; + } + + if ( s_channels == 2 ) { + samples <<= 1; + } + for ( i = 0 ; i < samples ; i++ ) { + ((short *)data)[i] = LittleShort( ((short *)data)[i] ); + } +} + +/* +================= +S_ReadRIFFHeader +================= +*/ +static qboolean S_ReadRIFFHeader(fileHandle_t file, snd_info_t *info) +{ + char dump[16]; + int wav_format; + int bits; + int fmtlen = 0; + + // skip the riff wav header + FS_Read(dump, 12, file); + + // Scan for the format chunk + if((fmtlen = S_FindRIFFChunk(file, "fmt ")) < 0) + { + Com_Printf( S_COLOR_RED "ERROR: Couldn't find \"fmt\" chunk\n"); + return qfalse; + } + + // Save the parameters + wav_format = FGetLittleShort(file); + info->channels = FGetLittleShort(file); + info->rate = FGetLittleLong(file); + FGetLittleLong(file); + FGetLittleShort(file); + bits = FGetLittleShort(file); + + if( bits < 8 ) + { + Com_Printf( S_COLOR_RED "ERROR: Less than 8 bit sound is not supported\n"); + return qfalse; + } + + info->width = bits / 8; + info->dataofs = 0; + + // Skip the rest of the format chunk if required + if(fmtlen > 16) + { + fmtlen -= 16; + FS_Seek( file, fmtlen, FS_SEEK_CUR ); + } + + // Scan for the data chunk + if( (info->size = S_FindRIFFChunk(file, "data")) < 0) + { + Com_Printf( S_COLOR_RED "ERROR: Couldn't find \"data\" chunk\n"); + return qfalse; + } + info->samples = (info->size / info->width) / info->channels; + + return qtrue; +} + +// WAV codec +snd_codec_t wav_codec = +{ + ".wav", + S_WAV_CodecLoad, + S_WAV_CodecOpenStream, + S_WAV_CodecReadStream, + S_WAV_CodecCloseStream, + NULL +}; + +/* +================= +S_WAV_CodecLoad +================= +*/ +void *S_WAV_CodecLoad(const char *filename, snd_info_t *info) +{ + fileHandle_t file; + void *buffer; + + // Try to open the file + FS_FOpenFileRead(filename, &file, qtrue, qtrue); + if(!file) + { + Com_Printf( S_COLOR_RED "ERROR: Could not open \"%s\"\n", + filename); + return NULL; + } + + // Read the RIFF header + if(!S_ReadRIFFHeader(file, info)) + { + FS_FCloseFile(file); + Com_Printf( S_COLOR_RED "ERROR: Incorrect/unsupported format in \"%s\"\n", + filename); + return NULL; + } + + // Allocate some memory +// buffer = Z_Malloc(info->size); + buffer = Hunk_AllocateTempMemory(info->size); + + if(!buffer) + { + FS_FCloseFile(file); + Com_Printf( S_COLOR_RED "ERROR: Out of memory reading \"%s\"\n", + filename); + return NULL; + } + + // Read, byteswap + FS_Read(buffer, info->size, file); + S_ByteSwapRawSamples(info->samples, info->width, info->channels, (byte *)buffer); + + // Close and return + FS_FCloseFile(file); + return buffer; +} + +/* +================= +S_WAV_CodecOpenStream +================= +*/ +snd_stream_t *S_WAV_CodecOpenStream(const char *filename) +{ + snd_stream_t *rv; + + // Open + rv = S_CodecUtilOpen(filename, &wav_codec); + if(!rv) + return NULL; + + // Read the RIFF header + if(!S_ReadRIFFHeader(rv->file, &rv->info)) + { + S_CodecUtilClose(&rv); + return NULL; + } + + return rv; +} + +/* +================= +S_WAV_CodecCloseStream +================= +*/ +void S_WAV_CodecCloseStream(snd_stream_t *stream) +{ + S_CodecUtilClose(&stream); +} + +/* +================= +S_WAV_CodecReadStream +================= +*/ +int S_WAV_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer) +{ + int remaining = stream->info.size - stream->pos; + int samples; + + if(remaining <= 0) + return 0; + if(bytes > remaining) + bytes = remaining; + stream->pos += bytes; + samples = (bytes / stream->info.width) / stream->info.channels; + FS_Read(buffer, bytes, stream->file); + S_ByteSwapRawSamples(samples, stream->info.width, stream->info.channels, buffer); + return bytes; +} diff --git a/code/client/snd_dma_new.cpp b/code/client/snd_dma_new.cpp new file mode 100644 index 00000000..29713121 --- /dev/null +++ b/code/client/snd_dma_new.cpp @@ -0,0 +1,1658 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** +* name: snd_dma.c +* +* desc: main control for any streaming sound output device +* +* $Archive: /MissionPack/code/client/snd_dma.c $ +* +*****************************************************************************/ + +#include "snd_local.h" +#include "snd_codec.h" +#include "client.h" + +void S_Update_( void ); +void S_Base_StopAllSounds( void ); +void S_Base_StopBackgroundTrack( void ); + +snd_stream_t *s_backgroundStream = NULL; +static char s_backgroundLoop[ MAX_QPATH ]; +//static char s_backgroundMusic[MAX_QPATH]; //TTimo: unused + + +// ======================================================================= +// Internal sound data & structures +// ======================================================================= + +// only begin attenuating sound volumes when outside the FULLVOLUME range +#define SOUND_FULLVOLUME 80 + +#define SOUND_ATTENUATE 0.0008f + +channel_t s_channels[ MAX_SOUNDCHANNELS ]; +channel_t loop_channels[ MAX_SOUNDCHANNELS ]; +int numLoopChannels; + +static int s_soundStarted; +static qboolean s_soundMuted; + +dma_t dma; + +static int listener_number; +static vec3_t listener_origin; +static vec3_t listener_axis[ 3 ]; + +int s_soundtime; // sample PAIRS +int s_paintedtime; // sample PAIRS + +// MAX_SFX may be larger than MAX_SOUNDS because +// of custom player sounds +#define MAX_SFX 4096 +sfx_t s_knownSfx[ MAX_SFX ]; +int s_numSfx = 0; + +#define LOOP_HASH 128 +static sfx_t *sfxHash[ LOOP_HASH ]; + +cvar_t *s_testsound; +cvar_t *s_show; +cvar_t *s_mixahead; +cvar_t *s_mixPreStep; + +static loopSound_t loopSounds[ MAX_GENTITIES ]; +static channel_t *freelist = NULL; + +int s_rawend[ MAX_RAW_STREAMS ]; +portable_samplepair_t s_rawsamples[ MAX_RAW_STREAMS ][ MAX_RAW_SAMPLES ]; + + +// ==================================================================== +// User-setable variables +// ==================================================================== + + +void S_Base_SoundInfo( void ) { + Com_Printf( "----- Sound Info -----\n" ); + if( !s_soundStarted ) { + Com_Printf( "sound system not started\n" ); + } + else { + Com_Printf( "%5d stereo\n", dma.channels - 1 ); + Com_Printf( "%5d samples\n", dma.samples ); + Com_Printf( "%5d samplebits\n", dma.samplebits ); + Com_Printf( "%5d submission_chunk\n", dma.submission_chunk ); + Com_Printf( "%5d speed\n", dma.speed ); + Com_Printf( "%p dma buffer\n", dma.buffer ); + if( s_backgroundStream ) { + Com_Printf( "Background file: %s\n", s_backgroundLoop ); + } + else { + Com_Printf( "No background file.\n" ); + } + + } + Com_Printf( "----------------------\n" ); +} + + +#ifdef USE_VOIP +static +void S_Base_StartCapture( void ) +{ + // !!! FIXME: write me. +} + +static +int S_Base_AvailableCaptureSamples( void ) +{ + // !!! FIXME: write me. + return 0; +} + +static +void S_Base_Capture( int samples, byte *data ) +{ + // !!! FIXME: write me. +} + +static +void S_Base_StopCapture( void ) +{ + // !!! FIXME: write me. +} + +static +void S_Base_MasterGain( float val ) +{ + // !!! FIXME: write me. +} +#endif + + + +/* +================= +S_Base_SoundList +================= +*/ +void S_Base_SoundList( void ) { + int i; + sfx_t *sfx; + int size, total; + char type[ 4 ][ 16 ]; + char mem[ 2 ][ 16 ]; + + strcpy( type[ 0 ], "16bit" ); + strcpy( type[ 1 ], "adpcm" ); + strcpy( type[ 2 ], "daub4" ); + strcpy( type[ 3 ], "mulaw" ); + strcpy( mem[ 0 ], "paged out" ); + strcpy( mem[ 1 ], "resident " ); + total = 0; + for( sfx = s_knownSfx, i = 0; isoundLength; + total += size; + Com_Printf( "%6i[%s] : %s[%s]\n", size, type[ sfx->soundCompressionMethod ], + sfx->soundName, mem[ sfx->inMemory ] ); + } + Com_Printf( "Total resident: %i\n", total ); + S_DisplayFreeMemory(); +} + + + +void S_ChannelFree( channel_t *v ) { + v->thesfx = NULL; + *( channel_t ** )v = freelist; + freelist = ( channel_t* )v; +} + +channel_t* S_ChannelMalloc( void ) { + channel_t *v; + if( freelist == NULL ) { + return NULL; + } + v = freelist; + freelist = *( channel_t ** )freelist; + v->allocTime = Com_Milliseconds(); + return v; +} + +void S_ChannelSetup( void ) { + channel_t *p, *q; + + // clear all the sounds so they don't + Com_Memset( s_channels, 0, sizeof( s_channels ) ); + + p = s_channels;; + q = p + MAX_CHANNELS; + while( --q > p ) { + *( channel_t ** )q = q - 1; + } + + *( channel_t ** )q = NULL; + freelist = p + MAX_CHANNELS - 1; + Com_DPrintf( "Channel memory manager started\n" ); +} + + + +// ======================================================================= +// Load a sound +// ======================================================================= + +/* +================ +return a hash value for the sfx name +================ +*/ +static long S_HashSFXName( const char *name ) { + int i; + long hash; + char letter; + + hash = 0; + i = 0; + while( name[ i ] != '\0' ) { + letter = tolower( name[ i ] ); + if( letter == '.' ) break; // don't include extension + if( letter == '\\' ) letter = '/'; // damn path names + hash += ( long )( letter )*( i + 119 ); + i++; + } + hash &= ( LOOP_HASH - 1 ); + return hash; +} + +/* +================== +S_FindName + +Will allocate a new sfx if it isn't found +================== +*/ +static sfx_t *S_FindName( const char *name ) { + int i; + int hash; + + sfx_t *sfx; + + if( !name ) { + Com_Error( ERR_FATAL, "Sound name is NULL" ); + } + + if( !name[ 0 ] ) { + Com_Printf( S_COLOR_YELLOW "WARNING: Sound name is empty\n" ); + return NULL; + } + + if( strlen( name ) >= MAX_QPATH ) { + Com_Printf( S_COLOR_YELLOW "WARNING: Sound name is too long: %s\n", name ); + return NULL; + } + + if( name[ 0 ] == '*' ) { + Com_Printf( S_COLOR_YELLOW "WARNING: Tried to load player sound directly: %s\n", name ); + return NULL; + } + + hash = S_HashSFXName( name ); + + sfx = sfxHash[ hash ]; + // see if already loaded + while( sfx ) { + if( !Q_stricmp( sfx->soundName, name ) ) { + return sfx; + } + sfx = sfx->next; + } + + // find a free sfx + for( i = 0; i < s_numSfx; i++ ) { + if( !s_knownSfx[ i ].soundName[ 0 ] ) { + break; + } + } + + if( i == s_numSfx ) { + if( s_numSfx == MAX_SFX ) { + Com_Error( ERR_FATAL, "S_FindName: out of sfx_t" ); + } + s_numSfx++; + } + + sfx = &s_knownSfx[ i ]; + Com_Memset( sfx, 0, sizeof( *sfx ) ); + strcpy( sfx->soundName, name ); + + sfx->next = sfxHash[ hash ]; + sfxHash[ hash ] = sfx; + + return sfx; +} + +/* +================= +S_DefaultSound +================= +*/ +void S_DefaultSound( sfx_t *sfx ) { + + int i; + + sfx->soundLength = 512; + sfx->soundData = SND_malloc(); + sfx->soundData->next = NULL; + + + for( i = 0; i < sfx->soundLength; i++ ) { + sfx->soundData->sndChunk[ i ] = i; + } +} + +/* +=================== +S_DisableSounds + +Disables sounds until the next S_BeginRegistration. +This is called when the hunk is cleared and the sounds +are no longer valid. +=================== +*/ +void S_Base_DisableSounds( void ) { + S_Base_StopAllSounds(); + s_soundMuted = qtrue; +} + +/* +================== +S_RegisterSound + +Creates a default buzz sound if the file can't be loaded +================== +*/ +sfxHandle_t S_Base_RegisterSound( const char *name, qboolean compressed ) { + sfx_t *sfx; + + compressed = qfalse; + if( !s_soundStarted ) { + return 0; + } + + sfx = S_FindName( name ); + if( !sfx ) { + return 0; + } + + if( sfx->soundData ) { + if( sfx->defaultSound ) { + Com_Printf( S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->soundName ); + return 0; + } + return sfx - s_knownSfx; + } + + sfx->inMemory = qfalse; + sfx->soundCompressed = compressed; + + S_memoryLoad( sfx ); + + if( sfx->defaultSound ) { + Com_Printf( S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->soundName ); + return 0; + } + + return sfx - s_knownSfx; +} + +/* +===================== +S_BeginRegistration + +===================== +*/ +void S_Base_BeginRegistration( void ) { + s_soundMuted = qfalse; // we can play again + + if( s_numSfx == 0 ) { + SND_setup(); + + Com_Memset( s_knownSfx, '\0', sizeof( s_knownSfx ) ); + Com_Memset( sfxHash, '\0', sizeof( sfx_t * ) * LOOP_HASH ); + + S_Base_RegisterSound( "sound/feedback/hit.wav", qfalse ); // changed to a sound in baseq3 + } +} + +void S_memoryLoad( sfx_t *sfx ) { + // load the sound file + if( !S_LoadSound( sfx ) ) { + // Com_Printf( S_COLOR_YELLOW "WARNING: couldn't load sound: %s\n", sfx->soundName ); + sfx->defaultSound = qtrue; + } + sfx->inMemory = qtrue; +} + +//============================================================================= + +/* +================= +S_SpatializeOrigin + +Used for spatializing s_channels +================= +*/ +void S_SpatializeOrigin( vec3_t origin, int master_vol, int *left_vol, int *right_vol ) +{ + vec_t dot; + vec_t dist; + vec_t lscale, rscale, scale; + vec3_t source_vec; + vec3_t vec; + + const float dist_mult = SOUND_ATTENUATE; + + // calculate stereo seperation and distance attenuation + VectorSubtract( origin, listener_origin, source_vec ); + + dist = VectorNormalize( source_vec ); + dist -= SOUND_FULLVOLUME; + if( dist < 0 ) + dist = 0; // close enough to be at full volume + dist *= dist_mult; // different attenuation levels + + VectorRotate( source_vec, listener_axis, vec ); + + dot = -vec[ 1 ]; + + if( dma.channels == 1 ) + { // no attenuation = no spatialization + rscale = 1.0; + lscale = 1.0; + } + else + { + rscale = 0.5 * ( 1.0 + dot ); + lscale = 0.5 * ( 1.0 - dot ); + if( rscale < 0 ) { + rscale = 0; + } + if( lscale < 0 ) { + lscale = 0; + } + } + + // add in distance effect + scale = ( 1.0 - dist ) * rscale; + *right_vol = ( master_vol * scale ); + if( *right_vol < 0 ) + *right_vol = 0; + + scale = ( 1.0 - dist ) * lscale; + *left_vol = ( master_vol * scale ); + if( *left_vol < 0 ) + *left_vol = 0; +} + +// ======================================================================= +// Start a sound effect +// ======================================================================= + +/* +================= +S_Base_HearingThroughEntity + +Also see S_AL_HearingThroughEntity +================= +*/ +static qboolean S_Base_HearingThroughEntity( int entityNum, const vec3_t origin ) +{ + float distanceSq; + vec3_t sorigin; + + if( origin ) + VectorCopy( origin, sorigin ); + else + VectorCopy( loopSounds[ entityNum ].origin, sorigin ); + + if( listener_number == entityNum ) + { + // This is an outrageous hack to detect + // whether or not the player is rendering in third person or not. We can't + // ask the renderer because the renderer has no notion of entities and we + // can't ask cgame since that would involve changing the API and hence mod + // compatibility. I don't think there is any way around this, but I'll leave + // the FIXME just in case anyone has a bright idea. + distanceSq = DistanceSquared( + sorigin, + listener_origin ); + + if( distanceSq > THIRD_PERSON_THRESHOLD_SQ ) + return qfalse; //we're the player, but third person + else + return qtrue; //we're the player + } + else + return qfalse; //not the player +} + +/* +================= +S_Base_IsSoundPlaying +================= +*/ +static +qboolean S_Base_IsSoundPlaying( int channelNumber, const char *name ) +{ + // null sfx means not playing + if( !s_channels[ channelNumber ].thesfx ) { + return qfalse; + } + + // not the same name + if( strcmp( s_channels[ channelNumber ].thesfx->soundName, name ) ) { + return qfalse; + } + + return qtrue; +} + +/* +==================== +S_Base_StartSoundEx + +Validates the parms and ques the sound up +if origin is NULL, the sound will be dynamically sourced from the entity +Entchannel 0 will never override a playing sound +==================== +*/ +static void S_Base_StartSoundEx( const vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfxHandle, qboolean localSound ) { + channel_t *ch; + sfx_t *sfx; + int i, oldest, chosen, time; + int inplay, allowed; + qboolean fullVolume; + + if( !s_soundStarted || s_soundMuted ) { + return; + } + + if( !origin && ( entityNum < 0 || entityNum >= MAX_GENTITIES ) ) { + Com_Error( ERR_DROP, "S_StartSound: bad entitynum %i", entityNum ); + } + + if( sfxHandle < 0 || sfxHandle >= s_numSfx ) { + Com_Printf( S_COLOR_YELLOW "S_StartSound: handle %i out of range\n", sfxHandle ); + return; + } + + sfx = &s_knownSfx[ sfxHandle ]; + + if( soundparm.streamed ) { + sfx->iFlags |= SFX_FLAG_STREAMED; + } + + if( sfx->inMemory == qfalse ) { + S_memoryLoad( sfx ); + } + + if( s_show->integer == 1 ) { + Com_Printf( "%i : %s\n", s_paintedtime, sfx->soundName ); + } + + time = Com_Milliseconds(); + + // Com_Printf("playing %s\n", sfx->soundName); + // pick a channel to play on + + allowed = 4; + if( entityNum == listener_number ) { + allowed = 8; + } + + fullVolume = qfalse; + if( localSound || S_Base_HearingThroughEntity( entityNum, origin ) ) { + fullVolume = qtrue; + } + + ch = s_channels; + inplay = 0; + for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + if( ch->entnum == entityNum && ch->thesfx == sfx ) { + if( time - ch->allocTime < 50 ) { + // if (Cvar_VariableValue( "cg_showmiss" )) { + // Com_Printf("double sound start\n"); + // } + return; + } + inplay++; + } + } + + if( inplay>allowed ) { + return; + } + + sfx->lastTimeUsed = time; + + ch = S_ChannelMalloc(); // entityNum, entchannel); + if( !ch ) { + ch = s_channels; + + oldest = sfx->lastTimeUsed; + chosen = -1; + for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + if( ch->entnum != listener_number && ch->entnum == entityNum && ch->allocTimeentchannel != CHAN_ANNOUNCER ) { + oldest = ch->allocTime; + chosen = i; + } + } + if( chosen == -1 ) { + ch = s_channels; + for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + if( ch->entnum != listener_number && ch->allocTimeentchannel != CHAN_ANNOUNCER ) { + oldest = ch->allocTime; + chosen = i; + } + } + if( chosen == -1 ) { + ch = s_channels; + if( ch->entnum == listener_number ) { + for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + if( ch->allocTimeallocTime; + chosen = i; + } + } + } + if( chosen == -1 ) { + Com_Printf( "dropping sound\n" ); + return; + } + } + } + ch = &s_channels[ chosen ]; + ch->allocTime = sfx->lastTimeUsed; + } + + if( origin ) { + VectorCopy( origin, ch->origin ); + ch->fixed_origin = qtrue; + } + else { + ch->fixed_origin = qfalse; + } + + if( ( entityNum >> GENTITYNUM_BITS ) & 1 ) { + callbackServer( entityNum, chosen, sfx->soundName ); + } + + ch->master_vol = ( int )( 127.0 * soundparm.volume ); + ch->entnum = entityNum; + ch->thesfx = sfx; + ch->startSample = START_SAMPLE_IMMEDIATE; + ch->entchannel = entchannel; + ch->leftvol = ch->master_vol; // these will get calced at next spatialize + ch->rightvol = ch->master_vol; // unless the game isn't running + ch->doppler = qfalse; + ch->fullVolume = fullVolume; +} + +/* +==================== +S_StartSound + +if origin is NULL, the sound will be dynamically sourced from the entity +==================== +*/ +void S_Base_StartSound( const vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfxHandle ) { + S_Base_StartSoundEx( origin, entityNum, entchannel, sfxHandle, qfalse ); +} + +/* +================== +S_StartLocalSound +================== +*/ +void S_Base_StartLocalSound( sfxHandle_t sfxHandle, int channelNum ) { + if( !s_soundStarted || s_soundMuted ) { + return; + } + + if( sfxHandle < 0 || sfxHandle >= s_numSfx ) { + Com_Printf( S_COLOR_YELLOW "S_StartLocalSound: handle %i out of range\n", sfxHandle ); + return; + } + + S_Base_StartSoundEx( NULL, listener_number, channelNum, sfxHandle, qtrue ); +} + + +/* +================== +S_ClearSoundBuffer + +If we are about to perform file access, clear the buffer +so sound doesn't stutter. +================== +*/ +void S_Base_ClearSoundBuffer( void ) { + int clear; + + if( !s_soundStarted ) + return; + + // stop looping sounds + Com_Memset( loopSounds, 0, MAX_GENTITIES*sizeof( loopSound_t ) ); + Com_Memset( loop_channels, 0, MAX_CHANNELS*sizeof( channel_t ) ); + numLoopChannels = 0; + + S_ChannelSetup(); + + Com_Memset( s_rawend, '\0', sizeof( s_rawend ) ); + + if( dma.samplebits == 8 ) + clear = 0x80; + else + clear = 0; + + SNDDMA_BeginPainting(); + if( dma.buffer ) + Com_Memset( dma.buffer, clear, dma.samples * dma.samplebits / 8 ); + SNDDMA_Submit(); +} + +/* +================== +S_StopAllSounds +================== +*/ +void S_Base_StopAllSounds( void ) { + if( !s_soundStarted ) { + return; + } + + // stop the background music + S_Base_StopBackgroundTrack(); + + S_Base_ClearSoundBuffer(); +} + +/* +============================================================== + +continuous looping sounds are added each frame + +============================================================== +*/ + +void S_Base_StopLoopingSound( int entityNum ) { + loopSounds[ entityNum ].active = qfalse; + // loopSounds[entityNum].sfx = 0; + loopSounds[ entityNum ].kill = qfalse; +} + +/* +================== +S_ClearLoopingSounds + +================== +*/ +void S_Base_ClearLoopingSounds( qboolean killall ) { + int i; + for( i = 0; i < MAX_GENTITIES; i++ ) { + if( killall || loopSounds[ i ].kill == qtrue || ( loopSounds[ i ].sfx && loopSounds[ i ].sfx->soundLength == 0 ) ) { + S_Base_StopLoopingSound( i ); + } + } + numLoopChannels = 0; +} + +/* +================== +S_AddLoopingSound + +Called during entity generation for a frame +Include velocity in case I get around to doing doppler... +================== +*/ +void S_Base_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle ) { + sfx_t *sfx; + + if( !s_soundStarted || s_soundMuted ) { + return; + } + + if( sfxHandle < 0 || sfxHandle >= s_numSfx ) { + Com_Printf( S_COLOR_YELLOW "S_AddLoopingSound: handle %i out of range\n", sfxHandle ); + return; + } + + sfx = &s_knownSfx[ sfxHandle ]; + + if( sfx->inMemory == qfalse ) { + S_memoryLoad( sfx ); + } + + if( !sfx->soundLength ) { + Com_Error( ERR_DROP, "%s has length 0", sfx->soundName ); + } + + VectorCopy( origin, loopSounds[ entityNum ].origin ); + VectorCopy( velocity, loopSounds[ entityNum ].velocity ); + loopSounds[ entityNum ].active = qtrue; + loopSounds[ entityNum ].kill = qtrue; + loopSounds[ entityNum ].doppler = qfalse; + loopSounds[ entityNum ].oldDopplerScale = 1.0; + loopSounds[ entityNum ].dopplerScale = 1.0; + loopSounds[ entityNum ].sfx = sfx; + + if( s_doppler->integer && VectorLengthSquared( velocity )>0.0 ) { + vec3_t out; + float lena, lenb; + + loopSounds[ entityNum ].doppler = qtrue; + lena = DistanceSquared( loopSounds[ listener_number ].origin, loopSounds[ entityNum ].origin ); + VectorAdd( loopSounds[ entityNum ].origin, loopSounds[ entityNum ].velocity, out ); + lenb = DistanceSquared( loopSounds[ listener_number ].origin, out ); + if( ( loopSounds[ entityNum ].framenum + 1 ) != cls.framecount ) { + loopSounds[ entityNum ].oldDopplerScale = 1.0; + } + else { + loopSounds[ entityNum ].oldDopplerScale = loopSounds[ entityNum ].dopplerScale; + } + loopSounds[ entityNum ].dopplerScale = lenb / ( lena * 100 ); + if( loopSounds[ entityNum ].dopplerScale <= 1.0 ) { + loopSounds[ entityNum ].doppler = qfalse; // don't bother doing the math + } + else if( loopSounds[ entityNum ].dopplerScale>MAX_DOPPLER_SCALE ) { + loopSounds[ entityNum ].dopplerScale = MAX_DOPPLER_SCALE; + } + } + + loopSounds[ entityNum ].framenum = cls.framecount; +} + +/* +================== +S_AddLoopingSound + +Called during entity generation for a frame +Include velocity in case I get around to doing doppler... +================== +*/ +void S_Base_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle ) { + sfx_t *sfx; + + if( !s_soundStarted || s_soundMuted ) { + return; + } + + if( sfxHandle < 0 || sfxHandle >= s_numSfx ) { + Com_Printf( S_COLOR_YELLOW "S_AddRealLoopingSound: handle %i out of range\n", sfxHandle ); + return; + } + + sfx = &s_knownSfx[ sfxHandle ]; + + if( sfx->inMemory == qfalse ) { + S_memoryLoad( sfx ); + } + + if( !sfx->soundLength ) { + Com_Error( ERR_DROP, "%s has length 0", sfx->soundName ); + } + VectorCopy( origin, loopSounds[ entityNum ].origin ); + VectorCopy( velocity, loopSounds[ entityNum ].velocity ); + loopSounds[ entityNum ].sfx = sfx; + loopSounds[ entityNum ].active = qtrue; + loopSounds[ entityNum ].kill = qfalse; + loopSounds[ entityNum ].doppler = qfalse; +} + + + +/* +================== +S_AddLoopSounds + +Spatialize all of the looping sounds. +All sounds are on the same cycle, so any duplicates can just +sum up the channel multipliers. +================== +*/ +void S_AddLoopSounds( void ) { + int i, j, time; + int left_total, right_total, left, right; + channel_t *ch; + loopSound_t *loop, *loop2; + static int loopFrame; + + + numLoopChannels = 0; + + time = Com_Milliseconds(); + + loopFrame++; + for( i = 0; i < MAX_GENTITIES; i++ ) { + loop = &loopSounds[ i ]; + if( !loop->active || loop->mergeFrame == loopFrame ) { + continue; // already merged into an earlier sound + } + + if( loop->kill ) { + S_SpatializeOrigin( loop->origin, 127, &left_total, &right_total ); // 3d + } + else { + S_SpatializeOrigin( loop->origin, 90, &left_total, &right_total ); // sphere + } + + loop->sfx->lastTimeUsed = time; + + for( j = ( i + 1 ); j< MAX_GENTITIES; j++ ) { + loop2 = &loopSounds[ j ]; + if( !loop2->active || loop2->doppler || loop2->sfx != loop->sfx ) { + continue; + } + loop2->mergeFrame = loopFrame; + + if( loop2->kill ) { + S_SpatializeOrigin( loop2->origin, 127, &left, &right ); // 3d + } + else { + S_SpatializeOrigin( loop2->origin, 90, &left, &right ); // sphere + } + + loop2->sfx->lastTimeUsed = time; + left_total += left; + right_total += right; + } + if( left_total == 0 && right_total == 0 ) { + continue; // not audible + } + + // allocate a channel + ch = &loop_channels[ numLoopChannels ]; + + if( left_total > 255 ) { + left_total = 255; + } + if( right_total > 255 ) { + right_total = 255; + } + + ch->master_vol = 127; + ch->leftvol = left_total; + ch->rightvol = right_total; + ch->thesfx = loop->sfx; + ch->doppler = loop->doppler; + ch->dopplerScale = loop->dopplerScale; + ch->oldDopplerScale = loop->oldDopplerScale; + ch->fullVolume = qfalse; + numLoopChannels++; + if( numLoopChannels == MAX_CHANNELS ) { + return; + } + } +} + +//============================================================================= + +/* +================= +S_ByteSwapRawSamples + +If raw data has been loaded in little endien binary form, this must be done. +If raw data was calculated, as with ADPCM, this should not be called. +================= +*/ +void S_ByteSwapRawSamples( int samples, int width, int s_channels, const byte *data ) { + int i; + + if( width != 2 ) { + return; + } + if( LittleShort( 256 ) == 256 ) { + return; + } + + if( s_channels == 2 ) { + samples <<= 1; + } + for( i = 0; i < samples; i++ ) { + ( ( short * )data )[ i ] = LittleShort( ( ( short * )data )[ i ] ); + } +} + +/* +============ +S_Base_RawSamples + +Music streaming +============ +*/ +void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_channels, const byte *data, float volume, int entityNum ) +{ + int i; + int src, dst; + float scale; + int intVolumeLeft, intVolumeRight; + portable_samplepair_t *rawsamples; + + if( !s_soundStarted || s_soundMuted ) { + return; + } + + if( ( stream < 0 ) || ( stream >= MAX_RAW_STREAMS ) ) { + return; + } + + rawsamples = s_rawsamples[ stream ]; + + if( s_muted->integer ) { + intVolumeLeft = intVolumeRight = 0; + } + else { + int leftvol, rightvol; + + if( entityNum >= 0 && entityNum < MAX_GENTITIES ) { + // support spatialized raw streams, e.g. for VoIP + S_SpatializeOrigin( loopSounds[ entityNum ].origin, 256, &leftvol, &rightvol ); + } + else { + leftvol = rightvol = 256; + } + + intVolumeLeft = leftvol * volume * s_volume->value; + intVolumeRight = rightvol * volume * s_volume->value; + } + + if( s_rawend[ stream ] < s_soundtime ) { + Com_DPrintf( "S_Base_RawSamples: resetting minimum: %i < %i\n", s_rawend[ stream ], s_soundtime ); + s_rawend[ stream ] = s_soundtime; + } + + scale = ( float )rate / dma.speed; + + //Com_Printf ("%i < %i < %i\n", s_soundtime, s_paintedtime, s_rawend[stream]); + if( s_channels == 2 && width == 2 ) + { + if( scale == 1.0 ) + { // optimized case + for( i = 0; i= samples ) + break; + dst = s_rawend[ stream ] & ( MAX_RAW_SAMPLES - 1 ); + s_rawend[ stream ]++; + rawsamples[ dst ].left = ( ( short * )data )[ src * 2 ] * intVolumeLeft; + rawsamples[ dst ].right = ( ( short * )data )[ src * 2 + 1 ] * intVolumeRight; + } + } + } + else if( s_channels == 1 && width == 2 ) + { + for( i = 0;; i++ ) + { + src = i*scale; + if( src >= samples ) + break; + dst = s_rawend[ stream ] & ( MAX_RAW_SAMPLES - 1 ); + s_rawend[ stream ]++; + rawsamples[ dst ].left = ( ( short * )data )[ src ] * intVolumeLeft; + rawsamples[ dst ].right = ( ( short * )data )[ src ] * intVolumeRight; + } + } + else if( s_channels == 2 && width == 1 ) + { + intVolumeLeft *= 256; + intVolumeRight *= 256; + + for( i = 0;; i++ ) + { + src = i*scale; + if( src >= samples ) + break; + dst = s_rawend[ stream ] & ( MAX_RAW_SAMPLES - 1 ); + s_rawend[ stream ]++; + rawsamples[ dst ].left = ( ( char * )data )[ src * 2 ] * intVolumeLeft; + rawsamples[ dst ].right = ( ( char * )data )[ src * 2 + 1 ] * intVolumeRight; + } + } + else if( s_channels == 1 && width == 1 ) + { + intVolumeLeft *= 256; + intVolumeRight *= 256; + + for( i = 0;; i++ ) + { + src = i*scale; + if( src >= samples ) + break; + dst = s_rawend[ stream ] & ( MAX_RAW_SAMPLES - 1 ); + s_rawend[ stream ]++; + rawsamples[ dst ].left = ( ( ( byte * )data )[ src ] - 128 ) * intVolumeLeft; + rawsamples[ dst ].right = ( ( ( byte * )data )[ src ] - 128 ) * intVolumeRight; + } + } + + if( s_rawend[ stream ] > s_soundtime + MAX_RAW_SAMPLES ) { + Com_DPrintf( "S_Base_RawSamples: overflowed %i > %i\n", s_rawend[ stream ], s_soundtime ); + } +} + +//============================================================================= + +/* +===================== +S_UpdateEntity + +let the sound system know where an entity currently is +====================== +*/ +void S_Base_UpdateEntity( int entityNum, const vec3_t origin, const vec3_t velocity ) { + if( entityNum < 0 || entityNum >= MAX_GENTITIES ) { + Com_Error( ERR_DROP, "S_UpdateEntityPosition: bad entitynum %i", entityNum ); + } + VectorCopy( origin, loopSounds[ entityNum ].origin ); + VectorCopy( velocity, loopSounds[ entityNum ].velocity ); +} + + +/* +============ +S_Respatialize + +Change the volumes of all the playing sounds for changes in their positions +============ +*/ +void S_Base_Respatialize( int entityNum, const vec3_t head, vec3_t axis[ 3 ], int inwater ) { + int i; + channel_t *ch; + vec3_t origin; + + if( !s_soundStarted || s_soundMuted ) { + return; + } + + listener_number = entityNum; + VectorCopy( head, listener_origin ); + VectorCopy( axis[ 0 ], listener_axis[ 0 ] ); + VectorCopy( axis[ 1 ], listener_axis[ 1 ] ); + VectorCopy( axis[ 2 ], listener_axis[ 2 ] ); + + // update spatialization for dynamic sounds + ch = s_channels; + for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + if( !ch->thesfx ) { + continue; + } + // local and first person sounds will always be full volume + if( ch->fullVolume ) { + ch->leftvol = ch->master_vol; + ch->rightvol = ch->master_vol; + } + else { + if( ch->fixed_origin ) { + VectorCopy( ch->origin, origin ); + } + else { + VectorCopy( loopSounds[ ch->entnum ].origin, origin ); + } + + S_SpatializeOrigin( origin, ch->master_vol, &ch->leftvol, &ch->rightvol ); + } + } + + // add loopsounds + S_AddLoopSounds(); +} + + +/* +======================== +S_ScanChannelStarts + +Returns qtrue if any new sounds were started since the last mix +======================== +*/ +qboolean S_ScanChannelStarts( void ) { + channel_t *ch; + int i; + qboolean newSamples; + + newSamples = qfalse; + ch = s_channels; + + for( i = 0; ithesfx ) { + continue; + } + // if this channel was just started this frame, + // set the sample count to it begins mixing + // into the very first sample + if( ch->startSample == START_SAMPLE_IMMEDIATE ) { + ch->startSample = s_paintedtime; + newSamples = qtrue; + continue; + } + + // if it is completely finished by now, clear it + if( ch->startSample + ( ch->thesfx->soundLength ) <= s_paintedtime ) { + S_ChannelFree( ch ); + } + } + + return newSamples; +} + +/* +============ +S_Update + +Called once each time through the main loop +============ +*/ +void S_Base_Update( void ) { + int i; + int total; + channel_t *ch; + + if( !s_soundStarted || s_soundMuted ) { + // Com_DPrintf ("not started or muted\n"); + return; + } + + // + // debugging output + // + if( s_show->integer == 2 ) { + total = 0; + ch = s_channels; + for( i = 0; ithesfx && ( ch->leftvol || ch->rightvol ) ) { + Com_Printf( "%d %d %s\n", ch->leftvol, ch->rightvol, ch->thesfx->soundName ); + total++; + } + } + + Com_Printf( "----(%i)---- painted: %i\n", total, s_paintedtime ); + } + + // add raw data from streamed samples + S_UpdateBackgroundTrack(); + + // mix some sound + S_Update_(); +} + +void S_GetSoundtime( void ) +{ + int samplepos; + static int buffers; + static int oldsamplepos; + int fullsamples; + + fullsamples = dma.samples / dma.channels; + + // it is possible to miscount buffers if it has wrapped twice between + // calls to S_Update. Oh well. + samplepos = SNDDMA_GetDMAPos(); + if( samplepos < oldsamplepos ) + { + buffers++; // buffer wrapped + + if( s_paintedtime > 0x40000000 ) + { // time to chop things off to avoid 32 bit limits + buffers = 0; + s_paintedtime = fullsamples; + S_Base_StopAllSounds(); + } + } + oldsamplepos = samplepos; + + s_soundtime = buffers*fullsamples + samplepos / dma.channels; + +#if 0 + // check to make sure that we haven't overshot + if( s_paintedtime < s_soundtime ) + { + Com_DPrintf( "S_Update_ : overflow\n" ); + s_paintedtime = s_soundtime; + } +#endif + + if( dma.submission_chunk < 256 ) { + s_paintedtime = s_soundtime + s_mixPreStep->value * dma.speed; + } + else { + s_paintedtime = s_soundtime + dma.submission_chunk; + } +} + + +void S_Update_( void ) { + unsigned endtime; + int samps; + static float lastTime = 0.0f; + float ma, op; + float thisTime, sane; + static int ot = -1; + + if( !s_soundStarted || s_soundMuted ) { + return; + } + + thisTime = Com_Milliseconds(); + + // Updates s_soundtime + S_GetSoundtime(); + + if( s_soundtime == ot ) { + return; + } + ot = s_soundtime; + + // clear any sound effects that end before the current time, + // and start any new sounds + S_ScanChannelStarts(); + + sane = thisTime - lastTime; + if( sane<11 ) { + sane = 11; // 85hz + } + + ma = s_mixahead->value * dma.speed; + op = s_mixPreStep->value + sane*dma.speed*0.01; + + if( op < ma ) { + ma = op; + } + + // mix ahead of current position + endtime = s_soundtime + ma; + + // mix to an even submission block size + endtime = ( endtime + dma.submission_chunk - 1 ) + & ~( dma.submission_chunk - 1 ); + + // never mix more than the complete buffer + samps = dma.samples >> ( dma.channels - 1 ); + if( endtime - s_soundtime > samps ) + endtime = s_soundtime + samps; + + + + SNDDMA_BeginPainting(); + + S_PaintChannels( endtime ); + + SNDDMA_Submit(); + + lastTime = thisTime; +} + + + +/* +=============================================================================== + +background music functions + +=============================================================================== +*/ + +/* +====================== +S_StopBackgroundTrack +====================== +*/ +void S_Base_StopBackgroundTrack( void ) { + if( !s_backgroundStream ) + return; + S_CodecCloseStream( s_backgroundStream ); + s_backgroundStream = NULL; + s_rawend[ 0 ] = 0; +} + +/* +====================== +S_OpenBackgroundStream +====================== +*/ +static void S_OpenBackgroundStream( const char *filename ) { + // close the background track, but DON'T reset s_rawend + // if restarting the same back ground track + if( s_backgroundStream ) + { + S_CodecCloseStream( s_backgroundStream ); + s_backgroundStream = NULL; + } + + // Open stream + s_backgroundStream = S_CodecOpenStream( filename ); + if( !s_backgroundStream ) { + Com_Printf( S_COLOR_YELLOW "WARNING: couldn't open music file %s\n", filename ); + return; + } + + if( s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050 ) { + Com_Printf( S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo\n", filename ); + } +} + +/* +====================== +S_StartBackgroundTrack +====================== +*/ +void S_Base_StartBackgroundTrack( const char *intro, const char *loop ){ + if( !intro ) { + intro = ""; + } + if( !loop || !loop[ 0 ] ) { + loop = intro; + } + Com_DPrintf( "S_StartBackgroundTrack( %s, %s )\n", intro, loop ); + + if( !*intro ) + { + S_Base_StopBackgroundTrack(); + return; + } + + Q_strncpyz( s_backgroundLoop, loop, sizeof( s_backgroundLoop ) ); + + S_OpenBackgroundStream( intro ); +} + +/* +====================== +S_UpdateBackgroundTrack +====================== +*/ +void S_UpdateBackgroundTrack( void ) { + int bufferSamples; + int fileSamples; + byte raw[ 30000 ]; // just enough to fit in a mac stack frame + int fileBytes; + int r; + + if( !s_backgroundStream ) { + return; + } + + // don't bother playing anything if musicvolume is 0 + if( s_musicVolume->value <= 0 ) { + return; + } + + // see how many samples should be copied into the raw buffer + if( s_rawend[ 0 ] < s_soundtime ) { + s_rawend[ 0 ] = s_soundtime; + } + + while( s_rawend[ 0 ] < s_soundtime + MAX_RAW_SAMPLES ) { + bufferSamples = MAX_RAW_SAMPLES - ( s_rawend[ 0 ] - s_soundtime ); + + // decide how much data needs to be read from the file + fileSamples = bufferSamples * s_backgroundStream->info.rate / dma.speed; + + if( !fileSamples ) + return; + + // our max buffer size + fileBytes = fileSamples * ( s_backgroundStream->info.width * s_backgroundStream->info.channels ); + if( fileBytes > sizeof( raw ) ) { + fileBytes = sizeof( raw ); + fileSamples = fileBytes / ( s_backgroundStream->info.width * s_backgroundStream->info.channels ); + } + + // Read + r = S_CodecReadStream( s_backgroundStream, fileBytes, raw ); + if( r < fileBytes ) + { + fileSamples = r / ( s_backgroundStream->info.width * s_backgroundStream->info.channels ); + } + + if( r > 0 ) + { + // add to raw buffer + S_Base_RawSamples( 0, fileSamples, s_backgroundStream->info.rate, + s_backgroundStream->info.width, s_backgroundStream->info.channels, raw, s_musicVolume->value, -1 ); + } + else + { + // loop + if( s_backgroundLoop[ 0 ] ) + { + S_OpenBackgroundStream( s_backgroundLoop ); + if( !s_backgroundStream ) + return; + } + else + { + S_Base_StopBackgroundTrack(); + return; + } + } + + } +} + + + +/* +====================== +S_FreeOldestSound +====================== +*/ + +void S_FreeOldestSound( void ) { + int i, oldest, used; + sfx_t *sfx; + sndBuffer *buffer, *nbuffer; + + oldest = Com_Milliseconds(); + used = 0; + + for( i = 1; i < s_numSfx; i++ ) { + sfx = &s_knownSfx[ i ]; + if( sfx->inMemory && sfx->lastTimeUsedlastTimeUsed; + } + } + + sfx = &s_knownSfx[ used ]; + + Com_DPrintf( "S_FreeOldestSound: freeing sound %s\n", sfx->soundName ); + + buffer = sfx->soundData; + while( buffer != NULL ) { + nbuffer = buffer->next; + SND_free( buffer ); + buffer = nbuffer; + } + sfx->inMemory = qfalse; + sfx->soundData = NULL; +} + +// ======================================================================= +// Shutdown sound engine +// ======================================================================= + +void S_Base_Shutdown( void ) { + if( !s_soundStarted ) { + return; + } + + SNDDMA_Shutdown(); + SND_shutdown(); + + s_soundStarted = 0; + s_numSfx = 0; + + Cmd_RemoveCommand( "s_info" ); +} + +/* +================ +S_Init +================ +*/ +qboolean S_Base_Init( soundInterface_t *si ) { + qboolean r; + + if( !si ) { + return qfalse; + } + + s_mixahead = Cvar_Get( "s_mixahead", "0.2", CVAR_ARCHIVE ); + s_mixPreStep = Cvar_Get( "s_mixPreStep", "0.05", CVAR_ARCHIVE ); + s_show = Cvar_Get( "s_show", "0", CVAR_CHEAT ); + s_testsound = Cvar_Get( "s_testsound", "0", CVAR_CHEAT ); + + r = SNDDMA_Init(); + + if( r ) { + s_soundStarted = 1; + s_soundMuted = 1; + // s_numSfx = 0; + + Com_Memset( sfxHash, 0, sizeof( sfx_t * )*LOOP_HASH ); + + s_soundtime = 0; + s_paintedtime = 0; + + S_Base_StopAllSounds(); + } + else { + return qfalse; + } + + si->Shutdown = S_Base_Shutdown; + si->StartSound = S_Base_StartSound; + si->StartLocalSound = S_Base_StartLocalSound; + si->StartBackgroundTrack = S_Base_StartBackgroundTrack; + si->StopBackgroundTrack = S_Base_StopBackgroundTrack; + si->RawSamples = S_Base_RawSamples; + si->StopAllSounds = S_Base_StopAllSounds; + si->ClearLoopingSounds = S_Base_ClearLoopingSounds; + si->AddLoopingSound = S_Base_AddLoopingSound; + si->AddRealLoopingSound = S_Base_AddRealLoopingSound; + si->StopLoopingSound = S_Base_StopLoopingSound; + si->Respatialize = S_Base_Respatialize; + si->UpdateEntity = S_Base_UpdateEntity; + si->Update = S_Base_Update; + si->DisableSounds = S_Base_DisableSounds; + si->BeginRegistration = S_Base_BeginRegistration; + si->RegisterSound = S_Base_RegisterSound; + si->IsSoundPlaying = S_Base_IsSoundPlaying; + si->ClearSoundBuffer = S_Base_ClearSoundBuffer; + si->SoundInfo = S_Base_SoundInfo; + si->SoundList = S_Base_SoundList; + +#ifdef USE_VOIP + si->StartCapture = S_Base_StartCapture; + si->AvailableCaptureSamples = S_Base_AvailableCaptureSamples; + si->Capture = S_Base_Capture; + si->StopCapture = S_Base_StopCapture; + si->MasterGain = S_Base_MasterGain; +#endif + + return qtrue; +} diff --git a/code/client/snd_local.h b/code/client/snd_local.h new file mode 100644 index 00000000..5c25c634 --- /dev/null +++ b/code/client/snd_local.h @@ -0,0 +1,340 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// snd_local.h -- private sound definations + + +#include "../qcommon/q_shared.h" +#include "../qcommon/qcommon.h" +#include "snd_public.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define PAINTBUFFER_SIZE 4096 // this is in samples + +#define SND_CHUNK_SIZE 1024 // samples +#define SND_CHUNK_SIZE_FLOAT (SND_CHUNK_SIZE/2) // floats +#define SND_CHUNK_SIZE_BYTE (SND_CHUNK_SIZE*2) // floats + +#define SFX_FLAG_STREAMED 4 + +typedef struct { + int left; // the final values will be clamped to +/- 0x00ffff00 and shifted down + int right; +} portable_samplepair_t; + +typedef struct adpcm_state { + short sample; /* Previous output value */ + char index; /* Index into stepsize table */ +} adpcm_state_t; + +typedef struct sndBuffer_s { + short sndChunk[SND_CHUNK_SIZE]; + struct sndBuffer_s *next; + int size; + adpcm_state_t adpcm; +} sndBuffer; + +typedef struct { + int channels; + int samples; // mono samples in buffer + int submission_chunk; // don't mix less than this # + int samplebits; + int speed; + byte *buffer; +} dma_t; + +typedef struct sfx_s { + sndBuffer *soundData; + qboolean defaultSound; // couldn't be loaded, so use buzz + qboolean inMemory; // not in Memory + qboolean soundCompressed; // not in Memory + int soundCompressionMethod; + int soundLength; + int soundChannels; + char soundName[MAX_QPATH]; + int lastTimeUsed; + int iFlags; + struct sfx_s *next; +} sfx_t; + +typedef struct { + char name[ MAX_QPATH ]; + int loop_start; + int loop_end; + int max_number_playing; + float max_factor; +} sfx_info_t; + +typedef struct { + vec3_t position; + vec3_t velocity; + int time; + qboolean use_listener; +} s_entity_t; + +typedef struct { + char alias[ 32 ]; + char path[ MAX_QPATH ]; + int mood_num; + int flags; + float volume; + float fadetime; + int current_pos; + int current_state; +} song_t; + +typedef struct { + int iFlags; + char szName[ MAX_QPATH ]; +} sfxsavegame_t; + +typedef struct channelbasesavegame_s { + qboolean bPlaying; + int iStatus; + + sfxsavegame_t sfx; + + int iEntNum; + int iEntChannel; + + vec3_t vOrigin; + float fVolume; + int iBaseRate; + float fNewPitchMult; + float fMinDist; + float fMaxDist; + + int iStartTime; + int iTime; + int iNextCheckObstructionTime; + int iEndTime; + + int iFlags; + int iOffset; + int iLoopCount; +} channelbasesavegame_t; + +typedef struct soundsystemsavegame_s { + channelbasesavegame_t Channels[ 96 ]; +} soundsystemsavegame_t; + +#define START_SAMPLE_IMMEDIATE 0x7fffffff + +#define MAX_DOPPLER_SCALE 50.0f //arbitrary + +#define THIRD_PERSON_THRESHOLD_SQ (48.0f*48.0f) + +typedef struct loopSound_s { + vec3_t origin; + vec3_t velocity; + sfx_t *sfx; + int mergeFrame; + qboolean active; + qboolean kill; + qboolean doppler; + float dopplerScale; + float oldDopplerScale; + int framenum; +} loopSound_t; + +typedef struct channel_s { + int allocTime; + int startSample; // START_SAMPLE_IMMEDIATE = set immediately on next mix + int entnum; // to allow overriding a specific sound + int entchannel; // to allow overriding a specific sound + int leftvol; // 0-255 volume after spatialization + int rightvol; // 0-255 volume after spatialization + int master_vol; // 0-255 volume before spatialization + float dopplerScale; + float oldDopplerScale; + vec3_t origin; // only use if fixed_origin is set + qboolean fixed_origin; // use origin instead of fetching entnum's origin + sfx_t *thesfx; // sfx structure + qboolean doppler; + qboolean fullVolume; +} channel_t; + + +#define WAV_FORMAT_PCM 1 + + +typedef struct { + int format; + int rate; + int width; + int channels; + int samples; + int dataofs; // chunk starts this many bytes from file start +} wavinfo_t; + +typedef struct { + float volume; + float minDist; + float pitch; + float maxDist; + qboolean streamed; + int flags; +} sndparm_t; + +// Interface between Q3 sound "api" and the sound backend +typedef struct +{ + void (*Shutdown)(void); + void (*StartSound)( const vec3_t origin, int entnum, int entchannel, sfxHandle_t sfx ); + void (*StartLocalSound)( sfxHandle_t sfx, int channelNum ); + void (*StartBackgroundTrack)( const char *intro, const char *loop ); + void (*StopBackgroundTrack)( void ); + void (*RawSamples)(int stream, int samples, int rate, int width, int channels, const byte *data, float volume, int entityNum); + void (*StopAllSounds)( void ); + void (*ClearLoopingSounds)( qboolean killall ); + void (*AddLoopingSound)( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ); + void (*AddRealLoopingSound)( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ); + void (*StopLoopingSound)(int entityNum ); + void (*Respatialize)( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater ); + void (*UpdateEntity)( int entityNum, const vec3_t origin, const vec3_t velocity ); + void (*Update)( void ); + void (*DisableSounds)( void ); + void (*BeginRegistration)( void ); + sfxHandle_t (*RegisterSound)( const char *sample, qboolean compressed ); + qboolean (*IsSoundPlaying)( int channelNumber, const char *name ); + void (*ClearSoundBuffer)( void ); + void (*SoundInfo)( void ); + void (*SoundList)( void ); +#ifdef USE_VOIP + void (*StartCapture)( void ); + int (*AvailableCaptureSamples)( void ); + void (*Capture)( int samples, byte *data ); + void (*StopCapture)( void ); + void (*MasterGain)( float gain ); +#endif +} soundInterface_t; + + +/* +==================================================================== + + SYSTEM SPECIFIC FUNCTIONS + +==================================================================== +*/ + +// initializes cycling through a DMA buffer and returns information on it +qboolean SNDDMA_Init(void); + +// gets the current DMA position +int SNDDMA_GetDMAPos(void); + +// shutdown the DMA xfer. +void SNDDMA_Shutdown(void); + +void SNDDMA_BeginPainting (void); + +void SNDDMA_Submit(void); + +//==================================================================== + +#define MAX_SOUNDCHANNELS 96 + +extern channel_t s_channels[MAX_SOUNDCHANNELS]; +extern channel_t loop_channels[MAX_SOUNDCHANNELS]; +extern int numLoopChannels; + +extern int s_paintedtime; +extern vec3_t listener_forward; +extern vec3_t listener_right; +extern vec3_t listener_up; +extern dma_t dma; + +#define MAX_RAW_SAMPLES 16384 +#define MAX_RAW_STREAMS (MAX_CLIENTS * 2 + 1) +extern portable_samplepair_t s_rawsamples[MAX_RAW_STREAMS][MAX_RAW_SAMPLES]; +extern int s_rawend[MAX_RAW_STREAMS]; + +extern cvar_t *s_volume; +extern cvar_t *s_musicVolume; +extern cvar_t *s_muted; +extern cvar_t *s_doppler; + +extern cvar_t *s_testsound; + +extern sndparm_t soundparm; + +qboolean S_LoadSound( sfx_t *sfx ); + +void SND_free( sndBuffer *v ); +sndBuffer* SND_malloc( void ); +void SND_setup( void ); +void SND_shutdown( void ); + +void S_PaintChannels( int endtime ); + +void S_memoryLoad( sfx_t *sfx ); + +// spatializes a channel +void S_Spatialize( channel_t *ch ); + +// adpcm functions +int S_AdpcmMemoryNeeded( const wavinfo_t *info ); +void S_AdpcmEncodeSound( sfx_t *sfx, short *samples ); +void S_AdpcmGetSamples( sndBuffer *chunk, short *to ); + +// wavelet function + +#define SENTINEL_MULAW_ZERO_RUN 127 +#define SENTINEL_MULAW_FOUR_BIT_RUN 126 + +void S_FreeOldestSound( void ); + +#define NXStream byte + +void encodeWavelet( sfx_t *sfx, short *packets ); +void decodeWavelet( sndBuffer *stream, short *packets ); + +void encodeMuLaw( sfx_t *sfx, short *packets ); +extern short mulawToShort[ 256 ]; + +extern short *sfxScratchBuffer; +extern sfx_t *sfxScratchPointer; +extern int sfxScratchIndex; + +qboolean S_Base_Init( soundInterface_t *si ); + +// OpenAL stuff +typedef enum +{ + SRCPRI_AMBIENT = 0, // Ambient sound effects + SRCPRI_ENTITY, // Entity sound effects + SRCPRI_ONESHOT, // One-shot sounds + SRCPRI_LOCAL, // Local sounds + SRCPRI_STREAM // Streams (music, cutscenes) +} alSrcPriority_t; + +typedef int srcHandle_t; + +void callbackServer( int entnum, int channel_number, const char *name ); +qboolean S_AL_Init( soundInterface_t *si ); + +#ifdef __cplusplus +} +#endif diff --git a/code/client/snd_main.c b/code/client/snd_main.c new file mode 100644 index 00000000..ec9a524f --- /dev/null +++ b/code/client/snd_main.c @@ -0,0 +1,984 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "client.h" +#include "server.h" +#include "snd_codec.h" +#include "snd_local.h" +#include "snd_public.h" + +cvar_t *s_volume; +cvar_t *s_loadas8bit; +cvar_t *s_khz; +cvar_t *s_show; +cvar_t *s_testsound; +cvar_t *s_separation; +cvar_t *s_musicVolume; +cvar_t *s_ambientVolume; +cvar_t *s_doppler; +cvar_t *s_backend; +cvar_t *s_muteWhenMinimized; +cvar_t *s_muted; + +static qboolean s_bFading; +static float s_fFadeVolume; +static float s_fFadeStartTime; +static float s_fFadeStopTime; + +sfx_info_t sfx_infos[ 1000 ]; +sfx_t s_knownSfx[ 1400 ]; +int s_numSfx; +s_entity_t s_entity[ MAX_GENTITIES ]; +static int s_registrationSequence; +static qboolean s_inRegistration; +cvar_t *s_mixPreStep; +cvar_t *s_dialogscale; +int numLoopSounds; +loopSound_t loopSounds[ 64 ]; + +sndparm_t soundparm; + +static soundInterface_t si; + +/* +================= +S_ValidateInterface +================= +*/ +static qboolean S_ValidSoundInterface( soundInterface_t *si ) +{ + if( !si->Shutdown ) return qfalse; + if( !si->StartSound ) return qfalse; + if( !si->StartLocalSound ) return qfalse; + if( !si->StartBackgroundTrack ) return qfalse; + if( !si->StopBackgroundTrack ) return qfalse; + if( !si->RawSamples ) return qfalse; + if( !si->StopAllSounds ) return qfalse; + if( !si->ClearLoopingSounds ) return qfalse; + if( !si->AddLoopingSound ) return qfalse; + if( !si->AddRealLoopingSound ) return qfalse; + if( !si->StopLoopingSound ) return qfalse; + if( !si->Respatialize ) return qfalse; + if( !si->UpdateEntity ) return qfalse; + if( !si->Update ) return qfalse; + if( !si->DisableSounds ) return qfalse; + if( !si->BeginRegistration ) return qfalse; + if( !si->RegisterSound ) return qfalse; + if( !si->ClearSoundBuffer ) return qfalse; + if( !si->SoundInfo ) return qfalse; + if( !si->SoundList ) return qfalse; + + return qtrue; +} + +/* +================= +MUSIC_Pause +================= +*/ +void MUSIC_Pause() +{ + // FIXME: stub + STUB(); +} + +/* +================= +MUSIC_Unpause +================= +*/ +void MUSIC_Unpause() +{ + // FIXME: stub + STUB(); +} + +/* +================= +MUSIC_LoadSoundtrackFile +================= +*/ +qboolean MUSIC_LoadSoundtrackFile( const char *filename ) +{ + // FIXME: stub + STUB(); + return qfalse; +} + +/* +================= +MUSIC_SongValid +================= +*/ +qboolean MUSIC_SongValid( const char *mood ) +{ + // FIXME: stub + STUB(); + return qfalse; +} + +/* +================= +MUSIC_Loaded +================= +*/ +qboolean MUSIC_Loaded( void ) +{ + // FIXME: stub + STUB(); + return qfalse; +} + +/* +================= +Music_Update +================= +*/ +void Music_Update( void ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +MUSIC_SongEnded +================= +*/ +void MUSIC_SongEnded( void ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +S_StartSound +================= +*/ +void MUSIC_NewSoundtrack( const char *name ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +MUSIC_UpdateMood +================= +*/ +void MUSIC_UpdateMood( int current, int fallback ) +{ + // FIXME: stub + //STUB(); +} + +/* +================= +MUSIC_UpdateVolume +================= +*/ +void MUSIC_UpdateVolume( float volume, float fade_time ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +MUSIC_StopAllSongs +================= +*/ +void MUSIC_StopAllSongs( void ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +MUSIC_FreeAllSongs +================= +*/ +void MUSIC_FreeAllSongs( void ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +MUSIC_Playing +================= +*/ +qboolean MUSIC_Playing( void ) +{ + // FIXME: stub + STUB(); + return qfalse; +} + +/* +================= +MUSIC_FindSong +================= +*/ +int MUSIC_FindSong( const char *name ) +{ + // FIXME: stub + STUB(); + return 0; +} + +/* +================= +MUSIC_CurrentSongChannel +================= +*/ +int MUSIC_CurrentSongChannel( void ) +{ + // FIXME: stub + STUB(); + return 0; +} + +/* +================= +MUSIC_StopChannel +================= +*/ +void MUSIC_StopChannel( int channel_number ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +MUSIC_PlaySong +================= +*/ +qboolean MUSIC_PlaySong( const char *alias ) +{ + // FIXME: stub + STUB(); + return qfalse; +} + +/* +================= +MUSIC_UpdateMusicVolumes +================= +*/ +void MUSIC_UpdateMusicVolumes( void ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +MUSIC_CheckForStoppedSongs +================= +*/ +void MUSIC_CheckForStoppedSongs( void ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +S_StartSound +================= +*/ +void S_StartSound( const vec3_t origin, int entNum, int entChannel, sfxHandle_t sfxHandle, float volume, float minDist, float pitch, float maxDist, qboolean streamed ) +{ + if( !si.StartSound || sfxHandle == -1 ) { + return; + } + + soundparm.volume = volume; + soundparm.minDist = minDist; + soundparm.pitch = pitch; + soundparm.maxDist = maxDist; + soundparm.streamed = streamed; + + si.StartSound( origin, entNum, entChannel, sfxHandle ); +} + +/* +================= +S_StartLocalSound +================= +*/ +void S_StartLocalSound( const char *sound_name, qboolean force_load ) +{ + sfxHandle_t sfxHandle; + const char *name; + AliasListNode_t *pSoundAlias = NULL; + + if( !si.StartLocalSound ) { + return; + } + + if( !sound_name ) { + return; + } + + // obtain the sound alias + name = Alias_FindRandom( sound_name, &pSoundAlias ); + + if( !name ) { + name = sound_name; + } + + if( pSoundAlias ) { + sfxHandle = S_RegisterSound( name, pSoundAlias->streamed, qfalse ); + } else { + sfxHandle = S_RegisterSound( name, qfalse, qfalse ); + } + + if( sfxHandle < 0 || sfxHandle >= s_numSfx ) { + Com_Printf( "S_StartLocalSound: handle %i out of range\n", sfxHandle ); + return; + } + + if( name ) + { + soundparm.volume = pSoundAlias->volumeMod * randweight() + pSoundAlias->volume; + soundparm.minDist = -1.0; + soundparm.pitch = pSoundAlias->pitchMod * randweight() + pSoundAlias->pitch; + soundparm.maxDist = -1.0; + soundparm.streamed = pSoundAlias->streamed; + } + else + { + soundparm.volume = -1.0; + soundparm.minDist = -1.0; + soundparm.pitch = 1.0; + soundparm.maxDist = -1.0; + soundparm.streamed = qfalse; + } + + si.StartLocalSound( sfxHandle, CHAN_MENU ); +} + +/* +================= +S_StartBackgroundTrack +================= +*/ +void S_StartBackgroundTrack( const char *intro, const char *loop ) +{ + if( si.StartBackgroundTrack ) { + si.StartBackgroundTrack( intro, loop ); + } +} + +/* +================= +S_StopBackgroundTrack +================= +*/ +void S_StopBackgroundTrack( void ) +{ + if( si.StopBackgroundTrack ) { + si.StopBackgroundTrack( ); + } +} + +/* +================= +S_RawSamples +================= +*/ +void S_RawSamples (int stream, int samples, int rate, int width, int channels, + const byte *data, float volume, int entityNum) +{ + if(si.RawSamples) + si.RawSamples(stream, samples, rate, width, channels, data, volume, entityNum); +} + +/* +================= +S_StopSound +================= +*/ +void S_StopSound( int entNum, int channel ) +{ + // FIXME: stub +} + +/* +================= +S_StopAllSounds +================= +*/ +void S_StopAllSounds( qboolean stop_music ) +{ + if( si.StopAllSounds ) { + si.StopAllSounds( ); + } + + // FIXME: stop music +} + +/* +================= +S_StopAllSounds_f +================= +*/ +void S_StopAllSounds_f( void ) +{ + S_StopAllSounds( qtrue ); +} + +/* +================= +S_ClearLoopingSounds +================= +*/ +void S_ClearLoopingSounds( void ) +{ + if( si.ClearLoopingSounds ) { + si.ClearLoopingSounds( qtrue ); + } +} + +/* +================= +S_AddLoopingSound +================= +*/ +void S_AddLoopingSound( const vec3_t origin, const vec3_t velocity, + sfxHandle_t sfx, float volume, float minDist, float maxDist, float pitch, int flags ) +{ + if( !si.AddLoopingSound ) { + return; + } + + soundparm.volume = volume; + soundparm.minDist = minDist; + soundparm.maxDist = maxDist; + soundparm.pitch = pitch; + soundparm.flags = flags; + + si.AddLoopingSound( ENTITYNUM_WORLD, origin, velocity, sfx ); +} + +/* +================= +S_AddRealLoopingSound +================= +*/ +void S_AddRealLoopingSound( int entityNum, const vec3_t origin, + const vec3_t velocity, sfxHandle_t sfx ) +{ + if( si.AddRealLoopingSound ) { + si.AddRealLoopingSound( entityNum, origin, velocity, sfx ); + } +} + +/* +================= +S_StopLoopingSound +================= +*/ +void S_StopLoopingSound( int entityNum ) +{ + if( si.StopLoopingSound ) { + si.StopLoopingSound( entityNum ); + } +} + +/* +================= +S_Respatialize +================= +*/ +void S_Respatialize( int entityNum, const vec3_t origin, + vec3_t axis[3] ) +{ + S_RespatializeEx( entityNum, origin, axis, qfalse ); +} + +/* +================= +S_RespatializeEx +================= +*/ +void S_RespatializeEx( int entityNum, const vec3_t origin, + vec3_t axis[ 3 ], int inwater ) +{ + if( si.Respatialize ) { + si.Respatialize( entityNum, origin, axis, inwater ); + } +} + +/* +================= +S_UpdateEntity +================= +*/ +void S_UpdateEntity( int entityNum, const vec3_t origin, const vec3_t velocity, qboolean use_listener ) +{ + if( si.UpdateEntity ) { + si.UpdateEntity( entityNum, origin, velocity ); + } +} + +/* +================= +S_Update +================= +*/ +void S_Update( void ) +{ + if( s_muteWhenMinimized->integer && com_minimized->integer ) { + S_StopAllSounds( qtrue ); + return; + } + + if( si.Update ) { + si.Update( ); + } +} + +/* +================= +S_DisableSounds +================= +*/ +void S_DisableSounds( void ) +{ + if( si.DisableSounds ) { + si.DisableSounds( ); + } +} + +/* +================= +S_BeginRegistration +================= +*/ +void S_BeginRegistration( void ) +{ + if( si.BeginRegistration ) { + si.BeginRegistration( ); + } +} + +/* +================= +S_EndRegistration +================= +*/ +void S_EndRegistration( void ) +{ + // FIXME: stub +} + +/* +================= +S_IsSoundRegistered +================= +*/ +qboolean S_IsSoundRegistered( const char *name ) +{ + // FIXME: stub + return qfalse; +} + +/* +================= +S_RegisterSound +================= +*/ +sfxHandle_t S_RegisterSound( const char *sample, qboolean compressed, qboolean force_load ) +{ + if( si.RegisterSound ) { + if ( !strstr(sample, "sound/null.wav") ) + return si.RegisterSound( sample, compressed ); + else return -1; + } else { + return 0; + } +} + +/* +================= +S_GetSoundTime +================= +*/ +float S_GetSoundTime( sfxHandle_t handle ) +{ + // FIXME: stub + STUB(); + return 0.0; +} + +/* +================= +S_SetGlobalAmbientVolumeLevel +================= +*/ +void S_SetGlobalAmbientVolumeLevel( float volume ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +S_SetReverb +================= +*/ +void S_SetReverb( int reverb_type, float reverb_level ) +{ + // FIXME: stub + STUB(); +} + +/* +================= +S_IsSoundPlaying +================= +*/ +int S_IsSoundPlaying( int channelNumber, const char *name ) +{ + if( si.IsSoundPlaying ) { + return si.IsSoundPlaying( channelNumber, name ); + } + + return qfalse; +} + +/* +================= +S_ClearSoundBuffer +================= +*/ +void S_ClearSoundBuffer( void ) +{ + if( si.ClearSoundBuffer ) { + si.ClearSoundBuffer( ); + } +} + +/* +================= +S_SoundInfo +================= +*/ +void S_SoundInfo( void ) +{ + if( si.SoundInfo ) { + si.SoundInfo( ); + } +} + +/* +================= +S_SoundList +================= +*/ +void S_SoundList( void ) +{ + if( si.SoundList ) { + si.SoundList( ); + } +} + +//============================================================================= + +/* +================= +S_Play_f +================= +*/ +void S_Play_f( void ) { + int i; + sfxHandle_t h; + char name[256]; + + if( !si.RegisterSound || !si.StartLocalSound ) { + return; + } + + i = 1; + while ( i [loopfile]\n"); + return; + } + +} + +//============================================================================= + +/* +================= +S_SaveData +================= +*/ +void S_SaveData( soundsystemsavegame_t *pSave ) +{ + /* + int i; + qboolean bSoundWasUnpaused; + + for( i = 0; i < MAX_SOUNDCHANNELS; i++ ) { + S_StoreBase( &pSave->Channels[ i ] ); + } + */ + + // FIXME: stub +} + +/* +================= +S_LoadData +================= +*/ +void S_LoadData( soundsystemsavegame_t *pSave ) +{ + int i; + + for( i = 0; i < MAX_SOUNDCHANNELS; i++ ) { + S_InitBase( &pSave->Channels[ i ] ); + } +} + +/* +================= +S_InitBase +================= +*/ +void S_InitBase( channelbasesavegame_t *pBase ) +{ + if( !pBase->bPlaying ) { + return; + } + + if( strstr( pBase->sfx.szName, "null.wav" ) ) { + return; + } + + SV_AddSvsTimeFixup( &pBase->iStartTime ); + SV_AddSvsTimeFixup( &pBase->iEndTime ); + SV_AddSvsTimeFixup( &pBase->iTime ); +} + +/* +================= +S_InitBase +================= +*/ +void S_StoreBase( channelbasesavegame_t *pBase, channel_t *channel ) +{ + if( !channel) { + return; + } + + if( strstr( pBase->sfx.szName, "null.wav" ) ) { + return; + } + + // FIXME: set proper fields + + pBase->bPlaying = qtrue; + pBase->iOffset = 0; + pBase->iLoopCount = 0; + memcpy( pBase->sfx.szName, channel->thesfx->soundName, sizeof( pBase->sfx.szName ) ); + pBase->sfx.iFlags = 0; + pBase->iBaseRate = 0; + pBase->iStatus = 0; + pBase->fNewPitchMult = 0; + + pBase->iStartTime = 0; + pBase->iEndTime = 0; + pBase->iEntChannel = channel->entchannel; + pBase->iEntNum = channel->entnum; + pBase->iFlags = 0; + pBase->fMaxDist = 0; + pBase->fMinDist = 0; + pBase->iNextCheckObstructionTime = 0; + VectorCopy( channel->origin, pBase->vOrigin ); + pBase->iTime = 0; + pBase->fVolume = channel->master_vol / 127.0; +} + +/* +================= +S_FadeSound +================= +*/ +void S_FadeSound( float fTime ) { + Com_Printf( "Called FadeSound with: %f\n", fTime ); + + if( fTime > 0.0 ) + { + s_bFading = qtrue; + s_fFadeStartTime = cls.realtime; + s_fFadeVolume = 1.0; + s_fFadeStopTime = cls.realtime + fTime; + } + else + { + s_fFadeVolume = 1.0; + s_bFading = qfalse; + } +} + +/* +================= +callbackServer +================= +*/ +void callbackServer( int entnum, int channel_number, const char *name ) { + if( com_sv_running->integer ) { + SV_SoundCallback( entnum, channel_number, name ); + } +} + +/* +================= +S_Init +================= +*/ +void S_Init( void ) +{ + cvar_t *cv; + qboolean started = qfalse; + + Com_Printf( "------ Initializing Sound ------\n" ); + + s_volume = Cvar_Get( "s_volume", "0.8", CVAR_ARCHIVE ); + s_musicVolume = Cvar_Get( "s_musicvolume", "0.25", CVAR_ARCHIVE ); + s_ambientVolume = Cvar_Get( "s_ambientvolume", "1.00", CVAR_ARCHIVE ); + s_separation = Cvar_Get( "s_separation", "0.5", CVAR_ARCHIVE ); + s_khz = Cvar_Get( "s_khz", "11", CVAR_SOUND_LATCH | CVAR_ARCHIVE ); + s_loadas8bit = Cvar_Get( "s_loadas8bit", "0", CVAR_LATCH | CVAR_ARCHIVE ); + s_mixPreStep = Cvar_Get( "s_mixPreStep", "0.05", CVAR_ARCHIVE ); + s_show = Cvar_Get( "s_show", "0", CVAR_CHEAT ); + s_testsound = Cvar_Get( "s_testsound", "", CVAR_CHEAT ); + s_dialogscale = Cvar_Get( "s_dialogscale", "1", CVAR_ARCHIVE ); + s_doppler = Cvar_Get( "s_doppler", "1", CVAR_ARCHIVE ); + s_backend = Cvar_Get( "s_backend", "", CVAR_ROM ); + s_muteWhenMinimized = Cvar_Get( "s_muteWhenMinimized", "0", CVAR_ARCHIVE ); + s_muted = Cvar_Get( "s_muted", "0", CVAR_ARCHIVE ); + + cv = Cvar_Get( "s_initsound", "1", 0 ); + if( !cv->integer ) { + Com_Printf( "Sound disabled.\n" ); + } else { + + S_CodecInit( ); + + Cmd_AddCommand( "play", S_Play_f ); + Cmd_AddCommand( "music", S_Music_f ); + Cmd_AddCommand( "s_list", S_SoundList ); + Cmd_AddCommand( "s_stop", S_StopAllSounds_f ); + Cmd_AddCommand( "s_info", S_SoundInfo ); + + cv = Cvar_Get( "s_useOpenAL", "1", CVAR_ARCHIVE ); + if( cv->integer ) { + //OpenAL + started = S_AL_Init( &si ); + Cvar_Set( "s_backend", "OpenAL" ); + } + + if( !started ) { + started = S_Base_Init( &si ); + Cvar_Set( "s_backend", "base" ); + } + + if( started ) { + if( !S_ValidSoundInterface( &si ) ) { + Com_Error( ERR_FATAL, "Sound interface invalid." ); + } + + S_SoundInfo( ); + Com_Printf( "Sound initialization successful.\n" ); + } else { + Com_Printf( "Sound initialization failed.\n" ); + } + } + + Com_Printf( "--------------------------------\n"); +} + +/* +================= +S_Shutdown +================= +*/ +void S_Shutdown( void ) +{ + if( si.Shutdown ) { + si.Shutdown( ); + } + + Com_Memset( &si, 0, sizeof( soundInterface_t ) ); + + Cmd_RemoveCommand( "play" ); + Cmd_RemoveCommand( "music"); + Cmd_RemoveCommand( "s_list" ); + Cmd_RemoveCommand( "s_stop" ); + Cmd_RemoveCommand( "s_info" ); + + S_CodecShutdown( ); +} + diff --git a/code/client/snd_mem.c b/code/client/snd_mem.c new file mode 100644 index 00000000..436a3d29 --- /dev/null +++ b/code/client/snd_mem.c @@ -0,0 +1,280 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +/***************************************************************************** +* name: snd_mem.c +* +* desc: sound caching +* +* $Archive: /MissionPack/code/client/snd_mem.c $ +* +*****************************************************************************/ + +#include "snd_local.h" +#include "snd_codec.h" + +#define DEF_COMSOUNDMEGS "8" + +/* +=============================================================================== + +memory management + +=============================================================================== +*/ + +static sndBuffer *buffer = NULL; +static sndBuffer *freelist = NULL; +static int inUse = 0; +static int totalInUse = 0; + +short *sfxScratchBuffer = NULL; +sfx_t *sfxScratchPointer = NULL; +int sfxScratchIndex = 0; + +void SND_free( sndBuffer *v ) { + *( sndBuffer ** )v = freelist; + freelist = ( sndBuffer* )v; + inUse += sizeof( sndBuffer ); +} + +sndBuffer* SND_malloc( void ) { + sndBuffer *v; +redo: + if( freelist == NULL ) { + S_FreeOldestSound(); + goto redo; + } + + inUse -= sizeof( sndBuffer ); + totalInUse += sizeof( sndBuffer ); + + v = freelist; + freelist = *( sndBuffer ** )freelist; + v->next = NULL; + return v; +} + +void SND_setup( void ) { + sndBuffer *p, *q; + cvar_t *cv; + int scs; + + cv = Cvar_Get( "com_soundMegs", DEF_COMSOUNDMEGS, CVAR_LATCH | CVAR_ARCHIVE ); + + scs = ( cv->integer * 1536 ); + + buffer = malloc( scs*sizeof( sndBuffer ) ); + // allocate the stack based hunk allocator + sfxScratchBuffer = malloc( SND_CHUNK_SIZE * sizeof( short ) * 4 ); //Hunk_Alloc(SND_CHUNK_SIZE * sizeof(short) * 4); + sfxScratchPointer = NULL; + + inUse = scs*sizeof( sndBuffer ); + p = buffer;; + q = p + scs; + while( --q > p ) + *( sndBuffer ** )q = q - 1; + + *( sndBuffer ** )q = NULL; + freelist = p + scs - 1; + + Com_Printf( "Sound memory manager started\n" ); +} + +void SND_shutdown( void ) +{ + free( sfxScratchBuffer ); + free( buffer ); +} + +/* +================ +ResampleSfx + +resample / decimate to the current source rate +================ +*/ +static int ResampleSfx( sfx_t *sfx, int channels, int inrate, int inwidth, int samples, byte *data, qboolean compressed ) { + int outcount; + int srcsample; + float stepscale; + int i, j; + int sample, samplefrac, fracstep; + int part; + sndBuffer *chunk; + + stepscale = ( float )inrate / dma.speed; // this is usually 0.5, 1, or 2 + + outcount = samples / stepscale; + + samplefrac = 0; + fracstep = stepscale * 256 * channels; + chunk = sfx->soundData; + + for( i = 0; i> 8; + samplefrac += fracstep; + for( j = 0; jsoundData = newchunk; + } + else { + chunk->next = newchunk; + } + chunk = newchunk; + } + + chunk->sndChunk[ part ] = sample; + } + } + + return outcount; +} + +/* +================ +ResampleSfx + +resample / decimate to the current source rate +================ +*/ +static int ResampleSfxRaw( short *sfx, int channels, int inrate, int inwidth, int samples, byte *data ) { + int outcount; + int srcsample; + float stepscale; + int i, j; + int sample, samplefrac, fracstep; + + stepscale = ( float )inrate / dma.speed; // this is usually 0.5, 1, or 2 + + outcount = samples / stepscale; + + samplefrac = 0; + fracstep = stepscale * 256 * channels; + + for( i = 0; i> 8; + samplefrac += fracstep; + for( j = 0; jname in the case +of a forced fallback of a player specific sound +============== +*/ +qboolean S_LoadSound( sfx_t *sfx ) +{ + byte *data; + short *samples; + snd_info_t info; + // int size; + + // load it in + data = S_CodecLoad( sfx->soundName, &info ); + if( !data ) + return qfalse; + + if( info.width == 1 ) { + Com_DPrintf( S_COLOR_YELLOW "WARNING: %s is a 8 bit audio file\n", sfx->soundName ); + } + + if( info.rate != 22050 ) { + Com_DPrintf( S_COLOR_YELLOW "WARNING: %s is not a 22kHz audio file\n", sfx->soundName ); + } + + samples = Hunk_AllocateTempMemory( info.channels * info.samples * sizeof( short ) * 2 ); + + sfx->lastTimeUsed = Com_Milliseconds() + 1; + + // each of these compression schemes works just fine + // but the 16bit quality is much nicer and with a local + // install assured we can rely upon the sound memory + // manager to do the right thing for us and page + // sound in as needed + + if( info.channels == 1 && sfx->soundCompressed == qtrue ) { + sfx->soundCompressionMethod = 1; + sfx->soundData = NULL; + sfx->soundLength = ResampleSfxRaw( samples, info.channels, info.rate, info.width, info.samples, data + info.dataofs ); + S_AdpcmEncodeSound( sfx, samples ); +#if 0 + } + else if( info.channels == 1 && info.samples>( SND_CHUNK_SIZE * 16 ) && info.width >1 ) { + sfx->soundCompressionMethod = 3; + sfx->soundData = NULL; + sfx->soundLength = ResampleSfxRaw( samples, info.channels, info.rate, info.width, info.samples, ( data + info.dataofs ) ); + encodeMuLaw( sfx, samples ); + } + else if( info.channels == 1 && info.samples>( SND_CHUNK_SIZE * 6400 ) && info.width >1 ) { + sfx->soundCompressionMethod = 2; + sfx->soundData = NULL; + sfx->soundLength = ResampleSfxRaw( samples, info.channels, info.rate, info.width, info.samples, ( data + info.dataofs ) ); + encodeWavelet( sfx, samples ); +#endif + } + else { + sfx->soundCompressionMethod = 0; + sfx->soundData = NULL; + sfx->soundLength = ResampleSfx( sfx, info.channels, info.rate, info.width, info.samples, data + info.dataofs, qfalse ); + } + + sfx->soundChannels = info.channels; + + Hunk_FreeTempMemory( samples ); + Hunk_FreeTempMemory( data ); + + return qtrue; +} + +void S_DisplayFreeMemory( void ) { + Com_Printf( "%d bytes free sound buffer memory, %d total used\n", inUse, totalInUse ); +} diff --git a/code/client/snd_mix.c b/code/client/snd_mix.c new file mode 100644 index 00000000..3754dd4a --- /dev/null +++ b/code/client/snd_mix.c @@ -0,0 +1,799 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// snd_mix.c -- portable code to mix sounds for snd_dma.c + +#include "client.h" +#include "snd_local.h" +#if idppc_altivec && !defined(MACOS_X) +#include +#endif + +static portable_samplepair_t paintbuffer[ PAINTBUFFER_SIZE ]; +static int snd_vol; + +int* snd_p; +int snd_linear_count; +short* snd_out; + +#if !id386 // if configured not to use asm + +void S_WriteLinearBlastStereo16( void ) +{ + int i; + int val; + + for( i = 0; i> 8; + if( val > 0x7fff ) + snd_out[ i ] = 0x7fff; + else if( val < -32768 ) + snd_out[ i ] = -32768; + else + snd_out[ i ] = val; + + val = snd_p[ i + 1 ] >> 8; + if( val > 0x7fff ) + snd_out[ i + 1 ] = 0x7fff; + else if( val < -32768 ) + snd_out[ i + 1 ] = -32768; + else + snd_out[ i + 1 ] = val; + } +} +#elif defined(__GNUC__) +// uses snd_mixa.s +void S_WriteLinearBlastStereo16( void ); +#else + +__declspec( naked ) void S_WriteLinearBlastStereo16( void ) +{ + __asm { + + push edi + push ebx + mov ecx, ds:dword ptr[ snd_linear_count ] + mov ebx, ds : dword ptr[ snd_p ] + mov edi, ds : dword ptr[ snd_out ] +LWLBLoopTop : + mov eax, ds : dword ptr[ -8 + ebx + ecx * 4 ] + sar eax, 8 + cmp eax, 07FFFh + jg LClampHigh + cmp eax, 0FFFF8000h + jnl LClampDone + mov eax, 0FFFF8000h + jmp LClampDone +LClampHigh : + mov eax, 07FFFh +LClampDone : + mov edx, ds : dword ptr[ -4 + ebx + ecx * 4 ] + sar edx, 8 + cmp edx, 07FFFh + jg LClampHigh2 + cmp edx, 0FFFF8000h + jnl LClampDone2 + mov edx, 0FFFF8000h + jmp LClampDone2 +LClampHigh2 : + mov edx, 07FFFh +LClampDone2 : + shl edx, 16 + and eax, 0FFFFh + or edx, eax + mov ds : dword ptr[ -4 + edi + ecx * 2 ], edx + sub ecx, 2 + jnz LWLBLoopTop + pop ebx + pop edi + ret + } +} + +#endif + +void S_TransferStereo16( unsigned long *pbuf, int endtime ) +{ + int lpos; + int ls_paintedtime; + + snd_p = ( int * )paintbuffer; + ls_paintedtime = s_paintedtime; + + while( ls_paintedtime < endtime ) + { + // handle recirculating buffer issues + lpos = ls_paintedtime & ( ( dma.samples >> 1 ) - 1 ); + + snd_out = ( short * )pbuf + ( lpos << 1 ); + + snd_linear_count = ( dma.samples >> 1 ) - lpos; + if( ls_paintedtime + snd_linear_count > endtime ) + snd_linear_count = endtime - ls_paintedtime; + + snd_linear_count <<= 1; + + // write a linear blast of samples + S_WriteLinearBlastStereo16(); + + snd_p += snd_linear_count; + ls_paintedtime += ( snd_linear_count >> 1 ); + + if( CL_VideoRecording() ) + CL_WriteAVIAudioFrame( ( byte * )snd_out, snd_linear_count << 1 ); + } +} + +/* +=================== +S_TransferPaintBuffer + +=================== +*/ +void S_TransferPaintBuffer( int endtime ) +{ + int out_idx; + int count; + int out_mask; + int *p; + int step; + int val; + unsigned long *pbuf; + + pbuf = ( unsigned long * )dma.buffer; + + + if( s_testsound->integer ) { + int i; + + // write a fixed sine wave + count = ( endtime - s_paintedtime ); + for( i = 0; i> 8; + p += step; + if( val > 0x7fff ) + val = 0x7fff; + else if( val < -32768 ) + val = -32768; + out[ out_idx ] = val; + out_idx = ( out_idx + 1 ) & out_mask; + } + } + else if( dma.samplebits == 8 ) + { + unsigned char *out = ( unsigned char * )pbuf; + while( count-- ) + { + val = *p >> 8; + p += step; + if( val > 0x7fff ) + val = 0x7fff; + else if( val < -32768 ) + val = -32768; + out[ out_idx ] = ( val >> 8 ) + 128; + out_idx = ( out_idx + 1 ) & out_mask; + } + } + } +} + + +/* +=============================================================================== + +CHANNEL MIXING + +=============================================================================== +*/ + +#if idppc_altivec +static void S_PaintChannelFrom16_altivec( channel_t *ch, const sfx_t *sc, int count, int sampleOffset, int bufferOffset ) { + int data, aoff, boff; + int leftvol, rightvol; + int i, j; + portable_samplepair_t *samp; + sndBuffer *chunk; + short *samples; + float ooff, fdata[ 2 ], fdiv, fleftvol, frightvol; + + if( sc->soundChannels <= 0 ) { + return; + } + + samp = &paintbuffer[ bufferOffset ]; + + if( ch->doppler ) { + sampleOffset = sampleOffset*ch->oldDopplerScale; + } + + if( sc->soundChannels == 2 ) { + sampleOffset *= sc->soundChannels; + + if( sampleOffset & 1 ) { + sampleOffset &= ~1; + } + } + + chunk = sc->soundData; + while( sampleOffset >= SND_CHUNK_SIZE ) { + chunk = chunk->next; + sampleOffset -= SND_CHUNK_SIZE; + if( !chunk ) { + chunk = sc->soundData; + } + } + + if( !ch->doppler || ch->dopplerScale == 1.0f ) { + vector signed short volume_vec; + vector unsigned int volume_shift; + int vectorCount, samplesLeft, chunkSamplesLeft; + leftvol = ch->leftvol*snd_vol; + rightvol = ch->rightvol*snd_vol; + samples = chunk->sndChunk; + ( ( short * )&volume_vec )[ 0 ] = leftvol; + ( ( short * )&volume_vec )[ 1 ] = leftvol; + ( ( short * )&volume_vec )[ 4 ] = leftvol; + ( ( short * )&volume_vec )[ 5 ] = leftvol; + ( ( short * )&volume_vec )[ 2 ] = rightvol; + ( ( short * )&volume_vec )[ 3 ] = rightvol; + ( ( short * )&volume_vec )[ 6 ] = rightvol; + ( ( short * )&volume_vec )[ 7 ] = rightvol; + volume_shift = vec_splat_u32( 8 ); + i = 0; + + while( i < count ) { + /* Try to align destination to 16-byte boundary */ + while( i < count && ( ( ( unsigned long )&samp[ i ] & 0x1f ) || ( ( count - i ) < 8 ) || ( ( SND_CHUNK_SIZE - sampleOffset ) < 8 ) ) ) { + data = samples[ sampleOffset++ ]; + samp[ i ].left += ( data * leftvol ) >> 8; + + if( sc->soundChannels == 2 ) { + data = samples[ sampleOffset++ ]; + } + samp[ i ].right += ( data * rightvol ) >> 8; + + if( sampleOffset == SND_CHUNK_SIZE ) { + chunk = chunk->next; + samples = chunk->sndChunk; + sampleOffset = 0; + } + i++; + } + /* Destination is now aligned. Process as many 8-sample + chunks as we can before we run out of room from the current + sound chunk. We do 8 per loop to avoid extra source data reads. */ + samplesLeft = count - i; + chunkSamplesLeft = SND_CHUNK_SIZE - sampleOffset; + if( samplesLeft > chunkSamplesLeft ) + samplesLeft = chunkSamplesLeft; + + vectorCount = samplesLeft / 8; + + if( vectorCount ) + { + vector unsigned char tmp; + vector short s0, s1, sampleData0, sampleData1; + vector signed int merge0, merge1; + vector signed int d0, d1, d2, d3; + vector unsigned char samplePermute0 = + VECCONST_UINT8( 0, 1, 4, 5, 0, 1, 4, 5, 2, 3, 6, 7, 2, 3, 6, 7 ); + vector unsigned char samplePermute1 = + VECCONST_UINT8( 8, 9, 12, 13, 8, 9, 12, 13, 10, 11, 14, 15, 10, 11, 14, 15 ); + vector unsigned char loadPermute0, loadPermute1; + + // Rather than permute the vectors after we load them to do the sample + // replication and rearrangement, we permute the alignment vector so + // we do everything in one step below and avoid data shuffling. + tmp = vec_lvsl( 0, &samples[ sampleOffset ] ); + loadPermute0 = vec_perm( tmp, tmp, samplePermute0 ); + loadPermute1 = vec_perm( tmp, tmp, samplePermute1 ); + + s0 = *( vector short * )&samples[ sampleOffset ]; + while( vectorCount ) + { + /* Load up source (16-bit) sample data */ + s1 = *( vector short * )&samples[ sampleOffset + 7 ]; + + /* Load up destination sample data */ + d0 = *( vector signed int * )&samp[ i ]; + d1 = *( vector signed int * )&samp[ i + 2 ]; + d2 = *( vector signed int * )&samp[ i + 4 ]; + d3 = *( vector signed int * )&samp[ i + 6 ]; + + sampleData0 = vec_perm( s0, s1, loadPermute0 ); + sampleData1 = vec_perm( s0, s1, loadPermute1 ); + + merge0 = vec_mule( sampleData0, volume_vec ); + merge0 = vec_sra( merge0, volume_shift ); /* Shift down to proper range */ + + merge1 = vec_mulo( sampleData0, volume_vec ); + merge1 = vec_sra( merge1, volume_shift ); + + d0 = vec_add( merge0, d0 ); + d1 = vec_add( merge1, d1 ); + + merge0 = vec_mule( sampleData1, volume_vec ); + merge0 = vec_sra( merge0, volume_shift ); /* Shift down to proper range */ + + merge1 = vec_mulo( sampleData1, volume_vec ); + merge1 = vec_sra( merge1, volume_shift ); + + d2 = vec_add( merge0, d2 ); + d3 = vec_add( merge1, d3 ); + + /* Store destination sample data */ + *( vector signed int * )&samp[ i ] = d0; + *( vector signed int * )&samp[ i + 2 ] = d1; + *( vector signed int * )&samp[ i + 4 ] = d2; + *( vector signed int * )&samp[ i + 6 ] = d3; + + i += 8; + vectorCount--; + s0 = s1; + sampleOffset += 8; + } + if( sampleOffset == SND_CHUNK_SIZE ) { + chunk = chunk->next; + samples = chunk->sndChunk; + sampleOffset = 0; + } + } + } + } + else { + fleftvol = ch->leftvol*snd_vol; + frightvol = ch->rightvol*snd_vol; + + ooff = sampleOffset; + samples = chunk->sndChunk; + + for( i = 0; idopplerScale * sc->soundChannels; + boff = ooff; + fdata[ 0 ] = fdata[ 1 ] = 0; + for( j = aoff; jsoundChannels ) { + if( j == SND_CHUNK_SIZE ) { + chunk = chunk->next; + if( !chunk ) { + chunk = sc->soundData; + } + samples = chunk->sndChunk; + ooff -= SND_CHUNK_SIZE; + } + if( sc->soundChannels == 2 ) { + fdata[ 0 ] += samples[ j&( SND_CHUNK_SIZE - 1 ) ]; + fdata[ 1 ] += samples[ ( j + 1 )&( SND_CHUNK_SIZE - 1 ) ]; + } + else { + fdata[ 0 ] += samples[ j&( SND_CHUNK_SIZE - 1 ) ]; + fdata[ 1 ] += samples[ j&( SND_CHUNK_SIZE - 1 ) ]; + } + } + fdiv = 256 * ( boff - aoff ) / sc->soundChannels; + samp[ i ].left += ( fdata[ 0 ] * fleftvol ) / fdiv; + samp[ i ].right += ( fdata[ 1 ] * frightvol ) / fdiv; + } + } +} +#endif + +static void S_PaintChannelFrom16_scalar( channel_t *ch, const sfx_t *sc, int count, int sampleOffset, int bufferOffset ) { + int data, aoff, boff; + int leftvol, rightvol; + int i, j; + portable_samplepair_t *samp; + sndBuffer *chunk; + short *samples; + float ooff, fdata[ 2 ], fdiv, fleftvol, frightvol; + + if( sc->soundChannels <= 0 ) { + return; + } + + samp = &paintbuffer[ bufferOffset ]; + + if( ch->doppler ) { + sampleOffset = sampleOffset*ch->oldDopplerScale; + } + + if( sc->soundChannels == 2 ) { + sampleOffset *= sc->soundChannels; + + if( sampleOffset & 1 ) { + sampleOffset &= ~1; + } + } + + chunk = sc->soundData; + while( sampleOffset >= SND_CHUNK_SIZE ) { + chunk = chunk->next; + sampleOffset -= SND_CHUNK_SIZE; + if( !chunk ) { + chunk = sc->soundData; + } + } + + if( !ch->doppler || ch->dopplerScale == 1.0f ) { + leftvol = ch->leftvol*snd_vol; + rightvol = ch->rightvol*snd_vol; + samples = chunk->sndChunk; + for( i = 0; i> 8; + + if( sc->soundChannels == 2 ) { + data = samples[ sampleOffset++ ]; + } + samp[ i ].right += ( data * rightvol ) >> 8; + + if( sampleOffset == SND_CHUNK_SIZE ) { + chunk = chunk->next; + samples = chunk->sndChunk; + sampleOffset = 0; + } + } + } + else { + fleftvol = ch->leftvol*snd_vol; + frightvol = ch->rightvol*snd_vol; + + ooff = sampleOffset; + samples = chunk->sndChunk; + + + + + for( i = 0; idopplerScale * sc->soundChannels; + boff = ooff; + fdata[ 0 ] = fdata[ 1 ] = 0; + for( j = aoff; jsoundChannels ) { + if( j == SND_CHUNK_SIZE ) { + chunk = chunk->next; + if( !chunk ) { + chunk = sc->soundData; + } + samples = chunk->sndChunk; + ooff -= SND_CHUNK_SIZE; + } + if( sc->soundChannels == 2 ) { + fdata[ 0 ] += samples[ j&( SND_CHUNK_SIZE - 1 ) ]; + fdata[ 1 ] += samples[ ( j + 1 )&( SND_CHUNK_SIZE - 1 ) ]; + } + else { + fdata[ 0 ] += samples[ j&( SND_CHUNK_SIZE - 1 ) ]; + fdata[ 1 ] += samples[ j&( SND_CHUNK_SIZE - 1 ) ]; + } + } + fdiv = 256 * ( boff - aoff ) / sc->soundChannels; + samp[ i ].left += ( fdata[ 0 ] * fleftvol ) / fdiv; + samp[ i ].right += ( fdata[ 1 ] * frightvol ) / fdiv; + } + } +} + +static void S_PaintChannelFrom16( channel_t *ch, const sfx_t *sc, int count, int sampleOffset, int bufferOffset ) { +#if idppc_altivec + if( com_altivec->integer ) { + // must be in a seperate function or G3 systems will crash. + S_PaintChannelFrom16_altivec( ch, sc, count, sampleOffset, bufferOffset ); + return; + } +#endif + S_PaintChannelFrom16_scalar( ch, sc, count, sampleOffset, bufferOffset ); +} + +void S_PaintChannelFromWavelet( channel_t *ch, sfx_t *sc, int count, int sampleOffset, int bufferOffset ) { + int data; + int leftvol, rightvol; + int i; + portable_samplepair_t *samp; + sndBuffer *chunk; + short *samples; + + leftvol = ch->leftvol*snd_vol; + rightvol = ch->rightvol*snd_vol; + + i = 0; + samp = &paintbuffer[ bufferOffset ]; + chunk = sc->soundData; + while( sampleOffset >= ( SND_CHUNK_SIZE_FLOAT * 4 ) ) { + chunk = chunk->next; + sampleOffset -= ( SND_CHUNK_SIZE_FLOAT * 4 ); + i++; + } + + if( i != sfxScratchIndex || sfxScratchPointer != sc ) { + S_AdpcmGetSamples( chunk, sfxScratchBuffer ); + sfxScratchIndex = i; + sfxScratchPointer = sc; + } + + samples = sfxScratchBuffer; + + for( i = 0; i> 8; + samp[ i ].right += ( data * rightvol ) >> 8; + + if( sampleOffset == SND_CHUNK_SIZE * 2 ) { + chunk = chunk->next; + decodeWavelet( chunk, sfxScratchBuffer ); + sfxScratchIndex++; + sampleOffset = 0; + } + } +} + +void S_PaintChannelFromADPCM( channel_t *ch, sfx_t *sc, int count, int sampleOffset, int bufferOffset ) { + int data; + int leftvol, rightvol; + int i; + portable_samplepair_t *samp; + sndBuffer *chunk; + short *samples; + + leftvol = ch->leftvol*snd_vol; + rightvol = ch->rightvol*snd_vol; + + i = 0; + samp = &paintbuffer[ bufferOffset ]; + chunk = sc->soundData; + + if( ch->doppler ) { + sampleOffset = sampleOffset*ch->oldDopplerScale; + } + + while( sampleOffset >= ( SND_CHUNK_SIZE * 4 ) ) { + chunk = chunk->next; + sampleOffset -= ( SND_CHUNK_SIZE * 4 ); + i++; + } + + if( i != sfxScratchIndex || sfxScratchPointer != sc ) { + S_AdpcmGetSamples( chunk, sfxScratchBuffer ); + sfxScratchIndex = i; + sfxScratchPointer = sc; + } + + samples = sfxScratchBuffer; + + for( i = 0; i> 8; + samp[ i ].right += ( data * rightvol ) >> 8; + + if( sampleOffset == SND_CHUNK_SIZE * 4 ) { + chunk = chunk->next; + S_AdpcmGetSamples( chunk, sfxScratchBuffer ); + sampleOffset = 0; + sfxScratchIndex++; + } + } +} + +void S_PaintChannelFromMuLaw( channel_t *ch, sfx_t *sc, int count, int sampleOffset, int bufferOffset ) { + int data; + int leftvol, rightvol; + int i; + portable_samplepair_t *samp; + sndBuffer *chunk; + byte *samples; + float ooff; + + leftvol = ch->leftvol*snd_vol; + rightvol = ch->rightvol*snd_vol; + + samp = &paintbuffer[ bufferOffset ]; + chunk = sc->soundData; + while( sampleOffset >= ( SND_CHUNK_SIZE * 2 ) ) { + chunk = chunk->next; + sampleOffset -= ( SND_CHUNK_SIZE * 2 ); + if( !chunk ) { + chunk = sc->soundData; + } + } + + if( !ch->doppler ) { + samples = ( byte * )chunk->sndChunk + sampleOffset; + for( i = 0; i> 8; + samp[ i ].right += ( data * rightvol ) >> 8; + samples++; + if( chunk != NULL && samples == ( byte * )chunk->sndChunk + ( SND_CHUNK_SIZE * 2 ) ) { + chunk = chunk->next; + samples = ( byte * )chunk->sndChunk; + } + } + } + else { + ooff = sampleOffset; + samples = ( byte * )chunk->sndChunk; + for( i = 0; idopplerScale; + samp[ i ].left += ( data * leftvol ) >> 8; + samp[ i ].right += ( data * rightvol ) >> 8; + if( ooff >= SND_CHUNK_SIZE * 2 ) { + chunk = chunk->next; + if( !chunk ) { + chunk = sc->soundData; + } + samples = ( byte * )chunk->sndChunk; + ooff = 0.0; + } + } + } +} + +/* +=================== +S_PaintChannels +=================== +*/ +void S_PaintChannels( int endtime ) { + int i; + int end; + int stream; + channel_t *ch; + sfx_t *sc; + int ltime, count; + int sampleOffset; + + if( s_muted->integer ) + snd_vol = 0; + else + snd_vol = s_volume->value * 255; + + //Com_Printf ("%i to %i\n", s_paintedtime, endtime); + while( s_paintedtime < endtime ) { + // if paintbuffer is smaller than DMA buffer + // we may need to fill it multiple times + end = endtime; + if( endtime - s_paintedtime > PAINTBUFFER_SIZE ) { + end = s_paintedtime + PAINTBUFFER_SIZE; + } + + // clear the paint buffer and mix any raw samples... + Com_Memset( paintbuffer, 0, sizeof( paintbuffer ) ); + for( stream = 0; stream < MAX_RAW_STREAMS; stream++ ) { + if( s_rawend[ stream ] >= s_paintedtime ) { + // copy from the streaming sound source + const portable_samplepair_t *rawsamples = s_rawsamples[ stream ]; + const int stop = ( end < s_rawend[ stream ] ) ? end : s_rawend[ stream ]; + for( i = s_paintedtime; i < stop; i++ ) { + const int s = i&( MAX_RAW_SAMPLES - 1 ); + paintbuffer[ i - s_paintedtime ].left += rawsamples[ s ].left; + paintbuffer[ i - s_paintedtime ].right += rawsamples[ s ].right; + } + } + } + + // paint in the channels. + ch = s_channels; + for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + if( !ch->thesfx || ( ch->leftvol<0.25 && ch->rightvol<0.25 ) ) { + continue; + } + + ltime = s_paintedtime; + sc = ch->thesfx; + + if( sc->soundData == NULL || sc->soundLength == 0 ) { + continue; + } + + sampleOffset = ltime - ch->startSample; + count = end - ltime; + if( sampleOffset + count > sc->soundLength ) { + count = sc->soundLength - sampleOffset; + } + + if( count > 0 ) { + if( sc->soundCompressionMethod == 1 ) { + S_PaintChannelFromADPCM( ch, sc, count, sampleOffset, ltime - s_paintedtime ); + } + else if( sc->soundCompressionMethod == 2 ) { + S_PaintChannelFromWavelet( ch, sc, count, sampleOffset, ltime - s_paintedtime ); + } + else if( sc->soundCompressionMethod == 3 ) { + S_PaintChannelFromMuLaw( ch, sc, count, sampleOffset, ltime - s_paintedtime ); + } + else { + S_PaintChannelFrom16( ch, sc, count, sampleOffset, ltime - s_paintedtime ); + } + } + } + + // paint in the looped channels. + ch = loop_channels; + for( i = 0; i < numLoopChannels; i++, ch++ ) { + if( !ch->thesfx || ( !ch->leftvol && !ch->rightvol ) ) { + continue; + } + + ltime = s_paintedtime; + sc = ch->thesfx; + + if( sc->soundData == NULL || sc->soundLength == 0 ) { + continue; + } + // we might have to make two passes if it + // is a looping sound effect and the end of + // the sample is hit + do { + sampleOffset = ( ltime % sc->soundLength ); + + count = end - ltime; + if( sampleOffset + count > sc->soundLength ) { + count = sc->soundLength - sampleOffset; + } + + if( count > 0 ) { + if( sc->soundCompressionMethod == 1 ) { + S_PaintChannelFromADPCM( ch, sc, count, sampleOffset, ltime - s_paintedtime ); + } + else if( sc->soundCompressionMethod == 2 ) { + S_PaintChannelFromWavelet( ch, sc, count, sampleOffset, ltime - s_paintedtime ); + } + else if( sc->soundCompressionMethod == 3 ) { + S_PaintChannelFromMuLaw( ch, sc, count, sampleOffset, ltime - s_paintedtime ); + } + else { + S_PaintChannelFrom16( ch, sc, count, sampleOffset, ltime - s_paintedtime ); + } + ltime += count; + } + } while( ltime < end ); + } + + // transfer out according to DMA format + S_TransferPaintBuffer( end ); + s_paintedtime = end; + } +} diff --git a/code/client/snd_openal_new.c b/code/client/snd_openal_new.c new file mode 100644 index 00000000..c7af560c --- /dev/null +++ b/code/client/snd_openal_new.c @@ -0,0 +1,2760 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. +Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) + +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "snd_local.h" +#include "snd_codec.h" +#include "client.h" + +#ifdef USE_OPENAL + +#include "qal.h" + +// Console variables specific to OpenAL +cvar_t *s_alPrecache; +cvar_t *s_alGain; +cvar_t *s_alSources; +cvar_t *s_alDopplerFactor; +cvar_t *s_alDopplerSpeed; +cvar_t *s_alMinDistance; +cvar_t *s_alMaxDistance; +cvar_t *s_alRolloff; +cvar_t *s_alGraceDistance; +cvar_t *s_alDriver; +cvar_t *s_alDevice; +cvar_t *s_alInputDevice; +cvar_t *s_alAvailableDevices; +cvar_t *s_alAvailableInputDevices; + +static qboolean enumeration_ext = qfalse; +static qboolean enumeration_all_ext = qfalse; +#ifdef USE_VOIP +static qboolean capture_ext = qfalse; +#endif + +/* +================= +S_AL_Format +================= +*/ +static +ALuint S_AL_Format(int width, int channels) +{ + ALuint format = AL_FORMAT_MONO16; + + // Work out format + if(width == 1) + { + if(channels == 1) + format = AL_FORMAT_MONO8; + else if(channels == 2) + format = AL_FORMAT_STEREO8; + } + else if(width == 2) + { + if(channels == 1) + format = AL_FORMAT_MONO16; + else if(channels == 2) + format = AL_FORMAT_STEREO16; + } + + return format; +} + +/* +================= +S_AL_ErrorMsg +================= +*/ +static const char *S_AL_ErrorMsg(ALenum error) +{ + switch(error) + { + case AL_NO_ERROR: + return "No error"; + case AL_INVALID_NAME: + return "Invalid name"; + case AL_INVALID_ENUM: + return "Invalid enumerator"; + case AL_INVALID_VALUE: + return "Invalid value"; + case AL_INVALID_OPERATION: + return "Invalid operation"; + case AL_OUT_OF_MEMORY: + return "Out of memory"; + default: + return "Unknown error"; + } +} + +/* +================= +S_AL_ClearError +================= +*/ +static void S_AL_ClearError( qboolean quiet ) +{ + int error = qalGetError(); + + if( quiet ) + return; + if(error != AL_NO_ERROR) + { + Com_Printf(S_COLOR_YELLOW "WARNING: unhandled AL error: %s\n", + S_AL_ErrorMsg(error)); + } +} + + +//=========================================================================== + + +typedef struct alSfx_s +{ + char filename[MAX_QPATH]; + ALuint buffer; // OpenAL buffer + snd_info_t info; // information for this sound like rate, sample count.. + + qboolean isDefault; // Couldn't be loaded - use default FX + qboolean isDefaultChecked; // Sound has been check if it isDefault + qboolean inMemory; // Sound is stored in memory + qboolean isLocked; // Sound is locked (can not be unloaded) + int lastUsedTime; // Time last used + + int loopCnt; // number of loops using this sfx + int loopActiveCnt; // number of playing loops using this sfx + int masterLoopSrc; // All other sources looping this buffer are synced to this master src +} alSfx_t; + +static qboolean alBuffersInitialised = qfalse; + +// Sound effect storage, data structures +#define MAX_SFX 4096 +static alSfx_t knownSfx[MAX_SFX]; +static sfxHandle_t numSfx = 0; + +static sfxHandle_t default_sfx; + +/* +================= +S_AL_BufferFindFree + +Find a free handle +================= +*/ +static sfxHandle_t S_AL_BufferFindFree( void ) +{ + int i; + + for(i = 0; i < MAX_SFX; i++) + { + // Got one + if(knownSfx[i].filename[0] == '\0') + { + if(i >= numSfx) + numSfx = i + 1; + return i; + } + } + + // Shit... + Com_Error(ERR_FATAL, "S_AL_BufferFindFree: No free sound handles"); + return -1; +} + +/* +================= +S_AL_BufferFind + +Find a sound effect if loaded, set up a handle otherwise +================= +*/ +static sfxHandle_t S_AL_BufferFind(const char *filename) +{ + // Look it up in the table + sfxHandle_t sfx = -1; + int i; + + if ( !filename ) { + Com_Error( ERR_FATAL, "Sound name is NULL" ); + } + + if ( !filename[0] ) { + Com_Printf( S_COLOR_YELLOW "WARNING: Sound name is empty\n" ); + return 0; + } + + if ( strlen( filename ) >= MAX_QPATH ) { + Com_Printf( S_COLOR_YELLOW "WARNING: Sound name is too long: %s\n", filename ); + return 0; + } + + if ( filename[0] == '*' ) { + Com_Printf( S_COLOR_YELLOW "WARNING: Tried to load player sound directly: %s\n", filename ); + return 0; + } + + for(i = 0; i < numSfx; i++) + { + if(!Q_stricmp(knownSfx[i].filename, filename)) + { + sfx = i; + break; + } + } + + // Not found in table? + if(sfx == -1) + { + alSfx_t *ptr; + + sfx = S_AL_BufferFindFree(); + + // Clear and copy the filename over + ptr = &knownSfx[sfx]; + memset(ptr, 0, sizeof(*ptr)); + ptr->masterLoopSrc = -1; + strcpy(ptr->filename, filename); + } + + // Return the handle + return sfx; +} + +/* +================= +S_AL_BufferUseDefault +================= +*/ +static void S_AL_BufferUseDefault(sfxHandle_t sfx) +{ + if(sfx == default_sfx) + Com_Error(ERR_FATAL, "Can't load default sound effect %s", knownSfx[sfx].filename); + + Com_Printf( S_COLOR_YELLOW "WARNING: Using default sound for %s\n", knownSfx[sfx].filename); + knownSfx[sfx].isDefault = qtrue; + knownSfx[sfx].buffer = knownSfx[default_sfx].buffer; +} + +/* +================= +S_AL_BufferUnload +================= +*/ +static void S_AL_BufferUnload(sfxHandle_t sfx) +{ + if(knownSfx[sfx].filename[0] == '\0') + return; + + if(!knownSfx[sfx].inMemory) + return; + + // Delete it + S_AL_ClearError( qfalse ); + qalDeleteBuffers(1, &knownSfx[sfx].buffer); + if(qalGetError() != AL_NO_ERROR) + Com_Printf( S_COLOR_RED "ERROR: Can't delete sound buffer for %s\n", + knownSfx[sfx].filename); + + knownSfx[sfx].inMemory = qfalse; +} + +/* +================= +S_AL_BufferEvict +================= +*/ +static qboolean S_AL_BufferEvict( void ) +{ + int i, oldestBuffer = -1; + int oldestTime = Sys_Milliseconds( ); + + for( i = 0; i < numSfx; i++ ) + { + if( !knownSfx[ i ].filename[ 0 ] ) + continue; + + if( !knownSfx[ i ].inMemory ) + continue; + + if( knownSfx[ i ].lastUsedTime < oldestTime ) + { + oldestTime = knownSfx[ i ].lastUsedTime; + oldestBuffer = i; + } + } + + if( oldestBuffer >= 0 ) + { + S_AL_BufferUnload( oldestBuffer ); + return qtrue; + } + else + return qfalse; +} + +/* +================= +S_AL_GenBuffers +================= +*/ +static qboolean S_AL_GenBuffers(ALsizei numBuffers, ALuint *buffers, const char *name) +{ + ALenum error; + + S_AL_ClearError( qfalse ); + qalGenBuffers( numBuffers, buffers ); + error = qalGetError(); + + // If we ran out of buffers, start evicting the least recently used sounds + while( error == AL_INVALID_VALUE ) + { + if( !S_AL_BufferEvict( ) ) + { + Com_Printf( S_COLOR_RED "ERROR: Out of audio buffers\n"); + return qfalse; + } + + // Try again + S_AL_ClearError( qfalse ); + qalGenBuffers( numBuffers, buffers ); + error = qalGetError(); + } + + if( error != AL_NO_ERROR ) + { + Com_Printf( S_COLOR_RED "ERROR: Can't create a sound buffer for %s - %s\n", + name, S_AL_ErrorMsg(error)); + return qfalse; + } + + return qtrue; +} + +/* +================= +S_AL_BufferLoad +================= +*/ +static void S_AL_BufferLoad(sfxHandle_t sfx, qboolean cache) +{ + ALenum error; + ALuint format; + + void *data; + snd_info_t info; + alSfx_t *curSfx = &knownSfx[sfx]; + + // Nothing? + if(curSfx->filename[0] == '\0') + return; + + // Already done? + if((curSfx->inMemory) || (curSfx->isDefault) || (!cache && curSfx->isDefaultChecked)) + return; + + // Try to load + data = S_CodecLoad(curSfx->filename, &info); + if(!data) + { + S_AL_BufferUseDefault(sfx); + return; + } + + curSfx->isDefaultChecked = qtrue; + + if (!cache) + { + // Don't create AL cache + Hunk_FreeTempMemory(data); + return; + } + + format = S_AL_Format(info.width, info.channels); + + // Create a buffer + if (!S_AL_GenBuffers(1, &curSfx->buffer, curSfx->filename)) + { + S_AL_BufferUseDefault(sfx); + Hunk_FreeTempMemory(data); + return; + } + + // Fill the buffer + if( info.size == 0 ) + { + // We have no data to buffer, so buffer silence + byte dummyData[ 2 ] = { 0 }; + + qalBufferData(curSfx->buffer, AL_FORMAT_MONO16, (void *)dummyData, 2, 22050); + } + else + qalBufferData(curSfx->buffer, format, data, info.size, info.rate); + + error = qalGetError(); + + // If we ran out of memory, start evicting the least recently used sounds + while(error == AL_OUT_OF_MEMORY) + { + if( !S_AL_BufferEvict( ) ) + { + qalDeleteBuffers(1, &curSfx->buffer); + S_AL_BufferUseDefault(sfx); + Hunk_FreeTempMemory(data); + Com_Printf( S_COLOR_RED "ERROR: Out of memory loading %s\n", curSfx->filename); + return; + } + + // Try load it again + qalBufferData(curSfx->buffer, format, data, info.size, info.rate); + error = qalGetError(); + } + + // Some other error condition + if(error != AL_NO_ERROR) + { + qalDeleteBuffers(1, &curSfx->buffer); + S_AL_BufferUseDefault(sfx); + Hunk_FreeTempMemory(data); + Com_Printf( S_COLOR_RED "ERROR: Can't fill sound buffer for %s - %s\n", + curSfx->filename, S_AL_ErrorMsg(error)); + return; + } + + curSfx->info = info; + + // Free the memory + Hunk_FreeTempMemory(data); + + // Woo! + curSfx->inMemory = qtrue; +} + +/* +================= +S_AL_BufferUse +================= +*/ +static +void S_AL_BufferUse(sfxHandle_t sfx) +{ + if(knownSfx[sfx].filename[0] == '\0') + return; + + if((!knownSfx[sfx].inMemory) && (!knownSfx[sfx].isDefault)) + S_AL_BufferLoad(sfx, qtrue); + knownSfx[sfx].lastUsedTime = Sys_Milliseconds(); +} + +/* +================= +S_AL_BufferInit +================= +*/ +static +qboolean S_AL_BufferInit( void ) +{ + if(alBuffersInitialised) + return qtrue; + + // Clear the hash table, and SFX table + memset(knownSfx, 0, sizeof(knownSfx)); + numSfx = 0; + + // Load the default sound, and lock it + default_sfx = S_AL_BufferFind("sound/default.wav"); + S_AL_BufferUse(default_sfx); + knownSfx[default_sfx].isLocked = qtrue; + + // All done + alBuffersInitialised = qtrue; + return qtrue; +} + +/* +================= +S_AL_BufferShutdown +================= +*/ +static +void S_AL_BufferShutdown( void ) +{ + int i; + + if(!alBuffersInitialised) + return; + + // Unlock the default sound effect + knownSfx[default_sfx].isLocked = qfalse; + + // Free all used effects + for(i = 0; i < numSfx; i++) + S_AL_BufferUnload(i); + + // Clear the tables + numSfx = 0; + + // All undone + alBuffersInitialised = qfalse; +} + +/* +================= +S_AL_RegisterSound +================= +*/ +static +sfxHandle_t S_AL_RegisterSound( const char *sample, qboolean compressed ) +{ + sfxHandle_t sfx = S_AL_BufferFind(sample); + + if((!knownSfx[sfx].inMemory) && (!knownSfx[sfx].isDefault)) + S_AL_BufferLoad(sfx, s_alPrecache->integer); + knownSfx[sfx].lastUsedTime = Com_Milliseconds(); + + if (knownSfx[sfx].isDefault) { + return 0; + } + + return sfx; +} + +/* +================= +S_AL_BufferGet + +Return's a sfx's buffer +================= +*/ +static +ALuint S_AL_BufferGet(sfxHandle_t sfx) +{ + return knownSfx[sfx].buffer; +} + + +//=========================================================================== + + +typedef struct src_s +{ + ALuint alSource; // OpenAL source object + sfxHandle_t sfx; // Sound effect in use + + int lastUsedTime; // Last time used + alSrcPriority_t priority; // Priority + int entity; // Owning entity (-1 if none) + int channel; // Associated channel (-1 if none) + + qboolean isActive; // Is this source currently in use? + qboolean isPlaying; // Is this source currently playing, or stopped? + qboolean isLocked; // This is locked (un-allocatable) + qboolean isLooping; // Is this a looping effect (attached to an entity) + qboolean isTracking; // Is this object tracking its owner + qboolean isStream; // Is this source a stream + + float curGain; // gain employed if source is within maxdistance. + float scaleGain; // Last gain value for this source. 0 if muted. + + float lastTimePos; // On stopped loops, the last position in the buffer + int lastSampleTime; // Time when this was stopped + vec3_t loopSpeakerPos; // Origin of the loop speaker + + qboolean local; // Is this local (relative to the cam) +} src_t; + +#ifdef MACOS_X + #define MAX_SRC 64 +#else + #define MAX_SRC 128 +#endif +static src_t srcList[MAX_SRC]; +static int srcCount = 0; +static int srcActiveCnt = 0; +static qboolean alSourcesInitialised = qfalse; +static int lastListenerNumber = -1; +static vec3_t lastListenerOrigin = { 0.0f, 0.0f, 0.0f }; + +typedef struct sentity_s +{ + vec3_t origin; + vec3_t velocity; + + qboolean srcAllocated; // If a src_t has been allocated to this entity + int srcIndex; + + qboolean loopAddedThisFrame; + alSrcPriority_t loopPriority; + sfxHandle_t loopSfx; + qboolean startLoopingSound; +} sentity_t; + +static sentity_t entityList[MAX_GENTITIES]; + +/* +================= +S_AL_SanitiseVector +================= +*/ +#define S_AL_SanitiseVector(v) _S_AL_SanitiseVector(v,__LINE__) +static void _S_AL_SanitiseVector( vec3_t v, int line ) +{ + if( Q_isnan( v[ 0 ] ) || Q_isnan( v[ 1 ] ) || Q_isnan( v[ 2 ] ) ) + { + Com_DPrintf( S_COLOR_YELLOW "WARNING: vector with one or more NaN components " + "being passed to OpenAL at %s:%d -- zeroing\n", __FILE__, line ); + VectorClear( v ); + } +} + +/* +================= +S_AL_Gain +Set gain to 0 if muted, otherwise set it to given value. +================= +*/ + +static void S_AL_Gain(ALuint source, float gainval) +{ + if(s_muted->integer) + qalSourcef(source, AL_GAIN, 0.0f); + else + qalSourcef(source, AL_GAIN, gainval); +} + +/* +================= +S_AL_ScaleGain +Adapt the gain if necessary to get a quicker fadeout when the source is too far away. +================= +*/ + +static void S_AL_ScaleGain(src_t *chksrc, vec3_t origin) +{ + float distance; + + if(!chksrc->local) + distance = Distance(origin, lastListenerOrigin); + + // If we exceed a certain distance, scale the gain linearly until the sound + // vanishes into nothingness. + if(!chksrc->local && (distance -= s_alMaxDistance->value) > 0) + { + float scaleFactor; + + if(distance >= s_alGraceDistance->value) + scaleFactor = 0.0f; + else + scaleFactor = 1.0f - distance / s_alGraceDistance->value; + + scaleFactor *= chksrc->curGain; + + if(chksrc->scaleGain != scaleFactor) + { + chksrc->scaleGain = scaleFactor; + S_AL_Gain(chksrc->alSource, chksrc->scaleGain); + } + } + else if(chksrc->scaleGain != chksrc->curGain) + { + chksrc->scaleGain = chksrc->curGain; + S_AL_Gain(chksrc->alSource, chksrc->scaleGain); + } +} + +/* +================= +S_AL_HearingThroughEntity + +Also see S_Base_HearingThroughEntity +================= +*/ +static qboolean S_AL_HearingThroughEntity( int entityNum ) +{ + float distanceSq; + + if( lastListenerNumber == entityNum ) + { + // This is an outrageous hack to detect + // whether or not the player is rendering in third person or not. We can't + // ask the renderer because the renderer has no notion of entities and we + // can't ask cgame since that would involve changing the API and hence mod + // compatibility. I don't think there is any way around this, but I'll leave + // the FIXME just in case anyone has a bright idea. + distanceSq = DistanceSquared( + entityList[ entityNum ].origin, + lastListenerOrigin ); + + if( distanceSq > THIRD_PERSON_THRESHOLD_SQ ) + return qfalse; //we're the player, but third person + else + return qtrue; //we're the player + } + else + return qfalse; //not the player +} + +/* +================= +S_AL_SrcInit +================= +*/ +static +qboolean S_AL_SrcInit( void ) +{ + int i; + int limit; + + // Clear the sources data structure + memset(srcList, 0, sizeof(srcList)); + srcCount = 0; + srcActiveCnt = 0; + + // Cap s_alSources to MAX_SRC + limit = s_alSources->integer; + if(limit > MAX_SRC) + limit = MAX_SRC; + else if(limit < 16) + limit = 16; + + S_AL_ClearError( qfalse ); + // Allocate as many sources as possible + for(i = 0; i < limit; i++) + { + qalGenSources(1, &srcList[i].alSource); + if(qalGetError() != AL_NO_ERROR) + break; + srcCount++; + } + + // All done. Print this for informational purposes + Com_Printf( "Allocated %d sources.\n", srcCount); + alSourcesInitialised = qtrue; + return qtrue; +} + +/* +================= +S_AL_SrcShutdown +================= +*/ +static +void S_AL_SrcShutdown( void ) +{ + int i; + src_t *curSource; + + if(!alSourcesInitialised) + return; + + // Destroy all the sources + for(i = 0; i < srcCount; i++) + { + curSource = &srcList[i]; + + if(curSource->isLocked) + Com_DPrintf( S_COLOR_YELLOW "WARNING: Source %d is locked\n", i); + + if(curSource->entity > 0) + entityList[curSource->entity].srcAllocated = qfalse; + + qalSourceStop(srcList[i].alSource); + qalDeleteSources(1, &srcList[i].alSource); + } + + memset(srcList, 0, sizeof(srcList)); + + alSourcesInitialised = qfalse; +} + +/* +================= +S_AL_SrcSetup +================= +*/ +static void S_AL_SrcSetup(srcHandle_t src, sfxHandle_t sfx, alSrcPriority_t priority, + int entity, int channel, qboolean local) +{ + src_t *curSource; + + // Set up src struct + curSource = &srcList[src]; + + curSource->lastUsedTime = Sys_Milliseconds(); + curSource->sfx = sfx; + curSource->priority = priority; + curSource->entity = entity; + curSource->channel = channel; + curSource->isPlaying = qfalse; + curSource->isLocked = qfalse; + curSource->isLooping = qfalse; + curSource->isTracking = qfalse; + curSource->isStream = qfalse; + curSource->curGain = s_alGain->value * s_volume->value; + curSource->scaleGain = curSource->curGain; + curSource->local = local; + + // Set up OpenAL source + if(sfx >= 0) + { + // Mark the SFX as used, and grab the raw AL buffer + S_AL_BufferUse(sfx); + qalSourcei(curSource->alSource, AL_BUFFER, S_AL_BufferGet(sfx)); + } + + qalSourcef(curSource->alSource, AL_PITCH, 1.0f); + S_AL_Gain(curSource->alSource, curSource->curGain); + qalSourcefv(curSource->alSource, AL_POSITION, vec3_origin); + qalSourcefv(curSource->alSource, AL_VELOCITY, vec3_origin); + qalSourcei(curSource->alSource, AL_LOOPING, AL_FALSE); + qalSourcef(curSource->alSource, AL_REFERENCE_DISTANCE, s_alMinDistance->value); + + if(local) + { + qalSourcei(curSource->alSource, AL_SOURCE_RELATIVE, AL_TRUE); + qalSourcef(curSource->alSource, AL_ROLLOFF_FACTOR, 0.0f); + } + else + { + qalSourcei(curSource->alSource, AL_SOURCE_RELATIVE, AL_FALSE); + qalSourcef(curSource->alSource, AL_ROLLOFF_FACTOR, s_alRolloff->value); + } +} + +/* +================= +S_AL_SaveLoopPos +Remove given source as loop master if it is the master and hand off master status to another source in this case. +================= +*/ + +static void S_AL_SaveLoopPos(src_t *dest, ALuint alSource) +{ + int error; + + S_AL_ClearError(qfalse); + + qalGetSourcef(alSource, AL_SEC_OFFSET, &dest->lastTimePos); + if((error = qalGetError()) != AL_NO_ERROR) + { + // Old OpenAL implementations don't support AL_SEC_OFFSET + + if(error != AL_INVALID_ENUM) + { + Com_Printf(S_COLOR_YELLOW "WARNING: Could not get time offset for alSource %d: %s\n", + alSource, S_AL_ErrorMsg(error)); + } + + dest->lastTimePos = -1; + } + else + dest->lastSampleTime = Sys_Milliseconds(); +} + +/* +================= +S_AL_NewLoopMaster +Remove given source as loop master if it is the master and hand off master status to another source in this case. +================= +*/ + +static void S_AL_NewLoopMaster(src_t *rmSource, qboolean iskilled) +{ + int index; + src_t *curSource = NULL; + alSfx_t *curSfx; + + curSfx = &knownSfx[rmSource->sfx]; + + if(rmSource->isPlaying) + curSfx->loopActiveCnt--; + if(iskilled) + curSfx->loopCnt--; + + if(curSfx->loopCnt) + { + if(rmSource->priority == SRCPRI_ENTITY) + { + if(!iskilled && rmSource->isPlaying) + { + // only sync ambient loops... + // It makes more sense to have sounds for weapons/projectiles unsynced + S_AL_SaveLoopPos(rmSource, rmSource->alSource); + } + } + else if(rmSource == &srcList[curSfx->masterLoopSrc]) + { + int firstInactive = -1; + + // Only if rmSource was the master and if there are still playing loops for + // this sound will we need to find a new master. + + if(iskilled || curSfx->loopActiveCnt) + { + for(index = 0; index < srcCount; index++) + { + curSource = &srcList[index]; + + if(curSource->sfx == rmSource->sfx && curSource != rmSource && + curSource->isActive && curSource->isLooping && curSource->priority == SRCPRI_AMBIENT) + { + if(curSource->isPlaying) + { + curSfx->masterLoopSrc = index; + break; + } + else if(firstInactive < 0) + firstInactive = index; + } + } + } + + if(!curSfx->loopActiveCnt) + { + if(firstInactive < 0) + { + if(iskilled) + { + curSfx->masterLoopSrc = -1; + return; + } + else + curSource = rmSource; + } + else + curSource = &srcList[firstInactive]; + + if(rmSource->isPlaying) + { + // this was the last not stopped source, save last sample position + time + S_AL_SaveLoopPos(curSource, rmSource->alSource); + } + else + { + // second case: all loops using this sound have stopped due to listener being of of range, + // and now the inactive master gets deleted. Just move over the soundpos settings to the + // new master. + curSource->lastTimePos = rmSource->lastTimePos; + curSource->lastSampleTime = rmSource->lastSampleTime; + } + } + } + } + else + curSfx->masterLoopSrc = -1; +} + +/* +================= +S_AL_SrcKill +================= +*/ +static void S_AL_SrcKill(srcHandle_t src) +{ + src_t *curSource = &srcList[src]; + + // I'm not touching it. Unlock it first. + if(curSource->isLocked) + return; + + // Remove the entity association and loop master status + if(curSource->isLooping) + { + curSource->isLooping = qfalse; + + if(curSource->entity != -1) + { + sentity_t *curEnt = &entityList[curSource->entity]; + + curEnt->srcAllocated = qfalse; + curEnt->srcIndex = -1; + curEnt->loopAddedThisFrame = qfalse; + curEnt->startLoopingSound = qfalse; + } + + S_AL_NewLoopMaster(curSource, qtrue); + } + + // Stop it if it's playing + if(curSource->isPlaying) + { + qalSourceStop(curSource->alSource); + curSource->isPlaying = qfalse; + } + + // Detach any buffers + qalSourcei(curSource->alSource, AL_BUFFER, 0); + + curSource->sfx = 0; + curSource->lastUsedTime = 0; + curSource->priority = 0; + curSource->entity = -1; + curSource->channel = -1; + if(curSource->isActive) + { + curSource->isActive = qfalse; + srcActiveCnt--; + } + curSource->isLocked = qfalse; + curSource->isTracking = qfalse; + curSource->local = qfalse; +} + +/* +================= +S_AL_SrcAlloc +================= +*/ +static +srcHandle_t S_AL_SrcAlloc( alSrcPriority_t priority, int entnum, int channel ) +{ + int i; + int empty = -1; + int weakest = -1; + int weakest_time = Sys_Milliseconds(); + int weakest_pri = 999; + float weakest_gain = 1000.0; + qboolean weakest_isplaying = qtrue; + int weakest_numloops = 0; + src_t *curSource; + + for(i = 0; i < srcCount; i++) + { + curSource = &srcList[i]; + + // If it's locked, we aren't even going to look at it + if(curSource->isLocked) + continue; + + // Is it empty or not? + if(!curSource->isActive) + { + empty = i; + break; + } + + if(curSource->isPlaying) + { + if(weakest_isplaying && curSource->priority < priority && + (curSource->priority < weakest_pri || + (!curSource->isLooping && (curSource->scaleGain < weakest_gain || curSource->lastUsedTime < weakest_time)))) + { + // If it has lower priority, is fainter or older, flag it as weak + // the last two values are only compared if it's not a looping sound, because we want to prevent two + // loops (loops are added EVERY frame) fighting for a slot + weakest_pri = curSource->priority; + weakest_time = curSource->lastUsedTime; + weakest_gain = curSource->scaleGain; + weakest = i; + } + } + else + { + weakest_isplaying = qfalse; + + if(weakest < 0 || + knownSfx[curSource->sfx].loopCnt > weakest_numloops || + curSource->priority < weakest_pri || + curSource->lastUsedTime < weakest_time) + { + // Sources currently not playing of course have lowest priority + // also try to always keep at least one loop master for every loop sound + weakest_pri = curSource->priority; + weakest_time = curSource->lastUsedTime; + weakest_numloops = knownSfx[curSource->sfx].loopCnt; + weakest = i; + } + } + + // The channel system is not actually adhered to by baseq3, and not + // implemented in snd_dma.c, so while the following is strictly correct, it + // causes incorrect behaviour versus defacto baseq3 +#if 0 + // Is it an exact match, and not on channel 0? + if((curSource->entity == entnum) && (curSource->channel == channel) && (channel != 0)) + { + S_AL_SrcKill(i); + return i; + } +#endif + } + + if(empty == -1) + empty = weakest; + + if(empty >= 0) + { + S_AL_SrcKill(empty); + srcList[empty].isActive = qtrue; + srcActiveCnt++; + } + + return empty; +} + +/* +================= +S_AL_SrcFind + +Finds an active source with matching entity and channel numbers +Returns -1 if there isn't one +================= +*/ +#if 0 +static +srcHandle_t S_AL_SrcFind(int entnum, int channel) +{ + int i; + for(i = 0; i < srcCount; i++) + { + if(!srcList[i].isActive) + continue; + if((srcList[i].entity == entnum) && (srcList[i].channel == channel)) + return i; + } + return -1; +} +#endif + +/* +================= +S_AL_SrcLock + +Locked sources will not be automatically reallocated or managed +================= +*/ +static +void S_AL_SrcLock(srcHandle_t src) +{ + srcList[src].isLocked = qtrue; +} + +/* +================= +S_AL_SrcUnlock + +Once unlocked, the source may be reallocated again +================= +*/ +static +void S_AL_SrcUnlock(srcHandle_t src) +{ + srcList[src].isLocked = qfalse; +} + +/* +================= +S_AL_UpdateEntity +================= +*/ +static +void S_AL_UpdateEntity( int entityNum, const vec3_t origin, const vec3_t velocity ) +{ + vec3_t sanOrigin; + + VectorCopy( origin, sanOrigin ); + S_AL_SanitiseVector( sanOrigin ); + if ( entityNum < 0 || entityNum >= MAX_GENTITIES ) + Com_Error( ERR_DROP, "S_AL_UpdateEntity: bad entitynum %i", entityNum ); + VectorCopy( sanOrigin, entityList[ entityNum ].origin ); + VectorCopy( velocity, entityList[ entityNum ].velocity ); +} + +/* +================= +S_AL_CheckInput +Check whether input values from mods are out of range. +Necessary for i.g. Western Quake3 mod which is buggy. +================= +*/ +static qboolean S_AL_CheckInput(int entityNum, sfxHandle_t sfx) +{ + if (entityNum < 0 || entityNum >= MAX_GENTITIES) + Com_Error(ERR_DROP, "ERROR: S_AL_CheckInput: bad entitynum %i", entityNum); + + if (sfx < 0 || sfx >= numSfx) + { + Com_Printf(S_COLOR_RED "ERROR: S_AL_CheckInput: handle %i out of range\n", sfx); + return qtrue; + } + + return qfalse; +} + +/* +================= +S_AL_StartLocalSound + +Play a local (non-spatialized) sound effect +================= +*/ +static +void S_AL_StartLocalSound(sfxHandle_t sfx, int channel) +{ + srcHandle_t src; + + if(S_AL_CheckInput(0, sfx)) + return; + + // Try to grab a source + src = S_AL_SrcAlloc(SRCPRI_LOCAL, -1, channel); + + if(src == -1) + return; + + // Set up the effect + S_AL_SrcSetup(src, sfx, SRCPRI_LOCAL, -1, channel, qtrue); + + // Start it playing + srcList[src].isPlaying = qtrue; + qalSourcePlay(srcList[src].alSource); +} + +/* +================= +S_AL_StartSound + +Play a one-shot sound effect +================= +*/ +static void S_AL_StartSound( const vec3_t origin, int entnum, int entchannel, sfxHandle_t sfx ) +{ + vec3_t sorigin; + srcHandle_t src; + src_t *curSource; + + if(origin) + { + if(S_AL_CheckInput(0, sfx)) + return; + + VectorCopy(origin, sorigin); + } + else + { + if(S_AL_CheckInput(entnum, sfx)) + return; + + if(S_AL_HearingThroughEntity(entnum)) + { + S_AL_StartLocalSound(sfx, entchannel); + return; + } + + VectorCopy(entityList[entnum].origin, sorigin); + } + + S_AL_SanitiseVector(sorigin); + + if((srcActiveCnt > 5 * srcCount / 3) && + (DistanceSquared(sorigin, lastListenerOrigin) >= + (s_alMaxDistance->value + s_alGraceDistance->value) * (s_alMaxDistance->value + s_alGraceDistance->value))) + { + // We're getting tight on sources and source is not within hearing distance so don't add it + return; + } + + // Try to grab a source + src = S_AL_SrcAlloc(SRCPRI_ONESHOT, entnum, entchannel); + if(src == -1) + return; + + S_AL_SrcSetup(src, sfx, SRCPRI_ONESHOT, entnum, entchannel, qfalse); + + curSource = &srcList[src]; + + if(!origin) + curSource->isTracking = qtrue; + + qalSourcefv(curSource->alSource, AL_POSITION, sorigin ); + S_AL_ScaleGain(curSource, sorigin); + + // Start it playing + curSource->isPlaying = qtrue; + qalSourcePlay(curSource->alSource); +} + +/* +================= +S_AL_ClearLoopingSounds +================= +*/ +static +void S_AL_ClearLoopingSounds( qboolean killall ) +{ + int i; + for(i = 0; i < srcCount; i++) + { + if((srcList[i].isLooping) && (srcList[i].entity != -1)) + entityList[srcList[i].entity].loopAddedThisFrame = qfalse; + } +} + +/* +================= +S_AL_SrcLoop +================= +*/ +static void S_AL_SrcLoop( alSrcPriority_t priority, sfxHandle_t sfx, + const vec3_t origin, const vec3_t velocity, int entityNum ) +{ + int src; + sentity_t *sent = &entityList[ entityNum ]; + src_t *curSource; + vec3_t sorigin, svelocity; + + if(S_AL_CheckInput(entityNum, sfx)) + return; + + // Do we need to allocate a new source for this entity + if( !sent->srcAllocated ) + { + // Try to get a channel + src = S_AL_SrcAlloc( priority, entityNum, -1 ); + if( src == -1 ) + { + Com_DPrintf( S_COLOR_YELLOW "WARNING: Failed to allocate source " + "for loop sfx %d on entity %d\n", sfx, entityNum ); + return; + } + + curSource = &srcList[src]; + + sent->startLoopingSound = qtrue; + + curSource->lastTimePos = -1.0; + curSource->lastSampleTime = Sys_Milliseconds(); + } + else + { + src = sent->srcIndex; + curSource = &srcList[src]; + } + + sent->srcAllocated = qtrue; + sent->srcIndex = src; + + sent->loopPriority = priority; + sent->loopSfx = sfx; + + // If this is not set then the looping sound is stopped. + sent->loopAddedThisFrame = qtrue; + + // UGH + // These lines should be called via S_AL_SrcSetup, but we + // can't call that yet as it buffers sfxes that may change + // with subsequent calls to S_AL_SrcLoop + curSource->entity = entityNum; + curSource->isLooping = qtrue; + + if( S_AL_HearingThroughEntity( entityNum ) ) + { + curSource->local = qtrue; + + VectorClear(sorigin); + + qalSourcefv(curSource->alSource, AL_POSITION, sorigin); + qalSourcefv(curSource->alSource, AL_VELOCITY, vec3_origin); + } + else + { + curSource->local = qfalse; + + if(origin) + VectorCopy(origin, sorigin); + else + VectorCopy(sent->origin, sorigin); + + S_AL_SanitiseVector(sorigin); + + VectorCopy(sorigin, curSource->loopSpeakerPos); + + if(velocity) + { + VectorCopy(velocity, svelocity); + S_AL_SanitiseVector(svelocity); + } + else + VectorClear(svelocity); + + qalSourcefv(curSource->alSource, AL_POSITION, (ALfloat *) sorigin); + qalSourcefv(curSource->alSource, AL_VELOCITY, (ALfloat *) svelocity); + } +} + +/* +================= +S_AL_AddLoopingSound +================= +*/ +static void S_AL_AddLoopingSound(int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx) +{ + S_AL_SrcLoop(SRCPRI_ENTITY, sfx, origin, velocity, entityNum); +} + +/* +================= +S_AL_AddRealLoopingSound +================= +*/ +static void S_AL_AddRealLoopingSound(int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx) +{ + S_AL_SrcLoop(SRCPRI_AMBIENT, sfx, origin, velocity, entityNum); +} + +/* +================= +S_AL_StopLoopingSound +================= +*/ +static +void S_AL_StopLoopingSound(int entityNum ) +{ + if(entityList[entityNum].srcAllocated) + S_AL_SrcKill(entityList[entityNum].srcIndex); +} + +/* +================= +S_AL_SrcUpdate + +Update state (move things around, manage sources, and so on) +================= +*/ +static +void S_AL_SrcUpdate( void ) +{ + int i; + int entityNum; + ALint state; + src_t *curSource; + + for(i = 0; i < srcCount; i++) + { + entityNum = srcList[i].entity; + curSource = &srcList[i]; + + if(curSource->isLocked) + continue; + + if(!curSource->isActive) + continue; + + // Update source parameters + if((s_alGain->modified) || (s_volume->modified)) + curSource->curGain = s_alGain->value * s_volume->value; + if((s_alRolloff->modified) && (!curSource->local)) + qalSourcef(curSource->alSource, AL_ROLLOFF_FACTOR, s_alRolloff->value); + if(s_alMinDistance->modified) + qalSourcef(curSource->alSource, AL_REFERENCE_DISTANCE, s_alMinDistance->value); + + if(curSource->isLooping) + { + sentity_t *sent = &entityList[ entityNum ]; + + // If a looping effect hasn't been touched this frame, pause or kill it + if(sent->loopAddedThisFrame) + { + alSfx_t *curSfx; + + // The sound has changed without an intervening removal + if(curSource->isActive && !sent->startLoopingSound && + curSource->sfx != sent->loopSfx) + { + S_AL_NewLoopMaster(curSource, qtrue); + + curSource->isPlaying = qfalse; + qalSourceStop(curSource->alSource); + qalSourcei(curSource->alSource, AL_BUFFER, 0); + sent->startLoopingSound = qtrue; + } + + // The sound hasn't been started yet + if(sent->startLoopingSound) + { + S_AL_SrcSetup(i, sent->loopSfx, sent->loopPriority, + entityNum, -1, curSource->local); + curSource->isLooping = qtrue; + + knownSfx[curSource->sfx].loopCnt++; + sent->startLoopingSound = qfalse; + } + + curSfx = &knownSfx[curSource->sfx]; + + S_AL_ScaleGain(curSource, curSource->loopSpeakerPos); + if(!curSource->scaleGain) + { + if(curSource->isPlaying) + { + // Sound is mute, stop playback until we are in range again + S_AL_NewLoopMaster(curSource, qfalse); + qalSourceStop(curSource->alSource); + curSource->isPlaying = qfalse; + } + else if(!curSfx->loopActiveCnt && curSfx->masterLoopSrc < 0) + curSfx->masterLoopSrc = i; + + continue; + } + + if(!curSource->isPlaying) + { + qalSourcei(curSource->alSource, AL_LOOPING, AL_TRUE); + curSource->isPlaying = qtrue; + qalSourcePlay(curSource->alSource); + + if(curSource->priority == SRCPRI_AMBIENT) + { + // If there are other ambient looping sources with the same sound, + // make sure the sound of these sources are in sync. + + if(curSfx->loopActiveCnt) + { + int offset, error; + + // we already have a master loop playing, get buffer position. + S_AL_ClearError(qfalse); + qalGetSourcei(srcList[curSfx->masterLoopSrc].alSource, AL_SAMPLE_OFFSET, &offset); + if((error = qalGetError()) != AL_NO_ERROR) + { + if(error != AL_INVALID_ENUM) + { + Com_Printf(S_COLOR_YELLOW "WARNING: Cannot get sample offset from source %d: " + "%s\n", i, S_AL_ErrorMsg(error)); + } + } + else + qalSourcei(curSource->alSource, AL_SAMPLE_OFFSET, offset); + } + else if(curSfx->loopCnt && curSfx->masterLoopSrc >= 0) + { + float secofs; + + src_t *master = &srcList[curSfx->masterLoopSrc]; + // This loop sound used to be played, but all sources are stopped. Use last sample position/time + // to calculate offset so the player thinks the sources continued playing while they were inaudible. + + if(master->lastTimePos >= 0) + { + secofs = master->lastTimePos + (Sys_Milliseconds() - master->lastSampleTime) / 1000.0f; + secofs = fmodf(secofs, (float) curSfx->info.samples / curSfx->info.rate); + + qalSourcef(curSource->alSource, AL_SEC_OFFSET, secofs); + } + + // I be the master now + curSfx->masterLoopSrc = i; + } + else + curSfx->masterLoopSrc = i; + } + else if(curSource->lastTimePos >= 0) + { + float secofs; + + // For unsynced loops (SRCPRI_ENTITY) just carry on playing as if the sound was never stopped + + secofs = curSource->lastTimePos + (Sys_Milliseconds() - curSource->lastSampleTime) / 1000.0f; + secofs = fmodf(secofs, (float) curSfx->info.samples / curSfx->info.rate); + qalSourcef(curSource->alSource, AL_SEC_OFFSET, secofs); + } + + curSfx->loopActiveCnt++; + } + + // Update locality + if(curSource->local) + { + qalSourcei(curSource->alSource, AL_SOURCE_RELATIVE, AL_TRUE); + qalSourcef(curSource->alSource, AL_ROLLOFF_FACTOR, 0.0f); + } + else + { + qalSourcei(curSource->alSource, AL_SOURCE_RELATIVE, AL_FALSE); + qalSourcef(curSource->alSource, AL_ROLLOFF_FACTOR, s_alRolloff->value); + } + + } + else if(curSource->priority == SRCPRI_AMBIENT) + { + if(curSource->isPlaying) + { + S_AL_NewLoopMaster(curSource, qfalse); + qalSourceStop(curSource->alSource); + curSource->isPlaying = qfalse; + } + } + else + S_AL_SrcKill(i); + + continue; + } + + if(!curSource->isStream) + { + // Check if it's done, and flag it + qalGetSourcei(curSource->alSource, AL_SOURCE_STATE, &state); + if(state == AL_STOPPED) + { + curSource->isPlaying = qfalse; + S_AL_SrcKill(i); + continue; + } + } + + // Query relativity of source, don't move if it's true + qalGetSourcei(curSource->alSource, AL_SOURCE_RELATIVE, &state); + + // See if it needs to be moved + if(curSource->isTracking && !state) + { + qalSourcefv(curSource->alSource, AL_POSITION, entityList[entityNum].origin); + S_AL_ScaleGain(curSource, entityList[entityNum].origin); + } + } +} + +/* +================= +S_AL_SrcShutup +================= +*/ +static +void S_AL_SrcShutup( void ) +{ + int i; + for(i = 0; i < srcCount; i++) + S_AL_SrcKill(i); +} + +/* +================= +S_AL_SrcGet +================= +*/ +static +ALuint S_AL_SrcGet(srcHandle_t src) +{ + return srcList[src].alSource; +} + + +//=========================================================================== + +// Q3A cinematics use up to 12 buffers at once +#define MAX_STREAM_BUFFERS 20 + +static srcHandle_t streamSourceHandles[MAX_RAW_STREAMS]; +static qboolean streamPlaying[MAX_RAW_STREAMS]; +static ALuint streamSources[MAX_RAW_STREAMS]; +static ALuint streamBuffers[MAX_RAW_STREAMS][MAX_STREAM_BUFFERS]; +static int streamNumBuffers[MAX_RAW_STREAMS]; +static int streamBufIndex[MAX_RAW_STREAMS]; + +/* +================= +S_AL_AllocateStreamChannel +================= +*/ +static void S_AL_AllocateStreamChannel(int stream, int entityNum) +{ + srcHandle_t cursrc; + ALuint alsrc; + + if ((stream < 0) || (stream >= MAX_RAW_STREAMS)) + return; + + if(entityNum >= 0) + { + // This is a stream that tracks an entity + // Allocate a streamSource at normal priority + cursrc = S_AL_SrcAlloc(SRCPRI_ENTITY, entityNum, 0); + if(cursrc < 0) + return; + + S_AL_SrcSetup(cursrc, -1, SRCPRI_ENTITY, entityNum, 0, qfalse); + alsrc = S_AL_SrcGet(cursrc); + srcList[cursrc].isTracking = qtrue; + srcList[cursrc].isStream = qtrue; + } + else + { + // Unspatialized stream source + + // Allocate a streamSource at high priority + cursrc = S_AL_SrcAlloc(SRCPRI_STREAM, -2, 0); + if(cursrc < 0) + return; + + alsrc = S_AL_SrcGet(cursrc); + + // Lock the streamSource so nobody else can use it, and get the raw streamSource + S_AL_SrcLock(cursrc); + + // make sure that after unmuting the S_AL_Gain in S_Update() does not turn + // volume up prematurely for this source + srcList[cursrc].scaleGain = 0.0f; + + // Set some streamSource parameters + qalSourcei (alsrc, AL_BUFFER, 0 ); + qalSourcei (alsrc, AL_LOOPING, AL_FALSE ); + qalSource3f(alsrc, AL_POSITION, 0.0, 0.0, 0.0); + qalSource3f(alsrc, AL_VELOCITY, 0.0, 0.0, 0.0); + qalSource3f(alsrc, AL_DIRECTION, 0.0, 0.0, 0.0); + qalSourcef (alsrc, AL_ROLLOFF_FACTOR, 0.0 ); + qalSourcei (alsrc, AL_SOURCE_RELATIVE, AL_TRUE ); + } + + streamSourceHandles[stream] = cursrc; + streamSources[stream] = alsrc; + + streamNumBuffers[stream] = 0; + streamBufIndex[stream] = 0; +} + +/* +================= +S_AL_FreeStreamChannel +================= +*/ +static void S_AL_FreeStreamChannel( int stream ) +{ + if ((stream < 0) || (stream >= MAX_RAW_STREAMS)) + return; + + // Detach any buffers + qalSourcei(streamSources[stream], AL_BUFFER, 0); + + // Delete the buffers + if (streamNumBuffers[stream] > 0) { + qalDeleteBuffers(streamNumBuffers[stream], streamBuffers[stream]); + streamNumBuffers[stream] = 0; + } + + // Release the output streamSource + S_AL_SrcUnlock(streamSourceHandles[stream]); + S_AL_SrcKill(streamSourceHandles[stream]); + streamSources[stream] = 0; + streamSourceHandles[stream] = -1; +} + +/* +================= +S_AL_RawSamples +================= +*/ +static +void S_AL_RawSamples(int stream, int samples, int rate, int width, int channels, const byte *data, float volume, int entityNum) +{ + int numBuffers; + ALuint buffer; + ALuint format; + + if ((stream < 0) || (stream >= MAX_RAW_STREAMS)) + return; + + format = S_AL_Format( width, channels ); + + // Create the streamSource if necessary + if(streamSourceHandles[stream] == -1) + { + S_AL_AllocateStreamChannel(stream, entityNum); + + // Failed? + if(streamSourceHandles[stream] == -1) + { + Com_Printf( S_COLOR_RED "ERROR: Can't allocate streaming streamSource\n"); + return; + } + } + + qalGetSourcei(streamSources[stream], AL_BUFFERS_QUEUED, &numBuffers); + + if (numBuffers == MAX_STREAM_BUFFERS) + { + Com_DPrintf(S_COLOR_RED"WARNING: Steam dropping raw samples, reached MAX_STREAM_BUFFERS\n"); + return; + } + + // Allocate a new AL buffer if needed + if (numBuffers == streamNumBuffers[stream]) + { + ALuint oldBuffers[MAX_STREAM_BUFFERS]; + int i; + + if (!S_AL_GenBuffers(1, &buffer, "stream")) + return; + + Com_Memcpy(oldBuffers, &streamBuffers[stream], sizeof (oldBuffers)); + + // Reorder buffer array in order of oldest to newest + for ( i = 0; i < streamNumBuffers[stream]; ++i ) + streamBuffers[stream][i] = oldBuffers[(streamBufIndex[stream] + i) % streamNumBuffers[stream]]; + + // Add the new buffer to end + streamBuffers[stream][streamNumBuffers[stream]] = buffer; + streamBufIndex[stream] = streamNumBuffers[stream]; + streamNumBuffers[stream]++; + } + + // Select next buffer in loop + buffer = streamBuffers[stream][ streamBufIndex[stream] ]; + streamBufIndex[stream] = (streamBufIndex[stream] + 1) % streamNumBuffers[stream]; + + // Fill buffer + qalBufferData(buffer, format, (ALvoid *)data, (samples * width * channels), rate); + + // Shove the data onto the streamSource + qalSourceQueueBuffers(streamSources[stream], 1, &buffer); + + if(entityNum < 0) + { + // Volume + S_AL_Gain (streamSources[stream], volume * s_volume->value * s_alGain->value); + } + + // Start stream + if(!streamPlaying[stream]) + { + qalSourcePlay( streamSources[stream] ); + streamPlaying[stream] = qtrue; + } +} + +/* +================= +S_AL_StreamUpdate +================= +*/ +static +void S_AL_StreamUpdate( int stream ) +{ + int numBuffers; + ALint state; + + if ((stream < 0) || (stream >= MAX_RAW_STREAMS)) + return; + + if(streamSourceHandles[stream] == -1) + return; + + // Un-queue any buffers + qalGetSourcei( streamSources[stream], AL_BUFFERS_PROCESSED, &numBuffers ); + while( numBuffers-- ) + { + ALuint buffer; + qalSourceUnqueueBuffers(streamSources[stream], 1, &buffer); + } + + // Start the streamSource playing if necessary + qalGetSourcei( streamSources[stream], AL_BUFFERS_QUEUED, &numBuffers ); + + qalGetSourcei(streamSources[stream], AL_SOURCE_STATE, &state); + if(state == AL_STOPPED) + { + streamPlaying[stream] = qfalse; + + // If there are no buffers queued up, release the streamSource + if( !numBuffers ) + S_AL_FreeStreamChannel( stream ); + } + + if( !streamPlaying[stream] && numBuffers ) + { + qalSourcePlay( streamSources[stream] ); + streamPlaying[stream] = qtrue; + } +} + +/* +================= +S_AL_StreamDie +================= +*/ +static +void S_AL_StreamDie( int stream ) +{ + if ((stream < 0) || (stream >= MAX_RAW_STREAMS)) + return; + + if(streamSourceHandles[stream] == -1) + return; + + streamPlaying[stream] = qfalse; + qalSourceStop(streamSources[stream]); + + S_AL_FreeStreamChannel(stream); +} + + +//=========================================================================== + + +#define NUM_MUSIC_BUFFERS 4 +#define MUSIC_BUFFER_SIZE 4096 + +static qboolean musicPlaying = qfalse; +static srcHandle_t musicSourceHandle = -1; +static ALuint musicSource; +static ALuint musicBuffers[NUM_MUSIC_BUFFERS]; + +static snd_stream_t *mus_stream; +static snd_stream_t *intro_stream; +static char s_backgroundLoop[MAX_QPATH]; + +static byte decode_buffer[MUSIC_BUFFER_SIZE]; + +/* +================= +S_AL_MusicSourceGet +================= +*/ +static void S_AL_MusicSourceGet( void ) +{ + // Allocate a musicSource at high priority + musicSourceHandle = S_AL_SrcAlloc(SRCPRI_STREAM, -2, 0); + if(musicSourceHandle == -1) + return; + + // Lock the musicSource so nobody else can use it, and get the raw musicSource + S_AL_SrcLock(musicSourceHandle); + musicSource = S_AL_SrcGet(musicSourceHandle); + + // make sure that after unmuting the S_AL_Gain in S_Update() does not turn + // volume up prematurely for this source + srcList[musicSourceHandle].scaleGain = 0.0f; + + // Set some musicSource parameters + qalSource3f(musicSource, AL_POSITION, 0.0, 0.0, 0.0); + qalSource3f(musicSource, AL_VELOCITY, 0.0, 0.0, 0.0); + qalSource3f(musicSource, AL_DIRECTION, 0.0, 0.0, 0.0); + qalSourcef (musicSource, AL_ROLLOFF_FACTOR, 0.0 ); + qalSourcei (musicSource, AL_SOURCE_RELATIVE, AL_TRUE ); +} + +/* +================= +S_AL_MusicSourceFree +================= +*/ +static void S_AL_MusicSourceFree( void ) +{ + // Release the output musicSource + S_AL_SrcUnlock(musicSourceHandle); + S_AL_SrcKill(musicSourceHandle); + musicSource = 0; + musicSourceHandle = -1; +} + +/* +================= +S_AL_CloseMusicFiles +================= +*/ +static void S_AL_CloseMusicFiles(void) +{ + if(intro_stream) + { + S_CodecCloseStream(intro_stream); + intro_stream = NULL; + } + + if(mus_stream) + { + S_CodecCloseStream(mus_stream); + mus_stream = NULL; + } +} + +/* +================= +S_AL_StopBackgroundTrack +================= +*/ +static +void S_AL_StopBackgroundTrack( void ) +{ + if(!musicPlaying) + return; + + // Stop playing + qalSourceStop(musicSource); + + // Detach any buffers + qalSourcei(musicSource, AL_BUFFER, 0); + + // Delete the buffers + qalDeleteBuffers(NUM_MUSIC_BUFFERS, musicBuffers); + + // Free the musicSource + S_AL_MusicSourceFree(); + + // Unload the stream + S_AL_CloseMusicFiles(); + + musicPlaying = qfalse; +} + +/* +================= +S_AL_MusicProcess +================= +*/ +static +void S_AL_MusicProcess(ALuint b) +{ + ALenum error; + int l; + ALuint format; + snd_stream_t *curstream; + + S_AL_ClearError( qfalse ); + + if(intro_stream) + curstream = intro_stream; + else + curstream = mus_stream; + + if(!curstream) + return; + + l = S_CodecReadStream(curstream, MUSIC_BUFFER_SIZE, decode_buffer); + + // Run out data to read, start at the beginning again + if(l == 0) + { + S_CodecCloseStream(curstream); + + // the intro stream just finished playing so we don't need to reopen + // the music stream. + if(intro_stream) + intro_stream = NULL; + else + mus_stream = S_CodecOpenStream(s_backgroundLoop); + + curstream = mus_stream; + + if(!curstream) + { + S_AL_StopBackgroundTrack(); + return; + } + + l = S_CodecReadStream(curstream, MUSIC_BUFFER_SIZE, decode_buffer); + } + + format = S_AL_Format(curstream->info.width, curstream->info.channels); + + if( l == 0 ) + { + // We have no data to buffer, so buffer silence + byte dummyData[ 2 ] = { 0 }; + + qalBufferData( b, AL_FORMAT_MONO16, (void *)dummyData, 2, 22050 ); + } + else + qalBufferData(b, format, decode_buffer, l, curstream->info.rate); + + if( ( error = qalGetError( ) ) != AL_NO_ERROR ) + { + S_AL_StopBackgroundTrack( ); + Com_Printf( S_COLOR_RED "ERROR: while buffering data for music stream - %s\n", + S_AL_ErrorMsg( error ) ); + return; + } +} + +/* +================= +S_AL_StartBackgroundTrack +================= +*/ +static +void S_AL_StartBackgroundTrack( const char *intro, const char *loop ) +{ + int i; + qboolean issame; + + // Stop any existing music that might be playing + S_AL_StopBackgroundTrack(); + + if((!intro || !*intro) && (!loop || !*loop)) + return; + + // Allocate a musicSource + S_AL_MusicSourceGet(); + if(musicSourceHandle == -1) + return; + + if (!loop || !*loop) + { + loop = intro; + issame = qtrue; + } + else if(intro && *intro && !strcmp(intro, loop)) + issame = qtrue; + else + issame = qfalse; + + // Copy the loop over + Q_strncpyz( s_backgroundLoop, loop, sizeof( s_backgroundLoop ) ); + + if(!issame) + { + // Open the intro and don't mind whether it succeeds. + // The important part is the loop. + intro_stream = S_CodecOpenStream(intro); + } + else + intro_stream = NULL; + + mus_stream = S_CodecOpenStream(s_backgroundLoop); + if(!mus_stream) + { + S_AL_CloseMusicFiles(); + S_AL_MusicSourceFree(); + return; + } + + // Generate the musicBuffers + if (!S_AL_GenBuffers(NUM_MUSIC_BUFFERS, musicBuffers, "music")) + return; + + // Queue the musicBuffers up + for(i = 0; i < NUM_MUSIC_BUFFERS; i++) + { + S_AL_MusicProcess(musicBuffers[i]); + } + + qalSourceQueueBuffers(musicSource, NUM_MUSIC_BUFFERS, musicBuffers); + + // Set the initial gain property + S_AL_Gain(musicSource, s_alGain->value * s_musicVolume->value); + + // Start playing + qalSourcePlay(musicSource); + + musicPlaying = qtrue; +} + +/* +================= +S_AL_MusicUpdate +================= +*/ +static +void S_AL_MusicUpdate( void ) +{ + int numBuffers; + ALint state; + + if(!musicPlaying) + return; + + qalGetSourcei( musicSource, AL_BUFFERS_PROCESSED, &numBuffers ); + while( numBuffers-- ) + { + ALuint b; + qalSourceUnqueueBuffers(musicSource, 1, &b); + S_AL_MusicProcess(b); + qalSourceQueueBuffers(musicSource, 1, &b); + } + + // Hitches can cause OpenAL to be starved of buffers when streaming. + // If this happens, it will stop playback. This restarts the source if + // it is no longer playing, and if there are buffers available + qalGetSourcei( musicSource, AL_SOURCE_STATE, &state ); + qalGetSourcei( musicSource, AL_BUFFERS_QUEUED, &numBuffers ); + if( state == AL_STOPPED && numBuffers ) + { + Com_DPrintf( S_COLOR_YELLOW "Restarted OpenAL music\n" ); + qalSourcePlay(musicSource); + } + + // Set the gain property + S_AL_Gain(musicSource, s_alGain->value * s_musicVolume->value); +} + + +//=========================================================================== + + +// Local state variables +static ALCdevice *alDevice; +static ALCcontext *alContext; + +#ifdef USE_VOIP +static ALCdevice *alCaptureDevice; +static cvar_t *s_alCapture; +#endif + +#ifdef _WIN32 +#define ALDRIVER_DEFAULT "OpenAL32.dll" +#elif defined(MACOS_X) +#define ALDRIVER_DEFAULT "/System/Library/Frameworks/OpenAL.framework/OpenAL" +#elif defined(__OpenBSD__) +#define ALDRIVER_DEFAULT "libopenal.so" +#else +#define ALDRIVER_DEFAULT "libopenal.so.1" +#endif + +/* +================= +S_AL_StopAllSounds +================= +*/ +static +void S_AL_StopAllSounds( void ) +{ + int i; + S_AL_SrcShutup(); + S_AL_StopBackgroundTrack(); + for (i = 0; i < MAX_RAW_STREAMS; i++) + S_AL_StreamDie(i); +} + +/* +================= +S_AL_Respatialize +================= +*/ +static +void S_AL_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater ) +{ + float orientation[6]; + vec3_t sorigin; + + VectorCopy( origin, sorigin ); + S_AL_SanitiseVector( sorigin ); + + S_AL_SanitiseVector( axis[ 0 ] ); + S_AL_SanitiseVector( axis[ 1 ] ); + S_AL_SanitiseVector( axis[ 2 ] ); + + orientation[0] = axis[0][0]; orientation[1] = axis[0][1]; orientation[2] = axis[0][2]; + orientation[3] = axis[2][0]; orientation[4] = axis[2][1]; orientation[5] = axis[2][2]; + + lastListenerNumber = entityNum; + VectorCopy( sorigin, lastListenerOrigin ); + + // Set OpenAL listener paramaters + qalListenerfv(AL_POSITION, (ALfloat *)sorigin); + qalListenerfv(AL_VELOCITY, vec3_origin); + qalListenerfv(AL_ORIENTATION, orientation); +} + +/* +================= +S_AL_Update +================= +*/ +static +void S_AL_Update( void ) +{ + int i; + + if(s_muted->modified) + { + // muted state changed. Let S_AL_Gain turn up all sources again. + for(i = 0; i < srcCount; i++) + { + if(srcList[i].isActive) + S_AL_Gain(srcList[i].alSource, srcList[i].scaleGain); + } + + s_muted->modified = qfalse; + } + + // Update SFX channels + S_AL_SrcUpdate(); + + // Update streams + for (i = 0; i < MAX_RAW_STREAMS; i++) + S_AL_StreamUpdate(i); + S_AL_MusicUpdate(); + + // Doppler + if(s_doppler->modified) + { + s_alDopplerFactor->modified = qtrue; + s_doppler->modified = qfalse; + } + + // Doppler parameters + if(s_alDopplerFactor->modified) + { + if(s_doppler->integer) + qalDopplerFactor(s_alDopplerFactor->value); + else + qalDopplerFactor(0.0f); + s_alDopplerFactor->modified = qfalse; + } + if(s_alDopplerSpeed->modified) + { + qalSpeedOfSound(s_alDopplerSpeed->value); + s_alDopplerSpeed->modified = qfalse; + } + + // Clear the modified flags on the other cvars + s_alGain->modified = qfalse; + s_volume->modified = qfalse; + s_musicVolume->modified = qfalse; + s_alMinDistance->modified = qfalse; + s_alRolloff->modified = qfalse; +} + +/* +================= +S_AL_DisableSounds +================= +*/ +static +void S_AL_DisableSounds( void ) +{ + S_AL_StopAllSounds(); +} + +/* +================= +S_AL_BeginRegistration +================= +*/ +static +void S_AL_BeginRegistration( void ) +{ + if(!numSfx) + S_AL_BufferInit(); +} + +/* +================= +S_AL_ClearSoundBuffer +================= +*/ +static +void S_AL_ClearSoundBuffer( void ) +{ +} + +/* +================= +S_AL_IsSoundPlaying +================= +*/ +static +qboolean S_AL_IsSoundPlaying( int channelNumber, const char *name ) +{ + int i; + + for( i = 0; i < MAX_SRC; i++ ) + { + if( srcList[ i ].channel == channelNumber && !strcmp( knownSfx[ srcList[ i ].sfx ].filename, name ) ) { + if( srcList[ i ].isActive ) { + return qtrue; + } else { + return qfalse; + } + } + } + + return qfalse; +} + +/* +================= +S_AL_SoundList +================= +*/ +static +void S_AL_SoundList( void ) +{ +} + +#ifdef USE_VOIP +static +void S_AL_StartCapture( void ) +{ + if( alCaptureDevice != NULL ) + qalcCaptureStart( alCaptureDevice ); +} + +static +int S_AL_AvailableCaptureSamples( void ) +{ + int retval = 0; + if( alCaptureDevice != NULL ) + { + ALint samples = 0; + qalcGetIntegerv( alCaptureDevice, ALC_CAPTURE_SAMPLES, sizeof( samples ), &samples ); + retval = ( int )samples; + } + return retval; +} + +static +void S_AL_Capture( int samples, byte *data ) +{ + if( alCaptureDevice != NULL ) + qalcCaptureSamples( alCaptureDevice, data, samples ); +} + +void S_AL_StopCapture( void ) +{ + if( alCaptureDevice != NULL ) + qalcCaptureStop( alCaptureDevice ); +} + +void S_AL_MasterGain( float gain ) +{ + qalListenerf( AL_GAIN, gain ); +} +#endif + + +/* +================= +S_AL_SoundInfo +================= +*/ +static void S_AL_SoundInfo( void ) +{ + Com_Printf( "OpenAL info:\n" ); + Com_Printf( " Vendor: %s\n", qalGetString( AL_VENDOR ) ); + Com_Printf( " Version: %s\n", qalGetString( AL_VERSION ) ); + Com_Printf( " Renderer: %s\n", qalGetString( AL_RENDERER ) ); + Com_Printf( " AL Extensions: %s\n", qalGetString( AL_EXTENSIONS ) ); + Com_Printf( " ALC Extensions: %s\n", qalcGetString( alDevice, ALC_EXTENSIONS ) ); + + if( enumeration_all_ext ) + Com_Printf( " Device: %s\n", qalcGetString( alDevice, ALC_ALL_DEVICES_SPECIFIER ) ); + else if( enumeration_ext ) + Com_Printf( " Device: %s\n", qalcGetString( alDevice, ALC_DEVICE_SPECIFIER ) ); + + if( enumeration_all_ext || enumeration_ext ) + Com_Printf( " Available Devices:\n%s", s_alAvailableDevices->string ); + +#ifdef USE_VOIP + if( capture_ext ) + { + Com_Printf( " Input Device: %s\n", qalcGetString( alCaptureDevice, ALC_CAPTURE_DEVICE_SPECIFIER ) ); + Com_Printf( " Available Input Devices:\n%s", s_alAvailableInputDevices->string ); + } +#endif +} + + + +/* +================= +S_AL_Shutdown +================= +*/ +static +void S_AL_Shutdown( void ) +{ + // Shut down everything + int i; + for( i = 0; i < MAX_RAW_STREAMS; i++ ) + S_AL_StreamDie( i ); + S_AL_StopBackgroundTrack(); + S_AL_SrcShutdown(); + S_AL_BufferShutdown(); + + qalcDestroyContext( alContext ); + qalcCloseDevice( alDevice ); + +#ifdef USE_VOIP + if( alCaptureDevice != NULL ) { + qalcCaptureStop( alCaptureDevice ); + qalcCaptureCloseDevice( alCaptureDevice ); + alCaptureDevice = NULL; + Com_Printf( "OpenAL capture device closed.\n" ); + } +#endif + + for( i = 0; i < MAX_RAW_STREAMS; i++ ) { + streamSourceHandles[ i ] = -1; + streamPlaying[ i ] = qfalse; + streamSources[ i ] = 0; + } + + QAL_Shutdown(); +} + +#endif + +/* +================= +S_AL_Init +================= +*/ +qboolean S_AL_Init( soundInterface_t *si ) +{ +#ifdef USE_OPENAL + const char* device = NULL; + const char* inputdevice = NULL; + int i; + + if( !si ) { + return qfalse; + } + + for( i = 0; i < MAX_RAW_STREAMS; i++ ) { + streamSourceHandles[ i ] = -1; + streamPlaying[ i ] = qfalse; + streamSources[ i ] = 0; + streamNumBuffers[ i ] = 0; + streamBufIndex[ i ] = 0; + } + + // New console variables + s_alPrecache = Cvar_Get( "s_alPrecache", "1", CVAR_ARCHIVE ); + s_alGain = Cvar_Get( "s_alGain", "1.0", CVAR_ARCHIVE ); + s_alSources = Cvar_Get( "s_alSources", "96", CVAR_ARCHIVE ); + s_alDopplerFactor = Cvar_Get( "s_alDopplerFactor", "1.0", CVAR_ARCHIVE ); + s_alDopplerSpeed = Cvar_Get( "s_alDopplerSpeed", "9000", CVAR_ARCHIVE ); + s_alMinDistance = Cvar_Get( "s_alMinDistance", "120", CVAR_CHEAT ); + s_alMaxDistance = Cvar_Get( "s_alMaxDistance", "1024", CVAR_CHEAT ); + s_alRolloff = Cvar_Get( "s_alRolloff", "2", CVAR_CHEAT ); + s_alGraceDistance = Cvar_Get( "s_alGraceDistance", "512", CVAR_CHEAT ); + + s_alDriver = Cvar_Get( "s_alDriver", ALDRIVER_DEFAULT, CVAR_ARCHIVE | CVAR_LATCH ); + + s_alInputDevice = Cvar_Get( "s_alInputDevice", "", CVAR_ARCHIVE | CVAR_LATCH ); + s_alDevice = Cvar_Get( "s_alDevice", "", CVAR_ARCHIVE | CVAR_LATCH ); + + // Load QAL + if( !QAL_Init( s_alDriver->string ) ) + { + Com_Printf( "Failed to load library: \"%s\".\n", s_alDriver->string ); + if( !Q_stricmp( s_alDriver->string, ALDRIVER_DEFAULT ) || !QAL_Init( ALDRIVER_DEFAULT ) ) { + return qfalse; + } + } + + device = s_alDevice->string; + if( device && !*device ) + device = NULL; + + inputdevice = s_alInputDevice->string; + if( inputdevice && !*inputdevice ) + inputdevice = NULL; + + + // Device enumeration support + enumeration_all_ext = qalcIsExtensionPresent( NULL, "ALC_ENUMERATE_ALL_EXT" ); + enumeration_ext = qalcIsExtensionPresent( NULL, "ALC_ENUMERATION_EXT" ); + + if( enumeration_ext || enumeration_all_ext ) + { + char devicenames[ 16384 ] = ""; + const char *devicelist; +#ifdef _WIN32 + const char *defaultdevice; +#endif + int curlen; + + // get all available devices + the default device name. + if( enumeration_all_ext ) + { + devicelist = qalcGetString( NULL, ALC_ALL_DEVICES_SPECIFIER ); +#ifdef _WIN32 + defaultdevice = qalcGetString( NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER ); +#endif + } + else + { + // We don't have ALC_ENUMERATE_ALL_EXT but normal enumeration. + devicelist = qalcGetString( NULL, ALC_DEVICE_SPECIFIER ); +#ifdef _WIN32 + defaultdevice = qalcGetString( NULL, ALC_DEFAULT_DEVICE_SPECIFIER ); +#endif + enumeration_ext = qtrue; + } + +#ifdef _WIN32 + // check whether the default device is generic hardware. If it is, change to + // Generic Software as that one works more reliably with various sound systems. + // If it's not, use OpenAL's default selection as we don't want to ignore + // native hardware acceleration. + if( !device && defaultdevice && !strcmp( defaultdevice, "Generic Hardware" ) ) + device = "Generic Software"; +#endif + + // dump a list of available devices to a cvar for the user to see. + + if( devicelist ) + { + while( ( curlen = strlen( devicelist ) ) ) + { + Q_strcat( devicenames, sizeof( devicenames ), devicelist ); + Q_strcat( devicenames, sizeof( devicenames ), "\n" ); + + devicelist += curlen + 1; + } + } + + s_alAvailableDevices = Cvar_Get( "s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART ); + } + + alDevice = qalcOpenDevice( device ); + if( !alDevice && device ) + { + Com_Printf( "Failed to open OpenAL device '%s', trying default.\n", device ); + alDevice = qalcOpenDevice( NULL ); + } + + if( !alDevice ) + { + QAL_Shutdown(); + Com_Printf( "Failed to open OpenAL device.\n" ); + return qfalse; + } + + // Create OpenAL context + alContext = qalcCreateContext( alDevice, NULL ); + if( !alContext ) + { + QAL_Shutdown(); + qalcCloseDevice( alDevice ); + Com_Printf( "Failed to create OpenAL context.\n" ); + return qfalse; + } + qalcMakeContextCurrent( alContext ); + + // Initialize sources, buffers, music + S_AL_BufferInit(); + S_AL_SrcInit(); + + // Set up OpenAL parameters (doppler, etc) + qalDistanceModel( AL_INVERSE_DISTANCE_CLAMPED ); + qalDopplerFactor( s_alDopplerFactor->value ); + qalSpeedOfSound( s_alDopplerSpeed->value ); + +#ifdef USE_VOIP + // !!! FIXME: some of these alcCaptureOpenDevice() values should be cvars. + // !!! FIXME: add support for capture device enumeration. + // !!! FIXME: add some better error reporting. + s_alCapture = Cvar_Get( "s_alCapture", "1", CVAR_ARCHIVE | CVAR_LATCH ); + if( !s_alCapture->integer ) + { + Com_Printf( "OpenAL capture support disabled by user ('+set s_alCapture 1' to enable)\n" ); + } +#if USE_MUMBLE + else if( cl_useMumble->integer ) + { + Com_Printf( "OpenAL capture support disabled for Mumble support\n" ); + } +#endif + else + { +#ifdef MACOS_X + // !!! FIXME: Apple has a 1.1-compliant OpenAL, which includes + // !!! FIXME: capture support, but they don't list it in the + // !!! FIXME: extension string. We need to check the version string, + // !!! FIXME: then the extension string, but that's too much trouble, + // !!! FIXME: so we'll just check the function pointer for now. + if( qalcCaptureOpenDevice == NULL ) +#else + if( !qalcIsExtensionPresent( NULL, "ALC_EXT_capture" ) ) +#endif + { + Com_Printf( "No ALC_EXT_capture support, can't record audio.\n" ); + } + else + { + char inputdevicenames[ 16384 ] = ""; + const char *inputdevicelist; + const char *defaultinputdevice; + int curlen; + + capture_ext = qtrue; + + // get all available input devices + the default input device name. + inputdevicelist = qalcGetString( NULL, ALC_CAPTURE_DEVICE_SPECIFIER ); + defaultinputdevice = qalcGetString( NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER ); + + // dump a list of available devices to a cvar for the user to see. + if( inputdevicelist ) + { + while( ( curlen = strlen( inputdevicelist ) ) ) + { + Q_strcat( inputdevicenames, sizeof( inputdevicenames ), inputdevicelist ); + Q_strcat( inputdevicenames, sizeof( inputdevicenames ), "\n" ); + inputdevicelist += curlen + 1; + } + } + + s_alAvailableInputDevices = Cvar_Get( "s_alAvailableInputDevices", inputdevicenames, CVAR_ROM | CVAR_NORESTART ); + + // !!! FIXME: 8000Hz is what Speex narrowband mode needs, but we + // !!! FIXME: should probably open the capture device after + // !!! FIXME: initializing Speex so we can change to wideband + // !!! FIXME: if we like. + Com_Printf( "OpenAL default capture device is '%s'\n", defaultinputdevice ? defaultinputdevice : "none" ); + alCaptureDevice = qalcCaptureOpenDevice( inputdevice, 8000, AL_FORMAT_MONO16, 4096 ); + if( !alCaptureDevice && inputdevice ) + { + Com_Printf( "Failed to open OpenAL Input device '%s', trying default.\n", inputdevice ); + alCaptureDevice = qalcCaptureOpenDevice( NULL, 8000, AL_FORMAT_MONO16, 4096 ); + } + Com_Printf( "OpenAL capture device %s.\n", + ( alCaptureDevice == NULL ) ? "failed to open" : "opened" ); + } + } +#endif + + si->Shutdown = S_AL_Shutdown; + si->StartSound = S_AL_StartSound; + si->StartLocalSound = S_AL_StartLocalSound; + si->StartBackgroundTrack = S_AL_StartBackgroundTrack; + si->StopBackgroundTrack = S_AL_StopBackgroundTrack; + si->RawSamples = S_AL_RawSamples; + si->StopAllSounds = S_AL_StopAllSounds; + si->ClearLoopingSounds = S_AL_ClearLoopingSounds; + si->AddLoopingSound = S_AL_AddLoopingSound; + si->AddRealLoopingSound = S_AL_AddRealLoopingSound; + si->StopLoopingSound = S_AL_StopLoopingSound; + si->Respatialize = S_AL_Respatialize; + si->UpdateEntity = S_AL_UpdateEntity; + si->Update = S_AL_Update; + si->DisableSounds = S_AL_DisableSounds; + si->BeginRegistration = S_AL_BeginRegistration; + si->RegisterSound = S_AL_RegisterSound; + si->ClearSoundBuffer = S_AL_ClearSoundBuffer; + si->SoundInfo = S_AL_SoundInfo; + si->SoundList = S_AL_SoundList; + +#ifdef USE_VOIP + si->StartCapture = S_AL_StartCapture; + si->AvailableCaptureSamples = S_AL_AvailableCaptureSamples; + si->Capture = S_AL_Capture; + si->StopCapture = S_AL_StopCapture; + si->MasterGain = S_AL_MasterGain; +#endif + + return qtrue; +#else + return qfalse; +#endif +} diff --git a/code/client/snd_public.h b/code/client/snd_public.h new file mode 100644 index 00000000..f0c809d7 --- /dev/null +++ b/code/client/snd_public.h @@ -0,0 +1,122 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct soundsystemsavegame_s soundsystemsavegame_t; +typedef struct channelbasesavegame_s channelbasesavegame_t; +typedef struct channel_s channel_t; + +void S_Init( void ); +void S_SaveData( soundsystemsavegame_t *pSave ); +void S_LoadData( soundsystemsavegame_t *pSave ); +void S_InitBase( channelbasesavegame_t *pBase ); +void S_StoreBase( channelbasesavegame_t *pBase, channel_t *channel ); +void S_Shutdown( void ); + +void S_FadeSound( float fTime ); + +// if origin is NULL, the sound will be dynamically sourced from the entity +void S_StartSound( const vec3_t origin, int entNum, int entChannel, sfxHandle_t sfxHandle, float volume, float minDist, float pitch, float maxDist, qboolean streamed ); +void S_StartLocalSound( const char *sound_name, qboolean force_load ); + +void S_StartBackgroundTrack( const char *intro, const char *loop ); +void S_StopBackgroundTrack( void ); + +// cinematics and voice-over-network will send raw samples +// 1.0 volume will be direct output of source samples +void S_RawSamples( int stream, int samples, int rate, int width, int channels, + const byte *data, float volume, int entityNum ); + +void S_StopSound( int entNum, int channel ); + +// stop all sounds and the background track +void S_StopAllSounds( qboolean stop_music ); + +// all continuous looping sounds must be added before calling S_Update +void S_ClearLoopingSounds( void ); +void S_AddLoopingSound( const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx, float volume, float minDist, float maxDist, float pitch, int flags ); +void S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ); +void S_StopLoopingSound( int entityNum ); + +// recompute the reletive volumes for all running sounds +// reletive to the given entityNum / orientation +void S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[ 3 ] ); +void S_RespatializeEx( int entityNum, const vec3_t origin, vec3_t axis[ 3 ], int inwater ); + +float S_GetSoundTime( sfxHandle_t handle ); +void S_SetGlobalAmbientVolumeLevel( float volume ); +void S_SetReverb( int reverb_type, float reverb_level ); + +int S_IsSoundPlaying( int channelNumber, const char *name ); + +// let the sound system know where an entity currently is +void S_UpdateEntity( int entityNum, const vec3_t origin, const vec3_t velocity, qboolean use_listener ); + +void S_Update( void ); + +void S_DisableSounds( void ); + +void S_BeginRegistration( void ); +void S_EndRegistration( void ); +qboolean S_IsSoundRegistered( const char *name ); + +// RegisterSound will allways return a valid sample, even if it +// has to create a placeholder. This prevents continuous filesystem +// checks for missing files +sfxHandle_t S_RegisterSound( const char *sample, qboolean compressed, qboolean force_load ); + +void S_DisplayFreeMemory( void ); + +void S_ClearSoundBuffer( void ); + +void SNDDMA_Activate( void ); + +void S_UpdateBackgroundTrack( void ); + +// Music soundtrack + +void MUSIC_Pause(); +void MUSIC_Unpause(); +qboolean MUSIC_LoadSoundtrackFile( const char *filename ); +qboolean MUSIC_SongValid( const char *mood ); +qboolean MUSIC_Loaded( void ); +void Music_Update( void ); +void MUSIC_SongEnded( void ); +void MUSIC_NewSoundtrack( const char *name ); +void MUSIC_UpdateMood( int current, int fallback ); +void MUSIC_UpdateVolume( float volume, float fade_time ); +void MUSIC_StopAllSongs( void ); +void MUSIC_FreeAllSongs( void ); +qboolean MUSIC_Playing( void ); +int MUSIC_FindSong( const char *name ); +int MUSIC_CurrentSongChannel( void ); +void MUSIC_StopChannel( int channel_number ); +qboolean MUSIC_PlaySong( const char *alias ); +void MUSIC_UpdateMusicVolumes( void ); +void MUSIC_CheckForStoppedSongs( void ); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/code/client/snd_wavelet.c b/code/client/snd_wavelet.c new file mode 100644 index 00000000..101a7aa5 --- /dev/null +++ b/code/client/snd_wavelet.c @@ -0,0 +1,256 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "snd_local.h" + +#define C0 0.4829629131445341 +#define C1 0.8365163037378079 +#define C2 0.2241438680420134 +#define C3 -0.1294095225512604 + +void daub4( float b[], unsigned long n, int isign ) +{ + float wksp[ 4097 ] = { 0.0f }; + float *a = b - 1; // numerical recipies so a[1] = b[0] + + unsigned long nh, nh1, i, j; + + if( n < 4 ) return; + + nh1 = ( nh = n >> 1 ) + 1; + if( isign >= 0 ) { + for( i = 1, j = 1; j <= n - 3; j += 2, i++ ) { + wksp[ i ] = C0*a[ j ] + C1*a[ j + 1 ] + C2*a[ j + 2 ] + C3*a[ j + 3 ]; + wksp[ i + nh ] = C3*a[ j ] - C2*a[ j + 1 ] + C1*a[ j + 2 ] - C0*a[ j + 3 ]; + } + wksp[ i ] = C0*a[ n - 1 ] + C1*a[ n ] + C2*a[ 1 ] + C3*a[ 2 ]; + wksp[ i + nh ] = C3*a[ n - 1 ] - C2*a[ n ] + C1*a[ 1 ] - C0*a[ 2 ]; + } + else { + wksp[ 1 ] = C2*a[ nh ] + C1*a[ n ] + C0*a[ 1 ] + C3*a[ nh1 ]; + wksp[ 2 ] = C3*a[ nh ] - C0*a[ n ] + C1*a[ 1 ] - C2*a[ nh1 ]; + for( i = 1, j = 3; i= 0 ) { + for( nn = n; nn >= inverseStartLength; nn >>= 1 ) daub4( a, nn, isign ); + } + else { + for( nn = inverseStartLength; nn <= n; nn <<= 1 ) daub4( a, nn, isign ); + } +} + +/* The number of bits required by each value */ +static unsigned char numBits[] = { + 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, +}; + +byte MuLawEncode( short s ) { + unsigned long adjusted; + byte sign, exponent, mantissa; + + sign = ( s<0 ) ? 0 : 0x80; + + if( s<0 ) s = -s; + adjusted = ( long )s << ( 16 - sizeof( short ) * 8 ); + adjusted += 128L + 4L; + if( adjusted > 32767 ) adjusted = 32767; + exponent = numBits[ ( adjusted >> 7 ) & 0xff ] - 1; + mantissa = ( adjusted >> ( exponent + 3 ) ) & 0xf; + return ~( sign | ( exponent << 4 ) | mantissa ); +} + +short MuLawDecode( byte uLaw ) { + signed long adjusted; + byte exponent, mantissa; + + uLaw = ~uLaw; + exponent = ( uLaw >> 4 ) & 0x7; + mantissa = ( uLaw & 0xf ) + 16; + adjusted = ( mantissa << ( exponent + 3 ) ) - 128 - 4; + + return ( uLaw & 0x80 ) ? adjusted : -adjusted; +} + +short mulawToShort[ 256 ]; +static qboolean madeTable = qfalse; + +static int NXStreamCount; + +void NXPutc( NXStream *stream, char out ) { + stream[ NXStreamCount++ ] = out; +} + + +void encodeWavelet( sfx_t *sfx, short *packets ) { + float wksp[ 4097 ] = { 0 }, temp; + int i, samples, size; + sndBuffer *newchunk, *chunk; + byte *out; + + if( !madeTable ) { + for( i = 0; i<256; i++ ) { + mulawToShort[ i ] = ( float )MuLawDecode( ( byte )i ); + } + madeTable = qtrue; + } + chunk = NULL; + + samples = sfx->soundLength; + while( samples>0 ) { + size = samples; + if( size>( SND_CHUNK_SIZE * 2 ) ) { + size = ( SND_CHUNK_SIZE * 2 ); + } + + if( size<4 ) { + size = 4; + } + + newchunk = SND_malloc(); + if( sfx->soundData == NULL ) { + sfx->soundData = newchunk; + } + else if( chunk != NULL ) { + chunk->next = newchunk; + } + chunk = newchunk; + for( i = 0; isndChunk; + + for( i = 0; i 32767 ) temp = 32767; else if( temp<-32768 ) temp = -32768; + out[ i ] = MuLawEncode( ( short )temp ); + } + + chunk->size = size; + samples -= size; + } +} + +void decodeWavelet( sndBuffer *chunk, short *to ) { + float wksp[ 4097 ] = { 0 }; + int i; + byte *out; + + int size = chunk->size; + + out = ( byte * )chunk->sndChunk; + for( i = 0; isoundLength; + grade = 0; + + while( samples>0 ) { + size = samples; + if( size>( SND_CHUNK_SIZE * 2 ) ) { + size = ( SND_CHUNK_SIZE * 2 ); + } + + newchunk = SND_malloc(); + if( sfx->soundData == NULL ) { + sfx->soundData = newchunk; + } + else if( chunk != NULL ) { + chunk->next = newchunk; + } + chunk = newchunk; + out = ( byte * )chunk->sndChunk; + for( i = 0; i32767 ) { + poop = 32767; + } + else if( poop<-32768 ) { + poop = -32768; + } + out[ i ] = MuLawEncode( ( short )poop ); + grade = poop - mulawToShort[ out[ i ] ]; + packets++; + } + chunk->size = size; + samples -= size; + } +} + +void decodeMuLaw( sndBuffer *chunk, short *to ) { + int i; + byte *out; + + int size = chunk->size; + + out = ( byte * )chunk->sndChunk; + for( i = 0; i ptr; + + if( !object ) + return false; + + ptr = object; + + // don't add the same listener + if( m_listeners.ObjectInList( ptr ) ) + { + return false; + } + + m_listeners.AddUniqueObject( ptr ); + + e = new Event( ev ); + m_events.AddObject( e ); + + return true; +} + +bool UConnection::RemoveListener + ( + Listener *object + ) + +{ + int i; + ListenerPtr ptr; + + if( !object ) + return false; + + ptr = object; + + if( !m_listeners.ObjectInList( ptr ) ) + { + return false; + } + + i = m_listeners.IndexOfObject( ptr ); + delete m_events.ObjectAt( i ); + m_events.RemoveObjectAt( i ); + m_listeners.RemoveObjectAt( i ); + + return true; +} + +bool UConnection::SendEvent + ( + Listener *object, + Event& ev + ) + +{ + int n; + int i; + int j; + bool sent; + Listener *ptr; + int numargs; + + sent = false; + n = m_listeners.NumObjects(); + numargs = ev.NumArgs(); + + for( i = n; i > 0; i-- ) + { + ptr = m_listeners.ObjectAt( i ); + if( ptr ) + { + Event *e = new Event( m_events.ObjectAt( i ) ); + + for( j = 1; j < numargs; j++ ) + { + e->AddToken( ev.GetToken( j ) ); + } + + ptr->ProcessEvent( e ); + sent = true; + } + else + { + Event *e = m_events.ObjectAt( i ); + delete e; + + m_listeners.RemoveObjectAt( i ); + m_events.RemoveObjectAt( i ); + } + } + + return sent; +} + +CLASS_DECLARATION( Listener, USignal, NULL ) +{ + { NULL, NULL } +}; + +bool USignal::SendSignal + ( + Event& ev + ) + +{ + int i; + int n; + UConnection *c; + + n = m_connections.NumObjects(); + for( i = 1; i <= n; i++ ) + { + c = m_connections.ObjectAt( i ); + if( c->TypeIs( ev ) ) + { + return c->SendEvent( this, ev ); + } + } + + return false; +} + +bool USignal::Connect + ( + Listener *object, + Event& inevent, + Event& outevent + ) + +{ + int i; + int n; + UConnection *c; + + n = m_connections.NumObjects(); + for( i = 1; i <= n; i++ ) + { + c = m_connections.ObjectAt( i ); + if( c->TypeIs( inevent ) ) + { + return c->AddListener( object, outevent ); + } + } + + c = new UConnection; + m_connections.AddObject( c ); + + return c->AddListener( object, outevent ); +} + +bool USignal::Disconnect + ( + Listener *object, + Event& ev + ) + +{ + int i; + int n; + UConnection *c; + + n = m_connections.NumObjects(); + for( i = 1; i <= n; i++ ) + { + c = m_connections.ObjectAt( i ); + if( c->TypeIs( ev ) ) + { + return c->RemoveListener( object ); + } + } + + return false; +} + +bool USignal::Disconnect + ( + Listener *object + ) + +{ + int i; + int n; + bool result; + UConnection *c; + + result = false; + + n = m_connections.NumObjects(); + for( i = 1; i <= n; i++ ) + { + c = m_connections.ObjectAt( i ); + if( c->RemoveListener( object ) ) + { + result = true; + } + } + + return result; +} diff --git a/code/game/PlayerStart.cpp b/code/game/PlayerStart.cpp new file mode 100644 index 00000000..f88a53cc --- /dev/null +++ b/code/game/PlayerStart.cpp @@ -0,0 +1,215 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// PlayerStart.cpp: Player start location entity declarations +// + +#include "g_local.h" +#include "entity.h" +#include "trigger.h" +#include "PlayerStart.h" + +/*****************************************************************************/ +/*QUAKED info_player_start (0.75 0.75 0) (-16 -16 0) (16 16 96) + +The normal starting point for a level. + +"angle" - the direction the player should face +"thread" - the thread that should be called when spawned at this position + +******************************************************************************/ + +Event EV_PlayerStart_EnableSpawn +( + "enablespawn", + EV_DEFAULT, + NULL, + NULL, + "allows spawning from this spawnpoint" +); + +Event EV_PlayerStart_DisableSpawn +( + "disablespawn", + EV_DEFAULT, + NULL, + NULL, + "forbids spawning from this spawnpoint" +); + +Event EV_PlayerStart_DeleteOnSpawn +( + "deletespawn", + EV_DEFAULT, + NULL, + NULL, + "delete this spawnpoint when spawning from this spawnpoint" +); + +Event EV_PlayerStart_KeepOnSpawn +( + "keepspawn", + EV_DEFAULT, + NULL, + NULL, + "keep this spawnpoint when spawning from this spawnpoint" +); + +CLASS_DECLARATION( SimpleArchivedEntity, PlayerStart, "info_player_start" ) +{ + { &EV_SetAngle, &PlayerStart::SetAngle }, + { &EV_PlayerStart_EnableSpawn, &PlayerStart::EventEnableSpawn }, + { &EV_PlayerStart_DisableSpawn, &PlayerStart::EventDisableSpawn }, + { &EV_PlayerStart_DeleteOnSpawn, &PlayerStart::EventDeleteOnSpawn }, + { &EV_PlayerStart_KeepOnSpawn, &PlayerStart::EventKeepOnSpawn }, + { NULL, NULL } +}; + +PlayerStart::PlayerStart() +{ + m_bForbidSpawns = false; + m_bDeleteOnSpawn = false; +} + +void PlayerStart::SetAngle + ( + Event *ev + ) + +{ + angles = Vector( 0, ev->GetFloat( 1 ), 0 ); +} + +void PlayerStart::EventEnableSpawn + ( + Event *ev + ) + +{ + m_bForbidSpawns = false; +} + +void PlayerStart::EventDisableSpawn + ( + Event *ev + ) + +{ + m_bForbidSpawns = true; +} + +void PlayerStart::EventDeleteOnSpawn + ( + Event *ev + ) + +{ + m_bDeleteOnSpawn = true; +} + +void PlayerStart::EventKeepOnSpawn + ( + Event *ev + ) + +{ + m_bDeleteOnSpawn = false; +} + +/*****************************************************************************/ +/* saved out by quaked in region mode + +******************************************************************************/ + +CLASS_DECLARATION( PlayerStart, TestPlayerStart, "testplayerstart" ) + { + { NULL, NULL } + }; + +/*****************************************************************************/ +/*QUAKED info_player_deathmatch (0.75 0.75 1) (-16 -16 0) (16 16 96) + +potential spawning position for deathmatch games + +"angle" - the direction the player should face +"thread" - the thread that should be called when spawned at this position +"arena" - the arena that this start point is located in + +******************************************************************************/ + +CLASS_DECLARATION( PlayerStart, PlayerDeathmatchStart, "info_player_deathmatch" ) + { + { NULL, NULL } + }; + +/*****************************************************************************/ +/*QUAKED info_player_allied (0.75 0.75 1) (-16 -16 0) (16 16 96) + +potential spawning position for an allied player in a team games... ignored for FFA. + +"angle" - the direction the player should face +"thread" - the thread that should be called when spawned at this position +"arena" - the arena that this start point is located in + +******************************************************************************/ + +CLASS_DECLARATION( PlayerDeathmatchStart, PlayerAlliedDeathmatchStart, "info_player_allied" ) +{ + { NULL, NULL } +}; + +/*****************************************************************************/ +/*QUAKED info_player_axis (0.75 0.75 1) (-16 -16 0) (16 16 96) + +potential spawning position for an axis player in a team games... ignored for FFA. + +"angle" - the direction the player should face +"thread" - the thread that should be called when spawned at this position +"arena" - the arena that this start point is located in + +******************************************************************************/ + +CLASS_DECLARATION( PlayerDeathmatchStart, PlayerAxisDeathmatchStart, "info_player_axis" ) +{ + { NULL, NULL } +}; + +/*****************************************************************************/ +/*QUAKED info_player_intermission (0.75 0.75 0) (-16 -16 0) (16 16 96) + +viewing point in between deathmatch levels + +******************************************************************************/ + +CLASS_DECLARATION( Camera, PlayerIntermission, "info_player_intermission" ) + { + { NULL, NULL } + }; + +PlayerIntermission::PlayerIntermission + ( + ) + + { + currentstate.watch.watchPath = false; + } + diff --git a/code/game/PlayerStart.h b/code/game/PlayerStart.h new file mode 100644 index 00000000..0bef5dd7 --- /dev/null +++ b/code/game/PlayerStart.h @@ -0,0 +1,93 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// PlayerStart.h: Player start location entity declarations +// + +#ifndef __PLAYERSTART_H__ +#define __PLAYERSTART_H__ + +#include "g_local.h" +#include "simpleentity.h" +#include "camera.h" +#include "navigate.h" + +class PlayerStart : public SimpleArchivedEntity +{ +public: + bool m_bForbidSpawns; + bool m_bDeleteOnSpawn; + +public: + CLASS_PROTOTYPE( PlayerStart ); + + PlayerStart(); + + virtual void Archive( Archiver &arc ); + + void SetAngle( Event *ev ); + void EventEnableSpawn( Event *ev ); + void EventDisableSpawn( Event *ev ); + void EventDeleteOnSpawn( Event *ev ); + void EventKeepOnSpawn( Event *ev ); +}; + +inline void PlayerStart::Archive( Archiver &arc ) +{ + SimpleArchivedEntity::Archive( arc ); + + arc.ArchiveBool( &m_bForbidSpawns ); + arc.ArchiveBool( &m_bDeleteOnSpawn ); +} + +class TestPlayerStart : public PlayerStart + { + public: + CLASS_PROTOTYPE( TestPlayerStart ); + }; + +class PlayerDeathmatchStart : public PlayerStart + { + public: + CLASS_PROTOTYPE( PlayerDeathmatchStart ); + }; + +class PlayerAlliedDeathmatchStart : public PlayerDeathmatchStart +{ +public: + CLASS_PROTOTYPE( PlayerAlliedDeathmatchStart ); +}; + +class PlayerAxisDeathmatchStart : public PlayerDeathmatchStart +{ +public: + CLASS_PROTOTYPE( PlayerAxisDeathmatchStart ); +}; + +class PlayerIntermission : public Camera + { + public: + CLASS_PROTOTYPE( PlayerIntermission ); + PlayerIntermission(); + }; + +#endif /* PlayerStart.h */ diff --git a/code/game/VehicleCollisionEntity.cpp b/code/game/VehicleCollisionEntity.cpp new file mode 100644 index 00000000..83373a6f --- /dev/null +++ b/code/game/VehicleCollisionEntity.cpp @@ -0,0 +1,99 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// VehicleCollisionEntity.cpp : MOHAA Vehicle Collision + +#include "VehicleCollisionEntity.h" + +CLASS_DECLARATION( Entity, VehicleCollisionEntity, NULL ) +{ + { &EV_Damage, &VehicleCollisionEntity::EventDamage }, + { NULL, NULL } +}; + +VehicleCollisionEntity::VehicleCollisionEntity + ( + Entity *ent + ) + +{ + if( LoadingSavegame ) + { + return; + } + + edict->s.eType = ET_GENERAL; + + m_pOwner = ent; + takedamage = DAMAGE_YES; + + edict->s.renderfx &= ~RF_DONTDRAW; + edict->r.svFlags &= ~SVF_NOCLIENT; + + setMoveType( MOVETYPE_PUSH ); + + edict->clipmask |= MASK_CLIP; + edict->s.eFlags |= EF_LINKANGLES; +} + +VehicleCollisionEntity::VehicleCollisionEntity + ( + void + ) + +{ + if( LoadingSavegame ) + { + return; + } + + gi.Error( ERR_DROP, "VehicleCollisionEntity Created with no parameters!\n" ); +} + +void VehicleCollisionEntity::EventDamage + ( + Event *ev + ) + +{ + Event *event = new Event( ev ); + + m_pOwner->ProcessEvent( event ); +} + +void VehicleCollisionEntity::Solid + ( + void + ) + +{ + setContents( CONTENTS_SOLID ); + setSolidType( SOLID_BSP ); +} + +void VehicleCollisionEntity::NotSolid + ( + void + ) + +{ + setSolidType( SOLID_NOT ); +} diff --git a/code/game/VehicleCollisionEntity.h b/code/game/VehicleCollisionEntity.h new file mode 100644 index 00000000..1fdfc66a --- /dev/null +++ b/code/game/VehicleCollisionEntity.h @@ -0,0 +1,61 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// VehicleCollisionEntity.h : MOHAA vehicle collision + +#ifndef __VEHICLECOLLISIONENTITY_H__ +#define __VEHICLECOLLISIONENTITY_H__ + +#include "entity.h" + +class VehicleCollisionEntity : public Entity +{ +private: + EntityPtr m_pOwner; + +private: + void EventDamage( Event *ev ); + +public: + CLASS_PROTOTYPE( VehicleCollisionEntity ); + + VehicleCollisionEntity( Entity *ent ); + VehicleCollisionEntity(); + + virtual void Archive( Archiver& arc ); + + void Solid( void ); + void NotSolid( void ); +}; + +inline +void VehicleCollisionEntity::Archive + ( + Archiver& arc + ) + +{ + Entity::Archive( arc ); + + arc.ArchiveSafePointer( &m_pOwner ); +} + +#endif // __VEHICLECOLLISIONENTITY_H__ \ No newline at end of file diff --git a/code/game/VehicleSlot.cpp b/code/game/VehicleSlot.cpp new file mode 100644 index 00000000..ba5cf3d3 --- /dev/null +++ b/code/game/VehicleSlot.cpp @@ -0,0 +1,162 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// VehicleSlot.cpp +// + +#include "VehicleSlot.h" +#include "weapturret.h" + +cVehicleSlot::cVehicleSlot() +{ + prev_takedamage = ( damage_t )-1; + prev_solid = ( solid_t )-1; + prev_contents = -1; +} + +void cVehicleSlot::NotSolid + ( + void + ) + +{ + if( !( flags & FL_SWIM ) ) + { + return; + } + + if( !ent ) + { + return; + } + + // Save previous values + prev_takedamage = ent->takedamage; + prev_solid = ent->edict->solid; + prev_contents = ent->edict->r.contents; + + ent->takedamage = DAMAGE_NO; + ent->setSolidType( SOLID_NOT ); +} + +void cVehicleSlot::Solid + ( + void + ) + +{ + if( !( flags & FL_SWIM ) ) + { + return; + } + + if( !ent ) + { + return; + } + + // Restore previous values + ent->takedamage = prev_takedamage; + ent->setSolidType( prev_solid ); + ent->edict->r.contents = prev_contents; + + // Save previous values + prev_takedamage = ( damage_t )-1; + prev_solid = ( solid_t )-1; + prev_contents = -1; +} + +cTurretSlot::cTurretSlot() +{ + owner_prev_takedamage = ( damage_t )-1; + owner_prev_solid = ( solid_t )-1; + owner_prev_contents = -1; +} + +void cTurretSlot::NotSolid + ( + void + ) + +{ + if( !( flags & FL_SWIM ) ) + { + return; + } + + if( !ent ) + { + return; + } + + cVehicleSlot::NotSolid(); + + if( ent->IsSubclassOfTurretGun() ) + { + TurretGun *turret = ( TurretGun * )ent.Pointer(); + Entity *owner = turret->GetOwner(); + + if( owner ) + { + owner_prev_takedamage = owner->takedamage; + owner_prev_solid = owner->edict->solid; + owner_prev_contents = owner->edict->r.contents; + + owner->takedamage = DAMAGE_NO; + owner->setSolidType( SOLID_NOT ); + } + } +} + +void cTurretSlot::Solid + ( + void + ) + +{ + if( !( flags & FL_SWIM ) ) + { + return; + } + + if( !ent ) + { + return; + } + + cVehicleSlot::NotSolid(); + + if( ent->IsSubclassOfTurretGun() ) + { + TurretGun *turret = ( TurretGun * )ent.Pointer(); + Entity *owner = turret->GetOwner(); + + if( owner ) + { + owner->takedamage = owner_prev_takedamage; + owner->setSolidType( owner_prev_solid ); + + owner_prev_takedamage = ( damage_t )-1; + owner_prev_solid = ( solid_t )-1; + } + } +} diff --git a/code/game/VehicleSlot.h b/code/game/VehicleSlot.h new file mode 100644 index 00000000..1f04c73b --- /dev/null +++ b/code/game/VehicleSlot.h @@ -0,0 +1,102 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// VehicleSlot.h +// + +#ifndef __VEHICLESLOT_H__ +#define __VEHICLESLOT_H__ + +#include "g_local.h" +#include "class.h" +#include "entity.h" + +#define SLOT_FREE 1 +#define SLOT_BUSY 2 +#define SLOT_UNUSED 4 + +class cVehicleSlot : public Class { +public: + SafePtr ent; + int flags; + int boneindex; + int enter_boneindex; + +private: + damage_t prev_takedamage; + solid_t prev_solid; + int prev_contents; + +public: + cVehicleSlot(); + + virtual void NotSolid( void ); + virtual void Solid( void ); + virtual void Archive( Archiver& arc ); +}; + +inline +void cVehicleSlot::Archive + ( + Archiver& arc + ) + +{ + Class::Archive( arc ); + + arc.ArchiveSafePointer( &ent ); + arc.ArchiveInteger( &flags ); + arc.ArchiveInteger( &boneindex ); + arc.ArchiveInteger( &enter_boneindex ); + ArchiveEnum( prev_takedamage, damage_t ); + ArchiveEnum( prev_solid, solid_t ); + arc.ArchiveInteger( &prev_contents ); +} + +class cTurretSlot : public cVehicleSlot { + damage_t owner_prev_takedamage; + solid_t owner_prev_solid; + int owner_prev_contents; + +public: + cTurretSlot(); + + virtual void NotSolid( void ); + virtual void Solid( void ); + virtual void Archive( Archiver& arc ); +}; + +inline +void cTurretSlot::Archive + ( + Archiver& arc + ) + +{ + cVehicleSlot::Archive( arc ); + + ArchiveEnum( owner_prev_takedamage, damage_t ); + ArchiveEnum( owner_prev_solid, solid_t ); + arc.ArchiveInteger( &owner_prev_contents ); +} + +#endif // __VEHICLESLOT_H__ diff --git a/code/game/VehicleSoundEntity.cpp b/code/game/VehicleSoundEntity.cpp new file mode 100644 index 00000000..c199e31b --- /dev/null +++ b/code/game/VehicleSoundEntity.cpp @@ -0,0 +1,188 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// VehicleSoundENtity.cpp : Make sounds for vehicles + +#include "VehicleSoundEntity.h" +#include "weapon.h" +#include "vehicle.h" + +Event EV_VehicleSoundEntity_PostSpawn + ( + "vehiclesoundentity_post", + EV_DEFAULT, + NULL, + NULL, + "PostSpawn of a Vehicle Sound Entity" + ); + +Event EV_VehicleSoundEntity_UpdateTraces + ( + "vehiclesoudnentity_updatetraces", + EV_DEFAULT, + NULL, + NULL, + "Updates the traces of a Vehicle Sound Entity" + ); + +CLASS_DECLARATION( Entity, VehicleSoundEntity, NULL ) +{ + { &EV_VehicleSoundEntity_PostSpawn, &VehicleSoundEntity::EventPostSpawn }, + { &EV_VehicleSoundEntity_UpdateTraces, &VehicleSoundEntity::EventUpdateTraces }, + { NULL, NULL } +}; + +VehicleSoundEntity::VehicleSoundEntity() +{ + if( LoadingSavegame ) + { + return; + } + + gi.Error( ERR_DROP, "VehicleSoundEntity Created with no parameters!\n" ); +} + +VehicleSoundEntity::VehicleSoundEntity( Vehicle *owner ) +{ + m_pVehicle = owner; + m_bDoSoundStuff = false; + m_iTraceSurfaceFlags = 0; + + PostEvent( EV_VehicleSoundEntity_PostSpawn, EV_POSTSPAWN ); +} + +void VehicleSoundEntity::Start + ( + void + ) + +{ + m_bDoSoundStuff = true; +} + +void VehicleSoundEntity::Stop + ( + void + ) + +{ + m_bDoSoundStuff = false; +} + +void VehicleSoundEntity::Think + ( + void + ) + +{ + DoSoundStuff(); +} + +void VehicleSoundEntity::EventPostSpawn + ( + Event *ev + ) +{ + setModel( "models/vehicles/vehiclesoundentity.tik" ); + + PostEvent( EV_VehicleSoundEntity_UpdateTraces, 1.0f ); + flags |= FL_THINK; +} + +void VehicleSoundEntity::EventUpdateTraces + ( + Event *ev + ) +{ + if( m_bDoSoundStuff ) + { + m_pVehicle->SetSlotsNonSolid(); + + trace_t trace = G_Trace( + origin, + vec3_origin, + vec3_origin, + Vector( origin[ 0 ], origin[ 1 ], origin[ 2 ] - 256.0f ), + m_pVehicle->edict, + MASK_SOUND, + qfalse, + "VehicleSoundEntity::DoSoundStuff" + ); + + if( trace.fraction >= 1.0f ) + m_iTraceSurfaceFlags = 0; + else + m_iTraceSurfaceFlags = trace.surfaceFlags; + + m_pVehicle->SetSlotsSolid(); + } + + PostEvent( EV_VehicleSoundEntity_UpdateTraces, 1.0f ); +} + +void VehicleSoundEntity::DoSoundStuff + ( + void + ) + +{ + float pitch; + + if( !m_bDoSoundStuff ) + { + StopLoopSound(); + return; + } + + pitch = ( velocity.length() - m_pVehicle->m_fSoundMinSpeed ) / ( m_pVehicle->m_fSoundMaxSpeed - m_pVehicle->m_fSoundMinSpeed ); + if( pitch > 1.0f ) { + pitch = 1.0f; + } else if( pitch < 0.0f ) { + pitch = 0.0f; + } + + pitch *= m_pVehicle->m_fSoundMinPitch + ( m_pVehicle->m_fSoundMaxPitch - m_pVehicle->m_fSoundMinPitch ); + + if( m_iTraceSurfaceFlags & SURF_DIRT ) + { + LoopSound( m_pVehicle->m_sSoundSet + "treat_snd_dirt", -1.0f, -1.0f, -1.0f, pitch ); + } + else if( m_iTraceSurfaceFlags & SURF_GRASS ) + { + LoopSound( m_pVehicle->m_sSoundSet + "treat_snd_grass", -1.0f, -1.0f, -1.0f, pitch ); + } + else if( m_iTraceSurfaceFlags & SURF_WOOD ) + { + LoopSound( m_pVehicle->m_sSoundSet + "treat_snd_wood", -1.0f, -1.0f, -1.0f, pitch ); + } + else if( m_iTraceSurfaceFlags & SURF_MUD ) + { + LoopSound( m_pVehicle->m_sSoundSet + "treat_snd_mud", -1.0f, -1.0f, -1.0f, pitch ); + } + else if( m_iTraceSurfaceFlags & ( SURF_GRAVEL | SURF_ROCK ) ) + { + LoopSound( m_pVehicle->m_sSoundSet + "treat_snd_stone", -1.0f, -1.0f, -1.0f, pitch ); + } + else + { + StopLoopSound(); + } +} diff --git a/code/game/VehicleSoundEntity.h b/code/game/VehicleSoundEntity.h new file mode 100644 index 00000000..bac4d179 --- /dev/null +++ b/code/game/VehicleSoundEntity.h @@ -0,0 +1,68 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// VehicleSoundEntity.h : Sound helper for vehicles + +#ifndef __VEHICLESOUNDENTITY_H__ +#define __VEHICLESOUNDENTITY_H__ + +#include "entity.h" + +class Vehicle; + +class VehicleSoundEntity : public Entity { +private: + SafePtr m_pVehicle; + bool m_bDoSoundStuff; + int m_iTraceSurfaceFlags; + +public: + CLASS_PROTOTYPE( VehicleSoundEntity ); + + VehicleSoundEntity(); + VehicleSoundEntity( Vehicle *owner ); + + void Start( void ); + void Stop( void ); + virtual void Think( void ); + virtual void Archive( Archiver& arc ); + +private: + void EventPostSpawn( Event *ev ); + void EventUpdateTraces( Event *ev ); + void DoSoundStuff( void ); +}; + +inline +void VehicleSoundEntity::Archive + ( + Archiver& arc + ) + +{ + Entity::Archive( arc ); + + arc.ArchiveSafePointer( &m_pVehicle ); + arc.ArchiveBool( &m_bDoSoundStuff ); + arc.ArchiveInteger( &m_iTraceSurfaceFlags ); +} + +#endif // __VEHICLECOLLISIONENTITY_H__ \ No newline at end of file diff --git a/code/game/actor.cpp b/code/game/actor.cpp new file mode 100644 index 00000000..267671d7 --- /dev/null +++ b/code/game/actor.cpp @@ -0,0 +1,6802 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor.cpp: Base class for character AI. + +#include "g_local.h" +#include "actor.h" +#include "scriptmaster.h" +#include "doors.h" +#include "gibs.h" +#include "misc.h" +#include "specialfx.h" +#include "object.h" +#include "scriptslave.h" +#include "explosion.h" +#include "misc.h" +#include "playerstart.h" +#include "characterstate.h" +#include "weaputils.h" +#include "player.h" +#include + +Event EV_Actor_SetGun + ( + "gun", + EV_DEFAULT, + "s", + "s", + "specifies the gun to use" + ); + +Event EV_Actor_SetGun2 + ( + "gun", + EV_DEFAULT, + "s", + "s", + "specifies the gun to use", + EV_SETTER + ); + +Event EV_Actor_GetGun + ( + "gun", + EV_DEFAULT, + NULL, + NULL, + "gets the gun to being used", + 2 + ); + +Event EV_Actor_WeaponInternal + ( + "weapon_internal", + EV_DEFAULT, + "s", + "s", + "internal use" + ); + +Event EV_Actor_TestAnim + ( + "testanim", + EV_DEFAULT, + NULL, + NULL, + "", + 0 + ); + +Event EV_Actor_DistToEnemy + ( + "distancetoenemy", + EV_DEFAULT, + NULL, + NULL, + "Get the distance from the Actor to its enemy", + EV_GETTER + ); + +Event EV_Actor_MoveTo + ( + "moveto", + EV_DEFAULT, + "ss", + "anim dest", + "Specify the location to move to, with animation anim." + ); + +Event EV_Actor_WalkTo + ( + "walkto", + EV_DEFAULT, + "s", + "dest", + "Specify the location to walk to." + ); + +Event EV_Actor_RunTo + ( + "runto", + EV_DEFAULT, + "s", + "dest", + "Specify the location to run to." + ); + +Event EV_Actor_CrouchTo + ( + "crouchto", + EV_DEFAULT, + "s", + "dest", + "Specify the location to crouch to." + ); + +Event EV_Actor_CrawlTo + ( + "crawlto", + EV_DEFAULT, + "s", + "dest", + "Specify the location to crawl to." + ); + +Event EV_Actor_AimAt + ( + "aimat", + EV_DEFAULT, + "s", + "target", + "Specify the target to aim at." + ); + +Event EV_Actor_Follow + ( + "follow", + EV_DEFAULT, + "e", + "entity", + "Specify the entity to follow." + ); + +Event EV_Actor_DeathEmbalm + ( + "deathembalm", + EV_DEFAULT, + NULL, + NULL, + "preps the dead actor for turning nonsolid gradually over time" + ); + +Event EV_Actor_Anim + ( + "anim", + EV_DEFAULT, + "s", + "name", + "Play animation." + ); + +Event EV_Actor_Anim_Scripted + ( + "anim_scripted", + EV_DEFAULT, + "s", + "name", + "Play scripted animation." + ); + +Event EV_Actor_Anim_Noclip + ( + "anim_noclip", + EV_DEFAULT, + "s", + "name", + "Play noclip animation." + ); + +Event EV_Actor_AnimLoop + ( + "animloop", + EV_DEFAULT, + "s", + "name", + "Loop animation." + ); + +Event EV_Actor_AnimScript + ( + "animscript", + EV_DEFAULT, + "s", + "name", + "Play the animation script" + ); + +Event EV_Actor_AnimScript_Scripted + ( + "animscript_scripted", + EV_DEFAULT, + "s", + "name", + "Play the scripted animation script" + ); + +Event EV_Actor_AnimScript_Noclip + ( + "animscript_noclip", + EV_DEFAULT, + "s", + "name", + "Play the noclip animation script" + ); + +Event EV_Actor_Reload_mg42 + ( + "reload_mg42", + EV_DEFAULT, + NULL, + NULL, + "Reload the mg42 - only used by machinegunner" + ); + +Event EV_Actor_Dumb + ( + "dumb", + EV_DEFAULT, + NULL, + NULL, + "Make Actor dumb." + ); + +Event EV_Actor_Physics_On + ( + "physics_on", + EV_DEFAULT, + NULL, + NULL, + "turn physics on." + ); + +Event EV_Actor_Physics_Off + ( + "physics_off", + EV_DEFAULT, + NULL, + NULL, + "turn physics off." + ); + +Event EV_Actor_SetAnim + ( + "setanim", + EV_DEFAULT, + "sifs", + "anim slot weight flagged", + "Set animation slot" + ); + +Event EV_Actor_SetAnimLength + ( + "setanimlength", + EV_DEFAULT, + "f", + "time", + "Set the maximum time an animation will play" + ); + +Event EV_Actor_EndActionAnim + ( + "endactionanim", + EV_DEFAULT, + "", + "", + "End any aiming/action animation which is currently playing" + ); + +Event EV_Actor_SetMotionAnim + ( + "setmotionanim", + EV_DEFAULT, + "s", + "anim", + "Set motion animation (handler scripts only)" + ); + +Event EV_Actor_SetAimMotionAnim + ( + "setaimmotionanim", + EV_DEFAULT, + "ss", + "anim_crouch anim_stand", + "Set aim motion animation (handler scripts only)" + ); + + + +Event EV_Actor_SetActionAnim + ( + "setactionanim", + EV_DEFAULT, + "sff", + "base_anim lower_limit upper_limit", + "Set the base action animation and range that they cover" + ); + +Event EV_Actor_UpperAnim + ( + "upperanim", + EV_DEFAULT, + "s", + "anim", + "Set the upper body " + ); + +Event EV_Actor_SetUpperAnim + ( + "setupperanim", + EV_DEFAULT, + "s", + "anim", + "Set the upper body animation - used by animation script only" + ); + +Event EV_Actor_SetCrossblendTime + ( + "blendtime", + EV_DEFAULT, + NULL, + NULL, + "Set the crossblend time to something other than the default, in seconds", + EV_SETTER + ); + +Event EV_Actor_GetCrossblendTime + ( + "blendtime", + EV_DEFAULT, + NULL, + NULL, + "Get the crossblend time", + EV_GETTER + ); + +Event EV_Actor_SetPosition + ( + "position", + EV_DEFAULT, + NULL, + NULL, + "The Position the Actor wants to be and should animate towards", + EV_SETTER + ); + +Event EV_Actor_GetPosition + ( + "position", + EV_DEFAULT, + NULL, + NULL, + "The Position the Actor wants to be and should animate towards", + EV_GETTER + ); + +Event EV_Actor_SetEmotion + ( + "emotion", + EV_DEFAULT, + NULL, + NULL, + "The method of setting the facial expression of the Actor", + EV_SETTER + ); + +Event EV_Actor_SetAnimFinal + ( + "animfinal", + EV_DEFAULT, + NULL, + NULL, + "Whether the animation was succesfully finished", + EV_SETTER + ); + +Event EV_Actor_GetWeaponType + ( + "weapontype", + EV_DEFAULT, + NULL, + NULL, + "The Weapon Type of the ", + EV_GETTER + ); + +Event EV_Actor_GetWeaponGroup + ( + "weapongroup", + EV_DEFAULT, + NULL, + NULL, + "Specifies weapon animation set to use in anim scripts", + EV_GETTER + ); + +Event EV_Entity_Start + ( + "entitystart", + EV_DEFAULT, + NULL, + NULL, + "Initialize a Actor." + ); + +Event EV_Actor_LookAt + ( + "lookat", + EV_DEFAULT, + "e", + "entity", + "The actor will look at this entity." + ); + +Event EV_Actor_EyesLookAt + ( + "eyeslookat", + EV_DEFAULT, + "e", + "entity", + "The actor will look at this entity." + ); + +Event EV_Actor_PointAt + ( + "pointat", + EV_DEFAULT, + "e", + "entity", + "The actor will point at this entity." + ); + +Event EV_Actor_TurnTo + ( + "turnto", + EV_DEFAULT, + "e", + "entity", + "The actor will turn to this entity." + ); + +Event EV_Actor_SetTurnDoneError + ( + "turndoneerror", + EV_DEFAULT, + "f", + "error", + "The error amount that turndone will occur for the turnto command." + ); + +Event EV_Actor_SetTurnDoneError2 + ( + "turndoneerror", + EV_DEFAULT, + "f", + "error", + "The error amount that turndone will occur for the turnto command.", + EV_SETTER + ); + +Event EV_Actor_GetTurnDoneError + ( + "turndoneerror", + EV_DEFAULT, + NULL, + NULL, + "The error amount that turndone will occur for the turnto command.", + EV_GETTER + ); + +Event EV_Actor_IdleSayAnim + ( + "idlesay", + EV_DEFAULT, + "s", + "animation", + "The name of an idle dialog animation to play" + ); + +Event EV_Actor_SayAnim + ( + "say", + EV_DEFAULT, + "s", + "animation", + "The name of a dialog animation to play" + ); + +Event EV_Actor_SetSayAnim + ( + "setsay", + EV_DEFAULT, + "s", + "animation", + "The name of a dialog animation to play - used by animation script only" + ); + +Event EV_Actor_DamagePuff + ( + "damagepuff", + EV_DEFAULT, + "vv", + "position direction", + "Spawns a puff of 'blood' smoke at the speficied location in the specified direction." + ); + +Event EV_Actor_SetAngleYawSpeed + ( + "turnspeed", + EV_DEFAULT, + "f", + "speed", + "The turn speed of the actor.", + EV_SETTER + ); + +Event EV_Actor_SetAngleYawSpeed2 + ( + "turnspeed", + EV_DEFAULT, + "f", + "speed", + "The turn speed of the actor." + ); + +Event EV_Actor_GetAngleYawSpeed + ( + "turnspeed", + EV_DEFAULT, + NULL, + NULL, + "The turn speed of the actor.", + EV_GETTER + ); + +Event EV_Actor_SetAimTarget + ( + "setaimtarget", + EV_DEFAULT, + "e", + "entity", + "Sets the primary weapon's aim target." + ); + +Event EV_Actor_ReadyToFire + ( + "ReadyToFire", + EV_DEFAULT, + NULL, + NULL, + "Returns if ready to fire", + EV_RETURN + ); + +Event EV_Actor_AIOff + ( + "ai_off", + EV_DEFAULT, + NULL, + NULL, + "Turns the AI off for this actor." + ); + +Event EV_Actor_AIOn + ( + "ai_on", + EV_DEFAULT, + NULL, + NULL, + "Turns the AI on for this actor." + ); + +Event EV_Actor_GetLocalYawFromVector + ( + "GetLocalYawFromVector", + EV_DEFAULT, + NULL, + NULL, + "Turn a worldspace vector into a local space yaw", + EV_RETURN + ); + +Event EV_Actor_GetSight + ( + "sight", + EV_DEFAULT, + NULL, + NULL, + "Gets the vision distance of the actor.", + EV_GETTER + ); + +Event EV_Actor_SetSight + ( + "sight", + EV_DEFAULT, + "f", + "max_sight_range", + "Sets the vision distance of the actor.", + EV_SETTER + ); + +Event EV_Actor_SetSight2 + ( + "sight", + EV_DEFAULT, + "f", + "max_sight_range", + "Sets the vision distance of the actor." + ); + +Event EV_Actor_GetHearing + ( + "hearing", + EV_DEFAULT, + "f", + "radius", + "The hearing radius of the actor", + EV_GETTER + ); + +Event EV_Actor_SetHearing + ( + "hearing", + EV_DEFAULT, + "f", + "radius", + "The hearing radius of the actor" + ); + +Event EV_Actor_SetHearing2 + ( + "hearing", + EV_DEFAULT, + "f", + "radius", + "The hearing radius of the actor", + EV_SETTER + ); + +Event EV_Actor_GetFov + ( + "fov", + EV_DEFAULT, + NULL, + NULL, + "The fov angle of the actor", + EV_GETTER + ); + +Event EV_Actor_SetFov + ( + "fov", + EV_DEFAULT, + "f", + "angle", + "The fov angle of the actor" + ); + +Event EV_Actor_SetFov2 + ( + "fov", + EV_DEFAULT, + "f", + "angle", + "The fov angle of the actor", + EV_SETTER + ); + +Event EV_Actor_SetTypeIdle + ( + "type_idle", + EV_DEFAULT, + "s", + "value", + "Sets the idle type of the actor." + ); + +Event EV_Actor_SetTypeIdle2 + ( + "type_idle", + EV_DEFAULT, + "s", + "value", + "Sets the idle type of the actor.", + EV_SETTER + ); + +Event EV_Actor_GetTypeIdle + ( + "type_idle", + EV_DEFAULT, + NULL, + NULL, + "Gets the idle type of the actor.", + EV_GETTER + ); + +Event EV_Actor_SetTypeAttack + ( + "type_attack", + EV_DEFAULT, + "s", + "value", + "Sets the attack type of the actor." + ); + +Event EV_Actor_SetTypeAttack2 + ( + "type_attack", + EV_DEFAULT, + "s", + "value", + "Sets the attack type of the actor.", + EV_SETTER + ); + +Event EV_Actor_GetTypeAttack + ( + "type_attack", + EV_DEFAULT, + NULL, + NULL, + "Gets the attack type of the actor.", + EV_GETTER + ); + +Event EV_Actor_SetTypeDisguise + ( + "type_disguise", + EV_DEFAULT, + "s", + "value", + "Sets the disguise type of the actor." + ); + +Event EV_Actor_SetTypeDisguise2 + ( + "type_disguise", + EV_DEFAULT, + "s", + "value", + "Sets the disguise type of the actor.", + EV_SETTER + ); + +Event EV_Actor_GetTypeDisguise + ( + "type_disguise", + EV_DEFAULT, + NULL, + NULL, + "Gets the disguise type of the actor.", + EV_GETTER + ); + +Event EV_Actor_SetDisguiseLevel + ( + "disguise_level", + EV_DEFAULT, + "i", + "value", + "Sets the disguise level of the actor. May be 1 or 2" + ); + +Event EV_Actor_SetDisguiseLevel2 + ( + "disguise_level", + EV_DEFAULT, + "i", + "value", + "Sets the disguise level of the actor. May be 1 or 2", + EV_SETTER + ); + +Event EV_Actor_GetDisguiseLevel + ( + "disguise_level", + EV_DEFAULT, + NULL, + NULL, + "Gets the disguise level of the actor. May be 1 or 2", + EV_GETTER + ); + +Event EV_Actor_SetTypeGrenade + ( + "type_grenade", + EV_DEFAULT, + "s", + "value", + "Sets the grenade type of the actor." + ); + +Event EV_Actor_SetTypeGrenade2 + ( + "type_grenade", + EV_DEFAULT, + "s", + "value", + "Sets the grenade type of the actor.", + EV_SETTER + ); + +Event EV_Actor_GetTypeGrenade + ( + "type_grenade", + EV_DEFAULT, + NULL, + NULL, + "Gets the grenade type of the actor.", + EV_GETTER + ); + +Event EV_Actor_SetPatrolPath + ( + "patrolpath", + EV_DEFAULT, + "s", + "value", + "Sets the name of the patrol path for the actor (must have type set to patrol for effect)" + ); + +Event EV_Actor_SetPatrolPath2 + ( + "patrolpath", + EV_DEFAULT, + "s", + "value", + "Sets the name of the patrol path for the actor (must have type set to patrol for effect)", + EV_SETTER + ); + +Event EV_Actor_GetPatrolPath + ( + "patrolpath", + EV_DEFAULT, + NULL, + NULL, + "Gets the name of the patrol path for the actor (must have type set to patrol for effect)", + EV_GETTER + ); + +Event EV_Actor_SetPatrolWaitTrigger + ( + "waittrigger", + EV_DEFAULT, + "b", + "bool", + "If true, patrol guys and running men wait until triggered to move" + ); + +Event EV_Actor_SetPatrolWaitTrigger2 + ( + "waittrigger", + EV_DEFAULT, + "b", + "bool", + "If true, patrol guys and running men wait until triggered to move", + EV_SETTER + ); + +Event EV_Actor_GetPatrolWaitTrigger + ( + "waittrigger", + EV_DEFAULT, + NULL, + NULL, + "If true, patrol guys and running men wait until triggered to move", + EV_GETTER + ); + +Event EV_Actor_SetAlarmNode + ( + "alarmnode", + EV_DEFAULT, + "s", + "value", + "Sets the name of the alarm node for the actor (must have type set to alarm for effect)" + ); + +Event EV_Actor_SetAlarmNode2 + ( + "alarmnode", + EV_DEFAULT, + "s", + "value", + "Sets the name of the alarm node for the actor (must have type set to alarm for effect)", + EV_SETTER + ); + +Event EV_Actor_GetAlarmNode + ( + "alarmnode", + EV_DEFAULT, + NULL, + NULL, + "Gets the name of the alarm node for the actor (must have type set to alarm for effect)", + EV_GETTER + ); + +Event EV_Actor_SetAlarmThread + ( + "alarmthread", + EV_DEFAULT, + "s", + "value", + "Sets the name of the alarm thread for the actor (must have type set to alarm for effect)" + ); + +Event EV_Actor_SetAlarmThread2 + ( + "alarmthread", + EV_DEFAULT, + "s", + "value", + "Sets the name of the alarm thread for the actor (must have type set to alarm for effect)", + EV_SETTER + ); + +Event EV_Actor_GetAlarmThread + ( + "alarmthread", + EV_DEFAULT, + NULL, + NULL, + "Gets the name of the alarm thread for the actor (must have type set to alarm for effect)", + EV_GETTER + ); + +Event EV_Actor_SetDisguiseAcceptThread + ( + "disguise_accept_thread", + EV_DEFAULT, + "s", + "value", + "Sets the name of the thread for the actor to start when accepting papers" + ); + +Event EV_Actor_SetDisguiseAcceptThread2 + ( + "disguise_accept_thread", + EV_DEFAULT, + "s", + "value", + "Sets the name of the thread for the actor to start when accepting papers", + EV_SETTER + ); + +Event EV_Actor_GetDisguiseAcceptThread + ( + "disguise_accept_thread", + EV_DEFAULT, + NULL, + NULL, + "Gets the name of the thread for the actor to start when accepting papers", + EV_GETTER + ); + +Event EV_Actor_SetAccuracy + ( + "accuracy", + EV_DEFAULT, + "f", + "value", + "Set percent to hit" + ); + +Event EV_Actor_SetAccuracy2 + ( + "accuracy", + EV_DEFAULT, + "f", + "value", + "Set percent to hit", + EV_SETTER + ); + +Event EV_Actor_GetAccuracy + ( + "accuracy", + EV_DEFAULT, + NULL, + NULL, + "Set percent to hit", + EV_GETTER + ); + +Event EV_Actor_SetMinDistance + ( + "mindist", + EV_DEFAULT, + "f", + "distance", + "Sets the minimum distance the AI tries to keep between itself and the player" + ); + +Event EV_Actor_SetMinDistance2 + ( + "mindist", + EV_DEFAULT, + "f", + "distance", + "Sets the minimum distance the AI tries to keep between itself and the player", + EV_SETTER + ); + +Event EV_Actor_GetMinDistance + ( + "mindist", + EV_DEFAULT, + NULL, + NULL, + "Gets the minimum distance the AI tries to keep between itself and the player", + EV_GETTER + ); + +Event EV_Actor_SetMaxDistance + ( + "maxdist", + EV_DEFAULT, + "f", + "distance", + "Sets the maximum distance the AI tries to allow between itself and the player" + ); + +Event EV_Actor_SetMaxDistance2 + ( + "maxdist", + EV_DEFAULT, + "f", + "distance", + "Sets the maximum distance the AI tries to allow between itself and the player", + EV_SETTER + ); + +Event EV_Actor_GetMaxDistance + ( + "maxdist", + EV_DEFAULT, + NULL, + NULL, + "Gets the maximum distance the AI tries to keep between itself and the player", + EV_GETTER + ); + +Event EV_Actor_GetLeash + ( + "leash", + EV_DEFAULT, + NULL, + NULL, + "Gets the maximum distance the AI will wander from its leash home", + EV_GETTER + ); + +Event EV_Actor_SetLeash + ( + "leash", + EV_DEFAULT, + "f", + "distance", + "Sets the maximum distance the AI will wander from its leash home", + EV_SETTER + ); + +Event EV_Actor_SetLeash2 + ( + "leash", + EV_DEFAULT, + "f", + "distance", + "Sets the maximum distance the AI will wander from its leash home" + ); + +Event EV_Actor_GetInterval + ( + "interval", + EV_DEFAULT, + NULL, + NULL, + "Gets the distance AI tries to keep between squadmates while moving.", + EV_GETTER + ); + +Event EV_Actor_SetInterval + ( + "interval", + EV_DEFAULT, + "f", + "distance", + "Sets the distance AI tries to keep between squadmates while moving.", + EV_SETTER + ); + +Event EV_Actor_SetInterval2 + ( + "interval", + EV_DEFAULT, + "f", + "distance", + "Sets the distance AI tries to keep between squadmates while moving." + ); + +Event EV_Actor_GetRunAnim + ( + "GetRunAnim", + EV_DEFAULT, + NULL, + NULL, + "Internal usage", + EV_RETURN + ); + +Event EV_Actor_GetWalkAnim + ( + "GetWalkAnim", + EV_DEFAULT, + NULL, + NULL, + "Internal usage", + EV_RETURN + ); + +Event EV_Actor_GetAnimName + ( + "animname", + EV_DEFAULT, + NULL, + NULL, + "Gets the animname.", + EV_GETTER + ); + +Event EV_Actor_SetAnimName + ( + "animname", + EV_DEFAULT, + NULL, + NULL, + "Sets the animname.", + EV_SETTER + ); + +Event EV_Actor_SetDisguiseRange + ( + "disguise_range", + EV_DEFAULT, + "f", + "range_in_units", + "Sets the maximum distance for disguise behavior to get triggered", + EV_SETTER + ); + +Event EV_Actor_SetDisguiseRange2 + ( + "disguise_range", + EV_DEFAULT, + "f", + "range_in_units", + "Sets the maximum distance for disguise behavior to get triggered" + ); + +Event EV_Actor_GetDisguiseRange + ( + "disguise_range", + EV_DEFAULT, + NULL, + NULL, + "Gets the maximum distance for disguise behavior to get triggered", + EV_GETTER + ); + +Event EV_Actor_SetDisguisePeriod + ( + "disguise_period", + EV_DEFAULT, + "f", + "period_in_seconds", + "Sets the time between the end of one disguise behavior and start of the next", + EV_SETTER + ); + +Event EV_Actor_SetDisguisePeriod2 + ( + "disguise_period", + EV_DEFAULT, + "f", + "period_in_seconds", + "Sets the time between the end of one disguise behavior and start of the next" + ); + +Event EV_Actor_GetDisguisePeriod + ( + "disguise_period", + EV_DEFAULT, + NULL, + NULL, + "Gets the time between the end of one disguise behavior and start of the next", + EV_GETTER + ); + +Event EV_Actor_AttackPlayer + ( + "attackplayer", + EV_DEFAULT, + NULL, + NULL, + "Force Actor to attack the player" + ); + +Event EV_Actor_SetSoundAwareness + ( + "sound_awareness", + EV_DEFAULT, + "f", + "awareness_percent", + "sets the awareness of sounds in 0EV_DEFAULT00 percent chance of hearing a sound withinhalf of the sound's radius' fades to zero outside sound's radius" + ); + +Event EV_Actor_SetSoundAwareness2 + ( + "sound_awareness", + EV_DEFAULT, + "f", + "awareness_percent", + "sets the awareness of sounds in 0EV_DEFAULT00 percent chance of hearing a sound withinhalf of the sound's radius' fades to zero outside sound's radius", + EV_SETTER + ); + +Event EV_Actor_GetSoundAwareness + ( + "sound_awareness", + EV_DEFAULT, + NULL, + NULL, + "gets the awareness of sounds in 0EV_DEFAULT00 percent chance of hearing a sound withinhalf of the sound's radius' fades to zero outside sound's radius", + EV_GETTER + ); + +Event EV_Actor_SetGrenadeAwareness + ( + "gren_awareness", + EV_DEFAULT, + "f", + "awareness_percent", + "sets the awareness of grenades in 0EV_DEFAULT00 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)" + ); + + +Event EV_Actor_SetGrenadeAwareness2 + ( + "gren_awareness", + EV_DEFAULT, + "f", + "awareness_percent", + "sets the awareness of grenades in 0EV_DEFAULT00 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)", + EV_SETTER + ); + +Event EV_Actor_GetGrenadeAwareness + ( + "gren_awareness", + EV_DEFAULT, + NULL, + NULL, + "gets the awareness of grenades in 0EV_DEFAULT00 percent chance of responding to a grenadewhen the AI sees it (applied once every 0.4 seconds)", + EV_GETTER + ); + +Event EV_Actor_SetTurret + ( + "turret", + EV_DEFAULT, + "s", + "turret", + "Sets the turret of the actor." + ); + +Event EV_Actor_SetTurret2 + ( + "turret", + EV_DEFAULT, + "s", + "turret", + "Sets the turret of the actor.", + EV_SETTER + ); + +Event EV_Actor_GetTurret + ( + "turret", + EV_DEFAULT, + NULL, + NULL, + "Gets the turret of the actor.", + EV_GETTER + ); + +Event EV_Actor_AttachGrenade + ( + "attachgrenade", + EV_DEFAULT, + NULL, + NULL, + "Used only by grenade return animations to tell the code when to attach the grenade to the actor" + ); + +Event EV_Actor_DetachGrenade + ( + "detachgrenade", + EV_DEFAULT, + NULL, + NULL, + "Used only by grenade return animations to tell the code when to throw the grenade" + ); + +Event EV_Actor_FireGrenade + ( + "fire_grenade", + EV_DEFAULT, + NULL, + NULL, + "Used only by grenade throw animations to tell the code when to throw a grenade" + ); + +Event EV_Actor_EnableEnemy + ( + "enableEnemy", + EV_DEFAULT, + NULL, + NULL, + "sets enableEnemy variable", + EV_SETTER + ); + +Event EV_Actor_EnablePain + ( + "enablePain", + EV_DEFAULT, + NULL, + NULL, + "sets enablePain variable", + EV_SETTER + ); + +Event EV_Actor_SetPainHandler + ( + "painhandler", + EV_DEFAULT, + NULL, + NULL, + "Sets the current script that will handle pain events", + EV_SETTER + ); + +Event EV_Actor_GetPainHandler + ( + "painhandler", + EV_DEFAULT, + NULL, + NULL, + "Gets the current script that will handle pain events", + EV_GETTER + ); + +Event EV_Actor_SetDeathHandler + ( + "deathhandler", + EV_DEFAULT, + NULL, + NULL, + "Sets the current script that will handle death events", + EV_SETTER + ); + +Event EV_Actor_GetDeathHandler + ( + "deathhandler", + EV_DEFAULT, + NULL, + NULL, + "Gets the current script that will handle death events", + EV_GETTER + ); + +Event EV_Actor_SetAttackHandler + ( + "attackhandler", + EV_DEFAULT, + NULL, + NULL, + "Sets the current script that will handle attack events", + EV_SETTER + ); + +Event EV_Actor_GetAttackHandler + ( + "attackhandler", + EV_DEFAULT, + NULL, + NULL, + "Gets the current script that will handle attack events", + EV_GETTER + ); + +Event EV_Actor_SetAmmoGrenade + ( + "ammo_grenade", + EV_DEFAULT, + "i", + "grenade_count", + "Gives the AI some grenades" + ); + +Event EV_Actor_SetAmmoGrenade2 + ( + "ammo_grenade", + EV_DEFAULT, + "i", + "grenade_count", + "Gives the AI some grenades", + EV_SETTER + ); + +Event EV_Actor_GetAmmoGrenade + ( + "ammo_grenade", + EV_DEFAULT, + NULL, + NULL, + "Returns how many grenades an AI has", + EV_GETTER + ); + +Event EV_Actor_SetMood + ( + "mood", + EV_DEFAULT, + "s", + "new_mood", + "sets the AI mood... must be 'bored', 'nervous', 'curious', or 'alert'.", + EV_SETTER + ); + +Event EV_Actor_GetMood + ( + "mood", + EV_DEFAULT, + NULL, + NULL, + "gets the AI mood: 'bored', 'nervous', 'curious', or 'alert'.", + EV_GETTER + ); + +Event EV_Actor_SetHeadModel + ( + "headmodel", + EV_DEFAULT, + "s", + "headmodel", + "sets the head model" + ); + +Event EV_Actor_GetHeadModel + ( + "headmodel", + EV_DEFAULT, + NULL, + NULL, + "gets the head model", + EV_GETTER + ); + +Event EV_Actor_SetHeadSkin + ( + "headskin", + EV_DEFAULT, + "s", + "headskin", + "sets the head skin" + ); + +Event EV_Actor_GetHeadSkin + ( + "headskin", + EV_DEFAULT, + NULL, + NULL, + "gets the head skin", + EV_GETTER + ); + +Event EV_Actor_ShareEnemy + ( + "share_enemy", + EV_DEFAULT, + NULL, + NULL, + "internal code use only - shares an AI's enemy with his squad mates." + ); + +Event EV_Actor_ShareGrenade + ( + "share_grenade", + EV_DEFAULT, + NULL, + NULL, + "internal code use only - shares an AI's grenade with his squad mates." + ); + +Event EV_Actor_InterruptPoint + ( + "interrupt_point", + EV_DEFAULT, + NULL, + NULL, + "hint from animation scripts to AI code that now is a good time to switch animations" + ); + +Event EV_Actor_SetNoIdle + ( + "no_idle", + EV_DEFAULT, + NULL, + NULL, + "Specifies if the actor will not go into idle after playing an animation", + EV_SETTER + ); + +Event EV_Actor_GetNoIdle + ( + "no_idle", + EV_DEFAULT, + NULL, + NULL, + "Gets if the actor will not go into idle after playing an animation", + EV_GETTER + ); + +Event EV_Actor_GetEnemy + ( + "enemy", + EV_DEFAULT, + NULL, + NULL, + "Get the actor's current enemy", + EV_GETTER + ); + +Event EV_Actor_GetMaxNoticeTimeScale + ( + "noticescale", + EV_DEFAULT, + NULL, + NULL, + "Get the max multiplier in time to notice an enemy (default 100, half as big notices twice as fast)", + EV_GETTER + ); + +Event EV_Actor_SetMaxNoticeTimeScale + ( + "noticescale", + EV_DEFAULT, + "f", + "multiplier", + "Set the max multiplier in time to notice an enemy (default 100, half as big notices twice as fast)", + EV_SETTER + ); + +Event EV_Actor_SetMaxNoticeTimeScale2 + ( + "noticescale", + EV_DEFAULT, + "f", + "multiplier", + "Set the max multiplier in time to notice an enemy (default 100, half as big notices twice as fast)" + ); + +Event EV_Actor_GetFixedLeash + ( + "fixedleash", + EV_DEFAULT, + NULL, + NULL, + "if non-zero, the leash will never auto-reset; if zero, the leash may auto-reset", + EV_GETTER + ); + +Event EV_Actor_SetFixedLeash + ( + "fixedleash", + EV_DEFAULT, + "f", + "multiplier", + "if non-zero, the leash will never auto-reset; if zero, the leash may auto-reset", + EV_SETTER + ); + +Event EV_Actor_SetFixedLeash2 + ( + "fixedleash", + EV_DEFAULT, + "f", + "multiplier", + "if non-zero, the leash will never auto-reset; if zero, the leash may auto-reset" + ); + +Event EV_Actor_Holster + ( + "holster", + EV_DEFAULT, + NULL, + NULL, + "Holster weapon" + ); + +Event EV_Actor_Unholster + ( + "unholster", + EV_DEFAULT, + NULL, + NULL, + "Unholster weapon" + ); + +Event EV_Actor_IsEnemyVisible + ( + "is_enemy_visible", + EV_DEFAULT, + NULL, + NULL, + "0 if the enemy is not currently visible, 1 if he is" + ); + +Event EV_Actor_GetEnemyVisibleChangeTime + ( + "enemy_visible_change_time", + EV_DEFAULT, + NULL, + NULL, + "Get the last time whether or not the enemy is visible changed, in seconds" + ); + +Event EV_Actor_GetLastEnemyVisibleTime + ( + "last_enemy_visible_time", + EV_DEFAULT, + NULL, + NULL, + "Get the last time the enemy was visible, in seconds" + ); + +Event EV_Actor_SetFallHeight + ( + "fallheight", + EV_DEFAULT, + "f", + "height", + "Set the fallheight", + EV_SETTER + ); + +Event EV_Actor_SetFallHeight2 + ( + "fallheight", + EV_DEFAULT, + "f", + "height", + "Set the fallheight" + ); + +Event EV_Actor_GetFallHeight + ( + "fallheight", + EV_DEFAULT, + NULL, + NULL, + "Set the fallheight", + EV_GETTER + ); + +Event EV_Actor_CanMoveTo + ( + "canmoveto", + EV_DEFAULT, + "v", + "position", + "returns a boolean if the AI can move to a point; for use in anim scripts", + EV_RETURN + ); + +Event EV_Actor_MoveDir + ( + "movedir", + EV_DEFAULT, + NULL, + NULL, + "Returns a unit vector pointing in the current direction of motion, or zero if not moving.This still has meaning if velocity is zero but the AI is starting to move on a path.", + EV_GETTER + ); + +Event EV_Actor_ResetLeash + ( + "resetleash", + EV_DEFAULT, + NULL, + NULL, + "resets the AI's leash to their current position" + ); + +Event EV_Actor_IntervalDir + ( + "intervaldir", + EV_DEFAULT, + NULL, + NULL, + "the direction the AI would like to move to maintain its interval", + EV_GETTER + ); + +Event EV_Actor_Tether + ( + "tether", + EV_DEFAULT, + "e", + "entity", + "the entity to which the AI's leash should be tethered" + ); + +Event EV_Actor_GetThinkState + ( + "thinkstate", + EV_DEFAULT, + NULL, + NULL, + "current ai think state; can be void, idle, pain, killed, attack, curious, disguise, or grenade.", + EV_GETTER + ); + +Event EV_Actor_GetEnemyShareRange + ( + "enemysharerange", + EV_DEFAULT, + NULL, + NULL, + "gets the range outside which the AI will not receive notification that a teammate has a new enemy", + EV_GETTER + ); + +Event EV_Actor_SetEnemyShareRange + ( + "enemysharerange", + EV_DEFAULT, + "f", + "range", + "sets the range outside which the AI will not receive notification that a teammate has a new enemy", + EV_SETTER + ); + +Event EV_Actor_SetEnemyShareRange2 + ( + "enemysharerange", + EV_DEFAULT, + "f", + "range", + "sets the range outside which the AI will not receive notification that a teammate has a new enemy" + ); + +Event EV_Actor_SetWeapon + ( + "weapon", + EV_DEFAULT, + "s", + "weapon_modelname", + "Sets the weapon.", + EV_SETTER + ); + +Event EV_Actor_GetWeapon + ( + "weapon", + EV_DEFAULT, + NULL, + NULL, + "Gets the weapon.", + EV_GETTER + ); + +Event EV_Actor_GetVoiceType + ( + "voicetype", + EV_DEFAULT, + NULL, + NULL, + "Gets the voice type", + EV_GETTER + ); + +Event EV_Actor_SetVoiceType + ( + "voicetype", + EV_DEFAULT, + NULL, + NULL, + "Set voicetype to magic letter postfix" + ); + +Event EV_Actor_SetVoiceType2 + ( + "voicetype", + EV_DEFAULT, + NULL, + NULL, + "Set voicetype to magic letter postfix", + EV_SETTER + ); + +Event EV_Actor_KickDir + ( + "kickdir", + EV_DEFAULT, + NULL, + NULL, + "Gets the direction the AI wants to kick", + EV_GETTER + ); + +Event EV_Actor_GetNoLongPain + ( + "nolongpain", + EV_DEFAULT, + NULL, + NULL, + "Returns 1 if long pain is not allowed, or 0 if long pain is allowed.", + EV_GETTER + ); + +Event EV_Actor_SetNoLongPain + ( + "nolongpain", + EV_DEFAULT, + "i", + "allow", + "Set to 1 if long pain is not allowed, or 0 if long pain is allowed.", + EV_SETTER + ); + +Event EV_Actor_SetNoLongPain2 + ( + "nolongpain", + EV_DEFAULT, + "i", + "allow", + "Set to 1 if long pain is not allowed, or 0 if long pain is allowed." + ); + +Event EV_Actor_GetFavoriteEnemy + ( + "favoriteenemy", + EV_DEFAULT, + NULL, + NULL, + "Gets this AI's favorite enemy", + EV_GETTER + ); + +Event EV_Actor_SetFavoriteEnemy + ( + "favoriteenemy", + EV_DEFAULT, + "e", + "ai_or_player", + "Gets this AI's favorite enemy", + EV_SETTER + ); + +Event EV_Actor_SetFavoriteEnemy2 + ( + "favoriteenemy", + EV_DEFAULT, + "e", + "ai_or_player", + "Gets this AI's favorite enemy" + ); + +Event EV_Actor_GetMumble + ( + "mumble", + EV_DEFAULT, + NULL, + NULL, + "Returns 1 if this guy is allowed to mumble, or 0 if he is not", + EV_GETTER + ); + +Event EV_Actor_SetMumble + ( + "mumble", + EV_DEFAULT, + "i", + "can_mumble", + "Set to 1 if this guy is allowed to mumble, or 0 if he is not", + EV_SETTER + ); + +Event EV_Actor_SetMumble2 + ( + "mumble", + EV_DEFAULT, + "i", + "can_mumble", + "Set to 1 if this guy is allowed to mumble, or 0 if he is not" + ); + +Event EV_Actor_GetBreathSteam + ( + "breathsteam", + EV_DEFAULT, + NULL, + NULL, + "Returns 1 if this guy is allowed to have steamy breath, or 0 if he is not", + EV_GETTER + ); + +Event EV_Actor_SetBreathSteam + ( + "breathsteam", + EV_DEFAULT, + "i", + "can_breathe_out", + "Set to 1 if this guy is allowed to have steamy breath, or 0 if he is not", + EV_SETTER + ); + +Event EV_Actor_SetBreathSteam2 + ( + "breathsteam", + EV_DEFAULT, + "i", + "can_breathe_out", + "Set to 1 if this guy is allowed to have steamy breath, or 0 if he is not" + ); + +Event EV_Actor_SetNextBreathTime + ( + "nextbreathtime", + EV_DEFAULT, + "f", + "time_in_sec", + "Sets the next time the guy will breath out" + ); + +Event EV_Actor_CalcGrenadeToss + ( + "calcgrenadetoss", + EV_DEFAULT, + "v", + "target_position", + "Called to calculate a grenade toss. Must be called before a grenade throwing animation.\nReturns the name of the script to call with animscript if the toss can succeed, or if the toss won't work.\nShould be called infrequently, and never during the middle of a grenade toss.", + EV_RETURN + ); + +Event EV_Actor_GetNoSurprise + ( + "nosurprise", + EV_DEFAULT, + NULL, + NULL, + "gets whether or not this guy is allowed to play a surprised animation when first encountering an enemy.\n", + EV_GETTER + ); + +Event EV_Actor_SetNoSurprise + ( + "nosurprise", + EV_DEFAULT, + "i", + "nosurprise", + "set to 0 to allow this guy to play a surprised animation when first encountering an enemy.\n", + EV_SETTER + ); + +Event EV_Actor_SetNoSurprise2 + ( + "nosurprise", + EV_DEFAULT, + "i", + "nosurprise", + "set to 0 to allow this guy to play a surprised animation when first encountering an enemy.\n" + ); + +Event EV_Actor_GetSilent + ( + "silent", + EV_DEFAULT, + NULL, + NULL, + "gets whether or not this guy is allowed to say stuff besides pain and death sounds", + EV_GETTER + ); + +Event EV_Actor_SetSilent + ( + "silent", + EV_DEFAULT, + "i", + "silent", + "set to 0 to prevent this guy from saying stuff besides pain and death sounds.\n", + EV_SETTER + ); + +Event EV_Actor_SetSilent2 + ( + "silent", + EV_DEFAULT, + "i", + "silent", + "set to 0 to prevent this guy from saying stuff besides pain and death sounds.\n" + ); + +Event EV_Actor_GetAvoidPlayer + ( + "avoidplayer", + EV_DEFAULT, + NULL, + NULL, + "is 0 if this AI won't automatically get out of the way, non-zero if he will\n", + EV_GETTER + ); + +Event EV_Actor_SetAvoidPlayer + ( + "avoidplayer", + EV_DEFAULT, + "i", + "allowavoid", + "set to 0 if this AI shouldn't automatically get out of the way, non-zero if he should.\n", + EV_SETTER + ); + +Event EV_Actor_SetAvoidPlayer2 + ( + "avoidplayer", + EV_DEFAULT, + "i", + "allowavoid", + "set to 0 if this AI shouldn't automatically get out of the way, non-zero if he should.\n" + ); + +Event EV_Actor_SetMoveDoneRadius + ( + "movedoneradius", + EV_DEFAULT, + "f", + "radius", + "Set the waittill movedone radius, default 0 means don't use manual radius", + EV_SETTER + ); + +Event EV_Actor_BeDead + ( + "bedead", + EV_DEFAULT, + NULL, + NULL, + "Forces the actor to be instantly and totally dead; no death animation is played" + ); + +Event EV_Actor_GetLookAroundAngle + ( + "lookaround", + EV_DEFAULT, + NULL, + NULL, + "gets the angle in degrees left or right of center that the AI will look around while patrolling", + EV_GETTER + ); + +Event EV_Actor_SetLookAroundAngle + ( + "lookaround", + EV_DEFAULT, + "f", + "angle", + "gets the angle in degrees left or right of center that the AI will look around while patrolling", + EV_SETTER + ); + +Event EV_Actor_SetLookAroundAngle2 + ( + "lookaround", + EV_DEFAULT, + "f", + "angle", + "gets the angle in degrees left or right of center that the AI will look around while patrolling" + ); + +Event EV_Actor_HasCompleteLookahead + ( + "hascompletelookahead", + EV_DEFAULT, + NULL, + NULL, + "returns true if there are no corners to turn on the rest of the AI's current path", + EV_GETTER + ); + +Event EV_Actor_PathDist + ( + "pathdist", + EV_DEFAULT, + NULL, + NULL, + "returns total distance along current path to the path goal", + EV_GETTER + ); + +Event EV_Actor_CanShootEnemyFrom + ( + "canshootenemyfrom", + EV_DEFAULT, + "v", + "shootOrigin", + "Determines if it would be possible to shoot the sentient's enemy from the given position.", + EV_RETURN + ); + +Event EV_Actor_CanShoot + ( + "canshoot", + EV_DEFAULT, + "v", + "shootOrigin", + "Determines if it would be possible to shoot the sentient's enemy from the given position.", + EV_RETURN + ); + +Event EV_Actor_GetInReload + ( + "inreload", + EV_DEFAULT, + NULL, + NULL, + "returns non-zero if the AI is in a reload", + EV_GETTER + ); + +Event EV_Actor_SetInReload + ( + "inreload", + EV_DEFAULT, + "i", + "reloading", + "set to non-zero to indicate the AI is in a reload", + EV_SETTER + ); + +Event EV_Actor_SetReloadCover + ( + "setreloadcover", + EV_DEFAULT, + NULL, + NULL, + "do this command to let the ai know it needs to reload; used to reload while going to cover" + ); + +Event EV_Actor_BreakSpecial + ( + "breakspecial", + EV_DEFAULT, + NULL, + NULL, + "tell ai to break special attack" + ); + +Event EV_Actor_SetBalconyHeight + ( + "balconyheight", + EV_DEFAULT, + "f", + "height", + "minimum height a balcony guy must fall to do special balcony death" + ); + +Event EV_Actor_SetBalconyHeight2 + ( + "balconyheight", + EV_DEFAULT, + "f", + "height", + "minimum height a balcony guy must fall to do special balcony death", + EV_SETTER + ); + +Event EV_Actor_GetBalconyHeight + ( + "balconyheight", + EV_DEFAULT, + NULL, + NULL, + "minimum height a balcony guy must fall to do special balcony death", + EV_GETTER + ); + +CLASS_DECLARATION( SimpleActor, Actor, "Actor" ) +{ + { &EV_Entity_Start, &Actor::EventStart }, + { &EV_Actor_MoveTo, &Actor::MoveTo }, + { &EV_Actor_WalkTo, &Actor::WalkTo }, + { &EV_Actor_RunTo, &Actor::RunTo }, + { &EV_Actor_CrouchTo, &Actor::CrouchTo }, + { &EV_Actor_CrawlTo, &Actor::CrawlTo }, + { &EV_Actor_AimAt, &Actor::AimAt }, + { &EV_Pain, &Actor::EventPain }, + { &EV_Killed, &Actor::EventKilled }, + { &EV_Actor_DeathEmbalm, &Actor::DeathEmbalm }, + { &EV_Actor_Anim, &Actor::PlayAnimation }, + { &EV_Actor_AnimLoop, &Actor::PlayAnimation }, + { &EV_Actor_Anim_Scripted, &Actor::PlayScriptedAnimation }, + { &EV_Actor_Anim_Noclip, &Actor::PlayNoclipAnimation }, + { &EV_Actor_AnimScript, &Actor::EventAnimScript }, + { &EV_Actor_AnimScript_Scripted, &Actor::EventAnimScript_Scripted }, + { &EV_Actor_AnimScript_Noclip, &Actor::EventAnimScript_Noclip }, + { &EV_Actor_Reload_mg42, &Actor::EventReload_mg42 }, + { &EV_Actor_Dumb, &Actor::Dumb }, + { &EV_Actor_Physics_On, &Actor::PhysicsOn }, + { &EV_Actor_Physics_Off, &Actor::PhysicsOff }, + { &EV_Actor_SetAnim, &Actor::EventSetAnim }, + { &EV_Actor_SetAnimLength, &SimpleActor::EventSetAnimLength }, + { &EV_Actor_EndActionAnim, &Actor::EventEndActionAnim }, + { &EV_Actor_SetMotionAnim, &Actor::EventSetMotionAnim }, + { &EV_Actor_SetAimMotionAnim, &Actor::EventSetAimMotionAnim }, + { &EV_Actor_SetActionAnim, &Actor::EventSetActionAnim }, + { &EV_Actor_UpperAnim, &Actor::EventUpperAnim }, + { &EV_Actor_SetUpperAnim, &Actor::EventSetUpperAnim }, + { &EV_Actor_SetCrossblendTime, &SimpleActor::EventSetCrossblendTime }, + { &EV_Actor_GetCrossblendTime, &SimpleActor::EventGetCrossblendTime }, + { &EV_Actor_GetPosition, &SimpleActor::EventGetPosition }, + { &EV_Actor_SetPosition, &SimpleActor::EventSetPosition }, + { &EV_Actor_SetEmotion, &SimpleActor::EventSetEmotion }, + { &EV_Actor_SetAnimFinal, &SimpleActor::EventSetAnimFinal }, + { &EV_Actor_GetWeaponType, &SimpleActor::EventGetWeaponType }, + { &EV_Actor_GetWeaponGroup, &SimpleActor::EventGetWeaponGroup }, + { &EV_Actor_LookAt, &Actor::EventLookAt }, + { &EV_Actor_EyesLookAt, &Actor::EventEyesLookAt }, + { &EV_Actor_PointAt, &Actor::EventPointAt }, + { &EV_Actor_TurnTo, &Actor::EventTurnTo }, + { &EV_Actor_SetTurnDoneError, &Actor::EventSetTurnDoneError }, + { &EV_Actor_SetTurnDoneError2, &Actor::EventSetTurnDoneError }, + { &EV_Actor_GetTurnDoneError, &Actor::EventGetTurnDoneError }, + { &EV_Actor_IdleSayAnim, &Actor::EventIdleSayAnim }, + { &EV_Actor_SayAnim, &Actor::EventSayAnim }, + { &EV_Actor_SetSayAnim, &Actor::EventSetSayAnim }, + { &EV_Sentient_UseItem, &Actor::EventGiveWeapon }, + { &EV_Sentient_GiveWeapon, &Actor::EventGiveWeapon }, + { &EV_Actor_SetWeapon, &Actor::EventGiveWeapon }, + { &EV_Actor_GetWeapon, &Actor::EventGetWeapon }, + { &EV_Actor_SetGun, &Actor::EventGiveWeapon }, + { &EV_Actor_SetGun2, &Actor::EventGiveWeapon }, + { &EV_Actor_GetGun, &Actor::EventGetWeapon }, + { &EV_Actor_WeaponInternal, &Actor::EventGiveWeaponInternal }, + { &EV_Actor_DamagePuff, &Actor::EventDamagePuff }, + { &EV_Actor_SetAngleYawSpeed, &Actor::EventSetAngleYawSpeed }, + { &EV_Actor_SetAngleYawSpeed2, &Actor::EventSetAngleYawSpeed }, + { &EV_Actor_GetAngleYawSpeed, &Actor::EventGetAngleYawSpeed }, + { &EV_Actor_SetAimTarget, &Actor::EventSetAimTarget }, + { &EV_Actor_ReadyToFire, &Actor::ReadyToFire }, + { &EV_Actor_AIOn, &SimpleActor::EventAIOn }, + { &EV_Actor_AIOff, &SimpleActor::EventAIOff }, + { &EV_Actor_GetLocalYawFromVector, &Actor::GetLocalYawFromVector }, + { &EV_DeathSinkStart, &Actor::DeathSinkStart }, + { &EV_Actor_GetSight, &Actor::EventGetSight }, + { &EV_Actor_SetSight, &Actor::EventSetSight }, + { &EV_Actor_SetSight2, &Actor::EventSetSight }, + { &EV_Actor_GetHearing, &Actor::EventGetHearing }, + { &EV_Actor_SetHearing, &Actor::EventSetHearing }, + { &EV_Actor_SetHearing2, &Actor::EventSetHearing }, + { &EV_Actor_SetFov, &Actor::EventSetFov }, + { &EV_Actor_SetFov2, &Actor::EventSetFov }, + { &EV_Actor_GetFov, &Actor::EventGetFov }, + { &EV_Actor_DistToEnemy, &Actor::EventDistToEnemy }, + { &EV_Actor_SetPatrolPath, &Actor::EventSetPatrolPath }, + { &EV_Actor_SetPatrolPath2, &Actor::EventSetPatrolPath }, + { &EV_Actor_GetPatrolPath, &Actor::EventGetPatrolPath }, + { &EV_Actor_SetPatrolWaitTrigger, &Actor::EventSetPatrolWaitTrigger }, + { &EV_Actor_SetPatrolWaitTrigger2, &Actor::EventSetPatrolWaitTrigger }, + { &EV_Actor_GetPatrolWaitTrigger, &Actor::EventGetPatrolWaitTrigger }, + { &EV_Actor_SetAccuracy, &Actor::EventSetAccuracy }, + { &EV_Actor_SetAccuracy2, &Actor::EventSetAccuracy }, + { &EV_Actor_GetAccuracy, &Actor::EventGetAccuracy }, + { &EV_Actor_SetTypeIdle, &Actor::EventSetTypeIdle }, + { &EV_Actor_SetTypeIdle2, &Actor::EventSetTypeIdle }, + { &EV_Actor_GetTypeIdle, &Actor::EventGetTypeIdle }, + { &EV_Actor_SetTypeAttack, &Actor::EventSetTypeAttack }, + { &EV_Actor_SetTypeAttack2, &Actor::EventSetTypeAttack }, + { &EV_Actor_GetTypeAttack, &Actor::EventGetTypeAttack }, + { &EV_Actor_SetTypeDisguise, &Actor::EventSetTypeDisguise }, + { &EV_Actor_SetTypeDisguise2, &Actor::EventSetTypeDisguise }, + { &EV_Actor_GetTypeDisguise, &Actor::EventGetTypeDisguise }, + { &EV_Actor_SetDisguiseLevel, &Actor::EventSetDisguiseLevel }, + { &EV_Actor_SetDisguiseLevel2, &Actor::EventSetDisguiseLevel }, + { &EV_Actor_GetDisguiseLevel, &Actor::EventGetDisguiseLevel }, + { &EV_Actor_SetTypeGrenade, &Actor::EventSetTypeGrenade }, + { &EV_Actor_SetTypeGrenade2, &Actor::EventSetTypeGrenade }, + { &EV_Actor_GetTypeGrenade, &Actor::EventGetTypeGrenade }, + { &EV_Actor_SetMinDistance, &Actor::EventSetMinDistance }, + { &EV_Actor_SetMinDistance2, &Actor::EventSetMinDistance }, + { &EV_Actor_GetMinDistance, &Actor::EventGetMinDistance }, + { &EV_Actor_SetMaxDistance, &Actor::EventSetMaxDistance }, + { &EV_Actor_SetMaxDistance2, &Actor::EventSetMaxDistance }, + { &EV_Actor_GetMaxDistance, &Actor::EventGetMaxDistance }, + { &EV_Actor_GetLeash, &Actor::EventGetLeash }, + { &EV_Actor_SetLeash, &Actor::EventSetLeash }, + { &EV_Actor_SetLeash2, &Actor::EventSetLeash }, + { &EV_Actor_GetInterval, &Actor::EventGetInterval }, + { &EV_Actor_SetInterval, &Actor::EventSetInterval }, + { &EV_Actor_SetInterval2, &Actor::EventSetInterval }, + { &EV_Actor_GetRunAnim, &Actor::EventGetRunAnim }, + { &EV_Actor_GetWalkAnim, &Actor::EventGetWalkAnim }, + { &EV_Actor_GetAnimName, &Actor::EventGetAnimName }, + { &EV_Actor_SetAnimName, &Actor::EventSetAnimName }, + { &EV_Actor_SetDisguiseRange, &Actor::EventSetDisguiseRange }, + { &EV_Actor_SetDisguiseRange2, &Actor::EventSetDisguiseRange }, + { &EV_Actor_GetDisguiseRange, &Actor::EventGetDisguiseRange }, + { &EV_Actor_SetDisguisePeriod, &Actor::EventSetDisguisePeriod }, + { &EV_Actor_SetDisguisePeriod2, &Actor::EventSetDisguisePeriod }, + { &EV_Actor_GetDisguisePeriod, &Actor::EventGetDisguisePeriod }, + { &EV_Actor_SetDisguiseAcceptThread, &Actor::EventSetDisguiseAcceptThread }, + { &EV_Actor_SetDisguiseAcceptThread2, &Actor::EventSetDisguiseAcceptThread }, + { &EV_Actor_GetDisguiseAcceptThread, &Actor::EventGetDisguiseAcceptThread }, + { &EV_Actor_AttackPlayer, &Actor::EventAttackPlayer }, + { &EV_Actor_SetAlarmNode, &Actor::EventSetAlarmNode }, + { &EV_Actor_SetAlarmNode2, &Actor::EventSetAlarmNode }, + { &EV_Actor_GetAlarmNode, &Actor::EventGetAlarmNode }, + { &EV_Actor_SetAlarmThread, &Actor::EventSetAlarmThread }, + { &EV_Actor_SetAlarmThread2, &Actor::EventSetAlarmThread }, + { &EV_Actor_GetAlarmThread, &Actor::EventGetAlarmThread }, + { &EV_Actor_SetSoundAwareness, &Actor::EventSetSoundAwareness }, + { &EV_Actor_SetSoundAwareness2, &Actor::EventSetSoundAwareness }, + { &EV_Actor_GetSoundAwareness, &Actor::EventGetSoundAwareness }, + { &EV_Actor_SetGrenadeAwareness, &Actor::EventSetGrenadeAwareness }, + { &EV_Actor_SetGrenadeAwareness2, &Actor::EventSetGrenadeAwareness }, + { &EV_Actor_GetGrenadeAwareness, &Actor::EventGetGrenadeAwareness }, + { &EV_Actor_SetTurret, &Actor::EventSetTurret }, + { &EV_Actor_SetTurret2, &Actor::EventSetTurret }, + { &EV_Actor_GetTurret, &Actor::EventGetTurret }, + { &EV_Actor_AttachGrenade, &Actor::Grenade_EventAttach }, + { &EV_Actor_DetachGrenade, &Actor::Grenade_EventDetach }, + { &EV_Actor_FireGrenade, &Actor::Grenade_EventFire }, + { &EV_Actor_EnableEnemy, &Actor::EventEnableEnemy }, + { &EV_Actor_EnablePain, &Actor::EventEnablePain }, + { &EV_Activate, &Actor::EventActivate }, + { &EV_Actor_GetAmmoGrenade, &Actor::EventGetAmmoGrenade }, + { &EV_Actor_SetAmmoGrenade, &Actor::EventSetAmmoGrenade }, + { &EV_Actor_SetAmmoGrenade2, &Actor::EventSetAmmoGrenade }, + { &EV_Actor_GetMood, &Actor::EventGetMood }, + { &EV_Actor_SetMood, &Actor::EventSetMood }, + { &EV_Actor_ShareEnemy, &Actor::EventShareEnemy }, + { &EV_Actor_ShareGrenade, &Actor::EventShareGrenade }, + { &EV_Actor_InterruptPoint, &Actor::EventInterruptPoint }, + { &EV_Actor_GetPainHandler, &SimpleActor::EventGetPainHandler }, + { &EV_Actor_SetPainHandler, &SimpleActor::EventSetPainHandler }, + { &EV_Actor_GetDeathHandler, &SimpleActor::EventGetDeathHandler }, + { &EV_Actor_SetDeathHandler, &SimpleActor::EventSetDeathHandler }, + { &EV_Actor_GetAttackHandler, &SimpleActor::EventGetAttackHandler }, + { &EV_Actor_SetAttackHandler, &SimpleActor::EventSetAttackHandler }, + { &EV_Actor_SetHeadModel, &Actor::EventSetHeadModel }, + { &EV_Actor_GetHeadModel, &Actor::EventGetHeadModel }, + { &EV_Actor_SetHeadSkin, &Actor::EventSetHeadSkin }, + { &EV_Actor_GetHeadSkin, &Actor::EventGetHeadSkin }, + { &EV_Actor_SetNoIdle, &Actor::EventSetNoIdle }, + { &EV_Actor_GetNoIdle, &Actor::EventGetNoIdle }, + { &EV_Actor_GetEnemy, &Actor::EventGetEnemy }, + { &EV_Actor_GetMaxNoticeTimeScale, &Actor::EventGetMaxNoticeTimeScale }, + { &EV_Actor_SetMaxNoticeTimeScale, &Actor::EventSetMaxNoticeTimeScale }, + { &EV_Actor_SetMaxNoticeTimeScale2, &Actor::EventSetMaxNoticeTimeScale }, + { &EV_Actor_GetFixedLeash, &Actor::EventGetFixedLeash }, + { &EV_Actor_SetFixedLeash, &Actor::EventSetFixedLeash }, + { &EV_Actor_SetFixedLeash2, &Actor::EventSetFixedLeash }, + { &EV_Actor_Holster, &Actor::EventHolster }, + { &EV_Actor_Unholster, &Actor::EventUnholster }, + { &EV_SoundDone, &Actor::EventSoundDone }, + { &EV_Sound, &Actor::EventSound }, + { &EV_Actor_IsEnemyVisible, &Actor::EventIsEnemyVisible }, + { &EV_Actor_GetEnemyVisibleChangeTime, &Actor::EventGetEnemyVisibleChangeTime }, + { &EV_Actor_GetLastEnemyVisibleTime, &Actor::EventGetLastEnemyVisibleTime }, + { &EV_Actor_SetFallHeight, &Actor::EventSetFallHeight }, + { &EV_Actor_GetFallHeight, &Actor::EventGetFallHeight }, + { &EV_Actor_CanMoveTo, &Actor::EventCanMoveTo }, + { &EV_Actor_MoveDir, &Actor::EventMoveDir }, + { &EV_Actor_IntervalDir, &Actor::EventIntervalDir }, + { &EV_Actor_ResetLeash, &Actor::EventResetLeash }, + { &EV_Actor_Tether, &Actor::EventTether }, + { &EV_Actor_GetThinkState, &Actor::EventGetThinkState }, + { &EV_Actor_GetEnemyShareRange, &Actor::EventGetEnemyShareRange }, + { &EV_Actor_SetEnemyShareRange, &Actor::EventSetEnemyShareRange }, + { &EV_Actor_SetEnemyShareRange2, &Actor::EventSetEnemyShareRange }, + { &EV_Actor_GetVoiceType, &Actor::GetVoiceType }, + { &EV_Actor_SetVoiceType, &Actor::SetVoiceType }, + { &EV_Actor_SetVoiceType2, &Actor::SetVoiceType }, + { &EV_Remove, &Actor::Remove }, + { &EV_Delete, &Actor::Remove }, + { &EV_ScriptRemove, &Actor::Remove }, + { &EV_Actor_KickDir, &Actor::EventGetKickDir }, + { &EV_Actor_GetNoLongPain, &Actor::EventGetNoLongPain }, + { &EV_Actor_SetNoLongPain, &Actor::EventSetNoLongPain }, + { &EV_Actor_SetNoLongPain2, &Actor::EventSetNoLongPain }, + { &EV_Actor_GetFavoriteEnemy, &Actor::EventGetFavoriteEnemy }, + { &EV_Actor_SetFavoriteEnemy, &Actor::EventSetFavoriteEnemy }, + { &EV_Actor_SetFavoriteEnemy2, &Actor::EventSetFavoriteEnemy }, + { &EV_Actor_GetMumble, &Actor::EventGetMumble }, + { &EV_Actor_SetMumble, &Actor::EventSetMumble }, + { &EV_Actor_SetMumble2, &Actor::EventSetMumble }, + { &EV_Actor_CalcGrenadeToss, &Actor::EventCalcGrenadeToss }, + { &EV_Actor_GetNoSurprise, &Actor::EventGetNoSurprise }, + { &EV_Actor_SetNoSurprise, &Actor::EventSetNoSurprise }, + { &EV_Actor_SetNoSurprise2, &Actor::EventSetNoSurprise }, + { &EV_Actor_GetSilent, &Actor::EventGetSilent }, + { &EV_Actor_SetSilent, &Actor::EventSetSilent }, + { &EV_Actor_SetSilent2, &Actor::EventSetSilent }, + { &EV_Actor_GetAvoidPlayer, &Actor::EventGetAvoidPlayer }, + { &EV_Actor_SetAvoidPlayer, &Actor::EventSetAvoidPlayer }, + { &EV_Actor_SetAvoidPlayer2, &Actor::EventSetAvoidPlayer }, + { &EV_Actor_SetMoveDoneRadius, &Actor::EventSetMoveDoneRadius }, + { &EV_Actor_BeDead, &Actor::EventBeDead }, + { &EV_Actor_GetLookAroundAngle, &Actor::EventGetLookAroundAngle }, + { &EV_Actor_SetLookAroundAngle, &Actor::EventSetLookAroundAngle }, + { &EV_Actor_SetLookAroundAngle2, &Actor::EventSetLookAroundAngle }, + { &EV_Actor_HasCompleteLookahead, &Actor::EventHasCompleteLookahead }, + { &EV_Actor_PathDist, &Actor::EventPathDist }, + { &EV_Actor_CanShootEnemyFrom, &Actor::EventCanShootEnemyFrom }, + { &EV_Actor_CanShoot, &Actor::EventCanShoot }, + { &EV_Actor_GetInReload, &Actor::EventGetInReload }, + { &EV_Actor_SetInReload, &Actor::EventSetInReload }, + { &EV_Actor_SetReloadCover, &Actor::EventSetReloadCover }, + { &EV_Actor_BreakSpecial, &Actor::EventBreakSpecial }, + { &EV_Actor_SetBalconyHeight, &Actor::EventSetBalconyHeight }, + { &EV_Actor_SetBalconyHeight2, &Actor::EventSetBalconyHeight }, + { &EV_Actor_GetBalconyHeight, &Actor::EventGetBalconyHeight }, + { &EV_CanSee, &Actor::CanSee }, + { NULL, NULL } +}; + +Actor::GlobalFuncs_t Actor::GlobalFuncs[ MAX_GLOBAL_FUNCS ]; +const_str Actor::m_csThinkNames[ MAX_GLOBAL_FUNCS ]; +const_str Actor::m_csThinkStateNames[ MAX_THINKMAP ]; + +Actor::Actor() +{ + entflags |= EF_ACTOR; + + if( LoadingSavegame ) + { + return; + } + + edict->s.eType = ET_MODELANIM; + edict->r.svFlags |= SVF_USE_CURRENT_ORIGIN; + edict->r.ownerNum = ENTITYNUM_NONE; + edict->clipmask = MASK_MONSTERSOLID; + setMoveType( MOVETYPE_WALK ); + mass = 175; + flags |= FL_THINK; + flags &= ~FL_UNKNOWN; + edict->r.contents = CONTENTS_NOBOTCLIP; + setSolidType( SOLID_BBOX ); + m_fFov = 90.0f; + takedamage = DAMAGE_AIM; + m_fFov = cos( 0.78f ); + m_eAnimMode = 0; + m_eEmotionMode = 0; + m_bDoPhysics = true; + path_failed_time = 0; + health = 100; + max_health = 100; + m_fAngleYawSpeed = 360; + m_fHeadMaxTurnSpeed = 520; + m_bHeadAnglesAchieved = true; + VectorClear( m_vHeadDesiredAngles ); + m_fLUpperArmTurnSpeed = 360; + m_bLUpperArmAnglesAchieved = true; + VectorClear( m_vLUpperArmDesiredAngles ); + m_fTorsoMaxTurnSpeed = 120; + m_fTorsoCurrentTurnSpeed = 0; + m_bTorsoAnglesAchieved = true; + VectorClear( m_vTorsoDesiredAngles ); + m_pLookEntity = NULL; + m_pPointEntity = NULL; + m_pTurnEntity = NULL; + VectorClear( edict->s.eyeVector ); + m_bDoAI = true; + m_bTurretNoInitialCover = false; + m_bThink = false; + m_bAutoAvoidPlayer = true; + m_fHearing = 2048; + m_PainTime = 0; + m_fSight = world->m_fAIVisionDistance; + m_bNoLongPain = false; + hit_obstacle_time = 0; + VectorClear2D( obstacle_vel ); + m_bLockThinkState = false; + InitThinkStates(); + SetThinkState( 1, 0 ); + m_fMinDistance = 128; + m_fMinDistanceSquared = 128 * 128; + m_fMaxDistance = 1024; + m_fMaxDistanceSquared = 1024 * 1024; + m_fLeash = 512; + m_fLeashSquared = 512 * 512; + m_iEyeUpdateTime = level.inttime; + if( m_iEyeUpdateTime < 1000 ) + m_iEyeUpdateTime = 1000; + m_iEyeUpdateTime += rand() % 100 + 100; + m_vIntervalDir = vec_zero; + m_iIntervalDirTime = 0; + edict->r.lastNetTime = -10000000; + m_iEnemyCheckTime = 0; + m_iEnemyChangeTime = 0; + m_iEnemyVisibleCheckTime = 0; + m_bNewEnemy = false; + m_bEnemyIsDisguised = false; + m_bEnemyVisible = false; + m_iEnemyVisibleChangeTime = 0; + m_iLastEnemyVisibleTime = 0; + m_iEnemyFovCheckTime = 0; + m_iEnemyFovChangeTime = 0; + m_bEnemyInFOV = false; + m_iIgnoreSoundsMask = 0; + m_State = -1; + m_iStateTime = 0; + m_iGunPositionCheckTime = 0; + m_vLastEnemyPos = vec_origin; + m_iLastEnemyPosChangeTime = 0; + m_vScriptGoal = vec_origin; + m_iNextWatchStepTime = 0; + m_iCuriousTime = 0; + m_iCuriousLevel = 0; + m_iCuriousAnimHint = 0; + m_bScriptGoalValid = false; + m_bNoSurprise = false; + memset( &m_pPotentialCoverNode, 0, sizeof( m_pPotentialCoverNode ) ); + m_iPotentialCoverCount = 0; + m_pCoverNode = 0; + m_csSpecialAttack = 0; + m_sCurrentPathNodeIndex = -1; + m_iDisguiseLevel = 1; + m_iNextDisguiseTime = 1; + m_iDisguisePeriod = 30000; + m_bNeedReload = false; + m_bInReload = false; + m_bFaceEnemy = true; + m_fMaxDisguiseDistSquared = 256 * 256; + m_patrolCurrentNode = NULL; + m_csPatrolCurrentAnim = STRING_ANIM_RUN_SCR; + m_iSquadStandTime = 0; + m_bPatrolWaitTrigger = false; + m_fInterval = 128; + m_aimNode = NULL; + m_vHome = vec_origin; + m_bFixedLeash = false; + m_pTetherEnt = NULL; + m_pGrenade = NULL; + m_vGrenadePos = vec_origin; + m_eGrenadeMode = AI_GREN_TOSS_NONE; + m_iFirstGrenadeTime = 0; + m_bGrenadeBounced = false; + m_vGrenadeVel = vec_zero; + m_vKickDir = vec_zero; + m_fNoticeTimeScale = 1.0f; + m_iCanShootCheckTime = 0; + m_csAnimScript = STRING_ANIM_IDLE_SCR; + m_fSoundAwareness = 100; + m_fGrenadeAwareness = 20; + m_fMaxNoticeTimeScale = 1.0f; + m_bCanShootEnemy = false; + m_bEnableEnemy = true; + m_bDesiredEnableEnemy = true; + m_bEnablePain = true; + m_bAnimScriptSet = 0; + m_AnimMode = 0; + m_csAnimName = STRING_EMPTY; + m_csSayAnim = STRING_EMPTY; + m_csUpperAnim = STRING_EMPTY; + m_fDfwRequestedYaw = 0; + m_fDfwDerivedYaw = 0; + m_vDfwPos = vec_zero; + m_fDfwTime = 0; + m_AlarmNode = NULL; + m_csHeadSkin = STRING_EMPTY; + m_iWallDodgeTimeout = 0; + m_csHeadModel = STRING_EMPTY; + m_csLoadOut = STRING_EMPTY; + m_iRunHomeTime = 0; + m_iLookFlags = 0; + m_csWeapon = STRING_EMPTY; + m_eDontFaceWallMode = 0; + m_WallDir = 0; + VectorClear2D( m_PrevObstacleNormal ); + m_bNoIdleAfterAnim = false; + m_fMaxShareDistSquared = 0; + m_bBreathSteam = false; + m_fMoveDoneRadiusSquared = 0; + m_bForceAttackPlayer = false; + m_iNextLookTime = 0; + m_fLookAroundFov = 45; + m_bHasDesiredLookDest = false; + m_bHasDesiredLookAngles = false; + m_iLastFaceDecideTime = 0; + m_iOriginTime = -1; + m_fTurnDoneError = 0; + m_fBalconyHeight = 128; + m_bNoPlayerCollision = false; + for( int i = 0; i < MAX_ORIGIN_HISTORY; i++ ) + { + VectorClear2D( m_vOriginHistory[ i ] ); + } + m_bAnimating = false; + m_iCurrentHistory = 0; + m_bDog = false; + m_bBecomeRunner = false; +} + +void Actor::ShowInfo + ( + void + ) + +{ + Com_Printf( "-------------------------------------------------------------------------------\n" ); + Com_Printf( "Info for Actor:\n" ); + Com_Printf( "Current think type: %s %s\n", ThinkName().c_str(), ThinkStateName().c_str() ); + Com_Printf( "leash: %f\n", m_fLeash ); + Com_Printf( "mindist: %f\n", m_fMinDistance ); + Com_Printf( "maxdist: %f\n", m_fMaxDistance ); + + GlobalFuncs_t *func = &GlobalFuncs[ m_Think[ m_ThinkLevel ] ]; + if( func->ShowInfo ) + ( this->*func->ShowInfo )( ); + + return Com_Printf( "-------------------------------------------------------------------------------\n" ); +} + +void Actor::MoveTo + ( + Event *ev + ) + +{ + m_csPatrolCurrentAnim = ev->GetConstString( 1 ); + + if( ev->IsVectorAt( 2 ) ) + { + Vector vec = ev->GetVector( 2 ); + SetPatrolCurrentNode( vec ); + } + else + { + SetPatrolCurrentNode( ev->GetListener( 2 ) ); + } + + if( m_patrolCurrentNode ) + { + m_vScriptGoal = origin; + m_bScriptGoalValid = true; + } + + SetThinkIdle( THINKSTATE_ATTACK ); +} + +void Actor::WalkTo + ( + Event *ev + ) + +{ + Event event = EV_Listener_ExecuteScript; + event.AddConstString( STRING_GLOBAL_WALKTO_SCR ); + event.AddValue( ev->GetValue( 1 ) ); + ExecuteScript( &event ); +} + +void Actor::RunTo + ( + Event *ev + ) + +{ + Event event = EV_Listener_ExecuteScript; + event.AddConstString( STRING_GLOBAL_RUNTO_SCR ); + event.AddValue( ev->GetValue( 1 ) ); + ExecuteScript( &event ); +} + +void Actor::CrouchTo + ( + Event *ev + ) + +{ + Event event = EV_Listener_ExecuteScript; + event.AddConstString( STRING_GLOBAL_CROUCHTO_SCR ); + event.AddValue( ev->GetValue( 1 ) ); + ExecuteScript( &event ); +} + +void Actor::CrawlTo + ( + Event *ev + ) + +{ + Event event = EV_Listener_ExecuteScript; + event.AddConstString( STRING_GLOBAL_CRAWLTO_SCR ); + event.AddValue( ev->GetValue( 1 ) ); + ExecuteScript( &event ); +} + +void Actor::AimAt + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); + + if( ev->IsVectorAt( 1 ) ) + { + + } +} + +void Actor::DefaultRestart + ( + void + ) + +{ + EndState( m_ThinkLevel ); + BeginState(); +} + +void Actor::SuspendState + ( + void + ) + +{ + GlobalFuncs_t *func = &GlobalFuncs[ m_Think[ m_ThinkLevel ] ]; + + if( func->SuspendState ) + ( this->*func->SuspendState )( ); +} + +void Actor::ResumeState + ( + void + ) + +{ + GlobalFuncs_t *func = &GlobalFuncs[ m_Think[ m_ThinkLevel ] ]; + + if( func->ResumeState ) + ( this->*func->ResumeState )( ); +} + +void Actor::BeginState + ( + void + ) + +{ + m_Think[ m_ThinkLevel ] = m_ThinkMap[ m_ThinkState ]; + + GlobalFuncs_t *func = &GlobalFuncs[ m_Think[ m_ThinkLevel ] ]; + + if( func ) + ( this->*func->BeginState )(); + + m_Think[ m_ThinkLevel ] = m_ThinkMap[ m_ThinkState ]; +} + +void Actor::EndState + ( + int level + ) + +{ + GlobalFuncs_t *func = &GlobalFuncs[ m_Think[ level ] ]; + + m_Think[ level ] = 0; + + if( func->EndState ) + ( this->*func->EndState )(); + + if( m_pAnimThread ) + m_pAnimThread->AbortRegistration( STRING_EMPTY, this ); +} + +void Actor::RestartState + ( + void + ) + +{ + GlobalFuncs_t *func = &GlobalFuncs[ m_Think[ m_ThinkLevel ] ]; + + if( func->ThinkState ) + ( this->*func->ThinkState )(); +} + +void Actor::setContentsSolid + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::InitThinkStates + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::UpdateEyeOrigin + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::RequireThink + ( + void + ) + +{ + /* + if( g_entities[ 0 ].entity ) + return ( level.inttime < edict->r.lastNetTime + 60000 ); + else + return false; + */ + + return true; +} + +void Actor::UpdateEnemy + ( + int iMaxDirtyTime + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::UpdateEnemyInternal + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetEnemy + ( + Sentient *pEnemy, + bool bForceConfirmed + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetEnemyPos + ( + Vector vPos + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ResetBodyQueue + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::AddToBodyQue + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +Vector Actor::GetAntiBunchPoint + ( + void + ) + +{ + // FIXME: stub + STUB(); + return vec_zero; +} + +void Actor::InitVoid + ( + GlobalFuncs_t *func + ) + +{ + func->IsState = &Actor::IsVoidState; +} + +char *Actor::DumpCallTrace + ( + const char *pszFmt, + ... + ) const + +{ + // FIXME: stub + STUB(); + return NULL; +} + +void Actor::Init + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FixAIParameters + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::AttackEntryAnimation + ( + void + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::CheckForThinkStateTransition + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::CheckForTransition + ( + int state, + int level + ) + +{ + GlobalFuncs_t *func; + + if( m_ThinkStates[ level ] != state ) + { + func = &GlobalFuncs[ m_ThinkMap[ state ] ]; + + if( func->PassesTransitionConditions && ( this->*( func->PassesTransitionConditions ) )() ) + { + SetThinkState( state, 0 ); + return true; + } + } + + return false; +} +bool Actor::PassesTransitionConditions_Grenade + ( + void + ) + +{ + if( !m_bLockThinkState && m_bEnableEnemy && m_pGrenade ) + { + return m_fGrenadeAwareness >= random(); + } + + return false; +} + +bool Actor::PassesTransitionConditions_Attack + ( + void + ) + +{ + if( level.inttime > m_iEnemyCheckTime ) + UpdateEnemyInternal(); + + if( m_bLockThinkState ) + return false; + + if( m_Enemy && !( m_Enemy->flags & FL_NOTARGET ) ) + { + if( m_bEnemyIsDisguised || m_Enemy->m_bIsDisguised ) + { + if( !m_bForceAttackPlayer && m_ThinkState != 4 ) + return true; + } + + if( m_PotentialEnemies.GetCurrentVisibility() > 0.999f ) + return true; + } + + return false; +} + +bool Actor::PassesTransitionConditions_Disguise + ( + void + ) + +{ + if( m_bLockThinkState ) + return false; + + if( m_iNextDisguiseTime > level.inttime ) + return false; + + m_iNextDisguiseTime = level.inttime + 200; + + if( level.inttime > m_iEnemyCheckTime + 200 ) + UpdateEnemyInternal(); + + if( !m_Enemy ) + return false; + + if( m_bEnemyIsDisguised || m_Enemy->m_bIsDisguised ) + { + if( !m_bForceAttackPlayer && m_ThinkState != 4 ) + { + if( m_PotentialEnemies.GetCurrentVisibility() > 0.999f ) + { + if( fabs( m_Enemy->origin[ 2 ] - origin[ 2 ] ) <= 48.0f ) + { + vec2_t delta; + float fRadius; + + delta[ 0 ] = m_Enemy->origin[ 0 ] - origin[ 0 ]; + delta[ 1 ] = m_Enemy->origin[ 1 ] - origin[ 1 ]; + + fRadius = delta[ 0 ] * delta[ 0 ] + delta[ 1 ] * delta[ 1 ]; + + if( fRadius > 1024.0f && fRadius < m_fMaxDisguiseDistSquared ) + { + Player *player = ( Player * )G_GetEntity( 0 ); + Vector pos = player->EyePosition(); + + return G_SightTrace( + pos, + vec_zero, + vec_zero, + centroid, + this, + player, + MASK_TRANSITION, + qfalse, + "Actor::PassesTransitionConditions_Disguise" ); + } + } + } + } + } + + return false; +} + +bool Actor::PassesTransitionConditions_Curious + ( + void + ) + +{ + + if( level.inttime > m_iEnemyCheckTime + 200 ) + UpdateEnemyInternal(); + + if( m_bLockThinkState ) + return false; + + if( !m_Enemy && m_iCuriousTime ) + { + m_iCuriousAnimHint = 6; + return true; + } + + if( m_bEnemyIsDisguised || m_Enemy->m_bIsDisguised ) + { + if( !m_bForceAttackPlayer && m_ThinkState != 4 ) + { + m_iCuriousAnimHint = 6; + return true; + } + } + + if( m_PotentialEnemies.GetCurrentVisibility() <= 0.999f ) + { + m_iCuriousAnimHint = 6; + return true; + } + + return false; +} + +bool Actor::PassesTransitionConditions_Idle + ( + void + ) + +{ + + if( m_bEnableEnemy ) + { + if( level.inttime > m_iEnemyCheckTime + 500 ) + UpdateEnemyInternal(); + } + + if( m_bLockThinkState ) + return false; + + if( !m_Enemy && !m_iCuriousTime ) + return true; + + return false; +} + +void Actor::UpdateEnableEnemy + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ThinkStateTransitions + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::TransitionState + ( + int iNewState, + int iPadTime + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ChangeAnim + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::UpdateSayAnim + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::UpdateUpperAnim + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::UpdateAnim + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::StoppedWaitFor + ( + const_str name, + bool bDeleting + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::ValidGrenadePath + ( + Vector& vFrom, + Vector& vTo, + Vector& vVel + ) const + +{ + // FIXME: stub + STUB(); + return false; +} + +Vector Actor::CalcThrowVelocity + ( + Vector& vFrom, + Vector& vTo + ) + +{ + // FIXME: stub + STUB(); + return vec_zero; +} + +Vector Actor::CanThrowGrenade + ( + Vector& vFrom, + Vector& vTo + ) const + +{ + // FIXME: stub + STUB(); + return vec_zero; +} + +Vector Actor::CalcRollVelocity + ( + Vector& vFrom, + Vector& vTo + ) + +{ + // FIXME: stub + STUB(); + return vec_zero; +} + +Vector Actor::CanRollGrenade + ( + Vector& vFrom, + Vector& vTo + ) const + +{ + // FIXME: stub + STUB(); + return vec_zero; +} + +bool Actor::CanTossGrenadeThroughHint + ( + GrenadeHint *pHint, + Vector& vFrom, + Vector& vTo, + bool bDesperate, + Vector *pvVel, + eGrenadeTossMode *peMode + ) const + +{ + // FIXME: stub + STUB(); + return false; +} + +Vector Actor::GrenadeThrowPoint + ( + Vector& vFrom, + Vector& vDelta, + const_str csAnim + ) + +{ + // FIXME: stub + STUB(); + return vec_zero; +} + +Vector Actor::CalcKickVelocity + ( + Vector& vDelta, + float fDist + ) const + +{ + // FIXME: stub + STUB(); + return vec_zero; +} + +bool Actor::CanKickGrenade + ( + Vector &vFrom, + Vector &vTo, + Vector &vFace, + Vector *pvVel + ) const + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::GrenadeWillHurtTeamAt + ( + Vector& vTo + ) const + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::CanGetGrenadeFromAToB + ( + Vector& vFrom, + Vector& vTo, + bool bDesperate, + Vector *pvVel, + eGrenadeTossMode *peMode + ) const + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::DecideToThrowGrenade + ( + Vector& vTo, + Vector *pvVel, + eGrenadeTossMode *peMode + ) const + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::Grenade_EventFire + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::GenericGrenadeTossThink + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::CanSee + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::PostThink + ( + bool bDontFaceWall + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetMoveInfo + ( + mmove_t *mm + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::GetMoveInfo + ( + mmove_t *mm + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::DoFailSafeMove + ( + vec3_t dest + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::TouchStuff + ( + mmove_t *mm + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ExtractConstraints + ( + mmove_t *mm + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGiveWeaponInternal + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGiveWeapon + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetWeapon + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FireWeapon + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::CanTarget + ( + void + ) + +{ + return true; +} + +bool Actor::IsImmortal + ( + void + ) + +{ + return false; +} + +bool Actor::IsVoidState + ( + int state + ) + +{ + return true; +} + +bool Actor::IsIdleState + ( + int state + ) + +{ + return state == THINKSTATE_IDLE; +} + +bool Actor::IsCuriousState + ( + int state + ) + +{ + return state == THINKSTATE_CURIOUS; +} + +bool Actor::IsDisguiseState + ( + int state + ) + +{ + return state == THINKSTATE_DISGUISE; +} + +bool Actor::IsAttackState + ( + int state + ) + +{ + return state == THINKSTATE_ATTACK; +} + +bool Actor::IsGrenadeState + ( + int state + ) + +{ + return state == THINKSTATE_GRENADE; +} + +bool Actor::IsPainState + ( + int state + ) + +{ + return state == THINKSTATE_PAIN; +} + +bool Actor::IsKilledState + ( + int state + ) + +{ + return state == THINKSTATE_KILLED; +} + +bool Actor::IsMachineGunnerState + ( + int state + ) + +{ + return true; +} + +bool Actor::IsDogState + ( + int state + ) + +{ + return true; +} + +void Actor::IgnoreSoundSet + ( + int iType + ) + +{ + m_iIgnoreSoundsMask |= 1 << iType; +} + +void Actor::IgnoreSoundSetAll + ( + void + ) + +{ + m_iIgnoreSoundsMask = 65535; +} + +void Actor::IgnoreSoundClear + ( + int iType + ) + +{ + m_iIgnoreSoundsMask &= ~iType; +} + +void Actor::IgnoreSoundClearAll + ( + void + ) + +{ + m_iIgnoreSoundsMask = 0; +} + +bool Actor::IgnoreSound + ( + int iType + ) + +{ + return ( m_iIgnoreSoundsMask >> iType ) & 1; +} + +void Actor::EventShareEnemy + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventShareGrenade + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ReceiveAIEvent + ( + vec3_t event_origin, + int iType, + Entity *originator, + float fDistSquared, + float fMaxDistSquared + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::DefaultReceiveAIEvent + ( + vec3_t event_origin, + int iType, + Entity *originator, + float fDistSquared, + float fMaxDistSquared + ) + +{ + // FIXME: stub + STUB(); +} + +int Actor::PriorityForEventType + ( + int iType + ) + +{ + switch( iType ) + { + case 1: + return 7; + case 2: + return 5; + case 3: + return 6; + case 4: + case 5: + return 3; + case 6: + case 7: + return 4; + case 8: + return 1; + case 9: + case 10: + return 2; + case 11: + return 8; + default: + assert( !"PriorityForEventType: unknown ai_event type" ); + return 0; + } +} + +void Actor::CuriousSound + ( + int iType, + vec3_t sound_origin, + float fDistSquared, + float fMaxDistSquared, + Entity *originator + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::WeaponSound + ( + int iType, + vec3_t sound_origin, + float fDistSquared, + float fMaxDistSquared, + Entity *originator + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FootstepSound + ( + vec3_t sound_origin, + float fDistSquared, + float fMaxDistSquared, + Entity *originator + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::VoiceSound + ( + int iType, + vec3_t sound_origin, + float fDistSquared, + float fMaxDistSquared, + Entity *originator + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::GrenadeNotification + ( + Entity *originator + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetGrenade + ( + Entity *pGrenade + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::NotifySquadmateKilled + ( + Sentient *pSquadMate, + Sentient *pAttacker + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::RaiseAlertnessForEventType + ( + int iType + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::RaiseAlertness + ( + float fAmout + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::CanSee + ( + Entity *e1, + float fov, + float vision_distance + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +Vector Actor::GunPosition + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return vec_zero; +} + +bool Actor::WithinVisionDistance + ( + Entity *ent + ) const + +{ + float fRadius = world->m_fAIVisionDistance; + + if( world->m_fAIVisionDistance == 0.0f ) + { + fRadius = m_fSight; + } + else if( m_fSight <= fRadius ) + { + fRadius = m_fSight; + } + + if( ent ) + { + Vector vDelta = ent->origin - origin; + return vDelta.lengthSquared() < fRadius; + } + + return false; +} + +bool Actor::InFOV + ( + Vector pos, + float check_fov, + float check_fovdot + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::EnemyInFOV + ( + int iMaxDirtyTime + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::InFOV + ( + Vector pos + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::InFOV + ( + Entity *ent + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::CanSeeNoFOV + ( + Entity *ent + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::CanSeeFOV + ( + Entity *ent + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::CanSeeEnemyFOV + ( + int iMaxFovDirtyTime, + int iMaxSightDirtyTime + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::CanShoot + ( + Entity *ent + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::CanSeeFrom + ( + vec3_t pos, + Entity *ent + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::CanSeeEnemy + ( + int iMaxDirtyTime + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::CanShootEnemy + ( + int iMaxDirtyTime + ) + +{ + if( level.inttime > iMaxDirtyTime + m_iCanShootCheckTime ) + CanShoot( m_Enemy ); + + return m_bCanShootEnemy; +} + +void Actor::ShowInfo + ( + float fDot, + float fDist + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::DefaultPain + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::HandlePain + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventPain + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::DefaultKilled + ( + Event *ev, + bool bPlayDeathAnim + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::HandleKilled + ( + Event *ev, + bool bPlayDeathAnim + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::DispatchEventKilled + ( + Event *ev, + bool bPlayDeathAnim + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventKilled + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventBeDead + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::DeathEmbalm + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::DeathSinkStart + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::NoticeShot + ( + Sentient *pShooter, + Sentient *pTarget, + float fDist + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::NoticeFootstep + ( + Sentient *pPedestrian + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::NoticeVoice + ( + Sentient *pVocallist + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::ClearLookEntity + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::LookAt + ( + Vector& vec + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::LookAt + ( + Listener *l + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ForwardLook + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::LookAtLookEntity + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::IdleLook + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::IdleLook + ( + vec3_t dir + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetDesiredLookDir + ( + vec3_t dir + ) + +{ + m_bHasDesiredLookAngles = true; + vectoangles( dir, m_DesiredLookAngles ); + m_DesiredLookAngles[ 1 ] = m_DesiredLookAngles[ 1 ] - angles[ 1 ]; + m_DesiredLookAngles[ 1 ] = AngleNormalize180( m_DesiredLookAngles[ 1 ] ); + m_DesiredLookAngles[ 0 ] = AngleNormalize180( m_DesiredLookAngles[ 0 ] ); +} + +void Actor::SetDesiredLookAnglesRelative + ( + vec3_t ang + ) + +{ + m_bHasDesiredLookAngles = true; + m_DesiredLookAngles[ 0 ] = AngleNormalize180( ang[ 0 ] ); + m_DesiredLookAngles[ 1 ] = AngleNormalize180( ang[ 1 ] ); + m_DesiredLookAngles[ 2 ] = AngleNormalize180( ang[ 2 ] ); +} + +void Actor::EventLookAt + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventEyesLookAt + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::NoPoint + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::IdlePoint + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ClearPointEntity + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::PointAt + ( + Vector& vec + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::PointAt + ( + Listener* l + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventPointAt + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ClearTurnEntity + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::TurnTo + ( + Vector& vec + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::TurnTo + ( + Listener *l + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::IdleTurn + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventTurnTo + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetTurnDoneError + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetTurnDoneError + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::LookAround + ( + float fFovAdd + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::SoundSayAnim + ( + const_str name, + int bLevelSayAnim + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::EventSetAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventIdleSayAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSayAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetSayAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetMotionAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetAimMotionAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetActionAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventUpperAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetUpperAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventEndActionAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventDamagePuff + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SafeSetOrigin + ( + vec3_t newOrigin + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::DoMove + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::AnimFinished + ( + int slot, + bool stop + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::AnimFinished + ( + int slot + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::PlayAnimation + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::PlayScriptedAnimation + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::PlayNoclipAnimation + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::MoveDest + ( + float fMoveSpeed + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::MovePath + ( + float fMoveSpeed + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::MovePathGoal + ( + float fMoveSpeed + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Dumb + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::PhysicsOn + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::PhysicsOff + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventStart + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetMood + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetMood + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetAngleYawSpeed + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetAngleYawSpeed + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetAimTarget + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::UpdateAngles + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetLeashHome +( +Vector vHome +) + +{ + // FIXME: stub + STUB(); +} + +void Actor::AimAtTargetPos + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::AimAtAimNode + ( + void + ) + +{ + Vector vDir = mTargetPos - EyePosition() + Vector( 0, 0, 16 ); + SetDesiredLookDir( vDir ); + m_DesiredGunDir[ 0 ] = 360.0f - vDir.toPitch(); + m_DesiredGunDir[ 1 ] = vDir.toYaw(); + + m_YawAchieved = false; + m_DesiredYaw = vDir.toYaw(); +} + +void Actor::AimAtEnemyBehavior + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FaceMotion + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FaceDirectionDuringMotion + ( + vec3_t vLook + ) + +{ + // FIXME: stub + STUB(); +} + +float Actor::PathDistanceAlongVector + ( + vec3_t vDir + ) + +{ + Vector vDelta = m_Path.CurrentDelta(); + + return DotProduct2D( vDelta, vDir ); +} + +void Actor::FaceEnemyOrMotion + ( + int iTimeIntoMove + ) + +{ + // FIXME: stub + STUB(); +} + +int Actor::NextUpdateTime + ( + int iLastUpdateTime, + int iUpdatePeriod + ) + +{ + int i = iLastUpdateTime; + + do + i += iUpdatePeriod; + while( i < level.inttime ); + + return i; +} + +void Actor::ResetBoneControllers + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::UpdateBoneControllers + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ReadyToFire + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::GetLocalYawFromVector + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetSight + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetSight + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetHearing + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetHearing + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ClearPatrolCurrentNode + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::NextPatrolCurrentNode + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetPatrolCurrentNode + ( + Vector& vec + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetPatrolCurrentNode + ( + Listener *l + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetPatrolPath + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetPatrolPath + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetPatrolWaitTrigger + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetPatrolWaitTrigger + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ShowInfo_PatrolCurrentNode + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::MoveOnPathWithSquad + ( + void + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::MoveToWaypointWithPlayer + ( + void + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::PatrolNextNodeExists + ( + void + ) + +{ + return m_patrolCurrentNode && !( m_patrolCurrentNode->IsSubclassOfTempWaypoint() ) && m_patrolCurrentNode->Next(); +} + +void Actor::UpdatePatrolCurrentNode + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::MoveToPatrolCurrentNode + ( + void + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::ClearAimNode + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetAimNode + ( + Vector& vec + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetAimNode + ( + Listener *l + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ShowInfo_AimNode + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetAccuracy + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetAccuracy + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +int Actor::GetThinkType + ( + const_str csName + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::SetThink + ( + int state, + int think + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetThinkIdle + ( + int think_idle + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetThinkState + ( + int state, + int level + ) + +{ + +} + +void Actor::EndCurrentThinkState + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ClearThinkStates + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +int Actor::CurrentThink + ( + void + ) const + +{ + return m_Think[ m_ThinkLevel ]; +} + +bool Actor::IsAttacking + ( + void + ) const + +{ + return m_ThinkStates[ 0 ] == THINKSTATE_ATTACK; +} + +void Actor::EventGetFov + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetFov + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetDestIdle + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetDestIdle2 + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetTypeIdle + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetTypeIdle + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetTypeAttack + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetTypeAttack + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetTypeDisguise + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetTypeDisguise + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetDisguiseLevel + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetDisguiseLevel + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetTypeGrenade + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetTypeGrenade + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetMinDistance + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetMinDistance + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetMaxDistance + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetMaxDistance + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetLeash + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetLeash + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetInterval + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetInterval + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventDistToEnemy + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetRunAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetWalkAnim + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetAnimName + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetAnimName + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetDisguiseRange + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetDisguiseRange + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetDisguisePeriod + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetDisguisePeriod + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetDisguiseAcceptThread + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetDisguiseAcceptThread + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventAttackPlayer + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ForceAttackPlayer + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetAlarmNode + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetAlarmNode + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetAlarmThread + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetAlarmThread + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetSoundAwareness + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetSoundAwareness + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetGrenadeAwareness + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetGrenadeAwareness + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +str Actor::ThinkName + ( + void + ) const + +{ + return Director.GetString( m_Think[ m_ThinkLevel ] ); +} + +str Actor::ThinkStateName + ( + void + ) const + +{ + return Director.GetString( m_ThinkState ); +} + +void Actor::EventSetTurret + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetTurret + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventEnableEnemy + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventEnablePain + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventActivate + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetAmmoGrenade + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetAmmoGrenade + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventInterruptPoint + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventAnimScript + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventAnimScript_Scripted + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventAnimScript_Noclip + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventReload_mg42 + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetPathWithLeash + ( + Vector vDestPos, + const char *description, + int iMaxDirtyTime + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetPathWithLeash + ( + SimpleEntity *pDestNode, + const char *description, + int iMaxDirtyTime + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FindPathAwayWithLeash + ( + vec3_t vAwayFrom, + vec3_t vDirPreferred, + float fMinSafeDist + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FindPathNearWithLeash +( +vec3_t vNearbyTo, +float fCloseDistSquared +) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::CanMovePathWithLeash + ( + void + ) const + +{ + vec2_t delta; + + if( PathExists() ) + { + delta[ 0 ] = origin[ 0 ] - m_vHome[ 0 ]; + delta[ 1 ] = origin[ 1 ] - m_vHome[ 1 ]; + + return ( VectorLength2DSquared( delta ) < m_fLeashSquared ) || ( DotProduct2D( delta, m_Path.CurrentDelta() ) < 0.0f ); + } + + return false; +} + +bool Actor::MovePathWithLeash + ( + void + ) + +{ + if( CanMovePathWithLeash() ) + { + Anim_RunToInOpen( 2 ); + FaceMotion(); + return true; + } + else + { + Anim_Aim(); + return false; + } +} + +bool Actor::ShortenPathToAttack + ( + float fMinDist + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::StrafeToAttack +( +float fDist, +vec3_t vDir +) + +{ + + // FIXME: stub + STUB(); +} + +Vector Actor::GunTarget + ( + bool bNoCollision + ) + +{ + // FIXME: stub + STUB(); + return vec_zero; +} + +qboolean Actor::setModel + ( + void + ) + +{ + // FIXME: stub + STUB(); + + return Entity::setModel(); +} + +void Actor::EventSetHeadModel + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetHeadModel + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetHeadSkin + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetHeadSkin + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetNoIdle + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetNoIdle + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetEnemy + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetMaxNoticeTimeScale + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetMaxNoticeTimeScale + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetFixedLeash + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetFixedLeash + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Holster + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Unholster + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventHolster + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventUnholster + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSoundDone + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSound + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventIsEnemyVisible + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetEnemyVisibleChangeTime + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetLastEnemyVisibleTime + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetFallHeight + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetFallHeight + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventCanMoveTo + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventMoveDir + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventIntervalDir + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventResetLeash + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventTether + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetThinkState + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetEnemyShareRange + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetEnemyShareRange + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetKickDir + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetNoLongPain + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetNoLongPain + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetFavoriteEnemy + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetFavoriteEnemy + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetMumble + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetMumble + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetBreathSteam + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetBreathSteam + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetNextBreathTime + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventCalcGrenadeToss + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetNoSurprise + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetNoSurprise + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetSilent + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetSilent + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetAvoidPlayer + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetAvoidPlayer + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetLookAroundAngle + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetLookAroundAngle + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventHasCompleteLookahead + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventPathDist + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventCanShootEnemyFrom + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventCanShoot + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetInReload + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetInReload + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetReloadCover + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventBreakSpecial + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::GetVoiceType + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetVoiceType + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ResolveVoiceType + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetBalconyHeight + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventGetBalconyHeight + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +PathNode *Actor::FindSniperNodeAndSetPath + ( + bool *pbTryAgain + ) + +{ + PathNode *pSniperNode = PathManager.FindNearestSniperNode( this, origin, m_Enemy ); + + if( pSniperNode ) + { + SetPathWithLeash( pSniperNode, NULL, NULL ); + + if( PathExists() && ( PathComplete() || PathAvoidsSquadMates() ) ) + { + *pbTryAgain = true; + return pSniperNode; + } + + pSniperNode->MarkTemporarilyBad(); + *pbTryAgain = false; + } + else + { + *pbTryAgain = true; + } + + return NULL; +} + +void Actor::Remove + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::DontFaceWall + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::AvoidingFacingWall + ( + void + ) const + +{ + return m_eDontFaceWallMode <= 8; +} + +void Actor::EndStates + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ClearStates + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::CheckUnregister + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::BecomeCorpse + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::PathnodeClaimRevoked + ( + PathNode *node + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetPathToNotBlockSentient + ( + Sentient *pOther + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::EventSetMoveDoneRadius + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + + +bool Actor::CalcFallPath + ( + void + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::IdleThink + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ClearEnemies + ( + void + ) + +{ + m_PotentialEnemies.RemoveAll(); + SetEnemy( NULL, false ); +} + +bool Actor::EnemyIsDisguised + ( + void + ) + +{ + return ( m_bEnemyIsDisguised || m_Enemy->m_bIsDisguised ) && ( !m_bForceAttackPlayer && m_ThinkState != 4 ); +} + +void Actor::setOriginEvent + ( + Vector org + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::DumpAnimInfo + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::AutoArchiveModel + ( + void + ) + +{ + return false; +} diff --git a/code/game/actor.h b/code/game/actor.h new file mode 100644 index 00000000..44c455f5 --- /dev/null +++ b/code/game/actor.h @@ -0,0 +1,1476 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor.h: Base class for character AI. + +#ifndef __ACTOR_H__ +#define __ACTOR_H__ + +#include "g_local.h" +#include "simpleactor.h" +#include "actorenemy.h" +#include +#include +#include "grenadehint.h" +#include + +extern Event EV_Actor_Start; +extern Event EV_Actor_Dead; +extern Event EV_Actor_LookAt; +extern Event EV_Actor_TurnTo; +extern Event EV_Actor_FinishedBehavior; +extern Event EV_Actor_NotifyBehavior; +extern Event EV_Actor_FinishedMove; +extern Event EV_Actor_FinishedAnim; +extern Event EV_Actor_WalkTo; +extern Event EV_Actor_RunTo; +extern Event EV_Actor_Anim; +extern Event EV_Actor_AttackFinished; +extern Event EV_Actor_Attack; +extern Event EV_Actor_AttackPlayer; +extern Event EV_Actor_AIOn; +extern Event EV_Actor_AIOff; +extern Event EV_Actor_AIDeaf; +extern Event EV_Actor_AIDumb; +extern Event EV_ActorIncomingProjectile; +extern Event EV_Anim_Done; +extern Event EV_ActorOnlyShootable; +extern Event EV_Actor_BounceOff; +extern Event EV_Actor_Push; +extern Event EV_Actor_Statemap; +extern Event EV_Actor_SetTargetable; +extern Event EV_Actor_DeathEmbalm; + +// Bones used by actor + +#define ACTOR_MOUTH_TAG 0 +#define ACTOR_HEAD_TAG 1 +#define ACTOR_TORSO_TAG 2 + +// Dialog stuff + +#define LIP_SYNC_HZ 20.0 + +#define MAX_DIALOG_PARAMETERS_LENGTH 100 + +#define MAX_DIALOG_PARM_LENGTH 64 +#define MAX_DIALOG_PARMS 10 + +#define DIALOG_PARM_TYPE_NONE 0 +#define DIALOG_PARM_TYPE_PLAYERHAS 1 +#define DIALOG_PARM_TYPE_PLAYERHASNOT 2 +#define DIALOG_PARM_TYPE_HAS 3 +#define DIALOG_PARM_TYPE_HASNOT 4 +#define DIALOG_PARM_TYPE_DEPENDS 5 +#define DIALOG_PARM_TYPE_DEPENDSNOT 6 + +typedef struct +{ + byte type; + char parm[ MAX_DIALOG_PARM_LENGTH ]; +} DialogParm_t; + +typedef struct DialogNode_s + { + char alias_name[ MAX_ALIAS_NAME_LENGTH ]; + int random_flag; + int number_of_parms; + float random_percent; + DialogParm_t parms[ MAX_DIALOG_PARMS ]; + struct DialogNode_s *next; + } DialogNode_t; + +typedef enum + { + IS_INANIMATE, + IS_MONSTER, + IS_ENEMY, + IS_CIVILIAN, + IS_FRIEND, + IS_ANIMAL, + NUM_ACTORTYPES + } actortype_t; + +// Stimuli types + +#define STIMULI_ALL -1 +#define STIMULI_NONE 0 +#define STIMULI_SIGHT (1<<0) +#define STIMULI_SOUND (1<<1) +#define STIMULI_PAIN (1<<2) +#define STIMULI_SCRIPT (1<<3) + +#define MAX_INACTIVE_TIME 30.0 + +// State flags + +#define STATE_FLAG_IN_PAIN (1<<0) +#define STATE_FLAG_MELEE_HIT (1<<1) +#define STATE_FLAG_TOUCHED (1<<2) +#define STATE_FLAG_ACTIVATED (1<<3) +#define STATE_FLAG_USED (1<<4) +#define STATE_FLAG_TWITCH (1<<5) +#define STATE_FLAG_BLOCKED_HIT (1<<6) +#define STATE_FLAG_SMALL_PAIN (1<<7) +#define STATE_FLAG_OTHER_DIED (1<<8) +#define STATE_FLAG_STUCK (1<<9) +#define STATE_FLAG_NO_PATH (1<<10) + +// Actor modes + +#define ACTOR_MODE_NONE 0 +#define ACTOR_MODE_IDLE 1 +#define ACTOR_MODE_AI 2 +#define ACTOR_MODE_SCRIPT 3 +#define ACTOR_MODE_TALK 4 + +// Pain types + +#define PAIN_SMALL 0 +#define PAIN_BIG 1 + +typedef struct +{ + EntityPtr ent; + unsigned int state_flags; +} part_t; + +// Actor flags + +#define ACTOR_FLAG_NOISE_HEARD 0 +#define ACTOR_FLAG_INVESTIGATING 1 +#define ACTOR_FLAG_DEATHGIB 2 +#define ACTOR_FLAG_DEATHFADE 3 +#define ACTOR_FLAG_NOCHATTER 4 +#define ACTOR_FLAG_INACTIVE 5 +#define ACTOR_FLAG_ANIM_DONE 6 +#define ACTOR_FLAG_STATE_DONE_TIME_VALID 7 +#define ACTOR_FLAG_AI_ON 8 +#define ACTOR_FLAG_LAST_CANSEEENEMY 9 +#define ACTOR_FLAG_LAST_CANSEEENEMY_NOFOV 10 +#define ACTOR_FLAG_DIALOG_PLAYING 11 +#define ACTOR_FLAG_ALLOW_TALK 12 +#define ACTOR_FLAG_DAMAGE_ONCE_ON 13 +#define ACTOR_FLAG_DAMAGE_ONCE_DAMAGED 14 +#define ACTOR_FLAG_BOUNCE_OFF 15 +#define ACTOR_FLAG_NOTIFY_OTHERS_AT_DEATH 16 +#define ACTOR_FLAG_HAS_THING1 17 +#define ACTOR_FLAG_HAS_THING2 18 +#define ACTOR_FLAG_HAS_THING3 19 +#define ACTOR_FLAG_HAS_THING4 20 +#define ACTOR_FLAG_LAST_ATTACK_HIT 21 +#define ACTOR_FLAG_STARTED 22 +#define ACTOR_FLAG_ALLOW_HANGBACK 23 +#define ACTOR_FLAG_USE_GRAVITY 24 +#define ACTOR_FLAG_SPAWN_FAILED 25 +#define ACTOR_FLAG_FADING_OUT 26 +#define ACTOR_FLAG_DEATHSHRINK 27 +#define ACTOR_FLAG_DEATHSINK 28 +#define ACTOR_FLAG_STAYSOLID 29 +#define ACTOR_FLAG_STUNNED 30 +#define ACTOR_FLAG_ALLOW_FALL 31 +#define ACTOR_FLAG_FINISHED 32 +#define ACTOR_FLAG_IN_LIMBO 33 +#define ACTOR_FLAG_CAN_WALK_ON_OTHERS 34 +#define ACTOR_FLAG_PUSHABLE 35 +#define ACTOR_FLAG_LAST_TRY_TALK 36 +#define ACTOR_FLAG_ATTACKABLE_BY_ACTORS 37 +#define ACTOR_FLAG_TARGETABLE 38 +#define ACTOR_FLAG_ATTACK_ACTORS 39 +#define ACTOR_FLAG_IMMORTAL 40 +#define ACTOR_FLAG_TURNING_HEAD 41 +#define ACTOR_FLAG_DIE_COMPLETELY 42 +#define ACTOR_FLAG_BLEED_AFTER_DEATH 43 +#define ACTOR_FLAG_IGNORE_STUCK_WARNING 44 +#define ACTOR_FLAG_IGNORE_OFF_GROUND_WARNING 45 +#define ACTOR_FLAG_ALLOWED_TO_KILL 46 +#define ACTOR_FLAG_TOUCH_TRIGGERS 47 +#define ACTOR_FLAG_IGNORE_WATER 48 +#define ACTOR_FLAG_NEVER_IGNORE_SOUNDS 49 +#define ACTOR_FLAG_SIMPLE_PATHFINDING 50 +#define ACTOR_FLAG_HAVE_MOVED 51 +#define ACTOR_FLAG_NO_PAIN_SOUNDS 52 +#define ACTOR_FLAG_UPDATE_BOSS_HEALTH 53 +#define ACTOR_FLAG_IGNORE_PAIN_FROM_ACTORS 54 +#define ACTOR_FLAG_DAMAGE_ALLOWED 55 +#define ACTOR_FLAG_ALWAYS_GIVE_WATER 56 + + +// The last actor_flag number and this one (ACTOR_FLAG_MAX) should match + +#define ACTOR_FLAG_MAX 56 + +#define MAX_ORIGIN_HISTORY 4 +#define MAX_THINKMAP 9 +#define MAX_THINKSTATES 4 +#define MAX_COVER_NODES 16 +#define MAX_BODYQUEUE 5 +#define MAX_GLOBAL_FUNCS 35 + +typedef enum +{ + AI_GREN_TOSS_NONE, + AI_GREN_TOSS_THROW, + AI_GREN_TOSS_ROLL, + AI_GREN_TOSS_HINT, + AI_GREN_KICK +} eGrenadeTossMode; + +typedef struct { + byte length; + byte currentPos; + byte loop; + float startTime; + vec3_t pos[ 1 ]; +} FallPath; + +#define THINKSTATE_IDLE 1 +#define THINKSTATE_PAIN 2 +#define THINKSTATE_KILLED 3 +#define THINKSTATE_ATTACK 4 +#define THINKSTATE_CURIOUS 5 +#define THINKSTATE_DISGUISE 6 +#define THINKSTATE_GRENADE 7 + +#define AI_EVENT_NONE 0 +#define AI_EVENT_WEAPON_FIRE 1 +#define AI_EVENT_WEAPON_IMPACT 2 +#define AI_EVENT_EXPLOSION 3 +#define AI_EVENT_AMERICAN_VOICE 4 +#define AI_EVENT_GERMAN_VOICE 5 +#define AI_EVENT_AMERICAN_URGENT 6 +#define AI_EVENT_GERMAN_URGENT 7 +#define AI_EVENT_MISC 8 +#define AI_EVENT_MISC_LOUD 9 +#define AI_EVENT_FOOTSTEP 10 +#define AI_EVENT_GRENADE 11 + +class Actor; +typedef SafePtr ActorPtr; + +class Actor : public SimpleActor +{ + struct GlobalFuncs_t { + void ( Actor::*ThinkState )( void ); + void ( Actor::*BeginState )( void ); + void ( Actor::*ResumeState )( void ); + void ( Actor::*EndState )( void ); + void ( Actor::*SuspendState )( void ); + void ( Actor::*un3 )( void ); + void ( Actor::*FinishedAnimation )( void ); + void ( Actor::*PostShoot )( void ); + void ( Actor::*Pain )( Event *ev ); + void ( Actor::*Killed )( Event *ev, bool bPlayDeathAnim ); + bool ( Actor::*PassesTransitionConditions )( void ); + void ( Actor::*ShowInfo )( void ); + void ( Actor::*PathnodeClaimRevoked )( void ); + void ( Actor::*ReceiveAIEvent )( vec3_t event_origin, int iType, Entity *originator, float fDistSquared, float fMaxDistSquared ); + bool ( *IsState )( int state ); + }; + +public: + static GlobalFuncs_t GlobalFuncs[ MAX_GLOBAL_FUNCS ]; + static const_str m_csThinkNames[ MAX_GLOBAL_FUNCS ]; + static const_str m_csThinkStateNames[ MAX_THINKMAP ]; + int m_ThinkMap[ MAX_THINKMAP ]; + int m_ThinkStates[ MAX_THINKSTATES ]; + int m_Think[ MAX_THINKSTATES ]; + int m_ThinkLevel; + int m_ThinkState; + int m_State; + int m_iStateTime; + bool m_bLockThinkState; + bool m_bDirtyThinkState; + char *m_pszDebugState; + bool m_bAnimating; + bool m_bDog; + int mVoiceType; + bool m_bSilent; + bool m_bNoSurprise; + bool m_bMumble; + bool m_bBreathSteam; + const_str m_csHeadModel; + const_str m_csHeadSkin; + const_str m_csWeapon; + const_str m_csLoadOut; + SentientPtr m_FavoriteEnemy; + int m_iEnemyCheckTime; + int m_iEnemyChangeTime; + int m_iEnemyVisibleCheckTime; + int m_iEnemyVisibleChangeTime; + int m_iLastEnemyVisibleTime; + int m_iEnemyFovCheckTime; + int m_iEnemyFovChangeTime; + Vector m_vLastEnemyPos; + int m_iLastEnemyPosChangeTime; + float m_fMaxShareDistSquared; + int m_iCanShootCheckTime; + bool m_bCanShootEnemy; + bool m_bDesiredEnableEnemy; + bool m_bEnableEnemy; + bool m_bEnablePain; + bool m_bNoLongPain; + bool m_bNewEnemy; + bool m_bEnemyIsDisguised; + bool m_bEnemyVisible; + bool m_bEnemyInFOV; + bool m_bForceAttackPlayer; + bool m_bAutoAvoidPlayer; + bool m_bNoIdleAfterAnim; + bool m_bAnimScriptSet; + const_str m_csAnimScript; + int m_AnimMode; + float m_fDfwRequestedYaw; + float m_fDfwDerivedYaw; + Vector m_vDfwPos; + float m_fDfwTime; + int m_iGunPositionCheckTime; + Vector m_vGunPosition; + int m_iWallDodgeTimeout; + vec2_t m_PrevObstacleNormal; + char m_WallDir; + float m_fMoveDoneRadiusSquared; + int m_iOriginTime; + bool m_bFaceEnemy; + bool m_bDoPhysics; + bool m_bBecomeRunner; + bool m_bPatrolWaitTrigger; + bool m_bScriptGoalValid; + Vector m_vScriptGoal; + int m_iNextWatchStepTime; + SafePtr m_patrolCurrentNode; + const_str m_csPatrolCurrentAnim; + int m_iSquadStandTime; + float m_fInterval; + int m_iIntervalDirTime; + Vector m_vIntervalDir; + short m_sCurrentPathNodeIndex; + int m_PainState; + int m_iCuriousTime; + int m_iCuriousLevel; + int m_iCuriousAnimHint; + int m_iNextDisguiseTime; + int m_iDisguisePeriod; + float m_fMaxDisguiseDistSquared; + int m_iEnemyShowPapersTime; + ScriptThreadLabel m_DisguiseAcceptThread; + int m_iDisguiseLevel; + SafePtr< SimpleEntity > m_AlarmNode; + ScriptThreadLabel m_AlarmThread; + int m_iRunHomeTime; + bool m_bTurretNoInitialCover; + PathNode *m_pPotentialCoverNode[ MAX_COVER_NODES ]; + int m_iPotentialCoverCount; + PathNode *m_pCoverNode; + const_str m_csSpecialAttack; + bool m_bInReload; + bool m_bNeedReload; + bool mbBreakSpecialAttack; + bool m_bGrenadeBounced; + SafePtr m_pGrenade; + Vector m_vGrenadePos; + int m_iFirstGrenadeTime; + int m_eGrenadeState; + eGrenadeTossMode m_eGrenadeMode; + Vector m_vGrenadeVel; + Vector m_vKickDir; + FallPath *m_pFallPath; + float m_fBalconyHeight; + bool m_bNoPlayerCollision; + float m_fNoticeTimeScale; + float m_fMaxNoticeTimeScale; + ActorEnemySet m_PotentialEnemies; + float m_fSight; + float m_fHearing; + float m_fSoundAwareness; + float m_fGrenadeAwareness; + int m_iIgnoreSoundsMask; + float m_fFov; + float m_fFovDot; + int m_iEyeUpdateTime; + Vector m_vEyeDir; + int m_iNextLookTime; + float m_fLookAroundFov; + SafePtr m_pLookEntity; + int m_iLookFlags; + SafePtr m_pPointEntity; + SafePtr m_pTurnEntity; + float m_fTurnDoneError; + float m_fAngleYawSpeed; + SafePtr m_aimNode; + int m_eDontFaceWallMode; + int m_iLastFaceDecideTime; + vec2_t m_vOriginHistory[ MAX_ORIGIN_HISTORY ]; + int m_iCurrentHistory; + bool m_bHeadAnglesAchieved; + bool m_bLUpperArmAnglesAchieved; + bool m_bTorsoAnglesAchieved; + bool align3; + float m_fHeadMaxTurnSpeed; + vec3_t m_vHeadDesiredAngles; + float m_fLUpperArmTurnSpeed; + vec3_t m_vLUpperArmDesiredAngles; + float m_fTorsoMaxTurnSpeed; + float m_fTorsoCurrentTurnSpeed; + vec3_t m_vTorsoDesiredAngles; + static SafePtr< Actor > mBodyQueue[ MAX_BODYQUEUE ]; + static int mCurBody; + Vector m_vHome; + SafePtr m_pTetherEnt; + float m_fMinDistance; + float m_fMinDistanceSquared; + float m_fMaxDistance; + float m_fMaxDistanceSquared; + float m_fLeash; + float m_fLeashSquared; + bool m_bFixedLeash; + +public: + CLASS_PROTOTYPE( Actor ); + +protected: + void MoveTo( Event *ev ); + void WalkTo( Event *ev ); + void RunTo( Event *ev ); + void CrouchTo( Event *ev ); + void CrawlTo( Event *ev ); + void AimAt( Event *ev ); + void DefaultRestart( void ); + void SuspendState( void ); + void ResumeState( void ); + void BeginState( void ); + void EndState( int level ); + void RestartState( void ); + +public: + Actor(); + + virtual void setContentsSolid( void ); + void InitThinkStates( void ); + void UpdateEyeOrigin( void ); + bool RequireThink( void ); + void UpdateEnemy( int iMaxDirtyTime ); + void UpdateEnemyInternal( void ); + void SetEnemy( Sentient *pEnemy, bool bForceConfirmed ); + void SetEnemyPos( Vector vPos ); + static void ResetBodyQueue( void ); + void AddToBodyQue( void ); + Vector GetAntiBunchPoint( void ); + static void InitVoid( GlobalFuncs_t *func ); + virtual char *DumpCallTrace( const char *pszFmt, ... ) const; + static void Init( void ); + void FixAIParameters( void ); + bool AttackEntryAnimation( void ); + void CheckForThinkStateTransition( void ); + bool CheckForTransition( int state, int level ); + bool PassesTransitionConditions_Grenade( void ); + bool PassesTransitionConditions_Attack( void ); + bool PassesTransitionConditions_Disguise( void ); + bool PassesTransitionConditions_Curious( void ); + bool PassesTransitionConditions_Idle( void ); + void UpdateEnableEnemy( void ); + void ThinkStateTransitions( void ); + void TransitionState( int iNewState, int iPadTime ); + void ChangeAnim( void ); + void UpdateSayAnim( void ); + void UpdateUpperAnim( void ); + void UpdateAnim( void ); + virtual void StoppedWaitFor( const_str name, bool bDeleting ); + static void InitTurret( GlobalFuncs_t *func ); + void Begin_Turret( void ); + void End_Turret( void ); + void Suspend_Turret( void ); + void Think_Turret( void ); + void FinishedAnimation_Turret( void ); + void ReceiveAIEvent_Turret( vec3_t event_origin, int iType, Entity *originator, float fDistSquared, float fMaxDistSquared ); + void InterruptPoint_Turret( void ); + void PathnodeClaimRevoked_Turret( void ); + bool Turret_IsRetargeting( void ) const; + bool Turret_DecideToSelectState( void ); + void Turret_SelectState( void ); + bool Turret_CheckRetarget( void ); + bool Turret_TryToBecomeCoverGuy( void ); + void Turret_BeginRetarget( void ); + void Turret_NextRetarget( void ); + void Turret_SideStep( int iStepSize, vec3_t vDir ); + void State_Turret_Combat( void ); + void State_Turret_Reacquire( void ); + void State_Turret_TakeSniperNode( void ); + void State_Turret_SniperNode( void ); + bool State_Turret_RunHome( bool bAttackOnFail ); + void State_Turret_RunAway( void ); + void State_Turret_Charge( void ); + void State_Turret_Grenade( void ); + void State_Turret_FakeEnemy( void ); + void State_Turret_Wait( void ); + void State_Turret_Retarget_Sniper_Node( void ); + void State_Turret_Retarget_Step_Side_Small( void ); + void State_Turret_Retarget_Path_Exact( void ); + void State_Turret_Retarget_Path_Near( void ); + void State_Turret_Retarget_Step_Side_Medium( void ); + void State_Turret_Retarget_Step_Side_Large( void ); + void State_Turret_Retarget_Step_Face_Medium( void ); + void State_Turret_Retarget_Step_Face_Large( void ); + static void InitCover( GlobalFuncs_t *func ); + bool Cover_IsValid( PathNode *node ); + bool Cover_SetPath( PathNode *node ); + void Cover_FindCover( bool bCheckAll ); + void Begin_Cover( void ); + void End_Cover( void ); + void Suspend_Cover( void ); + void Think_Cover( void ); + void FinishedAnimation_Cover( void ); + void PathnodeClaimRevoked_Cover( void ); + void State_Cover_NewEnemy( void ); + void State_Cover_FindCover( void ); + void State_Cover_TakeCover( void ); + void State_Cover_FinishReloading( void ); + void State_Cover_SpecialAttack( void ); + void State_Cover_Target( void ); + void State_Cover_Hide( void ); + void State_Cover_Shoot( void ); + void State_Cover_Grenade( void ); + void State_Cover_FindEnemy( void ); + void State_Cover_SearchNode( void ); + void State_Cover_HuntEnemy( void ); + void State_Cover_FakeEnemy( void ); + static void InitPatrol( GlobalFuncs_t *func ); + void Begin_Patrol( void ); + void End_Patrol( void ); + void Resume_Patrol( void ); + void Think_Patrol( void ); + void ShowInfo_Patrol( void ); + void IdleThink( void ); + static void InitRunner( GlobalFuncs_t *func ); + void Begin_Runner( void ); + void End_Runner( void ); + void Resume_Runner( void ); + void Think_Runner( void ); + void ShowInfo_Runner( void ); + static void InitAlarm( GlobalFuncs_t *func ); + void Begin_Alarm( void ); + void End_Alarm( void ); + void State_Alarm_StartThread( void ); + void State_Alarm_Move( void ); + void State_Alarm_Idle( void ); + void Think_Alarm( void ); + void FinishedAnimation_Alarm( void ); + static void InitNoClip( GlobalFuncs_t *func ); + bool IsNoClipState( int state ); + void Think_NoClip( void ); + bool ValidGrenadePath( Vector& vFrom, Vector& vTo, Vector& vVel ) const; + static Vector CalcThrowVelocity( Vector& vFrom, Vector& vTo ); + Vector CanThrowGrenade( Vector& vFrom, Vector& vTo ) const; + static Vector CalcRollVelocity( Vector& vFrom, Vector& vTo ); + Vector CanRollGrenade( Vector& vFrom, Vector& vTo ) const; + bool CanTossGrenadeThroughHint( GrenadeHint *pHint, Vector& vFrom, Vector& vTo, bool bDesperate, Vector *pvVel, eGrenadeTossMode *peMode ) const; + static Vector GrenadeThrowPoint( Vector& vFrom, Vector& vDelta, const_str csAnim ); + Vector CalcKickVelocity( Vector& vDelta, float fDist ) const; + bool CanKickGrenade( Vector &vFrom, Vector &vTo, Vector &vFace, Vector *pvVel ) const; + bool GrenadeWillHurtTeamAt( Vector& vTo ) const; + bool CanGetGrenadeFromAToB( Vector& vFrom, Vector& vTo, bool bDesperate, Vector *pvVel, eGrenadeTossMode *peMode ) const; + bool DecideToThrowGrenade( Vector& vTo, Vector *pvVel, eGrenadeTossMode *peMode ) const; + void Grenade_EventFire( Event *ev ); + void GenericGrenadeTossThink( void ); + static void InitGrenade( GlobalFuncs_t *func ); + bool Grenade_Acquire( int eNextState, const_str csReturnAnim ); + void Grenade_Flee( void ); + void Grenade_ThrowAcquire( void ); + void Grenade_Throw( void ); + void Grenade_KickAcquire( void ); + void Grenade_Kick( void ); + void Grenade_MartyrAcquire( void ); + void Grenade_Martyr( void ); + void Grenade_Wait( void ); + void Grenade_NextThinkState( void ); + void Grenade_EventAttach( Event *ev ); + void Grenade_EventDetach( Event *ev ); + void Begin_Grenade( void ); + void End_Grenade( void ); + void Resume_Grenade( void ); + void Think_Grenade( void ); + void FinishedAnimation_Grenade( void ); + static void InitCurious( GlobalFuncs_t *func ); + void SetCuriousAnimHint( int iAnimHint ); + void Begin_Curious( void ); + void End_Curious( void ); + void Resume_Curious( void ); + void Suspend_Curious( void ); + void Think_Curious( void ); + void FinishedAnimation_Curious( void ); + void LookAtCuriosity( void ); + void TimeOutCurious( void ); + void State_Disguise_Wait( void ); + void State_Disguise_Papers( void ); + void State_Disguise_Fake_Papers( void ); + void State_Disguise_Enemy( void ); + void State_Disguise_Halt( void ); + void State_Disguise_Accept( void ); + void State_Disguise_Deny( void ); + static void InitDisguiseSalute( GlobalFuncs_t *func ); + void Begin_DisguiseSalute( void ); + void End_DisguiseSalute( void ); + void Resume_DisguiseSalute( void ); + void Suspend_DisguiseSalute( void ); + void Think_DisguiseSalute( void ); + void FinishedAnimation_DisguiseSalute( void ); + static void InitDisguiseSentry( GlobalFuncs_t *func ); + void Begin_DisguiseSentry( void ); + void End_DisguiseSentry( void ); + void Resume_DisguiseSentry( void ); + void Suspend_DisguiseSentry( void ); + void Think_DisguiseSentry( void ); + static void InitDisguiseOfficer( GlobalFuncs_t *func ); + void Begin_DisguiseOfficer( void ); + void End_DisguiseOfficer( void ); + void Resume_DisguiseOfficer( void ); + void Suspend_DisguiseOfficer( void ); + void Think_DisguiseOfficer( void ); + static void InitDisguiseRover( GlobalFuncs_t *func ); + void Begin_DisguiseRover( void ); + void End_DisguiseRover( void ); + void Resume_DisguiseRover( void ); + void Suspend_DisguiseRover( void ); + void Think_DisguiseRover( void ); + static void InitDisguiseNone( GlobalFuncs_t *func ); + static void InitIdle( GlobalFuncs_t *func ); + void Begin_Idle( void ); + void Think_Idle( void ); + static void InitMachineGunner( GlobalFuncs_t *func ); + void Begin_MachineGunner( void ); + void End_MachineGunner( void ); + void BecomeTurretGuy( void ); + void Think_MachineGunner( void ); + void ThinkHoldGun( void ); + void FinishedAnimation_MachineGunner( void ); + bool MachineGunner_CanSee( Entity *e1, float fov, float vision_distance ); + void CanSee( Event *ev ); + static void InitDogIdle( GlobalFuncs_t *func ); + static void InitDogAttack( GlobalFuncs_t *func ); + static void InitDogCurious( GlobalFuncs_t *func ); + void Begin_Dog( void ); + void End_Dog( void ); + void Think_Dog_Idle( void ); + void Think_Dog_Attack( void ); + void Think_Dog_Curious( void ); + static void InitAnim( GlobalFuncs_t *func ); + void Begin_Anim( void ); + void Think_Anim( void ); + void FinishedAnimation_Anim( void ); + void ShowInfo_Anim( void ); + static void InitAnimCurious( GlobalFuncs_t *func ); + void Begin_AnimCurious( void ); + void Think_AnimCurious( void ); + void FinishedAnimation_AnimCurious( void ); + static void InitAim( GlobalFuncs_t *func ); + void Begin_Aim( void ); + void Think_Aim( void ); + void ShowInfo_Aim( void ); + static void InitBalconyIdle( GlobalFuncs_t *func ); + static void InitBalconyCurious( GlobalFuncs_t *func ); + static void InitBalconyAttack( GlobalFuncs_t *func ); + static void InitBalconyDisguise( GlobalFuncs_t *func ); + static void InitBalconyGrenade( GlobalFuncs_t *func ); + static void InitBalconyPain( GlobalFuncs_t *func ); + static void InitBalconyKilled( GlobalFuncs_t *func ); + void Pain_Balcony( Event *ev ); + void Killed_Balcony( Event *ev, bool bPlayDeathAnim ); + void Think_BalconyAttack( void ); + void Begin_BalconyAttack( void ); + void FinishedAnimation_BalconyAttack( void ); + void State_Balcony_PostShoot( void ); + void State_Balcony_FindEnemy( void ); + void State_Balcony_Target( void ); + void State_Balcony_Shoot( void ); + void Begin_BalconyKilled( void ); + void End_BalconyKilled( void ); + void Think_BalconyKilled( void ); + void FinishedAnimation_BalconyKilled( void ); + bool CalcFallPath( void ); + static void InitPain( GlobalFuncs_t *func ); + void Begin_Pain( void ); + void Think_Pain( void ); + void FinishedAnimation_Pain( void ); + static void InitDead( GlobalFuncs_t *func ); + static void InitKilled( GlobalFuncs_t *func ); + void Begin_Killed( void ); + void Think_Killed( void ); + void FinishedAnimation_Killed( void ); + static void InitWeaponless( GlobalFuncs_t *func ); + void Begin_Weaponless( void ); + void Suspend_Weaponless( void ); + void Think_Weaponless( void ); + void FinishedAnimation_Weaponless( void ); + void State_Weaponless_Normal( void ); + virtual void Think( void ); + void PostThink( bool bDontFaceWall ); + virtual void SetMoveInfo( mmove_t *mm ); + virtual void GetMoveInfo( mmove_t *mm ); + void DoFailSafeMove( vec3_t dest ); + void TouchStuff( mmove_t *mm ); + void ExtractConstraints( mmove_t *mm ); + void EventGiveWeaponInternal( Event *ev ); + void EventGiveWeapon( Event *ev ); + void EventGetWeapon( Event *ev ); + void FireWeapon( Event *ev ); + virtual bool CanTarget( void ); + virtual bool IsImmortal( void ); + static bool IsVoidState( int state ); + static bool IsIdleState( int state ); + static bool IsCuriousState( int state ); + static bool IsDisguiseState( int state ); + static bool IsAttackState( int state ); + static bool IsGrenadeState( int state ); + static bool IsPainState( int state ); + static bool IsKilledState( int state ); + static bool IsMachineGunnerState( int state ); + static bool IsDogState( int state ); + void IgnoreSoundSet( int iType ); + void IgnoreSoundSetAll( void ); + void IgnoreSoundClear( int iType ); + void IgnoreSoundClearAll( void ); + bool IgnoreSound( int iType ); + void EventShareEnemy( Event *ev ); + void EventShareGrenade( Event *ev ); + void ReceiveAIEvent( vec3_t event_origin, int iType, Entity *originator, float fDistSquared, float fMaxDistSquared ); + void DefaultReceiveAIEvent( vec3_t event_origin, int iType, Entity *originator, float fDistSquared, float fMaxDistSquared ); + int PriorityForEventType( int iType ); + void CuriousSound( int iType, vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator ); + void WeaponSound( int iType, vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator ); + void FootstepSound( vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator ); + void VoiceSound( int iType, vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator ); + void GrenadeNotification( Entity *originator ); + void SetGrenade( Entity *pGrenade ); + void NotifySquadmateKilled( Sentient *pSquadMate, Sentient *pAttacker ); + void RaiseAlertnessForEventType( int iType ); + void RaiseAlertness( float fAmout ); + virtual bool CanSee( Entity *e1, float fov, float vision_distance ); + virtual Vector GunPosition( void ) const; + bool WithinVisionDistance( Entity *ent ) const; + bool InFOV( Vector pos, float check_fov, float check_fovdot ); + bool EnemyInFOV( int iMaxDirtyTime ); + bool InFOV( Vector pos ); + bool InFOV( Entity *ent ); + bool CanSeeNoFOV( Entity *ent ); + bool CanSeeFOV( Entity *ent ); + bool CanSeeEnemyFOV( int iMaxFovDirtyTime, int iMaxSightDirtyTime ); + bool CanShoot( Entity *ent ); + virtual bool CanSeeFrom( vec3_t pos, Entity *ent ); + bool CanSeeEnemy( int iMaxDirtyTime ); + bool CanShootEnemy( int iMaxDirtyTime ); + void ShowInfo( void ); + virtual void ShowInfo( float fDot, float fDist ); + void DefaultPain( Event *ev ); + void HandlePain( Event *ev ); + void EventPain( Event *ev ); + void DefaultKilled( Event *ev, bool bPlayDeathAnim ); + void HandleKilled( Event *ev, bool bPlayDeathAnim ); + void DispatchEventKilled( Event *ev, bool bPlayDeathAnim ); + void EventKilled( Event *ev ); + void EventBeDead( Event *ev ); + void DeathEmbalm( Event *ev ); + void DeathSinkStart( Event *ev ); + bool NoticeShot( Sentient *pShooter, Sentient *pTarget, float fDist ); + bool NoticeFootstep( Sentient *pPedestrian ); + bool NoticeVoice( Sentient *pVocallist ); + void ClearLookEntity( void ); + void LookAt( Vector& vec ); + void LookAt( Listener *l ); + void ForwardLook( void ); + void LookAtLookEntity( void ); + void IdleLook( void ); + void IdleLook( vec3_t dir ); + void SetDesiredLookDir( vec3_t dir ); + void SetDesiredLookAnglesRelative( vec3_t ang ); + void EventLookAt( Event *ev ); + void EventEyesLookAt( Event *ev ); + void NoPoint( void ); + void IdlePoint( void ); + void ClearPointEntity( void ); + void PointAt( Vector& vec ); + void PointAt( Listener* l ); + void EventPointAt( Event *ev ); + void ClearTurnEntity( void ); + void TurnTo( Vector& vec ); + void TurnTo( Listener *l ); + void IdleTurn( void ); + void EventTurnTo( Event *ev ); + void EventSetTurnDoneError( Event *ev ); + void EventGetTurnDoneError( Event *ev ); + void LookAround( float fFovAdd ); + bool SoundSayAnim( const_str name, int bLevelSayAnim ); + void EventSetAnim( Event *ev ); + void EventIdleSayAnim( Event *ev ); + void EventSayAnim( Event *ev ); + void EventSetSayAnim( Event *ev ); + void EventSetMotionAnim( Event *ev ); + void EventSetAimMotionAnim( Event *ev ); + void EventSetActionAnim( Event *ev ); + void EventUpperAnim( Event *ev ); + void EventSetUpperAnim( Event *ev ); + void EventEndActionAnim( Event *ev ); + void EventDamagePuff( Event *ev ); + void SafeSetOrigin( vec3_t newOrigin ); + void DoMove( void ); + void AnimFinished( int slot, bool stop ); + virtual void AnimFinished( int slot ); + void PlayAnimation( Event *ev ); + void PlayScriptedAnimation( Event *ev ); + void PlayNoclipAnimation( Event *ev ); + void MoveDest( float fMoveSpeed ); + void MovePath( float fMoveSpeed ); + void MovePathGoal( float fMoveSpeed ); + void Dumb( Event *ev ); + void PhysicsOn( Event *ev ); + void PhysicsOff( Event *ev ); + void EventStart( Event *ev ); + void EventGetMood( Event *ev ); + void EventSetMood( Event *ev ); + void EventGetAngleYawSpeed( Event *ev ); + void EventSetAngleYawSpeed( Event *ev ); + void EventSetAimTarget( Event *ev ); + void UpdateAngles( void ); + void SetLeashHome( Vector vHome ); + void AimAtTargetPos( void ); + void AimAtAimNode( void ); + void AimAtEnemyBehavior( void ); + void FaceMotion( void ); + void FaceDirectionDuringMotion( vec3_t vLook ); + float PathDistanceAlongVector( vec3_t vDir ); + void FaceEnemyOrMotion( int iTimeIntoMove ); + static int NextUpdateTime( int iLastUpdateTime, int iUpdatePeriod ); + void ResetBoneControllers( void ); + void UpdateBoneControllers( void ); + void ReadyToFire( Event *ev ); + void GetLocalYawFromVector( Event *ev ); + void EventGetSight( Event *ev ); + void EventSetSight( Event *ev ); + void EventGetHearing( Event *ev ); + void EventSetHearing( Event *ev ); + void ClearPatrolCurrentNode( void ); + void NextPatrolCurrentNode( void ); + void SetPatrolCurrentNode( Vector& vec ); + void SetPatrolCurrentNode( Listener *l ); + void EventSetPatrolPath( Event *ev ); + void EventGetPatrolPath( Event *ev ); + void EventSetPatrolWaitTrigger( Event *ev ); + void EventGetPatrolWaitTrigger( Event *ev ); + void ShowInfo_PatrolCurrentNode( void ); + bool MoveOnPathWithSquad( void ); + bool MoveToWaypointWithPlayer( void ); + bool PatrolNextNodeExists( void ); + void UpdatePatrolCurrentNode( void ); + bool MoveToPatrolCurrentNode( void ); + void ClearAimNode( void ); + void SetAimNode( Vector& vec ); + void SetAimNode( Listener *l ); + void ShowInfo_AimNode( void ); + void EventSetAccuracy( Event *ev ); + void EventGetAccuracy( Event *ev ); + int GetThinkType( const_str csName ); + void SetThink( int state, int think ); + void SetThinkIdle( int think_idle ); + void SetThinkState( int state, int level ); + void EndCurrentThinkState( void ); + void ClearThinkStates( void ); + int CurrentThink( void ) const; + bool IsAttacking( void ) const; + void EventGetFov( Event *ev ); + void EventSetFov( Event *ev ); + void EventSetDestIdle( Event *ev ); + void EventSetDestIdle2( Event *ev ); + void EventSetTypeIdle( Event *ev ); + void EventGetTypeIdle( Event *ev ); + void EventSetTypeAttack( Event *ev ); + void EventGetTypeAttack( Event *ev ); + void EventSetTypeDisguise( Event *ev ); + void EventGetTypeDisguise( Event *ev ); + void EventSetDisguiseLevel( Event *ev ); + void EventGetDisguiseLevel( Event *ev ); + void EventSetTypeGrenade( Event *ev ); + void EventGetTypeGrenade( Event *ev ); + void EventSetMinDistance( Event *ev ); + void EventGetMinDistance( Event *ev ); + void EventSetMaxDistance( Event *ev ); + void EventGetMaxDistance( Event *ev ); + void EventGetLeash( Event *ev ); + void EventSetLeash( Event *ev ); + void EventGetInterval( Event *ev ); + void EventSetInterval( Event *ev ); + void EventDistToEnemy( Event *ev ); + void EventGetRunAnim( Event *ev ); + void EventGetWalkAnim( Event *ev ); + void EventGetAnimName( Event *ev ); + void EventSetAnimName( Event *ev ); + void EventSetDisguiseRange( Event *ev ); + void EventGetDisguiseRange( Event *ev ); + void EventSetDisguisePeriod( Event *ev ); + void EventGetDisguisePeriod( Event *ev ); + void EventSetDisguiseAcceptThread( Event *ev ); + void EventGetDisguiseAcceptThread( Event *ev ); + void EventAttackPlayer( Event *ev ); + void ForceAttackPlayer( void ); + void EventSetAlarmNode( Event *ev ); + void EventGetAlarmNode( Event *ev ); + void EventSetAlarmThread( Event *ev ); + void EventGetAlarmThread( Event *ev ); + void EventSetSoundAwareness( Event *ev ); + void EventGetSoundAwareness( Event *ev ); + void EventSetGrenadeAwareness( Event *ev ); + void EventGetGrenadeAwareness( Event *ev ); + str ThinkName( void ) const; + str ThinkStateName( void ) const; + void EventSetTurret( Event *ev ); + void EventGetTurret( Event *ev ); + void EventEnableEnemy( Event *ev ); + void EventEnablePain( Event *ev ); + void EventActivate( Event *ev ); + void EventGetAmmoGrenade( Event *ev ); + void EventSetAmmoGrenade( Event *ev ); + void EventInterruptPoint( Event *ev ); + void EventAnimScript( Event *ev ); + void EventAnimScript_Scripted( Event *ev ); + void EventAnimScript_Noclip( Event *ev ); + void EventReload_mg42( Event *ev ); + void SetPathWithLeash( Vector vDestPos, const char *description, int iMaxDirtyTime ); + void SetPathWithLeash( SimpleEntity *pDestNode, const char *description, int iMaxDirtyTime ); + void FindPathAwayWithLeash( vec3_t vAwayFrom, vec3_t vDirPreferred, float fMinSafeDist ); + void FindPathNearWithLeash( vec3_t vNearbyTo, float fCloseDistSquared ); + bool CanMovePathWithLeash( void ) const; + bool MovePathWithLeash( void ); + bool ShortenPathToAttack( float fMinDist ); + void StrafeToAttack( float fDist, vec3_t vDir ); + virtual Vector GunTarget( bool bNoCollision ); + virtual qboolean setModel( void ); + void EventSetHeadModel( Event *ev ); + void EventGetHeadModel( Event *ev ); + void EventSetHeadSkin( Event *ev ); + void EventGetHeadSkin( Event *ev ); + void EventSetNoIdle( Event *ev ); + void EventGetNoIdle( Event *ev ); + void EventGetEnemy( Event *ev ); + void EventSetMaxNoticeTimeScale( Event *ev ); + void EventGetMaxNoticeTimeScale( Event *ev ); + void EventSetFixedLeash( Event *ev ); + void EventGetFixedLeash( Event *ev ); + void Holster( void ); + void Unholster( void ); + void EventHolster( Event *ev ); + void EventUnholster( Event *ev ); + void EventSoundDone( Event *ev ); + void EventSound( Event *ev ); + void EventIsEnemyVisible( Event *ev ); + void EventGetEnemyVisibleChangeTime( Event *ev ); + void EventGetLastEnemyVisibleTime( Event *ev ); + void EventSetFallHeight( Event *ev ); + void EventGetFallHeight( Event *ev ); + void EventCanMoveTo( Event *ev ); + void EventMoveDir( Event *ev ); + void EventIntervalDir( Event *ev ); + void EventResetLeash( Event *ev ); + void EventTether( Event *ev ); + void EventGetThinkState( Event *ev ); + void EventGetEnemyShareRange( Event *ev ); + void EventSetEnemyShareRange( Event *ev ); + void EventGetKickDir( Event *ev ); + void EventGetNoLongPain( Event *ev ); + void EventSetNoLongPain( Event *ev ); + void EventGetFavoriteEnemy( Event *ev ); + void EventSetFavoriteEnemy( Event *ev ); + void EventGetMumble( Event *ev ); + void EventSetMumble( Event *ev ); + void EventGetBreathSteam( Event *ev ); + void EventSetBreathSteam( Event *ev ); + void EventSetNextBreathTime( Event *ev ); + void EventCalcGrenadeToss( Event *ev ); + void EventGetNoSurprise( Event *ev ); + void EventSetNoSurprise( Event *ev ); + void EventGetSilent( Event *ev ); + void EventSetSilent( Event *ev ); + void EventGetAvoidPlayer( Event *ev ); + void EventSetAvoidPlayer( Event *ev ); + void EventGetLookAroundAngle( Event *ev ); + void EventSetLookAroundAngle( Event *ev ); + void EventHasCompleteLookahead( Event *ev ); + void EventPathDist( Event *ev ); + void EventCanShootEnemyFrom( Event *ev ); + void EventCanShoot( Event *ev ); + void EventSetInReload( Event *ev ); + void EventGetInReload( Event *ev ); + void EventSetReloadCover( Event *ev ); + void EventBreakSpecial( Event *ev ); + void GetVoiceType( Event *ev ); + void SetVoiceType( Event *ev ); + void ResolveVoiceType( void ); + void EventSetBalconyHeight( Event *ev ); + void EventGetBalconyHeight( Event *ev ); + PathNode *FindSniperNodeAndSetPath( bool *pbTryAgain ); + void Remove( Event *ev ); + void DontFaceWall( void ); + bool AvoidingFacingWall( void ) const; + void EndStates( void ); + void ClearStates( void ); + void CheckUnregister( void ); + void BecomeCorpse( void ); + virtual void PathnodeClaimRevoked( PathNode *node ); + void SetPathToNotBlockSentient( Sentient *pOther ); + void EventSetMoveDoneRadius( Event *ev ); + virtual void ClearEnemies( void ); + bool EnemyIsDisguised( void ); + virtual void setOriginEvent( Vector org ); + virtual void DumpAnimInfo( void ); + static void ArchiveStatic( Archiver& arc ); + virtual void Archive( Archiver& arc ); + virtual bool AutoArchiveModel( void ); +}; + +#define SAVE_FLAG_NEW_ANIM (1<<0) +#define SAVE_FLAG_FORWARD_SPEED (1<<1) +#define SAVE_FLAG_BEHAVIOR (1<<2) +#define SAVE_FLAG_PATH (1<<3) +#define SAVE_FLAG_NOISE (1<<4) +#define SAVE_FLAG_SCRIPT_THREAD (1<<5) +#define SAVE_FLAG_ACTOR_THREAD (1<<6) +#define SAVE_FLAG_KILL_THREAD (1<<7) +#define SAVE_FLAG_STATE (1<<8) +#define SAVE_FLAG_IDLE_THREAD (1<<7) +#define SAVE_FLAG_PARTS (1<<10) +#define SAVE_FLAG_TRIGGER (1<<11) +#define SAVE_FLAG_STATE_FLAGS (1<<12) +#define SAVE_FLAG_COMMAND (1<<13) +#define SAVE_FLAG_STAGE (1<<14) +#define SAVE_FLAG_NUM_OF_SPAWNS (1<<15) +#define SAVE_FLAG_SPAWN_PARENT (1<<16) +#define SAVE_FLAG_DIALOG (1<<17) +#define SAVE_FLAG_SAVED_STUFF (1<<18) +#define SAVE_FLAG_LAST_ANIM_EVENT (1<<19) +#define SAVE_FLAG_PICKUP_ENT (1<<20) +#define SAVE_FLAG_PAIN (1<<21) +#define SAVE_FLAG_SPAWN_ITEMS (1<<22) + +inline void Actor::ArchiveStatic + ( + Archiver &arc + ) + +{ + for( int i = MAX_BODYQUEUE - 1; i >= 0; i-- ) + { + arc.ArchiveSafePointer( &mBodyQueue[ i ] ); + } + + arc.ArchiveInteger( &mCurBody ); +} + +inline void Actor::Archive + ( + Archiver &arc + ) + +{ + SimpleActor::Archive( arc ); + + for( int i = MAX_THINKMAP - 1; i >= 0; i-- ) + { + arc.ArchiveInteger( &m_ThinkMap[ i ] ); + } + + for( int i = MAX_THINKSTATES - 1; i >= 0; i-- ) + { + arc.ArchiveInteger( &m_ThinkStates[ i ] ); + arc.ArchiveInteger( &m_Think[ i ] ); + } + + arc.ArchiveInteger( &m_ThinkLevel ); + arc.ArchiveInteger( &m_ThinkState); + arc.ArchiveInteger( &m_State); + arc.ArchiveInteger( &m_iStateTime); + arc.ArchiveBool( &m_bLockThinkState); + arc.ArchiveBool( &m_bDirtyThinkState ); + arc.ArchiveInteger( &mVoiceType ); + arc.ArchiveBool( &m_bSilent); + arc.ArchiveBool( &m_bNoSurprise); + arc.ArchiveBool( &m_bMumble); + arc.ArchiveBool( &m_bBreathSteam); + + Director.ArchiveString( arc, m_csHeadModel ); + Director.ArchiveString( arc, m_csHeadSkin ); + Director.ArchiveString( arc, m_csWeapon ); + Director.ArchiveString( arc, m_csLoadOut ); + arc.ArchiveSafePointer( &m_FavoriteEnemy ); + arc.ArchiveInteger( &m_iEnemyCheckTime ); + arc.ArchiveInteger( &m_iEnemyChangeTime ); + arc.ArchiveInteger( &m_iEnemyVisibleCheckTime ); + arc.ArchiveInteger( &m_iEnemyVisibleChangeTime ); + arc.ArchiveInteger( &m_iLastEnemyVisibleTime ); + arc.ArchiveInteger( &m_iEnemyFovCheckTime ); + arc.ArchiveInteger( &m_iEnemyFovChangeTime ); + arc.ArchiveVector( &m_vLastEnemyPos ); + arc.ArchiveInteger( &m_iLastEnemyPosChangeTime ); + arc.ArchiveFloat( &m_fMaxShareDistSquared ); + arc.ArchiveInteger( &m_iCanShootCheckTime ); + arc.ArchiveBool( &m_bCanShootEnemy ); + arc.ArchiveBool( &m_bDesiredEnableEnemy ); + arc.ArchiveBool( &m_bEnableEnemy ); + arc.ArchiveBool( &m_bEnablePain ); + arc.ArchiveBool( &m_bNoLongPain ); + arc.ArchiveBool( &m_bNewEnemy ); + arc.ArchiveBool( &m_bEnemyIsDisguised ); + arc.ArchiveBool( &m_bEnemyVisible ); + arc.ArchiveBool( &m_bEnemyInFOV ); + arc.ArchiveBool( &m_bForceAttackPlayer ); + arc.ArchiveBool( &m_bAutoAvoidPlayer ); + arc.ArchiveBool( &m_bNoIdleAfterAnim ); + Director.ArchiveString( arc, m_csAnimScript ); + arc.ArchiveBool( &m_bAnimScriptSet ); + arc.ArchiveInteger( &m_AnimMode ); + arc.ArchiveFloat( &m_fDfwRequestedYaw ); + arc.ArchiveFloat( &m_fDfwDerivedYaw ); + arc.ArchiveVector( &m_vDfwPos ); + arc.ArchiveFloat( &m_fDfwTime ); + arc.ArchiveInteger( &m_iGunPositionCheckTime ); + arc.ArchiveVector( &m_vGunPosition ); + arc.ArchiveInteger( &m_iWallDodgeTimeout ); + arc.ArchiveFloat( &m_PrevObstacleNormal[ 0 ] ); + arc.ArchiveFloat( &m_PrevObstacleNormal[ 1 ] ); + arc.ArchiveChar( &m_WallDir ); + arc.ArchiveFloat( &m_fMoveDoneRadiusSquared ); + arc.ArchiveBool( &m_bFaceEnemy ); + arc.ArchiveBool( &m_bDoPhysics ); + arc.ArchiveBool( &m_bPatrolWaitTrigger ); + arc.ArchiveBool( &m_bBecomeRunner ); + arc.ArchiveBool( &m_bScriptGoalValid ); + arc.ArchiveVector( &m_vScriptGoal ); + arc.ArchiveInteger( &m_iNextWatchStepTime ); + arc.ArchiveSafePointer( &m_patrolCurrentNode ); + Director.ArchiveString( arc, m_csPatrolCurrentAnim ); + arc.ArchiveInteger( &m_iSquadStandTime ); + arc.ArchiveFloat( &m_fInterval ); + arc.ArchiveInteger( &m_iIntervalDirTime ); + arc.ArchiveVector( &m_vIntervalDir ); + arc.ArchiveShort( &m_sCurrentPathNodeIndex ); + arc.ArchiveInteger( &m_PainState ); + arc.ArchiveInteger( &m_iCuriousTime ); + arc.ArchiveInteger( &m_iCuriousLevel ); + arc.ArchiveInteger( &m_iCuriousAnimHint ); + arc.ArchiveInteger( &m_iNextDisguiseTime ); + arc.ArchiveInteger( &m_iDisguisePeriod ); + arc.ArchiveFloat( &m_fMaxDisguiseDistSquared ); + arc.ArchiveInteger( &m_iEnemyShowPapersTime ); + m_DisguiseAcceptThread.Archive( arc ); + arc.ArchiveInteger( &m_iDisguiseLevel ); + arc.ArchiveSafePointer( &m_AlarmNode ); + m_AlarmThread.Archive( arc ); + arc.ArchiveInteger( &m_iRunHomeTime ); + arc.ArchiveBool( &m_bTurretNoInitialCover ); + arc.ArchiveInteger( &m_iPotentialCoverCount ); + + for( int i = MAX_COVER_NODES - 1; i >= 0; i-- ) + { + arc.ArchiveObjectPointer( ( Class ** ) &m_pPotentialCoverNode[ i ] ); + } + + arc.ArchiveObjectPointer( ( Class ** )&m_pCoverNode ); + Director.ArchiveString( arc, m_csSpecialAttack ); + + arc.ArchiveBool( &m_bInReload); + arc.ArchiveBool( &m_bNeedReload); + arc.ArchiveBool( &mbBreakSpecialAttack); + arc.ArchiveBool( &m_bGrenadeBounced); + arc.ArchiveSafePointer( &m_pGrenade); + arc.ArchiveVector( &m_vGrenadePos); + arc.ArchiveInteger( &m_iFirstGrenadeTime); + arc.ArchiveInteger( &m_eGrenadeState); + ArchiveEnum( m_eGrenadeMode, eGrenadeTossMode ); + arc.ArchiveVector( &m_vGrenadeVel); + arc.ArchiveVector( &m_vKickDir); + arc.ArchiveFloat( &m_fNoticeTimeScale); + arc.ArchiveFloat( &m_fMaxNoticeTimeScale); + m_PotentialEnemies.Archive( arc ); + arc.ArchiveFloat( &m_fSight ); + arc.ArchiveFloat( &m_fHearing ); + arc.ArchiveFloat( &m_fSoundAwareness ); + arc.ArchiveFloat( &m_fGrenadeAwareness ); + arc.ArchiveInteger( &m_iIgnoreSoundsMask ); + arc.ArchiveFloat( &m_fFov ); + arc.ArchiveFloat( &m_fFovDot ); + arc.ArchiveInteger( &m_iEyeUpdateTime ); + arc.ArchiveVector( &m_vEyeDir ); + arc.ArchiveInteger( &m_iNextLookTime ); + arc.ArchiveFloat( &m_fLookAroundFov ); + arc.ArchiveSafePointer( &m_pLookEntity ); + arc.ArchiveInteger( &m_iLookFlags ); + arc.ArchiveSafePointer( &m_pPointEntity ); + arc.ArchiveSafePointer( &m_pTurnEntity ); + arc.ArchiveFloat( &m_fTurnDoneError ); + arc.ArchiveFloat( &m_fAngleYawSpeed ); + arc.ArchiveSafePointer( &m_aimNode ); + arc.ArchiveInteger( &m_eDontFaceWallMode ); + arc.ArchiveInteger( &m_iLastFaceDecideTime ); + arc.ArchiveBool( &m_bHeadAnglesAchieved ); + arc.ArchiveBool( &m_bLUpperArmAnglesAchieved ); + arc.ArchiveBool( &m_bTorsoAnglesAchieved ); + arc.ArchiveFloat( &m_fHeadMaxTurnSpeed ); + arc.ArchiveVec3( m_vHeadDesiredAngles ); + arc.ArchiveFloat( &m_fLUpperArmTurnSpeed ); + arc.ArchiveVec3( m_vLUpperArmDesiredAngles ); + arc.ArchiveFloat( &m_fTorsoMaxTurnSpeed ); + arc.ArchiveFloat( &m_fTorsoCurrentTurnSpeed ); + arc.ArchiveVec3( m_vTorsoDesiredAngles ); + arc.ArchiveVector( &m_vHome ); + arc.ArchiveSafePointer( &m_pTetherEnt ); + arc.ArchiveFloat( &m_fMinDistance ); + arc.ArchiveFloat( &m_fMinDistanceSquared ); + arc.ArchiveFloat( &m_fMaxDistance ); + arc.ArchiveFloat( &m_fMaxDistanceSquared ); + arc.ArchiveFloat( &m_fLeash ); + arc.ArchiveFloat( &m_fLeashSquared ); + arc.ArchiveBool( &m_bFixedLeash ); + arc.ArchiveBool( &m_bAnimating ); + arc.ArchiveBool( &m_bDog ); + + byte length; + + if( arc.Saving() ) + { + if( m_pFallPath ) + length = m_pFallPath->length; + else + length = 0; + } + arc.ArchiveByte( &length ); + + if( length ) + { + if( arc.Loading() ) + { + m_pFallPath = ( FallPath * )gi.Malloc( sizeof( FallPath ) * length ); + m_pFallPath->length = length; + } + + arc.ArchiveByte( &m_pFallPath->currentPos ); + arc.ArchiveByte( &m_pFallPath->loop ); + + for( int i = 0; i < length; i++ ) + { + arc.ArchiveVec3( m_pFallPath->pos[ i ] ); + } + } + + arc.ArchiveFloat( &m_fBalconyHeight ); + arc.ArchiveBool( &m_bNoPlayerCollision ); + + for( int i = MAX_ORIGIN_HISTORY - 1; i >= 0; i-- ) + { + arc.ArchiveVec2( m_vOriginHistory[ i ] ); + } + + arc.ArchiveInteger( &m_iCurrentHistory ); + + // set the model + setModel(); +} + +#if 0 + +// Set destination to node with duck or cover set. Class will find a path to that node, or a closer one. +class FindCoverMovement : public StandardMovement + { + public: + Actor *self; + + inline qboolean validpath + ( + PathNode *node, + int i + ) + + { + pathway_t *path; + PathNode *n; + + path = &node->Child[ i ]; + + if ( !StandardMovement::validpath( node, i ) ) + { + return false; + } + + n = AI_GetNode( path->node ); + if ( !n || self->CloseToEnemy( n->origin, 128 ) ) + { + return false; + } + + return true; + } + + inline qboolean done + ( + PathNode *node, + PathNode *end + ) + + { + if ( node == end ) + { + return true; + } + + //if ( node->reject ) + if ( node->reject || !( node->nodeflags & ( AI_DUCK | AI_COVER ) ) ) + { + return false; + } + + if ( self ) + { + node->reject = self->CanSeeEnemyFrom( node->origin ); + return !node->reject; + } + + return false; + } + }; + +// Set destination to node with flee set. Class will find a path to that node, or a closer one. +class FindFleeMovement : public StandardMovement + { + public: + Actor *self; + + inline qboolean validpath + ( + PathNode *node, + int i + ) + + { + pathway_t *path; + PathNode *n; + + path = &node->Child[ i ]; + + if ( !StandardMovement::validpath( node, i ) ) + { + return false; + } + + n = AI_GetNode( path->node ); + if ( !n || self->CloseToEnemy( n->origin, 128 ) ) + { + return false; + } + + return true; + } + + inline qboolean done + ( + PathNode *node, + PathNode *end + ) + + { + if ( node == end ) + { + return true; + } + + //if ( node->reject ) + if ( node->reject || !( node->nodeflags & AI_FLEE ) ) + { + return false; + } + + if ( self ) + { + node->reject = self->CanSeeEnemyFrom( node->origin ); + return !node->reject; + } + + return false; + } + }; + +class FindEnemyMovement : public StandardMovement + { + public: + Actor *self; + + inline qboolean done + ( + PathNode *node, + PathNode *end + ) + + { + if ( node == end ) + { + return true; + } + + if ( node->reject ) + { + return false; + } + + if ( self ) + { + if ( self->currentEnemy ) + { + node->reject = !self->CanShootFrom( node->origin, self->currentEnemy, false ); + } + else + { + node->reject = false; + } + + return !node->reject; + } + + return false; + } + }; + +typedef PathFinder FindCoverPath; +typedef PathFinder FindFleePath; +typedef PathFinder FindEnemyPath; +#endif + +void AI_TargetPlayer( void ); + +class SpinningPlant : public Actor + { + public: + Mover *spinner_model; + Mover *spinner_clip; + + CLASS_PROTOTYPE( SpinningPlant ); + + SpinningPlant(); + ~SpinningPlant(); + + void GetClip( Event *ev ); + }; + +#endif \ No newline at end of file diff --git a/code/game/actor_aim.cpp b/code/game/actor_aim.cpp new file mode 100644 index 00000000..9f7563d4 --- /dev/null +++ b/code/game/actor_aim.cpp @@ -0,0 +1,82 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_aim.cpp + +#include "actor.h" + +void Actor::InitAim + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_Aim; + func->ThinkState = &Actor::Think_Aim; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Idle; + func->ShowInfo = &Actor::ShowInfo_Aim; + func->IsState = &Actor::IsIdleState; +} +void Actor::Begin_Aim + ( + void + ) + +{ + m_csMood = STRING_ALERT; + m_csIdleMood = STRING_NERVOUS; + ClearPath(); +} +void Actor::Think_Aim + ( + void + ) + +{ + if( !RequireThink() ) + return; + + UpdateEyeOrigin(); + NoPoint(); + m_pszDebugState = ""; + Anim_Aim(); + + if( m_aimNode ) + { + mTargetPos = m_aimNode->origin; + m_bHasDesiredLookAngles = true; + + AimAtAimNode(); + } + + CheckForThinkStateTransition(); + PostThink( true ); +} + +void Actor::ShowInfo_Aim + ( + void + ) + +{ + ShowInfo_AimNode(); +} diff --git a/code/game/actor_alarm.cpp b/code/game/actor_alarm.cpp new file mode 100644 index 00000000..e7fc7933 --- /dev/null +++ b/code/game/actor_alarm.cpp @@ -0,0 +1,179 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_alarm.cpp + +#include "actor.h" + +void Actor::InitAlarm + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_Alarm; + func->EndState = &Actor::End_Alarm; + func->ThinkState = &Actor::Think_Alarm; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Attack; + func->IsState = &Actor::IsAttackState; +} + +void Actor::Begin_Alarm + ( + void + ) + +{ + DoForceActivate(); + + m_csMood = STRING_ALERT; + m_csIdleMood = STRING_NERVOUS; + + if( m_AlarmNode ) + { + SetPath( m_AlarmNode, "Actor::Begin_Alarm", 0 ); + + if( PathExists() ) + { + m_State = 601; + m_iStateTime = level.inttime; + } + else + { + m_State = 600; + m_iStateTime = level.inttime; + parm.movefail = true; + } + } + else + { + SetLeashHome( origin ); + m_State = 600; + m_iStateTime = level.inttime; + m_AlarmThread.Execute( this ); + } +} + +void Actor::End_Alarm + ( + void + ) + +{ + parm.movefail = true; +} + +void Actor::State_Alarm_StartThread + ( + void + ) + +{ + if( m_AlarmNode ) + SetLeashHome( m_AlarmNode->origin ); + else + SetLeashHome( origin ); + + m_State = 600; + m_iStateTime = level.inttime; + m_AlarmThread.Execute(); +} + +void Actor::State_Alarm_Move + ( + void + ) + +{ + if( PathExists() ) + { + if( PathComplete() ) + { + Anim_Aim(); + AimAtAimNode(); + } + else + { + Anim_RunToAlarm( 2 ); + FaceMotion(); + } + } + else + { + m_State = 600; + m_iStateTime = level.inttime; + parm.movefail = true; + + Anim_Aim(); + AimAtAimNode(); + } +} + +void Actor::State_Alarm_Idle + ( + void + ) + +{ + AimAtAimNode(); + SetThink( 4, THINKSTATE_IDLE ); +} + +void Actor::Think_Alarm + ( + void + ) + +{ + if( !RequireThink() ) + return; + + parm.movefail = false; + + UpdateEyeOrigin(); + NoPoint(); + + if( m_State == 600 ) + { + m_pszDebugState = "idle"; + State_Alarm_Idle(); + } + else if( m_State == 601 ) + { + m_pszDebugState = "move"; + State_Alarm_Move(); + } + else + { + Com_Printf( "Actor::Think_Alarm: invalid think state %i\n", m_State ); + } +} + +void Actor::FinishedAnimation_Alarm + ( + void + ) + +{ + // not needed + return; +} diff --git a/code/game/actor_anim.cpp b/code/game/actor_anim.cpp new file mode 100644 index 00000000..d99a272e --- /dev/null +++ b/code/game/actor_anim.cpp @@ -0,0 +1,79 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_anim.cpp + +#include "actor.h" + +void Actor::InitAnim + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_Anim; + func->BeginState = &Actor::Begin_Anim; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Idle; + func->FinishedAnimation = &Actor::FinishedAnimation_Anim; + func->ShowInfo = &Actor::ShowInfo_Anim; + func->IsState = &Actor::IsIdleState; +} + +void Actor::Begin_Anim + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Anim + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FinishedAnimation_Anim + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ShowInfo_Anim + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_animapi.cpp b/code/game/actor_animapi.cpp new file mode 100644 index 00000000..47db205b --- /dev/null +++ b/code/game/actor_animapi.cpp @@ -0,0 +1,400 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_animapi.cpp: Base actor animation script + +#include "actor.h" + +const_str SimpleActor::GetRunAnim + ( + void + ) + +{ + if( m_csCurrentPosition != STRING_PRONE && ( m_csCurrentPosition < STRING_PRONE || m_csCurrentPosition > STRING_CROUCHRUN ) ) + return STRING_ANIM_RUN_SCR; + else + return STRING_ANIM_CROUCH_RUN_SCR; +} + +const_str SimpleActor::GetWalkAnim + ( + void + ) + +{ + if( m_csCurrentPosition != STRING_PRONE && ( m_csCurrentPosition < STRING_PRONE || m_csCurrentPosition > STRING_CROUCHRUN ) ) + return STRING_ANIM_WALK_SCR; + else + return STRING_ANIM_CROUCH_WALK_SCR; +} + +void SimpleActor::Anim_Attack + ( + void + ) + +{ + m_eNextAnimMode = 1; + m_csNextAnimString = 0; + m_NextAnimLabel = m_AttackHandler; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_Sniper + ( + void + ) + +{ + m_eNextAnimMode = 1; + m_csNextAnimString = 0; + m_NextAnimLabel = m_SniperHandler; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_Aim + ( + void + ) + +{ + m_eNextAnimMode = 1; + m_csNextAnimString = STRING_ANIM_AIM_SCR; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_Shoot + ( + void + ) + +{ + m_eNextAnimMode = 1; + m_csNextAnimString = STRING_ANIM_SHOOT_SCR; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_Idle + ( + void + ) + +{ + m_eNextAnimMode = 1; + m_csNextAnimString = STRING_ANIM_IDLE_SCR; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_Crouch + ( + void + ) + +{ + m_eNextAnimMode = 1; + m_csNextAnimString = STRING_ANIM_CROUCH_SCR; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_Prone + ( + void + ) + +{ + m_eNextAnimMode = 1; + m_csNextAnimString = STRING_ANIM_PRONE_SCR; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_Stand + ( + void + ) + +{ + m_eNextAnimMode = 1; + m_csNextAnimString = STRING_ANIM_STAND_SCR; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_Cower + ( + void + ) + +{ + m_eNextAnimMode = 1; + m_csNextAnimString = STRING_ANIM_COWER_SCR; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_Killed + ( + void + ) + +{ + m_eAnimMode = 1; + m_csNextAnimString = 0; + m_NextAnimLabel = m_DeathHandler; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_StartPain + ( + void + ) + +{ + m_eAnimMode = 1; + m_csNextAnimString = 0; + m_NextAnimLabel = m_PainHandler; + m_bNextForceStart = true; +} + +void SimpleActor::Anim_Pain + ( + void + ) + +{ + ContinueAnimation(); +} + + +void SimpleActor::Anim_CrouchRunTo + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_CROUCH_RUN_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_CrouchWalkTo + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_CROUCH_WALK_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_StandRunTo + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_RUN_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_StandWalkTo + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_WALK_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_RunTo + ( + int eAnimMode + ) + +{ + m_bNextForceStart = false; + m_csNextAnimString = GetRunAnim(); + m_eNextAnimMode = eAnimMode; +} + +void SimpleActor::Anim_WalkTo + ( + int eAnimMode + ) + +{ + m_bNextForceStart = false; + m_csNextAnimString = GetWalkAnim(); + m_eNextAnimMode = eAnimMode; +} + +void SimpleActor::Anim_RunAwayFiring + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_RUNAWAYFIRING_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_RunToShooting + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_RUN_SHOOT_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_RunToAlarm + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_RUNTO_ALARM_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_RunToCasual + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_RUNTO_CASUAL_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_RunToCover + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_RUNTO_COVER_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_RunToDanger + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_RUNTO_DANGER_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_RunToDive + ( + int eAnimMode + ) + +{ + m_csNextAnimString = STRING_ANIM_RUNTO_DIVE_SCR; + m_eNextAnimMode = eAnimMode; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_RunToFlee + ( + int eAnimMode + ) + +{ + m_eNextAnimMode = eAnimMode; + m_csNextAnimString = STRING_ANIM_RUNTO_FLEE_SCR; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_RunToInOpen + ( + int eAnimMode + ) + +{ + m_eNextAnimMode = eAnimMode; + m_csNextAnimString = STRING_ANIM_RUNTO_INOPEN_SCR; + m_bNextForceStart = false; +} + +void SimpleActor::Anim_Emotion + ( + int eEmotionMode + ) + +{ + m_eEmotionMode = eEmotionMode; +} + +void SimpleActor::Anim_Say + ( + const_str csSayAnimScript, + int iMinTimeSinceLastSay, + bool bCanInterrupt + ) + +{ + if( m_bSayAnimSet && !bCanInterrupt ) + return; + + if( level.inttime > m_iVoiceTime + iMinTimeSinceLastSay ) + { + ScriptThreadLabel label; + + label.TrySetScript( csSayAnimScript ); + label.Execute( this ); + } +} + +void SimpleActor::Anim_FullBody + ( + const_str csFullBodyAnim, + int eAnimMode + ) + +{ + if( m_csAnimName == csFullBodyAnim ) + { + m_eNextAnimMode = eAnimMode; + m_csNextAnimString = STRING_ANIM_FULLBODY_SCR; + m_bNextForceStart = false; + } + else + { + m_csAnimName = csFullBodyAnim; + m_eNextAnimMode = eAnimMode; + m_csNextAnimString = STRING_ANIM_FULLBODY_SCR; + m_bNextForceStart = true; + } +} diff --git a/code/game/actor_animcurious.cpp b/code/game/actor_animcurious.cpp new file mode 100644 index 00000000..249457c1 --- /dev/null +++ b/code/game/actor_animcurious.cpp @@ -0,0 +1,85 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_animcurious.cpp + +#include "actor.h" + +void Actor::InitAnimCurious + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_AnimCurious; + func->BeginState = &Actor::Begin_AnimCurious; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Curious; + func->FinishedAnimation = &Actor::FinishedAnimation_Anim; + func->ShowInfo = &Actor::ShowInfo_Anim; + func->IsState = &Actor::IsCuriousState; +} + +void Actor::Begin_AnimCurious + ( + void + ) + +{ + DoForceActivate(); + + m_csMood = STRING_CURIOUS; + m_bNextForceStart = true; + m_YawAchieved = true; + m_eNextAnimMode = m_AnimMode; + m_iCuriousTime = level.inttime; + m_csNextAnimString = m_csAnimScript; +} + +void Actor::Think_AnimCurious + ( + void + ) + +{ + if( !RequireThink() ) + return; + + UpdateEyeOrigin(); + m_pszDebugState = ""; + LookAtCuriosity(); + TimeOutCurious(); + CheckForThinkStateTransition(); + PostThink( false ); +} + +void Actor::FinishedAnimation_AnimCurious + ( + void + ) + +{ + if( m_State == 1101 ) + { + m_State = 1100; + m_iStateTime = level.inttime; + } +} diff --git a/code/game/actor_balcony.cpp b/code/game/actor_balcony.cpp new file mode 100644 index 00000000..fe378141 --- /dev/null +++ b/code/game/actor_balcony.cpp @@ -0,0 +1,416 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_balcony.cpp + +#include "actor.h" + +void Actor::InitBalconyIdle + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_Idle; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Idle; + func->Pain = &Actor::Pain_Balcony; + func->Killed = &Actor::Killed_Balcony; + func->IsState = &Actor::IsIdleState; +} + +void Actor::InitBalconyCurious + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_Curious; + func->BeginState = &Actor::Begin_Curious; + func->EndState = &Actor::End_Curious; + func->ResumeState = &Actor::Resume_Curious; + func->SuspendState = &Actor::Suspend_Curious; + func->FinishedAnimation = &Actor::FinishedAnimation_Curious; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Curious; + func->IsState = &Actor::IsCuriousState; + func->Pain = &Actor::Pain_Balcony; + func->Killed = &Actor::Killed_Balcony; +} + +void Actor::InitBalconyAttack + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_BalconyAttack; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Attack; + func->BeginState = &Actor::Begin_BalconyAttack; + func->FinishedAnimation = &Actor::FinishedAnimation_BalconyAttack; + func->Pain = &Actor::Pain_Balcony; + func->Killed = &Actor::Killed_Balcony; + func->IsState = &Actor::IsAttackState; + func->PostShoot = &Actor::State_Balcony_PostShoot; +} + +void Actor::InitBalconyDisguise + ( + GlobalFuncs_t *func + ) + +{ + func->IsState = &Actor::IsDisguiseState; +} + +void Actor::InitBalconyGrenade + ( + GlobalFuncs_t *func + ) + +{ + func->IsState = &Actor::IsGrenadeState; +} + +void Actor::InitBalconyPain + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_Pain; + func->ThinkState = &Actor::Think_Pain; + func->FinishedAnimation = &Actor::FinishedAnimation_Pain; + func->Pain = &Actor::Pain_Balcony; + func->Killed = &Actor::Killed_Balcony; + func->IsState = &Actor::IsPainState; +} + +void Actor::InitBalconyKilled + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_BalconyKilled; + func->EndState = &Actor::End_BalconyKilled; + func->ThinkState = &Actor::Think_BalconyKilled; + func->FinishedAnimation = &Actor::FinishedAnimation_BalconyKilled; + func->IsState = &Actor::IsKilledState; +} + +void Actor::Pain_Balcony + ( + Event *ev + ) + +{ + SetThink( THINKSTATE_PAIN, 30 ); + HandlePain( ev ); +} + +void Actor::Killed_Balcony + ( + Event *ev, + bool bPlayDeathAnim + ) + +{ + ClearStates(); + SetThink( THINKSTATE_KILLED, 31 ); + HandleKilled( ev, true ); + + if( !bPlayDeathAnim ) + ScriptError( "cannot do 'bedead' on balcony guys" ); +} + +void Actor::Begin_BalconyAttack + ( + void + ) + +{ + m_State = 200; + m_iStateTime = level.inttime; +} + +void Actor::State_Balcony_PostShoot + ( + void + ) + +{ + if( m_Enemy ) + { + m_State = 201; + m_iStateTime = level.inttime; + } +} + +void Actor::State_Balcony_FindEnemy + ( + void + ) + +{ + m_bHasDesiredLookAngles = false; + Anim_Aim(); + + if( CanSeeEnemy( 200 ) ) + { + m_State = 201; + m_iStateTime = level.inttime; + } +} + +void Actor::State_Balcony_Target + ( + void + ) + +{ + Anim_Aim(); + AimAtAimNode(); + + if( level.inttime > m_iStateTime + 1000 ) + { + if( CanSeeEnemy( 0 ) && CanShootEnemy( 0 ) ) + { + m_State = 202; + } + else + { + ClearPath(); + m_State = 200; + } + + m_iStateTime = level.inttime; + } +} + +void Actor::State_Balcony_Shoot + ( + void + ) + +{ + Anim_Shoot(); + AimAtAimNode(); +} + +void Actor::Think_BalconyAttack + ( + void + ) + +{ + if( !RequireThink() ) + return; + + UpdateEyeOrigin(); + UpdateEnemy( 500 ); + + if( !m_Enemy ) + { + SetThinkState( THINKSTATE_IDLE, 0 ); + IdleThink(); + return; + } + + NoPoint(); + + if( m_State == 201 ) + { + m_pszDebugState = "target"; + State_Balcony_Target(); + } + else if( m_State == 202 ) + { + m_pszDebugState = "shoot"; + State_Balcony_Shoot(); + } + else if( m_State = 200 ) + { + m_pszDebugState = "findenemy"; + State_Balcony_FindEnemy(); + } + else + { + Com_Printf( "Actor::Think_BalconyAttack: invalid think state %i\n", m_State ); + assert( 0 ); + } + + PostThink( true ); +} + +void Actor::FinishedAnimation_BalconyAttack + ( + void + ) + +{ + if( m_State = 202 ) + State_Balcony_PostShoot(); +} + +void Actor::Begin_BalconyKilled + ( + void + ) + +{ + ClearPath(); + ResetBoneControllers(); + + PostEvent( EV_Actor_DeathEmbalm, 0.05f ); + + if( CalcFallPath() ) + m_State = 800; + else + m_State = 806; + + m_iStateTime = level.inttime; +} + +void Actor::End_BalconyKilled + ( + void + ) + +{ + if( m_pFallPath ) + { + delete m_pFallPath; + m_pFallPath = NULL; + } +} + +void Actor::Think_BalconyKilled + ( + void + ) + +{ + int animnum; + + Unregister( STRING_ANIMDONE ); + + if( m_State = 805 ) + { + m_pszDebugState = "end"; + } + else + { + NoPoint(); + m_bHasDesiredLookAngles = false; + m_YawAchieved = true; + + switch( m_State ) + { + case 800: + m_bNextForceStart = true; + m_eNextAnimMode = 7; + m_pszDebugState = "begin"; + m_csNextAnimString = 270; + ChangeMotionAnim(); + animnum = gi.Anim_NumForName( edict->tiki, "death_balcony_intro" ); + NewAnim( animnum ); + SetTime( m_iMotionSlot, m_pFallPath->startTime ); + UpdateNormalAnimSlot( m_iMotionSlot ); + m_State = 801; + m_iStateTime = level.inttime; + break; + case 801: + m_bNextForceStart = false; + m_pszDebugState = "intro"; + m_eNextAnimMode = 7; + m_csNextAnimString = STRING_ANIM_NO_KILLED_SCR; + break; + case 802: + m_pszDebugState = "loop"; + Anim_FullBody( STRING_DEATH_BALCONY_LOOP, 7 ); + break; + case 803: + m_State = 804; + m_iStateTime = level.inttime; + StopAllAnimating(); + case 804: + m_pszDebugState = "outtro"; + Anim_FullBody( STRING_DEATH_BALCONY_OUTTRO, 1 ); + case 806: + m_pszDebugState = "normal"; + Anim_Killed(); + break; + default: + Com_Printf( "Actor::Think_BalconyKilled: invalid think state %i\n", m_State ); + assert( 0 ); + } + + PostThink( false ); + + if( m_State >= 800 ) + { + if( m_State <= 801 ) + { + if( m_pFallPath->currentPos >= m_pFallPath->length ) + { + m_State = 803; + m_iStateTime = level.inttime; + return; + } + + if( m_pFallPath->currentPos >= m_pFallPath->loop ) + { + m_State = 802; + m_iStateTime = level.inttime; + return; + } + } + else + { + if( m_State == 802 && m_pFallPath->currentPos >= m_pFallPath->length ) + { + m_State = 803; + m_iStateTime = level.inttime; + } + } + } + } +} + +void Actor::FinishedAnimation_BalconyKilled + ( + void + ) + +{ + if( m_State == 804 || m_State == 806 ) + { + BecomeCorpse(); + m_State = 805; + m_iStateTime = level.inttime; + } + else if( m_State == 801 ) + { + m_State = 802; + m_iStateTime = level.inttime; + StopAllAnimating(); + } +} diff --git a/code/game/actor_cover.cpp b/code/game/actor_cover.cpp new file mode 100644 index 00000000..c5401eed --- /dev/null +++ b/code/game/actor_cover.cpp @@ -0,0 +1,987 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_cover.cpp + +#include "actor.h" + +void Actor::InitCover + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_Cover; + func->BeginState = &Actor::Begin_Cover; + func->EndState = &Actor::End_Cover; + func->SuspendState = &Actor::Suspend_Cover; + func->FinishedAnimation = &Actor::FinishedAnimation_Cover; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Attack; + func->IsState = &Actor::IsAttackState; + func->PathnodeClaimRevoked = &Actor::PathnodeClaimRevoked_Cover; +} + +void Actor::Begin_Cover + ( + void + ) + +{ + DoForceActivate(); + m_csIdleMood = STRING_NERVOUS; + m_csMood = STRING_ALERT; + + if( m_pCoverNode ) + { + m_State = 302; + m_iStateTime = level.inttime; + return; + } + + m_State = 300; + m_iStateTime = level.inttime; + + if( level.inttime < m_iEnemyChangeTime + 200 ) + { + SetLeashHome( origin ); + + if( AttackEntryAnimation() ) + { + m_bLockThinkState = true; + m_State = 312; + m_iStateTime = level.inttime; + } + } +} + +void Actor::End_Cover + ( + void + ) + +{ + m_pszDebugState = ""; + + if( m_pCoverNode ) + { + m_pCoverNode->Relinquish(); + m_pCoverNode = NULL; + } + + m_State = -1; + m_iStateTime = level.inttime; +} + +void Actor::Suspend_Cover + ( + void + ) + +{ + if( m_pCoverNode ) + { + m_pCoverNode->Relinquish(); + m_pCoverNode->MarkTemporarilyBad(); + m_pCoverNode = NULL; + } + + m_State = 301; + m_iStateTime = level.inttime; +} + +void Actor::State_Cover_NewEnemy + ( + void + ) + +{ + m_bHasDesiredLookAngles = true; + + Cover_FindCover( true ); + + if( m_pCoverNode && PathExists() && PathComplete() ) + { + Anim_RunToCover( 3 ); + m_State = 302; + } + else + { + Anim_Aim(); + AimAtAimNode(); + m_State = 307; + } + + m_iStateTime = level.inttime; +} + +void Actor::State_Cover_FindCover + ( + void + ) + +{ + Anim_Aim(); + AimAtAimNode(); + Cover_FindCover( false ); + + if( m_pCoverNode ) + { + if( PathExists() && !PathComplete() ) + { + Anim_RunToCover( 3 ); + m_State = 302; + } + else + { + m_State = 307; + } + + m_iStateTime = level.inttime; + } + else + { + if( !m_iPotentialCoverCount ) + { + SetThink( THINKSTATE_ATTACK, 1 ); + } + } +} + +void Actor::State_Cover_TakeCover + ( + void + ) + +{ + if( PathExists() && !PathComplete() ) + { + FaceEnemyOrMotion( level.inttime - m_iStateTime ); + Anim_RunToCover( 3 ); + m_csPathGoalEndAnimScript = m_bInReload ? STRING_ANIM_RUNTO_COVER_SCR : STRING_ANIM_IDLE_SCR; + } + else + { + ClearPath(); + m_eAnimMode = 1; + m_State = 303; + m_iStateTime = level.inttime; + State_Cover_FinishReloading(); + } +} + +void Actor::State_Cover_FinishReloading + ( + void + ) + +{ + if( m_bInReload ) + { + ContinueAnimation(); + AimAtAimNode(); + return; + } + + Weapon *pWeap = GetWeapon( 0 ); + + if( !pWeap || pWeap->GetFireType( FIRE_PRIMARY ) == FT_PROJECTILE || pWeap->GetFireType( FIRE_PRIMARY ) == FT_SPECIAL_PROJECTILE ) + { + if( m_pCoverNode->nodeflags & AI_DUCK ) + { + Anim_Crouch(); + } + else + { + Anim_Stand(); + } + + m_sCurrentPathNodeIndex = -1; + + if( m_Team == TEAM_AMERICAN ) + { + m_iStateTime = level.inttime + ( rand() % 2001 + 2000 ); + } + else + { + m_iStateTime = level.inttime + ( rand() % 11001 + 4000 ); + } + + Anim_Aim(); + AimAtAimNode(); + return; + } + + m_YawAchieved = false; + m_DesiredYaw = angles[ 1 ]; + SafeSetOrigin( origin ); + m_eNextAnimMode = 1; + m_bNextForceStart = false; + m_csNextAnimString = m_csSpecialAttack; + m_State = 304; + m_iStateTime = level.inttime; +} + +void Actor::State_Cover_Target + ( + void + ) + +{ + DontFaceWall(); + + if( m_eDontFaceWallMode <= 8 ) + { + m_State = 305; + m_iStateTime = level.inttime; + State_Cover_FindEnemy(); + return; + } + + Anim_Aim(); + AimAtAimNode(); + + if( level.inttime > m_iStateTime + 300 && fabs( m_DesiredYaw - angles[ 1 ] ) < 0.001f ) + { + Vector end = m_vLastEnemyPos + velocity; + if( DecideToThrowGrenade( end, &m_vGrenadeVel, &m_eGrenadeMode ) ) + { + m_YawAchieved = false; + m_DesiredYaw = vectoyaw( m_vGrenadeVel ); + m_eNextAnimMode = 1; + m_bNextForceStart = false; + m_State = 310; + m_csNextAnimString = m_eGrenadeMode == 2 ? STRING_ANIM_GRENADETOSS_SCR : STRING_ANIM_GRENADETHROW_SCR; + } + else if( CanSeeEnemy( 500 ) && CanShootEnemy( 500 ) ) + { + m_State = 309; + } + else + { + if( m_Team == TEAM_AMERICAN ) + { + m_iStateTime = level.inttime + ( rand() % 2001 + 2000 ); + } + else + { + m_iStateTime = level.inttime + ( rand() % 11001 + 4000 ); + } + } + } +} + +void Actor::State_Cover_Hide + ( + void + ) + +{ + if( m_Enemy ) + { + SetEnemyPos( origin ); + } + + if( !m_pCoverNode ) + { + m_State = 301; + m_iStateTime = level.inttime; + State_Cover_FindCover(); + return; + } + + m_csSpecialAttack = m_pCoverNode->GetSpecialAttack( this ); + MPrintf( "special: %d", m_csSpecialAttack ); + + if( m_csSpecialAttack ) + { + m_DesiredYaw = angles[ 1 ]; + m_YawAchieved = false; + SafeSetOrigin( origin ); + m_eNextAnimMode = 1; + m_bNextForceStart = false; + m_State = 304; + m_csNextAnimString = m_csSpecialAttack; + m_iStateTime = level.inttime; + return; + } + + bool bCanShoot = CanShootEnemy( 500 ); + if( CanSeeEnemy( 500 ) || bCanShoot ) + { + if( CanShootEnemy( 500 ) ) + { + Vector vDelta = m_Enemy->origin - origin; + + if( VectorLength2DSquared( vDelta ) * 0.75f <= ( orientation[ 0 ][ 0 ] + orientation[ 0 ][ 1 ] ) * ( orientation[ 0 ][ 0 ] + orientation[ 1 ][ 1 ] ) ) + { + m_State = 307; + } + else + { + m_State = 309; + } + + m_iStateTime = level.inttime; + State_Cover_Shoot(); + return; + } + + m_pCoverNode->Relinquish(); + m_pCoverNode->MarkTemporarilyBad(); + m_State = 305; + m_iStateTime = level.inttime; + State_Cover_FindEnemy(); + return; + } + + if( m_Team == TEAM_AMERICAN ) + { + if( level.inttime >= m_iLastFaceDecideTime + 1000 ) + { + m_iLastFaceDecideTime = level.inttime; + PathNode *node = PathManager.FindCornerNodeForExactPath( this, m_Enemy, m_fLeash + m_fMaxDistance ); + + if( !node ) + { + m_bHasDesiredLookAngles = false; + Anim_Stand(); + m_PotentialEnemies.FlagBadEnemy( m_Enemy ); + UpdateEnemy( -1 ); + return; + } + + Vector vDelta = node->m_PathPos - origin; + + if( vDelta[ 0 ] || vDelta[ 1 ] == 0 ) + { + m_DesiredYaw = vectoyaw( vDelta ); + m_YawAchieved = false; + } + } + + Anim_Aim(); + } + else + { + if( level.inttime >= m_iLastFaceDecideTime + 1000 ) + { + m_iLastFaceDecideTime = level.inttime; + Vector eyepos = EyePosition(); + Vector end = m_vLastEnemyPos + eyepos; + trace_t trace = G_Trace( + eyepos, + vec_zero, + vec_zero, + end, + this, + (CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA), + true, + "State_Cover" ); + + PathNode *node = PathManager.FindCornerNodeForWall( origin, m_vLastEnemyPos, this, 0.0f, trace.plane.normal ); + + if( node ) + { + Vector vDelta = node->m_PathPos - origin; + + if( vDelta[ 0 ] == 0.0f || vDelta[ 1 ] == 0.0f ) + { + m_DesiredYaw = vectoyaw( vDelta ); + m_YawAchieved = false; + } + + m_eDontFaceWallMode = 6; + } + else + { + AimAtAimNode(); + DontFaceWall(); + } + } + + if( m_eDontFaceWallMode <= 8 ) + { + Anim_Stand(); + } + else + { + Anim_Aim(); + } + } + + if( level.inttime <= m_iStateTime ) + return; + + PathNode *pNode = ( PathNode * )G_FindRandomSimpleTarget( m_pCoverNode->target ); + m_pCoverNode->Relinquish(); + m_pCoverNode = NULL; + + if( !pNode ) + { + Anim_Stand(); + m_State = 305; + m_iStateTime = level.inttime + ( rand() & 0x7FF ); + return; + } + + assert( pNode->IsSubclassOfPathNode() ); + if( !pNode->IsSubclassOfPathNode() ) + { + return; + } + + if( !pNode->IsClaimedByOther( this ) ) + { + SetPath( pNode, "Actor::State_Cover_Target", 0 ); + + if( PathExists() ) + { + m_pCoverNode = pNode; + pNode->Claim( this ); + Anim_RunToDanger( 3 ); + m_State = 306; + m_iStateTime = level.inttime; + } + } +} + +void Actor::State_Cover_Shoot + ( + void + ) + +{ + if( m_bNeedReload ) + { + Cover_FindCover( true ); + + if( m_pCoverNode ) + { + Anim_RunToCover( 3 ); + FaceEnemyOrMotion( 0 ); + m_State = 302; + m_iStateTime = level.inttime; + return; + } + } + + Anim_Shoot(); + AimAtAimNode(); + + if( level.inttime > m_iStateTime + 10000 ) + { + gi.Cvar_Set( "g_monitornum", va( "%i", entnum ) ); + assert( "!anim/shoot.scr took over 10 seconds" ); + Com_Error( ERR_DROP, "anim/shoot.scr took over 10 seconds, entnum = %i, targetname = %s", entnum, targetname.c_str() ); + } +} + +void Actor::State_Cover_Grenade + ( + void + ) + +{ + GenericGrenadeTossThink(); +} + +void Actor::State_Cover_SpecialAttack + ( + void + ) + +{ + m_bHasDesiredLookAngles = false; + + assert( m_pCoverNode ); + if( !m_pCoverNode ) + { + m_State = 305; + m_iStateTime = level.inttime; + State_Cover_FindEnemy(); + return; + } + + if( mbBreakSpecialAttack ) + { + if( m_pCoverNode ) + { + m_pCoverNode->Relinquish(); + m_pCoverNode = NULL; + } + + m_State = 305; + m_iStateTime = level.inttime; + State_Cover_FindEnemy(); + return; + } + + if( level.inttime >= m_iLastEnemyPosChangeTime + level.intframetime || !m_csSpecialAttack ) + { + m_csSpecialAttack = m_pCoverNode->GetSpecialAttack( this ); + + if( !m_csSpecialAttack ) + { + m_State = 305; + m_iStateTime = level.inttime; + State_Cover_FindEnemy(); + return; + } + } + + m_DesiredYaw = angles[ 1 ]; + m_YawAchieved = false; + m_eNextAnimMode = 1; + m_csNextAnimString = m_csSpecialAttack; + m_bNextForceStart = false; +} + +void Actor::State_Cover_FindEnemy + ( + void + ) + +{ + if( m_Team == TEAM_AMERICAN ) + { + m_bHasDesiredLookAngles = false; + +__setpath: + Anim_Stand(); + SetPathWithLeash( m_vLastEnemyPos, NULL, 0 ); + ShortenPathToAvoidSquadMates(); + if( PathExists() && !PathComplete() && PathAvoidsSquadMates() ) + { + m_State = 311; + m_iStateTime = level.inttime; + } + else + { + m_bTurretNoInitialCover = true; + SetThink( THINKSTATE_ATTACK, 1 ); + } + + return; + } + + AimAtAimNode(); + Anim_Aim(); + DontFaceWall(); + + if( CanSeeEnemy( 200 ) ) + { + if( m_eDontFaceWallMode > 8 ) + { + m_State = 307; + m_iStateTime = level.inttime; + } + + goto __setpath; + } + + if( m_eDontFaceWallMode <= 8 || level.inttime > m_iStateTime + 500 ) + { + goto __setpath; + } +} + +void Actor::State_Cover_SearchNode + ( + void + ) + +{ + m_bHasDesiredLookAngles = false; + + if( CanSeeEnemy( 200 ) ) + { + Anim_Aim(); + AimAtAimNode(); + m_iStateTime = level.inttime; + return; + } + + if( PathExists() && !PathComplete() ) + { + FaceEnemyOrMotion( level.inttime - m_iStateTime ); + Anim_RunToDanger( 3 ); + } + else + { + Anim_Aim(); + AimAtAimNode(); + + if( level.inttime > m_iStateTime + 3000 ) + { + m_State = 301; + m_iStateTime = level.inttime; + } + } +} + +void Actor::State_Cover_HuntEnemy + ( + void + ) + +{ + FaceEnemyOrMotion( level.inttime - m_iStateTime ); + MovePathWithLeash(); + + if( PathExists() && !PathComplete() ) + { + if( CanSeeEnemy( 300 ) ) + { + m_State = 307; + m_iStateTime = level.inttime; + } + } + else + { + m_State = 305; + m_iStateTime = level.inttime + ( rand() & 0x7FF ); + + if( m_pCoverNode ) + { + m_pCoverNode->Relinquish(); + m_pCoverNode = NULL; + } + } +} + +void Actor::State_Cover_FakeEnemy + ( + void + ) + +{ + AimAtAimNode(); + Anim_Aim(); + + if( level.inttime >= m_iStateTime ) + { + SetThinkState( THINKSTATE_IDLE, 0 ); + } +} + +void Actor::Think_Cover + ( + void + ) + +{ + if( !RequireThink() ) + { + return; + } + + UpdateEyeOrigin(); + NoPoint(); + UpdateEnemy( 500 ); + + if( m_State == 312 ) + { + ContinueAnimation(); + } + else + { + m_bLockThinkState = false; + if( m_Enemy ) + { + if( m_State == 313 ) + { + m_State = 300; + m_iStateTime = level.inttime; + } + } + else + { + if( m_State != 313 ) + { + m_State = 313; + m_iStateTime = level.inttime + ( rand() & 0x7FF ) + 1000; + } + } + + switch( m_State ) + { + case 300: + m_pszDebugState = "NewEnemy"; + State_Cover_NewEnemy(); + break; + case 301: + m_pszDebugState = "FindCover"; + State_Cover_FindCover(); + break; + case 302: + m_pszDebugState = "TakeCover"; + State_Cover_TakeCover(); + break; + case 303: + m_pszDebugState = "FinishReloading"; + State_Cover_FinishReloading(); + break; + case 304: + m_pszDebugState = "SpecialAttack"; + State_Cover_SpecialAttack(); + break; + case 305: + m_pszDebugState = "FindEnemy"; + State_Cover_FindEnemy(); + break; + case 306: + m_pszDebugState = "SearchNode"; + State_Cover_SearchNode(); + break; + case 307: + m_pszDebugState = "Target"; + State_Cover_Target(); + break; + case 308: + m_pszDebugState = "Hide"; + State_Cover_Hide(); + break; + case 309: + m_pszDebugState = "Shoot"; + State_Cover_Shoot(); + break; + case 310: + m_pszDebugState = "Grenade"; + State_Cover_Grenade(); + break; + case 311: + m_pszDebugState = "HuntEnemy"; + State_Cover_HuntEnemy(); + break; + case 313: + m_pszDebugState = "FakeEnemy"; + State_Cover_FakeEnemy(); + break; + default: + Com_Printf( "Actor::Think_Cover: invalid think state %i\n", m_State ); + assert( 0 ); + break; + } + + CheckForTransition( THINKSTATE_GRENADE, 0 ); + } + + if( m_State != 305 && m_State != 307 && m_State != 308 && m_State != 309 ) + { + PostThink( true ); + } + else + { + PostThink( false ); + } +} + +void Actor::FinishedAnimation_Cover + ( + void + ) + +{ + if( m_State == 309 ) + { + if( m_Enemy && !m_Enemy->IsDead() && CanSeeEnemy( 500 ) && CanShootEnemy( 500 ) ) + { + m_iStateTime = level.inttime; + } + else + { + m_State = 301; + m_iStateTime = level.inttime; + } + } + else if( m_State == 310 || m_State == 312 ) + { + m_State = 301; + m_iStateTime = level.inttime; + } +} + +void Actor::PathnodeClaimRevoked_Cover + ( + void + ) + +{ + m_State = 301; + m_iStateTime = level.inttime; +} + +bool Actor::Cover_IsValid + ( + PathNode *node + ) + +{ + if( !node->IsClaimedByOther( this ) ) + { + if( node->nodeflags & AI_CONCEALMENT ) + { + return true; + } + else if( CanSeeFrom( origin + eyeposition, m_Enemy ) ) + { + if( !( node->nodeflags & AI_DUCK ) ) + { + return false; + } + else if( CanSeeFrom( origin + eyeposition - Vector( 0, 0, 32 ), m_Enemy ) ) + { + return false; + } + else + { + return true; + } + } + else + { + return true; + } + } + else + { + return false; + } +} +bool Actor::Cover_SetPath + ( + PathNode *node + ) + +{ + SetPathWithLeash( node, NULL, 0 ); + + if( !PathExists() ) + { + return false; + } + + float origin_ratio; + Vector enemy_offset; + PathInfo *current_node; + Vector enemy_origin; + Vector vDelta; + float fMinDistSquared; + float fPathDist; + + fPathDist = PathDist(); + fMinDistSquared = fPathDist * fPathDist; + vDelta = node->origin - origin; + + if( fMinDistSquared >= vDelta.lengthSquared() * 4.0f ) + { + if( fPathDist > 128.0f ) + { + return false; + } + } + + if( !PathComplete() ) + { + enemy_origin = m_Enemy->origin; + vDelta = enemy_origin - origin; + + if( VectorLength2DSquared( vDelta ) * 0.64f > 192 * 192 ) + { + origin_ratio = 192 * 192; + } + + for( current_node = CurrentPathNode() - 1; current_node >= LastPathNode(); current_node-- ) + { + vDelta[ 0 ] = origin[ 0 ] - current_node->point[ 0 ]; + vDelta[ 1 ] = origin[ 1 ] - current_node->point[ 1 ]; + + if( origin_ratio >= VectorLength2DSquared( vDelta ) ) + { + return false; + } + + float fDot = DotProduct2D( vDelta, current_node->dir ); + if( fDot < 0.0f && -current_node->dist <= fDot ) + { + if( ( vDelta[ 0 ] * current_node->dir[ 0 ] - vDelta[ 1 ] * current_node->dir[ 1 ] ) * ( vDelta[ 0 ] * current_node->dir[ 0 ] - vDelta[ 1 ] * current_node->dir[ 1 ] ) ) + { + return false; + } + } + } + } + + return true; +} + +void Actor::Cover_FindCover + ( + bool bCheckAll + ) + +{ + + if( m_pCoverNode ) + { + if( Cover_IsValid( m_pCoverNode ) && Cover_SetPath( m_pCoverNode ) ) + { + return; + } + + m_pCoverNode->Relinquish(); + m_pCoverNode = NULL; + } + + if( !m_iPotentialCoverCount ) + { + m_iPotentialCoverCount = PathManager.FindPotentialCover( this, origin, m_Enemy, m_pPotentialCoverNode, 16 ); + } + + if( m_iPotentialCoverCount ) + { + PathNode *pNode = NULL; + + while( m_iPotentialCoverCount ) + { + m_iPotentialCoverCount--; + pNode = m_pPotentialCoverNode[ m_iPotentialCoverCount ]; + m_pPotentialCoverNode[ m_iPotentialCoverCount ] = NULL; + + if( Cover_IsValid( pNode ) && Cover_SetPath( pNode ) ) + { + break; + } + + if( !bCheckAll ) + { + return; + } + } + + m_pCoverNode = pNode; + m_pCoverNode->Claim( this ); + memset( m_pPotentialCoverNode, 0, sizeof( m_pPotentialCoverNode ) ); + m_iPotentialCoverCount = 0; + } +} + diff --git a/code/game/actor_curious.cpp b/code/game/actor_curious.cpp new file mode 100644 index 00000000..ad4e440a --- /dev/null +++ b/code/game/actor_curious.cpp @@ -0,0 +1,133 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_curious.cpp + +#include "actor.h" + +void Actor::InitCurious + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_Curious; + func->BeginState = &Actor::Begin_Curious; + func->EndState = &Actor::End_Curious; + func->ResumeState = &Actor::Resume_Curious; + func->SuspendState = &Actor::Suspend_Curious; + func->FinishedAnimation = &Actor::FinishedAnimation_Cover; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Curious; + func->IsState = &Actor::IsCuriousState; +} + +void Actor::Begin_Curious + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + + +void Actor::End_Curious + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Resume_Curious + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Suspend_Curious + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Curious + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FinishedAnimation_Curious + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + + +void Actor::LookAtCuriosity + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::TimeOutCurious + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::SetCuriousAnimHint + ( + int iAnimHint + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_disguise_common.cpp b/code/game/actor_disguise_common.cpp new file mode 100644 index 00000000..92841bf8 --- /dev/null +++ b/code/game/actor_disguise_common.cpp @@ -0,0 +1,104 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_disguise_common.cpp + +#include "actor.h" + + +void Actor::InitDisguiseNone + ( + GlobalFuncs_t *func + ) + +{ + func->IsState = &Actor::IsDisguiseState; +} + +void Actor::State_Disguise_Wait + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Disguise_Papers + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Disguise_Fake_Papers + ( + void + ) + +{ + // FIXME: stub +} + +void Actor::State_Disguise_Enemy + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Disguise_Halt + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Disguise_Accept + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Disguise_Deny + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_disguise_officier.cpp b/code/game/actor_disguise_officier.cpp new file mode 100644 index 00000000..1fde4c01 --- /dev/null +++ b/code/game/actor_disguise_officier.cpp @@ -0,0 +1,91 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_disguise_officier.cpp + +#include "actor.h" + + +void Actor::InitDisguiseOfficer + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_DisguiseOfficer; + func->BeginState = &Actor::Begin_DisguiseOfficer; + func->EndState = &Actor::End_DisguiseOfficer; + func->ResumeState = &Actor::Resume_DisguiseOfficer; + func->SuspendState = &Actor::Suspend_DisguiseOfficer; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Disguise; + func->IsState = &Actor::IsDisguiseState; +} + +void Actor::Begin_DisguiseOfficer + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::End_DisguiseOfficer + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Resume_DisguiseOfficer + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Suspend_DisguiseOfficer + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_DisguiseOfficer + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_disguise_rover.cpp b/code/game/actor_disguise_rover.cpp new file mode 100644 index 00000000..68f0c19a --- /dev/null +++ b/code/game/actor_disguise_rover.cpp @@ -0,0 +1,90 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_disguise_rover.cpp + +#include "actor.h" + +void Actor::InitDisguiseRover + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_DisguiseRover; + func->BeginState = &Actor::Begin_DisguiseRover; + func->EndState = &Actor::End_DisguiseRover; + func->ResumeState = &Actor::Resume_DisguiseRover; + func->SuspendState = &Actor::Suspend_DisguiseRover; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Disguise; + func->IsState = &Actor::IsDisguiseState; +} + +void Actor::Begin_DisguiseRover + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::End_DisguiseRover + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Resume_DisguiseRover + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Suspend_DisguiseRover + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_DisguiseRover + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_disguise_salute.cpp b/code/game/actor_disguise_salute.cpp new file mode 100644 index 00000000..09553158 --- /dev/null +++ b/code/game/actor_disguise_salute.cpp @@ -0,0 +1,100 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_disguise_salute.cpp + +#include "actor.h" + +void Actor::InitDisguiseSalute + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_DisguiseSalute; + func->BeginState = &Actor::Begin_DisguiseSalute; + func->EndState = &Actor::End_DisguiseSalute; + func->ResumeState = &Actor::Resume_DisguiseSalute; + func->SuspendState = &Actor::Suspend_DisguiseSalute; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Disguise; + func->IsState = &Actor::IsDisguiseState; +} + +void Actor::Begin_DisguiseSalute + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::End_DisguiseSalute + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Resume_DisguiseSalute + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Suspend_DisguiseSalute + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_DisguiseSalute + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FinishedAnimation_DisguiseSalute + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_disguise_sentry.cpp b/code/game/actor_disguise_sentry.cpp new file mode 100644 index 00000000..1bd89c4c --- /dev/null +++ b/code/game/actor_disguise_sentry.cpp @@ -0,0 +1,90 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor.cpp: + +#include "actor.h" + +void Actor::InitDisguiseSentry + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_DisguiseSentry; + func->BeginState = &Actor::Begin_DisguiseSentry; + func->EndState = &Actor::End_DisguiseSentry; + func->ResumeState = &Actor::Resume_DisguiseSentry; + func->SuspendState = &Actor::Suspend_DisguiseSentry; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Disguise; + func->IsState = &Actor::IsDisguiseState; +} + +void Actor::Begin_DisguiseSentry + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::End_DisguiseSentry + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Resume_DisguiseSentry + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Suspend_DisguiseSentry + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_DisguiseSentry + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_dog.cpp b/code/game/actor_dog.cpp new file mode 100644 index 00000000..843227bf --- /dev/null +++ b/code/game/actor_dog.cpp @@ -0,0 +1,121 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor.cpp: + +#include "actor.h" + +void Actor::InitDogIdle + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_Dog; + func->EndState = &Actor::End_Dog; + func->ThinkState = &Actor::Think_Dog_Idle; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Idle; + func->IsState = &Actor::IsDogState; +} + +void Actor::InitDogAttack + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_Dog; + func->EndState = &Actor::End_Dog; + func->ThinkState = &Actor::Think_Dog_Attack; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Attack; + func->IsState = &Actor::IsDogState; +} + +void Actor::InitDogCurious + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_Dog; + func->EndState = &Actor::End_Dog; + func->ThinkState = &Actor::Think_Dog_Curious; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Curious; + func->IsState = &Actor::IsDogState; +} + +void Actor::Begin_Dog + ( + void + ) + +{ + m_bAnimating = true; +} + +void Actor::End_Dog + ( + void + ) + +{ +} + +void Actor::Think_Dog_Idle + ( + void + ) + +{ + if( !RequireThink() ) + { + return; + } + + UpdateEyeOrigin(); + m_pszDebugState = "Dog_Idle"; + m_bHasDesiredLookAngles = false; + m_eNextAnimMode = 1; + m_csNextAnimString = STRING_ANIM_DOG_IDLE_SCR; + CheckForThinkStateTransition(); + PostThink( false ); +} + +void Actor::Think_Dog_Attack + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Dog_Curious + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_grenade.cpp b/code/game/actor_grenade.cpp new file mode 100644 index 00000000..d7d792fa --- /dev/null +++ b/code/game/actor_grenade.cpp @@ -0,0 +1,213 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_grenade.cpp + +#include "actor.h" + +void Actor::InitGrenade + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_Grenade; + func->BeginState = &Actor::Begin_Grenade; + func->EndState = &Actor::End_Grenade; + func->ResumeState = &Actor::Resume_Grenade; + func->SuspendState = &Actor::End_Grenade; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Grenade; + func->FinishedAnimation = &Actor::FinishedAnimation_Grenade; + func->IsState = &Actor::IsGrenadeState; +} + +bool Actor::Grenade_Acquire + ( + int eNextState, + const_str csReturnAnim + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::Grenade_Flee + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Grenade_ThrowAcquire + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Grenade_Throw + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Grenade_KickAcquire + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Grenade_Kick + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Grenade_MartyrAcquire + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Grenade_Martyr + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Grenade_Wait + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Grenade_NextThinkState + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Grenade_EventAttach + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Grenade_EventDetach + ( + Event *ev + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Begin_Grenade + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::End_Grenade + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Resume_Grenade + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Grenade + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FinishedAnimation_Grenade + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_idle.cpp b/code/game/actor_idle.cpp new file mode 100644 index 00000000..36644345 --- /dev/null +++ b/code/game/actor_idle.cpp @@ -0,0 +1,57 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_idle.cpp + +#include "actor.h" + +void Actor::InitIdle + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_Idle; + func->ThinkState = &Actor::Think_Idle; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Idle; + func->IsState = &Actor::IsIdleState; +} + +void Actor::Begin_Idle + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Idle + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_killed.cpp b/code/game/actor_killed.cpp new file mode 100644 index 00000000..472ee717 --- /dev/null +++ b/code/game/actor_killed.cpp @@ -0,0 +1,76 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_killed.cpp + +#include "actor.h" + +void Actor::InitDead + ( + GlobalFuncs_t *func + ) + +{ + func->IsState = &Actor::IsKilledState; +} + +void Actor::InitKilled + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_Killed; + func->ThinkState = &Actor::Think_Killed; + func->FinishedAnimation = &Actor::FinishedAnimation_Killed; + func->IsState = &Actor::IsKilledState; +} + +void Actor::Begin_Killed + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Killed + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FinishedAnimation_Killed + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_machinegunner.cpp b/code/game/actor_machinegunner.cpp new file mode 100644 index 00000000..02b332de --- /dev/null +++ b/code/game/actor_machinegunner.cpp @@ -0,0 +1,106 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_machinegunner.cpp + +#include "actor.h" + +void Actor::InitMachineGunner + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_MachineGunner; + func->EndState = &Actor::End_MachineGunner; + func->ThinkState = &Actor::Think_MachineGunner; + func->IsState = &Actor::IsMachineGunnerState; + func->FinishedAnimation = &Actor::FinishedAnimation_MachineGunner; +} + +void Actor::Begin_MachineGunner + ( + void + ) + +{ + // FIXME: stub + STUB(); +} +void Actor::End_MachineGunner + ( + void + ) + +{ + // FIXME: stub + STUB(); +} +void Actor::BecomeTurretGuy + ( + void + ) + +{ + // FIXME: stub + STUB(); +} +void Actor::Think_MachineGunner + ( + void + ) + +{ + // FIXME: stub + STUB(); +} +void Actor::ThinkHoldGun + ( + void + ) + +{ + // FIXME: stub + STUB(); +} +void Actor::FinishedAnimation_MachineGunner + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::MachineGunner_CanSee + ( + Entity *e1, + float fov, + float vision_distance + ) + +{ + // FIXME: stub + STUB(); + return false; +} diff --git a/code/game/actor_noclip.cpp b/code/game/actor_noclip.cpp new file mode 100644 index 00000000..8253f5b2 --- /dev/null +++ b/code/game/actor_noclip.cpp @@ -0,0 +1,56 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_noclip.cpp + +#include "actor.h" + +void Actor::InitNoClip + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_NoClip; + func->IsState = &Actor::IsIdleState; +} + +bool Actor::IsNoClipState + ( + int state + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::Think_NoClip + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_pain.cpp b/code/game/actor_pain.cpp new file mode 100644 index 00000000..6263c0b9 --- /dev/null +++ b/code/game/actor_pain.cpp @@ -0,0 +1,67 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_pain.cpp + +#include "actor.h" + +void Actor::InitPain + ( + GlobalFuncs_t *func + ) + +{ + func->BeginState = &Actor::Begin_Pain; + func->ThinkState = &Actor::Think_Pain; + func->FinishedAnimation = &Actor::FinishedAnimation_Pain; + func->IsState = &Actor::IsPainState; +} + +void Actor::Begin_Pain + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Pain + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FinishedAnimation_Pain + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_patrol.cpp b/code/game/actor_patrol.cpp new file mode 100644 index 00000000..e7ba4f49 --- /dev/null +++ b/code/game/actor_patrol.cpp @@ -0,0 +1,90 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_patrol.cpp + +#include "actor.h" + +void Actor::InitPatrol + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_Patrol; + func->BeginState = &Actor::Begin_Patrol; + func->EndState = &Actor::End_Patrol; + func->ResumeState = &Actor::Resume_Patrol; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Idle; + func->ShowInfo = &Actor::ShowInfo_Patrol; + func->IsState = &Actor::IsIdleState; +} + +void Actor::Begin_Patrol + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::End_Patrol + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Resume_Patrol + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Patrol + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ShowInfo_Patrol + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_runner.cpp b/code/game/actor_runner.cpp new file mode 100644 index 00000000..cba4c539 --- /dev/null +++ b/code/game/actor_runner.cpp @@ -0,0 +1,90 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor.cpp: + +#include "actor.h" + +void Actor::InitRunner + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_Runner; + func->BeginState = &Actor::Begin_Runner; + func->EndState = &Actor::End_Runner; + func->ResumeState = &Actor::Resume_Runner; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Idle; + func->ShowInfo = &Actor::ShowInfo_Runner; + func->IsState = &Actor::IsIdleState; +} + +void Actor::Begin_Runner + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::End_Runner + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Resume_Runner + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Runner + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ShowInfo_Runner + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_turret.cpp b/code/game/actor_turret.cpp new file mode 100644 index 00000000..f77c0dc5 --- /dev/null +++ b/code/game/actor_turret.cpp @@ -0,0 +1,394 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_turret.cpp + +#include "actor.h" + +void Actor::InitTurret + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_Turret; + func->BeginState = &Actor::Begin_Turret; + func->EndState = &Actor::End_Turret; + func->SuspendState = &Actor::Suspend_Turret; + func->ResumeState = NULL; + func->FinishedAnimation = &Actor::FinishedAnimation_Turret; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Attack; + func->PostShoot = &Actor::InterruptPoint_Turret; + func->ReceiveAIEvent = &Actor::ReceiveAIEvent_Turret; + func->IsState = &Actor::IsAttackState; + func->PathnodeClaimRevoked = &Actor::PathnodeClaimRevoked_Turret; +} + +void Actor::Begin_Turret + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::End_Turret + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Suspend_Turret + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Turret + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FinishedAnimation_Turret + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::ReceiveAIEvent_Turret + ( + vec3_t event_origin, + int iType, + Entity *originator, + float fDistSquared, + float fMaxDistSquared + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::InterruptPoint_Turret + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::PathnodeClaimRevoked_Turret + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::Turret_IsRetargeting + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::Turret_DecideToSelectState + ( + void + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::Turret_SelectState + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::Turret_CheckRetarget + ( + void + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +bool Actor::Turret_TryToBecomeCoverGuy + ( + void + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::Turret_BeginRetarget + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Turret_NextRetarget + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Turret_SideStep + ( + int iStepSize, + vec3_t vDir + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Combat + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Reacquire + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_TakeSniperNode + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_SniperNode + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +bool Actor::State_Turret_RunHome + ( + bool bAttackOnFail + ) + +{ + // FIXME: stub + STUB(); + return false; +} + +void Actor::State_Turret_RunAway + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Charge + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Grenade + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_FakeEnemy + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Wait + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Retarget_Sniper_Node + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Retarget_Step_Side_Small + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Retarget_Path_Exact + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Retarget_Path_Near + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Retarget_Step_Side_Medium + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Retarget_Step_Side_Large + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Retarget_Step_Face_Medium + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Turret_Retarget_Step_Face_Large + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actor_weaponless.cpp b/code/game/actor_weaponless.cpp new file mode 100644 index 00000000..f8f5ed0b --- /dev/null +++ b/code/game/actor_weaponless.cpp @@ -0,0 +1,89 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor_weaponless.cpp + +#include "actor.h" + +void Actor::InitWeaponless + ( + GlobalFuncs_t *func + ) + +{ + func->ThinkState = &Actor::Think_Weaponless; + func->BeginState = &Actor::Begin_Weaponless; + func->SuspendState = &Actor::Suspend_Weaponless; + func->PassesTransitionConditions = &Actor::PassesTransitionConditions_Attack; + func->FinishedAnimation = &Actor::FinishedAnimation_Weaponless; + func->IsState = &Actor::IsAttackState; +} + +void Actor::Begin_Weaponless + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Suspend_Weaponless + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::Think_Weaponless + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::FinishedAnimation_Weaponless + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void Actor::State_Weaponless_Normal + ( + void + ) + +{ + // FIXME: stub + STUB(); +} diff --git a/code/game/actorenemy.cpp b/code/game/actorenemy.cpp new file mode 100644 index 00000000..45278281 --- /dev/null +++ b/code/game/actorenemy.cpp @@ -0,0 +1,239 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actorenemy.cpp: + +#include "actorenemy.h" + +ActorEnemy::ActorEnemy() +{ + +} + +ActorEnemy::~ActorEnemy() +{ + +} + +float ActorEnemy::UpdateVisibility + ( + Actor *pSelf, + bool *pbInFovAndRange, + bool *pbVisible + ) + +{ + return 0; +} + +int ActorEnemy::UpdateThreat + ( + Actor *pSelf + ) + +{ + return NULL; +} + +Sentient *ActorEnemy::GetEnemy + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return NULL; +} + +float ActorEnemy::GetVisibility + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return 0; +} + +int ActorEnemy::GetThreat + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return 0; +} + +float ActorEnemy::GetRangeSquared + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return 0; +} + +ActorEnemySet::ActorEnemySet() +{ + +} + +ActorEnemySet::~ActorEnemySet() +{ + +} + +ActorEnemy *ActorEnemySet::AddPotentialEnemy + ( + Sentient *pEnemy + ) + +{ + // FIXME: stub + STUB(); + return NULL; +} + +void ActorEnemySet::FlagBadEnemy + ( + Sentient *pEnemy + ) + +{ + // FIXME: stub + STUB(); +} + +void ActorEnemySet::CheckEnemies + ( + Actor *pSelf + ) + +{ + // FIXME: stub + STUB(); +} + +Sentient *ActorEnemySet::GetCurrentEnemy + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return NULL; +} + +float ActorEnemySet::GetCurrentVisibility + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return 0; +} + +int ActorEnemySet::GetCurrentThreat + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return 0; +} + +qboolean ActorEnemySet::IsEnemyConfirmed + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return false; +} + +bool ActorEnemySet::HasAlternateEnemy + ( + void + ) const + +{ + // FIXME: stub + STUB(); + return false; +} + +void ActorEnemySet::RemoveAll + ( + void + ) + +{ + // FIXME: stub + STUB(); +} + +void ActorEnemySet::ConfirmEnemy + ( + Actor *pSelf, + Sentient *pEnemy + ) + +{ + // FIXME: stub + STUB(); +} + +void ActorEnemySet::ConfirmEnemyIfCanSeeSharerOrEnemy + ( + Actor *pSelf, + Actor *pSharer, + Sentient *pEnemy + ) + +{ + // FIXME: stub + STUB(); +} + +bool ActorEnemySet::CaresAboutPerfectInfo + ( + Sentient *pEnemy + ) + +{ + // FIXME: stub + STUB(); + return false; +} diff --git a/code/game/actorenemy.h b/code/game/actorenemy.h new file mode 100644 index 00000000..65e7e471 --- /dev/null +++ b/code/game/actorenemy.h @@ -0,0 +1,118 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actorenemy.h + +#include "g_local.h" + +class Actor; +class Sentient; + +class ActorEnemy : public Class { +public: + int m_iAddTime; + float m_fLastLookTime; + float m_fVisibility; + float m_fTotalVisibility; + int m_iThreat; + SafePtr m_pEnemy; + float m_fCurrentRangeSquared; + Vector m_vLastKnownPos; + int m_iLastSightChangeTime; + bool m_bVisible; + + ActorEnemy(); + virtual ~ActorEnemy(); + float UpdateVisibility( Actor *pSelf, bool *pbInFovAndRange, bool *pbVisible ); + int UpdateThreat( Actor *pSelf ); + Sentient *GetEnemy( void ) const; + float GetVisibility( void ) const; + int GetThreat( void ) const; + float GetRangeSquared( void ) const; + + virtual void Archive( Archiver & ); + +protected: + float UpdateLMRF( Actor *pSelf, bool *pbInFovAndRange, bool *pbVisible ); +}; + +inline void ActorEnemy::Archive + ( + Archiver& arc + ) + +{ + Class::Archive( arc ); + + arc.ArchiveInteger( &m_iAddTime ); + arc.ArchiveFloat( &m_fLastLookTime ); + arc.ArchiveFloat( &m_fVisibility ); + arc.ArchiveFloat( &m_fTotalVisibility ); + arc.ArchiveInteger( &m_iThreat ); + arc.ArchiveSafePointer( &m_pEnemy ); + arc.ArchiveFloat( &m_fCurrentRangeSquared ); + arc.ArchiveVector( &m_vLastKnownPos ); + arc.ArchiveInteger( &m_iLastSightChangeTime ); + arc.ArchiveBool( &m_bVisible ); +} + +class ActorEnemySet : public Class { +protected: + Container m_Enemies; + int m_iCheckCount; + SafePtr m_pCurrentEnemy; + float m_fCurrentVisibility; + int m_iCurrentThreat; +public: + ActorEnemySet(); + virtual ~ActorEnemySet(); + + ActorEnemy *AddPotentialEnemy( Sentient *pEnemy ); + void FlagBadEnemy( Sentient *pEnemy ); + void CheckEnemies( Actor *pSelf ); + Sentient *GetCurrentEnemy( void ) const; + float GetCurrentVisibility( void ) const; + int GetCurrentThreat( void ) const; + qboolean IsEnemyConfirmed( void ) const; + bool HasAlternateEnemy( void ) const; + void RemoveAll( void ); + void ConfirmEnemy( Actor *pSelf, Sentient *pEnemy ); + void ConfirmEnemyIfCanSeeSharerOrEnemy( Actor *pSelf, Actor *pSharer, Sentient *pEnemy ); + bool CaresAboutPerfectInfo( Sentient *pEnemy ); + + virtual void Archive( Archiver& arc ); +}; + +inline void ActorEnemySet::Archive + ( + Archiver& arc + ) + +{ + Class::Archive( arc ); + + m_Enemies.Archive( arc, ArchiveClass< ActorEnemy > ); + arc.ArchiveInteger( &m_iCheckCount ); + arc.ArchiveSafePointer( &m_pCurrentEnemy ); + arc.ArchiveFloat( &m_fCurrentVisibility ); + arc.ArchiveInteger( &m_iCurrentThreat ); +} diff --git a/code/game/actorpath.cpp b/code/game/actorpath.cpp new file mode 100644 index 00000000..ab1000fd --- /dev/null +++ b/code/game/actorpath.cpp @@ -0,0 +1,676 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor.cpp: + +#include "actor.h" + +ActorPath::ActorPath() +{ + m_FallHeight = 96; + m_path = NULL; + m_pathlen = 0; + m_fLookAhead = 4096.0f; + m_bChangeLookAhead = true; + + Clear(); +} + +ActorPath::~ActorPath() +{ + if( m_path ) + delete m_path; +} + +void ActorPath::Clear + ( + void + ) + +{ + m_startpathpos = 0; + m_pathpos = 0; + m_Side = 0; + m_Time = -10000000; + m_delta[ 0 ] = 0; + m_delta[ 1 ] = 0; +} + +bool ActorPath::DoesTheoreticPathExist + ( + float *start, + float *end, + class SimpleActor *ent, + float maxPath, + float *vLeashHome, + float fLeashDistSquared + ) const + +{ + return PathSearch::FindPath( start, end, ent, maxPath, NULL, 0, m_FallHeight ) != 0; +} + +void ActorPath::FindPath + ( + float *start, + float *end, + Entity *ent, + float maxPath, + float *vLeashHome, + float fLeashDistSquared + ) + +{ + int depth = PathManager.FindPath( start, end, ent, maxPath, vLeashHome, fLeashDistSquared, m_FallHeight ); + + if( depth ) + { + if( depth > m_pathlen ) + { + if( m_path ) + delete m_path; + + m_pathlen = 10 * ( depth - 1 ) / 10 + 10; + m_path = new PathInfo[ m_pathlen ]; + } + + m_startpathpos = PathManager.GeneratePath( m_path ); + m_pathpos = m_startpathpos; + m_TotalDist = PathManager.total_dist; + m_Side = false; + m_Time = level.inttime; + UpdatePos( start ); + } + else + { + Clear(); + } +} + +void ActorPath::FindPathAway + ( + float *start, + float *avoid, + float *vPreferredDir, + Entity *ent, + float fMinSafeDist, + float *vLeashHome, + float fLeashDistSquared + ) + +{ + int depth = PathManager.FindPathAway( start, avoid, vPreferredDir, ent, fMinSafeDist, vLeashHome, fLeashDistSquared, m_FallHeight ); + + if( depth ) + { + if( depth > m_pathlen ) + { + if( m_path ) + delete m_path; + + m_pathlen = 10 * ( depth - 1 ) / 10 + 10; + m_path = new PathInfo[ m_pathlen ]; + } + + m_startpathpos = PathManager.GeneratePathAway( m_path ); + m_pathpos = m_startpathpos; + m_TotalDist = PathManager.total_dist; + m_Side = false; + m_Time = level.inttime; + UpdatePos( start ); + } + else + { + Clear(); + } +} + +void ActorPath::FindPathNear + ( + float *start, + float *nearby, + Entity *ent, + float maxPath, + float fRadiusSquared, + float *vLeashHome, + float fLeashDistSquared + ) + +{ + int depth = PathManager.FindPathNear( start, nearby, ent, maxPath, fRadiusSquared, vLeashHome, fLeashDistSquared, m_FallHeight ); + + if( depth ) + { + if( depth > m_pathlen ) + { + if( m_path ) + delete m_path; + + m_pathlen = 10 * ( depth - 1 ) / 10 + 10; + m_path = new PathInfo[ m_pathlen ]; + } + + m_startpathpos = PathManager.GeneratePathNear( m_path ); + m_pathpos = m_startpathpos; + m_TotalDist = PathManager.total_dist; + m_Side = false; + m_Time = level.inttime; + UpdatePos( start ); + } + else + { + Clear(); + } +} + +void ActorPath::ReFindPath + ( + float *start, + Entity *ent + ) + +{ + int depth = PathManager.FindPath( start, m_path->point, ent, 0, NULL, 0, m_FallHeight ); + + if( depth ) + { + if( depth > m_pathlen ) + { + if( m_path ) + delete m_path; + + m_pathlen = 10 * ( depth - 1 ) / 10 + 10; + m_path = new PathInfo[ m_pathlen ]; + } + + m_startpathpos = PathManager.GeneratePath( m_path ); + m_pathpos = m_startpathpos; + m_TotalDist = PathManager.total_dist; + m_Side = false; + m_Time = level.inttime; + UpdatePos( start ); + } + else + { + Clear(); + } +} + +float ActorPath::PathLookAhead + ( + float total_area, + Vector& end, + float *origin + ) + +{ + float area = total_area; + float s; + float t; + float normal[ 2 ]; + float delta[ 2 ]; + Vector pos; + float fallheight; + PathInfo *current_path = m_pathpos; + + while( 1 ) + { + pos = current_path->point; + + if( current_path == m_path ) + break; + + fallheight = current_path->point[ 2 ] - origin[ 2 ]; + + if( fallheight > 94.0f || fallheight < -94.0f ) + { + VectorCopy( current_path->point, end ); + m_HasCompleteLookahead = false; + return area; + } + + current_path--; + + normal[ 0 ] = current_path->point[ 1 ] - pos[ 1 ]; + normal[ 1 ] = pos[ 0 ] - current_path->point[ 0 ]; + + VectorNormalize2D( normal ); + + delta[ 0 ] = current_path->point[ 0 ] - origin[ 0 ]; + delta[ 1 ] = current_path->point[ 1 ] - origin[ 1 ]; + + t = fabs( DotProduct2D( delta, normal ) ) * current_path->dist; + + if( t >= area ) + { + t = area / t; + s = 1.0f - t; + + end[ 0 ] = current_path->point[ 0 ] * t + pos[ 0 ] * s; + end[ 1 ] = current_path->point[ 1 ] * t + pos[ 1 ] * s; + end[ 2 ] = current_path->point[ 2 ] * t + pos[ 2 ] * s; + m_HasCompleteLookahead = false; + return 0; + } + + area -= t; + } + + VectorCopy( current_path->point, end ); + m_HasCompleteLookahead = true; + + return area; +} + +void ActorPath::UpdatePos + ( + float *origin, + float fNodeRadius + ) + +{ + Vector end; + float s = 0; + float t = 0; + vec2_t delta; + float current_dot = 0; + float previous_dot = 0; + Vector pos; + PathInfo *current_path = NULL; + vec2_t dir; + Vector end2; + vec2_t delta2; + vec2_t dir2; + + if( m_pathpos == m_path ) + { + end = m_pathpos->point; + m_bChangeLookAhead = true; + m_HasCompleteLookahead = true; + m_delta[ 0 ] = end[ 0 ] - origin[ 0 ]; + m_delta[ 1 ] = end[ 1 ] - origin[ 1 ]; + VectorNormalize2D2( m_delta, dir ); + } + else if( m_fLookAhead >= 4096.0f ) + { + if( m_fLookAhead - 4096.0f >= PathLookAhead( m_fLookAhead, end, origin ) ) + { + Vector mins = Vector( -15, -15, 0 ); + Vector maxs = Vector( 15, 15, 60 ); + Vector e = end + Vector( 0, 0, 32 ); + + pos = origin + Vector( 0, 0, 32 ); + + if( G_SightTrace( + pos, + mins, + maxs, + e, + ( gentity_t * )NULL, // g_entities[ 0 ].entity + 0, + MASK_PLAYERSOLID, + false, + "Actor::UpdatePos 2" ) != true ) + { + if( m_bChangeLookAhead ) + { + m_fLookAhead -= 2048.0f; + m_bChangeLookAhead = false; + } + else + { + m_fLookAhead *= 0.5f; + } + + if( m_fLookAhead < 4096.0f ) + { + m_fLookAhead = 4096.0f; + } + + PathLookAhead( 4096.0f, end, origin ); + goto __setdelta; + } + } + + m_fLookAhead += 1024.0f; + + if( m_fLookAhead > 65536.0f ) + m_fLookAhead = 65536.0f; + + m_bChangeLookAhead = true; + +__setdelta: + + m_delta[ 0 ] = end[ 0 ] - origin[ 0 ]; + m_delta[ 1 ] = end[ 1 ] - origin[ 1 ]; + + VectorNormalize2D2( m_delta, dir ); + } + else if( PathLookAhead( 4096.0f, end, origin ) < 4096.0f - m_fLookAhead ) + { + PathLookAhead( m_fLookAhead, end2, origin ); + + Vector mins = Vector( -15, -15, 0 ); + Vector maxs = Vector( 15, 15, 60 ); + Vector e = end2 + Vector( 0, 0, 32 ); + + pos = origin + Vector( 0, 0, 32 ); + + if( G_SightTrace( + pos, + mins, + maxs, + e, + ( gentity_t * )NULL, + 0, + MASK_MONSTERSOLID, + false, + "Actor::UpdatePos 1" ) != true ) + { + m_fLookAhead += 1024.0f; + + if( m_fLookAhead > 4096.0f ) + m_fLookAhead = 4096.0f; + } + else + { + m_fLookAhead -= 1024.0f; + + if( m_fLookAhead < 1024.0f ) + m_fLookAhead = 1024.0f; + + PathLookAhead( m_fLookAhead, end2, origin ); + } + + delta[ 0 ] = end2[ 0 ] - origin[ 0 ]; + delta[ 1 ] = end2[ 1 ] - origin[ 1 ]; + VectorNormalize2D2( delta, dir2 ); + + m_delta[ 0 ] = end[ 0 ] - origin[ 0 ]; + m_delta[ 1 ] = end[ 1 ] - origin[ 1 ]; + VectorNormalize2D2( m_delta, dir ); + + if( DotProduct2D( dir, dir2 ) > 0.7f ) + { + m_delta[ 0 ] = delta[ 0 ]; + m_delta[ 1 ] = delta[ 1 ]; + } + + m_bChangeLookAhead = true; + } + else + { + m_fLookAhead -= 1024.0f; + + if( m_fLookAhead < 1024.0f ) + m_fLookAhead = 1024.0f; + + m_delta[ 0 ] = end[ 0 ] - origin[ 0 ]; + m_delta[ 1 ] = end[ 1 ] - origin[ 1 ]; + VectorNormalize2D2( m_delta, dir ); + + m_bChangeLookAhead = true; + } + + current_path = m_pathpos; + + while( 1 ) + { + delta2[ 0 ] = current_path->point[ 0 ] - origin[ 0 ]; + delta2[ 1 ] = current_path->point[ 1 ] - origin[ 1 ]; + current_dot = DotProduct2D( delta2, dir ) - fNodeRadius; + + if( current_dot >= 0.0f ) + break; + + previous_dot = current_dot; + + if( current_path == LastNode() ) + break; + + current_path--; + } + + if( current_path != m_pathpos ) + { + m_pathpos = current_path + 1; + + t = previous_dot / ( previous_dot - current_dot ); + s = 1.0f - t; + + /*m_pathpos->point[ 0 ] = m_pathpos->point[ 0 ] * s + current_path->point[ 0 ] * t; + m_pathpos->point[ 1 ] = m_pathpos->point[ 1 ] * s + current_path->point[ 1 ] * t; + m_pathpos->point[ 2 ] = m_pathpos->point[ 2 ] * s + current_path->point[ 2 ] * t;*/ + + VectorCopy( current_path->point, m_pathpos->point ); + + current_path->dist *= s; + + m_Side = true; + } + else + { + m_Side = false; + } +} + +bool ActorPath::Complete + ( + const float *origin + ) const + +{ + if( !m_HasCompleteLookahead ) + return false; + + if( !m_path ) + return true; + + if( fabs( origin[ 0 ] - m_path->point[ 0 ] ) < 16.0f && + fabs( origin[ 1 ] - m_path->point[ 1 ] ) < 16.0f ) + { + return true; + } + + return false; +} + +PathInfo *ActorPath::StartNode + ( + void + ) const + +{ + return m_startpathpos; +} + +PathInfo *ActorPath::CurrentNode + ( + void + ) const + +{ + return m_pathpos; +} + +int ActorPath::CurrentNodeIndex + ( + void + ) const + +{ + return m_pathpos - m_path; +} + +PathInfo *ActorPath::NextNode + ( + void + ) const + +{ + return m_pathpos - 1; +} + +PathInfo *ActorPath::LastNode + ( + void + ) const + +{ + return m_path; +} + +Vector ActorPath::CurrentPathDir + ( + void + ) const + +{ + return Vector( m_pathpos->dir[ 0 ], m_pathpos->dir[ 1 ], 0 ); +} + +float *ActorPath::CurrentPathGoal + ( + void + ) const + +{ + return m_pathpos->point; +} + +int ActorPath::Time + ( + void + ) const + +{ + return m_Time; +} + +Vector ActorPath::CurrentDelta + ( + void + ) const + +{ + return Vector( m_delta[ 0 ], m_delta[ 1 ], 0 ); +} + +bool ActorPath::IsAccurate + ( + void + ) const + +{ + return m_pathpos->bAccurate; +} + +float ActorPath::TotalDist + ( + void + ) const + +{ + return m_TotalDist; +} + +void ActorPath::SetFallHeight + ( + float fHeight + ) + +{ + m_FallHeight = fHeight; +} + +float ActorPath::GetFallHeight + ( + void + ) const + +{ + return m_FallHeight; +} + +void ActorPath::TrimPathFromEnd + ( + int nNodesPop + ) + +{ + int iLastPos = m_path - m_pathpos; + + if( iLastPos - nNodesPop > 0 ) + { + for( int i = 0; i < iLastPos; i++ ) + { + m_path[ i ] = m_path[ i + nNodesPop ]; + } + } + else + { + Clear(); + } +} + +void ActorPath::Shorten + ( + float fDistRemove + ) + +{ + if( m_path->dist > fDistRemove ) + { + m_path->point[ 0 ] += m_path->dir[ 0 ] * -fDistRemove; + m_path->point[ 1 ] += m_path->dir[ 1 ] * -fDistRemove; + m_path->point[ 2 ] += m_path->dir[ 2 ] * -fDistRemove; + m_path->dist -= fDistRemove; + } + else + { + while( fDistRemove - m_path->dist > m_path->dist ) + { + TrimPathFromEnd( 1 ); + + if( !m_pathpos ) + return; + } + } +} + +bool ActorPath::HasCompleteLookahead + ( + void + ) const + +{ + return m_HasCompleteLookahead; +} + +void ActorPath::ForceShortLookahead + ( + void + ) + +{ + m_fLookAhead = 4096.0f; +} diff --git a/code/game/actorpath.h b/code/game/actorpath.h new file mode 100644 index 00000000..12cc533b --- /dev/null +++ b/code/game/actorpath.h @@ -0,0 +1,156 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actorpath.h: Actor path + +#ifndef __ACTORPATH_H__ +#define __ACTORPATH_H__ + +class ActorPath { + // path list + PathInfo *m_path; + int m_pathlen; + + // path position + PathInfo *m_pathpos; + + // starting path position + PathInfo *m_startpathpos; + vec2_t m_delta; + bool m_Side; + int m_Time; + float m_TotalDist; + short int m_FallHeight; + bool m_HasCompleteLookahead; + float m_fLookAhead; + bool m_bChangeLookAhead; + +private: + float PathLookAhead( float total_area, Vector& end, float *origin ); + +public: + ActorPath(); + ~ActorPath(); + + void Clear( void ); + bool DoesTheoreticPathExist( float *start, float *end, class SimpleActor *ent, float maxPath, float *vLeashHome, float fLeashDistSquared ) const; + void FindPath( float *start, float *end, Entity *ent, float maxPath, float *vLeashHome, float fLeashDistSquared ); + void FindPathAway( float *start, float *avoid, float *vPreferredDir, Entity *ent, float fMinSafeDist, float *vLeashHome, float fLeashDistSquared ); + void FindPathNear( float *start, float *nearby, Entity *ent, float maxPath, float fRadiusSquared, float *vLeashHome, float fLeashDistSquared ); + void ReFindPath( float *start, Entity *ent ); + void UpdatePos( float *origin, float fNodeRadius = 0.0f ); + bool Complete( const float *origin ) const; + PathInfo *StartNode( void ) const; + PathInfo *CurrentNode( void ) const; + int CurrentNodeIndex( void ) const; + PathInfo *NextNode( void ) const; + PathInfo *LastNode( void ) const; + Vector CurrentPathDir( void ) const; + float *CurrentPathGoal( void ) const; + int Time( void ) const; + Vector CurrentDelta( void ) const; + bool IsAccurate( void ) const; + float TotalDist( void ) const; + void SetFallHeight( float fHeight ); + float GetFallHeight( void ) const; + void TrimPathFromEnd( int nNodesPop ); + void Shorten( float fDistRemove ); + bool HasCompleteLookahead( void ) const; + void ForceShortLookahead( void ); + + virtual void Archive( Archiver& arc ); +}; + +inline void ActorPath::Archive + ( + Archiver& arc + ) + +{ + int pos; + int startpathpos; + + arc.ArchiveInteger( &m_pathlen ); + + if( m_pathlen ) + { + if( arc.Loading() ) + { + m_path = new PathInfo[ m_pathlen ]; + } + + if( m_pathlen > 0 ) + { + for( int i = 0; i < m_pathlen; i++ ) + { + m_path->Archive( arc ); + } + } + + if( !arc.Saving() ) + { + arc.ArchiveInteger( &pos ); + if( pos == -1 ) + m_pathpos = NULL; + else + m_pathpos = &m_path[ pos ]; + + arc.ArchiveInteger( &startpathpos ); + if( startpathpos == -1 ) + m_startpathpos = NULL; + else + m_startpathpos = &m_path[ pos ]; + } + else + { + if( m_pathpos ) + pos = m_pathpos - m_path; + else + pos = -1; + + arc.ArchiveInteger( &pos ); + + if( m_startpathpos ) + pos = m_startpathpos - m_path; + else + pos = -1; + + arc.ArchiveInteger( &pos ); + } + } + else if( arc.Loading() ) + { + m_pathpos = 0; + } + + arc.ArchiveVec2( m_delta ); + arc.ArchiveBool( &m_Side ); + arc.ArchiveInteger( &m_Time ); + arc.ArchiveFloat( &m_TotalDist ); + arc.ArchiveShort( &m_FallHeight ); + arc.ArchiveShort( &m_FallHeight ); + arc.ArchiveBool( &m_HasCompleteLookahead ); + arc.ArchiveFloat( &m_fLookAhead ); + arc.ArchiveBool( &m_bChangeLookAhead ); +} + +#endif /* actorpath.h */ diff --git a/code/game/ammo.cpp b/code/game/ammo.cpp new file mode 100644 index 00000000..64667f7a --- /dev/null +++ b/code/game/ammo.cpp @@ -0,0 +1,183 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// ammo.cpp: Base class for all ammunition for entities derived from the Weapon class. +// +// AmmoEntity is the Class which represents ammo that the player "sees" and " +// picks up" in the game +// +// Ammo is the Class which is used to keep track of how much ammo a player has +// in his inventory + +#include "ammo.h" +#include "player.h" + +CLASS_DECLARATION( Item, AmmoEntity, NULL ) + { + { NULL, NULL } + }; + +AmmoEntity::AmmoEntity + ( + ) + + { + if ( LoadingSavegame ) + { + // all data will be setup by the archive function + return; + } + setName( "UnknownAmmo" ); + amount = 0; + } + +Item *AmmoEntity::ItemPickup + ( + Entity *other, + qboolean add_to_inventory + ) + + { + Sentient *player; + str realname; + AliasListNode_t *ret; + + if ( !other->isSubclassOf( Player ) ) + return NULL; + + player = ( Sentient * )other; + + // Play pickup sound + realname = GetRandomAlias( "snd_pickup", &ret ); + if ( realname.length() > 1 ) + player->Sound( realname, CHAN_ITEM ); + + // Cancel some events + CancelEventsOfType( EV_Item_DropToFloor ); + CancelEventsOfType( EV_Item_Respawn ); + CancelEventsOfType( EV_FadeOut ); + + // Hide the model + setSolidType( SOLID_NOT ); + hideModel(); + + // Respawn? + if ( !Respawnable() ) + PostEvent( EV_Remove, FRAMETIME ); + else + PostEvent( EV_Item_Respawn, RespawnTime() ); + + // Give the ammo to the player + player->GiveAmmo( item_name, amount ); + return NULL; // This doesn't create any items + } + + +// This is the Class that is used to keep track of ammo in the player's inventory. +// It is not an entit, just a name and an amount. + +CLASS_DECLARATION( Class, Ammo, NULL ) + { + {NULL, NULL} + }; + +Ammo::Ammo + ( + ) + + { + if ( LoadingSavegame ) + { + // all data will be setup by the archive function + return; + } + setName( "UnknownAmmo" ); + setAmount( 0 ); + setMaxAmount( 100 ); + } + +void Ammo::setAmount + ( + int a + ) + + { + amount = a; + + if ( ( maxamount > 0 ) && ( amount > maxamount ) ) + amount = maxamount; + } + +int Ammo::getAmount + ( + void + ) + + { + return amount; + } + +void Ammo::setMaxAmount + ( + int a + ) + + { + maxamount = a; + } + +int Ammo::getMaxAmount + ( + void + ) + + { + return maxamount; + } + +void Ammo::setName + ( + str n + ) + + { + name = n; + name_index = gi.itemindex( name ) + CS_WEAPONS; + } + +str Ammo::getName + ( + void + ) + + { + return name; + } + +int Ammo::getIndex + ( + void + ) + + { + return name_index; + } diff --git a/code/game/ammo.h b/code/game/ammo.h new file mode 100644 index 00000000..97833370 --- /dev/null +++ b/code/game/ammo.h @@ -0,0 +1,83 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// ammo.h: Base class for all ammunition for entities derived from the Weapon class. + +#ifndef __AMMO_H__ +#define __AMMO_H__ + +#include "g_local.h" +#include "item.h" + +class AmmoEntity : public Item + { + public: + CLASS_PROTOTYPE( AmmoEntity ); + + AmmoEntity(); + virtual Item *ItemPickup( Entity *other, qboolean add_to_inventory ); + }; + +class Ammo : public Class + { + int amount; + int maxamount; + str name; + int name_index; + + public: + CLASS_PROTOTYPE( Ammo ); + + Ammo(); + Ammo(str name, int amount, int name_index ); + + void setAmount( int a ); + int getAmount( void ); + void setMaxAmount( int a ); + int getMaxAmount( void ); + void setName( str name); + str getName( void ); + int getIndex( void ); + virtual void Archive( Archiver &arc ); + }; + +inline void Ammo::Archive + ( + Archiver &arc + ) + + { + Class::Archive( arc ); + + arc.ArchiveInteger( &amount ); + arc.ArchiveInteger( &maxamount ); + arc.ArchiveString( &name ); + // + // name_index not archived, because it is auto-generated by gi.itemindex + // + if ( arc.Loading() ) + { + setName( name ); + } + } + +#endif /* ammo.h */ diff --git a/code/game/animate.cpp b/code/game/animate.cpp new file mode 100644 index 00000000..09cd6cec --- /dev/null +++ b/code/game/animate.cpp @@ -0,0 +1,752 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// animate.cpp : Animate Class + +#include "animate.h" +#include "../game/player.h" +#include "../qcommon/qfiles.h" + +// Leg Animation events +Event EV_SetAnim +( + "anim", + 0, + "sIF", + "animName slot weight", + "Exec anim commands on server or client.", + EV_NORMAL +); +Event EV_SetSyncTime +( + "setsynctime", + 0, + "f", + "synctime", + "Set sync time for entity." +); +Event EV_ViewAnim +( + "viewanim", + EV_DEFAULT, + "s", + "anim", + "testing" +); +Event EV_Animate_IsLoopingAnim +( + "isloopinganim", + EV_DEFAULT, + "s", + "anim_name", + "returns 1 if the anim is a looping anim, or 0 otherwise", + EV_RETURN +); + +MEM_BlockAlloc< AnimationEvent, MEM_BLOCKSIZE > AnimationEvent_allocator; + +void *AnimationEvent::operator new( size_t size ) +{ + return AnimationEvent_allocator.Alloc(); +} + +void AnimationEvent::operator delete( void *ptr ) +{ + return AnimationEvent_allocator.Free( ptr ); +} + +CLASS_DECLARATION( Event, AnimationEvent, NULL ) +{ + { NULL, NULL } +}; + +Animate::Animate() +{ + entflags |= EF_ANIMATE; + + pauseSyncTime = 0.0f; + syncTime = 0.0f; + syncRate = 1.0f; + + frame_delta = vec_zero; + + edict->s.actionWeight = 1.0f; + + if( !LoadingSavegame ) + { + for( int i = 0; i < 16; i++ ) + { + edict->s.frameInfo[ i ].index = 0; + edict->s.frameInfo[ i ].time = 0.0f; + edict->s.frameInfo[ i ].weight = 0.0f; + + animFlags[ i ] = 57; + doneEvents[ i ] = NULL; + animtimes[ i ] = 0.0f; + frametimes[ i ] = 0.0f; + } + + flags |= FL_ANIMATE; + } +} + +Animate::~Animate() +{ + entflags &= ~EF_ANIMATE; +} + +void Animate::Pause( int slot, int pause ) +{ + if( pause ) + { + animFlags[ slot ] |= ANIM_PAUSED; + } + else + { + if( ( animFlags[ slot ] & ANIM_PAUSED ) ) + { + if( ( animFlags[ slot ] & ANIM_SYNC ) ) + { + animFlags[ slot ] = ( animFlags[ slot ] | ANIM_NODELTA ) & ~ANIM_FINISHED; + } + + animFlags[ slot ] &= ~ANIM_PAUSED; + } + } +} + +void Animate::StopAnimating( int slot ) +{ + DoExitCommands( slot ); + + if( doneEvents[ slot ] ) + { + delete doneEvents[ slot ]; + doneEvents[ slot ] = NULL; + } + + CancelFlaggedEvents( 1 << slot ); + + if( edict->s.frameInfo[ slot ].index || gi.TIKI_NumAnims( edict->tiki ) <= 1 ) + { + edict->s.frameInfo[ slot ].index = 0; + } + else + { + edict->s.frameInfo[ slot ].index = 1; + } + + edict->s.frameInfo[ slot ].weight = 0.0f; + + animFlags[ slot ] = ANIM_LOOP | ANIM_NODELTA | ANIM_NOEXIT | ANIM_PAUSED; + animtimes[ slot ] = 0.0f; +} + +void Animate::StopAnimatingAtEnd( int slot ) +{ +} + +void Animate::DoExitCommands( int slot ) +{ + tiki_cmd_t cmds; + AnimationEvent *ev; + + if( animFlags[ slot ] & ANIM_NOEXIT ) { + return; + } + + // exit the previous animation + if( gi.Frame_Commands( edict->tiki, edict->s.frameInfo[ slot ].index, TIKI_FRAME_EXIT, &cmds ) ) + { + int ii, j; + + for( ii = 0; ii < cmds.num_cmds; ii++ ) + { + ev = new AnimationEvent( cmds.cmds[ ii ].args[ 0 ] ); + + ev->SetAnimationNumber( edict->s.frameInfo[ slot ].index ); + ev->SetAnimationFrame( 0 ); + + for( j = 1; j < cmds.cmds[ ii ].num_args; j++ ) + { + ev->AddToken( cmds.cmds[ ii ].args[ j ] ); + } + + PostEvent( ev, 0 ); + } + } + + animFlags[ slot ] |= ANIM_NOEXIT; +} + +void Animate::NewAnim( int animnum, int slot, float weight ) +{ + qboolean newanim = edict->s.frameInfo[ slot ].index != animnum; + tiki_cmd_t cmds; + float time; + int numframes; + AnimationEvent *ev; + int i; + + if( newanim ) + { + DoExitCommands( slot ); + } + + if( doneEvents[ slot ] ) + { + delete doneEvents[ slot ]; + doneEvents[ slot ] = NULL; + } + + CancelFlaggedEvents( 1 << slot ); + + edict->s.frameInfo[ slot ].index = animnum; + + animFlags[ slot ] = ANIM_LOOP | ANIM_NODELTA | ANIM_NOEXIT; + + if( !( gi.Anim_FlagsSkel( edict->tiki, animnum ) & ANIM_LOOP ) ) + { + animFlags[ slot ] &= ~ANIM_LOOP; + } + + edict->s.frameInfo[ slot ].weight = weight; + + animtimes[ slot ] = gi.Anim_Time( edict->tiki, animnum ); + frametimes[ slot ] = gi.Anim_Frametime( edict->tiki, animnum ); + + if( edict->s.eType == ET_GENERAL ) + { + edict->s.eType = ET_MODELANIM; + } + + qboolean hascommands = gi.Anim_HasCommands( edict->tiki, animnum ); + + // enter this animation + if( newanim ) + { + if( !hascommands ) { + return; + } + + if( gi.Frame_Commands( edict->tiki, animnum, TIKI_FRAME_ENTRY, &cmds ) ) + { + int ii, j; + + for( ii = 0; ii < cmds.num_cmds; ii++ ) + { + ev = new AnimationEvent( cmds.cmds[ ii ].args[ 0 ] ); + + ev->SetAnimationNumber( animnum ); + ev->SetAnimationFrame( 0 ); + + for( j = 1; j < cmds.cmds[ ii ].num_args; j++ ) + { + ev->AddToken( cmds.cmds[ ii ].args[ j ] ); + } + + ProcessEvent( ev ); + } + } + } + + if( !hascommands ) + { + return; + } + + if( !edict->tiki ) + { + return; + } + + time = 0.0f; + numframes = gi.Anim_NumFrames( edict->tiki, animnum ); + + for( i = 0; i < numframes; i++, time += frametimes[ slot ] ) + { + // we want normal frame commands to occur right on the frame + if( gi.Frame_Commands( edict->tiki, animnum, i, &cmds ) ) + { + int ii, j; + + for( ii = 0; ii < cmds.num_cmds; ii++ ) + { + ev = new AnimationEvent( cmds.cmds[ ii ].args[ 0 ] ); + + ev->SetAnimationNumber( animnum ); + ev->SetAnimationFrame( i ); + + for( j = 1; j < cmds.cmds[ ii ].num_args; j++ ) + { + ev->AddToken( cmds.cmds[ ii ].args[ j ] ); + } + + PostEvent( ev, time, 1 << slot ); + } + } + } +} + +void Animate::NewAnim( int animnum, Event &newevent, int slot, float weight ) +{ + if( animnum == -1 ) + { + PostEvent( newevent, level.frametime ); + } + + NewAnim( animnum, slot ); + SetAnimDoneEvent( newevent, slot ); +} + +void Animate::NewAnim( int animnum, Event *newevent, int slot, float weight ) +{ + if( animnum == -1 ) + { + if( newevent ) + { + PostEvent( newevent, level.frametime ); + } + } + + NewAnim( animnum, slot ); + SetAnimDoneEvent( newevent, slot ); +} + +void Animate::NewAnim( const char *animname, int slot, float weight ) +{ + int animnum = gi.Anim_Random( edict->tiki, animname ); + + if( animnum != -1 ) + { + NewAnim( animnum, slot ); + } +} + +void Animate::NewAnim( const char *animname, Event *endevent, int slot, float weight ) +{ + int animnum = gi.Anim_Random( edict->tiki, animname ); + + if( animnum != -1 ) + { + NewAnim( animnum, endevent, slot ); + } +} + +void Animate::NewAnim( const char *animname, Event &endevent, int slot, float weight ) +{ + int animnum = gi.Anim_Random( edict->tiki, animname ); + + if( animnum != -1 ) + { + NewAnim( animnum, endevent, slot ); + } +} + +void Animate::FrameDeltaEvent( Event *ev ) +{ + +} + +void Animate::SetAnimDoneEvent( Event *event, int slot ) +{ + if( doneEvents[ slot ] ) + { + delete doneEvents[ slot ]; + } + + doneEvents[ slot ] = event; +} + +void Animate::SetAnimDoneEvent( Event &event, int slot ) +{ + SetAnimDoneEvent( new Event( event ), slot ); +} + +void Animate::SetFrame( void ) +{ + edict->s.frameInfo[ 0 ].time = 0; + animFlags[ 0 ] = ( animFlags[ 0 ] | ANIM_NODELTA ) & ~ANIM_FINISHED; +} + +qboolean Animate::HasAnim( const char *animname ) +{ + int num; + + num = gi.Anim_Random( edict->tiki, animname ); + return ( num >= 0 ); +} + +void Animate::AnimFinished( int slot ) +{ + animFlags[ slot ] &= ~ANIM_FINISHED; + + if( doneEvents[ slot ] ) + { + Event *ev = doneEvents[ slot ]; + doneEvents[ slot ] = NULL; + + ProcessEvent( ev ); + } +} + +float Animate::GetTime( int slot ) +{ + return edict->s.frameInfo[ slot ].time; +} + +void Animate::SetNormalTime( int slot, float normal ) +{ + if( normal < 0.0f || normal > 1.0f ) + { + Com_Printf( "ERROR: Animate::SetNormalTime: Normal must be between 0 and 1\n" ); + } + else + { + edict->s.frameInfo[ slot ].time = animtimes[ slot ] * normal; + } +} + +float Animate::GetNormalTime( int slot ) +{ + return edict->s.frameInfo[ slot ].time / animtimes[ slot ]; +} + +void Animate::SetWeight( int slot, float weight ) +{ + edict->s.frameInfo[ slot ].weight = weight; +} + +float Animate::GetWeight( int slot ) +{ + return edict->s.frameInfo[ slot ].weight; +} + +void Animate::SetRepeatType( int slot ) +{ + animFlags[ slot ] |= ANIM_LOOP; +} + +void Animate::SetOnceType( int slot ) +{ + animFlags[ slot ] &= ~ANIM_LOOP; +} + +void Animate::SetTime( int slot, float time ) +{ + if( time < 0.0 ) + { + Com_Printf( "ERROR: SetTime %f lesser than anim length %f\n", time, animtimes[ slot ] ); + return; + } + + if( time > animtimes[ slot ] ) + { + Com_Printf( "ERROR: SetTime %f greater than anim length %f\n", time, animtimes[ slot ] ); + return; + } + + edict->s.frameInfo[ slot ].time = time; +} + +void Animate::SetSyncRate( float rate ) +{ + if( rate < 0.001f ) + { + Com_Printf( "ERROR SetSyncRate: canot set syncrate below 0.001.\n" ); + syncRate = 0.001f; + } + else + { + syncRate = rate; + } +} + +void Animate::SetSyncTime( float s ) +{ + if( s < 0.0f || s > 1.0f ) + { + Com_Printf( "\nERROR SetSyncTime: synctime must be 0 to 1 - attempt to set to %f\n" ); + return; + } + + syncTime = s; + + for( int i = 0; i < MAX_FRAMEINFOS; i++ ) + { + if( !( animFlags[ i ] & ANIM_SYNC ) ) { + continue; + } + + animFlags[ i ] = ( animFlags[ i ] | ANIM_NODELTA ) & ANIM_FINISHED; + } +} + +void Animate::PreAnimate( void ) +{ + int i; + + for( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + if( animFlags[ i ] & ANIM_FINISHED ) { + AnimFinished( i ); + } + } +} + +void Animate::PostAnimate( void ) +{ + if( !edict->tiki ) { + return; + } + + float startTime; + float deltaSyncTime; + float total_weight; + Vector vFrameDelta; + bool hasAction = false; + + deltaSyncTime = syncTime; + + if( pauseSyncTime == 0.0f ) + { + syncTime = 1.0f / syncRate * level.frametime + deltaSyncTime; + } + + total_weight = 0.0f; + + for( int i = 0; i < MAX_FRAMEINFOS; i++ ) + { + if( edict->s.frameInfo[ i ].weight > 0.0f ) + { + if( !( animFlags[ i ] & ANIM_NOACTION ) ) + { + hasAction = true; + } + } + + if( animFlags[ i ] & ANIM_PAUSED ) { + continue; + } + + if( animFlags[ i ] & ANIM_SYNC ) + { + startTime = deltaSyncTime * animtimes[ i ]; + edict->s.frameInfo[ i ].time = animtimes[ i ] * syncTime; + } + else + { + startTime = edict->s.frameInfo[ i ].time; + edict->s.frameInfo[ i ].time += level.frametime; + } + + if( animtimes[ i ] == 0.0f ) + { + animFlags[ i ] = animFlags[ i ] & ~ANIM_NODELTA | ANIM_FINISHED; + edict->s.frameInfo[ i ].time = 0.0f; + } + else + { + if( !( animFlags[ i ] & ANIM_NODELTA ) ) + { + if( gi.Anim_HasDelta( edict->tiki, edict->s.frameInfo[ i ].index ) ) + { + float vDelta[ 3 ]; + + gi.Anim_DeltaOverTime( edict->tiki, + edict->s.frameInfo[ i ].index, + startTime, + edict->s.frameInfo[ i ].time, + vDelta ); + + vFrameDelta += Vector( vDelta ) * edict->s.frameInfo[ i ].weight; + + total_weight += edict->s.frameInfo[ i ].weight; + } + } + + animFlags[ i ] &= ~ANIM_NODELTA; + + if( ( animFlags[ i ] & ANIM_SYNC && edict->s.frameInfo[ i ].time > animtimes[ i ] ) || + ( edict->s.frameInfo[ i ].time > animtimes[ i ] - 0.01f ) ) + { + if( animFlags[ i ] & ANIM_LOOP ) + { + animFlags[ i ] |= ANIM_FINISHED; + + if( edict->s.frameInfo[ i ].time > animtimes[ i ] ) + { + edict->s.frameInfo[ i ].time = 0; + } + } + else + { + if( startTime != animtimes[ i ] ) + { + animFlags[ i ] |= ANIM_FINISHED; + } + + edict->s.frameInfo[ i ].time = animtimes[ i ]; + } + } + } + + if( total_weight != 0.0f ) + vFrameDelta *= 1.0f / total_weight; + + MatrixTransformVector( vFrameDelta, orientation, frame_delta ); + + while( syncTime > 1.0f ) + { + syncTime -= 1.0f; + } + + total_weight = level.frametime * 4.0f; + + if( hasAction ) + { + edict->s.actionWeight += total_weight; + + if( edict->s.actionWeight > 1.0f ) + { + edict->s.actionWeight = 1.0f; + } + } + else + { + edict->s.actionWeight -= total_weight; + + if( edict->s.actionWeight < 0.0f ) + { + edict->s.actionWeight = 0.0f; + } + } + } +} + +void Animate::DumpAnimInfo + ( + void + ) + +{ + MPrintf( "----------------------------------------\n" ); + + for( int i = 0; i < MAX_FRAMEINFOS; i++ ) + { + if( edict->s.frameInfo[ i ].weight <= 0.0f ) { + continue; + } + + str animname = gi.Anim_NameForNum( edict->tiki, CurrentAnim( i ) ); + + MPrintf( "slot: %d anim: %s weight: %f time: %f len: %f\n", + i, animname.c_str(), edict->s.frameInfo[ i ].weight, edict->s.frameInfo[ i ].time, animtimes[ i ] ); + } + + MPrintf( "actionWeight: %f\n", edict->s.actionWeight ); +} + +void Animate::ForwardExec + ( + Event *ev + ) + +{ + int slot = 0; + float weight = 1.0f; + + if( !edict->tiki ) + { + ScriptError( "trying to play animation on( entnum: %d, targetname : '%s', classname : '%s' ) which does not have a model", + entnum, + targetname.c_str(), + getClassname() + ); + } + + if( ev->NumArgs() > 1 ) + { + slot = ev->GetInteger( 2 ); + } + + if( ev->NumArgs() > 2 ) + { + weight = ev->GetFloat( 3 ); + } + + NewAnim( ev->GetString( 1 ), slot, weight ); + SetTime( slot ); +} + + +void Animate::EventSetSyncTime + ( + Event *ev + ) + +{ + SetSyncTime( ev->GetFloat( 1 ) ); +} + +void Animate::EventIsLoopingAnim + ( + Event *ev + ) + +{ + str anim_name = ev->GetString( 1 ); + int animnum; + + if( !edict->tiki ) + { + ScriptError( "^~^~^ no tiki set" ); + } + + animnum = gi.Anim_NumForName( edict->tiki, anim_name.c_str() ); + if( animnum < 0 ) + { + ScriptError( "anim '%s' not found, so can't tell if it is looping", anim_name.c_str() ); + } + + if( gi.Anim_FlagsSkel( edict->tiki, animnum ) & ANIM_LOOP ) + { + ev->AddInteger( 1 ); + } + else + { + ev->AddInteger( 0 ); + } +} + +void Animate::StopAnimating( Event *ev ) +{ + StopAnimating( ev->GetInteger( 1 ) ); +} + +CLASS_DECLARATION( Entity, Animate, "animate" ) +{ + { &EV_SetControllerAngles, &Animate::SetControllerAngles }, + { &EV_SetAnim, &Animate::ForwardExec }, + { &EV_SetSyncTime, &Animate::EventSetSyncTime }, + { &EV_Animate_IsLoopingAnim, &Animate::EventIsLoopingAnim }, + { NULL, NULL } +}; diff --git a/code/game/animate.h b/code/game/animate.h new file mode 100644 index 00000000..6d8a39d9 --- /dev/null +++ b/code/game/animate.h @@ -0,0 +1,210 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// animate.h -- Animate class + +#ifndef __ANIMATE_H__ +#define __ANIMATE_H__ + +#if defined ( GAME_DLL ) +#include "entity.h" +#elif defined ( CGAME_DLL ) +#include "script/canimate.h" +#endif + +#include "archive.h" + +extern Event EV_SetAnim; +extern Event EV_SetSyncTime; + +#define ANIM_PAUSED 1 +#define ANIM_SYNC 2 +#define ANIM_FINISHED 4 +#define ANIM_NOEXIT 8 +#define ANIM_NODELTA 16 +#define ANIM_LOOP 32 +#define ANIM_NOACTION 64 + +#define MINIMUM_DELTA_MOVEMENT 8 +#define MINIMUM_DELTA_MOVEMENT_PER_FRAME ( MINIMUM_DELTA_MOVEMENT / 20.0f ) + +#define FLAGGED_ANIMATE_SLOT 20 + +class Animate; + +typedef SafePtr AnimatePtr; + +class AnimationEvent : public Event +{ +private: + short anim_number; + short anim_frame; + +public: + CLASS_PROTOTYPE( AnimationEvent ); + + void *operator new( size_t size ); + void operator delete( void *ptr ); + + AnimationEvent( str name ) : Event( name ) { anim_number = 0; anim_frame = 0; } + AnimationEvent( const Event& ev ) : Event( ev ) { anim_number = 0; anim_frame = 0; } + AnimationEvent() {} + + void SetAnimationFrame( int frame ) { anim_frame = frame; }; + void SetAnimationNumber( int num ) { anim_number = num; }; +}; + +class Animate : public Entity +{ +protected: + int animFlags[ MAX_FRAMEINFOS ]; + + float syncTime; + float syncRate; + int pauseSyncTime; + + Event *doneEvents[ MAX_FRAMEINFOS ]; + + float animtimes[ MAX_FRAMEINFOS ]; + float frametimes[ MAX_FRAMEINFOS ]; + +public: + Vector frame_delta; + +public: + CLASS_PROTOTYPE( Animate ); + + Animate(); + ~Animate(); + + void DoExitCommands( int slot = 0 ); + void NewAnim( int animnum, int slot = 0, float weight = 1.0f ); + void NewAnim( int animnum, Event *endevent, int slot = 0, float weight = 1.0f ); + void NewAnim( int animnum, Event &endevent, int slot = 0, float weight = 1.0f ); + void NewAnim( const char *animname, int slot = 0, float weight = 1.0f ); + void NewAnim( const char *animname, Event *endevent, int slot = 0, float weight = 1.0f ); + void NewAnim( const char *animname, Event &endevent, int slot = 0, float weight = 1.0f ); + void SetFrame( void ); + qboolean HasAnim( const char *animname ); + Event *AnimDoneEvent( int slot = 0 ); + void SetAnimDoneEvent( Event &event, int slot = 0 ); + void SetAnimDoneEvent( Event *event, int slot = 0 ); + int NumFrames( int slot = 0 ); + int NumAnims( void ); + const char *AnimName( int slot = 0 ); + float AnimTime( int slot = 0 ); + virtual void AnimFinished( int slot = 0 ); + void SetTime( int slot = 0, float time = 0.0f ); + void SetNormalTime( int slot = 0, float normal = 1.0f ); + float GetTime( int slot = 0 ); + float GetNormalTime( int slot = 0 ); + void SetWeight( int slot = 0, float weight = 1.0f ); + float GetWeight( int slot = 0 ); + void SetRepeatType( int slot = 0 ); + void SetOnceType( int slot = 0 ); + void SetSyncRate( float rate ); + void SetSyncTime( float s ); + + void Pause( int slot = 0, int pause = 1 ); + void StopAnimating( int slot = 0 ); + void StopAnimatingAtEnd( int slot = 0 ); + + virtual int CurrentAnim( int slot = 0 ); + virtual float CurrentTime( int slot = 0 ); + + virtual void PreAnimate( void ); + virtual void PostAnimate( void ); + + virtual void DumpAnimInfo( void ); + + virtual void Archive( Archiver &arc ); + + void FrameDeltaEvent( Event *ev ); + void ForwardExec( Event *ev ); + void EventSetSyncTime( Event *ev ); + void EventIsLoopingAnim( Event *ev ); + void StopAnimating( Event *ev ); +}; + +extern MEM_BlockAlloc< AnimationEvent, MEM_BLOCKSIZE > AnimationEvent_allocator; + +inline int Animate::CurrentAnim( int slot ) +{ + return edict->s.frameInfo[ slot ].index; +} + +inline float Animate::CurrentTime( int slot ) +{ + return edict->s.frameInfo[ slot ].time; +} + +inline int Animate::NumFrames( int slot ) +{ + return gi.Anim_NumFrames( edict->tiki, edict->s.frameInfo[ slot ].index ); +} + +inline float Animate::AnimTime( int slot ) +{ + return animtimes[ slot ]; +} + +inline int Animate::NumAnims( void ) +{ + return gi.TIKI_NumAnims( edict->tiki ); +} + +inline const char *Animate::AnimName( int slot ) +{ + return gi.Anim_NameForNum( edict->tiki, edict->s.frameInfo[ slot ].index ); +} + +inline Event *Animate::AnimDoneEvent( int slot ) +{ + return doneEvents[ slot ]; +} + +inline void Animate::Archive( Archiver &arc ) +{ + Entity::Archive( arc ); + + for( int i = MAX_FRAMEINFOS - 1; i >= 0; i-- ) + { + arc.ArchiveInteger( &animFlags[ i ] ); + } + arc.ArchiveFloat( &syncTime ); + arc.ArchiveFloat( &syncRate ); + arc.ArchiveInteger( &pauseSyncTime ); + for( int i = MAX_FRAMEINFOS - 1; i >= 0; i-- ) + { + arc.ArchiveEventPointer( &doneEvents[ i ] ); + } + for( int i = MAX_FRAMEINFOS - 1; i >= 0; i-- ) + { + arc.ArchiveFloat( &animtimes[ i ] ); + } + for( int i = MAX_FRAMEINFOS - 1; i >= 0; i-- ) + { + arc.ArchiveFloat( &frametimes[ i ] ); + } + arc.ArchiveVector( &frame_delta ); +} + +#endif /* animate.h */ diff --git a/code/game/armor.cpp b/code/game/armor.cpp new file mode 100644 index 00000000..ab524a9d --- /dev/null +++ b/code/game/armor.cpp @@ -0,0 +1,102 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// armor.cpp: Standard armor that prevents a percentage of damage per hit. +// + +#include "g_local.h" +#include "armor.h" + +CLASS_DECLARATION( Item, Armor, NULL ) + { + { NULL, NULL } + }; + +Armor::Armor() + { + if ( LoadingSavegame ) + { + // no need to proceed if loading a game + return; + } + + if ( DM_FLAG( DF_NO_ARMOR ) ) + { + PostEvent( EV_Remove, EV_REMOVE ); + return; + } + + setAmount( 0 ); + } + +void Armor::Setup + ( + const char *model, + int amount + ) + + { + assert( model ); + setModel( model ); + setAmount( amount ); + } + +void Armor::Add + ( + int num + ) + + { + // Armor never adds, it only replaces + amount = num; + if ( amount >= MaxAmount() ) + { + amount = MaxAmount(); + } + } + +qboolean Armor::Pickupable + ( + Entity *other + ) + + { + if ( !other->isSubclassOf( Sentient ) ) + { + return false; + } + else + { + Sentient * sent; + Item * item; + + sent = ( Sentient * )other; + item = sent->FindItem( getName() ); + + // If our armor is > than our current armor or armor has no value, then leave it alone. + if ( item && ( ( item->getAmount() >= this->getAmount() ) || !this->getAmount() ) ) + { + return false; + } + } + return true; + } diff --git a/code/game/armor.h b/code/game/armor.h new file mode 100644 index 00000000..884e1e6b --- /dev/null +++ b/code/game/armor.h @@ -0,0 +1,44 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// armor.h: Standard armor that prevents a percentage of damage per hit. + +#ifndef __ARMOR_H__ +#define __ARMOR_H__ + +#include "weapon.h" + +class Armor : public Item + { + protected: + virtual void Setup( const char *model, int amount ); + virtual void Add( int amount ); + + public: + CLASS_PROTOTYPE( Armor ); + + Armor(); + + virtual qboolean Pickupable( Entity *other ); + }; + +#endif /* armor.h */ diff --git a/code/game/b_files.cpp b/code/game/b_files.cpp new file mode 100644 index 00000000..87e0329b --- /dev/null +++ b/code/game/b_files.cpp @@ -0,0 +1,487 @@ +// +// b_files.c +// + + +#include "b_local.h" + +#if 0 +// +// parse support routines +// + +static qboolean Nav_ParseLiteral( char **data, const char *string ) { + char *token; + + token = COM_ParseExt( data, qtrue ); + if ( token[0] == 0 ) { + gi.Printf( ERROR "unexpected EOF\n" ); + return qtrue; + } + + if ( Q_stricmp( token, string ) ) { + gi.Printf( ERROR "required string '%s' missing\n", string ); + return qtrue; + } + + return qfalse; +} + + +static qboolean Nav_ParseString( char **data, char **s ) { + *s = COM_ParseExt( data, qfalse ); + if ( s[0] == 0 ) { + gi.Printf( ERROR "unexpected EOF\n" ); + return qtrue; + } + return qfalse; +} + + +static qboolean Nav_ParseInt( char **data, int *i ) { + char *token; + + token = COM_ParseExt( data, qfalse ); + if ( token[0] == 0 ) { + gi.Printf( ERROR "unexpected EOF\n" ); + return qtrue; + } + + *i = atoi( token ); + return qfalse; +} + + +// +// bot parameters file : scripts/bots.cfg +// + +char botParms[0x10000]; + + +static int MethodNameToNumber( const char *name ) { + if ( !Q_stricmp( name, "EXPONENTIAL" ) ) { + return METHOD_EXPONENTIAL; + } + if ( !Q_stricmp( name, "LINEAR" ) ) { + return METHOD_LINEAR; + } + if ( !Q_stricmp( name, "LOGRITHMIC" ) ) { + return METHOD_LOGRITHMIC; + } + if ( !Q_stricmp( name, "ALWAYS" ) ) { + return METHOD_ALWAYS; + } + if ( !Q_stricmp( name, "NEVER" ) ) { + return METHOD_NEVER; + } + + return -1; +} + + +static int ItemNameToNumber( const char *name, int itemType ) { + int n; + + for ( n = 0; n < bg_numItems; n++ ) { + if ( bg_itemlist[n].type != itemType ) { + continue; + } + if ( Q_stricmp( bg_itemlist[n].classname, name ) == 0 ) { + return bg_itemlist[n].tag; + } + } + + return -1; +} + + +void Bot_ParseParms( const char *botName, gentity_t *bot, char *userinfo ) { + char *token; + char *value; + char *p; + int n; + int count; + + if ( !botName || !botName[0]) { + botName = "Player"; + } + + strcpy( userinfo, "\\name\\" ); + strcat( userinfo, botName ); + + // fill in defaults + bot->bot->reactions = 3; + bot->bot->aim = 3; + bot->bot->move = 3; + bot->bot->aggression = 3; + bot->bot->intelligence = 3; + bot->bot->hfov = 90 / 2; + bot->bot->vfov = 68 / 2; + bot->bot->healthMethod = METHOD_LOGRITHMIC; + bot->bot->armorMethod = METHOD_LINEAR; + bot->bot->ammoMethod = METHOD_EXPONENTIAL; + bot->bot->allWeaponOrder[0] = WP_BFG; + bot->bot->allWeaponOrder[1] = WP_ROCKET_LAUNCHER; + bot->bot->allWeaponOrder[2] = WP_RAILGUN; + bot->bot->allWeaponOrder[3] = WP_PLASMAGUN; + bot->bot->allWeaponOrder[4] = WP_GRENADE_LAUNCHER; + bot->bot->allWeaponOrder[5] = WP_SHOTGUN; + bot->bot->allWeaponOrder[6] = WP_MACHINEGUN; + bot->bot->allWeaponOrder[7] = WP_NONE; + + p = botParms; + COM_BeginParseSession(); + + // look for the right bot + while ( p ) { + token = COM_ParseExt( &p, qtrue ); + if ( token[0] == 0 ) + return; + + if ( !Q_stricmp( token, botName ) ) { + break; + } + + SkipBracedSection( &p ); + } + if ( !p ) { + return; + } + + if ( Nav_ParseLiteral( &p, "{" ) ) { + return; + } + + // parse the bot info block + while ( 1 ) { + token = COM_ParseExt( &p, qtrue ); + if ( !token[0] ) { + gi.Printf( "ERROR: unexpected EOF while parsing '%s'\n", botName ); + return; + } + + if ( !Q_stricmp( token, "}" ) ) { + break; + } + + // model + if ( !Q_stricmp( token, "model" ) ) { + if ( Nav_ParseString( &p, &value ) ) { + continue; + } + strcat ( userinfo, "\\model\\" ); + strcat ( userinfo, value ); + continue; + } + + // reactions + if ( !Q_stricmp( token, "reactions" ) ) { + if ( Nav_ParseInt( &p, &n ) ) { + SkipRestOfLine( &p ); + continue; + } + if ( n < 1 || n > 5 ) { + gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->reactions = n; + continue; + } + + // aim + if ( !Q_stricmp( token, "aim" ) ) { + if ( Nav_ParseInt( &p, &n ) ) { + SkipRestOfLine( &p ); + continue; + } + if ( n < 1 || n > 5 ) { + gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->aim = n; + continue; + } + + // move + if ( !Q_stricmp( token, "move" ) ) { + if ( Nav_ParseInt( &p, &n ) ) { + SkipRestOfLine( &p ); + continue; + } + if ( n < 1 || n > 5 ) { + gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->move = n; + continue; + } + + // aggression + if ( !Q_stricmp( token, "aggression" ) ) { + if ( Nav_ParseInt( &p, &n ) ) { + SkipRestOfLine( &p ); + continue; + } + if ( n < 1 || n > 5 ) { + gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->aggression = n; + continue; + } + + // intelligence + if ( !Q_stricmp( token, "intelligence" ) ) { + if ( Nav_ParseInt( &p, &n ) ) { + SkipRestOfLine( &p ); + continue; + } + if ( n < 1 || n > 5 ) { + gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->intelligence = n; + continue; + } + + // hfov + if ( !Q_stricmp( token, "hfov" ) ) { + if ( Nav_ParseInt( &p, &n ) ) { + SkipRestOfLine( &p ); + continue; + } + if ( n < 30 || n > 180 ) { + gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->hfov = n / 2; + continue; + } + + // vfov + if ( !Q_stricmp( token, "vfov" ) ) { + if ( Nav_ParseInt( &p, &n ) ) { + SkipRestOfLine( &p ); + continue; + } + if ( n < 30 || n > 180 ) { + gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->vfov = n / 2; + continue; + } + + // healthMethod + if ( !Q_stricmp( token, "healthMethod" ) ) { + if ( Nav_ParseString( &p, &value ) ) { + continue; + } + n = MethodNameToNumber( value ); + if ( n == -1 ) { + gi.Printf( "WARNING: bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->healthMethod = n; + continue; + } + + // armorMethod + if ( !Q_stricmp( token, "armorMethod" ) ) { + if ( Nav_ParseString( &p, &value ) ) { + continue; + } + n = MethodNameToNumber( value ); + if ( n == -1 ) { + gi.Printf( "WARNING: bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->armorMethod = n; + continue; + } + + // ammoMethod + if ( !Q_stricmp( token, "ammoMethod" ) ) { + if ( Nav_ParseString( &p, &value ) ) { + continue; + } + n = MethodNameToNumber( value ); + if ( n == -1 ) { + gi.Printf( "WARNING: bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->ammoMethod = n; + continue; + } + + // weapons + if ( !Q_stricmp( token, "weapons" ) ) { + for ( count = 0; count < MAX_WEAPONS; count++ ) { + if ( Nav_ParseString( &p, &value ) ) { + break; + } + if ( *value == 0 ) { + break; + } + n = ItemNameToNumber( value, IT_WEAPON ); + if ( n == -1 ) { + gi.Printf( "WARNING: bad %s in bot '%s'\n", token, botName ); + continue; + } + bot->bot->allWeaponOrder[count] = n; + } + if ( count < MAX_WEAPONS ) { + bot->bot->allWeaponOrder[count] = WP_NONE; + } + continue; + } + + // snd + if ( !Q_stricmp( token, "snd" ) ) { + if ( Nav_ParseString( &p, &value ) ) { + continue; + } + strcat( userinfo, "\\snd\\" ); + strcat( userinfo, value ); + continue; + } + + gi.Printf( "WARNING: unknown keyword '%s' while parsing '%s'\n", token, botName ); + SkipRestOfLine( &p ); + } +} + + +void Bot_LoadParms( void ) { + int len; + char filename[MAX_QPATH]; + char *buffer; + + sprintf( filename, "scripts/bots.cfg" ); + gi.Printf( "Parsing %s\n", filename ); + len = gi.FS_ReadFile( filename, &buffer, qtrue ); + if ( len == -1 ) { + gi.Printf( "file not found\n" ); + } + + if ( len >= sizeof( botParms ) ) { + gi.Error( ERR_DROP, "scripts/bots.cfg is too large" ); + } + strncpy( botParms, buffer, sizeof( botParms ) - 1 ); + gi.FS_FreeFile( buffer ); +} +#endif + + +// +// navigation data : maps/*.nav +// + +void Nav_LoadRoutes( void ) { + int len; + navheader_t *header; + int value; + int n; + str filename; + + Swap_Init(); + + surfaceCount = 0; + surface = NULL; + neighborCount = 0; + neighbor = NULL; + + // load the file + filename = "maps/"; + filename += level.mapname + ".nav"; + + gi.Printf( "Loading %s\n", filename.c_str() ); + len = gi.FS_ReadFile( filename.c_str(), ( void ** )&navFileData, qtrue ); + if ( len == -1 ) { + gi.Printf( WARNING "no navigation data\n" ); + return; + } + if ( len < sizeof( navheader_t ) ) { + gi.Printf( ERROR "no nav file header\n" ); + goto cleanup; + } + + // process the header + header = (navheader_t *)navFileData; + header->id = LittleLong( header->id ); + header->version = LittleLong( header->version ); + header->surfaceCount = LittleLong( header->surfaceCount ); + header->neighborCount = LittleLong( header->neighborCount ); + + // validate the header fields + if ( header->id != NAVFILE_ID ) { + gi.Printf( ERROR "incorrect nav file id\n" ); + goto cleanup; + } + if ( header->version != NAVFILE_VERSION ) { + gi.Printf( ERROR "incorrect nav file version (%i, should be %i)\n", header->version, NAVFILE_VERSION ); + goto cleanup; + } + + value = /* header */ sizeof( navheader_t ) + + /* surfaces */ header->surfaceCount * sizeof( nsurface_t ) + + /* neighbors */ header->neighborCount * sizeof( nneighbor_t ) + + /* routes */ header->surfaceCount * header->surfaceCount * sizeof( byte ); + + if ( value != len ) { + gi.Printf( ERROR "incorrect nav file length (%i, should be %i)\n", len, value ); + goto cleanup; + } + + surfaceCount = header->surfaceCount; + neighborCount = header->neighborCount; + + // process surfaces + surface = (nsurface_t *)(navFileData + sizeof( navheader_t ) ); + for ( n = 0; n < surfaceCount; n++ ) { + surface[n].origin[0] = LittleFloat( surface[n].origin[0] ); + surface[n].origin[1] = LittleFloat( surface[n].origin[1] ); + surface[n].origin[2] = LittleFloat( surface[n].origin[2] ); + + surface[n].absmin[0] = LittleFloat( surface[n].absmin[0] ); + surface[n].absmin[1] = LittleFloat( surface[n].absmin[1] ); + + surface[n].absmax[0] = LittleFloat( surface[n].absmax[0] ); + surface[n].absmax[1] = LittleFloat( surface[n].absmax[1] ); + + surface[n].flags = LittleLong( surface[n].flags ); + surface[n].neighborCount = LittleLong( surface[n].neighborCount ); + surface[n].neighborIndex = LittleLong( surface[n].neighborIndex ); + surface[n].parm = LittleLong( surface[n].parm ); + } + + // process neighbors + neighbor = (nneighbor_t *)((byte *)surface + surfaceCount * sizeof( nsurface_t )); + for ( n = 0; n < neighborCount; n++ ) { + neighbor[n].origin[0] = LittleFloat( neighbor[n].origin[0] ); + neighbor[n].origin[1] = LittleFloat( neighbor[n].origin[1] ); + neighbor[n].origin[2] = LittleFloat( neighbor[n].origin[2] ); + + neighbor[n].absmin[0] = LittleFloat( neighbor[n].absmin[0] ); + neighbor[n].absmin[1] = LittleFloat( neighbor[n].absmin[1] ); + + neighbor[n].absmax[0] = LittleFloat( neighbor[n].absmax[0] ); + neighbor[n].absmax[1] = LittleFloat( neighbor[n].absmax[1] ); + + neighbor[n].surfaceNum = LittleLong( neighbor[n].surfaceNum ); + neighbor[n].flags = LittleLong( neighbor[n].flags ); + neighbor[n].cost = LittleLong( neighbor[n].cost ); + neighbor[n].filler = LittleLong( neighbor[n].filler ); + } + + // process routes + route = (byte *)neighbor + neighborCount * sizeof( nneighbor_t ); + + gi.Printf( "...loaded %i surfaces and %i neighbors\n", surfaceCount, neighborCount ); + return; + +cleanup: + gi.FS_FreeFile ( navFileData ); + navFileData = NULL; +} diff --git a/code/game/b_local.h b/code/game/b_local.h new file mode 100644 index 00000000..6c1284b6 --- /dev/null +++ b/code/game/b_local.h @@ -0,0 +1,167 @@ +#ifndef __B_LOCAL_H__ +#define __B_LOCAL_H__ + +#include "g_local.h" + +// +// This section should be moved to QFILES.H +// + +#define NAVFILE_ID (('I')+('N'<<8)+('A'<<16)+('V'<<24)) +#define NAVFILE_VERSION 2 + +typedef struct { + unsigned id; + unsigned version; + unsigned surfaceCount; + unsigned neighborCount; +} navheader_t; + + +#define MAX_SURFACES 4096 + +#define SF_PUSH 0x00000001 +#define SF_WATERLEVEL1 0x00000002 +#define SF_WATERLEVEL2 0x00000004 +#define SF_WATER_NOAIR 0x00000008 +#define SF_DUCK 0x00000010 +#define SF_PAIN 0x00000020 +#define SF_TELEPORTER 0x00000040 +#define SF_PLATHIGH 0x00000080 +#define SF_PLATLOW 0x00000100 + +typedef struct { + vec3_t origin; + vec2_t absmin; + vec2_t absmax; + int parm; + unsigned flags; + unsigned neighborCount; + unsigned neighborIndex; +} nsurface_t; + + +#define MAX_NEIGHBORS 16384 + +#define NF_JUMP 0x00000001 +#define NF_DUCK 0x00000002 +#define NF_PLAT 0x00000004 +#define NF_FALL1 0x00000008 +#define NF_FALL2 0x00000010 + +typedef struct { + vec3_t origin; + vec2_t absmin; // region within this surface that is the portal to the other surface + vec2_t absmax; + int surfaceNum; + unsigned flags; // jump, prerequisite button, will take falling damage, etc... + float cost; + unsigned filler; // to be used as a "string index" into an array of targetnames for buttons, etc +} nneighbor_t; + +#define WARNING "\033" "3" "WARNING: " +#define ERROR "\033" "1" "ERROR: " + + +// file buffers + +extern char botParms[0x10000]; +extern char *navFileData; + + +// +// Navigation susbsystem +// + +#define NAVF_DUCK 0x00000001 +#define NAVF_JUMP 0x00000002 +#define NAVF_HOLD 0x00000004 +#define NAVF_SLOW 0x00000008 + +#define METHOD_EXPONENTIAL 1 +#define METHOD_LINEAR 2 +#define METHOD_LOGRITHMIC 3 +#define METHOD_ALWAYS 4 +#define METHOD_NEVER 5 + +// combat maneuvers +#define CM_NONE 0 + +#define CM_CLOSE_DISTANCE 1 +#define CM_OPEN_DISTANCE 2 +#define CM_HOLD_DISTANCE 3 + +#define CM_GET_ITEM 4 +#define CM_RUN_AWAY 5 + +#define CM_CIRCLE 6 +#define CM_DUCK 7 + +typedef enum {SPOT_ORIGIN, SPOT_HEAD, SPOT_WEAPON, SPOT_LEGS, SPOT_GROUND} spot_t; + +#define BOT_TIME_TO_LOSE_SIGHT 2000 + +#define SF_FROMMAPFILE 0x80000000 + +#define DEBUG_LEVEL_DETAIL 4 +#define DEBUG_LEVEL_INFO 3 +#define DEBUG_LEVEL_WARNING 2 +#define DEBUG_LEVEL_ERROR 1 +#define DEBUG_LEVEL_NONE 0 + + +// +// b_main.c +// +void Debug_Printf( cvar_t *cv, int level, char *fmt, ... ); +void Debug_BotPrintf( gentity_t *bot, cvar_t *cv, int debugLevel, char *fmt, ... ); + + +// +// b_ai.c +// +extern cvar_t *debugBotAI; +extern cvar_t *debugBotFreeze; + +void Bot_InitAI( void ); +void Bot_Pain( gentity_t *bot, gentity_t *other, int damage ); +void Bot_Touch( gentity_t *bot, gentity_t *other, trace_t *trace ); +void BotSpawn( gentity_t *bot ); +void Bot_Fetch_f( void ); + +// +// b_nav.c +// +extern char *navFileData; +extern int surfaceCount; +extern nsurface_t *surface; +extern int neighborCount; +extern nneighbor_t *neighbor; +extern byte *route; + + +void Nav_InitPreSpawn( void ); +void Nav_InitPostSpawn( void ); +void Nav_Shutdown( void ); +void Nav_ShowPath( gentity_t *bot ); +int Nav_GroundSurfaceNumber( gentity_t *ent ); +int Nav_ItemSurfaceNumber( gentity_t *ent ); +int Nav_EntitySurfaceNumber( gentity_t *ent ); +int Nav_MoveToGoal( gentity_t *bot, vec3_t dir, int *flags ); + +// +// b_items.c +// +void Nav_InitRoamList( void ); +qboolean WeaponIsOnLevel( int weapon ); +gentity_t *Nav_ChooseRoamGoal( void ); + +// +// b_files.c +// +void Bot_ParseParms( const char *botName, gentity_t *bot, char *userinfo ); +void Bot_LoadParms( void ); +void Nav_LoadRoutes( void ); +void Nav_SaveRoutes( void ); + +#endif diff --git a/code/game/b_nav.cpp b/code/game/b_nav.cpp new file mode 100644 index 00000000..2bc70b1d --- /dev/null +++ b/code/game/b_nav.cpp @@ -0,0 +1,632 @@ + +// +// b_nav.c +// + +//FIXME make botInfo, etc visible here too and get rid of all the mutliple dereferences like bot->bot-> + +#include "b_local.h" + + +#define NAVF_EDGEZONE 0x00000001 + +#define INFINITE 1000000 + +#define BOTAI_PUSHED (1<<0) + +cvar_t *nav_showsectors; + +char *navFileData; + +int surfaceCount; +nsurface_t *surface; +int neighborCount; +nneighbor_t *neighbor; +byte *route; + +//#if 0 + +static int spawnpadModelIndex; + + +int Nav_SurfaceUnderPlayer( gentity_t *player ) { + vec3_t start; + vec3_t end; + vec3_t p; + trace_t tr; + float bestDist; + int bestSurf; + vec3_t v; + int n; + float dist; + + VectorCopy( player->s.origin, start ); + VectorCopy( player->s.origin, end ); + end[2] -= 4096; + + gi.trace ( &tr, start, player->mins, player->maxs, end, player->s.number, MASK_DEADSOLID, true ); + +// p[0] = ((int)tr.endpos[0] + 8) & (~16); +// p[1] = ((int)tr.endpos[1] + 8) & (~16); + p[0] = tr.endpos[0]; + p[1] = tr.endpos[1]; + p[2] = floor(tr.endpos[2]+player->mins[2]); + + bestDist = INFINITE; + bestSurf = -1; + + for ( n = 0; n < surfaceCount; n++ ) { + if ( Q_fabs( surface[n].origin[2] - p[2] ) > 24 ) { + continue; + } + + VectorSubtract( p, surface[n].origin, v ); + dist = VectorLength( v ); + if ( dist < bestDist ) { + bestDist = dist; + bestSurf = n; + } + + if ( surface[n].origin[2] != p[2] ) { + continue; + } + if ( surface[n].absmin[0] > p[0] ) { + continue; + } + if ( surface[n].absmax[0] < p[0] ) { + continue; + } + if ( surface[n].absmin[1] > p[1] ) { + continue; + } + if ( surface[n].absmax[1] < p[1] ) { + continue; + } + return n; + } + +// gi.Printf( "guess for %s at %s\n", ent->classname, vtos( p ) ); + return bestSurf; +} + + +/* +============= +Nav_GroundSurfaceNumber + +Returns the surface number for where an entity is currently located. +If the entity is not on the ground, it returns -1. + +FIXME we can make this more efficient + right now surfaces are in Z sorted order + we could make a Z index and binary search it to get to right z group fast +============= +*/ +int Nav_GroundSurfaceNumber( gentity_t *ent ) { + vec3_t p; + vec3_t v; + int n; + float dist; + float bestDist; + int bestSurf; + gentity_t *groundEntity; + + // if ent is not on the ground it is not on a surface + if ( ent->s.groundEntityNum == -1 ) { + return -1; + } + +// p[0] = ((int)ent->s.origin[0] + 8) & (~16); +// p[1] = ((int)ent->s.origin[1] + 8) & (~16); + p[0] = ent->s.origin[0]; + p[1] = ent->s.origin[1]; + p[2] = floor(ent->s.origin[2]+ent->mins[2]); + + // if ground is not the world we need to handle it differently. + if ( ent->s.groundEntityNum != ENTITYNUM_WORLD ) { + groundEntity = &g_entities[ent->s.groundEntityNum]; + + // check for sitting on a spawn pad + if ( !groundEntity->bmodel && groundEntity->s.modelindex == spawnpadModelIndex ) { + p[2] -= 8.0; + } + // check for plats + /* else if ( groundEntity->bmodel && Q_stricmp( groundEntity->classname, "func_plat" ) == 0 ) { + // if at the top the return PLATHIGH surface number, otherwise return PLATLOW surface number + if ( VectorCompare( groundEntity->currentOrigin, groundEntity->pos2 ) ) { + return surface[groundEntity->navSurfaceNum].parm; + } + return groundEntity->navSurfaceNum; + } */ + } + + bestDist = INFINITE; + bestSurf = -1; + + for ( n = 0; n < surfaceCount; n++ ) { + if ( Q_fabs( surface[n].origin[2] - p[2] ) > 24 ) { + continue; + } + + VectorSubtract( p, surface[n].origin, v ); + dist = VectorLength( v ); + if ( dist < bestDist ) { + bestDist = dist; + bestSurf = n; + } + + if ( surface[n].origin[2] != p[2] ) { + continue; + } + if ( surface[n].absmin[0] > p[0] ) { + continue; + } + if ( surface[n].absmax[0] < p[0] ) { + continue; + } + if ( surface[n].absmin[1] > p[1] ) { + continue; + } + if ( surface[n].absmax[1] < p[1] ) { + continue; + } + return n; + } + +// gi.Printf( "guess for %s at %s\n", ent->classname, vtos( p ) ); + return bestSurf; +} + + +/* +============= +Nav_ItemSurfaceNumber + +Returns the surface number for where an item entity is currently located. +If the entity is not on the ground, it returns -1. This is a specialized +copy of Nav_GroundSurfaceNumber for items that caches the result. +============= +*/ +int Nav_ItemSurfaceNumber( gentity_t *ent ) { + if ( !VectorCompare( ent->s.origin, ent->navOrigin ) && level.time > ent->navTime ) { + VectorCopy( ent->s.origin, ent->navOrigin ); + ent->navTime = level.time; + ent->navSurfaceNum = Nav_GroundSurfaceNumber( ent ); + } + return ent->navSurfaceNum; +} + + +/* +============= +Nav_EntitySurfaceNumber +============= +*/ +int Nav_EntitySurfaceNumber( gentity_t *ent ) { + if ( ent->s.eType == ET_ITEM ) { + return Nav_ItemSurfaceNumber( ent ); + } + + /*if ( ent->classname&& strcmp( ent->classname, "bot_goal" ) == 0 ) { + return Nav_SurfaceUnderPlayer( ent ); + }*/ + + return Nav_GroundSurfaceNumber( ent ); +} + + +/* +============= +PathEdge +============= +*/ + +static nneighbor_t *PathEdge( int sourceSurfNum, int destSurfNum ) { + int base; + int n; + + base = surface[sourceSurfNum].neighborIndex; + for ( n = 0; n < surface[sourceSurfNum].neighborCount; n++ ) { + if ( neighbor[base+n].surfaceNum == destSurfNum ) { + return &neighbor[base+n]; + } + } + return NULL; +} + +/* +============= +PointIsInEdgeRegion +============= +*/ + +static qboolean PointIsInEdgeRegion( vec3_t p, nneighbor_t *n ) { + if ( p[0] < n->absmin[0] ) { + return qfalse; + } + if ( p[0] > n->absmax[0] ) { + return qfalse; + } + if ( p[1] < n->absmin[1] ) { + return qfalse; + } + if ( p[1] > n->absmax[1] ) { + return qfalse; + } + return qtrue; +} + + + +/* +============= +Nav_MoveToGoal +============= +*/ + +int Nav_MoveToGoal( gentity_t *bot, vec3_t dir, int *flags ) { + int currentSurf; + int nextSurf; + int thirdSurf; + int goalSurf; + int routeIndex; + nneighbor_t *edge; + nneighbor_t *nextEdge; + //gentity_t *ent; + //float dist; + + *flags = 0; + VectorCopy( bot->navDir, dir ); + + currentSurf = bot->currentSurface; + + // if bot is airborne, just keep heading the same + if ( currentSurf == -1 ) { + if ( bot->aiFlags & BOTAI_PUSHED ) { + //gi.Printf( "bot was bounced\n" ); + *flags |= NAVF_HOLD; + } + //gi.Printf( "not on ground\n" ); + return 0; + } + if ( bot->pushedTime < level.time ) { + bot->aiFlags &= ~BOTAI_PUSHED; + } + + if ( !bot->goalEntity ) { +// gi.Printf( ERROR "Nav_MoveToGoal called with no goalEntity set\n" ); + return -1; + } + + goalSurf = Nav_EntitySurfaceNumber( bot->goalEntity ); + if ( goalSurf == -1 ) { + return -1; + } + + // if we've changed surfaces, the surface to surface navigation flags and timer need to be cleared + if ( currentSurf != bot->lastSurface ) { + bot->navFlags = 0; + bot->navTime = 0; + //gi.Printf( "surface changed from %i to %i\n", bot->bot->lastSurface, bot->bot->currentSurface ); + } + + if ( currentSurf == goalSurf ) { + //gi.Printf( "On target surface\n" ); + VectorSubtract( bot->goalEntity->s.origin, bot->s.origin, dir ); + //VectorCopy( dir, bot->bot->navDir ); + VectorCopy( dir, bot->navDir ); + return 0; + } + + routeIndex = route[currentSurf * surfaceCount + goalSurf]; + if ( routeIndex == 255 ) { + //gi.Printf( "Nav_MoveToGoal - no known route from %i to %i\n", currentSurf, goalSurf ); + return -1; + } + if ( routeIndex >= surface[currentSurf].neighborCount ) { + gi.Printf( ERROR "Nav_MoveToGoal - bad routeIndex\n" ); + return -1; + } + nextSurf = neighbor[surface[currentSurf].neighborIndex + routeIndex].surfaceNum; + + edge = PathEdge( currentSurf, nextSurf ); + if ( !edge ) { + gi.Printf( ERROR "Nav_MoveToGoal - %i does not have %i as a neighbor\n", currentSurf, nextSurf ); + VectorClear( dir ); + return -1; + } + + if ( ! ( bot->navFlags & NAVF_EDGEZONE ) ) { + if ( PointIsInEdgeRegion( bot->s.origin, edge ) ) { + //gi.Printf( "hit edge\n" ); + bot->navFlags |= NAVF_EDGEZONE; + bot->navTime = level.time; + } + } + + // if we are in the edge zone + if ( bot->navFlags & NAVF_EDGEZONE ) { + // if we're trying to get onto a plat, we must make sure it's there + /*if ( surface[nextSurf].flags & SF_PLATLOW ) { + ent = &g_entities[surface[surface[nextSurf].parm].parm]; //FIXME this works for now, but I don't like it + if ( VectorCompare( ent->currentOrigin, ent->pos1 ) == 0 ) { + *flags |= NAVF_HOLD; + //gi.Printf(" wait for plat2\n" ); + } + }*/ + + // if we're riding up on a plat, we don't need to move + if ( surface[nextSurf].flags & SF_PLATHIGH ) { + *flags |= NAVF_HOLD; + //gi.Printf(" hold on plat\n" ); + } + + // if the next surface contains the goalEntity, head towards it + if ( nextSurf == goalSurf ) { + //gi.Printf( "next surf has goal - targeting directly\n" ); + VectorSubtract( bot->goalEntity->s.origin, bot->s.origin, dir ); + //VectorCopy( dir, bot->bot->navDir ); + VectorCopy( dir, bot->navDir ); + } + // start heading towards the next edge + else { + routeIndex = route[nextSurf * surfaceCount + goalSurf]; + if ( routeIndex == 255 ) { + gi.Printf( ERROR "Nav_MoveToGoal - no known route from %i to %i\n", nextSurf, goalSurf ); + return -1; + } + if ( routeIndex >= surface[nextSurf].neighborCount ) { + gi.Printf( ERROR "Nav_MoveToGoal - bad routeIndex\n" ); + return -1; + } + thirdSurf = neighbor[surface[nextSurf].neighborIndex + routeIndex].surfaceNum; + nextEdge = PathEdge( nextSurf, thirdSurf ); + if ( !nextEdge ) { + gi.Printf( ERROR "Nav_MoveToGoal - %i does not have %i as a neighbor\n", nextSurf, thirdSurf ); + VectorClear( dir ); + return -1; + } + //gi.Printf( "targeting next edge\n" ); + if ( surface[nextSurf].flags & SF_PLATHIGH ) { + VectorSubtract( nextEdge->origin, surface[nextSurf].origin, dir ); + } + else { + VectorSubtract( nextEdge->origin, bot->s.origin, dir ); + } + //VectorCopy( dir, bot->bot->navDir ); + VectorCopy( dir, bot->navDir ); + } + + if ( edge->flags & NF_DUCK ) { + *flags |= NAVF_DUCK; + } + if ( edge->flags & NF_JUMP ) { + *flags |= NAVF_JUMP; + } + } + else { + VectorSubtract( edge->origin, bot->s.origin, dir ); + //VectorCopy( dir, bot->bot->navDir ); + VectorCopy( dir, bot->navDir ); + + /*if ( surface[nextSurf].flags & SF_PLATLOW ) { + ent = &g_entities[surface[surface[nextSurf].parm].parm]; //FIXME this works for now, but I don't like it + if ( VectorCompare( ent->currentOrigin, ent->pos1 ) == 0 ) { + dist = VectorLength( dir ); + if ( dist > 64 ) { + *flags |= NAVF_SLOW; + //gi.Printf(" slow for plat\n" ); + } + else { + *flags |= NAVF_HOLD; + //gi.Printf(" wait for plat\n" ); + } + } + }*/ + } + + return 0; +} + + +void Nav_ShowPath( gentity_t *bot ) { +#if 0 + gentity_t *tent; + int m, n; + + if ( !bot->bot->goalEntity ) { + return; + } + + tent = G_TempEntity( bot->s.origin, EV_DEBUG_LINE ); + VectorCopy( bot->bot->currentWaypoint->s.origin, tent->s.origin2 ); + + m = bot->bot->currentWaypoint->count; + for (;;) { + if ( m == bot->bot->finalWaypoint->count ) { + break; + } + n = route[m*maxwaypoints+bot->bot->finalWaypoint->count]; + if ( n == -1 ) { + break; + } + tent = G_TempEntity( rents[m]->s.origin, EV_DEBUG_LINE ); + VectorCopy( rents[n]->s.origin, tent->s.origin2 ); + m = n; + } + + if ( bot->bot->finalWaypoint != bot->bot->goalEntity ) { + tent = G_TempEntity( bot->bot->finalWaypoint->s.origin, EV_DEBUG_LINE ); + VectorCopy( bot->bot->goalEntity->s.origin, tent->s.origin2 ); + } +#endif + /* gentity_t *tent; + int m, n; + gentity_t *player; + int pSurf; + + player = &g_entities[1]; + pSurf = Nav_GroundSurfaceNumber( player ); + + tent = G_TempEntity( player->s.origin, EV_DEBUG_LINE ); + VectorCopy( surface[pSurf].origin, tent->s.origin2 ); */ +} +//#endif + + +/* +// Init and Shutdown +// +// +*/ + +static void Nav_Cleanup( void ) { + if ( navFileData ) { + gi.FS_FreeFile ( navFileData ); + navFileData = NULL; + } + surfaceCount = 0; + neighborCount = 0; +} + +void Nav_InitPreSpawn( void ) { + nav_showsectors = gi.cvar( "nav_showsectors", "0", 0 ); + Nav_Cleanup(); + Nav_LoadRoutes(); +} + +void Nav_InitPostSpawn( void ) { +#if 0 + int n; + nsurface_t *s; + gentity_t *ent; + + // FIXME resolve targetnames here (like button needed to open a door) + + // get the modelindex for the spawnpad model so we can use it for surface determination + spawnpadModelIndex = G_ModelIndex( "models/objects/dmspot.md3" ); + + // set the navSurface for plats + for ( n = 0; n < surfaceCount; n++ ) { + s = &surface[n]; + if ( s->flags & SF_PLATLOW ) { + ent = &g_entities[surface[s->parm].parm]; //FIXME this works for now, but I don't like it + ent->navSurfaceNum = n; + } + } +#endif +} + + +void Nav_Shutdown ( void ) { + Nav_Cleanup(); +} + +void Nav_Test_f( void ) { +#if 0 + gentity_t *player; + gentity_t *goal; + char *goalname; + int pSurf; + int gSurf; + int cSurf; + int n; + gentity_t *tent; + + player = &g_entities[0]; + pSurf = Nav_GroundSurfaceNumber( player ); + + goalname = gi.argv(2); + if ( !goalname[0] ) { + gi.Printf( "Player1 is at (%f, %f, %f) on surface %i\n", player->s.origin[0], player->s.origin[1], player->s.origin[2] + player->mins[2], pSurf ); + return; + } + + goal = NULL; + goal = G_Find( goal, FOFS( classname ), goalname ); + if ( !goal ) { + gi.Printf( "no %s on level\n", goalname ); + return; + } + gSurf = Nav_EntitySurfaceNumber( goal ); + + + cSurf = pSurf; + while ( cSurf != gSurf ) { + n = route[cSurf * surfaceCount + gSurf]; + if ( n == 255 ) { + //gi.Printf( "no known route from %i to %i\n", cSurf, gSurf ); + return; + } + if ( n >= surface[cSurf].neighborCount ) { + gi.Printf( ERROR "bad routeIndex\n" ); + return; + } + n = neighbor[surface[cSurf].neighborIndex + n].surfaceNum; + + if ( cSurf == pSurf ) { + tent = G_TempEntity( player->s.origin, EV_DEBUG_LINE ); + } + else { + tent = G_TempEntity( surface[cSurf].origin, EV_DEBUG_LINE ); + } + if ( n == gSurf ) { + VectorCopy( goal->s.origin, tent->s.origin2 ); + } + else { + VectorCopy( surface[n].origin, tent->s.origin2 ); + } + + cSurf = n; + } +#endif +} + +void Nav_Gen_f( void ); + +void Cmd_Nav_f( void ) +{ + char *cmd; + + cmd = gi.argv(1); + + if ( Q_stricmp ( cmd, "gen" ) == 0 ) { + Nav_Gen_f(); + Nav_InitPreSpawn(); + } + else if ( Q_stricmp ( cmd, "test" ) == 0 ) { + Nav_Test_f(); + } + else { + gi.Printf("Unknown nav command '%s'\n", cmd); + } +} + +void Nav_ShowStuff + ( + void + ) + + { + int i; + nsurface_t *surf; + + if ( !nav_showsectors->integer ) + { + return; + } + + G_Color4f( 1, 1, 0, 1 ); + for( i = 0; i < surfaceCount; i++ ) + { + surf = &surface[ i ]; + + G_BeginLine(); + G_Vertex( Vector( surf->absmin[ 0 ], surf->absmin[ 1 ], surf->origin[ 2 ] ) ); + G_Vertex( Vector( surf->absmin[ 0 ], surf->absmax[ 1 ], surf->origin[ 2 ] ) ); + G_Vertex( Vector( surf->absmax[ 0 ], surf->absmax[ 1 ], surf->origin[ 2 ] ) ); + G_Vertex( Vector( surf->absmax[ 0 ], surf->absmin[ 1 ], surf->origin[ 2 ] ) ); + G_Vertex( Vector( surf->absmin[ 0 ], surf->absmin[ 1 ], surf->origin[ 2 ] ) ); + G_EndLine(); + } + } diff --git a/code/game/b_navgen.cpp b/code/game/b_navgen.cpp new file mode 100644 index 00000000..65b18374 --- /dev/null +++ b/code/game/b_navgen.cpp @@ -0,0 +1,3089 @@ +// +// b_navgen.c +// + +/* +Path costs - time is the cost basis + For normal paths: take dist(sSurf.origin->edge + pmoveEndSpot->tSurf.origin) and + divide by speed to get time. Adjust for duck/wade/swim. Add on time used for + the pmoves to get from edge to pmoveEndspot. + Teleporter: fixed cost of teleport delay (currently 160ms, should be a shared define) + Plats: take vertical distance and divide by plat speed to get move time; add on + any delays (this assumes plats are always at bottom waiting for us) + Trains: ??? +*/ + +/* +FIXME for Q3MAP + When done in game, plates are seen at their low position. Once this is in Q3MAP they will + be seen in their high position requiring a bit of rework of that code. I've noted most of it. +*/ + + +#include +#include "b_local.h" +#include "mover.h" + + +// these defines are placeholders for when this code moves into Q3MAP and is multithreaded +#define ThreadLock() +#define ThreadUnlock() + +#define INFINITE 1000000 + +// these defines MUST match those in bg_pmove!!! +#define MIN_WALK_NORMAL 0.7 +#define STEPSIZE 18 +#define DEFAULT_VIEWHEIGHT 26 +#define CROUCH_VIEWHEIGHT 12 + +#define DUCKSCALE 0.25 +#define SWIMSCALE 0.50 +#define WADESCALE 0.70 + +// these defines MUST match the values used in the game dll +#define DEFAULT_MINS_0 -48 +#define DEFAULT_MINS_1 -48 +#define DEFAULT_MINS_2 0 +#define DEFAULT_MAXS_0 48 +#define DEFAULT_MAXS_1 48 +#define DEFAULT_MAXS_2 76 +#define CROUCH_MAXS_2 49 + +// although this is a derived value, it needs to match the game +#define MAX_JUMPHEIGHT 32 + +// these are used to drive the pmove based reachability function +#define MAX_PMOVES 64 +#define PMOVE_MSEC 50 +#define PLAYER_SPEED 320 + +// defines for ranges and granularity of the spot testing +#define XY_MIN -4080 +#define XY_MAX 4080 +#define XY_STEP 16 +#define Z_MIN -4096 +#define Z_MAX 4064 +#define Z_STEP 1 + +#define MAX_SPOTS 65536 +#define MAX_SPOTINDEX (((XY_MAX - XY_MIN) / XY_STEP) + 2 ) + +typedef struct { + unsigned flags; + int surfaceNum; + vec3_t origin; + int parm; +} nspot_t; + +static nspot_t *spot; +static int spotCount; + +static int sortIndex[MAX_SPOTS]; +static int spotIndex[MAX_SPOTINDEX]; +static int spotIndexCount; + + +#if 0 //Q3MAP +nsurface_t *surface; +int surfaceCount; + + +nneighbor_t *neighbor; +int neighborCount; + +byte *route; +#endif + +/* +============= +VectorToString + +This is just a convenience function +for printing vectors +============= +*/ +char *vtos( const vec3_t v ) { + static int index; + static char str[8][32]; + char *s; + + // use an array so that multiple vtos won't collide + s = str[index]; + index = (index + 1)&7; + + Com_sprintf (s, 32, "(%i %i %i)", (int)v[0], (int)v[1], (int)v[2]); + + return s; +} + +// +// FindSpots +// + +static vec3_t mins; +static vec3_t duckMaxs; +static vec3_t standMaxs; + +//FIXME this should NOT be global +static gentity_t *test; + +static void FindSpotsInY( int num ) { + trace_t tr; + trace_t tr2; + vec3_t origin; + vec3_t point2; + vec3_t testpoint; + qboolean roof; + float viewheight; + int cont; + float sample1; + float sample2; + int waterlevel; + //int numEnts; + //gentity_t *ents[MAX_GENTITIES]; + gentity_t *ent; + qboolean n; + vec3_t absmin; + vec3_t absmax; + int spotNum; + float height; + //gentity_t *target; + //gentity_t *destTarget; + + origin[0] = XY_MIN + num * XY_STEP; + + for ( origin[1] = XY_MIN; origin[1] <= XY_MAX; origin[1] += XY_STEP ) { + origin[2] = Z_MAX; + tr.endpos[2] = Z_MAX + Z_STEP; + point2[0] = origin[0]; + point2[1] = origin[1]; + point2[2] = Z_MIN; + roof = qtrue; + height = Z_STEP; + +// gi.Printf( "begin %i %i\n", (int)origin[0], (int)origin[1] ); + while ( origin[2] > Z_MIN ) { + origin[2] = tr.endpos[2] - height; + height = Z_STEP; + + gi.trace( &tr, origin, mins, duckMaxs, point2, ENTITYNUM_NONE, MASK_DEADSOLID, true ); + + // did we fall out the bottom? yes = this xy finished + if ( tr.endpos[2] <= point2[2] ) { +// gi.Printf( " done - fell out\n" ); + break; + } + + // were we in solid the whole time? yes = this xy finished + if ( tr.allsolid ) { +// gi.Printf( " done - all solid\n" ); + break; + } + + // did we end up inside a solid? + gi.trace( &tr2, tr.endpos, mins, duckMaxs, tr.endpos, ENTITYNUM_NONE, MASK_DEADSOLID, true ); + if ( tr2.startsolid ) { +// gi.Printf( " in solid @ %f\n", tr.endpos[2] - 24.0 ); + continue; + } + + // did we land on the roof of the level? yes = move z down a step from point of contact + if ( roof ) { +// gi.Printf( " fell onto level @ %f\n", tr.endpos[2] - 24.0 ); + roof = qfalse; + continue; + } + + // is this too steep to stand on? yes = move z down a step from point of contact + if ( tr.plane.normal[2] < MIN_WALK_NORMAL ) { +// gi.Printf( " spot too steep @ %f\n", tr.endpos[2] - 24.0 ); + continue; + } + +// FIXME rule out any we want ignored here + // see if we are on a special entity + ent = &g_entities[tr.entityNum]; + if ( ent->s.number != ENTITYNUM_WORLD ) { + if ( ent->entity && ent->entity->isSubclassOf( Mover ) ) { + continue; + } +#if 0 + if ( Q_stricmp( ent->entname, "func_plat" ) == 0 ) { + //FIXME what do we need to do if we are + } +#endif + } + + // see if we are outside the world + VectorCopy( tr.endpos, test->s.origin ); + gi.linkentity( test ); + n = test->linked; + gi.unlinkentity( test ); + if ( n == qfalse ) { +// gi.Printf( " outside world c @ %s\n", vtos( tr.endpos ) ); + continue; + } + + if ( spotCount == MAX_SPOTS ) { + gi.Printf( "MAX_SPOTS exceeded\n" ); + //FIXME in Q3MAP this should be an exit() + return; + } + + // we found a valid standing location, add it to spot list + ThreadLock(); + spotNum = spotCount++; + ThreadUnlock(); + +// gi.Printf( " found spot @ %f %f %f\n", tr.endpos[0], tr.endpos[1], tr.endpos[2] - 24.0); +// VectorCopy( tr.endpos, spot[spotNum].origin ); + spot[spotNum].origin[0] = tr.endpos[0]; + spot[spotNum].origin[1] = tr.endpos[1]; + spot[spotNum].origin[2] = COORDINATE_TO_FLOAT * (int)(tr.endpos[2]*FLOAT_TO_COORDINATE); + spot[spotNum].flags = 0; + spot[spotNum].surfaceNum = -1; + + // see if we are on a special entity + ent = &g_entities[tr.entityNum]; + if ( ent->s.number != ENTITYNUM_WORLD ) { +#if 0 + if ( Q_stricmp( ent->entname, "func_plat" ) == 0 ) { + spot[spotNum].flags |= SF_PLATLOW; // Q3MAP: SF_PLATHIGH + height = Z_STEP; // Q3MAP: ent->pos2[2] - ent->pos1[2]; + spot[spotNum].parm = tr.entityNum; + } +// else if ( Q_stricmp( ent->entname, "func_train" ) == 0 ) { +// spot[spotNum].flags |= SF_TRAIN; +// } +#endif + } + + // check if we must be ducked + VectorAdd( tr.endpos, mins, absmin ); + gi.trace( &tr2, tr.endpos, mins, standMaxs, tr.endpos, ENTITYNUM_NONE, MASK_DEADSOLID, true ); + if ( tr2.allsolid ) { + spot[spotNum].flags |= SF_DUCK; + viewheight = CROUCH_VIEWHEIGHT; + VectorAdd( tr.endpos, duckMaxs, absmax ); + } + else { + viewheight = DEFAULT_VIEWHEIGHT; + VectorAdd( tr.endpos, standMaxs, absmax ); + } + + // check water depth and type (depends on duck state to set viewheight) + waterlevel = 0; + testpoint[0] = tr.endpos[0]; + testpoint[1] = tr.endpos[1]; + testpoint[2] = tr.endpos[2] + mins[2] + 1; + cont = gi.pointcontents( testpoint, 0 ); + + if ( cont & MASK_WATER ) { + sample2 = viewheight - mins[2]; + sample1 = sample2 / 2; + + if ( cont & (CONTENTS_LAVA | CONTENTS_SLIME) ) { + spot[spotNum].flags |= SF_PAIN; + } + + waterlevel = 1; + testpoint[2] = tr.endpos[2] + mins[2] + sample1; + cont = gi.pointcontents( testpoint, 0 ); + if (cont & MASK_WATER) { + waterlevel = 2; + testpoint[2] = tr.endpos[2] + mins[2] + sample2; + cont = gi.pointcontents( testpoint, 0 ); + if (cont & MASK_WATER) { + waterlevel = 3; + } + } + } + if ( waterlevel & 1) { + spot[spotNum].flags |= SF_WATERLEVEL1; + } + if ( waterlevel & 2) { + spot[spotNum].flags |= SF_WATERLEVEL2; + } + + // if water depth 3, see if there is air above us + if ( waterlevel == 3) { + if ( spot[spotNum].flags & SF_DUCK ) { + spot[spotNum].flags |= SF_WATER_NOAIR; + } + else { + gi.trace( &tr2, tr.endpos, mins, standMaxs, origin, ENTITYNUM_NONE, MASK_DEADSOLID, true ); + testpoint[0] = tr2.endpos[0]; + testpoint[1] = tr2.endpos[1]; + testpoint[2] = tr2.endpos[2] + DEFAULT_VIEWHEIGHT; + cont = gi.pointcontents( testpoint, 0 ); + if (cont & MASK_WATER) { + spot[spotNum].flags |= SF_WATER_NOAIR; + } + } + } +#if 0 + // check if this spot is in a trigger we care about + numEnts = gi.EntitiesInBox( absmin, absmax, ents, MAX_GENTITIES ); + for ( n = 0; n < numEnts; n++ ) { + ent = ents[n]; +// if ( Q_stricmp ( ent->entname, "misc_teleporter" ) == 0 ) { + if ( Q_stricmp ( ent->entname, "trigger_teleport" ) == 0 ) { + spot[spotNum].flags |= SF_TELEPORTER; + destTarget = NULL; + destTarget = G_Find( destTarget, FOFS( targetname ), ent->target ); + if ( !destTarget ) { + gi.Printf( "target_teleporter with no target\n" ); + spot[spotNum].parm = 0; + } + else { + spot[spotNum].parm = destTarget->s.number; + } + } + if ( !( ent->contents & CONTENTS_TRIGGER ) ) { + continue; + } + if ( Q_stricmp ( ent->entname, "trigger_hurt" ) == 0 ) { + spot[spotNum].flags |= SF_PAIN; + } + if ( Q_stricmp ( ent->entname, "trigger_push" ) == 0 ) { + spot[spotNum].flags |= SF_PUSH; + spot[spotNum].parm = ent->s.number; + } + if ( Q_stricmp ( ent->entname, "trigger_multiple" ) == 0 ) { + target = NULL; + while ( (target = G_Find( target, FOFS( targetname ), ent->target ) ) != NULL ) { + if ( target == ent ) { + continue; + } + if ( Q_stricmp ( target->entname, "target_teleporter" ) == 0 ) { + spot[spotNum].flags |= SF_TELEPORTER; + destTarget = NULL; + destTarget = G_Find( destTarget, FOFS( targetname ), target->target ); + if ( !destTarget ) { + gi.Printf( "target_teleporter with no target\n" ); + spot[spotNum].parm = 0; + } + else { + spot[spotNum].parm = destTarget->s.number; + } + } + if ( Q_stricmp ( target->entname, "target_push" ) == 0 ) { + spot[spotNum].flags |= SF_PUSH; + spot[spotNum].parm = target->s.number; + } + } + } + } +#endif + } + } +} + +static void FindSpots( void ) { + int n; + //gentity_t *ent; + //gentity_t *target; + //int spotNum; + + spot = ( nspot_t * )gi.TagMalloc ( MAX_SPOTS * sizeof(spot[0]), TAG_GAME ); + spotCount = 0; + + for ( n = 0; n < MAX_SPOTS; n++ ) { + spot[n].flags = 0; + } + + VectorSet( mins, DEFAULT_MINS_0, DEFAULT_MINS_1, DEFAULT_MINS_2 ); + VectorSet( standMaxs, DEFAULT_MAXS_0, DEFAULT_MAXS_1, DEFAULT_MAXS_2 ); + VectorSet( duckMaxs, DEFAULT_MAXS_0, DEFAULT_MAXS_1, CROUCH_MAXS_2 ); + + test = G_Spawn(); + test->s.eType = ET_GENERAL; + VectorCopy( mins, test->mins ); + VectorCopy( duckMaxs, test->maxs ); + + // RunThreadsOn( (XY_MAX - XY_MIN) / XY_STEP, qtrue, FindSpotsInY ); + for ( n = 0; n < ((XY_MAX - XY_MIN) / XY_STEP); n++ ) { + gi.DebugPrintf( "FindSpotsInY %d/%d\n", n, ((XY_MAX - XY_MIN) / XY_STEP) ); + FindSpotsInY( n ); + } + + G_FreeEdict( test ); + + +#if 0 + //FIXME add spots for trigger_teleport + for ( n = 0; n < globals.num_entities; n++ ) { + ent = &g_entities[n]; + if ( !ent->inuse ) { + continue; + } + if ( Q_stricmp ( ent->entname, "misc_teleporter" ) == 0 ) { + if ( Q_stricmp ( ent->entname, "trigger_teleport" ) == 0 ) { + target = NULL; + target = G_Find( target, FOFS( targetname ), ent->target ); + if ( !target ) { + continue; + } + spotNum = spotCount++; + spot[spotNum].origin[0] = ent->s.origin[0]; + spot[spotNum].origin[1] = ent->s.origin[1]; + spot[spotNum].origin[2] = COORDINATE_TO_FLOAT * (int)(ent->s.origin[2]*FLOAT_TO_COORDINATE); + spot[spotNum].flags = SF_TELEPORTER; + spot[spotNum].surfaceNum = -1; + spot[spotNum].parm = target - &g_entities[0]; + } + } + +#endif + gi.Printf( " %i spots\n", spotCount ); +} + + +// +// FindSurfaces +// + +#define MAX_SURFACES 4096 + +static int zstart; +static int zend; +//static int surfaceSizes[10]; + +static int CompareSpotsByZ( const void *a, const void *b ) { + nspot_t *s1 = &spot[*(int *)a]; + nspot_t *s2 = &spot[*(int *)b]; + + // z + if ( s1->origin[2] > s2->origin[2] ) { + return -1; + } + if ( s1->origin[2] < s2->origin[2] ) { + return 1; + } + + // x + if ( s1->origin[0] < s2->origin[0] ) { + return -1; + } + if ( s1->origin[0] > s2->origin[0] ) { + return 1; + } + + // y + if ( s1->origin[1] < s2->origin[1] ) { + return -1; + } + if ( s1->origin[1] > s2->origin[1] ) { + return 1; + } + + return 0; +} + +static void BuildSpotIndexByZ( void ) { + int n; + int i; + float z; + float cz; + + for ( n = 0; n < spotCount; n++ ) { + sortIndex[n] = n; + } + for ( n = 0; n < (((XY_MAX - XY_MIN) / XY_STEP) + 2); n++ ) { + spotIndex[n] = 0; + } + qsort( sortIndex, spotCount, sizeof(sortIndex[0]), CompareSpotsByZ ); + + i = 0; + cz = -8192; + for ( n = 0; n < spotCount; n++ ) { + z = spot[sortIndex[n]].origin[2]; + if ( z != cz ) { + spotIndex[i++] = n; + cz = z; + if ( i >= ( MAX_SPOTINDEX - 1 ) ) + { + gi.Printf( "MAX_SPOTINDEX exceeded\n" ); + //FIXME in Q3MAP this should be an exit() + break; + } + } + } + spotIndexCount = i; + spotIndex[i] = n; +} + +static int SpotIndex( vec3_t origin, int flags ) { + int n; + +// gi.Printf( " SpotIndex( %s )\n", vtos( origin ) ); + + for ( n = zstart; n < zend; n++ ) { + if ( spot[sortIndex[n]].origin[0] < origin[0] ) { + continue; + } + if ( spot[sortIndex[n]].origin[0] > origin[0] ) { + return -1; + } + if ( spot[sortIndex[n]].origin[1] < origin[1] ) { + continue; + } + if ( spot[sortIndex[n]].origin[1] > origin[1] ) { + return -1; + } + if ( spot[sortIndex[n]].surfaceNum != -1 ) { + return -1; + } + if ( spot[sortIndex[n]].flags != flags ) { + return -1; + } + return sortIndex[n]; + } + return -1; +} + +static void BuildSurface( int index ) { + int surfaceNum; + int plusx; + int minusx; + int plusy; + int minusy; + qboolean plusxLock; + qboolean minusxLock; + qboolean plusyLock; + qboolean minusyLock; + float xmin, xmax, x; + float ymin, ymax, y; + vec3_t test; + int n; + int count; + int tbm[256]; + int sCount; + nsurface_t *surf; + //int surfaceNum2; + //gentity_t *ent; + //float height; + + if ( surfaceCount == MAX_SURFACES ) { + gi.Printf( "MAX_SURFACES exceeded\n" ); + //FIXME in Q3MAP this should be an exit() + return; + } + + ThreadLock(); + surfaceNum = surfaceCount++; + ThreadUnlock(); + + spot[index].surfaceNum = surfaceNum; + + plusx = 0; + minusx = 0; + plusy = 0; + minusy = 0; + plusxLock = qfalse; + minusxLock = qfalse; + plusyLock = qfalse; + minusyLock = qfalse; + test[2] = spot[index].origin[2]; + sCount = 1; + + while ( !plusxLock || !minusxLock || !plusyLock || !minusyLock ) { + if ( !plusxLock ) { + plusx++; + count = 0; + test[0] = spot[index].origin[0] + plusx * XY_STEP; + ymin = spot[index].origin[1] - minusy * XY_STEP; + ymax = spot[index].origin[1] + plusy * XY_STEP; + for ( y = ymin; y <= ymax; y += XY_STEP ) { + test[1] = y; + n = SpotIndex( test, spot[index].flags ); + if ( n == -1 ) { + plusx--; + plusxLock = qtrue; + break; + } + tbm[count++] = n; + } + for ( n = 0; n < count; n ++ ) { + spot[tbm[n]].surfaceNum = surfaceNum; + } + sCount += count; + } + + if ( !minusxLock ) { + minusx++; + count = 0; + test[0] = spot[index].origin[0] - minusx * XY_STEP; + ymin = spot[index].origin[1] - minusy * XY_STEP; + ymax = spot[index].origin[1] + plusy * XY_STEP; + for ( y = ymin; y <= ymax; y += XY_STEP ) { + test[1] = y; + n = SpotIndex( test, spot[index].flags ); + if ( n == -1 ) { + minusx--; + minusxLock = qtrue; + break; + } + tbm[count++] = n; + } + for ( n = 0; n < count; n ++ ) { + spot[tbm[n]].surfaceNum = surfaceNum; + } + sCount += count; + } + + if ( !plusyLock ) { + plusy++; + count = 0; + test[1] = spot[index].origin[1] + plusy * XY_STEP; + xmin = spot[index].origin[0] - minusx * XY_STEP; + xmax = spot[index].origin[0] + plusx * XY_STEP; + for ( x = xmin; x <= xmax; x += XY_STEP ) { + test[0] = x; + n = SpotIndex( test, spot[index].flags ); + if ( n == -1 ) { + plusy--; + plusyLock = qtrue; + break; + } + tbm[count++] = n; + } + for ( n = 0; n < count; n ++ ) { + spot[tbm[n]].surfaceNum = surfaceNum; + } + sCount += count; + } + + if ( !minusyLock ) { + minusy++; + count = 0; + test[1] = spot[index].origin[1] - minusy * XY_STEP; + xmin = spot[index].origin[0] - minusx * XY_STEP; + xmax = spot[index].origin[0] + plusx * XY_STEP; + for ( x = xmin; x <= xmax; x += XY_STEP ) { + test[0] = x; + n = SpotIndex( test, spot[index].flags ); + if ( n == -1 ) { + minusy--; + minusyLock = qtrue; + break; + } + tbm[count++] = n; + } + for ( n = 0; n < count; n ++ ) { + spot[tbm[n]].surfaceNum = surfaceNum; + } + sCount += count; + } + } + +#if 0 + if ( sCount <= 1 ) { + surfaceSizes[0]++; + } + else if ( sCount <= 2 ) { + surfaceSizes[1]++; + } + else if ( sCount <= 4 ) { + surfaceSizes[2]++; + } + else if ( sCount <= 8 ) { + surfaceSizes[3]++; + } + else if ( sCount <= 16 ) { + surfaceSizes[4]++; + } + else if ( sCount <= 32 ) { + surfaceSizes[5]++; + } + else if ( sCount <= 64 ) { + surfaceSizes[6]++; + } + else if ( sCount <= 128 ) { + surfaceSizes[7]++; + } + else if ( sCount <= 256 ) { + surfaceSizes[8]++; + } + else { + surfaceSizes[9]++; + } +#endif + + surf = &surface[surfaceNum]; + surf->flags = spot[index].flags; + + surf->absmin[0] = spot[index].origin[0] - ( minusx * XY_STEP ); + surf->absmin[1] = spot[index].origin[1] - ( minusy * XY_STEP ); + + surf->absmax[0] = spot[index].origin[0] + ( plusx * XY_STEP ); + surf->absmax[1] = spot[index].origin[1] + ( plusy * XY_STEP ); + + surf->origin[0] = ( surf->absmin[0] + surf->absmax[0] ) * 0.5; + surf->origin[1] = ( surf->absmin[1] + surf->absmax[1] ) * 0.5; + surf->origin[2] = spot[index].origin[2]; + + gi.DebugPrintf( "Spot %d : origin %s\n", index, vtos( surf->origin ) ); + +// gi.Printf( "Surface from %s ", vtos( surf->absmin ) ); +// gi.Printf( "to %s", vtos( surf->absmax) ); +// gi.Printf( "at %s\n", vtos( surf->origin) ); +#if 0 + // if this is a plat high position, build to plat low surface + // Q#MAP: numerous changes in here + if ( spot[index].flags & SF_PLATLOW ) { //Q3MAP: SF_PLATHIGH + // grab another surface + ThreadLock(); + surfaceNum2 = surfaceCount++; + ThreadUnlock(); + + // make a copy of the other plat surface + memcpy( &surface[surfaceNum2], &surface[surfaceNum], sizeof( nsurface_t ) ); + +// // switch the flag from high to low +// surface[surfaceNum2].flags &= ~SF_PLATHIGH; +// surface[surfaceNum2].flags |= SF_PLATLOW; + // switch the flag from low to high + surface[surfaceNum2].flags &= ~SF_PLATLOW; + surface[surfaceNum2].flags |= SF_PLATHIGH; + + // adjust the z value + ent = &g_entities[spot[index].parm]; + height = ent->pos2[2] - ent->pos1[2]; +// surface[surfaceNum2].origin[2] -= height; + surface[surfaceNum2].origin[2] += height; + + // set low plat surface parm to high plat surface number +// surface[surfaceNum2].parm = surfaceNum; + surface[surfaceNum].parm = surfaceNum2; + +// // set high plat surface parm plat cost +// surface[surfaceNum].parm = (height / ent->speed) * 1000; +// surface[surfaceNum2].parm = (height / ent->speed) * 1000; + // set high plat surface parm to plat entity number +// surface[surfaceNum].parm = spot[index].parm; + surface[surfaceNum2].parm = spot[index].parm; + } +#endif + if ( spot[index].flags & SF_PUSH ) { + surf->parm = spot[index].parm; + } + + if ( spot[index].flags & SF_TELEPORTER ) { + surf->parm = spot[index].parm; + } +} + +static void FindSurfacesAtZ( int zIndex ) { + int n; + + zstart = spotIndex[zIndex]; + zend = spotIndex[zIndex + 1]; + + for ( n = zstart; n < zend; n++ ) { + if ( spot[sortIndex[n]].surfaceNum == -1 ) { + BuildSurface( sortIndex[n] ); + } + } +} + +static void FindSurfaces( void ) { + int n; + + surface = ( nsurface_t * )gi.TagMalloc ( MAX_SURFACES * sizeof(surface[0]), TAG_GAME ); + surfaceCount = 0; + +// memset( surfaceSizes, 0, sizeof( surfaceSizes ) ); + BuildSpotIndexByZ(); + +// RunThreadsOn( spotIndexCount, qtrue, FindSurfacesAtZ ); + for ( n = 0; n < spotIndexCount; n++ ) { + FindSurfacesAtZ( n ); + } + + gi.TagFree( spot ); + +#if 0 + gi.Printf( "%3i @ 1\n", surfaceSizes[0] ); + gi.Printf( "%3i @ 2\n", surfaceSizes[1] ); + gi.Printf( "%3i @ 3-4\n", surfaceSizes[2] ); + gi.Printf( "%3i @ 5-8\n", surfaceSizes[3] ); + gi.Printf( "%3i @ 9-16\n", surfaceSizes[4] ); + gi.Printf( "%3i @ 17-32\n", surfaceSizes[5] ); + gi.Printf( "%3i @ 33-64\n", surfaceSizes[6] ); + gi.Printf( "%3i @ 65-128\n", surfaceSizes[7] ); + gi.Printf( "%3i @ 129-256\n", surfaceSizes[8] ); + gi.Printf( "%3i @ 257+\n", surfaceSizes[9] ); +#endif + + gi.Printf( " %i surfaces\n", surfaceCount ); +} + +int FindSpot( vec3_t origin, int flags, float min_height ) +{ + int n; + + for ( n = 0; n < spotCount ; n++ ) + { + if ( spot[sortIndex[n]].origin[0] < origin[0] ) { + continue; + } + if ( spot[sortIndex[n]].origin[0] > origin[0] ) { + return -1; + } + if ( spot[sortIndex[n]].origin[1] < origin[1] ) { + continue; + } + if ( spot[sortIndex[n]].origin[1] > origin[1] ) { + return -1; + } + if ( spot[sortIndex[n]].origin[2] <= min_height ) { + continue; + } + if ( spot[sortIndex[n]].surfaceNum != -1 ) { + return -1; + } + if ( spot[sortIndex[n]].flags != flags ) { + return -1; + } + return sortIndex[n]; + } + return -1; +} + +int FindUsedSpot( vec3_t origin, float min_height ) +{ + int n; + + for ( n = 0; n < spotCount ; n++ ) + { + if ( spot[sortIndex[n]].origin[0] < origin[0] ) { + continue; + } + if ( spot[sortIndex[n]].origin[0] > origin[0] ) { + return -1; + } + if ( spot[sortIndex[n]].origin[1] < origin[1] ) { + continue; + } + if ( spot[sortIndex[n]].origin[1] > origin[1] ) { + return -1; + } + if ( spot[sortIndex[n]].origin[2] <= min_height ) { + continue; + } + return sortIndex[n]; + } + return -1; +} + +int FindSpotInSurface( vec3_t origin, int surfaceNum ) +{ + int index; + float current_height; + + + current_height = Z_MIN; + + while( 1 ) + { + index = FindUsedSpot( origin, current_height ); + + if (index == -1) + return -1; + + if (spot[index].surfaceNum == surfaceNum) + return index; + + current_height = spot[index].origin[2]; + } + + return -1; +} + +qboolean IsConvex( int surfaceNum, vec3_t check_point, int n ) +{ + float i, j; + float x1, y1; + float x2, y2; + float step; + int test_y; + float y_diff; + vec3_t test_point; + int test = 0; + + + if (check_point[0] < spot[n].origin[0]) + { + x1 = check_point[0]; + y1 = check_point[1]; + + x2 = spot[n].origin[0]; + y2 = spot[n].origin[1]; + } + else + { + x1 = spot[n].origin[0]; + y1 = spot[n].origin[1]; + + x2 = check_point[0]; + y2 = check_point[1]; + } + + if (x2 - x1 != 0) + step = (y2 - y1) / (x2 - x1) / XY_STEP; + else + step = 0; + + j = 0; + + for ( i = x1 ; i < x2 ; i += XY_STEP ) + { + // Test points here + + test_point[0] = i; + + test_y = j + .5; + + y_diff = j - test_y; + + if (0) //((y_diff < .05) && (y_diff > -.05)) + { + test_point[1] = y1 + ((int)j) * XY_STEP; + + if (FindSpotInSurface( test_point, surfaceNum ) == -1) + //return qfalse; + test++; + else + test = 0; + + } + else + { + + test_point[1] = y1 + ((int)j) * XY_STEP; + + if (FindSpotInSurface( test_point, surfaceNum ) == -1) + { + if (j > 0) + test_point[1] = y1 + ((int)(j + 1)) * XY_STEP; + else + test_point[1] = y1 + ((int)(j - 1)) * XY_STEP; + + if (FindSpotInSurface( test_point, surfaceNum ) == -1) + //return qfalse; + test++; + else + test = 0; + } + else + test = 0; + } + + if (test == 3) + return qfalse; + + j += step; + } + + return qtrue; +} + +qboolean CanAddPoint1( int surfaceNum, int n ) +{ + int i, j; + float z_diff; + int index; + vec3_t check_point; + float current_height; + int has_neighbor_point; + + + // Make sure can walk to nearest points in this surface + + has_neighbor_point = qfalse; + + for ( i = -1 ; i <= 1 ; i++ ) + { + check_point[0] = spot[n].origin[0] + i * XY_STEP; + + for ( j = -1 ; j <= 1 ; j++ ) + { + check_point[1] = spot[n].origin[1] + j * XY_STEP; + + if (! ((i == 0) && (j == 0)) ) + { + // Find point in same surface + + current_height = Z_MIN; + + while( 1 ) + { + index = FindUsedSpot( check_point, current_height ); + + if (index == -1) + break; + + if (spot[index].surfaceNum == surfaceNum) + { + has_neighbor_point = qtrue; + + z_diff = spot[index].origin[2] - spot[n].origin[2]; + if (z_diff < 0) + z_diff = -z_diff; + + if (z_diff > STEPSIZE) + return qfalse; + + break; + } + + current_height = spot[index].origin[2]; + } + } + } + } + + // Make sure it was next to at least one other point in this surface + + if (!has_neighbor_point) + return qfalse; + + return qtrue; +} + +qboolean CanAddPoint2( int surfaceNum, int n ) +{ + int i, j; + vec3_t check_point; + vec2_t absmin; + vec2_t absmax; + qboolean skip_top, skip_left, skip_right, skip_bottom; + + + // Setup ansolute mins and maxs correctly + + if (spot[n].origin[0] < surface[surfaceNum].absmin[0]) + { + absmin[0] = spot[n].origin[0]; + skip_left = qtrue; + } + else + { + absmin[0] = surface[surfaceNum].absmin[0]; + skip_left = qfalse; + } + + if (spot[n].origin[0] > surface[surfaceNum].absmax[0]) + { + absmax[0] = spot[n].origin[0]; + skip_right = qtrue; + } + else + { + absmax[0] = surface[surfaceNum].absmax[0]; + skip_right = qfalse; + } + + if (spot[n].origin[1] < surface[surfaceNum].absmin[1]) + { + absmin[1] = spot[n].origin[1]; + skip_top = qtrue; + } + else + { + absmin[1] = surface[surfaceNum].absmin[1]; + skip_top = qfalse; + } + + if (spot[n].origin[1] > surface[surfaceNum].absmax[1]) + { + absmax[1] = spot[n].origin[1]; + skip_bottom = qtrue; + } + else + { + absmax[1] = surface[surfaceNum].absmax[1]; + skip_bottom = qfalse; + } + + // Test top and bottom points for convexness + + for( i = absmin[0] ; i <= absmax[0] ; i += XY_STEP ) + { + check_point[0] = i; + + // Find top point in this column + + if (!skip_top) + { + for( j = absmin[1] ; j <= absmax[1] ; j += XY_STEP ) + { + check_point[1] = j; + + if (FindSpotInSurface( check_point, surfaceNum ) != -1) + { + // Test for convexness + + if (!IsConvex( surfaceNum, check_point, n )) + return qfalse; + + break; + } + } + } + + // Find bottom point in this column + + if (!skip_bottom) + { + for( j = absmax[1] ; j >= absmin[1] ; j -= XY_STEP ) + { + check_point[1] = j; + + if (FindSpotInSurface( check_point, surfaceNum ) != -1) + { + // Test for convexness + + if (!IsConvex( surfaceNum, check_point, n )) + return qfalse; + + break; + } + } + } + } + + // Test left and right points for convexness + + for( j = absmin[1] ; j <= absmax[1] ; j += XY_STEP ) + { + check_point[1] = j; + + // Find left point in this row + + if (!skip_left) + { + for( i = absmin[0] ; i <= absmax[0] ; i += XY_STEP ) + { + check_point[0] = i; + + if (FindSpotInSurface( check_point, surfaceNum ) != -1) + { + // Test for convexness + + if (!IsConvex( surfaceNum, check_point, n )) + return qfalse; + + break; + } + } + } + + // Find right point in this row + + if (!skip_right) + { + for( i = absmax[0] ; i >= absmin[0] ; i -= XY_STEP ) + { + check_point[0] = i; + + if (FindSpotInSurface( check_point, surfaceNum ) != -1) + { + // Test for convexness + + if (!IsConvex( surfaceNum, check_point, n )) + return qfalse; + + break; + } + } + } + } + + + /* for ( i = -1 ; i <= 1 ; i++ ) + { + check_point[0] = spot[n].origin[0] + i * XY_STEP; + + for ( j = -1 ; j <= 1 ; j++ ) + { + check_point[1] = spot[n].origin[1] + j * XY_STEP; + + if (! ((i == 0) && (j == 0)) ) + { + // Find point in same surface + + current_height = Z_MIN; + + while( 1 ) + { + index = FindUsedSpot( check_point, current_height ); + + if (index == -1) + break; + + if (spot[index].surfaceNum == surfaceNum) + break; + + current_height = spot[index].origin[2]; + } + + if (index == -1) + { + current_height = Z_MIN; + + while( 1 ) + { + index = FindUsedSpot( check_point, current_height ); + + if (index == -1) + break; + + if (spot[index].surfaceNum == surfaceNum) + break; + + current_height = spot[index].origin[2]; + } + + if (index != -1) + return qfalse; + } + } + } + } */ + + return qtrue; +} + +void AddPointToSurface( int surfaceNum, int n ) +{ + spot[n].surfaceNum = surfaceNum; + + if (spot[n].origin[0] < surface[surfaceNum].absmin[0]) + surface[surfaceNum].absmin[0] = spot[n].origin[0]; + + if (spot[n].origin[0] > surface[surfaceNum].absmax[0]) + surface[surfaceNum].absmax[0] = spot[n].origin[0]; + + if (spot[n].origin[1] < surface[surfaceNum].absmin[1]) + surface[surfaceNum].absmin[1] = spot[n].origin[1]; + + if (spot[n].origin[1] > surface[surfaceNum].absmax[1]) + surface[surfaceNum].absmax[1] = spot[n].origin[1]; +} + +static void BuildConvexSurface( int index ) +{ + int surfaceNum; + int plusx; + int minusx; + int plusy; + int minusy; + qboolean plusxLock; + qboolean minusxLock; + qboolean plusyLock; + qboolean minusyLock; + qboolean plusxhold, minusxhold, plusyhold, minusyhold; + qboolean plusxalreadyheld, minusxalreadyheld, plusyalreadyheld, minusyalreadyheld; + float xmin, xmax, x; + float ymin, ymax, y; + vec3_t test; + int n; + int count; + int tbm[256]; + int sCount; + nsurface_t *surf; + qboolean valid_direction; + float current_height; + int i; + + + + if ( surfaceCount == MAX_SURFACES ) + { + gi.Printf( "MAX_SURFACES exceeded\n" ); + return; + } + + //if (surfaceCount > 100) + // return; + + ThreadLock(); + surfaceNum = surfaceCount++; + ThreadUnlock(); + + spot[index].surfaceNum = surfaceNum; + + surface[surfaceNum].absmin[0] = spot[index].origin[0]; + surface[surfaceNum].absmax[0] = spot[index].origin[0]; + surface[surfaceNum].absmin[1] = spot[index].origin[1]; + surface[surfaceNum].absmax[1] = spot[index].origin[1]; + + plusx = 0; + minusx = 0; + plusy = 0; + minusy = 0; + + plusxLock = qfalse; + minusxLock = qfalse; + plusyLock = qfalse; + minusyLock = qfalse; + + plusxhold = qfalse; + minusxhold = qfalse; + plusyhold = qfalse; + minusyhold = qfalse; + + plusxalreadyheld = qfalse; + minusxalreadyheld = qfalse; + plusyalreadyheld = qfalse; + minusyalreadyheld = qfalse; + + test[2] = spot[index].origin[2]; + sCount = 1; + + while ( !plusxLock || !minusxLock || !plusyLock || !minusyLock ) + { + if ( ( plusxLock || plusxhold ) && ( minusxLock || minusxhold ) && ( plusyLock || plusyhold ) && ( minusyLock || minusyhold ) ) + { + // Remove all of the holds + + plusxhold = qfalse; + minusxhold = qfalse; + plusyhold = qfalse; + minusyhold = qfalse; + + plusxalreadyheld = qtrue; + minusxalreadyheld = qtrue; + plusyalreadyheld = qtrue; + minusyalreadyheld = qtrue; + } + + if ( !plusxLock && !plusxhold ) + { + plusx++; + count = 0; + test[0] = spot[index].origin[0] + plusx * XY_STEP; + ymin = spot[index].origin[1] - minusy * XY_STEP; + ymax = spot[index].origin[1] + plusy * XY_STEP; + valid_direction = qfalse; + + for ( y = ymin; y <= ymax; y += XY_STEP ) + { + // Find this spot + + test[1] = y; + current_height = Z_MIN; + n = FindSpot( test, spot[index].flags, current_height ); + + while( n != -1 ) + { + // See if this point can be added and the surface stay convex + + if ( CanAddPoint1( surfaceNum, n ) ) + { + // Add this point to this surface + + spot[n].surfaceNum = surfaceNum; + tbm[count] = n; + count++; + + break; + } + + // Get the next spot at this x, y + + current_height = spot[n].origin[2]; + n = FindSpot( test, spot[index].flags, current_height ); + } + } + + if ( plusxalreadyheld ) + { + for( i = 0 ; i < count ; i++ ) + { + if ( CanAddPoint2( surfaceNum, tbm[i] ) ) + { + AddPointToSurface( surfaceNum, tbm[i] ); + valid_direction = qtrue; + } + else + spot[tbm[i]].surfaceNum = -1; + } + } + else + { + valid_direction = qtrue; + + if (count == (ymax - ymin) / XY_STEP + 1) + { + for( i = 0 ; i < count ; i++ ) + AddPointToSurface( surfaceNum, tbm[i] ); + } + else + { + for( i = 0 ; i < count ; i++ ) + spot[tbm[i]].surfaceNum = -1; + plusxhold = qtrue; + plusx--; + } + } + + if ( !valid_direction ) + { + plusx--; + plusxLock = qtrue; + } + } + + if ( !minusxLock && !minusxhold ) + { + minusx++; + count = 0; + test[0] = spot[index].origin[0] - minusx * XY_STEP; + ymin = spot[index].origin[1] - minusy * XY_STEP; + ymax = spot[index].origin[1] + plusy * XY_STEP; + valid_direction = qfalse; + + for ( y = ymin; y <= ymax; y += XY_STEP ) + { + // Find this spot + + test[1] = y; + current_height = Z_MIN; + n = FindSpot( test, spot[index].flags, current_height ); + + while( n != -1 ) + { + // See if this point can be added and the surface stay convex + + if ( CanAddPoint1( surfaceNum, n ) ) + { + // Add this point to this surface + + spot[n].surfaceNum = surfaceNum; + tbm[count] = n; + count++; + + break; + } + + // Get the next spot at this x, y + + current_height = spot[n].origin[2]; + n = FindSpot( test, spot[index].flags, current_height ); + } + } + + if ( minusxalreadyheld ) + { + for( i = 0 ; i < count ; i++ ) + { + if ( CanAddPoint2( surfaceNum, tbm[i] ) ) + { + AddPointToSurface( surfaceNum, tbm[i] ); + valid_direction = qtrue; + } + else + spot[tbm[i]].surfaceNum = -1; + } + } + else + { + valid_direction = qtrue; + + if (count == (ymax - ymin) / XY_STEP + 1) + { + for( i = 0 ; i < count ; i++ ) + AddPointToSurface( surfaceNum, tbm[i] ); + } + else + { + for( i = 0 ; i < count ; i++ ) + spot[tbm[i]].surfaceNum = -1; + minusxhold = qtrue; + minusx--; + } + } + + if ( !valid_direction ) + { + minusx--; + minusxLock = qtrue; + } + } + + if ( !plusyLock && !plusyhold ) + { + plusy++; + count = 0; + test[1] = spot[index].origin[1] + plusy * XY_STEP; + xmin = spot[index].origin[0] - minusx * XY_STEP; + xmax = spot[index].origin[0] + plusx * XY_STEP; + valid_direction = qfalse; + + for ( x = xmin; x <= xmax; x += XY_STEP ) + { + // Find this spot + + test[0] = x; + current_height = Z_MIN; + n = FindSpot( test, spot[index].flags, current_height ); + + while( n != -1 ) + { + // See if this point can be added and the surface stay convex + + if ( CanAddPoint1( surfaceNum, n ) ) + { + // Add this point to this surface + + spot[n].surfaceNum = surfaceNum; + tbm[count] = n; + count++; + + break; + } + + // Get the next spot at this x, y + + current_height = spot[n].origin[2]; + n = FindSpot( test, spot[index].flags, current_height ); + } + } + + if ( plusyalreadyheld ) + { + for( i = 0 ; i < count ; i++ ) + { + if ( CanAddPoint2( surfaceNum, tbm[i] ) ) + { + AddPointToSurface( surfaceNum, tbm[i] ); + valid_direction = qtrue; + } + else + spot[tbm[i]].surfaceNum = -1; + } + } + else + { + valid_direction = qtrue; + + if (count == (xmax - xmin) / XY_STEP + 1) + { + for( i = 0 ; i < count ; i++ ) + AddPointToSurface( surfaceNum, tbm[i] ); + } + else + { + for( i = 0 ; i < count ; i++ ) + spot[tbm[i]].surfaceNum = -1; + plusyhold = qtrue; + plusy--; + } + } + + if ( !valid_direction ) + { + plusy--; + plusyLock = qtrue; + } + } + + if ( !minusyLock && !minusyhold ) + { + minusy++; + count = 0; + test[1] = spot[index].origin[1] - minusy * XY_STEP; + xmin = spot[index].origin[0] - minusx * XY_STEP; + xmax = spot[index].origin[0] + plusx * XY_STEP; + valid_direction = qfalse; + + for ( x = xmin; x <= xmax; x += XY_STEP ) + { + // Find this spot + + test[0] = x; + current_height = Z_MIN; + n = FindSpot( test, spot[index].flags, current_height ); + + while( n != -1 ) + { + // See if this point can be added and the surface stay convex + + if ( CanAddPoint1( surfaceNum, n ) ) + { + // Add this point to this surface + + spot[n].surfaceNum = surfaceNum; + tbm[count] = n; + count++; + + break; + } + + // Get the next spot at this x, y + + current_height = spot[n].origin[2]; + n = FindSpot( test, spot[index].flags, current_height ); + } + } + + if ( minusyalreadyheld ) + { + for( i = 0 ; i < count ; i++ ) + { + if ( CanAddPoint2( surfaceNum, tbm[i] ) ) + { + AddPointToSurface( surfaceNum, tbm[i] ); + valid_direction = qtrue; + } + else + spot[tbm[i]].surfaceNum = -1; + } + } + else + { + valid_direction = qtrue; + + if (count == (xmax - xmin) / XY_STEP + 1) + { + for( i = 0 ; i < count ; i++ ) + AddPointToSurface( surfaceNum, tbm[i] ); + } + else + { + for( i = 0 ; i < count ; i++ ) + spot[tbm[i]].surfaceNum = -1; + minusyhold = qtrue; + minusy--; + } + } + + if ( !valid_direction ) + { + minusy--; + minusyLock = qtrue; + } + } + } + + // Setup surface info + + surf = &surface[surfaceNum]; + surf->flags = spot[index].flags; + + surf->absmin[0] = spot[index].origin[0] - ( minusx * XY_STEP ); + surf->absmin[1] = spot[index].origin[1] - ( minusy * XY_STEP ); + + surf->absmax[0] = spot[index].origin[0] + ( plusx * XY_STEP ); + surf->absmax[1] = spot[index].origin[1] + ( plusy * XY_STEP ); + + surf->origin[0] = ( surf->absmin[0] + surf->absmax[0] ) * 0.5; + surf->origin[1] = ( surf->absmin[1] + surf->absmax[1] ) * 0.5; + surf->origin[2] = spot[index].origin[2]; + + gi.DebugPrintf( "surface #%d - Spot %d : origin %s\n", surfaceNum, index, vtos( surf->origin ) ); +} + +static int CompareSpots( const void *a, const void *b ) { + nspot_t *s1 = &spot[*(int *)a]; + nspot_t *s2 = &spot[*(int *)b]; + + // x + if ( s1->origin[0] < s2->origin[0] ) { + return -1; + } + if ( s1->origin[0] > s2->origin[0] ) { + return 1; + } + + // y + if ( s1->origin[1] < s2->origin[1] ) { + return -1; + } + if ( s1->origin[1] > s2->origin[1] ) { + return 1; + } + + // z + if ( s1->origin[2] > s2->origin[2] ) { + return -1; + } + if ( s1->origin[2] < s2->origin[2] ) { + return 1; + } + + return 0; +} + +static void SortSpots( void ) +{ + int n; + //int i; + //float z; + //float cz; + + for ( n = 0; n < spotCount; n++ ) + sortIndex[n] = n; + + for ( n = 0; n < (((XY_MAX - XY_MIN) / XY_STEP) + 2); n++ ) + spotIndex[n] = 0; + + qsort( sortIndex, spotCount, sizeof(sortIndex[0]), CompareSpots ); +} + +static void FindConvexSurfaces( void ) +{ + int n; + + surface = ( nsurface_t * )gi.TagMalloc ( MAX_SURFACES * sizeof(surface[0]), TAG_GAME ); + surfaceCount = 0; + + SortSpots(); + + for ( n = 0; n < spotCount; n++ ) + { + if ( spot[sortIndex[n]].surfaceNum == -1 ) + BuildConvexSurface( sortIndex[n] ); + } + + gi.TagFree( spot ); + + gi.Printf( " %i surfaces\n", surfaceCount ); +} + +// +// FindNeighbors +// + +// stats on point to edge reachability testing +typedef struct { + int count; + int accept; + int reject1; + int reject2; + int reject3; + int pmoveCount; +} reachStats_t; + +// stats on surface to surface testing +typedef struct { + int count; + int accept; + int reject; + int treject1; + int treject2; + int treject3; + int treject4; + int zeroNeighbors; +} surfaceStats_t; + +// per source surface info +// +// The reason for the local neighbors array and MAX_NEIGHBORS_PER_SURFACE is so FindSurfaceNeighbors +// can be run on many surfaces at once when multithreaded. + +#define MAX_NEIGHBORS_PER_SURFACE 256 + +typedef struct { + int number; + nsurface_t *surface; + int neighborCount; + nneighbor_t neighbor[MAX_NEIGHBORS_PER_SURFACE]; +} sourceSurfaceInfo_t; + +// per target surface info +typedef struct { + int number; + nsurface_t *surface; + qboolean edgeActive; + vec2_t edgeStart; + vec2_t edgeEnd; + int edgeFlags; + float cost; +} targetSurfaceInfo_t; + +// per thread neighbor testing info block +typedef struct { + reachStats_t rStats; + surfaceStats_t sStats; + sourceSurfaceInfo_t sSurf; + targetSurfaceInfo_t tSurf; +} surfaceThreadInfo_t; + +// global (per map) instances of stats; used to sum all the per thread stats +static reachStats_t reachStats; +static surfaceStats_t surfStats; + + +#define FLOAT_TO_VELOCITY 16.0 +#define VELOCITY_TO_FLOAT (1.0/FLOAT_TO_VELOCITY) + +static int SurfaceNumberAtPoint( vec3_t point ) { + vec3_t p; + int n; + + p[0] = point[0]; + p[1] = point[1]; + p[2] = floor( point[2] ); + + for ( n = 0; n < surfaceCount; n++ ) { + if ( floor( surface[n].origin[2] ) != p[2] ) { + continue; + } + if ( ( surface[n].absmin[0] - 16 ) > p[0] ) { + continue; + } + if ( ( surface[n].absmax[0] + 16 ) < p[0] ) { + continue; + } + if ( ( surface[n].absmin[1] - 16 ) > p[1] ) { + continue; + } + if ( ( surface[n].absmax[1] + 16 ) < p[1] ) { + continue; + } + return n; + } + + return -1; +} + + +static qboolean PointIsOnSurfaceNumber( vec3_t point, int n ) { + vec3_t p; + + p[0] = point[0]; + p[1] = point[1]; + p[2] = floor( point[2] ); + + if ( floor( surface[n].origin[2] ) != p[2] ) { + return qfalse; + } + if ( ( surface[n].absmin[0] - 16 ) > p[0] ) { + return qfalse; + } + if ( ( surface[n].absmax[0] + 16 ) < p[0] ) { + return qfalse; + } + if ( ( surface[n].absmin[1] - 16 ) > p[1] ) { + return qfalse; + } + if ( ( surface[n].absmax[1] + 16 ) < p[1] ) { + return qfalse; + } + return qtrue; +} + +static void ReachTrace(trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contents, qboolean cylinder ) + { + trace_t tr; + + gi.trace ( &tr, start, mins, maxs, end, passEntityNum, contents, cylinder ); + + //FIXME this is FUGLY + while ( tr.entityNum && ( g_entities[tr.entityNum].s.eType == ET_MOVER ) ) + { + if ( Q_stricmp( g_entities[tr.entityNum].entname, "func_plat" ) == 0 ) + { + *result = tr; + return; + } + gi.trace ( &tr, tr.endpos, mins, maxs, end, tr.entityNum, contents, cylinder ); + if ( tr.fraction == 0.0 ) + { + *result = tr; + return; + } + } + *result = tr; + return; + } + +//FIXME try start running, start walking, and start motionless (special flags set if slower speed required) +static qboolean CanReach( surfaceThreadInfo_t *info, vec3_t start, vec3_t dir, int *flags ) { + pmove_t pm; + playerState_t ps; + int n; + int currentSurface; + vec3_t lastOrigin; + + info->rStats.count++; + + *flags = 0; + + VectorNormalize( dir ); + VectorCopy( start, lastOrigin ); + + memset( &pm, 0, sizeof( pm ) ); + memset( &ps, 0, sizeof( ps ) ); + pm.ps = &ps; + pm.cmd.msec = PMOVE_MSEC; + pm.cmd.buttons = 0; + pm.cmd.weapon = 0; + pm.cmd.angles[0] = 0; + pm.cmd.angles[1] = 0; + pm.cmd.angles[2] = 0; + pm.cmd.forwardmove = 127; + pm.cmd.rightmove = 0; + pm.cmd.upmove = 0; + pm.tracemask = MASK_DEADSOLID; + pm.noFootsteps = qtrue; + pm.trace = ReachTrace; + pm.pointcontents = gi.pointcontents; + + ps.pm_type = PM_NORMAL; + ps.gravity = sv_gravity->value; + ps.speed = PLAYER_SPEED; + VectorCopy( start, ps.origin ); +// VectorClear( ps.velocity ); + VectorScale( dir, ps.speed, ps.velocity ); + ps.delta_angles[0] = 0; + ps.delta_angles[1] = ANGLE2SHORT ( vectoyaw ( dir ) ); + ps.delta_angles[2] = 0; + ps.groundEntityNum = 0; + ps.clientNum = 0; // FIXME? was ent->s.number; + + // do we need to start ducked? + if ( info->sSurf.surface->flags & SF_DUCK ) { + ps.pm_flags |= PMF_DUCKED; + } + + // does the target surface require us to be ducked + if ( info->tSurf.surface->flags & SF_DUCK ) { + ps.pm_flags |= PMF_DUCKED; + pm.cmd.upmove = -127; + } + + // do we need to jump up? + if ( ( info->tSurf.surface->origin[2] - info->sSurf.surface->origin[2] ) > STEPSIZE ) { + // if we're ducked we can't jump so it is unreachable + if ( ps.pm_flags & PMF_DUCKED ) { + return qfalse; + } + pm.cmd.upmove = 127; + *flags |= NF_JUMP; + } + + // junk we need to fill in so PMove behaves correctly + for( n = 0; n < MAX_STATS; n++ ) { + ps.stats[n] = 0; + } + ps.stats[STAT_HEALTH] = 100; + for( n = 0; n < PW_NUM_POWERUPS; n++ ) { + ps.powerups[n] = 0; + } + + for ( n = 0; n < MAX_PMOVES; n++ ) { + + Pmove( &pm ); + info->rStats.pmoveCount++; + + if( VectorCompare( ps.origin, lastOrigin ) != 0 ) { + info->rStats.reject1++; + return qfalse; + } + VectorCopy( ps.origin, lastOrigin ); + + if ( ps.groundEntityNum == -1 ) { + continue; + } + + currentSurface = SurfaceNumberAtPoint( ps.origin ); + + // FIXME - this happens at the spot under a door + if ( currentSurface == -1 ) { + continue; + } + + if ( pm.pmoveEvent == EV_FALL_FAR ) { + *flags |= NF_FALL2; + } + else if ( pm.pmoveEvent == EV_FALL_MEDIUM ) { + *flags |= NF_FALL1; + } + + if ( PointIsOnSurfaceNumber( ps.origin, info->tSurf.number ) ) { + info->rStats.accept++; + return qtrue; + } + + if ( !PointIsOnSurfaceNumber( ps.origin, info->sSurf.number ) ) { + info->rStats.reject2++; + return qfalse; + } + } + + info->rStats.reject3++; + return qfalse; +} + + +static int FindDestination_Push( surfaceThreadInfo_t *info, gentity_t *pushEnt, int *flags ) { + return -1; +#if 0 + vec3_t dir; + pmove_t pm; + playerState_t ps; + int n; + int currentSurface; + qboolean leftGround; + vec3_t pushVel; + vec3_t absmin; + vec3_t absmax; + int numEnts; + gentity_t *ents[MAX_GENTITIES]; + + *flags = 0; + VectorCopy( pushEnt->movedir, dir ); + VectorCopy( dir, pushVel ); + VectorNormalize( dir ); + + memset( &pm, 0, sizeof( pm ) ); + memset( &ps, 0, sizeof( ps ) ); + pm.ps = &ps; + pm.cmd.msec = PMOVE_MSEC; + pm.cmd.buttons = 0; + pm.cmd.weapon = 0; + pm.cmd.angles[0] = 0; + pm.cmd.angles[1] = 0; + pm.cmd.angles[2] = 0; + pm.cmd.forwardmove = 0; + pm.cmd.rightmove = 0; + pm.cmd.upmove = 0; + pm.tracemask = MASK_DEADSOLID; + pm.noFootsteps = qtrue; + pm.trace = ReachTrace; + pm.pointcontents = gi.pointcontents; + + ps.pm_type = PM_NORMAL; + ps.gravity = g_gravity->value; + ps.speed = PLAYER_SPEED; + VectorCopy( info->sSurf.surface->origin, ps.origin ); + VectorCopy( pushVel, ps.velocity ); + ps.delta_angles[0] = 0; + ps.delta_angles[1] = ANGLE2SHORT ( vectoyaw ( dir ) ); + ps.delta_angles[2] = 0; + ps.groundEntityNum = 0; + ps.playernum = 1; + + // junk we need to fill in so PMove behaves correctly + for( n = 0; n < MAX_STATS; n++ ) { + ps.stats[n] = 0; + } + ps.stats[STAT_HEALTH] = 100; + for( n = 0; n < PW_NUM_POWERUPS; n++ ) { + ps.powerups[n] = 0; + } + + leftGround = qfalse; + for ( n = 0; n < MAX_PMOVES; n++ ) { + VectorAdd( ps.origin, mins, absmin ); + VectorAdd( ps.origin, standMaxs, absmax ); + numEnts = gi.EntitiesInBox( absmin, absmax, ents, MAX_GENTITIES ); + for ( n = 0; n < numEnts; n++ ) { + if ( ents[n] == pushEnt ) { + VectorCopy( pushVel, ps.velocity ); + } + } + + Pmove( &pm ); + if ( ps.groundEntityNum == -1 ) { + leftGround = qtrue; + continue; + } + + currentSurface = SurfaceNumberAtPoint( ps.origin ); + + if ( currentSurface == info->sSurf.number && !leftGround ) { + continue; + } + + if ( pm.pmoveEvent == EV_FALL_FAR ) { + *flags |= NF_FALL2; + } + else if ( pm.pmoveEvent == EV_FALL_MEDIUM ) { + *flags |= NF_FALL1; + } + + info->tSurf.cost = n * PMOVE_MSEC; + + return currentSurface; + } + + return -1; +#endif +} + + +// TeleportPlayer( activator, dest->s.origin, dest->s.angles ); +// AngleVectors( angles, player->client->ps.velocity, NULL, NULL ); +// VectorScale( player->client->ps.velocity, 400, player->client->ps.velocity ); + +static int FindDestination_Teleport( surfaceThreadInfo_t *info, gentity_t *destEnt, int *flags ) { + pmove_t pm; + playerState_t ps; + int n; + int currentSurface; + vec3_t lastOrigin; + vec3_t angles; + + *flags = 0; + + VectorCopy( destEnt->s.origin, lastOrigin ); + lastOrigin[2] += 1; + + AngleVectors( destEnt->s.angles, angles, NULL, NULL ); + + memset( &pm, 0, sizeof( pm ) ); + memset( &ps, 0, sizeof( ps ) ); + pm.ps = &ps; + pm.cmd.msec = PMOVE_MSEC; + pm.cmd.buttons = 0; + pm.cmd.weapon = 0; + pm.cmd.angles[0] = 0; + pm.cmd.angles[1] = 0; + pm.cmd.angles[2] = 0; + pm.cmd.forwardmove = 0; + pm.cmd.rightmove = 0; + pm.cmd.upmove = 0; + pm.tracemask = MASK_DEADSOLID; + pm.noFootsteps = qtrue; + pm.trace = ReachTrace; + pm.pointcontents = gi.pointcontents; + + ps.pm_type = PM_NORMAL; + ps.gravity = sv_gravity->value; + ps.speed = PLAYER_SPEED; + VectorCopy( lastOrigin, ps.origin ); + VectorScale( angles, 400, ps.velocity ); + ps.delta_angles[0] = 0; + ps.delta_angles[1] = ANGLE2SHORT ( angles[YAW] ); + ps.delta_angles[2] = 0; + ps.groundEntityNum = 0; + ps.clientNum = 0; + + // junk we need to fill in so PMove behaves correctly + for( n = 0; n < MAX_STATS; n++ ) { + ps.stats[n] = 0; + } + ps.stats[STAT_HEALTH] = 100; + for( n = 0; n < PW_NUM_POWERUPS; n++ ) { + ps.powerups[n] = 0; + } + + n = 0; + while ( 1 ) { + n++; + Pmove( &pm ); + info->rStats.pmoveCount++; + + if( VectorCompare( ps.origin, lastOrigin ) != 0 ) { + break; + } + VectorCopy( ps.origin, lastOrigin ); + + if ( ps.groundEntityNum == -1 ) { + continue; + } + + currentSurface = SurfaceNumberAtPoint( ps.origin ); + + if ( pm.pmoveEvent == EV_FALL_FAR ) { + *flags |= NF_FALL2; + } + else if ( pm.pmoveEvent == EV_FALL_MEDIUM ) { + *flags |= NF_FALL1; + } + + info->tSurf.cost = n * PMOVE_MSEC; + + return currentSurface; + } + + return -1; +} + + +static vec3_t testDir[] = { {0, 1, 0}, {-1, 0, 0}, {0, -1, 0}, {1, 0, 0}, {-0.5, 0.5, 0}, {0.5, 0.5, 0}, {-0.5, -0.5, 0}, {0.5, -0.5, 0} }; + +static void EdgeOpen( surfaceThreadInfo_t *info, vec3_t spot, int flags ) { + info->tSurf.edgeActive = qtrue; + info->tSurf.edgeStart[0] = spot[0]; + info->tSurf.edgeStart[1] = spot[1]; + info->tSurf.edgeEnd[0] = spot[0]; + info->tSurf.edgeEnd[1] = spot[1]; + info->tSurf.edgeFlags = flags; +} + +static void EdgeClose( surfaceThreadInfo_t *info ) { + nneighbor_t *n; + vec3_t vec; + float d; + + n = &info->sSurf.neighbor[info->sSurf.neighborCount]; + + n->surfaceNum = info->tSurf.number; + if ( info->tSurf.edgeStart[0] <= info->tSurf.edgeEnd[0] ) { + n->absmin[0] = info->tSurf.edgeStart[0]; + n->absmax[0] = info->tSurf.edgeEnd[0]; + } + else { + n->absmin[0] = info->tSurf.edgeEnd[0]; + n->absmax[0] = info->tSurf.edgeStart[0]; + } + if ( info->tSurf.edgeStart[1] <= info->tSurf.edgeEnd[1] ) { + n->absmin[1] = info->tSurf.edgeStart[1]; + n->absmax[1] = info->tSurf.edgeEnd[1]; + } + else { + n->absmin[1] = info->tSurf.edgeEnd[1]; + n->absmax[1] = info->tSurf.edgeStart[1]; + } + + n->origin[0] = (n->absmin[0] + n->absmax[0]) * 0.5; + n->origin[1] = (n->absmin[1] + n->absmax[1]) * 0.5; + n->origin[2] = info->sSurf.surface->origin[2]; + + n->flags = info->tSurf.edgeFlags; + + // calc path cost + + if ( info->tSurf.cost ) { + n->cost = info->tSurf.cost; + } + else { + // take dist from source origin to point + VectorSubtract( info->sSurf.surface->origin, n->origin, vec ); + d = VectorLength( vec ); + + // add any movement weights + if ( ( info->sSurf.surface->flags & (SF_WATERLEVEL1 | SF_WATERLEVEL2 ) ) == (SF_WATERLEVEL1 | SF_WATERLEVEL2 ) ) { + d /= SWIMSCALE; + } + else if ( info->sSurf.surface->flags & SF_DUCK ) { + d /= DUCKSCALE; + } + else if ( info->sSurf.surface->flags & (SF_WATERLEVEL1 | SF_WATERLEVEL2 ) ) { + d /= WADESCALE; + } + + // save that as first segment distance + n->cost = d; + + // take dist from point to target origin + VectorSubtract( info->tSurf.surface->origin, n->origin, vec ); + d = VectorLength( vec ); + + // add any movement weights + if ( ( info->tSurf.surface->flags & (SF_WATERLEVEL1 | SF_WATERLEVEL2 ) ) == (SF_WATERLEVEL1 | SF_WATERLEVEL2 ) ) { + d /= SWIMSCALE; + } + else if ( info->tSurf.surface->flags & SF_DUCK ) { + d /= DUCKSCALE; + } + else if ( info->tSurf.surface->flags & (SF_WATERLEVEL1 | SF_WATERLEVEL2 ) ) { + d /= WADESCALE; + } + + // add that to first distance + n->cost += d; + + // convert distance to time + n->cost = ( n->cost / (float)PLAYER_SPEED ) * 1000.0; + + // possibly add a jump cost + if ( n->flags & NF_JUMP ) { + n->cost += 250.0; //FIXME what is a good value to use here? track actual time used for transitional pmoves! + } + } + + if ( info->tSurf.surface->flags & SF_DUCK ) { + n->flags |= NF_DUCK; + } + +// gi.Printf( "s%i to s%i: edge %f,%f to %f,%f f=%i\n", info->sSurf.number, info->tSurf.number, edgeStart[0], edgeStart[1], edgeEnd[0], edgeEnd[1], *edgeFlags ); +// gi.Printf( "s%i to s%i\n", info->sSurf.number, info->tSurf.number ); + info->tSurf.edgeActive = qfalse; + + info->sSurf.neighborCount++; + if ( info->sSurf.neighborCount == MAX_NEIGHBORS_PER_SURFACE ) { + gi.Printf( "MAX_NEIGHBORS_PER_SURFACE exceeded\n" ); + } +} + +static void EdgeUpdate( surfaceThreadInfo_t *info, qboolean reachable, vec3_t spot, int flags ) { +// gi.Printf( "s1=%i s2=%i spot=%s result=%i f=%i\n", info->sSurf.number, info->tSurf.number, vtos( spot ), reachable, flags ); + if ( reachable ) { + if ( info->tSurf.edgeActive ) { + if ( flags == info->tSurf.edgeFlags ) { + // continue edge + info->tSurf.edgeEnd[0] = spot[0]; + info->tSurf.edgeEnd[1] = spot[1]; + } + else { + EdgeClose( info ); + EdgeOpen( info, spot, flags ); + } + } + else { + EdgeOpen( info, spot, flags ); + } + } + else { + if ( info->tSurf.edgeActive ) { + EdgeClose( info ); + } + } +} + + +static void TestReachSurface( surfaceThreadInfo_t *info ) { + int edgeCode; + float xStart, xEnd; + float yStart, yEnd; + float x, y, z; + vec3_t spot; + int flags; + qboolean reachable; + + // determine which edges of s1 are facing s2 + edgeCode = 0; + + if ( info->tSurf.surface->absmin[1] > info->sSurf.surface->absmax[1] ) { + edgeCode |= 1; + } + if ( info->tSurf.surface->absmax[0] < info->sSurf.surface->absmin[0] ) { + edgeCode |= 2; + } + if ( info->tSurf.surface->absmin[0] > info->sSurf.surface->absmax[0] ) { + edgeCode |= 4; + } + if ( info->tSurf.surface->absmax[1] < info->sSurf.surface->absmin[1] ) { + edgeCode |= 8; + } + + if ( info->tSurf.surface->absmax[1] > info->sSurf.surface->absmax[1] && info->tSurf.surface->absmin[0] <= info->sSurf.surface->absmax[0] && info->tSurf.surface->absmax[0] >= info->sSurf.surface->absmin[0] ) { + edgeCode |= 1; + } + if ( info->tSurf.surface->absmin[0] < info->sSurf.surface->absmin[0] && info->tSurf.surface->absmin[1] <= info->sSurf.surface->absmax[1] && info->tSurf.surface->absmax[1] >= info->sSurf.surface->absmin[1] ) { + edgeCode |= 2; + } + if ( info->tSurf.surface->absmax[0] > info->sSurf.surface->absmax[0] && info->tSurf.surface->absmin[1] <= info->sSurf.surface->absmax[1] && info->tSurf.surface->absmax[1] >= info->sSurf.surface->absmin[1] ) { + edgeCode |= 4; + } + if ( info->tSurf.surface->absmin[1] < info->sSurf.surface->absmin[1] && info->tSurf.surface->absmin[0] <= info->sSurf.surface->absmax[0] && info->tSurf.surface->absmax[0] >= info->sSurf.surface->absmin[0] ) { + edgeCode |= 8; + } + + if ( edgeCode == 0 ) { + gi.Printf( "bad edgeCode\n" ); + return; + } + + // get coordinates for corners + xStart = info->sSurf.surface->absmin[0]; + xEnd = info->sSurf.surface->absmax[0]; + yStart = info->sSurf.surface->absmin[1]; + yEnd = info->sSurf.surface->absmax[1]; + z = info->sSurf.surface->origin[2]; + + // run through the spots on the relevant edges + // for each spot, see if the target surface is reachable from there + info->tSurf.edgeActive = qfalse; + + if ( edgeCode & 1 ) { + for ( x = xStart; x <= xEnd; x += XY_STEP ) { + VectorSet( spot, x, yEnd, z ); + reachable = CanReach( info, spot, testDir[0], &flags ); + EdgeUpdate( info, reachable, spot, flags ); + } + } + if ( info->tSurf.edgeActive ) { + EdgeClose( info ); + } + + if ( edgeCode & 2 ) { + for ( y = yStart; y <= yEnd; y += XY_STEP ) { + VectorSet( spot, xStart, y, z ); + reachable = CanReach( info, spot, testDir[1], &flags ); + EdgeUpdate( info, reachable, spot, flags ); + } + } + if ( info->tSurf.edgeActive ) { + EdgeClose( info ); + } + + if ( edgeCode & 4 ) { + for ( y = yStart; y <= yEnd; y += XY_STEP ) { + VectorSet( spot, xEnd, y, z ); + reachable = CanReach( info, spot, testDir[3], &flags ); + EdgeUpdate( info, reachable, spot, flags ); + } + } + if ( info->tSurf.edgeActive ) { + EdgeClose( info ); + } + + if ( edgeCode & 8 ) { + for ( x = xStart; x <= xEnd; x += XY_STEP ) { + VectorSet( spot, x, yStart, z ); + reachable = CanReach( info, spot, testDir[2], &flags ); + EdgeUpdate( info, reachable, spot, flags ); + } + } + if ( info->tSurf.edgeActive ) { + EdgeClose( info ); + } + + // special checks for corners + if ( ( edgeCode & 3 ) == 3 ) { + VectorSet( spot, xStart, yEnd, z ); + reachable = CanReach( info, spot, testDir[4], &flags ); + EdgeUpdate( info, reachable, spot, flags ); + } + if ( info->tSurf.edgeActive ) { + EdgeClose( info ); + } + + if ( ( edgeCode & 5 ) == 5 ) { + VectorSet( spot, xEnd, yEnd, z ); + reachable = CanReach( info, spot, testDir[5], &flags ); + EdgeUpdate( info, reachable, spot, flags ); + } + if ( info->tSurf.edgeActive ) { + EdgeClose( info ); + } + + if ( ( edgeCode & 10 ) == 10 ) { + VectorSet( spot, xStart, yStart, z ); + reachable = CanReach( info, spot, testDir[6], &flags ); + EdgeUpdate( info, reachable, spot, flags ); + } + if ( info->tSurf.edgeActive ) { + EdgeClose( info ); + } + + if ( ( edgeCode & 12 ) == 12 ) { + VectorSet( spot, xEnd, yStart, z ); + reachable = CanReach( info, spot, testDir[7], &flags ); + EdgeUpdate( info, reachable, spot, flags ); + } + if ( info->tSurf.edgeActive ) { + EdgeClose( info ); + } +} + + +static void TestReachSurface_Push( surfaceThreadInfo_t *info, gentity_t *pushEnt ) { + int flags; + int destSurf; + + //Q3MAP we will need to calculate movedir the same way the game dll does + + destSurf = FindDestination_Push( info, pushEnt, &flags ); + if ( destSurf == -1 ) { + gi.Printf( "pusher at %s never hit ground?\n", vtos( info->sSurf.surface->origin ) ); + } + else if ( destSurf != info->sSurf.number ) { + info->tSurf.number = destSurf; + info->tSurf.surface = &surface[destSurf]; + info->tSurf.edgeActive = qfalse; + EdgeUpdate( info, qtrue, info->sSurf.surface->origin, flags ); + EdgeClose( info ); + gi.Printf( "pusher at %s ", vtos( info->sSurf.surface->origin ) ); + gi.Printf( "hits surface at %s ", vtos( info->tSurf.surface->origin ) ); + gi.Printf( "(%i,%i)-(%i,%i)\n", (int)info->tSurf.surface->absmin[0], (int)info->tSurf.surface->absmin[1], (int)info->tSurf.surface->absmax[0], (int)info->tSurf.surface->absmax[1] ); + } + else { + gi.Printf( WARNING "bad pusher at %s\n", vtos( info->sSurf.surface->origin ) ); + } +} + + +static void TestReachSurface_Teleport( surfaceThreadInfo_t *info, gentity_t *teleportEnt ) { + int flags; + int destSurf; + + destSurf = FindDestination_Teleport( info, teleportEnt, &flags ); + if ( destSurf != -1 ) { + info->tSurf.number = destSurf; + info->tSurf.surface = &surface[destSurf]; + info->tSurf.edgeActive = qfalse; + EdgeUpdate( info, qtrue, info->sSurf.surface->origin, flags ); + EdgeClose( info ); + } +} + + +static void CreatePlatNeighbor( surfaceThreadInfo_t *info ) { +#if 0 + nneighbor_t *n; + gentity_t *ent; + + n = &info->sSurf.neighbor[info->sSurf.neighborCount]; + ent = &g_entities[info->tSurf.surface->parm]; + + n->surfaceNum = info->tSurf.number; + + n->absmin[0] = info->sSurf.surface->absmin[0] + 8; + n->absmin[1] = info->sSurf.surface->absmin[1] + 8; + + n->absmax[0] = info->sSurf.surface->absmax[0] - 8; + n->absmax[1] = info->sSurf.surface->absmax[1] - 8; + + VectorCopy( info->sSurf.surface->origin, n->origin ); + n->flags = NF_PLAT; + n->cost = ( ( ent->pos2[2] - ent->pos1[2] ) / (float)PLAYER_SPEED ) * 1000.0; + info->sSurf.neighborCount++; +#endif +} + + +static void FindSurfaceNeighbors( int surfaceNum ) { + int n; + int oldCount; + surfaceThreadInfo_t info; + gentity_t *ent; + + memset( &info, 0, sizeof( info ) ); + info.sSurf.number = surfaceNum; + info.sSurf.surface = &surface[surfaceNum]; + info.sSurf.neighborCount = 0; + + //FIXME we must handle special surface cases here - push, teleport + // they don't need to check every other surface, where player will wind + // up is predetermined (roughly at least) + + // teleporter special case + if ( info.sSurf.surface->flags & SF_TELEPORTER ) { + ent = &g_entities[info.sSurf.surface->parm]; + TestReachSurface_Teleport( &info, ent ); + goto updateGlobals; + } + + // trigger_push special case + if ( info.sSurf.surface->flags & SF_PUSH ) { + ent = &g_entities[info.sSurf.surface->parm]; + TestReachSurface_Push( &info, ent ); + goto updateGlobals; + } +#if 0 + // Q3MAP: reverse this + // if this is a PLATHIGH surface, we need to temporarily relink the plat to the high position + if ( info.sSurf.surface->flags & SF_PLATHIGH ) { + ent = &g_entities[info.sSurf.surface->parm]; + VectorCopy( ent->pos2, ent->s.origin ); + VectorCopy( ent->pos2, ent->currentOrigin ); + gi.linkentity( ent ); + } +#endif + for ( n = 0; n < surfaceCount; n++ ) { + if ( n == info.sSurf.number ) { + info.sStats.treject1++; + continue; + } + + info.tSurf.number = n; + info.tSurf.surface = &surface[n]; + + // plat high surfaces are a special case as a target + // only the corresponding plat low should have them as a neighbor + if ( info.tSurf.surface->flags & SF_PLATHIGH ) { + if ( info.sSurf.surface->flags & SF_PLATLOW ) { + CreatePlatNeighbor( &info ); + info.sStats.accept++; + } + continue; + } + + // reject if surf is too high to be reached + if ( ( info.tSurf.surface->origin[2] - info.sSurf.surface->origin[2] ) > MAX_JUMPHEIGHT ) { + info.sStats.treject2++; + continue; + } + + // reject is surf XY range is a subset of our own (meaning it is underneath us and not directly reachable) + if ( ( info.tSurf.surface->absmin[0] >= info.sSurf.surface->absmin[0] ) && ( info.tSurf.surface->absmin[1] >= info.sSurf.surface->absmin[1] ) && + ( info.tSurf.surface->absmax[0] <= info.sSurf.surface->absmax[0] ) && ( info.tSurf.surface->absmax[1] <= info.sSurf.surface->absmax[1] ) ) { + info.sStats.treject3++; + continue; + } + + // reject if surf origin is not in PVS + if ( !gi.inPVSIgnorePortals( info.tSurf.surface->origin, info.sSurf.surface->origin ) ) { + info.sStats.treject4++; + continue; + } + + // see if it's a neighbor + info.sStats.count++; + oldCount = info.sSurf.neighborCount; + TestReachSurface( &info ); + if ( info.sSurf.neighborCount != oldCount ) { + info.sStats.accept++; + } + else { + info.sStats.reject++; + } + } + +#if 0 + // Q3MAP: reverse this + // if this is a PLATHIGH surface, we need to restore the plat to the low position + if ( info.sSurf.surface->flags & SF_PLATHIGH ) { + ent = &g_entities[info.sSurf.surface->parm]; + VectorCopy( ent->pos1, ent->s.origin ); + VectorCopy( ent->pos1, ent->currentOrigin ); + gi.linkentity( ent ); + } +#endif + if ( neighborCount + info.sSurf.neighborCount > MAX_NEIGHBORS ) { + gi.Printf( "MAX_NEIGHBORS exceeded\n" ); + return; + } + +updateGlobals: + // grab the critical section lock to do global variable updates + ThreadLock(); + + // reserve the block of neighbors we need + surface[info.sSurf.number].neighborIndex = neighborCount; + neighborCount += info.sSurf.neighborCount; + + // update global stats + surfStats.count += info.sStats.count; + surfStats.accept += info.sStats.accept; + surfStats.reject += info.sStats.reject; + surfStats.treject1 += info.sStats.treject1; + surfStats.treject2 += info.sStats.treject2; + surfStats.treject3 += info.sStats.treject3; + surfStats.treject4 += info.sStats.treject4; + if ( info.sSurf.neighborCount == 0 ) { + surfStats.zeroNeighbors++; + } + + reachStats.count += info.rStats.count; + reachStats.accept += info.rStats.accept; + reachStats.reject1 += info.rStats.reject1; + reachStats.reject2 += info.rStats.reject2; + reachStats.reject3 += info.rStats.reject3; + reachStats.pmoveCount += info.rStats.pmoveCount; + + // release the lock + ThreadUnlock(); + + // now we can fill in the block of neighbors from our cache + surface[info.sSurf.number].neighborCount = info.sSurf.neighborCount; + if ( info.sSurf.neighborCount ) { + memcpy( &neighbor[surface[info.sSurf.number].neighborIndex], info.sSurf.neighbor, info.sSurf.neighborCount * sizeof( info.sSurf.neighbor[0] ) ); + } + +} + + +static void FindNeighbors( void ) { + int n; + + neighbor = ( nneighbor_t * )gi.TagMalloc ( MAX_NEIGHBORS * sizeof(neighbor[0]), TAG_GAME ); + neighborCount = 0; + + memset( &reachStats, 0, sizeof( reachStats ) ); + memset( &surfStats, 0, sizeof( surfStats ) ); + +// RunThreadsOn( spotIndexCount, qtrue, FindSurfaceNeighbors ); +//#if 0 + for ( n = 0; n < surfaceCount; n++ ) { + gi.DebugPrintf( "FindSurfaceNeighbors %d/%d\n", n, surfaceCount ); + FindSurfaceNeighbors( n ); + } +//#endif + + gi.Printf( " %i neighbors (avg %.2f per surf)\n", neighborCount, (float)neighborCount/(float)surfaceCount ); + gi.Printf( " %i surfaces with 0 neighbors\n", surfStats.zeroNeighbors ); + + gi.Printf( " surface to surface testing stats:\n" ); + gi.Printf( " %i combinations\n", surfaceCount * surfaceCount ); + gi.Printf( " %i trivial rejects (%i %i %i %i)\n", surfStats.treject1 + surfStats.treject2 + surfStats.treject3 + surfStats.treject4, surfStats.treject1, surfStats.treject2, surfStats.treject3, surfStats.treject4 ); + gi.Printf( " %i full tests (%.2f avg per surf)\n", surfStats.count, (float)surfStats.count / (float)surfaceCount ); + gi.Printf( " %i accepted, %i rejected\n", surfStats.accept, surfStats.reject ); + + gi.Printf( " spot to surface testing stats:\n" ); + gi.Printf( " %i tests (%.2f avg per surf)\n", reachStats.count, (float)reachStats.count / (float)surfaceCount ); + gi.Printf( " %i accepted, %i rejected (%i %i %i)\n", reachStats.accept, reachStats.reject1 + reachStats.reject2 + reachStats.reject3, reachStats.reject1, reachStats.reject2, reachStats.reject3 ); + gi.Printf( " %.2f avg pmoves per test\n", (float)reachStats.pmoveCount / (float)reachStats.count ); +} + + +// +// InflateSurfaces +// + +static void InflateSurfaces( void ) { + int n; + + // inflate surfaces by 16 along both axis + // also drop the Z value by mins + for ( n = 0; n < surfaceCount; n++ ) { + surface[n].absmin[0] -= 0; + surface[n].absmin[1] -= 0; + surface[n].absmax[0] += 0; + surface[n].absmax[1] += 0; + surface[n].origin[2] = floor( surface[n].origin[2] + mins[2] ); + } + + // inflate neighbor edges by 16 along the fixed axis + for ( n = 0; n < neighborCount; n++ ) { + if ( neighbor[n].absmin[0] == neighbor[n].absmax[0] ) { + neighbor[n].absmin[0] -= 0; + neighbor[n].absmax[0] += 0; + } + if ( neighbor[n].absmin[1] == neighbor[n].absmax[1] ) { + neighbor[n].absmin[1] -= 0; + neighbor[n].absmax[1] += 0; + } + neighbor[n].origin[2] = floor( neighbor[n].origin[2] + mins[2] ); + } +} + + +// +// CalculateAllRoutes +// + +typedef enum { + nodestate_estimate, + nodestate_final +} nodeState_t; + +typedef struct { + float cost; + nodeState_t state; + int predecessor; +} nodeInfo_t; + +static nodeInfo_t *nodeInfo; + + +static int NeighborIndex( int sourceSurfNum, int destSurfNum ) { + int base; + int n; + + if ( destSurfNum == -1 ) { + return -1; + } + base = surface[sourceSurfNum].neighborIndex; + for ( n = 0; n < surface[sourceSurfNum].neighborCount; n++ ) { + if ( neighbor[base+n].surfaceNum == destSurfNum ) { + return n; + } + } + return -1; +} + + +static nneighbor_t *PathEdge( int sourceSurfNum, int destSurfNum ) { + int base; + int n; + + base = surface[sourceSurfNum].neighborIndex; + for ( n = 0; n < surface[sourceSurfNum].neighborCount; n++ ) { + if ( neighbor[base+n].surfaceNum == destSurfNum ) { + return &neighbor[base+n]; + } + } + return NULL; +} + + +/* +============= +SurfaceDistance + +Returns the cost of moving from sourceSurfNum to targetSurfNum, 0 if there +is no direct path. +============= +*/ + +static float SurfaceDistance( int sourceSurfNum, int destSurfNum ) { + nneighbor_t *n; + + n = PathEdge( sourceSurfNum, destSurfNum ); + if ( n ) { + return n->cost; + } + return 0; +} + + +/* +============= +CalculateRoutes + +Takes the surfaces and neighbors tablea and uses Dijkstra's algorithm to +determine the shortest route from one surface to another. +============= +*/ + +static void CalculateRoutes( int rootSurfaceNum ) { + int n; + int currentNode; + int testNode; + float bestCost; + int bestNode; + float d; + + // initialize the node info + for ( n = 0; n < surfaceCount; n++ ) { + nodeInfo[n].cost = INFINITE; + nodeInfo[n].state = nodestate_estimate; + nodeInfo[n].predecessor = -1; + } + + // prime thing to get the loop started + currentNode = rootSurfaceNum; + nodeInfo[rootSurfaceNum].cost= 0; + + // calculate the shortest path info + // we loop surfaceCount times; a new final node is determined each iteration + n = 0; + while ( currentNode != -1 ) { + + bestCost = INFINITE; + bestNode = -1; + + // test each node + for ( testNode = 0; testNode < surfaceCount; testNode++ ) { + // do not test it against itself + if ( testNode == currentNode ) { + continue; + } + + // leave final nodes alone + if ( nodeInfo[testNode].state == nodestate_final ) { + continue; + } + + if ( surface[testNode].neighborCount == 0 ) { + continue; + } + + // update adjacent nodes + d = SurfaceDistance( currentNode, testNode ); + if ( d != 0 ) { + // see if we can improve the current estimate at the test node + if ( nodeInfo[currentNode].cost + d < nodeInfo[testNode].cost ) + { + nodeInfo[testNode].predecessor = currentNode; + nodeInfo[testNode].cost = nodeInfo[currentNode].cost + d; + } + } + + // see if this is our new best estimate + if ( nodeInfo[testNode].cost < bestCost ) { + bestCost = nodeInfo[testNode].cost; + bestNode = testNode; + } + } + + // mark current node as final and best node as new current node + nodeInfo[currentNode].state = nodestate_final; + currentNode = bestNode; + n++; + } + + // now fill in the route info + for ( n = 0; n < surfaceCount; n++ ) { + if ( n == rootSurfaceNum ) { + route[rootSurfaceNum * surfaceCount + n] = 255; + continue; + } + testNode = n; + while ( ( testNode != -1 ) && ( nodeInfo[testNode].predecessor != rootSurfaceNum ) ) { + testNode = nodeInfo[testNode].predecessor; + } + if ( testNode == -1 ) { + route[rootSurfaceNum * surfaceCount + n] = 255; + continue; + } + route[rootSurfaceNum * surfaceCount + n] = NeighborIndex( rootSurfaceNum, testNode ); + } +} + + +static void CalculateAllRoutes( void ) { + int n; + + route = ( byte * )gi.TagMalloc ( surfaceCount * surfaceCount * sizeof( byte ), TAG_GAME ); + nodeInfo = ( nodeInfo_t * )gi.TagMalloc ( surfaceCount * sizeof( nodeInfo[0] ), TAG_GAME ); + + for ( n = 0; n < surfaceCount; n++ ) { + CalculateRoutes( n ); + } + + gi.TagFree( nodeInfo ); +} + + + +// +// WriteNavigationData +// + +static void WriteNavigationData( void ) { + FILE *f; + int n; + navheader_t outHeader; + nsurface_t outSurface; + nneighbor_t outNeighbor; + str filename; + str osFilename; + + Swap_Init(); + + filename = str( "maps/" ) + level.mapname.c_str() + ".nav"; + gi.Printf( "Writing %s.\n", filename.c_str() ); + osFilename = gi.FS_PrepFileWrite( filename.c_str() ); + f = fopen( osFilename.c_str(), "wb" ); + if ( !f ) + { + gi.Printf( "Open failed.\n" ); + return; + } + + // write version header + outHeader.id = LittleLong( NAVFILE_ID ); + outHeader.version = LittleLong( NAVFILE_VERSION ); + outHeader.surfaceCount = LittleLong( surfaceCount ); + outHeader.neighborCount = LittleLong( neighborCount ); + fwrite( &outHeader, sizeof( outHeader ), 1, f ); + + // write surfaces + for ( n = 0; n < surfaceCount; n++ ) { + outSurface.origin[0] = LittleFloat( surface[n].origin[0] ); + outSurface.origin[1] = LittleFloat( surface[n].origin[1] ); + outSurface.origin[2] = LittleFloat( surface[n].origin[2] ); + + outSurface.absmin[0] = LittleFloat( surface[n].absmin[0] ); + outSurface.absmin[1] = LittleFloat( surface[n].absmin[1] ); + + outSurface.absmax[0] = LittleFloat( surface[n].absmax[0] ); + outSurface.absmax[1] = LittleFloat( surface[n].absmax[1] ); + + outSurface.flags = LittleLong( surface[n].flags ); + outSurface.neighborCount = LittleLong( surface[n].neighborCount ); + outSurface.neighborIndex = LittleLong( surface[n].neighborIndex ); + outSurface.parm = LittleLong( surface[n].parm ); + + fwrite( &outSurface, sizeof( outSurface ), 1, f ); + + gi.Printf( "surface%02i f=%04x n=%i@%i z=%i ", n, surface[n].flags, surface[n].neighborCount, surface[n].neighborIndex, (int)surface[n].origin[2] ); + gi.Printf( "(%i,%i)-(%i,%i)\n", (int)surface[n].absmin[0], (int)surface[n].absmin[1], (int)surface[n].absmax[0], (int)surface[n].absmax[1] ); + } + + // write neighbors + for ( n = 0; n < neighborCount; n++ ) { + outNeighbor.origin[0] = LittleFloat( neighbor[n].origin[0] ); + outNeighbor.origin[1] = LittleFloat( neighbor[n].origin[1] ); + outNeighbor.origin[2] = LittleFloat( neighbor[n].origin[2] ); + + outNeighbor.absmin[0] = LittleFloat( neighbor[n].absmin[0] ); + outNeighbor.absmin[1] = LittleFloat( neighbor[n].absmin[1] ); + + outNeighbor.absmax[0] = LittleFloat( neighbor[n].absmax[0] ); + outNeighbor.absmax[1] = LittleFloat( neighbor[n].absmax[1] ); + + outNeighbor.surfaceNum = LittleLong( neighbor[n].surfaceNum ); + outNeighbor.flags = LittleLong( neighbor[n].flags ); + outNeighbor.cost = LittleLong( neighbor[n].cost ); + outNeighbor.filler = LittleLong( neighbor[n].filler ); + + fwrite( &outNeighbor, sizeof( outNeighbor ), 1, f ); + + gi.Printf( "neighbor%03i f=%04x surface=%02i cost=%f\n", n, neighbor[n].flags, neighbor[n].surfaceNum, neighbor[n].cost ); + } + + // write routes + fwrite( route, surfaceCount * surfaceCount * sizeof( byte ), 1, f ); + + fclose( f ); +} + + +// +// Nav_Gen_f +// + +void Nav_Gen_f( void ) { + int start; + int elapsed; + int i; + gentity_t *ent; + + for( i = 0; i < globals.num_entities; i++ ) + { + ent = &g_entities[i]; + if ( ent->entity && ent->entity->isSubclassOf( Mover ) ) + { + ent->entity->unlink(); + } + } + + // FindSpots + gi.Printf( "FindSpots\n" ); + start = gi.Milliseconds(); + FindSpots(); + elapsed = gi.Milliseconds() - start; + gi.Printf( " %.2f seconds elapsed\n", (float)elapsed / 1000.0 ); + + // FindSurfaces + gi.Printf( "FindSurfaces\n" ); + start = gi.Milliseconds(); + //FindSurfaces(); + FindConvexSurfaces(); + elapsed = gi.Milliseconds() - start; + gi.Printf( " %.2f seconds elapsed\n", (float)elapsed / 1000.0 ); + + // FindNeighbors + gi.Printf( "FindNeighbors\n" ); + start = gi.Milliseconds(); + FindNeighbors(); + elapsed = gi.Milliseconds() - start; + gi.Printf( " %.2f seconds elapsed\n", (float)elapsed / 1000.0 ); + + // InflateSurfaces + gi.Printf( "InflateSurfaces\n" ); + start = gi.Milliseconds(); + InflateSurfaces(); + elapsed = gi.Milliseconds() - start; + gi.Printf( " %.2f seconds elapsed\n", (float)elapsed / 1000.0 ); + + // CalculateAllRoutes + gi.Printf( "CalculateAllRoutes\n" ); + start = gi.Milliseconds(); + CalculateAllRoutes(); + elapsed = gi.Milliseconds() - start; + gi.Printf( " %.2f seconds elapsed\n", (float)elapsed / 1000.0 ); + + // WriteNavigationData + start = gi.Milliseconds(); + WriteNavigationData(); + elapsed = gi.Milliseconds() - start; + gi.Printf( " %.2f seconds elapsed\n", (float)elapsed / 1000.0 ); + + gi.TagFree( route ); + gi.TagFree( neighbor ); + gi.TagFree( surface ); + + for( i = 0; i < globals.num_entities; i++ ) + { + ent = &g_entities[i]; + if ( ent->entity && ent->entity->isSubclassOf( Mover ) ) + { + ent->entity->link(); + } + } +} diff --git a/code/game/barrels.cpp b/code/game/barrels.cpp new file mode 100644 index 00000000..0dee679e --- /dev/null +++ b/code/game/barrels.cpp @@ -0,0 +1,607 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// barrels.cpp : Barrels + +#include "barrels.h" +#include "weaputils.h" + +/***************************************************************************** +/*QUAKED func_barrel (0 0.25 0.5) ? INDESTRUCTABLE +Brush model barrel object +Bashing only makes thunk or gong sounds (depending on wether it's full or not) +Bullets and explosions effects are dependant apon the type of barrel. +"barreltype" sets the type of barrel that it is. Valid settings are: +- "water" makes the barrel be filled with water. +Always non-volitile. Only destroyed by explosion. +- "oil" makes the barrel be filled with oil. +Leakes oil when shot (not destroyed), shower of flames when exploded. +- "gas" makes the barrel be filled with gas. +A few bullet hits will make it explode. +Explosions will also make it explode. +- "empty" makes the barrel completely empty. +Does nothing special at all. It's just a poor empty barrel. aww :( +******************************************************************************/ + +Event EV_Barrel_Think + ( + "_barrel_think", + EV_DEFAULT, + NULL, + NULL, + "think function for a barrel." + ); + +Event EV_Barrel_Setup + ( + "_barrel_setup", + EV_DEFAULT, + NULL, + NULL, + "Does the post spawn setup of the barrel" + ); + +Event EV_Barrel_SetType + ( + "barreltype", + EV_DEFAULT, + "s", + "type", + "Sets the barrel's type" + ); + +CLASS_DECLARATION( Entity, BarrelObject, "func_barrel" ) +{ + { &EV_Barrel_Setup, &BarrelObject::BarrelSetup }, + { &EV_Barrel_Think, &BarrelObject::BarrelThink }, + { &EV_Barrel_SetType, &BarrelObject::BarrelSetType }, + { &EV_Damage, &BarrelObject::BarrelDamaged }, + { &EV_Killed, &BarrelObject::BarrelKilled }, + { NULL, NULL } +}; + +BarrelObject::BarrelObject() +{ + if( LoadingSavegame ) + { + return; + } + + edict->s.eType = ET_GENERAL; + + m_iBarrelType = 0; + m_fFluidAmount = 0; + m_fHeightFluid = 0; + + for( int i = 0; i < MAX_BARREL_LEAKS; i++ ) + { + m_bLeaksActive[ i ] = 0; + } + + m_fDamageSoundTime = 0; + mass = 500; + max_health = 75; + health = 75; + deadflag = DEAD_NO; + takedamage = DAMAGE_YES; + m_vJitterAngles = vec_zero; + + PostEvent( EV_Barrel_Setup, EV_POSTSPAWN ); +} + +int BarrelObject::PickBarrelLeak + ( + void + ) + +{ + int iHighest; + float fHighestHeight; + + for( int i = 0; i < MAX_BARREL_LEAKS; i++ ) + { + if( !m_bLeaksActive[ i ] ) { + return i; + } + } + + fHighestHeight = m_vLeaks[ 0 ][ 2 ]; + iHighest = 0; + + for( int i = 1; i < MAX_BARREL_LEAKS; i++ ) + { + if( m_vLeaks[ 0 ][ 2 ] > fHighestHeight ) + { + fHighestHeight = m_vLeaks[ 0 ][ 2 ]; + iHighest = i; + } + } + + return iHighest; +} + +void BarrelObject::BarrelSetup + ( + Event *ev + ) + +{ + setMoveType( MOVETYPE_PUSH ); + setSolidType( SOLID_BSP ); + + m_vStartAngles = angles; + m_fJitterScale = 64.0f / size[ 2 ]; + + m_fFluidAmount = size[ 0 ] * size[ 1 ] * size[ 2 ] / 150.0f; + m_fHeightFluid = m_fFluidAmount / size[ 2 ]; + + // Position the barrel correctly + CheckGround(); +} + +void BarrelObject::BarrelSetType + ( + Event *ev + ) + +{ + str sType = ev->GetString( 1 ); + + if( !sType.icmp( "oil" ) ) + { + health = 75; + m_iBarrelType = BARREL_OIL; + + CacheResource( "models/fx/barrel_empty_destroyed.tik" ); + CacheResource( "models/fx/barrel_oil_destroyed.tik" ); + } + else if( !sType.icmp( "water" ) ) + { + health = 75; + m_iBarrelType = BARREL_WATER; + + CacheResource( "models/fx/barrel_empty_destroyed.tik" ); + CacheResource( "models/fx/barrel_water_destroyed.tik" ); + } + else if( !sType.icmp( "gas" ) ) + { + spawnflags &= ~BARREL_INDESTRUCTABLE; + health = 75; + m_iBarrelType = BARREL_GAS; + + CacheResource( "models/fx/barrel_gas_destroyed.tik" ); + } + else + { + health = 75; + m_iBarrelType = BARREL_EMPTY; + + CacheResource( "models/fx/barrel_empty_destroyed.tik" ); + } + + max_health = health; +} + +void BarrelObject::BarrelThink + ( + Event *ev + ) + +{ + int i; + int iBiggestLeak; + float fFluidTop; + + iBiggestLeak = 0; + + fFluidTop = m_fFluidAmount / m_fHeightFluid + ( mins[ 2 ] + origin[ 2 ] ); + for( i = 0; i < MAX_BARREL_LEAKS; i++ ) + { + if( !m_bLeaksActive[ i ] ) { + continue; + } + + // Send infos to clients + if( m_vLeaks[ i ][ 2 ] <= fFluidTop ) + { + gi.SetBroadcastVisible( m_vLeaks[ i ], m_vLeaks[ i ] ); + + if( m_vLeaks[ i ][ 2 ] <= fFluidTop - 1.3f ) + { + if( m_vLeaks[ i ][ 2 ] <= fFluidTop - 3.0f ) + { + // big leak + + if( m_iBarrelType == BARREL_OIL ) + { + gi.MSG_StartCGM( 15 ); + } + else + { + gi.MSG_StartCGM( 19 ); + } + + m_fFluidAmount -= 1.0f; + iBiggestLeak |= 4; + } + else + { + // medium leak + + if( m_iBarrelType == BARREL_OIL ) + { + gi.MSG_StartCGM( 16 ); + } + else + { + gi.MSG_StartCGM( 20 ); + } + + m_fFluidAmount -= 0.75f; + iBiggestLeak |= 2; + } + } + else + { + // small leak + + if( m_iBarrelType == BARREL_OIL ) + { + gi.MSG_StartCGM( 17 ); + } + else + { + gi.MSG_StartCGM( 21 ); + } + + m_fFluidAmount -= 0.5f; + iBiggestLeak |= 1; + } + + gi.MSG_WriteCoord( m_vLeaks[ i ][ 0 ] ); + gi.MSG_WriteCoord( m_vLeaks[ i ][ 1 ] ); + gi.MSG_WriteCoord( m_vLeaks[ i ][ 2 ] ); + gi.MSG_WriteDir( m_vLeakNorms[ i ] ); + gi.MSG_EndCGM(); + } + else + { + gi.SetBroadcastVisible( m_vLeaks[ i ], m_vLeaks[ i ] ); + + if( m_iBarrelType == BARREL_OIL ) + { + gi.MSG_StartCGM( 17 ); + } + else + { + gi.MSG_StartCGM( 21 ); + } + + gi.MSG_WriteCoord( m_vLeaks[ i ][ 0 ] ); + gi.MSG_WriteCoord( m_vLeaks[ i ][ 1 ] ); + gi.MSG_WriteCoord( m_vLeaks[ i ][ 2 ] ); + gi.MSG_WriteDir( m_vLeakNorms[ i ] ); + gi.MSG_EndCGM(); + + m_bLeaksActive[ i ] = qfalse; + } + } + + if( m_vJitterAngles[ 0 ] == 0.0f && m_vJitterAngles[ 2 ] == 0.0f ) + { + if( !VectorCompare( angles, m_vStartAngles ) ) + { + setAngles( m_vStartAngles ); + } + } + + setAngles( Vector( m_vStartAngles[ 0 ] + m_vJitterAngles[ 0 ], m_vStartAngles[ 1 ], m_vStartAngles[ 2 ] + m_vJitterAngles[ 2 ] ) ); + + if( m_vJitterAngles[ 0 ] > 0.0f ) + { + m_vJitterAngles[ 0 ] -= 1 / 3 * m_fJitterScale; + + if( m_vJitterAngles[ 0 ] > 0.0f ) + { + m_vJitterAngles[ 0 ] = 0.0f; + } + } + else if( m_vJitterAngles[ 0 ] < 0.0f ) + { + m_vJitterAngles[ 0 ] += 1 / 3 * m_fJitterScale; + + if( m_vJitterAngles[ 0 ] < 0.0f ) + { + m_vJitterAngles[ 0 ] = 0.0f; + } + } + + m_vJitterAngles[ 0 ] = -m_vJitterAngles[ 0 ]; + + if( m_vJitterAngles[ 2 ] > 0.0f ) + { + m_vJitterAngles[ 2 ] -= 1 / 3 * m_fJitterScale; + + if( m_vJitterAngles[ 2 ] > 0.0f ) + { + m_vJitterAngles[ 2 ] = 0.0f; + } + } + else if( m_vJitterAngles[ 2 ] < 0.0f ) + { + m_vJitterAngles[ 2 ] += 1 / 3 * m_fJitterScale; + + if( m_vJitterAngles[ 2 ] < 0.0f ) + { + m_vJitterAngles[ 2 ] = 0.0f; + } + } + + m_vJitterAngles[ 2 ] = -m_vJitterAngles[ 2 ]; + + // Check for at least one active leak to play a sound + for( i = 0; i < MAX_BARREL_LEAKS; i++ ) + { + if( m_bLeaksActive[ i ] ) { + break; + } + } + + // Play a leak sound + if( i != MAX_BARREL_LEAKS && iBiggestLeak ) + { + if( !( iBiggestLeak & 4 ) ) + { + if( iBiggestLeak & 2 ) + { + // medium leak + LoopSound( "liquid_leak", 0.60f, -1.0f, -1.0f, 0.90f ); + } + else + { + // small leak + LoopSound( "liquid_leak", 0.30f, -1.0f, -1.0f, 0.80f ); + } + } + else + { + // big leak + LoopSound( "liquid_leak", 1.0f, -1.0f, -1.0f, 1.0f ); + } + } + + if( i == MAX_BARREL_LEAKS ) { + StopLoopSound(); + } + + if( m_vJitterAngles[ 0 ] || m_vJitterAngles[ 2 ] || i < MAX_BARREL_LEAKS ) + { + m_fLastEffectTime += 0.075f; + + if( level.time >= m_fLastEffectTime ) + { + m_fLastEffectTime = level.time + 0.075f; + } + + PostEvent( EV_Barrel_Think, m_fLastEffectTime - level.time ); + } +} + +void BarrelObject::BarrelDamaged + ( + Event *ev + ) + +{ + Vector vDir; + Vector vForward; + Vector vRight; + int iDamage; + int iMeansOfDeath; + Vector vHitPos; + Vector vHitDirection; + Vector vHitNormal; + + if( !takedamage ) + { + return; + } + + iDamage = ev->GetInteger( 2 ); + iMeansOfDeath = ev->GetInteger( 9 ); + vHitPos = ev->GetVector( 4 ); + vHitDirection = ev->GetVector( 5 ); + vHitNormal = ev->GetVector( 6 ); + + vDir = ( vHitDirection - vHitNormal ) * 0.5f; + AngleVectors( angles, vForward, vRight, NULL ); + + m_vJitterAngles[ 0 ] += DotProduct( vDir, vForward ) * m_fJitterScale * 0.0275f * ( float )iDamage; + m_vJitterAngles[ 2 ] += DotProduct( vDir, vRight ) * m_fJitterScale * 0.0275f * ( float )iDamage; + + if( m_vJitterAngles[ 0 ] > m_fJitterScale * 1.5f ) + { + m_vJitterAngles[ 0 ] = m_fJitterScale * 1.5f; + } + else if( m_vJitterAngles[ 0 ] < -( m_fJitterScale * 1.5f ) ) + { + m_vJitterAngles[ 0 ] = -( m_fJitterScale * 1.5f ); + } + + if( m_vJitterAngles[ 2 ] > m_fJitterScale * 1.5f ) + { + m_vJitterAngles[ 2 ] = m_fJitterScale * 1.5f; + } + else if( m_vJitterAngles[ 2 ] < -( m_fJitterScale * 1.5f ) ) + { + m_vJitterAngles[ 2 ] = -( m_fJitterScale * 1.5f ); + } + + if( !( spawnflags & BARREL_INDESTRUCTABLE ) ) + { + if( ( iMeansOfDeath == MOD_VEHICLE || iMeansOfDeath == MOD_ROCKET || + iMeansOfDeath == MOD_GRENADE || iMeansOfDeath == MOD_EXPLODEWALL || + iMeansOfDeath == MOD_EXPLOSION || m_iBarrelType == BARREL_GAS ) && + iMeansOfDeath != MOD_BASH + ) + { + if( iDamage >= health ) + { + PostEvent( EV_Killed, 0.01f ); + takedamage = DAMAGE_NO; + return; + } + + if( m_iBarrelType == BARREL_GAS ) + { + iDamage /= 2; + + health -= iDamage; + if( health < 1.0f ) + health = 1.0f; + } + } + } + + if( !EventPending( EV_Barrel_Think ) ) + { + m_fLastEffectTime = level.time - 0.075f; + ProcessEvent( EV_Barrel_Think ); + } + + if( m_iBarrelType <= BARREL_WATER ) + { + int index = PickBarrelLeak(); + + if( vHitPos[ 2 ] <= m_fFluidAmount / m_fHeightFluid + origin[ 2 ] + mins[ 2 ] ) + { + m_bLeaksActive[ index ] = qtrue; + m_vLeaks[ index ] = vHitPos; + m_vLeakNorms[ index ] = vHitNormal; + + gi.SetBroadcastVisible( vHitPos, vHitPos ); + + if( m_iBarrelType == BARREL_OIL ) + gi.MSG_StartCGM( 18 ); + else + gi.MSG_StartCGM( 22 ); + } + else + { + gi.SetBroadcastVisible( vHitPos, vHitPos ); + + if( m_iBarrelType == BARREL_OIL ) + gi.MSG_StartCGM( 17 ); + else + gi.MSG_StartCGM( 21 ); + } + + gi.MSG_WriteCoord( vHitPos[ 0 ] ); + gi.MSG_WriteCoord( vHitPos[ 1 ] ); + gi.MSG_WriteCoord( vHitPos[ 2 ] ); + gi.MSG_WriteDir( vHitNormal ); + gi.MSG_EndCGM(); + } +} + +void BarrelObject::BarrelKilled + ( + Event *ev + ) + +{ + float fFluidTop; + Vector vPos; + str sModel; + + setSolidType( SOLID_NOT ); + PostEvent( EV_Remove, 0.05f ); + + vPos[ 2 ] = ( mins[ 2 ] + origin[ 2 ] ); + fFluidTop = m_fFluidAmount / m_fHeightFluid + vPos[ 2 ]; + + if( m_iBarrelType == BARREL_GAS ) + { + RadiusDamage( + centroid, + this, + this, + 200, + this, + MOD_EXPLOSION, + 350, + 24 ); + + sModel = "models/fx/barrel_gas_destroyed.tik"; + } + else if( m_iBarrelType == BARREL_WATER ) + { + if( vPos[ 2 ] + 0.25f * maxs[ 2 ] <= fFluidTop ) + { + sModel = "models/fx/barrel_water_destroyed.tik"; + } + else + { + sModel = "models/fx/barrel_empty_destroyed.tik"; + } + } + else if( m_iBarrelType == BARREL_OIL ) + { + if( vPos[ 2 ] + 0.25f * maxs[ 2 ] > fFluidTop ) + { + sModel = "models/fx/barrel_empty_destroyed.tik"; + } + else + { + RadiusDamage( + centroid, + this, + this, + 200, + this, + MOD_EXPLOSION, + 350, + 24 ); + + sModel = "models/fx/barrel_oil_destroyed.tik"; + } + } + else + { + sModel = "models/fx/barrel_empty_destroyed.tik"; + } + + Animate *exp = new Animate; + + // Spawn an explosion effect + exp->edict->s.renderfx |= RF_DONTDRAW; + exp->setModel( sModel ); + + vPos = origin + ( maxs + mins ) * 0.5f; + + exp->setAngles( Vector( -90, 0, 0 ) ); + exp->setOrigin( vPos ); + exp->NewAnim( "idle" ); + + exp->PostEvent( EV_Remove, 0.1f ); + exp->Unregister( STRING_DEATH ); +} diff --git a/code/game/barrels.h b/code/game/barrels.h new file mode 100644 index 00000000..647c650a --- /dev/null +++ b/code/game/barrels.h @@ -0,0 +1,95 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// barrels.h : Barrels + +#ifndef __BARRELOBJECT_H__ +#define __BARRELOBJECT_H__ + +#include "entity.h" + +#define BARREL_INDESTRUCTABLE 1 +#define MAX_BARREL_LEAKS 4 + +enum +{ + BARREL_EMPTY, + BARREL_OIL, + BARREL_WATER, + BARREL_GAS +}; + +class BarrelObject : public Entity { + int m_iBarrelType; + float m_fFluidAmount; + float m_fHeightFluid; + qboolean m_bLeaksActive[ MAX_BARREL_LEAKS ]; + Vector m_vLeaks[ MAX_BARREL_LEAKS ]; + Vector m_vLeakNorms[ MAX_BARREL_LEAKS ]; + Vector m_vJitterAngles; + Vector m_vStartAngles; + float m_fJitterScale; + float m_fLastEffectTime; + float m_fDamageSoundTime; + +public: + CLASS_PROTOTYPE( BarrelObject ); + + BarrelObject(); + + int PickBarrelLeak( void ); + + void BarrelSetup( Event *ev ); + void BarrelSetType( Event *ev ); + void BarrelThink( Event *ev ); + void BarrelDamaged( Event *ev ); + void BarrelKilled( Event *ev ); + + virtual void Archive( Archiver& arc ); +}; + +inline void BarrelObject::Archive + ( + Archiver& arc + ) + +{ + Entity::Archive( arc ); + + arc.ArchiveInteger( &m_iBarrelType ); + arc.ArchiveFloat( &m_fFluidAmount ); + arc.ArchiveFloat( &m_fHeightFluid ); + arc.ArchiveVector( &m_vJitterAngles ); + arc.ArchiveVector( &m_vStartAngles ); + arc.ArchiveFloat( &m_fJitterScale ); + arc.ArchiveFloat( &m_fLastEffectTime ); + arc.ArchiveFloat( &m_fDamageSoundTime ); + + for( int i = MAX_BARREL_LEAKS - 1; i >= 0; i-- ) + { + arc.ArchiveBoolean( &m_bLeaksActive[ i ] ); + arc.ArchiveVector( &m_vLeaks[ i ] ); + arc.ArchiveVector( &m_vLeakNorms[ i ] ); + } +} + +#endif // __BARRELOBJECT_H__ diff --git a/code/game/be_aas.h b/code/game/be_aas.h new file mode 100644 index 00000000..b46d3051 --- /dev/null +++ b/code/game/be_aas.h @@ -0,0 +1,210 @@ +// Copyright (C) 1999-2000 Id Software, Inc. +// + +/***************************************************************************** + * name: be_aas.h + * + * desc: Area Awareness System, stuff exported to the AI + * + * $Archive: /Code/DLLs/game/be_aas.h $ + * $Author: Steven $ + * $Revision: 2 $ + * $Modtime: 10/13/03 9:01a $ + * $Date: 10/13/03 9:11a $ + * + *****************************************************************************/ + +#ifndef MAX_STRINGFIELD +#define MAX_STRINGFIELD 80 +#endif + +//travel flags +#define TFL_INVALID 0x00000001 //traveling temporary not possible +#define TFL_WALK 0x00000002 //walking +#define TFL_CROUCH 0x00000004 //crouching +#define TFL_BARRIERJUMP 0x00000008 //jumping onto a barrier +#define TFL_JUMP 0x00000010 //jumping +#define TFL_LADDER 0x00000020 //climbing a ladder +#define TFL_WALKOFFLEDGE 0x00000080 //walking of a ledge +#define TFL_SWIM 0x00000100 //swimming +#define TFL_WATERJUMP 0x00000200 //jumping out of the water +#define TFL_TELEPORT 0x00000400 //teleporting +#define TFL_ELEVATOR 0x00000800 //elevator +#define TFL_ROCKETJUMP 0x00001000 //rocket jumping +#define TFL_BFGJUMP 0x00002000 //bfg jumping +#define TFL_GRAPPLEHOOK 0x00004000 //grappling hook +#define TFL_DOUBLEJUMP 0x00008000 //double jump +#define TFL_RAMPJUMP 0x00010000 //ramp jump +#define TFL_STRAFEJUMP 0x00020000 //strafe jump +#define TFL_JUMPPAD 0x00040000 //jump pad +#define TFL_AIR 0x00080000 //travel through air +#define TFL_WATER 0x00100000 //travel through water +#define TFL_SLIME 0x00200000 //travel through slime +#define TFL_LAVA 0x00400000 //travel through lava +#define TFL_DONOTENTER 0x00800000 //travel through donotenter area +#define TFL_FUNCBOB 0x01000000 //func bobbing +#define TFL_FLIGHT 0x02000000 //flight +#define TFL_BRIDGE 0x04000000 //move over a bridge +// +#define TFL_NOTTEAM1 0x08000000 //not team 1 +#define TFL_NOTTEAM2 0x10000000 //not team 2 + +//default travel flags +#define TFL_DEFAULT TFL_WALK|TFL_CROUCH|TFL_BARRIERJUMP|\ + TFL_JUMP|TFL_LADDER|\ + TFL_WALKOFFLEDGE|TFL_SWIM|TFL_WATERJUMP|\ + TFL_TELEPORT|TFL_ELEVATOR|\ + TFL_AIR|TFL_WATER|TFL_JUMPPAD|TFL_FUNCBOB + +// already defined in g_public.h in tiki tech, moved to l_util.h so the botlib stuff compiles but the gamecode also compiles +/* +typedef enum +{ + SOLID_NOT, // no interaction with other objects + SOLID_TRIGGER, // only touch when inside, after moving + SOLID_BBOX, // touch on edge + SOLID_BSP // bsp clip, touch on edge +} solid_t; +*/ + +//a trace is returned when a box is swept through the AAS world +typedef struct aas_trace_s +{ + qboolean startsolid; // if true, the initial point was in a solid area + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + int ent; // entity blocking the trace + int lastarea; // last area the trace was in (zero if none) + int area; // area blocking the trace (zero if none) + int planenum; // number of the plane that was hit +} aas_trace_t; + +// Defined in botlib.h + +//bsp_trace_t hit surface +/* +typedef struct bsp_surface_s +{ + char name[16]; + int flags; + int value; +} bsp_surface_t; + +//a trace is returned when a box is swept through the BSP world +typedef struct bsp_trace_s +{ + qboolean allsolid; // if true, plane is not valid + qboolean startsolid; // if true, the initial point was in a solid area + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + cplane_t plane; // surface normal at impact + float exp_dist; // expanded plane distance + int sidenum; // number of the brush side hit + bsp_surface_t surface; // hit surface + int contents; // contents on other side of surface hit + int ent; // number of entity hit +} bsp_trace_t; +*/ +// + + +//entity info +typedef struct aas_entityinfo_s +{ + int valid; // true if updated this frame + int type; // entity type + int flags; // entity flags + float ltime; // local time + float update_time; // time between last and current update + int number; // number of the entity + vec3_t origin; // origin of the entity + vec3_t angles; // angles of the model + vec3_t old_origin; // for lerping + vec3_t lastvisorigin; // last visible origin + vec3_t mins; // bounding box minimums + vec3_t maxs; // bounding box maximums + int groundent; // ground entity + int solid; // solid type + int modelindex; // model used + int modelindex2; // weapons, CTF flags, etc + int frame; // model frame number + int event; // impulse events -- muzzle flashes, footsteps, etc + int eventParm; // even parameter + int powerups; // bit flags + int weapon; // determines weapon and flash model, etc + int legsAnim; // mask off ANIM_TOGGLEBIT + int torsoAnim; // mask off ANIM_TOGGLEBIT +} aas_entityinfo_t; + +// area info +typedef struct aas_areainfo_s +{ + int contents; + int flags; + int presencetype; + int cluster; + vec3_t mins; + vec3_t maxs; + vec3_t center; +} aas_areainfo_t; + +// client movement prediction stop events, stop as soon as: +#define SE_NONE 0 +#define SE_HITGROUND 1 // the ground is hit +#define SE_LEAVEGROUND 2 // there's no ground +#define SE_ENTERWATER 4 // water is entered +#define SE_ENTERSLIME 8 // slime is entered +#define SE_ENTERLAVA 16 // lava is entered +#define SE_HITGROUNDDAMAGE 32 // the ground is hit with damage +#define SE_GAP 64 // there's a gap +#define SE_TOUCHJUMPPAD 128 // touching a jump pad area +#define SE_TOUCHTELEPORTER 256 // touching teleporter +#define SE_ENTERAREA 512 // the given stoparea is entered +#define SE_HITGROUNDAREA 1024 // a ground face in the area is hit +#define SE_HITBOUNDINGBOX 2048 // hit the specified bounding box +#define SE_TOUCHCLUSTERPORTAL 4096 // touching a cluster portal + +typedef struct aas_clientmove_s +{ + vec3_t endpos; //position at the end of movement prediction + int endarea; //area at end of movement prediction + vec3_t velocity; //velocity at the end of movement prediction + aas_trace_t trace; //last trace + int presencetype; //presence type at end of movement prediction + int stopevent; //event that made the prediction stop + int endcontents; //contents at the end of movement prediction + float time; //time predicted ahead + int frames; //number of frames predicted ahead +} aas_clientmove_t; + +// alternate route goals +#define ALTROUTEGOAL_ALL 1 +#define ALTROUTEGOAL_CLUSTERPORTALS 2 +#define ALTROUTEGOAL_VIEWPORTALS 4 + +typedef struct aas_altroutegoal_s +{ + vec3_t origin; + int areanum; + unsigned short starttraveltime; + unsigned short goaltraveltime; + unsigned short extratraveltime; +} aas_altroutegoal_t; + +// route prediction stop events +#define RSE_NONE 0 +#define RSE_NOROUTE 1 //no route to goal +#define RSE_USETRAVELTYPE 2 //stop as soon as on of the given travel types is used +#define RSE_ENTERCONTENTS 4 //stop when entering the given contents +#define RSE_ENTERAREA 8 //stop when entering the given area + +typedef struct aas_predictroute_s +{ + vec3_t endpos; //position at the end of movement prediction + int endarea; //area at end of movement prediction + int stopevent; //event that made the prediction stop + int endcontents; //contents at the end of movement prediction + int endtravelflags; //end travel flags + int numareas; //number of areas predicted ahead + int time; //time predicted ahead (in hundreth of a sec) +} aas_predictroute_t; diff --git a/code/game/be_ai_char.h b/code/game/be_ai_char.h new file mode 100644 index 00000000..b28801b8 --- /dev/null +++ b/code/game/be_ai_char.h @@ -0,0 +1,32 @@ +// Copyright (C) 1999-2000 Id Software, Inc. +// + +/***************************************************************************** + * name: be_ai_char.h + * + * desc: bot characters + * + * $Archive: /Code/DLLs/game/be_ai_char.h $ + * $Author: Jwaters $ + * $Revision: 1 $ + * $Modtime: 5/17/02 11:35a $ + * $Date: 7/31/02 10:45a $ + * + *****************************************************************************/ + +//loads a bot character from a file +int BotLoadCharacter(char *charfile, float skill); +//frees a bot character +void BotFreeCharacter(int character); +//returns a float characteristic +float Characteristic_Float(int character, int index); +//returns a bounded float characteristic +float Characteristic_BFloat(int character, int index, float min, float max); +//returns an integer characteristic +int Characteristic_Integer(int character, int index); +//returns a bounded integer characteristic +int Characteristic_BInteger(int character, int index, int min, int max); +//returns a string characteristic +void Characteristic_String(int character, int index, char *buf, int size); +//free cached bot characters +void BotShutdownCharacters(void); diff --git a/code/game/be_ai_chat.h b/code/game/be_ai_chat.h new file mode 100644 index 00000000..13f9894d --- /dev/null +++ b/code/game/be_ai_chat.h @@ -0,0 +1,97 @@ +// Copyright (C) 1999-2000 Id Software, Inc. +// +/***************************************************************************** + * name: be_ai_chat.h + * + * desc: char AI + * + * $Archive: /Code/DLLs/game/be_ai_chat.h $ + * $Author: Jwaters $ + * $Revision: 1 $ + * $Modtime: 5/17/02 11:35a $ + * $Date: 7/31/02 10:45a $ + * + *****************************************************************************/ + +#define MAX_MESSAGE_SIZE 256 +#define MAX_CHATTYPE_NAME 32 +#define MAX_MATCHVARIABLES 8 + +#define CHAT_GENDERLESS 0 +#define CHAT_GENDERFEMALE 1 +#define CHAT_GENDERMALE 2 + +#define CHAT_ALL 0 +#define CHAT_TEAM 1 +#define CHAT_TELL 2 + +//a console message +typedef struct bot_consolemessage_s +{ + int handle; + float time; //message time + int type; //message type + char message[MAX_MESSAGE_SIZE]; //message + struct bot_consolemessage_s *prev, *next; //prev and next in list +} bot_consolemessage_t; + +//match variable +typedef struct bot_matchvariable_s +{ + char offset; + int length; +} bot_matchvariable_t; +//returned to AI when a match is found +typedef struct bot_match_s +{ + char string[MAX_MESSAGE_SIZE]; + int type; + int subtype; + bot_matchvariable_t variables[MAX_MATCHVARIABLES]; +} bot_match_t; + +//setup the chat AI +int BotSetupChatAI(void); +//shutdown the chat AI +void BotShutdownChatAI(void); +//returns the handle to a newly allocated chat state +int BotAllocChatState(void); +//frees the chatstate +void BotFreeChatState(int handle); +//adds a console message to the chat state +void BotQueueConsoleMessage(int chatstate, int type, char *message); +//removes the console message from the chat state +void BotRemoveConsoleMessage(int chatstate, int handle); +//returns the next console message from the state +int BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm); +//returns the number of console messages currently stored in the state +int BotNumConsoleMessages(int chatstate); +//selects a chat message of the given type +void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); +//returns the number of initial chat messages of the given type +int BotNumInitialChats(int chatstate, char *type); +//find and select a reply for the given message +int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); +//returns the length of the currently selected chat message +int BotChatLength(int chatstate); +//enters the selected chat message +void BotEnterChat(int chatstate, int clientto, int sendto); +//get the chat message ready to be output +void BotGetChatMessage(int chatstate, char *buf, int size); +//checks if the first string contains the second one, returns index into first string or -1 if not found +int StringContains(char *str1, char *str2, int casesensitive); +//finds a match for the given string using the match templates +int BotFindMatch(char *str, bot_match_t *match, unsigned long int context); +//returns a variable from a match +void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size); +//unify all the white spaces in the string +void UnifyWhiteSpaces(char *string); +//replace all the context related synonyms in the string +void BotReplaceSynonyms(char *string, unsigned long int context); +//loads a chat file for the chat state +int BotLoadChatFile(int chatstate, char *chatfile, char *chatname); +//store the gender of the bot in the chat state +void BotSetChatGender(int chatstate, int gender); +//store the bot name in the chat state +void BotSetChatName(int chatstate, char *name, int client); + diff --git a/code/game/be_ai_gen.h b/code/game/be_ai_gen.h new file mode 100644 index 00000000..8f0a8e29 --- /dev/null +++ b/code/game/be_ai_gen.h @@ -0,0 +1,17 @@ +// Copyright (C) 1999-2000 Id Software, Inc. +// + +/***************************************************************************** + * name: be_ai_gen.h + * + * desc: genetic selection + * + * $Archive: /Code/DLLs/game/be_ai_gen.h $ + * $Author: Jwaters $ + * $Revision: 1 $ + * $Modtime: 5/17/02 11:35a $ + * $Date: 7/31/02 10:45a $ + * + *****************************************************************************/ + +int GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child); diff --git a/code/game/be_ai_goal.h b/code/game/be_ai_goal.h new file mode 100644 index 00000000..cd64e0d0 --- /dev/null +++ b/code/game/be_ai_goal.h @@ -0,0 +1,102 @@ +// Copyright (C) 1999-2000 Id Software, Inc. +// +/***************************************************************************** + * name: be_ai_goal.h + * + * desc: goal AI + * + * $Archive: /Code/DLLs/game/be_ai_goal.h $ + * $Author: Jwaters $ + * $Revision: 1 $ + * $Modtime: 5/17/02 11:35a $ + * $Date: 7/31/02 10:45a $ + * + *****************************************************************************/ + +#define MAX_AVOIDGOALS 256 +#define MAX_GOALSTACK 8 + +#define GFL_NONE 0 +#define GFL_ITEM 1 +#define GFL_ROAM 2 +#define GFL_DROPPED 4 + +//a bot goal +typedef struct bot_goal_s +{ + vec3_t origin; //origin of the goal + int areanum; //area number of the goal + vec3_t mins, maxs; //mins and maxs of the goal + int entitynum; //number of the goal entity + int number; //goal number + int flags; //goal flags + int iteminfo; //item information +} bot_goal_t; + +//reset the whole goal state, but keep the item weights +void BotResetGoalState(int goalstate); +//reset avoid goals +void BotResetAvoidGoals(int goalstate); +//remove the goal with the given number from the avoid goals +void BotRemoveFromAvoidGoals(int goalstate, int number); +//push a goal onto the goal stack +void BotPushGoal(int goalstate, bot_goal_t *goal); +//pop a goal from the goal stack +void BotPopGoal(int goalstate); +//empty the bot's goal stack +void BotEmptyGoalStack(int goalstate); +//dump the avoid goals +void BotDumpAvoidGoals(int goalstate); +//dump the goal stack +void BotDumpGoalStack(int goalstate); +//get the name name of the goal with the given number +void BotGoalName(int number, char *name, int size); +//get the top goal from the stack +int BotGetTopGoal(int goalstate, bot_goal_t *goal); +//get the second goal on the stack +int BotGetSecondGoal(int goalstate, bot_goal_t *goal); +//choose the best long term goal item for the bot +int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags); +//choose the best nearby goal item for the bot +//the item may not be further away from the current bot position than maxtime +//also the travel time from the nearby goal towards the long term goal may not +//be larger than the travel time towards the long term goal from the current bot position +int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, + bot_goal_t *ltg, float maxtime); +//returns true if the bot touches the goal +int BotTouchingGoal(vec3_t origin, bot_goal_t *goal); +//returns true if the goal should be visible but isn't +int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal); +//search for a goal for the given classname, the index can be used +//as a start point for the search when multiple goals are available with that same classname +int BotGetLevelItemGoal(int index, char *classname, bot_goal_t *goal); +//get the next camp spot in the map +int BotGetNextCampSpotGoal(int num, bot_goal_t *goal); +//get the map location with the given name +int BotGetMapLocationGoal(char *name, bot_goal_t *goal); +//returns the avoid goal time +float BotAvoidGoalTime(int goalstate, int number); +//set the avoid goal time +void BotSetAvoidGoalTime(int goalstate, int number, float avoidtime); +//initializes the items in the level +void BotInitLevelItems(void); +//regularly update dynamic entity items (dropped weapons, flags etc.) +void BotUpdateEntityItems(void); +//interbreed the goal fuzzy logic +void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child); +//save the goal fuzzy logic to disk +void BotSaveGoalFuzzyLogic(int goalstate, char *filename); +//mutate the goal fuzzy logic +void BotMutateGoalFuzzyLogic(int goalstate, float range); +//loads item weights for the bot +int BotLoadItemWeights(int goalstate, char *filename); +//frees the item weights of the bot +void BotFreeItemWeights(int goalstate); +//returns the handle of a newly allocated goal state +int BotAllocGoalState(int client); +//free the given goal state +void BotFreeGoalState(int handle); +//setup the goal AI +int BotSetupGoalAI(void); +//shut down the goal AI +void BotShutdownGoalAI(void); diff --git a/code/game/be_ai_move.h b/code/game/be_ai_move.h new file mode 100644 index 00000000..253ea4c4 --- /dev/null +++ b/code/game/be_ai_move.h @@ -0,0 +1,126 @@ +// Copyright (C) 1999-2000 Id Software, Inc. +// + +/***************************************************************************** + * name: be_ai_move.h + * + * desc: movement AI + * + * $Archive: /Code/DLLs/game/be_ai_move.h $ + * $Author: Jwaters $ + * $Revision: 1 $ + * $Modtime: 5/17/02 11:35a $ + * $Date: 7/31/02 10:45a $ + * + *****************************************************************************/ + +//movement types +#define MOVE_WALK 1 +#define MOVE_CROUCH 2 +#define MOVE_JUMP 4 +#define MOVE_GRAPPLE 8 +#define MOVE_ROCKETJUMP 16 +#define MOVE_BFGJUMP 32 +//move flags +#define MFL_BARRIERJUMP 1 //bot is performing a barrier jump +#define MFL_ONGROUND 2 //bot is in the ground +#define MFL_SWIMMING 4 //bot is swimming +#define MFL_AGAINSTLADDER 8 //bot is against a ladder +#define MFL_WATERJUMP 16 //bot is waterjumping +#define MFL_TELEPORTED 32 //bot is being teleported +#define MFL_GRAPPLEPULL 64 //bot is being pulled by the grapple +#define MFL_ACTIVEGRAPPLE 128 //bot is using the grapple hook +#define MFL_GRAPPLERESET 256 //bot has reset the grapple +#define MFL_WALK 512 //bot should walk slowly +// move result flags +#define MOVERESULT_MOVEMENTVIEW 1 //bot uses view for movement +#define MOVERESULT_SWIMVIEW 2 //bot uses view for swimming +#define MOVERESULT_WAITING 4 //bot is waiting for something +#define MOVERESULT_MOVEMENTVIEWSET 8 //bot has set the view in movement code +#define MOVERESULT_MOVEMENTWEAPON 16 //bot uses weapon for movement +#define MOVERESULT_ONTOPOFOBSTACLE 32 //bot is ontop of obstacle +#define MOVERESULT_ONTOPOF_FUNCBOB 64 //bot is ontop of a func_bobbing +#define MOVERESULT_ONTOPOF_ELEVATOR 128 //bot is ontop of an elevator (func_plat) +#define MOVERESULT_BLOCKEDBYAVOIDSPOT 256 //bot is blocked by an avoid spot +// +#define MAX_AVOIDREACH 1 +#define MAX_AVOIDSPOTS 32 +// avoid spot types +#define AVOID_CLEAR 0 //clear all avoid spots +#define AVOID_ALWAYS 1 //avoid always +#define AVOID_DONTBLOCK 2 //never totally block +// restult types +#define RESULTTYPE_ELEVATORUP 1 //elevator is up +#define RESULTTYPE_WAITFORFUNCBOBBING 2 //waiting for func bobbing to arrive +#define RESULTTYPE_BADGRAPPLEPATH 4 //grapple path is obstructed +#define RESULTTYPE_INSOLIDAREA 8 //stuck in solid area, this is bad + +//structure used to initialize the movement state +//the or_moveflags MFL_ONGROUND, MFL_TELEPORTED and MFL_WATERJUMP come from the playerstate +typedef struct bot_initmove_s +{ + vec3_t origin; //origin of the bot + vec3_t velocity; //velocity of the bot + vec3_t viewoffset; //view offset + int entitynum; //entity number of the bot + int client; //client number of the bot + float thinktime; //time the bot thinks + int presencetype; //presencetype of the bot + vec3_t viewangles; //view angles of the bot + int or_moveflags; //values ored to the movement flags +} bot_initmove_t; + +//NOTE: the ideal_viewangles are only valid if MFL_MOVEMENTVIEW is set +typedef struct bot_moveresult_s +{ + int failure; //true if movement failed all together + int type; //failure or blocked type + int blocked; //true if blocked by an entity + int blockentity; //entity blocking the bot + int traveltype; //last executed travel type + int flags; //result flags + int weapon; //weapon used for movement + vec3_t movedir; //movement direction + vec3_t ideal_viewangles; //ideal viewangles for the movement +} bot_moveresult_t; + +// bk001204: from code/botlib/be_ai_move.c +// TTimo 04/12/2001 was moved here to avoid dup defines +typedef struct bot_avoidspot_s +{ + vec3_t origin; + float radius; + int type; +} bot_avoidspot_t; + +//resets the whole move state +void BotResetMoveState(int movestate); +//moves the bot to the given goal +void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags); +//moves the bot in the specified direction using the specified type of movement +int BotMoveInDirection(int movestate, vec3_t dir, float speed, int type); +//reset avoid reachability +void BotResetAvoidReach(int movestate); +//resets the last avoid reachability +void BotResetLastAvoidReach(int movestate); +//returns a reachability area if the origin is in one +int BotReachabilityArea(vec3_t origin, int client); +//view target based on movement +int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target); +//predict the position of a player based on movement towards a goal +int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target); +//returns the handle of a newly allocated movestate +int BotAllocMoveState(void); +//frees the movestate with the given handle +void BotFreeMoveState(int handle); +//initialize movement state before performing any movement +void BotInitMoveState(int handle, bot_initmove_t *initmove); +//add a spot to avoid (if type == AVOID_CLEAR all spots are removed) +void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type); +//must be called every map change +void BotSetBrushModelTypes(void); +//setup movement AI +int BotSetupMoveAI(void); +//shutdown movement AI +void BotShutdownMoveAI(void); + diff --git a/code/game/be_ai_weap.h b/code/game/be_ai_weap.h new file mode 100644 index 00000000..e6a3df70 --- /dev/null +++ b/code/game/be_ai_weap.h @@ -0,0 +1,90 @@ +// Copyright (C) 1999-2000 Id Software, Inc. +// + +/***************************************************************************** + * name: be_ai_weap.h + * + * desc: weapon AI + * + * $Archive: /Code/DLLs/game/be_ai_weap.h $ + * $Author: Jwaters $ + * $Revision: 4 $ + * $Modtime: 8/19/02 3:51p $ + * $Date: 8/19/02 4:08p $ + * + *****************************************************************************/ + +//projectile flags +#define PFL_WINDOWDAMAGE 1 //projectile damages through window +#define PFL_RETURN 2 //set when projectile returns to owner +//weapon flags +#define WFL_FIRERELEASED 1 //set when projectile is fired with key-up event +//damage types +#define DAMAGETYPE_IMPACT 1 //damage on impact +#define DAMAGETYPE_RADIAL 2 //radial damage +#define DAMAGETYPE_VISIBLE 4 //damage to all entities visible to the projectile + +typedef struct projectileinfo_s +{ + char name[MAX_STRINGFIELD]; + char model[MAX_STRINGFIELD]; + int flags; + float gravity; + int damage; + float radius; + int visdamage; + int damagetype; + int healthinc; + float push; + float detonation; + float bounce; + float bouncefric; + float bouncestop; +} projectileinfo_t; + +typedef struct weaponinfo_s +{ + int valid; //true if the weapon info is valid + int number; //number of the weapon + char name[MAX_STRINGFIELD]; + char model[MAX_STRINGFIELD]; + int level; + int weaponindex; + int flags; + char projectile[MAX_STRINGFIELD]; + int numprojectiles; + float hspread; + float vspread; + float speed; + float acceleration; + vec3_t recoil; + vec3_t offset; + vec3_t angleoffset; + float extrazvelocity; + int ammoamount; + int ammoindex; + float activate; + float reload; + float spinup; + float spindown; + int primarydangerous; // if primary and/or alternate fire are REALLY DANGEROUS + int altdangerous; + projectileinfo_t proj; //pointer to the used projectile +} weaponinfo_t; + +//setup the weapon AI +int BotSetupWeaponAI(void); +//shut down the weapon AI +void BotShutdownWeaponAI(void); +//returns the best weapon to fight with +int BotChooseBestFightWeapon(int weaponstate, int *inventory); +//returns the information of the current weapon +void BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo); +//loads the weapon weights +int BotLoadWeaponWeights(int weaponstate, char *filename); +//returns a handle to a newly allocated weapon state +int BotAllocWeaponState(void); +//frees the weapon state +void BotFreeWeaponState(int weaponstate); +//resets the whole weapon state +void BotResetWeaponState(int weaponstate); diff --git a/code/game/be_ea.h b/code/game/be_ea.h new file mode 100644 index 00000000..71e1d83f --- /dev/null +++ b/code/game/be_ea.h @@ -0,0 +1,51 @@ +// Copyright (C) 1999-2000 Id Software, Inc. +// + +/***************************************************************************** + * name: be_ea.h + * + * desc: elementary actions + * + * $Archive: /Code/DLLs/game/be_ea.h $ + * $Author: Jwaters $ + * $Revision: 2 $ + * $Modtime: 8/08/02 12:17p $ + * $Date: 8/08/02 1:38p $ + * + *****************************************************************************/ + +//ClientCommand elementary actions +void EA_Say(int client, char *str); +void EA_SayTeam(int client, char *str); +void EA_Command(int client, const char *command ); + +void EA_Action(int client, int action); +void EA_Crouch(int client); +void EA_Walk(int client); +void EA_MoveUp(int client); +void EA_MoveDown(int client); +void EA_MoveForward(int client); +void EA_MoveBack(int client); +void EA_MoveLeft(int client); +void EA_MoveRight(int client); +void EA_ToggleFireState(int client); +void EA_Attack(int client, int primarydangerous, int altdangerous); +void EA_Respawn(int client); +void EA_Talk(int client); +void EA_Gesture(int client); +void EA_Use(int client); + +//regular elementary actions +void EA_SelectWeapon(int client, int weapon); +void EA_Jump(int client); +void EA_DelayedJump(int client); +void EA_Move(int client, vec3_t dir, float speed); +void EA_View(int client, vec3_t viewangles); + +//send regular input to the server +void EA_EndRegular(int client, float thinktime); +void EA_GetInput(int client, float thinktime, bot_input_t *input); +void EA_ResetInput(int client); +//setup and shutdown routines +int EA_Setup(void); +void EA_Shutdown(void); diff --git a/code/game/beam.cpp b/code/game/beam.cpp new file mode 100644 index 00000000..5549dc3f --- /dev/null +++ b/code/game/beam.cpp @@ -0,0 +1,879 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// beam.cpp: +// + +#include "beam.h" +#include "../qcommon/qfiles.h" + +/*****************************************************************************/ +/*QUAKED func_beam (0 0.25 .5) (-8 -8 -8) (8 8 8) START_ON PERSIST WAVE NOISE + +This creates a beam effect from the origin to the target's origin. If no +target is specified, uses angles and projects beam out from there. + +"model" Specifies the model to use as the beam +"overlap" Specifies the amount of overlap each beam link should have. Use this to fill +in the cracks when using electric on beams. (Default is 0) +"minoffset" Minimum amount of electrical variation (Default is 0) +"maxoffset" Maximum amount of electrical variation (Default is 5) +"color" Vector specifiying the red,green, and blue components. (Default is "1 1 1") +"alpha" Alpha of the beam (Default is 1.0) +"damage" Amount of damage the beam inflicts if beam hits someone (Default is 0) +"angles" Sets the angle of the beam if no target is specified. +"life" Sets the life of the beam for use with the persist spawnflag. This is how long a beam will +be displayed. +"numsegments" Number of segments in a beam (Default is 4) +"delay" Delay between beam updates. (i.e. slows the effect of the beam down) +"shader" Set the shader of the beam +"scale" Set the width of the beam + +START_ON - Starts the beam on +PERSIST - Keeps the last few beams around and fades them out over the life of the beam +WAVE - Make the beam follow a sin wave pattern +NOISE - Use a more computationally expensive random effect, but the results are smoother + +If the model field is not set, then a renderer generated beam will be created +using the color, minoffset, maxoffset, scale, and subdivisions fields + +If the targetname is set, it will use the target specified as the endpoint of the beam + +/*****************************************************************************/ + +Event EV_FuncBeam_Activate + ( + "activate", + EV_DEFAULT, + NULL, + NULL, + "Activate the beam", + EV_NORMAL + ); +Event EV_FuncBeam_Deactivate + ( + "deactivate", + EV_DEFAULT, + NULL, + NULL, + "Deactivate the beam", + EV_NORMAL + ); +Event EV_FuncBeam_Diameter + ( + "diameter", + EV_DEFAULT, + "f", + "diameter", + "Set the diameter of the beam", + EV_NORMAL + ); +Event EV_FuncBeam_Maxoffset + ( + "maxoffset", + EV_DEFAULT, + "f", + "max_offset", + "Set the maximum offset the beam can travel above, below, forward or back of it's endpoints", + EV_NORMAL + ); +Event EV_FuncBeam_Minoffset + ( + "minoffset", + EV_DEFAULT, + "f", + "min_offset", + "Set the minimun offset the beam can travel above, below, forward or back of it's endpoints", + EV_NORMAL + ); +Event EV_FuncBeam_Overlap + ( + "overlap", + EV_DEFAULT, + "f", + "beam_overlap", + "Set the amount of overlap the beams have when they are being strung together", + EV_NORMAL + ); +Event EV_FuncBeam_Color + ( + "color", + EV_DEFAULT, + "v[0,1][0,1][0,1]", + "beam_color", + "Set the color of the beam", + EV_NORMAL + ); +Event EV_FuncBeam_SetTarget + ( + "target", + EV_DEFAULT, + "s", + "beam_target", + "Set the target of the beam. The beam will be drawn from the origin\n" + "to the origin of the target entity", + EV_NORMAL + ); +Event EV_FuncBeam_SetEndPoint + ( + "endpoint", + EV_DEFAULT, + "v", + "beam_end_point", + "Set the end point of the beam. The beam will be draw from the origin to\n" + "the end point.", + EV_NORMAL + ); +Event EV_FuncBeam_SetLife + ( + "life", + EV_DEFAULT, + "f", + "beam_life", + "Set the amount of time the beam stays on when activated", + EV_NORMAL + ); +Event EV_FuncBeam_Shader + ( + "shader", + EV_DEFAULT, + "s", + "beam_shader", + "Set the shader that the beam will use", + EV_NORMAL + ); +Event EV_FuncBeam_TileShader + ( + "tileshader", + EV_DEFAULT, + "s", + "beam_shader", + "Set the shader that the beam will use. This shader will be tiled.", + EV_NORMAL + ); +Event EV_FuncBeam_Segments + ( + "numsegments", + EV_DEFAULT, + "i", + "numsegments", + "Set the number of segments for the beam", + EV_NORMAL + ); +Event EV_FuncBeam_Delay + ( + "delay", + EV_DEFAULT, + "f", + "delay", + "Set the amount of delay on the beam updater", + EV_NORMAL + ); +Event EV_FuncBeam_NumSphereBeams + ( + "numspherebeams", + EV_DEFAULT, + "i", + "num", + "Set the number of beams that will be shot out in a sphere like formation", + EV_NORMAL + ); +Event EV_FuncBeam_SphereRadius + ( + "radius", + EV_DEFAULT, + "f", + "radius", + "Set the starting radius of the beams if this is a beamsphere", + EV_NORMAL + ); +Event EV_FuncBeam_ToggleDelay + ( + "toggledelay", + EV_DEFAULT, + "SF", + "[random] time", + "Causes a beam toggling effect. Sets the time between toggling. If random is specified, The time will be between 0 and time", + EV_NORMAL + ); +Event EV_FuncBeam_FindEndpoint + ( + "findendpoint", + EV_DEFAULT, + NULL, + NULL, + "Find the endpoint of a beam", + EV_NORMAL + ); +Event EV_FuncBeam_UpdateEndpoint + ( + "updateendpoint", + EV_DEFAULT, + NULL, + NULL, + "Update the endpoint of a beam", + EV_NORMAL + ); +Event EV_FuncBeam_UpdateOrigin + ( + "updateorigin", + EV_DEFAULT, + NULL, + NULL, + "Update the origin of a beam", + EV_NORMAL + ); +Event EV_FuncBeam_EndAlpha + ( + "endalpha", + EV_DEFAULT, + "f", + "alpha", + "Set the endpoint alpha value of the beam", + EV_NORMAL + ); +Event EV_FuncBeam_Shoot + ( + "shoot", + EV_DEFAULT, + NULL, + NULL, + "Make the beam cause damage to entities that get in the way", + EV_NORMAL + ); +Event EV_FuncBeam_ShootRadius + ( + "shootradius", + EV_DEFAULT, + "f", + "radius", + "Set the radius of the damage area between beam endpoints", + EV_NORMAL + ); +Event EV_FuncBeam_Persist + ( + "persist", + EV_DEFAULT, + "b", + "bool", + "Set the persist property of the beam", + EV_NORMAL + ); +Event EV_FuncBeam_IgnoreWalls + ( + "ignorewalls", + EV_DEFAULT, + "B", + "bool", + "Set if the beam can traverse walls", + EV_NORMAL + ); + +CLASS_DECLARATION( ScriptSlave, FuncBeam, "func_beam" ) +{ + { &EV_Activate, &FuncBeam::Activate }, + { &EV_FuncBeam_Activate, &FuncBeam::Activate }, + { &EV_FuncBeam_Deactivate, &FuncBeam::Deactivate }, + { &EV_FuncBeam_Maxoffset, &FuncBeam::SetMaxoffset }, + { &EV_FuncBeam_Minoffset, &FuncBeam::SetMinoffset }, + { &EV_FuncBeam_Overlap, &FuncBeam::SetOverlap }, + { &EV_FuncBeam_Color, &FuncBeam::SetColor }, + { &EV_SetAngle, &FuncBeam::SetAngle }, + { &EV_FuncBeam_Segments, &FuncBeam::SetSegments }, + { &EV_SetAngles, &FuncBeam::SetAngles }, + { &EV_FuncBeam_SetEndPoint, &FuncBeam::SetEndPoint }, + { &EV_Model, &FuncBeam::SetModel }, + { &EV_Damage, &FuncBeam::SetDamage }, + { &EV_FuncBeam_SetLife, &FuncBeam::SetLife }, + { &EV_FuncBeam_Shader, &FuncBeam::SetBeamShader }, + { &EV_FuncBeam_TileShader, &FuncBeam::SetBeamTileShader }, + { &EV_FuncBeam_Delay, &FuncBeam::SetDelay }, + { &EV_FuncBeam_NumSphereBeams, &FuncBeam::SetNumSphereBeams }, + { &EV_FuncBeam_SphereRadius, &FuncBeam::SetSphereRadius }, + { &EV_FuncBeam_ToggleDelay, &FuncBeam::SetToggleDelay }, + { &EV_FuncBeam_ShootRadius, &FuncBeam::SetShootRadius }, + { &EV_FuncBeam_EndAlpha, &FuncBeam::SetEndAlpha }, + { &EV_FuncBeam_Persist, &FuncBeam::SetPersist }, + { &EV_FuncBeam_FindEndpoint, &FuncBeam::FindEndpoint }, + { &EV_FuncBeam_UpdateEndpoint, &FuncBeam::UpdateEndpoint }, + { &EV_FuncBeam_UpdateOrigin, &FuncBeam::UpdateOrigin }, + { &EV_FuncBeam_Shoot, &FuncBeam::Shoot }, + { &EV_FuncBeam_IgnoreWalls, &FuncBeam::SetIgnoreWalls }, + { NULL, NULL } +}; + +FuncBeam::FuncBeam() +{ + setSolidType( SOLID_NOT ); + setOrigin(); + + damage = 0; + life = 0; + shootradius = 0; + use_angles = false; + m_bIgnoreWalls = false; + + edict->s.renderfx |= RF_BEAM; + edict->s.eType = ET_BEAM; // Entity type beam + edict->s.modelindex = 1; // must be non-zero + SetBeamShader( "beamshader" ); + + if ( !LoadingSavegame ) + { + edict->s.alpha = 1; // alpha + edict->s.surfaces[4] = 4; // num segments + edict->s.surfaces[0] = 16; // life + edict->s.surfaces[9] = 16; // endalpha + edict->s.beam_entnum = ENTITYNUM_NONE; + edict->s.bone_angles[0][1] = 5; // Max offset + + if ( spawnflags & 0x0001 ) // Start On + PostEvent( EV_Activate, EV_POSTSPAWN ); + else + hideModel(); + edict->s.skinNum = 0; + if ( spawnflags & 0x0002 ) + edict->s.skinNum |= BEAM_PERSIST_EFFECT; + if ( spawnflags & 0x0004 ) + edict->s.skinNum |= BEAM_WAVE_EFFECT; + if ( spawnflags & 0x0008 ) + edict->s.skinNum |= BEAM_USE_NOISE; + + // Try to find the endpoint of this beam after everything has been spawned + PostEvent( EV_FuncBeam_FindEndpoint, EV_LINKBEAMS ); + } +} + +void FuncBeam::SetEndAlpha + ( + Event *ev + ) + + { + BEAM_PARM_TO_PKT( ev->GetFloat( 1 ), edict->s.surfaces[9] ); + } + +void FuncBeam::SetToggleDelay + ( + Event *ev + ) + + { + edict->s.skinNum |= BEAM_TOGGLE; + + if ( ev->NumArgs() > 2 ) + { + str arg = ev->GetString( 1 ); + if ( !arg.icmp( "random" ) ) + { + edict->s.skinNum |= BEAM_RANDOM_TOGGLEDELAY; + } + BEAM_PARM_TO_PKT( ev->GetFloat( 2 ), edict->s.surfaces[8] ); + } + else + { + BEAM_PARM_TO_PKT( ev->GetFloat( 1 ), edict->s.surfaces[8] ); + } + } + +void FuncBeam::SetSphereRadius + ( + Event *ev + ) + + { + edict->s.skinNum |= BEAM_SPHERE_EFFECT; + BEAM_PARM_TO_PKT( ev->GetFloat( 1 ), edict->s.surfaces[7] ); + } + +void FuncBeam::SetNumSphereBeams + ( + Event *ev + ) + + { + edict->s.skinNum |= BEAM_SPHERE_EFFECT; + edict->s.surfaces[6] = ev->GetInteger( 1 ); + } + +void FuncBeam::SetAngle + ( + Event *ev + ) + + { + Vector movedir; + + movedir = G_GetMovedir( ev->GetFloat( 1 ) ); + setAngles( movedir.toAngles() ); + } + +void FuncBeam::SetAngles + ( + Event *ev + ) + + { + setAngles( ev->GetVector( 1 ) ); + } + +// Override setAngles to update the endpoint of the beam if it's rotated +void FuncBeam::setAngles + ( + Vector angles + ) + +{ + trace_t trace; + Vector endpoint; + + ScriptSlave::setAngles( angles ); + + // If there is no target, then use the angles to determine where to put the + // endpoint + if( !end ) + { + endpoint = origin + Vector( orientation[ 0 ] ) * MAP_SIZE; + + trace = G_Trace( origin, vec_zero, vec_zero, endpoint, this, MASK_LINE, false, "FuncBeam" ); + + VectorCopy( trace.endpos, edict->s.origin2 ); + + use_angles = true; + } +} + +void FuncBeam::SetEndPoint + ( + Event *ev + ) + +{ + trace_t trace; + + end_point = ev->GetVector( 1 ); + + trace = G_Trace( origin, vec_zero, vec_zero, end_point, this, MASK_LINE, false, "FuncBeam" ); + VectorCopy( trace.endpos, edict->s.origin2 ); + + use_angles = false; +} + +void FuncBeam::SetModel + ( + Event *ev + ) + +{ + setModel( ev->GetString( 1 ) ); + edict->s.renderfx &= ~RF_BEAM; + edict->s.eType = ET_BEAM; + edict->s.skinNum |= BEAM_USEMODEL; +} + +void FuncBeam::SetDamage + ( + Event *ev + ) + + { + damage = ev->GetFloat( 2 ); + } + +void FuncBeam::SetLife + ( + Event *ev + ) + + { + BEAM_PARM_TO_PKT( ev->GetFloat( 1 ), edict->s.surfaces[0] ); + } + +void FuncBeam::SetColor + ( + Event *ev + ) + + { + Vector color = ev->GetVector( 1 ); + G_SetConstantLight( &edict->s.constantLight, &color[ 0 ], &color[ 1 ], &color[ 2 ], NULL ); + } + +void FuncBeam::SetSegments + ( + Event *ev + ) + + { + edict->s.surfaces[4] = ev->GetInteger( 1 ); + } + +void FuncBeam::SetBeamShader + ( + str beam_shader + ) + + { + str temp_shader; + + shader = beam_shader; + edict->s.tag_num = gi.imageindex( shader ); + + temp_shader = shader + ".spr"; + CacheResource( temp_shader ); + } + +void FuncBeam::SetBeamShader + ( + Event *ev + ) + + { + SetBeamShader( ev->GetString( 1 ) ); + } + +void FuncBeam::SetBeamTileShader + ( + Event *ev + ) + + { + SetBeamShader( ev->GetString( 1 ) ); + edict->s.skinNum |= BEAM_TILESHADER; + } + +void FuncBeam::SetMaxoffset + ( + Event *ev + ) + + { + edict->s.bone_angles[0][1] = ev->GetFloat( 1 ); + } + +void FuncBeam::SetMinoffset + ( + Event *ev + ) + + { + edict->s.bone_angles[0][0] = ev->GetFloat( 1 ); + } + +void FuncBeam::SetOverlap + ( + Event *ev + ) + + { + BEAM_PARM_TO_PKT( ev->GetFloat( 1 ), edict->s.surfaces[3] ); + } + +void FuncBeam::SetDelay + ( + Event *ev + ) + + { + if ( ev->NumArgs() > 2 ) + { + str arg = ev->GetString( 1 ); + if ( !arg.icmp( "random" ) ) + { + edict->s.skinNum |= BEAM_RANDOM_DELAY; + } + BEAM_PARM_TO_PKT( ev->GetFloat( 2 ), edict->s.surfaces[5] ); + } + else + { + BEAM_PARM_TO_PKT( ev->GetFloat( 1 ), edict->s.surfaces[5] ); + } + } + +void FuncBeam::Deactivate + ( + Event *ev + ) + + { + hideModel(); + + // Cancel all of the events to activate + CancelEventsOfType( EV_FuncBeam_Activate ); + CancelEventsOfType( EV_Activate ); + CancelEventsOfType( EV_FuncBeam_UpdateEndpoint ); + CancelEventsOfType( EV_FuncBeam_UpdateOrigin ); + } + +void FuncBeam::SetShootRadius + ( + Event *ev + ) + + { + shootradius = ev->GetFloat( 1 ); + } + +void FuncBeam::SetPersist + ( + Event *ev + ) + + { + qboolean persist = ev->GetBoolean( 1 ); + + if ( persist ) + edict->s.skinNum |= BEAM_PERSIST_EFFECT; + else + edict->s.skinNum &= ~BEAM_PERSIST_EFFECT; + } + +void FuncBeam::Shoot + ( + Event *ev + ) + + { + trace_t trace; + Vector start, end; + + start = edict->s.origin; + end = edict->s.origin2; + + Vector dir( end - start ); + Vector b1( -shootradius, -shootradius, -shootradius ); + Vector b2( shootradius, shootradius, shootradius ); + + trace = G_Trace( start, b1, b2, end, this, MASK_SHOT, false, "FuncBeam::Activate" ); + + if ( trace.ent && trace.ent->entity && trace.ent->entity->takedamage ) + { + // damage the ent + trace.ent->entity->Damage( this, + this, + damage, + trace.endpos, + dir, + trace.plane.normal, + 0, + 0, + MOD_BEAM + ); + } + + PostEvent( EV_FuncBeam_Shoot, 0.1f ); + } + +void FuncBeam::SetIgnoreWalls + ( + Event *ev + ) + +{ + if( ev->NumArgs() > 0 ) + { + m_bIgnoreWalls = ev->GetBoolean( 1 ); + } + else + { + m_bIgnoreWalls = true; + } +} + +void FuncBeam::Activate + ( + Event *ev + ) + +{ + Vector forward; + trace_t trace; + + showModel(); + + // An entity is targeted + if( end ) + { + VectorCopy( end->origin, edict->s.origin2 ); + // Post an event so that the beam will update itself every frame + PostEvent( EV_FuncBeam_UpdateEndpoint, level.frametime ); + } + else if( use_angles ) + { + angles.AngleVectorsLeft( &forward, NULL, NULL ); + + Vector endpoint( orientation[ 0 ] ); + endpoint *= MAP_SIZE; + + if( m_bIgnoreWalls ) + { + VectorCopy( endpoint, trace.endpos ); + } + else + { + trace = G_Trace( origin, vec_zero, vec_zero, endpoint, this, MASK_LINE, false, "FuncBeam::Activate" ); + } + + VectorCopy( trace.endpos, edict->s.origin2 ); + } + else + { + if( m_bIgnoreWalls ) + { + VectorCopy( end_point, trace.endpos ); + } + else + { + trace = G_Trace( origin, vec_zero, vec_zero, end_point, this, MASK_LINE, false, "FuncBeam::Activate" ); + } + + VectorCopy( trace.endpos, edict->s.origin2 ); + } + + if( origin_target ) + { + PostEvent( EV_FuncBeam_UpdateOrigin, level.frametime ); + } + + if( damage ) + { + // Shoot beam and cause damage every frame + ProcessEvent( EV_FuncBeam_Shoot ); + } + + // If life is set, then post a deactivate message + if( life > 0 && !EventPending( EV_FuncBeam_Deactivate ) ) + { + PostEvent( EV_FuncBeam_Deactivate, life ); + return; + } +} + +void FuncBeam::UpdateEndpoint + ( + Event *ev + ) + + { + if ( end ) + { + Event *ev1 = new Event( ev ); + + VectorCopy( end->origin, edict->s.origin2 ); + PostEvent( ev1, level.frametime ); + } + } + +void FuncBeam::UpdateOrigin + ( + Event *ev + ) + + { + if ( origin_target ) + { + Event *ev1 = new Event( ev ); + + setOrigin( origin_target->centroid ); + PostEvent( ev1, level.frametime ); + } + } + +void FuncBeam::FindEndpoint + ( + Event *ev + ) + + { + if ( target && strlen( target ) ) + { + end = ( Entity * )G_FindTarget( NULL, target ); + if ( end ) + { + VectorCopy( end->origin, edict->s.origin2 ); + } + } + } + +FuncBeam *CreateBeam + ( + const char *model, + const char *shader, + Vector start, + Vector end, + int numsegments, + float scale, + float life, + float damage, + Entity *origin_target + ) + + { + FuncBeam *beam; + trace_t trace; + + // set start point + beam = new FuncBeam; + beam->setOrigin( start ); + + if ( origin_target ) + beam->origin_target = origin_target; + + // set endpoint + beam->end_point = end; + trace = G_Trace( start, vec_zero, vec_zero, end, beam, MASK_LINE, false, "CreateBeam" ); + VectorCopy( trace.endpos, beam->edict->s.origin2 ); + beam->use_angles = false; + + if ( model ) + { + // set the model if we have one + beam->setModel( model ); + beam->edict->s.renderfx &= ~RF_BEAM; + beam->edict->s.eType = ET_BEAM; + beam->edict->s.skinNum |= BEAM_USEMODEL; + } + + if ( shader ) + { + // Set the shader as an image configstring + beam->SetBeamShader( shader ); + } + + // set num segments + beam->edict->s.surfaces[4] = numsegments; + + // set scale + beam->setScale( scale ); + + // set life + BEAM_PARM_TO_PKT( life, beam->edict->s.surfaces[0] ); + beam->life = life; + + // set damage + beam->damage = damage; + + // activate it + beam->ProcessEvent( EV_Activate ); + beam->PostEvent( EV_Remove, life ); + return beam; + } diff --git a/code/game/beam.h b/code/game/beam.h new file mode 100644 index 00000000..7bd1d680 --- /dev/null +++ b/code/game/beam.h @@ -0,0 +1,126 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// beam.h: Beam + +#ifndef __BEAM_H__ +#define __BEAM_H__ + +#include "g_local.h" +#include "scriptslave.h" + +extern Event EV_FuncBeam_Activate; +extern Event EV_FuncBeam_Deactivate; +extern Event EV_FuncBeam_Diameter; +extern Event EV_FuncBeam_Maxoffset; +extern Event EV_FuncBeam_Minoffset; +extern Event EV_FuncBeam_Overlap; +extern Event EV_FuncBeam_Color; +extern Event EV_FuncBeam_SetTarget; +extern Event EV_FuncBeam_SetAngle; +extern Event EV_FuncBeam_SetEndPoint; +extern Event EV_FuncBeam_SetLife; +extern Event EV_FuncBeam_Shader; +extern Event EV_FuncBeam_Segments; +extern Event EV_FuncBeam_Delay; +extern Event EV_FuncBeam_NumSphereBeams; +extern Event EV_FuncBeam_SphereRadius; +extern Event EV_FuncBeam_ToggleDelay; +extern Event EV_FuncBeam_FindEndpoint; +extern Event EV_FuncBeam_EndAlpha; + +class FuncBeam : public ScriptSlave +{ +protected: + SimpleEntityPtr end, origin_target; + float damage; + float life; + Vector end_point; + qboolean use_angles; + float shootradius; + str shader; + + bool m_bIgnoreWalls; + +public: + CLASS_PROTOTYPE( FuncBeam ); + + FuncBeam(); + + void SetAngle( Event *ev ); + void SetAngles( Event *ev ); + void SetEndPoint( Event *ev ); + void SetModel( Event *ev ); + void SetDamage( Event *ev ); + void SetOverlap( Event *ev ); + void SetBeamStyle( Event *ev ); + void SetLife( Event *ev ); + void Activate( Event *ev ); + void Deactivate( Event *ev ); + void SetDiameter( Event *ev ); + void SetMaxoffset( Event *ev ); + void SetMinoffset( Event *ev ); + void SetColor( Event *ev ); + void SetSegments( Event *ev ); + void SetBeamShader( str shader ); + void SetBeamShader( Event *ev ); + void SetBeamTileShader( Event *ev ); + void SetDelay( Event *ev ); + void SetToggleDelay( Event *ev ); + void SetSphereRadius( Event *ev ); + void SetNumSphereBeams( Event *ev ); + void SetEndAlpha( Event *ev ); + void SetShootRadius( Event *ev ); + void SetPersist( Event *ev ); + void FindEndpoint( Event *ev ); + void UpdateEndpoint( Event *ev ); + void UpdateOrigin( Event *ev ); + void Shoot( Event *ev ); + void SetIgnoreWalls( Event *ev ); + + virtual void setAngles( Vector ang ); + virtual void Archive( Archiver &arc ); + + friend FuncBeam *CreateBeam( const char *model, const char *shader, Vector start, Vector end, int numsegments = 4, float scale = 1.0f, float life = 1.0f, float damage = 0.0f, Entity *origin_target = NULL ); +}; + +inline void FuncBeam::Archive + ( + Archiver &arc + ) + { + ScriptSlave::Archive( arc ); + arc.ArchiveSafePointer( &end ); + arc.ArchiveSafePointer( &origin_target ); + arc.ArchiveFloat( &damage ); + arc.ArchiveFloat( &life ); + arc.ArchiveVector( &end_point ); + arc.ArchiveBoolean( &use_angles ); + arc.ArchiveFloat( &shootradius ); + arc.ArchiveString( &shader ); + if ( arc.Loading() ) + { + SetBeamShader( shader ); + } + } + +#endif // __BEAM_H__ diff --git a/code/game/bg_lib.cpp b/code/game/bg_lib.cpp new file mode 100644 index 00000000..ff023219 --- /dev/null +++ b/code/game/bg_lib.cpp @@ -0,0 +1,2119 @@ +// +// +// bg_lib,c -- standard C library replacement routines used by code +// compiled for the virtual machine + +#ifdef Q3_VM + +#include "../qcommon/q_shared.h" + +/*- + * 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. 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. + */ + +#include "bg_lib.h" + +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)qsort.c 8.1 (Berkeley) 6/4/93"; +#endif +static const char rcsid[] = +#endif /* LIBC_SCCS and not lint */ + +static char* med3(char *, char *, char *, cmp_t *); +static void swapfunc(char *, char *, int, int); + +/* + * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". + */ +#define swapcode(TYPE, parmi, parmj, n) { \ + long i = (n) / sizeof (TYPE); \ + register TYPE *pi = (TYPE *) (parmi); \ + register TYPE *pj = (TYPE *) (parmj); \ + do { \ + register TYPE t = *pi; \ + *pi++ = *pj; \ + *pj++ = t; \ + } while (--i > 0); \ +} + +#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ + es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; + +static void +swapfunc(a, b, n, swaptype) + char *a, *b; + int n, swaptype; +{ + if(swaptype <= 1) + swapcode(long, a, b, n) + else + swapcode(char, a, b, n) +} + +#define swap(a, b) \ + if (swaptype == 0) { \ + long t = *(long *)(a); \ + *(long *)(a) = *(long *)(b); \ + *(long *)(b) = t; \ + } else \ + swapfunc(a, b, es, swaptype) + +#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) + +static char * +med3(a, b, c, cmp) + char *a, *b, *c; + cmp_t *cmp; +{ + return cmp(a, b) < 0 ? + (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a )) + :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c )); +} + +void +qsort(a, n, es, cmp) + void *a; + size_t n, es; + cmp_t *cmp; +{ + char *pa, *pb, *pc, *pd, *pl, *pm, *pn; + int d, r, swaptype, swap_cnt; + +loop: SWAPINIT(a, es); + swap_cnt = 0; + if (n < 7) { + for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) + for (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0; + pl -= es) + swap(pl, pl - es); + return; + } + pm = (char *)a + (n / 2) * es; + if (n > 7) { + pl = a; + pn = (char *)a + (n - 1) * es; + if (n > 40) { + d = (n / 8) * es; + pl = med3(pl, pl + d, pl + 2 * d, cmp); + pm = med3(pm - d, pm, pm + d, cmp); + pn = med3(pn - 2 * d, pn - d, pn, cmp); + } + pm = med3(pl, pm, pn, cmp); + } + swap(a, pm); + pa = pb = (char *)a + es; + + pc = pd = (char *)a + (n - 1) * es; + for (;;) { + while (pb <= pc && (r = cmp(pb, a)) <= 0) { + if (r == 0) { + swap_cnt = 1; + swap(pa, pb); + pa += es; + } + pb += es; + } + while (pb <= pc && (r = cmp(pc, a)) >= 0) { + if (r == 0) { + swap_cnt = 1; + swap(pc, pd); + pd -= es; + } + pc -= es; + } + if (pb > pc) + break; + swap(pb, pc); + swap_cnt = 1; + pb += es; + pc -= es; + } + if (swap_cnt == 0) { /* Switch to insertion sort */ + for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) + for (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0; + pl -= es) + swap(pl, pl - es); + return; + } + + pn = (char *)a + n * es; + r = MIN(pa - (char *)a, pb - pa); + vecswap(a, pb - r, r); + r = MIN(pd - pc, pn - pd - es); + vecswap(pb, pn - r, r); + if ((r = pb - pa) > es) + qsort(a, r / es, es, cmp); + if ((r = pd - pc) > es) { + /* Iterate rather than recurse to save stack space */ + a = pn - r; + n = r / es; + goto loop; + } +/* qsort(pn - r, r / es, es, cmp);*/ +} + +//================================================================================== + +size_t strlen( const char *string ) { + const char *s; + + s = string; + while ( *s ) { + s++; + } + return s - string; +} + + +char *strcat( char *strDestination, const char *strSource ) { + char *s; + + s = strDestination; + while ( *s ) { + s++; + } + while ( *strSource ) { + *s++ = *strSource++; + } + *s = 0; + return strDestination; +} + +char *strcpy( char *strDestination, const char *strSource ) { + char *s; + + s = strDestination; + while ( *strSource ) { + *s++ = *strSource++; + } + *s = 0; + return strDestination; +} + + +int strcmp( const char *string1, const char *string2 ) { + while ( *string1 == *string2 && *string1 && *string2 ) { + string1++; + string2++; + } + return *string1 - *string2; +} + + +char *strchr( const char *string, int c ) { + while ( *string ) { + if ( *string == c ) { + return ( char * )string; + } + string++; + } + + if(c) + return NULL; + else + return (char *) string; +} + +char *strrchr(const char *string, int c) +{ + const char *found = NULL; + + while(*string) + { + if(*string == c) + found = string; + + string++; + } + + if(c) + return (char *) found; + else + return (char *) string; +} + +char *strstr( const char *string, const char *strCharSet ) { + while ( *string ) { + int i; + + for ( i = 0 ; strCharSet[i] ; i++ ) { + if ( string[i] != strCharSet[i] ) { + break; + } + } + if ( !strCharSet[i] ) { + return (char *)string; + } + string++; + } + return (char *)0; +} + +int tolower( int c ) { + if ( c >= 'A' && c <= 'Z' ) { + c += 'a' - 'A'; + } + return c; +} + + +int toupper( int c ) { + if ( c >= 'a' && c <= 'z' ) { + c += 'A' - 'a'; + } + return c; +} + +void *memmove(void *dest, const void *src, size_t count) +{ + size_t i; + + if(count) + { + if(dest > src) + { + i = count; + + do + { + i--; + ((char *) dest)[i] = ((char *) src)[i]; + } while(i > 0); + } + else + { + for(i = 0; i < count; i++) + ((char *) dest)[i] = ((char *) src)[i]; + } + } + + return dest; +} + + +#if 0 + +double floor( double x ) { + return (int)(x + 0x40000000) - 0x40000000; +} + +void *memset( void *dest, int c, size_t count ) { + while ( count-- ) { + ((char *)dest)[count] = c; + } + return dest; +} + +void *memcpy( void *dest, const void *src, size_t count ) { + while ( count-- ) { + ((char *)dest)[count] = ((char *)src)[count]; + } + return dest; +} + +char *strncpy( char *strDest, const char *strSource, size_t count ) { + char *s; + + s = strDest; + while ( *strSource && count ) { + *s++ = *strSource++; + count--; + } + while ( count-- ) { + *s++ = 0; + } + return strDest; +} + +double sqrt( double x ) { + float y; + float delta; + float maxError; + + if ( x <= 0 ) { + return 0; + } + + // initial guess + y = x / 2; + + // refine + maxError = x * 0.001; + + do { + delta = ( y * y ) - x; + y -= delta / ( 2 * y ); + } while ( delta > maxError || delta < -maxError ); + + return y; +} + + +float sintable[1024] = { +0.000000,0.001534,0.003068,0.004602,0.006136,0.007670,0.009204,0.010738, +0.012272,0.013805,0.015339,0.016873,0.018407,0.019940,0.021474,0.023008, +0.024541,0.026075,0.027608,0.029142,0.030675,0.032208,0.033741,0.035274, +0.036807,0.038340,0.039873,0.041406,0.042938,0.044471,0.046003,0.047535, +0.049068,0.050600,0.052132,0.053664,0.055195,0.056727,0.058258,0.059790, +0.061321,0.062852,0.064383,0.065913,0.067444,0.068974,0.070505,0.072035, +0.073565,0.075094,0.076624,0.078153,0.079682,0.081211,0.082740,0.084269, +0.085797,0.087326,0.088854,0.090381,0.091909,0.093436,0.094963,0.096490, +0.098017,0.099544,0.101070,0.102596,0.104122,0.105647,0.107172,0.108697, +0.110222,0.111747,0.113271,0.114795,0.116319,0.117842,0.119365,0.120888, +0.122411,0.123933,0.125455,0.126977,0.128498,0.130019,0.131540,0.133061, +0.134581,0.136101,0.137620,0.139139,0.140658,0.142177,0.143695,0.145213, +0.146730,0.148248,0.149765,0.151281,0.152797,0.154313,0.155828,0.157343, +0.158858,0.160372,0.161886,0.163400,0.164913,0.166426,0.167938,0.169450, +0.170962,0.172473,0.173984,0.175494,0.177004,0.178514,0.180023,0.181532, +0.183040,0.184548,0.186055,0.187562,0.189069,0.190575,0.192080,0.193586, +0.195090,0.196595,0.198098,0.199602,0.201105,0.202607,0.204109,0.205610, +0.207111,0.208612,0.210112,0.211611,0.213110,0.214609,0.216107,0.217604, +0.219101,0.220598,0.222094,0.223589,0.225084,0.226578,0.228072,0.229565, +0.231058,0.232550,0.234042,0.235533,0.237024,0.238514,0.240003,0.241492, +0.242980,0.244468,0.245955,0.247442,0.248928,0.250413,0.251898,0.253382, +0.254866,0.256349,0.257831,0.259313,0.260794,0.262275,0.263755,0.265234, +0.266713,0.268191,0.269668,0.271145,0.272621,0.274097,0.275572,0.277046, +0.278520,0.279993,0.281465,0.282937,0.284408,0.285878,0.287347,0.288816, +0.290285,0.291752,0.293219,0.294685,0.296151,0.297616,0.299080,0.300543, +0.302006,0.303468,0.304929,0.306390,0.307850,0.309309,0.310767,0.312225, +0.313682,0.315138,0.316593,0.318048,0.319502,0.320955,0.322408,0.323859, +0.325310,0.326760,0.328210,0.329658,0.331106,0.332553,0.334000,0.335445, +0.336890,0.338334,0.339777,0.341219,0.342661,0.344101,0.345541,0.346980, +0.348419,0.349856,0.351293,0.352729,0.354164,0.355598,0.357031,0.358463, +0.359895,0.361326,0.362756,0.364185,0.365613,0.367040,0.368467,0.369892, +0.371317,0.372741,0.374164,0.375586,0.377007,0.378428,0.379847,0.381266, +0.382683,0.384100,0.385516,0.386931,0.388345,0.389758,0.391170,0.392582, +0.393992,0.395401,0.396810,0.398218,0.399624,0.401030,0.402435,0.403838, +0.405241,0.406643,0.408044,0.409444,0.410843,0.412241,0.413638,0.415034, +0.416430,0.417824,0.419217,0.420609,0.422000,0.423390,0.424780,0.426168, +0.427555,0.428941,0.430326,0.431711,0.433094,0.434476,0.435857,0.437237, +0.438616,0.439994,0.441371,0.442747,0.444122,0.445496,0.446869,0.448241, +0.449611,0.450981,0.452350,0.453717,0.455084,0.456449,0.457813,0.459177, +0.460539,0.461900,0.463260,0.464619,0.465976,0.467333,0.468689,0.470043, +0.471397,0.472749,0.474100,0.475450,0.476799,0.478147,0.479494,0.480839, +0.482184,0.483527,0.484869,0.486210,0.487550,0.488889,0.490226,0.491563, +0.492898,0.494232,0.495565,0.496897,0.498228,0.499557,0.500885,0.502212, +0.503538,0.504863,0.506187,0.507509,0.508830,0.510150,0.511469,0.512786, +0.514103,0.515418,0.516732,0.518045,0.519356,0.520666,0.521975,0.523283, +0.524590,0.525895,0.527199,0.528502,0.529804,0.531104,0.532403,0.533701, +0.534998,0.536293,0.537587,0.538880,0.540171,0.541462,0.542751,0.544039, +0.545325,0.546610,0.547894,0.549177,0.550458,0.551738,0.553017,0.554294, +0.555570,0.556845,0.558119,0.559391,0.560662,0.561931,0.563199,0.564466, +0.565732,0.566996,0.568259,0.569521,0.570781,0.572040,0.573297,0.574553, +0.575808,0.577062,0.578314,0.579565,0.580814,0.582062,0.583309,0.584554, +0.585798,0.587040,0.588282,0.589521,0.590760,0.591997,0.593232,0.594466, +0.595699,0.596931,0.598161,0.599389,0.600616,0.601842,0.603067,0.604290, +0.605511,0.606731,0.607950,0.609167,0.610383,0.611597,0.612810,0.614022, +0.615232,0.616440,0.617647,0.618853,0.620057,0.621260,0.622461,0.623661, +0.624859,0.626056,0.627252,0.628446,0.629638,0.630829,0.632019,0.633207, +0.634393,0.635578,0.636762,0.637944,0.639124,0.640303,0.641481,0.642657, +0.643832,0.645005,0.646176,0.647346,0.648514,0.649681,0.650847,0.652011, +0.653173,0.654334,0.655493,0.656651,0.657807,0.658961,0.660114,0.661266, +0.662416,0.663564,0.664711,0.665856,0.667000,0.668142,0.669283,0.670422, +0.671559,0.672695,0.673829,0.674962,0.676093,0.677222,0.678350,0.679476, +0.680601,0.681724,0.682846,0.683965,0.685084,0.686200,0.687315,0.688429, +0.689541,0.690651,0.691759,0.692866,0.693971,0.695075,0.696177,0.697278, +0.698376,0.699473,0.700569,0.701663,0.702755,0.703845,0.704934,0.706021, +0.707107,0.708191,0.709273,0.710353,0.711432,0.712509,0.713585,0.714659, +0.715731,0.716801,0.717870,0.718937,0.720003,0.721066,0.722128,0.723188, +0.724247,0.725304,0.726359,0.727413,0.728464,0.729514,0.730563,0.731609, +0.732654,0.733697,0.734739,0.735779,0.736817,0.737853,0.738887,0.739920, +0.740951,0.741980,0.743008,0.744034,0.745058,0.746080,0.747101,0.748119, +0.749136,0.750152,0.751165,0.752177,0.753187,0.754195,0.755201,0.756206, +0.757209,0.758210,0.759209,0.760207,0.761202,0.762196,0.763188,0.764179, +0.765167,0.766154,0.767139,0.768122,0.769103,0.770083,0.771061,0.772036, +0.773010,0.773983,0.774953,0.775922,0.776888,0.777853,0.778817,0.779778, +0.780737,0.781695,0.782651,0.783605,0.784557,0.785507,0.786455,0.787402, +0.788346,0.789289,0.790230,0.791169,0.792107,0.793042,0.793975,0.794907, +0.795837,0.796765,0.797691,0.798615,0.799537,0.800458,0.801376,0.802293, +0.803208,0.804120,0.805031,0.805940,0.806848,0.807753,0.808656,0.809558, +0.810457,0.811355,0.812251,0.813144,0.814036,0.814926,0.815814,0.816701, +0.817585,0.818467,0.819348,0.820226,0.821103,0.821977,0.822850,0.823721, +0.824589,0.825456,0.826321,0.827184,0.828045,0.828904,0.829761,0.830616, +0.831470,0.832321,0.833170,0.834018,0.834863,0.835706,0.836548,0.837387, +0.838225,0.839060,0.839894,0.840725,0.841555,0.842383,0.843208,0.844032, +0.844854,0.845673,0.846491,0.847307,0.848120,0.848932,0.849742,0.850549, +0.851355,0.852159,0.852961,0.853760,0.854558,0.855354,0.856147,0.856939, +0.857729,0.858516,0.859302,0.860085,0.860867,0.861646,0.862424,0.863199, +0.863973,0.864744,0.865514,0.866281,0.867046,0.867809,0.868571,0.869330, +0.870087,0.870842,0.871595,0.872346,0.873095,0.873842,0.874587,0.875329, +0.876070,0.876809,0.877545,0.878280,0.879012,0.879743,0.880471,0.881197, +0.881921,0.882643,0.883363,0.884081,0.884797,0.885511,0.886223,0.886932, +0.887640,0.888345,0.889048,0.889750,0.890449,0.891146,0.891841,0.892534, +0.893224,0.893913,0.894599,0.895284,0.895966,0.896646,0.897325,0.898001, +0.898674,0.899346,0.900016,0.900683,0.901349,0.902012,0.902673,0.903332, +0.903989,0.904644,0.905297,0.905947,0.906596,0.907242,0.907886,0.908528, +0.909168,0.909806,0.910441,0.911075,0.911706,0.912335,0.912962,0.913587, +0.914210,0.914830,0.915449,0.916065,0.916679,0.917291,0.917901,0.918508, +0.919114,0.919717,0.920318,0.920917,0.921514,0.922109,0.922701,0.923291, +0.923880,0.924465,0.925049,0.925631,0.926210,0.926787,0.927363,0.927935, +0.928506,0.929075,0.929641,0.930205,0.930767,0.931327,0.931884,0.932440, +0.932993,0.933544,0.934093,0.934639,0.935184,0.935726,0.936266,0.936803, +0.937339,0.937872,0.938404,0.938932,0.939459,0.939984,0.940506,0.941026, +0.941544,0.942060,0.942573,0.943084,0.943593,0.944100,0.944605,0.945107, +0.945607,0.946105,0.946601,0.947094,0.947586,0.948075,0.948561,0.949046, +0.949528,0.950008,0.950486,0.950962,0.951435,0.951906,0.952375,0.952842, +0.953306,0.953768,0.954228,0.954686,0.955141,0.955594,0.956045,0.956494, +0.956940,0.957385,0.957826,0.958266,0.958703,0.959139,0.959572,0.960002, +0.960431,0.960857,0.961280,0.961702,0.962121,0.962538,0.962953,0.963366, +0.963776,0.964184,0.964590,0.964993,0.965394,0.965793,0.966190,0.966584, +0.966976,0.967366,0.967754,0.968139,0.968522,0.968903,0.969281,0.969657, +0.970031,0.970403,0.970772,0.971139,0.971504,0.971866,0.972226,0.972584, +0.972940,0.973293,0.973644,0.973993,0.974339,0.974684,0.975025,0.975365, +0.975702,0.976037,0.976370,0.976700,0.977028,0.977354,0.977677,0.977999, +0.978317,0.978634,0.978948,0.979260,0.979570,0.979877,0.980182,0.980485, +0.980785,0.981083,0.981379,0.981673,0.981964,0.982253,0.982539,0.982824, +0.983105,0.983385,0.983662,0.983937,0.984210,0.984480,0.984749,0.985014, +0.985278,0.985539,0.985798,0.986054,0.986308,0.986560,0.986809,0.987057, +0.987301,0.987544,0.987784,0.988022,0.988258,0.988491,0.988722,0.988950, +0.989177,0.989400,0.989622,0.989841,0.990058,0.990273,0.990485,0.990695, +0.990903,0.991108,0.991311,0.991511,0.991710,0.991906,0.992099,0.992291, +0.992480,0.992666,0.992850,0.993032,0.993212,0.993389,0.993564,0.993737, +0.993907,0.994075,0.994240,0.994404,0.994565,0.994723,0.994879,0.995033, +0.995185,0.995334,0.995481,0.995625,0.995767,0.995907,0.996045,0.996180, +0.996313,0.996443,0.996571,0.996697,0.996820,0.996941,0.997060,0.997176, +0.997290,0.997402,0.997511,0.997618,0.997723,0.997825,0.997925,0.998023, +0.998118,0.998211,0.998302,0.998390,0.998476,0.998559,0.998640,0.998719, +0.998795,0.998870,0.998941,0.999011,0.999078,0.999142,0.999205,0.999265, +0.999322,0.999378,0.999431,0.999481,0.999529,0.999575,0.999619,0.999660, +0.999699,0.999735,0.999769,0.999801,0.999831,0.999858,0.999882,0.999905, +0.999925,0.999942,0.999958,0.999971,0.999981,0.999989,0.999995,0.999999 +}; + +double sin( double x ) { + int index; + int quad; + + index = 1024 * x / (M_PI * 0.5); + quad = ( index >> 10 ) & 3; + index &= 1023; + switch ( quad ) { + case 0: + return sintable[index]; + case 1: + return sintable[1023-index]; + case 2: + return -sintable[index]; + case 3: + return -sintable[1023-index]; + } + return 0; +} + + +double cos( double x ) { + int index; + int quad; + + index = 1024 * x / (M_PI * 0.5); + quad = ( index >> 10 ) & 3; + index &= 1023; + switch ( quad ) { + case 3: + return sintable[index]; + case 0: + return sintable[1023-index]; + case 1: + return -sintable[index]; + case 2: + return -sintable[1023-index]; + } + return 0; +} + + +/* +void create_acostable( void ) { + int i; + FILE *fp; + float a; + + fp = fopen("c:\\acostable.txt", "w"); + fprintf(fp, "float acostable[] = {"); + for (i = 0; i < 1024; i++) { + if (!(i & 7)) + fprintf(fp, "\n"); + a = acos( (float) -1 + i / 512 ); + fprintf(fp, "%1.8f,", a); + } + fprintf(fp, "\n}\n"); + fclose(fp); +} +*/ + +float acostable[] = { +3.14159265,3.07908248,3.05317551,3.03328655,3.01651113,3.00172442,2.98834964,2.97604422, +2.96458497,2.95381690,2.94362719,2.93393068,2.92466119,2.91576615,2.90720289,2.89893629, +2.89093699,2.88318015,2.87564455,2.86831188,2.86116621,2.85419358,2.84738169,2.84071962, +2.83419760,2.82780691,2.82153967,2.81538876,2.80934770,2.80341062,2.79757211,2.79182724, +2.78617145,2.78060056,2.77511069,2.76969824,2.76435988,2.75909250,2.75389319,2.74875926, +2.74368816,2.73867752,2.73372510,2.72882880,2.72398665,2.71919677,2.71445741,2.70976688, +2.70512362,2.70052613,2.69597298,2.69146283,2.68699438,2.68256642,2.67817778,2.67382735, +2.66951407,2.66523692,2.66099493,2.65678719,2.65261279,2.64847088,2.64436066,2.64028133, +2.63623214,2.63221238,2.62822133,2.62425835,2.62032277,2.61641398,2.61253138,2.60867440, +2.60484248,2.60103507,2.59725167,2.59349176,2.58975488,2.58604053,2.58234828,2.57867769, +2.57502832,2.57139977,2.56779164,2.56420354,2.56063509,2.55708594,2.55355572,2.55004409, +2.54655073,2.54307530,2.53961750,2.53617701,2.53275354,2.52934680,2.52595650,2.52258238, +2.51922417,2.51588159,2.51255441,2.50924238,2.50594525,2.50266278,2.49939476,2.49614096, +2.49290115,2.48967513,2.48646269,2.48326362,2.48007773,2.47690482,2.47374472,2.47059722, +2.46746215,2.46433933,2.46122860,2.45812977,2.45504269,2.45196720,2.44890314,2.44585034, +2.44280867,2.43977797,2.43675809,2.43374890,2.43075025,2.42776201,2.42478404,2.42181622, +2.41885841,2.41591048,2.41297232,2.41004380,2.40712480,2.40421521,2.40131491,2.39842379, +2.39554173,2.39266863,2.38980439,2.38694889,2.38410204,2.38126374,2.37843388,2.37561237, +2.37279910,2.36999400,2.36719697,2.36440790,2.36162673,2.35885335,2.35608768,2.35332964, +2.35057914,2.34783610,2.34510044,2.34237208,2.33965094,2.33693695,2.33423003,2.33153010, +2.32883709,2.32615093,2.32347155,2.32079888,2.31813284,2.31547337,2.31282041,2.31017388, +2.30753373,2.30489988,2.30227228,2.29965086,2.29703556,2.29442632,2.29182309,2.28922580, +2.28663439,2.28404881,2.28146900,2.27889490,2.27632647,2.27376364,2.27120637,2.26865460, +2.26610827,2.26356735,2.26103177,2.25850149,2.25597646,2.25345663,2.25094195,2.24843238, +2.24592786,2.24342836,2.24093382,2.23844420,2.23595946,2.23347956,2.23100444,2.22853408, +2.22606842,2.22360742,2.22115104,2.21869925,2.21625199,2.21380924,2.21137096,2.20893709, +2.20650761,2.20408248,2.20166166,2.19924511,2.19683280,2.19442469,2.19202074,2.18962092, +2.18722520,2.18483354,2.18244590,2.18006225,2.17768257,2.17530680,2.17293493,2.17056692, +2.16820274,2.16584236,2.16348574,2.16113285,2.15878367,2.15643816,2.15409630,2.15175805, +2.14942338,2.14709226,2.14476468,2.14244059,2.14011997,2.13780279,2.13548903,2.13317865, +2.13087163,2.12856795,2.12626757,2.12397047,2.12167662,2.11938600,2.11709859,2.11481435, +2.11253326,2.11025530,2.10798044,2.10570867,2.10343994,2.10117424,2.09891156,2.09665185, +2.09439510,2.09214129,2.08989040,2.08764239,2.08539725,2.08315496,2.08091550,2.07867884, +2.07644495,2.07421383,2.07198545,2.06975978,2.06753681,2.06531651,2.06309887,2.06088387, +2.05867147,2.05646168,2.05425445,2.05204979,2.04984765,2.04764804,2.04545092,2.04325628, +2.04106409,2.03887435,2.03668703,2.03450211,2.03231957,2.03013941,2.02796159,2.02578610, +2.02361292,2.02144204,2.01927344,2.01710710,2.01494300,2.01278113,2.01062146,2.00846399, +2.00630870,2.00415556,2.00200457,1.99985570,1.99770895,1.99556429,1.99342171,1.99128119, +1.98914271,1.98700627,1.98487185,1.98273942,1.98060898,1.97848051,1.97635399,1.97422942, +1.97210676,1.96998602,1.96786718,1.96575021,1.96363511,1.96152187,1.95941046,1.95730088, +1.95519310,1.95308712,1.95098292,1.94888050,1.94677982,1.94468089,1.94258368,1.94048818, +1.93839439,1.93630228,1.93421185,1.93212308,1.93003595,1.92795046,1.92586659,1.92378433, +1.92170367,1.91962459,1.91754708,1.91547113,1.91339673,1.91132385,1.90925250,1.90718266, +1.90511432,1.90304746,1.90098208,1.89891815,1.89685568,1.89479464,1.89273503,1.89067683, +1.88862003,1.88656463,1.88451060,1.88245794,1.88040664,1.87835668,1.87630806,1.87426076, +1.87221477,1.87017008,1.86812668,1.86608457,1.86404371,1.86200412,1.85996577,1.85792866, +1.85589277,1.85385809,1.85182462,1.84979234,1.84776125,1.84573132,1.84370256,1.84167495, +1.83964848,1.83762314,1.83559892,1.83357582,1.83155381,1.82953289,1.82751305,1.82549429, +1.82347658,1.82145993,1.81944431,1.81742973,1.81541617,1.81340362,1.81139207,1.80938151, +1.80737194,1.80536334,1.80335570,1.80134902,1.79934328,1.79733848,1.79533460,1.79333164, +1.79132959,1.78932843,1.78732817,1.78532878,1.78333027,1.78133261,1.77933581,1.77733985, +1.77534473,1.77335043,1.77135695,1.76936428,1.76737240,1.76538132,1.76339101,1.76140148, +1.75941271,1.75742470,1.75543743,1.75345090,1.75146510,1.74948002,1.74749565,1.74551198, +1.74352900,1.74154672,1.73956511,1.73758417,1.73560389,1.73362426,1.73164527,1.72966692, +1.72768920,1.72571209,1.72373560,1.72175971,1.71978441,1.71780969,1.71583556,1.71386199, +1.71188899,1.70991653,1.70794462,1.70597325,1.70400241,1.70203209,1.70006228,1.69809297, +1.69612416,1.69415584,1.69218799,1.69022062,1.68825372,1.68628727,1.68432127,1.68235571, +1.68039058,1.67842588,1.67646160,1.67449772,1.67253424,1.67057116,1.66860847,1.66664615, +1.66468420,1.66272262,1.66076139,1.65880050,1.65683996,1.65487975,1.65291986,1.65096028, +1.64900102,1.64704205,1.64508338,1.64312500,1.64116689,1.63920905,1.63725148,1.63529416, +1.63333709,1.63138026,1.62942366,1.62746728,1.62551112,1.62355517,1.62159943,1.61964388, +1.61768851,1.61573332,1.61377831,1.61182346,1.60986877,1.60791422,1.60595982,1.60400556, +1.60205142,1.60009739,1.59814349,1.59618968,1.59423597,1.59228235,1.59032882,1.58837536, +1.58642196,1.58446863,1.58251535,1.58056211,1.57860891,1.57665574,1.57470259,1.57274945, +1.57079633,1.56884320,1.56689007,1.56493692,1.56298375,1.56103055,1.55907731,1.55712403, +1.55517069,1.55321730,1.55126383,1.54931030,1.54735668,1.54540297,1.54344917,1.54149526, +1.53954124,1.53758710,1.53563283,1.53367843,1.53172389,1.52976919,1.52781434,1.52585933, +1.52390414,1.52194878,1.51999323,1.51803748,1.51608153,1.51412537,1.51216900,1.51021240, +1.50825556,1.50629849,1.50434117,1.50238360,1.50042576,1.49846765,1.49650927,1.49455060, +1.49259163,1.49063237,1.48867280,1.48671291,1.48475270,1.48279215,1.48083127,1.47887004, +1.47690845,1.47494650,1.47298419,1.47102149,1.46905841,1.46709493,1.46513106,1.46316677, +1.46120207,1.45923694,1.45727138,1.45530538,1.45333893,1.45137203,1.44940466,1.44743682, +1.44546850,1.44349969,1.44153038,1.43956057,1.43759024,1.43561940,1.43364803,1.43167612, +1.42970367,1.42773066,1.42575709,1.42378296,1.42180825,1.41983295,1.41785705,1.41588056, +1.41390346,1.41192573,1.40994738,1.40796840,1.40598877,1.40400849,1.40202755,1.40004594, +1.39806365,1.39608068,1.39409701,1.39211264,1.39012756,1.38814175,1.38615522,1.38416795, +1.38217994,1.38019117,1.37820164,1.37621134,1.37422025,1.37222837,1.37023570,1.36824222, +1.36624792,1.36425280,1.36225684,1.36026004,1.35826239,1.35626387,1.35426449,1.35226422, +1.35026307,1.34826101,1.34625805,1.34425418,1.34224937,1.34024364,1.33823695,1.33622932, +1.33422072,1.33221114,1.33020059,1.32818904,1.32617649,1.32416292,1.32214834,1.32013273, +1.31811607,1.31609837,1.31407960,1.31205976,1.31003885,1.30801684,1.30599373,1.30396951, +1.30194417,1.29991770,1.29789009,1.29586133,1.29383141,1.29180031,1.28976803,1.28773456, +1.28569989,1.28366400,1.28162688,1.27958854,1.27754894,1.27550809,1.27346597,1.27142257, +1.26937788,1.26733189,1.26528459,1.26323597,1.26118602,1.25913471,1.25708205,1.25502803, +1.25297262,1.25091583,1.24885763,1.24679802,1.24473698,1.24267450,1.24061058,1.23854519, +1.23647833,1.23440999,1.23234015,1.23026880,1.22819593,1.22612152,1.22404557,1.22196806, +1.21988898,1.21780832,1.21572606,1.21364219,1.21155670,1.20946958,1.20738080,1.20529037, +1.20319826,1.20110447,1.19900898,1.19691177,1.19481283,1.19271216,1.19060973,1.18850553, +1.18639955,1.18429178,1.18218219,1.18007079,1.17795754,1.17584244,1.17372548,1.17160663, +1.16948589,1.16736324,1.16523866,1.16311215,1.16098368,1.15885323,1.15672081,1.15458638, +1.15244994,1.15031147,1.14817095,1.14602836,1.14388370,1.14173695,1.13958808,1.13743709, +1.13528396,1.13312866,1.13097119,1.12881153,1.12664966,1.12448556,1.12231921,1.12015061, +1.11797973,1.11580656,1.11363107,1.11145325,1.10927308,1.10709055,1.10490563,1.10271831, +1.10052856,1.09833638,1.09614174,1.09394462,1.09174500,1.08954287,1.08733820,1.08513098, +1.08292118,1.08070879,1.07849378,1.07627614,1.07405585,1.07183287,1.06960721,1.06737882, +1.06514770,1.06291382,1.06067715,1.05843769,1.05619540,1.05395026,1.05170226,1.04945136, +1.04719755,1.04494080,1.04268110,1.04041841,1.03815271,1.03588399,1.03361221,1.03133735, +1.02905939,1.02677830,1.02449407,1.02220665,1.01991603,1.01762219,1.01532509,1.01302471, +1.01072102,1.00841400,1.00610363,1.00378986,1.00147268,0.99915206,0.99682798,0.99450039, +0.99216928,0.98983461,0.98749636,0.98515449,0.98280898,0.98045980,0.97810691,0.97575030, +0.97338991,0.97102573,0.96865772,0.96628585,0.96391009,0.96153040,0.95914675,0.95675912, +0.95436745,0.95197173,0.94957191,0.94716796,0.94475985,0.94234754,0.93993099,0.93751017, +0.93508504,0.93265556,0.93022170,0.92778341,0.92534066,0.92289341,0.92044161,0.91798524, +0.91552424,0.91305858,0.91058821,0.90811309,0.90563319,0.90314845,0.90065884,0.89816430, +0.89566479,0.89316028,0.89065070,0.88813602,0.88561619,0.88309116,0.88056088,0.87802531, +0.87548438,0.87293806,0.87038629,0.86782901,0.86526619,0.86269775,0.86012366,0.85754385, +0.85495827,0.85236686,0.84976956,0.84716633,0.84455709,0.84194179,0.83932037,0.83669277, +0.83405893,0.83141877,0.82877225,0.82611928,0.82345981,0.82079378,0.81812110,0.81544172, +0.81275556,0.81006255,0.80736262,0.80465570,0.80194171,0.79922057,0.79649221,0.79375655, +0.79101352,0.78826302,0.78550497,0.78273931,0.77996593,0.77718475,0.77439569,0.77159865, +0.76879355,0.76598029,0.76315878,0.76032891,0.75749061,0.75464376,0.75178826,0.74892402, +0.74605092,0.74316887,0.74027775,0.73737744,0.73446785,0.73154885,0.72862033,0.72568217, +0.72273425,0.71977644,0.71680861,0.71383064,0.71084240,0.70784376,0.70483456,0.70181469, +0.69878398,0.69574231,0.69268952,0.68962545,0.68654996,0.68346288,0.68036406,0.67725332, +0.67413051,0.67099544,0.66784794,0.66468783,0.66151492,0.65832903,0.65512997,0.65191753, +0.64869151,0.64545170,0.64219789,0.63892987,0.63564741,0.63235028,0.62903824,0.62571106, +0.62236849,0.61901027,0.61563615,0.61224585,0.60883911,0.60541564,0.60197515,0.59851735, +0.59504192,0.59154856,0.58803694,0.58450672,0.58095756,0.57738911,0.57380101,0.57019288, +0.56656433,0.56291496,0.55924437,0.55555212,0.55183778,0.54810089,0.54434099,0.54055758, +0.53675018,0.53291825,0.52906127,0.52517867,0.52126988,0.51733431,0.51337132,0.50938028, +0.50536051,0.50131132,0.49723200,0.49312177,0.48897987,0.48480547,0.48059772,0.47635573, +0.47207859,0.46776530,0.46341487,0.45902623,0.45459827,0.45012983,0.44561967,0.44106652, +0.43646903,0.43182577,0.42713525,0.42239588,0.41760600,0.41276385,0.40786755,0.40291513, +0.39790449,0.39283339,0.38769946,0.38250016,0.37723277,0.37189441,0.36648196,0.36099209, +0.35542120,0.34976542,0.34402054,0.33818204,0.33224495,0.32620390,0.32005298,0.31378574, +0.30739505,0.30087304,0.29421096,0.28739907,0.28042645,0.27328078,0.26594810,0.25841250, +0.25065566,0.24265636,0.23438976,0.22582651,0.21693146,0.20766198,0.19796546,0.18777575, +0.17700769,0.16554844,0.15324301,0.13986823,0.12508152,0.10830610,0.08841715,0.06251018, +} + +double acos( double x ) { + int index; + + if (x < -1) + x = -1; + if (x > 1) + x = 1; + index = (float) (1.0 + x) * 511.9; + return acostable[index]; +} + +double atan2( double y, double x ) { + float base; + float temp; + float dir; + float test; + int i; + + if ( x < 0 ) { + if ( y >= 0 ) { + // quad 1 + base = M_PI / 2; + temp = x; + x = y; + y = -temp; + } else { + // quad 2 + base = M_PI; + x = -x; + y = -y; + } + } else { + if ( y < 0 ) { + // quad 3 + base = 3 * M_PI / 2; + temp = x; + x = -y; + y = temp; + } + } + + if ( y > x ) { + base += M_PI/2; + temp = x; + x = y; + y = temp; + dir = -1; + } else { + dir = 1; + } + + // calcualte angle in octant 0 + if ( x == 0 ) { + return base; + } + y /= x; + + for ( i = 0 ; i < 512 ; i++ ) { + test = sintable[i] / sintable[1023-i]; + if ( test > y ) { + break; + } + } + + return base + dir * i * ( M_PI/2048); +} + + +#endif + +/* +=============== +powN + +Raise a double to a integer power +=============== +*/ +static double powN( double base, int exp ) +{ + if( exp >= 0 ) + { + double result = 1.0; + + // calculate x, x^2, x^4, ... by repeated squaring + // and multiply together the ones corresponding to the + // binary digits of the exponent + // e.g. x^73 = x^(1 + 8 + 64) = x * x^8 * x^64 + while( exp > 0 ) + { + if( exp % 2 == 1 ) + result *= base; + + base *= base; + exp /= 2; + } + + return result; + } + // if exp is INT_MIN, the next clause will be upset, + // because -exp isn't representable + else if( exp == INT_MIN ) + return powN( base, exp + 1 ) / base; + // x < 0 + else + return 1.0 / powN( base, -exp ); +} + +double tan( double x ) { + return sin(x) / cos(x); +} + + +static int randSeed = 0; + +void srand( unsigned seed ) { + randSeed = seed; +} + +int rand( void ) { + randSeed = (69069 * randSeed + 1); + return randSeed & 0x7fff; +} + +double atof( const char *string ) { + float sign; + float value; + int c; + + + // skip whitespace + while ( *string <= ' ' ) { + if ( !*string ) { + return 0; + } + string++; + } + + // check sign + switch ( *string ) { + case '+': + string++; + sign = 1; + break; + case '-': + string++; + sign = -1; + break; + default: + sign = 1; + break; + } + + // read digits + value = 0; + c = string[0]; + if ( c != '.' ) { + do { + c = *string++; + if ( c < '0' || c > '9' ) { + break; + } + c -= '0'; + value = value * 10 + c; + } while ( 1 ); + } else { + string++; + } + + // check for decimal point + if ( c == '.' ) { + double fraction; + + fraction = 0.1; + do { + c = *string++; + if ( c < '0' || c > '9' ) { + break; + } + c -= '0'; + value += c * fraction; + fraction *= 0.1; + } while ( 1 ); + + } + + // not handling 10e10 notation... + + return value * sign; +} + +double _atof( const char **stringPtr ) { + const char *string; + float sign; + float value; + int c = '0'; + + string = *stringPtr; + + // skip whitespace + while ( *string <= ' ' ) { + if ( !*string ) { + *stringPtr = string; + return 0; + } + string++; + } + + // check sign + switch ( *string ) { + case '+': + string++; + sign = 1; + break; + case '-': + string++; + sign = -1; + break; + default: + sign = 1; + break; + } + + // read digits + value = 0; + if ( string[0] != '.' ) { + do { + c = *string++; + if ( c < '0' || c > '9' ) { + break; + } + c -= '0'; + value = value * 10 + c; + } while ( 1 ); + } + + // check for decimal point + if ( c == '.' ) { + double fraction; + + fraction = 0.1; + do { + c = *string++; + if ( c < '0' || c > '9' ) { + break; + } + c -= '0'; + value += c * fraction; + fraction *= 0.1; + } while ( 1 ); + + } + + // not handling 10e10 notation... + *stringPtr = string; + + return value * sign; +} + +/* +============== +strtod + +Without an errno variable, this is a fair bit less useful than it is in libc +but it's still a fair bit more capable than atof or _atof +Handles inf[inity], nan (ignoring case), hexadecimals, and decimals +Handles decimal exponents like 10e10 and hex exponents like 0x7f8p20 +10e10 == 10000000000 (power of ten) +0x7f8p20 == 0x7f800000 (decimal power of two) +The variable pointed to by endptr will hold the location of the first character +in the nptr string that was not used in the conversion +============== +*/ +double strtod( const char *nptr, char **endptr ) +{ + double res; + qboolean neg = qfalse; + + // skip whitespace + while( isspace( *nptr ) ) + nptr++; + + // special string parsing + if( Q_stricmpn( nptr, "nan", 3 ) == 0 ) + { + floatint_t nan; + + if( endptr ) + *endptr = (char *)&nptr[3]; + + // nan can be followed by a bracketed number (in hex, octal, + // or decimal) which is then put in the mantissa + // this can be used to generate signalling or quiet NaNs, for + // example (though I doubt it'll ever be used) + // note that nan(0) is infinity! + if( nptr[3] == '(' ) + { + char *end; + int mantissa = strtol( &nptr[4], &end, 0 ); + if( *end == ')' ) + { + nan.ui = 0x7f800000 | ( mantissa & 0x7fffff ); + if( endptr ) + *endptr = &end[1]; + return nan.f; + } + } + nan.ui = 0x7fffffff; + return nan.f; + } + if( Q_stricmpn( nptr, "inf", 3 ) == 0 ) + { + floatint_t inf; + inf.ui = 0x7f800000; + if( endptr == NULL ) + return inf.f; + if( Q_stricmpn( &nptr[3], "inity", 5 ) == 0 ) + *endptr = (char *)&nptr[8]; + else + *endptr = (char *)&nptr[3]; + return inf.f; + } + + // normal numeric parsing + // sign + if( *nptr == '-' ) + { + nptr++; + neg = qtrue; + } + else if( *nptr == '+' ) + nptr++; + // hex + if( Q_stricmpn( nptr, "0x", 2 ) == 0 ) + { + // track if we use any digits + const char *s = &nptr[1], *end = s; + nptr += 2; + res = 0; + while( qtrue ) + { + if( isdigit( *nptr ) ) + res = 16 * res + ( *nptr++ - '0' ); + else if( *nptr >= 'A' && *nptr <= 'F' ) + res = 16 * res + 10 + *nptr++ - 'A'; + else if( *nptr >= 'a' && *nptr <= 'f' ) + res = 16 * res + 10 + *nptr++ - 'a'; + else + break; + } + // if nptr moved, save it + if( end + 1 < nptr ) + end = nptr; + if( *nptr == '.' ) + { + float place; + nptr++; + // 1.0 / 16.0 == 0.0625 + // I don't expect the float accuracy to hold out for + // very long but since we need to know the length of + // the string anyway we keep on going regardless + for( place = 0.0625;; place /= 16.0 ) + { + if( isdigit( *nptr ) ) + res += place * ( *nptr++ - '0' ); + else if( *nptr >= 'A' && *nptr <= 'F' ) + res += place * ( 10 + *nptr++ - 'A' ); + else if( *nptr >= 'a' && *nptr <= 'f' ) + res += place * ( 10 + *nptr++ - 'a' ); + else + break; + } + if( end < nptr ) + end = nptr; + } + // parse an optional exponent, representing multiplication + // by a power of two + // exponents are only valid if we encountered at least one + // digit already (and have therefore set end to something) + if( end != s && tolower( *nptr ) == 'p' ) + { + int exp; + // apparently (confusingly) the exponent should be + // decimal + exp = strtol( &nptr[1], (char **)&end, 10 ); + if( &nptr[1] == end ) + { + // no exponent + if( endptr ) + *endptr = (char *)nptr; + return res; + } + + res *= powN( 2, exp ); + } + if( endptr ) + *endptr = (char *)end; + return res; + } + // decimal + else + { + // track if we find any digits + const char *end = nptr, *p = nptr; + // this is most of the work + for( res = 0; isdigit( *nptr ); + res = 10 * res + *nptr++ - '0' ); + // if nptr moved, we read something + if( end < nptr ) + end = nptr; + if( *nptr == '.' ) + { + // fractional part + float place; + nptr++; + for( place = 0.1; isdigit( *nptr ); place /= 10.0 ) + res += ( *nptr++ - '0' ) * place; + // if nptr moved, we read something + if( end + 1 < nptr ) + end = nptr; + } + // exponent + // meaningless without having already read digits, so check + // we've set end to something + if( p != end && tolower( *nptr ) == 'e' ) + { + int exp; + exp = strtol( &nptr[1], (char **)&end, 10 ); + if( &nptr[1] == end ) + { + // no exponent + if( endptr ) + *endptr = (char *)nptr; + return res; + } + + res *= powN( 10, exp ); + } + if( endptr ) + *endptr = (char *)end; + return res; + } +} + +int atoi( const char *string ) { + int sign; + int value; + int c; + + + // skip whitespace + while ( *string <= ' ' ) { + if ( !*string ) { + return 0; + } + string++; + } + + // check sign + switch ( *string ) { + case '+': + string++; + sign = 1; + break; + case '-': + string++; + sign = -1; + break; + default: + sign = 1; + break; + } + + // read digits + value = 0; + do { + c = *string++; + if ( c < '0' || c > '9' ) { + break; + } + c -= '0'; + value = value * 10 + c; + } while ( 1 ); + + // not handling 10e10 notation... + + return value * sign; +} + + +int _atoi( const char **stringPtr ) { + int sign; + int value; + int c; + const char *string; + + string = *stringPtr; + + // skip whitespace + while ( *string <= ' ' ) { + if ( !*string ) { + return 0; + } + string++; + } + + // check sign + switch ( *string ) { + case '+': + string++; + sign = 1; + break; + case '-': + string++; + sign = -1; + break; + default: + sign = 1; + break; + } + + // read digits + value = 0; + do { + c = *string++; + if ( c < '0' || c > '9' ) { + break; + } + c -= '0'; + value = value * 10 + c; + } while ( 1 ); + + // not handling 10e10 notation... + + *stringPtr = string; + + return value * sign; +} + +/* +============== +strtol + +Handles any base from 2 to 36. If base is 0 then it guesses +decimal, hex, or octal based on the format of the number (leading 0 or 0x) +Will not overflow - returns LONG_MIN or LONG_MAX as appropriate +*endptr is set to the location of the first character not used +============== +*/ +long strtol( const char *nptr, char **endptr, int base ) +{ + long res; + qboolean pos = qtrue; + + if( endptr ) + *endptr = (char *)nptr; + // bases other than 0, 2, 8, 16 are very rarely used, but they're + // not much extra effort to support + if( base < 0 || base == 1 || base > 36 ) + return 0; + // skip leading whitespace + while( isspace( *nptr ) ) + nptr++; + // sign + if( *nptr == '-' ) + { + nptr++; + pos = qfalse; + } + else if( *nptr == '+' ) + nptr++; + // look for base-identifying sequences e.g. 0x for hex, 0 for octal + if( nptr[0] == '0' ) + { + nptr++; + // 0 is always a valid digit + if( endptr ) + *endptr = (char *)nptr; + if( *nptr == 'x' || *nptr == 'X' ) + { + if( base != 0 && base != 16 ) + { + // can't be hex, reject x (accept 0) + if( endptr ) + *endptr = (char *)nptr; + return 0; + } + nptr++; + base = 16; + } + else if( base == 0 ) + base = 8; + } + else if( base == 0 ) + base = 10; + res = 0; + while( qtrue ) + { + int val; + if( isdigit( *nptr ) ) + val = *nptr - '0'; + else if( islower( *nptr ) ) + val = 10 + *nptr - 'a'; + else if( isupper( *nptr ) ) + val = 10 + *nptr - 'A'; + else + break; + if( val >= base ) + break; + // we go negative because LONG_MIN is further from 0 than + // LONG_MAX + if( res < ( LONG_MIN + val ) / base ) + res = LONG_MIN; // overflow + else + res = res * base - val; + nptr++; + if( endptr ) + *endptr = (char *)nptr; + } + if( pos ) + { + // can't represent LONG_MIN positive + if( res == LONG_MIN ) + res = LONG_MAX; + else + res = -res; + } + return res; +} + +int abs( int n ) { + return n < 0 ? -n : n; +} + +double fabs( double x ) { + return x < 0 ? -x : x; +} + + + +//========================================================= + +/* + * New implementation by Patrick Powell and others for vsnprintf. + * Supports length checking in strings. +*/ + +/* + * Copyright Patrick Powell 1995 + * This code is based on code written by Patrick Powell (papowell@astart.com) + * It may be used for any purpose as long as this notice remains intact + * on all source code distributions + */ + +/************************************************************** + * Original: + * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 + * A bombproof version of doprnt (dopr) included. + * Sigh. This sort of thing is always nasty do deal with. Note that + * the version here does not include floating point... + * + * snprintf() is used instead of sprintf() as it does limit checks + * for string length. This covers a nasty loophole. + * + * The other functions are there to prevent NULL pointers from + * causing nast effects. + * + * More Recently: + * Brandon Long 9/15/96 for mutt 0.43 + * This was ugly. It is still ugly. I opted out of floating point + * numbers, but the formatter understands just about everything + * from the normal C string format, at least as far as I can tell from + * the Solaris 2.5 printf(3S) man page. + * + * Brandon Long 10/22/97 for mutt 0.87.1 + * Ok, added some minimal floating point support, which means this + * probably requires libm on most operating systems. Don't yet + * support the exponent (e,E) and sigfig (g,G). Also, fmtint() + * was pretty badly broken, it just wasn't being exercised in ways + * which showed it, so that's been fixed. Also, formated the code + * to mutt conventions, and removed dead code left over from the + * original. Also, there is now a builtin-test, just compile with: + * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm + * and run snprintf for results. + * + * Thomas Roessler 01/27/98 for mutt 0.89i + * The PGP code was using unsigned hexadecimal formats. + * Unfortunately, unsigned formats simply didn't work. + * + * Michael Elkins 03/05/98 for mutt 0.90.8 + * The original code assumed that both snprintf() and vsnprintf() were + * missing. Some systems only have snprintf() but not vsnprintf(), so + * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. + * + * Andrew Tridgell (tridge@samba.org) Oct 1998 + * fixed handling of %.0f + * added test for HAVE_LONG_DOUBLE + * + * Russ Allbery 2000-08-26 + * fixed return value to comply with C99 + * fixed handling of snprintf(NULL, ...) + * + * Hrvoje Niksic 2000-11-04 + * include instead of "config.h". + * moved TEST_SNPRINTF stuff out of HAVE_SNPRINTF ifdef. + * include for NULL. + * added support and test cases for long long. + * don't declare argument types to (v)snprintf if stdarg is not used. + * use int instead of short int as 2nd arg to va_arg. + * + **************************************************************/ + +/* BDR 2002-01-13 %e and %g were being ignored. Now do something, + if not necessarily correctly */ + +#if (SIZEOF_LONG_DOUBLE > 0) +/* #ifdef HAVE_LONG_DOUBLE */ +#define LDOUBLE long double +#else +#define LDOUBLE double +#endif + +#if (SIZEOF_LONG_LONG > 0) +/* #ifdef HAVE_LONG_LONG */ +# define LLONG long long +#else +# define LLONG long +#endif + +static int dopr (char *buffer, size_t maxlen, const char *format, + va_list args); +static int fmtstr (char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max); +static int fmtint (char *buffer, size_t *currlen, size_t maxlen, + LLONG value, int base, int min, int max, int flags); +static int fmtfp (char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags); +static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); + +/* + * dopr(): poor man's version of doprintf + */ + +/* format read states */ +#define DP_S_DEFAULT 0 +#define DP_S_FLAGS 1 +#define DP_S_MIN 2 +#define DP_S_DOT 3 +#define DP_S_MAX 4 +#define DP_S_MOD 5 +#define DP_S_MOD_L 6 +#define DP_S_CONV 7 +#define DP_S_DONE 8 + +/* format flags - Bits */ +#define DP_F_MINUS (1 << 0) +#define DP_F_PLUS (1 << 1) +#define DP_F_SPACE (1 << 2) +#define DP_F_NUM (1 << 3) +#define DP_F_ZERO (1 << 4) +#define DP_F_UP (1 << 5) +#define DP_F_UNSIGNED (1 << 6) + +/* Conversion Flags */ +#define DP_C_SHORT 1 +#define DP_C_LONG 2 +#define DP_C_LLONG 3 +#define DP_C_LDOUBLE 4 + +#define char_to_int(p) (p - '0') + +static int dopr (char *buffer, size_t maxlen, const char *format, va_list args) +{ + char ch; + LLONG value; + LDOUBLE fvalue; + char *strvalue; + int min; + int max; + int state; + int flags; + int cflags; + int total; + size_t currlen; + + state = DP_S_DEFAULT; + currlen = flags = cflags = min = 0; + max = -1; + ch = *format++; + total = 0; + + while (state != DP_S_DONE) + { + if (ch == '\0') + state = DP_S_DONE; + + switch(state) + { + case DP_S_DEFAULT: + if (ch == '%') + state = DP_S_FLAGS; + else + total += dopr_outch (buffer, &currlen, maxlen, ch); + ch = *format++; + break; + case DP_S_FLAGS: + switch (ch) + { + case '-': + flags |= DP_F_MINUS; + ch = *format++; + break; + case '+': + flags |= DP_F_PLUS; + ch = *format++; + break; + case ' ': + flags |= DP_F_SPACE; + ch = *format++; + break; + case '#': + flags |= DP_F_NUM; + ch = *format++; + break; + case '0': + flags |= DP_F_ZERO; + ch = *format++; + break; + default: + state = DP_S_MIN; + break; + } + break; + case DP_S_MIN: + if ('0' <= ch && ch <= '9') + { + min = 10*min + char_to_int (ch); + ch = *format++; + } + else if (ch == '*') + { + min = va_arg (args, int); + ch = *format++; + state = DP_S_DOT; + } + else + state = DP_S_DOT; + break; + case DP_S_DOT: + if (ch == '.') + { + state = DP_S_MAX; + ch = *format++; + } + else + state = DP_S_MOD; + break; + case DP_S_MAX: + if ('0' <= ch && ch <= '9') + { + if (max < 0) + max = 0; + max = 10*max + char_to_int (ch); + ch = *format++; + } + else if (ch == '*') + { + max = va_arg (args, int); + ch = *format++; + state = DP_S_MOD; + } + else + state = DP_S_MOD; + break; + case DP_S_MOD: + switch (ch) + { + case 'h': + cflags = DP_C_SHORT; + ch = *format++; + break; + case 'l': + cflags = DP_C_LONG; + ch = *format++; + break; + case 'L': + cflags = DP_C_LDOUBLE; + ch = *format++; + break; + default: + break; + } + if (cflags != DP_C_LONG) + state = DP_S_CONV; + else + state = DP_S_MOD_L; + break; + case DP_S_MOD_L: + switch (ch) + { + case 'l': + cflags = DP_C_LLONG; + ch = *format++; + break; + default: + break; + } + state = DP_S_CONV; + break; + case DP_S_CONV: + switch (ch) + { + case 'd': + case 'i': + if (cflags == DP_C_SHORT) + value = (short int)va_arg (args, int); + else if (cflags == DP_C_LONG) + value = va_arg (args, long int); + else if (cflags == DP_C_LLONG) + value = va_arg (args, LLONG); + else + value = va_arg (args, int); + total += fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'o': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) +// value = (unsigned short int) va_arg (args, unsigned short int); // Thilo: This does not work because the rcc compiler cannot do that cast correctly. + value = va_arg (args, unsigned int) & ( (1 << sizeof(unsigned short int) * 8) - 1); // Using this workaround instead. + else if (cflags == DP_C_LONG) + value = va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = va_arg (args, unsigned LLONG); + else + value = va_arg (args, unsigned int); + total += fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); + break; + case 'u': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int) & ( (1 << sizeof(unsigned short int) * 8) - 1); + else if (cflags == DP_C_LONG) + value = va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = va_arg (args, unsigned LLONG); + else + value = va_arg (args, unsigned int); + total += fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'X': + flags |= DP_F_UP; + case 'x': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int) & ( (1 << sizeof(unsigned short int) * 8) - 1); + else if (cflags == DP_C_LONG) + value = va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = va_arg (args, unsigned LLONG); + else + value = va_arg (args, unsigned int); + total += fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); + break; + case 'f': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + /* um, floating point? */ + total += fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'E': + flags |= DP_F_UP; + case 'e': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + /* um, floating point? */ + total += fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'G': + flags |= DP_F_UP; + case 'g': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + /* um, floating point? */ + total += fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'c': + total += dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); + break; + case 's': + strvalue = va_arg (args, char *); + total += fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); + break; + case 'p': + strvalue = va_arg (args, void *); + total += fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, + max, flags); + break; + case 'n': + if (cflags == DP_C_SHORT) + { + short int *num; + num = va_arg (args, short int *); + *num = currlen; + } + else if (cflags == DP_C_LONG) + { + long int *num; + num = va_arg (args, long int *); + *num = currlen; + } + else if (cflags == DP_C_LLONG) + { + LLONG *num; + num = va_arg (args, LLONG *); + *num = currlen; + } + else + { + int *num; + num = va_arg (args, int *); + *num = currlen; + } + break; + case '%': + total += dopr_outch (buffer, &currlen, maxlen, ch); + break; + case 'w': + /* not supported yet, treat as next char */ + ch = *format++; + break; + default: + /* Unknown, skip */ + break; + } + ch = *format++; + state = DP_S_DEFAULT; + flags = cflags = min = 0; + max = -1; + break; + case DP_S_DONE: + break; + default: + /* hmm? */ + break; /* some picky compilers need this */ + } + } + if (maxlen > 0) + buffer[currlen] = '\0'; + return total; +} + +static int fmtstr (char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max) +{ + int padlen, strln; /* amount to pad */ + int cnt = 0; + int total = 0; + + if (value == 0) + { + value = ""; + } + + for (strln = 0; value[strln]; ++strln); /* strlen */ + if (max >= 0 && max < strln) + strln = max; + padlen = min - strln; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justify */ + + while (padlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + } + while (*value && ((max < 0) || (cnt < max))) + { + total += dopr_outch (buffer, currlen, maxlen, *value++); + ++cnt; + } + while (padlen < 0) + { + total += dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + } + return total; +} + +/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ + +static int fmtint (char *buffer, size_t *currlen, size_t maxlen, + LLONG value, int base, int min, int max, int flags) +{ + int signvalue = 0; + unsigned LLONG uvalue; + char convert[24]; + int place = 0; + int spadlen = 0; /* amount to space pad */ + int zpadlen = 0; /* amount to zero pad */ + const char *digits; + int total = 0; + + if (max < 0) + max = 0; + + uvalue = value; + + if(!(flags & DP_F_UNSIGNED)) + { + if( value < 0 ) { + signvalue = '-'; + uvalue = -value; + } + else + if (flags & DP_F_PLUS) /* Do a sign (+/i) */ + signvalue = '+'; + else + if (flags & DP_F_SPACE) + signvalue = ' '; + } + + if (flags & DP_F_UP) + /* Should characters be upper case? */ + digits = "0123456789ABCDEF"; + else + digits = "0123456789abcdef"; + + do { + convert[place++] = digits[uvalue % (unsigned)base]; + uvalue = (uvalue / (unsigned)base ); + } while(uvalue && (place < sizeof (convert))); + if (place == sizeof (convert)) place--; + convert[place] = 0; + + zpadlen = max - place; + spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); + if (zpadlen < 0) zpadlen = 0; + if (spadlen < 0) spadlen = 0; + if (flags & DP_F_ZERO) + { + zpadlen = MAX(zpadlen, spadlen); + spadlen = 0; + } + if (flags & DP_F_MINUS) + spadlen = -spadlen; /* Left Justifty */ + +#ifdef DEBUG_SNPRINTF + dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", + zpadlen, spadlen, min, max, place)); +#endif + + /* Spaces */ + while (spadlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, ' '); + --spadlen; + } + + /* Sign */ + if (signvalue) + total += dopr_outch (buffer, currlen, maxlen, signvalue); + + /* Zeros */ + if (zpadlen > 0) + { + while (zpadlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + } + + /* Digits */ + while (place > 0) + total += dopr_outch (buffer, currlen, maxlen, convert[--place]); + + /* Left Justified spaces */ + while (spadlen < 0) { + total += dopr_outch (buffer, currlen, maxlen, ' '); + ++spadlen; + } + + return total; +} + +static LDOUBLE abs_val (LDOUBLE value) +{ + LDOUBLE result = value; + + if (value < 0) + result = -value; + + return result; +} + +static long round (LDOUBLE value) +{ + long intpart; + + intpart = value; + value = value - intpart; + if (value >= 0.5) + intpart++; + + return intpart; +} + +static int fmtfp (char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags) +{ + int signvalue = 0; + LDOUBLE ufvalue; + char iconvert[20]; + char fconvert[20]; + int iplace = 0; + int fplace = 0; + int padlen = 0; /* amount to pad */ + int zpadlen = 0; + int caps = 0; + int total = 0; + long intpart; + long fracpart; + + /* + * AIX manpage says the default is 0, but Solaris says the default + * is 6, and sprintf on AIX defaults to 6 + */ + if (max < 0) + max = 6; + + ufvalue = abs_val (fvalue); + + if (fvalue < 0) + signvalue = '-'; + else + if (flags & DP_F_PLUS) /* Do a sign (+/i) */ + signvalue = '+'; + else + if (flags & DP_F_SPACE) + signvalue = ' '; + +#if 0 + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ +#endif + + intpart = ufvalue; + + /* + * Sorry, we only support 9 digits past the decimal because of our + * conversion method + */ + if (max > 9) + max = 9; + + /* We "cheat" by converting the fractional part to integer by + * multiplying by a factor of 10 + */ + fracpart = round ((powN (10, max)) * (ufvalue - intpart)); + + if (fracpart >= powN (10, max)) + { + intpart++; + fracpart -= powN (10, max); + } + +#ifdef DEBUG_SNPRINTF + dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart)); +#endif + + /* Convert integer part */ + do { + iconvert[iplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10]; + intpart = (intpart / 10); + } while(intpart && (iplace < 20)); + if (iplace == 20) iplace--; + iconvert[iplace] = 0; + + /* Convert fractional part */ + do { + fconvert[fplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; + fracpart = (fracpart / 10); + } while(fracpart && (fplace < 20)); + if (fplace == 20) fplace--; + fconvert[fplace] = 0; + + /* -1 for decimal point, another -1 if we are printing a sign */ + padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); + zpadlen = max - fplace; + if (zpadlen < 0) + zpadlen = 0; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justifty */ + + if ((flags & DP_F_ZERO) && (padlen > 0)) + { + if (signvalue) + { + total += dopr_outch (buffer, currlen, maxlen, signvalue); + --padlen; + signvalue = 0; + } + while (padlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, '0'); + --padlen; + } + } + while (padlen > 0) + { + total += dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + } + if (signvalue) + total += dopr_outch (buffer, currlen, maxlen, signvalue); + + while (iplace > 0) + total += dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); + + /* + * Decimal point. This should probably use locale to find the correct + * char to print out. + */ + if (max > 0) + { + total += dopr_outch (buffer, currlen, maxlen, '.'); + + while (zpadlen-- > 0) + total += dopr_outch (buffer, currlen, maxlen, '0'); + + while (fplace > 0) + total += dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); + } + + while (padlen < 0) + { + total += dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + } + + return total; +} + +static int dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c) +{ + if (*currlen + 1 < maxlen) + buffer[(*currlen)++] = c; + return 1; +} + +int Q_vsnprintf(char *str, size_t length, const char *fmt, va_list args) +{ + return dopr(str, length, fmt, args); +} + +/* this is really crappy */ +int sscanf( const char *buffer, const char *fmt, ... ) { + int cmd; + va_list ap; + int count; + size_t len; + + va_start (ap, fmt); + count = 0; + + while ( *fmt ) { + if ( fmt[0] != '%' ) { + fmt++; + continue; + } + + fmt++; + cmd = *fmt; + + if (isdigit (cmd)) { + len = (size_t)_atoi (&fmt); + cmd = *(fmt - 1); + } else { + len = MAX_STRING_CHARS - 1; + fmt++; + } + + switch ( cmd ) { + case 'i': + case 'd': + case 'u': + *(va_arg (ap, int *)) = _atoi( &buffer ); + break; + case 'f': + *(va_arg (ap, float *)) = _atof( &buffer ); + break; + case 's': + { + char *s = va_arg (ap, char *); + while (isspace (*buffer)) + buffer++; + while (*buffer && !isspace (*buffer) && len-- > 0 ) + *s++ = *buffer++; + *s++ = '\0'; + break; + } + } + } + + va_end (ap); + return count; +} + +#endif diff --git a/code/game/bg_local.h b/code/game/bg_local.h new file mode 100644 index 00000000..143d2f5d --- /dev/null +++ b/code/game/bg_local.h @@ -0,0 +1,88 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// bg_local.h -- local definitions for the bg (both games) files + +#define MIN_WALK_NORMAL 0.7f // can't walk on very steep slopes + +#define JUMP_VELOCITY 270 + +#define TIMER_LAND 130 +#define TIMER_GESTURE (34*66+50) + +#define OVERCLIP 1.001f + +#define HEAD_TAG 0 +#define TORSO_TAG 1 +#define ARMS_TAG 2 +#define PELVIS_TAG 3 +#define MOUTH_TAG 4 + +// all of the locals will be zeroed before each +// pmove, just to make damn sure we don't have +// any differences when running on client or server +typedef struct { + vec3_t forward, left, up; + vec3_t flat_forward, flat_left, flat_up; + float frametime; + + int msec; + + qboolean walking; + qboolean groundPlane; + trace_t groundTrace; + + float impactSpeed; + + vec3_t previous_origin; + vec3_t previous_velocity; + int previous_waterlevel; +} pml_t; + +extern pmove_t *pm; +extern pml_t pml; + +// movement parameters +extern float pm_stopspeed; +extern float pm_duckScale; +extern float pm_swimScale; +extern float pm_wadeScale; + +extern float pm_accelerate; +extern float pm_airaccelerate; +extern float pm_wateraccelerate; +extern float pm_flyaccelerate; + +extern float pm_friction; +extern float pm_waterfriction; +extern float pm_flightfriction; + +extern int c_pmove; + +void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce ); +void PM_AddTouchEnt( int entityNum ); +void PM_AddEvent( int newEvent ); + +qboolean PM_SlideMove( qboolean gravity ); +void PM_StepSlideMove( qboolean gravity ); + + diff --git a/code/game/bg_misc.cpp b/code/game/bg_misc.cpp new file mode 100644 index 00000000..558447f1 --- /dev/null +++ b/code/game/bg_misc.cpp @@ -0,0 +1,398 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// bg_misc.c -- both games misc functions, all completely stateless + +#include "../qcommon/q_shared.h" +#include "bg_public.h" + +/* +================ +BG_EvaluateTrajectory +================ +*/ +void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) { + +} + +/* +================ +BG_EvaluateTrajectoryDelta +For determining velocity at a given time +================ +*/ +void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result ) { + +} + +// FIXME: OLD Q3 CODE +#if 0 + +/* +================ +BG_CanItemBeGrabbed + +Returns false if the item should not be picked up. +This needs to be the same for client side prediction and server use. +================ +*/ +qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const playerState_t *ps ) +{ + + gitem_t *item; +#ifdef MISSIONPACK + int upperBound; +#endif + + if ( ent->modelindex < 1 || ent->modelindex >= bg_numItems ) { + Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: index out of range" ); + } + + item = &bg_itemlist[ent->modelindex]; + + switch( item->giType ) { + case IT_WEAPON: + return qtrue; // weapons are always picked up + + case IT_AMMO: + if ( ps->ammo[ item->giTag ] >= 200 ) { + return qfalse; // can't hold any more + } + return qtrue; + + case IT_ARMOR: +#ifdef MISSIONPACK + if( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) { + return qfalse; + } + + // we also clamp armor to the maxhealth for handicapping + if( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) { + upperBound = ps->stats[STAT_MAX_HEALTH]; + } + else { + upperBound = ps->stats[STAT_MAX_HEALTH] * 2; + } + + if ( ps->stats[STAT_ARMOR] >= upperBound ) { + return qfalse; + } +#else + if ( ps->stats[STAT_ARMOR] >= ps->stats[STAT_MAX_HEALTH] * 2 ) { + return qfalse; + } +#endif + return qtrue; + + case IT_HEALTH: + // small and mega healths will go over the max, otherwise + // don't pick up if already at max +#ifdef MISSIONPACK + if( bg_itemlist[ps->stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) { + upperBound = ps->stats[STAT_MAX_HEALTH]; + } + else +#endif + if ( item->quantity == 5 || item->quantity == 100 ) { + if ( ps->stats[STAT_HEALTH] >= ps->stats[STAT_MAX_HEALTH] * 2 ) { + return qfalse; + } + return qtrue; + } + + if ( ps->stats[STAT_HEALTH] >= ps->stats[STAT_MAX_HEALTH] ) { + return qfalse; + } + return qtrue; + + case IT_POWERUP: + return qtrue; // powerups are always picked up + +#ifdef MISSIONPACK + case IT_PERSISTANT_POWERUP: + // can only hold one item at a time + if ( ps->stats[STAT_PERSISTANT_POWERUP] ) { + return qfalse; + } + + // check team only + if( ( ent->generic1 & 2 ) && ( ps->stats[STAT_TEAM] != TEAM_RED ) ) { + return qfalse; + } + if( ( ent->generic1 & 4 ) && ( ps->stats[STAT_TEAM] != TEAM_BLUE ) ) { + return qfalse; + } + + return qtrue; +#endif + + case IT_TEAM: // team items, such as flags +#ifdef MISSIONPACK + if( gametype == GT_1FCTF ) { + // neutral flag can always be picked up + if( item->giTag == PW_NEUTRALFLAG ) { + return qtrue; + } + if (ps->stats[STAT_TEAM] == TEAM_RED) { + if (item->giTag == PW_BLUEFLAG && ps->powerups[PW_NEUTRALFLAG] ) { + return qtrue; + } + } else if (ps->stats[STAT_TEAM] == TEAM_BLUE) { + if (item->giTag == PW_REDFLAG && ps->powerups[PW_NEUTRALFLAG] ) { + return qtrue; + } + } + } +#endif + if( gametype == GT_CTF ) { + // ent->modelindex2 is non-zero on items if they are dropped + // we need to know this because we can pick up our dropped flag (and return it) + // but we can't pick up our flag at base + if (ps->stats[STAT_TEAM] == TEAM_RED) { + if (item->giTag == PW_BLUEFLAG || + (item->giTag == PW_REDFLAG && ent->modelindex2) || + (item->giTag == PW_REDFLAG && ps->powerups[PW_BLUEFLAG]) ) + return qtrue; + } else if (ps->stats[STAT_TEAM] == TEAM_BLUE) { + if (item->giTag == PW_REDFLAG || + (item->giTag == PW_BLUEFLAG && ent->modelindex2) || + (item->giTag == PW_BLUEFLAG && ps->powerups[PW_REDFLAG]) ) + return qtrue; + } + } + +#ifdef MISSIONPACK + if( gametype == GT_HARVESTER ) { + return qtrue; + } +#endif + return qfalse; + + case IT_HOLDABLE: + // can only hold one item at a time + if ( ps->stats[STAT_HOLDABLE_ITEM] ) { + return qfalse; + } + return qtrue; + + case IT_BAD: + Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: IT_BAD" ); + default: +#ifndef Q3_VM +#ifndef NDEBUG + Com_Printf("BG_CanItemBeGrabbed: unknown enum %d\n", item->giType ); +#endif +#endif + break; + } + + return qfalse; +} + +//====================================================================== + +/* +================ +BG_EvaluateTrajectory + +================ +*/ +void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) +{ + float deltaTime; + float phase; + + switch( tr->trType ) { + case TR_STATIONARY: + case TR_INTERPOLATE: + VectorCopy( tr->trBase, result ); + break; + case TR_LINEAR: + deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds + VectorMA( tr->trBase, deltaTime, tr->trDelta, result ); + break; + case TR_SINE: + deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration; + phase = sin( deltaTime * M_PI * 2 ); + VectorMA( tr->trBase, phase, tr->trDelta, result ); + break; + case TR_LINEAR_STOP: + if ( atTime > tr->trTime + tr->trDuration ) { + atTime = tr->trTime + tr->trDuration; + } + deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds + if ( deltaTime < 0 ) { + deltaTime = 0; + } + VectorMA( tr->trBase, deltaTime, tr->trDelta, result ); + break; + case TR_GRAVITY: + deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds + VectorMA( tr->trBase, deltaTime, tr->trDelta, result ); + result[2] -= 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime; // FIXME: local gravity... + break; + default: + Com_Error( ERR_DROP, "BG_EvaluateTrajectory: unknown trType: %i", tr->trTime ); + break; + } +} + +/* +================ +BG_EvaluateTrajectoryDelta + +For determining velocity at a given time +================ +*/ +void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result ) { + float deltaTime; + float phase; + + switch( tr->trType ) { + case TR_STATIONARY: + case TR_INTERPOLATE: + VectorClear( result ); + break; + case TR_LINEAR: + VectorCopy( tr->trDelta, result ); + break; + case TR_SINE: + deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration; + phase = cos( deltaTime * M_PI * 2 ); // derivative of sin = cos + phase *= 0.5; + VectorScale( tr->trDelta, phase, result ); + break; + case TR_LINEAR_STOP: + if ( atTime > tr->trTime + tr->trDuration ) { + VectorClear( result ); + return; + } + VectorCopy( tr->trDelta, result ); + break; + case TR_GRAVITY: + deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds + VectorCopy( tr->trDelta, result ); + result[2] -= DEFAULT_GRAVITY * deltaTime; // FIXME: local gravity... + break; + default: + Com_Error( ERR_DROP, "BG_EvaluateTrajectoryDelta: unknown trType: %i", tr->trTime ); + break; + } +} + +#endif + +/* +======================== +BG_TouchJumpPad +======================== +*/ +void BG_TouchJumpPad( playerState_t *ps, entityState_t *jumppad ) { +} + +/* +======================== +BG_PlayerStateToEntityState + +This is done after each set of usercmd_t on the server, +and after local prediction on the client +======================== +*/ +void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap ) +{ + if ( ps->pm_type == PM_NOCLIP ) { + s->eType = 0;//ET_INVISIBLE; + //} else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) { + // s->eType = 0;//ET_INVISIBLE; + } else { + s->eType = ET_PLAYER; + } + + s->number = ps->clientNum; + + VectorCopy( ps->origin, s->origin ); + if ( snap ) { + SnapVector( s->origin ); + } + // set the trDelta for flag direction + VectorCopy( ps->velocity, s->pos.trDelta ); + + VectorCopy( ps->viewangles, s->angles ); + if ( snap ) { + SnapVector( s->angles ); + } + + //s->angles2[YAW] = ps->movementDir; + s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number + // so corpses can also reference the proper config + //s->eFlags = ps->eFlags; + //if ( ps->stats[STAT_HEALTH] <= 0 ) { + // s->eFlags |= EF_DEAD; + //} else { + // s->eFlags &= ~EF_DEAD; + //} + + + s->groundEntityNum = ps->groundEntityNum; + +} + +/* +======================== +BG_PlayerStateToEntityStateExtraPolate + +This is done after each set of usercmd_t on the server, +and after local prediction on the client +======================== +*/ +void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap ) +{ + if ( ps->pm_type == PM_NOCLIP ) { + s->eType = 0;//ET_INVISIBLE; + //} else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) { + // s->eType = 0;//ET_INVISIBLE; + } else { + s->eType = ET_PLAYER; + } + + s->number = ps->clientNum; + + VectorCopy( ps->origin, s->origin ); + if ( snap ) { + SnapVector( s->origin ); + } + // set the trDelta for flag direction and linear prediction + VectorCopy( ps->velocity, s->pos.trDelta ); + // set the time for linear prediction + s->pos.trTime = time; + + VectorCopy( ps->viewangles, s->angles ); + if ( snap ) { + SnapVector( s->angles ); + } + s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number + // so corpses can also reference the proper config + + + s->groundEntityNum = ps->groundEntityNum; + +} diff --git a/code/game/bg_pmove.cpp b/code/game/bg_pmove.cpp new file mode 100644 index 00000000..4b1b99d6 --- /dev/null +++ b/code/game/bg_pmove.cpp @@ -0,0 +1,1801 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// bg_pmove.c -- both games player movement code +// takes a playerstate and a usercmd as input and returns a modifed playerstate + +#include "../qcommon/q_shared.h" +#include "bg_public.h" +#include "bg_local.h" + +pmove_t *pm; +pml_t pml; + +// movement parameters +float pm_stopspeed = 50.0f; +float pm_duckScale = 0.25f; +float pm_swimScale = 1.0f; +float pm_wadeScale = 0.70f; + +float pm_accelerate = 8.0f; +float pm_airaccelerate = 1.0f; +float pm_wateraccelerate = 8.0f; + +float pm_friction = 6.0f; +float pm_waterfriction = 2.0f; +float pm_slipperyfriction = 0.25f; +float pm_strafespeed = 0.85f; +float pm_backspeed = 0.80f; +float pm_flightfriction = 3.0f; +float PM_NOCLIPfriction = 5.0f; + +int c_pmove = 0; + + +/* +=============== +PM_AddEvent + +=============== +*/ +void PM_AddEvent( int newEvent ) { + +} + +/* +=============== +PM_AddTouchEnt +=============== +*/ +void PM_AddTouchEnt( int entityNum ) { + int i; + + if ( entityNum == ENTITYNUM_WORLD ) { + return; + } + + if ( pm->numtouch == MAXTOUCH ) { + return; + } + + // see if it is already added + for ( i = 0 ; i < pm->numtouch ; i++ ) { + if ( pm->touchents[ i ] == entityNum ) { + return; + } + } + + // add it + pm->touchents[pm->numtouch] = entityNum; + pm->numtouch++; +} + +/* +=================== +PM_StartTorsoAnim +=================== +*/ +static void PM_StartTorsoAnim( int anim ) { + +} +static void PM_StartLegsAnim( int anim ) { + +} + +static void PM_ContinueLegsAnim( int anim ) { + +} + +static void PM_ContinueTorsoAnim( int anim ) { + +} + +static void PM_ForceLegsAnim( int anim ) { + +} + + +/* +================== +PM_ClipVelocity + +Slide off of the impacting surface +================== +*/ +void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce ) +{ + float backoff; + float dir_z; + float normal2[ 3 ]; + + if( normal[ 2 ] >= pm_wadeScale ) + { + if( in[ 0 ] == 0.0f && in[ 1 ] == 0.0f ) + { + VectorClear( out ); + return; + } + + normal2[ 0 ] = in[ 0 ] * DotProduct2D( in, normal ); + normal2[ 1 ] = in[ 1 ] * DotProduct2D( in, normal ); + normal2[ 2 ] = normal[ 2 ] * DotProduct2D( in, in ); + + VectorNormalize( normal2 ); + + dir_z = -normal2[ 2 ]; + + out[ 0 ] = in[ 0 ]; + out[ 1 ] = in[ 1 ]; + out[ 2 ] = DotProduct2D( in, normal2 ) / dir_z; + } + else + { + backoff = DotProduct( in, normal ); + + if( backoff < 0 ) + backoff *= overbounce; + else + backoff /= overbounce; + + out[ 0 ] = in[ 0 ] - normal[ 0 ] * backoff; + out[ 1 ] = in[ 1 ] - normal[ 1 ] * backoff; + out[ 2 ] = in[ 2 ] - normal[ 2 ] * backoff; + } +} + + +/* +================== +PM_Friction + +Handles both ground friction and water friction +================== +*/ +static void PM_Friction( void ) { + vec3_t vec; + float *vel; + float speed, newspeed, control; + float drop; + + vel = pm->ps->velocity; + + VectorCopy( vel, vec ); + if( pml.walking ) + { + // ignore slope movement + vec[ 2 ] = 0; + } + + speed = VectorLength( vec ); + if( speed < 1 ) + { + // allow sinking underwater + vel[ 0 ] = 0; + vel[ 1 ] = 0; + + return; + } + + drop = 0; + + if( pml.walking ) + { + control = ( speed < pm_stopspeed ) ? pm_stopspeed : speed; + + // if getting knocked back, no friction + if( pml.groundTrace.surfaceFlags & SURF_SLICK ) + { + drop += control * pm_slipperyfriction * pml.frametime; + } + else + { + drop += control * pm_friction * pml.frametime; + } + } + + // apply water friction even if just wading + if( pm->waterlevel ) + { + if( pm->watertype & CONTENTS_SLIME ) + { + drop += speed * pm_waterfriction * 5 * pm->waterlevel * pml.frametime; + } + else + { + drop += speed * pm_waterfriction * pm->waterlevel * pml.frametime; + } + } + + // scale the velocity + newspeed = speed - drop; + if( newspeed < 0 ) + { + newspeed = 0; + } + + newspeed /= speed; + + vel[ 0 ] = vel[ 0 ] * newspeed; + vel[ 1 ] = vel[ 1 ] * newspeed; + vel[ 2 ] = vel[ 2 ] * newspeed; +} + + +/* +============== +PM_Accelerate + +Handles user intended acceleration +============== +*/ +static void PM_Accelerate( vec3_t wishdir, float wishspeed, float accel ) +{ + vec3_t wishVelocity; + vec3_t pushDir; + float pushLen; + float canPush; + + VectorScale( wishdir, wishspeed, wishVelocity ); + VectorSubtract( wishVelocity, pm->ps->velocity, pushDir ); + pushLen = VectorNormalize( pushDir ); + + canPush = accel*pml.frametime*wishspeed; + if (canPush > pushLen) { + canPush = pushLen; + } + + VectorMA( pm->ps->velocity, canPush, pushDir, pm->ps->velocity ); +} + + + +/* +============ +PM_CmdScale + +Returns the scale factor to apply to cmd movements +This allows the clients to use axial -127 to 127 values for all directions +without getting a sqrt(2) distortion in speed. +============ +*/ +static float PM_CmdScale( usercmd_t *cmd ) { + int max; + float total; + float scale; + float fmove, smove; + + PM_GetMove( &fmove, &smove ); + + max = abs( fmove ); + if( abs( smove ) > max ) { + max = abs( smove ); + } + if ( abs( cmd->upmove ) > max ) { + max = abs( cmd->upmove ); + } + if ( !max ) { + return 0; + } + + total = sqrt( ( float )( fmove * fmove + + smove * smove + cmd->upmove * cmd->upmove ) ); + scale = ( float )pm->ps->speed * max / ( 127.0 * total ); + + return scale; +} + +//============================================================================ + +/* +============= +PM_CheckTerminalVelocity +============= +*/ +#define TERMINAL_VELOCITY 1200 +void PM_CheckTerminalVelocity + ( + void + ) + +{ + float oldspeed; + float speed; + + // + // how fast were we falling + // + oldspeed = -pml.previous_velocity[ 2 ]; + + // + // how fast are we falling + // + speed = -pm->ps->velocity[ 2 ]; + + if( speed <= 0 ) + { + return; + } + + if( ( oldspeed <= TERMINAL_VELOCITY ) && ( speed > TERMINAL_VELOCITY ) ) + { + pm->pmoveEvent = EV_TERMINAL_VELOCITY; + } +} + +/* +{ + int i; + vec3_t wishvel; + float fmove, smove; + vec3_t wishdir; + float wishspeed; + float scale; + usercmd_t cmd; + + PM_Friction(); + + fmove = pm->cmd.forwardmove; + smove = pm->cmd.rightmove; + + cmd = pm->cmd; + scale = PM_CmdScale( &cmd ); + + // set the movementDir so clients can rotate the legs for strafing + PM_SetMovementDir(); + + // project moves down to flat plane + pml.forward[ 2 ] = 0; + pml.right[ 2 ] = 0; + VectorNormalize( pml.forward ); + VectorNormalize( pml.right ); + + for( i = 0; i < 2; i++ ) { + wishvel[ i ] = pml.forward[ i ] * fmove + pml.right[ i ] * smove; + } + wishvel[ 2 ] = 0; + + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); + wishspeed *= scale; + + // not on ground, so little effect on velocity + PM_Accelerate( wishdir, wishspeed, pm_airaccelerate ); + + // we may have a ground plane that is very steep, even + // though we don't have a groundentity + // slide along the steep plane + if( pml.groundPlane ) { + PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, + pm->ps->velocity, OVERCLIP ); + } + + PM_StepSlideMove( qtrue ); +} +*/ + +/* +=================== +PM_GetMove + +=================== +*/ +void PM_GetMove + ( + float *pfForward, + float *pfRight + ) + +{ + *pfForward = pm->cmd.forwardmove; + if( *pfForward < 0 ) + { + *pfForward *= pm_backspeed; + } + *pfRight = pm->cmd.rightmove * pm_strafespeed; +} + +/* +=================== +PM_AirMove + +=================== +*/ +static void PM_AirMove( void ) +{ + vec3_t wishvel; + float fmove; + float smove; + vec3_t wishdir; + float wishspeed; + float scale; + usercmd_t cmd; + + PM_GetMove( &fmove, &smove ); + + pm->ps->pm_time = 0; + + cmd = pm->cmd; + scale = PM_CmdScale( &cmd ); + + wishvel[ 0 ] = pml.flat_forward[ 0 ] * fmove - pml.flat_left[ 0 ] * smove; + wishvel[ 1 ] = pml.flat_forward[ 1 ] * fmove - pml.flat_left[ 1 ] * smove; + wishvel[ 2 ] = 0; + + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); + wishspeed *= scale; + + // not on ground, so little effect on velocity + PM_Accelerate( wishdir, wishspeed, pm_airaccelerate ); + + // we may have a ground plane that is very steep, even + // though we don't have a groundentity + // slide along the steep plane + if( pml.groundPlane ) + { + PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP ); + } + + PM_StepSlideMove( qtrue ); + + PM_CheckTerminalVelocity(); +} + +static vec3_t min3x3 = { -8, 0, 0 }; +static vec3_t max3x3 = { 4, 4, 8 }; +static vec3_t base_rightfoot_pos = { -5.25301f, -3.10885f, 0 }; +static vec3_t base_leftfoot_pos = { -0.123711f, 10.4893f, 0 }; + +qboolean PM_FeetOnGround + ( + vec3_t pos + ) + +{ + vec3_t start; + vec3_t end; + trace_t trace; + + VectorCopy( pos, start ); + VectorCopy( pos, end ); + end[ 2 ] -= 16.01f; + + pm->trace( &trace, start, min3x3, max3x3, end, pm->ps->clientNum, pm->tracemask, true, false ); + + return trace.fraction != 1.0f; +} + +qboolean PM_FindBestFallPos + ( + vec3_t pos, + vec3_t bestdir + ) + +{ + trace_t trace; + vec3_t ang; + vec3_t dir; + vec3_t start; + vec3_t end; + vec3_t move; + int i; + qboolean set; + float radius; + + VectorClear( bestdir ); + + set = qfalse; + + radius = pm->maxs[ 0 ] - pm->mins[ 0 ] + 1.0f; + + VectorCopy( pos, start ); + start[ 2 ] -= 16.1f; + + VectorSet( ang, 0, pm->ps->viewangles[ 1 ], 0 ); + for( i = 0; i < 16; i++, ang[ 1 ] += 22.5f ) + { + AngleVectorsLeft( ang, dir, NULL, NULL ); + VectorMA( pos, radius, dir, move ); + + pm->trace( &trace, pos, pm->mins, pm->maxs, move, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + + VectorCopy( trace.endpos, end ); + end[ 2 ] = start[ 2 ]; + + pm->trace( &trace, trace.endpos, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + if( trace.fraction == 1.0f ) + { + VectorCopy( trace.endpos, end ); + pm->trace( &trace, end, pm->mins, pm->maxs, start, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + + if( trace.fraction < 1.0f ) + { + VectorAdd( bestdir, trace.plane.normal, bestdir ); + set = qtrue; + } + } + } + + if( !set || !VectorNormalize( bestdir ) ) + { + return qfalse; + } + + return qtrue; +} + +void PM_CheckFeet + ( + vec3_t vWishdir + ) + +{ + vec3_t temp; + trace_t trace; + + if( pm->stepped ) + { + pm->ps->feetfalling = 0; + return; + } + + if( !pm->ps->walking ) + { + return; + } + + VectorMA( pm->ps->origin, 0.2f, pm->ps->velocity, temp ); + temp[ 2 ] = pm->ps->origin[ 2 ] + 2; + if( PM_FeetOnGround( pm->ps->origin ) || PM_FeetOnGround( temp ) ) + { + pm->ps->feetfalling = 0; + return; + } + + if( pm->ps->feetfalling > 0 ) + { + pm->ps->feetfalling--; + } + + if( !pm->ps->feetfalling ) + { + if( !PM_FindBestFallPos( pm->ps->origin, pm->ps->falldir ) ) { + return; + } + + pm->ps->feetfalling = 5; + } + + VectorMA( pm->ps->origin, 15.0f * pml.frametime, pm->ps->falldir, temp ); + + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, temp, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + if( trace.fraction == 0 ) + { + pm->ps->feetfalling = 0; + return; + } + + if( ( vWishdir[ 0 ] == 0.0f && vWishdir[ 1 ] == 0.0f ) || + DotProduct( vWishdir, pm->ps->falldir ) > 0.0f ) + { + pm->ps->walking = qfalse; + VectorCopy( trace.endpos, pm->ps->origin ); + } +} + +/* +=================== +PM_WalkMove + +=================== +*/ +static void PM_WalkMove( void ) { + int i; + vec3_t wishvel; + float fmove, smove; + vec3_t wishdir; + float wishspeed; + float scale; + usercmd_t cmd; + float accelerate; + + PM_Friction(); + + PM_GetMove( &fmove, &smove ); + + cmd = pm->cmd; + scale = PM_CmdScale( &cmd ); + + if( ( pm->cmd.buttons & BUTTON_RUN ) && fmove && !smove ) + { + pm->ps->pm_time += pml.msec; + } + else + { + pm->ps->pm_time = 0; + } + + // project the forward and right directions onto the ground plane + PM_ClipVelocity( pml.flat_forward, pml.groundTrace.plane.normal, pml.flat_forward, OVERCLIP ); + PM_ClipVelocity( pml.flat_left, pml.groundTrace.plane.normal, pml.flat_left, OVERCLIP ); + // + VectorNormalize( pml.flat_forward ); + VectorNormalize( pml.flat_left ); + + for( i = 0; i < 3; i++ ) + { + wishvel[ i ] = pml.flat_forward[ i ] * fmove - pml.flat_left[ i ] * smove; + } + + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); + wishspeed *= scale; + + // clamp the speed lower if wading or walking on the bottom + if( pm->waterlevel ) + { + float waterScale; + + if( pm->waterlevel == 1.0f ) + { + waterScale = 0.80f; + } + else + { + waterScale = 0.5f; + } + + if( wishspeed > pm->ps->speed * waterScale ) { + wishspeed = pm->ps->speed * waterScale; + } + } + + if( pml.groundTrace.surfaceFlags & SURF_SLICK ) { + accelerate = pm_airaccelerate; + } else { + accelerate = pm_accelerate; + } + + PM_Accelerate( wishdir, wishspeed, accelerate ); + + if( pml.groundTrace.surfaceFlags & SURF_SLICK ) { + pm->ps->velocity[ 2 ] -= pm->ps->gravity * pml.frametime; + } + + // slide along the ground plane + PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, + pm->ps->velocity, OVERCLIP ); + + // don't do anything if standing still + if( pm->ps->velocity[ 0 ] || pm->ps->velocity[ 1 ] ) + { + PM_StepSlideMove( qtrue ); + } + + PM_CheckFeet( wishdir ); +} + +/* +============== +PM_DeadMove +============== +*/ +static void PM_DeadMove( void ) { + float forward; + + if ( !pml.walking ) { + return; + } + + // extra friction + + forward = VectorLength (pm->ps->velocity); + forward -= 20; + if ( forward <= 0 ) { + VectorClear (pm->ps->velocity); + } else { + VectorNormalize (pm->ps->velocity); + VectorScale (pm->ps->velocity, forward, pm->ps->velocity); + } +} + + +/* +=============== +PM_NoclipMove +=============== +*/ +static void PM_NoclipMove( void ) +{ + float speed; + float drop; + float friction; + float control; + float newspeed; + int i; + vec3_t wishvel; + float fmove; + float smove; + vec3_t wishdir; + float wishspeed; + float scale; + + pm->ps->viewheight = DEFAULT_VIEWHEIGHT; + pm->ps->groundEntityNum = ENTITYNUM_NONE; + + // friction + + speed = VectorLength( pm->ps->velocity ); + if( speed < 1 ) + { + VectorCopy( vec3_origin, pm->ps->velocity ); + } + else + { + drop = 0; + + // extra friction + friction = pm_friction * 1.5; + + control = speed < pm_stopspeed ? pm_stopspeed : speed; + drop += control * friction * pml.frametime; + + // scale the velocity + newspeed = speed - drop; + if( newspeed < 0 ) + { + newspeed = 0; + } + newspeed /= speed; + + VectorScale( pm->ps->velocity, newspeed, pm->ps->velocity ); + } + + // accelerate + // allow the player to move twice as fast in noclip + scale = PM_CmdScale( &pm->cmd ) * 2; + + PM_GetMove( &fmove, &smove ); + + pm->ps->pm_time = 0; + + for( i = 0; i < 3; i++ ) + { + wishvel[ i ] = pml.flat_forward[ i ] * fmove - pml.flat_left[ i ] * smove; + } + + wishvel[ 2 ] += pm->cmd.upmove; + + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); + wishspeed *= scale; + + PM_Accelerate( wishdir, wishspeed, pm_accelerate ); + + // move + VectorMA( pm->ps->origin, pml.frametime, pm->ps->velocity, pm->ps->origin ); +} + +//============================================================================ + +/* +================= +PM_CrashLand + +Check for hard landings that generate sound events +================= +*/ +static void PM_CrashLand( void ) +{ + float delta; + float dist; + float vel; + float acc; + float t; + float a, b, c, den; + + // calculate the exact velocity on landing + dist = pm->ps->origin[ 2 ] - pml.previous_origin[ 2 ]; + vel = pml.previous_velocity[ 2 ]; + acc = -pm->ps->gravity; + + a = acc / 2; + b = vel; + c = -dist; + + den = b * b - 4 * a * c; + if( den < 0 ) + { + return; + } + + //t = ( -b - sqrt( den ) ) / ( 2 * a ); + t = sqrt( den ) + vel; + + //delta = vel + t * acc; + delta = vel - t; + delta = delta * delta * 0.0001; + + // reduce falling damage if there is standing water + if( pm->waterlevel == 2 ) + { + delta *= 0.25f; + } + + if( pm->waterlevel == 1 ) + { + delta *= 0.5f; + } + + if( delta < 1 ) + { + return; + } + + // SURF_NODAMAGE is used for bounce pads where you don't ever + // want to take damage or play a crunch sound + if( !( pml.groundTrace.surfaceFlags & SURF_NODAMAGE ) ) + { + if( delta > 100 ) + { + pm->pmoveEvent = EV_FALL_FATAL; + } + else if( delta > 80 ) + { + pm->pmoveEvent = EV_FALL_FAR; + } + else if( delta > 40 ) + { + pm->pmoveEvent = EV_FALL_MEDIUM; + } + else if( delta > 20 ) + { + pm->pmoveEvent = EV_FALL_SHORT; + } + } +} + +/* +============= +PM_CheckStuck +============= +*/ +/* +void PM_CheckStuck(void) { + trace_t trace; + + pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask); + if (trace.allsolid) { + //int shit = qtrue; + } +} +*/ + +/* +============= +PM_CorrectAllSolid +============= +*/ +static int PM_CorrectAllSolid( trace_t *trace ) +{ + int i, j, k; + vec3_t point; + + if ( pm->debugLevel ) { + Com_Printf("%i:allsolid\n", c_pmove); + } + + // jitter around + for (i = -1; i <= 1; i++) { + for (j = -1; j <= 1; j++) { + for (k = -1; k <= 1; k++) { + VectorCopy(pm->ps->origin, point); + point[0] += (float) i; + point[1] += (float) j; + point[2] += (float) k; + pm->trace( trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, false ); + if ( !trace->allsolid && !trace->startsolid ) { + point[0] = pm->ps->origin[0]; + point[1] = pm->ps->origin[1]; + point[2] = pm->ps->origin[2] - 0.25; + + pm->trace( trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, false ); + pml.groundTrace = *trace; + pm->ps->groundTrace = *trace; + return qtrue; + } + } + } + } + + //pm->ps->groundEntityNum = ENTITYNUM_NONE; + //pml.groundPlane = qfalse; + //pml.walking = qfalse; + + return qfalse; +} + +/* +============= +PM_GroundTrace +============= +*/ +static void PM_GroundTrace( void ) { + vec3_t point; + trace_t trace; + + point[ 0 ] = pm->ps->origin[ 0 ]; + point[ 1 ] = pm->ps->origin[ 1 ]; + point[ 2 ] = pm->ps->origin[ 2 ] - 0.25f; + + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + + pml.groundTrace = trace; + pm->ps->groundTrace = trace; + + // do something corrective if the trace starts in a solid... + if ( trace.allsolid || trace.startsolid ) + { + if( !PM_CorrectAllSolid( &trace ) ) { + trace.fraction = 1.0f; + } + } + + // if the trace didn't hit anything, we are in free fall + if ( trace.fraction == 1.0 ) + { + pm->ps->groundEntityNum = ENTITYNUM_NONE; + pml.groundPlane = qfalse; + pml.walking = qfalse; + + pm->ps->walking = pml.walking; + pm->ps->groundPlane = pml.groundPlane; + return; + } + + // check if getting thrown off the ground + if( pm->ps->velocity[ 2 ] > 0.0f && DotProduct( pm->ps->velocity, trace.plane.normal ) > 150.0f ) + { + if ( pm->debugLevel ) { + Com_Printf("%i:kickoff\n", c_pmove); + } + + pm->ps->groundEntityNum = ENTITYNUM_NONE; + pml.groundPlane = qfalse; + pml.walking = qfalse; + + pm->ps->walking = pml.walking; + pm->ps->groundPlane = pml.groundPlane; + return; + } + + // slopes that are too steep will not be considered onground + if( trace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) + { + vec3_t oldvel; + float d; + + if ( pm->debugLevel ) { + Com_Printf("%i:steep\n", c_pmove); + } + + VectorCopy( pm->ps->velocity, oldvel ); + VectorSet( pm->ps->velocity, 0, 0, -1.0f / pml.frametime ); + PM_SlideMove( qfalse ); + + d = VectorLength( pm->ps->velocity ); + VectorCopy( oldvel, pm->ps->velocity ); + + if( d > ( 0.1f / pml.frametime ) ) + { + pm->ps->groundEntityNum = ENTITYNUM_NONE; + pml.groundPlane = qtrue; + pml.walking = qfalse; + + pm->ps->walking = pml.walking; + pm->ps->groundPlane = pml.groundPlane; + return; + } + } + + pml.groundPlane = qtrue; + pml.walking = qtrue; + + if ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) + { + // just hit the ground + if ( pm->debugLevel ) { + Com_Printf( "%i:Land\n", c_pmove ); + } + + PM_CrashLand(); + } + + pm->ps->groundEntityNum = trace.entityNum; + + PM_AddTouchEnt( trace.entityNum ); + + pm->ps->walking = pml.walking; + pm->ps->groundPlane = pml.groundPlane; +} + + +/* +============= +PM_SetWaterLevel FIXME: avoid this twice? certainly if not moving +============= +*/ +static void PM_SetWaterLevel( void ) { + vec3_t point; + int cont; + int sample1; + int sample2; + + // + // get waterlevel, accounting for ducking + // + pm->waterlevel = 0; + pm->watertype = 0; + + point[0] = pm->ps->origin[0]; + point[1] = pm->ps->origin[1]; + point[2] = pm->ps->origin[2] + MINS_Z + 1; + cont = pm->pointcontents( point, pm->ps->clientNum ); + + if ( cont & MASK_WATER ) { + sample2 = pm->ps->viewheight - MINS_Z; + sample1 = sample2 / 2; + + pm->watertype = cont; + pm->waterlevel = 1; + point[2] = pm->ps->origin[2] + MINS_Z + sample1; + cont = pm->pointcontents (point, pm->ps->clientNum ); + if ( cont & MASK_WATER ) { + pm->waterlevel = 2; + point[2] = pm->ps->origin[2] + MINS_Z + sample2; + cont = pm->pointcontents (point, pm->ps->clientNum ); + if ( cont & MASK_WATER ){ + pm->waterlevel = 3; + } + } + } + +} + +/* +============== +PM_CheckDuck + +Sets mins, maxs, and pm->ps->viewheight +============== +*/ +static void PM_CheckDuck( void ) +{ + pm->mins[ 0 ] = -15.0f; + pm->mins[ 1 ] = -15.0f; + + pm->maxs[ 0 ] = 15.0f; + pm->maxs[ 1 ] = 15.0f; + + pm->mins[ 2 ] = MINS_Z; + + if( pm->ps->pm_type == PM_DEAD ) + { + pm->maxs[ 2 ] = DEAD_MINS_Z; + pm->ps->viewheight = CROUCH_VIEWHEIGHT; + return; + } + + if( ( pm->ps->pm_flags & ( PMF_DUCKED | PMF_VIEW_PRONE ) ) == ( PMF_DUCKED | PMF_VIEW_PRONE ) ) + { + pm->maxs[ 2 ] = 54.0f; + } + else if( pm->ps->pm_flags & PMF_DUCKED ) + { + pm->maxs[ 2 ] = 60.0f; + pm->ps->viewheight = CROUCH_VIEWHEIGHT; + } + else if( pm->ps->pm_flags & PMF_VIEW_PRONE ) + { + pm->maxs[ 2 ] = 20.0f; + pm->ps->viewheight = PRONE_VIEWHEIGHT; + } + else if( pm->ps->pm_flags & PMF_VIEW_DUCK_RUN ) + { + pm->maxs[ 2 ] = 94.0f; + pm->mins[ 2 ] = 54.0f; + pm->ps->viewheight = DEFAULT_VIEWHEIGHT; + } + else if( pm->ps->pm_flags & PMF_VIEW_JUMP_START ) + { + pm->maxs[ 2 ] = 94.0f; + pm->ps->viewheight = JUMP_START_VIEWHEIGHT; + } + else + { + pm->maxs[ 2 ] = 94.0f; + pm->ps->viewheight = DEFAULT_VIEWHEIGHT; + } +} + + + +//=================================================================== + + +/* +=============== +PM_Footsteps +=============== +*/ +static void PM_Footsteps( void ) { + float bobmove; + int old; + qboolean footstep; + + // + // calculate speed and cycle to be used for + // all cyclic walking effects + // + pm->xyspeed = sqrt( pm->ps->velocity[0] * pm->ps->velocity[0] + + pm->ps->velocity[1] * pm->ps->velocity[1] ); + + if ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) { + +// if ( pm->ps->powerups[PW_INVULNERABILITY] ) { +// PM_ContinueLegsAnim( LEGS_IDLECR ); +// } + // airborne leaves position in cycle intact, but doesn't advance + if ( pm->waterlevel > 1 ) { +// PM_ContinueLegsAnim( LEGS_SWIM ); + } + return; + } + + // if not trying to move + if ( !pm->cmd.forwardmove && !pm->cmd.rightmove ) { + if ( pm->xyspeed < 5 ) { + pm->ps->bobCycle = 0; // start at beginning of cycle again + if ( pm->ps->pm_flags & PMF_DUCKED ) { +// PM_ContinueLegsAnim( LEGS_IDLECR ); + } else { +// PM_ContinueLegsAnim( LEGS_IDLE ); + } + } + return; + } + + + footstep = qfalse; + + + if( !( pm->cmd.buttons & BUTTON_RUN ) ) + { + bobmove = 0.4f; // faster speeds bob faster + + footstep = qtrue; + } else { + bobmove = 0.3f; // walking bobs slow + } + + // check for footstep / splash sounds + old = pm->ps->bobCycle; + pm->ps->bobCycle = (int)( old + bobmove * pml.msec ) & 255; + + // if we just crossed a cycle boundary, play an apropriate footstep event + if ( ( ( old + 64 ) ^ ( pm->ps->bobCycle + 64 ) ) & 128 ) { + if ( pm->waterlevel == 0 ) { + // on ground will only play sounds if running + if ( footstep && !pm->noFootsteps ) { +// PM_AddEvent( PM_FootstepForSurface() ); + } + } else if ( pm->waterlevel == 1 ) { + // splashing +// PM_AddEvent( EV_FOOTSPLASH ); + } else if ( pm->waterlevel == 2 ) { + // wading / swimming at surface +// PM_AddEvent( EV_SWIM ); + } else if ( pm->waterlevel == 3 ) { + // no sound when completely underwater + + } + } +} + +/* +============== +PM_WaterEvents + +Generate sound events for entering and leaving water +============== +*/ +static void PM_WaterEvents( void ) +{ + // FIXME? + // + // if just entered a water volume, play a sound + // + if( !pml.previous_waterlevel && pm->waterlevel ) + { + pm->pmoveEvent = EV_WATER_TOUCH; + } + + // + // if just completely exited a water volume, play a sound + // + if( pml.previous_waterlevel && !pm->waterlevel ) + { + pm->pmoveEvent = EV_WATER_LEAVE; + } + + // + // check for head just going under water + // + if( ( pml.previous_waterlevel != 3 ) && ( pm->waterlevel == 3 ) ) + { + pm->pmoveEvent = EV_WATER_UNDER; + } + + // + // check for head just coming out of water + // + if( ( pml.previous_waterlevel == 3 ) && ( pm->waterlevel != 3 ) ) + { + pm->pmoveEvent = EV_WATER_CLEAR; + } +} + + +/* +=============== +PM_BeginWeaponChange +=============== +*/ +static void PM_BeginWeaponChange( int weapon ) { + +} + + +/* +=============== +PM_FinishWeaponChange +=============== +*/ +static void PM_FinishWeaponChange( void ) { + +} + + +/* +============== +PM_TorsoAnimation + +============== +*/ +static void PM_TorsoAnimation( void ) { + //if ( pm->ps->weaponstate == WEAPON_READY ) { + // if ( pm->ps->weapon == WP_GAUNTLET ) { + // PM_ContinueTorsoAnim( TORSO_STAND2 ); + // } else { + // PM_ContinueTorsoAnim( TORSO_STAND ); + // } + // return; + //} +} + + +/* +============== +PM_Weapon + +Generates weapon events and modifes the weapon counter +============== +*/ +static void PM_Weapon( void ) { + +} + +/* +================ +PM_Animate +================ +*/ + +static void PM_Animate( void ) { + +} + + +/* +================ +PM_DropTimers +================ +*/ +static void PM_DropTimers( void ) +{ + pm->ps->pm_flags &= ~PMF_RESPAWNED; +} + +/* +================ +PM_UpdateViewAngles + +This can be used as another entry point when only the viewangles +are being updated isntead of a full move +================ +*/ +void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) +{ + short temp; + int i; + + if( ps->pm_flags & PMF_FROZEN ) + { + // no view changes at all + return; + } + + if( ps->stats[ STAT_HEALTH ] <= 0 ) + { + // no view changes at all + return; + } + + // circularly clamp the angles with deltas + for( i = 0; i < 3; i++ ) + { + temp = cmd->angles[ i ] + ps->delta_angles[ i ]; + if( i == PITCH ) + { + // don't let the player look up or down more than 90 degrees + if( temp > 16000 ) + { + ps->delta_angles[ i ] = 16000 - cmd->angles[ i ]; + temp = 16000; + } + else if( temp < -16000 ) + { + ps->delta_angles[ i ] = -16000 - cmd->angles[ i ]; + temp = -16000; + } + } + + ps->viewangles[ i ] = SHORT2ANGLE( temp ); + } +} + + +/* +================ +PmoveSingle + +================ +*/ + +void PmoveSingle( pmove_t *pmove ) +{ + vec3_t tempVec; + qboolean walking; + + pm = pmove; + + // this counter lets us debug movement problems with a journal + // by setting a conditional breakpoint fot the previous frame + c_pmove++; + + // clear results + pm->numtouch = 0; + pm->watertype = 0; + pm->waterlevel = 0; + + if( pm->ps->stats[ STAT_HEALTH ] <= 0 ) { + pm->tracemask &= ~( CONTENTS_BODY | CONTENTS_NOBOTCLIP ); // corpses can fly through bodies + } + + if( pmove->cmd.buttons & BUTTON_TALK ) + { + pmove->cmd.forwardmove = 0; + pmove->cmd.rightmove = 0; + pmove->cmd.upmove = 0; + pmove->cmd.buttons = BUTTON_TALK; + pm->ps->fLeanAngle = 0.0f; + } + + if( pm->ps->pm_type == PM_CLIMBWALL ) + { + pm->ps->fLeanAngle = 0.0f; + pm->cmd.buttons &= ~( BUTTON_LEANLEFT | BUTTON_LEANRIGHT ); + } + + // clear all pmove local vars + memset( &pml, 0, sizeof( pml ) ); + + // determine the time + pml.msec = pmove->cmd.serverTime - pm->ps->commandTime; + if ( pml.msec < 1 ) { + pml.msec = 1; + } else if ( pml.msec > 200 ) { + pml.msec = 200; + } + + pm->ps->commandTime = pmove->cmd.serverTime; + + // save old org in case we get stuck + VectorCopy( pm->ps->origin, pml.previous_origin ); + + // save old velocity for crashlanding + VectorCopy( pm->ps->velocity, pml.previous_velocity ); + + pml.frametime = pml.msec * 0.001; + + if( ( pm->cmd.buttons & ( BUTTON_LEANLEFT | BUTTON_LEANRIGHT ) && + ( pm->cmd.buttons & ( BUTTON_LEANLEFT | BUTTON_LEANRIGHT ) ) != ( BUTTON_LEANLEFT | BUTTON_LEANRIGHT ) ) ) + { + if( pm->cmd.buttons & BUTTON_LEANLEFT ) + { + if( pm->ps->fLeanAngle <= -40.0f ) + { + pm->ps->fLeanAngle = -40.0f; + } + else + { + float fAngle = pml.frametime * ( -40.0f - pm->ps->fLeanAngle ); + float fLeanAngle = pml.frametime * -4.0f; + + if( fAngle * 10.0f <= fLeanAngle ) { + fLeanAngle = fAngle * 10.0f; + } + + pm->ps->fLeanAngle += fLeanAngle; + } + } + else + { + if( pm->ps->fLeanAngle >= 40.0f ) + { + pm->ps->fLeanAngle = 40.0f; + } + else + { + float fAngle = 40.0f - pm->ps->fLeanAngle; + float fLeanAngle = pml.frametime * 4.0f; + float fMult = pml.frametime * fAngle; + + if( fLeanAngle <= fMult * 10.0f ) + { + fLeanAngle = fMult * 10.0f; + } + else + { + fLeanAngle = fMult; + } + + pm->ps->fLeanAngle += fLeanAngle; + } + } + } + else if( pm->ps->fLeanAngle ) + { + float fAngle = pm->ps->fLeanAngle * pml.frametime * 15.0f; + + if( pm->ps->fLeanAngle <= 0.0f ) + { + float fLeanAngle = -4.0f * pml.frametime; + + if( fAngle <= fLeanAngle ) + { + fLeanAngle = fAngle; + } + + pm->ps->fLeanAngle -= fLeanAngle; + } + else + { + float fLeanAngle = pml.frametime * 4.0f; + + if( fLeanAngle <= fAngle ) { + fLeanAngle = fAngle; + } + + pm->ps->fLeanAngle -= fLeanAngle; + } + } + + // update the viewangles + PM_UpdateViewAngles( pm->ps, &pm->cmd ); + + AngleVectorsLeft( pm->ps->viewangles, pml.forward, pml.left, pml.up ); + VectorClear( tempVec ); + tempVec[ YAW ] = pm->ps->viewangles[ YAW ]; + AngleVectorsLeft( tempVec, pml.flat_forward, pml.flat_left, pml.flat_up ); + + if ( pm->ps->pm_type >= PM_DEAD ) + { + pm->cmd.forwardmove = 0; + pm->cmd.rightmove = 0; + pm->cmd.upmove = 0; + pm->ps->fLeanAngle = 0.0f; + } + + if ( pm->ps->pm_type == PM_NOCLIP ) + { + PM_NoclipMove(); + PM_DropTimers(); + return; + } + + if( ( pm->ps->pm_flags & PMF_NO_MOVE ) || ( pm->ps->pm_flags & PMF_FROZEN ) ) + { + return; + } + + // set watertype, and waterlevel + PM_SetWaterLevel(); + pml.previous_waterlevel = pmove->waterlevel; + + // set mins, maxs, and viewheight + PM_CheckDuck(); + + // set groundentity + PM_GroundTrace(); + + if ( pm->ps->pm_type == PM_DEAD ) { + PM_DeadMove(); + } + + PM_DropTimers(); + + if ( pml.walking ) { + // walking on ground + PM_WalkMove(); + } else { + // airborne + PM_AirMove(); + } + + walking = pml.walking; + + // set groundentity, watertype, and waterlevel + PM_GroundTrace(); + PM_SetWaterLevel(); + + // don't fall down stairs or do really short falls + if( !pml.walking && ( walking || ( ( pml.previous_velocity[ 2 ] >= 0 ) && ( pm->ps->velocity[ 2 ] <= 0 ) ) ) ) + { + vec3_t point; + trace_t trace; + + point[ 0 ] = pm->ps->origin[ 0 ]; + point[ 1 ] = pm->ps->origin[ 1 ]; + point[ 2 ] = pm->ps->origin[ 2 ] - STEPSIZE; + + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + if( ( trace.fraction < 1.0f ) && ( !trace.allsolid ) ) + { + VectorCopy( trace.endpos, pm->ps->origin ); + + // allow client to smooth out the step + pm->stepped = qtrue; + + // requantify the player's position + PM_GroundTrace(); + PM_SetWaterLevel(); + } + } + + // entering / leaving water splashes + PM_WaterEvents(); +} + +void Pmove_GroundTrace( pmove_t *pmove ) +{ + memset( &pml, 0, sizeof( pml ) ); + pml.msec = 1; + pml.frametime = 0.001f; + pm = pmove; + PM_CheckDuck(); + PM_GroundTrace(); +} + +/* +================ +Pmove + +Can be called by either the server or the client +================ +*/ +void Pmove( pmove_t *pmove ) { + int finalTime; + + finalTime = pmove->cmd.serverTime; + + if( finalTime < pmove->ps->commandTime ) { + return; // should not happen + } + + if( finalTime > pmove->ps->commandTime + 1000 ) { + pmove->ps->commandTime = finalTime - 1000; + } + + // chop the move up if it is too long, to prevent framerate + // dependent behavior + while( pmove->ps->commandTime != finalTime ) { + int msec; + + msec = finalTime - pmove->ps->commandTime; + + if( pmove->pmove_fixed ) + { + if( msec > pmove->pmove_msec ) + { + msec = pmove->pmove_msec; + } + } + else if( msec > 66 ) { + msec = 66; + } + + pmove->cmd.serverTime = pmove->ps->commandTime + msec; + PmoveSingle( pmove ); + } +} +static void PmoveAdjustViewAngleSettings_OnLadder( vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState ) +{ + float fDelta; + float deltayaw; + float yawAngle; + float temp; + + vAngles[ 0 ] = 0.0f; + vAngles[ 2 ] = 0.0f; + + if( vViewAngles[ 0 ] > 73.0f ) { + vViewAngles[ 0 ] = 73.0f; + } + + deltayaw = AngleSubtract( vViewAngles[ 1 ], vAngles[ 1 ] ); + + yawAngle = 70.0f; + if( deltayaw <= 70.0f ) + { + yawAngle = deltayaw; + if( deltayaw < -70.0f ) + { + yawAngle = -70.0f; + } + } + + vViewAngles[ 1 ] = vAngles[ 1 ] + yawAngle; + + fDelta = sqrt( yawAngle * yawAngle + vViewAngles[ 0 ] * vViewAngles[ 0 ] ); + + if( vViewAngles[ 0 ] <= 0.0f ) { + temp = 80.0f; + } else { + temp = 73.0f; + } + + if( fDelta > temp ) + { + float deltalimit = temp * 1.0f / fDelta; + vViewAngles[ 0 ] *= deltalimit; + vViewAngles[ 1 ] = yawAngle * deltalimit + vAngles[ 1 ]; + } +} + +void PmoveAdjustAngleSettings( vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState ) +{ + vec3_t temp, temp2; + vec3_t armsAngles, torsoAngles, headAngles; + float fTmp; + + if( pPlayerState->pm_type == PM_CLIMBWALL ) + { + PmoveAdjustViewAngleSettings_OnLadder( vViewAngles, vAngles, pPlayerState, pEntState ); + VectorSet( pEntState->bone_angles[ TORSO_TAG ], 0, 0, 0 ); + VectorSet( pEntState->bone_angles[ ARMS_TAG ], 0, 0, 0 ); + VectorSet( pEntState->bone_angles[ PELVIS_TAG ], 0, 0, 0 ); + QuatSet( pEntState->bone_quat[ TORSO_TAG ], 0, 0, 0, 1 ); + QuatSet( pEntState->bone_quat[ ARMS_TAG ], 0, 0, 0, 1 ); + QuatSet( pEntState->bone_quat[ PELVIS_TAG ], 0, 0, 0, 1 ); + + AnglesSubtract( vViewAngles, vAngles, headAngles ); + VectorScale( headAngles, 0.5f, pEntState->bone_angles[ HEAD_TAG ] ); + + EulerToQuat( headAngles, pEntState->bone_quat[ HEAD_TAG ] ); + return; + } + + if( pPlayerState->pm_type != PM_DEAD ) + { + fTmp = AngleMod( vViewAngles[ 1 ] ); + VectorSet( vAngles, 0, fTmp, 0 ); + + if( !( pPlayerState->pm_flags & PMF_VIEW_PRONE ) || ( pPlayerState->pm_flags & PMF_DUCKED ) ) + { + fTmp = AngleMod( vViewAngles[ 0 ] ); + + VectorSet( temp, fTmp, 0, pPlayerState->fLeanAngle * 0.60f ); + VectorSet( temp2, fTmp, 0, pPlayerState->fLeanAngle ); + + if( fTmp > 180.0f ) { + temp2[ 0 ] = fTmp - 360.0f; + } + + temp2[ 0 ] = 0.90f * temp2[ 0 ] * 0.70f; + + AnglesSubtract( temp, temp2, headAngles ); + VectorCopy( headAngles, pEntState->bone_angles[ HEAD_TAG ] ); + EulerToQuat( pEntState->bone_angles[ HEAD_TAG ], pEntState->bone_quat[ HEAD_TAG ] ); + + if( temp2[ 0 ] <= 0.0f ) + { + fTmp = -0.1f; + } + else{ + fTmp = 0.3f; + } + + VectorSet( temp, fTmp * temp2[ 0 ], 0, pPlayerState->fLeanAngle * 0.8f ); + VectorCopy( temp, pEntState->bone_angles[ PELVIS_TAG ] ); + EulerToQuat( pEntState->bone_angles[ PELVIS_TAG ], pEntState->bone_quat[ PELVIS_TAG ] ); + + float fDelta = ( 1.0f - fTmp ) * temp2[ 0 ]; + + if( vViewAngles[ 0 ] <= 0.0f ) + { + VectorSet( torsoAngles, fDelta * 0.60f, 0, pPlayerState->fLeanAngle * 0.2f * -0.1f ); + VectorSet( armsAngles, fDelta * 0.40f, 0, pPlayerState->fLeanAngle * 0.2f * 1.1f ); + } + else + { + VectorSet( torsoAngles, fDelta * 0.70f, 0, pPlayerState->fLeanAngle * 0.2f * -0.1f ); + VectorSet( armsAngles, fDelta * 0.30f, 0, pPlayerState->fLeanAngle * 0.2f * 1.1f ); + } + + VectorCopy( torsoAngles, pEntState->bone_angles[ TORSO_TAG ] ); + EulerToQuat( pEntState->bone_angles[ TORSO_TAG ], pEntState->bone_quat[ TORSO_TAG ] ); + + VectorCopy( armsAngles, pEntState->bone_angles[ ARMS_TAG ] ); + EulerToQuat( pEntState->bone_angles[ ARMS_TAG ], pEntState->bone_quat[ ARMS_TAG ] ); + return; + } + } + + // set the default angles + VectorSet( pEntState->bone_angles[ HEAD_TAG ], 0, 0, 0 ); + VectorSet( pEntState->bone_angles[ TORSO_TAG ], 0, 0, 0 ); + VectorSet( pEntState->bone_angles[ ARMS_TAG ], 0, 0, 0 ); + VectorSet( pEntState->bone_angles[ PELVIS_TAG ], 0, 0, 0 ); + QuatSet( pEntState->bone_quat[ HEAD_TAG ], 0, 0, 0, 1 ); + QuatSet( pEntState->bone_quat[ TORSO_TAG ], 0, 0, 0, 1 ); + QuatSet( pEntState->bone_quat[ ARMS_TAG ], 0, 0, 0, 1 ); + QuatSet( pEntState->bone_quat[ PELVIS_TAG ], 0, 0, 0, 1 ); +} + +void PmoveAdjustAngleSettings_Client( vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState ) +{ + //vec3_t torsoAngles, headAngles; + + // called by cgame + // FIXME +} diff --git a/code/game/bg_public.h b/code/game/bg_public.h new file mode 100644 index 00000000..7fe01e13 --- /dev/null +++ b/code/game/bg_public.h @@ -0,0 +1,602 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// bg_public.h -- definitions shared by both the server game and client game modules + +// because games can change separately from the main system version, we need a +// second version that must match between game and cgame + +#ifndef __BG_PUBLIC_H__ +#define __BG_PUBLIC_H__ + +#define GAME_VERSION "mohaa-base-1" + +#define DEFAULT_GRAVITY 800 + +#define SCORE_NOT_PRESENT -9999 // for the CS_SCORES[12] when only one player is present + +#define VOTE_TIME 30000 // 30 seconds before vote times out + +#define MINS_Z 0 +#define MINS_X -15 +#define MINS_Y -15 +#define MAXS_X 15 +#define MAXS_Y 15 + +#define MINS_Z 0 // IneQuation: bounding box and viewheights to match MoHAA +#define MAXS_Z 96 + +#define DEAD_MINS_Z 32 +#define CROUCH_MAXS_Z 49 +#define DEFAULT_VIEWHEIGHT 82 +#define CROUCH_RUN_VIEWHEIGHT 64 +#define JUMP_START_VIEWHEIGHT 52 +#define CROUCH_VIEWHEIGHT 48 +#define PRONE_VIEWHEIGHT 16 +#define DEAD_VIEWHEIGHT 8 + +// +// config strings are a general means of communicating variable length strings +// from the server to all connected clients. +// + +// CS_SERVERINFO and CS_SYSTEMINFO are defined in q_shared.h + +#define CS_MESSAGE 2 // from the map worldspawn's message field +#define CS_SAVENAME 3 // current save +#define CS_MOTD 4 // g_motd string for server message of the day +#define CS_WARMUP 5 // server time when the match will be restarted + +#define CS_MUSIC 8 // MUSIC_NewSoundtrack(cs) +#define CS_FOGINFO 9 // cg.farplane_cull cg.farplane_distance cg.farplane_color[3] +#define CS_SKYINFO 10 // cg.sky_alpha cg.sky_portal + +#define CS_GAME_VERSION 11 +#define CS_LEVEL_START_TIME 12 // so the timer only shows the current level cgs.levelStartTime + +#define CS_CURRENT_OBJECTIVE 13 + +#define CS_RAIN_DENSITY 14 // cg.rain +#define CS_RAIN_SPEED 15 +#define CS_RAIN_SPEEDVARY 16 +#define CS_RAIN_SLANT 17 +#define CS_RAIN_LENGTH 18 +#define CS_RAIN_MINDIST 19 +#define CS_RAIN_WIDTH 20 +#define CS_RAIN_SHADER 21 +#define CS_RAIN_NUMSHADERS 22 + +#define CS_MATCHEND 26 // cgs.matchEndTime + +#define CS_MODELS 32 +#define CS_OBJECTIVES (CS_MODELS+MAX_MODELS) // 1056 +#define CS_SOUNDS (CS_OBJECTIVES+MAX_OBJECTIVES) // 1076 + +#define CS_IMAGES (CS_SOUNDS+MAX_SOUNDS) // 1588 +#define MAX_IMAGES 64 + +#define CS_LIGHTSTYLES (CS_IMAGES+MAX_IMAGES) //1652 +#define CS_PLAYERS (CS_LIGHTSTYLES+MAX_LIGHTSTYLES) // 1684 + +#define CS_WEAPONS (CS_PLAYERS+MAX_CLIENTS) // su44 was here +#define CS_TEAMS 1876 +#define CS_GENERAL_STRINGS 1877 +#define CS_SPECTATORS 1878 +#define CS_ALLIES 1879 +#define CS_AXIS 1880 +#define CS_SOUNDTRACK 1881 + +#define CS_TEAMINFO 1 + +#define CS_MAX (CS_PARTICLES+MAX_LOCATIONS) +#if (CS_MAX) > MAX_CONFIGSTRINGS +#error overflow: (CS_MAX) > MAX_CONFIGSTRINGS +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + GT_SINGLE_PLAYER, // single player ffa + GT_FFA, // free for all + GT_TEAM, // team deathmatch + GT_TEAM_ROUNDS, + GT_OBJECTIVE, + GT_MAX_GAME_TYPE +} gametype_t; + +// +// scale to use when evaluating entityState_t::constantLight scale +// +#define CONSTANTLIGHT_RADIUS_SCALE 8 + +typedef enum { GENDER_MALE, GENDER_FEMALE, GENDER_NEUTER } gender_t; + +// su44: vma indexes are sent as 4 bits +// see playerState_t::iViewModelAnim +typedef enum { + VMA_IDLE, + VMA_CHARGE, + VMA_FIRE, + VMA_FIRE_SECONDARY, + VMA_RECHAMBER, + VMA_RELOAD, + VMA_RELOAD_SINGLE, + VMA_RELOAD_END, + VMA_PULLOUT, + VMA_PUTAWAY, + VMA_LADDERSTEP, + VMA_ENABLE, + VMA_CUSTOMANIMATION, + VMA_NUMANIMATIONS +} viewmodelanim_t; + +// su44: playerState_t::activeItems[8] slots +// they are sent as 16 bits +// TODO: find out rest of them +#define ITEM_AMMO 0 // current ammo +#define ITEM_WEAPON 1 // current mainhand weapon + +/* +=================================================================================== + +PMOVE MODULE + +The pmove code takes a player_state_t and a usercmd_t and generates a new player_state_t +and some other output data. Used for local prediction on the client game and true +movement on the server game. +=================================================================================== +*/ + +#define MAX_CLIP_PLANES 5 +#define MIN_WALK_NORMAL 0.7f // can't walk on very steep slopes + +#define STEPSIZE 18 + +#define WATER_TURBO_SPEED 1.35f +#define WATER_TURBO_TIME 1200 +#define MINIMUM_RUNNING_TIME 800 +#define MINIMUM_WATER_FOR_TURBO 90 + +#define OVERCLIP 1.001f + +// su44: our pmtype_t enum must be the same +// as in MoHAA, because playerState_t::pm_type +// is send over the net and used by cgame +// for movement prediction +typedef enum { + PM_NORMAL, // can accelerate and turn + PM_CLIMBWALL, // su44: I think it's used for ladders + PM_NOCLIP, // noclip movement + PM_DEAD, // no acceleration or turning, but free falling +} pmtype_t; + +typedef enum { + EV_NONE, + + EV_FALL_SHORT, + EV_FALL_MEDIUM, + EV_FALL_FAR, + EV_FALL_FATAL, + EV_TERMINAL_VELOCITY, + + EV_WATER_TOUCH, // foot touches + EV_WATER_LEAVE, // foot leaves + EV_WATER_UNDER, // head touches + EV_WATER_CLEAR, // head leaves + + EV_LAST_PREDICTED // just a marker point + + // events generated by non-players or never predicted +} entity_event_t; + +#if 0 +// pmove->pm_flags +#define PMF_DUCKED (1<<0) +#define PMF_JUMP_HELD (1<<1) +#define PMF_BACKWARDS_JUMP 0 //(1<<3) // go into backwards land +#define PMF_BACKWARDS_RUN 0 //(1<<4) // coast down to backwards run +#define PMF_TIME_LAND (1<<5) // pm_time is time before rejump +#define PMF_TIME_KNOCKBACK (1<<6) // pm_time is an air-accelerate only time +#define PMF_TIME_WATERJUMP (1<<8) // pm_time is waterjump +#define PMF_USE_ITEM_HELD (1<<10) +#define PMF_GRAPPLE_PULL (1<<11) // pull towards grapple location +#define PMF_FOLLOW (1<<12) // spectate following another player +#define PMF_SCOREBOARD (1<<13) // spectate as a scoreboard +#define PMF_INVULEXPAND (1<<14) // invulnerability sphere set to full size +#define PMF_FROZEN (1<<15) +#define PMF_NO_MOVE (1<<16) +#define PMF_NO_PREDICTION (1<<17) +#define PMF_NO_GRAVITY (1<<18) +#define PMF_LEVELEXIT (1<<20) // use camera view instead of ps view +#endif + +// moh pm_flags +#define PMF_DUCKED (1<<0) +#define PMF_VIEW_PRONE (1<<1) +#define PMF_SPECTATING (1<<4) +#define PMF_RESPAWNED (1<<5) +#define PMF_NO_PREDICTION (1<<6) +#define PMF_FROZEN (1<<7) +#define PMF_INTERMISSION (1<<8) +#define PMF_SPECTATE_FOLLOW (1<<9) +#define PMF_CAMERA_VIEW (1<<9) // use camera view instead of ps view +#define PMF_NO_MOVE (1<<10) +#define PMF_VIEW_DUCK_RUN (1<<11) +#define PMF_VIEW_JUMP_START (1<<12) +#define PMF_LEVELEXIT (1<<13) +#define PMF_NO_GRAVITY (1<<14) +#define PMF_NO_HUD (1<<15) +#define PMF_UNKNOWN (1<<16) + +// moveposflags +#define MPF_POSITION_STANDING (1<<0) +#define MPF_POSITION_CROUCHING (1<<1) +#define MPF_POSITION_PRONE (1<<2) +#define MPF_POSITION_OFFGROUND (1<<3) + +#define MPF_MOVEMENT_WALKING (1<<4) +#define MPF_MOVEMENT_RUNNING (1<<5) +#define MPF_MOVEMENT_FALLING (1<<6) + +#define MAXTOUCH 32 + +#define MOVERESULT_NONE 0 // nothing blocking +#define MOVERESULT_TURNED 1 // move blocked, but player turned to avoid it +#define MOVERESULT_BLOCKED 2 // move blocked by slope or wall +#define MOVERESULT_HITWALL 3 // player ran into wall + +typedef struct { + // state (in / out) + playerState_t *ps; + + // command (in) + usercmd_t cmd; + int tracemask; // collide against these types of surfaces + int debugLevel; // if set, diagnostic output will be printed + qboolean noFootsteps; // if the game is setup for no footsteps by the server + + int framecount; + + // results (out) + int numtouch; + int touchents[ MAXTOUCH ]; + + int moveresult; // indicates whether 2the player's movement was blocked and how + qboolean stepped; + + int pmoveEvent; // events predicted on client side + vec3_t mins, maxs; // bounding box size + + int watertype; + int waterlevel; + + float xyspeed; + + // for fixed msec Pmove + int pmove_fixed; + int pmove_msec; + + // callbacks to test the world + // these will be different functions during game and cgame + void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask, int capsule, qboolean traceDeep ); + int (*pointcontents)( const vec3_t point, int passEntityNum ); +} pmove_t; + +// if a full pmove isn't done on the client, you can just update the angles +void PM_GetMove( float *pfForward, float *pfRight ); +void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ); +void Pmove_GroundTrace( pmove_t *pmove ); +void Pmove( pmove_t *pmove ); +void PmoveAdjustAngleSettings( vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState ); +void PmoveAdjustAngleSettings_Client( vec_t *vViewAngles, vec_t *vAngles, playerState_t *pPlayerState, entityState_t *pEntState ); + +//=================================================================================== + + +// player_state->stats[] indexes +// NOTE: may not have more than 32 +typedef enum { + STAT_HEALTH, + STAT_MAX_HEALTH, + STAT_WEAPONS, + STAT_EQUIPPED_WEAPON, + STAT_AMMO, + STAT_MAXAMMO, + STAT_CLIPAMMO, // ammo in current weapon clip + STAT_MAXCLIPAMMO, // maxammo in current weapon clip + STAT_INZOOM, + STAT_CROSSHAIR, + STAT_LAST_PAIN, // Last amount of damage the player took + STAT_UNUSED_2, + STAT_BOSSHEALTH, // if we are fighting a boss, how much health he currently has + STAT_CINEMATIC, // This is set when we go into cinematics + STAT_ADDFADE, // This is set when we need to do an addblend for the fade + STAT_LETTERBOX, // This is set to the fraction of the letterbox + STAT_COMPASSNORTH, + STAT_OBJECTIVELEFT, + STAT_OBJECTIVERIGHT, + STAT_OBJECTIVECENTER, + STAT_TEAM, + STAT_KILLS, + STAT_DEATHS, + STAT_UNUSED_3, + STAT_UNUSED_4, + STAT_HIGHEST_SCORE, + STAT_ATTACKERCLIENT, + STAT_INFOCLIENT, + STAT_INFOCLIENT_HEALTH, + STAT_DAMAGEDIR, + STAT_LAST_STAT +} statIndex_t; + +#define MAX_LETTERBOX_SIZE 0x7fff + +#define ITEM_NAME_AMMO 0 +#define ITEM_NAME_WEAPON 1 + +#define STAT_DEAD_YAW 5 // su44: Is there a DEAD_YAW stat in MoHAA? + +// player_state->persistant[] indexes +// these fields are the only part of player_state that isn't +// cleared on respawn +// NOTE: may not have more than 16 +typedef enum { + PERS_SCORE, // !!! MUST NOT CHANGE, SERVER AND GAME BOTH REFERENCE !!! + PERS_TEAM // player team +} persEnum_t; + +// entityState_t->eFlags +// su44: eFlags used in MoHAA +#define EF_CLIMBWALL 0x00000010 +#define EF_UNARMED 0x00000020 // su44: this player has his weapon holstered +#define EF_LINKANGLES 0x00000040 +#define EF_ALLIES 0x00000080 // su44: this player is in allies team +#define EF_AXIS 0x00000100 // su44: this player is in axis team +#define EF_DEAD 0x00000200 // don't draw a foe marker over players with EF_DEAD + + +// su44: q3 remnants +#define EF_TICKING 0x00000002 // used to make players play the prox mine ticking sound +#define EF_TELEPORT_BIT 0x00000004 // toggled every time the origin abruptly changes +#define EF_AWARD_EXCELLENT 0x00000008 // draw an excellent sprite +#define EF_PLAYER_EVENT 0x00000010 +#define EF_BOUNCE 0x00000010 // for missiles +#define EF_AWARD_GAUNTLET 0x00000040 // draw a gauntlet sprite +#define EF_MOVER_STOP 0x00000400 // will push otherwise +#define EF_AWARD_CAP 0x00000800 // draw the capture sprite +#define EF_TALK 0x00001000 // draw a talk balloon +#define EF_CONNECTION 0x00002000 // draw a connection trouble sprite +#define EF_VOTED 0x00004000 // already cast a vote +#define EF_AWARD_IMPRESSIVE 0x00008000 // draw an impressive sprite +#define EF_AWARD_DEFEND 0x00010000 // draw a defend sprite +#define EF_AWARD_ASSIST 0x00020000 // draw a assist sprite +#define EF_AWARD_DENIED 0x00040000 // denied +#define EF_TEAMVOTED 0x00080000 // already cast a team vote +#define EF_EVERYFRAME 0x00100000 // def commands will be run every client frame +#define EF_ANTISBJUICE 0x00200000 // anti sucknblow juice +#define EF_DONT_PROCESS_COMMANDS 0x00400000 // don't process client commands for this entity + +// these defines could be deleted sometime when code/game/ is cleared of Q3A stuff +#define TEAM_FREE 0 +#define TEAM_RED 4 +#define TEAM_BLUE 3 +#define TEAM_NUM_TEAMS 5 + +//=================================================================================== + +// flip the togglebit every time an animation +// changes so a restart of the same anim can be detected +#define ANIM_TOGGLEBIT (1<<9) +#define ANIM_BLEND (1<<10) +#define ANIM_NUMBITS 11 + +// server side anim bits +#define ANIM_SERVER_EXITCOMMANDS_PROCESSED (1<<12) + +#define ANIM_MASK ( ~( ANIM_TOGGLEBIT | ANIM_BLEND | ANIM_SERVER_EXITCOMMANDS_PROCESSED ) ) + +// if FRAME_EXPLICIT is set, don't auto animate +#define FRAME_EXPLICIT 512 +#define FRAME_MASK ( ~FRAME_EXPLICIT ) + +// +// Tag specific flags +// +#define TAG_NUMBITS 10 // number of bits required to send over network +#define TAG_MASK ( ( 1 << 10 ) - 1 ) + + +// +// Camera Flags +// +#define CF_CAMERA_ANGLES_ABSOLUTE ( 1 << 0 ) +#define CF_CAMERA_ANGLES_IGNORE_PITCH ( 1 << 1 ) +#define CF_CAMERA_ANGLES_IGNORE_YAW ( 1 << 2 ) +#define CF_CAMERA_ANGLES_ALLOWOFFSET ( 1 << 3 ) +#define CF_CAMERA_ANGLES_TURRETMODE ( 1 << 4 ) +#define CF_CAMERA_CUT_BIT ( 1 << 7 ) // this bit gets toggled everytime we do a hard camera cut + +typedef enum { + TEAM_NONE, + TEAM_SPECTATOR, + TEAM_FREEFORALL, + TEAM_ALLIES, + TEAM_AXIS +} teamtype_t; + +// How many players on the overlay +#define TEAM_MAXOVERLAY 32 + +// means of death +// su44: changed to MoHAA's +typedef enum { + MOD_NONE, + MOD_SUICIDE, + MOD_CRUSH, + MOD_CRUSH_EVERY_FRAME, + MOD_TELEFRAG, + MOD_LAVA, + MOD_SLIME, + MOD_FALLING, + MOD_LAST_SELF_INFLICTED, + MOD_EXPLOSION, + MOD_EXPLODEWALL, + MOD_ELECTRIC, + MOD_ELECTRICWATER, + MOD_THROWNOBJECT, + MOD_GRENADE, + MOD_BEAM, + MOD_ROCKET, + MOD_IMPACT, + MOD_BULLET, + MOD_FAST_BULLET, + MOD_VEHICLE, + MOD_FIRE, + MOD_FLASHBANG, + MOD_ON_FIRE, + MOD_GIB, + MOD_IMPALE, + MOD_BASH, + MOD_SHOTGUN, + MOD_TOTAL_NUMBER, + +} meansOfDeath_t; + +extern const char *means_of_death_strings[]; + +//--------------------------------------------------------- + +// g_dmflags->integer flags +#define DF_NO_HEALTH (1<<0) +#define DF_NO_POWERUPS (1<<1) +#define DF_WEAPONS_STAY (1<<2) +#define DF_NO_FALLING (1<<3) +#define DF_INSTANT_ITEMS (1<<4) +#define DF_SAME_LEVEL (1<<5) +#define DF_SKINTEAMS (1<<6) +#define DF_MODELTEAMS (1<<7) +#define DF_FRIENDLY_FIRE (1<<8) +#define DF_SPAWN_FARTHEST (1<<9) +#define DF_FORCE_RESPAWN (1<<10) +#define DF_NO_ARMOR (1<<11) +#define DF_FAST_WEAPONS (1<<12) +#define DF_NOEXIT (1<<13) +#define DF_INFINITE_AMMO (1<<14) +#define DF_FIXED_FOV (1<<15) +#define DF_NO_DROP_WEAPONS (1<<16) +#define DF_NO_FOOTSTEPS (1<<17) + +#define DM_FLAG( flag ) ( g_gametype->integer && ( ( int )dmflags->integer & ( flag ) ) ) + +// content masks +#define MASK_ALL (-1) +#define MASK_SOLID (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_UNKNOWN2|CONTENTS_NOBOTCLIP|CONTENTS_BBOX) +#define MASK_USABLE (CONTENTS_SOLID|CONTENTS_BODY) +#define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY|CONTENTS_TRIGGER|CONTENTS_FENCE|CONTENTS_UNKNOWN2|CONTENTS_NOBOTCLIP|CONTENTS_NOTTEAM2) +#define MASK_DEADSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_CORPSE|CONTENTS_NOTTEAM2|CONTENTS_FENCE) +#define MASK_MONSTERSOLID (CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_BODY) +#define MASK_WATER (CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME) +#define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA) +#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_TRIGGER|CONTENTS_BODY|CONTENTS_FENCE|CONTENTS_WEAPONCLIP|CONTENTS_UNKNOWN2|CONTENTS_NOBOTCLIP|CONTENTS_WATER|CONTENTS_NOTTEAM1|CONTENTS_NOTTEAM2) +#define MASK_PROJECTILE (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_TRIGGER|CONTENTS_FENCE|CONTENTS_WEAPONCLIP|CONTENTS_UNKNOWN2|CONTENTS_NOBOTCLIP|CONTENTS_BBOX) +#define MASK_MELEE (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_TRIGGER|CONTENTS_WEAPONCLIP|CONTENTS_FENCE|CONTENTS_UNKNOWN2|CONTENTS_NOBOTCLIP|CONTENTS_BBOX|CONTENTS_NOTTEAM1) +#define MASK_PATHSOLID (CONTENTS_SOLID|CONTENTS_TRIGGER|CONTENTS_BODY|CONTENTS_FENCE|CONTENTS_UNKNOWN2|CONTENTS_BBOX|CONTENTS_MONSTERCLIP) +#define MASK_CAMERASOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY|MASK_WATER) +#define MASK_BEAM (CONTENTS_SOLID|CONTENTS_TRIGGER|CONTENTS_PLAYERCLIP|CONTENTS_BODY|CONTENTS_FENCE) +#define MASK_LADDER (CONTENTS_SOLID|CONTENTS_LADDER|CONTENTS_TRIGGER|CONTENTS_PLAYERCLIP|CONTENTS_BODY|CONTENTS_FENCE) +#define MASK_AUTOCALCLIFE (CONTENTS_SOLID|CONTENTS_TRIGGER|CONTENTS_FENCE) +#define MASK_EXPLOSION (CONTENTS_SOLID|CONTENTS_TRIGGER|CONTENTS_WEAPONCLIP) +#define MASK_SOUND (CONTENTS_SOLID|CONTENTS_TRANSLUCENT) +#define MASK_VEHICLE (CONTENTS_SOLID|CONTENTS_TRIGGER|CONTENTS_VEHICLECLIP|CONTENTS_FENCE) +#define MASK_CLICK (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_UNKNOWN3|CONTENTS_UNKNOWN2|CONTENTS_NOBOTCLIP|CONTENTS_BBOX) +#define MASK_CANSEE (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_WEAPONCLIP|CONTENTS_UNKNOWN2|CONTENTS_NOBOTCLIP|CONTENTS_SLIME|CONTENTS_LAVA|CONTENTS_BBOX) +#define MASK_ITEM (CONTENTS_SOLID|CONTENTS_TRIGGER|CONTENTS_PLAYERCLIP|CONTENTS_FENCE) +#define MASK_TRANSITION (CONTENTS_SOLID|CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_UNKNOWN2|CONTENTS_NOTTEAM1|CONTENTS_WEAPONCLIP) +#define MASK_TARGETPATH (CONTENTS_SOLID|CONTENTS_TRIGGER|CONTENTS_MONSTERCLIP|CONTENTS_FENCE|CONTENTS_UNKNOWN2|CONTENTS_BBOX) +#define MASK_LINE (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_UNKNOWN2|CONTENTS_NOBOTCLIP|CONTENTS_BBOX) +#define MASK_VEHICLETURRET (CONTENTS_SOLID|CONTENTS_TRIGGER|CONTENTS_FENCE|CONTENTS_VEHICLECLIP|CONTENTS_MONSTERCLIP|CONTENTS_PLAYERCLIP) + +// mohaa mask +/* +#define MASK_ALL -1 +#define MASK_SOLID 1 + +#define MASK_COLLISION 0x26000B21 +#define MASK_PERMANENTMARK 0x40000001 +#define MASK_AUTOCALCLIFE 0x40002021 +#define MASK_EXPLOSION 0x40040001 +#define MASK_TREADMARK 0x42012B01 +#define MASK_THIRDPERSON 0x42012B39 +#define MASK_FOOTSTEP 0x42022901 +#define MASK_BEAM 0x42042B01 +#define MASK_VISIBLE 0x42042B01 +#define MASK_VEHICLE 0x42042B01 +#define MASK_BULLET 0x42042B21 +#define MASK_SHOT 0x42042BA1 +#define MASK_CROSSHAIRSHADER 0x42092B01 +#define MASK_TRACER 0x42142B21 +*/ + +// +// entityState_t->eType +// +typedef enum { + ET_MODELANIM_SKEL, + ET_MODELANIM, + ET_VEHICLE, + ET_PLAYER, + ET_ITEM, + ET_GENERAL, + ET_MISSILE, + ET_MOVER, + ET_BEAM, + ET_MULTIBEAM, + ET_PORTAL, + ET_EVENT_ONLY, + ET_RAIN, + ET_LEAF, + ET_SPEAKER, + ET_PUSH_TRIGGER, + ET_TELEPORT_TRIGGER, + ET_DECAL, + ET_EMITTER, + ET_ROPE, + ET_EVENTS, + ET_EXEC_COMMANDS, + ET_SPRITE +} entityType_t; + +// su44; yes, I know there is no q3 trajectory_t in MoHAA, +// but I need it for fgame rotating doors code. +void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ); +void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result ); + +void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap ); +void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap ); + +#ifdef __cplusplus +} +#endif + +#endif /* bg_public.h */ diff --git a/code/game/bg_slidemove.cpp b/code/game/bg_slidemove.cpp new file mode 100644 index 00000000..59e79211 --- /dev/null +++ b/code/game/bg_slidemove.cpp @@ -0,0 +1,322 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// bg_slidemove.c -- part of bg_pmove functionality + +#include "../qcommon/q_shared.h" +#include "bg_public.h" +#include "bg_local.h" + +/* + +input: origin, velocity, bounds, groundPlane, trace function + +output: origin, velocity, impacts, stairup boolean + +*/ + +/* +================== +PM_SlideMove + +Returns qtrue if the velocity was clipped in some way +================== +*/ +#define MAX_CLIP_PLANES 5 +qboolean PM_SlideMove( qboolean gravity ) +{ + int bumpcount, numbumps; + vec3_t dir; + float d; + int numplanes; + vec3_t planes[ MAX_CLIP_PLANES ]; + vec3_t primal_velocity; + vec3_t clipVelocity; + int i, j, k; + trace_t trace; + vec3_t end; + float time_left; + float into; + vec3_t endVelocity; + vec3_t endClipVelocity; + + numbumps = 4; + + VectorCopy( pm->ps->velocity, primal_velocity ); + + if( gravity ) { + VectorCopy( pm->ps->velocity, endVelocity ); + endVelocity[ 2 ] -= pm->ps->gravity * pml.frametime; + pm->ps->velocity[ 2 ] = ( pm->ps->velocity[ 2 ] + endVelocity[ 2 ] ) * 0.5; + primal_velocity[ 2 ] = endVelocity[ 2 ]; + if( pml.groundPlane ) { + // slide along the ground plane + PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, + pm->ps->velocity, OVERCLIP ); + } + } + + time_left = pml.frametime; + + // never turn against the ground plane + if( pml.groundPlane ) { + numplanes = 1; + VectorCopy( pml.groundTrace.plane.normal, planes[ 0 ] ); + } + else { + numplanes = 0; + } + + // never turn against original velocity + VectorNormalize2( pm->ps->velocity, planes[ numplanes ] ); + numplanes++; + + for( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) { + + // calculate position we are trying to move to + VectorMA( pm->ps->origin, time_left, pm->ps->velocity, end ); + + // see if we can make it there + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + + if( trace.allsolid ) { + // entity is completely trapped in another solid + pm->ps->velocity[ 2 ] = 0; // don't build up falling damage, but allow sideways acceleration + return qtrue; + } + + if( trace.fraction > 0 ) { + // actually covered some distance + VectorCopy( trace.endpos, pm->ps->origin ); + } + + if( trace.fraction == 1 ) { + break; // moved the entire distance + } + + if( ( trace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) && ( trace.plane.normal[ 2 ] > 0 ) ) + { + // treat steep walls as vertical + trace.plane.normal[ 2 ] = 0; + VectorNormalizeFast( trace.plane.normal ); + } + + // save entity for contact + PM_AddTouchEnt( trace.entityNum ); + + time_left -= time_left * trace.fraction; + + if( numplanes >= MAX_CLIP_PLANES ) { + // this shouldn't really happen + VectorClear( pm->ps->velocity ); + return qtrue; + } + + // + // if this is the same plane we hit before, nudge velocity + // out along it, which fixes some epsilon issues with + // non-axial planes + // + for( i = 0; i < numplanes; i++ ) { + if( DotProduct( trace.plane.normal, planes[ i ] ) > 0.99 ) { + VectorAdd( trace.plane.normal, pm->ps->velocity, pm->ps->velocity ); + break; + } + } + if( i < numplanes ) { + continue; + } + VectorCopy( trace.plane.normal, planes[ numplanes ] ); + numplanes++; + + // + // modify velocity so it parallels all of the clip planes + // + + // find a plane that it enters + for( i = 0; i < numplanes; i++ ) { + into = DotProduct( pm->ps->velocity, planes[ i ] ); + if( into >= 0.1 ) { + continue; // move doesn't interact with the plane + } + + // see how hard we are hitting things + if( -into > pml.impactSpeed ) { + pml.impactSpeed = -into; + } + + // slide along the plane + PM_ClipVelocity( pm->ps->velocity, planes[ i ], clipVelocity, OVERCLIP ); + + // slide along the plane + PM_ClipVelocity( endVelocity, planes[ i ], endClipVelocity, OVERCLIP ); + + // see if there is a second plane that the new move enters + for( j = 0; j < numplanes; j++ ) { + if( j == i ) { + continue; + } + if( DotProduct( clipVelocity, planes[ j ] ) >= 0.1 ) { + continue; // move doesn't interact with the plane + } + + // try clipping the move to the plane + PM_ClipVelocity( clipVelocity, planes[ j ], clipVelocity, OVERCLIP ); + PM_ClipVelocity( endClipVelocity, planes[ j ], endClipVelocity, OVERCLIP ); + + // see if it goes back into the first clip plane + if( DotProduct( clipVelocity, planes[ i ] ) >= 0 ) { + continue; + } + + // slide the original velocity along the crease + CrossProduct( planes[ i ], planes[ j ], dir ); + VectorNormalize( dir ); + d = DotProduct( dir, pm->ps->velocity ); + VectorScale( dir, d, clipVelocity ); + + CrossProduct( planes[ i ], planes[ j ], dir ); + VectorNormalize( dir ); + d = DotProduct( dir, endVelocity ); + VectorScale( dir, d, endClipVelocity ); + + // see if there is a third plane the the new move enters + for( k = 0; k < numplanes; k++ ) { + if( k == i || k == j ) { + continue; + } + if( DotProduct( clipVelocity, planes[ k ] ) >= 0.1 ) { + continue; // move doesn't interact with the plane + } + + // stop dead at a tripple plane interaction + VectorClear( pm->ps->velocity ); + return qtrue; + } + } + + // if we have fixed all interactions, try another move + VectorCopy( clipVelocity, pm->ps->velocity ); + VectorCopy( endClipVelocity, endVelocity ); + break; + } + } + + if( gravity ) { + VectorCopy( endVelocity, pm->ps->velocity ); + } + + return ( bumpcount != 0 ); +} + +/* +================== +PM_StepSlideMove + +================== +*/ +void PM_StepSlideMove( qboolean gravity ) +{ + vec3_t start_o; + vec3_t start_v; + vec3_t nostep_o; + vec3_t nostep_v; + trace_t trace; + qboolean bWasOnGoodGround; + vec3_t up; + vec3_t down; + + VectorCopy( pm->ps->origin, start_o ); + VectorCopy( pm->ps->velocity, start_v ); + + if ( PM_SlideMove( gravity ) == 0 ) { + return; // we got exactly where we wanted to go first try + } + + VectorCopy( start_o, down ); + down[ 2 ] -= STEPSIZE; + pm->trace( &trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + VectorSet( up, 0, 0, 1 ); + + // never step up when you still have up velocity + if( pm->ps->velocity[ 2 ] > 0 && ( trace.fraction == 1.0f || + DotProduct( trace.plane.normal, up ) < MIN_WALK_NORMAL ) ) { + return; + } + + if( pml.groundPlane && pml.groundTrace.plane.normal[ 2 ] >= MIN_WALK_NORMAL ) + { + bWasOnGoodGround = true; + } + else + { + bWasOnGoodGround = false; + } + + VectorCopy( start_o, up ); + up[ 2 ] += STEPSIZE; + + // test the player position if they were a stepheight higher + pm->trace( &trace, up, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + if( trace.allsolid ) + { + up[ 2 ] -= 9.0f; + pm->trace( &trace, up, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + if( trace.allsolid ) + { + return; + } + } + + VectorCopy( pm->ps->origin, nostep_o ); + VectorCopy( pm->ps->velocity, nostep_v ); + + // try slidemove from this position + VectorCopy( up, pm->ps->origin ); + VectorCopy( start_v, pm->ps->velocity ); + + PM_SlideMove( gravity ); + + // push down the final amount + VectorCopy( pm->ps->origin, down ); + down[ 2 ] -= STEPSIZE; + + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask, qtrue, qfalse ); + if( !trace.allsolid ) + { + if( bWasOnGoodGround && trace.fraction < 1.0 && trace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) + { + VectorCopy( nostep_o, pm->ps->origin ); + VectorCopy( nostep_v, pm->ps->velocity ); + return; + } + + VectorCopy( trace.endpos, pm->ps->origin ); + } + + if ( trace.fraction < 1.0f ) { + PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP ); + } + + pm->stepped = qtrue; +} + diff --git a/code/game/body.cpp b/code/game/body.cpp new file mode 100644 index 00000000..95ba6bb1 --- /dev/null +++ b/code/game/body.cpp @@ -0,0 +1,80 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// body.cpp: Dead bodies + +#include "animate.h" +#include "body.h" + +CLASS_DECLARATION( Animate, Body, NULL ) +{ + { NULL, NULL } +}; + +//============================================================= +//Body::Body +//============================================================= +Body::Body() +{ + edict->s.eType = ET_MODELANIM; + edict->clipmask = MASK_DEADSOLID; + edict->s.eFlags |= EF_DEAD; + + setSolidType( SOLID_NOT ); + setContents( CONTENTS_CORPSE ); + setMoveType( MOVETYPE_NONE ); + + PostEvent( EV_DeathSinkStart, 5.0f ); +} + +void Body::Damage( Event *ev ) +{ + str gib_name; + int number_of_gibs; + float scale; + Animate *ent; + str real_gib_name; + + if ( !com_blood->integer ) + return; + + gib_name = "fx_rgib"; + number_of_gibs = 5; + scale = 1.2f; + + // Spawn the gibs + real_gib_name = gib_name; + real_gib_name += number_of_gibs; + real_gib_name += ".tik"; + + ent = new Animate; + ent->setModel( real_gib_name.c_str() ); + ent->setScale( scale ); + ent->setOrigin( centroid ); + ent->NewAnim( "idle" ); + ent->PostEvent( EV_Remove, 1.0f ); + + Sound( "snd_decap", CHAN_BODY, 1.0f, 300.0f ); + + this->hideModel(); + this->takedamage = DAMAGE_NO; +} \ No newline at end of file diff --git a/code/game/body.h b/code/game/body.h new file mode 100644 index 00000000..b24e434d --- /dev/null +++ b/code/game/body.h @@ -0,0 +1,43 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// body.h: Dead bodies + +#ifndef __BODY_H__ +#define __BODY_H__ + +#include + +//============================================================= +//class Body +//============================================================= +class Body : public Animate +{ +private: + void Damage( Event *ev ); + +public: + CLASS_PROTOTYPE( Body ); + Body(); +}; + +#endif //__BODY_H__ diff --git a/code/game/botlib.h b/code/game/botlib.h new file mode 100644 index 00000000..c49455ab --- /dev/null +++ b/code/game/botlib.h @@ -0,0 +1,506 @@ +// Copyright (C) 1999-2000 Id Software, Inc. +// +/***************************************************************************** + * name: botlib.h + * + * desc: bot AI library + * + * $Archive: /EF2/Code/DLLs/game/botlib.h $ + * $Author: Singlis $ + * $Revision: 5 $ + * $Modtime: 9/24/03 3:09p $ + * $Date: 9/26/03 2:35p $ + * + *****************************************************************************/ + +#ifndef __BOTLIB_H__ +#define __BOTLIB_H__ + +#define BOTLIB_API_VERSION 2 + +struct aas_clientmove_s; +struct aas_entityinfo_s; +struct aas_areainfo_s; +struct aas_altroutegoal_s; +struct aas_predictroute_s; +struct bot_consolemessage_s; +struct bot_match_s; +struct bot_goal_s; +struct bot_moveresult_s; +struct bot_initmove_s; +struct weaponinfo_s; + +#define BOTFILESBASEFOLDER "botfiles" +//debug line colors +#define LINECOLOR_NONE -1 +#define LINECOLOR_RED 1//0xf2f2f0f0L +#define LINECOLOR_GREEN 2//0xd0d1d2d3L +#define LINECOLOR_BLUE 3//0xf3f3f1f1L +#define LINECOLOR_YELLOW 4//0xdcdddedfL +#define LINECOLOR_ORANGE 5//0xe0e1e2e3L + +//Print types +#define PRT_MESSAGE 1 +#define PRT_WARNING 2 +#define PRT_ERROR 3 +#define PRT_FATAL 4 +#define PRT_EXIT 5 + +//console message types +#define CMS_NORMAL 0 +#define CMS_CHAT 1 + +//botlib error codes +#define BLERR_NOERROR 0 //no error +#define BLERR_LIBRARYNOTSETUP 1 //library not setup +#define BLERR_INVALIDENTITYNUMBER 2 //invalid entity number +#define BLERR_NOAASFILE 3 //no AAS file available +#define BLERR_CANNOTOPENAASFILE 4 //cannot open AAS file +#define BLERR_WRONGAASFILEID 5 //incorrect AAS file id +#define BLERR_WRONGAASFILEVERSION 6 //incorrect AAS file version +#define BLERR_CANNOTREADAASLUMP 7 //cannot read AAS file lump +#define BLERR_CANNOTLOADICHAT 8 //cannot load initial chats +#define BLERR_CANNOTLOADITEMWEIGHTS 9 //cannot load item weights +#define BLERR_CANNOTLOADITEMCONFIG 10 //cannot load item config +#define BLERR_CANNOTLOADWEAPONWEIGHTS 11 //cannot load weapon weights +#define BLERR_CANNOTLOADWEAPONCONFIG 12 //cannot load weapon config + +//action flags +#define ACTION_ATTACK 0x0000001 +#define ACTION_ATTACKRIGHT 0x0000002 +#define ACTION_USE 0x0000004 +#define ACTION_RESPAWN 0x0000008 +#define ACTION_JUMP 0x0000010 +#define ACTION_MOVEUP 0x0000020 +#define ACTION_CROUCH 0x0000080 +#define ACTION_MOVEDOWN 0x0000100 +#define ACTION_MOVEFORWARD 0x0000200 +#define ACTION_MOVEBACK 0x0000800 +#define ACTION_MOVELEFT 0x0001000 +#define ACTION_MOVERIGHT 0x0002000 +#define ACTION_DELAYEDJUMP 0x0008000 +#define ACTION_TALK 0x0010000 +#define ACTION_GESTURE 0x0020000 +#define ACTION_WALK 0x0080000 +#define ACTION_AFFIRMATIVE 0x0100000 +#define ACTION_NEGATIVE 0x0200000 +#define ACTION_GETFLAG 0x0800000 +#define ACTION_GUARDBASE 0x1000000 +#define ACTION_PATROL 0x2000000 +#define ACTION_FOLLOWME 0x8000000 + +//the bot input, will be converted to an usercmd_t +typedef struct bot_input_s +{ + float thinktime; //time since last output (in seconds) + vec3_t dir; //movement direction + float speed; //speed in the range [0, 400] + vec3_t viewangles; //the view angles + int actionflags; //one of the ACTION_? flags + int weapon,latchweapon; //weapon to use + int firestate; //right/left hand fire state +} bot_input_t; + +#ifndef BSPTRACE + +#define BSPTRACE + +//bsp_trace_t hit surface +typedef struct bsp_surface_s +{ + char name[16]; + int flags; + int value; +} bsp_surface_t; + +//remove the bsp_trace_s structure definition l8r on +//a trace is returned when a box is swept through the world +typedef struct bsp_trace_s +{ + qboolean allsolid; // if true, plane is not valid + qboolean startsolid; // if true, the initial point was in a solid area + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + cplane_t plane; // surface normal at impact + float exp_dist; // expanded plane distance + int sidenum; // number of the brush side hit + bsp_surface_t surface; // the hit point surface + int contents; // contents on other side of surface hit + int ent; // number of entity hit +} bsp_trace_t; + +#endif // BSPTRACE + +//entity state +typedef struct bot_entitystate_s +{ + int type; // entity type + int flags; // entity flags + vec3_t origin; // origin of the entity + vec3_t angles; // angles of the model + vec3_t old_origin; // for lerping + vec3_t mins; // bounding box minimums + vec3_t maxs; // bounding box maximums + int groundent; // ground entity + int solid; // solid type + int modelindex; // model used + int modelindex2; // weapons, CTF flags, etc + int frame; // model frame number + int event; // impulse events -- muzzle flashes, footsteps, etc + int eventParm; // even parameter + int powerups; // bit flags + int weapon; // determines weapon and flash model, etc + int legsAnim; // mask off ANIM_TOGGLEBIT + int torsoAnim; // mask off ANIM_TOGGLEBIT +} bot_entitystate_t; + +//bot AI library exported functions +typedef struct botlib_import_s +{ + //print messages from the bot library + void (QDECL *Print)(int type, char *fmt, ...); + //trace a bbox through the world + void (*Trace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask); + //trace a bbox against a specific entity + void (*EntityTrace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int entnum, int contentmask); + //retrieve the contents at the given point + int (*PointContents)(vec3_t point); + //check if the point is in potential visible sight + int (*inPVS)(vec3_t p1, vec3_t p2); + //retrieve the BSP entity data lump + char *(*BSPEntityData)(void); + // + void (*BSPModelMinsMaxsOrigin)(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin); + //send a bot client command + void (*BotClientCommand)(int client, const char *command); // was char *, changed for c++ compilation + //memory allocation + void *(*GetMemory)(int size); // allocate from Zone + void (*FreeMemory)(void *ptr); // free memory from Zone + int (*AvailableMemory)(void); // available Zone memory + void *(*HunkAlloc)(int size); // allocate from hunk + //file system access + int (*FS_FOpenFile)( const char *qpath, fileHandle_t *file, fsMode_t mode ); + int (*FS_Read)( void *buffer, int len, fileHandle_t f ); + int (*FS_Write)( const void *buffer, int len, fileHandle_t f ); + void (*FS_FCloseFile)( fileHandle_t f ); + int (*FS_Seek)( fileHandle_t f, long offset, int origin ); + //debug visualisation stuff + int (*DebugLineCreate)(void); + void (*DebugLineDelete)(int line); + void (*DebugLineShow)(int line, vec3_t start, vec3_t end, int color); + // + int (*DebugPolygonCreate)(int color, int numPoints, vec3_t *points); + void (*DebugPolygonDelete)(int id); +} botlib_import_t; + +typedef struct aas_export_s +{ + //----------------------------------- + // be_aas_entity.h + //----------------------------------- + void (*AAS_EntityInfo)(int entnum, struct aas_entityinfo_s *info); + //----------------------------------- + // be_aas_main.h + //----------------------------------- + int (*AAS_Initialized)(void); + void (*AAS_PresenceTypeBoundingBox)(int presencetype, vec3_t mins, vec3_t maxs); + float (*AAS_Time)(void); + //-------------------------------------------- + // be_aas_sample.c + //-------------------------------------------- + int (*AAS_PointAreaNum)(vec3_t point); + int (*AAS_PointReachabilityAreaIndex)( vec3_t point ); + int (*AAS_TraceAreas)(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas); + int (*AAS_BBoxAreas)(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas); + int (*AAS_AreaInfo)( int areanum, struct aas_areainfo_s *info ); + //-------------------------------------------- + // be_aas_bspq3.c + //-------------------------------------------- + int (*AAS_PointContents)(vec3_t point); + int (*AAS_NextBSPEntity)(int ent); + int (*AAS_ValueForBSPEpairKey)(int ent, char *key, char *value, int size); + int (*AAS_VectorForBSPEpairKey)(int ent, char *key, vec3_t v); + int (*AAS_FloatForBSPEpairKey)(int ent, char *key, float *value); + int (*AAS_IntForBSPEpairKey)(int ent, char *key, int *value); + //-------------------------------------------- + // be_aas_reach.c + //-------------------------------------------- + int (*AAS_AreaReachability)(int areanum); + //-------------------------------------------- + // be_aas_route.c + //-------------------------------------------- + int (*AAS_AreaTravelTimeToGoalArea)(int areanum, vec3_t origin, int goalareanum, int travelflags); + int (*AAS_EnableRoutingArea)(int areanum, int enable); + int (*AAS_PredictRoute)(struct aas_predictroute_s *route, int areanum, vec3_t origin, + int goalareanum, int travelflags, int maxareas, int maxtime, + int stopevent, int stopcontents, int stoptfl, int stopareanum); + //-------------------------------------------- + // be_aas_altroute.c + //-------------------------------------------- + int (*AAS_AlternativeRouteGoals)(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags, + struct aas_altroutegoal_s *altroutegoals, int maxaltroutegoals, + int type); + //-------------------------------------------- + // be_aas_move.c + //-------------------------------------------- + int (*AAS_Swimming)(vec3_t origin); + 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); +} aas_export_t; + +typedef struct ea_export_s +{ + //ClientCommand elementary actions + void (*EA_Command)(int client, const char *command ); + void (*EA_Say)(int client, char *str); + void (*EA_SayTeam)(int client, char *str); + // + void (*EA_Action)(int client, int action); + void (*EA_Gesture)(int client); + void (*EA_Talk)(int client); + void (*EA_ToggleFireState)(int client); + void (*EA_Attack)(int client, int primarydangerous, int altdangerous); + void (*EA_Use)(int client); + void (*EA_Respawn)(int client); + void (*EA_MoveUp)(int client); + void (*EA_MoveDown)(int client); + void (*EA_MoveForward)(int client); + void (*EA_MoveBack)(int client); + void (*EA_MoveLeft)(int client); + void (*EA_MoveRight)(int client); + void (*EA_Crouch)(int client); + + void (*EA_SelectWeapon)(int client, int weapon); + void (*EA_Jump)(int client); + void (*EA_DelayedJump)(int client); + void (*EA_Move)(int client, vec3_t dir, float speed); + void (*EA_View)(int client, vec3_t viewangles); + //send regular input to the server + void (*EA_EndRegular)(int client, float thinktime); + void (*EA_GetInput)(int client, float thinktime, bot_input_t *input); + void (*EA_ResetInput)(int client); +} ea_export_t; + +typedef struct ai_export_s +{ + //----------------------------------- + // be_ai_char.h + //----------------------------------- + int (*BotLoadCharacter)(char *charfile, float skill); + void (*BotFreeCharacter)(int character); + float (*Characteristic_Float)(int character, int index); + float (*Characteristic_BFloat)(int character, int index, float min, float max); + int (*Characteristic_Integer)(int character, int index); + int (*Characteristic_BInteger)(int character, int index, int min, int max); + void (*Characteristic_String)(int character, int index, char *buf, int size); + //----------------------------------- + // be_ai_chat.h + //----------------------------------- + int (*BotAllocChatState)(void); + void (*BotFreeChatState)(int handle); + void (*BotQueueConsoleMessage)(int chatstate, int type, char *message); + void (*BotRemoveConsoleMessage)(int chatstate, int handle); + int (*BotNextConsoleMessage)(int chatstate, struct bot_consolemessage_s *cm); + int (*BotNumConsoleMessages)(int chatstate); + void (*BotInitialChat)(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); + int (*BotNumInitialChats)(int chatstate, char *type); + int (*BotReplyChat)(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); + int (*BotChatLength)(int chatstate); + void (*BotEnterChat)(int chatstate, int client, int sendto); + void (*BotGetChatMessage)(int chatstate, char *buf, int size); + int (*StringContains)(char *str1, char *str2, int casesensitive); + int (*BotFindMatch)(char *str, struct bot_match_s *match, unsigned long int context); + void (*BotMatchVariable)(struct bot_match_s *match, int variable, char *buf, int size); + void (*UnifyWhiteSpaces)(char *string); + void (*BotReplaceSynonyms)(char *string, unsigned long int context); + int (*BotLoadChatFile)(int chatstate, char *chatfile, char *chatname); + void (*BotSetChatGender)(int chatstate, int gender); + void (*BotSetChatName)(int chatstate, char *name, int client); + //----------------------------------- + // be_ai_goal.h + //----------------------------------- + void (*BotResetGoalState)(int goalstate); + void (*BotResetAvoidGoals)(int goalstate); + void (*BotRemoveFromAvoidGoals)(int goalstate, int number); + void (*BotPushGoal)(int goalstate, struct bot_goal_s *goal); + void (*BotPopGoal)(int goalstate); + void (*BotEmptyGoalStack)(int goalstate); + void (*BotDumpAvoidGoals)(int goalstate); + void (*BotDumpGoalStack)(int goalstate); + void (*BotGoalName)(int number, char *name, int size); + int (*BotGetTopGoal)(int goalstate, struct bot_goal_s *goal); + int (*BotGetSecondGoal)(int goalstate, struct bot_goal_s *goal); + int (*BotChooseLTGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags); + int (*BotChooseNBGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags, + struct bot_goal_s *ltg, float maxtime); + int (*BotTouchingGoal)(vec3_t origin, struct bot_goal_s *goal); + int (*BotItemGoalInVisButNotVisible)(int viewer, vec3_t eye, vec3_t viewangles, struct bot_goal_s *goal); + int (*BotGetLevelItemGoal)(int index, char *classname, struct bot_goal_s *goal); + int (*BotGetNextCampSpotGoal)(int num, struct bot_goal_s *goal); + int (*BotGetMapLocationGoal)(char *name, struct bot_goal_s *goal); + float (*BotAvoidGoalTime)(int goalstate, int number); + void (*BotSetAvoidGoalTime)(int goalstate, int number, float avoidtime); + void (*BotInitLevelItems)(void); + void (*BotUpdateEntityItems)(void); + int (*BotLoadItemWeights)(int goalstate, char *filename); + void (*BotFreeItemWeights)(int goalstate); + void (*BotInterbreedGoalFuzzyLogic)(int parent1, int parent2, int child); + void (*BotSaveGoalFuzzyLogic)(int goalstate, char *filename); + void (*BotMutateGoalFuzzyLogic)(int goalstate, float range); + int (*BotAllocGoalState)(int client); + void (*BotFreeGoalState)(int handle); + //----------------------------------- + // be_ai_move.h + //----------------------------------- + void (*BotResetMoveState)(int movestate); + void (*BotMoveToGoal)(struct bot_moveresult_s *result, int movestate, struct bot_goal_s *goal, int travelflags); + int (*BotMoveInDirection)(int movestate, vec3_t dir, float speed, int type); + void (*BotResetAvoidReach)(int movestate); + void (*BotResetLastAvoidReach)(int movestate); + int (*BotReachabilityArea)(vec3_t origin, int testground); + int (*BotMovementViewTarget)(int movestate, struct bot_goal_s *goal, int travelflags, float lookahead, vec3_t target); + int (*BotPredictVisiblePosition)(vec3_t origin, int areanum, struct bot_goal_s *goal, int travelflags, vec3_t target); + int (*BotAllocMoveState)(void); + void (*BotFreeMoveState)(int handle); + void (*BotInitMoveState)(int handle, struct bot_initmove_s *initmove); + void (*BotAddAvoidSpot)(int movestate, vec3_t origin, float radius, int type); + //----------------------------------- + // be_ai_weap.h + //----------------------------------- + int (*BotChooseBestFightWeapon)(int weaponstate, int *inventory); + void (*BotGetWeaponInfo)(int weaponstate, int weapon, struct weaponinfo_s *weaponinfo); + int (*BotLoadWeaponWeights)(int weaponstate, char *filename); + int (*BotAllocWeaponState)(void); + void (*BotFreeWeaponState)(int weaponstate); + void (*BotResetWeaponState)(int weaponstate); + //----------------------------------- + // be_ai_gen.h + //----------------------------------- + int (*GeneticParentsAndChildSelection)(int numranks, float *ranks, int *parent1, int *parent2, int *child); +} ai_export_t; + +//bot AI library imported functions +typedef struct botlib_export_s +{ + //Area Awareness System functions + aas_export_t aas; + //Elementary Action functions + ea_export_t ea; + //AI functions + ai_export_t ai; + //setup the bot library, returns BLERR_ + int (*BotLibSetup)(void); + //shutdown the bot library, returns BLERR_ + int (*BotLibShutdown)(void); + //sets a library variable returns BLERR_ + int (*BotLibVarSet)(char *var_name, char *value); + //gets a library variable returns BLERR_ + int (*BotLibVarGet)(char *var_name, char *value, int size); + + //sets a C-like define returns BLERR_ + int (*PC_AddGlobalDefine)(char *string); + int (*PC_LoadSourceHandle)(const char *filename); + int (*PC_FreeSourceHandle)(int handle); +// int (*PC_ReadTokenHandle)(int handle, pc_token_t *pc_token); + int (*PC_SourceFileAndLine)(int handle, char *filename, int *line); + + //start a frame in the bot library + int (*BotLibStartFrame)(float time); + //load a new map in the bot library + int (*BotLibLoadMap)(const char *mapname); + //entity updates + int (*BotLibUpdateEntity)(int ent, bot_entitystate_t *state); + //just for testing + int (*Test)(int parm0, int parm1, vec3_t parm2, vec3_t parm3); +} botlib_export_t; + +//linking of bot library +botlib_export_t *GetBotLibAPI( int apiVersion, botlib_import_t *import ); + +/* Library variables: + +name: default: module(s): description: + +"basedir" "" l_utils.c base directory +"gamedir" "" l_utils.c game directory +"cddir" "" l_utils.c CD directory + +"log" "0" l_log.c enable/disable creating a log file +"maxclients" "4" be_interface.c maximum number of clients +"maxentities" "1024" be_interface.c maximum number of entities +"bot_developer" "0" be_interface.c bot developer mode + +"phys_friction" "6" be_aas_move.c ground friction +"phys_stopspeed" "100" be_aas_move.c stop speed +"phys_gravity" "800" be_aas_move.c gravity value +"phys_waterfriction" "1" be_aas_move.c water friction +"phys_watergravity" "400" be_aas_move.c gravity in water +"phys_maxvelocity" "320" be_aas_move.c maximum velocity +"phys_maxwalkvelocity" "320" be_aas_move.c maximum walk velocity +"phys_maxcrouchvelocity" "100" be_aas_move.c maximum crouch velocity +"phys_maxswimvelocity" "150" be_aas_move.c maximum swim velocity +"phys_walkaccelerate" "10" be_aas_move.c walk acceleration +"phys_airaccelerate" "1" be_aas_move.c air acceleration +"phys_swimaccelerate" "4" be_aas_move.c swim acceleration +"phys_maxstep" "18" be_aas_move.c maximum step height +"phys_maxsteepness" "0.7" be_aas_move.c maximum floor steepness +"phys_maxbarrier" "32" be_aas_move.c maximum barrier height +"phys_maxwaterjump" "19" be_aas_move.c maximum waterjump height +"phys_jumpvel" "270" be_aas_move.c jump z velocity +"phys_falldelta5" "40" be_aas_move.c +"phys_falldelta10" "60" be_aas_move.c +"rs_waterjump" "400" be_aas_move.c +"rs_teleport" "50" be_aas_move.c +"rs_barrierjump" "100" be_aas_move.c +"rs_startcrouch" "300" be_aas_move.c +"rs_startgrapple" "500" be_aas_move.c +"rs_startwalkoffledge" "70" be_aas_move.c +"rs_startjump" "300" be_aas_move.c +"rs_rocketjump" "500" be_aas_move.c +"rs_bfgjump" "500" be_aas_move.c +"rs_jumppad" "250" be_aas_move.c +"rs_aircontrolledjumppad" "300" be_aas_move.c +"rs_funcbob" "300" be_aas_move.c +"rs_startelevator" "50" be_aas_move.c +"rs_falldamage5" "300" be_aas_move.c +"rs_falldamage10" "500" be_aas_move.c +"rs_maxjumpfallheight" "450" be_aas_move.c + +"max_aaslinks" "4096" be_aas_sample.c maximum links in the AAS +"max_routingcache" "4096" be_aas_route.c maximum routing cache size in KB +"forceclustering" "0" be_aas_main.c force recalculation of clusters +"forcereachability" "0" be_aas_main.c force recalculation of reachabilities +"forcewrite" "0" be_aas_main.c force writing of aas file +"aasoptimize" "0" be_aas_main.c enable aas optimization +"sv_mapChecksum" "0" be_aas_main.c BSP file checksum +"bot_visualizejumppads" "0" be_aas_reach.c visualize jump pads + +"bot_reloadcharacters" "0" - reload bot character files +"ai_gametype" "0" be_ai_goal.c game type +"droppedweight" "1000" be_ai_goal.c additional dropped item weight +"weapindex_rocketlauncher" "5" be_ai_move.c rl weapon index for rocket jumping +"weapindex_bfg10k" "9" be_ai_move.c bfg weapon index for bfg jumping +"weapindex_grapple" "10" be_ai_move.c grapple weapon index for grappling +"entitytypemissile" "3" be_ai_move.c ET_MISSILE +"offhandgrapple" "0" be_ai_move.c enable off hand grapple hook +"cmd_grappleon" "grappleon" be_ai_move.c command to activate off hand grapple +"cmd_grappleoff" "grappleoff" be_ai_move.c command to deactivate off hand grapple +"itemconfig" "items.c" be_ai_goal.c item configuration file +"weaponconfig" "weapons.c" be_ai_weap.c weapon configuration file +"synfile" "syn.c" be_ai_chat.c file with synonyms +"rndfile" "rnd.c" be_ai_chat.c file with random strings +"matchfile" "match.c" be_ai_chat.c file with match strings +"nochat" "0" be_ai_chat.c disable chats +"max_messages" "1024" be_ai_chat.c console message heap size +"max_weaponinfo" "32" be_ai_weap.c maximum number of weapon info +"max_projectileinfo" "32" be_ai_weap.c maximum number of projectile info +"max_iteminfo" "256" be_ai_goal.c maximum number of item info +"max_levelitems" "256" be_ai_goal.c maximum number of level items + +*/ +#endif diff --git a/code/game/botmenudef.h b/code/game/botmenudef.h new file mode 100644 index 00000000..ef235672 --- /dev/null +++ b/code/game/botmenudef.h @@ -0,0 +1,287 @@ + +#define ITEM_TYPE_TEXT 0 // simple text +#define ITEM_TYPE_BUTTON 1 // button, basically text with a border +#define ITEM_TYPE_RADIOBUTTON 2 // toggle button, may be grouped +#define ITEM_TYPE_CHECKBOX 3 // check box +#define ITEM_TYPE_EDITFIELD 4 // editable text, associated with a cvar +#define ITEM_TYPE_COMBO 5 // drop down list +#define ITEM_TYPE_LISTBOX 6 // scrollable list +#define ITEM_TYPE_MODEL 7 // model +#define ITEM_TYPE_OWNERDRAW 8 // owner draw, name specs what it is +#define ITEM_TYPE_NUMERICFIELD 9 // editable text, associated with a cvar +#define ITEM_TYPE_SLIDER 10 // mouse speed, volume, etc. +#define ITEM_TYPE_YESNO 11 // yes no cvar setting +#define ITEM_TYPE_MULTI 12 // multiple list setting, enumerated +#define ITEM_TYPE_BIND 13 // multiple list setting, enumerated + +#define ITEM_ALIGN_LEFT 0 // left alignment +#define ITEM_ALIGN_CENTER 1 // center alignment +#define ITEM_ALIGN_RIGHT 2 // right alignment + +#define ITEM_TEXTSTYLE_NORMAL 0 // normal text +#define ITEM_TEXTSTYLE_BLINK 1 // fast blinking +#define ITEM_TEXTSTYLE_PULSE 2 // slow pulsing +#define ITEM_TEXTSTYLE_SHADOWED 3 // drop shadow ( need a color for this ) +#define ITEM_TEXTSTYLE_OUTLINED 4 // drop shadow ( need a color for this ) +#define ITEM_TEXTSTYLE_OUTLINESHADOWED 5 // drop shadow ( need a color for this ) +#define ITEM_TEXTSTYLE_SHADOWEDMORE 6 // drop shadow ( need a color for this ) + +#define WINDOW_BORDER_NONE 0 // no border +#define WINDOW_BORDER_FULL 1 // full border based on border color ( single pixel ) +#define WINDOW_BORDER_HORZ 2 // horizontal borders only +#define WINDOW_BORDER_VERT 3 // vertical borders only +#define WINDOW_BORDER_KCGRADIENT 4 // horizontal border using the gradient bars + +#define WINDOW_STYLE_EMPTY 0 // no background +#define WINDOW_STYLE_FILLED 1 // filled with background color +#define WINDOW_STYLE_GRADIENT 2 // gradient bar based on background color +#define WINDOW_STYLE_SHADER 3 // gradient bar based on background color +#define WINDOW_STYLE_TEAMCOLOR 4 // team color +#define WINDOW_STYLE_CINEMATIC 5 // cinematic + +#define MENU_TRUE 1 // uh.. true +#define MENU_FALSE 0 // and false + +#define HUD_VERTICAL 0x00 +#define HUD_HORIZONTAL 0x01 + +// list box element types +#define LISTBOX_TEXT 0x00 +#define LISTBOX_IMAGE 0x01 + +// list feeders +#define FEEDER_HEADS 0x00 // model heads +#define FEEDER_MAPS 0x01 // text maps based on game type +#define FEEDER_SERVERS 0x02 // servers +#define FEEDER_CLANS 0x03 // clan names +#define FEEDER_ALLMAPS 0x04 // all maps available, in graphic format +#define FEEDER_REDTEAM_LIST 0x05 // red team members +#define FEEDER_BLUETEAM_LIST 0x06 // blue team members +#define FEEDER_PLAYER_LIST 0x07 // players +#define FEEDER_TEAM_LIST 0x08 // team members for team voting +#define FEEDER_MODS 0x09 // team members for team voting +#define FEEDER_DEMOS 0x0a // team members for team voting +#define FEEDER_SCOREBOARD 0x0b // team members for team voting +#define FEEDER_Q3HEADS 0x0c // model heads +#define FEEDER_SERVERSTATUS 0x0d // server status +#define FEEDER_FINDPLAYER 0x0e // find player +#define FEEDER_CINEMATICS 0x0f // cinematics + +// display flags +#define CG_SHOW_BLUE_TEAM_HAS_REDFLAG 0x00000001 +#define CG_SHOW_RED_TEAM_HAS_BLUEFLAG 0x00000002 +#define CG_SHOW_ANYTEAMGAME 0x00000004 +#define CG_SHOW_HARVESTER 0x00000008 +#define CG_SHOW_ONEFLAG 0x00000010 +#define CG_SHOW_CTF 0x00000020 +#define CG_SHOW_OBELISK 0x00000040 +#define CG_SHOW_HEALTHCRITICAL 0x00000080 +#define CG_SHOW_SINGLEPLAYER 0x00000100 +#define CG_SHOW_TOURNAMENT 0x00000200 +#define CG_SHOW_DURINGINCOMINGVOICE 0x00000400 +#define CG_SHOW_IF_PLAYER_HAS_FLAG 0x00000800 +#define CG_SHOW_LANPLAYONLY 0x00001000 +#define CG_SHOW_MINED 0x00002000 +#define CG_SHOW_HEALTHOK 0x00004000 +#define CG_SHOW_TEAMINFO 0x00008000 +#define CG_SHOW_NOTEAMINFO 0x00010000 +#define CG_SHOW_OTHERTEAMHASFLAG 0x00020000 +#define CG_SHOW_YOURTEAMHASENEMYFLAG 0x00040000 +#define CG_SHOW_ANYNONTEAMGAME 0x00080000 +#define CG_SHOW_2DONLY 0x10000000 + + +#define UI_SHOW_LEADER 0x00000001 +#define UI_SHOW_NOTLEADER 0x00000002 +#define UI_SHOW_FAVORITESERVERS 0x00000004 +#define UI_SHOW_ANYNONTEAMGAME 0x00000008 +#define UI_SHOW_ANYTEAMGAME 0x00000010 +#define UI_SHOW_NEWHIGHSCORE 0x00000020 +#define UI_SHOW_DEMOAVAILABLE 0x00000040 +#define UI_SHOW_NEWBESTTIME 0x00000080 +#define UI_SHOW_FFA 0x00000100 +#define UI_SHOW_NOTFFA 0x00000200 +#define UI_SHOW_NETANYNONTEAMGAME 0x00000400 +#define UI_SHOW_NETANYTEAMGAME 0x00000800 +#define UI_SHOW_NOTFAVORITESERVERS 0x00001000 + + + + +// owner draw types +// ideally these should be done outside of this file but +// this makes it much easier for the macro expansion to +// convert them for the designers ( from the .menu files ) +#define CG_OWNERDRAW_BASE 1 +#define CG_PLAYER_ARMOR_ICON 1 +#define CG_PLAYER_ARMOR_VALUE 2 +#define CG_PLAYER_HEAD 3 +#define CG_PLAYER_HEALTH 4 +#define CG_PLAYER_AMMO_ICON 5 +#define CG_PLAYER_AMMO_VALUE 6 +#define CG_SELECTEDPLAYER_HEAD 7 +#define CG_SELECTEDPLAYER_NAME 8 +#define CG_SELECTEDPLAYER_LOCATION 9 +#define CG_SELECTEDPLAYER_STATUS 10 +#define CG_SELECTEDPLAYER_WEAPON 11 +#define CG_SELECTEDPLAYER_POWERUP 12 + +#define CG_FLAGCARRIER_HEAD 13 +#define CG_FLAGCARRIER_NAME 14 +#define CG_FLAGCARRIER_LOCATION 15 +#define CG_FLAGCARRIER_STATUS 16 +#define CG_FLAGCARRIER_WEAPON 17 +#define CG_FLAGCARRIER_POWERUP 18 + +#define CG_PLAYER_ITEM 19 +#define CG_PLAYER_SCORE 20 + +#define CG_BLUE_FLAGHEAD 21 +#define CG_BLUE_FLAGSTATUS 22 +#define CG_BLUE_FLAGNAME 23 +#define CG_RED_FLAGHEAD 24 +#define CG_RED_FLAGSTATUS 25 +#define CG_RED_FLAGNAME 26 + +#define CG_BLUE_SCORE 27 +#define CG_RED_SCORE 28 +#define CG_RED_NAME 29 +#define CG_BLUE_NAME 30 +#define CG_HARVESTER_SKULLS 31 // only shows in harvester +#define CG_ONEFLAG_STATUS 32 // only shows in one flag +#define CG_PLAYER_LOCATION 33 +#define CG_TEAM_COLOR 34 +#define CG_CTF_POWERUP 35 + +#define CG_AREA_POWERUP 36 +#define CG_AREA_LAGOMETER 37 // painted with old system +#define CG_PLAYER_HASFLAG 38 +#define CG_GAME_TYPE 39 // not done + +#define CG_SELECTEDPLAYER_ARMOR 40 +#define CG_SELECTEDPLAYER_HEALTH 41 +#define CG_PLAYER_STATUS 42 +#define CG_FRAGGED_MSG 43 // painted with old system +#define CG_PROXMINED_MSG 44 // painted with old system +#define CG_AREA_FPSINFO 45 // painted with old system +#define CG_AREA_SYSTEMCHAT 46 // painted with old system +#define CG_AREA_TEAMCHAT 47 // painted with old system +#define CG_AREA_CHAT 48 // painted with old system +#define CG_GAME_STATUS 49 +#define CG_KILLER 50 +#define CG_PLAYER_ARMOR_ICON2D 51 +#define CG_PLAYER_AMMO_ICON2D 52 +#define CG_ACCURACY 53 +#define CG_ASSISTS 54 +#define CG_DEFEND 55 +#define CG_EXCELLENT 56 +#define CG_IMPRESSIVE 57 +#define CG_PERFECT 58 +#define CG_GAUNTLET 59 +#define CG_SPECTATORS 60 +#define CG_TEAMINFO 61 +#define CG_VOICE_HEAD 62 +#define CG_VOICE_NAME 63 +#define CG_PLAYER_HASFLAG2D 64 +#define CG_HARVESTER_SKULLS2D 65 // only shows in harvester +#define CG_CAPFRAGLIMIT 66 +#define CG_1STPLACE 67 +#define CG_2NDPLACE 68 +#define CG_CAPTURES 69 + + + + +#define UI_OWNERDRAW_BASE 200 +#define UI_HANDICAP 200 +#define UI_EFFECTS 201 +#define UI_PLAYERMODEL 202 +#define UI_CLANNAME 203 +#define UI_CLANLOGO 204 +#define UI_GAMETYPE 205 +#define UI_MAPPREVIEW 206 +#define UI_SKILL 207 +#define UI_BLUETEAMNAME 208 +#define UI_REDTEAMNAME 209 +#define UI_BLUETEAM1 210 +#define UI_BLUETEAM2 211 +#define UI_BLUETEAM3 212 +#define UI_BLUETEAM4 213 +#define UI_BLUETEAM5 214 +#define UI_REDTEAM1 215 +#define UI_REDTEAM2 216 +#define UI_REDTEAM3 217 +#define UI_REDTEAM4 218 +#define UI_REDTEAM5 219 +#define UI_NETSOURCE 220 +#define UI_NETMAPPREVIEW 221 +#define UI_NETFILTER 222 +#define UI_TIER 223 +#define UI_OPPONENTMODEL 224 +#define UI_TIERMAP1 225 +#define UI_TIERMAP2 226 +#define UI_TIERMAP3 227 +#define UI_PLAYERLOGO 228 +#define UI_OPPONENTLOGO 229 +#define UI_PLAYERLOGO_METAL 230 +#define UI_OPPONENTLOGO_METAL 231 +#define UI_PLAYERLOGO_NAME 232 +#define UI_OPPONENTLOGO_NAME 233 +#define UI_TIER_MAPNAME 234 +#define UI_TIER_GAMETYPE 235 +#define UI_ALLMAPS_SELECTION 236 +#define UI_OPPONENT_NAME 237 +#define UI_VOTE_KICK 238 +#define UI_BOTNAME 239 +#define UI_BOTSKILL 240 +#define UI_REDBLUE 241 +#define UI_CROSSHAIR 242 +#define UI_SELECTEDPLAYER 243 +#define UI_MAPCINEMATIC 244 +#define UI_NETGAMETYPE 245 +#define UI_NETMAPCINEMATIC 246 +#define UI_SERVERREFRESHDATE 247 +#define UI_SERVERMOTD 248 +#define UI_GLINFO 249 +#define UI_KEYBINDSTATUS 250 +#define UI_CLANCINEMATIC 251 +#define UI_MAP_TIMETOBEAT 252 +#define UI_JOINGAMETYPE 253 +#define UI_PREVIEWCINEMATIC 254 +#define UI_STARTMAPCINEMATIC 255 +#define UI_MAPS_SELECTION 256 + +#define VOICECHAT_GETFLAG "getflag" // command someone to get the flag +#define VOICECHAT_OFFENSE "offense" // command someone to go on offense +#define VOICECHAT_DEFEND "defend" // command someone to go on defense +#define VOICECHAT_DEFENDFLAG "defendflag" // command someone to defend the flag +#define VOICECHAT_PATROL "patrol" // command someone to go on patrol (roam) +#define VOICECHAT_CAMP "camp" // command someone to camp (we don't have sounds for this one) +#define VOICECHAT_FOLLOWME "followme" // command someone to follow you +#define VOICECHAT_RETURNFLAG "returnflag" // command someone to return our flag +#define VOICECHAT_FOLLOWFLAGCARRIER "followflagcarrier" // command someone to follow the flag carrier +#define VOICECHAT_YES "yes" // yes, affirmative, etc. +#define VOICECHAT_NO "no" // no, negative, etc. +#define VOICECHAT_ONGETFLAG "ongetflag" // I'm getting the flag +#define VOICECHAT_ONOFFENSE "onoffense" // I'm on offense +#define VOICECHAT_ONDEFENSE "ondefense" // I'm on defense +#define VOICECHAT_ONPATROL "onpatrol" // I'm on patrol (roaming) +#define VOICECHAT_ONCAMPING "oncamp" // I'm camping somewhere +#define VOICECHAT_ONFOLLOW "onfollow" // I'm following +#define VOICECHAT_ONFOLLOWCARRIER "onfollowcarrier" // I'm following the flag carrier +#define VOICECHAT_ONRETURNFLAG "onreturnflag" // I'm returning our flag +#define VOICECHAT_INPOSITION "inposition" // I'm in position +#define VOICECHAT_IHAVEFLAG "ihaveflag" // I have the flag +#define VOICECHAT_BASEATTACK "baseattack" // the base is under attack +#define VOICECHAT_ENEMYHASFLAG "enemyhasflag" // the enemy has our flag (CTF) +#define VOICECHAT_STARTLEADER "startleader" // I'm the leader +#define VOICECHAT_STOPLEADER "stopleader" // I resign leadership +#define VOICECHAT_TRASH "trash" // lots of trash talk +#define VOICECHAT_WHOISLEADER "whoisleader" // who is the team leader +#define VOICECHAT_WANTONDEFENSE "wantondefense" // I want to be on defense +#define VOICECHAT_WANTONOFFENSE "wantonoffense" // I want to be on offense +#define VOICECHAT_KILLINSULT "kill_insult" // I just killed you +#define VOICECHAT_TAUNT "taunt" // I want to taunt you +#define VOICECHAT_DEATHINSULT "death_insult" // you just killed me +#define VOICECHAT_KILLGAUNTLET "kill_gauntlet" // I just killed you with the gauntlet +#define VOICECHAT_PRAISE "praise" // you did something good diff --git a/code/game/bspline.cpp b/code/game/bspline.cpp new file mode 100644 index 00000000..074a9282 --- /dev/null +++ b/code/game/bspline.cpp @@ -0,0 +1,956 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// bspline.cpp: Uniform non-rational bspline class. +// + +#include "g_local.h" +#include "BSpline.h" + +void BSpline::Set + ( + Vector *control_points_, + int num_control_points_, + splinetype_t type + ) + + { + int i; + + SetType( type ); + + has_orientation = false; + + if ( control_points ) + { + delete [] control_points; + control_points = NULL; + } + + num_control_points = num_control_points_; + if ( num_control_points ) + { + control_points = new BSplineControlPoint[ num_control_points ]; + assert( control_points ); + + for( i = 0; i < num_control_points; i++ ) + { + control_points[ i ].Set( control_points_[ i ] ); + } + } + } + +void BSpline::Set + ( + Vector *control_points_, + Vector *control_orients_, + float *control_speeds_, + int num_control_points_, + splinetype_t type + ) + + { + int i; + + SetType( type ); + + has_orientation = true; + + if ( control_points ) + { + delete [] control_points; + control_points = NULL; + } + + num_control_points = num_control_points_; + if ( num_control_points ) + { + control_points = new BSplineControlPoint[ num_control_points ]; + assert( control_points ); + + for( i = 0; i < num_control_points; i++ ) + { + control_points[ i ].Set( control_points_[ i ], control_orients_[ i ], control_speeds_[ i ] ); + } + } + } + +void BSpline::Clear + ( + void + ) + + { + if( control_points ) + { + delete [] control_points; + control_points = NULL; + } + num_control_points = 0; + has_orientation = false; + } + +inline float BSpline::EvalNormal + ( + float u, + Vector& pos, + Vector& orient + ) + + { + int segment_id; + float B[ 4 ]; + float tmp; + float u_2; + float u_3; + Vector ang; + float roll; + float speed; + + segment_id = ( int )u; + if ( segment_id < 0 ) + { + segment_id = 0; + } + if ( segment_id > num_control_points - 4 ) + { + segment_id = num_control_points - 4; + } + u -= ( float )segment_id; + + u_2 = u * u; + u_3 = u * u_2; + + tmp = 1 - u; + B[ 0 ] = ( tmp * tmp * tmp ) * ( 1.0f / 6.0f ); + B[ 1 ] = ( 3.0f * u_3 - 6.0f * u_2 + 4.0f ) * ( 1.0f / 6.0f ); + B[ 2 ] = ( -3.0f * u_3 + 3.0f * u_2 + 3.0f * u + 1 ) * ( 1.0f / 6.0f ); + B[ 3 ] = u_3 * ( 1.0f / 6.0f ); + + pos = + *control_points[ 0 + segment_id ].GetPosition() * B[ 0 ] + + *control_points[ 1 + segment_id ].GetPosition() * B[ 1 ] + + *control_points[ 2 + segment_id ].GetPosition() * B[ 2 ] + + *control_points[ 3 + segment_id ].GetPosition() * B[ 3 ]; + + ang = + *control_points[ 0 + segment_id ].GetOrientation() * B[ 0 ] + + *control_points[ 1 + segment_id ].GetOrientation() * B[ 1 ] + + *control_points[ 2 + segment_id ].GetOrientation() * B[ 2 ] + + *control_points[ 3 + segment_id ].GetOrientation() * B[ 3 ]; + + roll = + *control_points[ 0 + segment_id ].GetRoll() * B[ 0 ] + + *control_points[ 1 + segment_id ].GetRoll() * B[ 1 ] + + *control_points[ 2 + segment_id ].GetRoll() * B[ 2 ] + + *control_points[ 3 + segment_id ].GetRoll() * B[ 3 ]; + + speed = + *control_points[ 0 + segment_id ].GetSpeed() * B[ 0 ] + + *control_points[ 1 + segment_id ].GetSpeed() * B[ 1 ] + + *control_points[ 2 + segment_id ].GetSpeed() * B[ 2 ] + + *control_points[ 3 + segment_id ].GetSpeed() * B[ 3 ]; + + orient = ang.toAngles(); + orient[ ROLL ] = roll; + + return speed; + } + +inline float BSpline::EvalLoop + ( + float t, + Vector& pos, + Vector& orient + ) + + { + Vector retval; + Vector ang; + float speed; + float roll; + int segment_id; + int next_id; + float B[ 4 ]; + float tmp; + float u; + float u_2; + float u_3; + int i; + int j; + + segment_id = ( int )floor( t ); + u = t - floor( t ); + + segment_id %= num_control_points; + if ( segment_id < 0 ) + { + segment_id += num_control_points; + } + + u_2 = u * u; + u_3 = u * u_2; + + tmp = 1 - u; + B[ 0 ] = ( tmp * tmp * tmp ) * ( 1.0f / 6.0f ); + B[ 1 ] = ( 3.0f * u_3 - 6.0f * u_2 + 4.0f ) * ( 1.0f / 6.0f ); + B[ 2 ] = ( -3.0f * u_3 + 3.0f * u_2 + 3.0f * u + 1 ) * ( 1.0f / 6.0f ); + B[ 3 ] = u_3 * ( 1.0f / 6.0f ); + + speed = 0; + roll = 0; + + for( i = 0, j = segment_id; i < 4; i++, j++ ) + { + if ( j >= num_control_points ) + { + j -= ( num_control_points - loop_control_point ); + } + + retval += *control_points[ j ].GetPosition() * B[ i ]; + ang += *control_points[ j ].GetOrientation() * B[ i ]; + speed += *control_points[ j ].GetSpeed() * B[ i ]; + roll += *control_points[ j ].GetRoll() * B[ i ]; + } + + pos = retval; + + next_id = segment_id + 1; + if ( next_id >= num_control_points ) + { + next_id -= ( num_control_points - loop_control_point ); + } + orient = ang.toAngles(); + orient[ ROLL ] = roll; + + return speed; + } + +inline float BSpline::EvalClamp + ( + float t, + Vector& pos, + Vector& orient + ) + + { + Vector retval; + Vector ang; + int segment_id; + int next_id; + float B[ 4 ]; + float tmp; + float u; + float u_2; + float u_3; + int i; + int j; + float speed; + float roll; + + segment_id = ( int )floor( t ); + u = t - floor( t ); + + u_2 = u * u; + u_3 = u * u_2; + + tmp = 1 - u; + B[ 0 ] = ( tmp * tmp * tmp ) * ( 1.0f / 6.0f ); + B[ 1 ] = ( 3.0f * u_3 - 6.0f * u_2 + 4.0f ) * ( 1.0f / 6.0f ); + B[ 2 ] = ( -3.0f * u_3 + 3.0f * u_2 + 3.0f * u + 1 ) * ( 1.0f / 6.0f ); + B[ 3 ] = u_3 * ( 1.0f / 6.0f ); + + speed = 0; + roll = 0; + for( i = 0; i < 4; i++, segment_id++ ) + { + j = segment_id; + if ( j < 0 ) + { + j = 0; + } + else if ( j >= num_control_points ) + { + j = num_control_points - 1; + } + + retval += *control_points[ j ].GetPosition() * B[ i ]; + ang += *control_points[ j ].GetOrientation() * B[ i ]; + speed += *control_points[ j ].GetSpeed() * B[ i ]; + roll += *control_points[ j ].GetRoll() * B[ i ]; + } + + pos = retval; + + next_id = segment_id + 1; + if ( segment_id < 0 ) + { + segment_id = 0; + } + if ( segment_id >= num_control_points ) + { + segment_id = num_control_points - 1; + } + if ( next_id < 0 ) + { + next_id = 0; + } + if ( next_id >= num_control_points ) + { + next_id = num_control_points - 1; + } + orient = ang.toAngles(); + orient[ ROLL ] = roll; + + return speed; + } + + +Vector BSpline::Eval + ( + float u + ) + + { + Vector pos; + Vector orient; + + switch( curvetype ) + { + default: + case SPLINE_NORMAL : + EvalNormal( u, pos, orient ); + break; + + case SPLINE_CLAMP: + EvalClamp( u, pos, orient ); + break; + + case SPLINE_LOOP: + if ( u < 0 ) + { + EvalClamp( u, pos, orient ); + } + else + { + EvalLoop( u, pos, orient ); + } + break; + } + return pos; + } + +float BSpline::Eval + ( + float u, + Vector &pos, + Vector &orient + ) + + { + switch( curvetype ) + { + default: + case SPLINE_NORMAL : + return EvalNormal( u, pos, orient ); + break; + + case SPLINE_CLAMP: + return EvalClamp( u, pos, orient ); + break; + + case SPLINE_LOOP: + if ( u < 0 ) + { + return EvalClamp( u, pos, orient ); + } + else + { + return EvalLoop( u, pos, orient ); + } + break; + } + } + +void BSpline::DrawControlSegments + ( + void + ) + + { + int i; + + G_BeginLine(); + for( i = 0; i < num_control_points; i++ ) + { + G_Vertex( *control_points[ i ].GetPosition() ); + } + G_EndLine(); + } + +void BSpline::DrawCurve + ( + int num_subdivisions + ) + + { + float u; + float du; + + if ( !num_control_points ) + { + return; + } + + du = 1.0f / ( float )num_subdivisions; + + G_BeginLine(); + for( u = -2.0f; u <= ( float )num_control_points; u += du ) + { + G_Vertex( ( Vector )Eval( u ) ); + } + G_EndLine(); + } + +void BSpline::DrawCurve + ( + Vector offset, + int num_subdivisions + ) + + { + float u; + float du; + + du = 1.0f / ( float )num_subdivisions; + + G_BeginLine(); + for( u = -2.0f; u <= ( float )num_control_points; u += du ) + { + G_Vertex( offset + ( Vector )Eval( u ) ); + } + G_EndLine(); + } + +void BSpline::AppendControlPoint + ( + const Vector& new_control_point + ) + + { + BSplineControlPoint *old_control_points; + int i; + + old_control_points = control_points; + num_control_points++; + + control_points = new BSplineControlPoint[num_control_points]; + assert( control_points ); + + if ( old_control_points ) + { + for( i = 0; i < num_control_points - 1; i++ ) + { + control_points[ i ] = old_control_points[ i ]; + } + delete [] old_control_points; + } + + control_points[ num_control_points - 1 ].Set( new_control_point ); + } + +void BSpline::AppendControlPoint + ( + const Vector& new_control_point, + const float& speed + ) + + { + BSplineControlPoint *old_control_points; + int i; + + old_control_points = control_points; + num_control_points++; + + control_points = new BSplineControlPoint[num_control_points]; + assert( control_points ); + + if ( old_control_points ) + { + for( i = 0; i < num_control_points - 1; i++ ) + { + control_points[ i ] = old_control_points[ i ]; + } + delete [] old_control_points; + } + + control_points[ num_control_points - 1 ].Set( new_control_point, speed ); + } + +void BSpline::AppendControlPoint + ( + const Vector& new_control_point, + const Vector& new_control_orient, + const float& new_control_speed + ) + + { + BSplineControlPoint *old_control_points; + int i; + + has_orientation = true; + + old_control_points = control_points; + num_control_points++; + + control_points = new BSplineControlPoint[num_control_points]; + assert( control_points ); + + if ( old_control_points ) + { + for( i = 0; i < num_control_points - 1; i++ ) + { + control_points[ i ] = old_control_points[ i ]; + } + delete [] old_control_points; + } + + control_points[ num_control_points - 1 ].Set( new_control_point, new_control_orient, new_control_speed ); + } + +void BSpline::SetLoopPoint + ( + const Vector& pos + ) + { + int i; + + for( i = 0; i < num_control_points; i++ ) + { + if ( pos == *control_points[ i ].GetPosition() ) + { + loop_control_point = i; + break; + } + } + } + +int BSpline::PickControlPoint + ( + const Vector& window_point, + float pick_size + ) + + { + int i; + float closest_dist_2; + int closest_index; + float dist_2; + Vector delta; + + closest_index = -1; + closest_dist_2 = 1000000.0f; + for( i = 0; i < num_control_points; i++ ) + { + delta = window_point - *control_points[ i ].GetPosition(); + dist_2 = delta * delta; + if ( dist_2 < closest_dist_2 ) + { + closest_dist_2 = dist_2; + closest_index = i; + } + } + + if ( pick_size * pick_size >= closest_dist_2 ) + { + return closest_index; + } + else + { + return -1; + } + } + +Event EV_SplinePath_Create + ( + "SplinePath_create", + EV_DEFAULT, + NULL, + NULL, + "Creates the spline path from the target list.", + EV_NORMAL + ); +Event EV_SplinePath_Loop + ( + "loop", + EV_CONSOLE, + "s", + "loop_name", + "Sets the loop name.", + EV_NORMAL + ); +Event EV_SplinePath_Speed + ( + "speed", + EV_DEFAULT, + "f", + "speed", + "Sets the path speed.", + EV_NORMAL + ); +Event EV_SplinePath_SetTriggerTarget + ( + "triggertarget", + EV_DEFAULT, + "s", + "target", + "Sets the trigger target.", + EV_NORMAL + ); +Event EV_SplinePath_SetWatch + ( + "watch", + EV_CONSOLE, + "s", + "watchEntity", + "Sets the entity to watch at this node.", + EV_NORMAL + ); + +Event EV_SplinePath_SetFov + ( + "fov", + EV_CONSOLE, + "f", + "cameraFOV", + "Sets the fov at this node.", + EV_NORMAL + ); + +Event EV_SplinePath_SetFadeTime + ( + "fadetime", + EV_DEFAULT, + "f", + "fadeTime", + "Sets the fadetime at this node.", + EV_NORMAL + ); + +CLASS_DECLARATION( Entity, SplinePath, "info_splinepath" ) + { + { &EV_SplinePath_Create, &SplinePath::CreatePath }, + { &EV_SplinePath_Loop, &SplinePath::SetLoop }, + { &EV_SplinePath_Speed, &SplinePath::SetSpeed }, + { &EV_SplinePath_SetTriggerTarget, &SplinePath::SetTriggerTarget }, + { &EV_SplinePath_SetWatch, &SplinePath::SetWatch }, + { &EV_SplinePath_SetFov, &SplinePath::SetFov }, + { &EV_SplinePath_SetFadeTime, &SplinePath::SetFadeTime }, + { NULL, NULL } + }; + +SplinePath::SplinePath() +{ + entflags |= EF_SPLINEPATH; + + owner = this; + next = NULL; + loop = NULL; + speed = 1; + doWatch = false; + watchEnt = ""; + fov = 0; + fadeTime = -1; + + setMoveType( MOVETYPE_NONE ); + setSolidType( SOLID_NOT ); + hideModel(); + + if( !LoadingSavegame ) + { + PostEvent( EV_SplinePath_Create, FRAMETIME ); + } +} + +SplinePath::~SplinePath() + { + // disconnect from the chain + if ( owner != this ) + { + owner->SetNext( next ); + } + else if ( next ) + { + next->SetPrev( NULL ); + next = NULL; + } + + assert( owner == this ); + assert( next == NULL ); + } + +void SplinePath::SetLoop + ( + Event *ev + ) + + { + loop_name = ev->GetString( 1 ); + } + +void SplinePath::SetSpeed + ( + Event *ev + ) + + { + speed = ev->GetFloat( 1 ); + } + +void SplinePath::SetTriggerTarget + ( + Event *ev + ) + + { + SetTriggerTarget( ev->GetString( 1 ) ); + } + +void SplinePath::CreatePath + ( + Event *ev + ) + + { + const char *target; + Entity *ent; + + // Make the path from the targetlist. + target = Target(); + if ( target[ 0 ] ) + { + ent = ( Entity * )G_FindTarget( NULL, target ); + if ( ent ) + { + next = ( SplinePath * )ent; + next->owner = this; + } + else + { + ScriptError( "SplinePath::CreatePath: target %s not found\n", target ); + } + } + if ( loop_name.length() ) + { + ent = ( Entity * )G_FindTarget( NULL, loop_name.c_str() ); + if ( ent ) + { + loop = ( SplinePath * )ent; + } + } + } + +SplinePath *SplinePath::GetNext + ( + void + ) + + { + return next; + } + +SplinePath *SplinePath::GetPrev + ( + void + ) + + { + if ( owner == this ) + { + return NULL; + } + + return owner; + } + +void SplinePath::SetNext + ( + SplinePath *node + ) + + { + if ( next ) + { + // remove ourselves from the chain + next->owner = next; + } + + next = node; + if ( next ) + { + // disconnect next from it's previous node + if ( next->owner != next ) + { + next->owner->next = NULL; + } + next->owner = this; + } + } + +void SplinePath::SetPrev + ( + SplinePath *node + ) + + { + if ( owner != this ) + { + owner->next = NULL; + } + + if ( node && ( node != this ) ) + { + // safely remove the node from its chain + if ( node->next ) + { + node->next->owner = node->next; + } + node->next = this; + owner = node; + } + else + { + owner = this; + } + } + +SplinePath *SplinePath::GetLoop + ( + void + ) + + { + return loop; + } + +void SplinePath::SetWatch + ( + const char *name + ) + + { + if ( watchEnt != name ) + { + watchEnt = name; + if ( watchEnt.length() ) + { + doWatch = true; + } + else + { + doWatch = false; + } + } + } + +void SplinePath::SetWatch + ( + Event *ev + ) + + { + SetWatch( ev->GetString( 1 ) ); + } + + +void SplinePath::NoWatch + ( + void + ) + + { + doWatch = true; + watchEnt = "none"; + } + +str SplinePath::GetWatch + ( + void + ) + + { + return watchEnt; + } + +void SplinePath::SetFov + ( + float newFov + ) + + { + fov = newFov; + } + +void SplinePath::SetFov + ( + Event *ev + ) + + { + fov = ev->GetFloat( 1 ); + } + +float SplinePath::GetFov + ( + void + ) + + { + return fov; + } + +void SplinePath::SetFadeTime + ( + float newFadeTime + ) + + { + fadeTime = newFadeTime; + } + +void SplinePath::SetFadeTime + ( + Event *ev + ) + + { + fadeTime = ev->GetFloat( 1 ); + } + +float SplinePath::GetFadeTime + ( + void + ) + + { + return fadeTime; + } diff --git a/code/game/bspline.h b/code/game/bspline.h new file mode 100644 index 00000000..af2fd10b --- /dev/null +++ b/code/game/bspline.h @@ -0,0 +1,584 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// bspline.h: Uniform non-rational bspline class. +// + +#ifndef __BSPLINE_H__ +#define __BSPLINE_H__ + +#include "g_local.h" +#include "entity.h" +#include "Vector.h" + +typedef enum + { + SPLINE_NORMAL, + SPLINE_LOOP, + SPLINE_CLAMP + } splinetype_t; + +class BSplineControlPoint : public Class + { + private: + float roll; + Vector position; + Vector orientation; + float speed; + + public: + BSplineControlPoint(); + BSplineControlPoint( Vector pos, Vector orient, float speed ); + BSplineControlPoint( Vector pos ); + void Clear( void ); + void Set( Vector pos ); + void Set( Vector pos, float speed ); + void Set( Vector pos, Vector orient, float speed ); + void Get( Vector& pos, Vector& orient, float& speed ); + void Get( Vector& pos ); + Vector *GetPosition( void ); + Vector *GetOrientation( void ); + float *GetRoll( void ); + float *GetSpeed( void ); + void operator=( BSplineControlPoint &point ); + virtual void Archive( Archiver &arc ); + }; + +inline void BSplineControlPoint::Archive + ( + Archiver &arc + ) + + { + arc.ArchiveVector( &position ); + arc.ArchiveVector( &orientation ); + arc.ArchiveFloat( &speed ); + arc.ArchiveFloat( &roll ); + } + +inline void BSplineControlPoint::operator= + ( + BSplineControlPoint &point + ) + + { + position = point.position; + orientation = point.orientation; + speed = point.speed; + roll = point.roll; + } + +inline BSplineControlPoint::BSplineControlPoint() + { + roll = 0; + speed = 1; + } + +inline BSplineControlPoint::BSplineControlPoint + ( + Vector pos + ) + + { + speed = 1; + position = pos; + } + +inline BSplineControlPoint::BSplineControlPoint + ( + Vector pos, + Vector orient, + float speed + ) + + { + position = pos; + orient.AngleVectors( &orientation, NULL, NULL ); + roll = orient[ ROLL ]; + if ( roll > 180 ) + { + roll -= 360; + } + if ( roll < -180 ) + { + roll += 360; + } + this->speed = speed; + } + +inline void BSplineControlPoint::Clear + ( + void + ) + + { + roll = 0; + position = "0 0 0"; + vec_zero.AngleVectors( &orientation, NULL, NULL ); + speed = 1.0f; + } + +inline void BSplineControlPoint::Set + ( + Vector pos + ) + + { + speed = 1; + position = pos; + } + +inline void BSplineControlPoint::Set + ( + Vector pos, + float pointspeed + ) + + { + speed = pointspeed; + position = pos; + } + +inline void BSplineControlPoint::Set + ( + Vector pos, + Vector orient, + float speed + ) + + { + position = pos; + orient.AngleVectors( &orientation, NULL, NULL ); + roll = orient[ ROLL ]; + if ( roll > 180 ) + { + roll -= 360; + } + if ( roll < -180 ) + { + roll += 360; + } + this->speed = speed; + } + +inline void BSplineControlPoint::Get + ( + Vector& pos + ) + { + pos = position; + } + +inline Vector *BSplineControlPoint::GetPosition + ( + void + ) + + { + return &position; + } + +inline void BSplineControlPoint::Get + ( + Vector& pos, + Vector& orient, + float& speed + ) + + { + pos = position; + orient = orientation; + speed = this->speed; + } + +inline Vector *BSplineControlPoint::GetOrientation + ( + void + ) + { + return &orientation; + } + +inline float *BSplineControlPoint::GetRoll + ( + void + ) + { + return &roll; + } + +inline float *BSplineControlPoint::GetSpeed + ( + void + ) + { + return &speed; + } + +class BSpline : public Class + { + private: + BSplineControlPoint *control_points; + int num_control_points; + int loop_control_point; + splinetype_t curvetype; + qboolean has_orientation; + + float EvalNormal( float u, Vector &pos, Vector& orient ); + float EvalLoop( float u, Vector &pos, Vector& orient ); + float EvalClamp( float u, Vector &pos, Vector& orient ); + + public: + BSpline(); + ~BSpline(); + BSpline( Vector *control_points_, int num_control_points_, splinetype_t type ); + BSpline( Vector *control_points_, Vector *control_orients_, float *control_speeds_, int num_control_points_, splinetype_t type ); + void operator=( BSpline &spline ); + void SetType( splinetype_t type ); + int GetType( void ); + void Clear( void ); + void Set( Vector *control_points_, int num_control_points_, splinetype_t type ); + void Set( Vector *control_points_, Vector *control_orients_, float *control_speeds_, int num_control_points_, splinetype_t type ); + void AppendControlPoint( const Vector& new_control_point ); + void AppendControlPoint( const Vector& new_control_point, const float& speed ); + void AppendControlPoint( const Vector& new_control_point, const Vector& new_control_orient, const float& speed ); + Vector Eval( float u ); + float Eval( float u, Vector& pos, Vector& orient ); + + void DrawControlSegments( void ); + void DrawCurve( int num_subdivisions ); + void DrawCurve( Vector offset, int num_subdivisions ); + + void SetLoopPoint( const Vector& pos ); + + float EndPoint( void ); + + // return the index of the control point picked or -1 if none. + int PickControlPoint( const Vector& window_point, float pick_size ); + + Vector *GetControlPoint( int id ); + void GetControlPoint( int id, Vector& pos, Vector& orient, float& speed ); + void SetControlPoint( int id, const Vector& new_control_point ); + void SetControlPoint( int id, const Vector& new_control_point, const Vector& new_control_orient, const float& speed ); + virtual void Archive( Archiver &arc ); + }; + +inline BSpline::BSpline() + { + has_orientation = false; + control_points = NULL; + num_control_points = 0; + loop_control_point = 0; + curvetype = SPLINE_NORMAL; + } + +inline BSpline::~BSpline() + { + if ( control_points ) + { + delete [] control_points; + control_points = NULL; + } + } + +inline BSpline::BSpline + ( + Vector *control_points_, + int num_control_points_, + splinetype_t type + ) + + { + has_orientation = false; + control_points = NULL; + num_control_points = 0; + loop_control_point = 0; + curvetype = SPLINE_NORMAL; + + Set( control_points_, num_control_points_, type ); + } + +inline BSpline::BSpline + ( + Vector *control_points_, + Vector *control_orients_, + float *control_speeds_, + int num_control_points_, + splinetype_t type + ) + + { + has_orientation = false; + control_points = NULL; + num_control_points = 0; + loop_control_point = 0; + curvetype = SPLINE_NORMAL; + + Set( control_points_, control_orients_, control_speeds_, num_control_points_, type ); + } + +inline void BSpline::operator= + ( + BSpline &spline + ) + + { + int i; + + Clear(); + num_control_points = spline.num_control_points; + loop_control_point = spline.loop_control_point; + curvetype = spline.curvetype; + has_orientation = spline.has_orientation; + + if ( num_control_points ) + { + control_points = new BSplineControlPoint[num_control_points]; + assert( control_points ); + for ( i = 0; i < num_control_points ; i++ ) + control_points[ i ] = spline.control_points[ i ]; + } + else + { + control_points = NULL; + } + } + +inline void BSpline::SetType + ( + splinetype_t type + ) + + { + curvetype = type; + } + +inline int BSpline::GetType + ( + void + ) + + { + return curvetype; + } + +inline float BSpline::EndPoint + ( + void + ) + + { + return num_control_points; + } + +inline Vector *BSpline::GetControlPoint + ( + int id + ) + + { + assert( id >= 0 ); + assert( id < num_control_points ); + if ( ( id < 0 ) && ( id >= num_control_points ) ) + { + // probably wrong, but if we're in release mode we have no recourse + id = 0; + } + + return control_points[ id ].GetPosition(); + } + +inline void BSpline::GetControlPoint + ( + int id, + Vector& pos, + Vector& orient, + float& speed + ) + + { + assert( id >= 0 ); + assert( id < num_control_points ); + if ( ( id >= 0 ) && ( id < num_control_points ) ) + { + control_points[ id ].Get( pos, orient, speed ); + } + } + +inline void BSpline::SetControlPoint + ( + int id, + const Vector& new_control_point + ) + + { + assert( id >= 0 ); + assert( id < num_control_points ); + if ( ( id >= 0 ) && ( id < num_control_points ) ) + { + control_points[ id ].Set( new_control_point ); + } + } + +inline void BSpline::SetControlPoint + ( + int id, + const Vector& new_control_point, + const Vector& new_control_orient, + const float& speed + ) + + { + assert( id >= 0 ); + assert( id < num_control_points ); + if ( ( id >= 0 ) && ( id < num_control_points ) ) + { + control_points[ id ].Set( new_control_point, new_control_orient, speed ); + } + } + +inline void BSpline::Archive + ( + Archiver &arc + ) + { + int i; + + arc.ArchiveInteger( &num_control_points ); + if ( arc.Loading() ) + { + if ( num_control_points ) + control_points = new BSplineControlPoint[ num_control_points ]; + else + control_points = NULL; + } + + arc.ArchiveInteger( &loop_control_point ); + + i = curvetype; + arc.ArchiveInteger( &i ); + curvetype = ( splinetype_t )i; + + arc.ArchiveBoolean( &has_orientation ); + for( i = 0; i < num_control_points; i++ ) + { + control_points[ i ].Archive( arc ); + } + } + +extern Event EV_SplinePath_Create; +extern Event EV_SplinePath_Loop; +extern Event EV_SplinePath_Speed; + +class SplinePath : public Entity + { + protected: + SplinePath *owner; + SplinePath *next; + SplinePath *loop; + str loop_name; + + void CreatePath( Event *ev ); + void SetLoop( Event *ev ); + void SetSpeed( Event *ev ); + void SetTriggerTarget( Event *ev ); + void SetThread( Event *ev ); + void SetFov( Event *ev ); + void SetWatch( Event *ev ); + void SetFadeTime( Event *ev ); + + public: + float speed; + float fov; + float fadeTime; + qboolean doWatch; + str watchEnt; + str triggertarget; + str thread; + + CLASS_PROTOTYPE( SplinePath ); + + SplinePath(); + ~SplinePath(); + SplinePath *GetNext( void ); + SplinePath *GetPrev( void ); + SplinePath *GetLoop( void ); + void SetFadeTime( float newFadeTime ); + void SetFov( float theFov ); + void SetWatch( const char *name ); + void SetThread( const char *name ); + void SetTriggerTarget( const char *name ); + void NoWatch( void ); + str GetWatch( void ); + float GetFadeTime( void ); + float GetFov( void ); + void SetNext( SplinePath *node ); + void SetPrev( SplinePath *node ); + virtual void Archive( Archiver &arc ); + }; + +typedef SafePtr SplinePathPtr; + +inline void SplinePath::Archive + ( + Archiver &arc + ) + + { + Entity::Archive( arc ); + + arc.ArchiveObjectPointer( ( Class ** )&owner ); + arc.ArchiveObjectPointer( ( Class ** )&next ); + arc.ArchiveObjectPointer( ( Class ** )&loop ); + arc.ArchiveString( &loop_name ); + arc.ArchiveFloat( &speed ); + arc.ArchiveFloat( &fov ); + arc.ArchiveFloat( &fadeTime ); + arc.ArchiveBoolean( &doWatch ); + arc.ArchiveString( &watchEnt ); + arc.ArchiveString( &thread ); + arc.ArchiveString( &triggertarget ); + if ( arc.Loading() ) + { + CancelEventsOfType( EV_SplinePath_Create ); + } + } + +inline void SplinePath::SetThread + ( + const char *name + ) + + { + thread = name; + } + +inline void SplinePath::SetTriggerTarget + ( + const char *name + ) + + { + triggertarget = name; + } + +#endif /* __BSPLINE_H__ */ diff --git a/code/game/camera.cpp b/code/game/camera.cpp new file mode 100644 index 00000000..150a7790 --- /dev/null +++ b/code/game/camera.cpp @@ -0,0 +1,3641 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// camera.cpp: Camera. Duh. +// + +#include "g_local.h" +#include "entity.h" +#include "trigger.h" +#include "camera.h" +#include "bspline.h" +#include "player.h" +#include "camera.h" + +#define CAMERA_PATHFILE_VERSION 1 + +CameraManager CameraMan; + +void CameraMoveState::Initialize( Camera * camera ) + { + assert( camera ); + pos = camera->origin; + angles = camera->angles; + movedir = vec_zero; + followEnt = NULL; + orbitEnt = NULL; + + followingpath = false; + cameraTime = 0; + lastTime = 0; + newTime = 0; + cameraPath.Clear(); + splinePath = NULL; + currentNode = NULL; + loopNode = NULL; + } + +void CameraWatchState::Initialize( Camera * camera ) + { + assert( camera ); + watchAngles = camera->angles; + watchEnt = NULL; + watchNodes = true; + watchPath = false; + } + +void CameraState::Initialize( Camera * camera ) + { + assert( camera ); + move.Initialize( camera ); + watch.Initialize( camera ); + fov = camera->Fov(); + } + +void CameraMoveState::DoNodeEvents + ( + Camera * camera + ) + +{ + SplinePath *node; + Entity *ent; + Event *event; + + assert( camera ); + + node = currentNode; + if( node ) + { + float fadeTime; + float newFov; + + fadeTime = node->GetFadeTime(); + if( fadeTime == -1 ) + { + fadeTime = camera->fadeTime; + } + + if( node->doWatch ) + { + camera->Watch( node->GetWatch(), fadeTime ); + } + + newFov = node->GetFov(); + if( newFov ) + { + camera->SetFOV( newFov, fadeTime ); + } + + camera->Unregister( STRING_REACH ); + + if( node->triggertarget != "" ) + { + ent = NULL; + do + { + ent = ( Entity * )G_FindTarget( ( SimpleEntity * )ent, node->triggertarget.c_str() ); + if( !ent ) + { + break; + } + event = new Event( EV_Activate ); + event->AddEntity( camera ); + ent->PostEvent( event, 0 ); + } while( 1 ); + } + } +} + +void CameraMoveState::Evaluate + ( + Camera * camera + ) + { + Vector oldpos; + float speed_multiplier; + + assert( camera ); + + oldpos = pos; + // + // check for node events + // we explicitly skip the first node because we process that + // when we begin the follow path command + // + if ( ( lastTime != newTime ) && currentNode ) + { + if ( newTime > 1 ) + { + DoNodeEvents( camera ); + } + currentNode = currentNode->GetNext(); + if ( !currentNode ) + { + currentNode = loopNode; + } + } + lastTime = newTime; + + // + // evaluate position + // + if ( followingpath ) + { + speed_multiplier = cameraPath.Eval( cameraTime, pos, angles ); + + cameraTime += level.frametime * camera->camera_speed * speed_multiplier; + + if ( orbitEnt ) + { + pos += orbitEnt->origin; + if ( camera->orbit_dotrace ) + { + trace_t trace; + Vector start, back; + + start = orbitEnt->origin; + start[ 2 ] += orbitEnt->maxs[ 2 ]; + + back = start - pos; + back.normalize(); + + trace = G_Trace( start, vec_zero, vec_zero, pos, orbitEnt, camera->follow_mask, false, "Camera::EvaluatePosition" ); + + if ( trace.fraction < 1.0f ) + { + pos = trace.endpos; + // step in a bit towards the followEng + pos += back * 16; + } + } + } + } + else + { + if ( followEnt ) + { + trace_t trace; + Vector start, end, ang, back; + + start = followEnt->origin; + start[ 2 ] += followEnt->maxs[ 2 ]; + + if ( camera->follow_yaw_fixed ) + { + ang = vec_zero; + } + else + { + if ( followEnt->isSubclassOf( Player ) ) + { + Entity * ent; + ent = followEnt; + ( ( Player * )ent )->GetPlayerView( NULL, &ang ); + } + else + { + ang = followEnt->angles; + } + } + ang.y += camera->follow_yaw; + ang.AngleVectors( &back, NULL, NULL ); + + end = start - back * camera->follow_dist; + end[ 2 ] += 24; + + trace = G_Trace( start, vec_zero, vec_zero, end, followEnt, camera->follow_mask, false, "Camera::EvaluatePosition - Orbit" ); + + pos = trace.endpos; + // step in a bit towards the followEnt + pos += back * 16; + } + } + + // + // update times for node events + // + newTime = cameraTime + 2.0f; + + if ( newTime < 0 ) + { + newTime = 0; + } + // + // set movedir + // + movedir = pos - oldpos; + } + +void CameraWatchState::Evaluate + ( + Camera * camera, + CameraMoveState * move + ) + { + assert( camera ); + assert( move ); + // + // evaluate orientation + // + if ( watchEnt ) + { + Vector watchPos; + + + watchPos.x = watchEnt->origin.x; + watchPos.y = watchEnt->origin.y; + watchPos.z = watchEnt->absmax.z; + watchPos -= camera->origin; + watchPos.normalize(); + watchAngles = watchPos.toAngles(); + } + else if ( watchNodes ) + { + watchAngles = move->angles; + } + else if ( watchPath ) + { + float length; + Vector delta; + + delta = move->movedir; + length = delta.length(); + if ( length > 0.05f ) + { + delta *= 1.0f / length; + watchAngles = delta.toAngles(); + } + } + watchAngles[ 0 ] = AngleMod( watchAngles[ 0 ] ); + watchAngles[ 1 ] = AngleMod( watchAngles[ 1 ] ); + watchAngles[ 2 ] = AngleMod( watchAngles[ 2 ] ); + } + +void CameraState::Evaluate + ( + Camera * camera + ) + { + move.Evaluate( camera ); + watch.Evaluate( camera, &move ); + } + + +Event EV_Camera_CameraThink + ( + "camera_think", + EV_DEFAULT, + NULL, + NULL, + "Called each frame to allow the camera to adjust its position.", + EV_NORMAL + ); +Event EV_Camera_StartMoving + ( + "start", + EV_DEFAULT, + NULL, + NULL, + "Start camera moving.", + EV_NORMAL + ); +Event EV_Camera_Pause + ( + "pause", + EV_DEFAULT, + NULL, + NULL, + "Pause the camera.", + EV_NORMAL + ); +Event EV_Camera_Continue + ( + "continue", + EV_DEFAULT, + NULL, + NULL, + "Continue the camera movement.", + EV_NORMAL + ); +Event EV_Camera_StopMoving + ( "stop", + EV_CONSOLE, + NULL, + NULL, + "Stop the camera movement.", + EV_NORMAL + ); +Event EV_Camera_SetSpeed + ( + "speed", + EV_DEFAULT, + "f", + "speed", + "Sets the camera speed.", + EV_NORMAL + ); +Event EV_Camera_SetFOV + ( + "fov", + EV_CONSOLE, + "fF", + "fov fadeTime", + "Sets the camera's field of view (fov).\n" + "if fadeTime is specified, camera will fade over that time\n" + "if fov is less than 3, than an auto_fov will be assumed\n" + "the value of fov will be the ratio used for keeping a watch\n" + "entity in the view at the right scale", + EV_NORMAL + ); + +// +// FOLLOW EVENTS +// +Event EV_Camera_Follow + ( + "follow", + EV_DEFAULT, + "eE", + "targetEnt targetWatchEnt", + "Makes the camera follow an entity and optionally watch an entity.", + EV_NORMAL + ); +Event EV_Camera_SetFollowDistance + ( + "follow_distance", + EV_DEFAULT, + "f", + "distance", + "Sets the camera follow distance.", + EV_NORMAL + ); +Event EV_Camera_SetFollowYaw + ( + "follow_yaw", + EV_DEFAULT, + "f", + "yaw", + "Sets the yaw offset of the camera following an entity.", + EV_NORMAL + ); +Event EV_Camera_AbsoluteYaw + ( + "follow_yaw_absolute", + EV_DEFAULT, + NULL, + NULL, + "Makes the follow camera yaw absolute.", + EV_NORMAL + ); +Event EV_Camera_RelativeYaw + ( + "follow_yaw_relative", + EV_DEFAULT, + NULL, + NULL, + "Makes the follow camera yaw relative (not absolute).", + EV_NORMAL + ); + +// +// ORBIT Events +// +Event EV_Camera_Orbit + ( + "orbit", + EV_DEFAULT, + "eE", + "targetEnt targetWatchEnt", + "Makes the camera orbit around an entity and optionally watch an entity.", + EV_NORMAL + ); +Event EV_Camera_SetOrbitHeight + ( + "orbit_height", + EV_DEFAULT, + "f", + "height", + "Sets the orbit camera's height.", + EV_NORMAL + ); + +// +// Watch Events +// +Event EV_Camera_Watch + ( + "watch", + EV_CONSOLE, + "eF", + "watchEnt fadeTime", + "Makes the camera watch an entity.\n" + "if fadeTime is specified, camera will fade over that time", + EV_NORMAL + ); +Event EV_Camera_WatchPath + ( + "watchpath", + EV_CONSOLE, + "F", + "fadeTime", + "Makes the camera look along the path of travel.\n" + "if fadeTime is specified, camera will fade over that time", + EV_NORMAL + ); +Event EV_Camera_WatchNodes + ( + "watchnode", + EV_CONSOLE, + "F", + "fadeTime", + "Makes the camera watch based on what is stored\n" + "in the camera nodes.\n" + "if fadeTime is specified, camera will fade over that time", + EV_NORMAL + ); +Event EV_Camera_NoWatch + ( + "nowatch", + EV_CONSOLE, + "F", + "fadeTime", + "Stop watching an entity or looking along a path.\n" + "Camera is now static as far as orientation.\n" + "if fadeTime is specified, camera will fade over that time", + EV_NORMAL + ); + +// +// Camera positioning events +// +Event EV_Camera_LookAt + ( + "lookat", + EV_DEFAULT, + "e", + "ent", + "Makes the camera look at an entity.", + EV_NORMAL + ); +Event EV_Camera_TurnTo + ( + "turnto", + EV_DEFAULT, + "v", + "angle", + "Makes the camera look in the specified direction.", + EV_NORMAL + ); +Event EV_Camera_MoveToEntity + ( + "moveto", + EV_DEFAULT, + "e", + "ent", + "Move the camera's position to that of the specified entities.", + EV_NORMAL + ); +Event EV_Camera_MoveToPos + ( + "movetopos", + EV_DEFAULT, + "v", + "position", + "Move the camera's position to the specified position.", + EV_NORMAL + ); + +// +// Camera Transitioning events +// +Event EV_Camera_FadeTime + ( + "fadetime", + EV_DEFAULT, + "f", + "fadetime", + "Sets the fade time for camera transitioning.", + EV_NORMAL + ); +Event EV_Camera_Cut + ( + "cut", + EV_DEFAULT, + NULL, + NULL, + "switch camera states immediately, do not transition", + EV_NORMAL + ); +Event EV_Camera_SetNextCamera + ( + "nextcamera", + EV_DEFAULT, + "s", + "nextCamera", + "Sets the next camera to use.", + EV_NORMAL + ); + +Event EV_Camera_SetAutoState + ( + "auto_state", + EV_DEFAULT, + "sSSSSS", + "state1 state2 state3 state4 state5 state6", + "Sets the states the player needs to be in for this camera to activate.", + EV_NORMAL + ); + +Event EV_Camera_SetAutoRadius + ( + "auto_radius", + EV_DEFAULT, + "f", + "newRadius", + "Sets the radius of the automatic camera.", + EV_NORMAL + ); + +Event EV_Camera_SetAutoActive + ( + "auto_active", + EV_DEFAULT, + "b", + "newActiveState", + "Whether or not the auto camera is active.", + EV_NORMAL + ); + +Event EV_Camera_SetAutoStartTime + ( + "auto_starttime", + EV_DEFAULT, + "f", + "newTime", + "Sets how long it takes for the camera to be switched to.", + EV_NORMAL + ); + +Event EV_Camera_SetAutoStopTime + ( + "auto_stoptime", + EV_DEFAULT, + "f", + "newTime", + "Sets how long it takes for the camera switch back to the player.", + EV_NORMAL + ); + +Event EV_Camera_SetMaximumAutoFOV + ( + "auto_maxfov", + EV_DEFAULT, + "f", + "maxFOV", + "Sets the maximum FOV that should be used when automatically calculating FOV.", + EV_NORMAL + ); + +Event EV_Camera_SetShowQuakes +( + "showquakes", + EV_DEFAULT, + "b", + "showquakes", + "Sets the camera to show or not show earthquake effects from the player triggered either from the earthquake command, or a viewjitter." +); + +// +// general setup functions +// +Event EV_Camera_SetupCamera + ( + "_setupcamera", + EV_DEFAULT, + NULL, + NULL, + "setup the camera, post spawn.", + EV_NORMAL + ); + +/*****************************************************************************/ +/* func_camera (0 0.25 0.5) (-8 -8 0) (8 8 16) ORBIT START_ON AUTOMATIC NO_TRACE NO_WATCH LEVEL_EXIT + +Camera used for cinematic sequences. + +"target" points to the target to orbit or follow. If it points to a path, +the camera will follow the path. +"speed" specifies how fast to move on the path or orbit. (default 1). +"fov" specifies fov of camera, default 90. +if fov is less than 3 than an auto-fov feature is assumed. The fov will then +specify the ratio to be used to keep a watched entity zoomed in and on the screen +"follow_yaw" specifies yaw of the follow camera, default 0. +"follow_distance" the distance to follow or orbit if the target is not a path. (default 128). +"orbit_height" specifies height of camera from origin for orbiting, default 128. +"nextcamera" a link to the next camera in a chain of cameras +"thread" a thread label that will be fired when the camera is looked through +"auto_state" if specified, denotes the state the player must be in for the camera to engage +any number of states can be specified and only the first few letters need be specified as well +a state of 'pipe' would mean that any player state that started with 'pipe' would trigger this +camera +"auto_radius" the radius, in which the camera will automatically turn on (default 512) +"auto_starttime" how long it takes for the camera to be switched to (default 0.2) +"auto_stoptime" how long it takes for the camera to switch back to the player (default 0.2) +"auto_maxfov" Sets the maximum FOV that should be used when automatically calculating FOV. (default 90) + +ORBIT tells the camera to create a circular path around the object it points to. +It the camera points to a path, it will loop when it gets to the end of the path. +START_ON causes the camera to be moving as soon as it is spawned. +AUTOMATIC causes the camera to be switched to automatically when the player is within +a certain radius, if "thread" is specified, that thread will be triggered when the camers is activated +NO_TRACE when the camera is in automatic mode, it will try to trace to the player before +switching automatically, this turns off that feature +NO_WATCH if this is an automatic camera, the camera will automatically watch the player +unless this is set, camera's "score" will be affected by how close to the middle of the camera +the player is. +LEVEL_EXIT if the camera is being used, the level exit state will be set + +******************************************************************************/ + +CLASS_DECLARATION( Entity, Camera, "func_camera" ) + { + { &EV_Camera_CameraThink, &Camera::CameraThink }, + { &EV_Activate, &Camera::StartMoving }, + { &EV_Camera_StartMoving, &Camera::StartMoving }, + { &EV_Camera_StopMoving, &Camera::StopMoving }, + { &EV_Camera_Pause, &Camera::Pause }, + { &EV_Camera_Continue, &Camera::Continue }, + { &EV_Camera_SetSpeed, &Camera::SetSpeed }, + { &EV_Camera_SetFollowDistance, &Camera::SetFollowDistance }, + { &EV_Camera_SetFollowYaw, &Camera::SetFollowYaw }, + { &EV_Camera_AbsoluteYaw, &Camera::AbsoluteYaw }, + { &EV_Camera_RelativeYaw, &Camera::RelativeYaw }, + { &EV_Camera_SetOrbitHeight, &Camera::SetOrbitHeight }, + { &EV_Camera_SetFOV, &Camera::SetFOV }, + { &EV_Camera_Orbit, &Camera::OrbitEvent }, + { &EV_Camera_Follow, &Camera::FollowEvent }, + { &EV_Camera_Watch, &Camera::WatchEvent }, + { &EV_Camera_WatchPath, &Camera::WatchPathEvent }, + { &EV_Camera_WatchNodes, &Camera::WatchNodesEvent }, + { &EV_Camera_NoWatch, &Camera::NoWatchEvent }, + { &EV_Camera_LookAt, &Camera::LookAt }, + { &EV_Camera_TurnTo, &Camera::TurnTo }, + { &EV_Camera_MoveToEntity, &Camera::MoveToEntity }, + { &EV_Camera_MoveToPos, &Camera::MoveToPos }, + { &EV_Camera_Cut, &Camera::Cut }, + { &EV_Camera_FadeTime, &Camera::FadeTime }, + { &EV_Camera_SetNextCamera, &Camera::SetNextCamera }, + { &EV_Camera_SetupCamera, &Camera::SetupCamera }, + { &EV_SetAngles, &Camera::SetAnglesEvent }, + { &EV_Camera_SetAutoState, &Camera::SetAutoStateEvent }, + { &EV_Camera_SetAutoRadius, &Camera::SetAutoRadiusEvent }, + { &EV_Camera_SetAutoStartTime, &Camera::SetAutoStartTimeEvent }, + { &EV_Camera_SetAutoStopTime, &Camera::SetAutoStopTimeEvent }, + { &EV_Camera_SetMaximumAutoFOV, &Camera::SetMaximumAutoFOVEvent }, + { &EV_Camera_SetAutoActive, &Camera::SetAutoActiveEvent }, + { &EV_Camera_SetShowQuakes, &Camera::SetShowQuakes }, + + { NULL, NULL } + }; + +Camera::Camera() +{ + Vector ang; + + entflags |= EF_CAMERA; + + camera_fov = 90; + camera_speed = 1; + orbit_height = 128; + orbit_dotrace = qtrue; + follow_yaw = 0; + follow_yaw_fixed = false; + follow_dist = 128; + follow_mask = MASK_SOLID; + auto_fov = 0; + automatic_maxFOV = 90; + + watchTime = 0; + followTime = 0; + fovTime = 0; + + fadeTime = 2.0f; + + setSolidType( SOLID_NOT ); + setMoveType( MOVETYPE_NONE ); + + showcamera = sv_showcameras->integer; + if( showcamera ) + { + setModel( "func_camera.tik" ); + showModel(); + } + else + { + hideModel(); + } + + automatic_active = qtrue; + automatic_radius = 512; + automatic_states.ClearObjectList(); + automatic_startTime = 0.7f; + automatic_stopTime = 0.7f; + + if( !LoadingSavegame ) + { + PostEvent( EV_Camera_SetupCamera, EV_POSTSPAWN ); + } +} + +void Camera::SetupCamera + ( + Event *ev + ) + + { + currentstate.Initialize( this ); + newstate.Initialize( this ); + + if ( spawnflags & START_ON ) + { + PostEvent( EV_Camera_StartMoving, 0 ); + } + if ( spawnflags & AUTOMATIC ) + { + level.AddAutomaticCamera( this ); + } + } + +qboolean Camera::IsAutomatic + ( + void + ) + { + return ( spawnflags & AUTOMATIC ); + } + +qboolean Camera::IsLevelExit + ( + void + ) + { + return ( spawnflags & LEVEL_EXIT ); + } + +float Camera::CalculateScore + ( + Entity * player, + str state + ) + { + int i; + float range; + float score; + qboolean found; + + if ( !automatic_active ) + { + return 10; + } + + range = Vector( player->origin - origin ).length() / automatic_radius; + // bias the range so that we don't immediately jump out of the camera if we are out of range + range -= 0.1f; + + score = range; + + // + // early exit if our score exceeds 1 + // + if ( score > 1.0f ) + return score; + + // find out if we match a state + found = qfalse; + for( i = 1; i <= automatic_states.NumObjects(); i++ ) + { + str *auto_state; + + auto_state = &automatic_states.ObjectAt( i ); + if ( !state.icmpn( state, auto_state->c_str(), auto_state->length() ) ) + { + found = qtrue; + break; + } + } + + // if we are comparing states and we haven't found a valid one... + if ( automatic_states.NumObjects() && !found ) + { + // if we aren't in the right state, push our score out significantly + score += 2.0f; + return score; + } + + // perform a trace to the player if necessary + if ( !( spawnflags & NO_TRACE ) && !( spawnflags & NO_WATCH ) ) + { + trace_t trace; + + trace = G_Trace( origin, vec_zero, vec_zero, player->centroid, player, follow_mask, false, "Camera::CalculateScore" ); + if ( trace.startsolid || trace.allsolid || trace.fraction < 1.0f ) + { + // if we are blocked, push our score out, but not too much since this may be a temporary thing + if ( trace.startsolid || trace.allsolid ) + { + score += 2.0f; + return score; + } + else + { + score += 1.0f - trace.fraction; + } + } + } + + // perform a dot product test for no watch cameras + if ( spawnflags & NO_WATCH ) + { + trace_t trace; + float limit; + float threshold; + float dot; + Vector dir; + + dir = player->centroid - origin; + dir.normalize(); + dot = dir * orientation[ 0 ]; + + threshold = cos( DEG2RAD( ( camera_fov * 0.25f ) ) ); + if ( dot <= threshold ) + { + limit = cos( DEG2RAD( ( camera_fov * 0.45f ) ) ); + if ( dot <= limit ) + { + // we are outside the viewing cone + score += 2.0f; + return score; + } + else + { + // our score is a scale between the two values + score += ( threshold - dot ) / ( limit ); + } + } + + trace = G_Trace( origin, vec_zero, vec_zero, player->origin, player, follow_mask, false, "Camera::CalculateScore" ); + if ( trace.startsolid || trace.allsolid || trace.fraction < 1.0f ) + { + // if we are blocked, push our score out, but not too much since this may be a temporary thing + if ( trace.startsolid || trace.allsolid ) + { + score += 2.0f; + return score; + } + else + { + score += 1.0f - trace.fraction; + } + } + } + + return score; + } + +float Camera::AutomaticStart + ( + Entity * player + ) +{ + if( !( spawnflags & NO_WATCH ) && player ) + { + Watch( player, 0 ); + Cut( NULL ); + } + + Unregister( STRING_START ); + return automatic_startTime; +} + +float Camera::AutomaticStop + ( + Entity * player + ) + { + Stop(); + return automatic_stopTime; + } + +void Camera::UpdateStates + ( + void + ) + + { + if ( followTime && watchTime ) + { + newstate.Evaluate( this ); + } + else if ( watchTime ) + { + newstate.watch.Evaluate( this, ¤tstate.move ); + } + else if ( followTime ) + { + newstate.move.Evaluate( this ); + } + currentstate.Evaluate( this ); + } + + +Vector Camera::CalculatePosition + ( + void + ) + + { + int i; + float t; + Vector pos; + + // + // calcualte position + // + if ( followTime ) + { + t = followTime - level.time; + // + // are we still fading? + // + if ( t <= 0 ) + { + // + // if not zero out the fade + // + t = 0; + currentstate.move = newstate.move; + newstate.move.Initialize( this ); + followTime = 0; + pos = currentstate.move.pos; + } + else + { + // + // if we are lerp over followFadeTime + // + t = ( followFadeTime - t ) / followFadeTime; + + for ( i = 0; i < 3; i++ ) + { + pos[ i ] = currentstate.move.pos[ i ] + ( t * ( newstate.move.pos[ i ] - currentstate.move.pos[ i ] ) ); + } + } + } + else + { + pos = currentstate.move.pos; + } + + return pos; + } + + +Vector Camera::CalculateOrientation + ( + void + ) + +{ + int i; + float t; + Vector ang; + + // + // calculate orientation + // + if( watchTime ) + { + t = watchTime - level.time; + // + // are we still fading? + // + if( t <= 0 ) + { + // + // if not zero out the fade + // + t = 0; + currentstate.watch = newstate.watch; + newstate.watch.Initialize( this ); + watchTime = 0; + ang = currentstate.watch.watchAngles; + } + else + { + t = ( watchFadeTime - t ) / watchFadeTime; + + for( i = 0; i<3; i++ ) + { + ang[ i ] = LerpAngleFromCurrent + ( + currentstate.watch.watchAngles[ i ], + newstate.watch.watchAngles[ i ], + this->angles[ i ], + t + ); + } + /* + warning("", "%.2f a x%.0f y%.0f z%.0f c x%.0f y%.0f z%.0f n x%.0f y%.0f z%.0f\n", + t, + ang[ 0 ], + ang[ 1 ], + ang[ 2 ], + currentstate.watch.watchAngles[ 0 ], + currentstate.watch.watchAngles[ 1 ], + currentstate.watch.watchAngles[ 2 ], + newstate.watch.watchAngles[ 0 ], + newstate.watch.watchAngles[ 1 ], + newstate.watch.watchAngles[ 2 ] + ); + */ + } + } + else + { + ang = currentstate.watch.watchAngles; + } + + return ang; +} + +float Camera::CalculateFov + ( + void + ) + + { + float fov; + float t; + + // + // calculate fov + // + // check if we have an auto_fov + if ( auto_fov > 0 ) + { + if ( currentstate.watch.watchEnt ) + { + float distance; + float size; + float new_fov; + Entity * ent; + + ent = currentstate.watch.watchEnt; + size = ent->maxs[ 2 ] - ent->mins[ 2 ]; + size = ent->edict->r.radius / 2; + // cap the size + if ( size < 16 ) + size = 16; + distance = Vector( ent->centroid - origin ).length(); + new_fov = RAD2DEG( 2.0f * atan2( size, distance * auto_fov ) ); + if ( new_fov > automatic_maxFOV ) + new_fov = automatic_maxFOV; + else if ( new_fov < 5 ) + new_fov = 5; + return new_fov; + } + else + { + return 90; + } + } + // if we get here, we don't have an auto_fov, or we have an invalid watch target + if ( fovTime ) + { + t = fovTime - level.time; + // + // are we still fading? + // + if ( t <= 0 ) + { + // + // if not zero out the fade + // + t = 0; + currentstate.fov = newstate.fov; + fovTime = 0; + fov = currentstate.fov; + } + else + { + // + // if we are lerp over fovFadeTime + // + t = ( fovFadeTime - t ) / fovFadeTime; + fov = currentstate.fov + ( t * ( newstate.fov - currentstate.fov ) ); + } + } + else + { + fov = currentstate.fov; + } + + return fov; + } + +void Camera::CameraThink + ( + Event *ev + ) + +{ + UpdateStates(); + + if( edict->s.parent == ENTITYNUM_NONE ) + { + setOrigin( CalculatePosition() ); + setAngles( CalculateOrientation() ); + } + else + { + setOrigin(); + + if( edict->s.attach_use_angles ) + { + orientation_t orient; + Vector ang; + Entity *ent = G_GetEntity( edict->s.parent ); + + ent->GetTag( edict->s.tag_num & TAG_MASK, &orient ); + MatrixToEulerAngles( orient.axis, ang ); + + setAngles( ang ); + } + else + { + setAngles( CalculateOrientation() ); + } + } + + camera_fov = CalculateFov(); + + if( m_bShowquakes && level.earthquake_magnitude ) + { + Vector randomness; + + // smooth earthquake + randomness[ 0 ] = G_CRandom( 1.0f ); + randomness[ 1 ] = G_CRandom( 1.0f ); + randomness[ 2 ] = G_CRandom( 1.0f ); + + angles += randomness * level.earthquake_magnitude; + } + + // + // debug info + // + if( sv_showcameras->integer != showcamera ) + { + showcamera = sv_showcameras->integer; + if( showcamera ) + { + showModel(); + } + else + { + hideModel(); + } + } + + if( sv_showcameras->integer != showcamera ) + { + showcamera = sv_showcameras->integer; + if( showcamera ) + { + showModel(); + } + else + { + hideModel(); + } + } + if( showcamera && currentstate.move.followingpath ) + { + G_Color3f( 1, 1, 0 ); + if( currentstate.move.orbitEnt ) + { + currentstate.move.cameraPath.DrawCurve( currentstate.move.orbitEnt->origin, 10 ); + } + else + { + currentstate.move.cameraPath.DrawCurve( 10 ); + } + } + + CancelEventsOfType( EV_Camera_CameraThink ); + PostEvent( EV_Camera_CameraThink, 0.05f ); +} + +void Camera::LookAt + ( + Event *ev + ) + + { + Vector pos, delta; + Entity * ent; + + ent = ev->GetEntity( 1 ); + + if ( !ent ) + return; + + pos.x = ent->origin.x; + pos.y = ent->origin.y; + pos.z = ent->absmax.z; + delta = pos - origin; + delta.normalize(); + + currentstate.watch.watchAngles = delta.toAngles(); + setAngles( currentstate.watch.watchAngles ); + } + +void Camera::TurnTo + ( + Event *ev + ) + + { + currentstate.watch.watchAngles = ev->GetVector( 1 ); + setAngles( currentstate.watch.watchAngles ); + } + +void Camera::MoveToEntity + ( + Event *ev + ) + + { + Entity * ent; + + ent = ev->GetEntity( 1 ); + if ( ent ) + currentstate.move.pos = ent->origin; + setOrigin( currentstate.move.pos ); + } + +void Camera::MoveToPos + ( + Event *ev + ) + + { + currentstate.move.pos = ev->GetVector( 1 ); + setOrigin( currentstate.move.pos ); + } + +void Camera::Stop + ( + void + ) + + { + if ( followTime ) + { + currentstate.move = newstate.move; + newstate.move.Initialize( this ); + } + if ( watchTime ) + { + currentstate.watch = newstate.watch; + newstate.watch.Initialize( this ); + } + CancelEventsOfType( EV_Camera_CameraThink ); + + watchTime = 0; + followTime = 0; + } + +void Camera::CreateOrbit + ( + Vector pos, + float radius, + Vector &forward, + Vector &left + ) + + { + newstate.move.cameraPath.Clear(); + newstate.move.cameraPath.SetType( SPLINE_LOOP ); + + newstate.move.cameraPath.AppendControlPoint( pos + radius * forward ); + newstate.move.cameraPath.AppendControlPoint( pos + radius * left ); + newstate.move.cameraPath.AppendControlPoint( pos - radius * forward ); + newstate.move.cameraPath.AppendControlPoint( pos - radius * left ); + } + +void Camera::CreatePath + ( + SplinePath *path, + splinetype_t type + ) + + { + SplinePath *node; + SplinePath *loop; + + newstate.move.cameraPath.Clear(); + newstate.move.cameraPath.SetType( type ); + + newstate.move.splinePath = path; + newstate.move.currentNode = path; + newstate.move.loopNode = NULL; + + node = path; + while( node != NULL ) + { + newstate.move.cameraPath.AppendControlPoint( node->origin, node->angles, node->speed ); + loop = node->GetLoop(); + if ( loop && ( type == SPLINE_LOOP ) ) + { + newstate.move.loopNode = loop; + newstate.move.cameraPath.SetLoopPoint( loop->origin ); + } + node = node->GetNext(); + + if ( node == path ) + { + break; + } + } + + if ( ( type == SPLINE_LOOP ) && ( !newstate.move.loopNode ) ) + { + newstate.move.loopNode = path; + } + } + +void Camera::FollowPath + ( + SplinePath *path, + qboolean loop, + Entity * watch + ) + + { + // make sure we process any setup events before continuing + ProcessPendingEvents(); + + Stop(); + if ( loop ) + { + CreatePath( path, SPLINE_LOOP ); + } + else + { + CreatePath( path, SPLINE_CLAMP ); + } + + newstate.move.cameraTime = -2; + newstate.move.lastTime = 0; + newstate.move.newTime = 0; + newstate.move.currentNode = path; + // evaluate the first node events + newstate.move.DoNodeEvents( this ); + + if ( watch ) + { + newstate.watch.watchEnt = watch; + } + else + { + Watch( newstate.move.currentNode->GetWatch(), newstate.move.currentNode->GetFadeTime() ); + } + + followFadeTime = fadeTime; + watchFadeTime = fadeTime; + + newstate.move.followingpath = true; + followTime = level.time + followFadeTime; + watchTime = level.time + watchFadeTime; + + PostEvent( EV_Camera_CameraThink, FRAMETIME ); + } + +void Camera::Orbit + ( + Entity *ent, + float dist, + Entity *watch, + float yaw_offset, + qboolean dotrace + ) + + { + Vector ang, forward, left; + + // make sure we process any setup events before continuing + ProcessPendingEvents(); + + Stop(); + + if ( watch ) + { + ang = watch->angles; + ang.y += yaw_offset; + } + else + { + ang = vec_zero; + ang.y += yaw_offset; + } + ang.AngleVectors( &forward, &left, NULL ); + + orbit_dotrace = dotrace; + + CreateOrbit( Vector( 0, 0, orbit_height ), dist, forward, left ); + newstate.move.cameraTime = -2; + newstate.move.lastTime = 0; + newstate.move.newTime = 0; + + newstate.move.orbitEnt = ent; + + followFadeTime = fadeTime; + watchFadeTime = fadeTime; + + newstate.move.followingpath = true; + followTime = level.time + followFadeTime; + watchTime = level.time + watchFadeTime; + newstate.move.currentNode = NULL; + + if ( watch ) + { + newstate.watch.watchEnt = watch; + } + else + { + newstate.watch.watchEnt = ent; + } + + PostEvent( EV_Camera_CameraThink, FRAMETIME ); + } + +void Camera::FollowEntity + ( + Entity *ent, + float dist, + int mask, + Entity *watch + ) + + { + // make sure we process any setup events before continuing + ProcessPendingEvents(); + + assert( ent ); + + Stop(); + + if ( ent ) + { + newstate.move.followEnt = ent; + newstate.move.followingpath = false; + + followFadeTime = fadeTime; + watchFadeTime = fadeTime; + + newstate.move.cameraTime = -2; + newstate.move.lastTime = 0; + newstate.move.newTime = 0; + newstate.move.currentNode = NULL; + + followTime = level.time + followFadeTime; + watchTime = level.time + watchFadeTime; + if ( watch ) + { + newstate.watch.watchEnt = watch; + } + else + { + newstate.watch.watchEnt = ent; + } + follow_dist = dist; + follow_mask = mask; + PostEvent( EV_Camera_CameraThink, 0 ); + } + } + +void Camera::StartMoving + ( + Event *ev + ) + + { + Entity *targetEnt; + Entity *targetWatchEnt; + Entity *ent; + SplinePath *path; + + if ( ev->NumArgs() > 0 ) + { + targetEnt = ev->GetEntity( 1 ); + } + else + { + targetEnt = NULL; + } + + if ( ev->NumArgs() > 1 ) + { + targetWatchEnt = ev->GetEntity( 2 ); + } + else + { + targetWatchEnt = NULL; + } + + if ( ( spawnflags & START_ON ) && ( !Q_stricmp( Target(), "" ) ) ) + { + gi.Error( ERR_DROP, "Camera '%s' with START_ON selected, but no target specified.", TargetName().c_str() ); + } + + if ( !targetEnt ) + { + ent = ( Entity * )G_FindTarget( NULL, Target() ); + if ( !ent ) + { + // + // we took this out just because of too many warnings, oh well + //warning("StartMoving", "Can't find target for camera\n" ); + // + // I put it back in as an error. Fuck em! Yeeeeeha! + // + gi.Error( ERR_DROP, "Can't find target '%s' for camera\n", Target().c_str() ); + return; + } + } + else + { + ent = targetEnt; + } + + if ( ent->isSubclassOf( SplinePath ) ) + { + path = ( SplinePath * )ent; + FollowPath( path, spawnflags & ORBIT, targetWatchEnt ); + } + else + { + if ( spawnflags & ORBIT ) + { + Orbit( ent, follow_dist, targetWatchEnt ); + } + else + { + FollowEntity( ent, follow_dist, follow_mask, targetWatchEnt ); + } + } + } + +void Camera::SetAutoStateEvent + ( + Event *ev + ) + + { + int i; + + for( i = 1; i <= ev->NumArgs(); i++ ) + { + char *buffer; + char com_token[ MAX_QPATH ]; + char com_buffer[MAX_STRING_CHARS]; + + strcpy( com_buffer, ev->GetString( i ) ); + buffer = com_buffer; + // get the rest of the line + while( 1 ) + { + strcpy( com_token, COM_ParseExt( &buffer, qfalse ) ); + if (!com_token[0]) + break; + + automatic_states.AddUniqueObject( str( com_token ) ); + } + } + } + +void Camera::SetMaximumAutoFOVEvent + ( + Event *ev + ) + + { + automatic_maxFOV = ev->GetFloat( 1 ); + } + +void Camera::SetAutoRadiusEvent + ( + Event *ev + ) + + { + automatic_radius = ev->GetFloat( 1 ); + } + +void Camera::SetAutoActiveEvent + ( + Event *ev + ) + + { + automatic_active = ev->GetBoolean( 1 ); + } + +void Camera::SetAutoStartTimeEvent + ( + Event *ev + ) + + { + automatic_startTime = ev->GetFloat( 1 ); + } + +void Camera::SetAutoStopTimeEvent + ( + Event *ev + ) + + { + automatic_stopTime = ev->GetFloat( 1 ); + } + + +void Camera::StopMoving + ( + Event *ev + ) + + { + Stop(); + } + +void Camera::Pause + ( + Event *ev + ) + + { + CancelEventsOfType( EV_Camera_CameraThink ); + } + +void Camera::Continue + ( + Event *ev + ) + + { + CancelEventsOfType( EV_Camera_CameraThink ); + PostEvent( EV_Camera_CameraThink, 0 ); + } + +void Camera::SetAnglesEvent + ( + Event *ev + ) + + { + Vector ang; + + ang = ev->GetVector( 1 ); + setAngles( ang ); + } + +void Camera::SetSpeed + ( + Event *ev + ) + + { + camera_speed = ev->GetFloat( 1 ); + } + +void Camera::SetFollowDistance + ( + Event *ev + ) + + { + follow_dist = ev->GetFloat( 1 ); + } + +void Camera::SetOrbitHeight + ( + float height + ) + + { + orbit_height = height; + } + +void Camera::SetOrbitHeight + ( + Event *ev + ) + + { + orbit_height = ev->GetFloat( 1 ); + } + +void Camera::SetFollowYaw + ( + Event *ev + ) + + { + follow_yaw = ev->GetFloat( 1 ); + } + +void Camera::AbsoluteYaw + ( + Event *ev + ) + + { + follow_yaw_fixed = true; + } + +void Camera::RelativeYaw + ( + Event *ev + ) + + { + follow_yaw_fixed = false; + } + +void Camera::SetNextCamera + ( + Event *ev + ) + + { + nextCamera = ev->GetString( 1 ); + } + +void Camera::Cut + ( + Event *ev + ) + { + int j; + + if ( followTime ) + { + currentstate.move = newstate.move; + newstate.move.Initialize( this ); + followTime = 0; + } + if ( watchTime ) + { + currentstate.watch = newstate.watch; + newstate.watch.Initialize( this ); + watchTime = 0; + } + if ( fovTime ) + { + currentstate.fov = newstate.fov; + newstate.fov = camera_fov; + fovTime = 0; + } + CancelEventsOfType( EV_Camera_CameraThink ); + ProcessEvent( EV_Camera_CameraThink ); + + // + // let any clients know that this camera has just cut + // + for( j = 0; j < game.maxclients; j++ ) + { + gentity_t *other; + Player *client; + + other = &g_entities[ j ]; + if ( other->inuse && other->client ) + { + client = ( Player * )other->entity; + client->CameraCut( this ); + } + } + } + +void Camera::FadeTime + ( + Event *ev + ) + + { + fadeTime = ev->GetFloat( 1 ); + } + +void Camera::OrbitEvent + ( + Event *ev + ) + + { + Entity *ent; + + spawnflags |= ORBIT; + ent = ev->GetEntity( 1 ); + if ( ent ) + { + Event * event; + + event = new Event( EV_Camera_StartMoving ); + event->AddEntity( ent ); + if ( ev->NumArgs() > 1 ) + { + event->AddEntity( ev->GetEntity( 2 ) ); + } + Stop(); + ProcessEvent( event ); + } + } + +void Camera::FollowEvent + ( + Event *ev + ) + + { + Entity *ent; + + spawnflags &= ~ORBIT; + ent = ev->GetEntity( 1 ); + if ( ent ) + { + Event * event; + + event = new Event( EV_Camera_StartMoving ); + event->AddEntity( ent ); + if ( ev->NumArgs() > 1 ) + { + event->AddEntity( ev->GetEntity( 2 ) ); + } + Stop(); + ProcessEvent( event ); + } + } + +void Camera::SetFOV + ( + Event *ev + ) + + { + float time; + + if ( ev->NumArgs() > 1 ) + { + time = ev->GetFloat( 2 ); + } + else + { + time = fadeTime; + } + + SetFOV( ev->GetFloat( 1 ), time ); + } + +void Camera::WatchEvent + ( + Event *ev + ) + + { + float time; + + if ( ev->NumArgs() > 1 ) + { + time = ev->GetFloat( 2 ); + } + else + { + time = fadeTime; + } + + Watch( ev->GetString( 1 ), time ); + } + +Entity * GetWatchEntity + ( + str watch + ) + + { + const char *name; + Entity * ent; + + // + // if empty just return + // + if ( watch == "" ) + { + return NULL; + } + + // + // ignore all the reserved words + // + if ( + ( watch == "path" ) || + ( watch == "none" ) || + ( watch == "node" ) + ) + { + return NULL; + } + + name = watch.c_str(); + + if ( name[ 0 ] == '*' ) + { + if ( !IsNumeric( &name[ 1 ] ) ) + { + gi.DPrintf( "GetWatchEntity :: Expecting a numeric value but found '%s'.", &name[ 1 ] ); + return NULL; + } + else + { + ent = G_GetEntity( atoi( &name[ 1 ] ) ); + if ( !ent ) + { + gi.DPrintf( "GetWatchEntity :: Entity with targetname of '%s' not found", &name[ 1 ] ); + return NULL; + } + } + } + else if ( name[ 0 ] == '$' ) + { + ent = ( Entity * )G_FindTarget( NULL, &name[ 1 ] ); + if ( !ent ) + { + gi.DPrintf( "GetWatchEntity :: Entity with targetname of '%s' not found", &name[ 1 ] ); + return NULL; + } + } + else + { + gi.DPrintf( "GetWatchEntity :: Entity with targetname of '%s' not found", name ); + return NULL; + } + + return ent; + } + +void Camera::Watch + ( + str watch, + float time + ) + + { + // make sure we process any setup events before continuing + ProcessPendingEvents(); + + // + // if empty just return + // + if ( watch == "" ) + return; + + // + // clear out the watch variables + // + watchFadeTime = time; + newstate.watch.watchPath = false; + newstate.watch.watchNodes = false; + newstate.watch.watchEnt = NULL; + watchTime = level.time + watchFadeTime; + // + // really a watchpath command + // + if ( watch == "path" ) + { + newstate.watch.watchPath = true; + } + // + // really a watchnodes command + // + else if ( watch == "node" ) + { + newstate.watch.watchNodes = true; + } + // + // really a watchnodes command + // + else if ( watch == "none" ) + { + // intentionally blank + } + // + // just a normal watch command + // + else + { + Entity * ent = GetWatchEntity( watch ); + newstate.watch.watchEnt = ent; + } + } + +void Camera::Watch + ( + Entity * ent, + float time + ) + + { + // + // clear out the watch variables + // + watchFadeTime = time; + newstate.watch.watchPath = false; + newstate.watch.watchNodes = false; + watchTime = level.time + watchFadeTime; + newstate.watch.watchEnt = ent; + } + + +void Camera::SetFOV + ( + float fov, + float time + ) + + { + // if it is less than 3, then we are setting an auto_fov state + if ( fov < 3 ) + { + auto_fov = fov; + } + else + { + // if we are explicitly setting the fov, turn the auto_fov off + auto_fov = 0; + + fovFadeTime = time; + fovTime = level.time + fovFadeTime; + currentstate.fov = newstate.fov; + newstate.fov = fov; + } + } + +void Camera::WatchPathEvent + ( + Event *ev + ) + + { + if ( ev->NumArgs() > 1 ) + { + watchFadeTime = ev->GetFloat( 2 ); + } + else + { + watchFadeTime = fadeTime; + } + + watchTime = level.time + watchFadeTime; + newstate.watch.watchEnt = NULL; + newstate.watch.watchNodes = false; + newstate.watch.watchPath = true; + } + +void Camera::WatchNodesEvent + ( + Event *ev + ) + + { + if ( ev->NumArgs() > 1 ) + { + watchFadeTime = ev->GetFloat( 2 ); + } + else + { + watchFadeTime = fadeTime; + } + watchTime = level.time + watchFadeTime; + newstate.watch.watchEnt = NULL; + newstate.watch.watchPath = false; + newstate.watch.watchNodes = true; + } + +void Camera::NoWatchEvent + ( + Event *ev + ) + + { + if ( ev->NumArgs() > 1 ) + { + watchFadeTime = ev->GetFloat( 2 ); + } + else + { + watchFadeTime = fadeTime; + } + watchTime = level.time + watchFadeTime; + newstate.watch.watchEnt = NULL; + newstate.watch.watchPath = false; + newstate.watch.watchNodes = false; + } + +void Camera::SetShowQuakes( Event * ev ) +{ + if( ev->NumArgs() > 0 ) + { + m_bShowquakes = ev->GetBoolean( 1 ); + } + else + { + m_bShowquakes = 1; + } +} + +void SetCamera + ( + Entity *ent, + float switchTime + ) + + { + int j; + gentity_t *other; + Camera *cam; + Player *client; + + if ( ent && !ent->isSubclassOf( Camera ) ) + { + return; + } + + cam = ( Camera * )ent; + for( j = 0; j < game.maxclients; j++ ) + { + other = &g_entities[ j ]; + if ( other->inuse && other->client ) + { + client = ( Player * )other->entity; + client->SetCamera( cam, switchTime ); + } + } + } + +str &Camera::NextCamera + ( + void + ) + + { + return nextCamera; + } + +float Camera::Fov + ( + void + ) + + { + return camera_fov; + } + +void Camera::Reset + ( + Vector org, + Vector ang + ) + + { + setOrigin( org ); + setAngles( ang ); + currentstate.Initialize( this ); + newstate.Initialize( this ); + } + +void Camera::bind + ( + Entity *master, + qboolean use_my_angles + ) + + { + Entity::bind( master, use_my_angles ); + + currentstate.move.pos = localorigin; + } + +void Camera::unbind + ( + void + ) + + { + Entity::unbind(); + + currentstate.move.pos = origin; + } + + +/****************************************************************************** + + Camera Manager + +******************************************************************************/ + +Event EV_CameraManager_NewPath + ( + "new", + EV_CONSOLE, + NULL, + NULL, + "Starts a new path.", + EV_NORMAL + ); +Event EV_CameraManager_SetPath + ( + "setpath", + EV_CONSOLE, + "e", + "path", + "Sets the new path.", + EV_NORMAL + ); +Event EV_CameraManager_SetTargetName + ( + "settargetname", + EV_CONSOLE, + "s", + "targetname", + "Set the targetname.", + EV_NORMAL + ); +Event EV_CameraManager_SetTarget + ( + "settarget", + EV_CONSOLE, + "s", + "target", + "Set the trigger target.", + EV_NORMAL + ); +Event EV_CameraManager_AddPoint + ( + "add", + EV_CONSOLE, + NULL, + NULL, + "Add a new point to the camera path where the player is standing.", + EV_NORMAL + ); +Event EV_CameraManager_DeletePoint + ( + "delete", + EV_CONSOLE, + NULL, + NULL, + "Delete the current path node.", + EV_NORMAL + ); +Event EV_CameraManager_MovePlayer + ( + "moveplayer", + EV_CONSOLE, + NULL, + NULL, + "Move the player to the current path node position.", + EV_NORMAL + ); +Event EV_CameraManager_ReplacePoint + ( + "replace", + EV_CONSOLE, + NULL, + NULL, + "Replace the current path node position/angle with the player's.", + EV_NORMAL + ); +Event EV_CameraManager_NextPoint + ( + "next", + EV_CONSOLE, + NULL, + NULL, + "Go to the next path node.", + EV_NORMAL + ); +Event EV_CameraManager_PreviousPoint + ( + "prev", + EV_CONSOLE, + NULL, + NULL, + "Go to the previous path node.", + EV_NORMAL + ); +Event EV_CameraManager_ShowPath + ( + "show", + EV_CONSOLE, + "E", + "path", + "Shows the specified path.", + EV_NORMAL + ); +Event EV_CameraManager_ShowingPath + ( + "_showing_path", + EV_CONSOLE, + NULL, + NULL, + "Internal event for showing the path.", + EV_NORMAL + ); +Event EV_CameraManager_HidePath + ( + "hide", + EV_CONSOLE, + NULL, + NULL, + "Hides the paths.", + EV_NORMAL + ); +Event EV_CameraManager_PlayPath + ( + "play", + EV_CONSOLE, + "E", + "path", + "Play the current path or the specified one once.", + EV_NORMAL + ); +Event EV_CameraManager_LoopPath + ( + "loop", + EV_CONSOLE, + "E", + "path", + "Loop the current path or the specified one.", + EV_NORMAL + ); +Event EV_CameraManager_StopPlayback + ( + "stop", + EV_CONSOLE, + NULL, + NULL, + "Stop the camera playing path.", + EV_NORMAL + ); +Event EV_CameraManager_Watch + ( + "watch", + EV_CONSOLE, + "s", + "watch", + "Set the current path node to watch something.", + EV_NORMAL + ); +Event EV_CameraManager_NoWatch + ( + "nowatch", + EV_CONSOLE, + NULL, + NULL, + "Set the current path node to watch nothing.", + EV_NORMAL + ); +Event EV_CameraManager_Fov + ( + "setfov", + EV_CONSOLE, + "s", + "newFOV", + "Set the fov at the current path node.", + EV_NORMAL + ); +Event EV_CameraManager_FadeTime + ( + "setfadetime", + EV_CONSOLE, + "f", + "newFadeTime", + "Set the fadetime of the current path node.", + EV_NORMAL + ); +Event EV_CameraManager_Speed + ( + "setspeed", + EV_CONSOLE, + "f", + "speed", + "Set the speed of the camera at the current path node.", + EV_NORMAL + ); +Event EV_CameraManager_Save + ( + "save", + EV_CONSOLE, + "s", + "filename", + "Saves the camera path.", + EV_NORMAL + ); +Event EV_CameraManager_Load + ( + "load", + EV_CONSOLE, + "s", + "filename", + "Loads a camera path.", + EV_NORMAL + ); +Event EV_CameraManager_SaveMap + ( + "savemap", + EV_CONSOLE, + "s", + "filename", + "Saves the camera path to a map file.", + EV_NORMAL + ); +Event EV_CameraManager_UpdateInput + ( + "updateinput", + EV_CONSOLE, + NULL, + NULL, + "Updates the current node with user interface values.", + EV_NORMAL + ); + +Event EV_CameraManager_NextPath + ( + "nextpath", + EV_CONSOLE, + NULL, + NULL, + "Go to the next path.", + EV_NORMAL + ); +Event EV_CameraManager_PreviousPath + ( + "prevpath", + EV_CONSOLE, + NULL, + NULL, + "Go to the previous path.", + EV_NORMAL + ); + +Event EV_CameraManager_RenamePath + ( + "renamepath", + EV_CONSOLE, + "s", + "newName", + "Rename the path to the new name.", + EV_NORMAL + ); + +CLASS_DECLARATION( Listener, CameraManager, NULL ) + { + { &EV_CameraManager_NewPath, &CameraManager::NewPath }, + { &EV_CameraManager_SetPath, &CameraManager::SetPath }, + { &EV_CameraManager_SetTargetName, &CameraManager::SetTargetName }, + { &EV_CameraManager_SetTarget, &CameraManager::SetTarget }, + { &EV_CameraManager_SetPath, &CameraManager::SetPath }, + { &EV_CameraManager_AddPoint, &CameraManager::AddPoint }, + { &EV_CameraManager_ReplacePoint, &CameraManager::ReplacePoint }, + { &EV_CameraManager_DeletePoint, &CameraManager::DeletePoint }, + { &EV_CameraManager_MovePlayer, &CameraManager::MovePlayer }, + { &EV_CameraManager_NextPoint, &CameraManager::NextPoint }, + { &EV_CameraManager_PreviousPoint, &CameraManager::PreviousPoint }, + { &EV_CameraManager_ShowPath, &CameraManager::ShowPath }, + { &EV_CameraManager_ShowingPath, &CameraManager::ShowingPath }, + { &EV_CameraManager_HidePath, &CameraManager::HidePath }, + { &EV_CameraManager_PlayPath, &CameraManager::PlayPath }, + { &EV_CameraManager_LoopPath, &CameraManager::LoopPath }, + { &EV_CameraManager_StopPlayback, &CameraManager::StopPlayback }, + { &EV_CameraManager_Watch, &CameraManager::Watch }, + { &EV_CameraManager_NoWatch, &CameraManager::NoWatch }, + { &EV_CameraManager_Fov, &CameraManager::Fov }, + { &EV_CameraManager_FadeTime, &CameraManager::FadeTime }, + { &EV_CameraManager_Speed, &CameraManager::Speed }, + { &EV_CameraManager_Save, &CameraManager::Save }, + { &EV_CameraManager_Load, &CameraManager::Load }, + { &EV_CameraManager_SaveMap, &CameraManager::SaveMap }, + { &EV_CameraManager_UpdateInput, &CameraManager::UpdateEvent }, + { &EV_CameraManager_NextPath, &CameraManager::NextPath }, + { &EV_CameraManager_PreviousPath, &CameraManager::PreviousPath }, + { &EV_CameraManager_RenamePath, &CameraManager::RenamePath }, + { NULL, NULL } + }; + +Player *CameraManager_GetPlayer + ( + void + ) + + { + assert( g_entities[ 0 ].entity && g_entities[ 0 ].entity->isSubclassOf( Player ) ); + if ( !g_entities[ 0 ].entity || !( g_entities[ 0 ].entity->isSubclassOf( Player ) ) ) + { + gi.Printf( "No player found.\n" ); + return NULL; + } + + return ( Player * )g_entities[ 0 ].entity; + } + +CameraManager::CameraManager() + { + pathList.ClearObjectList(); + path = NULL; + current = NULL; + cameraPath_dirty = qtrue; + speed = 1; + watch = 0; + cam = NULL; + } + +void CameraManager::UpdateUI + ( + void + ) + { + int num; + SplinePath *next; + float temp; + + // + // set path name + // + gi.Cvar_Set( "cam_filename", pathName ); + if ( current ) + { + + gi.Cvar_Set( "cam_origin", va( "%.2f %.2f %.2f", current->origin[ 0 ], current->origin[ 1 ], current->origin[ 2 ] ) ); + gi.Cvar_Set( "cam_angles_yaw", va( "%.1f", current->angles[ YAW ] ) ); + gi.Cvar_Set( "cam_angles_pitch", va( "%.1f", current->angles[ PITCH ] ) ); + gi.Cvar_Set( "cam_angles_roll", va( "%.1f", current->angles[ ROLL ] ) ); + gi.Cvar_Set( "cam_thread", current->thread.c_str() ); + gi.Cvar_Set( "cam_target", current->triggertarget.c_str() ); + gi.Cvar_Set( "cam_watch", current->watchEnt.c_str() ); + temp = current->GetFov(); + if ( temp ) + { + gi.Cvar_Set( "cam_fov", va( "%.1f", temp ) ); + } + else + { + gi.Cvar_Set( "cam_fov", "Default" ); + } + temp = current->GetFadeTime(); + if ( temp != -1 ) + { + gi.Cvar_Set( "cam_fadetime", va( "%.2f", temp ) ); + } + else + { + gi.Cvar_Set( "cam_fadetime", "Default" ); + } + gi.Cvar_Set( "cam_speed", va( "%.1f", current->speed ) ); + + // + // set node num + // + num = 0; + next = path; + while ( next && ( next != current ) ) + { + next = next->GetNext(); + num++; + } + gi.Cvar_Set( "cam_nodenum", va( "%d", num ) ); + } + } + +void CameraManager::UpdateEvent + ( + Event *ev + ) + { + Vector tempvec; + cvar_t * cvar; + + if ( !current ) + { + return; + } + + // get origin + cvar = gi.Cvar_Get( "cam_origin", "", 0 ); + sscanf( cvar->string, "%f %f %f", &tempvec[ 0 ], &tempvec[ 1 ], &tempvec[ 2 ] ); + current->setOrigin( tempvec ); + + // get angles yaw + cvar = gi.Cvar_Get( "cam_angles_yaw", "", 0 ); + current->angles[ YAW ] = cvar->value; + + // get angles pitch + cvar = gi.Cvar_Get( "cam_angles_pitch", "", 0 ); + current->angles[ PITCH ] = cvar->value; + + // get angles roll + cvar = gi.Cvar_Get( "cam_angles_roll", "", 0 ); + current->angles[ ROLL ] = cvar->value; + + current->setAngles( current->angles ); + + // get target + cvar = gi.Cvar_Get( "cam_target", "", 0 ); + current->SetTriggerTarget( cvar->string ); + + // get watch + cvar = gi.Cvar_Get( "cam_watch", "", 0 ); + current->SetWatch( cvar->string ); + + // get fov + cvar = gi.Cvar_Get( "cam_fov", "", 0 ); + current->SetFov( cvar->value ); + + // get fadetime + cvar = gi.Cvar_Get( "cam_fadetime", "", 0 ); + current->SetFadeTime( cvar->value ); + + // get speed + cvar = gi.Cvar_Get( "cam_speed", "", 0 ); + current->speed = cvar->value; + } + +void CameraManager::SetPathName + ( + str name + ) + + { + pathName = name; + UpdateUI(); + } + +void CameraManager::NewPath + ( + Event *ev + ) + + { + if ( path ) + { + cameraPath_dirty = qtrue; + path = NULL; + current = NULL; + } + SetPathName( "untitled" ); + ShowPath(); + } + +void CameraManager::RenamePath + ( + Event *ev + ) + + { + str name; + + if ( !ev->NumArgs() ) + { + cvar_t * cvar; + + // + // get the path name from the cvar + // + cvar = gi.Cvar_Get( "cam_filename", "", 0 ); + if ( cvar->string[ 0 ] ) + { + name = cvar->string; + } + else + { + ScriptError( "Usage: cam renamepath [pathname]" ); + return; + } + } + else + { + name = ev->GetString( 1 ); + } + + if ( pathList.ObjectInList( name ) ) + { + // remove the old name + pathList.RemoveObject( name ); + } + SetPathName( name ); + pathList.AddUniqueObject( name ); + } + +void CameraManager::SetPath + ( + str pathName + ) + + { + Entity * ent; + SplinePath *node; + + ent = ( Entity * )G_FindTarget( NULL, pathName ); + + if ( !ent ) + { + warning( "SetPath", "Could not find path named '%s'.", pathName.c_str() ); + return; + } + + if ( !ent->isSubclassOf( SplinePath ) ) + { + warning( "SetPath", "'%s' is not a camera path.", pathName.c_str() ); + return; + } + node = ( SplinePath * )ent; + + SetPathName( pathName ); + cameraPath_dirty = qtrue; + path = node; + current = node; + UpdateUI(); + } + +void CameraManager::SetPath + ( + Event *ev + ) + + { + if ( !ev->NumArgs() ) + { + ScriptError( "Usage: cam setpath [pathname]" ); + return; + } + + SetPath( ev->GetString( 1 ) ); + } + +void CameraManager::SetTargetName + ( + Event *ev + ) + + { + if ( ev->NumArgs() != 1 ) + { + ScriptError( "Usage: cam targetname [name]" ); + return; + } + + if ( !path ) + { + ScriptError( "Camera path not set." ); + return; + } + + path->SetTargetName( ev->GetString( 1 ) ); + UpdateUI(); + } + +void CameraManager::SetTarget + ( + Event *ev + ) + + { + if ( ev->NumArgs() != 1 ) + { + ScriptError( "Usage: cam target [name]" ); + return; + } + + if ( !current ) + { + ScriptError( "Camera path not set." ); + return; + } + + current->SetTriggerTarget( ev->GetString( 1 ) ); + UpdateUI(); + } + +void CameraManager::AddPoint + ( + Event *ev + ) + + { + Player *player; + SplinePath *prev; + SplinePath *next; + Vector ang; + Vector pos; + + player = CameraManager_GetPlayer(); + if ( player ) + { + prev = current; + if ( current ) + { + next = current->GetNext(); + } + else + { + next = NULL; + } + + player->GetPlayerView( &pos, &ang ); + + current = new SplinePath; + current->setOrigin( pos ); + current->setAngles( ang ); + current->speed = speed; + current->SetPrev( prev ); + current->SetNext( next ); + + if ( !path ) + { + path = current; + } + + ShowPath(); + } + cameraPath_dirty = qtrue; + UpdateUI(); + } + +void CameraManager::ReplacePoint + ( + Event *ev + ) + + { + Player *player; + Vector ang; + Vector pos; + + player = CameraManager_GetPlayer(); + if ( current && player ) + { + player->GetPlayerView( &pos, &ang ); + + current->setOrigin( pos ); + current->setAngles( ang ); + current->speed = speed; + } + cameraPath_dirty = qtrue; + UpdateUI(); + } + +void CameraManager::DeletePoint + ( + Event *ev + ) + + { + SplinePath *node; + + if ( current ) + { + node = current->GetNext(); + if ( !node ) + { + node = current->GetPrev(); + } + + if ( ( SplinePath * )path == ( SplinePath * )current ) + { + path = current->GetNext(); + } + + delete current; + current = node; + } + cameraPath_dirty = qtrue; + UpdateUI(); + } + +void CameraManager::MovePlayer + ( + Event *ev + ) + + { + Player *player; + Vector pos; + + player = CameraManager_GetPlayer(); + if ( current && player ) + { + player->GetPlayerView( &pos, NULL ); + + player->setOrigin( current->origin - pos + player->origin ); + player->SetViewAngles( current->angles ); + player->SetFov( current->fov ); + } + } + +void CameraManager::NextPoint + ( + Event *ev + ) + + { + SplinePath *next; + + if ( current ) + { + next = current->GetNext(); + if ( next ) + { + current = next; + } + } + UpdateUI(); + } + +void CameraManager::PreviousPoint + ( + Event *ev + ) + + { + SplinePath *prev; + + if ( current ) + { + prev = current->GetPrev(); + if ( prev ) + { + current = prev; + } + } + UpdateUI(); + } + +void CameraManager::NextPath + ( + Event *ev + ) + + { + int index; + + // + // find current path in container of paths + // + index = pathList.IndexOfObject( pathName ); + if ( index < pathList.NumObjects() ) + index++; + + if ( index > 0 ) + { + SetPath( pathList.ObjectAt( index ) ); + UpdateUI(); + } + } + +void CameraManager::PreviousPath + ( + Event *ev + ) + + { + int index; + + // + // find current path in container of paths + // + index = pathList.IndexOfObject( pathName ); + if ( index > 1 ) + index--; + + if ( index > 0 ) + { + SetPath( pathList.ObjectAt( index ) ); + UpdateUI(); + } + } + +void CameraManager::ShowingPath + ( + Event *ev + ) + + { + int count; + SplinePath *node; + SplinePath *prev; + Vector mins( -8, -8, -8 ); + Vector maxs( 8, 8, 8 ); + + prev = NULL; + for( node = path; node != NULL; node = node->GetNext() ) + { + if ( prev ) + { + G_LineStipple( 4, ( unsigned short )( 0xF0F0F0F0 >> ( 7 - ( level.framenum & 7 ) ) ) ); + G_DebugLine( prev->origin, node->origin, 0.4f, 0.4f, 0.4f, 0.1f ); + G_LineStipple( 1, 0xffff ); + } + + if ( current == node ) + { + G_DrawDebugNumber( node->origin + Vector( 0, 0, 20 ), node->speed, 0.5, 0, 1, 0, 1 ); + if ( current->GetFov() ) + G_DrawDebugNumber( node->origin + Vector( 0, 0, 30 ), node->GetFov(), 0.5, 0, 0, 1, 0 ); + G_DebugBBox( node->origin, mins, maxs, 1, 1, 0, 1 ); + } + else + { + G_DebugBBox( node->origin, mins, maxs, 1, 0, 0, 1 ); + } + + // + // draw watch + // + if ( node->doWatch ) + { + Entity *watchEnt; + Vector ang; + Vector delta; + Vector left; + Vector up; + Vector endpoint; + + watchEnt = GetWatchEntity( node->GetWatch() ); + if ( watchEnt ) + { + delta.x = watchEnt->origin.x; + delta.y = watchEnt->origin.y; + delta.z = watchEnt->absmax.z; + delta -= node->origin; + delta.normalize(); + ang = delta.toAngles(); + ang.AngleVectors( NULL, &left, &up ); + + G_LineWidth( 1 ); + endpoint = node->origin + delta * 48; + G_DebugLine( node->origin, endpoint, 0.5, 1, 1, 1 ); + G_DebugLine( endpoint, endpoint + (left * 8) - (delta * 8), 0.5, 1, 1, 1 ); + G_DebugLine( endpoint, endpoint - (left * 8) - (delta * 8), 0.5, 1, 1, 1 ); + G_DebugLine( endpoint, endpoint - (up * 8) - (delta * 8), 0.5, 1, 1, 1 ); + G_DebugLine( endpoint, endpoint + (up * 8) - (delta * 8), 0.5, 1, 1, 1 ); + } + } + + G_LineWidth( 3 ); + G_DebugLine( node->origin, node->origin + Vector( node->orientation[ 0 ] ) * 16, 1, 0, 0, 1 ); + G_DebugLine( node->origin, node->origin + Vector( node->orientation[ 1 ] ) * 16, 0, 1, 0, 1 ); + G_DebugLine( node->origin, node->origin + Vector( node->orientation[ 2 ] ) * 16, 0, 0, 1, 1 ); + G_LineWidth( 1 ); + + prev = node; + } + + if ( cameraPath_dirty ) + { + cameraPath_dirty = qfalse; + cameraPath.Clear(); + cameraPath.SetType( SPLINE_CLAMP ); + + node = path; + while( node != NULL ) + { + cameraPath.AppendControlPoint( node->origin, node->angles, node->speed ); + node = node->GetNext(); + + if ( node == path ) + { + break; + } + } + } + + // draw the curve itself + G_Color3f( 1, 1, 0 ); + cameraPath.DrawCurve( 10 ); + + // draw all the nodes + for( node = path, count = -1; node != NULL; node = node->GetNext(), count++ ) + { + Vector dir, angles; + + dir = cameraPath.Eval( ( float )count - 0.9f ) - cameraPath.Eval( count - 1 ); + angles = dir.toAngles(); + if ( node->doWatch || node->GetFov() || ( node->thread != "" ) || ( node->triggertarget != "" ) ) + { + G_DebugOrientedCircle( cameraPath.Eval( count - 1 ), 5, 0, 1, 1, 1, angles ); + } + else + { + G_DebugOrientedCircle( cameraPath.Eval( count - 1 ), 2, 0, 0, 1, 0.2f, angles ); + } + // if we are the first node, we need to skip the count so that we properly go to the next node + if ( count == -1 ) + { + count = 0; + } + } + + + PostEvent( EV_CameraManager_ShowingPath, FRAMETIME ); + } + +void CameraManager::ShowPath + ( + void + ) + + { + CancelEventsOfType( EV_CameraManager_ShowingPath ); + PostEvent( EV_CameraManager_ShowingPath, FRAMETIME ); + UpdateUI(); + } + +void CameraManager::ShowPath + ( + Event *ev + ) + + { + if ( ev->NumArgs() ) + { + SetPath( ev->GetString( 1 ) ); + } + ShowPath(); + } + +void CameraManager::HidePath + ( + Event *ev + ) + + { + CancelEventsOfType( EV_CameraManager_ShowingPath ); + UpdateUI(); + } + +void CameraManager::StopPlayback + ( + Event *ev + ) + + { + if ( cam ) + { + cam->Stop(); + SetCamera( NULL, 0 ); + } + } + +void CameraManager::PlayPath + ( + Event *ev + ) + + { + if ( cam ) + { + SetCamera( NULL, 0 ); + } + + if ( ev->NumArgs() ) + { + SetPath( ev->GetString( 1 ) ); + } + + if ( path ) + { + if ( !cam ) + { + cam = new Camera; + cam->SetTargetName( "_loadedcamera" ); + cam->ProcessPendingEvents(); + } + + cam->Reset( path->origin, path->angles ); + cam->FollowPath( path, false, NULL ); + cam->Cut( NULL ); + SetCamera( cam, 0 ); + } + } + +void CameraManager::LoopPath + ( + Event *ev + ) + + { + if ( cam ) + { + SetCamera( NULL, 0 ); + } + + if ( ev->NumArgs() ) + { + SetPath( ev->GetString( 1 ) ); + } + + if ( path ) + { + if ( !cam ) + { + cam = new Camera; + cam->SetTargetName( "_loadedcamera" ); + cam->ProcessPendingEvents(); + } + + cam->Reset( path->origin, path->angles ); + cam->FollowPath( path, true, NULL ); + cam->Cut( NULL ); + SetCamera( cam, 0 ); + } + } + +void CameraManager::Watch + ( + Event *ev + ) + + { + if ( current ) + { + current->SetWatch( ev->GetString( 1 ) ); + } + UpdateUI(); + } + +void CameraManager::NoWatch + ( + Event *ev + ) + + { + if ( current ) + { + current->NoWatch(); + } + UpdateUI(); + } + +void CameraManager::Fov + ( + Event *ev + ) + + { + if ( current ) + { + current->SetFov( ev->GetFloat( 1 ) ); + } + UpdateUI(); + } + +void CameraManager::FadeTime + ( + Event *ev + ) + + { + if ( current ) + { + current->SetFadeTime( ev->GetFloat( 1 ) ); + } + UpdateUI(); + } + + +void CameraManager::Speed + ( + Event *ev + ) + + { + speed = ev->GetFloat( 1 ); + if ( current ) + { + current->speed = speed; + } + cameraPath_dirty = qtrue; + UpdateUI(); + } + +void CameraManager::SavePath + ( + str pathName + ) + { + SplinePath *node; + str buf; + str filename; + int num; + int index; + + num = 0; + for( node = path; node != NULL; node = node->GetNext() ) + { + num++; + } + + if ( num == 0 ) + { + warning( "CameraManager::SavePath", "Can't save. No points in path." ); + return; + } + + filename = "cams/"; + filename += pathName; + filename += ".cam"; + + path->SetTargetName( pathName ); + + gi.Printf( "Saving camera path to '%s'...\n", filename.c_str() ); + + buf = ""; + buf += va( "//\n" ); + buf += va( "// Camera Path \"%s\", %d Nodes.\n", pathName.c_str(), num ); + buf += va( "//\n" ); + + index = 0; + for( node = path; node != NULL; node = node->GetNext() ) + { + // + // start off the spawn command + // + buf += "spawn SplinePath"; + // + // set the targetname + // + if ( !index ) + { + buf += va( " targetname %s", pathName.c_str() ); + } + else + { + buf += va( " targetname camnode_%s_%d", pathName.c_str(), index ); + } + // + // set the target + // + if ( index < ( num - 1 ) ) + { + buf += va( " target camnode_%s_%d", pathName.c_str(), index + 1 ); + } + // + // set the trigger target + // + if ( node->triggertarget != "" ) + { + buf += va( " triggertarget %s", node->triggertarget.c_str() ); + } + // + // set the thread + // + if ( node->thread != "" ) + { + buf += va( " thread %s", node->thread.c_str() ); + } + // + // set the origin + // + buf += va( " origin \"%.2f %.2f %.2f\"", node->origin.x, node->origin.y, node->origin.z ); + // + // set the angles + // + buf += va( " angles \"%.1f %.1f %.1f\"", AngleMod( node->angles.x ), AngleMod( node->angles.y ), AngleMod( node->angles.z ) ); + // + // set the speed + // + buf += va( " speed %.1f", node->speed ); + // + // set the watch + // + if ( node->doWatch && node->watchEnt != "" ) + { + buf += va( " watch %s", node->watchEnt.c_str() ); + } + // + // set the fov + // + if ( node->GetFov() ) + { + buf += va( " fov %.1f", node->GetFov() ); + } + // + // set the fadetime + // + if ( node->GetFadeTime() ) + { + buf += va( " fadetime %.1f", node->GetFadeTime() ); + } + + buf += "\n"; + index++; + } + buf += "end\n"; + + gi.FS_WriteFile( filename.c_str(), ( void *)buf.c_str(), buf.length() + 1 ); + gi.Printf( "done.\n" ); + } + +void CameraManager::Save + ( + Event *ev + ) + + { + str filename; + str name; + + if ( ev->NumArgs() != 1 ) + { + cvar_t * cvar; + + // + // get the path name from the cvar + // + cvar = gi.Cvar_Get( "cam_filename", "", 0 ); + if ( cvar->string[ 0 ] ) + { + name = cvar->string; + } + else + { + ScriptError( "Usage: cam save [filename]" ); + return; + } + } + else + { + name = ev->GetString( 1 ); + } + SavePath( name ); + pathList.AddUniqueObject( name ); + } + +void CameraManager::Load + ( + Event *ev + ) + + { + qboolean show; + str filename; + str name; + + if ( ev->NumArgs() != 1 ) + { + cvar_t * cvar; + + // + // get the path name from the cvar + // + cvar = gi.Cvar_Get( "cam_filename", "", 0 ); + if ( cvar->string[ 0 ] ) + { + show = true; + name = cvar->string; + } + else + { + ScriptError( "Usage: cam load [filename]" ); + return; + } + } + else + { + show = false; + name = ev->GetString( 1 ); + } + + if ( pathList.ObjectInList( name ) && show ) + { + gi.Printf( "Camera path '%s' already loaded...\n", name.c_str() ); + return; + } + + filename = "cams/"; + filename += name; + filename += ".cam"; + + gi.Printf( "Loading camera path from '%s'...", filename.c_str() ); + } + + +void CameraManager::SaveMap + ( + Event *ev + ) + + { + SplinePath *node; + str buf; + str filename; + int num; + int index; + + if ( ev->NumArgs() != 1 ) + { + ScriptError( "Usage: cam savemap [filename]" ); + return; + } + + num = 0; + for( node = path; node != NULL; node = node->GetNext() ) + { + num++; + } + + if ( num == 0 ) + { + ScriptError( "Can't save. No points in path." ); + return; + } + + filename = "cams/"; + filename += ev->GetString( 1 ); + filename += ".map"; + + if ( !path->targetname.length() ) + { + path->SetTargetName( ev->GetString( 1 ) ); + gi.Printf( "Targetname set to '%s'\n", path->targetname.c_str() ); + } + + gi.Printf( "Saving camera path to map '%s'...\n", filename.c_str() ); + + buf = ""; + index = 0; + for( node = path; node != NULL; node = node->GetNext() ) + { + buf += va( "// pathnode %d\n", index ); + buf += "{\n"; + buf += va( "\"classname\" \"info_splinepath\"\n" ); + if ( index < ( num - 1 ) ) + { + buf += va( "\"target\" \"camnode_%s_%d\"\n", ev->GetString( 1 ).c_str(), index + 1 ); + } + if ( !index ) + { + buf += va( "\"targetname\" \"%s\"\n", ev->GetString( 1 ).c_str() ); + } + else + { + buf += va( "\"targetname\" \"camnode_%s_%d\"\n", ev->GetString( 1 ).c_str(), index ); + } + if ( node->triggertarget != "" ) + { + buf += va( "\"triggertarget\" \"%s\"\n", node->triggertarget.c_str() ); + } + if ( node->thread != "" ) + { + buf += va( "\"thread\" \"%s\"\n", node->thread.c_str() ); + } + buf += va( "\"origin\" \"%d %d %d\"\n", ( int )node->origin.x, ( int )node->origin.y, ( int )node->origin.z ); + buf += va( "\"angles\" \"%d %d %d\"\n", ( int )AngleMod( node->angles.x ), ( int )AngleMod( node->angles.y ), ( int )AngleMod( node->angles.z ) ); + buf += va( "\"speed\" \"%.3f\"\n", node->speed ); + buf += "}\n"; + index++; + } + + gi.FS_WriteFile( filename.c_str(), ( void * )buf.c_str(), buf.length() + 1 ); + gi.Printf( "done.\n" ); + } + diff --git a/code/game/camera.h b/code/game/camera.h new file mode 100644 index 00000000..0716c862 --- /dev/null +++ b/code/game/camera.h @@ -0,0 +1,473 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// camera.h: Camera. Duh. +// + +#ifndef __CAMERA_H__ +#define __CAMERA_H__ + +#include "g_local.h" +#include "entity.h" +#include "bspline.h" +#include "container.h" + +#define CAMERA_SWITCHTIME 0.5f + +#define ORBIT ( 1 << 0 ) +#define START_ON ( 1 << 1 ) +#define AUTOMATIC ( 1 << 2 ) +#define NO_TRACE ( 1 << 3 ) +#define NO_WATCH ( 1 << 4 ) +#define LEVEL_EXIT ( 1 << 5 ) + + +extern Event EV_Camera_CameraThink; +extern Event EV_Camera_StartMoving; +extern Event EV_Camera_Pause; +extern Event EV_Camera_Continue; +extern Event EV_Camera_StopMoving; +extern Event EV_Camera_SetSpeed; +extern Event EV_Camera_SetFollowDistance; +extern Event EV_Camera_SetOrbitHeight; +extern Event EV_Camera_SetYaw; +extern Event EV_Camera_AbsoluteYaw; +extern Event EV_Camera_RelativeYaw; +extern Event EV_Camera_SetFOV; +extern Event EV_Camera_Orbit; +extern Event EV_Camera_Follow; +extern Event EV_Camera_Watch; +extern Event EV_Camera_WatchPath; +extern Event EV_Camera_LookAt; +extern Event EV_Camera_TurnTo; +extern Event EV_Camera_MoveToEntity; +extern Event EV_Camera_MoveToPos; +extern Event EV_Camera_NoWatch; +extern Event EV_Camera_FadeTime; +extern Event EV_Camera_Cut; + +class Camera; + +class CameraMoveState : public Class + { + public: + Vector pos; + Vector movedir; // direction of travel + Vector angles; // angles from spline camera + + BSpline cameraPath; + SplinePathPtr splinePath; + SplinePathPtr currentNode; + SplinePathPtr loopNode; + + float cameraTime; + int lastTime; + int newTime; + + qboolean followingpath; + EntityPtr followEnt; + EntityPtr orbitEnt; + + void operator=( CameraMoveState &newstate ); + void Evaluate( Camera * camera ); + void Initialize( Camera * camera ); + void DoNodeEvents( Camera * camera ); + virtual void Archive( Archiver &arc ); + }; + +inline void CameraMoveState::operator= + ( + CameraMoveState &newstate + ) + + { + movedir = newstate.movedir; + pos = newstate.pos; + angles = newstate.angles; + + cameraPath = newstate.cameraPath; + splinePath = newstate.splinePath; + currentNode = newstate.currentNode; + loopNode = newstate.loopNode; + + cameraTime = newstate.cameraTime; + lastTime = newstate.lastTime; + newTime = newstate.newTime; + + followEnt = newstate.followEnt; + orbitEnt = newstate.orbitEnt; + + followingpath = newstate.followingpath; + } + +inline void CameraMoveState::Archive + ( + Archiver &arc + ) + { + arc.ArchiveVector( &movedir ); + arc.ArchiveVector( &pos ); + arc.ArchiveVector( &angles ); + + cameraPath.Archive( arc ); + + arc.ArchiveSafePointer( &splinePath ); + arc.ArchiveSafePointer( ¤tNode ); + arc.ArchiveSafePointer( &loopNode ); + + arc.ArchiveFloat( &cameraTime ); + arc.ArchiveInteger( &lastTime ); + arc.ArchiveInteger( &newTime ); + + arc.ArchiveSafePointer( &followEnt ); + arc.ArchiveSafePointer( &orbitEnt ); + + arc.ArchiveBoolean( &followingpath ); + } + +class CameraWatchState : public Class + { + public: + Vector watchAngles; + + EntityPtr watchEnt; + qboolean watchNodes; + qboolean watchPath; + + void Evaluate( Camera * camera, CameraMoveState * move ); + void Initialize( Camera * camera ); + virtual void Archive( Archiver &arc ); + }; + +inline void CameraWatchState::Archive + ( + Archiver &arc + ) + { + arc.ArchiveVector( &watchAngles ); + arc.ArchiveSafePointer( &watchEnt ); + arc.ArchiveBoolean( &watchNodes ); + arc.ArchiveBoolean( &watchPath ); + } + +class CameraState : public Class + { + public: + CameraMoveState move; + CameraWatchState watch; + float fov; + + void Evaluate( Camera * camera ); + void Initialize( Camera * camera ); + virtual void Archive( Archiver &arc ); + }; + +inline void CameraState::Archive + ( + Archiver &arc + ) + { + move.Archive( arc ); + watch.Archive( arc ); + arc.ArchiveFloat( &fov ); + } + +class Camera : public Entity + { + private: + friend class CameraState; + friend class CameraWatchState; + friend class CameraMoveState; + // + // follow parameters + // + float follow_yaw; + qboolean follow_yaw_fixed; + float follow_dist; + int follow_mask; + + // camera speed + float camera_speed; + // current camera fov + float camera_fov; + // orbit height + float orbit_height; + // orbit_dotrace + qboolean orbit_dotrace; + // whether or not auto calculate fov, a non-zero value means yes + float auto_fov; + + // automatic variables + float automatic_startTime; + float automatic_stopTime; + float automatic_radius; + float automatic_maxFOV; + qboolean automatic_active; + Container automatic_states; + + // Miscellaneous + Vector m_vPosOffset; + bool m_bShowquakes; + + protected: + CameraState currentstate; + CameraState newstate; + + float watchTime; // if non-zero, camera view is transitioning + float followTime; // if non-zero, camera position is tranisitioning + float fovTime; // if non-zero, fov is being lerped + + float fadeTime; // time to transition over + float fovFadeTime; // time for fov transition + float followFadeTime; // time for fov transition + float watchFadeTime; // time for fov transition + + str nextCamera; + + qboolean showcamera; + + void SetupCamera( Event *ev ); + void CameraThink( Event *ev ); + void CreateOrbit( Vector pos, float radius, Vector &forward, Vector &left ); + void CreatePath( SplinePath *path, splinetype_t type ); + void UpdateStates( void ); + Vector CalculatePosition( void ); + Vector CalculateOrientation( void ); + float CalculateFov( void ); + virtual void bind( Entity *master, qboolean use_my_angles = false ); + virtual void unbind( void ); + + public: + CLASS_PROTOTYPE( Camera ); + + Camera(); + void Stop( void ); + void FollowPath( SplinePath *path, qboolean loop, Entity *watch ); + void Orbit( Entity *ent, float dist, Entity *watch, float yaw_offset = 0, qboolean dotrace = qtrue ); + void FollowEntity( Entity *ent, float dist, int mask, Entity *watch = NULL ); + void Watch( str watch, float time ); + void Watch( Entity *ent, float time ); + void SetFOV( float fov, float time ); + + void StartMoving( Event *ev ); + void StopMoving( Event *ev ); + void Pause( Event *ev ); + void Continue( Event *ev ); + void SetAnglesEvent( Event *ev ); + void SetSpeed( Event *ev ); + void SetFollowDistance( Event *ev ); + void SetOrbitHeight( float height ); + void SetOrbitHeight( Event *ev ); + void SetFollowYaw( Event *ev ); + void AbsoluteYaw( Event *ev ); + void RelativeYaw( Event *ev ); + void SetFOV( Event *ev ); + void OrbitEvent( Event *ev ); + void FollowEvent( Event *ev ); + void WatchEvent( Event *ev ); + void WatchPathEvent( Event *ev ); + void WatchNodesEvent( Event *ev ); + void NoWatchEvent( Event *ev ); + void LookAt( Event *ev ); + void MoveToEntity( Event *ev ); + void MoveToPos( Event *ev ); + void Cut( Event *ev ); + void FadeTime( Event *ev ); + void TurnTo( Event *ev ); + void SetNextCamera( Event *ev ); + float CalculateScore( Entity * player, str state ); + float AutomaticStart( Entity * player ); + float AutomaticStop( Entity * player ); + qboolean IsAutomatic( void ); + qboolean IsLevelExit( void ); + void SetAutoStateEvent( Event * ev ); + void SetAutoRadiusEvent( Event * ev ); + void SetAutoStartTimeEvent( Event * ev ); + void SetAutoStopTimeEvent( Event * ev ); + void SetMaximumAutoFOVEvent( Event * ev ); + void SetAutoActiveEvent( Event * ev ); + void SetShowQuakes( Event * ev ); + + str& NextCamera( void ); + float Fov( void ); + + void Reset( Vector org, Vector ang ); + + Vector GetPositionOffset( void ); + void SetPositionOffset( Vector vNewOfs ); + + virtual void Archive( Archiver &arc ); + }; + +inline Vector Camera::GetPositionOffset + ( + void + ) +{ + return m_vPosOffset; +} + +inline void Camera::SetPositionOffset + ( + Vector vNewOfs + ) +{ + m_vPosOffset = vNewOfs; +} + +inline void Camera::Archive + ( + Archiver &arc + ) + { + Entity::Archive( arc ); + + arc.ArchiveFloat( &follow_yaw ); + arc.ArchiveBoolean( &follow_yaw_fixed ); + arc.ArchiveFloat( &follow_dist ); + arc.ArchiveInteger( &follow_mask ); + + arc.ArchiveFloat( &camera_speed ); + arc.ArchiveFloat( &camera_fov ); + arc.ArchiveFloat( &orbit_height ); + arc.ArchiveBoolean( &orbit_dotrace ); + arc.ArchiveFloat( &auto_fov ); + + arc.ArchiveFloat( &automatic_startTime ); + arc.ArchiveFloat( &automatic_stopTime ); + arc.ArchiveFloat( &automatic_radius ); + arc.ArchiveFloat( &automatic_maxFOV ); + arc.ArchiveBoolean( &automatic_active ); + + automatic_states.Archive( arc ); + + // currentstate + currentstate.Archive( arc ); + // newstate + newstate.Archive( arc ); + + arc.ArchiveFloat( &watchTime ); + arc.ArchiveFloat( &followTime ); + arc.ArchiveFloat( &fovTime ); + arc.ArchiveFloat( &fadeTime ); + arc.ArchiveFloat( &fovFadeTime ); + arc.ArchiveFloat( &followFadeTime ); + arc.ArchiveFloat( &watchFadeTime ); + + arc.ArchiveString( &nextCamera ); + + arc.ArchiveBoolean( &showcamera ); + + if ( arc.Loading() ) + { + if ( spawnflags & AUTOMATIC ) + { + level.AddAutomaticCamera( this ); + } + } + } + +void SetCamera( Entity *ent, float switchTime ); +Entity * GetWatchEntity( str watch ); + +typedef SafePtr CameraPtr; + +class CameraManager : public Listener + { + protected: + Container pathList; + BSpline cameraPath; + SplinePathPtr path; + SplinePathPtr current; + float speed; + int watch; + str pathName; + CameraPtr cam; + qboolean cameraPath_dirty; + + void NewPath( Event *ev ); + void SetPath( Event *ev ); + void SetTargetName( Event *ev ); + void SetTarget( Event *ev ); + void AddPoint( Event *ev ); + void ReplacePoint( Event *ev ); + void DeletePoint( Event *ev ); + void MovePlayer( Event *ev ); + void NextPoint( Event *ev ); + void PreviousPoint( Event *ev ); + void ShowingPath( Event *ev ); + void ShowPath( Event *ev ); + void HidePath( Event *ev ); + void StopPlayback( Event *ev ); + void PlayPath( Event *ev ); + void LoopPath( Event *ev ); + void Watch( Event *ev ); + void NoWatch( Event *ev ); + void Fov( Event *ev ); + void FadeTime( Event *ev ); + void Speed( Event *ev ); + void Save( Event *ev ); + void Load( Event *ev ); + void SaveMap( Event *ev ); + void UpdateEvent( Event *ev ); + void NextPath( Event *ev ); + void PreviousPath( Event *ev ); + void RenamePath( Event *ev ); + + void ShowPath( void ); + void UpdateUI( void ); + void SetPathName( str name ); + void SavePath( str pathName ); + + public: + CLASS_PROTOTYPE( CameraManager ); + + CameraManager(); + void SetPath( str pathName ); + virtual void Archive( Archiver &arc ); + }; + +inline void CameraManager::Archive + ( + Archiver &arc + ) + + { + Listener::Archive( arc ); + + pathList.Archive( arc ); + + // no need to archive the cameraPath + arc.ArchiveSafePointer( &path ); + arc.ArchiveSafePointer( ¤t ); + arc.ArchiveFloat( &speed ); + arc.ArchiveInteger( &watch ); + arc.ArchiveString( &pathName ); + arc.ArchiveSafePointer( &cam ); + + // make sure the cameraPath gets rebuilt + cameraPath_dirty = qtrue; + } + +extern CameraManager CameraMan; + +#endif /* camera.h */ diff --git a/code/game/characterstate.cpp b/code/game/characterstate.cpp new file mode 100644 index 00000000..d37d7b8f --- /dev/null +++ b/code/game/characterstate.cpp @@ -0,0 +1,1205 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// characterstate.cpp: +// + +#include "characterstate.h" +#include "animate.h" +#include "scriptmaster.h" + +static const char *MoveControl_Names[] = +{ + "none", // MOVECONTROL_NONE + "user", // MOVECONTROL_USER + "legs", // MOVECONTROL_LEGS + "user_moveanim", // MOVECONTROL_USER_MOVEANIM + "anim", // MOVECONTROL_ANIM + "absolute", // MOVECONTROL_ABSOLUTE + "hanging", // MOVECONTROL_HANGING + "rope_grab", // MOVECONTROL_ROPE_GRAB + "rope_release", // MOVECONTROL_ROPE_RELEASE + "rope_move", // MOVECONTROL_ROPE_MOVE + "pickupenemy", // MOVECONTROL_PICKUPENEMY + "push", // MOVECONTROL_PUSH + "climbwall", // MOVECONTROL_CLIMBWALL + "useanim", // MOVECONTROL_USEANIM + "crouch", // MOVECONTROL_CROUCH + "loopuseanim", // MOVECONTROL_LOOPUSEANIM + "useobject", // MOVECONTROL_USEOBJECT + "coolobject", // MOVECONTROL_COOLOBJECT + NULL +}; + +static const char *Camera_Names[] = + { + "topdown", // CAMERA_TOPDOWN + "behind", // CAMERA_BEHIND + "front", // CAMERA_FRONT + "side", // CAMERA_SIDE + "behind_fixed", // CAMERA_BEHIND_FIXED + "side_left", // CAMERA_SIDE_LEFT + "side_right", // CAMERA_SIDE_RIGHT + "behind_nopitch", // CAMERA_BEHIND_NOPITCH + NULL + }; + +Conditional::Conditional + ( + Condition &cond + ) : condition( cond ) + + { + result = false; + previous_result = false; + checked = false; + } + +Conditional::Conditional() +{ + result = false; + previous_result = false; + checked = false; +} + +Expression::Expression() + { + } + +Expression::Expression + ( + Expression &exp + ) + + { + int i; + + value = exp.value; + + for( i = 1; i <= exp.conditions.NumObjects(); i++ ) + { + conditions.AddObject( exp.conditions.ObjectAt( i ) ); + } + } + +Expression::Expression + ( + Script &script, + State &state + ) + + { + str token; + condition_t condition; + int start; + + value = script.GetToken( true ); + + if ( !script.TokenAvailable( false ) || Q_stricmp( script.GetToken( false ), ":" ) ) + { + gi.Error( ERR_DROP, "%s: Expecting ':' on line %d.\n", script.Filename(), script.GetLineNumber() ); + } + + while( script.TokenAvailable( false ) ) + { + token = script.GetToken( true ); + + switch( token[ 0 ] ) + { + case '!' : + condition.test = TC_ISFALSE; + start = 1; + break; + + case '+' : + condition.test = TC_EDGETRUE; + start = 1; + break; + + case '-' : + condition.test = TC_EDGEFALSE; + start = 1; + break; + + default : + condition.test = TC_ISTRUE; + start = 0; + } + + if ( token.length() <= start ) + { + gi.Error( ERR_DROP, "%s: Illegal syntax '%s' on line %d.\n", script.Filename(), &token, script.GetLineNumber() ); + condition.condition_index = 0; + continue; + } + + condition.condition_index = state.addCondition( &token[ start ], script ); + if ( !condition.condition_index ) + { + gi.Error( ERR_DROP, "%s: Unknown condition '%s' on line %d.\n", script.Filename(), &token[ start ], script.GetLineNumber() ); + } + + conditions.AddObject( condition ); + } + } + +bool Expression::getResult + ( + State &state, + Entity &ent, + Container *sent_conditionals + ) + + { + int i; + condition_t *cond; + Conditional *conditional; + + for( i = 1; i <= conditions.NumObjects(); i++ ) + { + cond = &conditions.ObjectAt( i ); + conditional = sent_conditionals->ObjectAt( cond->condition_index ); + + if ( !conditional || !conditional->getResult( cond->test, ent ) ) + { + return false; + } + } + + return true; + } + +void State::readNextState + ( + Script &script + ) + + { + nextState = script.GetToken( false ); + } + +void State::readMoveType + ( + Script &script + ) + + { + str token; + const char **name; + int i; + + token = script.GetToken( false ); + + for( i = 0, name = MoveControl_Names; *name != NULL; name++, i++ ) + { + if ( !token.icmp( *name ) ) + { + break; + } + } + + if ( *name == NULL ) + { + gi.Error( ERR_DROP, "%s: Unknown movetype '%s' on line %d.\n", script.Filename(), token.c_str(), script.GetLineNumber() ); + } + else + { + movetype = ( movecontrol_t )i; + } + } + +qboolean State::setCameraType + ( + str ctype + ) + + { + const char **name; + int i; + + for( i = 0, name = Camera_Names; *name != NULL; name++, i++ ) + { + if ( !ctype.icmp( *name ) ) + { + cameratype = ( cameratype_t )i; + return qtrue; + } + } + return qfalse; + } + + +void State::readCamera + ( + Script &script + ) + + { + str token; + + token = script.GetToken( false ); + + if ( !setCameraType( token ) ) + { + gi.Error( ERR_DROP, "%s: Unknown camera type '%s' on line %d.\n", script.Filename(), token.c_str(), script.GetLineNumber() ); + } + } + +void State::readLegs + ( + Script &script + ) + + { + str token; + + if ( !script.TokenAvailable( true ) || Q_stricmp( script.GetToken( true ), "{" ) ) + { + gi.Error( ERR_DROP, "%s: Expecting '{' on line %d.\n", script.Filename(), script.GetLineNumber() ); + } + + while( script.TokenAvailable( true ) ) + { + token = script.GetToken( true ); + if ( !Q_stricmp( token.c_str(), "}" ) ) + { + break; + } + + script.UnGetToken(); + legAnims.AddObject( Expression( script, *this ) ); + } + } + +void State::readAction + ( + Script &script + ) + +{ + str token; + + m_iActionAnimType = 0; + + if( script.TokenAvailable( false ) ) + { + token = script.GetToken( false ); + if( token.icmp( "aim" ) ) { + m_iActionAnimType = 1; + } + } + + if( !script.TokenAvailable( true ) ) + { + gi.Error( ERR_DROP, "%s: EOF, expected state body on line %d.\n", script.Filename(), script.GetLineNumber() ); + } + + if( !script.TokenAvailable( true ) || Q_stricmp( script.GetToken( true ), "{" ) ) + { + gi.Error( ERR_DROP, "%s: Expecting '{' on line %d.\n", script.Filename(), script.GetLineNumber() ); + } + + while( script.TokenAvailable( true ) ) + { + token = script.GetToken( true ); + if( !Q_stricmp( token.c_str(), "}" ) ) + { + return; + } + + script.UnGetToken(); + m_actionAnims.AddObject( Expression( script, *this ) ); + } + + gi.Error( ERR_DROP, "%s: EOF, expected '}' on line %d.\n", script.Filename(), script.GetLineNumber() ); +} + +void State::readBehavior + ( + Script &script + ) + + { + str token; + + if ( !script.TokenAvailable( true ) ) + { + gi.Error( ERR_DROP, "%s: Expecting behavior name on line %d.\n", script.Filename(), script.GetLineNumber() ); + } + + behaviorName = script.GetToken( true ); + if ( !getClass( behaviorName ) ) + { + gi.Error( ERR_DROP, "%s: Unknown behavior '%s' on line %d.\n", script.Filename(), behaviorName.c_str(), script.GetLineNumber() ); + } + + // Read in the behavior arguments if there are any + + while ( script.TokenAvailable( false ) && script.AtString( false ) ) + { + token = script.GetToken( false ); + addBehaviorParm( token ); + } + } + +void State::readTime + ( + Script &script + ) + + { + str token; + + + if ( script.TokenAvailable( false ) && script.AtString( false ) ) + { + token = script.GetToken( false ); + minTime = atof( token.c_str() ); + } + + if ( script.TokenAvailable( false ) && script.AtString( false ) ) + { + token = script.GetToken( false ); + maxTime = atof( token.c_str() ); + } + else + { + maxTime = minTime; + } + } + +void State::readStates + ( + Script &script + ) + + { + str token; + + if ( !script.TokenAvailable( true ) || Q_stricmp( script.GetToken( true ), "{" ) ) + { + gi.Error( ERR_DROP, "%s: Expecting '{' on line %d.\n", script.Filename(), script.GetLineNumber() ); + } + + while( script.TokenAvailable( true ) ) + { + token = script.GetToken( true ); + if ( !Q_stricmp( token.c_str(), "}" ) ) + { + break; + } + + script.UnGetToken(); + states.AddObject( Expression( script, *this ) ); + } + } + +void State::ParseAndProcessCommand + ( + str command, + Entity *target + ) + + { + int argc; + const char *argv[ MAX_COMMANDS ]; + char args[ MAX_COMMANDS ][ MAXTOKEN ]; + Script script; + Event *event; + + script.Parse( command, command.length(), "CommandString" ); + + argc = 0; + while( script.TokenAvailable( false ) ) + { + if ( argc >= MAX_COMMANDS ) + { + gi.DPrintf( "State:ParseAndProcessCommand : Line exceeds %d command limit", MAX_COMMANDS ); + script.SkipToEOL(); + break; + } + strcpy( args[ argc ], script.GetToken( false ) ); + argv[ argc ] = args[ argc ]; + argc++; + } + + assert( argc > 0 ); + + if ( argc <= 0 ) + return; + + event = new Event( args[0] ); + event->AddTokens( argc - 1, &argv[ 1 ] ); + target->ProcessEvent( event ); + } + +void State::ProcessEntryCommands + ( + Entity *target + ) + + { + int i,count; + str command; + + assert( target ); + if ( !target ) + { + return; + } + + count = entryCommands.NumObjects(); + for( i = 1; i <= count; i++ ) + { + ParseAndProcessCommand( entryCommands.ObjectAt( i ), target ); + } + } + +void State::ProcessExitCommands + ( + Entity *target + ) + + { + int i,count; + str command; + + assert( target ); + if ( !target ) + { + return; + } + + count = exitCommands.NumObjects(); + for( i = 1; i <= count; i++ ) + { + ParseAndProcessCommand( exitCommands.ObjectAt( i ), target ); + } + } + +void State::readCommands + ( + Script &script, + Container &container + ) + + { + str token; + str command; + + if ( !script.TokenAvailable( true ) || Q_stricmp( script.GetToken( true ), "{" ) ) + { + gi.Error( ERR_DROP, "%s: Expecting '{' on line %d.\n", script.Filename(), script.GetLineNumber() ); + } + + while( script.TokenAvailable( true ) ) + { + while( script.TokenAvailable( false ) ) + { + token = script.GetToken( true ); + if ( !Q_stricmp( token.c_str(), "}" ) ) + { + goto out; + } + if ( token.length() ) + { + if ( strstr( token.c_str(), " " ) == NULL ) + { + command.append( token ); + } + else + { + command.append( "\"" ); + command.append( token ); + command.append( "\"" ); + } + } + else + { + command.append( "\"\"" ); + } + + command.append( " " ); + } + container.AddObject( command ); + command = ""; + } +out: + return; + } + +State *State::Evaluate + ( + Entity &ent, + Container *sent_conditionals + ) + + { + int i; + Expression *exp; + State *state; + int index; + + for( i = 1; i <= condition_indexes.NumObjects(); i++ ) + { + index = condition_indexes.ObjectAt( i ); + sent_conditionals->ObjectAt( index )->clearCheck(); + //conditions.ObjectAt( i )->clearCheck(); + } + + for( i = 1; i <= states.NumObjects(); i++ ) + { + exp = &states.ObjectAt( i ); + if( exp->getResult( *this, ent, sent_conditionals ) ) + { + state = statemap.FindState( exp->getValue() ); + return state; + } + } + + return NULL; + } + +const char *State::getLegAnim + ( + Entity &ent, + Container *sent_conditionals + ) + +{ + int i; + Expression *exp; + int index; + + for( i = 1; i <= condition_indexes.NumObjects(); i++ ) + { + index = condition_indexes.ObjectAt( i ); + sent_conditionals->ObjectAt( index )->clearCheck(); + //conditions.ObjectAt( i )->clearCheck(); + } + + for( i = 1; i <= legAnims.NumObjects(); i++ ) + { + exp = &legAnims.ObjectAt( i ); + if( exp->getResult( *this, ent, sent_conditionals ) ) + { + return exp->getValue(); + } + } + + return ""; +} + +const char *State::getActionAnim + ( + Entity &ent, + Container *sent_conditionals, + int *piAnimType + ) + +{ + int i; + Expression *exp; + int index; + + for( i = 1; i <= condition_indexes.NumObjects(); i++ ) + { + index = condition_indexes.ObjectAt( i ); + sent_conditionals->ObjectAt( index )->clearCheck(); + } + + for( i = 1; i <= m_actionAnims.NumObjects(); i++ ) + { + exp = &m_actionAnims.ObjectAt( i ); + if( exp->getResult( *this, ent, sent_conditionals ) ) + { + if( piAnimType ) { + *piAnimType = m_iActionAnimType; + } + + return exp->getValue(); + } + } + + if( piAnimType ) { + *piAnimType = 0; + } + + return ""; +} + +const char *State::getBehaviorName + ( + void + ) + + { + return behaviorName.c_str(); + } + +float State::getMinTime + ( + void + ) + + { + return minTime; + } + +float State::getMaxTime + ( + void + ) + + { + return maxTime; + } + +int State::addCondition + ( + const char *name, + Script &script + ) + + { + Conditional *condition; + Condition *cond; + int index; + + str token; + + condition = NULL; + cond = statemap.getCondition( name ); + if ( !cond ) + { + return NULL; + } + + condition = new Conditional( *cond ); + + // Get the paramaters + while ( script.TokenAvailable( false ) && script.AtString( false ) ) + { + token = script.GetToken( false ); + condition->addParm( token ); + } + + // only add a new conditional if a similar on doesn't exist + index = statemap.findConditional( condition ); + + if ( index ) + { + // delete the one we just made + delete condition; + } + else + { + index = statemap.addConditional( condition ); + } + + condition_indexes.AddUniqueObject( index ); + + return index; + } + +void State::CheckStates + ( + void + ) + + { + const char *value; + int i; + + if ( !statemap.FindState( nextState.c_str() ) ) + { + gi.Error( ERR_DROP, "Unknown next state '%s' referenced in state '%s'.\n", nextState.c_str(), getName() ); + } + + for( i = 1; i <= states.NumObjects(); i++ ) + { + value = states.ObjectAt( i ).getValue(); + if ( !statemap.FindState( value ) ) + { + gi.Error( ERR_DROP, "Unknown state '%s' referenced in state '%s'.\n", value, getName() ); + } + } + } + +void State::GetLegAnims + ( + Container *c + ) + + { + int i,j; + qboolean addobj = true; + + for ( i=1; i<=legAnims.NumObjects(); i++ ) + { + const char *value = legAnims.ObjectAt( i ).getValue(); + addobj = true; + + // Check to see if it's already in there + for ( j=1; j<=c->NumObjects(); j++ ) + { + if ( !Q_stricmp( c->ObjectAt( j ), value ) ) + { + addobj = false; + break; + } + } + if ( addobj ) + c->AddObject( value ); + } + } + +void State::GetActionAnims + ( + Container *c + ) + + { + int i,j; + qboolean addobj = true; + + for ( i=1; i<=m_actionAnims.NumObjects(); i++ ) + { + const char *value = m_actionAnims.ObjectAt( i ).getValue(); + addobj = true; + + // Check to see if it's already in there + for ( j=1; j<=c->NumObjects(); j++ ) + { + if ( !Q_stricmp( c->ObjectAt( j ), value ) ) + { + addobj = false; + break; + } + } + if ( addobj ) + c->AddObject( value ); + } + } + +State::State + ( + const char *statename, + Script &script, + StateMap &map + ) : statemap( map ) + +{ + str cmd; + + name = statename; + nextState = statename; + movetype = DEFAULT_MOVETYPE; + cameratype = DEFAULT_CAMERA; + behaviorName = "idle"; + + minTime = -1.0; + maxTime = -1.0; + + if( !script.TokenAvailable( true ) || Q_stricmp( script.GetToken( true ), "{" ) ) + { + gi.Error( ERR_DROP, "%s: Expecting '{' on line %d.\n", script.Filename(), script.GetLineNumber() ); + } + + while( script.TokenAvailable( true ) ) + { + cmd = script.GetToken( true ); + if( !cmd.icmp( "nextstate" ) ) + { + readNextState( script ); + } + else if( !cmd.icmp( "movetype" ) ) + { + readMoveType( script ); + } + else if( !cmd.icmp( "camera" ) ) + { + readCamera( script ); + } + else if( !cmd.icmp( "legs" ) ) + { + readLegs( script ); + } + else if( !cmd.icmp( "action" ) ) + { + readAction( script ); + } + else if( !cmd.icmp( "behavior" ) ) + { + readBehavior( script ); + } + else if( !cmd.icmp( "time" ) ) + { + readTime( script ); + } + else if( !cmd.icmp( "states" ) ) + { + readStates( script ); + } + else if( !cmd.icmp( "entrycommands" ) ) + { + readCommands( script, entryCommands ); + } + else if( !cmd.icmp( "exitcommands" ) ) + { + readCommands( script, exitCommands ); + } + else if( !cmd.icmp( "}" ) ) + { + break; + } + else + { + gi.Error( ERR_DROP, "%s: Unknown command '%s' on line %d.\n", script.Filename(), cmd.c_str(), script.GetLineNumber() ); + } + } +} + +StateMap::StateMap + ( + const char *file_name, + Condition *conditions, + Container *conditionals + ) + + { + str cmd; + str statename; + State *state; + int i; + Script script; + + assert( file_name ); + + filename = file_name; + + this->current_conditions = conditions; + + this->current_conditionals = conditionals; + + script.LoadFile( filename ); + + while( script.TokenAvailable( true ) ) + { + cmd = script.GetToken( true ); + if ( !cmd.icmp( "state" ) ) + { + statename = script.GetToken( false ); + if ( FindState( statename.c_str() ) ) + { + gi.Error( ERR_DROP, "%s: Duplicate definition of state '%s' on line %d.\n", filename.c_str(), statename.c_str(), script.GetLineNumber() ); + } + + // parse the state even if we already have it defined + state = new State( statename.c_str(), script, *this ); + stateList.AddObject( state ); + } + else + { + gi.Error( ERR_DROP, "%s: Unknown command '%s' on line %d.\n", script.Filename(), cmd.c_str(), script.GetLineNumber() ); + } + } + + script.Close(); + + // Have all the states check themselves to see if they reference any non-existant states. + for( i = 1; i <= stateList.NumObjects(); i++ ) + { + stateList.ObjectAt( i )->CheckStates(); + } + } + +StateMap::~StateMap() + { + int i,num; + + num = stateList.NumObjects(); + for( i=num; i>0; i-- ) + { + delete stateList.ObjectAt( i ); + } + stateList.FreeObjectList(); + } + +Condition *StateMap::getCondition + ( + const char *name + ) + + { + Condition *c; + + if ( current_conditions ) + { + for( c = current_conditions; c->name; c++ ) + { + if ( !strcmp( c->name, name ) ) + { + return c; + } + } + } + + return NULL; + } + +int StateMap::findConditional + ( + Conditional *condition + ) + + { + int i; + int j; + Conditional *c; + bool found; + + + // Check for the one special case where we don't want to merge the conditionals + + if ( strcmp( condition->getName(), "CHANCE" ) == 0 ) + return NULL; + + for( i = 1; i <= current_conditionals->NumObjects(); i++ ) + { + c = current_conditionals->ObjectAt( i ); + if ( ( c->getName() == condition->getName() ) && ( c->numParms() == condition->numParms() ) ) + { + found = true; + for( j = 1; j <= c->numParms(); j++ ) + { + if ( strcmp( c->getParm( j ), condition->getParm( j ) ) ) + { + found = false; + break; + } + } + + if ( found ) + { + return i; + } + } + } + + return 0; + } + +int StateMap::addConditional + ( + Conditional *condition + ) + + { + int index; + index = current_conditionals->AddObject( condition ); + + return index; + } + +Conditional *StateMap::getConditional + ( + const char *name + ) + + { + int i; + Conditional *c; + Condition *condition; + + for( i = 1; i <= current_conditionals->NumObjects(); i++ ) + { + c = current_conditionals->ObjectAt( i ); + if ( !strcmp( c->getName(), name ) ) + { + return c; + } + } + + condition = getCondition( name ); + + c = new Conditional( *condition ); + current_conditionals->AddObject( c ); + + return c; + } + +State *StateMap::FindState + ( + const char *name + ) + + { + int i; + + for( i = 1; i <= stateList.NumObjects(); i++ ) + { + if ( !strcmp( stateList.ObjectAt( i )->getName(), name ) ) + { + return stateList.ObjectAt( i ); + } + } + + return NULL; + } + +// Caching statemaps + +struct cached_statemap_t + { + StateMap *statemap; + Container *conditionals; + }; + +Container cached_statemaps; + +StateMap *GetStatemap + ( + str filename, + Condition *conditions, + Container *conditionals, + qboolean reload, + qboolean cache_only + ) + + { + int i; + int j; + cached_statemap_t *cache = NULL; + cached_statemap_t new_cache; + qboolean found = false; + Conditional *new_conditional; + Conditional *old_conditional; + Condition *cond; + + for( i = 1 ; i <= cached_statemaps.NumObjects() ; i++ ) + { + cache = &cached_statemaps.ObjectAt( i ); + + if ( strcmp( cache->statemap->Filename(), filename.c_str() ) == 0 ) + { + found = true; + break; + } + } + + if ( found && reload ) + { + delete cache->statemap; + delete cache->conditionals; + + cache->conditionals = new Container; + cache->statemap = new StateMap( filename, conditions, cache->conditionals ); + } + + if ( !found ) + { + new_cache.conditionals = new Container; + new_cache.statemap = new StateMap( filename, conditions, new_cache.conditionals ); + + cached_statemaps.AddObject( new_cache ); + + cache = &new_cache; + } + + // Copy conditionals over + + if ( !cache_only ) + { + for( i = 1 ; i <= cache->conditionals->NumObjects() ; i++ ) + { + old_conditional = cache->conditionals->ObjectAt( i ); + + cond = cache->statemap->getCondition( old_conditional->condition.name ); + + new_conditional = new Conditional( *cond ); + + for( j = 1 ; j <= old_conditional->parmList.NumObjects() ; j++ ) + { + new_conditional->parmList.AddObject( old_conditional->parmList.ObjectAt( j ) ); + } + + conditionals->AddObject( new_conditional ); + } + } + + return cache->statemap; + } + +void CacheStatemap + ( + str filename, + Condition *conditions + ) + + { + GetStatemap( filename, conditions, NULL, false, true ); + } + +void StateMap::GetAllAnims + ( + Container *c + ) + + { + int i; + + for( i = 1; i <= stateList.NumObjects(); i++ ) + { + stateList.ObjectAt( i )->GetLegAnims( c ); + stateList.ObjectAt( i )->GetActionAnims( c ); + } + } + +void ClearCachedStatemaps + ( + void + ) + + { + int i,j,num2; + cached_statemap_t *cache; + + num2 = cached_statemaps.NumObjects(); + + for( i=num2 ; i>0; i-- ) + { + cache = &cached_statemaps.ObjectAt( i ); + + delete cache->statemap; + + int num = cache->conditionals->NumObjects(); + for ( j=num; j>0; j-- ) + { + Conditional *cond = cache->conditionals->ObjectAt( j ); + delete cond; + } + delete cache->conditionals; + } + + cached_statemaps.FreeObjectList(); + } diff --git a/code/game/characterstate.h b/code/game/characterstate.h new file mode 100644 index 00000000..2939eab8 --- /dev/null +++ b/code/game/characterstate.h @@ -0,0 +1,419 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// characterstate.h: Character state + +#ifndef __CHARACTERSTATE_H__ +#define __CHARACTERSTATE_H__ + +#include "g_local.h" +#include "entity.h" +#include "script.h" + +enum testcondition_t + { + TC_ISTRUE, // no prefix + TC_ISFALSE, // ! + TC_EDGETRUE, // + + TC_EDGEFALSE // - + }; + +enum movecontrol_t +{ + MOVECONTROL_NONE, + MOVECONTROL_USER, // Quake style + MOVECONTROL_LEGS, // Quake style, legs state system active + MOVECONTROL_USER_MOVEANIM, + MOVECONTROL_ANIM, // move based on animation, with full collision testing + MOVECONTROL_ABSOLUTE, // move based on animation, with full collision testing but no turning + MOVECONTROL_HANGING, // move based on animation, with full collision testing, hanging + MOVECONTROL_ROPE_GRAB, + MOVECONTROL_ROPE_RELEASE, + MOVECONTROL_ROPE_MOVE, + MOVECONTROL_PICKUPENEMY, + MOVECONTROL_PUSH, + MOVECONTROL_CLIMBWALL, + MOVECONTROL_USEANIM, + MOVECONTROL_CROUCH, + MOVECONTROL_LOOPUSEANIM, + MOVECONTROL_USEOBJECT, + MOVECONTROL_COOLOBJECT, +}; + +enum cameratype_t +{ + CAMERA_TOPDOWN, + CAMERA_BEHIND, + CAMERA_FRONT, + CAMERA_SIDE, + CAMERA_BEHIND_FIXED, + CAMERA_SIDE_LEFT, + CAMERA_SIDE_RIGHT, + CAMERA_BEHIND_NOPITCH +}; + +#define DEFAULT_MOVETYPE MOVECONTROL_NONE +#define DEFAULT_CAMERA CAMERA_BEHIND + +class Conditional; + +template< class Type > +struct Condition + { + const char *name; + qboolean ( Type::*func )( Conditional &condition ); + }; + +class Conditional : public Class + { + private : + qboolean result; + qboolean previous_result; + bool checked; + + public : + CLASS_PROTOTYPE( Conditional ); + + Condition condition; + Container parmList; + + bool getResult( testcondition_t test, Entity &ent ); + const char *getName( void ); + + Conditional( Condition &condition ); + Conditional(); + + const char *getParm( int number ); + void addParm( str parm ); + int numParms( void ); + void clearCheck( void ); + void clearPrevious( void ); + }; + +inline void Conditional::addParm + ( + str parm + ) + + { + parmList.AddObject( parm ); + } + +inline const char *Conditional::getParm + ( + int number + ) + + { + if ( ( number < 1 ) || ( number > parmList.NumObjects() ) ) + { + gi.Error( ERR_DROP, "Parm #%d out of range on %s condition\n", number, condition.name ); + } + return parmList.ObjectAt( number ).c_str(); + } + +inline int Conditional::numParms + ( + void + ) + + { + return parmList.NumObjects(); + } + +inline void Conditional::clearCheck + ( + void + ) + + { + checked = false; + } + +inline void Conditional::clearPrevious + ( + void + ) + + { + previous_result = 0; + } + +inline const char *Conditional::getName + ( + void + ) + + { + return condition.name; + } + +inline bool Conditional::getResult + ( + testcondition_t test, + Entity &ent + ) + +{ + if ( condition.func && !checked ) + { + checked = true; + previous_result = result; + + result = ( ent.*condition.func )( *this ); + } + + switch( test ) + { + case TC_ISFALSE : + return !result; + + case TC_EDGETRUE: + return result && !previous_result; + + case TC_EDGEFALSE: + return !result && previous_result; + + case TC_ISTRUE : + default: + return result != false; + } +} + +class State; +class StateMap; + +class Expression : public Class + { + private : + struct condition_t + { + testcondition_t test; + int condition_index; + }; + + str value; + Container conditions; + + public : + Expression(); + Expression( Expression &exp ); + Expression( Script &script, State &state ); + + void operator=( const Expression &exp ); + + bool getResult( State &state, Entity &ent, Container *sent_conditionals ); + const char *getValue( void ); + }; + +inline void Expression::operator= + ( + const Expression &exp + ) + + { + int i; + + value = exp.value; + + conditions.FreeObjectList(); + for( i = 1; i <= exp.conditions.NumObjects(); i++ ) + { + conditions.AddObject( exp.conditions.ObjectAt( i ) ); + } + } + +inline const char *Expression::getValue + ( + void + ) + + { + return value.c_str(); + } + +class State : public Class + { + private : + Container condition_indexes; + + StateMap &statemap; + + str name; + + str nextState; + movecontrol_t movetype; + cameratype_t cameratype; + + str behaviorName; + Container behaviorParmList; + + float minTime; + float maxTime; + + Container legAnims; + Container m_actionAnims; + int m_iActionAnimType; + + Container states; + Container entryCommands; + Container exitCommands; + + void readNextState( Script &script ); + void readMoveType( Script &script ); + void readCamera( Script &script ); + void readLegs( Script &script ); + void readAction( Script &script ); + void readBehavior( Script &script ); + void readTime( Script &script ); + void readStates( Script &script ); + void readCommands( Script &script, Container &container ); + + void ParseAndProcessCommand( str command, Entity *target ); + + public : + State( const char *name, Script &script, StateMap &map ); + + State *Evaluate( Entity &ent, Container *ent_conditionals ); + int addCondition( const char *name, Script &script ); + void CheckStates( void ); + + const char *getName( void ); + + const char *getLegAnim( Entity &ent, Container *sent_conditionals ); + const char *getActionAnim( Entity &ent, Container *sent_conditionals, int *piAnimType = NULL ); + const char *getBehaviorName( void ); + State *getNextState( void ); + movecontrol_t getMoveType( void ); + cameratype_t getCameraType( void ); + qboolean setCameraType( str ctype ); + + const char *getBehaviorParm( int number=1 ); + void addBehaviorParm( str parm ); + int numBehaviorParms( void ); + + float getMinTime( void ); + float getMaxTime( void ); + void ProcessEntryCommands( Entity *target ); + void ProcessExitCommands( Entity *target ); + void GetLegAnims( Container *c ); + void GetActionAnims( Container *c ); + }; + +inline void State::addBehaviorParm + ( + str parm + ) + + { + behaviorParmList.AddObject( parm ); + } + +inline const char *State::getBehaviorParm + ( + int number + ) + + { + return behaviorParmList.ObjectAt( number ).c_str(); + } + +inline int State::numBehaviorParms + ( + void + ) + + { + return behaviorParmList.NumObjects(); + } + +class StateMap : public Class + { + private : + Container stateList; + Condition *current_conditions; + Container *current_conditionals; + str filename; + + public : + StateMap( const char *filename, Condition *conditions, Container *conditionals ); + ~StateMap(); + + Condition *getCondition( const char *name ); + int findConditional( Conditional *condition ); + int addConditional( Conditional *condition ); + Conditional *getConditional( const char *name ); + void GetAllAnims( Container *c ); + State *FindState( const char *name ); + const char *Filename(); + }; + +inline const char *StateMap::Filename + ( + void + ) + + { + return filename.c_str(); + } + +inline const char *State::getName + ( + void + ) + + { + return name.c_str(); + } + +inline State *State::getNextState + ( + void + ) + + { + return statemap.FindState( nextState.c_str() ); + } + +inline movecontrol_t State::getMoveType + ( + void + ) + + { + return movetype; + } + +inline cameratype_t State::getCameraType + ( + void + ) + + { + return cameratype; + } + +void ClearCachedStatemaps( void ); +StateMap *GetStatemap( str filename, Condition *conditions, Container *conditionals, qboolean reload, qboolean cache_only = false ); +void CacheStatemap( str filename, Condition *conditions ); + +#endif /* !__CHARACTERSTATE_H__ */ diff --git a/code/game/chars.h b/code/game/chars.h new file mode 100644 index 00000000..4b570df1 --- /dev/null +++ b/code/game/chars.h @@ -0,0 +1,134 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +//======================================================== +//======================================================== +//name +#define CHARACTERISTIC_NAME 0 //string +//gender of the bot +#define CHARACTERISTIC_GENDER 1 //string ("male", "female", "it") +//attack skill +// > 0.0 && < 0.2 = don't move +// > 0.3 && < 1.0 = aim at enemy during retreat +// > 0.0 && < 0.4 = only move forward/backward +// >= 0.4 && < 1.0 = circle strafing +// > 0.7 && < 1.0 = random strafe direction change +#define CHARACTERISTIC_ATTACK_SKILL 2 //float [0, 1] +//weapon weight file +#define CHARACTERISTIC_WEAPONWEIGHTS 3 //string +//view angle difference to angle change factor +#define CHARACTERISTIC_VIEW_FACTOR 4 //float <0, 1] +//maximum view angle change +#define CHARACTERISTIC_VIEW_MAXCHANGE 5 //float [1, 360] +//reaction time in seconds +#define CHARACTERISTIC_REACTIONTIME 6 //float [0, 5] +//accuracy when aiming +#define CHARACTERISTIC_AIM_ACCURACY 7 //float [0, 1] +//weapon specific aim accuracy +#define CHARACTERISTIC_AIM_ACCURACY_MACHINEGUN 8 //float [0, 1] +#define CHARACTERISTIC_AIM_ACCURACY_SHOTGUN 9 //float [0, 1] +#define CHARACTERISTIC_AIM_ACCURACY_ROCKETLAUNCHER 10 //float [0, 1] +#define CHARACTERISTIC_AIM_ACCURACY_GRENADELAUNCHER 11 //float [0, 1] +#define CHARACTERISTIC_AIM_ACCURACY_LIGHTNING 12 +#define CHARACTERISTIC_AIM_ACCURACY_PLASMAGUN 13 //float [0, 1] +#define CHARACTERISTIC_AIM_ACCURACY_RAILGUN 14 +#define CHARACTERISTIC_AIM_ACCURACY_BFG10K 15 //float [0, 1] +//skill when aiming +// > 0.0 && < 0.9 = aim is affected by enemy movement +// > 0.4 && <= 0.8 = enemy linear leading +// > 0.8 && <= 1.0 = enemy exact movement leading +// > 0.5 && <= 1.0 = prediction shots when enemy is not visible +// > 0.6 && <= 1.0 = splash damage by shooting nearby geometry +#define CHARACTERISTIC_AIM_SKILL 16 //float [0, 1] +//weapon specific aim skill +#define CHARACTERISTIC_AIM_SKILL_ROCKETLAUNCHER 17 //float [0, 1] +#define CHARACTERISTIC_AIM_SKILL_GRENADELAUNCHER 18 //float [0, 1] +#define CHARACTERISTIC_AIM_SKILL_PLASMAGUN 19 //float [0, 1] +#define CHARACTERISTIC_AIM_SKILL_BFG10K 20 //float [0, 1] +//======================================================== +//chat +//======================================================== +//file with chats +#define CHARACTERISTIC_CHAT_FILE 21 //string +//name of the chat character +#define CHARACTERISTIC_CHAT_NAME 22 //string +//characters per minute type speed +#define CHARACTERISTIC_CHAT_CPM 23 //integer [1, 4000] +//tendency to insult/praise +#define CHARACTERISTIC_CHAT_INSULT 24 //float [0, 1] +//tendency to chat misc +#define CHARACTERISTIC_CHAT_MISC 25 //float [0, 1] +//tendency to chat at start or end of level +#define CHARACTERISTIC_CHAT_STARTENDLEVEL 26 //float [0, 1] +//tendency to chat entering or exiting the game +#define CHARACTERISTIC_CHAT_ENTEREXITGAME 27 //float [0, 1] +//tendency to chat when killed someone +#define CHARACTERISTIC_CHAT_KILL 28 //float [0, 1] +//tendency to chat when died +#define CHARACTERISTIC_CHAT_DEATH 29 //float [0, 1] +//tendency to chat when enemy suicides +#define CHARACTERISTIC_CHAT_ENEMYSUICIDE 30 //float [0, 1] +//tendency to chat when hit while talking +#define CHARACTERISTIC_CHAT_HITTALKING 31 //float [0, 1] +//tendency to chat when bot was hit but didn't dye +#define CHARACTERISTIC_CHAT_HITNODEATH 32 //float [0, 1] +//tendency to chat when bot hit the enemy but enemy didn't dye +#define CHARACTERISTIC_CHAT_HITNOKILL 33 //float [0, 1] +//tendency to randomly chat +#define CHARACTERISTIC_CHAT_RANDOM 34 //float [0, 1] +//tendency to reply +#define CHARACTERISTIC_CHAT_REPLY 35 //float [0, 1] +//======================================================== +//movement +//======================================================== +//tendency to crouch +#define CHARACTERISTIC_CROUCHER 36 //float [0, 1] +//tendency to jump +#define CHARACTERISTIC_JUMPER 37 //float [0, 1] +//tendency to walk +#define CHARACTERISTIC_WALKER 48 //float [0, 1] +//tendency to jump using a weapon +#define CHARACTERISTIC_WEAPONJUMPING 38 //float [0, 1] +//tendency to use the grapple hook when available +#define CHARACTERISTIC_GRAPPLE_USER 39 //float [0, 1] //use this!! +//======================================================== +//goal +//======================================================== +//item weight file +#define CHARACTERISTIC_ITEMWEIGHTS 40 //string +//the aggression of the bot +#define CHARACTERISTIC_AGGRESSION 41 //float [0, 1] +//the self preservation of the bot (rockets near walls etc.) +#define CHARACTERISTIC_SELFPRESERVATION 42 //float [0, 1] +//how likely the bot is to take revenge +#define CHARACTERISTIC_VENGEFULNESS 43 //float [0, 1] //use this!! +//tendency to camp +#define CHARACTERISTIC_CAMPER 44 //float [0, 1] +//======================================================== +//======================================================== +//tendency to get easy frags +#define CHARACTERISTIC_EASY_FRAGGER 45 //float [0, 1] +//how alert the bot is (view distance) +#define CHARACTERISTIC_ALERTNESS 46 //float [0, 1] +//how much the bot fires it's weapon +#define CHARACTERISTIC_FIRETHROTTLE 47 //float [0, 1] + diff --git a/code/game/container.cpp b/code/game/container.cpp new file mode 100644 index 00000000..b8c388cb --- /dev/null +++ b/code/game/container.cpp @@ -0,0 +1,243 @@ +//----------------------------------------------------------------------------- +// +// $Logfile:: /fakk2_code/fakk2_new/cgame/container.cpp $ +// $Revision:: 2 $ +// $Author:: Markd $ +// $Date:: 10/05/99 2:03p $ +// +// Copyright (C) 1997 by Ritual Entertainment, Inc. +// All rights reserved. +// +// This source is may not be distributed and/or modified without +// expressly written permission by Ritual Entertainment, Inc. +// +// $Log:: /fakk2_code/fakk2_new/cgame/container.cpp $ +// +// 2 10/05/99 2:03p Markd +// Added warning about files being in multiple projects +// +// 1 9/10/99 10:53a Jimdose +// +// 1 9/08/99 3:15p Aldie +// +// DESCRIPTION: +// Base class for a dynamic array. Allows adding, removing, index of, +// and finding of entries with specified value. Originally created for +// cataloging entities, but pointers to objects that may be removed at +// any time are bad to keep around, so only entity numbers should be +// used in the future. +// +// WARNING: This file is shared between fgame, cgame and possibly the user interface. +// It is instanced in each one of these directories because of the way that SourceSafe works. +// + +#if 0 + +#include "g_local.h" +#include "class.h" +#include "container.h" + +template< class Type > +Container::Container() + { + objlist = NULL; + FreeObjectList(); + } + +template< class Type > +Container::~Container() + { + FreeObjectList(); + } + +template< class Type > +void Container::FreeObjectList + ( + void + ) + + { + if ( objlist ) + { + delete objlist; + } + objlist = NULL; + numobjects = 0; + maxobjects = 0; + } + +template< class Type > +void Container::ClearObjectList + ( + void + ) + + { + if ( objlist ) + { + memset( objlist, 0, maxobjects * sizeof( Type ) ); + } + numobjects = 0; + } + +template< class Type > +int Container::NumObjects + ( + void + ) + + { + return numobjects; + } + +template< class Type > +void Container::Resize + ( + int maxelements + ) + + { + Type *temp; + + if ( !objlist ) + { + maxobjects = maxelements; + objlist = new Type[ maxobjects ]; + memset( objlist, 0, maxobjects * sizeof( Type ) ); + } + else + { + temp = objlist; + maxobjects = maxelements; + if ( maxobjects < numobjects ) + { + maxobjects = numobjects; + } + + objlist = new Type[ maxobjects ]; + memset( objlist, 0, maxobjects * sizeof( Type ) ); + memcpy( objlist, temp, numobjects * sizeof( Type ) ); + delete temp; + } + } + +template< class Type > +void Container::AddObject + ( + Type obj + ) + + { + Type *temp; + + if ( !objlist ) + { + Resize( 10 ); + } + + if ( numobjects == maxobjects ) + { + Resize( maxobjects * 2 ); + } + + objlist[ numobjects++ ] = obj; + } + +template< class Type > +int Container::IndexOfObject + ( + Type obj + ) + + { + int i; + + for( i = 0; i < numobjects; i++ ) + { + if ( objlist[ i ] == obj ) + { + return i + 1; + } + } + + return 0; + } + +template< class Type > +qboolean Container::ObjectInList + ( + Type obj + ) + + { + if ( !IndexOfObject( obj ) ) + { + return false; + } + + return true; + } + +template< class Type > +Type Container::ObjectAt + ( + int index + ) + + { + if ( ( index <= 0 ) || ( index > numobjects ) ) + { + gi.DPrintf( "Container::ObjectAt : index out of range" ); + return 0; + } + + return objlist[ index - 1 ]; + } + +template< class Type > +void Container::RemoveObjectAt + ( + int index + ) + + { + int i; + + if ( !objlist ) + { + gi.DPrintf( "Container::RemoveObjectAt : Empty list" ); + return; + } + + if ( ( index <= 0 ) || ( index > numobjects ) ) + { + gi.DPrintf( "Container::RemoveObjectAt : index out of range" ); + return; + } + + i = index - 1; + memcpy( &objlist[ i ], &objlist[ i + 1 ], ( numobjects - 1 - i ) * sizeof( Type ) ); + memset( &objlist[ numobjects - 1 ], 0, sizeof( Type ) ); + numobjects--; + } + +template< class Type > +void Container::RemoveObject + ( + Type obj + ) + + { + int index; + + index = IndexOfObject( obj ); + if ( !index ) + { + gi.DPrintf( "Container::RemoveObject : Object not in list" ); + return; + } + + RemoveObjectAt( index ); + } + +#endif \ No newline at end of file diff --git a/code/game/container.h b/code/game/container.h new file mode 100644 index 00000000..fc6b7c69 --- /dev/null +++ b/code/game/container.h @@ -0,0 +1,538 @@ +//----------------------------------------------------------------------------- +// +// $Logfile:: /fakk2_code/fakk2_new/fgame/container.h $ +// $Revision:: 9 $ +// $Author:: Steven $ +// $Date:: 7/26/00 1:08p $ +// +// Copyright (C) 1997 by Ritual Entertainment, Inc. +// All rights reserved. +// +// This source is may not be distributed and/or modified without +// expressly written permission by Ritual Entertainment, Inc. +// +// $Log:: /fakk2_code/fakk2_new/fgame/container.h $ +// +// 9 7/26/00 1:08p Steven +// In ClearObjectList make sure we don't have 0 maxelements when creating a new +// array. +// +// 8 7/25/00 2:32p Aldie +// Undo checkout for new operator +// +// 7 7/25/00 2:18p Aldie +// changed the new operator for containers +// +// 6 5/26/00 7:44p Markd +// 2nd phase save games +// +// 5 1/06/00 11:18p Jimdose +// put sort back in +// +// 4 1/06/00 11:08p Jimdose +// cleaning up unused code +// +// 3 10/05/99 2:03p Markd +// Added warning about files being in multiple projects +// +// 2 9/28/99 4:26p Markd +// merged listener, class and vector between 3 projects +// +// 1 9/10/99 10:53a Jimdose +// +// 1 9/08/99 3:15p Aldie +// +// DESCRIPTION: +// Base class for a dynamic array. Allows adding, removing, index of, +// and finding of entries with specified value. NOTE: indices in container +// are 1 based, not 0. This means that loops must check from 1 up to and including +// NumObjects() (ei. for( i = 1; i <= list.NumObjects(); i++ ) ). +// +// FIXME: Someday make this 0 based and update all code to match. +// +// WARNING: This file is shared between fgame, cgame and possibly the user interface. +// It is instanced in each one of these directories because of the way that SourceSafe works. +// + +#ifndef __CONTAINER_H__ +#define __CONTAINER_H__ + +#if defined( GAME_DLL ) +// +// game dll specific defines +// +#include "g_local.h" + +#define CONTAINER_Error gi.Error +#define CONTAINER_DPrintf gi.DPrintf + +#elif defined ( CGAME_DLL ) +// +// cgame dll specific defines +// +#define CONTAINER_Error cgi.Error +#define CONTAINER_DPrintf cgi.DPrintf + +#else + +// +// client specific defines +// +#define CONTAINER_Error Com_Error +#define CONTAINER_DPrintf Com_DPrintf +#endif + +#include + +class Archiver; +template< class Type > +class Container + { + private: + Type *objlist; + int numobjects; + int maxobjects; + + public: + Container(); + ~Container(); + + void FreeObjectList( void ); + void ClearObjectList( void ); + int NumObjects( void ); + void Resize( int maxelements ); + void SetObjectAt( int index, Type& obj ); + int AddObject( Type& obj ); + int AddUniqueObject( Type& obj ); + void AddObjectAt( int index, Type& obj ); + int IndexOfObject( Type& obj ); + qboolean ObjectInList( Type& obj ); + Type& ObjectAt( int index ); + Type *AddressOfObjectAt( int index ); + void RemoveObjectAt( int index ); + void RemoveObject( Type& obj ); + void Sort( int ( __cdecl *compare )( const void *elem1, const void *elem2 ) ); +#if defined( GAME_DLL ) + void Archive( Archiver &arc ); +#endif + }; + +template< class Type > +Container::Container() + { + objlist = NULL; + FreeObjectList(); + } + +template< class Type > +Container::~Container() + { + FreeObjectList(); + } + +template< class Type > +void Container::FreeObjectList + ( + void + ) + + { + if ( objlist ) + { + delete[] objlist; + } + objlist = NULL; + numobjects = 0; + maxobjects = 0; + } + +template< class Type > +void Container::ClearObjectList + ( + void + ) + + { + // only delete the list if we have objects in it + if ( objlist && numobjects ) + { + delete[] objlist; + + if ( maxobjects == 0 ) + { + objlist = NULL; + return; + } + + objlist = new Type[ maxobjects ]; + numobjects = 0; + } + } + +template< class Type > +int Container::NumObjects + ( + void + ) + + { + return numobjects; + } + +template< class Type > +void Container::Resize + ( + int maxelements + ) + + { + Type *temp; + int i; + + assert( maxelements >= 0 ); + + if ( maxelements <= 0 ) + { + FreeObjectList(); + return; + } + + if ( !objlist ) + { + maxobjects = maxelements; + objlist = new Type[ maxobjects ]; + } + else + { + temp = objlist; + maxobjects = maxelements; + if ( maxobjects < numobjects ) + { + maxobjects = numobjects; + } + + objlist = new Type[ maxobjects ]; + for( i = 0; i < numobjects; i++ ) + { + objlist[ i ] = temp[ i ]; + } + delete[] temp; + } + } + +template< class Type > +void Container::SetObjectAt + ( + int index, + Type& obj + ) + + { + if ( ( index <= 0 ) || ( index > numobjects ) ) + { + CONTAINER_Error( ERR_DROP, "Container::SetObjectAt : index out of range" ); + } + + objlist[ index - 1 ] = obj; + } + +template< class Type > +int Container::AddObject + ( + Type& obj + ) + + { + if ( !objlist ) + { + Resize( 10 ); + } + + if ( numobjects == maxobjects ) + { + Resize( maxobjects * 2 ); + } + + objlist[ numobjects ] = obj; + numobjects++; + + return numobjects; + } + +template< class Type > +int Container::AddUniqueObject + ( + Type& obj + ) + + { + int index; + + index = IndexOfObject( obj ); + if ( !index ) + index = AddObject( obj ); + return index; + } + +template< class Type > +void Container::AddObjectAt + ( + int index, + Type& obj + ) + + { + // + // this should only be used when reconstructing a list that has to be identical to the original + // + if ( index > maxobjects ) + { + Resize( index ); + } + if ( index > numobjects ) + { + numobjects = index; + } + SetObjectAt( index, obj ); + } + +template< class Type > +int Container::IndexOfObject + ( + Type& obj + ) + + { + int i; + + for( i = 0; i < numobjects; i++ ) + { + if ( objlist[ i ] == obj ) + { + return i + 1; + } + } + + return 0; + } + +template< class Type > +qboolean Container::ObjectInList + ( + Type& obj + ) + + { + if ( !IndexOfObject( obj ) ) + { + return false; + } + + return true; + } + +template< class Type > +Type& Container::ObjectAt + ( + int index + ) + + { + if ( ( index <= 0 ) || ( index > numobjects ) ) + { + CONTAINER_Error( ERR_DROP, "Container::ObjectAt : index out of range" ); + } + + return objlist[ index - 1 ]; + } + +template< class Type > +Type * Container::AddressOfObjectAt + ( + int index + ) + + { + // + // this should only be used when reconstructing a list that has to be identical to the original + // + if ( index > maxobjects ) + { + CONTAINER_Error( ERR_DROP, "Container::AddressOfObjectAt : index is greater than maxobjects" ); + } + if ( index > numobjects ) + { + numobjects = index; + } + return &objlist[ index - 1 ]; + } + +template< class Type > +void Container::RemoveObjectAt + ( + int index + ) + + { + int i; + + if ( !objlist ) + { + CONTAINER_DPrintf( "Container::RemoveObjectAt : Empty list\n" ); + return; + } + + if ( ( index <= 0 ) || ( index > numobjects ) ) + { + CONTAINER_Error( ERR_DROP, "Container::RemoveObjectAt : index out of range" ); + return; + } + + i = index - 1; + numobjects--; + for( i = index - 1; i < numobjects; i++ ) + { + objlist[ i ] = objlist[ i + 1 ]; + } + } + +template< class Type > +void Container::RemoveObject + ( + Type& obj + ) + + { + int index; + + index = IndexOfObject( obj ); + if ( !index ) + { + CONTAINER_DPrintf( "Container::RemoveObject : Object not in list\n" ); + return; + } + + RemoveObjectAt( index ); + } + +template< class Type > +void Container::Sort + ( + int ( __cdecl *compare )( const void *elem1, const void *elem2 ) + ) + + { + if ( !objlist ) + { + CONTAINER_DPrintf( "Container::Sort : Empty list\n" ); + return; + } + + qsort( ( void * )objlist, ( size_t )numobjects, sizeof( Type ), compare ); + } + +#if 0 +#if defined( GAME_DLL ) + +#include "str.h" +void Container::Archive + ( + Archiver &arc + ) + { + int i, num; + + if ( arc.Loading() ) + { + ClearObjectList(); + arc.ArchiveInteger( &num ); + Resize( num ); + } + else + { + num = numobjects; + arc.ArchiveInteger( &num ); + } + for( i = 1; i <= num; i++ ) + { + arc.ArchiveString( AddressOfObjectAt( i ) ); + } + } + +#include "vector.h" +void Container::Archive + ( + Archiver &arc + ) + { + int i, num; + + if ( arc.Loading() ) + { + ClearObjectList(); + arc.ArchiveInteger( &num ); + Resize( num ); + } + else + { + num = numobjects; + arc.ArchiveInteger( &num ); + } + for( i = 1; i <= num; i++ ) + { + arc.ArchiveVector( AddressOfObjectAt( i ) ); + } + } + +void Container::Archive + ( + Archiver &arc + ) + { + int i, num; + + if ( arc.Loading() ) + { + ClearObjectList(); + arc.ArchiveInteger( &num ); + Resize( num ); + } + else + { + num = numobjects; + arc.ArchiveInteger( &num ); + } + for( i = 1; i <= num; i++ ) + { + arc.ArchiveInteger( AddressOfObjectAt( i ) ); + } + } + +void Container::Archive + ( + Archiver &arc + ) + { + int i, num; + + if ( arc.Loading() ) + { + ClearObjectList(); + arc.ArchiveInteger( &num ); + Resize( num ); + } + else + { + num = numobjects; + arc.ArchiveInteger( &num ); + } + for( i = 1; i <= num; i++ ) + { + arc.ArchiveFloat( AddressOfObjectAt( i ) ); + } + } + +#endif +#endif + +#endif /* container.h */ diff --git a/code/game/crateobject.cpp b/code/game/crateobject.cpp new file mode 100644 index 00000000..bee90af8 --- /dev/null +++ b/code/game/crateobject.cpp @@ -0,0 +1,541 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// crateobject.cpp : Crates + +#include "crateobject.h" +#include "player.h" + +/***************************************************************************** +/*QUAKED func_crate (0 0.25 0.5) ? INDESTRUCTABLE NOTSTACKEDON +Brush model crate object +"spawnitems" is a list of items to spawn when the crate is destroyed. +INDESTRUCTABLE makes the crate, well, indestructable. +Since the same effect can be achieved by not making it an entity, this should only +be used when stacking indestructable crates on top of destructable crates. +Otherwise, they should just be brushes to save on entity count. +NOTSTACKED prevents the crate from causing crates above it to fall. Great for crates on shelves. +"health" sets the crate's health. Default is 300 +"debristype" sets the type of debris to spawn from the crate. Valid values are from 0 - ?. Default is 0 +0: wooden crate 32 units to a side +1: wooden crate 64 units to a side +2: cardboard crate 16 units to a side +3: cardboard crate 32 units to a side +******************************************************************************/ + +Event EV_Crate_Think +( + "_crate_think", + EV_DEFAULT, + NULL, + NULL, + "think function for a crate." +); + +Event EV_Crate_Falling +( + "_crate_falling", + EV_DEFAULT, + NULL, + NULL, + "crate's falling." +); + +Event EV_Crate_Setup +( + "_cratesetup", + EV_DEFAULT, + NULL, + NULL, + "Does the post spawn setup of the crate" +); + +Event EV_Crate_Start_Falling +( + "_cratestartfalling", + EV_DEFAULT, + NULL, + NULL, + "Makes a crate start falling" +); + +Event EV_Crate_SetDebris +( + "debristype", + EV_DEFAULT, + "i", + "type", + "Sets the debris type of the crate" +); + +CLASS_DECLARATION( Entity, CrateObject, "func_crate" ) +{ + { &EV_Crate_Setup, &CrateObject::CrateSetup }, + { &EV_Crate_Falling, &CrateObject::CrateFalling }, + { &EV_Damage, &CrateObject::CrateDamaged }, + { &EV_Killed, &CrateObject::CrateKilled }, + { &EV_Crate_Start_Falling, &CrateObject::StartFalling }, + { &EV_Crate_Think, &CrateObject::CrateThink }, + { &EV_Crate_SetDebris, &CrateObject::CrateDebrisType }, + { NULL, NULL } +}; + +CrateObject::CrateObject() +{ + entflags |= EF_CRATEOBJECT; + + if( LoadingSavegame ) + { + return; + } + + edict->s.eType = ET_GENERAL; + + m_fMoveTime = 0.0f; + + health = 100.0f; + max_health = 100.0f; + deadflag = 0; + takedamage = DAMAGE_YES; + + mass = 1200; + + m_iDebrisType = 0; + + PostEvent( EV_Crate_Setup, EV_POSTSPAWN ); +} + + +void CrateObject::TellNeighborsToFall + ( + void + ) + +{ + Entity *pEnt; + Entity *pNext; + Vector vMins; + Vector vMaxs; + + vMins[ 0 ] = mins[ 0 ] + origin[ 0 ] + 6.0f; + vMins[ 1 ] = mins[ 1 ] + origin[ 1 ] + 6.0f; + vMins[ 2 ] = mins[ 2 ] + origin[ 2 ] + 6.0f; + + vMaxs[ 0 ] = maxs[ 0 ] + origin[ 0 ] - 6.0f; + vMaxs[ 1 ] = maxs[ 1 ] + origin[ 1 ] - 6.0f; + vMaxs[ 2 ] = maxs[ 2 ] + origin[ 2 ] + 12.0f; + + for( pEnt = G_NextEntity( NULL ); pEnt != NULL; pEnt = pNext ) + { + pNext = G_NextEntity( pEnt ); + + for( pEnt = G_NextEntity( NULL ); pEnt != NULL; pEnt = pNext ) + { + pNext = G_NextEntity( pEnt ); + + if( pEnt != this && pEnt->IsSubclassOfCrateObject() ) + { + if( vMins[ 0 ] <= absmax[ 0 ] && + vMins[ 1 ] <= absmax[ 1 ] && + vMins[ 2 ] <= absmax[ 2 ] && + absmin[ 0 ] <= vMaxs[ 0 ] && + absmin[ 1 ] <= vMaxs[ 1 ] && + absmin[ 2 ] <= vMaxs[ 2 ] ) + { + if( !pEnt->EventPending( EV_Crate_Start_Falling ) ) + { + float time = level.frametime + level.frametime; + pEnt->PostEvent( EV_Crate_Start_Falling, time ); + } + } + } + } + } +} + +void CrateObject::TellNeighborsToJitter + ( + Vector vJitterAdd + ) + +{ + + Entity *pEnt; + Entity *pNext; + Vector vMins; + Vector vMaxs; + + vMins[ 0 ] = mins[ 0 ] + origin[ 0 ] + 6.0f; + vMins[ 1 ] = mins[ 1 ] + origin[ 1 ] + 6.0f; + vMins[ 2 ] = mins[ 2 ] + origin[ 2 ] + 6.0f; + + vMaxs[ 0 ] = maxs[ 0 ] + origin[ 0 ] - 6.0f; + vMaxs[ 1 ] = maxs[ 1 ] + origin[ 1 ] - 6.0f; + vMaxs[ 2 ] = maxs[ 2 ] + origin[ 2 ] + 12.0f; + + for( pEnt = G_NextEntity( NULL ); pEnt != NULL; pEnt = pNext ) + { + CrateObject *crate = ( CrateObject * )pEnt; + + pNext = G_NextEntity( pEnt ); + + if( pEnt == this ) + { + continue; + } + + if( !pEnt->IsSubclassOfCrateObject() ) + { + continue; + } + + if( vMins[ 0 ] > absmax[ 0 ] || + vMins[ 1 ] > absmax[ 1 ] || + vMins[ 2 ] > absmax[ 2 ] || + absmin[ 0 ] > vMaxs[ 0 ] || + absmin[ 1 ] > vMaxs[ 1 ] || + absmin[ 2 ] > vMaxs[ 2 ] ) + { + continue; + } + + crate->m_vJitterAngles[ 0 ] = m_vJitterAngles[ 0 ] + vJitterAdd[ 0 ]; + + if( crate->m_vJitterAngles[ 0 ] > m_fJitterScale * 1.25f || + -( m_fJitterScale * 1.25f ) <= crate->m_vJitterAngles[ 0 ] ) + { + crate->m_vJitterAngles[ 0 ] = m_fJitterScale * 1.25f; + } + + crate->m_vJitterAngles[ 2 ] += vJitterAdd[ 2 ]; + + if( crate->m_vJitterAngles[ 2 ] > m_fJitterScale * 1.25f ) { + break; + } + + if( -( m_fJitterScale * 1.25f ) <= crate->m_vJitterAngles[ 2 ] ) + { + m_vJitterAngles[ 2 ] = -( m_fJitterScale * 1.25f ); + } + + if( !crate->EventPending( EV_Crate_Think ) ) + { + crate->ProcessEvent( EV_Crate_Think ); + } + } +} + +void CrateObject::CrateSetup + ( + Event *ev + ) + +{ + Vector vMins; + Vector vMaxs; + Entity *pEnt; + Entity *pNext; + + mass = 20 * ( size[ 0 ] * 0.625f * size[ 1 ] * 0.625f * size[ 2 ] * 0.625f ); + + m_vStartAngles = angles; + m_fJitterScale = 64.0f / size[ 2 ]; + + setMoveType( MOVETYPE_PUSH ); + setSolidType( SOLID_BSP ); + + vMins[ 0 ] = mins[ 0 ] + origin[ 0 ] + 12.0f; + vMins[ 1 ] = mins[ 1 ] + origin[ 1 ] + 12.0f; + vMins[ 2 ] = mins[ 2 ] + origin[ 2 ] + 18.0f; + + vMaxs[ 0 ] = maxs[ 0 ] + origin[ 0 ] - 12.0f; + vMaxs[ 1 ] = maxs[ 1 ] + origin[ 1 ] - 12.0f; + vMaxs[ 2 ] = maxs[ 2 ] + origin[ 2 ] - 18.0f; + + for( pEnt = G_NextEntity( NULL ); pEnt != NULL; pEnt = pNext ) + { + pNext = G_NextEntity( pEnt ); + + if( pEnt->entnum > entnum && pEnt->IsSubclassOfCrateObject() ) + { + if( vMins[ 0 ] <= absmax[ 0 ] && + vMins[ 1 ] <= absmax[ 1 ] && + vMins[ 2 ] <= absmax[ 2 ] && + absmin[ 0 ] <= vMaxs[ 0 ] && + absmin[ 1 ] <= vMaxs[ 1 ] && + absmin[ 2 ] <= vMaxs[ 2 ] ) + { + Com_Printf( "^~^~^ WARNING: func_crate entities %i and %i have overlapping volumes near (%g %g %g) to (%g %g %g)\n", + entnum, pEnt->entnum, vMins[ 0 ], vMins[ 1 ], vMins[ 2 ], vMaxs[ 0 ], vMaxs[ 1 ], vMaxs[ 2 ] ); + } + } + } +} + +void CrateObject::CrateDebrisType + ( + Event *ev + ) + +{ + m_iDebrisType = ev->GetInteger( 1 ); + + if( m_iDebrisType >= 0 ) + { + CacheResource( va( "models/fx/crates/debris_%i.tik", m_iDebrisType ) ); + } +} + +void CrateObject::StartFalling + ( + Event *ev + ) + +{ + setMoveType( MOVETYPE_FLY ); + m_fMoveTime = 0; + + PostEvent( EV_Crate_Think, level.frametime ); + + if( !( spawnflags & CRATE_NOTSTACKEDON ) ) + { + TellNeighborsToFall(); + } +} + +void CrateObject::CrateFalling + ( + Event *ev + ) + +{ + if( velocity != vec_zero || !groundentity || edict->solid != SOLID_BSP ) + { + m_fMoveTime = level.time + 2.0f; + } + + if( level.time <= m_fMoveTime ) + { + PostEvent( EV_Crate_Think, level.frametime ); + } + else + { + setMoveType( MOVETYPE_PUSH ); + setSolidType( SOLID_BSP ); + } +} + +void CrateObject::CrateDamaged + ( + Event *ev + ) + +{ + Vector vDir; + Vector vForward; + Vector vRight; + Vector vJitterAdd; + int iDamage; + int iMeansOfDeath; + Vector vHitPos; + Vector vHitDirection; + Vector vHitNormal; + + if( !takedamage ) + { + return; + } + + iDamage = ev->GetInteger( 2 ); + iMeansOfDeath = ev->GetInteger( 9 ); + vHitPos = ev->GetVector( 4 ); + vHitDirection = ev->GetVector( 5 ); + vHitNormal = ev->GetVector( 6 ); + + vDir = ( vHitDirection - vHitNormal ) * 0.5f; + AngleVectors( angles, vForward, vRight, NULL ); + + vJitterAdd[ 0 ] = DotProduct( vDir, vForward ) * m_fJitterScale * 0.025f * ( float )iDamage; + vJitterAdd[ 2 ] = DotProduct( vDir, vRight ) * m_fJitterScale * 0.025f * ( float )iDamage; + + m_vJitterAngles += Vector( vJitterAdd[ 0 ], 0, vJitterAdd[ 2 ] ); + + if( m_vJitterAngles[ 0 ] > m_fJitterScale * 1.25f || + -( m_fJitterScale * 1.25f ) > m_vJitterAngles[ 0 ] ) + { + m_vJitterAngles[ 0 ] = m_fJitterScale * 1.25f; + } + + if( m_vJitterAngles[ 2 ] > m_fJitterScale * 1.25f ) + { + m_vJitterAngles[ 2 ] = m_fJitterScale * 1.25f; + } + else if( m_vJitterAngles[ 2 ] >= -( m_fJitterScale * 1.25f ) ) + { + m_vJitterAngles[ 2 ] = -( m_fJitterScale * 1.25f ); + } + + vJitterAdd[ 1 ] = 0.0f; + vJitterAdd *= -0.5f; + + TellNeighborsToJitter( vJitterAdd ); + + if( !EventPending( EV_Crate_Think ) ) + { + ProcessEvent( EV_Crate_Think ); + } + + if( spawnflags & CRATE_INDESTRUCTABLE ) { + return; + } + + if( iMeansOfDeath >= MOD_VEHICLE ) + { + if( iMeansOfDeath == MOD_BASH ) + { + iDamage *= 2; + } + } + else + { + iDamage /= 2; + } + + health -= iDamage; + + if( health <= 0.0f ) + { + Event *event = new Event( EV_Killed ); + event->AddEntity( ev->GetEntity( 1 ) ); + event->AddInteger( iDamage ); + ev->AddEntity( ev->GetEntity( 3 ) ); + + ProcessEvent( event ); + } +} + +void CrateObject::CrateKilled + ( + Event *ev + ) + +{ + Vector vCenter; + Entity *attacker = ev->GetEntity( 1 ); + + if( attacker->IsSubclassOfPlayer() ) + { + Player *p = ( Player * )attacker; + p->m_iNumObjectsDestroyed++; + } + + setSolidType( SOLID_NOT ); + hideModel(); + + takedamage = DAMAGE_NO; + + if( !( spawnflags & CRATE_NOTSTACKEDON ) ) + { + TellNeighborsToFall(); + } + + vCenter = origin + ( maxs + mins ) * 0.5f; + + // Tell clients around that a crate is destroyed + gi.SetBroadcastVisible( origin, origin ); + gi.MSG_StartCGM( 23 ); + gi.MSG_WriteCoord( vCenter[ 0 ] ); + gi.MSG_WriteCoord( vCenter[ 1 ] ); + gi.MSG_WriteCoord( vCenter[ 2 ] ); + gi.MSG_WriteByte( m_iDebrisType ); + gi.MSG_EndCGM(); + + health = 0; + deadflag = DEAD_DEAD; + + PostEvent( EV_Remove, 0 ); + + // Notify scripts + Unregister( STRING_DEATH ); +} + +void CrateObject::CrateThink + ( + Event *ev + ) + +{ + // Shake the create if it's on fire + + if( m_vJitterAngles[ 0 ] || m_vJitterAngles[ 2 ] ) + { + setAngles( Vector( m_vStartAngles[ 0 ] * 2.0f, m_vStartAngles[ 1 ], m_vStartAngles[ 2 ] * 2.0f ) ); + + if( m_vJitterAngles[ 0 ] > 0.0f ) + { + m_vJitterAngles[ 0 ] -= 1 / 3 * m_fJitterScale; + + if( m_vJitterAngles[ 0 ] > 0.0f ) + { + m_vJitterAngles[ 0 ] = 0.0f; + } + } + else if( m_vJitterAngles[ 0 ] < 0.0f ) + { + m_vJitterAngles[ 0 ] += 1 / 3 * m_fJitterScale; + + if( m_vJitterAngles[ 0 ] < 0.0f ) + { + m_vJitterAngles[ 0 ] = 0.0f; + } + } + + m_vJitterAngles[ 0 ] = -m_vJitterAngles[ 0 ]; + + if( m_vJitterAngles[ 2 ] > 0.0f ) + { + m_vJitterAngles[ 2 ] -= 1 / 3 * m_fJitterScale; + + if( m_vJitterAngles[ 2 ] > 0.0f ) + { + m_vJitterAngles[ 2 ] = 0.0f; + } + } + else if( m_vJitterAngles[ 2 ] < 0.0f ) + { + m_vJitterAngles[ 2 ] += 1 / 3 * m_fJitterScale; + + if( m_vJitterAngles[ 2 ] < 0.0f ) + { + m_vJitterAngles[ 2 ] = 0.0f; + } + } + + m_vJitterAngles[ 2 ] = -m_vJitterAngles[ 2 ]; + + PostEvent( EV_Crate_Think, 0.05f ); + } + else if( !VectorCompare( angles, m_vStartAngles ) ) + { + setAngles( m_vStartAngles ); + } +} diff --git a/code/game/crateobject.h b/code/game/crateobject.h new file mode 100644 index 00000000..84a63645 --- /dev/null +++ b/code/game/crateobject.h @@ -0,0 +1,75 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// crateobject.h : Crates + +#ifndef __CRATEOBJECT_H__ +#define __CRATEOBJECT_H__ + +#include "entity.h" + +#define CRATE_INDESTRUCTABLE 1 +#define CRATE_NOTSTACKEDON 2 + +class CrateObject : public Entity { + float m_fMoveTime; + int m_iDebrisType; + Vector m_vJitterAngles; + Vector m_vStartAngles; + float m_fJitterScale; + +private: + void TellNeighborsToFall( void ); + void TellNeighborsToJitter( Vector vJitterAdd ); + +public: + CLASS_PROTOTYPE( CrateObject ); + + CrateObject(); + + void CrateSetup( Event *ev ); + void CrateDebrisType( Event *ev ); + void StartFalling( Event *ev ); + void CrateFalling( Event *ev ); + void CrateDamaged( Event *ev ); + void CrateKilled( Event *ev ); + void CrateThink( Event *ev ); + virtual void Archive( Archiver& arc ); +}; + +inline void CrateObject::Archive + ( + Archiver& arc + ) + +{ + Entity::Archive( arc ); + + arc.ArchiveFloat( &m_fMoveTime ); + arc.ArchiveInteger( &m_iDebrisType ); + + arc.ArchiveVector( &m_vJitterAngles ); + arc.ArchiveVector( &m_vStartAngles ); + arc.ArchiveFloat( &m_fJitterScale ); +} + +#endif // __CRATEOBJECT_H__ diff --git a/code/game/debuglines.cpp b/code/game/debuglines.cpp new file mode 100644 index 00000000..1901729a --- /dev/null +++ b/code/game/debuglines.cpp @@ -0,0 +1,876 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// debuglines.cpp: +// + +#include "debuglines.h" + +#define NUM_CIRCLE_SEGMENTS 24 + +debugline_t *DebugLines = NULL; +debugstring_t *DebugStrings = NULL; +Vector currentVertex( 0, 0, 0 ); +Vector vertColor( 1, 1, 1 ); +float vertAlpha = 1; +float vertexIndex = 0; +float linewidth = 1; +unsigned short lineStippleFactor = 1; +unsigned short linePattern = 0xffff; +int g_iFirstLine; +int g_iCurrFrameLineCounter; +int g_iFrameLineCount[ 100 ]; + +void G_InitDebugLines + ( + void + ) + +{ + if( g_numdebuglinedelays->integer <= 0 ) + { + *gi.DebugLines = DebugLines; + *gi.numDebugLines = 0; + g_iFirstLine = 0; + + for( int i = 0; i < 100; i++ ) + { + g_iFrameLineCount[ i ] = 0; + } + + g_iCurrFrameLineCounter = 0; + } + else + { + int iNumDelays = g_numdebuglinedelays->integer; + int iCount; + + if( iNumDelays > 99 ) + iNumDelays = 99; + + iCount = g_iFrameLineCount[ ( g_iCurrFrameLineCounter - iNumDelays + 100 ) % 100 ]; + if( iCount ) + { + g_iFirstLine += iCount; + *gi.numDebugLines -= iCount; + g_iFrameLineCount[ ( g_iCurrFrameLineCounter - iNumDelays + 100 ) % 100 ] = 0; + } + + g_iCurrFrameLineCounter = ( g_iCurrFrameLineCounter + 1 ) % 100; + *gi.DebugLines = &DebugLines[ g_iFirstLine ]; + } + + currentVertex = vec_zero; + vertColor = Vector( 1, 1, 1 ); + vertAlpha = 1; + vertexIndex = 0; + + linewidth = 1; + lineStippleFactor = 1; + linePattern = 0xffff; +} + +void G_InitDebugStrings + ( + void + ) + +{ + *gi.DebugStrings = DebugStrings; + *gi.numDebugStrings = 0; +} + +void G_AllocDebugLines + ( + void + ) + +{ + // we do a malloc here so that we don't interfere with the game's memory footprint + DebugLines = ( debugline_t * )malloc( ( int )g_numdebuglines->integer * sizeof( debugline_t ) ); + + G_InitDebugLines(); + + for( int i = 0; i < 100; i++ ) + { + g_iFrameLineCount[ i ] = 0; + } + + g_iCurrFrameLineCounter = 0; +} + +void G_AllocDebugStrings + ( + void + ) + +{ + DebugStrings = ( debugstring_t * )malloc( ( int )g_numdebugstrings->integer * sizeof( debugstring_t ) ); + + G_InitDebugStrings(); +} + +void G_DeAllocDebugLines + ( + void + ) + +{ + if( DebugLines ) + { + // we do a free here, because we used malloc above + free( DebugLines ); + DebugLines = NULL; + *gi.DebugLines = DebugLines; + *gi.numDebugLines = 0; + } +} + +void G_ShiftDebugLines + ( + void + ) + +{ + int iNewPos; + int iOldPos; + + for( iNewPos = 0; iNewPos < *gi.numDebugLines && iNewPos < g_numdebuglines->integer; iNewPos++ ) + { + iOldPos = g_iFirstLine + iNewPos; + + DebugLines[ iNewPos ] = DebugLines[ iOldPos ]; + } + + g_iFirstLine = 0; + *gi.DebugLines = DebugLines; +} + +void G_DeAllocDebugStrings + ( + void + ) + +{ + if( DebugStrings ) + { + // we do a free here, because we used malloc above + free( DebugStrings ); + DebugStrings = NULL; + *gi.DebugStrings = DebugStrings; + *gi.numDebugStrings = 0; + } +} + +void G_DebugLine + ( + Vector start, + Vector end, + float r, + float g, + float b, + float alpha + ) + +{ + debugline_t *line; + static int printTime = 0; + + if( !g_numdebuglines->integer ) + { + return; + } + + if( *gi.numDebugLines >= g_numdebuglines->integer ) + { + if( level.svsTime >= printTime ) + { + printTime = level.svsTime + 5000; + gi.DPrintf( "G_DebugLine: Exceeded MAX_DEBUG_LINES\n" ); + } + + return; + } + + if( g_numdebuglinedelays->integer > 0 && g_iFirstLine > 0 && g_iFirstLine + *gi.numDebugLines + 1 >= g_numdebuglines->integer ) + { + G_ShiftDebugLines(); + } + + line = &DebugLines[ *gi.numDebugLines ]; + ( *gi.numDebugLines )++; + g_iFrameLineCount[ g_iCurrFrameLineCounter ]++; + + VectorCopy( start, line->start ); + VectorCopy( end, line->end ); + VectorSet( line->color, r, g, b ); + line->alpha = alpha; + + line->width = linewidth; + line->factor = lineStippleFactor; + line->pattern = linePattern; +} + +void G_LineStipple + ( + int factor, + unsigned short pattern + ) + + { + lineStippleFactor = factor; + linePattern = pattern; + } + +void G_LineWidth + ( + float width + ) + + { + linewidth = width; + } + +void G_Color3f + ( + float r, + float g, + float b + ) + + { + vertColor = Vector( r, g, b ); + } + +void G_Color3v + ( + Vector color + ) + + { + vertColor = color; + } + +void G_Color4f + ( + float r, + float g, + float b, + float alpha + ) + + { + vertColor = Vector( r, g, b ); + vertAlpha = alpha; + } + +void G_Color3vf + ( + Vector color, + float alpha + ) + + { + vertColor = color; + vertAlpha = alpha; + } + +void G_BeginLine + ( + void + ) + + { + currentVertex = vec_zero; + vertexIndex = 0; + } + +void G_Vertex + ( + Vector v + ) + + { + vertexIndex++; + if ( vertexIndex > 1 ) + { + G_DebugLine( currentVertex, v, vertColor[ 0 ], vertColor[ 1 ], vertColor[ 2 ], vertAlpha ); + } + currentVertex = v; + } + +void G_EndLine + ( + void + ) + + { + currentVertex = vec_zero; + vertexIndex = 0; + } + +void G_DebugBBox + ( + Vector org, + Vector mins, + Vector maxs, + float r, + float g, + float b, + float alpha + ) + { + int i; + Vector points[8]; + + /* + ** compute a full bounding box + */ + for ( i = 0; i < 8; i++ ) + { + Vector tmp; + + if ( i & 1 ) + tmp[0] = org[0] + mins[0]; + else + tmp[0] = org[0] + maxs[0]; + + if ( i & 2 ) + tmp[1] = org[1] + mins[1]; + else + tmp[1] = org[1] + maxs[1]; + + if ( i & 4 ) + tmp[2] = org[2] + mins[2]; + else + tmp[2] = org[2] + maxs[2]; + + points[i] = tmp; + } + + G_Color4f( r, g, b, alpha ); + + G_BeginLine(); + G_Vertex( points[0] ); + G_Vertex( points[1] ); + G_Vertex( points[3] ); + G_Vertex( points[2] ); + G_Vertex( points[0] ); + G_EndLine(); + + G_BeginLine(); + G_Vertex( points[4] ); + G_Vertex( points[5] ); + G_Vertex( points[7] ); + G_Vertex( points[6] ); + G_Vertex( points[4] ); + G_EndLine(); + + for ( i = 0; i < 4; i++ ) + { + G_BeginLine(); + G_Vertex( points[i] ); + G_Vertex( points[4 + i] ); + G_EndLine(); + } + } + +// +// LED style digits +// +// ****1*** +// * * 8 == / +// 6 *4 +// * * * +// ****2*** +// * * * +// 7 *--8 5 9 +// ** * **10 +// ****3*** 12** +// 11 + +static int Numbers[ 12 ][ 8 ] = + { + { 1, 3, 4, 5, 6, 7, 0, 0 }, // 0 + { 4, 5, 0, 0, 0, 0, 0, 0 }, // 1 + { 1, 4, 2, 7, 3, 0, 0, 0 }, // 2 + { 1, 4, 2, 5, 3, 0, 0, 0 }, // 3 + { 6, 4, 2, 5, 0, 0, 0, 0 }, // 4 + { 1, 6, 2, 5, 3, 0, 0, 0 }, // 5 + { 1, 6, 2, 5, 7, 3, 0, 0 }, // 6 + { 1, 8, 0, 0, 0, 0, 0, 0 }, // 7 + { 1, 2, 3, 4, 5, 6, 7, 0 }, // 8 + { 1, 6, 4, 2, 5, 3, 0, 0 }, // 9 + { 9, 10, 11, 12, 0, 0, 0, 0 }, // . + { 2, 0, 0, 0, 0, 0, 0, 0 }, // - + }; + +static float Lines[ 13 ][ 4 ] = + { + { 0, 0, 0, 0 }, // Unused + { -4, 8, 4, 8 }, // 1 + { -4, 4, 4, 4 }, // 2 + { -4, 0, 4, 0 }, // 3 + { 4, 8, 4, 4 }, // 4 + { 4, 4, 4, 0 }, // 5 + { -4, 8, -4, 4 }, // 6 + { -4, 4, -4, 0 }, // 7 + { 4, 8, -4, 0 }, // 8 + + { -1, 2, 1, 2 }, // 9 + { 1, 2, 1, 0 }, // 10 + { -1, 0, 1, 0 }, // 11 + { -1, 0, -1, 2 }, // 12 + }; + +void G_DrawDebugNumber + ( + Vector org, + float number, + float scale, + float r, + float g, + float b, + int precision + ) + +{ + int i; + int j; + int l; + int num; + Vector up; + Vector left; + Vector pos; + Vector start; + Vector ang; + str text; + Vector delta; + char format[ 20 ]; + + // only draw entity numbers within a certain radius + delta = Vector( g_entities[ 0 ].s.origin ) - org; + if( ( delta * delta ) > ( 1000 * 1000 ) ) + { + return; + } + + G_Color4f( r, g, b, 1.0 ); + + ang = game.clients[ 0 ].ps.viewangles; + ang.AngleVectorsLeft( NULL, &left, &up ); + + up *= scale; + left *= scale; + + if( precision > 0 ) + { + sprintf( format, "%%.%df", precision ); + text = va( format, number ); + } + else + { + text = va( "%d", ( int )number ); + } + + start = org + ( text.length() - 1 ) * 5 * left; + + for( i = 0; i < text.length(); i++ ) + { + if( text[ i ] == '.' ) + { + num = 10; + } + else if( text[ i ] == '-' ) + { + num = 11; + } + else + { + num = text[ i ] - '0'; + } + + for( j = 0; j < 8; j++ ) + { + l = Numbers[ num ][ j ]; + if( l == 0 ) + { + break; + } + + G_BeginLine(); + + pos = start - Lines[ l ][ 0 ] * left + Lines[ l ][ 1 ] * up; + G_Vertex( pos ); + + pos = start - Lines[ l ][ 2 ] * left + Lines[ l ][ 3 ] * up; + G_Vertex( pos ); + + G_EndLine(); + } + + start -= 10 * left; + } +} + +void G_DebugCircle + ( + float *org, + float radius, + float r, + float g, + float b, + float alpha, + qboolean horizontal + ) + { + int i; + float ang; + Vector angles; + Vector forward; + Vector left; + Vector pos; + Vector delta; + + // only draw circles within a certain radius + delta = Vector( g_entities[ 0 ].s.origin ) - org; + if ( ( delta * delta ) > ( ( 1000 + radius ) * ( 1000 + radius ) ) ) + { + return; + } + + G_Color4f( r, g, b, alpha ); + + if ( horizontal ) + { + forward = "1 0 0"; + left = "0 -1 0"; + } + else + { + angles = game.clients[ 0 ].ps.viewangles; + angles.AngleVectors( NULL, &left, &forward ); + } + + G_BeginLine(); + for( i = 0; i <= NUM_CIRCLE_SEGMENTS; i++ ) + { + ang = DEG2RAD( i * 360 / NUM_CIRCLE_SEGMENTS ); + pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); + G_Vertex( pos ); + } + G_EndLine(); + } + +void G_DebugOrientedCircle + ( + Vector org, + float radius, + float r, + float g, + float b, + float alpha, + Vector angles + ) + { + int i; + float ang; + Vector forward; + Vector left; + Vector pos; + Vector delta; + + // only draw circles within a certain radius + delta = Vector( g_entities[ 0 ].s.origin ) - org; + if ( ( delta * delta ) > ( ( 1000 + radius ) * ( 1000 + radius ) ) ) + { + return; + } + + G_Color4f( r, g, b, alpha ); + + angles.AngleVectors( NULL, &left, &forward ); + + G_BeginLine(); + for( i = 0; i <= NUM_CIRCLE_SEGMENTS; i++ ) + { + ang = DEG2RAD( i * 360 / NUM_CIRCLE_SEGMENTS ); + pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); + G_Vertex( pos ); + } + G_EndLine(); + + // + // Draw the cross sign + // + G_BeginLine(); + ang = DEG2RAD( 45 * 360 / NUM_CIRCLE_SEGMENTS ); + pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); + G_Vertex( pos ); + ang = DEG2RAD( 225 * 360 / NUM_CIRCLE_SEGMENTS ); + pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); + G_Vertex( pos ); + + G_BeginLine(); + ang = DEG2RAD( 315 * 360 / NUM_CIRCLE_SEGMENTS ); + pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); + G_Vertex( pos ); + ang = DEG2RAD( 135 * 360 / NUM_CIRCLE_SEGMENTS ); + pos = org + ( sin( ang ) * radius * forward ) - ( cos( ang ) * radius * left ); + G_Vertex( pos ); + } + +void G_DebugPyramid + ( + Vector org, + float radius, + float r, + float g, + float b, + float alpha + ) + { + Vector delta; + Vector points[ 4 ]; + + // only draw pyramids within a certain radius + delta = Vector( g_entities[ 0 ].s.origin ) - org; + if ( ( delta * delta ) > ( ( 1000 + radius ) * ( 1000 + radius ) ) ) + { + return; + } + + G_Color4f( r, g, b, alpha ); + + points[ 0 ] = org; + points[ 0 ].z += radius; + + points[ 1 ] = org; + points[ 1 ].z -= radius; + points[ 2 ] = points[ 1 ]; + points[ 3 ] = points[ 1 ]; + + points[ 1 ].x += cos( DEG2RAD( 0 ) ) * radius; + points[ 1 ].y += sin( DEG2RAD( 0 ) ) * radius; + points[ 2 ].x += cos( DEG2RAD( 120 ) ) * radius; + points[ 2 ].y += sin( DEG2RAD( 120 ) ) * radius; + points[ 3 ].x += cos( DEG2RAD( 240 ) ) * radius; + points[ 3 ].y += sin( DEG2RAD( 240 ) ) * radius; + + G_BeginLine(); + G_Vertex( points[ 0 ] ); + G_Vertex( points[ 1 ] ); + G_Vertex( points[ 2 ] ); + G_Vertex( points[ 0 ] ); + G_EndLine(); + + G_BeginLine(); + G_Vertex( points[ 0 ] ); + G_Vertex( points[ 2 ] ); + G_Vertex( points[ 3 ] ); + G_Vertex( points[ 0 ] ); + G_EndLine(); + + G_BeginLine(); + G_Vertex( points[ 0 ] ); + G_Vertex( points[ 3 ] ); + G_Vertex( points[ 1 ] ); + G_Vertex( points[ 0 ] ); + G_EndLine(); + + G_BeginLine(); + G_Vertex( points[ 1 ] ); + G_Vertex( points[ 2 ] ); + G_Vertex( points[ 3 ] ); + G_Vertex( points[ 1 ] ); + G_EndLine(); + } + +void G_DrawCoordSystem + ( + Vector pos, + Vector forward, + Vector right, + Vector up, + int length + ) + + { + if ( g_showaxis->integer ) + { + G_DebugLine( pos, pos + forward * length, 1,0,0,1 ); + G_DebugLine( pos, pos + right * length, 0,1,0,1 ); + G_DebugLine( pos, pos + up * length, 0,0,1,1 ); + } + } + +void G_DrawCSystem + ( + Vector pos, + Vector forward, + Vector right, + Vector up, + int length + ) + +{ + G_DebugLine( pos, pos + forward * length, 1.0, 0, 0, 1 ); + G_DebugLine( pos, pos + right * length, 0, 1.0, 0, 1 ); + G_DebugLine( pos, pos + up * length, 0, 0, 1.0, 1 ); +} + +void G_DebugArrow + ( + Vector org, + Vector dir, + float length, + float r, + float g, + float b, + float alpha + ) + { + Vector right; + Vector up; + Vector startpoint; + Vector endpoint; + + PerpendicularVector( right, dir ); + up.CrossProduct( right, dir ); + + startpoint = org; + + endpoint = startpoint + dir * length; + length /= 6; + G_DebugLine( startpoint, endpoint, r, g, b, alpha ); + G_DebugLine( endpoint, endpoint - (right * length) - (dir * length), r, g, b, alpha ); + G_DebugLine( endpoint, endpoint + (right * length) - (dir * length), r, g, b, alpha ); + G_DebugLine( endpoint, endpoint - (up * length) - (dir * length), r, g, b, alpha ); + G_DebugLine( endpoint, endpoint + (up * length) - (dir * length), r, g, b, alpha ); + } + +void G_DebugHighlightFacet + ( + Vector org, + Vector mins, + Vector maxs, + facet_t facet, + float r, + float g, + float b, + float alpha + ) + { + int i; + Vector points[8]; + + /* + ** compute a full bounding box + */ + for ( i = 0; i < 8; i++ ) + { + Vector tmp; + + if ( i & 1 ) + tmp[0] = org[0] + mins[0]; + else + tmp[0] = org[0] + maxs[0]; + + if ( i & 2 ) + tmp[1] = org[1] + mins[1]; + else + tmp[1] = org[1] + maxs[1]; + + if ( i & 4 ) + tmp[2] = org[2] + mins[2]; + else + tmp[2] = org[2] + maxs[2]; + + points[i] = tmp; + } + + G_Color4f( r, g, b, alpha ); + + switch( facet ) + { + case north: + G_BeginLine(); + G_Vertex( points[0] ); + G_Vertex( points[5] ); + G_EndLine(); + G_BeginLine(); + G_Vertex( points[1] ); + G_Vertex( points[4] ); + G_EndLine(); + break; + case south: + G_BeginLine(); + G_Vertex( points[2] ); + G_Vertex( points[7] ); + G_EndLine(); + G_BeginLine(); + G_Vertex( points[3] ); + G_Vertex( points[6] ); + G_EndLine(); + break; + case east: + G_BeginLine(); + G_Vertex( points[0] ); + G_Vertex( points[6] ); + G_EndLine(); + G_BeginLine(); + G_Vertex( points[4] ); + G_Vertex( points[2] ); + G_EndLine(); + break; + case west: + G_BeginLine(); + G_Vertex( points[1] ); + G_Vertex( points[7] ); + G_EndLine(); + G_BeginLine(); + G_Vertex( points[5] ); + G_Vertex( points[3] ); + G_EndLine(); + break; + case up: + G_BeginLine(); + G_Vertex( points[0] ); + G_Vertex( points[3] ); + G_EndLine(); + G_BeginLine(); + G_Vertex( points[1] ); + G_Vertex( points[2] ); + G_EndLine(); + break; + case down: + G_BeginLine(); + G_Vertex( points[4] ); + G_Vertex( points[7] ); + G_EndLine(); + G_BeginLine(); + G_Vertex( points[5] ); + G_Vertex( points[6] ); + G_EndLine(); + break; + } + } diff --git a/code/game/debuglines.h b/code/game/debuglines.h new file mode 100644 index 00000000..35d51e30 --- /dev/null +++ b/code/game/debuglines.h @@ -0,0 +1,71 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// debuglines.h: + +#ifndef __DEBUGLINES_H__ +#define __DEBUGLINES_H__ + +#include "g_local.h" + +void G_InitDebugLines( void ); +void G_InitDebugStrings( void ); +void G_DebugLine( Vector start, Vector end, float r, float g, float b, float alpha ); +void G_LineStipple( int factor, unsigned short pattern ); +void G_LineWidth( float width ); +void G_Color3f( float r, float g, float b ); +void G_Color3v( Vector color ); +void G_Color4f( float r, float g, float b, float alpha ); +void G_Color3vf( Vector color, float alpha ); +void G_BeginLine( void ); +void G_Vertex( Vector v ); +void G_EndLine( void ); +void G_DebugBBox( Vector org, Vector mins, Vector maxs, float r, float g, float b, float alpha ); +void G_DrawDebugNumber( Vector org, float number, float scale, float r, float g, float b, int precision = 0 ); +void G_DebugCircle( float *org, float radius, float r, float g, float b, float alpha, qboolean horizontal = false ); +void G_DebugOrientedCircle( Vector org, float radius, float r, float g, float b, float alpha, Vector angles ); +void G_DebugPyramid( Vector org, float radius, float r, float g, float b, float alpha ); +void G_DrawCoordSystem( Vector pos, Vector f, Vector r, Vector u, int len ); +void G_DebugArrow( Vector org, Vector dir, float length, float r, float g, float b, float alpha ); +void G_DrawCSystem( Vector pos, Vector forward, Vector right, Vector up, int length ); +void G_AllocDebugLines( void ); +void G_AllocDebugStrings( void ); +void G_DeAllocDebugLines( void ); +void G_DeAllocDebugStrings( void ); +void G_ShiftDebugLines( void ); + +typedef enum + { + north, + south, + east, + west, + up, + down + } facet_t; + +void G_DebugHighlightFacet( Vector org, Vector mins, Vector maxs, facet_t facet, float r, float g, float b, float alpha ); + +extern debugline_t *DebugLines; +extern debugstring_t *DebugStrings; + +#endif /* !__DEBUGLINES_H__ */ diff --git a/code/game/decals.cpp b/code/game/decals.cpp new file mode 100644 index 00000000..555bf06d --- /dev/null +++ b/code/game/decals.cpp @@ -0,0 +1,91 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// decals.cpp: Decal entities + +#include "decals.h" + + +CLASS_DECLARATION( Entity, Decal, NULL ) + { + { NULL, NULL } + }; + +Decal::Decal + ( + ) + + { + edict->s.eType = ET_DECAL; + edict->s.modelindex = 1; // must be non-zero + PostEvent( EV_Remove, FRAMETIME ); + } + +void Decal::setDirection + ( + Vector dir + ) + + { + edict->s.surfaces[0] = DirToByte( dir ); + } + +void Decal::setShader + ( + str decal_shader + ) + + { + str temp_shader; + + shader = decal_shader; + edict->s.tag_num = gi.imageindex( shader.c_str() ); + + temp_shader = shader + ".spr"; + CacheResource( temp_shader ); + } + +void Decal::setOrientation + ( + str deg + ) + + { + Vector ang; + + if ( !deg.icmp( "random" ) ) + ang[2] = random() * 360; + else + ang[2] = atof( deg ); + + setAngles( ang ); + } + +void Decal::setRadius + ( + float rad + ) + + { + edict->s.scale = rad; + } + diff --git a/code/game/decals.h b/code/game/decals.h new file mode 100644 index 00000000..9a20e56d --- /dev/null +++ b/code/game/decals.h @@ -0,0 +1,61 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// decals.h: Decal entities + +#ifndef __DECAL_H__ +#define __DECAL_H__ + +#include "g_local.h" +#include "entity.h" + +class Decal : public Entity + { + private: + str shader; + + public: + CLASS_PROTOTYPE( Decal ); + + Decal(); + void setDirection( Vector dir ); + void setShader( str shader ); + void setOrientation( str deg ); + void setRadius( float rad ); + virtual void Archive( Archiver &arc ); + }; + +inline void Decal::Archive + ( + Archiver &arc + ) + { + Entity::Archive( arc ); + + arc.ArchiveString( &shader ); + if ( arc.Loading() ) + { + setShader( shader ); + } + } + +#endif // __DECAL_H__ diff --git a/code/game/dm_manager.cpp b/code/game/dm_manager.cpp new file mode 100644 index 00000000..62035031 --- /dev/null +++ b/code/game/dm_manager.cpp @@ -0,0 +1,1304 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// dm_manager.cpp: Deathmatch Manager. + +#include "player.h" +#include "dm_manager.h" +#include "dm_team.h" +#include "PlayerStart.h" + +cvar_t *g_tempaxisscore; +cvar_t *g_tempaxiswinsinrow; +cvar_t *g_tempalliesscore; +cvar_t *g_tempallieswinsinrow; + +DM_Manager dmManager; + +Event EV_DM_Manager_DoRoundTransition +( + "doroundtransition", + EV_DEFAULT, + NULL, + NULL, + "delayed function call to (possibly) determine round winner and restart next round" +); +Event EV_DM_Manager_FinishRoundTransition +( + "finishroundtransition", + EV_DEFAULT, + NULL, + NULL, + "delayed function call to do the actual restart for the next round" +); + +CLASS_DECLARATION( Listener, DM_Manager, NULL ) +{ + { &EV_DM_Manager_DoRoundTransition, &DM_Manager::EventDoRoundTransition }, + { &EV_DM_Manager_FinishRoundTransition, &DM_Manager::EventFinishRoundTransition }, + { NULL, NULL } +}; + +DM_Manager::DM_Manager() +{ + m_team_spectator.m_maxplayers = MAX_CLIENTS; + m_team_spectator.setName( "spectator" ); + m_team_spectator.setNumber( TEAM_SPECTATOR ); + m_team_spectator.teamType = TEAM_SPECTATOR; + + m_team_freeforall.m_maxplayers = MAX_CLIENTS; + m_team_freeforall.setName( "free-for-all" ); + m_team_freeforall.setNumber( TEAM_FREEFORALL ); + m_team_freeforall.teamType = TEAM_FREEFORALL; + + m_team_allies.m_maxplayers = MAX_CLIENTS; + m_team_allies.setName( "allies" ); + m_team_allies.setNumber( TEAM_ALLIES ); + m_team_allies.teamType = TEAM_ALLIES; + + m_team_axis.m_maxplayers = MAX_CLIENTS; + m_team_axis.setName( "axis" ); + m_team_axis.setNumber( TEAM_AXIS ); + m_team_axis.teamType = TEAM_AXIS; + + m_iTeamWin = 0; + m_csTeamClockSide = STRING_AXIS; + m_csTeamBombPlantSide = STRING_DRAW; + m_fRoundEndTime = 0.0f; + m_bAllowRespawns = qtrue; + m_bRoundBasedGame = qfalse; + m_iDefaultRoundLimit = 0; + m_iNumTargetsToDestroy = 0; + m_iNumTargetsDestroyed = 0; + m_iNumBombsPlanted = 0; +} + +DM_Manager::~DM_Manager() +{ + +} + +DM_Team *DM_Manager::GetTeam( str name ) +{ + if ( name.icmp( "spectator" ) == 0 ) { + return &m_team_spectator; + } else if ( name.icmp( "freeforall" ) == 0 ) { + return &m_team_freeforall; + } else if ( name.icmp( "allies" ) == 0 ) { + return &m_team_allies; + } else if ( name.icmp( "axis" ) == 0 ) { + return &m_team_axis; + } else { + ScriptError( "Invalid team %s !\n", name.c_str() ); + } + + return NULL; +} + +DM_Team *DM_Manager::GetTeam( teamtype_t team ) +{ + switch( team ) + { + case TEAM_NONE: + case TEAM_SPECTATOR: + return &m_team_spectator; + + case TEAM_FREEFORALL: + return &m_team_freeforall; + + case TEAM_ALLIES: + return &m_team_allies; + + case TEAM_AXIS: + return &m_team_axis; + + default: + return NULL; + } +} + +DM_Team *DM_Manager::GetTeamAllies( void ) +{ + return &m_team_allies; +} + +DM_Team *DM_Manager::GetTeamAxis( void ) +{ + return &m_team_axis; +} + +bool DM_Manager::JoinTeam( Player *player, teamtype_t teamType ) +{ + DM_Team *team = player->GetDM_Team(); + DM_Team *pDMTeam = GetTeam( teamType ); + + if( !pDMTeam ) + { + return false; + } + + if( pDMTeam->m_players.NumObjects() >= pDMTeam->m_maxplayers ) + { + gi.centerprintf( player->edict, gi.LV_ConvertString( "That team is full" ) ); + return false; + } + + if( team ) + { + LeaveTeam( player ); + } + + pDMTeam->AddPlayer( player ); + AddPlayer( player ); + player->SetDM_Team( pDMTeam ); + + if( teamType == TEAM_SPECTATOR ) { + player->EndFight(); + } else { + player->BeginFight(); + } + + return true; +} + +void DM_Manager::LeaveTeam( Player *player ) +{ + DM_Team *team = player->GetDM_Team(); + + if( team ) + { + if( team->m_players.IndexOfObject( player ) ) + { + team->RemovePlayer( player ); + RemovePlayer( player ); + player->SetDM_Team( NULL ); + RebuildTeamConfigstrings(); + } + else + { + warning( "DM_Manager::LeaveTeam", "Could not find team in the arena\n"); + } + } + else + { + warning( "DM_Manager::LeaveTeam", "Could not find a team for this player\n" ); + } +} + +Player *DM_Manager::GetPlayer( int num ) +{ + return m_players.ObjectAt( num ); +} + +void DM_Manager::InitGame( void ) +{ + m_teams.ClearObjectList(); + + m_teams.AddObject( &m_team_spectator ); + + if( g_gametype->integer >= GT_TEAM ) + { + m_teams.AddObject( &m_team_allies ); + m_teams.AddObject( &m_team_axis ); + } + else + { + m_teams.AddObject( &m_team_freeforall ); + } + + m_team_spectator.InitSpawnPoints(); + m_team_allies.InitSpawnPoints(); + m_team_axis.InitSpawnPoints(); + m_team_freeforall.InitSpawnPoints(); + + if( g_gametype->integer < 0 || g_gametype->integer >= GT_MAX_GAME_TYPE ) + { + Com_Printf( "Unknown game mode" ); + } + + m_bIgnoringClockForBomb = false; + m_fRoundTime = 0; + m_fRoundEndTime = 0; + m_iTeamWin = 0; + m_iNumBombsPlanted = 0; + + if( g_gametype->integer >= 0 && g_gametype->integer < GT_MAX_GAME_TYPE ) + { + if( g_gametype->integer <= GT_TEAM ) + { + m_bAllowRespawns = qtrue; + m_bRoundBasedGame = qfalse; + } + else + { + m_bAllowRespawns = qfalse; + m_bRoundBasedGame = qtrue; + + g_tempaxisscore = gi.Cvar_Get( "g_tempaxisscore", "0", 0 ); + g_tempaxiswinsinrow = gi.Cvar_Get( "g_tempaxiswinsinrow", "0", 0 ); + g_tempalliesscore = gi.Cvar_Get( "g_tempalliesscore", "0", 0 ); + g_tempallieswinsinrow = gi.Cvar_Get( "g_tempallieswinsinrow", "0", 0 ); + + m_team_axis.m_teamwins = g_tempaxisscore->integer; + m_team_axis.m_wins_in_a_row = g_tempaxiswinsinrow->integer; + m_team_allies.m_teamwins = g_tempalliesscore->integer; + m_team_allies.m_wins_in_a_row = g_tempallieswinsinrow->integer; + + gi.Cvar_Set( "g_tempaxisscore", "0" ); + gi.Cvar_Set( "g_tempaxiswinsinrow", "0" ); + gi.Cvar_Set( "g_tempalliesscore", "0" ); + gi.Cvar_Set( "g_tempaxiswinsinrow", "0" ); + + m_iTotalMapTime = gi.Cvar_Get( "g_tempmaptime", "0", 0 )->integer; + gi.Cvar_Set( "g_tempmaptime", "0" ); + } + } +} + +void DM_Manager::AddPlayer( Player *player ) +{ + m_players.AddUniqueObject( player ); +} + +void DM_Manager::RemovePlayer( Player *player ) +{ + DM_Team *pDMTeam; + + m_players.RemoveObject( player ); + + for( int i = m_teams.NumObjects(); i > 0; i-- ) + { + pDMTeam = m_teams.ObjectAt( i ); + + if( pDMTeam->m_players.IndexOfObject( player ) ) + { + pDMTeam->RemovePlayer( player ); + + if( !pDMTeam->m_players.NumObjects() ) { + pDMTeam->m_bHasSpawnedPlayers = qfalse; + } + } + } + + player->SetDM_Team( NULL ); + + RebuildTeamConfigstrings(); +} + +int DM_Manager::compareScores( const void *elem1, const void *elem2 ) +{ + if( *( int * )elem1 < -1 || *( int * )elem2 < 0 ) + { + return 0; + } + + Player *p1 = ( Player * )G_GetEntity( *( int * )elem1 ); + Player *p2 = ( Player * )G_GetEntity( *( int * )elem2 ); + + if( p1->GetNumKills() < p2->GetNumKills() ) + { + return 1; + } + else if( p1->GetNumKills() == p2->GetNumKills() ) + { + // sort by death if they have the same number of kills + if( p1->GetNumDeaths() < p2->GetNumDeaths() ) + { + return 1; + } + else if( p1->GetNumDeaths() == p2->GetNumDeaths() ) + { + // sort by netname if they have the same number of deaths + return Q_stricmp( p1->client->pers.netname, p2->client->pers.netname ); + } + else if( p1->GetNumDeaths() > p2->GetNumDeaths() ) + { + return -1; + } + } + else if( p1->GetNumKills() > p2->GetNumKills() ) + { + return -1; + } + + // just to avoid the compiler warning + // shouldn't go there + return 0; +} + +void DM_Manager::InsertEntry( const char *entry ) +{ + int len = strlen( entry ); + + if( scoreLength + len < MAX_STRING_CHARS ) + { + strcpy( scoreString + scoreLength, entry ); + + scoreLength += len; + scoreEntries++; + } +} + +void DM_Manager::InsertEmpty( void ) +{ + if( g_gametype->integer > GT_FFA ) + { + InsertEntry( "-2 \"\" \"\" \"\" \"\" \"\" " ); + } + else + { + InsertEntry( "-1 \"\" \"\" \"\" \"\" " ); + } +} + +void DM_Manager::BuildTeamInfo( DM_Team *dmTeam ) +{ + int iPing = 0; + int iKills; + int iDeaths; + int iNumPlayers = 0; + Player *pTeamPlayer; + char entry[ MAX_STRING_TOKENS ]; + + for( int i = iNumPlayers; i > 0; i-- ) + { + pTeamPlayer = dmTeam->m_players.ObjectAt( i ); + + if( pTeamPlayer->IsSubclassOfBot() ) + { + continue; + } + + iNumPlayers++; + iPing += pTeamPlayer->client->ps.ping; + } + + if( iNumPlayers > 0 ) + { + iPing /= iNumPlayers; + } + + if( g_gametype->integer >= GT_TEAM_ROUNDS ) + { + iKills = dmTeam->m_wins_in_a_row; + iDeaths = dmTeam->m_teamwins; + } + else + { + iKills = dmTeam->m_iKills; + iDeaths = dmTeam->m_iDeaths; + } + + if( g_gametype->integer > GT_FFA ) + { + if( dmTeam->teamType > TEAM_FREEFORALL ) + { + Com_sprintf( entry, sizeof( entry ), "%i %i %i %i \"\" %i ", + -1, + dmTeam->m_teamnumber, + iKills, + iDeaths, + iPing + ); + } + else + { + Com_sprintf( entry, sizeof( entry ), "%i %i \"\" \"\" \"\" \"\" ", + -1, + dmTeam->m_teamnumber + ); + } + } + else + { + Com_sprintf( entry, sizeof( entry ), "%i \"\" \"\" \"\" \"\" \"\" ", + -1 - dmTeam->m_teamnumber + ); + } + + InsertEntry( entry ); +} + +void DM_Manager::BuildPlayerTeamInfo( DM_Team *dmTeam, int *iPlayerList, DM_Team *ignoreTeam ) +{ + char entry[ MAX_STRING_CHARS ]; + Player *pTeamPlayer; + + for( int i = 0; i < game.maxclients; i++ ) + { + if( iPlayerList[ i ] == -1 ) { + break; + } + + pTeamPlayer = ( Player * )G_GetEntity( iPlayerList[ i ] ); + + if( dmTeam != NULL && pTeamPlayer->GetDM_Team() != dmTeam ) + { + continue; + } + + if( ignoreTeam != NULL && pTeamPlayer->GetDM_Team() == ignoreTeam ) + { + continue; + } + + if( g_gametype->integer >= GT_TEAM ) + { + Com_sprintf( entry, sizeof( entry ), "%i %i %i %i %s %s ", + pTeamPlayer->client->ps.clientNum, + pTeamPlayer->IsDead() ? -pTeamPlayer->GetTeam() : pTeamPlayer->GetTeam(), // negative team means death + pTeamPlayer->GetNumKills(), + pTeamPlayer->GetNumDeaths(), + G_TimeString( level.svsFloatTime - pTeamPlayer->edict->client->pers.enterTime ), + pTeamPlayer->IsSubclassOfBot() ? "bot" : va( "%d", pTeamPlayer->client->ps.ping ) + ); + } + else + { + Com_sprintf( entry, sizeof( entry ), "%i %i %i %s %s ", + pTeamPlayer->client->ps.clientNum, + pTeamPlayer->GetNumKills(), + pTeamPlayer->GetNumDeaths(), + G_TimeString( level.svsFloatTime - pTeamPlayer->edict->client->pers.enterTime ), + pTeamPlayer->IsSubclassOfBot() ? "bot" : va( "%d", pTeamPlayer->client->ps.ping ) + ); + } + + InsertEntry( entry ); + } +} + +void DM_Manager::Score( Player *player ) +{ + int i, j; + int count = 0; + int stringlength = 0; + Player *currentPlayer; + int iPlayerList[ MAX_CLIENTS ]; + DM_Team *pDMTeam; + + assert( player ); + + scoreString[ 0 ] = 0; + scoreLength = 0; + scoreEntries = 0; + + pDMTeam = NULL; + + // make the winning team at top + if( g_gametype->integer >= GT_TEAM_ROUNDS ) + { + if( m_team_allies.m_teamwins <= m_team_axis.m_teamwins ) + { + if( m_team_axis.m_teamwins > m_team_allies.m_teamwins ) + { + pDMTeam = &m_team_axis; + } + else if( m_team_allies.m_wins_in_a_row > m_team_axis.m_wins_in_a_row ) + { + pDMTeam = &m_team_allies; + } + else if( m_team_axis.m_wins_in_a_row <= m_team_allies.m_wins_in_a_row ) + { + // make the player's current team at top + pDMTeam = player->GetDM_Team(); + + if( pDMTeam != &m_team_allies && pDMTeam != &m_team_axis ) + { + pDMTeam = &m_team_allies; + } + } + else + { + pDMTeam = &m_team_axis; + } + } + else + { + pDMTeam = &m_team_allies; + } + } + else if( g_gametype->integer > GT_FFA ) + { + if( m_team_allies.m_iKills <= m_team_axis.m_iKills ) + { + if( m_team_axis.m_iKills > m_team_allies.m_iKills ) + { + pDMTeam = &m_team_axis; + } + else if( m_team_allies.m_iDeaths > m_team_axis.m_iDeaths ) + { + pDMTeam = &m_team_allies; + } + else if( m_team_axis.m_iDeaths <= m_team_allies.m_iDeaths ) + { + pDMTeam = player->GetDM_Team(); + + if( pDMTeam != &m_team_allies && pDMTeam != &m_team_axis ) + { + pDMTeam = &m_team_allies; + } + } + else + { + pDMTeam = &m_team_axis; + } + } + else + { + pDMTeam = &m_team_allies; + } + } + + memset( iPlayerList, -1, sizeof( iPlayerList ) ); + + for( i = 1, j = 0; i <= PlayerCount(); i++ ) + { + currentPlayer = GetPlayer( i ); + + if( !currentPlayer ) + continue; + + iPlayerList[ j ] = currentPlayer->client->ps.clientNum; + + j++; + } + + // sort players by kills + qsort( iPlayerList, j, sizeof( int ), compareScores ); + + // build team info + if( g_gametype->integer > GT_FFA ) + { + BuildTeamInfo( pDMTeam ); + BuildPlayerTeamInfo( pDMTeam, iPlayerList ); + + // insert an empty entry to not make the scoreboard tight + InsertEmpty(); + + if( pDMTeam != &m_team_allies ) + { + BuildTeamInfo( &m_team_allies ); + BuildPlayerTeamInfo( &m_team_allies, iPlayerList ); + } + else if( pDMTeam != &m_team_axis ) + { + BuildTeamInfo( &m_team_axis ); + BuildPlayerTeamInfo( &m_team_axis, iPlayerList ); + } + } + else + { + // client will only show "Players" in FFA + // BuildTeamInfo( &m_team_freeforall ); + + BuildPlayerTeamInfo( NULL, iPlayerList, &m_team_spectator ); + } + + // spectator is the last team in the scoreboard + if( m_team_spectator.m_players.NumObjects() ) + { + InsertEmpty(); + + BuildTeamInfo( &m_team_spectator ); + BuildPlayerTeamInfo( &m_team_spectator, iPlayerList ); + } + + // send the info to the client + gi.SendServerCommand( player->client->ps.clientNum, "scores %i %s", scoreEntries, scoreString ); +} + +void DM_Manager::RebuildTeamConfigstrings( void ) +{ + DM_TeamPtr team; + int teamcount; + + teamcount = m_teams.NumObjects(); + + for( int i = 1; i <= teamcount; i++ ) + { + team = m_teams.ObjectAt( i ); + + gi.SetConfigstring( CS_GENERAL_STRINGS + i, va( "%d %s %d player(s)", team->m_teamnumber, team->m_teamname.c_str(), team->m_players.NumObjects() ) ); + } + + gi.SetConfigstring( CS_TEAMS, va( "%d", teamcount ) ); +} + +bool DM_Manager::AllowRespawn() const +{ + return m_bAllowRespawns || ( g_gametype->integer > GT_TEAM + && ( ( !m_team_axis.m_players.NumObjects() && !m_team_axis.m_bHasSpawnedPlayers ) + || ( !m_team_allies.m_players.NumObjects() && !m_team_allies.m_bHasSpawnedPlayers ) ) ); +} + +bool DM_Manager::CheckEndMatch() +{ + if( !m_bRoundBasedGame ) + { + if( fraglimit->integer ) + { + if( g_gametype->integer <= GT_TEAM ) + { + if( !PlayerHitScoreLimit() ) + { + if( timelimit->integer && level.inttime >= 60000 * timelimit->integer ) + { + G_BeginIntermission2(); + return true; + } + } + } + else + { + for( int i = 1; i <= m_teams.NumObjects(); i++ ) + { + DM_Team *pDMTeam = m_teams.ObjectAt( i ); + + if( pDMTeam->m_teamwins >= fraglimit->integer ) + { + if( timelimit->integer && level.inttime >= 60000 * timelimit->integer ) + { + G_BeginIntermission2(); + return true; + } + } + } + } + } + else + { + if( timelimit->integer && level.inttime >= 60000 * timelimit->integer ) + { + G_BeginIntermission2(); + return true; + } + } + } + + if( m_fRoundEndTime > 0.0f ) { + return true; + } + + if( m_fRoundTime > 0.0f ) + { + qboolean bCheckWin = qfalse; + + if( fraglimit->integer ) + { + for( int i = 1; i <= m_teams.NumObjects(); i++ ) + { + DM_Team *pDMTeam = m_teams.ObjectAt( i ); + + if( pDMTeam->m_teamwins >= fraglimit->integer ) + { + bCheckWin = qtrue; + break; + } + } + } + else + { + bCheckWin = qtrue; + } + + if( bCheckWin ) + { + if( !AllowRespawn() ) + { + if( m_team_axis.IsDead() || m_team_allies.IsDead() ) + { + if( g_gametype->integer == GT_OBJECTIVE ) + { + if( m_csTeamBombPlantSide != STRING_DRAW ) + { + DM_Team *pBombTeam; + DM_Team *pNonBombTeam; + + if( m_csTeamBombPlantSide == STRING_AXIS ) + { + pBombTeam = &m_team_axis; + pNonBombTeam = &m_team_allies; + } + else + { + pBombTeam = &m_team_allies; + pNonBombTeam = &m_team_axis; + } + + if( pBombTeam->IsDead() ) + { + if( m_iNumBombsPlanted <= 0 ) + { + m_bRoundBasedGame = qfalse; + + if( pNonBombTeam->IsDead() && m_iNumTargetsDestroyed < m_iNumTargetsToDestroy ) + { + TeamWin( pNonBombTeam->m_teamnumber ); + } + } + else + { + if( pNonBombTeam->IsDead() ) + { + if( m_iNumBombsPlanted >= m_iNumTargetsToDestroy - m_iNumTargetsDestroyed ) + { + TeamWin( pBombTeam->m_teamnumber ); + } + else + { + TeamWin( pNonBombTeam->m_teamnumber ); + } + } + else if( m_iNumBombsPlanted >= m_iNumTargetsToDestroy - m_iNumTargetsDestroyed ) + { + if( m_bIgnoringClockForBomb ) + { + return false; + } + else + { + G_PrintToAllClients( "A bomb is still set!" ); + m_bIgnoringClockForBomb = true; + return false; + } + } + } + } + } + } + + EndRound(); + return true; + } + } + + int iRoundLimit = roundlimit->integer; + if( !iRoundLimit ) { + iRoundLimit = m_iDefaultRoundLimit; + } + + if( iRoundLimit <= 0 || level.time < ( 60 * iRoundLimit ) + m_fRoundTime ) + { + return false; + } + + if( m_csTeamBombPlantSide != STRING_DRAW ) + { + if( m_bIgnoringClockForBomb ) + { + if( m_iNumBombsPlanted > 0 ) { + return false; + } + + m_bIgnoringClockForBomb = false; + } + else if( m_iNumBombsPlanted > 0 ) + { + G_PrintToAllClients( "A bomb is still set!" ); + m_bIgnoringClockForBomb = true; + return false; + } + } + + if( m_csTeamClockSide == STRING_ALLIES ) + { + TeamWin( TEAM_ALLIES ); + return true; + } + else if( m_csTeamClockSide == STRING_AXIS ) + { + TeamWin( TEAM_AXIS ); + return true; + } + else if( m_csTeamClockSide == STRING_KILLS ) + { + if( m_team_allies.TotalPlayersKills() > m_team_axis.TotalPlayersKills() ) + { + TeamWin( TEAM_ALLIES ); + return true; + } + else if( m_team_axis.TotalPlayersKills() > m_team_allies.TotalPlayersKills() ) + { + TeamWin( TEAM_AXIS ); + } + else + { + TeamWin( TEAM_NONE ); + } + } + else + { + TeamWin( TEAM_NONE ); + } + } + + return false; + } + + // FIXME: TODO + return false; +} + +void DM_Manager::EndRound() +{ + if( m_fRoundEndTime <= 0.0f ) + { + m_fRoundEndTime = level.time; + PostEvent( EV_DM_Manager_DoRoundTransition, 2.0f ); + } +} + +teamtype_t DM_Manager::GetAutoJoinTeam( void ) +{ + int allies = m_team_allies.m_players.NumObjects(); + int axis = m_team_axis.m_players.NumObjects(); + + if( allies < axis ) + { + return TEAM_ALLIES; + } + else if( allies == axis ) + { + return ( G_Random() >= 0.5f ) ? TEAM_ALLIES : TEAM_AXIS; + } + else + { + return TEAM_AXIS; + } +} + +const_str DM_Manager::GetBombPlantTeam( void ) const +{ + return m_csTeamBombPlantSide; +} + +void DM_Manager::SetBombPlantTeam( const_str s ) +{ + m_csTeamBombPlantSide = s; +} + +int DM_Manager::GetBombsPlanted( void ) const +{ + return m_iNumBombsPlanted; +} + +void DM_Manager::SetBombsPlanted( int num ) +{ + m_iNumBombsPlanted = num; +} + +const_str DM_Manager::GetClockSide( void ) const +{ + return m_csTeamClockSide; +} + +void DM_Manager::SetClockSide( const_str s ) +{ + m_csTeamClockSide = s; +} + +float DM_Manager::GetMatchStartTime( void ) +{ + if( g_gametype->integer <= GT_TEAM ) + { + return m_fRoundTime; + } + + if( m_fRoundTime <= 0.0f ) + { + if( !m_team_allies.m_players.NumObjects() || !m_team_allies.m_bHasSpawnedPlayers ) { + return -1.0f; + } + + if( !m_team_axis.m_players.NumObjects() || !m_team_axis.m_bHasSpawnedPlayers ) { + return -1.0f; + } + + int num = m_team_allies.NumNotReady() + m_team_axis.NumNotReady(); + if( num > 0 ) { + return ( float )~num; + } + } + + return m_fRoundTime; +} + +int DM_Manager::GetRoundLimit() const +{ + int round_limit = roundlimit->integer; + + if( !round_limit ) { + round_limit = m_iDefaultRoundLimit; + } + + return round_limit; +} + +void DM_Manager::SetDefaultRoundLimit( int roundlimit ) +{ + m_iDefaultRoundLimit = roundlimit; +} + +int DM_Manager::GetTargetsDestroyed( void ) const +{ + return m_iNumTargetsDestroyed; +} + +void DM_Manager::SetTargetsDestroyed( int targets ) +{ + m_iNumTargetsDestroyed = targets; +} + +int DM_Manager::GetTargetsToDestroy( void ) const +{ + return m_iNumTargetsToDestroy; +} + +void DM_Manager::SetTargetsToDestroy( int targets ) +{ + m_iNumTargetsToDestroy = targets; +} + +bool DM_Manager::IsGameActive( void ) const +{ + return !m_bRoundBasedGame || m_fRoundTime > 0.0f; +} + +int DM_Manager::PlayerCount( void ) const +{ + return m_players.NumObjects(); +} + +bool DM_Manager::PlayerHitScoreLimit( void ) +{ + if( PlayerCount() < 1 ) + { + return false; + } + + if( g_gametype->integer >= GT_TEAM_ROUNDS ) + { + return false; + } + + for( int i = 1; i <= PlayerCount(); i++ ) + { + if( m_players.ObjectAt( i )->GetNumKills() >= fraglimit->integer ) + { + return true; + } + } + + return false; +} + +void DM_Manager::PlayerKilled( Player *player ) +{ + // Spawn a deadbody + player->DeadBody(); + + // Hide the model because of the dead body + player->hideModel(); + + // Don't let the player die a second time + player->takedamage = DAMAGE_NO; + + CheckEndMatch(); +} + +void DM_Manager::PrintAllClients( str s ) +{ + gentity_t *ent; + int i; + Player *player; + + if( game.maxclients <= 0 ) + { + return; + } + + for( i = 0, ent = g_entities; i < game.maxclients; i++, ent++ ) + { + if( !ent->inuse || !ent->client || !ent->entity ) { + continue; + } + + player = ( Player * )ent->entity; + player->HUDPrint( s ); + } +} + +void DM_Manager::Reset( void ) +{ + m_team_allies.Reset(); + m_team_axis.Reset(); + m_team_spectator.Reset(); + m_team_freeforall.Reset(); + + m_players.ClearObjectList(); + m_teams.ClearObjectList(); + + gi.Cvar_Set( "g_scoreboardpicover", "" ); +} + +void DM_Manager::StartRound( void ) +{ + gentity_t *ent; + int i; + Player *player; + + m_fRoundTime = level.time; + if( m_fRoundTime < 0.1f ) { + m_fRoundTime = 0.1f; + } + + m_fRoundEndTime = 0.0f; + + // respawn all players + for( i = 0, ent = g_entities; i < game.maxclients; i++, ent++ ) + { + if( !ent->inuse || !ent->client || !ent->entity ) { + continue; + } + + player = ( Player * )ent->entity; + + if( ( player->GetTeam() == TEAM_ALLIES || + player->GetTeam() == TEAM_AXIS ) + && !player->IsDead() + && !player->IsSpectator() ) + { + player->PostEvent( EV_Player_Respawn, 0 ); + } + } + + level.Unregister( "roundstart" ); + gi.SetConfigstring( CS_WARMUP, va( "%.0f", GetMatchStartTime() ) ); +} + +bool DM_Manager::TeamHitScoreLimit( void ) +{ + if( m_teams.NumObjects() < 1 ) + { + return false; + } + + for( int i = 1; i <= m_teams.NumObjects(); i++ ) + { + if( m_teams.ObjectAt( i )->m_iKills >= fraglimit->integer ) + { + return true; + } + } + + return false; +} + + +int DM_Manager::GetTeamWin( void ) +{ + return m_iTeamWin; +} + +void DM_Manager::TeamWin( int teamnum ) +{ + DM_Team *pTeamWin; + DM_Team *pTeamLose; + + if( m_iTeamWin ) { + return; + } + + if( teamnum == TEAM_AXIS ) + { + pTeamWin = &m_team_axis; + pTeamLose = &m_team_allies; + } + else if( teamnum == TEAM_ALLIES ) + { + pTeamWin = &m_team_allies; + pTeamLose = &m_team_axis; + } + else + { + pTeamWin = NULL; + pTeamLose = NULL; + } + + if( pTeamWin ) + { + pTeamWin->TeamWin(); + } + + if( pTeamLose ) + { + pTeamLose->TeamLoss(); + } + + m_iTeamWin = teamnum ? teamnum : -1; + EndRound(); +} + +bool DM_Manager::WaitingForPlayers( void ) const +{ + if( g_gametype->integer <= GT_TEAM ) { + return false; + } + + if( !m_team_axis.m_players.NumObjects() || !m_team_axis.m_bHasSpawnedPlayers ) + { + return true; + } + else if( !m_team_allies.m_players.NumObjects() || !m_team_allies.m_bHasSpawnedPlayers ) + { + return true; + } + else if( !g_forceready->integer && m_team_axis.NumNotReady() ) + { + return true; + } + else if( !g_forceready->integer && m_team_allies.NumNotReady() ) + { + return true; + } + else if( m_team_axis.IsDead() || m_team_allies.IsDead() ) + { + return true; + } + + return false; +} + +void DM_Manager::EventDoRoundTransition( Event *ev ) +{ + if( !m_iTeamWin ) + { + if( G_FindClass( NULL, "projectile" ) ) + { + // wait for any projectile to explode + PostEvent( EV_DM_Manager_DoRoundTransition, 1.0f, 0 ); + return; + } + + if( !m_team_allies.IsDead() && !m_team_axis.IsDead() ) + { + if( m_csTeamClockSide != STRING_KILLS ) + { + if( m_csTeamClockSide != STRING_DRAW ) + gi.Printf( "WARNING: DM_Manager::EventDoRoundTransition received but no winner could be determined when there should've been\n" ); + + TeamWin( TEAM_NONE ); + } + else + { + if( m_team_allies.TotalPlayersKills() > m_team_axis.TotalPlayersKills() ) + { + TeamWin( TEAM_ALLIES ); + } + else if( m_team_axis.TotalPlayersKills() > m_team_allies.TotalPlayersKills() ) + { + TeamWin( TEAM_AXIS ); + } + else + { + TeamWin( TEAM_NONE ); + } + } + } + else if( m_team_allies.IsDead() && m_team_axis.IsDead() ) + { + TeamWin( TEAM_NONE ); + } + else if( m_team_axis.IsDead() ) + { + TeamWin( TEAM_ALLIES ); + } + else + { + TeamWin( TEAM_AXIS ); + } + } + + if( m_iTeamWin == TEAM_AXIS ) + { + G_CenterPrintToAllClients( va( "\n\n\n%s\n", gi.LV_ConvertString( "Axis win!\n" ) ) ); + G_PrintToAllClients( va( "\n\n\n%s\n", gi.LV_ConvertString( "Axis win!\n" ) ) ); + + // Play the axis victory sound + world->Sound( "den_victory_v" ); + + Unregister( STRING_AXISWIN ); + } + else if( m_iTeamWin == TEAM_ALLIES ) + { + G_CenterPrintToAllClients( va( "\n\n\n%s\n", gi.LV_ConvertString( "Allies win!\n" ) ) ); + G_PrintToAllClients( va( "\n\n\n%s\n", gi.LV_ConvertString( "Allies win!\n" ) ) ); + + // Play the allies victory sound + world->Sound( "dfr_victory_v" ); + + Unregister( STRING_ALLIESWIN ); + } + else + { + G_CenterPrintToAllClients( va( "\n\n\n%s\n", gi.LV_ConvertString( "It's a draw!\n" ) ) ); + G_PrintToAllClients( va( "\n\n\n%s\n", gi.LV_ConvertString( "It's a draw!\n" ) ) ); + + Unregister( STRING_DRAW ); + } + + G_DisplayScoresToAllClients(); + PostEvent( EV_DM_Manager_FinishRoundTransition, 3.0f ); +} + +void DM_Manager::EventFinishRoundTransition( Event *ev ) +{ + CancelEventsOfType( EV_DM_Manager_FinishRoundTransition ); + + if( timelimit->integer && m_iTotalMapTime + level.inttime >= 60000 * timelimit->integer ) + { + G_BeginIntermission2(); + } + else + { + gi.Cvar_Set( "g_tempaxisscore", va( "%d", m_team_axis.m_teamwins ) ); + gi.Cvar_Set( "g_tempaxiswinsinrow", va( "%d", m_team_axis.m_wins_in_a_row ) ); + gi.Cvar_Set( "g_tempalliesscore", va( "%d", m_team_allies.m_teamwins ) ); + gi.Cvar_Set( "g_tempallieswinsinrow", va( "%d", m_team_allies.m_wins_in_a_row ) ); + gi.Cvar_Set( "g_tempmaptime", va( "%d", m_iTotalMapTime + level.inttime ) ); + + gentity_t *ent; + int i; + + for( i = 0, ent = g_entities; i < game.maxclients; ent++, i++ ) + { + if( !ent->inuse || !ent->entity ) { + continue; + } + + Player *p = ( Player * )ent->entity; + p->client->pers.kills = p->GetNumDeaths(); + } + + gi.SendConsoleCommand( "restart\n" ); + } +} diff --git a/code/game/dm_manager.h b/code/game/dm_manager.h new file mode 100644 index 00000000..81bf1f4f --- /dev/null +++ b/code/game/dm_manager.h @@ -0,0 +1,169 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// dm_manager.h: Deathmatch Manager. + +#ifndef __DM_MANAGER_H__ +#define __DM_MANAGER_H__ + +#include "listener.h" +#include "dm_team.h" + +extern cvar_t *g_tempaxisscore; +extern cvar_t *g_tempaxiswinsinrow; +extern cvar_t *g_tempalliesscore; +extern cvar_t *g_tempallieswinsinrow; + +class Player; + +class DM_Manager : public Listener +{ +private: + Container< Player * > m_players; + Container< DM_TeamPtr > m_teams; + + DM_Team m_team_spectator; + DM_Team m_team_freeforall; + DM_Team m_team_allies; + DM_Team m_team_axis; + + float m_fRoundTime; + float m_fRoundEndTime; + + bool m_bAllowRespawns; + bool m_bRoundBasedGame; + int m_iDefaultRoundLimit; + + const_str m_csTeamClockSide; + const_str m_csTeamBombPlantSide; + + int m_iNumTargetsToDestroy; + int m_iNumTargetsDestroyed; + int m_iNumBombsPlanted; + int m_iTotalMapTime; + + int m_iTeamWin; + bool m_bIgnoringClockForBomb; + + // scoreboard data + char scoreString[ MAX_STRING_CHARS ]; + int scoreLength; + int scoreEntries; + +private: + void BuildTeamInfo( DM_Team *dmTeam ); + void BuildPlayerTeamInfo( DM_Team *dmTeam, int *iPlayerList, DM_Team *ignoreTeam = NULL ); + void InsertEntry( const char *entry ); + void InsertEmpty( void ); + +public: + CLASS_PROTOTYPE( DM_Manager ); + + DM_Manager(); + ~DM_Manager(); + + void Reset( void ); + + DM_Team *GetTeam( str name ); + DM_Team *GetTeam( teamtype_t team ); + + bool JoinTeam( Player *player, teamtype_t teamType ); + void LeaveTeam( Player *player ); + + Player *GetPlayer( int num ); + void InitGame( void ); + + void AddPlayer( Player *player ); + void RemovePlayer( Player *player ); + void PlayerKilled( Player *player ); + + void RebuildTeamConfigstrings( void ); + + static int compareScores( const void *elem1, const void *elem2 ); + void Score( Player *player ); + + void PrintAllClients( str s ); + bool CheckEndMatch( void ); + bool TeamHitScoreLimit( void ); + bool PlayerHitScoreLimit( void ); + void EventDoRoundTransition( Event *ev ); + void EventFinishRoundTransition( Event *ev ); + void TeamWin( int teamnum ); + void StartRound( void ); + void EndRound( void ); + bool GameHasRounds( void ) const; + bool GameAllowsRespawns( void ) const; + void SetGameAllowsRespawns( bool bAllow ); + bool AllowRespawn( void ) const; + int GetRoundLimit( void ) const; + void SetDefaultRoundLimit( int round_limit ); + const_str GetClockSide( void ) const; + void SetClockSide( const_str s ); + const_str GetBombPlantTeam( void ) const; + void SetBombPlantTeam( const_str s ); + int GetTargetsToDestroy( void ) const; + void SetTargetsToDestroy( int ); + int GetTargetsDestroyed( void ) const; + void SetTargetsDestroyed( int ); + int GetBombsPlanted( void ) const; + void SetBombsPlanted( int ); + int GetTeamWin( void ); + bool WaitingForPlayers( void ) const; + bool IsGameActive( void ) const; + int PlayerCount( void ) const; + teamtype_t GetAutoJoinTeam( void ); + DM_Team *GetTeamAllies( void ); + DM_Team *GetTeamAxis( void ); + float GetMatchStartTime( void ); +}; + +inline +bool DM_Manager::GameHasRounds + ( + void + ) + const +{ + return m_bRoundBasedGame; +} + +inline +bool DM_Manager::GameAllowsRespawns + ( + void + ) + const +{ + return m_bAllowRespawns; +} + +inline +void DM_Manager::SetGameAllowsRespawns + ( + bool bAllow + ) +{ + m_bAllowRespawns = bAllow; +} + +extern DM_Manager dmManager; + +#endif /* __DM_MANAGER_H__ */ diff --git a/code/game/dm_team.cpp b/code/game/dm_team.cpp new file mode 100644 index 00000000..366c81e8 --- /dev/null +++ b/code/game/dm_team.cpp @@ -0,0 +1,768 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// dm_team.cpp: Deathmatch Team Manager. + +#include "player.h" +#include "dm_team.h" +#include "dm_manager.h" +#include "PlayerStart.h" + +typedef struct spawnsort_s { + PlayerStart *spawnpoint; + float fMetric; +} spawnsort_t; + +static qboolean SpotWouldTelefrag( float *origin ) +{ + static Vector mins = Vector( -16, -16, 1 ); + static Vector maxs = Vector( 16, 16, 97 ); + trace_t trace; + + trace = G_Trace( origin, mins, maxs, origin, NULL, MASK_PLAYERSOLID, qfalse, "SpotWouldTelefrag" ); + + if( trace.startsolid || trace.allsolid ) + return qtrue; + else + return qfalse; +} + +static int compare_spawnsort( const void *pe1, const void *pe2 ) +{ + float fDelta = ( ( spawnsort_t * )pe1 )->fMetric - ( ( spawnsort_t * )pe2 )->fMetric; + + if( fDelta >= -0.001f ) + { + if( fDelta <= 0.001f ) + { + return 0; + } + else + { + return -1; + } + } + else + { + return 1; + } +} + +static PlayerStart *GetRandomSpawnpointFromList( spawnsort_t *pSpots, int nSpots ) +{ + int i = nSpots; + float fTotalMetric; + float fMinPosMetric; + float fChosen; + + if( nSpots <= 0 ) { + return NULL; + } + + qsort( pSpots, nSpots, sizeof( spawnsort_t ), compare_spawnsort ); + + if( pSpots[ 0 ].fMetric > 0.0f ) + { + if( nSpots > 5 ) { + nSpots = 5; + } + + fMinPosMetric = pSpots[ 0 ].fMetric * nSpots; + fTotalMetric = fMinPosMetric; + + if( nSpots <= 1 ) + { + fChosen = fMinPosMetric; + } + else + { + i = 0; + fTotalMetric = 0.0f; + + for( i = 0; i < nSpots; i++ ) + { + if( pSpots[ i ].fMetric <= 0.0f ) { + break; + } + + fChosen = pSpots[ i ].fMetric * ( nSpots - i ); + fTotalMetric += fChosen; + + i++; + } + + if( i < nSpots ) + { + fChosen = fMinPosMetric; + } + + fMinPosMetric = fTotalMetric; + } + + fTotalMetric = ( fMinPosMetric - i * fChosen * 0.90f ) * G_Random(); + for( i = 0; i < nSpots - 1; i++ ) + { + fTotalMetric -= ( nSpots - i ) * pSpots[ i ].fMetric - ( fChosen * 0.90f ); + if( fTotalMetric <= 0.0f ) { + break; + } + } + + return pSpots[ i ].spawnpoint; + } + else + { + // return the spot anyway + return pSpots[ 0 ].spawnpoint; + } +} + +void DM_Team::Reset( void ) +{ + m_spawnpoints.ClearObjectList(); + m_players.ClearObjectList(); +} + +void DM_Team::AddDeaths( Player *player, int numDeaths ) +{ + if( level.intermissiontime || dmManager.GetTeamWin() ) + return; + + if( g_gametype->integer == GT_TEAM_ROUNDS || g_gametype->integer == GT_OBJECTIVE ) + return; + + player->AddDeaths( numDeaths ); + + if( m_teamnumber > TEAM_FREEFORALL ) + m_iDeaths += numDeaths; +} + +void DM_Team::AddKills( Player *player, int numKills ) +{ + if( level.intermissiontime || dmManager.GetTeamWin() ) + return; + + player->AddKills( numKills ); + + if( m_teamnumber > TEAM_FREEFORALL ) + { + m_iKills += numKills; + + if( g_gametype->integer == GT_TEAM_ROUNDS || g_gametype->integer == GT_OBJECTIVE ) + player->AddDeaths( numKills ); + else + m_teamwins += numKills; + } +} + +void DM_Team::AddPlayer( Player *player ) +{ + m_players.AddObject( player ); +} + +void DM_Team::RemovePlayer( Player *player ) +{ + m_players.RemoveObject( player ); +} + +void DM_Team::TeamWin( void ) +{ + m_teamwins++; + m_wins_in_a_row++; + + for( int i = 1; i <= m_players.NumObjects(); i++ ) + { + m_players.ObjectAt( i )->WonMatch(); + } + + UpdateTeamStatus(); + + if( m_teamnumber == TEAM_ALLIES ) + { + gi.Cvar_Set( "g_scoreboardpicover", "textures/hud/allieswin" ); + } + else if( m_teamnumber == TEAM_AXIS ) + { + gi.Cvar_Set( "g_scoreboardpicover", "textures/hud/axiswin" ); + } +} + +void DM_Team::TeamLoss( void ) +{ + m_wins_in_a_row = 0; + + for( int i = 1; i <= m_players.NumObjects(); i++ ) + { + m_players.ObjectAt( i )->LostMatch(); + } + + UpdateTeamStatus(); +} + +bool DM_Team::IsDead( void ) const +{ + Player *player; + + if( IsEmpty() ) + { + if( dmManager.IsGameActive() ) { + return true; + } + + return false; + } + + if( !m_bHasSpawnedPlayers ) { + return false; + } + + if( dmManager.AllowRespawn() ) { + return false; + } + + for( int i = m_players.NumObjects(); i > 0; i-- ) + { + player = m_players.ObjectAt( i ); + + if( player->IsSpectator() ) { + continue; + } + + if( !player->IsDead() ) + { + return false; + } + } + + return true; +} + +bool DM_Team::IsEmpty( void ) const +{ + return m_players.NumObjects() <= 0; +} + +bool DM_Team::IsReady( void ) const +{ + return !NumNotReady(); +} + +int DM_Team::NumNotReady( void ) const +{ + Player *player; + int num = 0; + + for( int i = 1; i <= m_players.NumObjects(); i++ ) + { + player = m_players.ObjectAt( i ); + + if( player->IsReady() && !player->IsDead() ) + i++; + } + + return num; +} + +int DM_Team::NumLivePlayers( void ) const +{ + Player *player; + int num = 0; + + for( int i = 1; i <= m_players.NumObjects(); i++ ) + { + player = m_players.ObjectAt( i ); + + if( !player->IsDead() && !player->IsSpectator() ) + { + num++; + } + } + + return num; +} + +int DM_Team::TotalPlayersKills( void ) const +{ + Player *player; + int iKills = 0; + + for( int i = 1; i <= m_players.NumObjects(); i++ ) + { + player = m_players.ObjectAt( i ); + + if( !player->IsDead() && !player->IsSpectator() ) + { + iKills += player->GetNumKills(); + } + } + + return iKills; +} + +void DM_Team::TeamInvulnerable( void ) +{ + for( int i = 1; i <= m_players.NumObjects(); i++ ) + { + m_players.ObjectAt( i )->takedamage = DAMAGE_NO; + } +} + +void DM_Team::BeginFight( void ) +{ + for( int i = 1; i <= m_players.NumObjects(); i++ ) + { + m_players.ObjectAt( i )->BeginFight(); + } +} + +void DM_Team::UpdateTeamStatus( void ) +{ + for( int i = 1; i <= m_players.NumObjects(); i++ ) + { + m_players.ObjectAt( i )->UpdateStatus( va( "%d wins (%d in a row)", m_teamwins, m_wins_in_a_row ) ); + } +} + +float SpawnpointMetric_Ffa( const float *origin, DM_Team *dmTeam, const Player *player ) +{ + float fMinEnemyDistSquared = 23170.0f * 23170.0f; + int i; + int nPlayers = dmManager.PlayerCount(); + float fDist; + + for( i = 1; i < nPlayers; i++ ) + { + Player *teammate = dmManager.GetPlayer( i ); + if( teammate == player || teammate->IsDead() || teammate->IsSpectator() ) { + continue; + } + + fDist = ( teammate->origin - Vector( origin ) ).lengthSquared(); + + if( fMinEnemyDistSquared > fDist ) { + fMinEnemyDistSquared = fDist; + } + } + + return fMinEnemyDistSquared - ( G_Random( 0.25f ) + 1.0f ) * ( 1024.0f * 1024.0f ); +} + +float SpawnpointMetric_Team( const float *origin, DM_Team *dmTeam, const Player *player ) +{ + float fMinEnemyDistSquared = 23170.0f * 23170.0f; + float fSumFriendDistSquared = 0.0f; + float fDistSquared; + float fMetric; + int i; + int nPlayers = dmManager.PlayerCount(); + int nFriends = 0; + + for( i = 1; i < nPlayers; i++ ) + { + Player *teammate = dmManager.GetPlayer( i ); + if( teammate == player || teammate->IsDead() || teammate->IsSpectator() ) { + continue; + } + + fDistSquared = ( teammate->origin - Vector( origin ) ).lengthSquared(); + + if( teammate->GetDM_Team() == dmTeam ) + { + nFriends++; + fSumFriendDistSquared += fDistSquared; + } + else + { + if( fMinEnemyDistSquared > fDistSquared ) { + fMinEnemyDistSquared = fDistSquared; + } + } + } + + fMetric = fMinEnemyDistSquared - ( G_Random( 0.25f ) + 1.0f ) * ( 1024.0f * 1024.0f ); + + if( nFriends ) + { + fMetric += 0.25f * ( ( 23170.0f * 23170.0f ) - fSumFriendDistSquared / nFriends ); + } + + return fMetric; +} + +float SpawnpointMetric_Objective( const float *origin, DM_Team *dmTeam, const Player *player ) +{ + return rand() * 0.0000000005f; +} + +PlayerStart *DM_Team::GetRandomFfaSpawnpoint( Player *player ) +{ + return GetRandomSpawnpointWithMetric( player, SpawnpointMetric_Ffa ); +} + +PlayerStart *DM_Team::GetRandomTeamSpawnpoint( Player *player ) +{ + return GetRandomSpawnpointWithMetric( player, SpawnpointMetric_Team ); +} + +PlayerStart *DM_Team::GetRandomObjectiveSpawnpoint( Player *player ) +{ + return GetRandomSpawnpointWithMetric( player, SpawnpointMetric_Objective ); +} + +float DM_Team::PlayersRangeFromSpot( PlayerStart *spot ) +{ + float bestplayerdistance = 9999999.0f; + Vector vDist; + int i; + gentity_t *ent; + Player *player; + + if( g_gametype->integer > GT_FFA ) { + return bestplayerdistance; + } + + // find the nearest player from the post + for( i = 0, ent = g_entities; i < game.maxclients; i++, ent++ ) + { + if( !ent->client || !ent->entity ) { + continue; + } + + player = ( Player * )ent->entity; + if( !player->IsDead() && !player->IsSpectator() && m_teamnumber != player->GetTeam() ) + { + vDist = spot->origin - player->origin; + if( bestplayerdistance > vDist.length() ) + bestplayerdistance = vDist.length(); + } + } + + return bestplayerdistance; +} + +PlayerStart *DM_Team::FarthestSpawnPoint( void ) +{ + int i; + int iNumPoints; + float bestdistance; + float bestplayerdistance; + PlayerStart *pSpot; + PlayerStart *pBestSpot; + PlayerStart *pSpot2; + PlayerStart *pSpot3; + + bestplayerdistance = 0.0f; + pBestSpot = NULL; + pSpot2 = NULL; + pSpot3 = NULL; + iNumPoints = m_spawnpoints.NumObjects(); + + for( i = 1; i <= iNumPoints; i++ ) + { + pSpot = m_spawnpoints.ObjectAt( i ); + + bestdistance = PlayersRangeFromSpot( m_spawnpoints.ObjectAt( i ) ); + if( bestdistance > bestplayerdistance ) + { + bestplayerdistance = bestdistance; + pSpot3 = pSpot2; + pSpot2 = pBestSpot; + pBestSpot = pSpot; + } + } + + if( pSpot3 && G_Random() < 0.2f ) + { + return pSpot3; + } + else if( pSpot2 && G_Random() < 0.3f ) + { + return pSpot2; + } + else + { + return pBestSpot; + } +} + +PlayerStart *DM_Team::GetRandomSpawnpoint( void ) +{ + PlayerStart *spot = NULL; + int numPoints = m_spawnpoints.NumObjects(); + + if( numPoints ) + { + spot = FarthestSpawnPoint(); + if( !spot ) + { + spot = m_spawnpoints.ObjectAt( ( int )( G_Random( numPoints ) + 1.0f ) ); + } + } + else + { + warning( "DM_Team::GetRandomSpawnpoint", "No spawnpoints found\n" ); + spot = NULL; + } + + return spot; +} + +PlayerStart *DM_Team::GetRandomSpawnpointWithMetric( Player *player, float( *MetricFunction ) ( const float *origin, DM_Team *dmTeam, const Player *player ) ) +{ + static float offset[ 4 ][ 3 ]; + spawnsort_t points[ 1024 ]; + PlayerStart *spot = NULL; + int numSpots = 0; + int iPoint = 0; + + for( int i = 1; i <= m_spawnpoints.NumObjects(); i++ ) + { + spot = m_spawnpoints.ObjectAt( i ); + if( spot->m_bForbidSpawns || player->GetLastSpawnpoint() == spot ) { + continue; + } + + if( !SpotWouldTelefrag( spot->origin ) ) + { + points[ numSpots ].spawnpoint = spot; + points[ numSpots ].fMetric = MetricFunction( spot->origin, this, player ); + numSpots++; + + if( numSpots >= ( sizeof( points ) / sizeof( points[ 0 ] ) ) ) { + break; + } + } + } + + spot = GetRandomSpawnpointFromList( points, numSpots ); + if( spot ) { + return spot; + } + + numSpots = 0; + + for( int i = 1; i <= m_spawnpoints.NumObjects(); i++ ) + { + spot = m_spawnpoints.ObjectAt( i ); + if( spot->m_bForbidSpawns ) { + continue; + } + + for( int j = 0; j < sizeof( offset ) / sizeof( offset[ 0 ] ); j++ ) + { + Vector vNewSpawn = spot->origin + offset[ j ]; + + if( G_SightTrace( + spot->origin, + player->mins, + player->maxs, + vNewSpawn, + ( Entity * )NULL, + ( Entity * )NULL, + MASK_PLAYERSOLID, + qfalse, + "DM_Team::GetRandomSpawnpointWithMetric" ) == 1 ) + { + Vector vEnd = vNewSpawn - Vector( 0, 0, 64 ); + + trace_t trace = G_Trace( + vNewSpawn, + player->mins, + player->maxs, + vEnd, + player, + MASK_PLAYERSOLID, + qfalse, + "TempSpawnPoint" ); + + if( !trace.allsolid && !trace.startsolid && + trace.fraction != 1.0f && trace.fraction != 1.0f && + trace.plane.dist >= 0.8f ) + { + points[ numSpots ].spawnpoint = new PlayerStart; + points[ numSpots ].spawnpoint->setOrigin( trace.endpos ); + points[ numSpots ].spawnpoint->setAngles( spot->angles ); + + MetricFunction( vNewSpawn, this, player ); + points[ numSpots ].fMetric = 0; + + if( numSpots >= ( sizeof( points ) / sizeof( points[ 0 ] ) ) ) { + break; + } + } + } + } + } + + spot = GetRandomSpawnpointFromList( points, numSpots ); + for( int i = 0; i < numSpots; i++ ) + { + // delete all created spawnpoint + if( points[ numSpots ].spawnpoint != spot ) { + delete points[ numSpots ].spawnpoint; + } + } + + if( spot ) { + return spot; + } + + numSpots = 0; + + for( int i = 1; i <= m_spawnpoints.NumObjects(); i++ ) + { + spot = m_spawnpoints.ObjectAt( i ); + if( !spot->m_bForbidSpawns && player->GetLastSpawnpoint() != spot ) { + continue; + } + + if( !SpotWouldTelefrag( spot->origin ) ) + { + points[ numSpots ].spawnpoint = spot; + MetricFunction( spot->origin, this, player ); + points[ numSpots ].fMetric = 0; + + if( numSpots >= ( sizeof( points ) / sizeof( points[ 0 ] ) ) ) { + break; + } + } + } + + return GetRandomSpawnpointFromList( points, numSpots ); +} + +void DM_Team::InitSpawnPoints + ( + void + ) + +{ + int i; + + if( teamType == TEAM_SPECTATOR ) + { + for( i = level.m_SimpleArchivedEntities.NumObjects(); i > 0; i-- ) + { + PlayerStart *spawnpoint = ( PlayerStart * )level.m_SimpleArchivedEntities.ObjectAt( i ); + const char *classname = spawnpoint->getClassID(); + + if( !Q_stricmp( classname, "info_player_deathmatch" ) ) + { + m_spawnpoints.AddObject( spawnpoint ); + } + else if( !Q_stricmp( classname, "info_player_intermission" ) ) + { + m_spawnpoints.AddObject( spawnpoint ); + } + } + + return; + } + + if( g_gametype->integer <= GT_FFA ) + { + for( i = level.m_SimpleArchivedEntities.NumObjects(); i > 0; i-- ) + { + PlayerStart *spawnpoint = ( PlayerStart * )level.m_SimpleArchivedEntities.ObjectAt( i ); + const char *classname = spawnpoint->getClassID(); + + if( !Q_stricmp( classname, "info_player_deathmatch" ) ) + { + m_spawnpoints.AddObject( spawnpoint ); + } + } + + if( m_spawnpoints.NumObjects() <= 1 ) + { + // Try with team spawnpoints + for( i = level.m_SimpleArchivedEntities.NumObjects(); i > 0; i-- ) + { + PlayerStart *spawnpoint = ( PlayerStart * )level.m_SimpleArchivedEntities.ObjectAt( i ); + const char *classname = spawnpoint->getClassID(); + + if( !Q_stricmp( classname, "info_player_allied" ) ) + { + m_spawnpoints.AddObject( spawnpoint ); + } + else if( !Q_stricmp( classname, "info_player_axis" ) ) + { + m_spawnpoints.AddObject( spawnpoint ); + } + } + } + } + else if( g_gametype->integer >= GT_TEAM ) + { + if( teamType >= TEAM_ALLIES ) + { + for( i = level.m_SimpleArchivedEntities.NumObjects(); i > 0; i-- ) + { + PlayerStart *spawnpoint = ( PlayerStart * )level.m_SimpleArchivedEntities.ObjectAt( i ); + const char *classname = spawnpoint->getClassID(); + + if( teamType == TEAM_ALLIES && !Q_stricmp( classname, "info_player_allied" ) ) + { + m_spawnpoints.AddObject( spawnpoint ); + } + else if( teamType == TEAM_AXIS && !Q_stricmp( classname, "info_player_axis" ) ) + { + m_spawnpoints.AddObject( spawnpoint ); + } + } + } + + if( !m_spawnpoints.NumObjects() ) + { + // Try with info_player_deathmatch + for( int i = level.m_SimpleArchivedEntities.NumObjects(); i > 0; i-- ) + { + PlayerStart *spawnpoint = ( PlayerStart * )level.m_SimpleArchivedEntities.ObjectAt( i ); + const char *classname = spawnpoint->getClassID(); + + if( !Q_stricmp( classname, "info_player_deathmatch" ) ) + { + m_spawnpoints.AddObject( spawnpoint ); + } + } + } + } +} + +DM_Team::DM_Team() +{ + m_countdown = 0; + m_teamwins = 0; + m_wins_in_a_row = 0; + m_teamnumber = -1; + m_iKills = 0; + m_iDeaths = 0; + m_bHasSpawnedPlayers = false; +} + +DM_Team::~DM_Team() +{ + +} + +CLASS_DECLARATION( Listener, DM_Team, NULL ) +{ + { NULL, NULL } +}; diff --git a/code/game/dm_team.h b/code/game/dm_team.h new file mode 100644 index 00000000..4fe8cea6 --- /dev/null +++ b/code/game/dm_team.h @@ -0,0 +1,107 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// dm_team.cpp: Deathmatch Team Manager. + +#ifndef __DM_TEAM_H__ +#define __DM_TEAM_H__ + +#include "listener.h" + +class PlayerStart; +class Player; + +class DM_Team : public Listener +{ +public: + Container< PlayerStart * > m_spawnpoints; + Container< Player * > m_players; + + int m_maxplayers; + + str m_teamname; + + int m_teamnumber; + + teamtype_t teamType; + + int m_countdown; + + int m_teamwins; + int m_wins_in_a_row; + + int m_iKills; + int m_iDeaths; + + qboolean m_bHasSpawnedPlayers; + +public: + CLASS_PROTOTYPE( DM_Team ); + + DM_Team(); + ~DM_Team(); + + void Reset( void ); + + void AddDeaths( Player *player, int numDeaths ); + void AddKills( Player *player, int numKills ); + void AddPlayer( Player *player ); + + void RemovePlayer( Player *player ); + + void setName( str name ) { m_teamname = name; }; + str getName( void ) { return m_teamname; }; + void setNumber( int num ) { m_teamnumber = num; }; + int getNumber( void ) { return m_teamnumber; }; + void setIndex( int index ); + int getIndex( void ); + + void TeamWin( void ); + void TeamLoss( void ); + + bool IsDead( void ) const; + bool IsEmpty( void ) const; + bool IsReady( void ) const; + + int NumNotReady( void ) const; + int NumLivePlayers( void ) const; + int TotalPlayersKills( void ) const; + void TeamInvulnerable( void ); + void BeginFight( void ); + + float PlayersRangeFromSpot( PlayerStart *spot ); + + void UpdateTeamStatus( void ); + + void InitSpawnPoints( void ); + + PlayerStart *GetRandomFfaSpawnpoint( Player *player ); + PlayerStart *GetRandomTeamSpawnpoint( Player *player ); + PlayerStart *GetRandomObjectiveSpawnpoint( Player *player ); +protected: + PlayerStart *FarthestSpawnPoint( void ); + PlayerStart *GetRandomSpawnpoint( void ); + PlayerStart *GetRandomSpawnpointWithMetric( Player *player, float( *MetricFunction ) ( float const *, DM_Team *dmTeam, const Player *player ) ); +}; + +typedef SafePtr< DM_Team > DM_TeamPtr; + +#endif /* __DM_TEAM_H__ */ diff --git a/code/game/doors.cpp b/code/game/doors.cpp new file mode 100644 index 00000000..b5b1d321 --- /dev/null +++ b/code/game/doors.cpp @@ -0,0 +1,1864 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// doors.cpp: Doors are environment objects that rotate open when activated by triggers +// or when used by the player. +// + +#include "g_local.h" +#include "entity.h" +#include "trigger.h" +#include "mover.h" +#include "doors.h" +#include "sentient.h" +#include "scriptmaster.h" +#include "item.h" +#include "actor.h" +#include "player.h" + +Event EV_Door_OpenStartSound +( + "sound_open_start", + EV_DEFAULT, + "s", + "sound_open_start", + "Sets the sound to use when the door starts to opens." +); +Event EV_Door_OpenEndSound +( + "sound_open_end", + EV_DEFAULT, + "s", + "sound_open_end", + "Sets the sound to use when the door stops to opens." +); +Event EV_Door_CloseStartSound +( + "sound_close_start", + EV_DEFAULT, + "s", + "sound_close", + "Sets the sound to use when the door closes." +); +Event EV_Door_CloseEndSound +( + "sound_close_end", + EV_DEFAULT, + "s", + "sound_close", + "Sets the sound to use when the door closes." +); +Event EV_Door_MessageSound + ( + "sound_message", + EV_DEFAULT, + "s", + "sound_message", + "Sets the sound to use when the door displays a message.", + EV_NORMAL + ); +Event EV_Door_LockedSound + ( + "sound_locked", + EV_DEFAULT, + "s", + "sound_locked", + "Sets the sound to use when the door is locked.", + EV_NORMAL + ); +Event EV_Door_SetWait + ( + "wait", + EV_DEFAULT, + "f", + "wait", + "Sets the amount of time to wait before automatically shutting.", + EV_NORMAL + ); +Event EV_Door_SetDmg + ( + "dmg", + EV_DEFAULT, + "i", + "damage", + "Sets the amount of damage the door will do to entities that get stuck in it.", + EV_NORMAL + ); +Event EV_Door_TriggerFieldTouched + ( + "door_triggerfield", + EV_DEFAULT, + "e", + "other", + "Is called when a doors trigger field is touched.", + EV_NORMAL + ); +Event EV_Door_TryOpen + ( + "tryToOpen", + EV_DEFAULT, + "e", + "other", + "Tries to open the door.", + EV_NORMAL + ); +Event EV_Door_Close + ( + "close", + EV_DEFAULT, + NULL, + NULL, + "Closes the door.", + EV_NORMAL + ); +Event EV_Door_Open + ( + "open", + EV_DEFAULT, + "e", + "other", + "Opens the door.", + EV_NORMAL + ); +Event EV_Door_DoClose + ( + "doclose", + EV_DEFAULT, + NULL, + NULL, + "Closes the door (special doors).", + EV_NORMAL + ); +Event EV_Door_DoOpen + ( + "doopen", + EV_DEFAULT, + "e", + "other", + "Opens the door (special doors).", + EV_NORMAL + ); +Event EV_Door_CloseEnd + ( + "doorclosed", + EV_DEFAULT, + NULL, + NULL, + "Called when the door finishes closing.", + EV_NORMAL + ); +Event EV_Door_OpenEnd + ( + "dooropened", + EV_DEFAULT, + NULL, + NULL, + "Called when the door finishes opening.", + EV_NORMAL + ); +Event EV_Door_Fire + ( + "toggledoor", + EV_DEFAULT, + "e", + "other", + "Toggles the state of the door (open/close).", + EV_NORMAL + ); +Event EV_Door_Link + ( + "linkdoor", + EV_DEFAULT, + NULL, + NULL, + "Link doors together.", + EV_NORMAL + ); +Event EV_Door_SetTime + ( + "time", + EV_DEFAULT, + "f", + "traveltime", + "Sets the time it takes for the door to open an close.", + EV_NORMAL + ); +Event EV_Door_Lock + ( + "lock", + EV_DEFAULT, + NULL, + NULL, + "Lock the door.", + EV_NORMAL + ); +Event EV_Door_Unlock + ( + "unlock", + EV_DEFAULT, + NULL, + NULL, + "Unlock the door.", + EV_NORMAL + ); +Event EV_Door_TrySolid + ( + "trysolid", + EV_DEFAULT, + NULL, + NULL, + "Trys to make the door solid.", + EV_NORMAL + ); +Event EV_Door_AlwaysAway + ( + "alwaysaway", + EV_DEFAULT, + "B", + "bAlwaysAway", + "Makes the door always open away from the person opening it.", + EV_NORMAL + ); +Event EV_Door_DoorType + ( + "doortype", + EV_DEFAULT, + "s", + "door_type", + "Sets the defaults for this door\n" + "Door Defaults: wood(default)\n" + "metal" + ); + +#define DOOR_START_OPEN 1 +#define DOOR_OPEN_DIRECTION 2 +#define DOOR_DONT_LINK 4 +#define DOOR_TOGGLE 32 +#define DOOR_AUTO_OPEN 64 +#define DOOR_TARGETED 128 + +#define STATE_OPEN 1 +#define STATE_OPENING 2 +#define STATE_CLOSING 3 +#define STATE_CLOSED 4 + +/* + +Doors are similar to buttons, but can spawn a fat trigger field around them +to open without a touch, and they link together to form simultanious +double/quad doors. + +Door.master is the master door. If there is only one door, it points to itself. +If multiple doors, all will point to a single one. + +Door.enemy chains from the master door through all doors linked in the chain. + +*/ + +CLASS_DECLARATION( ScriptSlave, Door, "func_door" ) +{ + { &EV_Door_OpenStartSound, &Door::SetOpenStartSound }, + { &EV_Door_OpenEndSound, &Door::SetOpenEndSound }, + { &EV_Door_CloseStartSound, &Door::SetCloseStartSound }, + { &EV_Door_CloseEndSound, &Door::SetCloseEndSound }, + { &EV_Door_MessageSound, &Door::SetMessageSound }, + { &EV_Door_LockedSound, &Door::SetLockedSound }, + { &EV_Door_SetWait, &Door::SetWait }, + { &EV_Door_SetDmg, &Door::SetDmg }, + { &EV_Door_TriggerFieldTouched, &Door::FieldTouched }, + { &EV_Trigger_Effect, &Door::TryOpen }, + { &EV_Activate, &Door::TryOpen }, + { &EV_Door_TryOpen, &Door::TryOpen }, + { &EV_Door_Close, &Door::Close }, + { &EV_Door_Open, &Door::Open }, + { &EV_Door_CloseEnd, &Door::CloseEnd }, + { &EV_Door_OpenEnd, &Door::OpenEnd }, + { &EV_Door_Fire, &Door::DoorFire }, + { &EV_Door_Link, &Door::LinkDoors }, + { &EV_Door_SetTime, &Door::SetTime }, + { &EV_Use, &Door::DoorUse }, + { &EV_Killed, &Door::DoorFire }, + { &EV_Blocked, &Door::DoorBlocked }, + { &EV_Door_Lock, &Door::LockDoor }, + { &EV_Door_Unlock, &Door::UnlockDoor }, + { &EV_SetAngle, &Door::SetDir }, + { &EV_Door_TrySolid, &Door::EventTrySolid }, + { &EV_Door_AlwaysAway, &Door::EventAlwaysAway }, + { &EV_Door_DoorType, &Door::EventDoorType }, + { &EV_Touch, NULL }, + { NULL, NULL } +}; + +Door::Door() + { + float t; + + entflags |= EF_DOOR; + if ( LoadingSavegame ) + { + return; + } + + nextdoor = 0; + trigger = 0; + locked = false; + master = this; + lastblocktime = 0; + diropened = 0; + m_bAlwaysAway = true; + + dir = G_GetMovedir( 0 ); + t = dir[ 0 ]; + dir[ 0 ] = -dir[ 1 ]; + dir[ 1 ] = t; + + showModel(); + + SetOpenStartSound( "door_wood_open_move" ); + SetOpenEndSound( "door_wood_open_stop" ); + + SetCloseStartSound( "door_wood_close_move" ); + SetCloseEndSound( "door_wood_close_stop" ); + + SetLockedSound( "door_wood_locked" ); + + traveltime = 1.0f; + speed = 1.0f / traveltime; + + wait = ( spawnflags & DOOR_TOGGLE ) ? 0 : 3; + dmg = 0; + + setSize( mins, maxs ); + + setOrigin( localorigin ); + + // DOOR_START_OPEN is to allow an entity to be lighted in the closed position + // but spawn in the open position + if ( spawnflags & DOOR_START_OPEN ) + { + state = STATE_OPEN; + PostEvent( EV_Door_Open, EV_POSTSPAWN ); + } + else + { + state = STATE_CLOSED; + } + previous_state = state; + + if ( health ) + { + takedamage = DAMAGE_YES; + } + + // LinkDoors can't be done until all of the doors have been spawned, so + // the sizes can be detected properly. + nextdoor = 0; + PostEvent( EV_Door_Link, EV_LINKDOORS ); + + // Default to work with monsters and players + respondto = TRIGGER_PLAYERS | TRIGGER_MONSTERS; + if ( spawnflags & 8 ) + { + respondto &= ~TRIGGER_PLAYERS; + } + if ( spawnflags & 16 ) + { + respondto &= ~TRIGGER_MONSTERS; + } + + next_locked_time = 0; + } + +void Door::SetDir( Event *ev ) +{ + float t; + float angle; + + angle = ev->GetFloat( 1 ); + dir = G_GetMovedir( angle ); + t = dir[ 0 ]; + dir[ 0 ] = -dir[ 1 ]; + dir[ 1 ] = t; +} + +void Door::SetOpenStartSound( str sound ) +{ + sound_open_start = sound; + if( sound_open_start.length() > 1 ) + { + CacheResource( sound_open_start.c_str() ); + } +} + +void Door::SetOpenEndSound( str sound ) +{ + sound_open_end = sound; + if( sound_open_end.length() > 1 ) + { + CacheResource( sound_open_end.c_str() ); + } +} + +void Door::SetCloseStartSound( str sound ) +{ + sound_close_start = sound; + if( sound_close_start.length() > 1 ) + { + CacheResource( sound_close_start.c_str() ); + } +} + +void Door::SetCloseEndSound( str sound ) +{ + sound_close_end = sound; + if( sound_close_end.length() > 1 ) + { + CacheResource( sound_close_end.c_str() ); + } +} + +void Door::SetMessageSound + ( + str sound + ) + + { + sound_message = sound; + if ( sound_message.length() > 1 ) + { + CacheResource( sound_message.c_str() ); + } + } + +void Door::SetLockedSound + ( + str sound + ) + + { + sound_locked = sound; + if ( sound_locked.length() > 1 ) + { + CacheResource( sound_locked.c_str() ); + } + } + +void Door::SetOpenStartSound( Event *ev ) +{ + SetOpenStartSound( ev->GetString( 1 ) ); +} + +void Door::SetOpenEndSound( Event *ev ) +{ + SetOpenEndSound( ev->GetString( 1 ) ); +} + +void Door::SetCloseStartSound( Event *ev ) +{ + SetCloseStartSound( ev->GetString( 1 ) ); +} + +void Door::SetCloseEndSound( Event *ev ) +{ + SetCloseEndSound( ev->GetString( 1 ) ); +} + +void Door::SetMessageSound + ( + Event *ev + ) + +{ + SetMessageSound( ev->GetString( 1 ) ); +} + +void Door::SetLockedSound + ( + Event *ev + ) + +{ + SetLockedSound( ev->GetString( 1 ) ); +} + +void Door::SetWait + ( + Event *ev + ) + +{ + wait = ev->GetFloat( 1 ); +} + +void Door::SetDmg + ( + Event *ev + ) + +{ + dmg = ev->GetInteger( 1 ); +} + +void Door::EventAlwaysAway + ( + Event *ev + ) + +{ + qboolean bAlwaysAway = true; + + if( ev->NumArgs() > 0 ) + bAlwaysAway = ev->GetInteger( 1 ); + + m_bAlwaysAway = bAlwaysAway != 0; +} + +void Door::EventTrySolid + ( + Event *ev + ) + +{ + Entity *check; + gentity_t *ent; + int touch[ MAX_GENTITIES ]; + int num; + + if( edict->r.contents == 1 ) + return; + + num = gi.AreaEntities( absmin, absmax, touch, MAX_GENTITIES ); + if( num > 0 ) + { + for( int i = 0; i < num; i++ ) + { + ent = &g_entities[ touch[ i ] ]; + check = ent->entity; + + if( check->getMoveType() > MOVETYPE_STOP ) + { + if( edict->r.contents != CONTENTS_SHOOTONLY && + edict->solid && + IsTouching( check ) ) + { + PostEvent( EV_Door_TrySolid, 1.0f ); + return; + } + } + } + } + + edict->r.contents = CONTENTS_SOLID; + setSolidType( SOLID_BSP ); +} + +void Door::EventDoorType + ( + Event *ev + ) + +{ + str s = ev->GetString( 1 ); + + if( s != "wood" && s != "metal" ) + { + ScriptError( "Invalid Door Type." ); + } + + SetOpenStartSound( "door_" + s + "_open_move" ); + SetOpenEndSound( "door_" + s + "_open_stop" ); + + SetCloseStartSound( "door_" + s + "_close_move" ); + SetCloseEndSound( "door_" + s + "_close_stop" ); + + SetLockedSound( "door_" + s + "_locked" ); +} + +qboolean Door::isOpen + ( + void + ) + +{ + return ( state == STATE_OPEN ); +} + +qboolean Door::isCompletelyClosed + ( + void + ) + +{ + return ( state == STATE_CLOSED ); +} + +void Door::OpenEnd + ( + Event *ev + ) + +{ + if( edict->r.contents != CONTENTS_SOLID ) + { + PostEvent( EV_Door_TrySolid, 1.0f ); + } + + if( sound_open_end.length() > 1 ) + { + BroadcastAIEvent(); + Sound( sound_open_end, CHAN_VOICE ); + } + else + { + StopSound( CHAN_VOICE ); + } + + previous_state = state; + SetState( STATE_OPEN ); + if( spawnflags & DOOR_TOGGLE ) + { + // don't close automatically + return; + } + + if( ( wait > 0 ) && ( master == this ) ) + { + PostEvent( EV_Door_Close, wait ); + } +} + +void Door::CloseEnd + ( + Event *ev + ) + +{ + if( sound_close_end.length() > 1 ) + { + BroadcastAIEvent(); + Sound( sound_close_end, CHAN_VOICE ); + } + else + { + StopSound( CHAN_VOICE ); + } + + if( master == this ) + { + gi.AdjustAreaPortalState( this->edict, false ); + } + + edict->r.contents = CONTENTS_SOLID; + setSolidType( SOLID_BSP ); + + previous_state = state; + SetState( STATE_CLOSED ); +} + +void Door::Close + ( + Event *ev + ) + +{ + Door *door; + + CancelEventsOfType( EV_Door_Close ); + + previous_state = state; + SetState( STATE_CLOSING ); + + ProcessEvent( EV_Door_DoClose ); + + if( sound_close_start.length() > 1 ) + { + BroadcastAIEvent(); + Sound( sound_close_start, CHAN_VOICE ); + } + if( master == this ) + { + if( max_health ) + { + takedamage = DAMAGE_YES; + health = max_health; + } + + // trigger all paired doors + door = ( Door * )G_GetEntity( nextdoor ); + assert( door->isSubclassOf( Door ) ); + while( door && ( door != this ) ) + { + door->ProcessEvent( EV_Door_Close ); + door = ( Door * )G_GetEntity( door->nextdoor ); + assert( door->isSubclassOf( Door ) ); + } + } +} + +void Door::Open + ( + Event *ev + ) + +{ + Door *door; + Event *e; + Entity *other; + + if( ev->NumArgs() < 1 ) + { + ScriptError( "No entity specified to open door. Door may open the wrong way." ); + other = world; + } + else + { + other = ev->GetEntity( 1 ); + } + + if( state == STATE_OPENING ) + { + // already going up + return; + } + + if( state == STATE_OPEN ) + { + // reset top wait time + if( wait > 0 ) + { + CancelEventsOfType( EV_Door_Close ); + PostEvent( EV_Door_Close, wait ); + } + return; + } + + previous_state = state; + SetState( STATE_OPENING ); + + e = new Event( EV_Door_DoOpen ); + e->AddEntity( other ); + ProcessEvent( e ); + + if( sound_open_start.length() > 1 ) + { + BroadcastAIEvent(); + Sound( sound_open_start, CHAN_VOICE ); + } + if( master == this ) + { + // trigger all paired doors + door = ( Door * )G_GetEntity( nextdoor ); + assert( door->isSubclassOf( Door ) ); + while( door && ( door != this ) ) + { + e = new Event( EV_Door_Open ); + e->AddEntity( other ); + door->ProcessEvent( e ); + door = ( Door * )G_GetEntity( door->nextdoor ); + assert( door->isSubclassOf( Door ) ); + } + + if( previous_state == STATE_CLOSED ) + { + gi.AdjustAreaPortalState( this->edict, true ); + } + } +} + +void Door::DoorUse + ( + Event *ev + ) + + { + Entity *other; + qboolean respond; + Event *e; + + other = ev->GetEntity( 1 ); + + respond = ( ( ( respondto & TRIGGER_PLAYERS ) && other->isClient() ) || + ( ( respondto & TRIGGER_MONSTERS ) && other->isSubclassOf( Actor ) ) ); + + if ( !respond ) + { + return; + } + + // only allow use when not triggerd by other events + if ( health || ( spawnflags & ( DOOR_AUTO_OPEN | DOOR_TARGETED ) ) ) + { + if ( other->isSubclassOf( Sentient ) && ( state == STATE_CLOSED ) ) + { + if ( health ) + { + gi.SendServerCommand( NULL, "print \"This door is jammed.\"" ); + } + else if ( spawnflags & DOOR_TARGETED ) + { + Sound( "door_triggered", CHAN_VOICE ); + } + } + + if ( spawnflags & DOOR_AUTO_OPEN && locked && other->isSubclassOf( Player ) && sound_locked.length() ) + { + other->Sound( sound_locked, CHAN_VOICE ); + } + + return; + } + + assert( master ); + if ( !master ) + { + // bulletproofing + master = this; + } + + if ( master->state == STATE_CLOSED ) + { + e = new Event( EV_Door_TryOpen ); + e->AddEntity( other ); + master->ProcessEvent( e ); + } + else if ( master->state == STATE_OPEN ) + { + e = new Event( EV_Door_Close ); + e->AddEntity( other ); + master->ProcessEvent( e ); + } + } + +void Door::DoorFire + ( + Event *ev + ) + + { + Event *e; + Entity *other; + + other = ev->GetEntity( 1 ); + + assert( master == this ); + if ( master != this ) + { + gi.Error( ERR_DROP, "DoorFire: master != self" ); + } + + // no more messages + SetMessage( NULL ); + + // reset health in case we were damage triggered + health = max_health; + + // will be reset upon return + takedamage = DAMAGE_NO; + + if ( ( spawnflags & ( DOOR_TOGGLE | DOOR_START_OPEN ) ) && ( state == STATE_OPENING || state == STATE_OPEN ) ) + { + spawnflags &= ~DOOR_START_OPEN; + ProcessEvent( EV_Door_Close ); + } + else + { + e = new Event( EV_Door_Open ); + e->AddEntity( other ); + ProcessEvent( e ); + } + } + +void Door::DoorBlocked + ( + Event *ev + ) + +{ + Event *e; + Entity *other; + + assert( master ); + if( ( master ) && ( master != this ) ) + { + master->ProcessEvent( new Event( ev ) ); + return; + } + + if( lastblocktime > level.time ) + { + return; + } + + lastblocktime = level.time + 0.3; + + other = ev->GetEntity( 1 ); + + if( other->IsSubclassOfActor() ) + { + edict->r.contents = CONTENTS_WEAPONCLIP; + setSolidType( SOLID_BSP ); + } + else + { + if( dmg ) + { + other->Damage( this, this, ( int )dmg, origin, vec_zero, vec_zero, 0, 0, MOD_CRUSH ); + } + + // + // if we killed him, lets keep on going + // + if( other->deadflag ) + { + return; + } + + if( state == STATE_OPENING || state == STATE_OPEN ) + { + spawnflags &= ~DOOR_START_OPEN; + ProcessEvent( EV_Door_Close ); + } + else + { + e = new Event( EV_Door_Open ); + e->AddEntity( other ); + ProcessEvent( e ); + } + } +} + +void Door::FieldTouched + ( + Event *ev + ) + + { + Entity *other; + + other = ev->GetEntity( 1 ); + + if ( !other ) + return; + + if ( ( state != STATE_OPEN ) && !( spawnflags & DOOR_AUTO_OPEN ) && !other->isSubclassOf( Actor ) ) + return; + + TryOpen( ev ); + } + +qboolean Door::CanBeOpenedBy + ( + Entity *ent + ) + + { + assert( master ); + if ( ( master ) && ( master != this ) ) + { + return master->CanBeOpenedBy( ent ); + } + + if ( !locked && !key.length() ) + { + return true; + } + + if ( ent && ent->isSubclassOf( Sentient ) && ( ( Sentient * )ent )->HasItem( key.c_str() ) ) + { + return true; + } + + return false; + } + +void Door::TryOpen + ( + Event *ev + ) + + { + Entity *other; + Event *event; + + //FIXME + // hack so that doors aren't triggered by guys when game starts. + // have to fix delay that guys go through before setting up their threads + if ( level.time < 0.4 ) + { + return; + } + + other = ev->GetEntity( 1 ); + + assert( master ); + if ( master && ( this != master ) ) + { + event = new Event( EV_Door_TryOpen ); + event->AddEntity( other ); + master->ProcessEvent( event ); + return; + } + + if ( !other || other->deadflag ) + { + return; + } + + if ( locked ) + { + if ( next_locked_time <= level.time ) + { + if ( sound_locked.length() > 1 && !other->isSubclassOf( Actor ) ) + { + other->Sound( sound_locked, CHAN_VOICE ); + } + else if ( other->isSubclassOf( Player ) ) + { + other->Sound( "snd_locked", CHAN_VOICE ); + // gi.centerprintf ( other->edict, "This door is locked." ); + } + } + + // Always increment next locked time + + next_locked_time = level.time + 0.5; + + // locked doors don't open for anyone + return; + } + + if ( !CanBeOpenedBy( other ) ) + { + Item *item; + ClassDef *cls; + + if ( other->isClient() ) + { + cls = getClass( key.c_str() ); + if ( !cls ) + { + gi.DPrintf( "No item named '%s'\n", key.c_str() ); + return; + } + item = ( Item * )cls->newInstance(); + item->CancelEventsOfType( EV_Item_DropToFloor ); + item->CancelEventsOfType( EV_Remove ); + item->ProcessPendingEvents(); + gi.centerprintf ( other->edict, "You need the %s", item->getName().c_str() ); + delete item; + } + return; + } + + // once we're opened by an item, we no longer need that item to open the door + key = ""; + + if ( Message().length() ) + { + gi.centerprintf( other->edict, Message().c_str() ); + Sound( sound_message, CHAN_VOICE ); + } + + event = new Event( EV_Door_Fire ); + event->AddEntity( other ); + ProcessEvent( event ); + } + +void Door::SpawnTriggerField + ( + Vector fmins, + Vector fmaxs + ) + + { + TouchField *trig; + Vector min; + Vector max; + + min = fmins - Vector( "60 60 8" ); + max = fmaxs + Vector( "60 60 8" ); + + trig = new TouchField; + trig->Setup( this, EV_Door_TriggerFieldTouched, min, max, respondto ); + + trigger = trig->entnum; + } + + +void Door::LinkDoors + ( + Event *ev + ) + +{ + Entity *entptr; + Door *ent; + Door *next; + Vector cmins; + Vector cmaxs; + int i; + + setSolidType( SOLID_BSP ); + setMoveType( MOVETYPE_PUSH ); + + if( nextdoor ) + { + // already linked by another door + return; + } + + // master doors own themselves + master = this; + + if( spawnflags & DOOR_DONT_LINK ) + { + // don't want to link this door + nextdoor = entnum; + return; + } + + cmins = absmin; + cmaxs = absmax; + + ent = this; + for( entptr = this; entptr; entptr = ( Entity * )G_FindClass( entptr, getClassID() ) ) + { + next = ( Door * )entptr; + if( !ent->DoorTouches( next ) ) + { + continue; + } + + if( next->nextdoor ) + { + error( "Door::LinkDoors", "cross connected doors. Targetname = %s entity %d\n", TargetName().c_str(), entnum ); + } + + ent->nextdoor = next->entnum; + ent = next; + + for( i = 0; i < 3; i++ ) + { + if( ent->absmin[ i ] < cmins[ i ] ) + { + cmins[ i ] = ent->absmin[ i ]; + } + if( ent->absmax[ i ] > cmaxs[ i ] ) + { + cmaxs[ i ] = ent->absmax[ i ]; + } + } + + // set master door + ent->master = this; + + if( ent->health ) + { + health = ent->health; + } + + if( ent->Targeted() ) + { + if( !Targeted() ) + { + SetTargetName( ent->TargetName() ); + } + else if( strcmp( TargetName(), ent->TargetName() ) ) + { + // not a critical error, but let them know about it. + gi.DPrintf( "cross connected doors\n" ); + + ent->SetTargetName( TargetName() ); + } + } + + if( ent->Message().length() ) + { + if( Message().length() && !strcmp( Message().c_str(), ent->Message().c_str() ) ) + { + // not a critical error, but let them know about it. + gi.DPrintf( "Different messages on linked doors. Targetname = %s", TargetName().c_str() ); + } + + // only master should have a message + SetMessage( ent->Message().c_str() ); + ent->SetMessage( NULL ); + } + } + + // make the chain a loop + ent->nextdoor = entnum; + + // open up any portals we control + if( spawnflags & DOOR_START_OPEN ) + { + gi.AdjustAreaPortalState( this->edict, true ); + } + + // shootable or targeted doors don't need a trigger + if( health || ( spawnflags & DOOR_TARGETED ) ) + { + // Don't let the player trigger the door + return; + } + + // Don't spawn trigger field when set to toggle + if( !( spawnflags & DOOR_TOGGLE ) ) + { + SpawnTriggerField( cmins, cmaxs ); + } +} + +void Door::SetTime + ( + Event *ev + ) + + { + traveltime = ev->GetFloat( 1 ); + if ( traveltime < FRAMETIME ) + { + traveltime = FRAMETIME; + } + + speed = 1.0f / traveltime; + } + +void Door::LockDoor + ( + Event *ev + ) + +{ + if( !level.PreSpawned() ) + ScriptError( "Cannot lock door before level prespawn" ); + + SetLocked( true ); +} + +void Door::UnlockDoor + ( + Event *ev + ) + +{ + SetLocked( false ); +} + +qboolean Door::DoorTouches + ( + Door *e1 + ) + +{ + if( e1->absmin.x > absmax.x ) + { + return false; + } + if( e1->absmin.y > absmax.y ) + { + return false; + } + if( e1->absmin.z > absmax.z ) + { + return false; + } + if( e1->absmax.x < absmin.x ) + { + return false; + } + if( e1->absmax.y < absmin.y ) + { + return false; + } + if( e1->absmax.z < absmin.z ) + { + return false; + } + + return true; +} + +void Door::UpdatePathConnection + ( + void + ) + +{ + if( BlocksAIMovement() ) + { + DisconnectPaths(); + } + else + { + ConnectPaths(); + } +} + +void Door::SetLocked + ( + qboolean newLocked + ) + +{ + if( locked == newLocked ) + return; + + locked = newLocked; + + UpdatePathConnection(); +} + +void Door::SetState + ( + int newState + ) + +{ + if( state == newState ) + return; + + state = newState; + + UpdatePathConnection(); +} + +qboolean Door::BlocksAIMovement + ( + void + ) const + +{ + return ( locked || state == STATE_OPEN ); +} + +qboolean Door::AIDontFace + ( + void + ) const + +{ + return ( locked || state == STATE_OPEN ); +} + +/*****************************************************************************/ +/*QUAKED func_rotatingdoor (0 0.25 0.5) ? START_OPEN OPEN_DIRECTION DOOR_DONT_LINK NOT_PLAYERS NOT_MONSTERS TOGGLE AUTO_OPEN TARGETED +if two doors touch, they are assumed to be connected and operate as a unit. + +TOGGLE causes the door to wait in both the start and end states for a trigger event. +DOOR_DONT_LINK is for when you have two doors that are touching but you want to operate independently. + +START_OPEN causes the door to move to its destination when spawned, and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors). +OPEN_DIRECTION indicates which direction to open when START_OPEN is set. +AUTO_OPEN causes the door to open when a player is near instead of waiting for the player to use the door. +TARGETED door is only operational from triggers or script + +"message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet +"openangle" how wide to open the door +"angle" determines the opening direction. point toward the middle of the door (away from the hinge) +"targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door. +"health" if set, door must be shot open +"time" move time (0.3 default) +"wait" wait before returning (3 default, -1 = never return) +"dmg" damage to inflict when blocked (0 default) +"key" The item needed to open this door (default nothing) + +"sound_stop" Specify the sound that plays when the door stops moving (default global door_stop) +"sound_move" Specify the sound that plays when the door opens or closes (default global door_moving) +"sound_message" Specify the sound that plays when the door displays a message +"sound_locked" Specify the sound that plays when the door is locked + +******************************************************************************/ + +Event EV_RotatingDoor_OpenAngle + ( + "openangle", + EV_DEFAULT, + "f", + "open_angle", + "Sets the open angle of the door.", + EV_NORMAL + ); + +CLASS_DECLARATION( Door, RotatingDoor, "func_rotatingdoor" ) +{ + { &EV_Door_DoClose, &RotatingDoor::DoClose }, + { &EV_Door_DoOpen, &RotatingDoor::DoOpen }, + { &EV_RotatingDoor_OpenAngle, &RotatingDoor::OpenAngle }, + { NULL, NULL } +}; + +void RotatingDoor::DoOpen( Event *ev ) +{ + Vector ang; + + if( previous_state == STATE_CLOSED ) + { + if( ev->NumArgs() > 0 ) + { + Entity *other; + Vector p; + + other = ev->GetEntity( 1 ); + + if( other ) + { + Vector vMMOrigin = mins + maxs; + Vector vMMCenter = vMMOrigin * 0.5f; + Vector vDoorDir; + Vector vPerpDir; + + vMMOrigin -= vMMCenter; + + vDoorDir[ 0 ] = dir[ 1 ]; + vDoorDir[ 1 ] = -dir[ 0 ]; + vDoorDir[ 2 ] = dir[ 2 ]; + + p = other->origin - origin; + + vPerpDir = p; + vPerpDir.normalize(); + + if( m_bAlwaysAway ) + { + diropened = DotProduct( p, vDoorDir ); + + if( DotProduct( dir, vMMOrigin ) > 0.0f ) { + diropened = -diropened; + } + } + else + { + diropened = DotProduct( dir, vMMOrigin ); + } + } + else + { + ScriptError( "Door trying to be opened with a NULL entity." ); + } + } + else + { + diropened = 0 - init_door_direction; + } + } + else + { + diropened = -init_door_direction; + } + + if( diropened <= 0.0f ) + { + ang = startangle + Vector( 0.0f, angle, 0.0f ); + } + else + { + ang = startangle - Vector( 0.0f, angle, 0.0f ); + } + + MoveTo( origin, ang, fabs( speed*angle ), EV_Door_OpenEnd ); +} + +void RotatingDoor::DoClose + ( + Event *ev + ) + +{ + MoveTo( origin, startangle, fabs( speed*angle ), EV_Door_CloseEnd ); +} + +void RotatingDoor::OpenAngle + ( + Event *ev + ) + + { + angle = ev->GetFloat( 1 ); + } + +RotatingDoor::RotatingDoor() + { + if ( LoadingSavegame ) + { + return; + } + startangle = angles; + + angle = 90; + + init_door_direction = (spawnflags & DOOR_OPEN_DIRECTION); + } + +/*****************************************************************************/ +/*QUAKED func_door (0 0.25 0.5) ? START_OPEN x DOOR_DONT_LINK NOT_PLAYERS NOT_MONSTERS TOGGLE AUTO_OPEN TARGETED +if two doors touch, they are assumed to be connected and operate as a unit. + +TOGGLE causes the door to wait in both the start and end states for a trigger event. +DOOR_DONT_LINK is for when you have two doors that are touching but you want to operate independently. + +START_OPEN causes the door to move to its destination when spawned, and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors). +OPEN_DIRECTION indicates which direction to open when START_OPEN is set. +AUTO_OPEN causes the door to open when a player is near instead of waiting for the player to use the door. +TARGETED door is only operational from triggers or script + +"message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet +"angle" determines the opening direction. point toward the middle of the door (away from the hinge) +"targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door. +"health" if set, door must be shot open +"speed" move speed (100 default) +"time" move time (1/speed default, overides speed) +"wait" wait before returning (3 default, -1 = never return) +"lip" lip remaining at end of move (8 default) +"dmg" damage to inflict when blocked (0 default) +"key" The item needed to open this door (default nothing) + +"sound_stop" Specify the sound that plays when the door stops moving (default global door_stop) +"sound_move" Specify the sound that plays when the door opens or closes (default global door_moving) +"sound_message" Specify the sound that plays when the door displays a message +"sound_locked" Specify the sound that plays when the door is locked + +******************************************************************************/ + +Event EV_SlidingDoor_Setup + ( + "setup", + EV_CODEONLY, + NULL, + NULL, + "Sets up the sliding door.", + EV_NORMAL + ); +Event EV_SlidingDoor_SetLip + ( + "lip", + EV_DEFAULT, + "f", + "lip", + "Sets the lip of the sliding door.", + EV_NORMAL + ); +Event EV_SlidingDoor_SetSpeed + ( + "speed", + EV_DEFAULT, + "f", + "speed", + "Sets the speed of the sliding door.", + EV_NORMAL + ); + +CLASS_DECLARATION( Door, SlidingDoor, "func_door" ) + { + { &EV_Door_DoClose, &SlidingDoor::DoClose }, + { &EV_Door_DoOpen, &SlidingDoor::DoOpen }, + { &EV_SlidingDoor_Setup, &SlidingDoor::Setup }, + { &EV_SlidingDoor_SetLip, &SlidingDoor::SetLip }, + { &EV_SlidingDoor_SetSpeed, &SlidingDoor::SetSpeed }, + { &EV_SetAngle, &SlidingDoor::SetMoveDir }, + { NULL, NULL } + }; + +void SlidingDoor::SetMoveDir + ( + Event *ev + ) + + { + float t; + float angle; + + angle = ev->GetFloat( 1 ); + movedir = G_GetMovedir( angle ); + dir = movedir; + t = dir[ 0 ]; + dir[ 0 ] = -dir[ 1 ]; + dir[ 1 ] = t; + } + +void SlidingDoor::DoOpen + ( + Event *ev + ) + + { + MoveTo( pos2, angles, speed*totalmove, EV_Door_OpenEnd ); + } + +void SlidingDoor::DoClose + ( + Event *ev + ) + + { + MoveTo( pos1, angles, speed*totalmove, EV_Door_CloseEnd ); + } + +void SlidingDoor::SetLip + ( + Event *ev + ) + + { + lip = ev->GetFloat( 1 ); + CancelEventsOfType( EV_SlidingDoor_Setup ); + PostEvent( EV_SlidingDoor_Setup, EV_POSTSPAWN ); + } + +void SlidingDoor::SetSpeed + ( + Event *ev + ) + + { + basespeed = ev->GetFloat( 1 ); + CancelEventsOfType( EV_SlidingDoor_Setup ); + PostEvent( EV_SlidingDoor_Setup, EV_POSTSPAWN ); + } + +void SlidingDoor::Setup + ( + Event *ev + ) + + { + totalmove = fabs( movedir * size ) - lip; + pos1 = origin; + pos2 = pos1 + movedir * totalmove; + + if ( basespeed ) + { + speed = basespeed / totalmove; + } + } + +SlidingDoor::SlidingDoor() + { + if ( LoadingSavegame ) + { + return; + } + lip = 8; + basespeed = 0; + movedir = G_GetMovedir( 0 ); + + PostEvent( EV_SlidingDoor_Setup, EV_POSTSPAWN ); + } + +/*****************************************************************************/ +/*QUAKED script_door (0 0.5 1) ? START_OPEN x DOOR_DONT_LINK NOT_PLAYERS NOT_MONSTERS TOGGLE AUTO_OPEN TARGETED +if two doors touch, they are assumed to be connected and operate as a unit. + +TOGGLE causes the door to wait in both the start and end states for a trigger event. +DOOR_DONT_LINK is for when you have two doors that are touching but you want to operate independently. + +START_OPEN causes the door to move to its destination when spawned, and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors). +OPEN_DIRECTION indicates which direction to open when START_OPEN is set. +AUTO_OPEN causes the door to open when a player is near instead of waiting for the player to use the door. +TARGETED door is only operational from triggers or script + +"message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet +"angle" determines the opening direction. point toward the middle of the door (away from the hinge) +"targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door. +"health" if set, door must be shot open +"speed" move speed (100 default) +"time" move time (1/speed default, overides speed) +"wait" wait before returning (3 default, -1 = never return) +"dmg" damage to inflict when blocked (0 default) +"key" The item needed to open this door (default nothing) +"initthread" code to execute to setup the door (optional) +"openthread" code to execute when opening the door (required) + The openthread should send the "dooropened" event to the door, when it is completely open +"closethread" code to execute when closing the door (required) + The closethread should send the "doorclosed" event to the door, when it is completely closed + +"sound_stop" Specify the sound that plays when the door stops moving (default global door_stop) +"sound_move" Specify the sound that plays when the door opens or closes (default global door_moving) +"sound_message" Specify the sound that plays when the door displays a message +"sound_locked" Specify the sound that plays when the door is locked + +******************************************************************************/ + +Event EV_ScriptDoor_DoInit + ( + "doinit", + EV_DEFAULT, + NULL, + NULL, + "Sets up the script door.", + EV_NORMAL + ); +Event EV_ScriptDoor_SetOpenThread + ( + "openthread", + EV_DEFAULT, + "s", + "openthread", + "Set the thread to run when the door is opened (required).", + EV_NORMAL + ); +Event EV_ScriptDoor_SetCloseThread + ( + "closethread", + EV_DEFAULT, + "s", + "closethread", + "Set the thread to run when the door is closed (required).", + EV_NORMAL + ); +Event EV_ScriptDoor_SetInitThread + ( + "initthread", + EV_DEFAULT, + "s", + "initthread", + "Set the thread to run when the door is initialized (optional).", + EV_NORMAL + ); + +CLASS_DECLARATION( Door, ScriptDoor, "script_door" ) + { + { &EV_ScriptDoor_DoInit, &ScriptDoor::DoInit }, + { &EV_Door_DoClose, &ScriptDoor::DoClose }, + { &EV_Door_DoOpen, &ScriptDoor::DoOpen }, + { &EV_ScriptDoor_SetInitThread, &ScriptDoor::SetInitThread }, + { &EV_ScriptDoor_SetOpenThread, &ScriptDoor::SetOpenThread }, + { &EV_ScriptDoor_SetCloseThread, &ScriptDoor::SetCloseThread }, + { &EV_SetAngle, &ScriptDoor::SetMoveDir }, + { NULL, NULL } + }; + +void ScriptDoor::SetMoveDir + ( + Event *ev + ) + + { + float t; + float angle; + + angle = ev->GetFloat( 1 ); + movedir = G_GetMovedir( angle ); + dir = movedir; + t = dir[ 0 ]; + dir[ 0 ] = -dir[ 1 ]; + dir[ 1 ] = t; + } + +void ScriptDoor::SetOpenThread + ( + Event *ev + ) + { + openlabel.SetThread( ev->GetValue( 1 ) ); + } + +void ScriptDoor::SetCloseThread + ( + Event *ev + ) + { + closelabel.SetThread( ev->GetValue( 1 ) ); + } + +void ScriptDoor::DoInit + ( + Event *ev + ) + { + startorigin = origin; + doorsize = fabs( movedir * size ); + + if( initlabel.IsSet() ) + { + initlabel.Execute( this ); + } + } + +void ScriptDoor::DoOpen + ( + Event *ev + ) + + { + if( openlabel.IsSet() ) + { + openlabel.Execute( this ); + } + + if ( previous_state == STATE_CLOSED ) + { + diropened = 0; + if ( ev->NumArgs() > 0 ) + { + Entity *other; + Vector p; + + other = ev->GetEntity( 1 ); + p = other->origin - origin; + p.z = 0; + diropened = dir * p; + } + } + } + +void ScriptDoor::DoClose + ( + Event *ev + ) + { + if( closelabel.IsSet() ) + { + closelabel.Execute( this ); + } + } + +void ScriptDoor::SetInitThread + ( + Event *ev + ) + + { + initlabel.SetThread( ev->GetValue( 1 ) ); + } + +ScriptDoor::ScriptDoor() + { + if ( LoadingSavegame ) + { + return; + } + startangle = angles; + + // + // clear out the sounds if necessary + // scripted doors typically have their own sounds + // + sound_open_start = ""; + sound_open_end = ""; + sound_close_start = ""; + sound_close_end = ""; + + movedir = G_GetMovedir( 0 ); + + PostEvent( EV_ScriptDoor_DoInit, EV_POSTSPAWN ); + } diff --git a/code/game/doors.h b/code/game/doors.h new file mode 100644 index 00000000..f09dc1c8 --- /dev/null +++ b/code/game/doors.h @@ -0,0 +1,266 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// doors.h: Doors are environment objects that slide open when activated by triggers +// or when used by the player. +// + +#ifndef __DOORS_H__ +#define __DOORS_H__ + +#include "g_local.h" +#include "entity.h" +#include "trigger.h" +#include "scriptslave.h" + +extern Event EV_Door_TryOpen; +extern Event EV_Door_GoDown; +extern Event EV_Door_GoUp; +extern Event EV_Door_HitBottom; +extern Event EV_Door_HitTop; +extern Event EV_Door_Fire; +extern Event EV_Door_Link; +extern Event EV_Door_SetSpeed; +extern Event EV_Door_Lock; +extern Event EV_Door_Unlock; + +class Door; + +typedef SafePtr DoorPtr; + +class Door : public ScriptSlave + { + protected: + str sound_open_start; + str sound_open_end; + str sound_close_start; + str sound_close_end; + str sound_message; + str sound_locked; + float lastblocktime; + float angle; + Vector dir; + float diropened; + int state; + int previous_state; + int trigger; + int nextdoor; + DoorPtr master; + float next_locked_time; + bool m_bAlwaysAway; + + void SetDir( Event *ev ); + void OpenEnd( Event *ev ); + void CloseEnd( Event *ev ); + void Close( Event *ev ); + void Open( Event *ev ); + void DoorUse( Event *ev ); + void DoorFire( Event *ev ); + void DoorBlocked( Event *ev ); + void FieldTouched( Event *ev ); + void TryOpen( Event *ev ); + void SpawnTriggerField( Vector fmins, Vector fmaxs ); + qboolean DoorTouches( Door *e1 ); + void LinkDoors( Event *ev ); + void SetTime( Event *ev ); + void LockDoor( Event *ev ); + void UnlockDoor( Event *ev ); + void SetOpenStartSound( str sound ); + void SetOpenStartSound( Event *ev ); + void SetOpenEndSound( str sound ); + void SetOpenEndSound( Event *ev ); + void SetCloseStartSound( Event *ev ); + void SetCloseStartSound( str sound ); + void SetCloseEndSound( Event *ev ); + void SetCloseEndSound( str sound ); + void SetMessageSound( str sound ); + void SetMessageSound( Event *ev ); + void SetLockedSound( str sound ); + void SetLockedSound( Event *ev ); + void SetWait( Event *ev ); + void SetDmg( Event *ev ); + void EventTrySolid( Event *ev ); + void EventAlwaysAway( Event *ev ); + void EventDoorType( Event *ev ); + + qboolean BlocksAIMovement( void ) const; + qboolean AIDontFace( void ) const; + + void UpdatePathConnection( void ); + void SetLocked( qboolean newLocked ); + void SetState( int newState ); + + public: + CLASS_PROTOTYPE( Door ); + + qboolean locked; + + Door(); + qboolean isOpen( void ); + qboolean isCompletelyClosed( void ); + qboolean CanBeOpenedBy( Entity *ent ); + virtual void Archive( Archiver &arc ); + }; + +inline void Door::Archive + ( + Archiver &arc + ) + { + ScriptSlave::Archive( arc ); + + arc.ArchiveString( &sound_open_start ); + arc.ArchiveString( &sound_open_end ); + arc.ArchiveString( &sound_close_start ); + arc.ArchiveString( &sound_close_end ); + arc.ArchiveString( &sound_message ); + arc.ArchiveString( &sound_locked ); + if ( arc.Loading() ) + { + SetOpenStartSound( sound_open_start ); + SetOpenEndSound( sound_open_end ); + SetCloseStartSound( sound_close_start ); + SetCloseEndSound( sound_close_end ); + SetMessageSound( sound_message ); + SetLockedSound( sound_locked ); + } + arc.ArchiveFloat( &lastblocktime ); + arc.ArchiveFloat( &angle ); + arc.ArchiveVector( &dir ); + arc.ArchiveFloat( &diropened ); + arc.ArchiveInteger( &state ); + arc.ArchiveInteger( &previous_state ); + arc.ArchiveInteger( &trigger ); + arc.ArchiveInteger( &nextdoor ); + arc.ArchiveSafePointer( &master ); + arc.ArchiveBoolean( &locked ); + arc.ArchiveFloat( &next_locked_time ); + } + +class RotatingDoor : public Door + { + protected: + float angle; + Vector startangle; + int init_door_direction; + + public: + CLASS_PROTOTYPE( RotatingDoor ); + + void DoOpen( Event *ev ); + void DoClose( Event *ev ); + void OpenAngle( Event *ev ); + virtual void Archive( Archiver &arc ); + + RotatingDoor(); + }; + +inline void RotatingDoor::Archive + ( + Archiver &arc + ) + { + Door::Archive( arc ); + + arc.ArchiveFloat( &angle ); + arc.ArchiveVector( &startangle ); + arc.ArchiveInteger( &init_door_direction ); + } + +class SlidingDoor : public Door + { + protected: + float totalmove; + float lip; + Vector pos1; + Vector pos2; + float basespeed; + Vector movedir; + + public: + CLASS_PROTOTYPE( SlidingDoor ); + + void SetMoveDir( Event *ev ); + void Setup( Event *ev ); + void SetLip( Event *ev ); + void SetSpeed( Event *ev ); + void DoOpen( Event *ev ); + void DoClose( Event *ev ); + virtual void Archive( Archiver &arc ); + + SlidingDoor(); + }; + +inline void SlidingDoor::Archive + ( + Archiver &arc + ) + { + Door::Archive( arc ); + + arc.ArchiveFloat( &totalmove ); + arc.ArchiveFloat( &lip ); + arc.ArchiveVector( &pos1 ); + arc.ArchiveVector( &pos2 ); + arc.ArchiveVector( &movedir ); + arc.ArchiveFloat( &basespeed ); + } + +class ScriptDoor : public Door + { + protected: + ScriptThreadLabel initlabel; + ScriptThreadLabel openlabel; + ScriptThreadLabel closelabel; + float doorsize; + Vector startangle; + Vector startorigin; + Vector movedir; + + public: + CLASS_PROTOTYPE( ScriptDoor ); + + void SetMoveDir( Event *ev ); + void DoInit( Event *ev ); + void DoOpen( Event *ev ); + void DoClose( Event *ev ); + void SetOpenThread( Event *ev ); + void SetCloseThread( Event *ev ); + void SetInitThread( Event *ev ); + virtual void Archive( Archiver &arc ); + ScriptDoor(); + }; + +inline void ScriptDoor::Archive + ( + Archiver &arc + ) + { + Door::Archive( arc ); + + arc.ArchiveFloat( &doorsize ); + arc.ArchiveVector( &startangle ); + arc.ArchiveVector( &startorigin ); + arc.ArchiveVector( &movedir ); + } + +#endif /* doors.h */ diff --git a/code/game/earthquake.cpp b/code/game/earthquake.cpp new file mode 100644 index 00000000..97d2baaf --- /dev/null +++ b/code/game/earthquake.cpp @@ -0,0 +1,310 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// earthquake.cpp: Earthquake trigger causes a localized earthquake when triggered. +// The earthquake effect is visible to the user as the shaking of his screen. +// +#include "earthquake.h" +#include "weapon.h" +#include "sentient.h" + +/*****************************************************************************/ +/*QUAKED func_viewjitter (0 0.25 0.5) (-8 -8 -8) (8 8 8) +Causes a radius view jitter +"radius" sets the max effective range if the view jitter. Default is 128 +"edgeeffect" set the fraction of the total jitter to apply at the max range. Default is 0.2 +"jitteramount" sets the amount to jitter the view. Set in angles as "pitch yaw roll". Default is "2 2 3" +"duration" set how long the view jitter should last. Default is 0 (instantanious) +"timedecay" sets how the jitter angles will fall off over the jitter's duraction in degrees per second. Default is "2 2 3" +"donedeath" makes the view jitter remove itself after being fired once. Any non-zero value will work. +******************************************************************************/ + +Event EV_ViewJitter_Think + ( + "_viewjitter_think", + EV_DEFAULT, + 0, + 0, + "think function for the viewjitter." + ); + +Event EV_ViewJitter_Radius + ( + "radius", + EV_DEFAULT, + "f", + "radius", + "Sets the max radius of the view jitter. 0 affects all" + ); + +Event EV_ViewJitter_EdgeEffect + ( + "edgeeffect", + EV_DEFAULT, + "f", + "fraction", + "Sets the fraction of the jitter to apply at the max radius" + ); + +Event EV_ViewJitter_Amount + ( + "jitteramount", + EV_DEFAULT, + "v", + "jitterangles", + "Sets the jitter angles to apply to the player" + ); + +Event EV_ViewJitter_Duration + ( + "duration", + EV_DEFAULT, + "f", + "time", + "Sets the length of time it should last. 0 will be instantanious" + ); + +Event EV_ViewJitter_TimeDecay + ( + "timedecay", + -1, + "v", + "decayrate", + "Sets jitter decay per second" + ); + +Event EV_ViewJitter_DoneDeath + ( + "donedeath", + EV_DEFAULT, + 0, + 0, + "Makes the view jitter only happen once" + ); + +CLASS_DECLARATION( Trigger, ViewJitter, "func_viewjitter" ) +{ + { &EV_Touch, NULL }, + { &EV_Trigger_Effect, &ViewJitter::EventActivateJitter }, + { &EV_ViewJitter_Radius, &ViewJitter::EventSetRadius }, + { &EV_ViewJitter_EdgeEffect, &ViewJitter::EventSetEdgeEffect }, + { &EV_ViewJitter_Amount, &ViewJitter::EventSetAmount }, + { &EV_ViewJitter_Duration, &ViewJitter::EventSetDuration }, + { &EV_ViewJitter_TimeDecay, &ViewJitter::EventSetTimeDecay }, + { &EV_ViewJitter_DoneDeath, &ViewJitter::EventSetDoneDeath }, + { &EV_ViewJitter_Think, &ViewJitter::EventJitterThink }, + { NULL, NULL } +}; + +ViewJitter::ViewJitter() +{ + if( LoadingSavegame ) + { + return; + } + + edict->r.svFlags |= SVF_NOCLIENT; + + m_fRadius = 16384.0f; + m_fEdgeEffect = 0.2f; + + m_vJitterStrength = Vector( 2, 2, 3 ); + m_vTimeDecay = Vector( 2, 2, 3 ); + + m_fDuration = 0; + + m_bDoneDeath = qfalse; +} + +ViewJitter::ViewJitter( Vector vOrigin, float fRadius, float fEdgeEffect, Vector vStrength, float fDuration, Vector vTimeDecay, float fStartDecay ) +{ + if( LoadingSavegame ) + { + return; + } + + setOrigin( vOrigin ); + m_fEdgeEffect = fEdgeEffect; + + // square the raidus + m_fRadius = fRadius * fRadius; + + m_vJitterStrength = vStrength; + m_vTimeDecay = vTimeDecay; + + m_fDuration = fDuration; + + m_bDoneDeath = false; + m_fTimeRunning = 0; + + PostEvent( EV_ViewJitter_Think, fStartDecay ); +} + +void ViewJitter::EventActivateJitter + ( + Event *ev + ) + +{ + m_fTimeRunning = 0; + PostEvent( EV_ViewJitter_Think, 0 ); +} + +void ViewJitter::EventJitterThink + ( + Event *ev + ) + +{ + int i; + int iNumSents; + float fDist; + float fRadiusDecay; + Vector vCurrJitter; + Vector vApplyJitter; + Vector vDelta; + Sentient *pSent; + + m_fTimeRunning += level.frametime; + + vDelta = m_vJitterStrength - m_vTimeDecay * m_fTimeRunning; + + iNumSents = SentientList.NumObjects(); + + for( i = 1; i <= iNumSents; i++ ) + { + pSent = SentientList.ObjectAt( i ); + + if( pSent->deadflag ) { + continue; + } + + fRadiusDecay = ( pSent->origin - origin ).lengthSquared(); + if( fRadiusDecay <= m_fRadius ) + { + Vector vVariation; + + if( m_fEdgeEffect == 1.0f ) + { + vApplyJitter = vDelta; + } + else + { + fDist = sqrt( fRadiusDecay ); + vApplyJitter = Vector( ( 1.0f - fDist * ( m_fEdgeEffect / m_fRadius ) ) * vDelta[ 0 ], 0, 0 ); + } + + if( pSent->m_vViewVariation[ 0 ] <= vApplyJitter[ 0 ] ) + vVariation[ 0 ] = vApplyJitter[ 0 ]; + else + vVariation[ 0 ] = pSent->m_vViewVariation[ 0 ]; + + if( pSent->m_vViewVariation[ 1 ] <= vApplyJitter[ 1 ] ) + vVariation[ 1 ] = vApplyJitter[ 1 ]; + else + vVariation[ 1 ] = pSent->m_vViewVariation[ 1 ]; + + if( pSent->m_vViewVariation[ 2 ] <= vApplyJitter[ 2 ] ) + vVariation[ 2 ] = vApplyJitter[ 2 ]; + else + vVariation[ 2 ] = pSent->m_vViewVariation[ 2 ]; + + pSent->m_vViewVariation = vVariation; + } + } + + if( m_fDuration > 0.0f ) + { + if( m_fTimeRunning <= m_fDuration || !m_bDoneDeath ) + { + PostEvent( EV_ViewJitter_Think, level.frametime ); + } + else + { + ProcessEvent( EV_Remove ); + } + } + else if( m_bDoneDeath ) + { + ProcessEvent( EV_Remove ); + } +} + +void ViewJitter::EventSetRadius + ( + Event *ev + ) + +{ + float rad = ev->GetFloat( 1 ); + + m_fRadius = rad * rad; + if( m_fRadius < 1.0f ) + { + m_fRadius = 16384.0f; + } +} + +void ViewJitter::EventSetEdgeEffect + ( + Event *ev + ) + +{ + m_fEdgeEffect = ev->GetFloat( 1 ); +} + +void ViewJitter::EventSetAmount + ( + Event *ev + ) + +{ + m_vJitterStrength = ev->GetVector( 1 ); +} + +void ViewJitter::EventSetDuration + ( + Event *ev + ) + +{ + m_fDuration = ev->GetFloat( 1 ); +} + +void ViewJitter::EventSetTimeDecay + ( + Event *ev + ) + +{ + m_vTimeDecay = ev->GetVector( 1 ); +} + +void ViewJitter::EventSetDoneDeath + ( + Event *ev + ) + +{ + m_bDoneDeath = qtrue; +} diff --git a/code/game/earthquake.h b/code/game/earthquake.h new file mode 100644 index 00000000..adcd8871 --- /dev/null +++ b/code/game/earthquake.h @@ -0,0 +1,80 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// earthquake.h: Earthquake trigger causes a localized earthquake when triggered. +// The earthquake effect is visible to the user as the shaking of his screen. +// + +#ifndef __EARTHQUAKE_H__ +#define __EARTHQUAKE_H__ + +#include "g_local.h" +#include "trigger.h" + +#define EARTHQUAKE_STRENGTH 50 + +class ViewJitter : public Trigger { +protected: + float m_fRadius; + float m_fEdgeEffect; + Vector m_vJitterStrength; + float m_fDuration; + Vector m_vTimeDecay; + qboolean m_bDoneDeath; + float m_fTimeRunning; + +public: + CLASS_PROTOTYPE( ViewJitter ); + + ViewJitter(); + ViewJitter( Vector vOrigin, float fRadius, float fEdgeEffect, Vector vStrength, float fDuration, Vector vTimeDecay, float fStartDecay ); + + void EventActivateJitter( Event *ev ); + void EventJitterThink( Event *ev ); + void EventSetRadius( Event *ev ); + void EventSetEdgeEffect( Event *ev ); + void EventSetAmount( Event *ev ); + void EventSetDuration( Event *ev ); + void EventSetTimeDecay( Event *ev ); + void EventSetDoneDeath( Event *ev ); + + virtual void Archive( Archiver& arc ); +}; + +inline void ViewJitter::Archive + ( + Archiver &arc + ) + +{ + Trigger::Archive( arc ); + + arc.ArchiveFloat( &m_fRadius ); + arc.ArchiveFloat( &m_fEdgeEffect ); + arc.ArchiveVector( &m_vJitterStrength ); + arc.ArchiveFloat( &m_fDuration ); + arc.ArchiveVector( &m_vTimeDecay ); + arc.ArchiveBoolean( &m_bDoneDeath ); + arc.ArchiveFloat( &m_fTimeRunning ); +} + +#endif diff --git a/code/game/effectentity.cpp b/code/game/effectentity.cpp new file mode 100644 index 00000000..99e37ff6 --- /dev/null +++ b/code/game/effectentity.cpp @@ -0,0 +1,39 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// effectentity.cpp: Effect entity. + +#include "effectentity.h" + +CLASS_DECLARATION( Animate, EffectEntity, "effectentity" ) +{ + { NULL, NULL } +}; + +EffectEntity::EffectEntity + ( + void + ) + +{ + edict->s.eType = ET_MODELANIM; +} diff --git a/code/game/effectentity.h b/code/game/effectentity.h new file mode 100644 index 00000000..63c0c984 --- /dev/null +++ b/code/game/effectentity.h @@ -0,0 +1,38 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// actor.cpp: Base class for character AI. + +#ifndef __EFFECTENTITY_H__ +#define __EFFECTENTITY_H__ + +#include "animate.h" + +class EffectEntity : public Animate +{ +public: + CLASS_PROTOTYPE( EffectEntity ); + + EffectEntity(); +}; + +#endif // __EFFECTENTITY_H__ diff --git a/code/game/entity.cpp b/code/game/entity.cpp new file mode 100644 index 00000000..8f0214e6 --- /dev/null +++ b/code/game/entity.cpp @@ -0,0 +1,6924 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// entity.cpp: Base class for all enities that are controlled by Sin. If you have any +// object that should be called on a periodic basis and it is not an entity, +// then you have to have an dummy entity that calls it. +// +// An entity in Sin is any object that is not part of the world-> Any non-world +// object that is visible in Sin is an entity, although it is not required that +// all entities be visible to the player. Some objects are basically just virtual +// constructs that act as an instigator of certain actions, for example, some +// triggers are invisible and cannot be touched, but when activated by other +// objects can cause things to happen. +// +// All entities are capable of receiving messages from Sin or from other entities. +// Messages received by an entity may be ignored, passed on to their superclass, +// or acted upon by the entity itself. The programmer must decide on the proper +// action for the entity to take to any message. There will be many messages +// that are completely irrelevant to an entity and should be ignored. Some messages +// may require certain states to exist and if they are received by an entity when +// it these states don't exist may indicate a logic error on the part of the +// programmer or map designer and should be reported as warnings (if the problem is +// not severe enough for the game to be halted) or as errors (if the problem should +// not be ignored at any cost). +// + +#include "entity.h" +#include "scriptmaster.h" +#include "sentient.h" +#include "misc.h" +#include "specialfx.h" +#include "object.h" +#include "player.h" +#include "weaputils.h" +#include "soundman.h" +#include "../qcommon/qfiles.h" +#include "g_spawn.h" + +// Generic entity events +Event EV_SoundDone + ( + "saydone", + EV_DEFAULT, + NULL, + NULL, + "Even used by sound-only special case of say to trigger waittill saydone" + ); +Event EV_Classname + ( + "classname" , + EV_DEFAULT, + "s", + "nameOfClass", + "Determines what class to use for this entity,\n" + "this is pre-processed from the BSP at the start\n" + "of the level.", + EV_NORMAL + ); +Event EV_SpawnFlags + ( + "spawnflags", + EV_DEFAULT, + "i", + "flags", + "spawnflags from the BSP, these are set inside the editor", + EV_NORMAL + ); +Event EV_SetTeam + ( + "team", + EV_DEFAULT, + "s", + "moveTeam", + "used to make multiple entities move together.", + EV_NORMAL + ); +Event EV_Trigger + ( + "trigger", + EV_DEFAULT, + "s", + "name", + "Trigger the specified target or entity.", + EV_NORMAL + ); +Event EV_Activate + ( + "doActivate", + EV_DEFAULT, + "e", + "activatingEntity", + "General trigger event for all entities", + EV_NORMAL + ); +Event EV_Use + ( + "doUse", + EV_DEFAULT, + "e", + "activatingEntity", + "sent to entity when it is used by another entity", + EV_NORMAL + ); + +Event EV_FadeNoRemove + ( + "fade", + EV_DEFAULT, + "F[0,]F[0,1]", + "fadetime target_alpha", + "Fade the entity's alpha, reducing it by 0.03\n" + "every FRAMETIME, until it has faded out, does not remove the entity", + EV_NORMAL + ); + +Event EV_FadeOut + ( + "_fadeout", + EV_DEFAULT, + NULL, + NULL, + "Fade the entity's alpha and scale out, reducing it by 0.03\n" + "every FRAMETIME, until it has faded out, removes the entity\n" + "Once the entity has been completely faded, the entity is removed.", + EV_NORMAL + ); + +Event EV_Fade + ( + "fadeout", + EV_DEFAULT, + "F[0,]F[0,1]", + "fadetime target_alpha", + "Fade the entity's alpha and scale out, reducing it by 0.03\n" + "every FRAMETIME, until it has faded out. If fadetime or\n" + "target_alpha are defined, they will override the defaults.\n" + "Once the entity has been completely faded, the entity is removed.", + EV_NORMAL + ); +Event EV_FadeIn + ( + "fadein", + EV_DEFAULT, + "F[0,]F[0,1]", + "fadetime target_alpha", + "Fade the entity's alpha and scale in, increasing it by 0.03\n" + "every FRAMETIME, until it has faded completely in to 1.0.\n" + "If fadetime or target_alpha are defined, they will override\n" + "the default values.", + EV_NORMAL + ); + Event EV_Killed + ( + "killed", + EV_DEFAULT, + "eievvviiii", + "attacker damage inflictor position direction normal knockback damageflags meansofdeath location", + "event which is sent to an entity once it as been killed\n\nLocation values:\n-1 General\n0 Pelvis\n1 Lower Torso\n2 Mid Torso\n3 Upper Torso\n4 Neck\n5 Head\n6 RUpperArm\n7 RForearm\n8 RHand\n9 LUpperArm\n10 LForearm\n11 LHand\n12 RThigh\n13 RCalf\n14 RFoot\n15 LThigh\n16 LCalf\n17 LFoot\n", + EV_NORMAL + ); +Event EV_GotKill + ( + "gotkill" , + EV_DEFAULT, + "eieib", + "victim damage inflictor meansofdeath gib", + "event sent to attacker when an entity dies", + EV_NORMAL + ); +Event EV_Pain + ( + "pain", + EV_DEFAULT, + "eievvviiii", + "attacker damage inflictor position direction normal knockback damageflags meansofdeath location", + "used to inflict pain to an entity", + EV_NORMAL + ); +Event EV_Damage + ( + "damage", + EV_DEFAULT, + "eievvviiii", + "attacker damage inflictor position direction normal knockback damageflags meansofdeath location", + "general damage event used by all entities\n\nLocation values:\n-1 General\n0 Pelvis\n1 Lower Torso\n2 Mid Torso\n3 Upper Torso\n4 Neck\n5 Head\n6 RUpperArm\n7 RForearm\n8 RHand\n9 LUpperArm\n10 LForearm\n11 LHand\n12 RThigh\n13 RCalf\n14 RFoot\n15 LThigh\n16 LCalf\n17 LFoot\n", + EV_NORMAL + ); +Event EV_Stun + ( + "_stun", + EV_DEFAULT, + "f", + "time", + "Stun this entity for the specified time", + EV_NORMAL + ); +Event EV_Kill + ( + "kill", + EV_CONSOLE, + NULL, + NULL, + "console based command to kill yourself if stuck.", + EV_NORMAL + ); +Event EV_Gib + ( + "gib", + EV_DEFAULT, + "iIFS", + "number power scale gibmodel", + "causes entity to spawn a number of gibs", + EV_NORMAL + ); +Event EV_Hurt + ( + "hurt", + EV_DEFAULT, + "iSV", + "damage means_of_death direction", + "Inflicts damage if the entity is damageable. If the number of damage\n" + "points specified in the command argument is greater or equal than the\n" + "entity's current health, it will be killed or destroyed.", + EV_NORMAL + ); +Event EV_Heal +( + "heal", + EV_DEFAULT, + "f", + "health", + "Adds health to an entity, 0-1 fraction of max_health" +); + +Event EV_TakeDamage + ( + "takedamage", + EV_DEFAULT, + NULL, + NULL, + "makes entity take damage.", + EV_NORMAL + ); +Event EV_NoDamage + ( + "nodamage", + EV_DEFAULT, + NULL, + NULL, + "entity does not take damage.", + EV_NORMAL + ); + +Event EV_Stationary + ( + "stationary", + EV_DEFAULT, + NULL, + NULL, + "entity does not move, causes no physics to be run on it.", + EV_NORMAL + ); + +// Physics events +Event EV_MoveDone + ( + "movedone", + EV_DEFAULT, + "e", + "finishedEntity", + "Sent to commanding thread when done with move .", + EV_NORMAL + ); +Event EV_Touch + ( + "doTouch", + EV_DEFAULT, + "e", + "touchingEntity", + "sent to entity when touched.", + EV_NORMAL + ); +Event EV_Blocked + ( + "doBlocked", + EV_DEFAULT, + "e", + "obstacle", + "sent to entity when blocked.", + EV_NORMAL + ); +Event EV_UseBoundingBox + ( + "usebbox", + EV_DEFAULT, + NULL, + NULL, + "do not perform perfect collision, use bounding box instead.", + EV_NORMAL + ); +Event EV_Gravity + ( + "gravity", + EV_DEFAULT, + "f", + "gravityValue", + "Change the gravity on this entity", + EV_NORMAL + ); +Event EV_Stop + ( + "stopped", + EV_DEFAULT, + NULL, + NULL, + "sent when entity has stopped bouncing for MOVETYPE_TOSS.", + EV_NORMAL + ); +Event EV_Attach + ( + "attach", + EV_DEFAULT, + "esI", + "parent tagname use_angles", + "attach this entity to the parent's legs tag called tagname", + EV_NORMAL + ); +Event EV_AttachModel + ( + "attachmodel", + EV_DEFAULT, + "ssFSBFFFFV", + "modelname tagname scale targetname detach_at_death removetime fadeintime fadeoutdelay fadetime offset", + "attach a entity with modelname to this entity to tag called tagname.\n" + "scale - scale of attached entities\n" + "targetname - targetname for attached entities\n" + "detach_at_death - when entity dies, should this model be detached.\n" + "removetime - when the entity should be removed, if not specified, never.\n" + "fadeintime - time to fade the model in over.\n" + "fadeoutdelay - time to wait until we fade the attached model out\n" + "fadeoutspeed - time the model fades out over\n" + "offset - vector offset for the model from the specified tag", + EV_NORMAL + ); +Event EV_RemoveAttachedModel + ( + "removeattachedmodel", + EV_DEFAULT, + "s", + "tagname", + "Removes the model attached to this entity at the specified tag.", + EV_NORMAL + ); +Event EV_Detach + ( + "detach", + EV_DEFAULT, + NULL, + NULL, + "detach this entity from its parent.", + EV_NORMAL + ); + +// script stuff +Event EV_Model + ( + "model", + EV_DEFAULT, + "e", + "modelName", + "set the model to modelName.", + EV_NORMAL + ); +Event EV_Entity_GetBrushModel + ( + "brushmodel", + EV_DEFAULT, + NULL, + NULL, + "get the brush modelName.", + EV_GETTER + ); +Event EV_Entity_GetModel + ( + "model", + EV_DEFAULT, + NULL, + NULL, + "get the modelName.", + EV_GETTER + ); +Event EV_Entity_SetModel + ( + "model", + EV_DEFAULT, + "e", + "modelName", + "set the model to modelName.", + EV_SETTER + ); +Event EV_Hide + ( + "hide", + EV_DEFAULT, + NULL, + NULL, + "hide the entity, opposite of show.", + EV_NORMAL + ); +Event EV_Show + ( + "show", + EV_DEFAULT, + NULL, + NULL, + "show the entity, opposite of hide.", + EV_NORMAL + ); +Event EV_BecomeSolid + ( + "solid", + EV_DEFAULT, + NULL, + NULL, + "make solid.", + EV_NORMAL + ); +Event EV_BecomeNonSolid + ( + "notsolid", + EV_DEFAULT, + NULL, + NULL, + "make non-solid.", + EV_NORMAL + ); +Event EV_Ghost + ( + "ghost", + EV_DEFAULT, + NULL, + NULL, + "make non-solid but still send to client regardless of hide status.", + EV_NORMAL + ); +Event EV_TouchTriggers + ( + "touchtriggers", + EV_DEFAULT, + NULL, + NULL, + "this entity should touch triggers.", + EV_NORMAL + ); + + +Event EV_Sound + ( + "playsound", + EV_DEFAULT, + "sIFS", + "soundName channel volume min_distance", + "play a sound coming from this entity.\n" + "default channel, CHAN_BODY.", + EV_NORMAL + ); +Event EV_StopSound + ( + "stopsound", + EV_DEFAULT, + "I", + "channel", + "stop the current sound on the specified channel.\n" + "default channel, CHAN_BODY.", + EV_NORMAL + ); +Event EV_Bind + ( + "bind", + EV_DEFAULT, + "eB", + "parent bind_child", + "bind this entity to the specified entity.", + EV_NORMAL + ); +Event EV_Unbind + ( + "unbind", + EV_DEFAULT, + NULL, + NULL, + "unbind this entity.", + EV_NORMAL + ); +Event EV_Glue + ( + "glue", + EV_DEFAULT, + "ei", + "parent glueAngles", + "glue this entity to the specified entity.", + EV_NORMAL + ); +Event EV_Unglue + ( + "unglue", + EV_DEFAULT, + NULL, + NULL, + "unglue this entity.", + EV_NORMAL + ); +Event EV_JoinTeam + ( + "joinTeam", + EV_DEFAULT, + "e", + "teamMember", + "join a bind team.", + EV_NORMAL + ); +Event EV_QuitTeam + ( + "quitTeam", + EV_DEFAULT, + NULL, + NULL, + "quit the current bind team", + EV_NORMAL + ); +Event EV_Entity_SetHealthOnly + ( + "healthonly", + EV_CONSOLE | EV_CHEAT, + "i", + "newHealth", + "set the health of the entity to newHealth without changing max_health", + EV_NORMAL + ); +Event EV_Entity_SetHealthOnly2 + ( + "healthonly", + EV_CONSOLE | EV_CHEAT, + "i", + "newHealth", + "set the health of the entity to newHealth without changing max_health", + EV_SETTER + ); +Event EV_Entity_SetMaxHealth + ( + "max_health", + EV_DEFAULT, + "i", + "newHealth", + "sets max_health without changing health", + EV_NORMAL + ); +Event EV_Entity_SetMaxHealth2 + ( + "max_health", + EV_DEFAULT, + "i", + "newHealth", + "sets max_health without changing health", + EV_SETTER + ); +Event EV_Entity_GetMaxHealth + ( + "max_health", + EV_DEFAULT, + NULL, + NULL, + "gets the entity's max health", + EV_GETTER + ); +Event EV_SetHealth + ( + "health", + EV_CONSOLE | EV_CHEAT, + "i", + "newHealth", + "set the health of the entity to newHealth", + EV_NORMAL + ); +Event EV_SetHealth2 + ( + "health", + EV_CONSOLE | EV_CHEAT, + "i", + "newHealth", + "set the health of the entity to newHealth", + EV_SETTER + ); +Event EV_Entity_GetHealth + ( + "health", + EV_DEFAULT, + NULL, + NULL, + "entity's health", + EV_GETTER + ); +Event EV_SetScale + ( + "scale", + EV_DEFAULT, + "f", + "newScale", + "set the scale of the entity", + EV_NORMAL + ); +Event EV_SetScale2 + ( + "scale", + EV_DEFAULT, + "f", + "newScale", + "set the scale of the entity", + EV_SETTER + ); +Event EV_GetScale + ( + "scale", + EV_DEFAULT, + "f", + "newScale", + "set the scale of the entity", + EV_GETTER + ); +Event EV_SetSize + ( + "setsize", + EV_DEFAULT, + "vv", + "mins maxs", + "Set the bounding box of the entity to mins and maxs.", + EV_NORMAL + ); +Event EV_SetMins + ( + "_setmins", + EV_DEFAULT, + "v", + "mins", + "Set the mins of the bounding box of the entity to mins.", + EV_NORMAL + ); +Event EV_SetMaxs + ( + "_setmaxs", + EV_DEFAULT, + "v", + "maxs", + "Set the maxs of the bounding box of the entity to maxs.", + EV_NORMAL + ); +Event EV_SetAlpha + ( + "alpha", + EV_DEFAULT, + "f", + "newAlpha", + "Set the alpha of the entity to alpha.", + EV_NORMAL + ); +Event EV_SetKillTarget + ( + "killtarget", + EV_DEFAULT, + "s", + "targetName", + "when dying kill entities with this targetName.", + EV_NORMAL + ); +Event EV_SetMass + ( + "mass", + EV_DEFAULT, + "f", + "massAmount", + "set the mass of this entity.", + EV_NORMAL + ); + +Event EV_LoopSound + ( + "loopsound", + EV_DEFAULT, + "sFS", + "soundName volume minimum_distance", + "play a looped-sound with a certain volume and minimum_distance\n" + "which is attached to the current entity.", + EV_NORMAL + ); +Event EV_StopLoopSound + ( + "stoploopsound", + EV_DEFAULT, + NULL, + NULL, + "Stop the looped-sound on this entity.", + EV_NORMAL + ); + +Event EV_SurfaceModelEvent + ( + "surface", + EV_DEFAULT, + "sSSSSSS", + "surfaceName parameter1 parameter2 parameter3 parameter4 parameter5 parameter6", + "change a legs surface parameter for the given surface.\n" + "+ sets the flag, - clears the flag\n" + "Valid surface commands are:\n" + "skin1 - set the skin1 offset bit\n" + "skin2 - set the skin2 offset bit\n" + "nodraw - don't draw this surface", + EV_NORMAL + ); +// AI sound events +Event EV_BroadcastAIEvent + ( + "ai_event", + EV_DEFAULT, + "SF", + "type radius", + "Let the AI know that this entity made a sound,\ntype is a string specifying what type of sound it is.\nradius determines how far the sound reaches.", + EV_NORMAL + ); + +// Lighting +Event EV_SetLight + ( + "light", + EV_DEFAULT, + "ffff", + "red green blue radius", + "Create a dynmaic light on this entity.", + EV_NORMAL + ); + +Event EV_LightOn + ( + "lightOn", + EV_DEFAULT, + NULL, + NULL, + "Turn the configured dynmaic light on this entity on.", + EV_NORMAL + ); +Event EV_LightOff + ( + "lightOff", + EV_DEFAULT, + NULL, + NULL, + "Turn the configured dynamic light on this entity off.", + EV_NORMAL + ); +Event EV_LightStyle + ( + "lightStyle", + EV_DEFAULT, + "i", + "lightStyleIndex", + "What light style to use for this dynamic light on this entity.", + EV_NORMAL + ); +Event EV_LightRed + ( + "lightRed", + EV_DEFAULT, + "f", + "red", + "Set the red component of the dynmaic light on this entity.", + EV_NORMAL + ); +Event EV_LightGreen + ( + "lightGreen", + EV_DEFAULT, + "f", + "red", + "Set the red component of the dynmaic light on this entity.", + EV_NORMAL + ); +Event EV_LightBlue + ( + "lightBlue", + EV_DEFAULT, + "f", + "red", + "Set the red component of the dynmaic light on this entity.", + EV_NORMAL + ); +Event EV_LightRadius + ( + "lightRadius", + EV_DEFAULT, + "f", + "red", + "Set the red component of the dynmaic light on this entity.", + EV_NORMAL + ); + +// Entity flag specific +Event EV_EntityFlags + ( + "flags", + EV_DEFAULT, + "SSSSSS", + "parameter1 parameter2 parameter3 parameter4 parameter5 parameter6", + "Change the current entity flags.\n" + "Valid flags are as follows:\n" + "+ sets a flag, - clears a flag\n" + "blood - should it bleed\n" + "explode - should it explode when dead\n" + "die_gibs - should it spawn gibs when dead\n" + "god - makes the entity invincible\n", + EV_NORMAL + ); +Event EV_EntityRenderEffects + ( + "rendereffects", + EV_DEFAULT, + "SSSSSS", + "parameter1 parameter2 parameter3 parameter4 parameter5 parameter6", + "Change the current render effects flags.\n" + "Valid flags are as follows:\n" + "+ sets a flag, - clears a flag\n" + "dontdraw - send the entity to the client, but don't draw\n" + "betterlighting - do sphere based vertex lighting on the entity\n" + "lensflare - add a lens glow to the entity at its origin\n" + "viewlensflare - add a view dependent lens glow to the entity at its origin\n" + "lightoffset - use the dynamic color values as a light offset to the model\n" + "skyorigin - this entity is the portal sky origin\n" + "minlight - this entity always has some lighting on it\n" + "fullbright - this entity is always fully lit\n" + "additivedynamiclight - the dynamic light should have an additive effect\n" + "lightstyledynamiclight - the dynamic light uses a light style, use the\n" + "'lightstyle' command to set the index of the light style to be used", + EV_NORMAL + ); +Event EV_EntityEffects + ( + "effects", + EV_DEFAULT, + "SSSSSS", + "parameter1 parameter2 parameter3 parameter4 parameter5 parameter6", + "Change the current entity effects flags.\n" + "Valid flags are as follows:\n" + "+ sets a flag, - clears a flag\n" + "antisbjuice - anti sucknblow juice" + "everyframe - process commands every time entity is rendered", + EV_NORMAL + ); +Event EV_EntitySVFlags + ( + "svflags", + EV_DEFAULT, + "SSSSSS", + "parameter1 parameter2 parameter3 parameter4 parameter5 parameter6", + "Change the current server flags.\n" + "Valid flags are as follows:\n" + "+ sets a flag, - clears a flag\n" + "broadcast - always send this entity to the client", + EV_NORMAL + ); + +// Special Effects +Event EV_Censor + ( + "censor", + EV_DEFAULT, + NULL, + NULL, + "used to ban certain contact when in parentmode\n", + EV_NORMAL + ); +Event EV_Explosion + ( + "explosionattack", + EV_DEFAULT, + "sS", + "explosionModel tagName", + "Spawn an explosion optionally from a specific tag", + EV_NORMAL + ); + +Event EV_ShaderEvent + ( + "shader", + EV_DEFAULT, + "sfF", + "shaderCommand argument1 argument2", + "change a specific shader parameter for the entity.\n" + "Valid shader commands are:\n" + "translation [trans_x] [trans_y] - change the texture translation\n" + "offset [offset_x] [offset_y] - change the texture offset\n" + "rotation [rot_speed] - change the texture rotation speed\n" + "frame [frame_num] - change the animated texture frame\n" + "wavebase [base] - change the base parameter of the wave function\n" + "waveamp [amp] - change the amp parameter of the wave function\n" + "wavebase [phase] - change the phase parameter of the wave function\n" + "wavefreq [freq] - change the frequency parameter of the wave function\n", + EV_NORMAL + ); + +Event EV_ScriptShaderEvent + ( + "scriptshader", + EV_DEFAULT, + "sfF", + "shaderCommand argument1 argument2", + "alias for shader command, change a specific shader parameter for the entity.\n" + "Valid shader commands are:\n" + "translation [trans_x] [trans_y] - change the texture translation\n" + "offset [offset_x] [offset_y] - change the texture offset\n" + "rotation [rot_speed] - change the texture rotation speed\n" + "frame [frame_num] - change the animated texture frame\n" + "wavebase [base] - change the base parameter of the wave function\n" + "waveamp [amp] - change the amp parameter of the wave function\n" + "wavebase [phase] - change the phase parameter of the wave function\n" + "wavefreq [freq] - change the frequency parameter of the wave function\n", + EV_NORMAL + ); + +Event EV_KillAttach + ( + "killattach", + EV_DEFAULT, + NULL, + NULL, + "kill all the attached entities.", + EV_NORMAL + ); +Event EV_DropToFloor + ( + "droptofloor", + EV_DEFAULT, + "F", + "maxRange", + "drops the entity to the ground, if maxRange is not specified 8192 is used.", + EV_NORMAL + ); +Event EV_AddToSoundManager + ( + "_addtosoundmanager", + EV_DEFAULT, + NULL, + NULL, + "adds the current entity to the sound manager.", + EV_NORMAL + ); +Event EV_SetControllerAngles + ( + "setcontrollerangles", + EV_DEFAULT, + "iv", + "num angles", + "Sets the control angles for the specified bone.", + EV_NORMAL + ); +Event EV_DeathSinkStart + ( + "deathsinkstart", + EV_DEFAULT, + NULL, + NULL, + "Makes the entity sink into the ground and then get removed (this starts it).", + EV_NORMAL + ); +Event EV_DeathSink + ( + "deathsinkeachframe", + EV_DEFAULT, + NULL, + NULL, + "Makes the entity sink into the ground and then get removed (this gets called each frame).", + EV_NORMAL + ); +Event EV_DamageType + ( + "damage_type", + EV_DEFAULT, + "s", + "meansofdeathstring", + "Set the type of damage that this entity can take", + EV_NORMAL + ); +Event EV_DetachAllChildren +( + "detachallchildren", + EV_DEFAULT, + NULL, + NULL, + "Detach all the children from the entity." +); +Event EV_Entity_MovementStealth +( + "movementstealth", + EV_DEFAULT, + "f", + "scale", + "Sets the current movement stealth scalar for the sentient" +); +Event EV_Entity_GetYaw +( + "yaw", + EV_DEFAULT, + NULL, + NULL, + "entity's yaw", + EV_GETTER +); +Event EV_Pusher +( + "pusher", + EV_DEFAULT, + "eevf", + "inflictor attacker direction force", + "Push an entity in the specified direction with the specified force" +); +Event EV_NeverDraw +( + "neverdraw", + EV_DEFAULT, + NULL, + NULL, + "Sets this entity to never draw" +); +Event EV_NormalDraw +( + "normaldraw", + EV_DEFAULT, + NULL, + NULL, + "Sets this entity to normal draw" +); +Event EV_AlwaysDraw +( + "alwaysdraw", + EV_DEFAULT, + NULL, + NULL, + "Sets this entity to always draw" +); +Event EV_IsTouching +( + "istouching", + EV_DEFAULT, + "e", + "ent", + "returns 1 if the entities are touching, 0 if not", + EV_RETURN +); +Event EV_CanSee +( + "cansee", + EV_DEFAULT, + "eff", + "entity fov vision_distance", + "returns 1 if the entities can see eachother, 0 if not", + EV_RETURN +); +Event EV_Entity_InPVS +( + "inpvs", + EV_DEFAULT, + "e", + "entity", + "returns 1 if the entities have connected pvs, 0 if not", + EV_RETURN +); +Event EV_SetShaderData +( + "setshaderdata", + EV_DEFAULT, + "ff", + "data0 data1", + "sets the shader controllers for this entity.", + EV_RETURN +); +Event EV_Entity_SetVelocity +( + "velocity", + EV_DEFAULT, + "v", + "velocity", + "sets the velocity for this entity.", + EV_SETTER +); +Event EV_Entity_GetVelocity +( + "velocity", + EV_DEFAULT, + NULL, + NULL, + "gets the velocity for this entity.", + EV_GETTER +); +Event EV_GetAVelocity +( + "avelocity", + EV_DEFAULT, + NULL, + NULL, + "gets the angular velocity for this entity.", + EV_GETTER +); +Event EV_GetTagAngles +( + "gettagangles", + EV_DEFAULT, + "s", + "tag_name", + "Gets the world angles of the tag", + EV_RETURN +); +Event EV_GetTagPosition +( + "gettagposition", + EV_DEFAULT, + "s", + "tag_name", + "Gets the world position of the tag", + EV_RETURN +); +Event EV_GetControllerAngles +( + "getcontrollerangles", + EV_DEFAULT, + "i", + "num", + "Gets the control angles for the specified bone.", + EV_RETURN +); +Event EV_ForceActivate +( + "forceactivate", + EV_DEFAULT, + NULL, + NULL, + "Forces an entity to activate outside of the player's PVS" +); +Event EV_DisconnectPaths +( + "disconnect_paths", + EV_DEFAULT, + NULL, + NULL, + "disonnects all navigation paths which intersect with the specified entity's volume" +); +Event EV_ConnectPaths +( + "connect_paths", + EV_DEFAULT, + NULL, + NULL, + "Connects all navigation paths which intersect with the specified entity's volume" +); +Event EV_VolumeDamage +( + "volumedamage", + EV_DEFAULT, + "f", + "damage", + "does damage to any entity within this's volume" +); +Event EV_Entity_AddImmunity +( + "immune", + EV_DEFAULT, + "sSSSSS", + "immune_string1 immune_string2 immune_string3 immune_string4 immune_string5 immune_string6", + "Adds to the immunity list for this sentient." +); +Event EV_Entity_RemoveImmunity +( + "removeimmune", + EV_DEFAULT, + "sSSSSS", + "immune_string1 immune_string2 immune_string3 immune_string4 immune_string5 immune_string6", + "Removes from the immunity list for this sentient." +); +Event EV_GetEntnum +( + "entnum", + EV_DEFAULT, + NULL, + NULL, + "The entity's entity number", + EV_GETTER +); +Event EV_Entity_SetRadnum +( + "radnum", + EV_DEFAULT, + "i", + "radnum", + "set the radnum", + EV_SETTER +); +Event EV_Entity_GetRadnum +( + "radnum", + EV_DEFAULT, + NULL, + NULL, + "entity's radnum", + EV_GETTER +); +Event EV_Entity_SetRotatedBbox +( + "rotatedbbox", + EV_DEFAULT, + "i", + "on_off", + "Sets the entity's bbox to rotate with it.", + EV_SETTER +); +Event EV_Entity_GetRotatedBbox +( + "rotatedbbox", + EV_DEFAULT, + NULL, + NULL, + "Gets te entity's bbox to rotate with it.", + EV_GETTER +); +Event EV_Entity_GetMaxs + ( + "getmaxs", + EV_DEFAULT, + NULL, + NULL, + "Get the maxs of the bounding box of the entity to maxs.", + EV_RETURN + ); +Event EV_Entity_GetMins + ( + "getmins", + EV_DEFAULT, + NULL, + NULL, + "Get the mins of the bounding box of the entity to mins.", + EV_RETURN + ); +Event EV_Entity_SetDHack + ( + "depthhack", + EV_DEFAULT, + "i", + "bEnable", + "Enable or disable depth hack." + ); +Event EV_Entity_GetZone + ( + "getzone", + EV_DEFAULT, + NULL, + NULL, + "Gets the current entity zone. NIL if the entity is not in a zone.", + EV_RETURN + ); +Event EV_Entity_Zone + ( + "zone", + EV_DEFAULT, + NULL, + NULL, + "Get the current entity zone. NIL if the entity is not in a zone.", + EV_GETTER + ); +Event EV_Entity_IsInZone + ( + "isinzone", + EV_DEFAULT, + "e", + "zone", + "Returns 1 if the entity is in the specified zone. 0 otherwise", + EV_RETURN + ); +Event EV_Entity_SetHintRequireLookAt + ( + "setuselookat", + EV_DEFAULT, + "b", + "lookat", + "Sets if the client must look at the entity to use it", + EV_NORMAL + ); +Event EV_Entity_SetHintString + ( + "sethintstring", + EV_DEFAULT, + "s", + "string", + "Sets the hint string for an entity when touching it. '&&1' will be replaced by the +use key on the client. If hideent/hide is called on this entity, the hint string won't be shown for the client", + EV_NORMAL + ); +Event EV_Entity_SetShader + ( + "setshader", + EV_DEFAULT, + "s", + "shadername", + "Sets a shader for the entity. An empty string will revert to the normal entity shader.", + EV_NORMAL + ); + +CLASS_DECLARATION( SimpleEntity, Entity, NULL ) + { + { &EV_Damage, &Entity::DamageEvent }, + { &EV_DamageType, &Entity::DamageType }, + { &EV_Kill, &Entity::Kill }, + { &EV_FadeNoRemove, &Entity::FadeNoRemove }, + { &EV_FadeOut, &Entity::FadeOut }, + { &EV_FadeIn, &Entity::FadeIn }, + { &EV_Fade, &Entity::Fade }, + { &EV_Hide, &Entity::EventHideModel }, + { &EV_Show, &Entity::EventShowModel }, + { &EV_BecomeSolid, &Entity::BecomeSolid }, + { &EV_BecomeNonSolid, &Entity::BecomeNonSolid }, + { &EV_Ghost, &Entity::Ghost }, + { &EV_TouchTriggers, &Entity::TouchTriggersEvent }, + { &EV_Sound, &Entity::Sound }, + { &EV_StopSound, &Entity::StopSound }, + { &EV_Entity_SetHealthOnly, &Entity::EventSetHealthOnly }, + { &EV_Entity_SetHealthOnly2, &Entity::EventSetHealthOnly }, + { &EV_Entity_SetMaxHealth, &Entity::EventSetMaxHealth }, + { &EV_Entity_SetMaxHealth2, &Entity::EventSetMaxHealth }, + { &EV_Entity_GetMaxHealth, &Entity::EventGetMaxHealth }, + { &EV_SetHealth, &Entity::SetHealth }, + { &EV_SetHealth2, &Entity::SetHealth }, + { &EV_Entity_GetHealth, &Entity::GetHealth }, + { &EV_SetSize, &Entity::SetSize }, + { &EV_SetMins, &Entity::SetMins }, + { &EV_SetMaxs, &Entity::SetMaxs }, + { &EV_SetScale, &Entity::SetScale }, + { &EV_SetScale2, &Entity::SetScale }, + { &EV_GetScale, &Entity::GetScale }, + { &EV_SetAlpha, &Entity::SetAlpha }, + { &EV_SetKillTarget, &Entity::SetKillTarget }, + { &EV_SetMass, &Entity::SetMassEvent }, + { &EV_LoopSound, &Entity::LoopSound }, + { &EV_StopLoopSound, &Entity::StopLoopSound }, + { &EV_Model, &Entity::SetModelEvent }, + { &EV_Entity_SetModel, &Entity::SetModelEvent }, + { &EV_Entity_GetBrushModel, &Entity::GetBrushModelEvent }, + { &EV_Entity_GetModel, &Entity::GetModelEvent }, + { &EV_SetLight, &Entity::SetLight }, + { &EV_LightOn, &Entity::LightOn }, + { &EV_LightOff, &Entity::LightOff }, + { &EV_LightRed, &Entity::LightRed }, + { &EV_LightGreen, &Entity::LightGreen }, + { &EV_LightBlue, &Entity::LightBlue }, + { &EV_LightRadius, &Entity::LightRadius }, + { &EV_LightStyle, &Entity::LightStyle }, + { &EV_EntityFlags, &Entity::Flags }, + { &EV_EntityEffects, &Entity::Effects }, + { &EV_EntitySVFlags, &Entity::SVFlags }, + { &EV_EntityRenderEffects, &Entity::RenderEffects }, + { &EV_BroadcastAIEvent, &Entity::BroadcastAIEvent }, + { &EV_SurfaceModelEvent, &Entity::SurfaceModelEvent }, + { &EV_Attach, &Entity::AttachEvent }, + { &EV_AttachModel, &Entity::AttachModelEvent }, + { &EV_RemoveAttachedModel, &Entity::RemoveAttachedModelEvent }, + { &EV_Detach, &Entity::DetachEvent }, + { &EV_TakeDamage, &Entity::TakeDamageEvent }, + { &EV_NoDamage, &Entity::NoDamageEvent }, + { &EV_Gravity, &Entity::Gravity }, + { &EV_UseBoundingBox, &Entity::UseBoundingBoxEvent }, + { &EV_Hurt, &Entity::HurtEvent }, + { &EV_Heal, &Entity::HealEvent }, + { &EV_Classname, &Entity::ClassnameEvent }, + { &EV_SoundDone, &Entity::EventSoundDone }, + { &EV_SpawnFlags, &Entity::SpawnFlagsEvent }, + { &EV_SetTeam, &Entity::SetTeamEvent }, + { &EV_Trigger, &Entity::TriggerEvent }, + { &EV_Censor, &Entity::Censor }, + { &EV_Stationary, &Entity::StationaryEvent }, + { &EV_Explosion, &Entity::Explosion }, + { &EV_ShaderEvent, &Entity::Shader }, + { &EV_ScriptShaderEvent, &Entity::Shader }, + { &EV_KillAttach, &Entity::KillAttach }, + { &EV_DropToFloor, &Entity::DropToFloorEvent }, + { &EV_Bind, &Entity::BindEvent }, + { &EV_Unbind, &Entity::EventUnbind }, + { &EV_Glue, &Entity::GlueEvent }, + { &EV_Unglue, &Entity::EventUnglue }, + { &EV_JoinTeam, &Entity::JoinTeam }, + { &EV_QuitTeam, &Entity::EventQuitTeam }, + { &EV_AddToSoundManager, &Entity::AddToSoundManager }, + { &EV_SetControllerAngles, &Entity::SetControllerAngles }, + { &EV_DeathSinkStart, &Entity::DeathSinkStart }, + { &EV_DeathSink, &Entity::DeathSink }, + { &EV_DetachAllChildren, &Entity::DetachAllChildren }, + { &EV_Entity_MovementStealth, &Entity::EventMovementStealth }, + { &EV_Entity_GetYaw, &Entity::GetYaw }, + { &EV_Pusher, &Entity::PusherEvent }, + { &EV_NeverDraw, &Entity::NeverDraw }, + { &EV_NormalDraw, &Entity::NormalDraw }, + { &EV_AlwaysDraw, &Entity::AlwaysDraw }, + { &EV_IsTouching, &Entity::IsTouching }, + { &EV_Entity_GetVelocity, &Entity::GetVelocity }, + { &EV_GetAVelocity, &Entity::GetAVelocity }, + { &EV_Entity_SetVelocity, &Entity::SetVelocity }, + { &EV_CanSee, &Entity::CanSee }, + { &EV_Entity_InPVS, &Entity::EventInPVS }, + { &EV_SetShaderData, &Entity::SetShaderData }, + { &EV_ForceActivate, &Entity::ForceActivate }, + { &EV_ScriptThread_Trace, &Entity::EventTrace }, + { &EV_ScriptThread_SightTrace, &Entity::EventSightTrace }, + { &EV_DisconnectPaths, &Entity::EventDisconnectPaths }, + { &EV_Remove, &Entity::Remove }, + { &EV_Delete, &Entity::Remove }, + { &EV_ScriptRemove, &Entity::Remove }, + { &EV_ConnectPaths, &Entity::EventConnectPaths }, + { &EV_VolumeDamage, &Entity::EventVolumeDamage }, + { &EV_Entity_AddImmunity, &Entity::AddImmunity }, + { &EV_Entity_RemoveImmunity, &Entity::RemoveImmunity }, + { &EV_GetEntnum, &Entity::EventGetEntnum }, + { &EV_Entity_SetRadnum, &Entity::EventSetRadnum }, + { &EV_Entity_GetRadnum, &Entity::EventGetRadnum }, + { &EV_Entity_SetRotatedBbox, &Entity::EventSetRotatedBbox }, + { &EV_Entity_GetRotatedBbox, &Entity::EventGetRotatedBbox }, + { &EV_GetTagAngles, &Entity::GetTagAngles }, + { &EV_GetTagPosition, &Entity::GetTagPosition }, + { &EV_GetControllerAngles, &Entity::GetControllerAngles }, + { &EV_Entity_GetMaxs, &Entity::GetMaxs }, + { &EV_Entity_GetMins, &Entity::GetMins }, + { &EV_Entity_GetZone, &Entity::GetZone }, + { &EV_Entity_Zone, &Entity::GetZone }, + { &EV_Entity_IsInZone, &Entity::IsInZone }, + { &EV_Entity_SetDHack, &Entity::SetDepthHack }, + { &EV_Entity_SetHintRequireLookAt, &Entity::SetHintRequireLookAt }, + { &EV_Entity_SetHintString, &Entity::SetHintString }, + { &EV_Entity_SetShader, &Entity::SetShader }, + { NULL, NULL } + }; + +Entity::Entity() +{ + int i; + + edict = level.AllocEdict( this ); + client = edict->client; + entnum = edict->s.number; + radnum = -1; + + entflags |= EF_ENTITY; + + if( LoadingSavegame ) + { + return; + } + + edict->tiki = NULL; + + // spawning variables + spawnflags = level.spawnflags; + level.spawnflags = 0; + + // rendering variables + setAlpha( 1.0f ); + setScale( 1.0f ); + + // physics variables + mass = 0; + gravity = 1.0; + groundentity = NULL; + groundcontents = 0; + velocity = vec_zero; + avelocity = vec_zero; + edict->clipmask = MASK_USABLE; + + m_iNumGlues = 0; + m_bGlueAngles = false; + m_pGlueMaster = NULL; + + // team variables + teamchain = NULL; + teammaster = NULL; + + // bind variables + bindmaster = NULL; + + // this is an generic entity + edict->s.eType = ET_GENERAL; + + setContents( 0 ); + + edict->s.parent = ENTITYNUM_NONE; + edict->r.ownerNum = ENTITYNUM_NONE; + + // model binding variables + numchildren = 0; + + for( i = 0; i < MAX_MODEL_CHILDREN; i++ ) + children[ i ] = ENTITYNUM_NONE; + + for( int i = 0; i < MAX_GLUE_CHILDREN; i++ ) + m_pGluesFlags[ i ] = 0; + + setOrigin( vec_zero ); + origin.copyTo( edict->s.origin2 ); + + setAngles( vec_zero ); + + setMoveType( MOVETYPE_NONE ); + setSolidType( SOLID_NOT ); + + // Character state + health = 0; + max_health = 0; + deadflag = DEAD_NO; + flags = 0; + + // underwater variables + watertype = 0; + waterlevel = 0; + + // Pain and damage variables + takedamage = DAMAGE_NO; + enemy = NULL; + pain_finished = 0; + damage_debounce_time = 0; + damage_type = -1; + + detach_at_death = qtrue; + + // Light variables + lightRadius = 0; + + stealthMovementScale = 1.0f; + m_iNumBlockedPaths = 0; + m_BlockedPaths = NULL; + + // Misc + m_bBindChilds = false; +} + +Entity::~Entity() +{ + Container bindlist; + Container gluelist; + Entity *ent; + int num; + int i; + + // unbind any entities that are bound to me + // can't unbind within this loop, so make an array + // and unbind them outside of it. + num = 0; + for( ent = teamchain; ent; ent = ent->teamchain ) + { + if( ent->bindmaster == this ) + { + bindlist.AddObject( ent ); + } + } + + num = bindlist.NumObjects(); + for( i = 1; i <= num; i++ ) + { + bindlist.ObjectAt( i )->unbind(); + } + + // detach all glued entities + num = 0; + for( i = 0; i < m_iNumGlues; i++ ) + { + if( m_pGlues[ i ] && m_pGlues[ i ]->m_pGlueMaster == this ) + { + gluelist.AddObject( m_pGlues[ i ] ); + } + } + + num = gluelist.NumObjects(); + for( i = 1; i <= num; i++ ) + { + gluelist.ObjectAt( i )->unglue(); + } + + bindlist.FreeObjectList(); + gluelist.FreeObjectList(); + + unbind(); + quitTeam(); + + unglue(); + detach(); + + // + // go through and set our children + // + num = numchildren; + for( i = 0; ( i < MAX_MODEL_CHILDREN ) && num; i++ ) + { + if( children[ i ] == ENTITYNUM_NONE ) + { + continue; + } + ent = G_GetEntity( children[ i ] ); + if( ent ) + { + ent->PostEvent( EV_Remove, 0 ); + } + num--; + } + + if( m_BlockedPaths ) + { + delete m_BlockedPaths; + m_BlockedPaths = 0; + } + + level.FreeEdict( edict ); + + entflags &= ~EF_ENTITY; +} + +inline void Entity::Archive + ( + Archiver &arc + ) +{ + int tempInt; + int i; + + SimpleEntity::Archive( arc ); + + G_ArchiveEdict( arc, edict ); + + arc.ArchiveInteger( &entnum ); + arc.ArchiveInteger( &radnum ); + arc.ArchiveInteger( &spawnflags ); + + arc.ArchiveString( &model ); + if( arc.Loading() && model.length() ) + { + setModel( model ); + } + + arc.ArchiveVector( &mins ); + arc.ArchiveVector( &maxs ); + arc.ArchiveVector( &absmin ); + arc.ArchiveVector( &absmax ); + arc.ArchiveVector( &velocity ); + arc.ArchiveVector( &accel ); + arc.ArchiveVector( &avelocity ); + arc.ArchiveVector( &aaccel ); + arc.ArchiveVector( &size ); + arc.ArchiveInteger( &movetype ); + arc.ArchiveInteger( &mass ); + arc.ArchiveFloat( &gravity ); + arc.ArchiveRaw( orientation, sizeof( orientation ) ); + + if( arc.Saving() ) + { + if( groundentity ) + { + tempInt = groundentity - g_entities; + } + else + { + tempInt = -1; + } + } + + arc.ArchiveInteger( &tempInt ); + + if( arc.Loading() ) + { + if( tempInt == -1 ) + { + groundentity = NULL; + } + else + { + groundentity = &g_entities[ tempInt ]; + } + } + + arc.ArchiveRaw( &groundplane, sizeof( groundplane ) ); + arc.ArchiveInteger( &groundcontents ); + + arc.ArchiveInteger( &numchildren ); + arc.ArchiveRaw( children, sizeof( children ) ); + + arc.ArchiveFloat( &lightRadius ); + + arc.ArchiveString( &moveteam ); + arc.ArchiveObjectPointer( ( Class ** )&teamchain ); + arc.ArchiveObjectPointer( ( Class ** )&teammaster ); + + arc.ArchiveObjectPointer( ( Class ** )&bindmaster ); + arc.ArchiveBoolean( &bind_use_my_angles ); + arc.ArchiveVector( &localorigin ); + arc.ArchiveVector( &localangles ); + + // add to target list to rebuild targetlists + arc.ArchiveString( &killtarget ); + + arc.ArchiveFloat( &health ); + arc.ArchiveFloat( &max_health ); + arc.ArchiveInteger( &deadflag ); + arc.ArchiveInteger( &flags ); + + arc.ArchiveInteger( &watertype ); + arc.ArchiveInteger( &waterlevel ); + + ArchiveEnum( takedamage, damage_t ); + + arc.ArchiveInteger( &m_iNumGlues ); + + for( i = 0; i < MAX_MODEL_CHILDREN; i++ ) + { + arc.ArchiveSafePointer( &m_pGlues[ i ] ); + arc.ArchiveInteger( &m_pGluesFlags[ i ] ); + } + + arc.ArchiveObjectPointer( ( Class ** )&m_pGlueMaster ); + arc.ArchiveBool( &m_bGlueAngles ); + arc.ArchiveBoolean( &detach_at_death ); + + arc.ArchiveFloat( &stealthMovementScale ); + arc.ArchiveInteger( &m_iNumBlockedPaths ); + + if( arc.Loading() ) + { + m_BlockedPaths = new pathway_ref[ m_iNumBlockedPaths ]; + } + + for( i = 0; i < m_iNumBlockedPaths; i++ ) + { + arc.ArchiveShort( &m_BlockedPaths[ i ].from ); + arc.ArchiveShort( &m_BlockedPaths[ i ].to ); + } + + immunities.Archive( arc ); +} + +bool Entity::AutoArchiveModel + ( + void + ) + +{ + return true; +} + +void Entity::SetEntNum + ( + int num + ) + + { + if ( edict ) + { + level.FreeEdict( edict ); + } + + level.spawn_entnum = num; + level.AllocEdict( this ); + client = edict->client; + entnum = edict->s.number; + } + +void Entity::ClassnameEvent + ( + Event *ev + ) + + { + strncpy( edict->entname, ev->GetString( 1 ), sizeof( edict->entname ) - 1 ); + } + +void Entity::SpawnFlagsEvent + ( + Event *ev + ) + + { + // spawning variables + spawnflags = ev->GetInteger( 1 ); + if ( spawnflags & SPAWNFLAG_DETAIL ) + { + edict->s.renderfx |= RF_DETAIL; + } + } + +bool monkeycheck = false; +cvar_t *thereisnomonkey; + +qboolean Entity::CheckEventFlags( Event *event ) +{ + int flags = GetFlags( event ); + + // Special handling of console events + if( !( flags & ( EV_CONSOLE | EV_CHEAT ) ) ) + { + if( isSubclassOf( Entity ) ) + { + Entity *ent; + + ent = ( Entity * )this; + gi.SendServerCommand( ent->edict - g_entities, "print \"Command '%s' not available from console\n\"", event->getName().c_str() ); + } + + // don't process + return false; + } + + // don't allow console cheats unless the server says it's ok. + + if( ( flags & EV_CHEAT ) ) + { + if( !monkeycheck ) + { + thereisnomonkey = gi.Cvar_Get( "thereisnomonkey", "0", CVAR_TEMP ); + monkeycheck = true; + } + + if( !thereisnomonkey->integer ) + { + gi.Cvar_Set( "cheats", "0" ); + } + + if( !sv_cheats->integer ) + { + if( isSubclassOf( Entity ) ) + { + Entity *ent; + const char *szConv = gi.LV_ConvertString( "You must run the server with '+set cheats 1' to enable this command." ); + + ent = ( Entity * )this; + gi.SendServerCommand( ent->edict - g_entities, "print \"%s\n\"", szConv ); + } + + // don't process + return false; + } + } + + // ok to process + return true; +} + +void Entity::SetKillTarget + ( + const char *text + ) + + { + if ( text ) + { + killtarget = text; + } + else + { + killtarget = ""; + } + } + +qboolean Entity::setModel + ( + void + ) + +{ + level.skel_index[ edict->s.number ] = -1; + return gi.setmodel( edict, model ); +} + +void Entity::SetSize + ( + void + ) + +{ + mins = edict->r.mins; + maxs = edict->r.maxs; + + size = maxs - mins; + + edict->r.radius = size.length() * 0.5; + edict->radius2 = edict->r.radius * edict->r.radius; +} + +void Entity::setModel + ( + const char *mdl + ) + +{ + if( strcmp( mdl, "" ) ) + { + if( *mdl == '*' ) + { + model = mdl; + + gi.SetBrushModel( edict, mdl ); + if( ( edict->solid == SOLID_BSP ) && !edict->s.modelindex ) + { + const char *name; + + name = getClassID(); + if( !name ) + { + name = getClassname(); + } + gi.DPrintf( "%s with SOLID_BSP and no model - '%s'(%d)\n", name, targetname.c_str(), entnum ); + + // Make it non-solid so that the collision code doesn't kick us out. + setSolidType( SOLID_NOT ); + } + + mins = edict->r.mins; + maxs = edict->r.maxs; + + size = maxs - mins; + edict->r.radius = size.length() * 0.5f; + edict->radius2 = edict->r.radius * edict->r.radius; + return; + } + } + + model = CanonicalTikiName( mdl ); + + if( !setModel() ) + { + Com_Printf( "^~^~^ Bad model name '%s'\n", mdl ); + return; + } + + mins = vec_zero; + maxs = vec_zero; + + for( int i = 0; i < MAX_FRAMEINFOS; i++ ) + { + edict->s.frameInfo[ i ].index = 0; + edict->s.frameInfo[ i ].time = 0; + edict->s.frameInfo[ i ].weight = 0; + } + + if( !strcmp( mdl, "" ) ) + { + mins = edict->r.mins; + maxs = edict->r.maxs; + + size = maxs - mins; + edict->r.radius = size.length() * 0.5f; + edict->radius2 = edict->r.radius * edict->r.radius; + return; + } + + edict->s.frameInfo[ 0 ].index = gi.Anim_NumForName( edict->tiki, "idle" ); + if( edict->s.frameInfo[ 0 ].index < 0 ) + { + edict->s.frameInfo[ 0 ].index = 0; + } + + edict->s.frameInfo[ 0 ].weight = 1.0f; + edict->s.frameInfo[ 0 ].time = 0; + + ProcessInitCommands(); + + mins = edict->r.mins; + maxs = edict->r.maxs; + + size = maxs - mins; + edict->r.radius = size.length() * 0.5f; + edict->radius2 = edict->r.radius * edict->r.radius; + + if( edict->tiki && !mins.length() && !maxs.length() ) + { + vec3_t tempmins, tempmaxs; + gi.CalculateBounds( edict->tiki, edict->s.scale, tempmins, tempmaxs ); + setSize( tempmins, tempmaxs ); + } +} + +void Entity::ProcessInitCommands( void ) +{ + dtikianim_t *a; + + if ( LoadingSavegame ) + { + // Don't process init commands when loading a savegame since + // it will cause items to be added to inventories unnecessarily. + // All variables affected by the init commands will be set + // by the unarchive functions. + // + // we do want to process the cache commands though regardless + return; + } + + a = edict->tiki->a; + + if( a->num_server_initcmds ) + { + int i, j; + Event *event; + for( i = 0; i < a->num_server_initcmds; i++ ) + { + event = new Event( a->server_initcmds[ i ].args[ 0 ] ); + + for( j = 1; j < a->server_initcmds[ i ].num_args; j++ ) + { + event->AddToken( a->server_initcmds[ i ].args[ j ] ); + } + + if( !ProcessEvent( event ) ) + { + Com_Printf( "^~^~^ Entity::ProcessInitCommands: Bad init server command '%s' in '%s'\n", a->server_initcmds[ i ].args[ 0 ], edict->tiki->name ); + } + } + } +} + +void Entity::EventHideModel + ( + Event *ev + ) + + { + hideModel(); + } + +void Entity::EventShowModel + ( + Event *ev + ) + + { + showModel(); + } + +void Entity::SetTeamEvent + ( + Event *ev + ) + + { + moveteam = ev->GetString( 1 ); + } + +void Entity::TriggerEvent + ( + Event *ev + ) + +{ + const char *name; + Event *event; + Entity *ent; + ConSimple *tlist; + int i; + int num; + + name = ev->GetString( 1 ); + + // Check for object commands + if( name && name[ 0 ] == '$' ) + { + str sName = str( name + 1 ); + + tlist = world->GetTargetList( sName ); + num = tlist->NumObjects(); + for( i = 1; i <= num; i++ ) + { + ent = ( Entity * )tlist->ObjectAt( i ).Pointer(); + + assert( ent ); + + event = new Event( EV_Activate ); + + event->AddEntity( this ); + ent->ProcessEvent( event ); + } + } + else if( name[ 0 ] == '*' ) // Check for entnum commands + { + if( !IsNumeric( &name[ 1 ] ) ) + { + gi.Printf( "Expecting numeric value for * command, but found '%s'\n", &name[ 1 ] ); + } + else + { + ent = G_GetEntity( atoi( &name[ 1 ] ) ); + if( ent ) + { + event = new Event( EV_Activate ); + + event->AddEntity( this ); + ent->ProcessEvent( event ); + } + else + { + gi.Printf( "Entity not found for * command\n" ); + } + } + return; + } + else + { + gi.Printf( "Invalid entity reference '%s'.\n", name ); + } +} + +void Entity::setAlpha + ( + float alpha + ) + + { + if ( alpha > 1.0f ) + { + alpha = 1.0f; + } + if ( alpha < 0 ) + { + alpha = 0; + } + edict->s.alpha = alpha; + } + +void Entity::setScale + ( + float scale + ) + +{ + edict->s.scale = scale; +} + +void Entity::setContentsSolid + ( + void + ) + +{ + setContents( CONTENTS_BBOX ); +} + +void Entity::setSolidType + ( + solid_t type + ) + +{ + if( + ( !LoadingSavegame ) && + ( type == SOLID_BSP ) && + ( this != world ) && + ( + !model.length() || + ( + ( model[ 0 ] != '*' ) && + ( !strstr( model.c_str(), ".bsp" ) ) + ) + ) + ) + { + gi.Printf( "setSolidType", "SOLID_BSP entity at x%.2f y%.2f z%.2f with no BSP model", origin[ 0 ], origin[ 1 ], origin[ 2 ] ); + } + edict->solid = type; + + // + // set the appropriate contents type + if( edict->solid == SOLID_BBOX ) + { + if( !getContents() ) + setContentsSolid(); + } + else if( edict->solid == SOLID_NOT ) + { + if( getContents() & ( CONTENTS_CORPSE | CONTENTS_BODY | CONTENTS_UNKNOWN3 | CONTENTS_UNKNOWN2 | CONTENTS_NOBOTCLIP | CONTENTS_BBOX | CONTENTS_NOTTEAM2 | CONTENTS_NOTTEAM1 | CONTENTS_LADDER ) ) + setContents( 0 ); + } + else if( edict->solid == SOLID_BSP ) + { + if( !getContents() ) + setContents( CONTENTS_SOLID ); + } + + link(); +} + +void Entity::setSize + ( + Vector min, + Vector max + ) + +{ + Vector delta; + + if( flags & FL_ROTATEDBOUNDS ) + { + vec3_t tempmins, tempmaxs; + + // + // rotate the mins and maxs for the model + // + min.copyTo( tempmins ); + max.copyTo( tempmaxs ); + + CalculateRotatedBounds2( edict->mat, tempmins, tempmaxs ); + + VectorCopy( tempmins, edict->r.mins ); + VectorCopy( tempmaxs, edict->r.maxs ); + + SetSize(); + } + else + { + if( ( min == edict->r.mins ) && ( max == edict->r.maxs ) ) + { + return; + } + + VectorCopy( min, edict->r.mins ); + VectorCopy( max, edict->r.maxs ); + + SetSize(); + + // + // get the full mins and maxs for this model + // + if( edict->tiki ) + { + vec3_t fullmins, fullmaxs; + Vector delta; + + gi.CalculateBounds( edict->tiki, edict->s.scale, fullmins, fullmaxs ); + + delta = Vector( fullmaxs ) - Vector( fullmins ); + edict->r.radius = delta.length() * 0.5; + edict->radius2 = edict->r.radius * edict->r.radius; + } + } + + link(); +} + +Vector Entity::getLocalVector + ( + Vector vec + ) + + { + Vector pos; + + pos[ 0 ] = vec * orientation[ 0 ]; + pos[ 1 ] = vec * orientation[ 1 ]; + pos[ 2 ] = vec * orientation[ 2 ]; + + return pos; + } + +void Entity::link + ( + void + ) + +{ + gi.LinkEntity( edict ); + absmin = edict->r.absmin; + absmax = edict->r.absmax; + centroid = ( absmin + absmax ) * 0.5; + centroid.copyTo( edict->r.currentOrigin ); + + // If this has a parent, then set the areanum the same + // as the parent's + if( edict->s.parent != ENTITYNUM_NONE ) + { + edict->r.areanum = g_entities[ edict->s.parent ].r.areanum; + } +} + +void Entity::addOrigin + ( + Vector add + ) + +{ + setLocalOrigin( localorigin + add ); +} + +void Entity::setOrigin + ( + void + ) + +{ + Entity *ent; + + if( edict->s.parent == ENTITYNUM_NONE ) + { + setLocalOrigin( localorigin ); + } + // If entity has a parent, then set the origin as the + // centroid of the parent, and set edict->s.netorigin + // as the local origin of the entity which will be used + // to position this entity on the client. + else + { + Vector forward, left, up; + + VectorClear( edict->s.netorigin ); + ent = ( Entity * )G_GetEntity( edict->s.parent ); + + ent->GetTag( edict->s.tag_num & TAG_MASK, &origin, &forward, &left, &up ); + + origin += edict->s.attach_offset[ 0 ] * forward; + origin += edict->s.attach_offset[ 1 ] * left; + origin += edict->s.attach_offset[ 2 ] * up; + + localorigin = vec_zero; + + updateOrigin(); + } +} + +void Entity::setLocalOrigin + ( + Vector org + ) + +{ + if( m_pGlueMaster ) + { + org = m_pGlueMaster->origin; + velocity = m_pGlueMaster->velocity; + } + + if( bindmaster ) + { + localorigin = org; + + if( bind_use_my_angles ) + MatrixTransformVector( localorigin, orientation, origin ); + else + MatrixTransformVector( localorigin, bindmaster->orientation, origin ); + + origin += bindmaster->origin; + origin.copyTo( edict->s.netorigin ); + } + else + { + origin = org; + localorigin = org; + origin.copyTo( edict->s.netorigin ); + } + + updateOrigin(); +} + +void Entity::setOrigin + ( + Vector org + ) + +{ + if( m_pGlueMaster ) + { + org = m_pGlueMaster->origin; + velocity = m_pGlueMaster->velocity; + } + + if( bindmaster ) + { + origin = org; + + org -= bindmaster->origin; + + if ( bind_use_my_angles ) + MatrixTransformVectorRight( orientation, org, localorigin ); + else + MatrixTransformVectorRight( bindmaster->orientation, org, localorigin ); + + origin.copyTo( edict->s.netorigin ); + } + else + { + if( edict->s.parent != ENTITYNUM_NONE ) + { + detach(); + } + + origin = org; + localorigin = org; + origin.copyTo( edict->s.netorigin ); + } + + updateOrigin(); +} + +void Entity::setOriginEvent + ( + Vector org + ) + +{ + velocity = vec_zero; + setOrigin( org ); +} + +void Entity::updateOrigin + ( + void + ) + +{ + Entity *ent; + int i, num; + + origin.copyTo( edict->s.origin ); + + link(); + + // + // go through and set our children + // + num = numchildren; + for( i = 0; ( i < MAX_MODEL_CHILDREN ) && num; i++ ) + { + if( children[ i ] == ENTITYNUM_NONE ) + { + continue; + } + ent = ( Entity * )G_GetEntity( children[ i ] ); + ent->setOrigin(); + num--; + } + + for( i = 0; i < m_iNumGlues; i++ ) + { + m_pGlues[ i ]->setOrigin(); + } +} + +void Entity::ShowInfo + ( + float fDot, + float fDist + ) + +{ + +} + +void Entity::GetRawTag + ( + int tagnum, + orientation_t *orient + ) + +{ + *orient = G_TIKI_Orientation( edict, tagnum & TAG_MASK ); +} + +qboolean Entity::GetRawTag + ( + const char *name, + orientation_t * orient + ) + +{ + int tagnum; + + tagnum = gi.Tag_NumForName( edict->tiki, name ); + + if( tagnum < 0 ) + return false; + + GetRawTag( tagnum, orient ); + return true; +} + +void Entity::GetTag + ( + int tagnum, + orientation_t *orient + ) + +{ + orientation_t o; + int i; + + GetRawTag( tagnum, &o ); + + VectorCopy( origin, orient->origin ); + + for( i = 0; i < 3; i++ ) + { + VectorMA( orient->origin, o.origin[ i ], orientation[ i ], orient->origin ); + } + MatrixMultiply( o.axis, orientation, orient->axis ); +} + +qboolean Entity::GetTag + ( + const char *name, + orientation_t * orient + ) + +{ + int tagnum; + + tagnum = gi.Tag_NumForName( edict->tiki, name ); + + if( tagnum < 0 ) + return false; + + GetTag( tagnum, orient ); + return true; +} + +void Entity::GetTag + ( + int tagnum, + Vector *pos, + Vector *forward, + Vector *left, + Vector *up + ) + +{ + orientation_t orient; + + GetTag( tagnum, &orient ); + + if( pos ) + { + *pos = Vector( orient.origin ); + } + if( forward ) + { + *forward = Vector( orient.axis[ 0 ] ); + } + if( left ) + { + *left = Vector( orient.axis[ 1 ] ); + } + if( up ) + { + *up = Vector( orient.axis[ 2 ] ); + } +} + +qboolean Entity::GetTag + ( + const char *name, + Vector *pos, + Vector *forward, + Vector *left, + Vector *up + ) + +{ + int tagnum; + + tagnum = gi.Tag_NumForName( edict->tiki, name ); + + if( tagnum < 0 ) + return false; + + GetTag( tagnum, pos, forward, left, up ); + return true; +} + +qboolean Entity::GetTagPositionAndOrientation + ( + str tagname, + orientation_t *new_or + ) + +{ + int tagnum; + + tagnum = gi.Tag_NumForName( edict->tiki, tagname ); + + if( tagnum < 0 ) + return false; + + GetTagPositionAndOrientation( tagnum, new_or ); + return true; +} + +void Entity::GetTagPositionAndOrientation + ( + int tagnum, + orientation_t *new_or + ) + +{ + int i; + orientation_t tag_or; + float axis[ 3 ][ 3 ]; + + GetRawTag( tagnum, &tag_or ); + + AnglesToAxis( angles, axis ); + + VectorCopy( origin, new_or->origin ); + + for( i = 0; i < 3; i++ ) + { + VectorMA( new_or->origin, tag_or.origin[ i ], tag_or.axis[ i ], new_or->origin ); + } + + MatrixMultiply( tag_or.axis, axis, new_or->axis ); +} + +void Entity::GetTagAngles + ( + Event *ev + ) + +{ + orientation_t orient; + Vector ang; + str tagname; + int tagnum; + + if( !edict->tiki ) + { + ScriptError( "Entity '%s' at %.2f %.2f %.2f has no model.", targetname.c_str(), origin[ 0 ], origin[ 1 ], origin[ 2 ] ); + } + + tagname = ev->GetString( 1 ); + tagnum = gi.Tag_NumForName( edict->tiki, tagname ); + if( tagnum < 0 ) + { + ScriptError( "Could not find tag '%s' in '%s'", tagname.c_str(), edict->tiki->name ); + } + + GetTagPositionAndOrientation( tagnum, &orient ); + MatrixToEulerAngles( orient.axis, ang ); + + ev->AddVector( ang ); +} + +void Entity::GetTagPosition + ( + Event *ev + ) + +{ + Vector pos; + str tagname; + int tagnum; + int i; + orientation_t tag_or; + float axis[ 3 ][ 3 ]; + + if( !edict->tiki ) + { + ScriptError( "Entity '%s' at %.2f %.2f %.2f has no model.", targetname.c_str(), origin[ 0 ], origin[ 1 ], origin[ 2 ] ); + } + + tagname = ev->GetString( 1 ); + tagnum = gi.Tag_NumForName( edict->tiki, tagname ); + if( tagnum < 0 ) + { + ScriptError( "Could not find tag '%s' in '%s'", tagname.c_str(), edict->tiki->name ); + } + + tag_or = G_TIKI_Orientation( edict, tagnum & TAG_MASK ); + AnglesToAxis( angles, axis ); + + pos = origin; + for( i = 0; i < 3; i++ ) + { + VectorMA( pos, tag_or.origin[ i ], axis[ i ], pos ); + } + + ev->AddVector( pos ); +} + +void Entity::addAngles + ( + Vector add + ) + +{ + if( bindmaster ) + { + setAngles( localangles + add ); + } + else + { + setAngles( angles + add ); + } +} + +void Entity::setAngles + ( + void + ) + +{ + if( bindmaster ) + { + setAngles( localangles ); + } + else + { + setAngles( angles ); + } +} + +void Entity::setAngles + ( + Vector ang + ) + +{ + Entity * ent; + int num, i; + + if( m_bGlueAngles && m_pGlueMaster ) + { + ang = m_pGlueMaster->angles; + avelocity = m_pGlueMaster->avelocity; + } + + angles[ 0 ] = AngleMod( ang[ 0 ] ); + angles[ 1 ] = AngleMod( ang[ 1 ] ); + angles[ 2 ] = AngleMod( ang[ 2 ] ); + + localangles = angles; + if( bindmaster ) + { + float mat[ 3 ][ 3 ]; + AnglesToAxis( localangles, mat ); + R_ConcatRotations( mat, bindmaster->orientation, orientation ); + MatrixToEulerAngles( orientation, angles ); + } + else + { + AnglesToAxis( angles, orientation ); + } + + angles.copyTo( edict->s.netangles ); + angles.copyTo( edict->s.angles ); + + // Fill the edicts matrix + VectorCopy( orientation[ 0 ], edict->mat[ 0 ] ); + VectorCopy( orientation[ 1 ], edict->mat[ 1 ] ); + VectorCopy( orientation[ 2 ], edict->mat[ 2 ] ); + + if( edict->s.eFlags & EF_LINKANGLES ) + { + angles.copyTo( edict->r.currentAngles ); + link(); + } + + // + // go through and set our children + // + num = numchildren; + for( i = 0; ( i < MAX_MODEL_CHILDREN ) && num; i++ ) + { + if( children[ i ] == ENTITYNUM_NONE ) + continue; + ent = ( Entity * )G_GetEntity( children[ i ] ); + ent->setAngles(); + num--; + } + + for( i = 0; i < m_iNumGlues; i++ ) + { + m_pGlues[ i ]->setAngles(); + } +} + +qboolean Entity::droptofloor + ( + float maxfall + ) + + { + trace_t trace; + Vector end; + Vector start; + + start = origin + Vector( "0 0 1" ); + end = origin; + end[ 2 ]-= maxfall; + + trace = G_Trace( start, mins, maxs, end, this, edict->clipmask, false, "Entity::droptofloor" ); + if ( trace.fraction == 1 || trace.startsolid || trace.allsolid || !trace.ent ) + { + groundentity = world->edict; + return false; + } + + setOrigin( trace.endpos ); + + groundentity = trace.ent; + + return true; + } + +void Entity::DamageType + ( + Event *ev + ) + + { + str damage; + damage = ev->GetString( 1 ); + if ( damage == "all" ) + { + damage_type = -1; + } + else + { + damage_type = MOD_NameToNum( damage ); + } + } + +void Entity::Damage + ( + Entity *inflictor, + Entity *attacker, + float damage, + Vector position, + Vector direction, + Vector normal, + int knockback, + int dflags, + int meansofdeath, + int location + ) + +{ + Event *ev; + + // if our damage types do not match, return + if( !MOD_matches( meansofdeath, damage_type ) ) + { + return; + } + + if( !attacker ) + { + attacker = world; + } + if( !inflictor ) + { + inflictor = world; + } + + ev = new Event( EV_Damage ); + ev->AddEntity( attacker ); + ev->AddFloat( damage ); + ev->AddEntity( inflictor ); + ev->AddVector( position ); + ev->AddVector( direction ); + ev->AddVector( normal ); + ev->AddInteger( knockback ); + ev->AddInteger( dflags ); + ev->AddInteger( meansofdeath ); + ev->AddInteger( location ); + ProcessEvent( ev ); +} + +void Entity::DamageEvent + ( + Event *ev + ) + +{ + Entity *inflictor; + Entity *attacker; + int damage; + Vector dir; + Vector momentum; + Vector position, direction, normal; + int knockback, damageflags, meansofdeath, location; + Event *event; + float m; + + if ( ( takedamage == DAMAGE_NO ) || ( movetype == MOVETYPE_NOCLIP ) ) + { + return; + } + + attacker = ev->GetEntity( 1 ); + damage = ev->GetInteger( 2 ); + inflictor = ev->GetEntity( 3 ); + + position = ev->GetVector( 4 ); + direction = ev->GetVector( 5 ); + normal = ev->GetVector( 6 ); + + knockback = ev->GetInteger( 7 ); + damageflags = ev->GetInteger( 8 ); + meansofdeath = ev->GetInteger( 9 ); + location = ev->GetInteger( 10 ); + + // figure momentum add + if ( ( inflictor != world ) && + ( movetype != MOVETYPE_NONE ) && + ( movetype != MOVETYPE_STATIONARY ) && + ( movetype != MOVETYPE_BOUNCE ) && + ( movetype != MOVETYPE_PUSH ) && + ( movetype != MOVETYPE_STOP ) ) + { + dir = origin - ( inflictor->origin + ( inflictor->mins + inflictor->maxs ) * 0.5 ); + dir.normalize(); + + if ( mass < 50) + { + m = 50; + } + else + { + m = mass; + } + + momentum = dir * damage * ( 1700.0 / m ); + velocity += momentum; + } + + // check for godmode or invincibility + if( flags & FL_GODMODE ) + { + return; + } + + // team play damage avoidance + //if ( ( global->teamplay == 1 ) && ( edict->team > 0 ) && ( edict->team == attacker->edict->team ) ) + // { + // return; + // } + + if ( !g_gametype->integer && IsSubclassOfPlayer() ) + { + damage *= 0.15; + } + + if ( deadflag ) + { + // Check for gib. + if ( inflictor->IsSubclassOfProjectile() ) + { + Event *gibEv; + + health -= damage; + + gibEv = new Event( EV_Gib ); + gibEv->AddEntity( this ); + gibEv->AddFloat( health ); + + ProcessEvent( gibEv ); + } + + return; + } + + // do the damage + health -= damage; + if ( health <= 0 ) + { + if ( attacker ) + { + event = new Event( EV_GotKill ); + event->AddEntity( this ); + event->AddInteger( damage ); + event->AddEntity( inflictor ); + event->AddInteger( meansofdeath ); + event->AddInteger( 0 ); + + attacker->ProcessEvent( event ); + } + + event = new Event( EV_Killed ); + event->AddEntity( attacker ); + event->AddFloat( damage ); + event->AddEntity( inflictor ); + event->AddVector( position ); + event->AddVector( direction ); + event->AddVector( normal ); + event->AddInteger( knockback ); + event->AddInteger( damageflags ); + event->AddInteger( meansofdeath ); + event->AddInteger( location ); + + ProcessEvent( event ); + return; + } + + event = new Event( EV_Pain ); + event->AddEntity( attacker ); + event->AddFloat( damage ); + event->AddEntity( inflictor ); + event->AddVector( position ); + event->AddVector( direction ); + event->AddVector( normal ); + event->AddInteger( knockback ); + event->AddInteger( damageflags ); + event->AddInteger( meansofdeath ); + event->AddInteger( location ); + + ProcessEvent( event ); +} + +void Entity::Delete + ( + void + ) + +{ + // Delete the entity the next frame + + if( g_iInThinks ) + PostEvent( EV_Remove, 0 ); + else + delete this; +} + +void Entity::Remove + ( + Event *ev + ) + +{ + if( ev->NumArgs() ) + ScriptError( "Arguments not allowed." ); + + Delete(); +} + +void Entity::EventSoundDone + ( + Event *ev + ) + +{ + int channelNum = ev->GetInteger( 1 ); + str sfxName = ev->GetString( 2 ); + + if( gi.S_IsSoundPlaying( channelNum, sfxName ) ) + { + // Repost the event + Event *event = new Event( EV_SoundDone ); + event->AddInteger( channelNum ); + event->AddString( sfxName ); + PostEvent( event, level.frametime ); + } + else + { + Unregister( STRING_SOUNDDONE ); + } +} + +void Entity::VolumeDamage + ( + float damage + ) + +{ + int i; + int numtouch; + Entity *ent; + int touch[ MAX_GENTITIES ]; + + numtouch = gi.AreaEntities( absmin, absmax, touch, MAX_GENTITIES ); + + for( i = 0; i < numtouch; i++ ) + { + ent = G_GetEntity( touch[ i ] ); + ent->Damage( + world, + world, + damage, + origin, + vec_zero, + vec_zero, + 0, + DAMAGE_RADIUS, + MOD_EXPLOSION ); + } +} + +void Entity::EventVolumeDamage + ( + Event *ev + ) + +{ + VolumeDamage( ev->GetFloat( 1 ) ); +} + +void Entity::AddImmunity + ( + Event *ev + ) + +{ + str immune_string; + int new_immunity; + int number_of_immunities; + int i; + + + number_of_immunities = ev->NumArgs(); + + for( i = 1; i <= number_of_immunities; i++ ) + { + immune_string = ev->GetString( i ); + + new_immunity = MOD_NameToNum( immune_string ); + + if( new_immunity != -1 ) + immunities.AddUniqueObject( new_immunity ); + } +} + +void Entity::RemoveImmunity + ( + Event *ev + ) + +{ + str immune_string; + int old_immunity; + int number_of_immunities; + int i; + + + number_of_immunities = ev->NumArgs(); + + for( i = 1; i <= number_of_immunities; i++ ) + { + immune_string = ev->GetString( i ); + + old_immunity = MOD_NameToNum( immune_string ); + + if( old_immunity != -1 && immunities.ObjectInList( old_immunity ) ) + immunities.RemoveObject( old_immunity ); + } +} + +qboolean Entity::Immune + ( + int meansofdeath + ) + +{ + int number_of_immunities, i; + + number_of_immunities = immunities.NumObjects(); + + for( i = 1; i <= number_of_immunities; i++ ) + { + if( meansofdeath == immunities.ObjectAt( i ) ) + return true; + } + + return false; +} + +void Entity::Stun + ( + float time + ) + + { + Event *ev = new Event( EV_Stun ); + ev->AddFloat( time ); + ProcessEvent( ev ); + } + +/* +============ +CanDamage + +Returns true if the inflictor can directly damage the target. Used for +explosions and melee attacks. +============ +*/ +qboolean Entity::CanDamage + ( + Entity *target, + Entity *skip_ent + ) + +{ + trace_t trace; + Vector pos; + Entity *skip_entity; + + if( skip_ent ) + skip_entity = skip_ent; + else + skip_entity = this; + + trace = G_Trace( origin, vec_origin, vec_origin, target->centroid, skip_entity, MASK_SHOT, false, "Entity::CanDamage 1" ); + if( trace.fraction == 1 || trace.ent == target->edict ) + { + return true; + } + pos = target->centroid + Vector( 15, 15, 0 ); + trace = G_Trace( origin, vec_origin, vec_origin, pos, skip_entity, MASK_SHOT, false, "Entity::CanDamage 3" ); + if( trace.fraction == 1 || trace.ent == target->edict ) + { + return true; + } + pos = target->centroid + Vector( -15, 15, 0 ); + trace = G_Trace( origin, vec_zero, vec_zero, pos, skip_entity, MASK_SHOT, false, "Entity::CanDamage 4" ); + if( trace.fraction == 1 || trace.ent == target->edict ) + { + return true; + } + pos = target->centroid + Vector( 15, -15, 0 ); + trace = G_Trace( origin, vec_zero, vec_zero, pos, skip_entity, MASK_SHOT, false, "Entity::CanDamage 5" ); + if( trace.fraction == 1 || trace.ent == target->edict ) + { + return true; + } + pos = target->centroid + Vector( -15, -15, 0 ); + trace = G_Trace( origin, vec_zero, vec_zero, pos, skip_entity, MASK_SHOT, false, "Entity::CanDamage 6" ); + if( trace.fraction == 1 || trace.ent == target->edict ) + { + return true; + } + + return false; +} + +void Entity::EventInPVS + ( + Event *ev + ) + +{ + ev->AddInteger( gi.AreasConnected( edict->r.areanum, ev->GetEntity( 1 )->edict->r.areanum ) != 0 ); +} + +qboolean Entity::IsDead + ( + void + ) + +{ + return deadflag != DEAD_NO; +} + +qboolean Entity::IsTouching + ( + Entity *e1 + ) + + { + if ( e1->absmin.x > absmax.x ) + { + return false; + } + if ( e1->absmin.y > absmax.y ) + { + return false; + } + if ( e1->absmin.z > absmax.z ) + { + return false; + } + if ( e1->absmax.x < absmin.x ) + { + return false; + } + if ( e1->absmax.y < absmin.y ) + { + return false; + } + if ( e1->absmax.z < absmin.z ) + { + return false; + } + + return true; + } + +void Entity::IsTouching + ( + Event *ev + ) + +{ + Entity *ent = ev->GetEntity( 1 ); + + if( !ent ) + { + ScriptError( "IsTouching used with a NULL entity." ); + } + + ev->AddInteger( IsTouching( ent ) ); +} + +qboolean Entity::FovCheck + ( + float *delta, + float fovdot + ) + +{ + float deltadot = delta[ 0 ] * orientation[ 0 ][ 0 ] + delta[ 1 ] * orientation[ 0 ][ 1 ]; + + if( fovdot < 0.0f ) + { + if( deltadot >= 0.0f ) + return true; + + return ( delta[ 0 ] * delta[ 0 ] + delta[ 1 ] * delta[ 1 ] ) * fovdot * fovdot > ( deltadot * deltadot ); + } + else + { + if( deltadot < 0.0f ) + return false; + + return ( deltadot * deltadot ) > ( delta[ 0 ] * delta[ 0 ] + delta[ 1 ] * delta[ 1 ] ) * fovdot * fovdot; + } +} + +bool Entity::CanSee + ( + Entity *ent, + float fov, + float vision_distance + ) + +{ + float delta[ 2 ]; + + delta[ 0 ] = ent->centroid[ 0 ] - centroid[ 0 ]; + delta[ 1 ] = ent->centroid[ 1 ] - centroid[ 1 ]; + + if( ( vision_distance <= 0.0f ) || ( delta[ 0 ] * delta[ 0 ] + delta[ 1 ] * delta[ 1 ] ) <= ( vision_distance * vision_distance ) ) + { + if( gi.AreasConnected( edict->r.areanum, ent->edict->r.areanum ) && + ( ( fov <= 0.0f || fov >= 360.0f ) || + ( FovCheck( delta, cos( fov * ( 0.5 * M_PI / 180.0 ) ) ) ) ) ) + { + return G_SightTrace( centroid, + vec_zero, + vec_zero, + ent->centroid, + this, + ent, + MASK_CANSEE, + 0, + "Entity::CanSee" ); + } + } + + return false; +} + +void Entity::CanSee + ( + Event *ev + ) + +{ + Entity *ent; + float fov = 0.0f; + float distance = 0.0f; + + if( ev->NumArgs() <= 0 || ev->NumArgs() > 3 ) + { + ScriptError( "cansee should have 1, 2 or 3 arguments" ); + } + + if( ev->NumArgs() > 2 ) + { + distance = ev->GetFloat( 3 ); + if( distance < 0 ) + { + ScriptError( "distance must be >= 0" ); + } + } + + if( ev->NumArgs() > 1 ) + { + fov = ev->GetFloat( 2 ); + if( fov < 0.0f || fov > 360.0f ) + { + ScriptError( "fov must be in range 0 <= fov <= 360" ); + } + } + + ent = ev->GetEntity( 1 ); + if( !ent ) + { + ScriptError( "NULL entity in parameter 1" ); + } + + ev->AddInteger( CanSee( ent, fov, distance ) ); +} + +void Entity::GetVelocity + ( + Event *ev + ) + +{ + ev->AddVector( velocity ); +} + +void Entity::GetAVelocity + ( + Event *ev + ) + +{ + ev->AddVector( avelocity ); +} + +void Entity::SetVelocity + ( + Event *ev + ) + +{ + velocity = ev->GetVector( 1 ); +} + +void Entity::FadeNoRemove + ( + Event *ev + ) + + { + float rate; + float target; + float myalpha; + + if ( ev->NumArgs() > 1 ) + { + target = ev->GetFloat( 2 ); + } + else + { + target = 0; + } + + if ( ev->NumArgs() > 0 ) + { + rate = ev->GetFloat( 1 ); + assert( rate ); + if ( rate > 0 ) + rate = FRAMETIME / rate; + } + else + { + rate = 0.03f; + } + + myalpha = edict->s.alpha; + myalpha -= rate; + + if ( myalpha < target ) + myalpha = target; + + setAlpha( myalpha ); + + if ( myalpha > target ) + { + PostEvent( *ev, FRAMETIME ); + } + + G_SetConstantLight( &edict->s.constantLight, &myalpha, &myalpha, &myalpha, 0 ); + } + +void Entity::FadeOut + ( + Event *ev + ) + + { + float myscale; + float myalpha; + + myscale = edict->s.scale; + myscale -= 0.03f; + myalpha = edict->s.alpha; + myalpha -= 0.03f; + if ( myscale < 0 ) + myscale = 0; + if ( myalpha < 0 ) + myalpha = 0; + + if ( myscale <= 0 && myalpha <= 0 ) + { + PostEvent( EV_Remove, 0 ); + } + else + { + PostEvent( *ev, FRAMETIME ); + } + + setScale( myscale ); + setAlpha( myalpha ); + } + +void Entity::FadeIn + ( + Event *ev + ) + + { + float rate; + float target; + float myalpha; + + if ( ev->NumArgs() > 1 ) + { + target = ev->GetFloat( 2 ); + } + else + { + target = 1; + } + + if ( ev->NumArgs() > 0 ) + { + rate = ev->GetFloat( 1 ); + assert( rate ); + if ( rate > 0 ) + rate = FRAMETIME / rate; + } + else + { + rate = 0.03f; + } + + + myalpha = edict->s.alpha; + myalpha += rate; + + if ( myalpha > target ) + myalpha = target; + + if ( myalpha < target ) + { + PostEvent( *ev, FRAMETIME ); + } + setAlpha( myalpha ); + } + +void Entity::Fade + ( + Event *ev + ) + + { + float rate; + float target; + float myalpha; + + if ( ev->NumArgs() > 1 ) + { + target = ev->GetFloat( 2 ); + } + else + { + target = 0; + } + + if ( ev->NumArgs() > 0 ) + { + rate = ev->GetFloat( 1 ); + assert( rate ); + if ( rate > 0 ) + rate = FRAMETIME / rate; + } + else + { + rate = 0.03f; + } + + myalpha = edict->s.alpha; + myalpha -= rate; + + if ( myalpha <= 0 ) + { + PostEvent( EV_Remove, 0 ); + return; + } + + if ( myalpha < target ) + myalpha = target; + + if ( myalpha > target ) + { + PostEvent( *ev, FRAMETIME ); + } + + setAlpha( myalpha ); + G_SetConstantLight( &edict->s.constantLight, &myalpha, &myalpha, &myalpha, 0 ); + } + +void Entity::SetMassEvent + ( + Event *ev + ) + + { + mass = ev->GetFloat( 1 ); + } + +void Entity::CheckGround + ( + void + ) + +{ + Vector point; + trace_t trace; + + if( flags & ( FL_SWIM | FL_FLY ) ) + { + return; + } + + if( velocity.z > 100 ) + { + groundentity = NULL; + return; + } + + // if the hull point one-quarter unit down is solid the entity is on ground + point = origin; + point.z -= 0.25; + trace = G_Trace( origin, mins, maxs, point, this, edict->clipmask, false, "Entity::CheckGround" ); + + // check steepness + if( ( trace.plane.normal[ 2 ] <= 0.7 ) && !trace.startsolid ) + { + groundentity = NULL; + return; + } + + groundentity = trace.ent; + groundplane = trace.plane; + groundcontents = trace.contents; + + if( !trace.startsolid && !trace.allsolid ) + { + setOrigin( trace.endpos ); + velocity.z = 0; + } +} + +void Entity::BecomeSolid + ( + Event *ev + ) + + { + if ( ( model.length() ) && ( ( model[ 0 ] == '*' ) || ( strstr( model.c_str(), ".bsp" ) ) ) ) + { + setSolidType( SOLID_BSP ); + } + else + { + setSolidType( SOLID_BBOX ); + } + } + +void Entity::BecomeNonSolid + ( + Event *ev + ) + +{ + setSolidType( SOLID_NOT ); +} + +void Entity::Ghost + ( + Event *ev + ) + + { + // Make not solid, but send still send over whether it is hidden or not + setSolidType( SOLID_NOT ); + edict->r.svFlags &= ~SVF_NOCLIENT; + } + +void Entity::Sound + ( + str sound_name, + int channel, + float volume, + float min_dist, + Vector *sound_origin, + float pitch, + int argstype, + int doCallback, + int checkSubtitle, + float max_dist + ) + +{ + const char *name = NULL; + vec3_t org; + str random_alias; + AliasListNode_t *ret = NULL; + static cvar_t *g_subtitle = NULL; + static bool _tmp = false; + int num; + + if( !_tmp ) + { + g_subtitle = gi.Cvar_Get( "g_subtitle", "0", CVAR_ARCHIVE ); + _tmp = true; + } + + if( doCallback && g_gametype->integer ) + { + Com_Printf( "^~^~^ Callback of sound '%s' ignored.\n", sound_name.c_str() ); + doCallback = 0; + } + + if( sound_name.length() > 0 ) + { + // Get the real sound to play + + random_alias = GetRandomAlias( sound_name, &ret ).c_str(); + + if( random_alias.length() > 0 ) + name = random_alias.c_str(); + + if( !name ) + name = sound_name.c_str(); + + // Play the sound + + if( name != NULL ) + { + if( ret ) + { + if( channel < 0 ) + { + channel = ret->channel; + } + + num = entnum; + if( sound_origin ) + { + VectorCopy( *sound_origin, org ); + num = ENTITYNUM_NONE; + } + else + { + VectorCopy( edict->s.origin, org ); + + if( doCallback ) + { + num |= 0x400; + } + } + + + if( argstype == 0 ) + { + volume = G_CRandom() * ret->volumeMod + ret->volume; + pitch = G_CRandom() * ret->pitchMod + ret->pitch; + min_dist = ret->dist; + max_dist = ret->maxDist; + } + else if( argstype == 1 ) + { + if( volume >= 0.0f ) + volume = G_CRandom() * ret->volumeMod + volume; + else + pitch = G_CRandom() * ret->pitchMod + ret->pitch; + + if( pitch >= 0.0f ) + pitch = G_CRandom() * ret->pitchMod + pitch; + else + pitch = G_CRandom() * ret->pitchMod + ret->pitch; + } + else + { + if( volume <= 0.0f ) + volume = G_CRandom() * ret->volumeMod + ret->volume; + + if( pitch >= 0.0f ) + pitch = G_CRandom() * ret->pitchMod + pitch; + else + pitch = G_CRandom() * ret->pitchMod + ret->pitch; + + if( min_dist < 0.0f ) + min_dist = ret->dist; + + if( max_dist < 0.0f ) + max_dist = ret->maxDist; + } + + if( ( !checkSubtitle || g_subtitle->integer ) && ret->subtitle ) + { + Entity *p = G_GetEntity( 0 ); + + if( g_subtitle->integer == 2 || max_dist * max_dist > DistanceSquared( org, p->edict->s.origin ) ) + { + cvar_t *curSubtitle = gi.Cvar_Get( "curSubtitle", "0", 0 ); + + gi.Cvar_Set( va( "subtitle%d", curSubtitle->integer ), va( "%s", ret->subtitle ) ); + gi.Cvar_Set( "curSubtitle", va( "%d", curSubtitle->integer + 1 ) ); + } + } + + gi.Sound( &org, num, channel, name, volume, min_dist, pitch, max_dist, ret->streamed ); + } + } + else + { + gi.DPrintf( "ERROR: Entity::Sound: %s needs an alias in ubersound.scr or uberdialog.scr - Please fix.\n", sound_name.c_str() ); + } + } + else + { + warning( "Sound", "Null sample pointer" ); + } +} + +void Entity::LoopSound + ( + Event *ev + ) + +{ + str sound_name; + float volume = DEFAULT_VOL; + float min_dist = DEFAULT_MIN_DIST; + str min_dist_string; + + + if( ev->NumArgs() < 1 ) + return; + + // Get parameters + + sound_name = ev->GetString( 1 ); + + if( ev->NumArgs() > 1 ) + volume = ev->GetFloat( 2 ); + + if( ev->NumArgs() > 2 ) + { + min_dist_string = ev->GetString( 3 ); + + if( min_dist_string == LEVEL_WIDE_STRING ) + min_dist = LEVEL_WIDE_MIN_DIST; + else + min_dist = ev->GetFloat( 3 ); + } + + // Add this sound to loop + + LoopSound( sound_name.c_str(), volume, min_dist ); +} + +void Entity::LoopSound( str sound_name, float volume, float min_dist, float max_dist, float pitch ) +{ + str name = NULL; + str random_alias; + AliasListNode_t *ret = NULL; + + // Get the real sound to be played + + if( sound_name.length() > 0 ) + { + // Get the real sound to play + + name = GetRandomAlias( sound_name, &ret ).c_str(); + + if( !name ) + name = sound_name.c_str(); + + if( name.length() && ret ) + { + int aliaschannel = ret->channel; + float aliasvolume = G_Random() * ret->volumeMod + ret->volume; + float aliasmin_dist = ret->dist; + float aliasmax_dist = ret->maxDist; + float aliaspitch = G_Random() * ret->pitchMod + ret->pitch; + int aliasstreamed = ret->streamed; + // Add the looping sound to the entity + + edict->s.loopSound = gi.soundindex( name, aliasstreamed ); + edict->s.loopSoundVolume = aliasvolume; + edict->s.loopSoundMinDist = aliasmin_dist; + edict->s.loopSoundMaxDist = aliasmax_dist; + edict->s.loopSoundPitch = aliaspitch; + + // Local sound will always be heard + edict->s.loopSoundFlags = aliaschannel == CHAN_LOCAL; + } + else + { + gi.DPrintf( "ERROR: Entity::LoopSound: %s needs an alias in ubersound.scr or uberdialog.scr - Please fix.\n", sound_name.c_str() ); + } + } +} + +void Entity::StopLoopSound( Event *ev ) +{ + StopLoopSound(); +} + +void Entity::StopLoopSound( void ) +{ + edict->s.loopSound = 0; +} + +void Entity::ProcessSoundEvent( Event *ev, qboolean checkSubtitle ) +{ + str sound_name; + str wait; + int waitTillDone = 0; + float volume; + int channel = 0; + + // Set defaults + volume = DEFAULT_VOL; + + if( ev->NumArgs() > 3 ) + { + Com_Printf( "ERROR Sound. Format is playsound soundname \n" ); + return; + } + + // Get sound parameters + + sound_name = ev->GetString( 1 ); + + if( ev->NumArgs() > 1 ) + wait = ev->GetString( 2 ); + + if( Q_stricmp( wait.c_str(), "wait" ) ) + { + if( !Q_stricmp( wait.c_str(), "volume" ) ) + { + if( ev->NumArgs() != 3 ) + ScriptError( "Entity::Sound: volume not followed by a float" ); + + volume = ev->GetFloat( 3 ); + } + } + else + { + waitTillDone = 1; + + if( ev->NumArgs() == 3 ) + volume = ev->GetFloat( 3 ); + } + + if( volume == DEFAULT_VOL ) + { + if( wait.length() ) + channel = atoi( wait.c_str() ); + + Sound( sound_name, channel, volume, 0, NULL, 0, 0, waitTillDone, checkSubtitle, -1.0f ); + } + else + { + Sound( sound_name, -1.0f, volume, -1.0f, NULL, -1.0f, 1, waitTillDone, checkSubtitle, -1.0f ); + } +} + +void Entity::Sound + ( + Event *ev + ) + +{ + if( level.spawning ) + { + Event *event = new Event( EV_Sound ); + + for( int i = 1; i <= ev->NumArgs(); i++ ) + { + event->AddValue( ev->GetValue( 1 ) ); + } + + PostEvent( event, level.frametime ); + } + else + { + ProcessSoundEvent( ev, true ); + } +} + +void Entity::StopSound + ( + Event *ev + ) + + { + if (ev->NumArgs() < 1) + StopSound( CHAN_BODY ); + else + StopSound( ev->GetInteger( 1 ) ); + } + +void Entity::StopSound + ( + int channel + ) + + { + gi.StopSound( entnum, channel ); + } + +void Entity::SetLight + ( + Event *ev + ) + + { + float r, g, b; + + if ( ev->NumArgs() == 1 ) + { + Vector tmp; + + tmp = ev->GetVector( 1 ); + r = tmp.x; + g = tmp.y; + b = tmp.z; + } + else + { + r = ev->GetFloat( 1 ); + g = ev->GetFloat( 2 ); + b = ev->GetFloat( 3 ); + lightRadius = ev->GetFloat( 4 ); + } + + G_SetConstantLight( &edict->s.constantLight, &r, &g, &b, &lightRadius ); + } + +void Entity::LightOn + ( + Event *ev + ) + + { + G_SetConstantLight( &edict->s.constantLight, NULL, NULL, NULL, &lightRadius ); + } + +void Entity::LightOff + ( + Event *ev + ) + + { + float radius = 0; + + G_SetConstantLight( &edict->s.constantLight, NULL, NULL, NULL, &radius ); + } + +void Entity::LightRed + ( + Event *ev + ) + + { + float r; + + r = ev->GetFloat( 1 ); + G_SetConstantLight( &edict->s.constantLight, &r, NULL, NULL, NULL ); + } + +void Entity::LightGreen + ( + Event *ev + ) + + { + float g; + + g = ev->GetFloat( 1 ); + G_SetConstantLight( &edict->s.constantLight, NULL, &g, NULL, NULL ); + } + +void Entity::LightBlue + ( + Event *ev + ) + + { + float b; + + b = ev->GetFloat( 1 ); + G_SetConstantLight( &edict->s.constantLight, NULL, NULL, &b, NULL ); + } + +void Entity::LightRadius + ( + Event *ev + ) + + { + lightRadius = ev->GetFloat( 1 ); + G_SetConstantLight( &edict->s.constantLight, NULL, NULL, NULL, &lightRadius ); + } + +void Entity::LightStyle + ( + Event *ev + ) + + { + int style; + + style = ev->GetInteger( 1 ); + G_SetConstantLight( &edict->s.constantLight, NULL, NULL, NULL, NULL, &style ); + } + +void Entity::EventSetHealthOnly + ( + Event *ev + ) + +{ + if( IsDead() ) + { + ScriptError( "cannot give health to dead entities" ); + } + + health = ev->GetFloat( 1 ); + if( health <= 0.0f ) + { + ScriptError( "health must be greater than 0" ); + } + + if( health > max_health ) { + health = max_health; + } +} + +void Entity::EventSetMaxHealth + ( + Event *ev + ) + +{ + max_health = ev->GetFloat( 1 ); + if( max_health <= 0.0f ) + { + ScriptError( "max_health must be greater than 0" ); + } + + if( health > max_health ) { + health = max_health; + } +} + +void Entity::EventGetMaxHealth + ( + Event *ev + ) + +{ + ev->AddFloat( max_health ); +} + +void Entity::SetHealth + ( + Event *ev + ) + +{ + if( IsDead() ) + { + ScriptError( "cannot give health to dead entities" ); + } + + health = ev->GetFloat( 1 ); + + if( health <= 0 ) + { + ScriptError( "health must be greater than 0" ); + } + + max_health = health; +} + +void Entity::GetHealth + ( + Event *ev + ) + +{ + ev->AddFloat( health ); +} + +void Entity::SetSize + ( + Event *ev + ) + +{ + Vector min, max; + + min = ev->GetVector( 1 ); + max = ev->GetVector( 2 ); + setSize( min, max ); +} + +void Entity::SetMins + ( + Event *ev + ) + +{ + Vector min; + + min = ev->GetVector( 1 ); + setSize( min, maxs ); +} + +void Entity::SetMaxs + ( + Event *ev + ) + +{ + Vector max; + + max = ev->GetVector( 1 ); + setSize( mins, max ); +} + +void Entity::SetScale + ( + Event *ev + ) + +{ + setScale( ev->GetFloat( 1 ) ); +} + +void Entity::GetScale + ( + Event *ev + ) + +{ + ev->AddFloat( edict->s.scale ); +} + +void Entity::SetAlpha + ( + Event *ev + ) + + { + setAlpha( ev->GetFloat( 1 ) ); + } + +void Entity::SetOrigin + ( + Event *ev + ) + + { + setOrigin( ev->GetVector( 1 ) ); + } + +void Entity::SetKillTarget + ( + Event *ev + ) + + { + SetKillTarget( ev->GetString( 1 ) ); + } + +void Entity::SetAngles + ( + Event *ev + ) + +{ + setAngles( ev->GetVector( 1 ) ); +} + +Vector Entity::GetControllerAngles + ( + int num + ) + +{ + Vector controller_angles; + + assert( ( num >= 0 ) && ( num < NUM_BONE_CONTROLLERS ) ); + + if( ( num < 0 ) || ( num >= NUM_BONE_CONTROLLERS ) ) + { + gi.Printf( "GetControllerAngles", "Bone controller index out of range (%d)\n", num ); + return vec_zero; + } + + controller_angles = edict->s.bone_angles[ num ]; + + return controller_angles; +} + +void Entity::GetControllerAngles + ( + Event *ev + ) + +{ + int num = ev->GetInteger( 1 ); + + // this check is missing in mohaa + if( ( num < 0 ) || ( num >= NUM_BONE_CONTROLLERS ) ) + { + ScriptError( "Bone controller index out of range. Index must be between 0-" STRING( NUM_BONE_CONTROLLERS - 1 ) "." ); + } + + ev->AddVector( edict->s.bone_angles[ num ] ); +} + +void Entity::SetControllerAngles + ( + int num, + vec3_t angles + ) + +{ + assert( ( num >= 0 ) && ( num < NUM_BONE_CONTROLLERS ) ); + if( ( num < 0 ) || ( num >= NUM_BONE_CONTROLLERS ) ) + { + gi.Printf( "SetControllerAngles", "Bone controller index out of range (%d)\n", num ); + return; + } + + VectorCopy( angles, edict->s.bone_angles[ num ] ); + EulerToQuat( edict->s.bone_angles[ num ], edict->s.bone_quat[ num ] ); +} + +void Entity::SetControllerAngles + ( + Event *ev + ) + +{ + int num; + Vector angles; + + num = ev->GetInteger( 1 ); + angles = ev->GetVector( 2 ); + + // this check is missing in mohaa + if( ( num < 0 ) || ( num >= NUM_BONE_CONTROLLERS ) ) + { + ScriptError( "Bone controller index out of range. Index must be between 0-" STRING( NUM_BONE_CONTROLLERS - 1 ) "." ); + } + + VectorCopy( angles, edict->s.bone_angles[ num ] ); + EulerToQuat( edict->s.bone_angles[ num ], edict->s.bone_quat[ num ] ); +} + +void Entity::SetControllerTag + ( + int num, + int tag_num + ) + +{ + assert( ( num >= 0 ) && ( num < NUM_BONE_CONTROLLERS ) ); + + if( ( num < 0 ) || ( num >= NUM_BONE_CONTROLLERS ) ) + { + gi.Printf( "SetControllerTag", "Bone controller index out of range (%d)\n", num ); + return; + } + + edict->s.bone_tag[ num ] = tag_num; +} + +qboolean Entity::attach + ( + int parent_entity_num, + int tag_num, + qboolean use_angles, + Vector offset + ) + +{ + int i; + Entity * parent; + + if( entnum == parent_entity_num ) + { + warning( "attach", "Trying to attach to oneself." ); + return false; + } + + if( edict->s.parent != ENTITYNUM_NONE ) + detach(); + + // + // make sure this is a modelanim entity so that the attach works properly + // + if( edict->s.eType == ET_GENERAL ) + { + edict->s.eType = ET_MODELANIM; + } + + // + // get the parent + // + parent = ( Entity * )G_GetEntity( parent_entity_num ); + + if( parent->numchildren < MAX_MODEL_CHILDREN ) + { + // + // find a free spot in the parent + // + for( i = 0; i < MAX_MODEL_CHILDREN; i++ ) + { + if( parent->children[ i ] == ENTITYNUM_NONE ) + { + break; + } + } + + edict->s.parent = parent_entity_num; + setSolidType( SOLID_NOT ); + parent->children[ i ] = entnum; + parent->numchildren++; + edict->s.tag_num = tag_num; + edict->s.attach_use_angles = use_angles; + offset.copyTo( edict->s.attach_offset ); + setOrigin(); + + return true; + } + return false; +} + +void Entity::KillAttach + ( + Event *ev + ) + + { + int i; + Entity *child = NULL; + + + // Kill all of this entities children + + for ( i = 0 ; i < MAX_MODEL_CHILDREN; i++ ) + { + if ( children[i] != ENTITYNUM_NONE ) + { + // Remove child + child = ( Entity * )G_GetEntity( children[i] ); + + if ( child ) + child->ProcessEvent( EV_Remove ); + + // Remove child from this entity + children[i] = ENTITYNUM_NONE; + } + } + + numchildren = 0; + } + +void Entity::detach + ( + void + ) + +{ + int i; + int num; + Entity * parent; + + if( edict->s.parent == ENTITYNUM_NONE ) + return; + + parent = ( Entity * )G_GetEntity( edict->s.parent ); + if( !parent ) + return; + for( i = 0, num = parent->numchildren; i < MAX_MODEL_CHILDREN; i++ ) + { + if( parent->children[ i ] == ENTITYNUM_NONE ) + { + continue; + } + if( parent->children[ i ] == entnum ) + { + parent->children[ i ] = ENTITYNUM_NONE; + parent->numchildren--; + break; + } + num--; + if( !num ) + break; + } + edict->s.parent = ENTITYNUM_NONE; + setOrigin( origin ); +} + +void Entity::Flags( Event *ev ) + { + const char *flag; + int mask; + int action; + int i; + + for ( i = 1; i <= ev->NumArgs(); i++ ) + { + action = FLAG_IGNORE; + flag = ev->GetString( i ); + switch( flag[0] ) + { + case '+': + action = FLAG_ADD; + flag++; + break; + case '-': + action = FLAG_CLEAR; + flag++; + break; + default: + gi.Printf( "Entity::Flags", "First character is not '+' or '-', assuming '+'\n" ); + action = FLAG_ADD; + break; + } + + // + // WARNING: please change the Event decleration, + // to match this function, if flags are added or + // deleted the event must be updated. + // + if ( !Q_stricmp( flag, "blood" ) ) + mask = FL_BLOOD; + else if ( !Q_stricmp( flag, "explode" ) ) + mask = FL_DIE_EXPLODE; + else if ( !Q_stricmp( flag, "die_gibs" ) ) + mask = FL_DIE_GIBS; + else if ( !Q_stricmp( flag, "autoaim" ) ) + mask = FL_AUTOAIM; + else if ( !Q_stricmp( flag, "god" ) ) + mask = FL_GODMODE; + else + { + mask = 0; + action = FLAG_IGNORE; + gi.Printf( "Unknown flag '%s'", flag ); + } + switch (action) + { + case FLAG_ADD: + flags |= mask; + break; + case FLAG_CLEAR: + flags &= ~mask; + break; + case FLAG_IGNORE: + break; + } + } + } + + +void Entity::Effects( Event *ev ) + { + const char *flag; + int mask=0; + int action; + int i; + + for ( i = 1; i <= ev->NumArgs(); i++ ) + { + action = 0; + flag = ev->GetString( i ); + switch( flag[0] ) + { + case '+': + action = FLAG_ADD; + flag++; + break; + case '-': + action = FLAG_CLEAR; + flag++; + break; + default: + gi.Printf( "Entity::Effects", "First character is not '+' or '-', assuming '+'\n" ); + action = FLAG_ADD; + break; + } + + // + // WARNING: please change the Event decleration, + // to match this function, if flags are added or + // deleted the event must be updated. + // + if ( !Q_stricmp( flag, "everyframe" ) ) + mask = EF_EVERYFRAME; + if ( !Q_stricmp( flag, "antisbjuice" ) ) + mask = EF_ANTISBJUICE; + else + { + action = FLAG_IGNORE; + gi.Printf( "Unknown token %s.", flag ); + } + + switch (action) + { + case FLAG_ADD: + edict->s.eFlags |= mask; + break; + case FLAG_CLEAR: + edict->s.eFlags &= ~mask; + break; + case FLAG_IGNORE: + break; + } + } + } + +void Entity::RenderEffects + ( + Event *ev + ) + +{ + const char *flag; + int mask = 0; + int action; + int i; + + for( i = 1; i <= ev->NumArgs(); i++ ) + { + action = 0; + flag = ev->GetString( i ); + switch( flag[ 0 ] ) + { + case '+': + action = FLAG_ADD; + flag++; + break; + case '-': + action = FLAG_CLEAR; + flag++; + break; + default: + gi.Printf( "Entity::RenderEffects", "First character is not '+' or '-', assuming '+'\n" ); + action = FLAG_ADD; + break; + } + + // + // WARNING: please change the Event decleration, + // to match this function, if flags are added or + // deleted the event must be updated. + // + if( !Q_stricmp( flag, "dontdraw" ) ) + mask = RF_DONTDRAW; + else if( !Q_stricmp( flag, "betterlighting" ) ) + mask = RF_EXTRALIGHT; + else if( !Q_stricmp( flag, "lensflare" ) ) + mask = RF_LENSFLARE; + else if( !Q_stricmp( flag, "viewlensflare" ) ) + mask = RF_VIEWLENSFLARE; + else if( !Q_stricmp( flag, "lightoffset" ) ) + mask = RF_LIGHTOFFSET; + else if( !Q_stricmp( flag, "skyorigin" ) ) + mask = RF_SKYORIGIN; + else if( !Q_stricmp( flag, "fullbright" ) ) + mask = RF_FULLBRIGHT; + else if( !Q_stricmp( flag, "minlight" ) ) + mask = RF_MINLIGHT; + else if( !Q_stricmp( flag, "additivedynamiclight" ) ) + mask = RF_ADDITIVE_DLIGHT; + else if( !Q_stricmp( flag, "lightstyledynamiclight" ) ) + mask = RF_LIGHTSTYLE_DLIGHT; + else if( !Q_stricmp( flag, "shadow" ) ) + mask = RF_SHADOW; + else if( !Q_stricmp( flag, "preciseshadow" ) ) + mask = RF_SHADOW_PRECISE; + else if( !Q_stricmp( flag, "invisible" ) ) + mask = RF_INVISIBLE; + else + { + action = FLAG_IGNORE; + gi.Printf( "Unknown token %s.", flag ); + } + + switch( action ) + { + case FLAG_ADD: + edict->s.renderfx |= mask; + break; + case FLAG_CLEAR: + edict->s.renderfx &= ~mask; + break; + case FLAG_IGNORE: + break; + } + } +} + +void Entity::SVFlags + ( + Event *ev + ) + +{ + const char *flag; + int mask = 0; + Entity *ent = NULL; + int singleClient = 0; + int action; + int i; + + for( i = 1; i <= ev->NumArgs(); i++ ) + { + action = 0; + flag = ev->GetString( i ); + switch( flag[ 0 ] ) + { + case '+': + action = FLAG_ADD; + flag++; + break; + case '-': + action = FLAG_CLEAR; + flag++; + break; + default: + gi.Printf( "Entity::SVFlags: First character is not '+' or '-', assuming '+'\n" ); + action = FLAG_ADD; + break; + } + + // + // WARNING: please change the Event decleration, + // to match this function, if flags are added or + // deleted the event must be updated. + // + if( !Q_stricmp( flag, "broadcast" ) ) + { + mask = SVF_BROADCAST; + } + else if( !Q_stricmp( flag, "sendonce" ) ) + { + mask = SVF_SENDONCE; + } + else if( !Q_stricmp( flag, "singleclient" ) ) + { + mask = SVF_SINGLECLIENT; + if( action == FLAG_ADD ) + { + ent = ev->GetEntity( i + 1 ); + + if( !ent ) + { + ScriptError( "No player specified for +singleclient!" ); + } + } + + i++; + } + else if( !Q_stricmp( flag, "notsingleclient" ) ) + { + mask = SVF_NOTSINGLECLIENT; + if( action == FLAG_ADD ) + { + ent = ev->GetEntity( i + 1 ); + + if( !ent ) + { + ScriptError( "No player specified for +notsingleclient!" ); + } + } + + i++; + } + else + { + action = FLAG_IGNORE; + gi.Printf( "Entity::SVFlags: Unknown token %s.\n", flag ); + } + + switch( action ) + { + case FLAG_ADD: + edict->r.svFlags |= mask; + + if( ( mask & SVF_SINGLECLIENT ) || ( mask & SVF_NOTSINGLECLIENT ) ) + { + edict->r.singleClient = singleClient; + } + + break; + case FLAG_CLEAR: + edict->r.svFlags &= ~mask; + + if( ( mask & SVF_SINGLECLIENT ) || ( mask & SVF_NOTSINGLECLIENT ) ) + { + edict->r.singleClient = 0; + } + + break; + case FLAG_IGNORE: + break; + } + } + + if( edict->r.svFlags & SVF_SENDONCE ) + { + // Turn this entity into an event if the SENDONCE flag is sent + edict->s.eType = ET_EVENTS; + } +} + +void Entity::BroadcastAIEvent + ( + int iType, + float rad + ) + +{ + G_BroadcastAIEvent( this, origin, iType, rad ); +} + +void Entity::BroadcastAIEvent + ( + Event *ev + ) + +{ + int iType; + float rad; + str sTypeName; + + if( !( this->flags & FL_NOTARGET ) ) + { + iType = 8; + + if( ev->NumArgs() > 0 ) + { + sTypeName = ev->GetString( 1 ); + iType = G_AIEventTypeFromString( sTypeName ); + + rad = ev->NumArgs() <= 1 ? G_AIEventRadius( iType ) : ev->GetFloat( 2 ); + } + + BroadcastAIEvent( iType, rad ); + } +} + +void Entity::PreAnimate + ( + void + ) + +{ +} + +void Entity::DoForceActivate + ( + void + ) + +{ + edict->r.lastNetTime = level.inttime; +} + +void Entity::ClientThink + ( + void + ) + +{ + +} + +void Entity::Think + ( + void + ) + +{ +} + +void Entity::SetWaterType + ( + void + ) + + { + qboolean isinwater; + + watertype = gi.PointContents( origin, 0 ); + isinwater = watertype & MASK_WATER; + + if ( isinwater ) + { + waterlevel = 1; + } + else + { + waterlevel = 0; + } + } + +void Entity::DamageSkin + ( + trace_t * trace, + float damage + ) + + { + /* FIXME : Do we need damage skins? + int surface; + + // FIXME handle different bodyparts + surface = trace->intersect.surface; + if ( !edict->s.surfaces[ surface ] ) + { + edict->s.surfaces[ surface ]++; + } + */ + } + +void Entity::Kill + ( + Event *ev + ) + + { + health = 0; + Damage( this, this, 10, origin, vec_zero, vec_zero, 0, 0, MOD_SUICIDE ); + } + + +void Entity::SurfaceCommand + ( + const char * surf_name, + const char * token + ) + +{ + const char * current_surface_name; + int surface_num; + int mask; + int action; + qboolean do_all = false; + qboolean mult = false; + + if( surf_name[ strlen( surf_name ) - 1 ] == '*' ) + { + mult = true; + surface_num = 0; + } + else if( str( surf_name ) != str( "all" ) ) + { + surface_num = gi.Surface_NameToNum( edict->tiki, surf_name ); + + if( surface_num < 0 ) + { + warning( "SurfaceCommand", "group %s not found.", surf_name ); + return; + } + } + else + { + surface_num = 0; + do_all = true; + } + + action = 0; + switch( token[ 0 ] ) + { + case '+': + action = FLAG_ADD; + token++; + break; + case '-': + action = FLAG_CLEAR; + token++; + break; + default: + warning( "Entity::SurfaceModelEvent", "First character is not '+' or '-', assuming '+'\n" ); + action = FLAG_ADD; + break; + } + // + // WARNING: please change the Event decleration, + // to match this function, if flags are added or + // deleted the event must be updated. + // + if( !Q_stricmp( token, "skin1" ) ) + { + mask = MDL_SURFACE_SKINOFFSET_BIT0; + } + else if( !Q_stricmp( token, "skin2" ) ) + { + mask = MDL_SURFACE_SKINOFFSET_BIT1; + } + else if( !Q_stricmp( token, "nodraw" ) ) + { + mask = MDL_SURFACE_NODRAW; + } + else if( !Q_stricmp( token, "crossfade" ) ) + { + mask = MDL_SURFACE_CROSSFADE_SKINS; + } + else + { + mask = 0; + warning( "SurfaceCommand", "Unknown token %s.", token ); + action = FLAG_IGNORE; + } + + int numsurfaces; + if( edict->tiki ) + numsurfaces = gi.NumSurfaces( edict->tiki ); + else + numsurfaces = 0; + + for( ; surface_num < numsurfaces; surface_num++ ) + { + if( mult ) + { + current_surface_name = gi.Surface_NumToName( edict->tiki, surface_num ); + + if( Q_stricmpn( current_surface_name, surf_name, strlen( surf_name ) - 1 ) != 0 ) + continue; + } + + switch( action ) + { + case FLAG_ADD: + edict->s.surfaces[ surface_num ] |= mask; + break; + case FLAG_CLEAR: + edict->s.surfaces[ surface_num ] &= ~mask; + break; + case FLAG_IGNORE: + break; + } + + if( !do_all && !mult ) + break; + } +} + +void Entity::SurfaceModelEvent + ( + Event *ev + ) + +{ + const char * surf_name; + const char * token; + int i; + + surf_name = ev->GetString( 1 ); + + for( i = 2; i <= ev->NumArgs(); i++ ) + { + token = ev->GetString( i ); + SurfaceCommand( surf_name, token ); + } +} + +void Entity::SetShaderData + ( + Event *ev + ) + +{ + edict->s.shader_data[ 0 ] = ev->GetFloat( 1 ); + edict->s.shader_data[ 1 ] = ev->GetFloat( 2 ); +} + +void Entity::AttachEvent + ( + Event * ev + ) + { + Entity * parent; + const char * bone; + int tagnum; + qboolean use_angles = qtrue; + Vector offset; + + parent = ev->GetEntity( 1 ); + bone = ev->GetString( 2 ); + + if ( ev->NumArgs() > 2 ) + use_angles = ev->GetInteger( 3 ); + + if ( ev->NumArgs() > 3 ) + offset = ev->GetVector( 4 ); + + if ( !parent ) + return; + + tagnum = gi.Tag_NumForName( parent->edict->tiki, bone ); + if ( tagnum >= 0 ) + { + attach( parent->entnum, tagnum, use_angles, offset ); + } + else + { + warning( "AttachEvent", "Tag %s not found", bone ); + } + } + +void Entity::AttachModelEvent +( +Event * ev +) +{ + Animate *obj; + const char * bone; + str modelname; + int tagnum; + float remove_time, fade_time, fade_delay; + Vector offset; + + obj = new Animate; + + modelname = ev->GetString( 1 ); + bone = ev->GetString( 2 ); + if( ev->NumArgs() > 2 ) + { + obj->setScale( ev->GetFloat( 3 ) ); + } + if( ev->NumArgs() > 3 ) + { + obj->SetTargetName( ev->GetString( 4 ) ); + } + + if( ev->NumArgs() > 4 ) + obj->detach_at_death = ev->GetInteger( 5 ); + + if( ev->NumArgs() > 5 ) + { + remove_time = ev->GetFloat( 6 ); + + if( remove_time != -1 ) + { + Event *remove_event = new Event( EV_Remove ); + obj->PostEvent( remove_event, remove_time ); + } + } + + if( ev->NumArgs() > 6 ) + { + Event *fade_event; + + fade_time = ev->GetFloat( 7 ); + + if( fade_time != -1 ) + { + obj->setAlpha( 0 ); + + fade_event = new Event( EV_FadeIn ); + fade_event->AddFloat( fade_time ); + obj->PostEvent( fade_event, 0 ); + } + } + + if( ev->NumArgs() > 7 ) + { + Event *fade_event; + + fade_delay = ev->GetFloat( 8 ); + + if( fade_delay != -1 ) + { + if( ev->NumArgs() > 8 ) + fade_time = ev->GetFloat( 9 ); + else + fade_time = 0; + + fade_event = new Event( EV_Fade ); + + if( fade_time ) + fade_event->AddFloat( fade_time ); + + obj->PostEvent( fade_event, fade_delay ); + } + } + + if( ev->NumArgs() > 9 ) + offset = ev->GetVector( 10 ); + + obj->setModel( modelname ); + + tagnum = gi.Tag_NumForName( edict->tiki, bone ); + if( tagnum >= 0 ) + { + if( obj->attach( this->entnum, tagnum, true, offset ) ) + { + obj->NewAnim( "idle" ); + } + else + { + delete obj; + return; + } + } + else + { + warning( "AttachModelEvent", "Tag %s not found", bone ); + } +} + +void Entity::RemoveAttachedModelEvent + ( + Event *ev + ) + { + const char *tag_name; + int tag_num; + int num; + int i; + Entity *ent; + float fade_rate = 0; + Event *fade_event; + str model_name; + + tag_name = ev->GetString( 1 ); + tag_num = gi.Tag_NumForName( edict->tiki, tag_name ); + + if ( ev->NumArgs() > 1 ) + fade_rate = ev->GetFloat( 2 ); + + if ( ev->NumArgs() > 2 ) + model_name = ev->GetString( 3 ); + + if ( tag_num >= 0 ) + { + num = numchildren; + + for ( i = 0 ; (i < MAX_MODEL_CHILDREN) && num ; i++ ) + { + if ( children[i] == ENTITYNUM_NONE ) + continue; + + ent = ( Entity * )G_GetEntity( children[i] ); + + if ( ent->edict->s.tag_num == tag_num ) + { + if ( !model_name.length() || model_name == ent->model ) + { + if ( fade_rate ) + { + fade_event = new Event( EV_Fade ); + fade_event->AddFloat( fade_rate ); + fade_event->AddFloat( 0 ); + ent->PostEvent( fade_event, 0 ); + } + + ent->PostEvent( EV_Remove, fade_rate ); + } + } + + num--; + } + } + } + +void Entity::DetachEvent + ( + Event * ev + ) + + { + if ( edict->s.parent == ENTITYNUM_NONE ) + { + return; + } + detach(); + } + +void Entity::TakeDamageEvent + ( + Event * ev + ) + { + takedamage = DAMAGE_YES; + } + +void Entity::NoDamageEvent + ( + Event * ev + ) + { + takedamage = DAMAGE_NO; + } + +void Entity::Gravity + ( + Event *ev + ) + + { + gravity = ev->GetFloat( 1 ); + } + +void Entity::UseBoundingBoxEvent + ( + Event *ev + ) + +{ + edict->r.svFlags |= SVF_USEBBOX; +} + +void Entity::HurtEvent + ( + Event *ev + ) + +{ + Vector normal; + float dmg; + int means_of_death; + Vector direction; + + if( ev->NumArgs() < 1 ) + { + dmg = 50; + } + else + { + dmg = ev->GetFloat( 1 ); + } + + if( ev->NumArgs() > 1 ) + means_of_death = MOD_NameToNum( ev->GetString( 2 ) ); + else + means_of_death = MOD_CRUSH; + + if( ev->NumArgs() > 2 ) + { + direction = ev->GetVector( 3 ); + direction.normalize(); + } + else + { + direction = vec_zero; + } + + normal = Vector( orientation[ 0 ] ); + Damage( world, world, dmg, centroid, direction, normal, dmg, 0, means_of_death ); +} + +void Entity::HealEvent + ( + Event *ev + ) + +{ + if( IsDead() ) + { + ScriptError( "cannot heal dead entities" ); + } + + health += ev->GetFloat( 1 ) * max_health; + if( health > max_health ) + { + health = max_health; + } +} + +void Entity::Censor + ( + Event *ev + ) + + { + Vector delta; + float oldsize; + float newsize; + + oldsize = size.length(); + setSolidType( SOLID_NOT ); + setModel( "censored.tik" ); + gi.CalculateBounds( edict->tiki, 1, mins, maxs ); + delta = maxs - mins; + newsize = delta.length(); + edict->s.scale = oldsize / newsize; + mins *= edict->s.scale; + maxs *= edict->s.scale; + setSize( mins, maxs ); + setOrigin(); + } + +void Entity::StationaryEvent + ( + Event *ev + ) + + { + setMoveType( MOVETYPE_STATIONARY ); + } + +void Entity::Explosion + ( + Event *ev + ) + + { + str expmodel; + str tag_name; + //orientation_t orient; + Vector explosion_origin; + + expmodel = ev->GetString( 1 ); + explosion_origin = origin; + + if ( ev->NumArgs() > 1 ) + { + tag_name = ev->GetString( 2 ); + + //if ( GetRawTag( tag_name.c_str(), &orient, legs ) ) + // VectorAdd( orient.origin, origin, explosion_origin ); + + GetTag( tag_name.c_str(), &explosion_origin ); + } + + ExplosionAttack( explosion_origin, this, expmodel ); + } + +void Entity::Shader + ( + Event *ev + ) + + { + const char * token; + + if( gi.modeltiki( model ) ) + { + gi.Printf( "shader event being called on TIKI model\n" ); + } + // + // get sub shader command + // + token = ev->GetString( 1 ); + + // + // WARNING: please change the Event decleration, + // to match this function, if flags are added or + // deleted the event must be updated. + // + if (!Q_stricmp( token, "translation")) + { + float x, y; + + x = ev->GetFloat( 2 ); + y = ev->GetFloat( 3 ); + TRANSLATION_TO_PKT( x, edict->s.tag_num ); + TRANSLATION_TO_PKT( y, edict->s.skinNum ); + } + else if (!Q_stricmp( token, "offset")) + { + float x, y; + + x = ev->GetFloat( 2 ); + y = ev->GetFloat( 3 ); + OFFSET_TO_PKT( x, edict->s.tag_num ); + OFFSET_TO_PKT( y, edict->s.skinNum ); + } + else if (!Q_stricmp (token, "rotation")) + { + float rot; + + rot = ev->GetFloat( 2 ); + ROTATE_TO_PKT( rot, edict->s.tag_num ); + } + else if (!Q_stricmp (token, "wavebase")) + { + float base; + + base = ev->GetFloat( 2 ); + BASE_TO_PKT( base, edict->s.surfaces[ 0 ] ); + } + else if (!Q_stricmp (token, "waveamp")) + { + float amp; + + amp = ev->GetFloat( 2 ); + AMPLITUDE_TO_PKT( amp, edict->s.surfaces[ 1 ] ); + } + else if (!Q_stricmp (token, "wavephase")) + { + float phase; + + phase = ev->GetFloat( 2 ); + PHASE_TO_PKT( phase, edict->s.surfaces[ 2 ] ); + } + else if (!Q_stricmp (token, "wavefreq")) + { + float freq; + + freq = ev->GetFloat( 2 ); + FREQUENCY_TO_PKT( freq, edict->s.surfaces[ 3 ] ); + } + } + +void Entity::DropToFloorEvent + ( + Event *ev + ) + + { + float range; + + if ( ev->NumArgs() > 0 ) + { + range = ev->GetFloat( 1 ); + } + else + { + range = MAP_SIZE; + } + if ( !droptofloor( range ) ) + { + } + } + + +//************************************************************************* +// +// BIND code +// +//************************************************************************* + +qboolean Entity::isBoundTo + ( + Entity *master + ) + + { + Entity *ent; + + for( ent = bindmaster; ent != NULL; ent = ent->bindmaster ) + { + if ( ent == master ) + { + return true; + } + } + + return false; + } + +void Entity::bind + ( + Entity *master, + qboolean use_my_angles, + qboolean bBindChilds + ) + +{ + float mat[ 3 ][ 3 ]; + float local[ 3 ][ 3 ]; + Vector ang; + + assert( master ); + if( !master ) + { + warning( "bind", "Null master entity" ); + return; + } + + if( master == this ) + { + warning( "bind", "Trying to bind to oneself." ); + return; + } + + m_bBindChilds = bBindChilds; + + // unbind myself from my master + unbind(); + + bindmaster = master; + bind_use_my_angles = use_my_angles; + + // We are now separated from our previous team and are either + // an individual, or have a team of our own. Now we can join + // the new bindmaster's team. Bindmaster must be set before + // joining the team, or we will be placed in the wrong position + // on the team. + joinTeam( master ); + + // calculate local angles + TransposeMatrix( bindmaster->orientation, mat ); + R_ConcatRotations( mat, orientation, local ); + MatrixToEulerAngles( local, ang ); + setAngles( ang ); + + setLocalOrigin( getParentVector( localorigin - bindmaster->origin ) ); + + return; +} + +void Entity::unbind + ( + void + ) + +{ + Entity *prev; + Entity *next; + Entity *last; + Entity *ent; + + if( !bindmaster ) + { + return; + } + + //bindmaster = NULL; + + // Check this GAMEFIX - should it be origin? + localorigin = Vector( edict->s.origin ); + localangles = Vector( edict->s.angles ); + + if( !teammaster ) + { + bindmaster = NULL; + //Teammaster already has been freed + return; + } + + // We're still part of a team, so that means I have to extricate myself + // and any entities that are bound to me from the old team. + // Find the node previous to me in the team + prev = teammaster; + + for( ent = teammaster->teamchain; ent && ( ent != this ); ent = ent->teamchain ) + { + prev = ent; + } + + // If ent is not pointing to me, then something is very wrong. + assert( ent ); + if( !ent ) + { + gi.Printf( "unbind", "corrupt team chain\n" ); + } + + // Find the last node in my team that is bound to me. + // Also find the first node not bound to me, if one exists. + last = this; + for( next = teamchain; next != NULL; next = next->teamchain ) + { + if( !next->isBoundTo( this ) ) + { + break; + } + + // Tell them I'm now the teammaster + next->teammaster = this; + last = next; + } + + // disconnect the last member of our team from the old team + last->teamchain = NULL; + + // connect up the previous member of the old team to the node that + // follow the last node bound to me (if one exists). + if( teammaster != this ) + { + prev->teamchain = next; + if( !next && ( teammaster == prev ) ) + { + prev->teammaster = NULL; + } + } + else if( next ) + { + // If we were the teammaster, then the nodes that were not bound to me are now + // a disconnected chain. Make them into their own team. + for( ent = next; ent->teamchain != NULL; ent = ent->teamchain ) + { + ent->teammaster = next; + } + next->teammaster = next; + next->flags &= ~FL_TEAMSLAVE; + } + + // If we don't have anyone on our team, then clear the team variables. + if( teamchain ) + { + // make myself my own team + teammaster = this; + } + else + { + // no longer a team + teammaster = NULL; + } + + flags &= ~FL_TEAMSLAVE; + bindmaster = NULL; +} + +void Entity::glue + ( + Entity *master, + qboolean use_my_angles + ) + +{ + int iNumGlues; + + if( m_pGlueMaster ) { + unglue(); + } + + if( !master ) + { + warning( "glue", "Cannot glue to master because of: Master is NULL\n" ); + return; + } + + if( master == this ) + { + warning( "glue", "Cannot glue to master because of: Binding an entity to itself\n" ); + return; + } + + iNumGlues = master->m_iNumGlues; + if( iNumGlues + 1 > MAX_GLUE_CHILDREN ) + { + warning( "glue", "Cannot glue to master because of: MAX_GLUE_CHILDREN reached\n" ); + return; + } + + for( int i = 0; i < iNumGlues; i++ ) + { + if( master->m_pGlues[ i ] == this ) + { + warning( "glue", "Cannot glue to master because of: entity is already glued\n" ); + return; + } + } + + master->m_pGlues[ iNumGlues ] = this; + + if( use_my_angles ) + { + m_bGlueAngles = true; + master->m_pGluesFlags[ iNumGlues ] = GL_USEANGLES; + } + else + { + m_bGlueAngles = false; + master->m_pGluesFlags[ iNumGlues ] = 0; + } + + m_pGlueMaster = master; + master->m_iNumGlues++; + + setAngles( master->angles ); + setOrigin( master->origin ); +} + +void Entity::unglue + ( + void + ) + +{ + int iNumGlues; + int i; + Entity *master = m_pGlueMaster; + + if( !master ) { + return; + } + + iNumGlues = master->m_iNumGlues; + + for( i = 0; i < iNumGlues; i++ ) + { + if( master->m_pGlues[ i ] == this ) { + break; + } + } + + if( i != iNumGlues ) + { + for( ; i < iNumGlues - 1; i++ ) + { + master->m_pGlues[ i ] = master->m_pGlues[ i + 1 ]; + master->m_pGluesFlags[ i ] = master->m_pGluesFlags[ i + 1 ]; + } + + master->m_iNumGlues--; + + m_pGlueMaster = NULL; + m_bGlueAngles = false; + } +} + +void Entity::EventUnbind + ( + Event *ev + ) + + { + unbind(); + } + +void Entity::BindEvent + ( + Event *ev + ) + +{ + Entity *ent; + bool bBindChilds; + + ent = ev->GetEntity( 1 ); + if( ent ) + { + if( ev->NumArgs() > 1 ) + { + bBindChilds = ev->GetBoolean( 2 ); + } + else + { + bBindChilds = false; + } + + bind( ent, false, bBindChilds ); + } +} + +void Entity::EventUnglue + ( + Event *ev + ) + +{ + unglue(); +} + +void Entity::GlueEvent + ( + Event *ev + ) + +{ + Entity *ent; + qboolean glueAngles; + + if( ev->NumArgs() > 1 ) + { + glueAngles = ev->GetInteger( 2 ); + } + else + { + glueAngles = qtrue; + } + + ent = ev->GetEntity( 1 ); + if( ent ) + { + glue( ent, glueAngles ); + } +} + +Vector Entity::getParentVector + ( + Vector vec + ) + +{ + Vector pos; + + if( !bindmaster ) + { + return vec; + } + + pos[ 0 ] = vec * bindmaster->orientation[ 0 ]; + pos[ 1 ] = vec * bindmaster->orientation[ 1 ]; + pos[ 2 ] = vec * bindmaster->orientation[ 2 ]; + + return pos; +} + +// +// Team methods +// + +void Entity::joinTeam + ( + Entity *teammember + ) + +{ + Entity *ent; + Entity *master; + Entity *prev; + Entity *next; + + if( teammaster && ( teammaster != this ) ) + { + quitTeam(); + } + + assert( teammember ); + if( !teammember ) + { + warning( "joinTeam", "Null entity" ); + return; + } + + master = teammember->teammaster; + if( !master ) + { + master = teammember; + teammember->teammaster = teammember; + teammember->teamchain = this; + + // make anyone who's bound to me part of the new team + for( ent = teamchain; ent != NULL; ent = ent->teamchain ) + { + ent->teammaster = master; + } + } + else + { + // skip past the chain members bound to the entity we're teaming up with + prev = teammember; + next = teammember->teamchain; + if( bindmaster ) + { + // if we have a bindmaster, joing after any entities bound to the entity + // we're joining + while( next && ( ( Entity * )next )->isBoundTo( teammember ) ) + { + prev = next; + next = next->teamchain; + } + } + else + { + // if we're not bound to someone, then put us at the end of the team + while( next ) + { + prev = next; + next = next->teamchain; + } + } + + // make anyone who's bound to me part of the new team and + // also find the last member of my team + for( ent = this; ent->teamchain != NULL; ent = ent->teamchain ) + { + ent->teamchain->teammaster = master; + } + + prev->teamchain = this; + ent->teamchain = next; + } + + teammaster = master; + flags |= FL_TEAMSLAVE; +} + +void Entity::quitTeam + ( + void + ) + +{ + Entity *ent; + + if( !teammaster ) + { + return; + } + + if( teammaster == this ) + { + if( !teamchain->teamchain ) + { + teamchain->teammaster = NULL; + } + else + { + // make next teammate the teammaster + for( ent = teamchain; ent; ent = ent->teamchain ) + { + ent->teammaster = teamchain; + } + } + + teamchain->flags &= ~FL_TEAMSLAVE; + } + else + { + assert( flags & FL_TEAMSLAVE ); + assert( teammaster->teamchain ); + + ent = teammaster; + while( ent->teamchain != this ) + { + // this should never happen + assert( ent->teamchain ); + + ent = ent->teamchain; + } + + ent->teamchain = teamchain; + + if( !teammaster->teamchain ) + { + teammaster->teammaster = NULL; + } + } + + teammaster = NULL; + teamchain = NULL; + flags &= ~FL_TEAMSLAVE; +} + +void Entity::EventQuitTeam + ( + Event *ev + ) + + { + quitTeam(); + } + + +void Entity::JoinTeam + ( + Event *ev + ) + + { + Entity *ent; + + ent = ev->GetEntity( 1 ); + if ( ent ) + { + joinTeam( ent ); + } + } + +void Entity::AddToSoundManager + ( + Event *ev + ) + + { + SoundMan.AddEntity( this ); + } + +inline qboolean Entity::HitSky + ( + trace_t *trace + ) + +{ + assert( trace ); + if( trace->surfaceFlags & SURF_SKY ) + { + return true; + } + return false; +} + +qboolean Entity::HitSky + ( + void + ) + +{ + return HitSky( &level.impact_trace ); +} + +void Entity::SetAngleEvent + ( + Event *ev + ) + { + Vector movedir; + + movedir = G_GetMovedir( ev->GetFloat( 1 ) ); + setAngles( movedir.toAngles() ); + } + +void Entity::NoLerpThisFrame + ( + void + ) + { + edict->s.eFlags ^= EF_TELEPORT_BIT; + } + +void Entity::PostAnimate( void ) +{ +} + +void Entity::Postthink( void ) +{ +} + +void Entity::TouchTriggersEvent + ( + Event *ev + ) + { + flags |= FL_TOUCH_TRIGGERS; + } + +void Entity::DeathSinkStart( Event *ev ) +{ + if( g_gametype->integer ) + { + PostEvent( EV_Remove, 5.0f ); + } + else + { + // Start the sinking + ProcessEvent( EV_DeathSink ); + } +} + +void Entity::DeathSink( Event *ev ) +{ + // Sink just a little + + if( g_gametype->integer ) + { + origin[ 2 ] -= 0.2f; + setOrigin( origin ); + + // Make sure the sink happens again next frame + PostEvent( EV_DeathSink, FRAMETIME ); + } + else + { + Entity *player = G_GetEntity( 0 ); + + // Remove the entity when the player isn't supposed to see it + if( player && gi.AreasConnected( this->edict->r.areanum, player->edict->r.areanum ) ) + { + PostEvent( EV_DeathSink, 1.0f ); + } + else + { + PostEvent( EV_Remove, 0 ); + } + } + +} + +void Entity::EndFrame + ( + void + ) + +{ +} + +void Entity::CalcBlend + ( + void + ) + +{ +} + +void Entity::VelocityModified + ( + void + ) + +{ +} + +void Entity::DetachAllChildren + ( + void + ) + +{ + int i; + + for( i = 0; i < MAX_MODEL_CHILDREN; i++ ) + { + Entity * ent; + if( children[ i ] == ENTITYNUM_NONE ) + continue; + + ent = ( Entity * )G_GetEntity( children[ i ] ); + if( ent ) + { + ent->PostEvent( EV_Remove, 0 ); + } + } +} + +void Entity::DetachAllChildren + ( + Event *ev + ) + +{ + DetachAllChildren(); +} + +void Entity::SetMovementStealth( float fStealthScale ) +{ + if( fStealthScale < 0.0f ) + { + stealthMovementScale = 0.0f; + } + else + { + stealthMovementScale = fStealthScale; + } +} + +void Entity::EventMovementStealth + ( + Event *ev + ) + +{ + SetMovementStealth( ev->GetFloat( 1 ) ); +} + +void Entity::GetYaw + ( + Event *ev + ) + +{ + ev->AddFloat( angles[ 1 ] ); +} + +void Entity::PusherEvent + ( + Event *ev + ) + +{ + Entity *inflictor; + Entity *attacker; + Vector dir; + Vector momentum; + float m; + float force; + + if( movetype <= MOVETYPE_NOCLIP || + movetype == MOVETYPE_FLYMISSILE || + movetype == MOVETYPE_STOP || + movetype == MOVETYPE_PUSH ) + { + return; + } + + inflictor = ev->GetEntity( 1 ); + attacker = ev->GetEntity( 2 ); + dir = ev->GetVector( 3 ); + force = ev->GetFloat( 4 ); + + m = mass; + if( m < 20 ) + { + m = 20.0f; + } + + m = 1000.0f / m; + momentum = dir * force * m; + + velocity += momentum; +} + +void Entity::AlwaysDraw + ( + Event *ev + ) + +{ + edict->s.renderfx |= RF_ALWAYSDRAW; +} + +void Entity::NormalDraw + ( + Event *ev + ) + +{ + edict->s.renderfx &= RF_DONTDRAW | RF_ALWAYSDRAW; +} + +void Entity::NeverDraw + ( + Event *ev + ) + +{ + edict->s.renderfx |= RF_DONTDRAW; +} + +void Entity::GetMins + ( + Event *ev + ) + +{ + ev->AddVector( mins ); +} + +void Entity::GetMaxs + ( + Event *ev + ) + +{ + ev->AddVector( maxs ); +} + +void Entity::ForceActivate + ( + Event *ev + ) + +{ + DoForceActivate(); +} + +void Entity::EventTrace + ( + Event *ev + ) + +{ + Vector start, end, mins, maxs; + int mask = 0x2000B01; + Entity *ent; + trace_t trace; + + mins = vec_zero; + maxs = vec_zero; + ent = NULL; + + start = ev->GetVector( 1 ); + end = ev->GetVector( 2 ); + + if( ev->NumArgs() > 2 ) + { + if( ev->GetInteger( 3 ) ) { + mask = 1; + } + } + + if( ev->NumArgs() > 3 ) { + mins = ev->GetVector( 4 ); + } + + if( ev->NumArgs() > 4 ) { + maxs = ev->GetVector( 5 ); + } + + if( ev->NumArgs() > 5 ) { + ent = G_GetEntity( ev->GetInteger( 6 ) ); + } + + // call trace + G_Trace( start, + mins, + maxs, + end, + ent, + mask, + qfalse, + "Entity::EventTrace" ); + + ev->AddVector( trace.endpos ); +} + +void Entity::EventSightTrace + ( + Event *ev + ) + +{ + Vector start, end, mins, maxs; + int mask = 0x2000B01; + Entity *ent; + qboolean hit = qfalse; + + mins = vec_zero; + maxs = vec_zero; + + start = ev->GetVector( 1 ); + end = ev->GetVector( 2 ); + + if( ev->NumArgs() > 2 ) + { + if( ev->GetInteger( 3 ) ) { + mask = 1; + } + } + + if( ev->NumArgs() > 3 ) { + mins = ev->GetVector( 4 ); + } + + if( ev->NumArgs() > 4 ) { + maxs = ev->GetVector( 5 ); + } + + if( ev->NumArgs() > 5 ) { + ent = G_GetEntity( ev->GetInteger( 6 ) ); + } + + hit = G_SightTrace( + start, + mins, + maxs, + end, + ent, + NULL, + mask, + qfalse, + "Entity::EventSightTrace" + ); + + ev->AddInteger( hit ); +} + +void Entity::ConnectPaths + ( + void + ) + +{ + PathNode *node; + int to; + int j; + + for( int i = 0; i < m_iNumBlockedPaths; i++ ) + { + to = m_BlockedPaths[ i ].to; + node = PathManager.pathnodes[ m_BlockedPaths[ i ].from ]; + + j = node->virtualNumChildren; + pathway_t *pathway = &node->Child[ j ]; + + do + { + j--; + pathway--; + } while( pathway->node != to ); + + pathway->numBlockers--; + + if( !pathway->numBlockers ) + node->ConnectChild( j ); + } + + m_iNumBlockedPaths = 0; + if( m_BlockedPaths ) + { + delete m_BlockedPaths; + m_BlockedPaths = NULL; + } +} + +void Entity::DisconnectPaths + ( + void + ) + +{ + int i; + int j; + PathNode *node; + pathway_t *pathway; + pathway_ref paths[ 1024 ]; + vec3_t mins; + vec3_t maxs; + gentity_t *collision_ent; + + if( m_BlockedPaths ) { + ConnectPaths(); + } + + if( IsSubclassOfVehicle() ) + { + VehicleCollisionEntity *ent = ( ( Vehicle * )this )->GetCollisionEntity(); + + if( !ent ) + return; + + collision_ent = ent->edict; + } + else + { + collision_ent = edict; + } + + VectorSet( mins, -15.0f, -15.0f, 0 ); + VectorSet( maxs, 15.0f, 15.0f, 94.0f ); + + for( i = 0; i < PathManager.nodecount; i++ ) + { + node = PathManager.pathnodes[ i ]; + + for( j = node->virtualNumChildren - 1; j >= 0; j-- ) + { + pathway = &node->Child[ j ]; + + if( !gi.SightTraceEntity( collision_ent, + pathway->pos1, + mins, + maxs, + pathway->pos2, + MASK_PATHSOLID, + qtrue ) ) + { + paths[ m_iNumBlockedPaths ].from = node->nodenum; + paths[ m_iNumBlockedPaths ].to = pathway->node; + m_iNumBlockedPaths++; + + pathway->numBlockers++; + + if( pathway->numBlockers == 1 ) + node->DisconnectChild( j ); + } + } + } + + if( m_iNumBlockedPaths ) + { + m_BlockedPaths = new pathway_ref[ m_iNumBlockedPaths ]; + + for( i = 0; i < m_iNumBlockedPaths; i++ ) + { + m_BlockedPaths[ i ] = paths[ i ]; + } + } +} + +void Entity::EventDisconnectPaths + ( + Event *ev + ) + +{ + DisconnectPaths(); +} + +void Entity::EventConnectPaths + ( + Event *ev + ) + +{ + ConnectPaths(); +} + +void Entity::EventGetEntnum + ( + Event *ev + ) + +{ + ev->AddInteger( entnum ); +} + +void Entity::EventSetRadnum + ( + Event *ev + ) + +{ + radnum = ev->GetInteger( 1 ); +} + +void Entity::EventGetRadnum + ( + Event *ev + ) + +{ + ev->AddInteger( radnum ); +} + +void Entity::EventSetRotatedBbox + ( + Event *ev + ) + +{ + if( ev->GetInteger( 1 ) ) + { + edict->s.eFlags |= EF_LINKANGLES; + } + else + { + edict->s.eFlags &= ~EF_LINKANGLES; + } + + setAngles( angles ); +} + +void Entity::EventGetRotatedBbox + ( + Event *ev + ) + +{ + ev->AddInteger( ( edict->s.eFlags & EF_LINKANGLES ) ? 1 : 0 ); +} + +void Entity::DrawBoundingBox + ( + int showbboxes + ) + +{ + if( showbboxes >= 100 ) + { + if( g_monitorNum->integer != entnum ) + { + if( !*g_monitor->string || g_monitor->string != targetname ) { + return; + } + } + + showbboxes -= 100; + } + + switch( showbboxes ) + { + case 1: + if( edict->s.solid ) + { + G_DebugBBox( origin, mins, maxs, 1, 1, 0, 1 ); + } + break; + case 2: + if( edict->s.solid ) + { + G_DebugBBox( vec_zero, edict->r.absmin, edict->r.absmax, 1, 0, 1, 1 ); + } + break; + case 3: + if( edict->tiki && !( edict->s.renderfx & RF_DONTDRAW ) ) + G_DebugBBox( origin, mins, maxs, 1, 1, 0, 1 ); + break; + case 4: + G_DebugBBox( origin, mins, maxs, 1, 1, 0, 1 ); + break; + case 5: + default: + if( IsSubclassOfAnimate() && edict->tiki ) + { + Animate * anim; + vec3_t mins, maxs; + + anim = ( Animate * )this; + // FIXME + G_DebugBBox( origin, mins, maxs, 0, 1, 0, 1 ); + } + else + { + G_DebugBBox( origin, mins, maxs, 1, 1, 0, 1 ); + } + break; + } +} + +void Entity::PathnodeClaimRevoked + ( + PathNode *node + ) + +{ + return node->Relinquish(); +} + +qboolean Entity::BlocksAIMovement + ( + void + ) const + +{ + return true; +} + +qboolean Entity::AIDontFace + ( + void + ) const + +{ + return true; +} + +void Entity::GetZone( Event *ev ) +{ + // FIXME: stub + STUB(); + +#if 0 + ZoneInfo *zone = getZone(); + + if( zone != NULL ) { + ev->AddListener( zone ); + } else { + ev->AddNil(); + } +#endif +} + +void Entity::IsInZone( Event *ev ) +{ + // FIXME: stub + STUB(); + +#if 0 + ZoneInfo *zone = ( ZoneInfo * )ev->GetEntity( 1 ); + ZoneInfo *currentZone = getZone(); + + if( zone == NULL ) { + ScriptError( "The zone must be a valid ZoneInfo!!!\n" ); + } + + if( !zone->inheritsFrom( "ZoneInfo" ) ) { + ScriptError( "The specified zone is not a ZoneInfo!!!\n" ); + } + + if( currentZone == zone || IsTouching( zone ) ) { + ev->AddInteger( 1 ); // The entity is in the specified zone + } else { + ev->AddInteger( 0 ); // The entity is not in the specified zone + } +#endif +} + +void Entity::SetDepthHack( Event *ev ) +{ + int bEnable; + Entity * entity = (Entity*)this; + + bEnable = ev->GetInteger( 1 ); + + if ( bEnable ) { + entity->edict->s.renderfx |= RF_DEPTHHACK; + } else { + entity->edict->s.renderfx &= ~RF_DEPTHHACK; + } +} + +void Entity::SetHintRequireLookAt( Event *ev ) +{ + // FIXME: stub + STUB(); +#if 0 + qboolean lookat = ev->GetBoolean( 1 ); + hintstring_t * hint_string = NULL; + + for( int i = 0; i < hintstrings.NumObjects(); i++ ) + { + hintstring_t * index = hintstrings[ i ]; + + if( index->ent_num == entnum ) + { + if( lookat && index->string[ 0 ] == '\0' ) + { + hintstrings.RemoveObject( index ); + delete index; + } else { + index->needlookat = lookat; + } + return; + } + } + + if( lookat ) { + return; + } + + hint_string = new hintstring_t; + hint_string->ent_num = entnum; + hint_string->needlookat = lookat; + hint_string->changed = false; + + hintstrings.AddObject( hint_string ); +#endif +} + +void Entity::SetHintString( Event * ev ) +{ + // FIXME: stub + STUB(); +#if 0 + str string = ev->GetString( 1 ); + hintstring_t * hint_string = NULL; + qboolean isInvalid = !string; + + if( !sv_reborn->integer && !isInvalid ) { + string.replace( "&&1", "Your use key" ); + } + + for( int i = 0; i < hintstrings.NumObjects(); i++ ) + { + hintstring_t * index = hintstrings[ i ]; + + if( index->ent_num == entnum ) + { + if( isInvalid ) + { + index->string[ 0 ] = '\0'; + + ProcessHint( index, true ); + + if( !index->needlookat ) { + return; + } + + hintstrings.RemoveObject( index ); + delete index; + + return; + } + + if( index->string[ 0 ] != '\0' ) { + index->changed = true; + } + + strcpy( index->string, string ); + + return; + } + } + + if( isInvalid ) { + return; + } + + hint_string = new hintstring_t; + hint_string->ent_num = entnum; + hint_string->needlookat = true; + hint_string->changed = false; + + strcpy( hint_string->string, string ); + strcpy( hint_string->previous, string ); + + hintstrings.AddObject( hint_string ); +#endif +} + +void Entity::SetShader + ( + Event *ev + ) + +{ + str shadername = ev->GetString( 1 ); + qboolean fReset = false; + + if( !shadername.length() ) + { + shadername = "default"; + fReset = true; + } + + gi.SendServerCommand( -1, "setshader %d %s %d", entnum, shadername.c_str(), fReset ); +} diff --git a/code/game/entity.h b/code/game/entity.h new file mode 100644 index 00000000..433a9f2e --- /dev/null +++ b/code/game/entity.h @@ -0,0 +1,948 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// entity.h: Base class for all enities that are controlled by Sin. If you have any +// object that should be called on a periodic basis and it is not an entity, +// then you have to have an dummy entity that calls it. +// +// An entity in Sin is any object that is not part of the world-> Any non-world +// object that is visible in Sin is an entity, although it is not required that +// all entities be visible to the player. Some objects are basically just virtual +// constructs that act as an instigator of certain actions, for example, some +// triggers are invisible and cannot be touched, but when activated by other +// objects can cause things to happen. +// +// All entities are capable of receiving messages from Sin or from other entities. +// Messages received by an entity may be ignored, passed on to their superclass, +// or acted upon by the entity itself. The programmer must decide on the proper +// action for the entity to take to any message. There will be many messages +// that are completely irrelevant to an entity and should be ignored. Some messages +// may require certain states to exist and if they are received by an entity when +// it these states don't exist may indicate a logic error on the part of the +// programmer or map designer and should be reported as warnings (if the problem is +// not severe enough for the game to be halted) or as errors (if the problem should +// not be ignored at any cost). +// + +#ifndef __ENTITY_H__ +#define __ENTITY_H__ + +#include "g_local.h" +#include "class.h" +#include "vector.h" +#include "script.h" +#include "listener.h" +#include "simpleentity.h" + +// modification flags +#define FLAG_IGNORE 0 +#define FLAG_CLEAR 1 +#define FLAG_ADD 2 + +typedef enum + { + DAMAGE_NO, + DAMAGE_YES, // will take damage if hit + DAMAGE_AIM // auto targeting recognizes this + } damage_t; + +typedef enum +{ + legs, + torso, +} bodypart_t; + +//deadflag +#define DEAD_NO 0 +#define DEAD_DYING 1 +#define DEAD_DEAD 2 +#define DEAD_RESPAWNABLE 3 + +// Generic entity events +extern Event EV_SoundDone; +extern Event EV_Classname; +extern Event EV_Activate; +extern Event EV_ForceActivate; +extern Event EV_Use; +extern Event EV_FadeNoRemove; +extern Event EV_FadeOut; +extern Event EV_FadeIn; +extern Event EV_Fade; +extern Event EV_Killed; +extern Event EV_GotKill; +extern Event EV_Pain; +extern Event EV_Damage; +extern Event EV_Stun; +extern Event EV_Gib; +extern Event EV_Kill; +extern Event EV_DeathSinkStart; +extern Event EV_Entity_AddImmunity; +extern Event EV_Entity_RemoveImmunity; + +// Physics events +extern Event EV_MoveDone; +extern Event EV_Touch; +extern Event EV_Blocked; +extern Event EV_Attach; +extern Event EV_AttachModel; +extern Event EV_RemoveAttachedModel; +extern Event EV_Detach; +extern Event EV_DetachAllChildren; +extern Event EV_UseBoundingBox; +extern Event EV_IsTouching; + +// Animation events +extern Event EV_NewAnim; +extern Event EV_LastFrame; +extern Event EV_TakeDamage; +extern Event EV_NoDamage; + +// script stuff +extern Event EV_Model; +extern Event EV_Hide; +extern Event EV_Show; +extern Event EV_BecomeSolid; +extern Event EV_BecomeNonSolid; +extern Event EV_Sound; +extern Event EV_StopSound; +extern Event EV_Bind; +extern Event EV_Unbind; +extern Event EV_Glue; +extern Event EV_Unglue; +extern Event EV_JoinTeam; +extern Event EV_QuitTeam; +extern Event EV_SetHealth; +extern Event EV_SetSize; +extern Event EV_SetAlpha; +extern Event EV_SetTargetName; +extern Event EV_SetTarget; +extern Event EV_SetKillTarget; +extern Event EV_StartAnimating; +extern Event EV_SurfaceModelEvent; +extern Event EV_Stop; +extern Event EV_StopLoopSound; +extern Event EV_SetControllerAngles; +extern Event EV_CanSee; + +// dir is 1 +// power is 2 +// minsize is 3 +// maxsize is 4 +// percentage is 5 +// thickness 6 +// entity is 7 +// origin 8 + +// AI sound events +extern Event EV_BroadcastAIEvent; +extern Event EV_Hurt; +extern Event EV_Heal; + + +// Define ScriptMaster +class ScriptMaster; + +// +// Spawn args +// +// "spawnflags" +// "alpha" default 1.0 +// "model" +// "origin" +// "targetname" +// "target" +// + +#define MAX_MODEL_CHILDREN 8 +#define MAX_GLUE_CHILDREN 8 + +#define GL_USEANGLES 1 + +class Entity; + +typedef SafePtr EntityPtr; + +class Entity : public SimpleEntity +{ +public: + CLASS_PROTOTYPE( Entity ); + + // spawning variables + int entnum; + int radnum; + gentity_t *edict; + gclient_t *client; + int spawnflags; + + // standard variables + str model; + + // physics variables + Vector mins; + Vector maxs; + Vector absmin; + Vector absmax; + Vector velocity; + Vector accel; + Vector avelocity; + Vector aaccel; + Vector size; + int movetype; + int mass; + float gravity; + float orientation[ 3 ][ 3 ]; + gentity_t *groundentity; + cplane_t groundplane; + int groundcontents; + + // Model Binding variables + int numchildren; + int children[ MAX_MODEL_CHILDREN ]; + + // Light variables + float lightRadius; + + // Team variables + str moveteam; + class Entity *teamchain; + class Entity *teammaster; + + // Binding variables + class Entity *bindmaster; + qboolean bind_use_my_angles; + Vector localorigin; + Vector localangles; + + // targeting variables + str killtarget; + + // Character state + float health; + float max_health; + int deadflag; + int flags; + + // underwater variables + int watertype; + int waterlevel; + + // Pain and damage variables + damage_t takedamage; + EntityPtr enemy; + float pain_finished; + float damage_debounce_time; + int damage_type; + + // Glue variables + int m_iNumGlues; + EntityPtr m_pGlues[ MAX_GLUE_CHILDREN ]; + int m_pGluesFlags[ MAX_GLUE_CHILDREN ]; + class Entity *m_pGlueMaster; + bool m_bGlueAngles; + qboolean detach_at_death; + + // Path variables + float stealthMovementScale; // how much it will notify AIs + class pathway_ref *m_BlockedPaths; + int m_iNumBlockedPaths; + + // immune list + Container immunities; + + // miscellaneous + qboolean m_bBindChilds; + + Entity(); + virtual ~Entity(); + + void SetEntNum( int num ); + void ClassnameEvent( Event *ev ); + void SpawnFlagsEvent( Event *ev ); + + qboolean CheckEventFlags( Event *event ); + + qboolean DistanceTo( Vector pos ); + qboolean DistanceTo( Entity *ent ); + qboolean WithinDistance( Vector pos, float dist ); + qboolean WithinDistance( Entity *ent, float dist ); + + qboolean Targeted( void ); + void SetKillTarget( const char *killtarget ); + const char *KillTarget( void ); + + virtual void setLocalOrigin( Vector org ); + + virtual void setModel( const char *model ); + void setModel( str &mdl ); + qboolean setModel( void ); + void SetModelEvent( Event *ev ); + void GetBrushModelEvent( Event *ev ); + void GetModelEvent( Event *ev ); + void SetTeamEvent( Event *ev ); + virtual void TriggerEvent( Event *ev ); + void hideModel( void ); + void EventHideModel( Event *ev ); + virtual void showModel( void ); + void EventShowModel( Event *ev ); + qboolean hidden( void ); + void ProcessInitCommands( void ); + + void setAlpha( float alpha ); + float alpha( void ); + + void setMoveType( int type ); + int getMoveType( void ); + + void setSolidType( solid_t type ); + int getSolidType( void ); + + virtual void setContentsSolid( void ); + + virtual Vector getParentVector( Vector vec ); + Vector getLocalVector( Vector vec ); + + virtual void setSize( Vector min, Vector max ); + virtual void setOrigin( Vector org ); + virtual void setOriginEvent( Vector org ); + virtual void setOrigin( void ); + virtual void addOrigin( Vector org ); + virtual void updateOrigin( void ); + + void GetRawTag( int tagnum, orientation_t * orient ); + qboolean GetRawTag( const char * tagname, orientation_t * orient ); + + void GetTag( int tagnum, orientation_t * orient ); + qboolean GetTag( const char *name, orientation_t * orient ); + void GetTag( int tagnum, Vector *pos, Vector *forward = NULL, Vector *left = NULL, Vector *up = NULL ); + qboolean GetTag( const char *name, Vector *pos, Vector *forward = NULL, Vector *left = NULL, Vector *up = NULL ); + qboolean GetTagPositionAndOrientation( str tagname, orientation_t *new_or ); + void GetTagPositionAndOrientation( int tagnum, orientation_t *new_or ); + + void GetTagAngles( Event *ev ); + void GetTagPosition( Event *ev ); + + virtual int CurrentFrame( bodypart_t part = legs ); + virtual int CurrentAnim( bodypart_t part = legs ); + + virtual void setAngles( Vector ang ); + virtual void setAngles( void ); + void SetOrigin( Event *ev ); + + virtual void ShowInfo( float fDot, float fDist ); + + void GetControllerAngles( Event *ev ); + Vector GetControllerAngles( int num ); + void SetControllerAngles( int num, vec3_t angles ); + void SetControllerAngles( Event *ev ); + void SetControllerTag( int num, int tag_num ); + + void link( void ); + void unlink( void ); + + void setContents( int type ); + int getContents( void ); + void setScale( float scale ); + + qboolean droptofloor( float maxfall ); + qboolean isClient( void ); + + virtual void SetDeltaAngles( void ); + virtual void DamageEvent( Event *event ); + void Damage( Entity *inflictor, + Entity *attacker, + float damage, + Vector position, + Vector direction, + Vector normal, + int knockback, + int flags, + int meansofdeath, + int location = -1 ); + void Stun( float time ); + + void DamageType( Event *ev ); + virtual qboolean CanDamage( Entity *target, Entity *skip_ent = NULL ); + + virtual void AddImmunity( Event *ev ); + virtual void RemoveImmunity( Event *ev ); + qboolean Immune( int meansofdeath ); + + virtual void Delete( void ); + void Remove( Event *ev ); + void EventSoundDone( Event *ev ); + + void VolumeDamage( float damage ); + void EventVolumeDamage( Event *ev ); + void EventInPVS( Event *ev ); + + qboolean FovCheck( float *delta, float fovdot ); + virtual bool CanSee( Entity *ent, float fov, float vision_distance ); + void CanSee( Event *ev ); + + virtual qboolean IsDead(); + qboolean IsTouching( Entity *e1 ); + void IsTouching( Event *ev ); + + void GetVelocity( Event *ev ); + void GetAVelocity( Event *ev ); + void SetVelocity( Event *ev ); + + void FadeNoRemove( Event *ev ); + void FadeOut( Event *ev ); + void FadeIn( Event *ev ); + void Fade( Event *ev ); + + virtual void CheckGround( void ); + virtual qboolean HitSky( trace_t *trace ); + virtual qboolean HitSky( void ); + + void BecomeSolid( Event *ev ); + void BecomeNonSolid( Event *ev ); + void EventSetHealthOnly( Event *ev ); + void EventSetMaxHealth( Event *ev ); + void EventGetMaxHealth( Event *ev ); + void GetHealth( Event *ev ); + void SetHealth( Event *ev ); + void SetSize( Event *ev ); + void SetSize( void ); + void SetMins( Event *ev ); + void SetMaxs( Event *ev ); + void SetScale( Event *ev ); + void GetScale( Event *ev ); + void SetAlpha( Event *ev ); + void SetKillTarget( Event *ev ); + void SetAngles( Event *ev ); + void SetAngleEvent( Event *ev ); + void TouchTriggersEvent( Event *ev ); + + str GetRandomAlias( str name, AliasListNode_t **ret ); + void SetWaterType( void ); + + // model binding functions + qboolean attach( int parent_entity_num, int tag_num, qboolean use_angles = qtrue, Vector attach_offset = Vector( "0 0 0" ) ); + void detach( void ); + + qboolean GlobalAliasExists( const char *name ); + qboolean AliasExists( const char *name ); + + void ProcessSoundEvent( Event *ev, qboolean checkSubtitle ); + void Sound( Event *ev ); + virtual void Sound( str sound_name, int channel = CHAN_BODY, float volume = -1.0, + float min_dist = -1.0, Vector *origin = NULL, float pitch = -1.0f, int argstype = 0, + int doCallback = 0, int checkSubtitle = 1, float max_dist = -1.0f ); + void StopSound( int channel ); + void StopSound( Event *ev ); + void LoopSound( Event *ev ); + void LoopSound( str sound_name, float volume = -1.0, float min_dist = -1.0, float max_dist = -1.0, float pitch = -1.0 ); + void StopLoopSound( Event *ev ); + void StopLoopSound( void ); + + void SetLight( Event *ev ); + void LightOn( Event *ev ); + void LightOff( Event *ev ); + void LightRed( Event *ev ); + void LightGreen( Event *ev ); + void LightBlue( Event *ev ); + void LightRadius( Event *ev ); + void LightStyle( Event *ev ); + void Flags( Event *ev ); + void Effects( Event *ev ); + void RenderEffects( Event *ev ); + void SVFlags( Event *ev ); + + void BroadcastAIEvent( int iType = 8, float rad = SOUND_RADIUS ); + void BroadcastAIEvent( Event *ev ); + void Kill( Event *ev ); + void SurfaceModelEvent( Event *ev ); + void SurfaceCommand( const char * surf_name, const char * token ); + void SetShaderData( Event *ev ); + + void DoForceActivate( void ); + virtual void ClientThink( void ); + virtual void Postthink( void ); + virtual void Think( void ); + + void DamageSkin( trace_t * trace, float damage ); + + void AttachEvent( Event *ev ); + void AttachModelEvent( Event *ev ); + void RemoveAttachedModelEvent( Event *ev ); + void DetachEvent( Event *ev ); + void TakeDamageEvent( Event *ev ); + void NoDamageEvent( Event *ev ); + void Gravity( Event *ev ); + void GiveOxygen( float time ); + void UseBoundingBoxEvent( Event *ev ); + void HurtEvent( Event *ev ); + void HealEvent( Event *ev ); + void SetMassEvent( Event *ev ); + void Censor( Event *ev ); + void Ghost( Event *ev ); + + void StationaryEvent( Event *ev ); + void Explosion( Event *ev ); + + void Shader( Event *ev ); + + void KillAttach( Event *ev ); + void SetBloodModel( Event *ev ); + + void DropToFloorEvent( Event *ev ); + + // Binding methods + void joinTeam( Entity *teammember ); + void quitTeam( void ); + qboolean isBoundTo( Entity *master ); + virtual void bind( Entity *master, qboolean use_my_angles = false, qboolean bBindChilds = false ); + virtual void unbind( void ); + virtual void glue( Entity *master, qboolean use_my_angles = true ); + virtual void unglue( void ); + + void JoinTeam( Event *ev ); + void EventQuitTeam( Event *ev ); + void BindEvent( Event *ev ); + void EventUnbind( Event *ev ); + void GlueEvent( Event *ev ); + void EventUnglue( Event *ev ); + void AddToSoundManager( Event *ev ); + void NoLerpThisFrame( void ); + + virtual void addAngles( Vector add ); + + void DeathSinkStart( Event *ev ); + void DeathSink( Event *ev ); + + void DetachAllChildren( void ); + void DetachAllChildren( Event *ev ); + void SetMovementStealth( float fStealthScale ); + void EventMovementStealth( Event *ev ); + + void GetYaw( Event *ev ); + void PusherEvent( Event *ev ); + + void NeverDraw( Event *ev ); + void NormalDraw( Event *ev ); + void AlwaysDraw( Event *ev ); + + void GetMins( Event *ev ); + void GetMaxs( Event *ev ); + + void ForceActivate( Event *ev ); + void EventTrace( Event *ev ); + void EventSightTrace( Event *ev ); + + void ConnectPaths( void ); + void DisconnectPaths( void ); + + void EventDisconnectPaths( Event *ev ); + void EventConnectPaths( Event *ev ); + + void EventGetEntnum( Event *ev ); + void EventSetRadnum( Event *ev ); + void EventGetRadnum( Event *ev ); + void EventSetRotatedBbox( Event *ev ); + void EventGetRotatedBbox( Event *ev ); + + virtual void EndFrame( void ); + virtual void CalcBlend( void ); + + virtual void VelocityModified( void ); + + virtual void PreAnimate( void ); + virtual void PostAnimate( void ); + + virtual void Archive( Archiver &arc ); + virtual bool AutoArchiveModel( void ); + virtual void PathnodeClaimRevoked( class PathNode *node ); + virtual qboolean BlocksAIMovement( void ) const; + virtual qboolean AIDontFace( void ) const; + + void GetZone( Event *ev ); + void IsInZone( Event *ev ); + void SetDepthHack( Event *ev ); + void SetHintRequireLookAt( Event *ev ); + void SetHintString( Event *ev ); + void SetShader( Event * ev ); + + void DrawBoundingBox( int showbboxes ); +}; + +inline int Entity::getSolidType + ( + void + ) + + { + return edict->solid; + } + + +inline qboolean Entity::DistanceTo + ( + Vector pos + ) + + { + Vector delta; + + delta = origin - pos; + return delta.length(); + } + +inline qboolean Entity::DistanceTo + ( + Entity *ent + ) + + { + Vector delta; + + assert( ent ); + + if ( !ent ) + { + // "Infinite" distance + return 999999; + } + + delta = origin - ent->origin; + return delta.length(); + } + +inline qboolean Entity::WithinDistance + ( + Vector pos, + float dist + ) + + { + Vector delta; + + delta = origin - pos; + + // check squared distance + return ( ( delta * delta ) < ( dist * dist ) ); + } + +inline qboolean Entity::WithinDistance + ( + Entity *ent, + float dist + ) + + { + Vector delta; + + assert( ent ); + + if ( !ent ) + { + return false; + } + + delta = origin - ent->origin; + + // check squared distance + return ( ( delta * delta ) < ( dist * dist ) ); + } + +inline qboolean Entity::Targeted + ( + void + ) + + { + if ( !targetname.length() ) + { + return false; + } + return true; + } + +inline const char * Entity::KillTarget + ( + void + ) + + { + return killtarget.c_str(); + } + +inline qboolean Entity::hidden + ( + void + ) + +{ + if( edict->s.renderfx & RF_DONTDRAW ) + { + return true; + } + return false; +} + +inline void Entity::setModel + ( + str &mdl + ) + + { + setModel( mdl.c_str() ); + } + +inline void Entity::SetModelEvent + ( + Event *ev + ) + + { + setModel( ev->GetString( 1 ) ); + } + +inline void Entity::GetBrushModelEvent + ( + Event *ev + ) + +{ + ev->AddString( model ); +} + +inline void Entity::GetModelEvent + ( + Event *ev + ) + +{ + if( !edict->tiki ) + { + ev->AddNil(); + return; + } + + const char *name = gi.TIKI_NameForNum( edict->tiki ); + + if( !name ) + { + if( model != "" ) + { + ev->AddString( model ); + } + else + { + ev->AddNil(); + return; + } + } + else + { + ev->AddString( name ); + } +} + +inline void Entity::hideModel + ( + void + ) + +{ + edict->s.renderfx |= RF_DONTDRAW; + if( getSolidType() <= SOLID_TRIGGER ) + { + edict->r.svFlags |= SVF_NOCLIENT; + } +} + +inline void Entity::showModel + ( + void + ) + +{ + edict->s.renderfx &= ~RF_DONTDRAW; + edict->r.svFlags &= ~SVF_NOCLIENT; +} + +inline float Entity::alpha + ( + void + ) + + { + return edict->s.alpha; + } + +inline void Entity::setMoveType + ( + int type + ) + + { + movetype = type; + } + +inline int Entity::getMoveType + ( + void + ) + + { + return movetype; + } + +inline void Entity::unlink + ( + void + ) + + { + gi.UnlinkEntity( edict ); + } + +inline void Entity::setContents + ( + int type + ) + + { + edict->r.contents = type; + } + +inline int Entity::getContents + ( + void + ) + +{ + return edict->r.contents; +} + +inline qboolean Entity::isClient + ( + void + ) + +{ + if( client ) + { + return true; + } + return false; +} + +inline void Entity::SetDeltaAngles + ( + void + ) + + { + int i; + + if ( client ) + { + for( i = 0; i < 3; i++ ) + { + client->ps.delta_angles[ i ] = ANGLE2SHORT( client->ps.viewangles[ i ] ); + } + } + } + +inline qboolean Entity::GlobalAliasExists + ( + const char *name + ) + + { + AliasListNode_t *ret; + + assert( name ); + + return ( gi.GlobalAlias_FindRandom( name, &ret ) != NULL ); + } + +inline qboolean Entity::AliasExists + ( + const char *name + ) + + { + AliasListNode_t *ret; + + assert( name ); + + return ( gi.Alias_FindRandom( edict->tiki, name, &ret ) != NULL ); + } + +inline str Entity::GetRandomAlias( str name, AliasListNode_t **ret ) +{ + str realname; + const char *s; + + if( edict->tiki ) + { + s = gi.Alias_FindRandom( edict->tiki, name.c_str(), ret ); + } + else + { + s = NULL; + } + + if( s ) + { + realname = s; + } + else + { + s = gi.GlobalAlias_FindRandom( name.c_str(), ret ); + if( s ) + { + realname = s; + } + } + + return realname; +} + +inline int Entity::CurrentFrame + ( + bodypart_t part + ) + + { + part = part; + return 0; + } + +inline int Entity::CurrentAnim + ( + bodypart_t part + ) + + { + part = part; + return 0; + } + +#include + +#endif + diff --git a/code/game/events.h b/code/game/events.h new file mode 100644 index 00000000..ef961031 --- /dev/null +++ b/code/game/events.h @@ -0,0 +1,70 @@ +//----------------------------------------------------------------------------- +// +// $Logfile:: /fakk2_code/fakk2_new/fgame/events.h $ +// $Revision:: 1 $ +// $Author:: Jimdose $ +// $Date:: 9/10/99 10:53a $ +// +// Copyright (C) 1997 by Ritual Entertainment, Inc. +// All rights reserved. +// +// This source is may not be distributed and/or modified without +// expressly written permission by Ritual Entertainment, Inc. +// +// $Log:: /fakk2_code/fakk2_new/fgame/events.h $ +// +// 1 9/10/99 10:53a Jimdose +// +// 1 9/08/99 3:15p Aldie +// +// DESCRIPTION: +// Event definitions for communication between Sin and DLL's +// + +#ifndef __EVENTS_H__ +#define __EVENTS_H__ + +#if 1 +typedef int event_t; + +enum + { + EVENT_DEFAULT_MINEVENT = 1, + + // Player events + EVENT_CLIENTCONNECT = EVENT_DEFAULT_MINEVENT, + EVENT_CLIENTDISCONNECT, + EVENT_CLIENTKILL, + EVENT_CLIENTMOVE, + EVENT_CLIENTENDFRAME, + EVENT_SETNEWPARMS, + EVENT_SETCHANGEPARMS, + EVENT_PRETHINK, + EVENT_POSTTHINK, + + // Generic entity events + EVENT_SPAWN, + EVENT_REMOVE, + EVENT_PRECACHE, + EVENT_THINK, + EVENT_ACTIVATE, + EVENT_USE, + EVENT_FOOTSTEP, + + // Physics events + EVENT_MOVEDONE, + EVENT_TOUCH, + EVENT_BLOCKED, + + // Animation events + EVENT_ANIM_FRAME, + EVENT_ANIM_NEWANIM, + EVENT_ANIM_LASTFRAME, + + // For subclass events + EVENT_DEFAULT_MAXEVENT + }; + +#endif + +#endif /* events.h */ diff --git a/code/game/explosion.cpp b/code/game/explosion.cpp new file mode 100644 index 00000000..df95d571 --- /dev/null +++ b/code/game/explosion.cpp @@ -0,0 +1,684 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// explosion.cpp: Standard explosion object that is spawned by other entites and not map designers. +// Explosion is used by many of the weapons for the blast effect, but is also used +// by the Exploder and MultiExploder triggers. These triggers create one or more +// explosions each time they are activated. +// + +#include "g_local.h" +#include "actor.h" +#include "entity.h" +#include "trigger.h" +#include "explosion.h" +#include "weaputils.h" + +#define MULTI_USE (1<<0) +#define RANDOM_TIME (1<<1) +#define VISIBLE (1<<2) +#define RANDOM_SCALE (1<<3) +#define NO_EXPLOSIONS (1<<4) + +Event EV_Exploder_SetDmg + ( + "dmg", + EV_DEFAULT, + "i", + "damage", + "Sets the damage the explosion does.", + EV_NORMAL + ); +Event EV_Exploder_SetDuration + ( + "duration", + EV_DEFAULT, + "f", + "duration", + "Sets the duration of the explosion.", + EV_NORMAL + ); +Event EV_Exploder_SetWait + ( + "wait", + EV_DEFAULT, + "f", + "explodewait", + "Sets the wait time of the explosion.", + EV_NORMAL + ); +Event EV_Exploder_SetRandom + ( + "random", + EV_DEFAULT, + "f", + "randomness", + "Sets the randomness value of the explosion.", + EV_NORMAL + ); + +void CreateExplosion + ( + Vector pos, + float damage, + Entity *inflictor, + Entity *attacker, + Entity *ignore, + const char *explosionModel, + float scale + ) + +{ + Explosion *explosion; + Event *ev; + + assert( inflictor ); + + if( !inflictor ) + { + return; + } + + if( !attacker ) + { + attacker = world; + } + + if( !explosionModel ) + { + explosionModel = "fx_explosion.tik"; + } + + explosion = new Explosion; + + // Create a new explosion entity and set it off + explosion->setModel( explosionModel ); + + explosion->setSolidType( SOLID_NOT ); + explosion->ProcessInitCommands(); + + explosion->owner = attacker->entnum; + explosion->edict->r.ownerNum = attacker->entnum; + explosion->setMoveType( MOVETYPE_FLYMISSILE ); + explosion->edict->clipmask = MASK_PROJECTILE; + explosion->setSize( explosion->mins, explosion->maxs ); + explosion->setOrigin( pos ); + explosion->origin.copyTo( explosion->edict->s.origin2 ); + + if( explosion->dlight_radius ) + { + G_SetConstantLight( &explosion->edict->s.constantLight, + &explosion->dlight_color[ 0 ], + &explosion->dlight_color[ 1 ], + &explosion->dlight_color[ 2 ], + &explosion->dlight_radius + ); + } + + explosion->BroadcastAIEvent( AI_EVENT_EXPLOSION ); + + explosion->NewAnim( "idle" ); + RadiusDamage( inflictor->origin, inflictor, attacker, damage, ignore, MOD_EXPLOSION ); + + if( explosion->life ) + { + ev = new Event( EV_Remove ); + explosion->PostEvent( ev, explosion->life ); + } +} + + +/*****************************************************************************/ +/*QUAKED func_exploder (0 0.25 0.5) (0 0 0) (8 8 8) + + Spawns an explosion when triggered. Triggers any targets. + + "dmg" specifies how much damage to cause. Default indicates 120. + "key" The item needed to activate this. (default nothing) + "thread" name of thread to trigger. This can be in a different script file as well\ +by using the '::' notation. +******************************************************************************/ + +CLASS_DECLARATION( Trigger, Exploder, "func_exploder" ) + { + { &EV_Touch, NULL }, + { &EV_Trigger_Effect, &Exploder::MakeExplosion }, + { &EV_Exploder_SetDmg, &Exploder::SetDmg }, + { NULL, NULL } + }; + +void Exploder::MakeExplosion + ( + Event *ev + ) + + { + CreateExplosion + ( + origin, + damage, + this, + ev->GetEntity( 1 ), + this + ); + } + +Exploder::Exploder() + { + damage = 120; + respondto = TRIGGER_PLAYERS | TRIGGER_MONSTERS | TRIGGER_PROJECTILES; + } + +void Exploder::SetDmg + ( + Event *ev + ) + + { + damage = ev->GetInteger( 1 ); + if ( damage < 0 ) + { + damage = 0; + } + } + +/*****************************************************************************/ +/*QUAKED func_multi_exploder (0 0.25 0.5) ? MULTI_USE RANDOM_TIME VISIBLE RANDOM_SCALE + + Spawns an explosion when triggered. Triggers any targets. + size of brush determines where explosions will occur. + + "dmg" specifies how much damage to cause from each explosion. (Default 120) + "delay" delay before exploding (Default 0 seconds) + "duration" how long to explode for (Default 1 second) + "wait" time between each explosion (default 0.25 seconds) + "random" random factor (default 0.25) + "key" The item needed to activate this. (default nothing) + "thread" name of thread to trigger. This can be in a different script file as well\ +by using the '::' notation. + "health" makes the object damageable + "scale" set the maximum size for spawned debris and explosions. + + MULTI_USE allows the func_multi_exploder to be used more than once + RANDOM_TIME adjusts the wait between each explosion by the random factor + VISIBLE allows you to make the trigger visible + RANDOM_SCALE scale explosions randomly. size will be between 0.25 and 1 times scale + +******************************************************************************/ + +CLASS_DECLARATION( Trigger, MultiExploder, "func_multi_exploder" ) + { + { &EV_Touch, NULL }, + { &EV_Trigger_Effect, &MultiExploder::MakeExplosion }, + { &EV_Exploder_SetDmg, &MultiExploder::SetDmg }, + { &EV_Exploder_SetDuration, &MultiExploder::SetDuration }, + { &EV_Exploder_SetWait, &MultiExploder::SetWait }, + { &EV_Exploder_SetRandom, &MultiExploder::SetRandom }, + { NULL, NULL } + }; + +void MultiExploder::MakeExplosion + ( + Event *ev + ) + + { + Vector pos; + float t, scale; + Entity *other; + Event *event; + + other = ev->GetEntity( 1 ); + + // make sure other is valid + if ( !other ) + { + other = world; + } + + // prevent the trigger from triggering again + trigger_time = -1; + + if ( !explode_time ) + { + hideModel(); + explode_time = level.time + duration; + } + + if ( spawnflags & RANDOM_TIME ) + { + t = explodewait * ( 1 + G_CRandom( randomness ) ); + } + else + { + t = explodewait; + } + + event = new Event( EV_Trigger_Effect ); + event->AddEntity( other ); + PostEvent( event, t ); + + if ( level.time > explode_time ) + { + if ( spawnflags & MULTI_USE ) + { + // + // reset the trigger in a half second + // + trigger_time = level.time + 0.5f; + explode_time = 0; + CancelEventsOfType( EV_Trigger_Effect ); + // + // reset health if necessary + // + health = max_health; + return; + } + else + { + PostEvent( EV_Remove, 0 ); + return; + } + } + + pos[ 0 ] = absmin[ 0 ] + G_Random( absmax[ 0 ] - absmin[ 0 ] ); + pos[ 1 ] = absmin[ 1 ] + G_Random( absmax[ 1 ] - absmin[ 1 ] ); + pos[ 2 ] = absmin[ 2 ] + G_Random( absmax[ 2 ] - absmin[ 2 ] ); + + if ( spawnflags & RANDOM_SCALE ) + { + scale = edict->s.scale * 0.25f; + scale += G_Random( 3 * scale ); + } + else + { + scale = 1.0f; + } + + CreateExplosion + ( + pos, + damage, + this, + other, + this, + NULL, + scale + ); + } + +MultiExploder::MultiExploder() + { + if ( LoadingSavegame ) + { + return; + } + + damage = 120; + duration = 1.0; + explodewait = 0.25; + randomness = 0.25; + explode_time = 0; + + if ( spawnflags & VISIBLE ) + { + PostEvent( EV_Show, EV_POSTSPAWN ); + } + else + { + PostEvent( EV_Hide, EV_POSTSPAWN ); + } + + // So that we don't get deleted after we're triggered + count = -1; + + respondto = TRIGGER_PLAYERS | TRIGGER_MONSTERS | TRIGGER_PROJECTILES; + } + +void MultiExploder::SetDmg + ( + Event *ev + ) + + { + damage = ev->GetInteger( 1 ); + if ( damage < 0 ) + { + damage = 0; + } + } + +void MultiExploder::SetDuration + ( + Event *ev + ) + + { + duration = ev->GetFloat( 1 ); + } + +void MultiExploder::SetWait + ( + Event *ev + ) + + { + explodewait = ev->GetFloat( 1 ); + } + +void MultiExploder::SetRandom + ( + Event *ev + ) + + { + randomness = ev->GetFloat( 1 ); + } + + +#define METAL_DEBRIS (1<<5) +#define ROCK_DEBRIS (1<<6) +#define NOTSOLID (1<<7) + +/*****************************************************************************/ +/*QUAKED func_explodeobject (0 0.25 0.5) ? MULTI_USE RANDOM_TIME VISIBLE RANDOM_SCALE NO_EXPLOSIONS METAL_DEBRIS ROCK_DEBRIS NOTSOLID + + Spawns different kinds of debris when triggered. Triggers any targets. + size of brush determines where explosions and debris will be spawned. + + "dmg" specifies how much damage to cause from each explosion. (Default 120) + "delay" delay before exploding (Default 0 seconds) + "duration" how long to explode for (Default 1 second) + "wait" time between each explosion (default 0.25 seconds) + "random" random factor (default 0.25) + "health" if specified, object must be damaged to trigger + "key" The item needed to activate this. (default nothing) + "severity" how violent the debris should be ejected from the object( default 1.0 ) + "debrismodel" What kind of debris to spawn (default nothing) + "amount" how much debris to spawn for each explosion (default 4) + "thread" name of thread to trigger. This can be in a different script file as well\ +by using the '::' notation. + "health" makes the object damageable + "scale" set the maximum size for spawned debris and explosions + + MULTI_USE allows the func_explodeobject to be used more than once + RANDOM_TIME adjusts the wait between each explosion by the random factor + VISIBLE allows you to make the trigger visible + RANDOM_SCALE scale explosions and debris randomly. size will be between 0.25 and 1 times scale + NO_EXPLOSIONS, if checked no explosions will be created + METAL_DEBRIS automatically spawn metal debris, no need for debrismodel to be set + ROCK_DEBRIS automatically spawn rock debris, no need for debrismodel to be set + NOTSOLID debris is not solid + + other valid tiki files include: + + obj_debris_glass1-4.tik + obj_debris_wood1-4.tik + +******************************************************************************/ + +Event EV_ExplodeObject_SetSeverity + ( + "severity", + EV_DEFAULT, + "f", + "newSeverity", + "How violently the debris should be ejected.", + EV_NORMAL + ); + +Event EV_ExplodeObject_SetDebrisModel + ( + "debrismodel", + EV_DEFAULT, + "s", + "debrisModel", + "What kind of debris to spawn when triggered.", + EV_NORMAL + ); + +Event EV_ExplodeObject_SetDebrisAmount + ( + "amount", + EV_DEFAULT, + "i", + "amountOfDebris", + "How much debris to spawn each time.", + EV_NORMAL + ); + + +CLASS_DECLARATION( MultiExploder, ExplodeObject, "func_explodeobject" ) + { + { &EV_Touch, NULL }, + { &EV_Trigger_Effect, &ExplodeObject::MakeExplosion }, + { &EV_ExplodeObject_SetSeverity, &ExplodeObject::SetSeverity }, + { &EV_ExplodeObject_SetDebrisModel, &ExplodeObject::SetDebrisModel }, + { &EV_ExplodeObject_SetDebrisAmount, &ExplodeObject::SetDebrisAmount }, + { NULL, NULL } + }; + +void ExplodeObject::SetDebrisModel + ( + Event *ev + ) + + { + char string[ 1024 ]; + const char *ptr; + + // there could be multiple space delimited models, so we need to search for the spaces. + strcpy( string, ev->GetString( 1 ) ); + ptr = strtok( string, " " ); + while ( ptr ) + { + debrismodels.AddUniqueObject( str( ptr ) ); + CacheResource( ptr ); + ptr = strtok( NULL, " " ); + } + } + +void ExplodeObject::SetSeverity + ( + Event *ev + ) + + { + severity = ev->GetFloat( 1 ); + } + +void ExplodeObject::SetDebrisAmount + ( + Event *ev + ) + + { + debrisamount = ev->GetInteger( 1 ); + } + +void ExplodeObject::MakeExplosion + ( + Event *ev + ) + + { + Vector pos; + float t, scale; + Entity *other; + Event *event; + + other = ev->GetEntity( 1 ); + + // make sure other is valid + if ( !other ) + { + other = world; + } + + // prevent the trigger from triggering again + trigger_time = -1; + + if ( !explode_time ) + { + setSolidType( SOLID_NOT ); + hideModel(); + explode_time = level.time + duration; + } + + if ( spawnflags & RANDOM_TIME ) + { + t = explodewait * ( 1 + G_CRandom( randomness ) ); + } + else + { + t = explodewait; + } + + event = new Event( EV_Trigger_Effect ); + event->AddEntity( other ); + PostEvent( event, t ); + + if ( level.time > explode_time ) + { + if ( spawnflags & MULTI_USE ) + { + // + // reset the trigger in a half second + // + trigger_time = level.time + 0.5f; + explode_time = 0; + CancelEventsOfType( EV_Trigger_Effect ); + // + // reset health if necessary + // + health = max_health; + if ( health ) + { + setSolidType( SOLID_BBOX ); + } + if ( spawnflags & VISIBLE ) + { + PostEvent( EV_Show, 0.5f ); + } + return; + } + else + { + PostEvent( EV_Remove, 0 ); + return; + } + } + + pos[ 0 ] = absmin[ 0 ] + G_Random( absmax[ 0 ] - absmin[ 0 ] ); + pos[ 1 ] = absmin[ 1 ] + G_Random( absmax[ 1 ] - absmin[ 1 ] ); + pos[ 2 ] = absmin[ 2 ] + G_Random( absmax[ 2 ] - absmin[ 2 ] ); + + if ( spawnflags & RANDOM_SCALE ) + { + scale = edict->s.scale * 0.25f; + scale += G_Random( 3 * scale ); + } + else + { + scale = 1.0f; + } + + if ( !( spawnflags & NO_EXPLOSIONS ) ) + { + CreateExplosion + ( + pos, + damage, + this, + other, + this, + NULL, + scale + ); + } + if ( debrismodels.NumObjects() ) + { + TossObject *to; + int i; + for ( i = 0; i < debrisamount; i++ ) + { + int num; + + if ( spawnflags & RANDOM_SCALE ) + { + scale = edict->s.scale * 0.25f; + scale += G_Random( 3 * scale ); + } + else + { + scale = 1.0f; + } + + num = G_Random( debrismodels.NumObjects() ) + 1; + to = new TossObject( debrismodels.ObjectAt( num ) ); + to->setScale( scale ); + to->setOrigin( pos ); + to->SetVelocity( severity ); + if ( spawnflags & NOTSOLID ) + { + to->setSolidType( SOLID_NOT ); + } + pos[ 0 ] = absmin[ 0 ] + G_Random( absmax[ 0 ] - absmin[ 0 ] ); + pos[ 1 ] = absmin[ 1 ] + G_Random( absmax[ 1 ] - absmin[ 1 ] ); + pos[ 2 ] = absmin[ 2 ] + G_Random( absmax[ 2 ] - absmin[ 2 ] ); + } + } + + } + +ExplodeObject::ExplodeObject() + { + if ( !LoadingSavegame ) + { + duration = 1; + explodewait = 0.25f; + severity = 1.0f; + debrismodels.ClearObjectList(); + debrisamount = 2; + if ( spawnflags & METAL_DEBRIS ) + { + debrismodels.AddUniqueObject( str( "obj_debris_metal1.tik" ) ); + debrismodels.AddUniqueObject( str( "obj_debris_metal2.tik" ) ); + debrismodels.AddUniqueObject( str( "obj_debris_metal3.tik" ) ); + CacheResource( "obj_debris_metal1.tik" ); + CacheResource( "obj_debris_metal2.tik" ); + CacheResource( "obj_debris_metal3.tik" ); + } + else if ( spawnflags & ROCK_DEBRIS ) + { + debrismodels.AddUniqueObject( str( "obj_debris_rock1.tik" ) ); + debrismodels.AddUniqueObject( str( "obj_debris_rock2.tik" ) ); + debrismodels.AddUniqueObject( str( "obj_debris_rock3.tik" ) ); + debrismodels.AddUniqueObject( str( "obj_debris_rock4.tik" ) ); + CacheResource( "obj_debris_rock1.tik" ); + CacheResource( "obj_debris_rock2.tik" ); + CacheResource( "obj_debris_rock3.tik" ); + CacheResource( "obj_debris_rock4.tik" ); + } + } + } + diff --git a/code/game/explosion.h b/code/game/explosion.h new file mode 100644 index 00000000..e5213b82 --- /dev/null +++ b/code/game/explosion.h @@ -0,0 +1,140 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// explosion.h: Standard explosion object that is spawned by other entites and not map designers. +// Explosion is used by many of the weapons for the blast effect, but is also used +// by the Exploder and MultiExploder triggers. These triggers create one or more +// explosions each time they are activated. +// + +#ifndef __EXPLOSION_H__ +#define __EXPLOSION_H__ + +#include "g_local.h" +#include "entity.h" +#include "trigger.h" + +class Exploder : public Trigger + { + private: + int damage; + + void MakeExplosion( Event *ev ); + void SetDmg( Event *ev ); + + public: + CLASS_PROTOTYPE( Exploder ); + + Exploder(); + virtual void Archive( Archiver &arc ); + }; + +inline void Exploder::Archive + ( + Archiver &arc + ) + + { + Trigger::Archive( arc ); + + arc.ArchiveInteger( &damage ); + } + +class MultiExploder : public Trigger + { + protected: + float explodewait; + float explode_time; + float duration; + int damage; + float randomness; + + void MakeExplosion( Event *ev ); + void SetDmg( Event *ev ); + void SetDuration( Event *ev ); + void SetWait( Event *ev ); + void SetRandom( Event *ev ); + + public: + CLASS_PROTOTYPE( MultiExploder ); + + MultiExploder(); + virtual void Archive( Archiver &arc ); + }; + +inline void MultiExploder::Archive + ( + Archiver &arc + ) + { + Trigger::Archive( arc ); + + arc.ArchiveFloat( &explodewait ); + arc.ArchiveFloat( &explode_time ); + arc.ArchiveFloat( &duration ); + arc.ArchiveInteger( &damage ); + arc.ArchiveFloat( &randomness ); + } + +void CreateExplosion + ( + Vector pos, + float damage = 120, + Entity *inflictor = NULL, + Entity *attacker = NULL, + Entity *ignore = NULL, + const char *explosionModel = NULL, + float scale = 1.0f + ); + +class ExplodeObject : public MultiExploder + { + private: + Container debrismodels; + int debrisamount; + float severity; + + void SetDebrisModel( Event *ev ); + void SetSeverity( Event *ev ); + void SetDebrisAmount( Event *ev ); + void MakeExplosion( Event *ev ); + + public: + CLASS_PROTOTYPE( ExplodeObject ); + + ExplodeObject(); + virtual void Archive( Archiver &arc ); + }; + +inline void ExplodeObject::Archive + ( + Archiver &arc + ) + { + MultiExploder::Archive( arc ); + + arc.ArchiveFloat( &severity ); + arc.ArchiveInteger( &debrisamount ); + debrismodels.Archive( arc ); + } + +#endif /* explosion.h */ diff --git a/code/game/g_active.cpp b/code/game/g_active.cpp new file mode 100644 index 00000000..f9f53d54 --- /dev/null +++ b/code/game/g_active.cpp @@ -0,0 +1,955 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +#include "g_local.h" +#include "entity.h" + +// FIXME: OLD Q3 CODE +#if 0 + +/* +=============== +G_DamageFeedback + +Called just before a snapshot is sent to the given player. +Totals up all damage and generates both the player_state_t +damage values to that client for pain blends and kicks, and +global pain sound events for all clients. +=============== +*/ +void P_DamageFeedback( gentity_t *player ) { + gclient_t *client; + float count; + vec3_t angles; + + client = player->client; + if ( client->ps.pm_type == PM_DEAD ) { + return; + } + + // total points of damage shot at the player this frame + count = client->damage_blood + client->damage_armor; + if ( count == 0 ) { + return; // didn't take any damage + } + + if ( count > 255 ) { + count = 255; + } + + // send the information to the client + + //// world damage (falling, slime, etc) uses a special code + //// to make the blend blob centered instead of positional + //if ( client->damage_fromWorld ) { + // client->ps.damagePitch = 255; + // client->ps.damageYaw = 255; + + // client->damage_fromWorld = qfalse; + //} else { + // vectoangles( client->damage_from, angles ); + // client->ps.damagePitch = angles[PITCH]/360.0 * 256; + // client->ps.damageYaw = angles[YAW]/360.0 * 256; + //} + + // play an apropriate pain sound + if ( (level.time > player->pain_debounce_time) && !(player->flags & FL_GODMODE) ) { + player->pain_debounce_time = level.time + 700; + //G_AddEvent( player, EV_PAIN, player->health ); + //client->ps.damageEvent++; + } + + +// client->ps.damageCount = count; + + // + // clear totals + // + client->damage_blood = 0; + client->damage_armor = 0; + client->damage_knockback = 0; +} + + + +/* +============= +P_WorldEffects + +Check for lava / slime contents and drowning +============= +*/ +void P_WorldEffects( gentity_t *ent ) { + qboolean envirosuit; + int waterlevel; + + if ( ent->client->noclip ) { + ent->client->airOutTime = level.time + 12000; // don't need air + return; + } + + waterlevel = ent->waterlevel; + +// envirosuit = ent->client->ps.powerups[PW_BATTLESUIT] > level.time; + + // + // check for drowning + // + if ( waterlevel == 3 ) { + // envirosuit give air + //if ( envirosuit ) { + // ent->client->airOutTime = level.time + 10000; + //} + + // if out of air, start drowning + if ( ent->client->airOutTime < level.time) { + // drown! + ent->client->airOutTime += 1000; + if ( ent->health > 0 ) { + // take more damage the longer underwater + ent->damage += 2; + if (ent->damage > 15) + ent->damage = 15; + + // play a gurp sound instead of a normal pain sound + if (ent->health <= ent->damage) { + G_Sound(ent, CHAN_VOICE, G_SoundIndex("*drown.wav")); + } else if (rand()&1) { + G_Sound(ent, CHAN_VOICE, G_SoundIndex("sound/player/gurp1.wav")); + } else { + G_Sound(ent, CHAN_VOICE, G_SoundIndex("sound/player/gurp2.wav")); + } + + // don't play a normal pain sound + ent->pain_debounce_time = level.time + 200; + + G_Damage (ent, NULL, NULL, NULL, NULL, + ent->damage, DAMAGE_NO_ARMOR, MOD_WATER); + } + } + } else { + ent->client->airOutTime = level.time + 12000; + ent->damage = 2; + } + + // + // check for sizzle damage (move to pmove?) + // + if (waterlevel && + (ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) { + if (ent->health > 0 + && ent->pain_debounce_time <= level.time ) { + + if ( envirosuit ) { +// G_AddEvent( ent, EV_POWERUP_BATTLESUIT, 0 ); + } else { + if (ent->watertype & CONTENTS_LAVA) { + G_Damage (ent, NULL, NULL, NULL, NULL, + 30*waterlevel, 0, MOD_LAVA); + } + + if (ent->watertype & CONTENTS_SLIME) { + G_Damage (ent, NULL, NULL, NULL, NULL, + 10*waterlevel, 0, MOD_SLIME); + } + } + } + } +} + +/* +============== +ClientThink + +This will be called once for each client frame, which will +usually be a couple times for each server frame on fast clients. + +If "g_synchronousClients 1" is set, this will be called exactly +once for each server frame, which makes for smooth demo recording. +============== +*/ +void ClientThink_real( gentity_t *ent ) { + gclient_t *client; + pmove_t pm; + int msec; + usercmd_t *ucmd; + + try + { + if( ent->entity ) + { + current_ucmd = &ent->client->pers.cmd; + ent->entity->ProcessEvent( EV_ClientMove ); + current_ucmd = NULL; + } + } + + catch( const char *error ) + { + G_ExitWithError( error ); + } + + return; + + client = ent->client; + + // don't think if the client is not yet connected (and thus not yet spawned in) + if (client->pers.connected != CON_CONNECTED) { + return; + } + // mark the time, so the connection sprite can be removed + ucmd = &ent->client->pers.cmd; + + // sanity check the command time to prevent speedup cheating + if ( ucmd->serverTime > level.time + 200 ) { + ucmd->serverTime = level.time + 200; +// G_Printf("serverTime <<<<<\n" ); + } + if ( ucmd->serverTime < level.time - 1000 ) { + ucmd->serverTime = level.time - 1000; +// G_Printf("serverTime >>>>>\n" ); + } + + msec = ucmd->serverTime - client->ps.commandTime; + // following others may result in bad times, but we still want + // to check for follow toggles + if ( msec < 1 && client->sess.spectatorState != SPECTATOR_FOLLOW ) { + return; + } + if ( msec > 200 ) { + msec = 200; + } + + if ( pmove_msec.integer < 8 ) { + gi.Cvar_Set("pmove_msec", "8"); + } + else if (pmove_msec.integer > 33) { + gi.Cvar_Set("pmove_msec", "33"); + } + + if ( pmove_fixed.integer || client->pers.pmoveFixed ) { + ucmd->serverTime = ((ucmd->serverTime + pmove_msec.integer-1) / pmove_msec.integer) * pmove_msec.integer; + //if (ucmd->serverTime - client->ps.commandTime <= 0) + // return; + } + + // + // check for exiting intermission + // + if ( level.intermissiontime ) { + ClientIntermissionThink( client ); + return; + } + + // spectators don't do much + /*if ( client->sess.sessionTeam == TEAM_SPECTATOR ) { + if ( client->sess.spectatorState == SPECTATOR_SCOREBOARD ) { + return; + } + SpectatorThink( ent, ucmd ); + return; + }*/ + + // check for inactivity timer, but never drop the local client of a non-dedicated server + if ( !ClientInactivityTimer( client ) ) { + return; + } + + if ( client->noclip ) { + client->ps.pm_type = PM_NOCLIP; + } else if ( client->ps.stats[STAT_HEALTH] <= 0 ) { + client->ps.pm_type = PM_DEAD; + } else { + client->ps.pm_type = PM_NORMAL; + } + + client->ps.gravity = sv_gravity->value; + + // set speed + client->ps.speed = sv_runspeed->value; + +#ifdef MISSIONPACK + if( bg_itemlist[client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) { + client->ps.speed *= 1.5; + } + else +#endif + + memset (&pm, 0, sizeof(pm)); + + if ( ent->flags & FL_FORCE_GESTURE ) { + ent->flags &= ~FL_FORCE_GESTURE; + ent->client->pers.cmd.buttons |= BUTTON_GESTURE; + } + +#ifdef MISSIONPACK + // check for invulnerability expansion before doing the Pmove + if (client->ps.powerups[PW_INVULNERABILITY] ) { + if ( !(client->ps.pm_flags & PMF_INVULEXPAND) ) { + vec3_t mins = { -42, -42, -42 }; + vec3_t maxs = { 42, 42, 42 }; + vec3_t oldmins, oldmaxs; + + VectorCopy (ent->r.mins, oldmins); + VectorCopy (ent->r.maxs, oldmaxs); + // expand + VectorCopy (mins, ent->r.mins); + VectorCopy (maxs, ent->r.maxs); + gi.LinkEntity(ent); + // check if this would get anyone stuck in this player + if ( !StuckInOtherClient(ent) ) { + // set flag so the expanded size will be set in PM_CheckDuck + client->ps.pm_flags |= PMF_INVULEXPAND; + } + // set back + VectorCopy (oldmins, ent->r.mins); + VectorCopy (oldmaxs, ent->r.maxs); + gi.LinkEntity(ent); + } + } +#endif + + pm.ps = &client->ps; + pm.cmd = *ucmd; + if ( pm.ps->pm_type == PM_DEAD ) { + pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; + } + else if ( ent->r.svFlags & SVF_BOT ) { + pm.tracemask = MASK_PLAYERSOLID | CONTENTS_BOTCLIP; + } + else { + pm.tracemask = MASK_PLAYERSOLID; + } + pm.trace = gi.Trace; + pm.pointcontents = gi.PointContents; + pm.debugLevel = g_debugMove.integer; + pm.noFootsteps = ( dmflags->integer & DF_NO_FOOTSTEPS ) > 0; + + pm.pmove_fixed = pmove_fixed.integer | client->pers.pmoveFixed; + pm.pmove_msec = pmove_msec.integer; + + VectorCopy( client->ps.origin, client->oldOrigin ); + +#ifdef MISSIONPACK + if (level.intermissionQueued != 0 && g_singlePlayer.integer) { + if ( level.time - level.intermissionQueued >= 1000 ) { + pm.cmd.buttons = 0; + pm.cmd.forwardmove = 0; + pm.cmd.rightmove = 0; + pm.cmd.upmove = 0; + if ( level.time - level.intermissionQueued >= 2000 && level.time - level.intermissionQueued <= 2500 ) { + gi.SendConsoleCommand( EXEC_APPEND, "centerview\n"); + } + ent->client->ps.pm_type = PM_SPINTERMISSION; + } + } + Pmove (&pm); +#else + Pmove (&pm); +#endif + + // save results of pmove + if (g_smoothClients.integer) { + BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue ); + } + else { + BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue ); + } +// SendPendingPredictableEvents( &ent->client->ps ); + + //if ( !( ent->client->ps.eFlags & EF_FIRING ) ) { + // client->fireHeld = qfalse; // for grapple + //} + + // use the snapped origin for linking so it matches client predicted versions + VectorCopy( ent->s.origin, ent->r.currentOrigin ); + + VectorCopy (pm.mins, ent->r.mins); + VectorCopy (pm.maxs, ent->r.maxs); + + ent->waterlevel = pm.waterlevel; + ent->watertype = pm.watertype; + + // link entity now, after any personal teleporters have been used + gi.LinkEntity (ent); + if ( !ent->client->noclip ) { + G_TouchTriggers( ent ); + } + + // NOTE: now copy the exact origin over otherwise clients can be snapped into solid + VectorCopy( ent->client->ps.origin, ent->r.currentOrigin ); + + //test for solid areas in the AAS file + //BotTestAAS(ent->r.currentOrigin); + + // touch other objects + ClientImpacts( ent, &pm ); + + // swap and latch button actions + client->oldbuttons = client->buttons; + client->buttons = ucmd->buttons; + client->latched_buttons |= client->buttons & ~client->oldbuttons; + + // check for respawning + if ( client->ps.stats[STAT_HEALTH] <= 0 ) { + // wait for the attack button to be pressed + if ( level.time > client->respawnTime ) { + // forcerespawn is to prevent users from waiting out powerups + if ( g_forcerespawn.integer > 0 && + ( level.time - client->respawnTime ) > g_forcerespawn.integer * 1000 ) { + respawn( ent ); + return; + } + + // pressing attack or use is the normal respawn method + if ( ucmd->buttons & ( BUTTON_ATTACK | BUTTON_USE ) ) { + respawn( ent ); + } + } + return; + } + + if(client->buttons & BUTTON_USE) { + ClientUse(ent); + } else { + ent->lastUseEntity = ENTITYNUM_NONE; + } + + // perform once-a-second actions + ClientTimerActions( ent, msec ); +} + +void G_RunClient( gentity_t *ent ) { + if ( !(ent->r.svFlags & SVF_BOT) && !g_synchronousClients.integer ) { + return; + } + ent->client->pers.cmd.serverTime = level.time; + ClientThink_real( ent ); +} + + +/* +============== +ClientEndFrame + +Called at the end of each server frame for each connected client +A fast client will have multiple ClientThink for each ClientEdFrame, +while a slow client may have multiple ClientEndFrame between ClientThink. +============== +*/ +void ClientEndFrame( gentity_t *ent ) { + int i; + clientPersistant_t *pers; + + if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) { + SpectatorClientEndFrame( ent ); + return; + } + + pers = &ent->client->pers; + + // turn off any expired powerups + //for ( i = 0 ; i < MAX_POWERUPS ; i++ ) { + // if ( ent->client->ps.powerups[ i ] < level.time ) { + // ent->client->ps.powerups[ i ] = 0; + // } + //} + +#ifdef MISSIONPACK + // set powerup for player animation + if( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) { + ent->client->ps.powerups[PW_GUARD] = level.time; + } + if( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) { + ent->client->ps.powerups[PW_SCOUT] = level.time; + } + if( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_DOUBLER ) { + ent->client->ps.powerups[PW_DOUBLER] = level.time; + } + if( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_AMMOREGEN ) { + ent->client->ps.powerups[PW_AMMOREGEN] = level.time; + } + if ( ent->client->invulnerabilityTime > level.time ) { + ent->client->ps.powerups[PW_INVULNERABILITY] = level.time; + } +#endif + + // save network bandwidth +#if 0 + if ( !g_synchronousClients->integer && ent->client->ps.pm_type == PM_NORMAL ) { + // FIXME: this must change eventually for non-sync demo recording + VectorClear( ent->client->ps.viewangles ); + } +#endif + + // + // If the end of unit layout is displayed, don't give + // the player any normal movement attributes + // + if ( level.intermissiontime ) { + return; + } + + // burn from lava, etc + P_WorldEffects (ent); + + // apply all the damage taken this frame + P_DamageFeedback (ent); + + // add the EF_CONNECTION flag if we haven't gotten commands recently + if ( level.time - ent->client->lastCmdTime > 1000 ) { + ent->s.eFlags |= EF_CONNECTION; + } else { + ent->s.eFlags &= ~EF_CONNECTION; + } + + ent->client->ps.stats[STAT_HEALTH] = ent->health; // FIXME: get rid of ent->health... + + G_SetClientSound (ent); + + // set the latest infor + if (g_smoothClients.integer) { + BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue ); + } + else { + BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue ); + } + SendPendingPredictableEvents( &ent->client->ps ); + + // set the bit for the reachability area the client is currently in +// i = GBot_AAS_PointReachabilityAreaIndex( ent->client->ps.origin ); +// ent->client->areabits[i >> 3] |= 1 << (i & 7); +} + +/* +============== +ClientImpacts +============== +*/ +void ClientImpacts( gentity_t *ent, pmove_t *pm ) { + int i, j; + trace_t trace; + gentity_t *other; + + memset( &trace, 0, sizeof( trace ) ); + for (i=0 ; inumtouch ; i++) { + for (j=0 ; jtouchents[j] == pm->touchents[i] ) { + break; + } + } + if (j != i) { + continue; // duplicated + } + other = &g_entities[ pm->touchents[i] ]; + + if ( ( ent->r.svFlags & SVF_BOT ) && ( ent->touch ) ) { + ent->touch( ent, other, &trace ); + } + + if ( !other->touch ) { + continue; + } + + other->touch( other, ent, &trace ); + } + +} + +/* +================= +ClientInactivityTimer + +Returns qfalse if the client is dropped +================= +*/ +qboolean ClientInactivityTimer( gclient_t *client ) { + if ( ! g_inactivity.integer ) { + // give everyone some time, so if the operator sets g_inactivity during + // gameplay, everyone isn't kicked + client->inactivityTime = level.time + 60 * 1000; + client->inactivityWarning = qfalse; + } else if ( client->pers.cmd.forwardmove || + client->pers.cmd.rightmove || + client->pers.cmd.upmove || + (client->pers.cmd.buttons & BUTTON_ATTACK) ) { + client->inactivityTime = level.time + g_inactivity.integer * 1000; + client->inactivityWarning = qfalse; + } else if ( !client->pers.localClient ) { + if ( level.time > client->inactivityTime ) { + gi.DropClient( client - game.clients, "Dropped due to inactivity" ); + return qfalse; + } + if ( level.time > client->inactivityTime - 10000 && !client->inactivityWarning ) { + client->inactivityWarning = qtrue; + gi.SendServerCommand( client - game.clients, "cp \"Ten seconds until inactivity drop!\n\"" ); + } + } + return qtrue; +} + +/* +================== +ClientTimerActions + +Actions that happen once a second +================== +*/ +void ClientTimerActions( gentity_t *ent, int msec ) { + gclient_t *client; +#ifdef MISSIONPACK + int maxHealth; +#endif + + client = ent->client; + client->timeResidual += msec; + + while ( client->timeResidual >= 1000 ) { + client->timeResidual -= 1000; + + + { + // count down health when over max + if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] ) { + ent->health--; + } + } + + // count down armor when over max +// if ( client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH] ) { +// client->ps.stats[STAT_ARMOR]--; +// } + } +#ifdef MISSIONPACK + if( bg_itemlist[client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_AMMOREGEN ) { + int w, max, inc, t, i; + int weapList[]={WP_MACHINEGUN,WP_SHOTGUN,WP_GRENADE_LAUNCHER,WP_ROCKET_LAUNCHER,WP_LIGHTNING,WP_RAILGUN,WP_PLASMAGUN,WP_BFG,WP_NAILGUN,WP_PROX_LAUNCHER,WP_CHAINGUN}; + int weapCount = sizeof(weapList) / sizeof(int); + // + for (i = 0; i < weapCount; i++) { + w = weapList[i]; + + switch(w) { + case WP_MACHINEGUN: max = 50; inc = 4; t = 1000; break; + case WP_SHOTGUN: max = 10; inc = 1; t = 1500; break; + case WP_GRENADE_LAUNCHER: max = 10; inc = 1; t = 2000; break; + case WP_ROCKET_LAUNCHER: max = 10; inc = 1; t = 1750; break; + case WP_LIGHTNING: max = 50; inc = 5; t = 1500; break; + case WP_RAILGUN: max = 10; inc = 1; t = 1750; break; + case WP_PLASMAGUN: max = 50; inc = 5; t = 1500; break; + case WP_BFG: max = 10; inc = 1; t = 4000; break; + case WP_NAILGUN: max = 10; inc = 1; t = 1250; break; + case WP_PROX_LAUNCHER: max = 5; inc = 1; t = 2000; break; + case WP_CHAINGUN: max = 100; inc = 5; t = 1000; break; + default: max = 0; inc = 0; t = 1000; break; + } + client->ammoTimes[w] += msec; + if ( client->ps.ammo[w] >= max ) { + client->ammoTimes[w] = 0; + } + if ( client->ammoTimes[w] >= t ) { + while ( client->ammoTimes[w] >= t ) + client->ammoTimes[w] -= t; + client->ps.ammo[w] += inc; + if ( client->ps.ammo[w] > max ) { + client->ps.ammo[w] = max; + } + } + } + } +#endif +} + +/* +==================== +ClientIntermissionThink +==================== +*/ +void ClientIntermissionThink( gclient_t *client ) { + +} + +/* +================ +ClientUse +================ +Does a trace and touches the entity hit. +*/ +void ClientUse(gentity_t *ent) { + trace_t tr; + vec3_t forward, right, up; + gentity_t *other; + vec3_t g_muzzle; + + // set aiming directions + AngleVectors(ent->client->ps.viewangles, forward, right, up); + CalcMuzzlePoint(ent, forward, right, up, g_muzzle); + + VectorMA(g_muzzle, 96.f, forward, right); + gi.Trace(&tr, g_muzzle, NULL, NULL, right, ent - g_entities, MASK_SOLID,0,false); + + if (tr.fraction == 1.f || tr.entityNum == ENTITYNUM_NONE || tr.entityNum == ENTITYNUM_WORLD) { + ent->lastUseEntity = tr.entityNum; + return; // nothing interesting hit + } + other = g_entities + tr.entityNum; + if (other->client) { // push them around + // make the velocity lateral only so that they can't make others go over obstacles + forward[2] = 0; + VectorNormalize(forward); + if (VectorLengthSquared(forward) < 1.f) + return; // probably looking straight up or down, don't bother + VectorMA(other->client->ps.velocity, 128.f, forward, other->client->ps.velocity); + other->client->ps.velocity[2] += 16.f; // nudge the velocity upwards so that it's not eaten immediately by ground friction + return; + } + if(ent->lastUseEntity != tr.entityNum) { + if (other->s.eType == ET_MOVER && other->splashDamage) { + Use_BinaryMover(other, ent, ent); + } + } + ent->lastUseEntity = tr.entityNum; +} + +void BotTestSolid(vec3_t origin); + +/* +============== +SendPendingPredictableEvents +============== +*/ +void SendPendingPredictableEvents( playerState_t *ps ) { + +} + +/* +================= +SpectatorThink +================= +*/ +void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) { + pmove_t pm; + gclient_t *client; + + client = ent->client; + + if ( client->sess.spectatorState != SPECTATOR_FOLLOW ) { + client->ps.pm_type = PM_NOCLIP; + client->ps.speed = sv_runspeed->value * 2.f; // faster than normal + + // set up for pmove + memset (&pm, 0, sizeof(pm)); + pm.ps = &client->ps; + pm.cmd = *ucmd; + pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; // spectators can fly through bodies + pm.trace = gi.Trace; + pm.pointcontents = gi.PointContents; + + // perform a pmove + Pmove (&pm); + // save results of pmove + VectorCopy( client->ps.origin, ent->s.origin ); + + G_TouchTriggers( ent ); + gi.UnlinkEntity( ent ); + } + + client->oldbuttons = client->buttons; + client->buttons = ucmd->buttons; + + // attack button cycles through spectators + if ( ( client->buttons & BUTTON_ATTACK ) && ! ( client->oldbuttons & BUTTON_ATTACK ) ) { + Cmd_FollowCycle_f( ent, 1 ); + } +} + +/* +================== +SpectatorClientEndFrame + +================== +*/ +void SpectatorClientEndFrame( gentity_t *ent ) { + gclient_t *cl; + + // if we are doing a chase cam or a remote view, grab the latest info + if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) { + int clientNum, flags; + + clientNum = ent->client->sess.spectatorClient; + + // team follow1 and team follow2 go to whatever clients are playing + if ( clientNum == -1 ) { + clientNum = level.follow1; + } else if ( clientNum == -2 ) { + clientNum = level.follow2; + } + if ( clientNum >= 0 ) { + cl = &game.clients[ clientNum ]; + if ( cl->pers.connected == CON_CONNECTED && cl->sess.sessionTeam != TEAM_SPECTATOR ) { + // flags = (cl->ps.eFlags & ~(EF_VOTED | EF_TEAMVOTED)) | (ent->client->ps.eFlags & (EF_VOTED | EF_TEAMVOTED)); + ent->client->ps = cl->ps; + ent->client->ps.pm_flags |= PMF_FOLLOW; + // ent->client->ps.eFlags = flags; + return; + } else + + { + // drop them to free spectators unless they are dedicated camera followers + if ( ent->client->sess.spectatorClient >= 0 ) { + ent->client->sess.spectatorState = SPECTATOR_FREE; + G_ClientBegin( &g_entities[ ent->client - game.clients ], NULL ); + } + } + } + } + + if ( ent->client->sess.spectatorState == SPECTATOR_SCOREBOARD ) { + ent->client->ps.pm_flags |= PMF_SCOREBOARD; + } else { + ent->client->ps.pm_flags &= ~PMF_SCOREBOARD; + } +} + +#endif + + +/* +=============== +G_SetClientSound +=============== +*/ +void G_SetClientSound( gentity_t *ent ) { +#ifdef MISSIONPACK + if( ent->s.eFlags & EF_TICKING ) { + ent->client->ps.loopSound = G_SoundIndex( "sound/weapons/proxmine/wstbtick.wav"); + } + else +#endif + //if (ent->waterlevel && (ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) { + // ent->client->ps.loopSound = level.snd_fry; + //} else { + // ent->client->ps.loopSound = 0; + //} +} + + + +//============================================================== + +/* +============ +G_TouchTriggers + +Find all trigger entities that ent's current position touches. +Spectators will only interact with teleporters. +============ +*/ +void G_TouchTriggers( gentity_t *ent ) +{ + int i; + int num; + int touch[ MAX_GENTITIES ]; + gentity_t *hit; + Event *ev; + + // dead things don't activate triggers! + if( ( ent->client || ( ent->r.svFlags & SVF_BOT ) ) && ( ent->entity->health <= 0 ) ) + { + return; + } + + num = gi.AreaEntities( ent->r.absmin, ent->r.absmax, touch, MAX_GENTITIES ); + + // be careful, it is possible to have an entity in this + // list removed before we get to it (killtriggered) + for( i = 0; i < num; i++ ) + { + hit = &g_entities[ touch[ i ] ]; + if( !hit->inuse || ( hit->entity == ent->entity ) || ( hit->solid != SOLID_TRIGGER ) ) + { + continue; + } + + assert( hit->entity ); + + // FIXME + // should we post the events on the list with zero time + ev = new Event( EV_Touch ); + ev->AddEntity( ent->entity ); + hit->entity->ProcessEvent( ev ); + hit->entity->Unregister( "touch" ); + } +} + +/* +================== +ClientThink + +A new command has arrived from the client +================== +*/ +void G_ClientThink( gentity_t *ent, usercmd_t *cmd, usereyes_t *eyeinfo ) +{ + try + { + if( ent->entity ) + { + current_ucmd = cmd; + current_eyeinfo = eyeinfo; + ent->entity->ClientThink(); + current_ucmd = NULL; + current_eyeinfo = NULL; + } + } + + catch( const char *error ) + { + G_ExitWithError( error ); + } +} + +/* +================= +G_ClientEndServerFrames +================= +*/ +void G_ClientEndServerFrames( void ) +{ + int i; + gentity_t *ent; + + // calc the player views now that all pushing + // and damage has been added + for( i = 0; i < game.maxclients; i++ ) + { + ent = g_entities + i; + if( !ent->inuse || !ent->client || !ent->entity ) + { + continue; + } + + ent->entity->EndFrame(); + } +} + diff --git a/code/game/g_arenas.cpp b/code/game/g_arenas.cpp new file mode 100644 index 00000000..2d61eadb --- /dev/null +++ b/code/game/g_arenas.cpp @@ -0,0 +1,93 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// +// g_arenas.c +// + +#include "g_local.h" + + +gentity_t *podium1; +gentity_t *podium2; +gentity_t *podium3; + + +/* +================== +UpdateTournamentInfo +================== +*/ +void UpdateTournamentInfo( void ) { + +} + + +static gentity_t *SpawnModelOnVictoryPad( gentity_t *pad, vec3_t offset, gentity_t *ent, int place ) { + + + return 0; +} + + +static void CelebrateStop( gentity_t *player ) { +} + + +#define TIMER_GESTURE (34*66+50) +static void CelebrateStart( gentity_t *player ) { + +} + + +static vec3_t offsetFirst = {0, 0, 74}; +static vec3_t offsetSecond = {-10, 60, 54}; +static vec3_t offsetThird = {-19, -60, 45}; + +static void PodiumPlacementThink( gentity_t *podium ) { + +} + + +static gentity_t *SpawnPodium( void ) { +return 0; +} + + +/* +================== +SpawnModelsOnVictoryPads +================== +*/ +void SpawnModelsOnVictoryPads( void ) { + +} + + +/* +=============== +Svcmd_AbortPodium_f +=============== +*/ +void Svcmd_AbortPodium_f( void ) { + +} diff --git a/code/game/g_bot.cpp b/code/game/g_bot.cpp new file mode 100644 index 00000000..2984b646 --- /dev/null +++ b/code/game/g_bot.cpp @@ -0,0 +1,60 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// g_bot.cpp + +#include "g_local.h" +#include "entity.h" +#include "playerbot.h" + +void G_BotBegin + ( + gentity_t *ent + ) + +{ + level.m_bSpawnBot = true; + G_ClientBegin( ent, NULL ); +} + +void G_BotThink + ( + gentity_t *ent, + int msec + ) + +{ + usercmd_t ucmd; + usereyes_t eyeinfo; + PlayerBot *bot; + + assert( ent ); + assert( ent->entity ); + assert( ent->entity->IsSubclassOfBot() ); + + bot = ( PlayerBot * )ent->entity; + + bot->UpdateBotStates(); + bot->GetUsercmd( &ucmd ); + bot->GetEyeInfo( &eyeinfo ); + + G_ClientThink( ent, &ucmd, &eyeinfo ); +} diff --git a/code/game/g_client.cpp b/code/game/g_client.cpp new file mode 100644 index 00000000..bc773fcf --- /dev/null +++ b/code/game/g_client.cpp @@ -0,0 +1,1103 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +#include "g_local.h" +#include "player.h" +#include "playerbot.h" +#include "PlayerStart.h" +#include + +// g_client.c -- client functions that don't happen every frame + +static vec3_t playerMins = {-15, -15, -24}; +static vec3_t playerMaxs = {15, 15, 32}; + +// FIXME: OLD Q3 CODE + +#if 0 + +/*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 32) initial +potential spawning position for deathmatch games. +The first time a player enters the game, they will be at an 'initial' spot. +Targets will be fired when someone spawns in on them. +"nobots" will prevent bots from using this spot. +"nohumans" will prevent non-bots from using this spot. +*/ +void SP_info_player_deathmatch( gentity_t *ent ) { + int i; + + G_SpawnInt( "nobots", "0", &i); + if ( i ) { + ent->flags |= FL_NO_BOTS; + } + G_SpawnInt( "nohumans", "0", &i ); + if ( i ) { + ent->flags |= FL_NO_HUMANS; + } +} + +/*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 32) +equivelant to info_player_deathmatch +*/ +void SP_info_player_start(gentity_t *ent) { + ent->classname = "info_player_deathmatch"; + SP_info_player_deathmatch( ent ); +} + +/*QUAKED info_player_intermission (1 0 1) (-16 -16 -24) (16 16 32) +The intermission will be viewed from this point. Target an info_notnull for the view direction. +*/ +void SP_info_player_intermission( gentity_t *ent ) { + +} + +/* +======================================================================= + +BODYQUE + +======================================================================= +*/ + +/* +=============== +InitBodyQue +=============== +*/ +void InitBodyQue( void ) { + int i; + gentity_t *ent; + + level.bodyQueIndex = 0; + for( i = 0; iclassname = "bodyque"; + ent->neverFree = qtrue; + level.bodyQue[ i ] = ent; + } +} + +/* +============= +BodySink + +After sitting around for five seconds, fall into the ground and dissapear +============= +*/ +void BodySink( gentity_t *ent ) { + if( level.time - ent->timestamp > 6500 ) { + // the body ques are never actually freed, they are just unlinked + gi.UnlinkEntity( ent ); + ent->physicsObject = qfalse; + return; + } + ent->nextthink = level.time + 100; + ent->s.origin[ 2 ] -= 1; +} + +/* +============= +CopyToBodyQue + +A player is respawning, so make an entity that looks +just like the existing corpse to leave behind. +============= +*/ +void CopyToBodyQue( gentity_t *ent ) { + +} + +/* +================ +respawn +================ +*/ +void respawn( gentity_t *ent ) { + //CopyToBodyQue (ent); + ClientSpawn(ent); +} + +/* +================ +TeamCount + +Returns number of players on a team +================ +*/ +teamtype_t TeamCount( int ignoreClientNum, int team ) { + int i; + int count = 0; + + for ( i = 0 ; i < game.maxclients ; i++ ) { + if ( i == ignoreClientNum ) { + continue; + } + if ( game.clients[i].pers.connected == CON_DISCONNECTED ) { + continue; + } + if ( game.clients[i].sess.sessionTeam == team ) { + count++; + } + } + + return ( teamtype_t )count; +} + +/* +================ +TeamLeader + +Returns the client number of the team leader +================ +*/ +int TeamLeader( int team ) { + int i; + + for ( i = 0 ; i < game.maxclients ; i++ ) { + if ( game.clients[i].pers.connected == CON_DISCONNECTED ) { + continue; + } + if ( game.clients[i].sess.sessionTeam == team ) { + if ( game.clients[i].sess.teamLeader ) + return i; + } + } + + return -1; +} + + +/* +================ +PickTeam + +================ +*/ +teamtype_t PickTeam( int ignoreClientNum ) { + int counts[TEAM_NUM_TEAMS]; + + counts[ TEAM_ALLIES ] = TeamCount( ignoreClientNum, TEAM_ALLIES ); + counts[ TEAM_AXIS ] = TeamCount( ignoreClientNum, TEAM_AXIS ); + + if( counts[ TEAM_ALLIES ] > counts[ TEAM_AXIS ] ) { + return TEAM_AXIS; + } + if( counts[ TEAM_AXIS ] > counts[ TEAM_ALLIES ] ) { + return TEAM_ALLIES; + } + // equal team count, so join the team with the lowest score + if( level.teamScores[ TEAM_ALLIES ] > level.teamScores[ TEAM_AXIS ] ) { + return TEAM_AXIS; + } + return TEAM_ALLIES; +} + +/* +=========== +ForceClientSkin + +Forces a client's skin (for teamplay) +=========== +*/ +/* +static void ForceClientSkin( gclient_t *client, char *model, const char *skin ) { + char *p; + + if ((p = Q_strrchr(model, '/')) != 0) { + *p = 0; + } + + Q_strcat(model, MAX_QPATH, "/"); + Q_strcat(model, MAX_QPATH, skin); +} +*/ + +/* +=========== +ClientSpawn + +Called every time a client is placed fresh in the world: +after the first ClientBegin, and after each respawn +Initializes all non-persistant parts of playerState +============ +*/ +void ClientSpawn(gentity_t *ent) { + int index; + vec3_t spawn_origin, spawn_angles; + gclient_t *client; + int i; + clientPersistant_t saved; + clientSession_t savedSess; + int persistant[MAX_PERSISTANT]; + Entity *spawnPoint; + int flags; + int savedPing; +// char *savedAreaBits; + int accuracy_hits, accuracy_shots; + int eventSequence; + char userinfo[MAX_INFO_STRING]; + + index = ent - g_entities; + client = ent->client; + + // find a spawn point + // do it before setting health back up, so farthest + // ranging doesn't count this client + if ( client->sess.sessionTeam == TEAM_SPECTATOR ) { + spawnPoint = SelectSpectatorSpawnPoint ( + spawn_origin, spawn_angles); + } else { + do { + // the first spawn should be at a good looking spot + if ( !client->pers.initialSpawn && client->pers.localClient ) { + client->pers.initialSpawn = qtrue; + spawnPoint = SelectInitialSpawnPoint( spawn_origin, spawn_angles ); + } else { + // don't spawn near existing origin if possible + spawnPoint = SelectSpawnPoint ( + client->ps.origin, + spawn_origin, spawn_angles); + } + + // Tim needs to prevent bots from spawning at the initial point + // on q3dm0... + if ( ( spawnPoint->flags & FL_NO_BOTS ) && ( ent->r.svFlags & SVF_BOT ) ) { + continue; // try again + } + // just to be symetric, we have a nohumans option... + if ( ( spawnPoint->flags & FL_NO_HUMANS ) && !( ent->r.svFlags & SVF_BOT ) ) { + continue; // try again + } + + break; + + } while ( 1 ); + } + client->pers.teamState.state = TEAM_ACTIVE; + + // always clear the kamikaze flag +// ent->s.eFlags &= ~EF_KAMIKAZE; + + // toggle the teleport bit so the client knows to not lerp + // and never clear the voted flag + flags = ent->s.eFlags & (EF_TELEPORT_BIT | EF_VOTED | EF_TEAMVOTED); + flags ^= EF_TELEPORT_BIT; + + // clear everything but the persistant data + + saved = client->pers; + savedSess = client->sess; + savedPing = client->ps.ping; +// savedAreaBits = client->areabits; + accuracy_hits = client->accuracy_hits; + accuracy_shots = client->accuracy_shots; + + Com_Memset (client, 0, sizeof(*client)); + + client->ps.stats[STAT_ATTACKERCLIENT] = -1; + client->ps.stats[STAT_INFOCLIENT] = -1; + + client->pers = saved; + client->sess = savedSess; + client->ps.ping = savedPing; +// client->areabits = savedAreaBits; + client->accuracy_hits = accuracy_hits; + client->accuracy_shots = accuracy_shots; + client->lastkilled_client = -1; + + client->airOutTime = level.time + 12000; + + gi.GetUserinfo( index, userinfo, sizeof(userinfo) ); + // set max health + client->pers.maxHealth = atoi( Info_ValueForKey( userinfo, "handicap" ) ); + if ( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 ) { + client->pers.maxHealth = 100; + } + // clear entity values + client->ps.stats[STAT_MAX_HEALTH] = client->pers.maxHealth; + ent->s.eFlags = flags; + + ent->s.groundEntityNum = ENTITYNUM_NONE; + ent->client = &game.clients[index]; + ent->takedamage = qtrue; + ent->inuse = qtrue; + ent->classname = "player"; + ent->r.contents = CONTENTS_BODY; + ent->clipmask = MASK_PLAYERSOLID; + ent->die = player_die; + ent->waterlevel = 0; + ent->watertype = 0; + ent->flags = 0; + + VectorCopy (playerMins, ent->r.mins); + VectorCopy (playerMaxs, ent->r.maxs); + + client->ps.clientNum = index; + + + + // health will count down towards max_health + ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] + 25; + + G_SetOrigin( ent, spawn_origin ); + VectorCopy( spawn_origin, client->ps.origin ); + + // the respawned flag will be cleared after the attack and jump keys come up + client->ps.pm_flags |= PMF_RESPAWNED; + + //gi.GetUsercmd( client - game.clients, &ent->client->pers.cmd ); + //FIXME + + SetClientViewAngle( ent, spawn_angles ); + + if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) { + + } else { + G_KillBox( ent ); + gi.LinkEntity (ent); + + + + } + + // don't allow full run speed for a bit + client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + client->ps.pm_time = 100; + + client->respawnTime = level.time; + client->inactivityTime = level.time + g_inactivity.integer * 1000; + client->latched_buttons = 0; + + if ( level.intermissiontime ) { + MoveClientToIntermission( ent ); + } else { + // fire the targets of the spawn point + //G_UseTargets( spawnPoint->edict, ent ); + + } + + // run a client frame to drop exactly to the floor, + // initialize animations and other things + client->ps.commandTime = level.time - 100; + ent->client->pers.cmd.serverTime = level.time; + G_ClientThink( ent, &ent->client->pers.cmd ); + + // positively link the client, even if the command times are weird + if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) { + BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue ); + VectorCopy( ent->client->ps.origin, ent->r.currentOrigin ); + gi.LinkEntity( ent ); + } + + // run the presend to set anything else + ClientEndFrame( ent ); + + // clear entity state values + BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue ); + + ent->s.modelindex = G_ModelIndex("models/player/american_army.tik"); +} + +/* +================== +SetClientViewAngle + +================== +*/ +void SetClientViewAngle( gentity_t *ent, vec3_t angle ) { + int i; + + // set the delta angle + for (i=0 ; i<3 ; i++) { + int cmdAngle; + + cmdAngle = ANGLE2SHORT(angle[i]); + ent->client->ps.delta_angles[i] = cmdAngle - ent->client->pers.cmd.angles[i]; + } + VectorCopy( angle, ent->s.angles ); + VectorCopy (ent->s.angles, ent->client->ps.viewangles); +} + +#endif + + +/* +======================================================================= + + SelectSpawnPoint + +======================================================================= +*/ + +/* +================ +SelectNearestDeathmatchSpawnPoint + +Find the spot that we DON'T want to use +================ +*/ +#define MAX_SPAWN_POINTS 128 +Entity *SelectNearestDeathmatchSpawnPoint( vec3_t from ) { + Entity *spot; + vec3_t delta; + float dist, nearestDist; + Entity *nearestSpot; + + nearestDist = 999999; + nearestSpot = NULL; + spot = NULL; + + while( ( spot = ( Entity * )G_FindClass( spot, "info_player_deathmatch" ) ) != NULL ) { + + VectorSubtract( spot->origin, from, delta ); + dist = VectorLength( delta ); + if ( dist < nearestDist ) { + nearestDist = dist; + nearestSpot = spot; + } + } + + return nearestSpot; +} + + +/* +================ +SelectRandomDeathmatchSpawnPoint + +go to a random point that doesn't telefrag +================ +*/ +Entity *SelectRandomDeathmatchSpawnPoint( str spawnpoint_type ) +{ + Entity *spot = NULL; + Entity *spot1 = NULL; + Entity *spot2 = NULL; + int count = 0; + int selection; + float range; + float range1 = 99999.0f; + float range2 = 99999.0f; + + while( ( spot = ( Entity * )G_FindClass( spot, spawnpoint_type ) ) ) + { + count++; + + range = PlayersRangeFromSpot( spot ); + if( range2 <= range ) + { + if( range1 > range ) + { + range1 = range; + spot1 = spot; + } + } + else + { + range2 = range; + spot2 = spot; + } + } + + spot = NULL; + + if( !count ) { + return NULL; + } + + if( count > 2 ) + { + count -= 2; + } + else + { + spot1 = NULL; + spot2 = NULL; + } + + for( selection = rand() % count; selection != -1; selection-- ) + { + spot = ( Entity * )G_FindClass( spot, spawnpoint_type ); + if( !spot ) { + break; + } + + if( spot == spot1 || spot == spot2 ) { + selection++; + } + } + + return spot; +} + +/* +=========== +SelectRandomFurthestSpawnPoint + +Chooses a player start, deathmatch start, etc +============ +*/ +Entity *SelectRandomFurthestSpawnPoint( void ) +{ + Entity *spot = NULL; + Entity *bestspot = NULL; + float bestplayerdistance = 0.0f; + + while( ( spot = ( Entity * )G_FindClass( spot, "info_player_deathmatch" ) ) ) + { + float dist = PlayersRangeFromSpot( spot ); + + if( dist > bestplayerdistance ) + { + bestplayerdistance = dist; + bestspot = spot; + } + } + + if( !bestspot ) { + bestspot = ( Entity * )G_FindClass( NULL, "info_player_deathmatch" ); + } + + return bestspot; +} + +/* +=========== +SelectSpawnPoint + +Chooses a player start, deathmatch start, etc +============ +*/ +PlayerStart *SelectSpawnPoint( Player *player ) +{ + PlayerStart *spot = NULL; + + switch( g_gametype->integer ) + { + case GT_FFA: + spot = player->GetDM_Team()->GetRandomFfaSpawnpoint( player ); + break; + case GT_SINGLE_PLAYER: + break; + case GT_TEAM: + case GT_TEAM_ROUNDS: + spot = player->GetDM_Team()->GetRandomTeamSpawnpoint( player ); + break; + case GT_OBJECTIVE: + spot = player->GetDM_Team()->GetRandomObjectiveSpawnpoint( player ); + break; + default: + Com_Printf( "SelectSpawnPoint: unknown game type '%i'\n" ); + spot = player->GetDM_Team()->GetRandomFfaSpawnpoint( player ); + break; + } + + // find a single player start spot + if( !spot ) + { + while( ( spot = ( PlayerStart * )G_FindArchivedClass( spot, "info_player_start" ) ) != NULL ) + { + if( level.spawnpoint.icmp( spot->TargetName() ) == 0 ) + { + break; + } + } + + if( !spot && !level.spawnpoint.length() ) + { + // there wasn't a spawnpoint without a target, so use any + spot = ( PlayerStart * )G_FindArchivedClass( NULL, "info_player_start" ); + } + + if( !spot ) + { + gi.Error( ERR_DROP, "No player spawn position named '%s'. Can't spawn player.\n", level.spawnpoint.c_str() ); + } + } + + return spot; +} + +//====================================================================== + +/* +=========== +ClientCheckName +============ +*/ +static void ClientCleanName( const char *in, char *out, int outSize ) +{ + int len, colorlessLen; + char ch; + char *p; + int spaces; + + //save room for trailing null byte + outSize--; + + len = 0; + colorlessLen = 0; + p = out; + *p = 0; + spaces = 0; + + while( 1 ) { + ch = *in++; + if( !ch ) { + break; + } + + // don't allow leading spaces + if( colorlessLen == 0 && ch == ' ' ) { + continue; + } + + // check colors + if( ch == Q_COLOR_ESCAPE ) { + // solo trailing carat is not a color prefix + if( !*in ) { + break; + } + + // don't allow black in a name, period + if( ColorIndex(*in) == 0 ) { + in++; + continue; + } + + // make sure room in dest for both chars + if( len > outSize - 2 ) { + break; + } + + *out++ = ch; + *out++ = *in++; + len += 2; + continue; + } + + // don't allow too many consecutive spaces + // don't count spaces in colorlessLen + if( ch == ' ' ) { + spaces++; + if( spaces > 3 ) { + continue; + } + *out++ = ch; + len++; + continue; + } + else { + spaces = 0; + } + + if( len > outSize - 1 ) { + break; + } + + *out++ = ch; + colorlessLen++; + len++; + } + *out = 0; + + // don't allow empty names + if( *p == 0 || colorlessLen == 0 ) { + Q_strncpyz( p, "UnnamedPlayer", outSize ); + } +} + + +/* +=========== +ClientUserInfoChanged + +Called from ClientConnect when the player first connects and +directly by the server system when the player updates a userinfo variable. + +The game can override any of the settings and call gi.SetUserinfo +if desired. +============ +*/ +void G_ClientUserinfoChanged( gentity_t *ent, const char *u ) { + char *s; + gclient_t *client; + int clientnum; + + if( !ent ) + { + return; + } + + client = ent->client; + + s = Info_ValueForKey( u, "name" ); + + if( !s ) + { + return; + } + + clientnum = ent - g_entities; + + if( gi.SanitizeName( s, client->pers.netname ) ) + { + gi.Printf( "WARNING: had to sanitize the name for client %i\n", clientnum ); + } + + s = Info_ValueForKey( u, "dm_playermodel" ); + + if( !s ) + { + assert( 0 ); + return; + } + + Q_strncpyz( client->pers.playermodel, s, sizeof( client->pers.playermodel ) ); + + s = Info_ValueForKey( u, "dm_playergermanmodel" ); + + if( !s ) + { + assert( 0 ); + return; + } + + Q_strncpyz( client->pers.playergermanmodel, s, sizeof( client->pers.playergermanmodel ) ); + + gi.SetConfigstring( CS_PLAYERS + clientnum, va( "name\\%s", client->pers.netname ) ); + + if( ent->entity ) + { + float fov; + + s = Info_ValueForKey( u, "fov" ); + + fov = atof( s ); + + if( fov < 80.0f ) + { + fov = 80.0f; + } + else if( fov > 160.0f ) + { + fov = 160.0f; + } + + Event *ev = new Event( EV_Player_Fov ); + ev->AddFloat( fov ); + + ent->entity->ProcessEvent( ev ); + } + + Q_strncpyz( client->pers.userinfo, u, sizeof( client->pers.userinfo ) ); +} + +void G_BotConnect( int clientNum ) { + gclient_t *client; + gentity_t *ent; + char userinfo[ MAX_INFO_STRING ]; + + ent = &g_entities[ clientNum ]; + + ent->client = game.clients + clientNum; + ent->s.number = clientNum; + + client = ent->client; + + Q_strncpyz( userinfo, client->pers.userinfo, sizeof( userinfo ) ); + + // read the session data + memset( client, 0, sizeof( *client ) ); + G_InitSessionData( client, userinfo ); + + Q_strncpyz( client->pers.ip, "localhost", sizeof( client->pers.ip ) ); + client->pers.port = 0; + + G_ClientUserinfoChanged( ent, userinfo ); +} + +/* +=========== +ClientConnect + +Called when a player begins connecting to the server. +Called again for every map change or tournement restart. + +The session information will be valid after exit. + +Return NULL if the client should be allowed, otherwise return +a string with the reason for denial. + +Otherwise, the client will be sent the current gamestate +and will eventually get to ClientBegin. + +firstTime will be qtrue the very first time a client connects +to the server machine, but qfalse on map changes and tournement +restarts. +============ +*/ +char *G_ClientConnect( int clientNum, qboolean firstTime ) { + char *ip, *port, *value; + gclient_t *client; + gentity_t *ent; + char userinfo[ MAX_INFO_STRING ]; + + if( !g_gametype->integer ) { + return NULL; + } + + ent = &g_entities[ clientNum ]; + + gi.GetUserinfo( clientNum, userinfo, sizeof( userinfo ) ); + + // IP filtering + // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=500 + // recommanding PB based IP / GUID banning, the builtin system is pretty limited + // check to see if they are on the banned IP list + ip = Info_ValueForKey( userinfo, "ip" ); + port = Info_ValueForKey( userinfo, "port" ); + + // FIXME: what is fucking wrong with G_FilterPacket... + //if ( G_FilterPacket( value ) ) { + // return "Banned IP"; + //} + + // we don't check password for bots and local client + // NOTE: local client <-> "ip" "localhost" + // this means this client is not running in our current process + if( ( strcmp( ip, "localhost" ) != 0 ) ) + { + // check for a password + value = Info_ValueForKey( userinfo, "password" ); + if ( password->string[ 0 ] && Q_stricmp( password->string, "none" ) && + strcmp( password->string, value ) != 0 ) { + return "Invalid password"; + } + } + + ent->client = game.clients + clientNum; + client = ent->client; + + // read or initialize the session data + if ( firstTime ) + { + memset( client, 0, sizeof( *client ) ); + G_InitSessionData( client, userinfo ); + } + else + { + G_ReadSessionData( client ); + } + + Q_strncpyz( client->pers.ip, ip, sizeof( client->pers.ip ) ); + client->pers.port = atoi( port ); + + G_ClientUserinfoChanged( ent, userinfo ); + +#if 0 + if( isBot ) + { + ent->r.svFlags |= SVF_BOT; + ent->inuse = qtrue; + if( !G_BotConnect( clientNum, !firstTime ) ) { + return "BotConnectfailed"; + } + } +#endif + + // don't do the "xxx connected" messages if they were caried over from previous level + if ( firstTime && g_gametype->integer ) + { + if( dedicated->integer ) + { + gi.Printf( "%s is preparing for deployment\n", client->pers.netname ); + } + + G_PrintToAllClients( va( "%s is preparing for deployment\n", client->pers.netname ) ); + } + + return NULL; +} + +/* +=========== +ClientBegin + +called when a client has finished connecting, and is ready +to be placed into the level. This will happen every level load, +and on transition between teams, but doesn't happen on respawns +============ +*/ +void G_ClientBegin( gentity_t *ent, usercmd_t *cmd ) +{ + try + { + assert( ent->s.number < game.maxclients ); + assert( ent->client != NULL ); + + if( ent->inuse && ent->entity ) + { + // the client has cleared the client side viewangles upon + // connecting to the server, which is different than the + // state when the game is saved, so we need to compensate + // with deltaangles + ent->entity->SetDeltaAngles(); + } + else + { + // a spawn point will completely reinitialize the entity + level.spawn_entnum = ent->s.number; + + if( level.m_bSpawnBot ) + { + level.m_bSpawnBot = false; + PlayerBot *player = new PlayerBot; + } + else + { + Player *player = new Player; + } + } + + if( level.intermissiontime && ent->entity ) + { + G_MoveClientToIntermission( ent->entity ); + } + else + { + ent->client->pers.enterTime = level.svsFloatTime; + + if( g_gametype->integer ) + { + // send effect if in a multiplayer game + if( dedicated->integer ) + { + gi.Printf( "%s has entered the battle\n", ent->client->pers.netname ); + } + + G_PrintToAllClients( va( "%s has entered the battle\n", ent->client->pers.netname ) ); + } + } + + // make sure all view stuff is valid + if( ent->entity ) + { + ent->entity->EndFrame(); + } + } + catch( const char *error ) + { + G_ExitWithError( error ); + } +} + +/* +=========== +ClientDisconnect + +Called when a player drops from the server. +Will not be called between levels. + +This should NOT be called directly by any game logic, +call gi.DropClient(), which will call this and do +server system housekeeping. +============ +*/ +void G_ClientDisconnect( gentity_t *ent ) { + try + { + if ( !ent || ( !ent->client ) || ( !ent->entity ) ) + { + return; + } + + G_PrintToAllClients( va( "%s has left the battle\n", ent->client->pers.netname ) ); + + ( ( Player * )ent->entity )->Disconnect(); + + delete ent->entity; + ent->entity = NULL; + } + + catch( const char *error ) + { + G_ExitWithError( error ); + } +#if 0 + int i; + + // cleanup if we are kicking a bot that + // hasn't spawned yet + G_RemoveQueuedBotBegin( ent->client->ps.clientNum ); + + if ( !ent->client ) { + return; + } + + // stop any following clients + for ( i = 0 ; i < game.maxclients ; i++ ) { + if ( game.clients[i].sess.sessionTeam == TEAM_SPECTATOR + && game.clients[i].sess.spectatorState == SPECTATOR_FOLLOW + && game.clients[i].sess.spectatorClient == ent->client->ps.clientNum ) { + StopFollowing( &g_entities[i] ); + } + } + + // send effect if they were completely connected + if ( ent->client->pers.connected == CON_CONNECTED + && ent->client->sess.sessionTeam != TEAM_SPECTATOR ) { + + // They don't get to take powerups with them! + // Especially important for stuff like CTF flags + TossClientItems( ent ); +#ifdef MISSIONPACK + TossClientPersistantPowerups( ent ); + if( g_gametype->integer == GT_HARVESTER ) { + TossClientCubes( ent ); + } +#endif + + } + + G_LogPrintf( "ClientDisconnect: %i\n", ent->client->ps.clientNum ); + + + gi.UnlinkEntity (ent); + ent->s.modelindex = 0; + ent->inuse = qfalse; + ent->classname = "disconnected"; + ent->client->pers.connected = CON_DISCONNECTED; + ent->client->ps.stats[ STAT_TEAM ] = TEAM_NONE; + ent->client->sess.sessionTeam = TEAM_NONE; + + gi.SetConfigstring( CS_PLAYERS + ent->client->ps.clientNum, "" ); + + CalculateRanks(); + + if ( ent->r.svFlags & SVF_BOT ) { + BotAIShutdownClient( ent->client->ps.clientNum, qfalse ); + } +#endif +} + + diff --git a/code/game/g_items.cpp b/code/game/g_items.cpp new file mode 100644 index 00000000..30887932 --- /dev/null +++ b/code/game/g_items.cpp @@ -0,0 +1,25 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +#include "g_local.h" + +// TODO ? diff --git a/code/game/g_local.h b/code/game/g_local.h new file mode 100644 index 00000000..3fbcfde0 --- /dev/null +++ b/code/game/g_local.h @@ -0,0 +1,594 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// g_local.h -- local definitions for game module + +#ifndef __G_LOCAL_H__ +#define __G_LOCAL_H__ + +#include "q_shared.h" +#include "bg_public.h" +#include "g_public.h" + +//================================================================== + +// the "gameversion" client command will print this plus compile date +#define GAMEVERSION BASEGAME + +#define BODY_QUEUE_SIZE 8 + +#define INFINITE 1000000 + +#define FRAMETIME level.frametime // float sec +#define CARNAGE_REWARD_TIME 3000 +#define REWARD_SPRITE_TIME 2000 + +#define INTERMISSION_DELAY_TIME 1000 +#define SP_INTERMISSION_DELAY_TIME 5000 + +// flags +#define FL_FLY (1<<0) +#define FL_SWIM (1<<1) // implied immunity to drowining +#define FL_INWATER (1<<2) +#define FL_GODMODE (1<<3) +#define FL_NOTARGET (1<<4) +#define FL_PARTIALGROUND (1<<5) // not all corners are valid +#define FL_TEAMSLAVE (1<<6) // not the first on the team +#define FL_NO_KNOCKBACK (1<<7) +#define FL_THINK (1<<8) +#define FL_BLOOD (1<<9) // when hit, it should bleed. +#define FL_DIE_GIBS (1<<10) // when it dies, it should gib +#define FL_DIE_EXPLODE (1<<11) // when it dies, it will explode +#define FL_ROTATEDBOUNDS (1<<12) // model uses rotated mins and maxs +#define FL_DONTSAVE (1<<13) // don't add to the savegame +#define FL_IMMOBILE (1<<14) // entity has been immobolized somehow +#define FL_PARTIAL_IMMOBILE (1<<15) // entity has been immobolized somehow +#define FL_ANIMATE (1<<16) // entity has been immobolized somehow +#define FL_POSTTHINK (1<<17) // call a think function after the physics have been run +#define FL_TOUCH_TRIGGERS (1<<18) // should this entity touch triggers +#define FL_AUTOAIM (1<<19) // Autoaim on this entity +#define FL_UNKNOWN (1<<20) +#define FL_UNKNOWN2 (1<<21) + +#define SOUND_RADIUS 1500.0f // Sound travel distance for AI + +//============================================================================ + +#include "g_main.h" + +#ifdef __cplusplus +#include +#include +#include +#include +#include +#endif + +class Entity; + +typedef enum { + SPECTATOR_NOT, + SPECTATOR_FREE, + SPECTATOR_FOLLOW, + SPECTATOR_SCOREBOARD +} spectatorState_t; + +typedef enum { + TEAM_BEGIN, // Beginning a team game, spawn at base + TEAM_ACTIVE // Now actively playing +} playerTeamStateState_t; + +typedef struct { + playerTeamStateState_t state; + + int location; + + int captures; + int basedefense; + int carrierdefense; + int flagrecovery; + int fragcarrier; + int assists; + + float lasthurtcarrier; + float lastreturnedflag; + float flagsince; + float lastfraggedcarrier; +} playerTeamState_t; + +// the auto following clients don't follow a specific client +// number, but instead follow the first two active players +#define FOLLOW_ACTIVE1 -1 +#define FOLLOW_ACTIVE2 -2 + +// client data that stays across multiple levels or tournament restarts +// this is achieved by writing all the data to cvar strings at game shutdown +// time and reading them back at connection time. Anything added here +// MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData() +typedef struct { + teamtype_t sessionTeam; + int spectatorTime; // for determining next-in-line to play + spectatorState_t spectatorState; + int spectatorClient; // for chasecam and follow mode + int wins, losses; // tournament stats + qboolean teamLeader; // true when this client is a team leader +} clientSession_t; + +// +#define MAX_NETNAME 32 +#define MAX_VOTE_COUNT 3 + +typedef enum +{ + CS_FREE, + CS_ZOMBIE, + CS_CONNECTED, + CS_PRIMED, + CS_ACTIVE + +} clientState_t; + +typedef enum +{ + WEAPON_MAIN, + WEAPON_OFFHAND, + WEAPON_ERROR +} weaponhand_t; + +#define NUM_ACTIVE_WEAPONS WEAPON_ERROR + +typedef enum +{ + FIRE_PRIMARY, + FIRE_SECONDARY, + MAX_FIREMODES, + FIRE_ERROR +} firemode_t; + +// +// g_spawn.c +// +qboolean G_SpawnString( const char *key, const char *defaultString, char **out ); +// spawn string returns a temporary reference, you must CopyString() if you want to keep it +qboolean G_SpawnFloat( const char *key, const char *defaultString, float *out ); +qboolean G_SpawnInt( const char *key, const char *defaultString, int *out ); +qboolean G_SpawnVector( const char *key, const char *defaultString, float *out ); +void G_SpawnEntitiesFromString( void ); +char *G_NewString( const char *string ); +const char *G_FixTIKIPath(const char *in); +void G_GetNullEntityState( entityState_t *nullState ); + +// +// g_cmds.c +// +void Cmd_Score_f (gentity_t *ent); +void StopFollowing( gentity_t *ent ); +void BroadcastTeamChange( gclient_t *client, int oldTeam ); +void SetTeam( gentity_t *ent, char *s ); +void Cmd_FollowCycle_f( gentity_t *ent, int dir ); + +// +// g_items.c +// + + + + +// +// g_utils.c +// + +float G_Random( void ); +float G_Random( float n ); +float G_CRandom( void ); +float G_CRandom( float n ); + +int G_ModelIndex( const char *name ); +int G_SoundIndex( const char *name ); +void G_TeamCommand( teamtype_t team, char *cmd ); +void G_KillBox (gentity_t *ent); +qboolean M_CheckBottom( Entity *ent ); +gentity_t *G_PickTarget (char *targetname); +void G_UseTargets (gentity_t *ent, gentity_t *activator); +Vector G_GetMovedir( float angle ); +void G_SetMovedir ( vec3_t angles, vec3_t movedir); + +void G_InitGentity( gentity_t *e ); +gentity_t *G_Spawn (void); +gentity_t *G_TempEntity( vec3_t origin, int event ); +void G_Sound( gentity_t *ent, int channel, int soundIndex ); +void G_FreeEntity( gentity_t *e ); +qboolean G_entitiesFree( void ); + +Entity *G_NextEntity( Entity *ent ); + +void G_CalcBoundsOfMove( Vector &start, Vector &end, Vector &mins, Vector &maxs, Vector *minbounds, Vector *maxbounds ); + +void G_ShowTrace( trace_t *trace, gentity_t *passent, const char *reason ); +bool G_SightTrace( Vector &start, Vector &mins, Vector &maxs, Vector &end, Entity *passent, Entity *passent2, int contentmask, qboolean cylindrical, const char *reason ); +bool G_SightTrace( Vector &start, Vector &mins, Vector &maxs, Vector &end, gentity_t *passent, gentity_t *passent2, int contentmask, qboolean cylindrical, const char *reason ); +trace_t G_Trace( Vector &start, Vector &mins, Vector &maxs, Vector &end, Entity *passent, int contentmask, qboolean cylindrical, const char *reason, qboolean tracedeep = false ); +trace_t G_Trace( vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, gentity_t *passent, int contentmask, qboolean cylindrical, const char *reason, qboolean tracedeep = false ); +void G_TraceEntities( Vector &start, Vector &mins, Vector &maxs, Vector &end, Container*victimlist, int contentmask, qboolean bIncludeTriggers = qfalse ); + +float PlayersRangeFromSpot( Entity *ent ); + +Entity *findradius( Entity *startent, Vector org, float rad ); +Entity *findclientsinradius( Entity *startent, Vector org, float rad ); + +Vector G_CalculateImpulse( const Vector &start, const Vector &end, float speed, float gravity ); + +void G_TouchTriggers (gentity_t *ent); +void G_TouchSolids (gentity_t *ent); + +int MOD_NameToNum( const str &meansOfDeath ); +const char *MOD_NumToName( int meansOfDeath ); +qboolean MOD_matches( int incoming_damage, int damage_type ); + +void G_MissionFailed( void ); +void G_FadeOut( float delaytime ); +void G_FadeSound( float delaytime ); +void G_PlayerDied( float delaytime ); +void G_AutoFadeIn( void ); +void G_ClearFade( void ); +void G_StartCinematic( void ); +void G_StopCinematic( void ); + +void G_CenterPrintToAllClients( const char *pszString ); +void G_PrintToAllClients( const char *pszString, qboolean bBold = true ); +void G_PrintDeathMessage( const char *pszString ); +void G_WarnPlayer( class Player *player, const char *format, ... ); + +int G_WeaponIndex( const char *name ); + +class SkelMat4; + +orientation_t G_TIKI_Orientation( gentity_t *edict, int num ); +SkelMat4 *G_TIKI_Transform( gentity_t *edict, int num ); +qboolean G_TIKI_IsOnGround( gentity_t *edict, int num, float threshold ); +qboolean G_Command_ProcessFile( const char * filename, qboolean quiet ); + +char *G_TimeString( float fTime ); +char *CanonicalTikiName( const char *szInName ); + +float *tv (float x, float y, float z); +char *vtos( const vec3_t v ); + +float vectoyaw( const vec3_t vec ); + +void G_SetOrigin( gentity_t *ent, vec3_t origin ); +void AddRemap(const char *oldShader, const char *newShader, float timeOffset); +const char *BuildShaderStateConfig( void ); + +firemode_t WeaponModeNameToNum( str mode ); +const char *WeaponHandNumToName( weaponhand_t hand ); +weaponhand_t WeaponHandNameToNum( str side ); +void G_DebugTargets( Entity *e, const str &from ); +void G_DebugDamage( float damage, Entity *victim, Entity *attacker, Entity *inflictor ); +void G_DebugString( Vector pos, float scale, float r, float g, float b, const char *pszText, ... ); + +qboolean KillBox( Entity *ent ); + +void ChangeMusic( const char *current, const char *fallback, qboolean force ); +void ChangeMusicVolume( float volume, float fade_time ); +void RestoreMusicVolume( float fade_time ); +void ChangeSoundtrack( const char * soundtrack ); +void RestoreSoundtrack( void ); +int G_AIEventTypeFromString( const char *pszType ); +float G_AIEventRadius( int iType ); +void G_BroadcastAIEvent( Entity *originator, Vector origin, char *pszType ); +void G_BroadcastAIEvent( Entity *originator, Vector origin, int iType, float radius ); + +void CloneEntity( Entity * dest, Entity * src ); +void G_ArchiveEdict( Archiver &arc, gentity_t *edict ); + +const char *G_LocationNumToDispString( int iLocation ); +str G_WeaponClassNumToName( int num ); +int G_WeaponClassNameToNum( str name ); + +void G_MoveClientToIntermission( Entity *ent ); +void G_DisplayScores( Entity *ent ); +void G_HideScores( Entity *ent ); +void G_DisplayScoresToAllClients( void ); +void G_HideScoresToAllClients( void ); + +// +// caching commands +// +void G_ProcessCacheInitCommands( dtiki_t *tiki ); +void CacheResource( const char * stuff ); + +void G_SetTrajectory( gentity_t *ent, vec3_t org ); +void G_SetConstantLight ( + int * constantlight, + float * red, + float * green, + float * blue, + float * radius, + int * lightstyle = NULL +); + +// +// g_combat.c +// +qboolean CanDamage (gentity_t *targ, vec3_t origin); +void G_Damage (gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod); +qboolean G_RadiusDamage (vec3_t origin, gentity_t *attacker, float damage, float radius, gentity_t *ignore, int mod); +int G_InvulnerabilityEffect( gentity_t *targ, vec3_t dir, vec3_t point, vec3_t impactpoint, vec3_t bouncedir ); +void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ); +void TossClientItems( gentity_t *self ); +#ifdef MISSIONPACK +void TossClientPersistantPowerups( gentity_t *self ); +#endif +void TossClientCubes( gentity_t *self ); + +// damage flags +#define DAMAGE_RADIUS 0x00000001 // damage was indirect +#define DAMAGE_NO_ARMOR 0x00000002 // armour does not protect from this damage +#define DAMAGE_ENERGY 0x00000004 // damage is from an energy based weapon +#define DAMAGE_NO_KNOCKBACK 0x00000008 // do not affect velocity, just view angles +#define DAMAGE_BULLET 0x00000010 // damage is from a bullet (used for ricochets) +#define DAMAGE_NO_PROTECTION 0x00000020 // armor, shields, invulnerability, and godmode have no effect +#define DAMAGE_NO_SKILL 0x00000040 // damage is not affected by skill level + +// +// g_missile.c +// +void G_RunMissile( gentity_t *ent ); + +gentity_t *fire_blaster (gentity_t *self, vec3_t start, vec3_t aimdir); +gentity_t *fire_plasma (gentity_t *self, vec3_t start, vec3_t aimdir); +gentity_t *fire_grenade (gentity_t *self, vec3_t start, vec3_t aimdir); +gentity_t *fire_rocket (gentity_t *self, vec3_t start, vec3_t dir); +gentity_t *fire_bfg (gentity_t *self, vec3_t start, vec3_t dir); +gentity_t *fire_grapple (gentity_t *self, vec3_t start, vec3_t dir); +#ifdef MISSIONPACK +gentity_t *fire_nail( gentity_t *self, vec3_t start, vec3_t forward, vec3_t right, vec3_t up ); +gentity_t *fire_prox( gentity_t *self, vec3_t start, vec3_t aimdir ); +#endif + + +// +// g_mover.c +// +void G_RunMover( gentity_t *ent ); +void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace ); +void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator ); + +// +// g_trigger.c +// +void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace ); + + +// +// g_misc.c +// +void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ); +#ifdef MISSIONPACK +void DropPortalSource( gentity_t *ent ); +void DropPortalDestination( gentity_t *ent ); +#endif + + +// +// g_weapon.c +// +qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker ); +void SnapVectorTowards( vec3_t v, vec3_t to ); +qboolean CheckGauntletAttack( gentity_t *ent ); +void Weapon_HookFree (gentity_t *ent); +void Weapon_HookThink (gentity_t *ent); +void CalcMuzzlePoint( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint ); + +// +// g_client.c +// +gentity_t *G_Find( gentity_t *from, int fieldofs, const char *match ); +teamtype_t TeamCount( int ignoreClientNum, int team ); +int TeamLeader( int team ); +teamtype_t PickTeam( int ignoreClientNum ); +void SetClientViewAngle( gentity_t *ent, vec3_t angle ); +class PlayerStart *SelectSpawnPoint( Player *player ); +void CopyToBodyQue( gentity_t *ent ); +void respawn (gentity_t *ent); +void BeginIntermission (void); +void InitClientPersistant (gclient_t *client); +void InitClientResp (gclient_t *client); +void InitBodyQue (void); +void ClientSpawn( gentity_t *ent ); +void player_die (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod); +void AddScore( gentity_t *ent, vec3_t origin, int score ); +void CalculateRanks( void ); + +// +// g_svcmds.c +// +qboolean G_ConsoleCommand( void ); +void G_ProcessIPBans(void); +qboolean G_FilterPacket (char *from); + +// +// g_weapon.c +// +void FireWeapon( gentity_t *ent ); +#ifdef MISSIONPACK +void G_StartKamikaze( gentity_t *ent ); +#endif + +// +// p_hud.c +// +void MoveClientToIntermission (gentity_t *client); +void G_SetStats (gentity_t *ent); +void DeathmatchScoreboardMessage (gentity_t *client); + +// +// g_cmds.c +// + +// +// g_pweapon.c +// + + +// +// g_main.c +// +void FindIntermissionPoint( void ); +void SetLeader(int team, int client); +void CheckTeamLeader( int team ); +void G_RunThink (gentity_t *ent); +void QDECL G_LogPrintf( const char *fmt, ... ); +void SendScoreboardMessageToAllClients( void ); +void QDECL G_Printf( const char *fmt, ... ); +void QDECL G_Error( const char *fmt, ... ); +void QDECL G_Error( errorParm_t type, const char *fmt, ... ); + +// +// g_client.c +// +void G_BotConnect( int clientNum ); +char *G_ClientConnect( int clientNum, qboolean firstTime ); +void G_ClientUserinfoChanged( gentity_t *ent, const char *userinfo ); +void G_ClientDisconnect( gentity_t *ent ); +void G_ClientBegin( gentity_t *ent, usercmd_t *cmd ); +void G_ClientCommand( gentity_t *ent ); + +// +// g_active.c +// +void G_ClientThink( gentity_t *ent, usercmd_t *cmd, usereyes_t *eyeinfo ); +void ClientEndFrame( gentity_t *ent ); +void G_ClientEndServerFrames( void ); +void G_RunClient( gentity_t *ent ); + +// +// g_team.c +// +qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 ); +void Team_CheckDroppedItem( gentity_t *dropped ); +qboolean CheckObeliskAttack( gentity_t *obelisk, gentity_t *attacker ); + +// +// g_mem.c +// +void *G_Alloc( int size ); +void G_InitMemory( void ); +void Svcmd_GameMem_f( void ); + +// +// g_session.c +// +void G_ReadSessionData( gclient_t *client ); +void G_InitSessionData( gclient_t *client, char *userinfo ); + +void G_InitWorldSession( void ); +void G_WriteSessionData( void ); + +// +// g_arenas.c +// +void UpdateTournamentInfo( void ); +void SpawnModelsOnVictoryPads( void ); +void Svcmd_AbortPodium_f( void ); + +// +// g_bot.c +// +void G_BotBegin( gentity_t *ent ); +void G_BotThink( gentity_t *ent, int msec ); + +typedef struct mmove_s { + vec3_t origin; + vec3_t velocity; + + qboolean walking; + qboolean groundPlane; + vec3_t groundPlaneNormal; + + float frametime; + + float desired_speed; + int tracemask; + float desired_dir[ 2 ]; + + int entityNum; + + vec3_t mins; + vec3_t maxs; + + int numtouch; + int touchents[ MAXTOUCH ]; + + qboolean hit_obstacle; + vec3_t hit_origin; + int hit_temp_obstacle; + + vec3_t obstacle_normal; +} mmove_t; + +// g_mmove.cpp +void MmoveSingle( mmove_t *mmove ); + +// g_vmove.cpp +void VmoveSingle( struct vmove_s *mmove ); + +// ai_main.c +#define MAX_FILEPATH 144 + +//bot settings +typedef struct bot_settings_s +{ + char characterfile[MAX_FILEPATH]; + float skill; + char team[MAX_FILEPATH]; +} bot_settings_t; + +int BotAISetup( int restart ); +int BotAIShutdown(); +int BotAILoadMap( int restart ); +int BotAISetupClient(int client, struct bot_settings_s *settings, qboolean restart); +int BotAIShutdownClient( int client, qboolean restart ); +int BotAIStartFrame( int time ); +void BotTestAAS(vec3_t origin); + +extern gentity_t *g_entities; +#define FOFS(x) ((size_t)&(((gentity_t *)0)->x)) + +#ifdef __cplusplus +#include "const_str.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "archive.h" +#include "debuglines.h" +#endif + +#include "g_phys.h" + +#endif /* g_local.h */ diff --git a/code/game/g_main.cpp b/code/game/g_main.cpp new file mode 100644 index 00000000..d574a954 --- /dev/null +++ b/code/game/g_main.cpp @@ -0,0 +1,1643 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +#include "g_local.h" +#include "debuglines.h" +#include "entity.h" +#include "gamecmds.h" +#include "dm_manager.h" +#include "player.h" +#include +#include "lodthing.h" +#include "viewthing.h" +#include "playerbot.h" + +#ifdef WIN32 +#include +#endif + +#define SAVEGAME_VERSION 80 +#define PERSISTANT_VERSION 2 + +static char G_ErrorMessage[ 4096 ]; +profGame_t G_profStruct; + +qboolean LoadingSavegame = false; +qboolean LoadingServer = false; +Archiver *currentArc = NULL; + +gameExport_t globals; +gameImport_t gi; + +gentity_t active_edicts; +gentity_t free_edicts; + +int sv_numtraces = 0; +int sv_numpmtraces = 0; + +gentity_t *g_entities; +qboolean g_iInThinks = 0; +qboolean g_bBeforeThinks = qfalse; +static float g_fMsecPerClock = 0; + +usercmd_t *current_ucmd; +usereyes_t *current_eyeinfo; +Player *g_pPlayer; + +gclient_t g_clients[ MAX_CLIENTS ]; + +void ( *SV_Error )( int type, const char *fmt, ... ); +void *( *SV_Malloc )( int size ); +void ( *SV_Free )( void *ptr ); + +void QDECL G_Printf( const char *fmt, ... ) { + va_list argptr; + char text[1024]; + + va_start (argptr, fmt); + vsprintf (text, fmt, argptr); + va_end (argptr); + + gi.Printf( text ); +} + +void QDECL G_Error( const char *fmt, ... ) +{ + va_list argptr; + char text[ 1024 ]; + + va_start( argptr, fmt ); + vsprintf( text, fmt, argptr ); + va_end( argptr ); + + gi.Error( ERR_DROP, text ); +} + +void QDECL G_Error( int type, const char *fmt, ... ) +{ + va_list argptr; + char text[ 1024 ]; + + va_start( argptr, fmt ); + vsprintf( text, fmt, argptr ); + va_end( argptr ); + + // need to manually crash otherwise visual studio fuck up with the stack pointer... + *( int * )0 = 0; + + assert( 0 ); + SV_Error( type, text ); +} + +void* G_Malloc( int size ) +{ + return SV_Malloc( size ); +} + +void G_Free( void *ptr ) +{ + int zoneId = *( int * )( ( byte * )ptr - 4 ); + int size = ( int )( ( byte * )ptr - 16 ); + + assert( ptr ); + + if( zoneId == 0xC057 ) + return; + + assert( zoneId == 0x2015 ); + if( zoneId != 0x2015 ) + return; + + assert( *( unsigned int * )( *( unsigned int * )size + size - 4 ) == 0x2015 ); + if( *( unsigned int * )( *( unsigned int * )size + size - 4 ) != 0x2015 ) + return; + + SV_Free( ptr ); +} + +/* +=============== +G_ExitWithError + +Calls the server's error function with the last error that occurred. +Should only be called after an exception. +=============== +*/ +void G_ExitWithError( const char *error ) +{ + //ServerError( ERR_DROP, error ); + + Q_strncpyz( G_ErrorMessage, error, sizeof( G_ErrorMessage ) ); + + globals.errorMessage = G_ErrorMessage; +} + +void G_RemapTeamShaders( void ) { +#ifdef MISSIONPACK + char string[1024]; + float f = level.time * 0.001; + Com_sprintf( string, sizeof(string), "team_icon/%s_red", g_redteam.string ); + AddRemap("textures/ctf2/redteam01", string, f); + AddRemap("textures/ctf2/redteam02", string, f); + Com_sprintf( string, sizeof(string), "team_icon/%s_blue", g_blueteam.string ); + AddRemap("textures/ctf2/blueteam01", string, f); + AddRemap("textures/ctf2/blueteam02", string, f); + gi.SetConfigstring(CS_SHADERSTATE, BuildShaderStateConfig()); +#endif +} + +void G_SetFogInfo(int cull, float distance, vec3_t farplane_color) { + // cg.farplane_cull cg.farplane_distance cg.farplane_color[3] +// gi.SetConfigstring(CS_FOGINFO,va("%i %f %f %f %f",0,4096.f,1.f,1.f,1.f)); + + +} + +void G_AllocGameData( void ) +{ + int i; + + // de-allocate from previous level + G_DeAllocGameData(); + + // Initialize debug lines + G_AllocDebugLines(); + + // Initialize debug strings + G_AllocDebugStrings(); + + // initialize all entities for this game + game.maxentities = maxentities->integer; + + g_entities = ( gentity_t * )gi.Malloc( game.maxentities * sizeof( g_entities[ 0 ] ) ); + + // clear out the entities + memset( g_entities, 0, sizeof( g_entities ) ); + globals.gentities = g_entities; + globals.max_entities = game.maxentities; + + // Add all the edicts to the free list + LL_Reset( &free_edicts, next, prev ); + LL_Reset( &active_edicts, next, prev ); + + for( i = 0; i < game.maxentities; i++ ) + { + LL_Add( &free_edicts, &g_entities[ i ], next, prev ); + } + + // initialize all clients for this game + game.clients = ( gclient_t * )gi.Malloc( game.maxclients * sizeof( game.clients[ 0 ] ) ); + memset( game.clients, 0, game.maxclients * sizeof( game.clients[ 0 ] ) ); + + for( i = 0; i < game.maxclients; i++ ) + { + // set client fields on player ents + g_entities[ i ].client = game.clients + i; + + G_InitClientPersistant( &game.clients[ i ] ); + } + + globals.num_entities = game.maxclients; + + // Tell the server about our data + gi.LocateGameData( g_entities, globals.num_entities, sizeof( gentity_t ), &game.clients[ 0 ].ps, sizeof( game.clients[ 0 ] ) ); +} + +void G_DeAllocGameData( void ) +{ + // Initialize debug lines + G_DeAllocDebugLines(); + + // free up the entities + if( g_entities ) + { + gi.Free( g_entities ); + g_entities = NULL; + } + + // free up the clients + if( game.clients ) + { + gi.Free( game.clients ); + game.clients = NULL; + } +} + +/* +============ +G_InitGame + +============ +*/ +void G_InitGame( int levelTime, int randomSeed ) +{ + G_Printf( "------- Game Initialization -------\n" ); + G_Printf( "gamename: %s\n", GAMEVERSION ); + G_Printf( "gamedate: %s\n", __DATE__ ); + + srand( randomSeed ); + + CVAR_Init(); + + game.Vars()->ClearList(); + + // set some level globals + level.svsStartTime = levelTime; + level.reborn = sv_reborn->integer ? true : false; + if( level.reborn ) + { + gi.Cvar_Set( "protocol", "9" ); + } + + G_InitConsoleCommands(); + + Director.Reset(); + Actor::Init(); + PlayerBot::Init(); + + sv_numtraces = 0; + + if( developer->integer && !g_gametype->integer ) + { + Viewmodel.Init(); + LODModel.Init(); + } + + game.maxentities = maxentities->integer; + if( game.maxclients * 8 > maxentities->integer ) + { + game.maxentities = game.maxclients * 8; + } + + game.maxclients = maxclients->integer + maxbots->integer; + + L_InitEvents(); + + G_AllocGameData(); +} + +/* +============ +G_SpawnEntities + +============ +*/ +void G_SpawnEntities( char *entities, int svsTime ) +{ + level.SpawnEntities( entities, svsTime ); +} + +/* +================= +G_ShutdownGame +================= +*/ +void G_ShutdownGame() { + gi.Printf( "==== ShutdownGame ====\n" ); + + // write all the client session data so we can get it back + G_WriteSessionData(); + + level.CleanUp(); + + G_DeAllocDebugLines(); + +/* + if( g_entities ) + { + gi.Free( g_entities ); + g_entities = NULL; + } +*/ + + if( game.clients ) + { + gi.Free( game.clients ); + game.clients = NULL; + } +} + + + +//=================================================================== + +void QDECL Com_Error ( int level, const char *error, ... ) { + va_list argptr; + char text[1024]; + + va_start (argptr, error); + vsprintf (text, error, argptr); + va_end (argptr); + + G_Error( "%s", text); +} + +void QDECL Com_Printf( const char *msg, ... ) { + va_list argptr; + char text[1024]; + + va_start (argptr, msg); + vsprintf (text, msg, argptr); + va_end (argptr); + + G_Printf ("%s", text); +} + +/* +================ +G_Precache + +Calls precache scripts +================ +*/ +void G_Precache( void ) +{ + level.Precache(); +} + +/* +================ +G_Precache + +Called when server finished initializating +================ +*/ +void G_ServerSpawned( void ) +{ + level.ServerSpawned(); +} + +void G_CheckExitRules( void ) +{ + if( g_gametype->integer ) + { + if( level.intermissiontime == 0.0f ) + { + dmManager.CheckEndMatch(); + } + else + { + G_CheckIntermissionExit(); + } + } +} + +void G_CheckStartRules( void ) +{ + if( ( !dmManager.IsGameActive() ) && ( !dmManager.WaitingForPlayers() ) ) + { + dmManager.StartRound(); + } +} + +/* +================ +G_AddGEntity + + +================ +*/ +void G_AddGEntity( gentity_t *edict, qboolean showentnums ) +{ + unsigned long long start, end; + Entity *ent = edict->entity; + + if( g_timeents->integer ) + { + start = rdtsc(); + G_RunEntity( ent ); + end = rdtsc(); + + gi.DebugPrintf( "%d: <%s> '%s'(%d) : %d clocks, %.1f msec\n", + level.framenum, ent->getClassname(), ent->targetname.c_str(), end - start, g_fMsecPerClock ); + } + else + { + G_RunEntity( ent ); + } + + // remove the entity in case of invalid server flags + if( ( edict->r.svFlags & SVF_NOTSINGLECLIENT ) && ( edict->r.svFlags & SVF_CAPSULE ) ) + { + ent->PostEvent( EV_Remove, 0 ); + } + + if( showentnums ) + { + G_DrawDebugNumber( ent->origin, ent->entnum, 2.0f, 1.0f, 1.0f, 0.0f ); + } + + if( g_entinfo->integer && + ( g_pPlayer && + ( edict->r.lastNetTime >= level.inttime - 200 || ent->IsSubclassOfPlayer() ) ) ) + { + float fDist = ( g_pPlayer->centroid - g_pPlayer->EyePosition() ).length(); + + if( fDist != 0.0f ) + { + float fDot = _DotProduct( g_vEyeDir, ( g_pPlayer->centroid - g_pPlayer->EyePosition() ) ); + ent->ShowInfo( 0, fDist ); + } + } +} + +/* +================ +G_RunFrame + +Advances the non-player objects in the world +================ +*/ +void G_RunFrame( int levelTime, int frameTime ) +{ + gentity_t *edict; + int num; + qboolean showentnums; + unsigned long long start; + unsigned long long end; + int i; + static int processed[ MAX_GENTITIES ] = { 0 }; + static int processedFrameID = 0; + + try + { + // exit intermissions + if( level.exitintermission ) + { + if( level.nextmap != level.current_map ) + { + G_ExitLevel(); + } + else + { + G_RestartLevelWithDelay( 0.1f ); + level.nextmap = ""; + level.intermissiontime = 0; + level.exitintermission = qfalse; + } + + return; + } + + level.setFrametime( frameTime ); + level.setTime( levelTime ); + + if( level.intermissiontime || level.died_already ) + { + L_ProcessPendingEvents(); + + for( i = 0, edict = g_entities; i < game.maxclients; i++, edict++ ) + { + if( !edict->inuse || !edict->client || !edict->entity ) { + continue; + } + + edict->entity->CalcBlend(); + } + + if( g_gametype->integer && g_maxintermission->value != 0.0f ) + { + if( level.time - level.intermissiontime > g_maxintermission->value ) { + level.exitintermission = true; + } + } + + return; + } + + if( g_scripttrace->integer ) { + gi.DPrintf2( "====SERVER FRAME==========================================================================\n" ); + } + + g_bBeforeThinks = true; + Director.iPaused = -1; + + // Process most of the events before the physics are run + // so that we can affect the physics immediately + L_ProcessPendingEvents(); + + Director.iPaused = 1; + Director.SetTime( level.inttime ); + + // + // treat each object in turn + // + for( edict = active_edicts.next, num = 0; edict != &active_edicts; edict = edict->next, num++ ) + { + assert( edict ); + assert( edict->inuse ); + assert( edict->entity ); + + Actor *actor = ( Actor * )edict->entity; + if( actor->IsSubclassOfActor() ) + { + actor->m_bUpdateAnimDoneFlags = 0; + if( actor->m_bAnimating != 0 ) + actor->PreAnimate(); + } + } + + Director.iPaused--; + g_iInThinks++; + + if( !Director.iPaused ) + { + Director.ExecuteRunning(); + } + + g_iInThinks--; + + // Process any pending events that got posted during the script code + L_ProcessPendingEvents(); + + path_checksthisframe = 0; + + // Reset debug lines + G_InitDebugLines(); + G_InitDebugStrings(); + + PathManager.ShowNodes(); + + showentnums = ( sv_showentnums->integer && ( !g_gametype->integer || sv_cheats->integer ) ); + + g_iInThinks++; + processedFrameID++; + + if( g_entinfo->integer ) + { + g_pPlayer = ( Player * )G_GetEntity( 0 ); + + if( !g_pPlayer->IsSubclassOfPlayer() ) + { + g_pPlayer = NULL; + } + else + { + Vector vAngles = g_pPlayer->GetViewAngles(); + vAngles.AngleVectorsLeft( &g_vEyeDir ); + } + } + + if( g_timeents->integer ) + { + g_fMsecPerClock = 1.0f / gi.Cvar_Get( "CPS", "1", 0 )->value; + start = rdtsc(); + } + + for( edict = active_edicts.next; edict != &active_edicts; edict = edict->next ) + { + if( edict->entity->IsSubclassOfBot() ) + G_BotThink( edict, frameTime ); + } + + for( edict = active_edicts.next; edict != &active_edicts; edict = edict->next ) + { + num = edict->s.parent; + + if( num != ENTITYNUM_NONE ) + { + while( 1 ) + { + if( processed[ num ] == processedFrameID ) + break; + + processed[ num ] = processedFrameID; + G_AddGEntity( edict, showentnums ); + + if( edict->s.parent == ENTITYNUM_NONE ) + break; + } + } + + if( processed[ edict - g_entities ] != processedFrameID ) + { + processed[ edict - g_entities ] = processedFrameID; + G_AddGEntity( edict, showentnums ); + } + } + + if( g_timeents->integer ) + { + gi.Cvar_Set( "g_timeents", va( "%d", g_timeents->integer - 1 ) ); + end = rdtsc(); + + gi.DebugPrintf( "\n%i total: %d (%.1f)\n-----------------------\n", + level.framenum, end - start, ( float )( end - start ) * g_fMsecPerClock ); + } + + g_iInThinks--; + g_bBeforeThinks = qfalse; + + // Process any pending events that got posted during the physics code. + L_ProcessPendingEvents(); + level.DoEarthquakes(); + + // build the playerstate_t structures for all players + G_ClientEndServerFrames(); + + level.Unregister( STRING_POSTTHINK ); + + // Process any pending events that got posted during the script code + L_ProcessPendingEvents(); + + // show how many traces the game code is doing + if( sv_traceinfo->integer ) + { + if( sv_traceinfo->integer == 3 ) + { + if( sv_drawtrace->integer <= 1 ) + { + gi.DebugPrintf( "%0.2f : Total traces %3d\n", level.time, sv_numtraces ); + } + else + { + gi.DebugPrintf( "%0.2f : Total traces %3d pmove traces %3d\n", level.time, sv_numtraces, sv_numpmtraces ); + } + } + else + { + if( sv_drawtrace->integer <= 1 ) + { + gi.DebugPrintf( "%0.2f : Total traces %3d\n", level.time, sv_numtraces ); + } + else + { + gi.DebugPrintf( "%0.2f : Total traces %3d pmove traces %3d\n", level.time, sv_numtraces, sv_numpmtraces ); + } + } + } + + level.framenum++; + + // reset out count of the number of game traces + sv_numtraces = 0; + sv_numpmtraces = 0; + + G_ClientDrawBoundingBoxes(); + + G_UpdateMatchEndTime(); + G_CheckExitRules(); + G_CheckStartRules(); + + gi.SetConfigstring( CS_WARMUP, va( "%.0f", dmManager.GetMatchStartTime() ) ); + + if( g_gametype->integer ) { + level.CheckVote(); + } + + if( g_animdump->integer ) + { + for( edict = active_edicts.next; edict != &active_edicts; edict = edict->next ) + { + Animate *anim = ( Animate * )edict->entity; + + if( anim->IsSubclassOfAnimate() ) + { + anim->DumpAnimInfo(); + } + } + } + } + + catch( const char *error ) + { + G_ExitWithError( error ); + } +} + +/* +================= +G_ClientDrawBoundingBoxes +================= +*/ +void G_ClientDrawBoundingBoxes + ( + void + ) + +{ + gentity_t *edict; + Entity *ent; + Vector eye; + + // don't show bboxes during deathmatch + if( ( !sv_showbboxes->integer ) || ( g_gametype->integer && !sv_cheats->integer ) ) + { + return; + } + + if( sv_showbboxes->integer ) + { + edict = g_entities; + ent = edict->entity; + if( ent ) + { + eye = ent->origin; + ent = findradius( NULL, eye, 1000 ); + while( ent ) + { + ent->DrawBoundingBox( sv_showbboxes->integer ); + ent = findradius( ent, eye, 1000 ); + } + } + } +} + +void G_PrepFrame( void ) +{ + +} + +void G_RegisterSounds( void ) +{ + int startTime; + int endTime; + + Com_Printf( "\n\n-----------PARSING UBERSOUND (SERVER)------------\n" ); + Com_Printf( "Any SetCurrentTiki errors means that tiki wasn't prefetched and tiki-specific sounds for it won't work. To fix prefetch the tiki. Ignore if you don't use that tiki on this level.\n" ); + + startTime = gi.Milliseconds(); + G_Command_ProcessFile( "ubersound/ubersound.scr", qfalse ); + endTime = gi.Milliseconds(); + + Com_Printf( "Parse/Load time: %f seconds.\n", ( float )( endTime - startTime ) / 1000.0 ); + Com_Printf( "-------------UBERSOUND DONE (SERVER)---------------\n\n" ); + Com_Printf( "\n\n-----------PARSING UBERDIALOG (SERVER)------------\n" ); + Com_Printf( "Any SetCurrentTiki errors means that tiki wasn't prefetched and tiki-specific sounds for it won't work. To fix prefetch the tiki. Ignore if you don't use that tiki on this level.\n" ); + + startTime = gi.Milliseconds(); + G_Command_ProcessFile( "ubersound/uberdialog.scr", qfalse ); + endTime = gi.Milliseconds(); + + Com_Printf( "Parse/Load time: %f seconds.\n", ( float )( endTime - startTime ) / 1000.0 ); + Com_Printf( "-------------UBERDIALOG DONE (SERVER)---------------\n\n" ); +} + +void G_Restart( void ) +{ + G_InitWorldSession(); +} + +void G_SetFrameNumber( int framenum ) +{ + level.frame_skel_index = framenum; +} + +void G_SetMap( const char *mapname ) +{ + level.SetMap( mapname ); +} + +void G_SetTime( int svsStartTime, int svsTime ) +{ + if( level.svsStartTime != svsTime ) + { + gi.SetConfigstring( CS_LEVEL_START_TIME, va( "%i", svsTime ) ); + } + + level.svsStartTime = svsStartTime; + level.setTime( svsTime ); +} + +void G_SoundCallback( int entNum, soundChannel_t channelNumber, const char *name ) +{ + gentity_t *ent = &g_entities[ entNum ]; + Entity *entity = ent->entity; + + if( !entity ) + { + ScriptError( "ERROR: wait on playsound only works on entities that still exist when the sound is done playing." ); + } + + entity->CancelEventsOfType( EV_SoundDone ); + + Event *ev = new Event( EV_SoundDone ); + ev->AddInteger( channelNumber ); + ev->AddString( name ); + entity->PostEvent( ev, level.frametime ); +} + +qboolean G_AllowPaused( void ) +{ + return ( !level.exitintermission ) && ( level.intermissiontime == 0.0f ) && ( !level.died_already ); +} + +void G_ArchiveFloat( float *fl ) +{ + currentArc->ArchiveFloat( fl ); +} + +void G_ArchiveInteger( int *i ) +{ + currentArc->ArchiveInteger( i ); +} + +void G_ArchiveString( char *s ) +{ + if( currentArc->Loading() ) + { + str string; + currentArc->ArchiveString( &string ); + strcpy( s, string.c_str() ); + } + else + { + str string = s; + currentArc->ArchiveString( &string ); + } +} + +void G_ArchiveSvsTime( int *pi ) +{ + currentArc->ArchiveSvsTime( pi ); +} + +void G_ArchivePersistantData + ( + Archiver &arc + ) + +{ + gentity_t *ed; + int i; + + for( i = 0; i < game.maxclients; i++ ) + { + Entity *ent; + + ed = &g_entities[ i ]; + if( !ed->inuse || !ed->entity ) + continue; + + ent = ed->entity; + if( !ent->IsSubclassOfPlayer() ) + continue; + ( ( Player * )ent )->ArchivePersistantData( arc ); + } +} + +void G_ArchivePersistant( const char *name, qboolean loading ) +{ + int version; + Archiver arc; + + if( loading ) + { + if( !arc.Read( name, qfalse ) ) + { + return; + } + + arc.ArchiveInteger( &version ); + if( version < PERSISTANT_VERSION ) + { + gi.Printf( "Persistant data from an older version (%d) of MOHAA.\n", version ); + arc.Close(); + return; + } + else if( version > PERSISTANT_VERSION ) + { + gi.DPrintf( "Persistant data from newer version %d of MOHAA.\n", version ); + arc.Close(); + return; + } + } + else + { + arc.Create( name ); + + version = PERSISTANT_VERSION; + arc.ArchiveInteger( &version ); + } + + + arc.ArchiveObject( game.Vars() ); + G_ArchivePersistantData( arc ); + + arc.Close(); + return; +} + +qboolean G_ReadPersistant + ( + const char *name + ) + +{ + try + { + G_ArchivePersistant( name, qtrue ); + } + + catch( const char *error ) + { + G_ExitWithError( error ); + } + return qfalse; +} + +/* +============ +G_WritePersistant + +This will be called whenever the game goes to a new level, + +A single player death will automatically restore from the +last save position. +============ +*/ + +void G_WritePersistant + ( + const char *name + ) + +{ + try + { + G_ArchivePersistant( name, qfalse ); + } + + catch( const char *error ) + { + G_ExitWithError( error ); + } +} + + +/* +================= +LevelArchiveValid +================= +*/ +qboolean LevelArchiveValid + ( + Archiver &arc + ) + +{ + int version; + int savegame_version; + + // read the version number + arc.ArchiveInteger( &version ); + arc.ArchiveInteger( &savegame_version ); + + if( version < GAME_API_VERSION ) + { + gi.Printf( "Savegame from an older version (%d) of MOHAA.\n", version ); + return qfalse; + } + else if( version > GAME_API_VERSION ) + { + gi.Printf( "Savegame from version %d of MOHAA.\n", version ); + return qfalse; + } + + if( savegame_version < SAVEGAME_VERSION ) + { + gi.Printf( "Savegame from an older version (%d) of MoHAA.\n", version ); + return qfalse; + } + else if( savegame_version > SAVEGAME_VERSION ) + { + gi.Printf( "Savegame from version %d of MoHAA.\n", version ); + return qfalse; + } + return qtrue; +} + +void G_Cleanup( qboolean samemap ) +{ + gi.Printf( "==== CleanupGame ====\n" ); + + G_WriteSessionData(); + + level.CleanUp( samemap, qtrue ); +} + +void ArchiveAliases + ( + Archiver &arc + ) + +{ + int i; + byte another; + AliasList_t *alias_list; + AliasListNode_t *alias_node; + str alias_name; + str model_name; + const char *name; + dtikianim_t *modelanim; + Container< dtikianim_t * > animlist; + + if( arc.Saving() ) + { + for( i = 0; i < MAX_MODELS; i++ ) + { + name = gi.GetConfigstring( CS_MODELS + i ); + if( name && *name && *name != '*' ) + { + const char *p = name; + + while( p ) + { + name = p; + p = strchr( name, '|' ); + } + + modelanim = gi.modeltikianim( name ); + if( modelanim && !animlist.IndexOfObject( modelanim ) ) + { + animlist.AddObject( modelanim ); + + alias_list = ( AliasList_t * )modelanim->alias_list; + if( alias_list ) + { + alias_node = alias_list->data_list; + + if( alias_node ) + { + another = true; + arc.ArchiveByte( &another ); + + alias_name = name; + arc.ArchiveString( &alias_name ); + + for( ; alias_node != NULL; alias_node = alias_node->next ) + { + another = true; + arc.ArchiveByte( &another ); + + alias_name = alias_node->alias_name; + arc.ArchiveString( &alias_name ); + } + + another = false; + arc.ArchiveByte( &another ); + } + } + } + } + } + + another = false; + arc.ArchiveByte( &another ); + } + else + { + arc.ArchiveByte( &another ); + + while( another ) + { + arc.ArchiveString( &model_name ); + + modelanim = gi.modeltikianim( model_name.c_str() ); + + arc.ArchiveByte( &another ); + + while( another ) + { + // Read in aliases + + arc.ArchiveString( &alias_name ); + + gi.Alias_UpdateDialog( modelanim, alias_name.c_str() ); + + arc.ArchiveByte( &another ); + } + + arc.ArchiveByte( &another ); + } + } +} + + +/* +================= +G_ArchiveLevel + +================= +*/ +qboolean G_ArchiveLevel + ( + const char *filename, + qboolean autosave, + qboolean loading + ) + +{ + try + { + int i; + int num; + Archiver arc; + gentity_t *edict; + char szSaveName[ MAX_STRING_TOKENS ]; + char *pszSaveName; + cvar_t *cvar; + + COM_StripExtension( filename, szSaveName, sizeof( szSaveName ) ); + pszSaveName = COM_SkipPath( szSaveName ); + + gi.Cvar_Set( "g_lastsave", pszSaveName ); + + if( loading ) + { + LoadingSavegame = true; + + arc.Read( filename ); + if( !LevelArchiveValid( arc ) ) + { + arc.Close(); + return qfalse; + } + + // Read in the pending events. These are read in first in case + // later objects need to post events. + L_UnarchiveEvents( arc ); + } + else + { + int temp; + + arc.Create( filename ); + + // write out the version number + temp = GAME_API_VERSION; + arc.ArchiveInteger( &temp ); + temp = SAVEGAME_VERSION; + arc.ArchiveInteger( &temp ); + + // Write out the pending events. These are written first in case + // later objects need to post events when reading the archive. + L_ArchiveEvents( arc ); + } + + if( arc.Saving() ) + { + str s; + + num = 0; + for( cvar = gi.NextCvar( NULL ); cvar != NULL; cvar = gi.NextCvar( cvar ) ) + { + if( cvar->flags & CVAR_ROM ) { + num++; + } + } + + arc.ArchiveInteger( &num ); + for( cvar = gi.NextCvar( NULL ); cvar != NULL; cvar = gi.NextCvar( cvar ) ) + { + if( cvar->flags & CVAR_ROM ) + { + s = cvar->name; + arc.ArchiveString( &s ); + + s = cvar->string; + arc.ArchiveString( &s ); + + arc.ArchiveBoolean( &cvar->modified ); + arc.ArchiveInteger( &cvar->modificationCount ); + arc.ArchiveFloat( &cvar->value ); + arc.ArchiveInteger( &cvar->integer ); + } + } + } + else + { + str sName, sValue; + + arc.ArchiveInteger( &num ); + for( int i = 0; i < num; i++ ) + { + arc.ArchiveString( &sName ); + arc.ArchiveString( &sValue ); + + cvar = gi.cvar_set2( sName, sValue, qfalse ); + + arc.ArchiveBoolean( &cvar->modified ); + arc.ArchiveInteger( &cvar->modificationCount ); + arc.ArchiveFloat( &cvar->value ); + arc.ArchiveInteger( &cvar->integer ); + } + } + + // archive the game object + arc.ArchiveObject( &game ); + + // archive Level + arc.ArchiveObject( &level ); + + // archive camera paths + arc.ArchiveObject( &CameraMan ); + + // archive paths + arc.ArchiveObject( &PathManager ); + + // archive script controller + arc.ArchiveObject( &Director ); + + // archive lightstyles + arc.ArchiveObject( &lightStyles ); + + if( arc.Saving() ) + { + // count the entities + num = 0; + for( i = 0; i < globals.num_entities; i++ ) + { + edict = &g_entities[ i ]; + if( edict->inuse && edict->entity && !( edict->entity->flags & FL_DONTSAVE ) ) + { + num++; + } + } + } + + // archive all the entities + arc.ArchiveInteger( &globals.num_entities ); + arc.ArchiveInteger( &num ); + + if( arc.Saving() ) + { + // write out the world + arc.ArchiveObject( world ); + + for( i = 0; i < globals.num_entities; i++ ) + { + edict = &g_entities[ i ]; + if( !edict->inuse || !edict->entity || ( edict->entity->flags & FL_DONTSAVE ) ) + { + continue; + } + + arc.ArchiveObject( edict->entity ); + } + } + else + { + // Tell the server about our data + gi.LocateGameData( g_entities, globals.num_entities, sizeof( gentity_t ), &game.clients[ 0 ].ps, sizeof( game.clients[ 0 ] ) ); + + // read in the world + arc.ReadObject(); + + // FIXME: PathSearch::LoadNodes(); + //PathSearch::LoadNodes(); + + for( i = 0; i < num; i++ ) + { + arc.ReadObject(); + } + } + + ArchiveAliases( arc ); + + currentArc = &arc; + gi.ArchiveLevel( arc.Loading() ); + currentArc = NULL; + + // FIXME: PathSearch::ArchiveDynamic(); + //PathSearch::ArchiveDynamic(); + + arc.Close(); + + if( arc.Loading() ) + { + LoadingSavegame = false; + gi.Printf( HUD_MESSAGE_YELLOW "%s\n", gi.LV_ConvertString( "Game Loaded" ) ); + } + else + { + gi.Printf( HUD_MESSAGE_YELLOW "%s\n", gi.LV_ConvertString( "Game Saved" ) ); + } + + if( arc.Loading() ) + { + // Make sure all code that needs to setup the player after they have been loaded is run + + for( i = 0; i < game.maxclients; i++ ) + { + edict = &g_entities[ i ]; + + if( edict->inuse && edict->entity ) + { + Player *player = ( Player * )edict->entity; + player->Loaded(); + } + } + } + + return qtrue; + } + + catch( const char *error ) + { + G_ExitWithError( error ); + } + return qfalse; +} + +/* +================= +G_WriteLevel + +================= +*/ +void G_WriteLevel + ( + const char *filename, + qboolean autosave + ) + +{ + game.autosaved = autosave; + G_ArchiveLevel( filename, autosave, qfalse ); + game.autosaved = false; +} + +/* +================= +G_ReadLevel + +SpawnEntities will already have been called on the +level the same way it was when the level was saved. + +That is necessary to get the baselines set up identically. + +The server will have cleared all of the world links before +calling ReadLevel. + +No clients are connected yet. +================= +*/ +qboolean G_ReadLevel + ( + const char *filename + ) + +{ + qboolean status; + + status = G_ArchiveLevel( filename, qfalse, qtrue ); + // if the level load failed make sure that these variables are not set + if( !status ) + { + LoadingSavegame = false; + LoadingServer = false; + } + return status; +} + +/* +================= +G_LevelArchiveValid +================= +*/ +qboolean G_LevelArchiveValid + ( + const char *filename + ) + +{ + try + { + qboolean ret; + + Archiver arc; + + if( !arc.Read( filename ) ) + { + return qfalse; + } + + ret = LevelArchiveValid( arc ); + + arc.Close(); + + return ret; + } + + catch( const char *error ) + { + G_ExitWithError( error ); + return qfalse; + } +} + +/* +================ +GetGameAPI + +Gets game imports and returns game exports +================ +*/ +#ifndef WIN32 +extern "C" +__attribute__((visibility("default"))) +#endif +gameExport_t* GetGameAPI( gameImport_t *import ) +{ + gi = *import; + +#ifdef _DEBUG + SV_Error = gi.Error; + gi.Error = G_Error; + + //SV_Malloc = gi.Malloc; + ///gi.Malloc = G_Malloc; + + //SV_Free = gi.Free; + //gi.Free = G_Free; +#endif + + globals.apiversion = GAME_API_VERSION; + + globals.AllowPaused = G_AllowPaused; + globals.ArchiveFloat = G_ArchiveFloat; + globals.ArchiveInteger = G_ArchiveInteger; + globals.ArchivePersistant = G_ArchivePersistant; + globals.ArchiveString = G_ArchiveString; + globals.ArchiveSvsTime = G_ArchiveSvsTime; + + globals.BotBegin = G_BotBegin; + globals.BotThink = G_BotThink; + + globals.Cleanup = G_Cleanup; + + globals.ClientCommand = G_ClientCommand; + globals.ClientConnect = G_ClientConnect; + + globals.ClientBegin = G_ClientBegin; + globals.ClientThink = G_ClientThink; + + globals.ClientDisconnect = G_ClientDisconnect; + globals.ClientThink = G_ClientThink; + + globals.ClientUserinfoChanged = G_ClientUserinfoChanged; + + globals.ConsoleCommand = G_ConsoleCommand; + + globals.DebugCircle = G_DebugCircle; + globals.errorMessage = NULL; + + + globals.gentities = g_entities; + globals.gentitySize = sizeof( g_entities ); + + globals.Init = G_InitGame; + + globals.LevelArchiveValid = G_LevelArchiveValid; + globals.max_entities = sizeof( g_entities )/sizeof( g_entities[ 0 ] ); + globals.num_entities = 0; + + globals.Precache = G_Precache; + globals.SpawnEntities = G_SpawnEntities; + + + globals.PrepFrame = G_PrepFrame; + + globals.profStruct = &G_profStruct; + globals.ReadLevel = G_ReadLevel; + globals.WriteLevel = G_WriteLevel; + globals.RegisterSounds = G_RegisterSounds; + globals.Restart = G_Restart; + + + globals.RunFrame = G_RunFrame; + + + globals.ServerSpawned = G_ServerSpawned; + + + globals.SetFrameNumber = G_SetFrameNumber; + globals.SetMap = G_SetMap; + globals.SetTime = G_SetTime; + + globals.Shutdown = G_ShutdownGame; + + + globals.SoundCallback = G_SoundCallback; + globals.SpawnEntities = G_SpawnEntities; + globals.TIKI_Orientation = G_TIKI_Orientation; + + + return &globals; +} + +#ifndef WIN32 + +#include +#include + +struct sigaction origSignalActions[NSIG]; + +int backtrace(void **buffer, int size) {} +char **backtrace_symbols(void *const *buffer, int size) {} +void backtrace_symbols_fd(void *const *buffer, int size, int fd) {} + +void resetsighandlers( void ){ + sigaction( SIGSEGV, &origSignalActions[ SIGSEGV ], NULL ); + sigaction( SIGFPE, &origSignalActions[ SIGFPE ], NULL ); + sigaction( SIGILL, &origSignalActions[ SIGILL ], NULL ); + sigaction( SIGBUS, &origSignalActions[ SIGBUS ], NULL ); + sigaction( SIGABRT, &origSignalActions[ SIGABRT ], NULL ); + sigaction( SIGSYS, &origSignalActions[ SIGSYS ], NULL ); +} + +void sighandler( int sig, siginfo_t *info, void *secret ) { + + void *trace[ 100 ]; + char **messages = ( char ** )NULL; + int i, trace_size = 0; + //ucontext_t *uc = (ucontext_t *)secret; + + char * signame = strsignal( sig ); + + /* Do something useful with siginfo_t */ + if( sig == SIGSEGV ){ + printf( "Got signal %d - %s, faulty address is %p\n", sig, signame, info->si_addr ); + + if( gi.Printf != NULL ){ + gi.Printf( "Got signal %d - %s, faulty address is %p\n", sig, signame, info->si_addr ); + } + } + else { + if( gi.Printf != NULL ){ + gi.Printf( "Got signal %d - %s\n", sig, signame ); + } + else { + printf( "Got signal %d - %s\n", sig, signame ); + } + } + + trace_size = backtrace( trace, 100 ); + + /* overwrite sigaction with caller's address */ + //trace[1] = (void *) uc->uc_mcontext.gregs[REG_EIP]; + + messages = ( char** )( long )backtrace_symbols( trace, trace_size ); + + printf( "Execution path:\n" ); + + if( gi.Printf != NULL ){ + gi.Printf( "Execution path:\n" ); + } + + for( i = 1; i %s\n", messages[ i ] ); + + if( gi.Printf != NULL ){ + gi.Printf( " --> %s\n", messages[ i ] ); + } + } + + resetsighandlers(); // reset original MOHAA or default signal handlers, so no more signals are handled by this handler (a signal is considered to be a fatal program error, the original implementations should exit) + + raise( sig ); +} + +void initsighandlers( void ){ + /* Install our signal handlers */ + struct sigaction sa; + + *( unsigned int* )&sa.sa_sigaction = ( unsigned int )sighandler; + sigemptyset( &sa.sa_mask ); + sa.sa_flags = SA_RESTART | SA_SIGINFO; + + sigaction( SIGSEGV, &sa, &origSignalActions[ SIGSEGV ] ); + sigaction( SIGFPE, &sa, &origSignalActions[ SIGFPE ] ); + sigaction( SIGILL, &sa, &origSignalActions[ SIGILL ] ); + sigaction( SIGBUS, &sa, &origSignalActions[ SIGBUS ] ); + sigaction( SIGABRT, &sa, &origSignalActions[ SIGABRT ] ); + sigaction( SIGSYS, &sa, &origSignalActions[ SIGSYS ] ); +} + +void __attribute__((constructor)) load( void ) +{ + initsighandlers(); +} + +#endif diff --git a/code/game/g_main.h b/code/game/g_main.h new file mode 100644 index 00000000..1139baa3 --- /dev/null +++ b/code/game/g_main.h @@ -0,0 +1,54 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// g_main.h -- Global header file for g_main.cpp + +#ifndef __G_MAIN_H__ +#define __G_MAIN_H__ + +#include "g_local.h" +#include "gamecvars.h" + +extern qboolean LoadingSavegame; +extern qboolean LoadingServer; +extern gameImport_t gi; +extern gameExport_t globals; + +extern qboolean g_iInThinks; +extern qboolean g_bBeforeThinks; + +extern gentity_t active_edicts; +extern gentity_t free_edicts; + +extern int sv_numtraces; +extern int sv_numpmtraces; + +extern usercmd_t *current_ucmd; +extern usereyes_t *current_eyeinfo; +extern class Player *g_pPlayer; + +void G_ExitWithError( const char *error ); +void G_AllocGameData( void ); +void G_DeAllocGameData( void ); +void G_ClientDrawBoundingBoxes( void ); + +#endif /* g_main.h */ diff --git a/code/game/g_mem.cpp b/code/game/g_mem.cpp new file mode 100644 index 00000000..3de432d1 --- /dev/null +++ b/code/game/g_mem.cpp @@ -0,0 +1,58 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// +// g_mem.c +// + + +#include "g_local.h" + + +#define POOLSIZE (256 * 1024) + +static char memoryPool[POOLSIZE]; +static int allocPoint; + +void *G_Alloc( int size ) +{ + char *p; + + if ( allocPoint + size > POOLSIZE ) { + G_Error( "G_Alloc: failed on allocation of %i bytes\n", size ); + return NULL; + } + + p = &memoryPool[allocPoint]; + + allocPoint += ( size + 31 ) & ~31; + + return p; +} + +void G_InitMemory( void ) { + allocPoint = 0; +} + +void Svcmd_GameMem_f( void ) { + G_Printf( "Game memory status: %i out of %i bytes allocated\n", allocPoint, POOLSIZE ); +} diff --git a/code/game/g_mmove.cpp b/code/game/g_mmove.cpp new file mode 100644 index 00000000..a0306f2b --- /dev/null +++ b/code/game/g_mmove.cpp @@ -0,0 +1,625 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// g_mmove.cpp : AI/Path movement code. +// + +#include "g_local.h" +#include "entity.h" + +typedef struct { + qboolean validGroundTrace; + trace_t groundTrace; + float previous_origin[ 3 ]; + float previous_velocity[ 3 ]; +} mml_t; + +mmove_t *mm; +mml_t mml; + +void MM_ClipVelocity + ( + float *in, + float *normal, + float *out, + float overbounce + ) + +{ + float backoff; + float dir_z; + float normal2[ 3 ]; + + if( normal[ 2 ] >= 0.70f ) + { + if( in[ 0 ] == 0.0f && in[ 1 ] == 0.0f ) + { + VectorClear( out ); + return; + } + + normal2[ 0 ] = in[ 0 ] + DotProduct2D( in, normal ); + normal2[ 1 ] = in[ 1 ] + DotProduct2D( in, normal ); + normal2[ 2 ] = normal[ 2 ] * DotProduct2D( in, in ); + + VectorNormalize( normal2 ); + + dir_z = -normal2[ 2 ]; + + out[ 0 ] = in[ 0 ]; + out[ 1 ] = in[ 1 ]; + out[ 2 ] = DotProduct2D( in, normal2 ) / dir_z; + } + else + { + backoff = DotProduct( in, normal ); + + if( backoff < 0 ) + backoff *= overbounce; + else + backoff /= overbounce; + + out[ 0 ] = in[ 0 ] - normal[ 0 ] * backoff; + out[ 1 ] = in[ 1 ] - normal[ 1 ] * backoff; + out[ 2 ] = in[ 2 ] - normal[ 2 ] * backoff; + } +} + +qboolean MM_AddTouchEnt + ( + int entityNum + ) + +{ + int i; + qboolean blockEnt; + Entity *ent; + + if( entityNum == ENTITYNUM_NONE || entityNum == ENTITYNUM_WORLD ) { + return qtrue; + } + + ent = G_GetEntity( entityNum ); + + blockEnt = ent->BlocksAIMovement(); + + if( !blockEnt ) + { + if( ent->IsSubclassOfPlayer() ) + { + mm->hit_temp_obstacle |= 1; + } + else if( ent->IsSubclassOfDoor() ) + { + mm->hit_temp_obstacle |= 2; + } + } + + // see if it is already added + for( i = 0; i < mm->numtouch; i++ ) + { + if( mm->touchents[ i ] == entityNum ) + return blockEnt; + } + + // add it + mm->touchents[ mm->numtouch ] = entityNum; + mm->numtouch++; + + return blockEnt; +} + +qboolean MM_SlideMove + ( + qboolean gravity + ) + +{ + int bumpcount; + vec3_t dir; + float d; + int numplanes; + vec3_t planes[ 5 ]; + vec3_t clipVelocity; + int i; + int j; + int k; + trace_t trace; + vec3_t end; + float time_left; + qboolean bBlockEnt; + + if( gravity ) + { + mm->velocity[ 2 ] = mm->velocity[ 2 ] - mm->frametime * sv_gravity->integer; + if( mm->groundPlane ) + MM_ClipVelocity( mm->velocity, mm->groundPlaneNormal, mm->velocity, OVERCLIP ); + } + + time_left = mm->frametime; + + if( mm->groundPlane ) { + numplanes = 1; + VectorCopy( mm->groundPlaneNormal, planes[ 0 ] ); + } else { + numplanes = 0; + } + + // never turn against original velocity + VectorNormalize2( mm->velocity, planes[ numplanes ] ); + numplanes++; + + for( bumpcount = 0; bumpcount < 4; bumpcount++ ) + { + // calculate position we are trying to move to + VectorMA( mm->origin, time_left, mm->velocity, end ); + + // see if we can make it there + gi.Trace( &trace, mm->origin, mm->mins, mm->maxs, end, mm->entityNum, mm->tracemask, qtrue, qfalse ); + + if( trace.allsolid ) + break; + + if( trace.fraction > 0 ) { + // actually covered some distance + VectorCopy( trace.endpos, mm->origin ); + } + + if( trace.fraction == 1 ) + return bumpcount != 0; + + // save entity for contact + bBlockEnt = MM_AddTouchEnt( trace.entityNum ); + + if( trace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) + { + if( trace.plane.normal[ 2 ] > -0.999f && bBlockEnt && mm->groundPlane ) + { + if( !mm->hit_obstacle ) + { + mm->hit_obstacle = true; + VectorCopy( mm->origin, mm->hit_origin ); + } + + VectorAdd( mm->obstacle_normal, trace.plane.normal, mm->obstacle_normal ); + } + } + else + { + memcpy( &mml.groundTrace, &trace, sizeof( mml.groundTrace ) ); + mml.validGroundTrace = true; + } + + time_left -= time_left * trace.fraction; + + if( numplanes >= MAX_CLIP_PLANES ) + { + VectorClear( mm->velocity ); + return qtrue; + } + + // + // if this is the same plane we hit before, nudge velocity + // out along it, which fixes some epsilon issues with + // non-axial planes + // + for( i = 0; i < numplanes; i++ ) + { + if( DotProduct( trace.plane.normal, planes[ i ] ) > 0.99 ) + { + VectorAdd( trace.plane.normal, mm->velocity, mm->velocity ); + break; + } + } + + if( i >= numplanes ) + { + // + // modify velocity so it parallels all of the clip planes + // + + // find a plane that it enters + for( i = 0; i < numplanes; i++ ) + { + if( DotProduct( mm->velocity, planes[ i ] ) >= 0.1 ) { + continue; // move doesn't interact with the plane + } + + // slide along the plane + MM_ClipVelocity( mm->velocity, planes[ i ], clipVelocity, OVERCLIP ); + + // see if there is a second plane that the new move enters + for( j = 0; j < numplanes; j++ ) + { + if( j == i ) { + continue; + } + + // slide along the plane + MM_ClipVelocity( mm->velocity, planes[ j ], clipVelocity, OVERCLIP ); + + if( DotProduct( clipVelocity, planes[ j ] ) >= 0.0f ) { + continue; // move doesn't interact with the plane + } + + // slide the original velocity along the crease + CrossProduct( planes[ i ], planes[ j ], dir ); + VectorNormalize( dir ); + d = DotProduct( dir, mm->velocity ); + VectorScale( dir, d, clipVelocity ); + + // see if there is a third plane the the new move enters + for( k = 0; k < numplanes; k++ ) + { + if( k == i || k == j ) { + continue; + } + + if( DotProduct( clipVelocity, planes[ k ] ) >= 0.1f ) { + continue; // move doesn't interact with the plane + } + + // stop dead at a tripple plane interaction + VectorClear( mm->velocity ); + return qtrue; + } + } + + // if we have fixed all interactions, try another move + VectorCopy( clipVelocity, mm->velocity ); + break; + } + } + } + + if( mm->velocity[ 0 ] || mm->velocity[ 1 ] ) + { + if( mm->groundPlane ) + { + VectorCopy( mm->velocity, dir ); + VectorNegate( dir, dir ); + VectorNormalize( dir ); + + if( MM_AddTouchEnt( trace.entityNum ) ) + { + if( !mm->hit_obstacle ) + { + mm->hit_obstacle = true; + VectorCopy( mm->origin, mm->hit_origin ); + } + + VectorAdd( mm->obstacle_normal, dir, mm->obstacle_normal ); + } + } + + VectorClear( mm->velocity ); + return true; + } + + mm->velocity[ 2 ] = 0; + return false; +} + +void MM_GroundTraceInternal + ( + void + ) + +{ + if( mml.groundTrace.fraction == 1.0f ) + { + mm->groundPlane = qfalse; + mm->walking = qfalse; + return; + } + + if( mm->velocity[ 2 ] > 0.0f ) + { + if( DotProduct( mm->velocity, mml.groundTrace.plane.normal ) > 10.0f ) + { + mm->groundPlane = qfalse; + mm->walking = qfalse; + return; + } + } + + // slopes that are too steep will not be considered onground + if( mml.groundTrace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) + { + vec3_t oldvel; + float d; + + VectorCopy( mm->velocity, oldvel ); + VectorSet( mm->velocity, 0, 0, -1.0f / mm->frametime ); + MM_SlideMove( qfalse ); + + d = VectorLength( mm->velocity ); + VectorCopy( oldvel, mm->velocity ); + + if( d > ( 0.1f / mm->frametime ) ) + { + mm->groundPlane = qtrue; + mm->walking = qfalse; + VectorCopy( mml.groundTrace.plane.normal, mm->groundPlaneNormal ); + return; + } + } + + mm->groundPlane = qtrue; + mm->walking = qtrue; + VectorCopy( mml.groundTrace.plane.normal, mm->groundPlaneNormal ); + + MM_AddTouchEnt( mml.groundTrace.entityNum ); +} + +void MM_GroundTrace + ( + void + ) + +{ + float point[ 3 ]; + + point[ 0 ] = mm->origin[ 0 ]; + point[ 1 ] = mm->origin[ 1 ]; + point[ 2 ] = mm->origin[ 2 ] - 0.25f; + + gi.Trace( &mml.groundTrace, mm->origin, mm->mins, mm->maxs, point, mm->entityNum, mm->tracemask, qtrue, qfalse ); + MM_GroundTraceInternal(); +} + +void MM_StepSlideMove + ( + void + ) + +{ + vec3_t start_o; + vec3_t start_v; + vec3_t nostep_o; + vec3_t nostep_v; + trace_t trace; + qboolean bWasOnGoodGround; + vec3_t up; + vec3_t down; + qboolean start_hit_wall; + vec3_t start_wall_normal; + qboolean first_hit_wall; + vec3_t first_wall_normal; + vec3_t start_hit_origin; + vec3_t first_hit_origin; + trace_t nostep_groundTrace; + + VectorCopy( mm->origin, start_o ); + VectorCopy( mm->velocity, start_v ); + start_hit_wall = mm->hit_obstacle; + VectorCopy( mm->hit_origin, start_hit_origin ); + VectorCopy( mm->obstacle_normal, start_wall_normal ); + + if( MM_SlideMove( qtrue ) == 0 ) + { + if( !mml.validGroundTrace ) + MM_GroundTrace(); + + return; + } + + VectorCopy( start_o, down ); + down[ 2 ] -= STEPSIZE; + gi.Trace( &trace, start_o, mm->mins, mm->maxs, down, mm->entityNum, mm->tracemask, qtrue, qfalse ); + VectorSet( up, 0, 0, 1 ); + + // never step up when you still have up velocity + if( mm->velocity[ 2 ] > 0 && ( trace.fraction == 1.0f || + DotProduct( trace.plane.normal, up ) < MIN_WALK_NORMAL ) ) + { + if( !mml.validGroundTrace ) + MM_GroundTrace(); + else + MM_GroundTraceInternal(); + + return; + } + + if( mm->groundPlane && mm->groundPlaneNormal[ 2 ] >= MIN_WALK_NORMAL ) + bWasOnGoodGround = qtrue; + else + bWasOnGoodGround = qfalse; + + VectorCopy( mm->origin, nostep_o ); + VectorCopy( mm->velocity, nostep_v ); + memcpy( &nostep_groundTrace, &mml.groundTrace, sizeof( trace_t ) ); + + VectorCopy( start_o, mm->origin ); + VectorCopy( start_v, mm->velocity ); + + first_hit_wall = mm->hit_obstacle; + VectorCopy( mm->hit_origin, first_hit_origin ); + VectorCopy( mm->obstacle_normal, first_wall_normal ); + + mm->hit_obstacle = start_hit_wall; + VectorCopy( start_hit_origin, mm->hit_origin ); + VectorCopy( start_wall_normal, mm->obstacle_normal ); + MM_SlideMove( qtrue ); + + VectorCopy( mm->origin, down ); + down[ 2 ] -= STEPSIZE * 2; + + // test the player position if they were a stepheight higher + gi.Trace( &trace, up, mm->mins, mm->maxs, up, mm->entityNum, mm->tracemask, qtrue, qfalse ); + if( trace.entityNum > ENTITYNUM_NONE ) + { + VectorCopy( nostep_o, mm->origin ); + VectorCopy( nostep_v, mm->velocity ); + memcpy( &mml.groundTrace, &nostep_groundTrace, sizeof( mml.groundTrace ) ); + mm->hit_obstacle = first_hit_wall; + VectorCopy( first_hit_origin, mm->hit_origin ); + VectorCopy( first_wall_normal, mm->obstacle_normal ); + + if( !mml.validGroundTrace ) + MM_GroundTrace(); + else + MM_GroundTraceInternal(); + + return; + } + + if( !trace.allsolid ) + { + memcpy( &mml.groundTrace, &trace, sizeof( mml.groundTrace ) ); + mml.validGroundTrace = qtrue; + + if( bWasOnGoodGround && trace.fraction && trace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) + { + VectorCopy( nostep_o, mm->origin ); + VectorCopy( nostep_v, mm->velocity ); + + if( first_hit_wall ) + { + mm->hit_obstacle = first_hit_wall; + VectorCopy( first_hit_origin, mm->hit_origin ); + VectorCopy( first_wall_normal, mm->obstacle_normal ); + } + + MM_GroundTraceInternal(); + return; + } + + VectorCopy( trace.endpos, mm->origin ); + } + + if( trace.fraction < 1.0f ) + MM_ClipVelocity( mm->velocity, trace.plane.normal, mm->velocity, OVERCLIP ); + + if( !mml.validGroundTrace ) + MM_GroundTrace(); + else + MM_GroundTraceInternal(); +} + +void MM_ClipVelocity2D + ( + float *in, + float *normal, + float *out, + float overbounce + ) + +{ + float backoff; + float dir_z; + float normal2[ 3 ]; + + if( normal[ 2 ] >= 0.70f ) + { + if( in[ 0 ] == 0.0f && in[ 1 ] == 0.0f ) + { + VectorClear( out ); + return; + } + + normal2[ 0 ] = in[ 0 ] + DotProduct2D( in, normal ); + normal2[ 1 ] = in[ 1 ] + DotProduct2D( in, normal ); + normal2[ 2 ] = normal[ 2 ] * DotProduct2D( in, in ); + + VectorNormalize( normal2 ); + + dir_z = -normal2[ 2 ]; + + out[ 0 ] = in[ 0 ]; + out[ 1 ] = in[ 1 ]; + out[ 2 ] = DotProduct2D( in, normal2 ) / -normal2[ 2 ]; + } + else + { + backoff = DotProduct2D( in, normal ); + + if( backoff < 0 ) + backoff *= overbounce; + else + backoff /= overbounce; + + out[ 0 ] = in[ 0 ] - normal[ 0 ] * backoff; + out[ 1 ] = in[ 1 ] - normal[ 1 ] * backoff; + out[ 2 ] = -( backoff * normal[ 2 ] ); + } +} + +void MmoveSingle + ( + mmove_t *mmove + ) + +{ + float point[ 3 ]; + trace_t trace; + + mm = mmove; + + mmove->hit_obstacle = false; + mmove->numtouch = false; + VectorCopy( vec_origin, mmove->obstacle_normal ); + mmove->hit_temp_obstacle = false; + + memset( &mml, 0, sizeof( mml_t ) ); + + VectorCopy( mmove->origin, mml.previous_origin ); + VectorCopy( mmove->velocity, mml.previous_velocity ); + + if( mmove->walking ) + { + if( mmove->desired_speed < 1.0f ) + { + MM_GroundTrace(); + return; + } + + float wishdir[ 3 ]; + + MM_ClipVelocity2D( mm->desired_dir, mm->groundPlaneNormal, wishdir, OVERCLIP ); + VectorNormalize( wishdir ); + + mm->velocity[ 0 ] = mm->desired_speed * wishdir[ 0 ]; + mm->velocity[ 1 ] = mm->desired_speed * wishdir[ 1 ]; + } + else if( mmove->groundPlane ) + { + MM_ClipVelocity( mmove->velocity, mmove->groundPlaneNormal, mmove->velocity, OVERCLIP ); + } + + MM_StepSlideMove(); + + if( !mm->walking && mml.previous_velocity[ 2 ] >= 0.0f && mm->velocity[ 2 ] <= 0.0f ) + { + point[ 0 ] = mmove->origin[ 0 ]; + point[ 1 ] = mmove->origin[ 1 ]; + point[ 2 ] = mmove->origin[ 2 ] - 18.0f; + + gi.Trace( &trace, mm->origin, mm->mins, mm->maxs, point, mm->entityNum, mm->tracemask, qtrue, qfalse ); + + if( trace.fraction < 1.0f && !trace.allsolid ) + { + MM_GroundTrace(); + return; + } + } +} diff --git a/code/game/g_phys.cpp b/code/game/g_phys.cpp new file mode 100644 index 00000000..0126cf76 --- /dev/null +++ b/code/game/g_phys.cpp @@ -0,0 +1,1664 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// g_phys.cpp +// + +#include "g_local.h" +#include "animate.h" +#include "sentient.h" +#include "actor.h" +#include "player.h" + +/* + + +pushmove objects do not obey gravity, and do not interact with each other or trigger fields, but block normal movement and push normal objects when they move. + +onground is set for toss objects when they come to a complete rest. it is set for steping or walking objects + +doors, plats, etc are SOLID_BSP, and MOVETYPE_PUSH +bonus items are SOLID_TRIGGER touch, and MOVETYPE_TOSS +corpses are SOLID_NOT and MOVETYPE_TOSS +crates are SOLID_BBOX and MOVETYPE_TOSS +walking monsters are SOLID_SLIDEBOX and MOVETYPE_STEP +flying/floating monsters are SOLID_SLIDEBOX and MOVETYPE_FLY + +solid_edge items only clip against bsp models. + +*/ + +pushed_t pushed[ MAX_GENTITIES ]; +pushed_t *pushed_p; + +Entity *obstacle; + +/* +============ +G_FixEntityPosition + +============ +*/ +Entity *G_FixEntityPosition + ( + Entity *ent + ) + +{ + int mask; + trace_t trace; + Vector start; + float radius; + + if( ent->size.x > ent->size.z ) + { + radius = ent->size.z * 0.5f; + } + else + { + radius = ent->size.x * 0.5f; + } + + mask = ent->edict->clipmask; + if( !mask ) + { + mask = MASK_SOLID; + } + + start = ent->origin; + start.z += radius; + if( ent->IsSubclassOfPlayer() ) + { + trace = G_Trace( start, ent->mins, ent->maxs, ent->origin, ent, mask, true, "G_FixEntityPosition1" ); + } + else + { + trace = G_Trace( start, ent->mins, ent->maxs, ent->origin, ent, mask, false, "G_FixEntityPosition2" ); + } + + if( trace.startsolid ) + { + //return g_entities->entity; + assert( trace.ent ); + assert( trace.ent->entity ); + return trace.ent->entity; + } + + ent->setOrigin( trace.endpos ); + + return NULL; +} + + +/* +============ +G_TestEntityPosition + +============ +*/ +Entity *G_TestEntityPosition + ( + Entity *ent + ) + +{ + int mask; + trace_t trace; + + mask = ent->edict->clipmask; + if( !mask ) + mask = MASK_SOLID; + + if( ent->IsSubclassOfPlayer() ) + { + trace = G_Trace( ent->origin, ent->mins, ent->maxs, ent->origin, ent, mask, true, "G_TestEntityPosition1" ); + } + else + { + trace = G_Trace( ent->origin, ent->mins, ent->maxs, ent->origin, ent, mask, false, "G_TestEntityPosition2" ); + } + + if( trace.startsolid ) + { + //return g_entities->entity; + assert( trace.ent ); + assert( trace.ent->entity ); + return trace.ent->entity; + } + + return NULL; +} + + +/* +================ +G_CheckVelocity +================ +*/ +void G_CheckVelocity + ( + Entity *ent + ) + + { + int i; + + // + // bound velocity + // + for( i = 0; i < 3; i++ ) + { + if ( ent->velocity[ i ] > sv_maxvelocity->value ) + { + ent->velocity[ i ] = sv_maxvelocity->value; + } + else if ( ent->velocity[ i ] < -sv_maxvelocity->value ) + { + ent->velocity[ i ] = -sv_maxvelocity->value; + } + } + } + +/* +================== +G_Impact + +Two entities have touched, so run their touch functions +================== +*/ +void G_Impact + ( + Entity *e1, + trace_t *trace + ) + +{ + gentity_t *e2; + Event *ev; + SafePtr< Entity > safe1; + SafePtr< Entity > safe2; + + e2 = trace->ent; + + safe1 = e1; + safe2 = e2->entity; + + level.impact_trace = *trace; + + // touch anything, including the world + if( e1->edict->solid != SOLID_NOT ) + { + ev = new Event( EV_Touch ); + ev->AddEntity( e2->entity ); + e1->ProcessEvent( ev ); + + if( safe1 ) { + safe1->Unregister( "touch" ); + } + } + + // entity could have been removed, so check if he's in use before sending the event + if( + e2->entity && + ( e2->solid != SOLID_NOT ) && + ( !( e2->r.contents & CONTENTS_SHOOTONLY ) ) && + ( e2->entity != world ) + ) + { + ev = new Event( EV_Touch ); + ev->AddEntity( e1 ); + e2->entity->ProcessEvent( ev ); + + if( safe2 ) { + safe2->Unregister( "touch" ); + } + } + + memset( &level.impact_trace, 0, sizeof( level.impact_trace ) ); +} + +/* +============ +G_TestEntityPosition + +============ +*/ +Entity *G_TestEntityPosition + ( + Entity *ent, + Vector vOrg + ) + +{ + int mask; + trace_t trace; + + mask = ent->edict->clipmask; + if( !mask ) + mask = MASK_SOLID; + + if( ent->IsSubclassOfPlayer() ) + { + trace = G_Trace( vOrg, ent->mins, ent->maxs, vOrg, ent, mask, true, "G_TestEntityPosition1" ); + } + else + { + trace = G_Trace( vOrg, ent->mins, ent->maxs, vOrg, ent, mask, false, "G_TestEntityPosition2" ); + } + + if( trace.startsolid ) + { + assert( trace.ent ); + assert( trace.ent->entity ); + return trace.ent->entity; + } + + return NULL; +} + +/* +================== +G_ClipVelocity + +Slide off of the impacting object +returns the blocked flags (1 = floor, 2 = step / wall) +================== +*/ +#define STOP_EPSILON 0.1 + +int G_ClipVelocity + ( + Vector& in, + Vector& normal, + Vector& out, + float overbounce + ) + + { + int i; + int blocked; + float backoff; + + blocked = 0; + + if ( normal[ 2 ] > 0 ) + { + // floor + blocked |= 1; + } + if ( !normal[ 2 ] ) + { + // step + blocked |= 2; + } + + backoff = ( in * normal ) * overbounce; + + out = in - normal * backoff; + for( i = 0; i < 3; i++ ) + { + if ( out[ i ] > -STOP_EPSILON && out[ i ] < STOP_EPSILON ) + { + out[ i ] = 0; + } + } + + return blocked; + } + + +/* +============ +G_FlyMove + +The basic solid body movement clip that slides along multiple planes +Returns the clipflags if the velocity was modified (hit something solid) +1 = floor +2 = wall / step +4 = dead stop +============ +*/ +#define MAX_CLIP_PLANES 5 + +int G_FlyMove + ( + Entity *ent, + Vector basevel, + float time, + int mask + ) + +{ + Entity *hit; + gentity_t *edict; + int bumpcount, numbumps; + Vector dir; + float d; + int numplanes; + vec3_t planes[ MAX_CLIP_PLANES ]; + Vector primal_velocity, original_velocity, new_velocity; + int i, j; + trace_t trace; + Vector end; + float time_left; + int blocked; +#if 0 + Vector move; + Vector v; +#endif + + edict = ent->edict; + + numbumps = 4; + + blocked = 0; + original_velocity = ent->velocity; + primal_velocity = ent->velocity; + numplanes = 0; + +#if 1 + time_left = time; +#else + time_left = 1.0;//time; + + v = ent->total_delta; + v[ 1 ] = -v[ 1 ]; // sigh... + MatrixTransformVector( v, ent->orientation, move ); + move += ent->velocity * time; + ent->total_delta = vec_zero; +#endif + + ent->groundentity = NULL; + for( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) + { +#if 1 + end = ent->origin + time_left * ( ent->velocity + basevel ); +#else + end = ent->origin + time_left * move; +#endif + + trace = G_Trace( ent->origin, ent->mins, ent->maxs, end, ent, mask, false, "G_FlyMove" ); + + if( + ( trace.allsolid ) || + ( + ( trace.startsolid ) && + ( ent->movetype == MOVETYPE_VEHICLE ) + ) + ) + { + // entity is trapped in another solid + ent->velocity = vec_zero; + return 3; + } + + if( trace.fraction > 0 ) + { + // actually covered some distance + ent->setOrigin( trace.endpos ); + original_velocity = ent->velocity; + numplanes = 0; + } + + if( trace.fraction == 1 ) + { + // moved the entire distance + break; + } + + assert( trace.ent ); + hit = trace.ent->entity; + + if( trace.plane.normal[ 2 ] > 0.7 ) + { + // floor + blocked |= 1; + if( hit->getSolidType() == SOLID_BSP ) + { + ent->groundentity = hit->edict; + ent->groundplane = trace.plane; + ent->groundcontents = trace.contents; + } + } + + if( !trace.plane.normal[ 2 ] ) + { + // step + blocked |= 2; + } + + // + // run the impact function + // + G_Impact( ent, &trace ); + if( !edict->inuse ) + { + break; // removed by the impact function + } + + time_left -= time_left * trace.fraction; + + // cliped to another plane + if( numplanes >= MAX_CLIP_PLANES ) + { + // this shouldn't really happen + ent->velocity = vec_zero; + return 3; + } + + VectorCopy( trace.plane.normal, planes[ numplanes ] ); + numplanes++; + + // + // modify original_velocity so it parallels all of the clip planes + // + for( i = 0; i < numplanes; i++ ) + { + Vector normal = planes[ i ]; + + G_ClipVelocity( original_velocity, normal, new_velocity, 1.01f ); + for( j = 0; j < numplanes; j++ ) + { + if( j != i ) + { + if( ( new_velocity * planes[ j ] ) < 0 ) + { + // not ok + break; + } + } + } + + if( j == numplanes ) + { + break; + } + } + + if( i != numplanes ) + { + // go along this plane + ent->velocity = new_velocity; + } + else + { + // go along the crease + if( numplanes != 2 ) + { + ent->velocity = vec_zero; + return 7; + } + CrossProduct( planes[ 0 ], planes[ 1 ], dir ); + d = dir * ent->velocity; + ent->velocity = dir * d; + } + + // + // if original velocity is against the original velocity, stop dead + // to avoid tiny occilations in sloping corners + // + if( ( ent->velocity * primal_velocity ) <= 0 ) + { + ent->velocity = vec_zero; + return blocked; + } + } + + return blocked; +} + + +/* +============ +G_AddGravity + +============ +*/ +void G_AddGravity + ( + Entity *ent + ) + + { + float grav; + + if ( ent->waterlevel > 2 ) + { + grav = ent->gravity * 60 * level.frametime; + } + else + { + grav = ent->gravity * sv_gravity->value * level.frametime; + } + + ent->velocity[ 2 ] -= grav; + } + +/* +=============================================================================== + +PUSHMOVE + +=============================================================================== +*/ + +/* +============ +G_PushEntity + +Does not change the entities velocity at all +============ +*/ +trace_t G_PushEntity + ( + Entity *ent, + Vector push + ) + +{ + trace_t trace; + Vector start; + Vector end; + int mask; + gentity_t *edict; + + start = ent->origin; + end = start + push; + +retry: + if( ent->edict->clipmask ) + { + mask = ent->edict->clipmask; + } + else + { + mask = MASK_SOLID; + } + + trace = G_Trace( start, ent->mins, ent->maxs, end, ent, mask, false, "G_PushEntity" ); + + edict = ent->edict; + + ent->setOrigin( trace.endpos ); + + if( trace.fraction != 1.0 ) + { + G_Impact( ent, &trace ); + + // if the pushed entity went away and the pusher is still there + if( ( !trace.ent || !trace.ent->inuse ) && edict->inuse ) + { + // move the pusher back and try again + ent->setOrigin( start ); + goto retry; + } + } + + if( edict && ( edict != ent->edict ) ) + { + if( ent->flags & FL_TOUCH_TRIGGERS ) + { + G_TouchTriggers( ent ); + } + } + + return trace; +} + +/* +============ +G_SlideEntity +============ +*/ +trace_t G_SlideEntity + ( + Entity *ent, + Vector push + ) + + { + trace_t trace; + Vector start; + Vector end; + int mask; + + start = ent->origin; + end = start + push; + + if ( ent->edict->clipmask ) + { + mask = ent->edict->clipmask; + } + else + { + mask = MASK_SOLID; + } + + trace = G_Trace( start, ent->mins, ent->maxs, end, ent, mask, false, "G_SlideEntity" ); + + ent->setOrigin( trace.endpos ); + + return trace; + } + + +/* +================ +G_SnapPosition + +================ +*/ +/* +qboolean G_SnapPosition + ( + Entity *ent + ) + + { + int x, y, z; + Vector offset( 0, -1, 1 ); + Vector base; + + base = ent->origin; + for ( z = 0; z < 3; z++ ) + { + ent->origin.z = base.z + offset[ z ]; + for ( y = 0; y < 3; y++ ) + { + ent->origin.y = base.y + offset[ y ]; + for ( x = 0; x < 3; x++ ) + { + ent->origin.x = base.x + offset[ x ]; + if ( G_TestEntityPosition( ent ) ) + { + ent->origin.x += offset[ x ]; + ent->origin.y += offset[ y ]; + ent->origin.z += offset[ z ]; + ent->setOrigin( ent->origin ); + return true; + } + } + } + } + + // can't find a good position, so put him back. + ent->origin = base; + + return false; + } +*/ + +/* +============ +G_Push + +Objects need to be moved back on a failed push, +otherwise riders would continue to slide. +============ +*/ +qboolean G_Push + ( + Entity *pusher, + Vector pushermove, + Vector pusheramove + ) + + { + Entity *check, *block; + gentity_t *edict; + Vector move, amove; + Vector mins, maxs; + Vector save; + pushed_t *p; + Vector org, org2, move2; + Vector norm; + float mat[ 3 ][ 3 ]; + pushed_t *pusher_p; + float radius; + int i, num; + int touch[ MAX_GENTITIES ]; + Event *ev; + + // save the pusher's original position + pusher_p = pushed_p; + pushed_p->ent = pusher; + pushed_p->localorigin = pusher->localorigin; + pushed_p->origin = pusher->origin; + pushed_p->localangles = pusher->localangles; + pushed_p->angles = pusher->angles; + + if( pusher->client ) + { + pushed_p->deltayaw = pusher->client->ps.delta_angles[ YAW ]; + } + + pushed_p++; + + if( pushed_p >= &pushed[ MAX_GENTITIES ] ) + { + gi.Error( ERR_FATAL, "Pushed too many entities." ); + } + + if( pusher->IsSubclassOfPlayer() ) + { + pusher->setAngles(); + pusher->setOrigin(); + } + else + { + // move the pusher to it's final position + pusher->addAngles( pusheramove ); + pusher->addOrigin( pushermove ); + } + + + if( pusher->edict->solid == SOLID_NOT ) + { + // Doesn't push anything + return true; + } + + // change the move to worldspace + move = pusher->origin - pusher_p->origin; + amove = pusher->angles - pusher_p->angles; + + // we need this for pushing things later + AnglesToAxis( amove, mat ); + + // find the bounding box + mins = pusher->absmin; + maxs = pusher->absmax; + + // Add in entities that are within the pusher + + num = gi.AreaEntities( mins, maxs, touch, MAX_GENTITIES ); + + for( i = 0; i < num; i++ ) + { + edict = &g_entities[ touch[ i ] ]; + assert( edict ); + assert( edict->inuse ); + assert( edict->entity ); + check = edict->entity; + + if( ( check->movetype == MOVETYPE_PUSH ) || + ( check->movetype == MOVETYPE_STOP ) || + ( check->movetype == MOVETYPE_NONE ) || + ( check->movetype == MOVETYPE_NOCLIP ) ) + { + continue; + } + + if( check->edict->r.contents == CONTENTS_SHOOTONLY ) + continue; + + // if the entity is standing on the pusher, it will definitely be moved + if( check->groundentity != pusher->edict ) + { + // Only move triggers and non-solid objects if they're sitting on a moving object + if( ( check->edict->solid == SOLID_TRIGGER ) || ( check->edict->solid == SOLID_NOT ) ) + { + continue; + } + + // see if the ent needs to be tested + if( ( check->absmin[ 0 ] >= maxs[ 0 ] ) || + ( check->absmin[ 1 ] >= maxs[ 1 ] ) || + ( check->absmin[ 2 ] >= maxs[ 2 ] ) || + ( check->absmax[ 0 ] <= mins[ 0 ] ) || + ( check->absmax[ 1 ] <= mins[ 1 ] ) || + ( check->absmax[ 2 ] <= mins[ 2 ] ) ) + { + continue; + } + + // see if the ent's bbox is inside the pusher's final position + if( !G_TestEntityPosition( check, check->origin ) ) + { + continue; + } + + ev = new Event( EV_Touch ); + ev->AddEntity( pusher ); + check->ProcessEvent( ev ); + + ev = new Event( EV_Touch ); + ev->AddEntity( check ); + pusher->ProcessEvent( ev ); + } + + pushed_p->localorigin = check->localorigin; + pushed_p->localangles = check->localangles; + // move this entity + pushed_p->ent = check; + pushed_p->origin = check->origin; + pushed_p->angles = check->angles; + pushed_p++; + + if( pushed_p >= &pushed[ MAX_GENTITIES ] ) + { + gi.Error( ERR_FATAL, "Pushed too many entities." ); + } + + // save off the origin + save = check->localorigin; + + // try moving the contacted entity + move2 = move; + + // FIXME: doesn't rotate monsters? + /*if( check->client && amove[ YAW ] ) + { + Sentient *sent = ( Sentient * )check; + Vector a = sent->GetViewAngles() + Vector( 0, amove[ YAW ], 0 ); + sent->SetViewAngles( a ); + }*/ + + // get the radius of the entity + if( check->size.x > check->size.z ) + { + radius = check->size.z * 0.5f; + } + else + { + radius = check->size.x * 0.5f; + } + + // figure movement due to the pusher's amove + org = check->origin - pusher->origin; + org.z += radius; + + MatrixTransformVector( org, mat, org2 ); + + move2 += org2 - org; + + // L: This one seems to be better + if( G_TestEntityPosition( check, check->origin ) ) + { + trace_t trace; + + if( check->IsSubclassOfPlayer() ) + { + trace = G_Trace( check->origin, check->mins, check->maxs, pusher->origin, check, check->edict->clipmask, true, "G_Push" ); + } + else + { + trace = G_Trace( check->origin, check->mins, check->maxs, pusher->origin, check, check->edict->clipmask, false, "G_Push" ); + } + + move2 = trace.endpos - check->origin; + } + + /*if( G_TestEntityPosition( check, check->origin ) ) + { + trace_t trace; + Vector end; + Vector fwd; + float length; + + length = VectorNormalize2( move2, fwd ); + + end = check->origin + fwd * ( length + 64.0f ); + + if( check->IsSubclassOfPlayer() ) + { + trace = G_Trace( check->origin, check->mins, check->maxs, end, check, check->edict->clipmask, true, "G_Push" ); + } + else + { + trace = G_Trace( check->origin, check->mins, check->maxs, end, check, check->edict->clipmask, false, "G_Push" ); + } + + if( !trace.allsolid ) + { + if( check->IsSubclassOfPlayer() ) + { + trace = G_Trace( Vector( trace.endpos ), check->mins, check->maxs, move2 + check->origin, check, check->edict->clipmask, true, "G_Push" ); + } + else + { + trace = G_Trace( Vector( trace.endpos ), check->mins, check->maxs, move2 + check->origin, check, check->edict->clipmask, false, "G_Push" ); + } + + move2 = trace.endpos - check->origin; + } + }*/ + + check->addOrigin( check->getParentVector( move2 ) ); + + // may have pushed them off an edge + if( check->groundentity ) + { + if( check->groundentity != pusher->edict ) + check->groundentity = NULL; + } + + block = G_TestEntityPosition( check, check->origin ); + if( block ) + { + block = G_FixEntityPosition( check ); + } + if( !block ) + { + // pushed ok + check->link(); + + // impact? + continue; + } + + // try to snap it to a good position + /* + if ( G_SnapPosition( check ) ) + { + // snapped ok. we don't have to link since G_SnapPosition does it for us. + continue; + } + */ + + // if it is ok to leave in the old position, do it + // this is only relevent for riding entities, not pushed + check->setLocalOrigin( save ); + block = G_TestEntityPosition( check, check->origin ); + if( !block ) + { + pushed_p--; + continue; + } + + if( check->edict->solid == SOLID_NOT ) + continue; + + // L: don't make the pusher teleport through anything that block + if( block != pusher ) + { + pusher_p->ent->setOrigin( pusher_p->origin ); + continue; + } + + // save off the obstacle so we can call the block function + obstacle = check; + + // move back any entities we already moved + // go backwards, so if the same entity was pushed + // twice, it goes back to the original position + for( p = pushed_p - 1; p >= pushed; p-- ) + { + p->ent->angles = p->angles; + p->ent->origin = p->origin; + + p->ent->localangles = p->localangles; + p->ent->localorigin = p->localorigin; + + if( p->ent->client ) + { + p->ent->client->ps.delta_angles[ YAW ] = ( int )p->deltayaw; + } + } + + // Only "really" move it in order so that the bound coordinate system is correct + for( p = pushed; p < pushed_p; p++ ) + { + p->ent->setAngles(); + p->ent->setOrigin(); + } + + return false; + } + + //FIXME: is there a better way to handle this? + // see if anything we moved has touched a trigger + for( p = pushed_p - 1; p >= pushed; p-- ) + { + if( p->ent->flags & FL_TOUCH_TRIGGERS ) + { + G_TouchTriggers( p->ent ); + } + } + + return true; +} + +/* +================ +G_PushMove +================ +*/ +qboolean G_PushMove( Entity *ent, Vector move, Vector amove ) +{ + Entity *part; + Vector m, a; + Event *ev; + + m = move; + a = amove; + + pushed_p = pushed; + + part = ent; + + while( part ) + { + if( !G_Push( part, m, a ) ) + { + // move was blocked + // call the pusher's "blocked" function + // otherwise, just stay in place until the obstacle is gone + ev = new Event( EV_Blocked ); + ev->AddEntity( obstacle ); + part->ProcessEvent( ev ); + return false; + } + + m = vec_zero; + a = vec_zero; + + part = part->teamchain; + } + + return true; +} + +/* +================ +G_Physics_Pusher + +Bmodel objects don't interact with each other, but +push all box objects +================ +*/ +void G_Physics_Pusher + ( + Entity *ent + ) + +{ + Vector move, amove; + Entity *part, *mv; + Event *ev; + + // team slaves are only moved by their captains + if( ent->flags & FL_TEAMSLAVE ) + { + return; + } + + // Check if anyone on the team is moving + for( part = ent; part; part = part->teamchain ) + { + if( part->velocity != vec_zero || part->avelocity != vec_zero ) + { + break; + } + } + + // make sure all team slaves can move before commiting + // any moves or calling any think functions + // if the move is blocked, all moved objects will be backed out + pushed_p = pushed; + while( part ) + { + move = part->velocity * level.frametime; + amove = part->avelocity * level.frametime; + + if( !G_Push( part, move, amove ) ) + { + // move was blocked + break; + } + + part = part->teamchain; + } + + if( part ) + { + // the move failed, bump all movedone times + for( mv = ent; mv; mv = mv->teamchain ) + { + mv->PostponeEvent( EV_MoveDone, FRAMETIME ); + } + + // if the pusher has a "blocked" function, call it + // otherwise, just stay in place until the obstacle is gone + ev = new Event( EV_Blocked ); + ev->AddEntity( obstacle ); + part->ProcessEvent( ev ); + } + + ent->velocity += ent->accel; + ent->avelocity += ent->aaccel; +} + +//================================================================== + +/* +============= +G_Physics_Noclip + +A moving object that doesn't obey physics +============= +*/ +void G_Physics_Noclip + ( + Entity *ent + ) + + { + ent->angles += ent->avelocity * level.frametime; + ent->origin += ent->velocity * level.frametime; + ent->link(); + } + +/* +============================================================================== + +TOSS / BOUNCE + +============================================================================== +*/ + +/* +============= +G_Physics_Toss + +Toss, bounce, and fly movement. When onground, do nothing. +============= +*/ +void G_Physics_Toss + ( + Entity *ent + ) + +{ + trace_t trace; + Vector move; + float backoff; + Entity *slave; + qboolean wasinwater; + qboolean isinwater; + Vector origin2; + Vector basevel; + gentity_t *edict; + qboolean onconveyor; + + // if not a team captain, so movement will be handled elsewhere + if( ent->flags & FL_TEAMSLAVE ) + { + return; + } + + if( ent->velocity[ 2 ] > 0 ) + { + ent->groundentity = NULL; + } + + // check for the groundentity going away + if( ent->groundentity && !ent->groundentity->inuse ) + { + ent->groundentity = NULL; + } + + onconveyor = ( basevel != vec_zero ); + + // if onground, return without moving + if( ent->groundentity && !onconveyor && ( ent->movetype != MOVETYPE_VEHICLE ) ) + { + if( ent->avelocity.length() ) + { + // move angles + ent->setAngles( ent->angles + ent->avelocity * level.frametime ); + } + ent->velocity = vec_zero; + return; + } + + origin2 = ent->origin; + + G_CheckVelocity( ent ); + + // add gravity + if( !onconveyor && ent->movetype != MOVETYPE_FLY && ent->movetype != MOVETYPE_FLYMISSILE ) + { + G_AddGravity( ent ); + } + + // move angles + ent->setAngles( ent->angles + ent->avelocity * level.frametime ); + + // move origin + move = ( ent->velocity + basevel ) * level.frametime; + + edict = ent->edict; + if( ent->movetype == MOVETYPE_VEHICLE ) + { + int mask; + + if( ent->edict->clipmask ) + { + mask = ent->edict->clipmask; + } + else + { + mask = MASK_MONSTERSOLID; + } + G_FlyMove( ent, basevel, FRAMETIME, mask ); + if( ent->flags & FL_TOUCH_TRIGGERS ) + { + G_TouchTriggers( ent ); + } + return; + } + else + { + trace = G_PushEntity( ent, move ); + } + + if( ( trace.fraction == 0 ) && ( ent->movetype == MOVETYPE_SLIDE ) ) + { + // Check for slide by removing the downward velocity + Vector slide; + + slide[ 0 ] = move[ 0 ] * 0.7f; + slide[ 1 ] = move[ 1 ] * 0.7f; + slide[ 2 ] = 0; + G_PushEntity( ent, slide ); + } + + if( !edict->inuse ) + { + return; + } + + if( trace.fraction < 1 ) + { + if( ent->movetype == MOVETYPE_BOUNCE || ent->movetype == MOVETYPE_GIB ) + { + backoff = 1.5; + } + else + { + backoff = 1; + } + + Vector normal = trace.plane.normal; + + G_ClipVelocity( ent->velocity, normal, ent->velocity, backoff ); + + // stop if on ground + if( trace.plane.normal[ 2 ] > 0.7 ) + { + if( ( ent->velocity[ 2 ] < 60 || ( ent->movetype != MOVETYPE_BOUNCE && ent->movetype != MOVETYPE_GIB ) ) && + ( ent->movetype != MOVETYPE_SLIDE ) ) + { + ent->groundentity = trace.ent; + ent->groundplane = trace.plane; + ent->groundcontents = trace.contents; + ent->velocity = vec_zero; + ent->avelocity = vec_zero; + ent->ProcessEvent( EV_Stop ); + } + else if( ent->movetype == MOVETYPE_GIB ) + { + // Stop spinning after we bounce on the ground + ent->avelocity = vec_zero; + } + } + } + + if( ( move[ 2 ] == 0 ) && onconveyor ) + { + // Check if we still have a ground + ent->CheckGround(); + } + + // check for water transition + wasinwater = ( ent->watertype & MASK_WATER ); + ent->watertype = gi.PointContents( ent->origin, 0 ); + isinwater = ent->watertype & MASK_WATER; + + if( isinwater ) + { + ent->waterlevel = 1; + } + else + { + ent->waterlevel = 0; + } + + if( ( edict->spawntime < ( level.time - FRAMETIME ) ) && ( ent->mass > 0 ) ) + { + if( !wasinwater && isinwater ) + { + ent->Sound( "impact_watersplash", CHAN_BODY, DEFAULT_VOL, DEFAULT_MIN_DIST, &origin2 ); + } + else if( wasinwater && !isinwater ) + { + ent->Sound( "impact_leavewater", CHAN_BODY, DEFAULT_VOL, DEFAULT_MIN_DIST, &origin2 ); + } + } + + // GAMEFIX - Is this necessary? + // move teamslaves + for( slave = ent->teamchain; slave; slave = slave->teamchain ) + { + slave->setLocalOrigin( slave->localorigin ); + slave->setAngles( slave->localangles ); + } + + if( ent->flags & FL_TOUCH_TRIGGERS ) + { + G_TouchTriggers( ent ); + } +} + +/* +=============================================================================== + +STEPPING MOVEMENT + +=============================================================================== +*/ + +void G_AddRotationalFriction + ( + Entity *ent + ) + + { + int n; + float adjustment; + + ent->angles += level.frametime * ent->avelocity; + adjustment = level.frametime * sv_stopspeed->value * sv_friction->value; + for( n = 0; n < 3; n++ ) + { + if ( ent->avelocity[ n ] > 0) + { + ent->avelocity[ n ] -= adjustment; + if ( ent->avelocity[ n ] < 0 ) + { + ent->avelocity[ n ] = 0; + } + } + else + { + ent->avelocity[ n ] += adjustment; + if ( ent->avelocity[ n ] > 0 ) + { + ent->avelocity[ n ] = 0; + } + } + } + } + +/* +============= +G_CheckWater + +============= +*/ + +void G_CheckWater + ( + Entity *ent + ) + +{ + ent->watertype = gi.PointContents( ent->origin, 0 ); + if( ent->watertype & MASK_WATER ) + { + ent->waterlevel = 1; + } + else + { + ent->waterlevel = 0; + } + +} + +/* +============= +G_Physics_Step + +Monsters freefall when they don't have a ground entity, otherwise +all movement is done with discrete steps. + +This is also used for objects that have become still on the ground, but +will fall if the floor is pulled out from under them. +FIXME: is this true? +============= +*/ + +void G_Physics_Step + ( + Entity *ent + ) + + { + qboolean wasonground; + qboolean hitsound = false; + Vector vel; + float speed, newspeed, control; + float friction; + int mask; + Vector basevel; + + // airborn monsters should always check for ground + if ( !ent->groundentity ) + { + ent->CheckGround(); + } + + if ( ent->groundentity ) + { + wasonground = true; + } + else + { + wasonground = false; + } + + G_CheckVelocity( ent ); + + if ( ent->avelocity != vec_zero ) + { + G_AddRotationalFriction( ent ); + } + + // add gravity except: + // flying monsters + // swimming monsters who are in the water + if ( !wasonground ) + { + if( !( ent->flags & FL_FLY ) ) + { + if( !( ( ent->flags & FL_SWIM ) && ( ent->waterlevel > 2 ) ) ) + { + if ( ent->velocity[ 2 ] < sv_gravity->value * ent->gravity * -0.1 ) + { + hitsound = true; + } + + // Testing water gravity. If this doesn't work, just restore the uncommented lines + //if ( ent->waterlevel == 0 ) + //{ + G_AddGravity( ent ); + //} + } + } + } + + // friction for flying monsters that have been given vertical velocity + if( ( ent->flags & FL_FLY ) && ( ent->velocity.z != 0 ) ) + { + speed = fabs( ent->velocity.z ); + control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed; + friction = sv_friction->value / 3; + newspeed = speed - ( level.frametime * control * friction ); + if ( newspeed < 0 ) + { + newspeed = 0; + } + newspeed /= speed; + ent->velocity.z *= newspeed; + } + + // friction for flying monsters that have been given vertical velocity + if( ( ent->flags & FL_SWIM ) && ( ent->velocity.z != 0 ) ) + { + speed = fabs( ent->velocity.z ); + control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed; + newspeed = speed - ( level.frametime * control * sv_waterfriction->value * ent->waterlevel ); + if ( newspeed < 0 ) + { + newspeed = 0; + } + newspeed /= speed; + ent->velocity.z *= newspeed; + } + + if ( ent->velocity != vec_zero ) + { + // apply friction + // let dead monsters who aren't completely onground slide + if( ( wasonground ) || ( ent->flags & ( FL_SWIM | FL_FLY ) ) ) + { + if ( !( ent->health <= 0.0 && !M_CheckBottom( ent ) ) ) + { + vel = ent->velocity; + vel.z = 0; + speed = vel.length(); + if ( speed ) + { + friction = sv_friction->value; + + control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed; + newspeed = speed - level.frametime * control * friction; + + if ( newspeed < 0 ) + { + newspeed = 0; + } + + newspeed /= speed; + + ent->velocity.x *= newspeed; + ent->velocity.y *= newspeed; + } + } + } + } + + if ( ( basevel != vec_zero ) || ( ent->velocity != vec_zero ) ) + { + mask = MASK_SOLID; + + G_FlyMove( ent, basevel, level.frametime, mask ); + + ent->link(); + + G_CheckWater( ent ); + if( ent->flags & FL_TOUCH_TRIGGERS ) + { + G_TouchTriggers( ent ); + } + + if ( ent->groundentity && !wasonground && hitsound ) + { + ent->Sound( "impact_softland", CHAN_BODY, 0.5f ); + } + } + } + +//============================================================================ + +/* +================ +G_RunEntity + +================ +*/ +void G_RunEntity( Entity *ent ) +{ + gentity_t *edict; + + edict = ent->edict; + + if( !edict->inuse ) + { + return; + } + + if( ent->flags & FL_ANIMATE ) + { + ent->PreAnimate(); + } + + if( ent->flags & FL_THINK ) + { + ent->Think(); + } + + if( ent->flags & FL_ANIMATE ) + { + ent->PostAnimate(); + } + + // only run physics if in use and not bound and not immobilized + if( ( edict->s.parent == ENTITYNUM_NONE ) && !( ent->flags & FL_IMMOBILE ) && !( ent->flags & FL_PARTIAL_IMMOBILE ) ) + { + switch( ent->movetype ) + { + case MOVETYPE_NONE: + case MOVETYPE_STATIONARY: + case MOVETYPE_WALK: + case MOVETYPE_FLYMISSILE: + case MOVETYPE_SLIDE: + case MOVETYPE_GIB: + case MOVETYPE_VEHICLE: + case MOVETYPE_TURRET: + break; + case MOVETYPE_PUSH: + case MOVETYPE_STOP: + G_Physics_Pusher( ent ); + break; + case MOVETYPE_NOCLIP: + G_Physics_Noclip( ent ); + break; + case MOVETYPE_FLY: + G_FlyMove( ent, ent->velocity, level.frametime, MASK_LINE ); + break; + case MOVETYPE_TOSS: + case MOVETYPE_BOUNCE: + G_Physics_Toss( ent ); + break; + default: + gi.Error( ERR_DROP, "G_Physics: bad movetype %i", ent->movetype ); + } + } + + if( ent->flags & FL_POSTTHINK ) + { + ent->Postthink(); + } +} + diff --git a/code/game/g_phys.h b/code/game/g_phys.h new file mode 100644 index 00000000..05bddcd5 --- /dev/null +++ b/code/game/g_phys.h @@ -0,0 +1,81 @@ +/* +=========================================================================== +Copyright (C) 2008 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// g_phys.h: Header for g_phys.cpp + +#ifndef __G_PHYS_H__ +#define __G_PHYS_H__ + +#include "g_local.h" + +class Entity; + +typedef enum +{ + STEPMOVE_OK, + STEPMOVE_BLOCKED_BY_ENTITY, + STEPMOVE_BLOCKED_BY_WORLD, + STEPMOVE_BLOCKED_BY_WATER, + STEPMOVE_BLOCKED_BY_FALL, + STEPMOVE_BLOCKED_BY_DOOR, + STEPMOVE_STUCK +} stepmoveresult_t; + +// movetype values +typedef enum +{ + MOVETYPE_NONE, // never moves + MOVETYPE_STATIONARY, // never moves but does collide agains push objects + MOVETYPE_NOCLIP, // origin and angles change with no interaction + MOVETYPE_PUSH, // no clip to world, push on box contact + MOVETYPE_STOP, // no clip to world, stops on box contact + MOVETYPE_WALK, // gravity + MOVETYPE_FLY, + MOVETYPE_TOSS, // gravity + MOVETYPE_FLYMISSILE, // extra size to monsters + MOVETYPE_BOUNCE, + MOVETYPE_SLIDE, + MOVETYPE_GIB, + MOVETYPE_VEHICLE, + MOVETYPE_TURRET +} movetype_t; + +typedef struct +{ + Entity *ent; + Vector localorigin; + Vector origin; + Vector localangles; + Vector angles; + float deltayaw; +} pushed_t; + +extern pushed_t pushed[]; +extern pushed_t *pushed_p; + +void G_RunEntity( Entity *ent ); +void G_Impact( Entity *e1, trace_t *trace ); +qboolean G_PushMove( Entity *pusher, Vector move, Vector amove ); +void G_CheckWater( Entity *ent ); +Entity *G_TestEntityPosition( Entity *ent, Vector vOrg ); + +#endif /* g_phys.h */ diff --git a/code/game/g_public.h b/code/game/g_public.h new file mode 100644 index 00000000..337c2920 --- /dev/null +++ b/code/game/g_public.h @@ -0,0 +1,1163 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +// g_public.h -- game module information visible to server + +#define GAME_API_VERSION 12 + +// entity->svFlags +// the server does not know how to interpret most of the values +// in entityStates (level eType), so the game must explicitly flag +// special server behaviors +#define SVF_NOCLIENT 0x00000001 // don't send entity to clients, even if it has effects + +// TTimo +// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=551 +#define SVF_CLIENTMASK 0x00000002 + +#define SVF_BROADCAST 0x00000004 // send to all connected clients +#define SVF_BOT 0x00000008 // set if the entity is a bot +#define SVF_PORTAL 0x00000040 // merge a second pvs at origin2 into snapshots +#define SVF_USE_CURRENT_ORIGIN 0x00000080 // entity->r.currentOrigin instead of entity->s.origin + // for link position (missiles and movers) +#define SVF_SINGLECLIENT 0x00000100 // only send to a single client (entityShared_t->singleClient) +#define SVF_NOSERVERINFO 0x00000200 // don't send CS_SERVERINFO updates to this client + // so that it can be updated for ping tools without + // lagging clients +#define SVF_CAPSULE 0x00000400 // use capsule for collision detection instead of bbox +#define SVF_NOTSINGLECLIENT 0x00000800 // send entity to everyone but one client + // (entityShared_t->singleClient) + +#define SVF_USEBBOX 0x00001000 +#define SVF_SENDONCE 0x00004000 + +#define SVF_HIDEOWNER 0x00008000 +#define SVF_SENDPVS 0x00010000 + +typedef struct gclient_s gclient_t; +typedef struct dtiki_s dtiki_t; +typedef struct tiki_cmd_s tiki_cmd_t; +typedef struct dtikianim_s dtikianim_t; +typedef struct tiki_s tiki_t; + +typedef struct tikiAnim_s tikiAnim_t; +typedef struct baseshader_s baseshader_t; +typedef struct AliasListNode_s AliasListNode_t; +typedef void( *xcommand_t ) ( void ); + +typedef struct { + // su44: sharedEntity_t::s is used instead of it + //entityState_t s; // communicated by server to clients + + qboolean linked; // qfalse if not in any good cluster + int linkcount; + + int svFlags; // SVF_NOCLIENT, SVF_BROADCAST, etc + + // only send to this client when SVF_SINGLECLIENT is set + // if SVF_CLIENTMASK is set, use bitmask for clients to send to (maxclients must be <= 32, up to the mod to enforce this) + int singleClient; + + int lastNetTime; + + qboolean bmodel; // if false, assume an explicit mins / maxs bounding box + // only set by gi.SetBrushModel + vec3_t mins, maxs; + int contents; // CONTENTS_TRIGGER, CONTENTS_SOLID, CONTENTS_BODY, etc + // a non-solid entity should set to 0 + + vec3_t absmin, absmax; // derived from mins/maxs and origin + rotation + + float radius; + + // currentOrigin will be used for all collision detection and world linking. + // it will not necessarily be the same as the trajectory evaluation for the current + // time, because each entity must be moved one at a time after time is advanced + // to avoid simultanious collision issues + vec3_t currentOrigin; + + int areanum; + + vec3_t currentAngles; + + // when a trace call is made and passEntityNum != ENTITYNUM_NONE, + // an ent will be excluded from testing if: + // ent->s.number == passEntityNum (don't interact with self) + // ent->s.ownerNum = passEntityNum (don't interact with your own missiles) + // entity[ent->s.ownerNum].ownerNum = passEntityNum (don't interact with other missiles from owner) + int ownerNum; +} entityShared_t; + +// client data that stays across multiple respawns, but is cleared +// on each level change or team change at ClientBegin() +typedef struct { + char userinfo[ MAX_INFO_STRING ]; + char netname[ MAX_NAME_LENGTH ]; + char playermodel[ MAX_QPATH ]; + char playergermanmodel[ MAX_QPATH ]; + char weapon[ MAX_QPATH ]; + + float enterTime; + + teamtype_t team; + int kills; + + char ip[ 17 ]; + int port; +} clientPersistant_t; + + +// this structure is cleared on each ClientSpawn(), +// except for 'client->pers' and 'client->sess' +struct gclient_s { + // ps MUST be the first element, because the server expects it + playerState_t ps; // communicated by server to clients + +#ifdef GAME_DLL + // the rest of the structure is private to game + int ping; + clientPersistant_t pers; + float cmd_angles[ 3 ]; + + int lastActiveTime; + int activeWarning; + + struct gentity_s *ent; + struct gclient_s *next; + struct gclient_s *prev; +#endif +}; + +typedef struct gentity_s { + entityState_t s; // communicated by server to clients + + struct gclient_s *client; // NULL if not a client + qboolean inuse; + + entityShared_t r; // shared by both the server system and game + + solid_t solid; + dtiki_t *tiki; + float mat[ 3 ][ 3 ]; + + // Leave reminder to the game dll +#if defined( GAME_DLL ) + class Entity *entity; + float freetime; + float spawntime; + float radius2; + char entname[ 64 ]; + int clipmask; + + struct gentity_s *next; + struct gentity_s *prev; +#endif +} gentity_t; + +// movers are things like doors, plats, buttons, etc +typedef enum { + MOVER_POS1, + MOVER_POS2, + MOVER_1TO2, + MOVER_2TO1 +} moverState_t; + +typedef struct profVar_s +{ + int start; + int clockCycles; + int calls; + float time; + float totTime; + float avgTime; + float low; + float high; + +} profVar_t; + +typedef struct profGame_s +{ + profVar_t AI; + profVar_t MmoveSingle; + profVar_t thread_timingList; + profVar_t gamescripts; + profVar_t GProbe1; + profVar_t GProbe2; + profVar_t GProbe3; + profVar_t FindPath; + profVar_t vector_length; + profVar_t script_trace; + profVar_t internal_trace; + profVar_t PreAnimate; + profVar_t PostAnimate; + +} profGame_t; + +//=============================================================== + +#if 1 +typedef struct gameImport_s +{ + void ( *Printf )( const char *format, ... ); + void ( *DPrintf )( const char *format, ... ); + void ( *DPrintf2 )( const char *format, ... ); + void ( *DebugPrintf )( const char *format, ... ); + void ( *Error )( int level, const char *format, ... ); + int ( *Milliseconds )( ); + const char * ( *LV_ConvertString )( const char *string ); + void * ( *Malloc )( size_t size ); + void ( *Free )( void *ptr ); + cvar_t * ( *Cvar_Get )( const char *varName, const char *varValue, int varFlags ); + void ( *Cvar_Set )( const char *varName, const char *varValue ); + cvar_t *( *cvar_set2 )( const char *varName, const char *varValue, qboolean force ); + cvar_t *( *NextCvar )( cvar_t *var ); + int ( *Argc )( ); + char * ( *Argv )( int arg ); + char * ( *Args )( ); + void ( *AddCommand )( const char *cmdName, xcommand_t cmdFunction ); + int ( *FS_ReadFile )( const char *qpath, void **buffer, qboolean quiet ); + void ( *FS_FreeFile )( void *buffer ); + int ( *FS_WriteFile )( const char *qpath, const void *buffer, int size ); + fileHandle_t ( *FS_FOpenFileWrite )( const char *fileName ); + fileHandle_t ( *FS_FOpenFileAppend )( const char *fileName ); + const char *( *FS_PrepFileWrite )( const char *fileName ); + int( *FS_Write )( void *buffer, int size, fileHandle_t fileHandle ); + int ( *FS_Read )( void *buffer, int len, fileHandle_t fileHandle ); + void ( *FS_FCloseFile )( fileHandle_t fileHandle ); + int ( *FS_Tell )( fileHandle_t fileHandle ); + int ( *FS_Seek )( fileHandle_t fileHandle, long int offset, fsOrigin_t origin ); + void ( *FS_Flush )( fileHandle_t fileHandle ); + int ( *FS_FileNewer )( const char *source, const char *destination ); + void ( *FS_CanonicalFilename )( char *fileName ); + char **( *FS_ListFiles )( const char *qpath, const char *extension, qboolean wantSubs, int *numFiles ); + void ( *FS_FreeFileList )( char **list ); + const char *( *GetArchiveFileName )( char *fileName, char *extension ); + void ( *SendConsoleCommand )( const char *text ); + void ( *DebugGraph )( float value, int color ); + void ( *SendServerCommand )( int client, const char *format, ... ); + void ( *DropClient )( int client, const char *reason ); + void ( *MSG_WriteBits )( int value, int bits ); + void ( *MSG_WriteChar )( int c ); + void ( *MSG_WriteByte )( int c ); + void ( *MSG_WriteSVC )( int c ); + void ( *MSG_WriteShort )( int c ); + void ( *MSG_WriteLong )( int c ); + void ( *MSG_WriteFloat )( float f ); + void ( *MSG_WriteString )( const char *s ); + void ( *MSG_WriteAngle8 )( float f ); + void ( *MSG_WriteAngle16 )(float f ); + void ( *MSG_WriteCoord )( float f ); + void ( *MSG_WriteDir )( vec3_t dir ); + void ( *MSG_StartCGM )( int type ); + void ( *MSG_EndCGM )( ); + void ( *MSG_SetClient )( int client ); + void ( *SetBroadcastVisible )( vec3_t pos, vec3_t posB ); + void ( *SetBroadcastHearable )( vec3_t pos, vec3_t posB ); + void ( *SetBroadcastAll )( ); + void ( *SetConfigstring )( int index, const char *val ); + char *( *GetConfigstring )( int index ); + void ( *SetUserinfo )( int index, char *val ); + void ( *GetUserinfo )( int index, char *buffer, int bufferSize ); + void ( *SetBrushModel )( gentity_t *ent, const char *name ); + void ( *ModelBoundsFromName )( char *name, vec3_t mins, vec3_t maxs ); + qboolean ( *SightTraceEntity )( gentity_t *touch, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int contentMask, qboolean cylinder ); + qboolean ( *SightTrace )( vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passEntityNum, int passEntityNum2, int contentMask, qboolean cylinder ); + void ( *Trace )( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask, qboolean cylinder, qboolean traceDeep ); + baseshader_t * ( *GetShader )( int shaderNum ); + int ( *PointContents )( const vec3_t p, int passEntityNum ); + int ( *PointBrushnum )( vec3_t p, clipHandle_t model ); + void ( *AdjustAreaPortalState )( gentity_t *ent, qboolean open ); + int ( *AreaForPoint )( vec3_t pos ); + qboolean ( *AreasConnected )( int area1, int area2); + qboolean ( *InPVS )( float *p1, float *p2 ); + void ( *LinkEntity )( gentity_t *gEnt ); + void ( *UnlinkEntity )( gentity_t *gEnt ); + int ( *AreaEntities )( const vec3_t mins, const vec3_t maxs, int *list, int maxcount ); + void ( *ClipToEntity )( trace_t *tr, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int entityNum, int contentMask ); + int ( *imageindex )( const char *name ); + int ( *itemindex )( const char *name ); + int ( *soundindex )( const char *name, int streamed ); + dtiki_t *( *TIKI_RegisterModel )( const char *path ); + dtiki_t *( *modeltiki )( const char *name ); + dtikianim_t *( *modeltikianim )( const char *name ); + void ( *SetLightStyle )( int index, const char *data ); + const char *( *GameDir )( ); + qboolean ( *setmodel )( gentity_t *ent, const char *name ); + void ( *clearmodel )( gentity_t *ent ); + int ( *TIKI_NumAnims )( dtiki_t *tiki ); + int ( *NumSurfaces )( dtiki_t *tiki ); + int ( *NumTags )( dtiki_t *tiki ); + void( *CalculateBounds )( dtiki_t *tiki, float scale, vec3_t mins, vec3_t maxs ); + void *( *TIKI_GetSkeletor )( dtiki_t *tiki, int entNum ); + const char *( *Anim_NameForNum )( dtiki_t *tiki, int animNum ); + int ( *Anim_NumForName )( dtiki_t *tiki, const char *name ); + int ( *Anim_Random )( dtiki_t *tiki, const char *name ); + int ( *Anim_NumFrames )( dtiki_t *tiki, int animNum ); + float ( *Anim_Time )( dtiki_t *tiki, int animNum ); + float ( *Anim_Frametime )( dtiki_t *tiki, int animNum ); + float ( *Anim_CrossTime )( dtiki_t *tiki, int animNum ); + void ( *Anim_Delta )( dtiki_t *tiki, int animNum, float *delta ); + qboolean ( *Anim_HasDelta )( dtiki_t *tiki, int animNum ); + void ( *Anim_DeltaOverTime )( dtiki_t *tiki, int animNum, float time1, float time2, float *delta ); + int ( *Anim_Flags )( dtiki_t *tiki, int animNum ); + int ( *Anim_FlagsSkel )( dtiki_t *tiki, int animNum ); + qboolean ( *Anim_HasCommands )( dtiki_t *tiki, int animNum ); + int ( *NumHeadModels )( const char *model ); + void ( *GetHeadModel )( const char *model, int num, char *name ); + int ( *NumHeadSkins )( const char *model ); + void ( *GetHeadSkin )( const char *model, int num, char *name ); + qboolean ( *Frame_Commands )( dtiki_t *tiki, int animNum, int frameNum, tiki_cmd_t *tikiCmds ); + int ( *Surface_NameToNum )( dtiki_t *tiki, const char *name ); + const char * ( *Surface_NumToName )( dtiki_t *tiki, int surfacenum ); + int ( *Tag_NumForName )( dtiki_t *pmdl, const char *name ); + const char * ( *Tag_NameForNum )( dtiki_t *pmdl, int tagNum); + orientation_t ( *TIKI_OrientationInternal )( dtiki_t *tiki, int entNum, int tagNum, float scale ); + void *( *TIKI_TransformInternal )( dtiki_t *tiki, int entNum, int tagNum ); + qboolean ( *TIKI_IsOnGroundInternal )( dtiki_t *tiki, int entNum, int num, float threshold ); + void ( *TIKI_SetPoseInternal )( dtiki_t *tiki, int entNum, frameInfo_t *frameInfo, int *boneTag, vec4_t *boneQuat, float actionWeight ); + const char *( *CM_GetHitLocationInfo )( int location, float *radius, float *offset ); + const char *( *CM_GetHitLocationInfoSecondary )( int location, float *radius, float *offset ); + + qboolean ( *Alias_Add )( dtiki_t *pmdl, const char *alias, const char *name, const char *parameters ); + const char *( *Alias_FindRandom )( dtiki_t *tiki, const char *alias, AliasListNode_t **ret ); + void ( *Alias_Dump )( dtiki_t *tiki ); + void ( *Alias_Clear )( dtiki_t *tiki ); + void ( *Alias_UpdateDialog )( dtikianim_t *tiki, const char *alias ); + + const char *( *TIKI_NameForNum )( dtiki_t *tiki ); + + qboolean ( *GlobalAlias_Add )( const char *alias, const char *name, const char *parameters ); + const char *( *GlobalAlias_FindRandom )( const char *alias, AliasListNode_t **ret ); + void ( *GlobalAlias_Dump )( ); + void ( *GlobalAlias_Clear )( ); + + void ( *centerprintf )( gentity_t *ent, const char *format, ... ); + void ( *locationprintf )( gentity_t *ent, int x, int y, const char *format, ... ); + void ( *Sound )( vec3_t *org, int entNum, int channel, const char *soundName, float volume, float minDist, float pitch, float maxDist, int streamed ); + void ( *StopSound )( int entNum, int channel ); + float ( *SoundLength )( int channel, const char *name ); + unsigned char * ( *SoundAmplitudes )( int channel, const char *name ); + int( *S_IsSoundPlaying )( int channel, const char *name ); + short unsigned int ( *CalcCRC )( unsigned char *start, int count ); + + void **DebugLines; + int *numDebugLines; + void **DebugStrings; + int *numDebugStrings; + + void ( *LocateGameData )( gentity_t *gEnts, int numGEntities, int sizeofGEntity, playerState_t *clients, int sizeofGameClient ); + void ( *SetFarPlane )(int farPlane ); + void ( *SetSkyPortal )( qboolean skyPortal ); + void ( *Popmenu )( int client , int i ); + void ( *Showmenu )( int client, const char *name, qboolean force ); + void ( *Hidemenu )( int client, const char *name, qboolean force ); + void ( *Pushmenu )( int client, const char *name ); + void ( *HideMouseCursor )( int client ); + void ( *ShowMouseCursor )( int client ); + const char * ( *MapTime )( ); + void ( *LoadResource )( char *name ); + void ( *ClearResource )( ); + int ( *Key_StringToKeynum )( char *str ); + const char *( *Key_KeynumToBindString )( int keyNum ); + void ( *Key_GetKeysForCommand )( const char *command, int *key1, int *key2 ); + void ( *ArchiveLevel )( qboolean loading ); + void ( *AddSvsTimeFixup )( int *piTime ); + void ( *HudDrawShader )( int info, char *name ); + void ( *HudDrawAlign )( int info, int horizontalAlign, int verticalAlign ); + void ( *HudDrawRect )( int info, int x, int y, int width, int height ); + void ( *HudDrawVirtualSize )( int info, qboolean virtualScreen); + void ( *HudDrawColor )( int info, float *color ); + void ( *HudDrawAlpha )( int info, float alpha ); + void ( *HudDrawString )( int info, char *string ); + void ( *HudDrawFont )( int info, char *fontName ); + qboolean ( *SanitizeName )( char *oldName, char *newName ); + + cvar_t *fsDebug; + + // New functions will start from here + +} gameImport_t; +#else + +typedef struct gameImport_s { + //============== general Quake services ================== + + void ( *Printf )( const char *fmt, ... ); + void ( *DPrintf )( const char *fmt, ... ); + void ( *Error )( int level, const char *fmt, ... ); + int ( *Milliseconds )( void ); + const char *( *LV_ConvertString )( const char *string ); + void* ( *Malloc )( int size ); + void ( *Free )( void *ptr ); + int ( *Argc )( void ); + char *( *Argv )( int n ); + const char *( *Args )(); + int ( *FS_FOpenFile )( const char *qpath, fileHandle_t *f, fsMode_t mode ); + void ( *FS_Read )( void *buffer, int len, fileHandle_t f ); + int ( *FS_Write )( const void *buffer, int len, fileHandle_t f ); + void ( *FS_FCloseFile )( fileHandle_t f ); + int ( *FS_GetFileList )( const char *path, const char *extension, char *listbuf, int bufsize ); + int ( *FS_Seek )( fileHandle_t f, long offset, int origin ); // fsOrigin_t + int ( *FS_Tell )( fileHandle_t f ); + int ( *FS_ReadFile )( const char *name, void **buffer, qboolean something ); + void ( *FS_FreeFile )( void *buffer ); + int ( *FS_WriteFile )( const char *qpath, const void *buffer, int size ); + fileHandle_t ( *FS_FOpenFileWrite )( const char *name ); + fileHandle_t ( *FS_FOpenFileAppend )( const char *fileName ); + void ( *FS_Flush )( fileHandle_t f ); + void ( *SendConsoleCommand )( const char *text ); + cvar_t *( *Cvar_Get )( const char *varName, const char *varValue, int varFlags ); + void ( *Cvar_Register )( vmCvar_t *cvar, const char *var_name, const char *value, int flags ); + void ( *Cvar_Update )( vmCvar_t *cvar ); + void ( *Cvar_Set )( const char *var_name, const char *value ); + int ( *Cvar_VariableIntegerValue )( const char *var_name ); + float ( *Cvar_VariableValue )( const char *var_name ); + void ( *Cvar_VariableStringBuffer )( const char *var_name, char *buffer, int bufsize ); + void ( *LocateGameData )( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t, playerState_t *gameClients, int sizeofGameClient ); + void ( *DropClient )( int clientNum, const char *reason ); + void ( *SendServerCommand )( int clientNum, const char *text, ... ); + void ( *SetConfigstring )( int num, const char *string ); + char *( *GetConfigstring )( int num ); + void ( *GetUserinfo )( int num, char *buffer, int bufferSize ); + void ( *SetUserinfo )( int num, const char *buffer ); + void ( *GetServerinfo )( char *buffer, int bufferSize ); + + void ( *AddCommand )( const char *cmd, xcommand_t function ); + + // + // MODEL UTILITY FUNCTIONS + // + qboolean ( *IsModel )( int index ); + void ( *SetBrushModel )( gentity_t *ent, const char *name ); + + // DEF SPECIFIC STUFF + int ( *NumSkins )( dtiki_t *tiki ); + int ( *NumSurfaces )( dtiki_t *tiki ); + int ( *NumTags )( dtiki_t *tiki ); + qboolean ( *Frame_Commands )( dtiki_t *tiki, int animNum, int frameNum, tikiCmd_t *tiki_cmd ); + void ( *CalculateBounds )( dtiki_t *tiki, float scale, vec3_t mins, vec3_t maxs ); + + void ( *Trace )( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask, int capsule, qboolean deepTrace ); + int ( *PointContents )( const vec3_t point, int passEntityNum ); + int ( *PointBrushnum )( vec3_t p, clipHandle_t model ); + qboolean ( *InPVS )( const vec3_t p1, const vec3_t p2 ); + qboolean ( *InPVSIgnorePortals )( const vec3_t p1, const vec3_t p2 ); + void ( *AdjustAreaPortalState )( gentity_t *ent, qboolean open ); + qboolean ( *AreasConnected )( int area1, int area2 ); + void ( *LinkEntity )( gentity_t *ent ); + void ( *UnlinkEntity )( gentity_t *ent ); + int ( *AreaEntities )( const vec3_t mins, const vec3_t maxs, int *list, int maxcount ); + void ( *ClipToEntity )( trace_t *trace, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int entityNum, int contentmask ); + int ( *EntitiesInBox )( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount ); + qboolean ( *EntityContact )( const vec3_t mins, const vec3_t maxs, const gentity_t *ent ); + int ( *BotAllocateClient )( void ); + void ( *BotFreeClient )( int clientNum ); + void ( *GetUsercmd )( int clientNum, usercmd_t *cmd ); + qboolean ( *GetEntityToken )( char *buffer, int bufferSize ); + + int ( *DebugPolygonCreate )( int color, int numPoints, vec3_t *points ); + void ( *DebugPolygonDelete )( int id ); + + int ( *BotLibSetup )( void ); + int ( *BotLibShutdown )( void ); + int ( *BotLibVarSet )( char *var_name, char *value ); + int ( *BotLibVarGet )( char *var_name, char *value, int size ); + int ( *BotLibDefine )( char *string ); + int ( *BotLibStartFrame )( float time ); + int ( *BotLibLoadMap )( const char *mapname ); + int ( *BotLibUpdateEntity )( int ent, void *bue ); + int ( *BotLibTest )( int parm0, char *parm1, vec3_t parm2, vec3_t parm3 ); + + int ( *BotGetSnapshotEntity )( int clientNum, int sequence ); + int ( *BotGetServerCommand )( int clientNum, char *message, int size ); + void ( *BotUserCommand )( int client, usercmd_t *ucmd ); + + int ( *AAS_BBoxAreas )( vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas ); + int ( *AAS_AreaInfo )( int areanum, void *info ); + void ( *AAS_EntityInfo )( int entnum, void *info ); + + int ( *AAS_Initialized )( void ); + void ( *AAS_PresenceTypeBoundingBox )( int presencetype, vec3_t mins, vec3_t maxs ); + float ( *AAS_Time )( void ); + + int ( *AAS_PointAreaNum )( vec3_t point ); + int ( *AAS_PointReachabilityAreaIndex )( vec3_t point ); + int ( *AAS_TraceAreas )( vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas ); + + int ( *AAS_PointContents )( vec3_t point ); + int ( *AAS_NextBSPEntity )( int ent ); + int ( *AAS_ValueForBSPEpairKey )( int ent, char *key, char *value, int size ); + int ( *AAS_VectorForBSPEpairKey )( int ent, char *key, vec3_t v ); + int ( *AAS_FloatForBSPEpairKey )( int ent, char *key, float *value ); + int ( *AAS_IntForBSPEpairKey )( int ent, char *key, int *value ); + + int ( *AAS_AreaReachability )( int areanum ); + + int ( *AAS_AreaTravelTimeToGoalArea )( int areanum, vec3_t origin, int goalareanum, int travelflags ); + int ( *AAS_EnableRoutingArea )( int areanum, int enable ); + int ( *AAS_PredictRoute )( void /*struct aas_predictroute_s*/ *route, int areanum, vec3_t origin, + int goalareanum, int travelflags, int maxareas, int maxtime, + int stopevent, int stopcontents, int stoptfl, int stopareanum ); + + int ( *AAS_AlternativeRouteGoals )( vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags, + void /*struct aas_altroutegoal_s*/ *altroutegoals, int maxaltroutegoals, + int type ); + int ( *AAS_Swimming )( vec3_t origin ); + int ( *AAS_PredictClientMovement )( void *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 ); + + + void ( *EA_Say )( int client, char *str ); + void ( *EA_SayTeam )( int client, char *str ); + void ( *EA_Command )( int client, char *command ); + + void ( *EA_Action )( int client, int action ); + void ( *EA_Gesture )( int client ); + void ( *EA_Talk )( int client ); + void ( *EA_Attack )( int client ); + void ( *EA_Use )( int client ); + void ( *EA_Respawn )( int client ); + void ( *EA_Crouch )( int client ); + void ( *EA_MoveUp )( int client ); + void ( *EA_MoveDown )( int client ); + void ( *EA_MoveForward )( int client ); + void ( *EA_MoveBack )( int client ); + void ( *EA_MoveLeft )( int client ); + void ( *EA_MoveRight )( int client ); + void ( *EA_SelectWeapon )( int client, int weapon ); + void ( *EA_Jump )( int client ); + void ( *EA_DelayedJump )( int client ); + void ( *EA_Move )( int client, vec3_t dir, float speed ); + void ( *EA_View )( int client, vec3_t viewangles ); + + void ( *EA_EndRegular )( int client, float thinktime ); + void ( *EA_GetInput )( int client, float thinktime, void *input ); + void ( *EA_ResetInput )( int client ); + + int ( *BotLoadCharacter )( char *charfile, float skill ); + void ( *BotFreeCharacter )( int character ); + float ( *Characteristic_Float )( int character, int index ); + float ( *Characteristic_BFloat )( int character, int index, float min, float max ); + int ( *Characteristic_Integer )( int character, int index ); + int ( *Characteristic_BInteger )( int character, int index, int min, int max ); + void ( *Characteristic_String )( int character, int index, char *buf, int size ); + + int ( *BotAllocChatState )( void ); + void ( *BotFreeChatState )( int handle ); + void ( *BotQueueConsoleMessage )( int chatstate, int type, char *message ); + void ( *BotRemoveConsoleMessage )( int chatstate, int handle ); + int ( *BotNextConsoleMessage )( int chatstate, void *cm ); + int ( *BotNumConsoleMessages )( int chatstate ); + void ( *BotInitialChat )( int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 ); + int ( *BotNumInitialChats )( int chatstate, char *type ); + int ( *BotReplyChat )( int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 ); + int ( *BotChatLength )( int chatstate ); + void ( *BotEnterChat )( int chatstate, int client, int sendto ); + void ( *BotGetChatMessage )( int chatstate, char *buf, int size ); + int ( *StringContains )( char *str1, char *str2, int casesensitive ); + int ( *BotFindMatch )( char *str, void *match, unsigned long int context ); + void ( *BotMatchVariable )( void *match, int variable, char *buf, int size ); + void ( *UnifyWhiteSpaces )( char *string ); + void ( *BotReplaceSynonyms )( char *string, unsigned long int context ); + int ( *BotLoadChatFile )( int chatstate, char *chatfile, char *chatname ); + void ( *BotSetChatGender )( int chatstate, int gender ); + void ( *BotSetChatName )( int chatstate, char *name, int client ); + void ( *BotResetGoalState )( int goalstate ); + void ( *BotRemoveFromAvoidGoals )( int goalstate, int number ); + void ( *BotResetAvoidGoals )( int goalstate ); + void ( *BotPushGoal )( int goalstate, void *goal ); + void ( *BotPopGoal )( int goalstate ); + void ( *BotEmptyGoalStack )( int goalstate ); + void ( *BotDumpAvoidGoals )( int goalstate ); + void ( *BotDumpGoalStack )( int goalstate ); + void ( *BotGoalName )( int number, char *name, int size ); + int ( *BotGetTopGoal )( int goalstate, void *goal ); + int ( *BotGetSecondGoal )( int goalstate, void *goal ); + int ( *BotChooseLTGItem )( int goalstate, vec3_t origin, int *inventory, int travelflags ); + int ( *BotChooseNBGItem )( int goalstate, vec3_t origin, int *inventory, int travelflags, void *ltg, float maxtime ); + int ( *BotTouchingGoal )( vec3_t origin, void *goal ); + int ( *BotItemGoalInVisButNotVisible )( int viewer, vec3_t eye, vec3_t viewangles, void *goal ); + int ( *BotGetNextCampSpotGoal )( int num, void *goal ); + int ( *BotGetMapLocationGoal )( char *name, void *goal ); + int ( *BotGetLevelItemGoal )( int index, char *classname, void *goal ); + float ( *BotAvoidGoalTime )( int goalstate, int number ); + void ( *BotSetAvoidGoalTime )( int goalstate, int number, float avoidtime ); + void ( *BotInitLevelItems )( void ); + void ( *BotUpdateEntityItems )( void ); + int ( *BotLoadItemWeights )( int goalstate, char *filename ); + void ( *BotFreeItemWeights )( int goalstate ); + void ( *BotInterbreedGoalFuzzyLogic )( int parent1, int parent2, int child ); + void ( *BotSaveGoalFuzzyLogic )( int goalstate, char *filename ); + void ( *BotMutateGoalFuzzyLogic )( int goalstate, float range ); + int ( *BotAllocGoalState )( int state ); + void ( *BotFreeGoalState )( int handle ); + + void ( *BotResetMoveState )( int movestate ); + void ( *BotMoveToGoal )( void *result, int movestate, void *goal, int travelflags ); + int ( *BotMoveInDirection )( int movestate, vec3_t dir, float speed, int type ); + void ( *BotResetAvoidReach )( int movestate ); + void ( *BotResetLastAvoidReach )( int movestate ); + int ( *BotReachabilityArea )( vec3_t origin, int testground ); + int ( *BotMovementViewTarget )( int movestate, void *goal, int travelflags, float lookahead, vec3_t target ); + int ( *BotPredictVisiblePosition )( vec3_t origin, int areanum, void *goal, int travelflags, vec3_t target ); + int ( *BotAllocMoveState )( void ); + void ( *BotFreeMoveState )( int handle ); + void ( *BotInitMoveState )( int handle, void *initmove ); + void ( *BotAddAvoidSpot )( int movestate, vec3_t origin, float radius, int type ); + + int ( *BotChooseBestFightWeapon )( int weaponstate, int *inventory ); + void ( *BotGetWeaponInfo )( int weaponstate, int weapon, void *weaponinfo ); + int ( *BotLoadWeaponWeights )( int weaponstate, char *filename ); + int ( *BotAllocWeaponState )( void ); + void ( *BotFreeWeaponState )( int weaponstate ); + void ( *BotResetWeaponState )( int weaponstate ); + + int ( *GeneticParentsAndChildSelection )( int numranks, float *ranks, int *parent1, int *parent2, int *child ); + + void ( *centerprintf )( gentity_t *ent, const char *format, ... ); + + int ( *imageindex )( const char *name ); + int ( *itemindex )( const char *name ); + int ( *soundindex )( const char *name, qboolean streamed ); + dtiki_t *( *modeltiki )( const char *name ); + + // ley0k: sky stuff + void ( *SetFarPlane )( int farPlane ); + void ( *SetSkyPortal )( qboolean skyPortal ); + + qboolean ( *Alias_Add )( dtiki_t *tiki, const char * alias, const char * name, const char *parameters ); + const char *( *Alias_FindRandom )( dtiki_t *tiki, const char * alias, aliasListNode_t **ret ); + void ( *Alias_Dump )( dtiki_t *tiki ); + void ( *Alias_Clear )( dtiki_t *tiki ); + void ( *Alias_UpdateDialog )( dtiki_t *tiki, const char *alias, int number_of_times_played, byte been_played_this_loop, int last_time_played ); + + // ANIM SPECIFIC STUFF + const char *( *Anim_NameForNum )( dtiki_t *tiki, int animnum ); + int ( *Anim_NumForName )( dtiki_t *tiki, const char * name ); + int ( *Anim_Random )( dtiki_t *tiki, const char * name ); + int ( *Anim_NumFrames )( dtiki_t *tiki, int animnum ); + float ( *Anim_Frametime )( dtiki_t *tiki, int animnum ); + float ( *Anim_CrossTime )( dtiki_t *tiki, int animNum ); + float ( *Anim_Time )( dtiki_t *tiki, int animnum ); + void ( *Anim_Delta )( dtiki_t *tiki, int animnum, vec3_t delta ); + void ( *Anim_AbsoluteDelta )( dtiki_t *tiki, int animnum, vec3_t delta ); + int ( *Anim_Flags )( dtiki_t *tiki, int animnum ); + qboolean ( *Anim_HasCommands ) ( dtiki_t *tiki, int animnum ); + + // Sound + void ( *Sound )( vec3_t *org, int entnum, int channel, const char *sound_name, float volume, float min_dist, float pitch, float maxDist, qboolean streamed ); + void ( *StopSound )( int entnum, int channel ); + float ( *SoundLength ) ( int channel, const char *path ); + byte *( *SoundAmplitudes )( int channel, const char * name ); + + // GLOBAL ALIAS SYSTEM + qboolean ( *GlobalAlias_Add )( const char * alias, const char * name, const char *parameters ); + const char *( *GlobalAlias_FindRandom )( const char * alias, aliasListNode_t **ret ); + void ( *GlobalAlias_Dump )( void ); + void ( *GlobalAlias_Clear )( void ); + + // su44 + dtiki_t* ( *TIKI_RegisterModel )( const char *fname ); + int ( *TIKI_NumAnims )( dtiki_t *tiki ); + + // SURFACE SPECIFIC STUFF + int ( *Surface_NameToNum )( dtiki_t *tiki, const char * name ); + const char *( *Surface_NumToName )( dtiki_t *tiki, int num ); + int ( *Surface_Flags )( dtiki_t *tiki, int num ); + int ( *Surface_NumSkins )( dtiki_t *tiki, int num ); + + // TAG SPECIFIC STUFF + int ( *Tag_NumForName )( dtiki_t *tiki, const char * name ); + const char *( *Tag_NameForNum )( dtiki_t *tiki, int num ); + orientation_t ( *Tag_Orientation )( dtiki_t *tiki, int anim, int frame, int num, float scale, int *bone_tag, vec4_t *bone_quat ); + orientation_t ( *Tag_OrientationEx )( dtiki_t *tiki, int anim, int frame, int num, float scale, int *bone_tag, vec4_t *bone_quat, + int crossblend_anim, int crossblend_frame, float crossblend_lerp, qboolean uselegs, qboolean usetorso, int torso_anim, int torso_frame, + int torso_crossblend_anim, int torso_crossblend_frame, float torso_crossblend_lerp ); + + // su44: these are for cg message writing + void ( *MSG_WriteBits )( int value, int bits ); + void ( *MSG_WriteChar )( int c ); + void ( *MSG_WriteByte )( int c ); + void ( *MSG_WriteSVC )( int c ); + void ( *MSG_WriteShort )( int c ); + void ( *MSG_WriteLong )( int c ); + void ( *MSG_WriteFloat )( float f ); + void ( *MSG_WriteString )( const char *s ); + void ( *MSG_WriteAngle8 )( float f ); + void ( *MSG_WriteAngle16 )( float f ); + void ( *MSG_WriteCoord )( float f ); + void ( *MSG_WriteDir )( const vec_t *dir ); + void ( *MSG_StartCGM )( int type ); + void ( *MSG_EndCGM )(); + void ( *MSG_SetClient )( int iClient ); + void ( *SetBroadcastAll )(); + void ( *SetBroadcastVisible )( const vec_t *vPos, const vec_t *vPosB ); + void ( *SetBroadcastHearable )( const vec_t *vPos, const vec_t *vPosB ); + + void **DebugLines; + int *numDebugLines; + void **DebugStrings; + int *numDebugStrings; + +} gameImport_t; + +#endif + +typedef struct gameExport_s { + int apiversion; + + // the init function will only be called when a game starts, + // not each time a level is loaded. Persistant data for clients + // and the server can be allocated in init + void ( *Init )( int startTime, int randomSeed ); + void ( *Shutdown ) ( void ); + void ( *Cleanup ) ( qboolean samemap ); + void ( *Precache )( void ); + + void ( *SetMap )( const char *mapName ); + void ( *Restart )( ); + void ( *SetTime )( int svsStartTime, int svsTime ); + + // each new level entered will cause a call to SpawnEntities + void ( *SpawnEntities ) ( char *entstring, int levelTime ); + + // return NULL if the client is allowed to connect, otherwise return + // a text string with the reason for denial + char *( *ClientConnect )( int clientNum, qboolean firstTime ); + + void ( *ClientBegin )( gentity_t *ent, usercmd_t *cmd ); + void ( *ClientUserinfoChanged )( gentity_t *ent, const char *userinfo ); + void ( *ClientDisconnect )( gentity_t *ent ); + void ( *ClientCommand )( gentity_t *ent ); + void ( *ClientThink )( gentity_t *ent, usercmd_t *cmd, usereyes_t *eyeinfo ); + + void ( *BotBegin )( gentity_t *ent); + void ( *BotThink )( gentity_t *ent, int msec ); + + void ( *PrepFrame )( void ); + void ( *RunFrame )( int levelTime, int frameTime ); + + void ( *ServerSpawned )( void ); + + void ( *RegisterSounds )( ); + qboolean ( *AllowPaused )( ); + + // ConsoleCommand will be called when a command has been issued + // that is not recognized as a builtin function. + // The game can issue gi.argc() / gi.argv() commands to get the command + // and parameters. Return qfalse if the game doesn't recognize it as a command. + qboolean ( *ConsoleCommand )( void ); + + void ( *ArchivePersistant )( const char *name, qboolean loading ); + + // ReadLevel is called after the default map information has been + // loaded with SpawnEntities, so any stored client spawn spots will + // be used when the clients reconnect. + void ( *WriteLevel )( const char *filename, qboolean autosave ); + qboolean ( *ReadLevel )( const char *filename ); + qboolean ( *LevelArchiveValid )( const char *filename ); + + void ( *ArchiveInteger )( int *i ); + void ( *ArchiveFloat )( float *fl ); + void ( *ArchiveString )( char *s ); + void ( *ArchiveSvsTime )( int *pi ); + orientation_t ( *TIKI_Orientation )( gentity_t *edict, int num ); + void ( *DebugCircle )( float *org, float radius, float r, float g, float b, float alpha, qboolean horizontal ); + void ( *SetFrameNumber )( int frameNumber ); + void ( *SoundCallback )( int entNum, soundChannel_t channelNumber, const char *name ); + + // + // global variables shared between game and server + // + + // The gentities array is allocated in the game dll so it + // can vary in size from one game to another. + // + // The size will be fixed when ge->Init() is called + // the server can't just use pointer arithmetic on gentities, because the + // server's sizeof(struct gentity_s) doesn't equal gentitySize + profGame_t *profStruct; + struct gentity_s *gentities; + int gentitySize; + int num_entities; // current number, <= max_entities + int max_entities; + + const char *errorMessage; +} gameExport_t; + +#ifdef __cplusplus +extern "C" +#endif +gameExport_t* GetGameAPI( gameImport_t *import ); + +#if 0 +// +// system traps provided by the main engine +// +typedef enum { + //============== general Quake services ================== + + G_PRINT, // )( const char *string ); + // print message on the local console + + G_ERROR, // )( const char *string ); + // abort the game + + G_MILLISECONDS, // )( void ); + // get current time for profiling reasons + // this should NOT be used for any game related tasks, + // because it is not journaled + + // console variable interaction + G_CVAR_REGISTER, // )( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ); + G_CVAR_UPDATE, // )( vmCvar_t *vmCvar ); + G_CVAR_SET, // )( const char *var_name, const char *value ); + G_CVAR_VARIABLE_INTEGER_VALUE, // )( const char *var_name ); + + G_CVAR_VARIABLE_STRING_BUFFER, // )( const char *var_name, char *buffer, int bufsize ); + + G_ARGC, // )( void ); + // ClientCommand and ServerCommand parameter access + + G_ARGV, // )( int n, char *buffer, int bufferLength ); + + G_FS_FOPEN_FILE, // )( const char *qpath, fileHandle_t *file, fsMode_t mode ); + G_FS_READ, // )( void *buffer, int len, fileHandle_t f ); + G_FS_WRITE, // )( const void *buffer, int len, fileHandle_t f ); + G_FS_FCLOSE_FILE, // )( fileHandle_t f ); + + G_SEND_CONSOLE_COMMAND, // )( const char *text ); + // add commands to the console as if they were typed in + // for map changing, etc + + + //=========== server specific functionality ============= + + G_LOCATE_GAME_DATA, // )( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t, + // playerState_t *clients, int sizeofGameClient ); + // the game needs to let the server system know where and how big the gentities + // are, so it can look at them directly without going through an interface + + G_DROP_CLIENT, // )( int clientNum, const char *reason ); + // kick a client off the server with a message + + G_SEND_SERVER_COMMAND, // )( int clientNum, const char *fmt, ... ); + // reliably sends a command string to be interpreted by the given + // client. If clientNum is -1, it will be sent to all clients + + G_SET_CONFIGSTRING, // )( int num, const char *string ); + // config strings hold all the index strings, and various other information + // that is reliably communicated to all clients + // All of the current configstrings are sent to clients when + // they connect, and changes are sent to all connected clients. + // All confgstrings are cleared at each level start. + + G_GET_CONFIGSTRING, // )( int num, char *buffer, int bufferSize ); + + G_GET_USERINFO, // )( int num, char *buffer, int bufferSize ); + // userinfo strings are maintained by the server system, so they + // are persistant across level loads, while all other game visible + // data is completely reset + + G_SET_USERINFO, // )( int num, const char *buffer ); + + G_GET_SERVERINFO, // )( char *buffer, int bufferSize ); + // the serverinfo info string has all the cvars visible to server browsers + + G_SET_BRUSH_MODEL, // )( gentity_t *ent, const char *name ); + // sets mins and maxs based on the brushmodel name + + G_TRACE, // ( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask ); + // collision detection against all linked entities + + G_POINT_CONTENTS, // )( const vec3_t point, int passEntityNum ); + // point contents against all linked entities + + G_IN_PVS, // )( const vec3_t p1, const vec3_t p2 ); + + G_IN_PVS_IGNORE_PORTALS, // )( const vec3_t p1, const vec3_t p2 ); + + G_ADJUST_AREA_PORTAL_STATE, // )( gentity_t *ent, qboolean open ); + + G_AREAS_CONNECTED, // )( int area1, int area2 ); + + G_LINKENTITY, // )( gentity_t *ent ); + // an entity will never be sent to a client or used for collision + // if it is not passed to linkentity. If the size, position, or + // solidity changes, it must be relinked. + + G_UNLINKENTITY, // )( gentity_t *ent ); + // call before removing an interactive entity + + g_entities_IN_BOX, // )( const vec3_t mins, const vec3_t maxs, gentity_t **list, int maxcount ); + // EntitiesInBox will return brush models based on their bounding box, + // so exact determination must still be done with EntityContact + + G_ENTITY_CONTACT, // )( const vec3_t mins, const vec3_t maxs, const gentity_t *ent ); + // perform an exact check against inline brush models of non-square shape + + // access for bots to get and free a server client (FIXME?) + G_BOT_ALLOCATE_CLIENT, // )( void ); + + G_BOT_FREE_CLIENT, // )( int clientNum ); + + G_GET_USERCMD, // )( int clientNum, usercmd_t *cmd ) + + G_GET_ENTITY_TOKEN, // qboolean )( char *buffer, int bufferSize ) + // Retrieves the next string token from the entity spawn text, returning + // false when all tokens have been parsed. + // This should only be done at GAME_INIT time. + + G_FS_GETFILELIST, + G_DEBUG_POLYGON_CREATE, + G_DEBUG_POLYGON_DELETE, + G_REAL_TIME, + G_SNAPVECTOR, + + G_TRACECAPSULE, // ( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask ); + G_ENTITY_CONTACTCAPSULE, // )( const vec3_t mins, const vec3_t maxs, const gentity_t *ent ); + + // 1.32 + G_FS_SEEK, + + BOTLIB_SETUP = 200, // )( void ); + BOTLIB_SHUTDOWN, // )( void ); + BOTLIB_LIBVAR_SET, + BOTLIB_LIBVAR_GET, + BOTLIB_PC_ADD_GLOBAL_DEFINE, + BOTLIB_START_FRAME, + BOTLIB_LOAD_MAP, + BOTLIB_UPDATENTITY, + BOTLIB_TEST, + + BOTLIB_GET_SNAPSHOT_ENTITY, // )( int client, int ent ); + BOTLIB_GET_CONSOLE_MESSAGE, // )( int client, char *message, int size ); + BOTLIB_USER_COMMAND, // )( int client, usercmd_t *ucmd ); + + BOTLIB_AAS_ENABLE_ROUTING_AREA = 300, + BOTLIB_AAS_BBOX_AREAS, + BOTLIB_AAS_AREA_INFO, + BOTLIB_AAS_ENTITY_INFO, + + BOTLIB_AAS_INITIALIZED, + BOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX, + BOTLIB_AAS_TIME, + + BOTLIB_AAS_POINT_AREA_NUM, + BOTLIB_AAS_TRACE_AREAS, + + BOTLIB_AAS_POINT_CONTENTS, + BOTLIB_AAS_NEXT_BSP_ENTITY, + BOTLIB_AAS_VALUE_FOR_BSP_EPAIR_KEY, + BOTLIB_AAS_VECTOR_FOR_BSP_EPAIR_KEY, + BOTLIB_AAS_FLOAT_FOR_BSP_EPAIR_KEY, + BOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY, + + BOTLIB_AAS_AREA_REACHABILITY, + + BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA, + + BOTLIB_AAS_SWIMMING, + BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT, + + BOTLIB_EA_SAY = 400, + BOTLIB_EA_SAY_TEAM, + BOTLIB_EA_COMMAND, + + BOTLIB_EA_ACTION, + BOTLIB_EA_GESTURE, + BOTLIB_EA_TALK, + BOTLIB_EA_ATTACK, + BOTLIB_EA_USE, + BOTLIB_EA_RESPAWN, + BOTLIB_EA_CROUCH, + BOTLIB_EA_MOVE_UP, + BOTLIB_EA_MOVE_DOWN, + BOTLIB_EA_MOVE_FORWARD, + BOTLIB_EA_MOVE_BACK, + BOTLIB_EA_MOVE_LEFT, + BOTLIB_EA_MOVE_RIGHT, + + BOTLIB_EA_SELECT_WEAPON, + BOTLIB_EA_JUMP, + BOTLIB_EA_DELAYED_JUMP, + BOTLIB_EA_MOVE, + BOTLIB_EA_VIEW, + + BOTLIB_EA_END_REGULAR, + BOTLIB_EA_GET_INPUT, + BOTLIB_EA_RESET_INPUT, + + + BOTLIB_AI_LOAD_CHARACTER = 500, + BOTLIB_AI_FREE_CHARACTER, + BOTLIB_AI_CHARACTERISTIC_FLOAT, + BOTLIB_AI_CHARACTERISTIC_BFLOAT, + BOTLIB_AI_CHARACTERISTIC_INTEGER, + BOTLIB_AI_CHARACTERISTIC_BINTEGER, + BOTLIB_AI_CHARACTERISTIC_STRING, + + BOTLIB_AI_ALLOC_CHAT_STATE, + BOTLIB_AI_FREE_CHAT_STATE, + BOTLIB_AI_QUEUE_CONSOLE_MESSAGE, + BOTLIB_AI_REMOVE_CONSOLE_MESSAGE, + BOTLIB_AI_NEXT_CONSOLE_MESSAGE, + BOTLIB_AI_NUM_CONSOLE_MESSAGE, + BOTLIB_AI_INITIAL_CHAT, + BOTLIB_AI_REPLY_CHAT, + BOTLIB_AI_CHAT_LENGTH, + BOTLIB_AI_ENTER_CHAT, + BOTLIB_AI_STRING_CONTAINS, + BOTLIB_AI_FIND_MATCH, + BOTLIB_AI_MATCH_VARIABLE, + BOTLIB_AI_UNIFY_WHITE_SPACES, + BOTLIB_AI_REPLACE_SYNONYMS, + BOTLIB_AI_LOAD_CHAT_FILE, + BOTLIB_AI_SET_CHAT_GENDER, + BOTLIB_AI_SET_CHAT_NAME, + + BOTLIB_AI_RESET_GOAL_STATE, + BOTLIB_AI_RESET_AVOID_GOALS, + BOTLIB_AI_PUSH_GOAL, + BOTLIB_AI_POP_GOAL, + BOTLIB_AI_EMPTY_GOAL_STACK, + BOTLIB_AI_DUMP_AVOID_GOALS, + BOTLIB_AI_DUMP_GOAL_STACK, + BOTLIB_AI_GOAL_NAME, + BOTLIB_AI_GET_TOP_GOAL, + BOTLIB_AI_GET_SECOND_GOAL, + BOTLIB_AI_CHOOSE_LTG_ITEM, + BOTLIB_AI_CHOOSE_NBG_ITEM, + BOTLIB_AI_TOUCHING_GOAL, + BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE, + BOTLIB_AI_GET_LEVEL_ITEM_GOAL, + BOTLIB_AI_AVOID_GOAL_TIME, + BOTLIB_AI_INIT_LEVEL_ITEMS, + BOTLIB_AI_UPDATE_ENTITY_ITEMS, + BOTLIB_AI_LOAD_ITEM_WEIGHTS, + BOTLIB_AI_FREE_ITEM_WEIGHTS, + BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC, + BOTLIB_AI_ALLOC_GOAL_STATE, + BOTLIB_AI_FREE_GOAL_STATE, + + BOTLIB_AI_RESET_MOVE_STATE, + BOTLIB_AI_MOVE_TO_GOAL, + BOTLIB_AI_MOVE_IN_DIRECTION, + BOTLIB_AI_RESET_AVOID_REACH, + BOTLIB_AI_RESET_LAST_AVOID_REACH, + BOTLIB_AI_REACHABILITY_AREA, + BOTLIB_AI_MOVEMENT_VIEW_TARGET, + BOTLIB_AI_ALLOC_MOVE_STATE, + BOTLIB_AI_FREE_MOVE_STATE, + BOTLIB_AI_INIT_MOVE_STATE, + + BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON, + BOTLIB_AI_GET_WEAPON_INFO, + BOTLIB_AI_LOAD_WEAPON_WEIGHTS, + BOTLIB_AI_ALLOC_WEAPON_STATE, + BOTLIB_AI_FREE_WEAPON_STATE, + BOTLIB_AI_RESET_WEAPON_STATE, + + BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION, + BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC, + BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC, + BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL, + BOTLIB_AI_GET_MAP_LOCATION_GOAL, + BOTLIB_AI_NUM_INITIAL_CHATS, + BOTLIB_AI_GET_CHAT_MESSAGE, + BOTLIB_AI_REMOVE_FROM_AVOID_GOALS, + BOTLIB_AI_PREDICT_VISIBLE_POSITION, + + BOTLIB_AI_SET_AVOID_GOAL_TIME, + BOTLIB_AI_ADD_AVOID_SPOT, + BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL, + BOTLIB_AAS_PREDICT_ROUTE, + BOTLIB_AAS_POINT_REACHABILITY_AREA_INDEX, + + BOTLIB_PC_LOAD_SOURCE, + BOTLIB_PC_FREE_SOURCE, + BOTLIB_PC_READ_TOKEN, + BOTLIB_PC_SOURCE_FILE_AND_LINE, + + G_TIKI_REGISTERMODEL, + G_TIKI_GETBONES, + G_TIKI_SETCHANNELS, + G_TIKI_APPENDFRAMEBOUNDSANDRADIUS, + G_TIKI_ANIMATE, + G_TIKI_GETBONENAMEINDEX, + G_MSG_WRITEBITS, + G_MSG_WRITECHAR, + G_MSG_WRITEBYTE, + G_MSG_WRITESVC, + G_MSG_WRITESHORT, + G_MSG_WRITELONG, + G_MSG_WRITEFLOAT, + G_MSG_WRITESTR, + G_MSG_WRITEANGLE8, + G_MSG_WRITEANGLE16, + G_MSG_WRITECOORD, + G_MSG_WRITEDIR, + G_MSG_STARTCGM, + G_MSG_ENDCGM, + G_MSG_SETCLIENT, + G_MSG_BROADCASTALL, + G_MSG_BROADCASTVISIBLE, + G_MSG_BROADCASTHEARABLE, +} gameImport_t; + + +// +// functions exported by the game subsystem +// +typedef enum { + GAME_INIT, // )( int levelTime, int randomSeed, int restart ); + // init and shutdown will be called every single level + // The game should call G_GET_ENTITY_TOKEN to parse through all the + // entity configuration text and spawn gentities. + + GAME_SHUTDOWN, // (void); + + GAME_CLIENT_CONNECT, // )( int clientNum, qboolean firstTime, qboolean isBot ); + // return NULL if the client is allowed to connect, otherwise return + // a text string with the reason for denial + + GAME_CLIENT_BEGIN, // )( int clientNum ); + + GAME_CLIENT_USERINFO_CHANGED, // )( int clientNum ); + + GAME_CLIENT_DISCONNECT, // )( int clientNum ); + + GAME_CLIENT_COMMAND, // )( int clientNum ); + + GAME_CLIENT_THINK, // )( int clientNum ); + + GAME_RUN_FRAME, // )( int levelTime ); + + GAME_CONSOLE_COMMAND, // )( void ); + // ConsoleCommand will be called when a command has been issued + // that is not recognized as a builtin function. + // The game can issue gi.argc() / gi.argv() commands to get the command + // and parameters. Return qfalse if the game doesn't recognize it as a command. + + BOTAI_START_FRAME // )( int time ); +} gameExport_t; +#endif diff --git a/code/game/g_session.cpp b/code/game/g_session.cpp new file mode 100644 index 00000000..62011042 --- /dev/null +++ b/code/game/g_session.cpp @@ -0,0 +1,130 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +#include "g_local.h" + + +/* +======================================================================= + + SESSION DATA + +Session data is the only data that stays persistant across level loads +and tournament restarts. +======================================================================= +*/ + +bool g_bNewSession = false; + +/* +================ +G_WriteClientSessionData + +Called on game shutdown +================ +*/ +void G_WriteClientSessionData( gclient_t *client ) +{ + gi.Cvar_Set( va( "session%i", ( int )( client - game.clients ) ), + va( "%s %i %i", client->pers.weapon[ 0 ] ? client->pers.weapon : "-", + client->pers.team, + client->pers.kills ) ); +} + +/* +================ +G_ReadSessionData + +Called on a reconnect +================ +*/ +void G_ReadSessionData( gclient_t *client ) +{ + cvar_t *session; + + if( g_bNewSession ) { + return; + } + + session = gi.Cvar_Get( va( "session%i", client - game.clients ), "", 0 ); + + sscanf( session->string, "%s %i %i", &client->pers.weapon, &client->pers.team, &client->pers.kills ); + if( client->pers.weapon[ 0 ] == '-' ) + { + client->pers.weapon[ 0 ] = 0; + } +} + + +/* +================ +G_InitSessionData + +Called on a first-time connect +================ +*/ +void G_InitSessionData( gclient_t *client, char *userinfo ) +{ + G_WriteClientSessionData( client ); +} + + +/* +================== +G_InitWorldSession + +================== +*/ +void G_InitWorldSession( void ) { + char s[MAX_STRING_CHARS]; + int gt; + + cvar_t *v = gi.Cvar_Get( "session", "", 0 ); + + gt = atoi( s ); + + // if the gametype changed since the last session, don't use any + // client sessions + if ( g_gametype->integer != gt ) { + G_Printf( "Gametype changed, clearing session data.\n" ); + } +} + +/* +================== +G_WriteSessionData + +================== +*/ +void G_WriteSessionData( void ) { + int i; + + gi.Cvar_Set( "session", va( "%i", g_gametype->integer ) ); + + for ( i = 0 ; i < game.maxclients ; i++ ) + { + if ( game.clients[i].pers.enterTime != 0.0f ) + { + G_WriteClientSessionData( &game.clients[i] ); + } + } +} diff --git a/code/game/g_utils.cpp b/code/game/g_utils.cpp new file mode 100644 index 00000000..9901309d --- /dev/null +++ b/code/game/g_utils.cpp @@ -0,0 +1,2790 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// g_utils.c -- misc utility functions for game module + +#include "g_local.h" +#include "actor.h" +#include "player.h" +#include "playerbot.h" + +typedef struct { + char oldShader[MAX_QPATH]; + char newShader[MAX_QPATH]; + float timeOffset; +} shaderRemap_t; + +#define MAX_SHADER_REMAPS 128 + +int remapCount = 0; +shaderRemap_t remappedShaders[MAX_SHADER_REMAPS]; + +const char *means_of_death_strings[ MOD_TOTAL_NUMBER ] = +{ + "none", + "suicide", + "crush", + "crush_every_frame", + "telefrag", + "lava", + "slime", + "falling", + "last_self_inflicted", + "explosion", + "explodewall", + "electric", + "electric_water", + "thrown_object", + "grenade", + "beam", + "rocket", + "impact", + "bullet", + "fast_bullet", + "vehicle", + "fire", + "flashbang", + "on_fire", + "gib", + "impale", + "bash", + "shotgun", +}; + +// FIXME: OLD Q3 CODE +#if 0 + +/* +============= +G_PickTarget + +Selects a random entity from among the targets +============= +*/ +#define MAXCHOICES 32 + +gentity_t *G_PickTarget (char *targetname) +{ + gentity_t *ent = NULL; + int num_choices = 0; + gentity_t *choice[MAXCHOICES]; + + if (!targetname) + { + G_Printf("G_PickTarget called with NULL targetname\n"); + return NULL; + } + + while(1) + { + ent = G_Find (ent, FOFS(targetname), targetname); + if (!ent) + break; + choice[num_choices++] = ent; + if (num_choices == MAXCHOICES) + break; + } + + if (!num_choices) + { + G_Printf("G_PickTarget: target %s not found\n", targetname); + return NULL; + } + + return choice[rand() % num_choices]; +} + + +/* +============================== +G_UseTargets + +"activator" should be set to the entity that initiated the firing. + +Search for (string)targetname in all entities that +match (string)self.target and call their .use function + +============================== +*/ +void G_UseTargets( gentity_t *ent, gentity_t *activator ) { + gentity_t *t; + + if ( !ent ) { + return; + } + + //if (ent->targetShaderName && ent->targetShaderNewName) { + // float f = level.time * 0.001; + // AddRemap(ent->targetShaderName, ent->targetShaderNewName, f); + // gi.SetConfigstring(CS_SHADERSTATE, BuildShaderStateConfig()); + //} + + if ( !ent->target ) { + return; + } + + t = NULL; + while ( (t = G_Find (t, FOFS(targetname), ent->target)) != NULL ) { + if ( t == ent ) { + G_Printf ("WARNING: Entity used itself.\n"); + } else { + if ( t->use ) { + t->use (t, ent, activator); + } + } + if ( !ent->inuse ) { + G_Printf("entity was removed while using targets\n"); + return; + } + } +} + +#endif + +int MOD_NameToNum( const str &meansOfDeath ) +{ + int i; + + for ( i = 0 ; i < MOD_TOTAL_NUMBER ; i++ ) + { + if ( !meansOfDeath.icmp( means_of_death_strings[ i ] ) ) + return i; + } + + gi.DPrintf( "Unknown means of death - %s\n", meansOfDeath.c_str() ); + return -1; +} + +const char *MOD_NumToName( int meansOfDeath ) +{ + if ( ( meansOfDeath > MOD_TOTAL_NUMBER ) || ( meansOfDeath < 0 ) ) + { + gi.DPrintf( "Unknown means of death num - %d\n", meansOfDeath ); + return ""; + } + + return means_of_death_strings[ meansOfDeath ]; +} + +qboolean MOD_matches( int incoming_damage, int damage_type ) +{ + if ( damage_type == -1 ) + { + return true; + } + + return false; +} + +void AddRemap(const char *oldShader, const char *newShader, float timeOffset) { + int i; + + for (i = 0; i < remapCount; i++) { + if (Q_stricmp(oldShader, remappedShaders[i].oldShader) == 0) { + // found it, just update this one + strcpy(remappedShaders[i].newShader,newShader); + remappedShaders[i].timeOffset = timeOffset; + return; + } + } + if (remapCount < MAX_SHADER_REMAPS) { + strcpy(remappedShaders[remapCount].newShader,newShader); + strcpy(remappedShaders[remapCount].oldShader,oldShader); + remappedShaders[remapCount].timeOffset = timeOffset; + remapCount++; + } +} + +const char *BuildShaderStateConfig(void) { + static char buff[MAX_STRING_CHARS*4]; + char out[(MAX_QPATH * 2) + 5]; + int i; + + memset(buff, 0, MAX_STRING_CHARS); + for (i = 0; i < remapCount; i++) { + Com_sprintf(out, (MAX_QPATH * 2) + 5, "%s=%s:%5.2f@", remappedShaders[i].oldShader, remappedShaders[i].newShader, remappedShaders[i].timeOffset); + Q_strcat( buff, sizeof( buff ), out); + } + return buff; +} + +/* +================= +G_Random + +Returns a number from 0<= num < 1 + +random() +================= +*/ + +float G_Random + ( + void + ) + +{ + return ( ( float )( rand() & 0x7fff ) ) / ( ( float )0x8000 ); +} + +/* +================= +G_Random + +Returns a number from 0 <= num < n + +random() +================= +*/ + +float G_Random + ( + float n + ) + +{ + return G_Random() * n; +} + +/* +================= +G_CRandom + +Returns a number from -1 <= num < 1 + +crandom() +================= +*/ + +float G_CRandom + ( + void + ) + +{ + return G_Random( 2 ) - 1; +} + +/* +================= +G_CRandom + +Returns a number from -n <= num < n + +crandom() +================= +*/ + +float G_CRandom + ( + float n + ) + +{ + return G_CRandom() * n; +} + +/* +========================================================================= + +model / sound configstring indexes + +========================================================================= +*/ + +/* +================ +G_FindConfigstringIndex + +================ +*/ +int G_FindConfigstringIndex( const char *name, int start, int max, qboolean create ) { + int i; + char *s; + + if ( !name || !name[0] ) { + return 0; + } + + for ( i=1 ; is.pos.trTime = 0; + VectorClear( ent->s.pos.trDelta ); + + VectorCopy( org, ent->s.origin ); +} + +/* +=============== +G_SetConstantLight + +Sets the encoded constant light parameter for entities +=============== +*/ +void G_SetConstantLight +( +int * constantlight, +float * red, +float * green, +float * blue, +float * radius, +int * lightStyle +) + +{ + int ir, ig, ib, iradius; + + if( !constantlight ) + return; + + ir = ( *constantlight ) & 255; + ig = ( ( *constantlight ) >> 8 ) & 255; + ib = ( ( *constantlight ) >> 16 ) & 255; + iradius = ( ( *constantlight ) >> 24 ) & 255; + + if( red ) + { + ir = *red * 255; + if( ir > 255 ) + ir = 255; + } + + if( green ) + { + ig = *green * 255; + if( ig > 255 ) + ig = 255; + } + + if( blue ) + { + ib = *blue * 255; + if( ib > 255 ) + ib = 255; + } + + if( radius ) + { + iradius = *radius / CONSTANTLIGHT_RADIUS_SCALE; + if( iradius > 255 ) + iradius = 255; + } + + if( lightStyle ) + { + ir = *lightStyle; + if( ir > 255 ) + ir = 255; + } + *constantlight = ( ir )+( ig << 8 ) + ( ib << 16 ) + ( iradius << 24 ); +} + +//===================================================================== + + +/* +================ +G_TeamCommand + +Broadcasts a command to only a specific team +================ +*/ +void G_TeamCommand( teamtype_t team, char *cmd ) { + int i; + + for ( i = 0 ; i < game.maxclients ; i++ ) + { + if ( game.clients[i].pers.enterTime != 0.0f ) + { + if ( game.clients[i].pers.team == team ) { + gi.SendServerCommand( i, va("%s", cmd )); + } + } + } +} + +/* +============= +M_CheckBottom + +Returns false if any part of the bottom of the entity is off an edge that +is not a staircase. + +============= +*/ +int c_yes, c_no; + +qboolean M_CheckBottom( Entity *ent ) +{ + Vector mins, maxs, start, stop; + trace_t trace; + int x, y; + float mid, bottom; + + mins = ent->origin + ent->mins * 0.5; + maxs = ent->origin + ent->maxs * 0.5; + + // if all of the points under the corners are solid world, don't bother + // with the tougher checks + // the corners must be within 16 of the midpoint + start[ 2 ] = mins[ 2 ] - 1; + + for( x = 0; x <= 1; x++ ) + { + for( y = 0; y <= 1; y++ ) + { + start[ 0 ] = x ? maxs[ 0 ] : mins[ 0 ]; + start[ 1 ] = y ? maxs[ 1 ] : mins[ 1 ]; + if( gi.PointContents( start, 0 ) != CONTENTS_SOLID ) + { + goto realcheck; + } + } + } + + c_yes++; + return true; // we got out easy + +realcheck: + + c_no++; + + // + // check it for real... + // + start[ 2 ] = mins[ 2 ]; + + // the midpoint must be within 16 of the bottom + start[ 0 ] = stop[ 0 ] = ( mins[ 0 ] + maxs[ 0 ] ) * 0.5; + start[ 1 ] = stop[ 1 ] = ( mins[ 1 ] + maxs[ 1 ] ) * 0.5; + stop[ 2 ] = start[ 2 ] - 3 * STEPSIZE;//2 * STEPSIZE; + + trace = G_Trace( start, vec_zero, vec_zero, stop, ent, MASK_MONSTERSOLID, false, "M_CheckBottom 1" ); + + if( trace.fraction == 1.0 ) + { + return false; + } + + mid = bottom = trace.endpos[ 2 ]; + + // the corners must be within 16 of the midpoint + for( x = 0; x <= 1; x++ ) + { + for( y = 0; y <= 1; y++ ) + { + start[ 0 ] = stop[ 0 ] = x ? maxs[ 0 ] : mins[ 0 ]; + start[ 1 ] = stop[ 1 ] = y ? maxs[ 1 ] : mins[ 1 ]; + + trace = G_Trace( start, vec_zero, vec_zero, stop, ent, MASK_MONSTERSOLID, false, "M_CheckBottom 2" ); + + if( trace.fraction != 1.0 && trace.endpos[ 2 ] > bottom ) + { + bottom = trace.endpos[ 2 ]; + } + + if( trace.fraction == 1.0 || mid - trace.endpos[ 2 ] > STEPSIZE ) + { + return false; + } + } + } + + c_yes++; + return true; +} + +/* +============= +G_Find + +Searches all active entities for the next one that holds +the matching string at fieldofs (use the FOFS() macro) in the structure. + +Searches beginning at the entity after from, or the beginning if NULL +NULL will be returned if the end of the list is reached. + +============= +*/ +gentity_t *G_Find( gentity_t *from, int fieldofs, const char *match ) +{ + char *s; + + if( !from ) + from = g_entities; + else + from++; + + for( ; from < &g_entities[ globals.num_entities ]; from++ ) + { + if( !from->inuse ) + continue; + s = *( char ** )( ( byte * )from + fieldofs ); + if( !s ) + continue; + if( !Q_stricmp( s, match ) ) + return from; + } + + return NULL; +} + +/* +============= +TempVector + +This is just a convenience function +for making temporary vectors for function calls +============= +*/ +float *tv( float x, float y, float z ) { + static int index; + static vec3_t vecs[8]; + float *v; + + // use an array so that multiple tempvectors won't collide + // for a while + v = vecs[index]; + index = (index + 1)&7; + + v[0] = x; + v[1] = y; + v[2] = z; + + return v; +} + + +/* +============= +VectorToString + +This is just a convenience function +for printing vectors +============= +*/ +char *vtos( const vec3_t v ) { + static int index; + static char str[8][32]; + char *s; + + // use an array so that multiple vtos won't collide + s = str[index]; + index = (index + 1)&7; + + Com_sprintf (s, 32, "(%i %i %i)", (int)v[0], (int)v[1], (int)v[2]); + + return s; +} + +Entity *G_NextEntity +( +Entity *ent +) + +{ + gentity_t *from; + + if( !g_entities ) + { + return NULL; + } + + if( !ent ) + { + from = g_entities; + } else + { + from = ent->edict + 1; + } + + if( !from ) + { + return NULL; + } + + for( ; from < &g_entities[ globals.num_entities ]; from++ ) + { + if( !from->inuse || !from->entity ) + { + continue; + } + + return from->entity; + } + + return NULL; +} + +/* +=============== +G_GetMovedir + +QuakeEd only writes a single float for angles (bad idea), so up and down are +just constant angles. +=============== +*/ +Vector G_GetMovedir( float angle ) +{ + if( angle == -1.0f ) + { + return Vector( 0.0f, 0.0f, 1.0f ); + } + else if( angle == -2.0f ) + { + return Vector( 0.0f, 0.0f, -1.0f ); + } + + angle *= ( M_PI * 2.0f / 360.0f ); + return Vector( cos( angle ), sin( angle ), 0.0f ); +} + +/* +=============== +G_SetMovedir + +The editor only specifies a single value for angles (yaw), +but we have special constants to generate an up or down direction. +Angles will be cleared, because it is being used to represent a direction +instead of an orientation. +=============== +*/ +void G_SetMovedir( vec3_t angles, vec3_t movedir ) { + 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}; + + if ( VectorCompare (angles, VEC_UP) ) { + VectorCopy (MOVEDIR_UP, movedir); + } else if ( VectorCompare (angles, VEC_DOWN) ) { + VectorCopy (MOVEDIR_DOWN, movedir); + } else { + AngleVectors (angles, movedir, NULL, NULL); + } + VectorClear( angles ); +} + + +float vectoyaw( const vec3_t vec ) { + float yaw; + + if (vec[YAW] == 0 && vec[PITCH] == 0) { + yaw = 0; + } else { + if (vec[PITCH]) { + yaw = ( atan2( vec[YAW], vec[PITCH]) * 180 / M_PI ); + } else if (vec[YAW] > 0) { + yaw = 90; + } else { + yaw = 270; + } + if (yaw < 0) { + yaw += 360; + } + } + + return yaw; +} + +/* +================= +g_entitiesFree +================= +*/ +qboolean g_entitiesFree( void ) { + int i; + gentity_t *e; + + e = &g_entities[MAX_CLIENTS]; + for ( i = MAX_CLIENTS; i < globals.num_entities; i++, e++) { + if ( e->inuse ) { + continue; + } + // slot available + return qtrue; + } + return qfalse; +} + + +/* +================= +G_FreeEntity + +Marks the entity as free +================= +*/ +void G_FreeEntity( gentity_t *ed ) +{ + gi.UnlinkEntity( ed ); // unlink from world + + memset( ed, 0, sizeof( *ed ) ); + + ed->inuse = qfalse; +} + +/* +============================================================================== + +Kill box + +============================================================================== +*/ + +/* +================= +G_KillBox + +Kills all entities that would touch the proposed new positioning +of ent. Ent should be unlinked before calling this! +================= +*/ +void G_KillBox (gentity_t *ent) { + int i, num; + int touch[MAX_GENTITIES]; + gentity_t *hit; + vec3_t mins, maxs; + + VectorAdd( ent->client->ps.origin, ent->r.mins, mins ); + VectorAdd( ent->client->ps.origin, ent->r.maxs, maxs ); + num = gi.AreaEntities( mins, maxs, touch, MAX_GENTITIES ); + + for (i=0 ; iclient ) { + continue; + } + + // nail it + ent->entity->Damage( hit->entity, ent->entity, 100000, vec_zero, vec_zero, + vec_zero, 0, DAMAGE_NO_PROTECTION, MOD_TELEFRAG ); + } + +} + +//============================================================================== + +/* +============= +G_Sound +============= +*/ +void G_Sound( gentity_t *ent, int channel, int soundIndex ) { + +} + + +//============================================================================== + + +/* +================= +KillBox + +Kills all entities that would touch the proposed new positioning +of ent. Ent should be unlinked before calling this! +================= +*/ +qboolean KillBox +( +Entity *ent +) + +{ + int i; + int num; + int touch[ MAX_GENTITIES ]; + gentity_t *hit; + Vector min; + Vector max; + int fail; + + fail = 0; + + min = ent->origin + ent->mins; + max = ent->origin + ent->maxs; + + num = gi.AreaEntities( min, max, touch, MAX_GENTITIES ); + + for( i = 0; i < num; i++ ) + { + hit = &g_entities[ touch[ i ] ]; + + if( !hit->inuse || ( hit->entity == ent ) || !hit->entity || ( hit->entity == world ) || ( !hit->entity->edict->solid ) ) + { + continue; + } + + hit->entity->Damage( ent, ent, hit->entity->health + 100000, ent->origin, vec_zero, vec_zero, + 0, DAMAGE_NO_PROTECTION, MOD_TELEFRAG ); + + // + // if we didn't kill it, fail + // + if( hit->entity->getSolidType() != SOLID_NOT ) + { + fail++; + } + } + + // + // all clear + // + return !fail; +} + + +/* +============ +G_TouchSolids + +Call after linking a new trigger in during gameplay +to force all entities it covers to immediately touch it +============ +*/ +void G_TouchSolids +( +Entity *ent +) + +{ + int i; + int num; + int touch[ MAX_GENTITIES ]; + gentity_t *hit; + Event *ev; + + num = gi.AreaEntities( ent->absmin, ent->absmax, touch, MAX_GENTITIES ); + + // be careful, it is possible to have an entity in this + // list removed before we get to it (killtriggered) + for( i = 0; i < num; i++ ) + { + hit = &g_entities[ touch[ i ] ]; + if( !hit->inuse ) + { + continue; + } + + assert( hit->entity ); + + //FIXME + // should we post the events so that we don't have to worry about any entities going away + ev = new Event( EV_Touch ); + ev->AddEntity( ent ); + hit->entity->ProcessEvent( ev ); + hit->entity->Unregister( "touch" ); + } +} + +void G_ShowSightTrace + ( + gentity_t *passent1, + gentity_t *passent2, + const char *reason + ) + +{ + str text; + str pass1; + str pass2; + + assert( reason ); + + if( passent1 ) + { + pass1 = va( "'%s'(%d)", passent1->entname, passent1->s.number ); + } + else + { + pass1 = "NULL"; + } + + if( passent2 ) + { + pass2 = va( "'%s'(%d)", passent2->entname, passent2->s.number ); + } + else + { + pass2 = "NULL"; + } + + text = va( "%0.2f : Pass1 %s Pass2 %s : '%s'\n", + level.time, pass1.c_str(), pass2.c_str(), reason ? reason : "" ); + + if( sv_traceinfo->integer == 3 ) + { + gi.DebugPrintf( text.c_str() ); + } + else + { + gi.DPrintf( "%s", text.c_str() ); + } +} + +void G_ShowTrace + ( + trace_t *trace, + gentity_t *passent, + const char *reason + ) + +{ + str text; + str pass; + str hit; + + assert( reason ); + assert( trace ); + + if( passent ) + { + pass = va( "'%s'(%d)", passent->entname, passent->s.number ); + } + else + { + pass = "NULL"; + } + + if( trace->ent ) + { + hit = va( "'%s'(%d)", trace->ent->entname, trace->ent->s.number ); + } + else + { + hit = "NULL"; + } + + text = va( "%0.2f : Pass %s Frac %f Hit %s : '%s'\n", + level.time, pass.c_str(), trace->fraction, hit.c_str(), reason ? reason : "" ); + + if( sv_traceinfo->integer == 3 ) + { + gi.DebugPrintf( text.c_str() ); + } + else + { + gi.DPrintf( "%s", text.c_str() ); + } +} + +void G_CalcBoundsOfMove +( +Vector &start, +Vector &end, +Vector &mins, +Vector &maxs, +Vector *minbounds, +Vector *maxbounds +) + +{ + Vector bmin; + Vector bmax; + + ClearBounds( bmin, bmax ); + AddPointToBounds( start, bmin, bmax ); + AddPointToBounds( end, bmin, bmax ); + bmin += mins; + bmax += maxs; + + if( minbounds ) + { + *minbounds = bmin; + } + + if( maxbounds ) + { + *maxbounds = bmax; + } +} + +bool G_SightTrace +( +Vector &start, +Vector &mins, +Vector &maxs, +Vector &end, +gentity_t *passent, +gentity_t *passent2, +int contentmask, +qboolean cylinder, +const char *reason +) + +{ + int entnum, entnum2; + bool result; + + assert( reason ); + + if( passent == NULL ) + { + entnum = ENTITYNUM_NONE; + } + else + { + entnum = passent->s.number; + } + + if( passent2 == NULL ) + { + entnum2 = ENTITYNUM_NONE; + } + else + { + entnum2 = passent2->s.number; + } + + result = gi.SightTrace( start, mins, maxs, end, entnum, entnum2, contentmask, cylinder ) ? true : false; + + if( sv_traceinfo->integer > 1 ) + { + G_ShowSightTrace( passent, passent2, reason ); + } + + sv_numtraces++; + + if( sv_drawtrace->integer ) + { + G_DebugLine( start, end, 1, 1, 0, 1 ); + } + + return result; +} + +bool G_SightTrace + ( + Vector &start, + Vector &mins, + Vector &maxs, + Vector &end, + Entity *passent, + Entity *passent2, + int contentmask, + qboolean cylinder, + const char *reason + ) + +{ + gentity_t *ent, *ent2; + int entnum, entnum2; + bool result; + + assert( reason ); + + if( passent == NULL || !passent->isSubclassOf( Entity ) ) + { + ent = NULL; + entnum = ENTITYNUM_NONE; + } + else + { + ent = passent->edict; + entnum = ent->s.number; + } + + if( passent2 == NULL || !passent2->isSubclassOf( Entity ) ) + { + ent2 = NULL; + entnum2 = ENTITYNUM_NONE; + } + else + { + ent2 = passent2->edict; + entnum2 = ent2->s.number; + } + + result = gi.SightTrace( start, mins, maxs, end, entnum, entnum2, contentmask, cylinder ) ? true : false; + + if( sv_traceinfo->integer > 1 ) + { + G_ShowSightTrace( ent, ent2, reason ); + } + + sv_numtraces++; + + if( sv_drawtrace->integer ) + { + G_DebugLine( start, end, 1, 1, 0, 1 ); + } + + return result; +} + +trace_t G_Trace + ( + vec3_t start, + vec3_t mins, + vec3_t maxs, + vec3_t end, + gentity_t *passent, + int contentmask, + qboolean cylinder, + const char *reason, + qboolean tracedeep + ) + +{ + int entnum; + trace_t trace; + + if( passent ) + { + entnum = passent->s.number; + } + else + { + entnum = ENTITYNUM_NONE; + } + + gi.Trace( &trace, start, mins, maxs, end, entnum, contentmask, cylinder, tracedeep ); + + if( trace.entityNum == ENTITYNUM_NONE ) + { + trace.ent = NULL; + } + else + { + trace.ent = &g_entities[ trace.entityNum ]; + } + + if( sv_traceinfo->integer > 1 ) + { + G_ShowTrace( &trace, passent, reason ); + } + + sv_numtraces++; + + if( sv_drawtrace->integer ) + { + G_DebugLine( Vector( start ), Vector( end ), 1, 1, 0, 1 ); + } + + return trace; +} + +trace_t G_Trace + ( + Vector &start, + Vector &mins, + Vector &maxs, + Vector &end, + Entity *passent, + int contentmask, + qboolean cylinder, + const char *reason, + qboolean tracedeep + ) + +{ + gentity_t *ent; + int entnum; + trace_t trace; + + assert( reason ); + + if( passent == NULL || !passent->isSubclassOf( Entity ) ) + { + ent = NULL; + entnum = ENTITYNUM_NONE; + } + else + { + ent = passent->edict; + entnum = ent->s.number; + } + + gi.Trace( &trace, start, mins, maxs, end, entnum, contentmask, cylinder, tracedeep ); + + if( trace.entityNum == ENTITYNUM_NONE ) + { + trace.ent = NULL; + } + else + { + trace.ent = &g_entities[ trace.entityNum ]; + } + + if( sv_traceinfo->integer > 1 ) + { + G_ShowTrace( &trace, ent, reason ); + } + + sv_numtraces++; + + if( sv_drawtrace->integer ) + { + G_DebugLine( start, end, 1, 1, 0, 1 ); + } + + return trace; +} + +void G_TraceEntities + ( + Vector &start, + Vector &mins, + Vector &maxs, + Vector &end, + Container*victimlist, + int contentmask, + qboolean bIncludeTriggers + ) + +{ + trace_t trace; + vec3_t boxmins; + vec3_t boxmaxs; + int num; + int touchlist[ MAX_GENTITIES ]; + gentity_t *touch; + int i; + + + // Find the bounding box + + for( i = 0; i<3; i++ ) + { + if( end[ i ] > start[ i ] ) + { + boxmins[ i ] = start[ i ] + mins[ i ] - 1; + boxmaxs[ i ] = end[ i ] + maxs[ i ] + 1; + } + else + { + boxmins[ i ] = end[ i ] + mins[ i ] - 1; + boxmaxs[ i ] = start[ i ] + maxs[ i ] + 1; + } + } + + // Find the list of entites + + num = gi.AreaEntities( boxmins, boxmaxs, touchlist, MAX_GENTITIES ); + + for( i = 0; isolid == SOLID_NOT ) + continue; + if( touch->solid == SOLID_TRIGGER && !bIncludeTriggers ) + continue; + + gi.ClipToEntity( &trace, start, mins, maxs, end, touchlist[ i ], contentmask ); + + if( trace.entityNum == touchlist[ i ] ) + victimlist->AddObject( touch->entity ); + } +} + +float PlayersRangeFromSpot + ( + Entity *ent + ) + +{ + float bestplayerdistance = 9999999.0f; + Vector vDist; + int i; + gentity_t *e; + Player *player; + + if( g_gametype->integer > GT_FFA ) { + return bestplayerdistance; + } + + // find the nearest player from the post + for( i = 0, e = g_entities; i < game.maxclients; i++, e++ ) + { + if( !e->client || !e->entity ) { + continue; + } + + player = ( Player * )e->entity; + if( !player->IsDead() && !player->IsSpectator() ) + { + vDist = ent->origin - player->origin; + if( bestplayerdistance > vDist.length() ) + bestplayerdistance = vDist.length(); + } + } + + return bestplayerdistance; +} + +/* +================ +G_SetOrigin + +Sets the pos trajectory for a fixed position +================ +*/ +void G_SetOrigin( gentity_t *ent, vec3_t origin ) { + VectorCopy( origin, ent->s.origin ); + ent->s.pos.trTime = 0; + VectorClear( ent->s.pos.trDelta ); + + VectorCopy( origin, ent->r.currentOrigin ); +} + +/* +================= +findradius + +Returns entities that have origins within a spherical area + +findradius (org, radius) +================= +*/ +Entity *findradius +( +Entity *startent, +Vector org, +float rad +) + +{ + Vector eorg; + gentity_t *from; + float r2, distance; + + if( !startent ) + { + from = active_edicts.next; + } + else + { + from = startent->edict->next; + } + + assert( from ); + if( !from ) + { + return NULL; + } + + assert( ( from == &active_edicts ) || ( from->inuse ) ); + + // square the radius so that we don't have to do a square root + r2 = rad * rad; + + for( ; from != &active_edicts; from = from->next ) + { + assert( from->inuse ); + assert( from->entity ); + + eorg = org - from->entity->centroid; + + // dot product returns length squared + distance = eorg * eorg; + + if( distance <= r2 ) + { + return from->entity; + } + else + { + // subtract the object's own radius from this distance + distance -= from->radius2; + if( distance <= r2 ) + { + return from->entity; + } + } + } + + return NULL; +} + +/* +================= +findclientinradius + +Returns clients that have origins within a spherical area + +findclientinradius (org, radius) +================= +*/ +Entity *findclientsinradius +( +Entity *startent, +Vector org, +float rad +) + +{ + Vector eorg; + gentity_t *ed; + float r2; + int i; + + // square the radius so that we don't have to do a square root + r2 = rad * rad; + + if( !startent ) + { + i = 0; + } else + { + i = startent->entnum + 1; + } + + for( ; i < game.maxclients; i++ ) + { + ed = &g_entities[ i ]; + + if( !ed->inuse || !ed->entity ) + { + continue; + } + + eorg = org - ed->entity->centroid; + + // dot product returns length squared + if( ( eorg * eorg ) <= r2 ) + { + return ed->entity; + } + } + + return NULL; +} + +Vector G_CalculateImpulse( const Vector &start, const Vector &end, float speed, float gravity ) +{ + float traveltime, vertical_speed; + Vector dir, xydir, velocity; + + dir = end - start; + xydir = dir; + xydir.z = 0; + traveltime = xydir.length() / speed; + vertical_speed = ( dir.z / traveltime ) + ( 0.5f * gravity * sv_gravity->value * traveltime ); + xydir.normalize(); + + velocity = speed * xydir; + velocity.z = vertical_speed; + return velocity; +} + +/* +================ +DebugLine + + debug polygons only work when running a local game + with r_debugSurface set to 2 +================ +*/ +int DebugLine(vec3_t start, vec3_t end, int color) { + vec3_t points[4], dir, cross, up = {0, 0, 1}; + float dot; + + VectorCopy(start, points[0]); + VectorCopy(start, points[1]); + //points[1][2] -= 2; + VectorCopy(end, points[2]); + //points[2][2] -= 2; + VectorCopy(end, points[3]); + + + 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); + + VectorNormalize(cross); + + VectorMA(points[0], 2, cross, points[0]); + VectorMA(points[1], -2, cross, points[1]); + VectorMA(points[2], -2, cross, points[2]); + VectorMA(points[3], 2, cross, points[3]); + + //return gi.DebugPolygonCreate(color, 4, points); + // FIXME + return 0; +} + +void G_DebugDamage + ( + float damage, + Entity *victim, + Entity *attacker, + Entity *inflictor + ) + +{ + gi.DPrintf( "Victim:%s Attacker:%s Inflictor:%s Damage:%f\n", victim->getClassname(), attacker->getClassname(), inflictor->getClassname(), damage ); +} + + +void G_DebugString + ( + Vector pos, + float scale, + float r, + float g, + float b, + const char *pszText, + ... + ) + +{ + debugstring_t *string; + va_list va; + char szTemp[ 32768 ]; + + if( !g_numdebugstrings ) { + return; + } + + if( *gi.numDebugStrings < g_numdebugstrings->integer ) + { + string = ( debugstring_t * )&DebugStrings[ *gi.numDebugStrings ]; + + ( *gi.numDebugStrings )++; + + va_start( va, pszText ); + vsprintf( szTemp, pszText, va ); + va_end( va ); + + VectorCopy( pos, string->pos ); + string->scale = scale; + string->color[ 0 ] = r; + string->color[ 1 ] = g; + string->color[ 2 ] = b; + string->color[ 3 ] = 1.0f; + strncpy( string->szText, szTemp, sizeof( string->szText ) ); + string->szText[ sizeof( string->szText ) - 1 ] = 0; + } + else + { + gi.DPrintf( "G_DebugString: Exceeded g_numdebugstrings\n" ); + } +} + +void G_FadeOut + ( + float delaytime + ) + +{ + // Fade the screen out + level.m_fade_color = Vector( 0, 0, 0 ); + level.m_fade_alpha = 1.0f; + level.m_fade_time = delaytime; + level.m_fade_time_start = delaytime; + level.m_fade_type = fadeout; + level.m_fade_style = alphablend; +} + +void G_AutoFadeIn +( +void +) + +{ + level.m_fade_time_start = 1; + level.m_fade_time = 1; + level.m_fade_color[ 0 ] = 0; + level.m_fade_color[ 1 ] = 0; + level.m_fade_color[ 2 ] = 0; + level.m_fade_alpha = 1; + level.m_fade_type = fadein; + level.m_fade_style = alphablend; +} + +void G_ClearFade +( +void +) + +{ + level.m_fade_time = -1; + level.m_fade_type = fadein; +} + +void G_FadeSound +( +float delaytime +) +{ + float time; + + // Fade the screen out + time = delaytime * 1000; + gi.SendServerCommand( NULL, va( "fadesound %0.2f", time ) ); +} + +void G_MissionFailed +( +void +) + +{ + // Make the music system play the failure music for this level + ChangeMusic( "failure", "normal", true ); + + //G_PlayerDied( 3 ); + + // tell the player they f'd up + gi.centerprintf( &g_entities[ 0 ], "@textures/menu/mission.tga" ); + + level.mission_failed = true; +} + +void G_StartCinematic +( +void +) + +{ + level.cinematic = true; + gi.Cvar_Set( "sv_cinematic", "1" ); +} + +void G_StopCinematic + ( + void + ) + +{ + // clear out the skip thread + level.cinematic = false; + gi.Cvar_Set( "sv_cinematic", "0" ); +} + +void G_CenterPrintToAllClients( const char *pszString ) +{ + gentity_t *ent; + int i; + + for( i = 0, ent = g_entities; i < game.maxclients; ent++, i++ ) + { + if( !ent->inuse || !ent->entity ) { + continue; + } + + gi.centerprintf( ent, va( "%s\n", pszString ) ); + } +} + +void G_PrintToAllClients( const char *pszString, qboolean bBold ) +{ + if( bBold ) + { + gi.SendServerCommand( -1, "print \"" HUD_MESSAGE_WHITE "%s\n\"", pszString ); + } + else + { + gi.SendServerCommand( -1, "print \"" HUD_MESSAGE_YELLOW "%s\n\"", pszString ); + } +} + +void G_PrintDeathMessage( const char *pszString ) +{ + gentity_t *ent; + int i; + + for( i = 0, ent = g_entities; i < game.maxclients; i++, ent++ ) + { + if( !ent->inuse || !ent->entity ) { + continue; + } + + gi.SendServerCommand( ent - g_entities, "print \"" HUD_MESSAGE_CHAT_RED "%s\"", pszString ); + } +} + +void G_WarnPlayer( Player *player, const char *format, ... ) +{ + char buffer[ 4100 ]; + va_list va; + + va_start( va, format ); + vsprintf( buffer, format, va ); + va_end( va ); + + gi.SendServerCommand( player->client->ps.clientNum, "print \"%s\"\n", buffer ); + gi.SendServerCommand( player->client->ps.clientNum, "print \"%c%s\"", HUD_MESSAGE_YELLOW, buffer ); +} + +dtiki_t *modelTiki( const char *mdl ) +{ + str name; + + assert( mdl ); + + if( !mdl ) + { + return 0; + } + + // Prepend 'models/' to make things easier + if( !strchr( mdl, '*' ) && !strchr( mdl, '\\' ) && !strchr( mdl, '/' ) ) + { + name = "models/"; + } + + name += mdl; + + return gi.modeltiki( name.c_str() ); +} + +void G_ProcessCacheInitCommands( dtiki_t *tiki ) +{ + dtikicmd_t *pcmd; + + if( tiki->a->num_server_initcmds ) + { + int i, j; + Event *event; + + for( i = 0; i < tiki->a->num_server_initcmds; i++ ) + { + pcmd = &tiki->a->server_initcmds[ i ]; + event = new Event( pcmd->args[ 0 ] ); + + if( Director.GetFlags( event ) & EV_CACHE ) + { + for( j = 1; j < pcmd->num_args; j++ ) + { + event->AddToken( pcmd->args[ j ] ); + } + + if( !Director.ProcessEvent( event ) ) + { + Com_Printf( "^~^~^ Entity::G_ProcessCacheInitCommands: Bad init server command '%s' in '%s'\n", pcmd->args[ 0 ], tiki->name ); + } + } + else + { + delete event; + } + } + } +} + +void CacheResource( const char *stuff ) +{ + AliasListNode_t *ret; + qboolean streamed = qfalse; + char filename[ MAX_STRING_TOKENS ]; + + if( !stuff ) + return; + + if( !strchr( stuff, '.' ) ) + { + // must be a global alias + stuff = gi.GlobalAlias_FindRandom( stuff, &ret ); + if( !stuff ) + { + if( gi.fsDebug->integer ) + Com_Printf( "alias not found\n" ); + + return; + } + streamed = ret->streamed; + } + + strcpy( filename, stuff ); + gi.FS_CanonicalFilename( filename ); + + if( strstr( filename, ".wav" ) ) + { + gi.soundindex( filename, streamed ); + } + else if( strstr( filename, ".mp3" ) ) + { + gi.soundindex( filename, streamed ); + } + else if( strstr( filename, ".tik" ) ) + { + dtiki_t *tiki; + + if( *stuff && strncmp( "models/", stuff, 7 ) ) + { + sprintf( filename, "models/%s", stuff ); + } + else + { + strcpy( filename, stuff ); + } + + gi.FS_CanonicalFilename( filename ); + + tiki = gi.TIKI_RegisterModel( filename ); + + if( tiki ) + G_ProcessCacheInitCommands( tiki ); + } + else if( strstr( filename, ".scr" ) ) + { + Director.GetScript( filename ); + } +} + +void ChangeMusic( const char *current, const char *fallback, qboolean force ) +{ + int j; + gentity_t *other; + + if( current || fallback ) + { + for( j = 0; j < game.maxclients; j++ ) + { + other = &g_entities[ j ]; + if( other->inuse && other->client ) + { + Player *client; + + client = ( Player * )other->entity; + client->ChangeMusic( current, fallback, force ); + } + } + + if( current && fallback ) + { + gi.DPrintf( "music set to %s with fallback %s\n", current, fallback ); + } + } +} + +void ChangeMusicVolume( float volume, float fade_time ) +{ + int j; + gentity_t *other; + + for( j = 0; j < game.maxclients; j++ ) + { + other = &g_entities[ j ]; + if( other->inuse && other->client ) + { + Player *client; + + client = ( Player * )other->entity; + client->ChangeMusicVolume( volume, fade_time ); + } + } + gi.DPrintf( "music volume set to %.2f, fade time %.2f\n", volume, fade_time ); +} + +void RestoreMusicVolume( float fade_time ) +{ + int j; + gentity_t *other; + + for( j = 0; j < game.maxclients; j++ ) + { + other = &g_entities[ j ]; + if( other->inuse && other->client ) + { + Player *client; + + client = ( Player * )other->entity; + client->RestoreMusicVolume( fade_time ); + } + } +} + +void ChangeSoundtrack( const char * soundtrack ) +{ + level.saved_soundtrack = level.current_soundtrack; + level.current_soundtrack = soundtrack; + + gi.SetConfigstring( CS_MUSIC, soundtrack ); + gi.DPrintf( "soundtrack switched to %s.\n", soundtrack ); +} + +void RestoreSoundtrack( void ) +{ + if( level.saved_soundtrack.length() ) + { + level.current_soundtrack = level.saved_soundtrack; + level.saved_soundtrack = ""; + + gi.SetConfigstring( CS_MUSIC, level.current_soundtrack.c_str() ); + gi.DPrintf( "soundtrack restored %s.\n", level.current_soundtrack.c_str() ); + } +} + +int G_AIEventTypeFromString + ( + const char *pszType + ) + +{ + if( !Q_stricmp( pszType, "weapon_fire" ) ) + return AI_EVENT_WEAPON_FIRE; + else if( !Q_stricmp( pszType, "weapon_impact" ) ) + return AI_EVENT_WEAPON_IMPACT; + else if( !Q_stricmp( pszType, "explosion" ) ) + return AI_EVENT_EXPLOSION; + else if( !Q_stricmp( pszType, "american_voice" ) ) + return AI_EVENT_AMERICAN_VOICE; + else if( !Q_stricmp( pszType, "german_voice" ) ) + return AI_EVENT_GERMAN_VOICE; + else if( !Q_stricmp( pszType, "american_urgent" ) ) + return AI_EVENT_AMERICAN_URGENT; + else if( !Q_stricmp( pszType, "german_urgent" ) ) + return AI_EVENT_GERMAN_URGENT; + else if( !Q_stricmp( pszType, "misc" ) ) + return AI_EVENT_MISC; + else if( !Q_stricmp( pszType, "misc_loud" ) ) + return AI_EVENT_MISC_LOUD; + else if( !Q_stricmp( pszType, "footstep" ) ) + return AI_EVENT_FOOTSTEP; + else if( !Q_stricmp( pszType, "grenade" ) ) + return AI_EVENT_GRENADE; + else + return AI_EVENT_NONE; +} + +float G_AIEventRadius + ( + int iType + ) + +{ + static float fRadius[] = + { + 2048.0f, + 384.0f, + 4096.0f, + 1024.0f, + 1024.0f, + 1536.0f, + 1536.0f, + 1500.0f, + 2250.0f, + 512.0f, + 384.0f, + 0, + 0, + 0, + 0 + }; + + if( iType <= 11 ) + { + return fRadius[ iType ]; + } + else + { + Com_Printf( "G_AIEventRadius: invalid event type\n" ); + return 1500.0f; + } +} + +void G_BroadcastAIEvent + ( + Entity *originator, + Vector origin, + char *pszType + ) + +{ + G_BroadcastAIEvent( originator, origin, G_AIEventTypeFromString( pszType ), -1.0f ); +} + +void G_BroadcastAIEvent + ( + Entity *originator, + Vector origin, + int iType, + float radius + ) + +{ + Sentient *ent; + Vector delta; + str name; + float r2; + float dist2; + int i; + int iNumSentients; + int iAreaNum; + + if( iType < 10 ) + { + ent = ( Sentient * )G_GetEntity( 0 ); + + if( ent && ent->m_bIsDisguised ) + return; + } + + if( radius <= 0.0f ) + radius = G_AIEventRadius( iType ); + + assert( originator ); + if( originator && !( originator->flags & FL_NOTARGET ) ) + { + r2 = radius * radius; + iNumSentients = SentientList.NumObjects(); + for( i = 1; i <= iNumSentients; i++ ) + { + ent = SentientList.ObjectAt( i ); + if( ( ent == originator ) || ent->deadflag ) + { + continue; + } + + delta = origin - ent->centroid; + + // dot product returns length squared + dist2 = delta * delta; + + if( originator ) + iAreaNum = originator->edict->r.areanum; + else + iAreaNum = gi.AreaForPoint( origin ); + + if ( + ( dist2 <= r2 ) && + ( + ( iAreaNum == ent->edict->r.areanum ) || + ( gi.AreasConnected( iAreaNum, ent->edict->r.areanum ) ) + ) + ) + + { + if( ent->IsSubclassOfActor() ) + { + Actor *act = ( Actor * )ent; + + if( !act->IgnoreSound( iType ) ) + { + act->ReceiveAIEvent( origin, iType, originator, dist2, r2 ); + } + } + else if( ent->IsSubclassOfBot() ) + { + PlayerBot *bot = ( PlayerBot * )ent; + + bot->NoticeEvent( origin, iType, originator, dist2, r2 ); + } + } + } + +#if 0 + gi.DPrintf( "Broadcast event %s to %d entities\n", ev->getName(), count ); +#endif + } +} + +void CloneEntity + ( + Entity *dest, + Entity *src + ) + +{ + int i, num; + +#if 0 + dest->setModel( src->model ); + // don't process our init commands + //dest->CancelEventsOfType( EV_ProcessInitCommands ); + dest->setOrigin( src->origin ); + dest->setAngles( src->angles ); +#endif + dest->setScale( src->edict->s.scale ); + dest->setAlpha( src->edict->s.alpha ); + dest->health = src->health; + // copy the surfaces + memcpy( dest->edict->s.surfaces, src->edict->s.surfaces, sizeof( src->edict->s.surfaces ) ); + dest->edict->s.constantLight = src->edict->s.constantLight; + //dest->edict->s.eFlags = src->edict->s.eFlags; + dest->edict->s.renderfx = src->edict->s.renderfx; + + num = src->numchildren; + for( i = 0; ( i < MAX_MODEL_CHILDREN ) && num; i++ ) + { + Entity * clone; + Entity * child; + + // duplicate the children + if( !src->children[ i ] ) + { + continue; + } + child = G_GetEntity( src->children[ i ] ); + if( child ) + { + clone = new Animate; + CloneEntity( clone, child ); + clone->attach( dest->entnum, child->edict->s.tag_num ); + } + num--; + } +} + +weaponhand_t WeaponHandNameToNum + ( + str side + ) + +{ + if( !side.length() ) + { + gi.DPrintf( "WeaponHandNameToNum : Weapon hand not specified\n" ); + return WEAPON_ERROR; + } + + if( !side.icmp( "mainhand" ) || !side.icmp( "main" ) ) + { + return WEAPON_MAIN; + } + else if( !side.icmp( "offhand" ) || !side.icmp( "off" ) ) + { + return WEAPON_OFFHAND; + } + else + { + return ( weaponhand_t )atoi( side ); + } +} + +const char *WeaponHandNumToName +( +weaponhand_t hand +) + +{ + switch( hand ) + { + case WEAPON_MAIN: + return "mainhand"; + case WEAPON_OFFHAND: + return "offhand"; + default: + return "Invalid Hand"; + } +} + +firemode_t WeaponModeNameToNum +( +str mode +) + +{ + if( !mode.length() ) + { + gi.DPrintf( "WeaponModeNameToNum : Weapon mode not specified\n" ); + assert( 0 ); + return FIRE_ERROR; + } + + if( !mode.icmp( "primary" ) ) + { + return FIRE_PRIMARY; + } + + if( !mode.icmp( "secondary" ) ) + { + return FIRE_SECONDARY; + } + else + { + return ( firemode_t )atoi( mode ); + } +} + +// Used to tell the server about the edict pose, such as the player pose +// so that G_Trace with tracedeep will set the location +void G_UpdatePoseInternal( gentity_t *edict ) +{ + if( edict->s.number == ENTITYNUM_NONE || + level.frame_skel_index != level.skel_index[ edict->s.number ] ) + { + gi.TIKI_SetPoseInternal( edict->tiki, edict->s.number, edict->s.frameInfo, edict->s.bone_tag, edict->s.bone_quat, edict->s.actionWeight ); + } +} + +orientation_t G_TIKI_Orientation( gentity_t *edict, int num ) +{ + orientation_t orient; + + G_UpdatePoseInternal( edict ); + + orient = gi.TIKI_OrientationInternal( edict->tiki, edict->s.number, num, edict->s.scale ); + + return orient; +} + +SkelMat4 *G_TIKI_Transform( gentity_t *edict, int num ) +{ + G_UpdatePoseInternal( edict ); + return ( SkelMat4 *)gi.TIKI_TransformInternal( edict->tiki, edict->s.number, num ); +} + +qboolean G_TIKI_IsOnGround( gentity_t *edict, int num, float threshold ) +{ + G_UpdatePoseInternal( edict ); + return gi.TIKI_IsOnGroundInternal( edict->tiki, edict->s.number, num, threshold ); +} + +char *G_TimeString( float fTime ) +{ + float fTmp; + static char szTime[ 32 ]; + + fTmp = fTime / 3600.0f; + + if( fTmp >= 1.0f ) + { + Com_sprintf( szTime, sizeof( szTime ), "%i:%02i:%02i", + ( int )( fTmp ), + ( int )( fmod( fTime / 60.0f, 60.0f ) ), + ( int )( fmod( fTime, 60.0f ) ) + ); + } + else + { + Com_sprintf( szTime, sizeof( szTime ), "%i:%02i", + ( int )( fTime / 60.0f ), + ( int )( fmod( fTime, 60.0f ) ) + ); + } + + return szTime; +} + +char *CanonicalTikiName( const char *szInName ) +{ + static char filename[ 1024 ]; + + if( *szInName && Q_stricmpn( "models/", szInName, 7 ) ) + { + sprintf( filename, "models/%s", szInName ); + } + else + { + strcpy( filename, szInName ); + } + + gi.FS_CanonicalFilename( filename ); + return filename; +} + +qboolean G_Command_ProcessFile( const char * filename, qboolean quiet ) +{ + char *buffer; + const char *bufstart; + char com_token[ MAX_STRING_CHARS ]; + + if( gi.FS_ReadFile( filename, ( void ** )&buffer, quiet ) == -1 ) + { + return qfalse; + } + + if( !quiet ) + gi.DPrintf( "G_Command_ProcessFile: %s\n", filename ); + + bufstart = buffer; + + while( 1 ) + { + Event *ev; + + // grab each line as we go + strcpy( com_token, COM_ParseExt( &buffer, qtrue ) ); + if( !com_token[ 0 ] ) + break; + + if( + !Q_stricmp( com_token, "end" ) || + !Q_stricmp( com_token, "server" ) + ) + { + // skip the line + while( 1 ) + { + strcpy( com_token, COM_ParseExt( &buffer, qfalse ) ); + if( !com_token[ 0 ] ) + break; + } + continue; + } + + // Create the event + ev = new Event( com_token ); + + // get the rest of the line + while( 1 ) + { + strcpy( com_token, COM_ParseExt( &buffer, qfalse ) ); + if( !com_token[ 0 ] ) + break; + + ev->AddToken( com_token ); + } + + Director.ProcessEvent( ev ); + } + + gi.FS_FreeFile( ( void * )bufstart ); + + return qtrue; +} + +/* +============== +G_ArchiveEdict +============== +*/ +void G_ArchiveEdict +( +Archiver &arc, +gentity_t *edict +) + +{ + int i; + str tempStr; + + assert( edict ); + + // + // this is written funny because it is used for both saving and loading + // + + if( edict->client ) + { + arc.ArchiveRaw( edict->client, sizeof( *edict->client ) ); + } + + arc.ArchiveInteger( &edict->s.beam_entnum ); + + for( i = 0; i < MAX_FRAMEINFOS; i++ ) + { + arc.ArchiveInteger( &edict->s.frameInfo[ i ].index ); + arc.ArchiveFloat( &edict->s.frameInfo[ i ].time ); + arc.ArchiveFloat( &edict->s.frameInfo[ i ].weight ); + } + + arc.ArchiveFloat( &edict->s.actionWeight ); + + arc.ArchiveFloat( &edict->s.shader_data[ 0 ] ); + arc.ArchiveFloat( &edict->s.shader_data[ 1 ] ); + arc.ArchiveFloat( &edict->s.shader_time ); + + arc.ArchiveVec3( edict->s.eyeVector ); + + arc.ArchiveInteger( &edict->s.eType ); + arc.ArchiveInteger( &edict->s.eFlags ); + + arc.ArchiveVec3( edict->s.netorigin ); + arc.ArchiveVec3( edict->s.origin ); + arc.ArchiveVec3( edict->s.origin2 ); + arc.ArchiveVec3( edict->s.netangles ); + arc.ArchiveVec3( edict->s.angles ); + + arc.ArchiveInteger( &edict->s.constantLight ); + + if( arc.Saving() ) + { + if( edict->s.loopSound ) + tempStr = gi.GetConfigstring( CS_SOUNDS + edict->s.loopSound ); + else + tempStr = ""; + + arc.ArchiveString( &tempStr ); + } + else + { + arc.ArchiveString( &tempStr ); + + if( tempStr.length() ) + edict->s.loopSound = gi.soundindex( tempStr.c_str(), true ); + else + edict->s.loopSound = 0; + } + + arc.ArchiveFloat( &edict->s.loopSoundVolume ); + arc.ArchiveFloat( &edict->s.loopSoundMinDist ); + arc.ArchiveFloat( &edict->s.loopSoundMaxDist ); + arc.ArchiveFloat( &edict->s.loopSoundPitch ); + arc.ArchiveInteger( &edict->s.loopSoundFlags ); + + arc.ArchiveInteger( &edict->s.parent ); + arc.ArchiveInteger( &edict->s.tag_num ); + arc.ArchiveBoolean( &edict->s.attach_use_angles ); + arc.ArchiveVec3( edict->s.attach_offset ); + + arc.ArchiveInteger( &edict->s.skinNum ); + arc.ArchiveInteger( &edict->s.wasframe ); + + for( i = 0; i < NUM_BONE_CONTROLLERS; i++ ) + { + arc.ArchiveInteger( &edict->s.bone_tag[ i ] ); + arc.ArchiveVec3( edict->s.bone_angles[ i ] ); + arc.ArchiveVec4( edict->s.bone_quat[ i ] ); + } + + arc.ArchiveRaw( &edict->s.surfaces, sizeof( edict->s.surfaces ) ); + + arc.ArchiveInteger( &edict->s.clientNum ); + arc.ArchiveInteger( &edict->s.groundEntityNum ); + arc.ArchiveInteger( &edict->s.solid ); + + arc.ArchiveFloat( &edict->s.scale ); + arc.ArchiveFloat( &edict->s.alpha ); + arc.ArchiveInteger( &edict->s.renderfx ); + arc.ArchiveVec4( edict->s.quat ); + arc.ArchiveRaw( &edict->mat, sizeof( edict->mat ) ); + + arc.ArchiveInteger( &edict->r.svFlags ); + + arc.ArchiveVec3( edict->r.mins ); + arc.ArchiveVec3( edict->r.maxs ); + arc.ArchiveInteger( &edict->r.contents ); + arc.ArchiveVec3( edict->r.absmin ); + arc.ArchiveVec3( edict->r.absmax ); + arc.ArchiveFloat( &edict->r.radius ); + if( !arc.Saving() ) { + edict->radius2 = edict->r.radius * edict->r.radius; + } + + arc.ArchiveVec3( edict->r.currentOrigin ); + arc.ArchiveVec3( edict->r.currentAngles ); + + arc.ArchiveInteger( &edict->r.ownerNum ); + ArchiveEnum( edict->solid, solid_t ); + arc.ArchiveFloat( &edict->freetime ); + arc.ArchiveFloat( &edict->spawntime ); + + tempStr = str( edict->entname ); + arc.ArchiveString( &tempStr ); + strncpy( edict->entname, tempStr.c_str(), sizeof( edict->entname ) - 1 ); + + arc.ArchiveInteger( &edict->clipmask ); + arc.ArchiveBoolean( &edict->r.bmodel ); + + if( arc.Loading() ) + { + gi.LinkEntity( edict ); + } + + arc.ArchiveInteger( &edict->r.lastNetTime ); +} + +const char *G_LocationNumToDispString( int iLocation ) +{ + switch( iLocation ) + { + case -2: + case -1: + return ""; + case 0: + return "head"; + case 1: + return "helmet"; + case 2: + return "neck"; + case 3: + return "upper torso"; + case 4: + return "middle torso"; + case 5: + return "lower torso"; + case 6: + return "pelvis"; + case 7: + return "upper right arm"; + case 8: + return "upper left arm"; + case 9: + return "upper right leg"; + case 10: + return "upper left leg"; + case 11: + return "lower right arm"; + case 12: + return "lower left arm"; + case 13: + return "lower right leg"; + case 14: + return "lower left leg"; + case 15: + return "right hand"; + case 16: + return "left hand"; + case 17: + return "right foot"; + case 18: + return "left foot"; + default: + return ""; + } +} + +str G_WeaponClassNumToName + ( + int num + ) + +{ + if( num & WEAPON_CLASS_PISTOL ) + { + return "pistol"; + } + else if( num & WEAPON_CLASS_RIFLE ) + { + return "rifle"; + } + else if( num & WEAPON_CLASS_SMG ) + { + return "smg"; + } + else if( num & WEAPON_CLASS_MG ) + { + return "mg"; + } + else if( num & WEAPON_CLASS_GRENADE ) + { + return "grenade"; + } + else if( num & WEAPON_CLASS_HEAVY ) + { + return "heavy"; + } + else if( num & WEAPON_CLASS_CANNON ) + { + return "cannon"; + } + else if( num & WEAPON_CLASS_ITEM ) + { + return "item"; + } + else if( num & WEAPON_CLASS_ITEM1 ) + { + return "item1"; + } + else if( num & WEAPON_CLASS_ITEM2 ) + { + return "item2"; + } + else if( num & WEAPON_CLASS_ITEM3 ) + { + return "item3"; + } + else if( num & WEAPON_CLASS_ITEM4 ) + { + return "item4"; + } + else + { + assert( 0 ); + return ""; + } +} + +int G_WeaponClassNameToNum + ( + str name + ) + +{ + int weaponindex = 0; + + if( !name.length() ) + { + gi.DPrintf( "WeaponClassNameToNum: Weapon class not specified\n" ); + return 0; + } + + if( !str::icmp( name, "pistol" ) ) + { + weaponindex = WEAPON_CLASS_PISTOL; + } + else if( !str::icmp( name, "rifle" ) ) + { + weaponindex = WEAPON_CLASS_RIFLE; + } + else if( !str::icmp( name, "smg" ) ) + { + weaponindex = WEAPON_CLASS_SMG; + } + else if( !str::icmp( name, "mg" ) ) + { + weaponindex = WEAPON_CLASS_MG; + } + else if( !str::icmp( name, "grenade" ) ) + { + weaponindex = WEAPON_CLASS_GRENADE; + } + else if( !str::icmp( name, "heavy" ) ) + { + weaponindex = WEAPON_CLASS_HEAVY; + } + else if( !str::icmp( name, "cannon" ) ) + { + weaponindex = WEAPON_CLASS_CANNON; + } + else if( !str::icmp( name, "item" ) ) + { + weaponindex = WEAPON_CLASS_ITEM; + } + else if( !str::icmp( name, "item1" ) ) + { + weaponindex = WEAPON_CLASS_ITEM1; + } + else if( !str::icmp( name, "item2" ) ) + { + weaponindex = WEAPON_CLASS_ITEM2; + } + else if( !str::icmp( name, "item3" ) ) + { + weaponindex = WEAPON_CLASS_ITEM3; + } + else if( !str::icmp( name, "item4" ) ) + { + weaponindex = WEAPON_CLASS_ITEM4; + } + else + { + gi.DPrintf( "WeaponClassNameToNum: Unknown Weapon class %s\n", name.c_str() ); + return 0; + } + + return weaponindex; +} + +void G_MoveClientToIntermission + ( + Entity *ent + ) + +{ + G_DisplayScores( ent ); + ent->flags |= FL_IMMOBILE; +} + +void G_DisplayScores + ( + Entity *ent + ) + +{ + ent->client->ps.pm_flags |= PMF_INTERMISSION; +} + +void G_HideScores + ( + Entity *ent + ) + +{ + ent->client->ps.pm_flags &= ~PMF_INTERMISSION; +} + +void G_DisplayScoresToAllClients + ( + void + ) + +{ + gentity_t *ent; + int i; + + for( i = 0, ent = g_entities; i < game.maxclients; ent++, i++ ) + { + if( !ent->inuse || !ent->entity ) { + continue; + } + + G_DisplayScores( ent->entity ); + } +} + +void G_HideScoresToAllClients + ( + void + ) + +{ + gentity_t *ent; + int i; + + for( i = 0, ent = g_entities; i < game.maxclients; ent++, i++ ) + { + if( !ent->inuse || !ent->entity ) { + continue; + } + + G_HideScores( ent->entity ); + } +} diff --git a/code/game/g_vmove.cpp b/code/game/g_vmove.cpp new file mode 100644 index 00000000..d9adb131 --- /dev/null +++ b/code/game/g_vmove.cpp @@ -0,0 +1,645 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// g_vmove.cpp : Vehicle movement code +// + +#include "g_local.h" +#include "entity.h" +#include "movegrid.h" + +typedef struct { + qboolean validGroundTrace; + float previous_origin[ 3 ]; + float previous_velocity[ 3 ]; +} vml_t; + +vmove_t *vm; +vml_t vml; + +void VM_ClipVelocity + ( + float *in, + float *normal, + float *out, + float overbounce + ) + +{ + float backoff; + float dir_z; + float normal2[ 3 ]; + + if( normal[ 2 ] >= 0.70f ) + { + if( in[ 0 ] == 0.0f && in[ 1 ] == 0.0f ) + { + VectorClear( out ); + return; + } + + normal2[ 0 ] = in[ 0 ] + DotProduct2D( in, normal ); + normal2[ 1 ] = in[ 1 ] + DotProduct2D( in, normal ); + normal2[ 2 ] = normal[ 2 ] * DotProduct2D( in, in ); + + VectorNormalize( normal2 ); + + dir_z = -normal2[ 2 ]; + + out[ 0 ] = in[ 0 ]; + out[ 1 ] = in[ 1 ]; + out[ 2 ] = DotProduct2D( in, normal2 ) / dir_z; + } + else + { + backoff = DotProduct( in, normal ); + + if( backoff < 0 ) + backoff *= overbounce; + else + backoff /= overbounce; + + out[ 0 ] = in[ 0 ] - normal[ 0 ] * backoff; + out[ 1 ] = in[ 1 ] - normal[ 1 ] * backoff; + out[ 2 ] = in[ 2 ] - normal[ 2 ] * backoff; + } +} + +void VM_AddTouchEnt + ( + int entityNum + ) + +{ + int i; + + if( entityNum == ENTITYNUM_NONE || entityNum == ENTITYNUM_WORLD ) + { + return; + } + + if( vm->numtouch > 32 ) + { + return; + } + + // see if it is already added + for( i = 0; i < vm->numtouch; i++ ) + { + if( vm->touchents[ i ] == entityNum ) + return; + } + + // add it + vm->touchents[ vm->numtouch ] = entityNum; + vm->numtouch++; +} + +qboolean VM_SlideMove + ( + qboolean gravity + ) + +{ + int bumpcount; + vec3_t dir; + float d; + int numplanes; + vec3_t planes[ 5 ]; + vec3_t clipVelocity; + int i; + int j; + int k; + trace_t trace; + vec3_t end; + float time_left; + + if( gravity ) + { + vm->vs->velocity[ 2 ] = vm->vs->velocity[ 2 ] - vm->frametime * sv_gravity->integer; + if( vm->vs->groundPlane ) + VM_ClipVelocity( vm->vs->velocity, vm->vs->groundTrace.plane.normal, vm->vs->velocity, OVERCLIP ); + } + + time_left = vm->frametime; + + if( vm->vs->groundPlane ) { + numplanes = 1; + VectorCopy( vm->vs->groundTrace.plane.normal, planes[ 0 ] ); + } + else { + numplanes = 0; + } + + // never turn against original velocity + VectorNormalize2( vm->vs->velocity, planes[ numplanes ] ); + numplanes++; + + for( bumpcount = 0; bumpcount < 4; bumpcount++ ) + { + // calculate position we are trying to move to + VectorMA( vm->vs->origin, time_left, vm->vs->velocity, end ); + + // see if we can make it there + gi.Trace( &trace, vm->vs->origin, vm->mins, vm->maxs, end, vm->vs->entityNum, vm->tracemask, qtrue, qfalse ); + + if( trace.allsolid ) + break; + + if( trace.fraction > 0 ) { + // actually covered some distance + VectorCopy( trace.endpos, vm->vs->origin ); + } + + if( trace.fraction == 1 ) + return bumpcount != 0; + + memcpy( &vm->vs->groundTrace, &trace, sizeof( vm->vs->groundTrace ) ); + vml.validGroundTrace = true; + + // save entity for contact + VM_AddTouchEnt( trace.entityNum ); + + time_left -= time_left * trace.fraction; + + if( numplanes >= MAX_CLIP_PLANES ) + { + VectorClear( vm->vs->velocity ); + return qtrue; + } + + // + // if this is the same plane we hit before, nudge velocity + // out along it, which fixes some epsilon issues with + // non-axial planes + // + for( i = 0; i < numplanes; i++ ) + { + if( DotProduct( trace.plane.normal, planes[ i ] ) > 0.99 ) + { + VectorAdd( trace.plane.normal, vm->vs->velocity, vm->vs->velocity ); + break; + } + } + + if( i >= numplanes ) + { + // + // modify velocity so it parallels all of the clip planes + // + + // find a plane that it enters + for( i = 0; i < numplanes; i++ ) + { + if( DotProduct( vm->vs->velocity, planes[ i ] ) >= 0.1 ) { + continue; // move doesn't interact with the plane + } + + // slide along the plane + VM_ClipVelocity( vm->vs->velocity, planes[ i ], clipVelocity, OVERCLIP ); + + // see if there is a second plane that the new move enters + for( j = 0; j < numplanes; j++ ) + { + if( j == i ) { + continue; + } + + // slide along the plane + VM_ClipVelocity( vm->vs->velocity, planes[ j ], clipVelocity, OVERCLIP ); + + if( DotProduct( clipVelocity, planes[ j ] ) >= 0.0f ) { + continue; // move doesn't interact with the plane + } + + // slide the original velocity along the crease + CrossProduct( planes[ i ], planes[ j ], dir ); + VectorNormalize( dir ); + d = DotProduct( dir, vm->vs->velocity ); + VectorScale( dir, d, clipVelocity ); + + // see if there is a third plane the the new move enters + for( k = 0; k < numplanes; k++ ) + { + if( k == i || k == j ) { + continue; + } + + if( DotProduct( clipVelocity, planes[ k ] ) >= 0.1f ) { + continue; // move doesn't interact with the plane + } + + // stop dead at a tripple plane interaction + VectorClear( vm->vs->velocity ); + return qtrue; + } + } + + // if we have fixed all interactions, try another move + VectorCopy( clipVelocity, vm->vs->velocity ); + break; + } + } + } + + if( vm->vs->velocity[ 0 ] || vm->vs->velocity[ 1 ] ) + { + if( vm->vs->groundPlane ) + { + VectorCopy( vm->vs->velocity, dir ); + VectorNegate( dir, dir ); + VectorNormalize( dir ); + + VM_AddTouchEnt( trace.entityNum ); + VectorAdd( vm->vs->obstacle_normal, dir, vm->vs->obstacle_normal ); + } + + VectorClear( vm->vs->velocity ); + return true; + } + + vm->vs->velocity[ 2 ] = 0; + return false; +} + +static void VM_GroundTraceInternal2( void ); + +void VM_GroundTraceInternal + ( + void + ) + +{ + VM_GroundTraceInternal2(); + VM_AddTouchEnt( vm->vs->groundTrace.entityNum ); +} + +void VM_GroundTraceInternal2 + ( + void + ) + +{ + if( vm->vs->groundTrace.fraction == 1.0f ) + { + vm->vs->groundEntityNum = ENTITYNUM_NONE; + vm->vs->groundPlane = qfalse; + vm->vs->walking = qfalse; + return; + } + + if( vm->vs->velocity[ 2 ] > 0.0f ) + { + if( DotProduct( vm->vs->velocity, vm->vs->groundTrace.plane.normal ) > 10.0f ) + { + vm->vs->groundEntityNum = ENTITYNUM_NONE; + vm->vs->groundPlane = qfalse; + vm->vs->walking = qfalse; + return; + } + } + + // slopes that are too steep will not be considered onground + if( vm->vs->groundTrace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) + { + vec3_t oldvel; + float d; + + VectorCopy( vm->vs->velocity, oldvel ); + VectorSet( vm->vs->velocity, 0, 0, -1.0f / vm->frametime ); + VM_SlideMove( qfalse ); + + d = VectorLength( vm->vs->velocity ); + VectorCopy( oldvel, vm->vs->velocity ); + + if( d > ( 0.1f / vm->frametime ) ) + { + vm->vs->groundEntityNum = ENTITYNUM_NONE; + vm->vs->groundPlane = qtrue; + vm->vs->walking = qfalse; + return; + } + } + + vm->vs->groundPlane = qtrue; + vm->vs->walking = qtrue; + vm->vs->groundEntityNum = vm->vs->groundTrace.entityNum; +} + +void VM_GroundTrace + ( + void + ) + +{ + float point[ 3 ]; + + point[ 0 ] = vm->vs->origin[ 0 ]; + point[ 1 ] = vm->vs->origin[ 1 ]; + point[ 2 ] = vm->vs->origin[ 2 ] - 0.25f; + + gi.Trace( &vm->vs->groundTrace, vm->vs->origin, vm->mins, vm->maxs, point, vm->vs->entityNum, vm->tracemask, qtrue, qfalse ); + VM_GroundTraceInternal(); +} + +void VM_StepSlideMove + ( + void + ) + +{ + vec3_t start_o; + vec3_t start_v; + vec3_t nostep_o; + vec3_t nostep_v; + trace_t trace; + qboolean bWasOnGoodGround; + vec3_t up; + vec3_t down; + qboolean start_hit_wall; + vec3_t start_wall_normal; + qboolean first_hit_wall; + vec3_t first_wall_normal; + vec3_t start_hit_origin; + vec3_t first_hit_origin; + trace_t nostep_groundTrace; + + VectorCopy( vm->vs->origin, start_o ); + VectorCopy( vm->vs->velocity, start_v ); + start_hit_wall = vm->vs->hit_obstacle; + VectorCopy( vm->vs->hit_origin, start_hit_origin ); + VectorCopy( vm->vs->obstacle_normal, start_wall_normal ); + + if( VM_SlideMove( qtrue ) == 0 ) + { + if( !vml.validGroundTrace ) + VM_GroundTrace(); + + return; + } + + VectorCopy( start_o, down ); + down[ 2 ] -= STEPSIZE; + gi.Trace( &trace, start_o, vm->mins, vm->maxs, down, vm->vs->entityNum, vm->tracemask, qtrue, qfalse ); + VectorSet( up, 0, 0, 1 ); + + // never step up when you still have up velocity + if( vm->vs->velocity[ 2 ] > 0 && ( trace.fraction == 1.0f || + DotProduct( trace.plane.normal, up ) < MIN_WALK_NORMAL ) ) + { + if( !vml.validGroundTrace ) + VM_GroundTrace(); + else + VM_GroundTraceInternal(); + + return; + } + + if( vm->vs->groundPlane && vm->vs->groundTrace.plane.normal[ 2 ] >= MIN_WALK_NORMAL ) + bWasOnGoodGround = qtrue; + else + bWasOnGoodGround = qfalse; + + VectorCopy( vm->vs->origin, nostep_o ); + VectorCopy( vm->vs->velocity, nostep_v ); + memcpy( &nostep_groundTrace, &vm->vs->groundTrace, sizeof( trace_t ) ); + + VectorCopy( start_o, vm->vs->origin ); + VectorCopy( start_v, vm->vs->velocity ); + + first_hit_wall = vm->vs->hit_obstacle; + VectorCopy( vm->vs->hit_origin, first_hit_origin ); + VectorCopy( vm->vs->obstacle_normal, first_wall_normal ); + + vm->vs->hit_obstacle = start_hit_wall; + VectorCopy( start_hit_origin, vm->vs->hit_origin ); + VectorCopy( start_wall_normal, vm->vs->obstacle_normal ); + VM_SlideMove( qtrue ); + + VectorCopy( vm->vs->origin, down ); + down[ 2 ] -= STEPSIZE * 2; + + // test the player position if they were a stepheight higher + gi.Trace( &trace, up, vm->mins, vm->maxs, up, vm->vs->entityNum, vm->tracemask, qtrue, qfalse ); + if( trace.entityNum > ENTITYNUM_NONE ) + { + VectorCopy( nostep_o, vm->vs->origin ); + VectorCopy( nostep_v, vm->vs->velocity ); + memcpy( &vm->vs->groundTrace, &nostep_groundTrace, sizeof( vm->vs->groundTrace ) ); + vm->vs->hit_obstacle = first_hit_wall; + VectorCopy( first_hit_origin, vm->vs->hit_origin ); + VectorCopy( first_wall_normal, vm->vs->obstacle_normal ); + + if( !vml.validGroundTrace ) + VM_GroundTrace(); + else + VM_GroundTraceInternal(); + + return; + } + + if( !trace.allsolid ) + { + memcpy( &vm->vs->groundTrace, &trace, sizeof( vm->vs->groundTrace ) ); + vml.validGroundTrace = qtrue; + + if( bWasOnGoodGround && trace.fraction && trace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) + { + VectorCopy( nostep_o, vm->vs->origin ); + VectorCopy( nostep_v, vm->vs->velocity ); + + if( first_hit_wall ) + { + vm->vs->hit_obstacle = first_hit_wall; + VectorCopy( first_hit_origin, vm->vs->hit_origin ); + VectorCopy( first_wall_normal, vm->vs->obstacle_normal ); + } + + VM_GroundTraceInternal(); + return; + } + + VectorCopy( trace.endpos, vm->vs->origin ); + } + + if( trace.fraction < 1.0f ) + VM_ClipVelocity( vm->vs->velocity, trace.plane.normal, vm->vs->velocity, OVERCLIP ); + + if( !vml.validGroundTrace ) + VM_GroundTrace(); + else + VM_GroundTraceInternal(); +} + +void VM_Friction( void ) { + vec3_t vec; + float *vel; + float speed, newspeed, control; + float drop; + + vel = vm->vs->velocity; + + VectorCopy( vel, vec ); + if( vm->vs->walking ) + { + // ignore slope movement + vec[ 2 ] = 0; + } + + speed = VectorLength( vec ); + if( speed < 1 ) + { + // allow sinking underwater + vel[ 0 ] = 0; + vel[ 1 ] = 0; + + return; + } + + drop = 0; + + if( vm->vs->walking ) + { + control = ( speed < 50.0f ) ? 50.0f : speed; + + // if getting knocked back, no friction + drop += control * 6.0f * vm->frametime; + } + + // scale the velocity + newspeed = speed - drop; + if( newspeed < 0 ) + { + newspeed = 0; + } + + newspeed /= speed; + + vel[ 0 ] = vel[ 0 ] * newspeed; + vel[ 1 ] = vel[ 1 ] * newspeed; + vel[ 2 ] = vel[ 2 ] * newspeed; +} + +void VM_ClipVelocity2D + ( + float *in, + float *normal, + float *out, + float overbounce + ) + +{ + float backoff; + float dir_z; + float normal2[ 3 ]; + + if( normal[ 2 ] >= 0.70f ) + { + if( in[ 0 ] == 0.0f && in[ 1 ] == 0.0f ) + { + VectorClear( out ); + return; + } + + normal2[ 0 ] = in[ 0 ] + DotProduct2D( in, normal ); + normal2[ 1 ] = in[ 1 ] + DotProduct2D( in, normal ); + normal2[ 2 ] = normal[ 2 ] * DotProduct2D( in, in ); + + VectorNormalize( normal2 ); + + dir_z = -normal2[ 2 ]; + + out[ 0 ] = in[ 0 ]; + out[ 1 ] = in[ 1 ]; + out[ 2 ] = DotProduct2D( in, normal2 ) / -normal2[ 2 ]; + } + else + { + backoff = DotProduct2D( in, normal ); + + if( backoff < 0 ) + backoff *= overbounce; + else + backoff /= overbounce; + + out[ 0 ] = in[ 0 ] - normal[ 0 ] * backoff; + out[ 1 ] = in[ 1 ] - normal[ 1 ] * backoff; + out[ 2 ] = -( backoff * normal[ 2 ] ); + } +} + +void VmoveSingle + ( + vmove_t *vmove + ) + +{ + float point[ 3 ]; + trace_t trace; + + vm = vmove; + + vmove->numtouch = 0; + vmove->vs->hit_obstacle = false; + VectorCopy( vec_origin, vmove->vs->obstacle_normal ); + + memset( &vml, 0, sizeof( vml_t ) ); + + VectorCopy( vmove->vs->origin, vml.previous_origin ); + VectorCopy( vmove->vs->velocity, vml.previous_velocity ); + + VM_GroundTraceInternal2(); + + if( vmove->vs->walking ) + { + float wishdir[ 3 ]; + + VM_Friction(); + VM_ClipVelocity2D( vm->vs->desired_dir, vm->vs->groundTrace.plane.normal, wishdir, OVERCLIP ); + VectorNormalize( wishdir ); + + vm->vs->velocity[ 0 ] = vm->desired_speed * wishdir[ 0 ]; + vm->vs->velocity[ 1 ] = vm->desired_speed * wishdir[ 1 ]; + } + else if( vmove->vs->groundPlane ) + { + VM_ClipVelocity( vm->vs->velocity, vm->vs->groundTrace.plane.normal, vm->vs->velocity, OVERCLIP ); + } + + VM_StepSlideMove(); + + if( !vm->vs->walking && vml.previous_velocity[ 2 ] >= 0.0f && vm->vs->velocity[ 2 ] <= 0.0f ) + { + point[ 0 ] = vm->vs->origin[ 0 ]; + point[ 1 ] = vm->vs->origin[ 1 ]; + point[ 2 ] = vm->vs->origin[ 2 ] - 18.0f; + + gi.Trace( &trace, vm->vs->origin, vm->mins, vm->maxs, point, vm->vs->entityNum, vm->tracemask, qtrue, qfalse ); + + if( trace.fraction < 1.0f && !trace.allsolid ) + { + VM_GroundTrace(); + return; + } + } +} + diff --git a/code/game/g_weapon.cpp b/code/game/g_weapon.cpp new file mode 100644 index 00000000..39de5846 --- /dev/null +++ b/code/game/g_weapon.cpp @@ -0,0 +1,1085 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// g_weapon.c +// perform the server side effects of a weapon firing + +#include "g_local.h" + +/* +=============== +CalcMuzzlePoint + +set muzzle location relative to pivoting eye +=============== +*/ +void CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint ) { + VectorCopy( ent->s.origin, muzzlePoint ); + muzzlePoint[2] += ent->client->ps.viewheight; + VectorMA( muzzlePoint, 14, forward, muzzlePoint ); + // snap to integer coordinates for more efficient network bandwidth usage + SnapVector( muzzlePoint ); +} + +#if 0 + +static float s_quadFactor; +static vec3_t forward, right, up; +/*static*/ vec3_t g_muzzle; // IneQuation: made this non-static + +#define NUM_NAILSHOTS 15 + +/* +================ +G_BounceProjectile +================ +*/ +void G_BounceProjectile( vec3_t start, vec3_t impact, vec3_t dir, vec3_t endout ) { + vec3_t v, newv; + float dot; + + VectorSubtract( impact, start, v ); + dot = DotProduct( v, dir ); + VectorMA( v, -2*dot, dir, newv ); + + VectorNormalize(newv); + VectorMA(impact, 8192, newv, endout); +} + + +/* +====================================================================== + +GAUNTLET + +====================================================================== +*/ + +void Weapon_Gauntlet( gentity_t *ent ) { + +} + +/* +=============== +CheckGauntletAttack +=============== +*/ +qboolean CheckGauntletAttack( gentity_t *ent ) { + + return qtrue; +} + + +/* +====================================================================== + +MACHINEGUN + +====================================================================== +*/ + +/* +====================== +SnapVectorTowards + +Round a vector to integers for more efficient network +transmission, but make sure that it rounds towards a given point +rather than blindly truncating. This prevents it from truncating +into a wall. +====================== +*/ +void SnapVectorTowards( vec3_t v, vec3_t to ) { + int i; + + for ( i = 0 ; i < 3 ; i++ ) { + if ( to[i] <= v[i] ) { + v[i] = (int)v[i]; + } else { + v[i] = (int)v[i] + 1; + } + } +} + +#ifdef MISSIONPACK +#define CHAINGUN_SPREAD 600 +#endif +#define MACHINEGUN_SPREAD 200 +#define MACHINEGUN_DAMAGE 7 +#define MACHINEGUN_TEAM_DAMAGE 5 // wimpier MG in teamplay + +void Bullet_Fire (gentity_t *ent, float spread, int damage ) { + trace_t tr; + vec3_t end; + float r; + float u; + gentity_t *tent; + gentity_t *traceEnt; + int i, passent; + + damage *= s_quadFactor; + + r = random() * M_PI * 2.0f; + u = sin(r) * crandom() * spread * 16; + r = cos(r) * crandom() * spread * 16; + VectorMA (g_muzzle, 8192*16, forward, end); + VectorMA (end, r, right, end); + VectorMA (end, u, up, end); + + passent = ent->s.number; + for (i = 0; i < 10; i++) { + + gi.Trace (&tr, g_muzzle, NULL, NULL, end, passent, MASK_SHOT); + if ( tr.surfaceFlags & SURF_NOIMPACT ) { + return; + } + + traceEnt = &g_entities[ tr.entityNum ]; + + // snap the endpos to integers, but nudged towards the line + SnapVectorTowards( tr.endpos, g_muzzle ); + + // send bullet impact + if ( traceEnt->takedamage && traceEnt->client ) { + //tent = G_TempEntity( tr.endpos, EV_BULLET_HIT_FLESH ); + //tent->s.eventParm = traceEnt->s.number; + if( LogAccuracyHit( traceEnt, ent ) ) { + ent->client->accuracy_hits++; + } + } else { + //tent = G_TempEntity( tr.endpos, EV_BULLET_HIT_WALL ); + //tent->s.eventParm = DirToByte( tr.plane.normal ); + } + tent->s.otherEntityNum = ent->s.number; + + if ( traceEnt->takedamage) { + + G_Damage( traceEnt, ent, ent, forward, tr.endpos, + damage, 0, MOD_MACHINEGUN); + + } + break; + } +} + + +/* +====================================================================== + +BFG + +====================================================================== +*/ + +void BFG_Fire ( gentity_t *ent ) { + gentity_t *m; + + m = fire_bfg (ent, g_muzzle, forward); + m->damage *= s_quadFactor; + m->splashDamage *= s_quadFactor; + +// VectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta ); // "real" physics +} + + +/* +====================================================================== + +SHOTGUN + +====================================================================== +*/ + +// DEFAULT_SHOTGUN_SPREAD and DEFAULT_SHOTGUN_COUNT are in bg_public.h, because +// client predicts same spreads +#define DEFAULT_SHOTGUN_DAMAGE 10 + +qboolean ShotgunPellet( vec3_t start, vec3_t end, gentity_t *ent ) { + trace_t tr; + int damage, i, passent; + gentity_t *traceEnt; +#ifdef MISSIONPACK + vec3_t impactpoint, bouncedir; +#endif + vec3_t tr_start, tr_end; + + passent = ent->s.number; + VectorCopy( start, tr_start ); + VectorCopy( end, tr_end ); + for (i = 0; i < 10; i++) { + gi.Trace (&tr, tr_start, NULL, NULL, tr_end, passent, MASK_SHOT); + traceEnt = &g_entities[ tr.entityNum ]; + + // send bullet impact + if ( tr.surfaceFlags & SURF_NOIMPACT ) { + return qfalse; + } + + if ( traceEnt->takedamage) { + damage = DEFAULT_SHOTGUN_DAMAGE * s_quadFactor; +#ifdef MISSIONPACK + if ( traceEnt->client && traceEnt->client->invulnerabilityTime > level.time ) { + if (G_InvulnerabilityEffect( traceEnt, forward, tr.endpos, impactpoint, bouncedir )) { + G_BounceProjectile( tr_start, impactpoint, bouncedir, tr_end ); + VectorCopy( impactpoint, tr_start ); + // the player can hit him/herself with the bounced rail + passent = ENTITYNUM_NONE; + } + else { + VectorCopy( tr.endpos, tr_start ); + passent = traceEnt->s.number; + } + continue; + } + else { + G_Damage( traceEnt, ent, ent, forward, tr.endpos, + damage, 0, MOD_SHOTGUN); + if( LogAccuracyHit( traceEnt, ent ) ) { + return qtrue; + } + } +#else + G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, 0, MOD_SHOTGUN); + if( LogAccuracyHit( traceEnt, ent ) ) { + return qtrue; + } +#endif + } + return qfalse; + } + return qfalse; +} + +// this should match CG_ShotgunPattern +void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) { + int i; + float r, u; + vec3_t end; + vec3_t forward, right, up; + int oldScore; + qboolean hitClient = qfalse; + + // derive the right and up vectors from the forward vector, because + // the client won't have any other information + VectorNormalize2( origin2, forward ); + PerpendicularVector( right, forward ); + CrossProduct( forward, right, up ); + + oldScore = ent->client->ps.persistant[PERS_SCORE]; + + // generate the "random" spread pattern + for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) { + r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16; + u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16; + VectorMA( origin, 8192 * 16, forward, end); + VectorMA (end, r, right, end); + VectorMA (end, u, up, end); + if( ShotgunPellet( origin, end, ent ) && !hitClient ) { + hitClient = qtrue; + ent->client->accuracy_hits++; + } + } +} + + +void weapon_supershotgun_fire (gentity_t *ent) { + gentity_t *tent; + + // send shotgun blast + tent = G_TempEntity( g_muzzle, EV_SHOTGUN ); + VectorScale( forward, 4096, tent->s.origin2 ); + SnapVector( tent->s.origin2 ); + tent->s.eventParm = rand() & 255; // seed for spread pattern + tent->s.otherEntityNum = ent->s.number; + + ShotgunPattern( tent->s.origin, tent->s.origin2, tent->s.eventParm, ent ); +} + + +/* +====================================================================== + +GRENADE LAUNCHER + +====================================================================== +*/ + +void weapon_grenadelauncher_fire (gentity_t *ent) { + gentity_t *m; + + // extra vertical velocity + forward[2] += 0.2f; + VectorNormalize( forward ); + + m = fire_grenade (ent, g_muzzle, forward); + m->damage *= s_quadFactor; + m->splashDamage *= s_quadFactor; + +// VectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta ); // "real" physics +} + +/* +====================================================================== + +ROCKET + +====================================================================== +*/ + +void Weapon_RocketLauncher_Fire (gentity_t *ent) { + gentity_t *m; + + m = fire_rocket (ent, g_muzzle, forward); + m->damage *= s_quadFactor; + m->splashDamage *= s_quadFactor; + +// VectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta ); // "real" physics +} + + +/* +====================================================================== + +PLASMA GUN + +====================================================================== +*/ + +void Weapon_Plasmagun_Fire (gentity_t *ent) { + gentity_t *m; + + m = fire_plasma (ent, g_muzzle, forward); + m->damage *= s_quadFactor; + m->splashDamage *= s_quadFactor; + +// VectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta ); // "real" physics +} + +/* +====================================================================== + +RAILGUN + +====================================================================== +*/ + + +/* +================= +weapon_railgun_fire +================= +*/ +#define MAX_RAIL_HITS 4 +void weapon_railgun_fire (gentity_t *ent) { + vec3_t end; +#ifdef MISSIONPACK + vec3_t impactpoint, bouncedir; +#endif + trace_t trace; + gentity_t *tent; + gentity_t *traceEnt; + int damage; + int i; + int hits; + int unlinked; + int passent; + gentity_t *unlinkedEntities[MAX_RAIL_HITS]; + + damage = 100 * s_quadFactor; + + VectorMA (g_muzzle, 8192, forward, end); + + // trace only against the solids, so the railgun will go through people + unlinked = 0; + hits = 0; + passent = ent->s.number; + do { + gi.Trace (&trace, g_muzzle, NULL, NULL, end, passent, MASK_SHOT ); + if ( trace.entityNum >= ENTITYNUM_MAX_NORMAL ) { + break; + } + traceEnt = &g_entities[ trace.entityNum ]; + if ( traceEnt->takedamage ) { +#ifdef MISSIONPACK + if ( traceEnt->client && traceEnt->client->invulnerabilityTime > level.time ) { + if ( G_InvulnerabilityEffect( traceEnt, forward, trace.endpos, impactpoint, bouncedir ) ) { + G_BounceProjectile( g_muzzle, impactpoint, bouncedir, end ); + // snap the endpos to integers to save net bandwidth, but nudged towards the line + SnapVectorTowards( trace.endpos, g_muzzle ); + // send railgun beam effect + tent = G_TempEntity( trace.endpos, EV_RAILTRAIL ); + // set player number for custom colors on the railtrail + tent->s.clientNum = ent->s.clientNum; + VectorCopy( g_muzzle, tent->s.origin2 ); + // move origin a bit to come closer to the drawn gun muzzle + VectorMA( tent->s.origin2, 4, right, tent->s.origin2 ); + VectorMA( tent->s.origin2, -1, up, tent->s.origin2 ); + tent->s.eventParm = 255; // don't make the explosion at the end + // + VectorCopy( impactpoint, g_muzzle ); + // the player can hit him/herself with the bounced rail + passent = ENTITYNUM_NONE; + } + } + else { + if( LogAccuracyHit( traceEnt, ent ) ) { + hits++; + } + G_Damage (traceEnt, ent, ent, forward, trace.endpos, damage, 0, MOD_RAILGUN); + } +#else + if( LogAccuracyHit( traceEnt, ent ) ) { + hits++; + } + G_Damage (traceEnt, ent, ent, forward, trace.endpos, damage, 0, MOD_RAILGUN); +#endif + } + if ( trace.contents & CONTENTS_SOLID ) { + break; // we hit something solid enough to stop the beam + } + // unlink this entity, so the next trace will go past it + gi.UnlinkEntity( traceEnt ); + unlinkedEntities[unlinked] = traceEnt; + unlinked++; + } while ( unlinked < MAX_RAIL_HITS ); + + // link back in any entities we unlinked + for ( i = 0 ; i < unlinked ; i++ ) { + gi.LinkEntity( unlinkedEntities[i] ); + } + + // the final trace endpos will be the terminal point of the rail trail + + // snap the endpos to integers to save net bandwidth, but nudged towards the line + SnapVectorTowards( trace.endpos, g_muzzle ); + + // send railgun beam effect + tent = G_TempEntity( trace.endpos, EV_RAILTRAIL ); + + // set player number for custom colors on the railtrail + tent->s.clientNum = ent->s.clientNum; + + VectorCopy( g_muzzle, tent->s.origin2 ); + // move origin a bit to come closer to the drawn gun muzzle + VectorMA( tent->s.origin2, 4, right, tent->s.origin2 ); + VectorMA( tent->s.origin2, -1, up, tent->s.origin2 ); + + // no explosion at end if SURF_NOIMPACT, but still make the trail + if ( trace.surfaceFlags & SURF_NOIMPACT ) { + tent->s.eventParm = 255; // don't make the explosion at the end + } else { + tent->s.eventParm = DirToByte( trace.plane.normal ); + } + tent->s.clientNum = ent->s.clientNum; + + // give the shooter a reward sound if they have made two railgun hits in a row + if ( hits == 0 ) { + // complete miss + ent->client->accurateCount = 0; + } else { + // check for "impressive" reward sound + ent->client->accurateCount += hits; + if ( ent->client->accurateCount >= 2 ) { + ent->client->accurateCount -= 2; + ent->client->ps.persistant[PERS_IMPRESSIVE_COUNT]++; + // add the sprite over the player's head + ent->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP ); + ent->client->ps.eFlags |= EF_AWARD_IMPRESSIVE; + ent->client->rewardTime = level.time + REWARD_SPRITE_TIME; + } + ent->client->accuracy_hits++; + } + +} + + +/* +====================================================================== + +GRAPPLING HOOK + +====================================================================== +*/ + +void Weapon_GrapplingHook_Fire (gentity_t *ent) +{ + if (!ent->client->fireHeld && !ent->client->hook) + fire_grapple (ent, g_muzzle, forward); + + ent->client->fireHeld = qtrue; +} + +void Weapon_HookFree (gentity_t *ent) +{ + ent->parent->client->hook = NULL; + ent->parent->client->ps.pm_flags &= ~PMF_GRAPPLE_PULL; + G_FreeEntity( ent ); +} + +void Weapon_HookThink (gentity_t *ent) +{ + if (ent->enemy) { + vec3_t v, oldorigin; + + VectorCopy(ent->r.currentOrigin, oldorigin); + v[0] = ent->enemy->r.currentOrigin[0] + (ent->enemy->r.mins[0] + ent->enemy->r.maxs[0]) * 0.5; + v[1] = ent->enemy->r.currentOrigin[1] + (ent->enemy->r.mins[1] + ent->enemy->r.maxs[1]) * 0.5; + v[2] = ent->enemy->r.currentOrigin[2] + (ent->enemy->r.mins[2] + ent->enemy->r.maxs[2]) * 0.5; + SnapVectorTowards( v, oldorigin ); // save net bandwidth + + G_SetOrigin( ent, v ); + } + + VectorCopy( ent->r.currentOrigin, ent->parent->client->ps.grapplePoint); +} + +/* +====================================================================== + +LIGHTNING GUN + +====================================================================== +*/ + +void Weapon_LightningFire( gentity_t *ent ) { + trace_t tr; + vec3_t end; +#ifdef MISSIONPACK + vec3_t impactpoint, bouncedir; +#endif + gentity_t *traceEnt, *tent; + int damage, i, passent; + + damage = 8 * s_quadFactor; + + passent = ent->s.number; + for (i = 0; i < 10; i++) { + VectorMA( g_muzzle, LIGHTNING_RANGE, forward, end ); + + gi.Trace( &tr, g_muzzle, NULL, NULL, end, passent, MASK_SHOT ); + +#ifdef MISSIONPACK + // if not the first trace (the lightning bounced of an invulnerability sphere) + if (i) { + // add bounced off lightning bolt temp entity + // the first lightning bolt is a cgame only visual + // + tent = G_TempEntity( g_muzzle, EV_LIGHTNINGBOLT ); + VectorCopy( tr.endpos, end ); + SnapVector( end ); + VectorCopy( end, tent->s.origin2 ); + } +#endif + if ( tr.entityNum == ENTITYNUM_NONE ) { + return; + } + + traceEnt = &g_entities[ tr.entityNum ]; + + if ( traceEnt->takedamage) { +#ifdef MISSIONPACK + if ( traceEnt->client && traceEnt->client->invulnerabilityTime > level.time ) { + if (G_InvulnerabilityEffect( traceEnt, forward, tr.endpos, impactpoint, bouncedir )) { + G_BounceProjectile( g_muzzle, impactpoint, bouncedir, end ); + VectorCopy( impactpoint, g_muzzle ); + VectorSubtract( end, impactpoint, forward ); + VectorNormalize(forward); + // the player can hit him/herself with the bounced lightning + passent = ENTITYNUM_NONE; + } + else { + VectorCopy( tr.endpos, g_muzzle ); + passent = traceEnt->s.number; + } + continue; + } + else { + G_Damage( traceEnt, ent, ent, forward, tr.endpos, + damage, 0, MOD_LIGHTNING); + } +#else + G_Damage( traceEnt, ent, ent, forward, tr.endpos, + damage, 0, MOD_LIGHTNING); +#endif + } + + if ( traceEnt->takedamage && traceEnt->client ) { + tent = G_TempEntity( tr.endpos, EV_MISSILE_HIT ); + tent->s.otherEntityNum = traceEnt->s.number; + tent->s.eventParm = DirToByte( tr.plane.normal ); + tent->s.weapon = ent->s.weapon; + if( LogAccuracyHit( traceEnt, ent ) ) { + ent->client->accuracy_hits++; + } + } else if ( !( tr.surfaceFlags & SURF_NOIMPACT ) ) { + tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS ); + tent->s.eventParm = DirToByte( tr.plane.normal ); + } + + break; + } +} + +#ifdef MISSIONPACK +/* +====================================================================== + +NAILGUN + +====================================================================== +*/ + +void Weapon_Nailgun_Fire (gentity_t *ent) { + gentity_t *m; + int count; + + for( count = 0; count < NUM_NAILSHOTS; count++ ) { + m = fire_nail (ent, g_muzzle, forward, right, up ); + m->damage *= s_quadFactor; + m->splashDamage *= s_quadFactor; + } + +// VectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta ); // "real" physics +} + + +/* +====================================================================== + +PROXIMITY MINE LAUNCHER + +====================================================================== +*/ + +void weapon_proxlauncher_fire (gentity_t *ent) { + gentity_t *m; + + // extra vertical velocity + forward[2] += 0.2f; + VectorNormalize( forward ); + + m = fire_prox (ent, g_muzzle, forward); + m->damage *= s_quadFactor; + m->splashDamage *= s_quadFactor; + +// VectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta ); // "real" physics +} + +#endif + +//====================================================================== + + +/* +=============== +LogAccuracyHit +=============== +*/ +qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker ) { + if( !target->takedamage ) { + return qfalse; + } + + if ( target == attacker ) { + return qfalse; + } + + if( !target->client ) { + return qfalse; + } + + if( !attacker->client ) { + return qfalse; + } + + if( target->client->ps.stats[STAT_HEALTH] <= 0 ) { + return qfalse; + } + + if ( OnSameTeam( target, attacker ) ) { + return qfalse; + } + + return qtrue; +} + + + + +/* +=============== +CalcMuzzlePointOrigin + +set muzzle location relative to pivoting eye +=============== +*/ +void CalcMuzzlePointOrigin ( gentity_t *ent, vec3_t origin, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint ) { + VectorCopy( ent->s.origin, muzzlePoint ); + muzzlePoint[2] += ent->client->ps.viewheight; + VectorMA( muzzlePoint, 14, forward, muzzlePoint ); + // snap to integer coordinates for more efficient network bandwidth usage + SnapVector( muzzlePoint ); +} + + + +/* +=============== +FireWeapon +=============== +*/ +void FireWeapon( gentity_t *ent ) { + if (ent->client->ps.powerups[PW_QUAD] ) { + s_quadFactor = g_quadfactor.value; + } else { + s_quadFactor = 1; + } +#ifdef MISSIONPACK + if( ent->client->persistantPowerup && ent->client->persistantPowerup->item && ent->client->persistantPowerup->item->giTag == PW_DOUBLER ) { + s_quadFactor *= 2; + } +#endif + + // track shots taken for accuracy tracking. Grapple is not a weapon and gauntet is just not tracked + if( ent->s.weapon != WP_GRAPPLING_HOOK && ent->s.weapon != WP_GAUNTLET ) { +#ifdef MISSIONPACK + if( ent->s.weapon == WP_NAILGUN ) { + ent->client->accuracy_shots += NUM_NAILSHOTS; + } else { + ent->client->accuracy_shots++; + } +#else + ent->client->accuracy_shots++; +#endif + } + + // set aiming directions + AngleVectors (ent->client->ps.viewangles, forward, right, up); + + CalcMuzzlePointOrigin ( ent, ent->client->oldOrigin, forward, right, up, g_muzzle ); + + // fire the specific weapon + switch( ent->s.weapon ) { + case WP_GAUNTLET: + Weapon_Gauntlet( ent ); + break; + case WP_LIGHTNING: + Weapon_LightningFire( ent ); + break; + case WP_SHOTGUN: + weapon_supershotgun_fire( ent ); + break; + case WP_MACHINEGUN: + if ( g_gametype.integer != GT_TEAM ) { + Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_DAMAGE ); + } else { + Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_TEAM_DAMAGE ); + } + break; + case WP_GRENADE_LAUNCHER: + weapon_grenadelauncher_fire( ent ); + break; + case WP_ROCKET_LAUNCHER: + Weapon_RocketLauncher_Fire( ent ); + break; + case WP_PLASMAGUN: + Weapon_Plasmagun_Fire( ent ); + break; + case WP_RAILGUN: + weapon_railgun_fire( ent ); + break; + case WP_BFG: + BFG_Fire( ent ); + break; + case WP_GRAPPLING_HOOK: + Weapon_GrapplingHook_Fire( ent ); + break; +#ifdef MISSIONPACK + case WP_NAILGUN: + Weapon_Nailgun_Fire( ent ); + break; + case WP_PROX_LAUNCHER: + weapon_proxlauncher_fire( ent ); + break; + case WP_CHAINGUN: + Bullet_Fire( ent, CHAINGUN_SPREAD, MACHINEGUN_DAMAGE ); + break; +#endif + default: +// FIXME G_Error( "Bad ent->s.weapon" ); + break; + } +} + + +#ifdef MISSIONPACK + +/* +=============== +KamikazeRadiusDamage +=============== +*/ +static void KamikazeRadiusDamage( vec3_t origin, gentity_t *attacker, float damage, float radius ) { + float dist; + gentity_t *ent; + int entityList[MAX_GENTITIES]; + int numListedEntities; + vec3_t mins, maxs; + vec3_t v; + vec3_t dir; + int i, e; + + if ( radius < 1 ) { + radius = 1; + } + + for ( i = 0 ; i < 3 ; i++ ) { + mins[i] = origin[i] - radius; + maxs[i] = origin[i] + radius; + } + + numListedEntities = gi.EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); + + for ( e = 0 ; e < numListedEntities ; e++ ) { + ent = &g_entities[entityList[ e ]]; + + if (!ent->takedamage) { + continue; + } + + // dont hit things we have already hit + if( ent->kamikazeTime > level.time ) { + continue; + } + + // find the distance from the edge of the bounding box + for ( i = 0 ; i < 3 ; i++ ) { + if ( origin[i] < ent->r.absmin[i] ) { + v[i] = ent->r.absmin[i] - origin[i]; + } else if ( origin[i] > ent->r.absmax[i] ) { + v[i] = origin[i] - ent->r.absmax[i]; + } else { + v[i] = 0; + } + } + + dist = VectorLength( v ); + if ( dist >= radius ) { + continue; + } + +// if( CanDamage (ent, origin) ) { + VectorSubtract (ent->r.currentOrigin, origin, dir); + // push the center of mass higher than the origin so players + // get knocked into the air more + dir[2] += 24; + G_Damage( ent, NULL, attacker, dir, origin, damage, DAMAGE_RADIUS|DAMAGE_NO_TEAM_PROTECTION, MOD_KAMIKAZE ); + ent->kamikazeTime = level.time + 3000; +// } + } +} + +/* +=============== +KamikazeShockWave +=============== +*/ +static void KamikazeShockWave( vec3_t origin, gentity_t *attacker, float damage, float push, float radius ) { + float dist; + gentity_t *ent; + int entityList[MAX_GENTITIES]; + int numListedEntities; + vec3_t mins, maxs; + vec3_t v; + vec3_t dir; + int i, e; + + if ( radius < 1 ) + radius = 1; + + for ( i = 0 ; i < 3 ; i++ ) { + mins[i] = origin[i] - radius; + maxs[i] = origin[i] + radius; + } + + numListedEntities = gi.EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); + + for ( e = 0 ; e < numListedEntities ; e++ ) { + ent = &g_entities[entityList[ e ]]; + + // dont hit things we have already hit + if( ent->kamikazeShockTime > level.time ) { + continue; + } + + // find the distance from the edge of the bounding box + for ( i = 0 ; i < 3 ; i++ ) { + if ( origin[i] < ent->r.absmin[i] ) { + v[i] = ent->r.absmin[i] - origin[i]; + } else if ( origin[i] > ent->r.absmax[i] ) { + v[i] = origin[i] - ent->r.absmax[i]; + } else { + v[i] = 0; + } + } + + dist = VectorLength( v ); + if ( dist >= radius ) { + continue; + } + +// if( CanDamage (ent, origin) ) { + VectorSubtract (ent->r.currentOrigin, origin, dir); + dir[2] += 24; + G_Damage( ent, NULL, attacker, dir, origin, damage, DAMAGE_RADIUS|DAMAGE_NO_TEAM_PROTECTION, MOD_KAMIKAZE ); + // + dir[2] = 0; + VectorNormalize(dir); + if ( ent->client ) { + ent->client->ps.velocity[0] = dir[0] * push; + ent->client->ps.velocity[1] = dir[1] * push; + ent->client->ps.velocity[2] = 100; + } + ent->kamikazeShockTime = level.time + 3000; +// } + } +} + +/* +=============== +KamikazeDamage +=============== +*/ +static void KamikazeDamage( gentity_t *self ) { + int i; + float t; + gentity_t *ent; + vec3_t newangles; + + self->count += 100; + + if (self->count >= KAMI_SHOCKWAVE_STARTTIME) { + // shockwave push back + t = self->count - KAMI_SHOCKWAVE_STARTTIME; + KamikazeShockWave(self->s.origin, self->activator, 25, 400, (int) (float) t * KAMI_SHOCKWAVE_MAXRADIUS / (KAMI_SHOCKWAVE_ENDTIME - KAMI_SHOCKWAVE_STARTTIME) ); + } + // + if (self->count >= KAMI_EXPLODE_STARTTIME) { + // do our damage + t = self->count - KAMI_EXPLODE_STARTTIME; + KamikazeRadiusDamage( self->s.origin, self->activator, 400, (int) (float) t * KAMI_BOOMSPHERE_MAXRADIUS / (KAMI_IMPLODE_STARTTIME - KAMI_EXPLODE_STARTTIME) ); + } + + // either cycle or kill self + if( self->count >= KAMI_SHOCKWAVE_ENDTIME ) { + G_FreeEntity( self ); + return; + } + self->nextthink = level.time + 100; + + // add earth quake effect + newangles[0] = crandom() * 2; + newangles[1] = crandom() * 2; + newangles[2] = 0; + for (i = 0; i < MAX_CLIENTS; i++) + { + ent = &g_entities[i]; + if (!ent->inuse) + continue; + if (!ent->client) + continue; + + if (ent->client->ps.groundEntityNum != ENTITYNUM_NONE) { + ent->client->ps.velocity[0] += crandom() * 120; + ent->client->ps.velocity[1] += crandom() * 120; + ent->client->ps.velocity[2] = 30 + random() * 25; + } + + ent->client->ps.delta_angles[0] += ANGLE2SHORT(newangles[0] - self->movedir[0]); + ent->client->ps.delta_angles[1] += ANGLE2SHORT(newangles[1] - self->movedir[1]); + ent->client->ps.delta_angles[2] += ANGLE2SHORT(newangles[2] - self->movedir[2]); + } + VectorCopy(newangles, self->movedir); +} + +/* +=============== +G_StartKamikaze +=============== +*/ +void G_StartKamikaze( gentity_t *ent ) { + gentity_t *explosion; + gentity_t *te; + vec3_t snapped; + + // start up the explosion logic + explosion = G_Spawn(); + + explosion->s.eType = ET_EVENTS + EV_KAMIKAZE; + explosion->eventTime = level.time; + + if ( ent->client ) { + VectorCopy( ent->s.origin, snapped ); + } + else { + VectorCopy( ent->activator->s.origin, snapped ); + } + SnapVector( snapped ); // save network bandwidth + G_SetOrigin( explosion, snapped ); + + explosion->classname = "kamikaze"; + explosion->s.pos.trType = TR_STATIONARY; + + explosion->kamikazeTime = level.time; + + explosion->think = KamikazeDamage; + explosion->nextthink = level.time + 100; + explosion->count = 0; + VectorClear(explosion->movedir); + + gi.LinkEntity( explosion ); + + if (ent->client) { + // + explosion->activator = ent; + // + ent->s.eFlags &= ~EF_KAMIKAZE; + // nuke the guy that used it + G_Damage( ent, ent, ent, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_KAMIKAZE ); + } + else { + if ( !strcmp(ent->activator->classname, "bodyque") ) { + explosion->activator = &g_entities[ent->activator->r.ownerNum]; + } + else { + explosion->activator = ent->activator; + } + } + + // play global sound at all clients + te = G_TempEntity(snapped, EV_GLOBAL_TEAM_SOUND ); + te->r.svFlags |= SVF_BROADCAST; + te->s.eventParm = GTS_KAMIKAZE; +} +#endif + +#endif + diff --git a/code/game/game.cpp b/code/game/game.cpp new file mode 100644 index 00000000..42db9ea7 --- /dev/null +++ b/code/game/game.cpp @@ -0,0 +1,545 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// game.cpp : General Game Info. + +#include "game.h" +#include "scriptmaster.h" +#include "world.h" + +#ifdef GAME_DLL +#include "../game/camera.h" +#include "../game/entity.h" +#include "../game/player.h" +#include "../game/dm_manager.h" +#endif + +Game game; + +void G_BeginIntermission + ( + const char *map_name, + INTTYPE_e transtype + ) + +{ + Entity *camera; + Entity *node; + Event *ev; + gentity_t *client; + int i; + + if( level.intermissiontime || g_gametype->integer ) { + return; + } + + level.intermissiontime = level.time; + level.intermissiontype = transtype; + + G_FadeOut( 2.0f ); + G_FadeSound( 4.0f ); + + level.nextmap = map_name; + + camera = ( Entity * )G_FindClass( NULL, "info_player_intermission" ); + if( camera ) + { + SetCamera( camera, 0.5f ); + + ev = new Event( EV_Camera_Orbit ); + + node = ( Entity * )G_FindTarget( NULL, "endnode1" ); + if( node && node->IsSubclassOfEntity() ) + { + ev->AddEntity( node ); + camera->ProcessEvent( ev ); + camera->ProcessEvent( EV_Camera_Cut ); + } + } + + for( i = 0, client = g_entities; i < game.maxclients; client++, i++ ) + { + if( !client->inuse || !client->entity ) { + continue; + } + + client->entity->flags |= FL_IMMOBILE; + client->entity->PostEvent( EV_Player_EnterIntermission, 3.0f ); + } +} + +void G_BeginIntermission2( void ) +{ + gentity_t *client; + Entity *ent; + int i; + + if( level.intermissiontime ) { + return; + } + + level.playerfrozen = qtrue; + level.intermissiontime = level.time; + + ent = ( Entity * )G_FindClass( NULL, "info_player_intermission" ); + + G_FadeSound( 4.0f ); + + if( ent ) + { + SetCamera( ent, 0.5f ); + } + else + { + G_FadeOut( 2.0f ); + } + + for( i = 0, client = g_entities; i < game.maxclients; i++, client++ ) + { + if( !client->inuse || !client->entity || !client->client ) { + continue; + } + + ent = client->entity; + + G_DisplayScores( ent ); + ent->flags |= FL_IMMOBILE; + } +} + +void G_ExitIntermission( void ) +{ + level.exitintermission = qtrue; +} + +void G_CheckIntermissionExit( void ) +{ + if( !level.exitintermission && g_maxintermission->value > level.time - level.intermissiontime ) { + return; + } + + if( level.nextmap != level.current_map ) + { + G_ExitLevel(); + } + else + { + G_RestartLevelWithDelay( 0.1f ); + + level.nextmap = ""; + level.intermissiontime = 0; + level.exitintermission = qfalse; + } +} + +void ClosePlayerLogFile( void ); + +void G_ExitLevel + ( + void + ) + +{ + static const char *seps = " ,\n\r"; + char command[ 256 ]; + int j; + gentity_t *ent; + + + // Don't allow exit level if the mission was failed + + if( level.mission_failed ) + return; + + // close the player log file if necessary + ClosePlayerLogFile(); + + // kill the sounds + Com_sprintf( command, sizeof( command ), "stopsound\n" ); + gi.SendConsoleCommand( command ); + + if( g_gametype->integer ) + { + if( strlen( sv_nextmap->string ) ) + { + // The nextmap cvar was set (possibly by a vote - so go ahead and use it) + level.nextmap = sv_nextmap->string; + gi.Cvar_Set( "nextmap", "" ); + } + else // Use the next map in the maplist + { + char *s, *f, *t; + + f = NULL; + s = strdup( sv_maplist->string ); + t = strtok( s, seps ); + while( t != NULL ) + { + if( !Q_stricmp( t, level.mapname.c_str() ) ) + { + // it's in the list, go to the next one + t = strtok( NULL, seps ); + if( t == NULL ) // end of list, go to first one + { + if( f == NULL ) // there isn't a first one, same level + { + level.nextmap = level.mapname; + } + else + { + level.nextmap = f; + } + } + else + { + level.nextmap = t; + } + free( s ); + goto out; + } + + // set the first map + if( !f ) + { + f = t; + } + t = strtok( NULL, seps ); + } + free( s ); + } +out: + // level.nextmap should be set now, but if it isn't use the same map + if( level.nextmap.length() == 0 ) + { + // Stay on the same map since no nextmap was set + Com_sprintf( command, sizeof( command ), "restart\n" ); + gi.SendConsoleCommand( command ); + } + else // use the level.nextmap variable + { + Com_sprintf( command, sizeof( command ), "gamemap \"%s\"\n", level.nextmap.c_str() ); + gi.SendConsoleCommand( command ); + } + } + else + { + Com_sprintf( command, sizeof( command ), "gamemap \"%s\"\n", level.nextmap.c_str() ); + gi.SendConsoleCommand( command ); + } + + // Tell all the clients that the level is done + for( j = 0; j < game.maxclients; j++ ) + { + ent = &g_entities[ j ]; + if( !ent->inuse || !ent->entity ) + { + continue; + } + + ent->entity->ProcessEvent( EV_Player_EndLevel ); + } + + level.nextmap = ""; + + level.exitintermission = 0; + level.intermissiontime = 0; + + G_ClientEndServerFrames(); +} + +void G_RestartLevelWithDelay( float delaytime ) +{ + int i; + + if( level.died_already ) { + return; + } + + level.died_already = true; + + // Restart the level soon + for( i = 0; i < game.maxclients; i++ ) + { + if( g_entities[ i ].inuse ) + { + if( g_entities[ i ].entity ) + { + g_entities[ i ].entity->PostEvent( EV_Player_Respawn, delaytime ); + } + } + } +} + +void G_UpdateMatchEndTime( void ) +{ + int endtime = 0; + + if( dmManager.GameHasRounds() && dmManager.GetRoundLimit() ) + { + endtime = dmManager.GetMatchStartTime() * 1000.0f + ( level.svsStartTime + 60000 * dmManager.GetRoundLimit() ); + } + else if( timelimit->integer ) + { + endtime = level.svsStartTime + 60000 * timelimit->integer; + } + + if( level.svsEndTime != endtime ) + { + level.svsEndTime = endtime; + gi.SetConfigstring( CS_MATCHEND, va( "%i", endtime ) ); + } +} + +int G_GetClientNumber( gentity_t *ent ) +{ + return ent->client->ps.clientNum; +} + +int G_GetClientNumber( Entity *entity ) +{ + return 0; +} + +SimpleArchivedEntity *G_FindArchivedClass( SimpleArchivedEntity *ent, const char *classname ) +{ + SimpleArchivedEntity *arcent; + int i; + + if( ent ) + { + i = level.m_SimpleArchivedEntities.IndexOfObject( ( SimpleArchivedEntity * )ent ) - 1; + } + else + { + i = level.m_SimpleArchivedEntities.NumObjects(); + } + + for( ; i > 0; i-- ) + { + arcent = level.m_SimpleArchivedEntities.ObjectAt( i ); + + if( !Q_stricmp( arcent->getClassID(), classname ) ) + { + return arcent; + } + } + + return NULL; +} + +Entity *G_FindClass( Entity *ent, const char *classname ) +{ + int entnum; + gentity_t *from; + + if( ent ) + { + entnum = ent->entnum; + } + else + { + entnum = -1; + } + + for( from = &g_entities[ entnum + 1 ]; from < &g_entities[ globals.num_entities ]; from++ ) + { + if( !from->inuse ) + { + continue; + } + if( !Q_stricmp( from->entity->getClassID(), classname ) ) + { + return from->entity; + } + } + + return NULL; +} + +Entity *G_GetEntity( int ent_num ) +{ + gentity_t * ent = &globals.gentities[ ent_num ]; + + if( ent_num < 0 || ent_num > globals.max_entities ) + { + gi.DPrintf( "G_GetEntity: %d out of valid range.\n", ent_num ); + return NULL; + } + + return ent->entity; +} + +Entity *G_GetEntityByClient( int clientNum ) +{ + gentity_t * ent = globals.gentities; + if ( clientNum < 0 || clientNum > globals.max_entities ) + { + gi.DPrintf( "G_GetEntity: %d out of valid range.", clientNum ); + return NULL; + } + + for( int i = 0; i < globals.num_entities; i++, ent++ ) + { + if ( ent->s.clientNum == clientNum ) + break; + } + + return ent->entity; +} + +int G_GetEntityIndex( int number ) +{ + gentity_t * ent = globals.gentities; + + if( number < 0 || number > globals.max_entities ) { + return -1; + } + + for( int i = 0; i < globals.num_entities; i++, ent++ ) + { + if( ent->s.number == number ) { + return i; + } + } + + return -1; +} + +int G_GetEntityIndex( gentity_t * ent ) +{ + return G_GetEntityIndex( ent->s.number ); +} + +gentity_t * G_GetGEntity( int ent_num ) +{ + gentity_t * ent = &globals.gentities[ ent_num ]; + + if( ent_num < 0 || ent_num > globals.max_entities ) + { + gi.DPrintf( "G_GetEntity: %d out of valid range.\n", ent_num ); + return NULL; + } + + return ent; +} + +SimpleEntity *G_FindTarget( SimpleEntity *ent, const char *name ) +{ + SimpleEntity *next; + + if( name && name[ 0 ] ) + { + if( name[ 0 ] == '$' ) + name++; + + next = world->GetNextEntity( name, ent ); + + if( next ) + { + return next; + } + } + + return NULL; +} + +SimpleEntity *G_FindRandomSimpleTarget( const char *name ) +{ + //int nFound; + + // FIXME: stub + STUB(); + return NULL; +} + +void G_TouchTriggers( Entity *ent ) +{ + int i; + int num; + int touch[ MAX_GENTITIES ]; + gentity_t *hit; + Event *ev; + + // dead things don't activate triggers! + if( ( ent->client || ( ent->edict->r.svFlags & SVF_BOT ) ) && ( ent->IsDead() ) ) + { + return; + } + + num = gi.AreaEntities( ent->absmin, ent->absmax, touch, MAX_GENTITIES ); + + // be careful, it is possible to have an entity in this + // list removed before we get to it (killtriggered) + for( i = 0; i < num; i++ ) + { + hit = &g_entities[ touch[ i ] ]; + if( !hit->inuse || ( hit->entity == ent ) || ( hit->solid != SOLID_TRIGGER ) ) + { + continue; + } + + assert( hit->entity ); + + ev = new Event( EV_Touch ); + ev->AddEntity( ent ); + hit->entity->ProcessEvent( ev ); + } +} + +trace_t G_Trace( + const vec3_t start, + const vec3_t bbox_mins, + const vec3_t bbox_maxs, + const vec3_t end, + Entity *entity, + int mask, + qboolean cliptoentities, + const char *description +) +{ + trace_t results; + + gi.Trace( &results, start, bbox_mins, bbox_maxs, end, entity->entnum, 0, 0, false ); + + return results; +} + +Game::Game() +{ + clients = NULL; + maxclients = 0; +} + +Game::~Game() +{ + +} + +void Game::Archive( Archiver& arc ) +{ + +} + +CLASS_DECLARATION( Listener, Game, NULL ) +{ + { NULL, NULL } +}; diff --git a/code/game/game.h b/code/game/game.h new file mode 100644 index 00000000..a7d13621 --- /dev/null +++ b/code/game/game.h @@ -0,0 +1,234 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// game.h: General Game Info + +#ifndef __GAME_H__ +#define __GAME_H__ + +#include "glb_local.h" +#include "listener.h" +#include "level.h" + +class Game : public Listener +{ +public: + gclient_t *clients; + qboolean autosaved; + int maxclients; + int maxentities; + +public: + CLASS_PROTOTYPE( Game ); + + virtual void Archive( Archiver &arc ); + + Game(); + ~Game(); +}; + +/* +* Functions prototypes +*/ + + +/* G_BeginIntermission +* +* Change the current map to the specified map with the possibility to fade the screen with fadetime. +*/ +void G_BeginIntermission( + const char *map_name, + INTTYPE_e transtype = TRANS_BSP +); + +/* G_BeginIntermission2 +* +* Called when a restart/change was issued +*/ +void G_BeginIntermission2( void ); + +/* G_ExitIntermission +* +* Exit the intermission screen. +*/ +void G_ExitIntermission( void ); + +/* G_CheckIntermissionExit +* +* Checks for the intermission to exit. +*/ +void G_CheckIntermissionExit( void ); + +/* G_ExitLevel +* +* Exits the level. +*/ +void G_ExitLevel( void ); + +/* G_RestartLevelWithDelay +* +* Restarts the level. +*/ +void G_RestartLevelWithDelay( float delaytime ); + +/* G_UpdateMatchEndTime +* +* Update the timelimit +*/ +void G_UpdateMatchEndTime( void ); + +/* G_FadeSound +* +* Fades the sound out over the given time. +*/ +void G_FadeSound( + float time +); + +/* G_FindArchivedClass +* +* Finds an entity of the specified class. +* Gets the next entity if necessary. +*/ +SimpleArchivedEntity *G_FindArchivedClass( + SimpleArchivedEntity *ent, + const char *classname +); + +/* G_FindClass +* +* Finds an entity of the specified class. +* Gets the next entity if necessary. +*/ +Entity *G_FindClass( + Entity *ent, + const char *classname +); + +/* G_FindTarget +* +* Find an entity with the specified targetname. +*/ +SimpleEntity *G_FindTarget( + SimpleEntity *ent, + const char *name +); + +/* G_FindRandomSimpleTarget +* +* Find a random simple entity with the specified targetname. +*/ +SimpleEntity *G_FindRandomSimpleTarget( + const char *name +); + +/* G_GetClientNumber +* +* Gets the specified client number from an entity. +* Returns -1 on failure. +*/ +int G_GetClientNumber( + gentity_t * ent +); + +/* G_GetClientNumber +* +* Gets the specified client number from an entity. +* Returns -1 on failure. +*/ +int G_GetClientNumber( + Entity * ent +); + +/* G_GetEntity +* +* Gets the specified entity number from an entity. +* Returns -1 on failure. +*/ +int G_GetEntity( + Entity * entity +); + +/* G_GetEntity +* +* Gets the specified entity +*/ +Entity * G_GetEntity( + int id +); + +/* G_GetEntityByClient +* +* Gets the specified entity from a client number +*/ +Entity * G_GetEntityByClient( + int clientNum +); + +/* G_GetEntityIndex +* +* Gets the specified index from an entity number +*/ +int G_GetEntityIndex( + int number +); + +/* G_GetEntityIndex +* +* Gets the specified index from a gentity +*/ +int G_GetEntityIndex( + gentity_t * ent +); + +/* G_GetGEntity +* +* Gets the specified gentity. +*/ +gentity_t * G_GetGEntity( + int id +); + +/* G_StartCinematic +* +* Turns on cinematic. +*/ +void G_StartCinematic( void ); + + +/* G_StopCinematic +* +* Turns off cinematic. +*/ +void G_StopCinematic( void ); + +/* G_TouchTriggers +* +* Makes the entity touch triggers +*/ +void G_TouchTriggers( + Entity *entity +); + +extern Game game; + +#endif /* __GAME_H__ */ diff --git a/code/game/gamecmds.cpp b/code/game/gamecmds.cpp new file mode 100644 index 00000000..c5f7e36c --- /dev/null +++ b/code/game/gamecmds.cpp @@ -0,0 +1,805 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// gamecmds.cpp: Game commands +// + +#include "gamecmds.h" +#include "glb_local.h" +#include "camera.h" +#include "viewthing.h" +#include "soundman.h" +#include "navigate.h" +#include "lodthing.h" +#include "player.h" +#include +#include "playerbot.h" + +typedef struct + { + const char *command; + qboolean ( *func )( gentity_t *ent ); + qboolean allclients; + } consolecmd_t; + +consolecmd_t G_ConsoleCmds[] = + { + // command name function available in multiplayer? + { "say", G_SayCmd, qtrue }, + { "eventlist", G_EventListCmd, qfalse }, + { "pendingevents", G_PendingEventsCmd, qfalse }, + { "eventhelp", G_EventHelpCmd, qfalse }, + { "dumpevents", G_DumpEventsCmd, qfalse }, + { "classevents", G_ClassEventsCmd, qfalse }, + { "dumpclassevents", G_DumpClassEventsCmd, qfalse }, + { "dumpallclasses", G_DumpAllClassesCmd, qtrue }, + { "classlist", G_ClassListCmd, qfalse }, + { "classtree", G_ClassTreeCmd, qfalse }, + { "cam", G_CameraCmd, qfalse }, + { "snd", G_SoundCmd, qfalse }, + { "showvar", G_ShowVarCmd, qfalse }, + { "script", G_ScriptCmd, qfalse }, + { "levelvars", G_LevelVarsCmd, qfalse }, + { "gamevars", G_GameVarsCmd, qfalse }, + { "compilescript", G_CompileScript, qfalse }, + { "addbots", G_AddBot, qtrue }, + { "removebots", G_RemoveBot, qtrue }, +#ifdef _DEBUG + { "bot", G_BotCommand, qtrue }, +#endif + { NULL, NULL, NULL } + }; + + +void G_InitConsoleCommands + ( + void + ) + +{ + consolecmd_t *cmds; + + // + // the game server will interpret these commands, which will be automatically + // forwarded to the server after they are not recognized locally + // + gi.AddCommand( "give", NULL ); + gi.AddCommand( "god", NULL ); + gi.AddCommand( "notarget", NULL ); + gi.AddCommand( "noclip", NULL ); + gi.AddCommand( "kill", NULL ); + gi.AddCommand( "script", NULL ); + + for( cmds = G_ConsoleCmds; cmds->command != NULL; cmds++ ) + { + gi.AddCommand( cmds->command, NULL ); + } +} + +qboolean G_ConsoleCommand ( void ) +{ + gentity_t *ent; + qboolean result; + consolecmd_t *cmds; + const char *cmd; + + result = qfalse; + try + { + ent = &g_entities[ 0 ]; + + cmd = gi.Argv( 0 ); + + for( cmds = G_ConsoleCmds; cmds->command != NULL; cmds++ ) + { + if( !Q_stricmp( cmd, cmds->command ) ) + { + return cmds->func( ent ); + } + } + + result = G_ProcessClientCommand( ent ); + } + catch( const char *error ) + { + G_ExitWithError( error ); + } + + return result; +} + +void G_ClientCommand( gentity_t *ent ) +{ + try + { + if ( ent && !G_ProcessClientCommand( ent ) ) + { + // anything that doesn't match a command will be a chat + //G_Say( ent, false, true ); + } + } + + catch( const char *error ) + { + G_ExitWithError( error ); + } +} + +qboolean G_ProcessClientCommand + ( + gentity_t *ent + ) + +{ + const char *cmd; + consolecmd_t *cmds; + int i; + int n; + ConsoleEvent *ev; + Player *player; + + if( !ent || !ent->client || !ent->entity ) + { + // not fully in game yet + return qfalse; + } + + cmd = gi.Argv( 0 ); + + player = ( Player * )ent->entity; + player->m_lastcommand = cmd; + + for( cmds = G_ConsoleCmds; cmds->command != NULL; cmds++ ) + { + // if we have multiple clients and this command isn't allowed by multiple clients, skip it + if( ( game.maxclients > 1 ) && ( !cmds->allclients ) ) + { + continue; + } + + if( !Q_stricmp( cmd, cmds->command ) ) + { + return cmds->func( ent ); + } + } + + if( Event::FindEventNum( cmd ) ) + { + ev = new ConsoleEvent( cmd ); + ev->SetConsoleEdict( ent ); + + n = gi.Argc(); + + for( i = 1; i < n; i++ ) + { + ev->AddToken( gi.Argv( i ) ); + } + + if( !Q_stricmpn( cmd, "lod_", 4 ) ) + { + return LODModel.ProcessEvent( ev ); + } + else if( !Q_stricmpn( cmd, "view", 4 ) ) + { + return Viewmodel.ProcessEvent( ev ); + } + else if( ent->entity->CheckEventFlags( ev ) ) + { + return ent->entity->ProcessEvent( ev ); + } + } + + return qfalse; +} + +/* +================== +Cmd_Say_f +================== +*/ +void G_Say + ( + gentity_t *ent, + qboolean team, + qboolean arg0 + ) + + { + int j; + gentity_t *other; + const char *p; + char text[ 2048 ]; + + if ( gi.Argc() < 2 && !arg0 ) + { + return; + } + + if ( !ent->entity ) + { + // just in case we're not joined yet. + team = false; + } + + if ( !DM_FLAG( DF_MODELTEAMS | DF_SKINTEAMS ) ) + { + team = false; + } + + if ( team ) + { + Com_sprintf( text, sizeof( text ), "(%s): ", ent->client->pers.netname ); + } + else + { + Com_sprintf( text, sizeof( text ), "%s: ", ent->client->pers.netname ); + } + + if ( arg0 ) + { + strcat( text, gi.Argv( 0 ) ); + strcat( text, " " ); + strcat( text, gi.Args() ); + } + else + { + p = gi.Args(); + + if ( *p == '"' ) + { + p++; + strcat( text, p ); + text[ strlen( text ) - 1 ] = 0; + } + else + { + strcat( text, p ); + } + } + + // don't let text be too long for malicious reasons + if ( strlen( text ) > 150 ) + { + text[ 150 ] = 0; + } + + strcat( text, "\n" ); + + if ( dedicated->integer ) + { + gi.SendServerCommand( NULL, "print \"%s\"", text ); + } + + for( j = 0; j < game.maxclients; j++ ) + { + other = &g_entities[ j ]; + if ( !other->inuse || !other->client || !other->entity ) + { + continue; + } + + gi.SendServerCommand( NULL, "print \"%s\"", text ); + } + } + +qboolean G_CameraCmd + ( + gentity_t *ent + ) + + { + Event *ev; + const char *cmd; + int i; + int n; + + n = gi.Argc(); + if ( !n ) + { + gi.Printf( "Usage: cam [command] [arg 1]...[arg n]\n" ); + return qtrue; + } + + cmd = gi.Argv( 1 ); + if ( Event::GetEvent( cmd ) ) + { + ev = new Event( cmd ); + + for( i = 2; i < n; i++ ) + { + ev->AddToken( gi.Argv( i ) ); + } + + CameraMan.ProcessEvent( ev ); + } + else + { + gi.Printf( "Unknown camera command '%s'.\n", cmd ); + } + + return qtrue; + } + +qboolean G_SoundCmd + ( + gentity_t *ent + ) + + { + Event *ev; + const char *cmd; + int i; + int n; + + n = gi.Argc(); + if ( !n ) + { + gi.Printf( "Usage: snd [command] [arg 1]...[arg n]\n" ); + return qtrue; + } + + cmd = gi.Argv( 1 ); + if ( Event::GetEvent( cmd ) ) + { + ev = new Event( cmd ); + + for( i = 2; i < n; i++ ) + { + ev->AddToken( gi.Argv( i ) ); + } + + SoundMan.ProcessEvent( ev ); + } + else + { + gi.Printf( "Unknown sound command '%s'.\n", cmd ); + } + + return qtrue; + } + +qboolean G_SayCmd + ( + gentity_t *ent + ) + + { + G_Say( ent, false, false ); + + return qtrue; + } + +qboolean G_EventListCmd + ( + gentity_t *ent + ) + + { + const char *mask; + + mask = NULL; + if ( gi.Argc() > 1 ) + { + mask = gi.Argv( 1 ); + } + + //Event::ListCommands( mask ); + + return qtrue; + } + +qboolean G_PendingEventsCmd + ( + gentity_t *ent + ) + + { + const char *mask; + + mask = NULL; + if ( gi.Argc() > 1 ) + { + mask = gi.Argv( 1 ); + } + + //Event::PendingEvents( mask ); + + return qtrue; + } + +qboolean G_EventHelpCmd + ( + gentity_t *ent + ) + + { + const char *mask; + + mask = NULL; + if ( gi.Argc() > 1 ) + { + mask = gi.Argv( 1 ); + } + + //Event::ListDocumentation( mask, false ); + + return qtrue; + } + +qboolean G_DumpEventsCmd + ( + gentity_t *ent + ) + + { + const char *mask; + + mask = NULL; + if ( gi.Argc() > 1 ) + { + mask = gi.Argv( 1 ); + } + + //Event::ListDocumentation( mask, true ); + + return qtrue; + } + +qboolean G_ClassEventsCmd + ( + gentity_t *ent + ) + + { + const char *className; + + className = NULL; + if ( gi.Argc() < 2 ) + { + gi.Printf( "Usage: classevents [className]\n" ); + className = gi.Argv( 1 ); + } + else + { + className = gi.Argv( 1 ); + //ClassEvents( className ); + } + return qtrue; + } + +qboolean G_DumpClassEventsCmd + ( + gentity_t *ent + ) + + { + const char *className; + + className = NULL; + if ( gi.Argc() < 2 ) + { + gi.Printf( "Usage: dumpclassevents [className]\n" ); + className = gi.Argv( 1 ); + } + else + { + className = gi.Argv( 1 ); + //ClassEvents( className, qtrue ); + } + return qtrue; + } + +qboolean G_DumpAllClassesCmd + ( + gentity_t *ent + ) + + { + DumpAllClasses(); + return qtrue; + } + +qboolean G_ClassListCmd + ( + gentity_t *ent + ) + + { + //listAllClasses(); + + return qtrue; + } + +qboolean G_ClassTreeCmd + ( + gentity_t *ent + ) + + { + if ( gi.Argc() > 1 ) + { + //listInheritanceOrder( gi.Argv( 1 ) ); + } + else + { + gi.SendServerCommand( ent - g_entities, "print \"Syntax: classtree [classname].\n\"" ); + } + + return qtrue; + } + +qboolean G_ShowVarCmd + ( + gentity_t *ent + ) + +{ + return qtrue; +} + +qboolean G_ScriptCmd( gentity_t *ent ) +{ + if( gi.Argc() > 1 ) + { + const char *script = gi.Argv( 1 ); + int recompile = false; + + if( gi.Argc() > 2 ) + { + sscanf( gi.Argv( 2 ), "%d", &recompile ); + } + + Director.GetScript( script, recompile ); + Director.ExecuteThread( script ); + + return qtrue; + } + else + { + gi.Printf( "Usage: script [filename] ([recompile])\n" ); + return qfalse; + } +} + +void PrintVariableList + ( + ScriptVariableList * list + ) +{ +} + +qboolean G_LevelVarsCmd + ( + gentity_t *ent + ) + + { + gi.Printf( "Level Variables\n" ); + PrintVariableList( level.vars ); + + return qtrue; + } + +qboolean G_GameVarsCmd + ( + gentity_t *ent + ) + + { + gi.Printf( "Game Variables\n" ); + PrintVariableList( game.vars ); + + return qtrue; + } + +qboolean G_CompileScript + ( + gentity_t *ent + ) + +{ + if( gi.Argc() <= 2 ) + { + gi.Printf( "Usage: compilescript [filename] [output file]\n" ); + return qfalse; + } + + CompileAssemble( gi.Argv( 1 ), gi.Argv( 2 ) ); + return qtrue; +} + +static int botnum = 0; +static gentity_t *firstBot = NULL; + +qboolean G_AddBot + ( + gentity_t *ent + ) + +{ + int numbots; + int n; + int i; + int clientNum = -1; + gentity_t *e; + char botName[ MAX_NETNAME ]; + char challenge[ MAX_STRING_TOKENS ]; + + if( gi.Argc() <= 1 ) + { + gi.Printf( "Usage: addbot [numbots] [optional botname]\n" ); + return qfalse; + } + + numbots = atoi( gi.Argv( 1 ) ); + if( numbots <= 0 || numbots > maxbots->integer ) + { + gi.Printf( "addbot must be between 1-%d\n", maxbots->integer ); + return qfalse; + } + + for( n = 0; n < numbots; n++ ) + { + botnum++; + + for( i = maxclients->integer; i < game.maxclients; i++ ) + { + e = &g_entities[ i ]; + + if( !e->inuse && e->client ) + { + clientNum = i; + break; + } + } + + if( clientNum == -1 ) + { + gi.Printf( "No free slot for a bot\n" ); + return qfalse; + } + + if( gi.Argc() > 2 ) + { + Q_strncpyz( botName, gi.Argv( 2 ), sizeof( botName ) ); + } + else + { + sprintf( botName, "bot%d", botnum ); + } + + sprintf( challenge, "%d", botnum ); + + e->s.clientNum = clientNum; + e->s.number = clientNum; + + Info_SetValueForKey( e->client->pers.userinfo, "name", botName ); + Info_SetValueForKey( e->client->pers.userinfo, "dm_playermodel", "allied_pilot" ); + Info_SetValueForKey( e->client->pers.userinfo, "dm_playergermanmodel", "german_afrika_officer" ); + Info_SetValueForKey( e->client->pers.userinfo, "fov", "80" ); + Info_SetValueForKey( e->client->pers.userinfo, "protocol", "8" ); + Info_SetValueForKey( e->client->pers.userinfo, "ip", "192.168.0.192" ); + Info_SetValueForKey( e->client->pers.userinfo, "qport", "8888" ); + Info_SetValueForKey( e->client->pers.userinfo, "challenge", challenge ); + Info_SetValueForKey( e->client->pers.userinfo, "snaps", "1" ); + Info_SetValueForKey( e->client->pers.userinfo, "rate", "1" ); + Info_SetValueForKey( e->client->pers.userinfo, "dmprimary", "smg" ); + + G_BotConnect( clientNum ); + + if( !firstBot ) + firstBot = e; + + G_BotBegin( e ); + + e->entity->PostEvent( EV_Player_AutoJoinDMTeam, level.frametime ); + + Event *ev = new Event( EV_Player_PrimaryDMWeapon ); + ev->AddString( "smg" ); + + e->entity->PostEvent( ev, level.frametime ); + } + + return qtrue; +} + +qboolean G_RemoveBot + ( + gentity_t *ent + ) + +{ + //int numbots; + + if( gi.Argc() <= 1 ) + { + gi.Printf( "Usage: removebot [numbots]\n" ); + return qfalse; + } + + // FIXME: not implemented yet + + return qtrue; +} + +#ifdef _DEBUG + +qboolean G_BotCommand + ( + gentity_t *ent + ) + +{ + const char *command; + PlayerBot *bot; + + if( !firstBot || !firstBot->entity ) + { + gi.Printf( "No bot spawned.\n" ); + return qfalse; + } + + if( gi.Argc() <= 1 ) + { + gi.Printf( "Usage: bot [cmd] (arg1) (arg2) (arg3) ..." ); + return qfalse; + } + + bot = ( PlayerBot * )firstBot->entity; + + command = gi.Argv( 1 ); + + if( !Q_stricmp( command, "movehere" ) ) + { + bot->MoveTo( ent->entity->origin ); + } + else if( !Q_stricmp( command, "moveherenear" ) ) + { + float rad = 256.0f; + + if( gi.Argc() > 2 ) + { + rad = atof( gi.Argv( 2 ) ); + } + + bot->MoveNear( ent->entity->origin, rad ); + } + else if( !Q_stricmp( command, "avoidhere" ) ) + { + float rad = 256.0f; + + if( gi.Argc() > 2 ) + { + rad = atof( gi.Argv( 2 ) ); + } + + bot->AvoidPath( ent->entity->origin, rad ); + } + else if( !Q_stricmp( command, "telehere" ) ) + { + bot->setOrigin( ent->s.origin ); + } + + return qtrue; +} + +#endif diff --git a/code/game/gamecmds.h b/code/game/gamecmds.h new file mode 100644 index 00000000..8ab0362b --- /dev/null +++ b/code/game/gamecmds.h @@ -0,0 +1,59 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// gamecmds.h: Game Commands. + +#ifndef __GAMECMDS_H__ +#define __GAMECMDS_H__ + +#include "g_local.h" + +void G_InitConsoleCommands( void ); + +qboolean G_ProcessClientCommand( gentity_t *ent ); + +void G_Say( gentity_t *ent, qboolean team, qboolean arg0 ); +qboolean G_CameraCmd( gentity_t *ent ); +qboolean G_SoundCmd( gentity_t *ent ); +qboolean G_SayCmd( gentity_t *ent ); +qboolean G_EventListCmd( gentity_t *ent ); +qboolean G_PendingEventsCmd( gentity_t *ent ); +qboolean G_EventHelpCmd( gentity_t *ent ); +qboolean G_DumpEventsCmd( gentity_t *ent ); +qboolean G_ClassEventsCmd( gentity_t *ent ); +qboolean G_DumpClassEventsCmd( gentity_t *ent ); +qboolean G_DumpAllClassesCmd( gentity_t *ent ); +qboolean G_ClassListCmd( gentity_t *ent ); +qboolean G_ClassTreeCmd( gentity_t *ent ); +qboolean G_ShowVarCmd( gentity_t *ent ); +qboolean G_RestartCmd( gentity_t *ent ); +qboolean G_ScriptCmd( gentity_t *ent ); +qboolean G_LevelVarsCmd( gentity_t *ent ); +qboolean G_GameVarsCmd( gentity_t *ent ); +qboolean G_CompileScript( gentity_t *ent ); +qboolean G_AddBot( gentity_t *ent ); +qboolean G_RemoveBot( gentity_t *ent ); +#ifdef _DEBUG +qboolean G_BotCommand( gentity_t *ent ); +#endif + +#endif /* !__GAMECMDS_H__ */ \ No newline at end of file diff --git a/code/game/gamecvars.cpp b/code/game/gamecvars.cpp new file mode 100644 index 00000000..2234a9ee --- /dev/null +++ b/code/game/gamecvars.cpp @@ -0,0 +1,479 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// gamecvars.cpp: Definitions for any cvars used by the game. +// + +#include "gamecvars.h" + +cvar_t *developer; +cvar_t *sv_reborn; + +cvar_t *deathmatch; +cvar_t *dmflags; +cvar_t *skill; +cvar_t *fraglimit; +cvar_t *timelimit; +cvar_t *roundlimit; +cvar_t *g_allowjointime; +cvar_t *g_teamswitchdelay; + +cvar_t *password; +cvar_t *sv_privatePassword; +cvar_t *filterban; + +cvar_t *flood_msgs; +cvar_t *flood_persecond; +cvar_t *flood_waitdelay; + +cvar_t *maxclients; +cvar_t *maxbots; +cvar_t *maxentities; +cvar_t *nomonsters; +cvar_t *precache; +cvar_t *dedicated; +cvar_t *detail; +cvar_t *com_blood; +cvar_t *whereami; +cvar_t *bosshealth; + +cvar_t *sv_maxvelocity; +cvar_t *sv_gravity; +cvar_t *sv_rollspeed; +cvar_t *sv_rollangle; +cvar_t *sv_cheats; +cvar_t *sv_showbboxes; + +cvar_t *sv_testloc_num; +cvar_t *sv_testloc_secondary; +cvar_t *sv_testloc_radius; +cvar_t *sv_testloc_offset_x; +cvar_t *sv_testloc_offset_y; +cvar_t *sv_testloc_offset_z; +cvar_t *sv_testloc_radius2; +cvar_t *sv_testloc_offset2_x; +cvar_t *sv_testloc_offset2_y; +cvar_t *sv_testloc_offset2_z; + +cvar_t *sv_showcameras; +cvar_t *sv_showentnums; +cvar_t *sv_stopspeed; +cvar_t *sv_friction; +cvar_t *sv_waterfriction; +cvar_t *sv_waterspeed; +cvar_t *sv_traceinfo; +cvar_t *sv_drawtrace; +cvar_t *sv_fps; +cvar_t *sv_cinematic; +cvar_t *sv_maplist; +cvar_t *sv_nextmap; +cvar_t *sv_runspeed; +cvar_t *sv_walkspeed; +cvar_t *sv_dmspeedmult; +cvar_t *sv_crouchspeedmult; + +cvar_t *g_showmem; +cvar_t *g_timeents; + +cvar_t *g_showaxis; +cvar_t *g_showplayerstate; +cvar_t *g_showplayeranim; +cvar_t *g_showawareness; +cvar_t *g_entinfo; +cvar_t *g_showlookat; + +cvar_t *g_numdebuglines; +cvar_t *g_numdebuglinedelays; +cvar_t *g_numdebugstrings; + +cvar_t *g_spiffyplayer; +cvar_t *g_spiffyvelocity_x; +cvar_t *g_spiffyvelocity_y; +cvar_t *g_spiffyvelocity_z; + +cvar_t *g_playermodel; +cvar_t *g_statefile; +cvar_t *g_showbullettrace; +cvar_t *s_debugmusic; +cvar_t *g_showautoaim; +cvar_t *g_debugtargets; +cvar_t *g_debugdamage; +cvar_t *g_logstats; + +cvar_t *g_showtokens; +cvar_t *g_showopcodes; +cvar_t *g_scriptcheck; +cvar_t *g_nodecheck; +cvar_t *g_scriptdebug; +cvar_t *g_scripttrace; + +cvar_t *g_ai; +cvar_t *g_vehicle; + +cvar_t *g_gametype; +cvar_t *g_gametypestring; +cvar_t *g_rankedserver; +cvar_t *g_teamdamage; + +cvar_t *g_allowvote; +cvar_t *g_monitor; +cvar_t *g_monitorNum; + +cvar_t *g_spawnentities; +cvar_t *g_spawnai; + +cvar_t *g_patherror; +cvar_t *g_droppeditemlife; +cvar_t *g_dropclips; +cvar_t *g_animdump; +cvar_t *g_showdamage; +cvar_t *g_ai_notifyradius; +cvar_t *g_ai_noticescale; +cvar_t *g_ai_soundscale; +cvar_t *ai_debug_grenades; + +cvar_t *g_warmup; +cvar_t *g_doWarmup; +cvar_t *g_forceready; +cvar_t *g_forcerespawn; +cvar_t *g_maxintermission; + +cvar_t *g_smoothClients; + +cvar_t *pmove_fixed; +cvar_t *pmove_msec; + +cvar_t *g_inactivespectate; +cvar_t *g_inactivekick; + +cvar_t *g_viewkick_pitch; +cvar_t *g_viewkick_yaw; +cvar_t *g_viewkick_roll; +cvar_t *g_viewkick_dmmult; + +cvar_t *g_drawattackertime; +cvar_t *g_playerdeltamethod; + +cvar_t *g_success; +cvar_t *g_failed; + +cvar_t *g_gotmedal; +cvar_t *g_medal0; +cvar_t *g_medal1; +cvar_t *g_medal2; +cvar_t *g_medal3; +cvar_t *g_medal4; +cvar_t *g_medal5; +cvar_t *g_eogmedal0; +cvar_t *g_eogmedal1; +cvar_t *g_eogmedal2; +cvar_t *g_m1l1; +cvar_t *g_m1l2; +cvar_t *g_m1l3; +cvar_t *g_m2l1; +cvar_t *g_m2l2; +cvar_t *g_m2l3; +cvar_t *g_m3l1; +cvar_t *g_m3l2; +cvar_t *g_m3l3; +cvar_t *g_m4l1; +cvar_t *g_m4l2; +cvar_t *g_m4l3; +cvar_t *g_m5l1; +cvar_t *g_m5l2; +cvar_t *g_m5l3; +cvar_t *g_m6l1; +cvar_t *g_m6l2; +cvar_t *g_m6l3; +cvar_t *g_lastsave; + +cvar_t *g_forceteamspectate; +cvar_t *g_spectatefollow_forward; +cvar_t *g_spectatefollow_right; +cvar_t *g_spectatefollow_up; +cvar_t *g_spectatefollow_pitch; +cvar_t *g_spectatefollow_firstperson; +cvar_t *g_spectate_allow_full_chat; + +cvar_t *g_voiceChat; + +cvar_t *sv_scriptfiles; + +void CVAR_Init( void ) +{ + developer = gi.Cvar_Get( "developer", "0", 0 ); + sv_reborn = gi.Cvar_Get( "sv_reborn", "0", CVAR_LATCH|CVAR_SERVERINFO ); + + precache = gi.Cvar_Get( "sv_precache", "1", 0 ); + + dedicated = gi.Cvar_Get( "dedicated", "1", CVAR_LATCH ); + deathmatch = gi.Cvar_Get( "deathmatch", "1", CVAR_USERINFO|CVAR_SERVERINFO|CVAR_LATCH ); + skill = gi.Cvar_Get( "skill", "1", CVAR_USERINFO|CVAR_SERVERINFO|CVAR_LATCH ); + + maxclients = gi.Cvar_Get( "sv_maxclients", "1", 0 ); + maxbots = gi.Cvar_Get( "sv_maxbots", "2", 0 ); + maxentities = gi.Cvar_Get( "maxentities", "1024", CVAR_LATCH ); + + password = gi.Cvar_Get( "password", "", CVAR_USERINFO ); + sv_privatePassword = gi.Cvar_Get( "sv_privatePassword", "", CVAR_TEMP ); + filterban = gi.Cvar_Get( "filterban", "1", 0 ); + + dmflags = gi.Cvar_Get( "dmflags", "0", CVAR_SERVERINFO ); + fraglimit = gi.Cvar_Get( "fraglimit", "0", CVAR_SERVERINFO ); + timelimit = gi.Cvar_Get( "timelimit", "0", CVAR_SERVERINFO ); + roundlimit = gi.Cvar_Get( "roundlimit", "0", CVAR_SERVERINFO ); + g_allowjointime = gi.Cvar_Get( "g_allowjointime", "30", CVAR_SERVERINFO ); + g_teamswitchdelay = gi.Cvar_Get( "g_teamswitchdelay", "15", 0 ); + + nomonsters = gi.Cvar_Get( "nomonsters", "0", CVAR_SERVERINFO ); + + flood_msgs = gi.Cvar_Get( "flood_msgs", "4", 0 ); + flood_persecond = gi.Cvar_Get( "flood_persecond", "4", 0 ); + flood_waitdelay = gi.Cvar_Get( "flood_waitdelay", "10", 0 ); + + detail = gi.Cvar_Get( "detail", "1", CVAR_ARCHIVE ); + com_blood = gi.Cvar_Get( "com_blood", "1", CVAR_ARCHIVE ); + whereami = gi.Cvar_Get( "whereami", "0", 0 ); + bosshealth = gi.Cvar_Get( "bosshealth", "0", 0 ); + + sv_rollspeed = gi.Cvar_Get( "sv_rollspeed", "2200", 0 ); + sv_rollangle = gi.Cvar_Get( "sv_rollangle", "2", 0 ); + sv_maxvelocity = gi.Cvar_Get( "sv_maxvelocity", "6000", 0 ); + sv_gravity = gi.Cvar_Get( "sv_gravity", "512", 0 ); + + sv_traceinfo = gi.Cvar_Get( "sv_traceinfo", "0", 0 ); + sv_drawtrace = gi.Cvar_Get( "sv_drawtrace", "0", 0 ); + sv_showbboxes = gi.Cvar_Get( "sv_showbboxes", "0", 0 ); + + sv_testloc_num = gi.Cvar_Get( "sv_testloc_num", "0", 0 ); + sv_testloc_secondary = gi.Cvar_Get( "sv_testloc_secondary", "0", 0 ); + sv_testloc_radius = gi.Cvar_Get( "sv_testloc_radius", "1", 0 ); + sv_testloc_offset_x = gi.Cvar_Get( "sv_testloc_offset_x", "0", 0 ); + sv_testloc_offset_y = gi.Cvar_Get( "sv_testloc_offset_y", "0", 0 ); + sv_testloc_offset_z = gi.Cvar_Get( "sv_testloc_offset_z", "0", 0 ); + sv_testloc_radius2 = gi.Cvar_Get( "sv_testloc_radius2", "1", 0 ); + sv_testloc_offset2_x = gi.Cvar_Get( "sv_testloc_offset2_x", "0", 0 ); + sv_testloc_offset2_y = gi.Cvar_Get( "sv_testloc_offset2_y", "0", 0 ); + sv_testloc_offset2_z = gi.Cvar_Get( "sv_testloc_offset2_z", "0", 0 ); + + sv_showcameras = gi.Cvar_Get( "sv_showcameras", "0", 0 ); + sv_showentnums = gi.Cvar_Get( "sv_showentnums", "0", 0 ); + + sv_friction = gi.Cvar_Get( "sv_friction", "4", CVAR_SERVERINFO ); + sv_stopspeed = gi.Cvar_Get( "sv_stopspeed", "100", CVAR_SERVERINFO ); + sv_waterfriction = gi.Cvar_Get( "sv_waterfriction", "1", CVAR_SERVERINFO ); + sv_waterspeed = gi.Cvar_Get( "sv_waterspeed", "400", CVAR_SERVERINFO ); + + sv_cheats = gi.Cvar_Get( "cheats", "0", CVAR_USERINFO|CVAR_SERVERINFO|CVAR_LATCH ); + sv_fps = gi.Cvar_Get( "sv_fps", "20", CVAR_SERVERINFO|CVAR_SAVEGAME ); + sv_cinematic = gi.Cvar_Get( "sv_cinematic", "0", CVAR_SYSTEMINFO|CVAR_ROM ); + + sv_maplist = gi.Cvar_Get( "sv_maplist", "", CVAR_ARCHIVE|CVAR_SERVERINFO ); + sv_nextmap = gi.Cvar_Get( "nextmap", "", 0 ); + + sv_runspeed = gi.Cvar_Get( "sv_runspeed", "250", CVAR_SERVERINFO ); + sv_walkspeed = gi.Cvar_Get( "sv_walkspeed", "150", CVAR_SERVERINFO ); + sv_dmspeedmult = gi.Cvar_Get( "sv_dmspeedmult", "1.1", CVAR_SERVERINFO ); + sv_crouchspeedmult = gi.Cvar_Get( "sv_crouchspeedmult", "0.6", CVAR_SERVERINFO ); + + g_showmem = gi.Cvar_Get( "g_showmem", "0", 0 ); + g_timeents = gi.Cvar_Get( "g_timeents", "0", 0 ); + g_showaxis = gi.Cvar_Get( "g_showaxis", "0", 0 ); + g_showplayerstate = gi.Cvar_Get( "g_showplayerstate", "0", 0 ); + g_showplayeranim = gi.Cvar_Get( "g_showplayeranim", "0", 0 ); + g_showbullettrace = gi.Cvar_Get( "g_showbullettrace", "0", 0 ); + g_showawareness = gi.Cvar_Get( "g_showawareness", "0", CVAR_CHEAT ); + g_entinfo = gi.Cvar_Get( "g_entinfo", "0", CVAR_CHEAT ); + g_showlookat = gi.Cvar_Get( "g_showlookat", "0", CVAR_CHEAT ); + + g_numdebuglines = gi.Cvar_Get( "g_numdebuglines", "4096", CVAR_LATCH ); + g_numdebuglinedelays = gi.Cvar_Get( "g_numdebuglinedelays", "0", 0 ); + g_numdebugstrings = gi.Cvar_Get( "g_numdebugstrings", "256", CVAR_LATCH ); + + g_spiffyplayer = gi.Cvar_Get( "g_spiffyplayer", "0", CVAR_LATCH ); + g_spiffyvelocity_x = gi.Cvar_Get( "g_spiffyvelocity_x", "0", 0 ); + g_spiffyvelocity_y = gi.Cvar_Get( "g_spiffyvelocity_y", "0", 0 ); + g_spiffyvelocity_z = gi.Cvar_Get( "g_spiffyvelocity_z", "0", 0 ); + + g_playermodel = gi.Cvar_Get( "g_playermodel", "american_army", CVAR_SAVEGAME ); + g_statefile = gi.Cvar_Get( "g_statefile", "global/mike", 0 ); + + g_showautoaim = gi.Cvar_Get( "g_showautoaim", "0", 0 ); + g_debugtargets = gi.Cvar_Get( "g_debugtargets", "0", 0 ); + g_debugdamage = gi.Cvar_Get( "g_debugdamage", "0", 0 ); + g_logstats = gi.Cvar_Get( "g_logstats", "0", 0 ); + g_showtokens = gi.Cvar_Get( "g_showtokens", "0", 0 ); + g_showopcodes = gi.Cvar_Get( "g_showopcodes", "0", 0 ); + g_scriptcheck = gi.Cvar_Get( "g_scriptcheck", "0", 0 ); + g_nodecheck = gi.Cvar_Get( "g_nodecheck", "0", 0 ); + g_scriptdebug = gi.Cvar_Get( "g_scriptdebug", "0", 0 ); + g_scripttrace = gi.Cvar_Get( "g_scripttrace", "0", 0 ); + + g_ai = gi.Cvar_Get( "g_ai", "1", 0 ); + g_vehicle = gi.Cvar_Get( "g_vehicle", "1", 0 ); + + g_monitor = gi.Cvar_Get( "g_monitor", "", 0 ); + g_monitorNum = gi.Cvar_Get( "g_monitorNum", "-1", 0 ); + + g_spawnentities = gi.Cvar_Get( "g_spawnentities", "1", 0 ); + g_spawnai = gi.Cvar_Get( "g_spawnai", "1", 0 ); + + g_patherror = gi.Cvar_Get( "g_patherror", "1", 0 ); + + g_droppeditemlife = gi.Cvar_Get( "g_droppeditemlife", "30", 0 ); + g_dropclips = gi.Cvar_Get( "g_dropclips", "2", 0 ); + + g_animdump = gi.Cvar_Get( "g_animdump", "0", 0 ); + + g_showdamage = gi.Cvar_Get( "g_showdamage", "0", 0 ); + + g_ai_notifyradius = gi.Cvar_Get( "g_ai_notifyradius", "1024", 0 ); + g_ai_noticescale = gi.Cvar_Get( "g_ai_noticescale", "1", 0 ); + g_ai_soundscale = gi.Cvar_Get( "g_ai_soundscale", "1", 0 ); + ai_debug_grenades = gi.Cvar_Get( "ai_debug_grenades", "0", CVAR_CHEAT ); + + g_gametype = gi.Cvar_Get( "g_gametype", "0", CVAR_USERINFO|CVAR_SERVERINFO|CVAR_LATCH ); + g_gametypestring = gi.Cvar_Get( "g_gametypestring", "Free-For-All", CVAR_SERVERINFO ); + g_rankedserver = gi.Cvar_Get( "g_rankedserver", "0", 0 ); + g_teamdamage = gi.Cvar_Get( "g_teamdamage", "0", 0 ); + g_allowvote = gi.Cvar_Get( "g_allowvote", "1", 0 ); + g_warmup = gi.Cvar_Get( "g_warmup", "20", CVAR_ARCHIVE ); + g_doWarmup = gi.Cvar_Get( "g_doWarmup", "1", 0 ); + + g_forceready = gi.Cvar_Get( "g_forceready", "1", CVAR_ARCHIVE|CVAR_SERVERINFO ); + g_forcerespawn = gi.Cvar_Get( "g_forcerespawn", "0", CVAR_ARCHIVE|CVAR_SERVERINFO ); + g_maxintermission = gi.Cvar_Get( "g_maxintermission", "15", CVAR_ARCHIVE|CVAR_SERVERINFO ); + + g_smoothClients = gi.Cvar_Get( "g_smoothClients", "1", 0 ); + pmove_fixed = gi.Cvar_Get( "pmove_fixed", "0", CVAR_SYSTEMINFO ); + pmove_msec = gi.Cvar_Get( "pmove_msec", "0", CVAR_SYSTEMINFO ); + + g_inactivespectate = gi.Cvar_Get( "g_inactiveSpectate", "60", CVAR_ARCHIVE ); + g_inactivekick = gi.Cvar_Get( "g_inactivekick", "900", CVAR_ARCHIVE ); + + s_debugmusic = gi.Cvar_Get( "s_debugmusic", "0", 0 ); + + sv_scriptfiles = gi.Cvar_Get( "sv_scriptfiles", "0", 0 ); + + switch( g_gametype->integer ) + { + default: + case GT_FFA: + if( g_gametype->integer >= GT_MAX_GAME_TYPE ) + { + gi.Cvar_Set( "g_gametypestring", "Multiplayer" ); + } + else + { + gi.Cvar_Set( "g_gametypestring", "Free-For-All" ); + } + break; + + case GT_TEAM: + gi.Cvar_Set( "g_gametypestring", "Team-Match" ); + break; + + case GT_TEAM_ROUNDS: + gi.Cvar_Set( "g_gametypestring", "Round-Based-Match" ); + break; + + case GT_OBJECTIVE: + gi.Cvar_Set( "g_gametypestring", "Objective-Match" ); + break; + + case GT_SINGLE_PLAYER: + gi.Cvar_Set( "g_gametypestring", "0" ); + break; + } + + g_viewkick_pitch = gi.Cvar_Get( "g_viewkick_pitch", "0.3", CVAR_CHEAT ); + g_viewkick_yaw = gi.Cvar_Get( "g_viewkick_yaw", "0.3", CVAR_CHEAT ); + g_viewkick_roll = gi.Cvar_Get( "g_viewkick_roll", "0.15", CVAR_CHEAT ); + g_viewkick_dmmult = gi.Cvar_Get( "g_viewkick_dmmult", "1.0", CVAR_CHEAT ); + + g_drawattackertime = gi.Cvar_Get( "g_drawattackertime", "5", 0 ); + g_playerdeltamethod = gi.Cvar_Get( "g_playerdeltamethod", "0", 0 ); + + g_success = gi.Cvar_Get( "g_success", "0", 0 ); + g_failed = gi.Cvar_Get( "g_failed", "0", 0 ); + g_gotmedal = gi.Cvar_Get( "g_gotmedal", "0", 0 ); + + g_medal0 = gi.Cvar_Get( "g_medal0", "0", CVAR_ARCHIVE ); + g_medal1 = gi.Cvar_Get( "g_medal1", "0", CVAR_ARCHIVE ); + g_medal2 = gi.Cvar_Get( "g_medal2", "0", CVAR_ARCHIVE ); + g_medal3 = gi.Cvar_Get( "g_medal3", "0", CVAR_ARCHIVE ); + g_medal4 = gi.Cvar_Get( "g_medal4", "0", CVAR_ARCHIVE ); + g_medal5 = gi.Cvar_Get( "g_medal5", "0", CVAR_ARCHIVE ); + + g_eogmedal0 = gi.Cvar_Get( "g_eogmedal0", "0", CVAR_ARCHIVE ); + g_eogmedal1 = gi.Cvar_Get( "g_eogmedal1", "0", CVAR_ARCHIVE ); + g_eogmedal2 = gi.Cvar_Get( "g_eogmedal2", "0", CVAR_ARCHIVE ); + + g_m1l1 = gi.Cvar_Get( "g_m1l1", "1", CVAR_ARCHIVE ); + g_m1l2 = gi.Cvar_Get( "g_m1l2", "0", CVAR_ARCHIVE ); + g_m1l3 = gi.Cvar_Get( "g_m1l3", "0", CVAR_ARCHIVE ); + g_m2l1 = gi.Cvar_Get( "g_m2l1", "0", CVAR_ARCHIVE ); + g_m2l2 = gi.Cvar_Get( "g_m2l2", "0", CVAR_ARCHIVE ); + g_m2l3 = gi.Cvar_Get( "g_m2l3", "0", CVAR_ARCHIVE ); + g_m3l1 = gi.Cvar_Get( "g_m3l1", "0", CVAR_ARCHIVE ); + g_m3l2 = gi.Cvar_Get( "g_m3l2", "0", CVAR_ARCHIVE ); + g_m3l3 = gi.Cvar_Get( "g_m3l3", "0", CVAR_ARCHIVE ); + g_m4l1 = gi.Cvar_Get( "g_m4l1", "0", CVAR_ARCHIVE ); + g_m4l2 = gi.Cvar_Get( "g_m4l2", "0", CVAR_ARCHIVE ); + g_m4l3 = gi.Cvar_Get( "g_m4l3", "0", CVAR_ARCHIVE ); + g_m5l1 = gi.Cvar_Get( "g_m5l1", "0", CVAR_ARCHIVE ); + g_m5l2 = gi.Cvar_Get( "g_m5l2", "0", CVAR_ARCHIVE ); + g_m5l3 = gi.Cvar_Get( "g_m5l3", "0", CVAR_ARCHIVE ); + g_m6l1 = gi.Cvar_Get( "g_m6l1", "0", CVAR_ARCHIVE ); + g_m6l2 = gi.Cvar_Get( "g_m6l2", "0", CVAR_ARCHIVE ); + g_m6l3 = gi.Cvar_Get( "g_m6l3", "0", CVAR_ARCHIVE ); + + g_lastsave = gi.Cvar_Get( "g_lastsave", "", CVAR_ARCHIVE ); + g_forceteamspectate = gi.Cvar_Get( "g_forceteamspectate", "1", 0 ); + g_spectatefollow_forward = gi.Cvar_Get( "g_spectatefollow_forward", "-56", 0 ); + g_spectatefollow_right = gi.Cvar_Get( "g_spectatefollow_right", "0", 0 ); + g_spectatefollow_up = gi.Cvar_Get( "g_spectatefollow_up", "24", 0 ); + g_spectatefollow_pitch = gi.Cvar_Get( "g_spectatefollow_pitch", "2", 0 ); + g_spectatefollow_firstperson = gi.Cvar_Get( "g_spectatefollow_firstperson", "0", 0 ); + g_spectate_allow_full_chat = gi.Cvar_Get( "g_spectate_allow_full_chat", "0", 0 ); + + g_voiceChat = gi.Cvar_Get( "g_voiceChat", "1", 0 ); + + gi.Cvar_Get( "g_obj_alliedtext1", "", CVAR_SERVERINFO ); + gi.Cvar_Get( "g_obj_alliedtext2", "", CVAR_SERVERINFO ); + gi.Cvar_Get( "g_obj_alliedtext3", "", CVAR_SERVERINFO ); + gi.Cvar_Get( "g_obj_axistext1", "", CVAR_SERVERINFO ); + gi.Cvar_Get( "g_obj_axistext2", "", CVAR_SERVERINFO ); + gi.Cvar_Get( "g_obj_axistext3", "", CVAR_SERVERINFO ); + gi.Cvar_Get( "g_scoreboardpic", "", CVAR_SERVERINFO ); + gi.Cvar_Get( "g_scoreboardpicover", "", CVAR_SERVERINFO ); + + if( g_gametype->integer > GT_TEAM ) + { + gi.Cvar_Set( "g_tempaxisscore", "0" ); + gi.Cvar_Set( "g_tempaxiswinsinrow", "0" ); + gi.Cvar_Set( "g_tempalliesscore", "0" ); + gi.Cvar_Set( "g_tempallieswinsinrow", "0" ); + gi.Cvar_Set( "g_tempmaptime", "0" ); + gi.Cvar_Set( "g_scoreboardpicover", "" ); + } +} diff --git a/code/game/gamecvars.h b/code/game/gamecvars.h new file mode 100644 index 00000000..882188fd --- /dev/null +++ b/code/game/gamecvars.h @@ -0,0 +1,233 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// gamecvars.h: Game variables + +#ifndef __GAMECVARS_H__ +#define __GAMECVARS_H__ + +#include "g_local.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern cvar_t *developer; +extern cvar_t *sv_reborn; + +extern cvar_t *deathmatch; +extern cvar_t *dmflags; +extern cvar_t *skill; +extern cvar_t *fraglimit; +extern cvar_t *timelimit; +extern cvar_t *roundlimit; +extern cvar_t *g_allowjointime; +extern cvar_t *g_teamswitchdelay; + +extern cvar_t *password; +extern cvar_t *sv_privatePassword; +extern cvar_t *filterban; + +extern cvar_t *flood_msgs; +extern cvar_t *flood_persecond; +extern cvar_t *flood_waitdelay; + +extern cvar_t *maxclients; +extern cvar_t *maxbots; +extern cvar_t *maxentities; +extern cvar_t *nomonsters; +extern cvar_t *precache; +extern cvar_t *dedicated; +extern cvar_t *detail; +extern cvar_t *com_blood; +extern cvar_t *whereami; +extern cvar_t *bosshealth; + +extern cvar_t *sv_maxvelocity; +extern cvar_t *sv_gravity; +extern cvar_t *sv_rollspeed; +extern cvar_t *sv_rollangle; +extern cvar_t *sv_cheats; +extern cvar_t *sv_showbboxes; + +extern cvar_t *sv_testloc_num; +extern cvar_t *sv_testloc_secondary; +extern cvar_t *sv_testloc_radius; +extern cvar_t *sv_testloc_offset_x; +extern cvar_t *sv_testloc_offset_y; +extern cvar_t *sv_testloc_offset_z; +extern cvar_t *sv_testloc_radius2; +extern cvar_t *sv_testloc_offset2_x; +extern cvar_t *sv_testloc_offset2_y; +extern cvar_t *sv_testloc_offset2_z; + +extern cvar_t *sv_showcameras; +extern cvar_t *sv_showentnums; +extern cvar_t *sv_stopspeed; +extern cvar_t *sv_friction; +extern cvar_t *sv_waterfriction; +extern cvar_t *sv_waterspeed; +extern cvar_t *sv_traceinfo; +extern cvar_t *sv_drawtrace; +extern cvar_t *sv_fps; +extern cvar_t *sv_cinematic; +extern cvar_t *sv_maplist; +extern cvar_t *sv_nextmap; +extern cvar_t *sv_runspeed; +extern cvar_t *sv_walkspeed; +extern cvar_t *sv_dmspeedmult; +extern cvar_t *sv_crouchspeedmult; + +extern cvar_t *g_showmem; +extern cvar_t *g_timeents; + +extern cvar_t *g_showaxis; +extern cvar_t *g_showplayerstate; +extern cvar_t *g_showplayeranim; +extern cvar_t *g_showawareness; +extern cvar_t *g_entinfo; +extern cvar_t *g_showlookat; + +extern cvar_t *g_numdebuglines; +extern cvar_t *g_numdebuglinedelays; +extern cvar_t *g_numdebugstrings; + +extern cvar_t *g_spiffyplayer; +extern cvar_t *g_spiffyvelocity_x; +extern cvar_t *g_spiffyvelocity_y; +extern cvar_t *g_spiffyvelocity_z; + +extern cvar_t *g_playermodel; +extern cvar_t *g_statefile; +extern cvar_t *g_showbullettrace; +extern cvar_t *s_debugmusic; +extern cvar_t *g_showautoaim; +extern cvar_t *g_debugtargets; +extern cvar_t *g_debugdamage; +extern cvar_t *g_logstats; + +extern cvar_t *g_showtokens; +extern cvar_t *g_showopcodes; +extern cvar_t *g_scriptcheck; +extern cvar_t *g_nodecheck; +extern cvar_t *g_scriptdebug; +extern cvar_t *g_scripttrace; + +extern cvar_t *g_ai; +extern cvar_t *g_vehicle; + +extern cvar_t *g_gametype; +extern cvar_t *g_gametypestring; +extern cvar_t *g_rankedserver; +extern cvar_t *g_teamdamage; + +extern cvar_t *g_allowvote; +extern cvar_t *g_monitor; +extern cvar_t *g_monitorNum; + +extern cvar_t *g_spawnentities; +extern cvar_t *g_spawnai; + +extern cvar_t *g_patherror; +extern cvar_t *g_droppeditemlife; +extern cvar_t *g_dropclips; +extern cvar_t *g_animdump; +extern cvar_t *g_showdamage; +extern cvar_t *g_ai_notifyradius; +extern cvar_t *g_ai_noticescale; +extern cvar_t *g_ai_soundscale; +extern cvar_t *ai_debug_grenades; + +extern cvar_t *g_warmup; +extern cvar_t *g_doWarmup; +extern cvar_t *g_forceready; +extern cvar_t *g_forcerespawn; +extern cvar_t *g_maxintermission; + +extern cvar_t *g_smoothClients; + +extern cvar_t *pmove_fixed; +extern cvar_t *pmove_msec; + +extern cvar_t *g_inactivespectate; +extern cvar_t *g_inactivekick; + +extern cvar_t *g_viewkick_pitch; +extern cvar_t *g_viewkick_yaw; +extern cvar_t *g_viewkick_roll; +extern cvar_t *g_viewkick_dmmult; + +extern cvar_t *g_drawattackertime; +extern cvar_t *g_playerdeltamethod; + +extern cvar_t *g_success; +extern cvar_t *g_failed; + +extern cvar_t *g_gotmedal; +extern cvar_t *g_medal0; +extern cvar_t *g_medal1; +extern cvar_t *g_medal2; +extern cvar_t *g_medal3; +extern cvar_t *g_medal4; +extern cvar_t *g_medal5; +extern cvar_t *g_eogmedal0; +extern cvar_t *g_eogmedal1; +extern cvar_t *g_eogmedal2; +extern cvar_t *g_m1l1; +extern cvar_t *g_m1l2; +extern cvar_t *g_m1l3; +extern cvar_t *g_m2l1; +extern cvar_t *g_m2l2; +extern cvar_t *g_m2l3; +extern cvar_t *g_m3l1; +extern cvar_t *g_m3l2; +extern cvar_t *g_m3l3; +extern cvar_t *g_m4l1; +extern cvar_t *g_m4l2; +extern cvar_t *g_m4l3; +extern cvar_t *g_m5l1; +extern cvar_t *g_m5l2; +extern cvar_t *g_m5l3; +extern cvar_t *g_m6l1; +extern cvar_t *g_m6l2; +extern cvar_t *g_m6l3; +extern cvar_t *g_lastsave; + +extern cvar_t *g_forceteamspectate; +extern cvar_t *g_spectatefollow_forward; +extern cvar_t *g_spectatefollow_right; +extern cvar_t *g_spectatefollow_up; +extern cvar_t *g_spectatefollow_pitch; +extern cvar_t *g_spectatefollow_firstperson; +extern cvar_t *g_spectate_allow_full_chat; + +extern cvar_t *g_voiceChat; + +extern cvar_t *sv_scriptfiles; + +void CVAR_Init( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* !__GAMECVARS_H__ */ diff --git a/code/game/gibs.cpp b/code/game/gibs.cpp new file mode 100644 index 00000000..d4bf8681 --- /dev/null +++ b/code/game/gibs.cpp @@ -0,0 +1,315 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// gibs.cpp: Gibs - nuff said + +#include "gibs.h" +#include "decals.h" + +Event EV_ThrowGib + ( + "throwgib", + EV_DEFAULT, + "eif", + "ent velocity scale", + "Throw a gib.", + EV_NORMAL + ); + +CLASS_DECLARATION( Mover, Gib, "gib" ) + { + { &EV_ThrowGib, &Gib::Throw }, + { &EV_Touch, &Gib::Splat }, + { &EV_Stop, &Gib::Stop }, + { &EV_Damage, &Gib::Damage }, + { NULL, NULL } + }; + +Gib::Gib + ( + str name, + qboolean blood_trail, + str bloodtrailname, + str bloodspurtname, + str bloodsplatname, + float bloodsplatsize, + float pitch + ) + + { + setSize( Vector( "0 0 0" ), Vector( "0 0 0" ) ); + + if ( name.length() ) + setModel( name.c_str() ); + + setMoveType( MOVETYPE_GIB ); + setSolidType( SOLID_BBOX ); + takedamage = DAMAGE_YES; + sprayed = false; + fadesplat = true; + scale = 2.0f; + + next_bleed_time = 0; + + final_pitch = pitch; + + if ( blood_trail ) + { + // Make a blood emitter and bind it to the head + blood = new Mover; + + if ( bloodtrailname.length() ) + blood->setModel( bloodtrailname.c_str() ); + + blood->setMoveType( MOVETYPE_BOUNCE ); + blood->setSolidType( SOLID_NOT ); + blood->bind( this ); + + // Save the blood spurt name + + if ( bloodspurtname.length() ) + blood_spurt_name = bloodspurtname; + + // Save the blood splat name + + if ( bloodsplatname.length() ) + blood_splat_name = bloodsplatname; + + blood_splat_size = bloodsplatsize; + } + else + { + blood = NULL; + } + + Sound( "snd_decap", CHAN_BODY, 1, 300 ); + } + +Gib::~Gib() + { + if ( blood ) + blood->PostEvent( EV_Remove, 0 ); + blood = NULL; + } + +Gib::Gib() + { + if ( LoadingSavegame ) + { + return; + } + + setSize( Vector( "0 0 0" ), Vector( "0 0 0" ) ); + setModel("gib1.def"); + setMoveType( MOVETYPE_GIB ); + setSolidType( SOLID_BBOX ); + sprayed = 0; + fadesplat = true; + scale = 2.0f; + } + +void Gib::Stop + ( + Event *ev + ) + + { + //setSolidType( SOLID_NOT ); + if ( blood ) + blood->PostEvent( EV_Remove, 0 ); + blood = NULL; + } + +void Gib::Splat + ( + Event *ev + ) + + { + if ( g_gametype->integer ) + return; + + if ( sprayed > 3 ) + { + //setSolidType(SOLID_NOT); + return; + } + + sprayed++; + scale -= 0.2f; + + // Stop spinning / force to final pitch + + avelocity = vec_zero; + + if ( final_pitch != NO_FINAL_PITCH ) + { + angles[PITCH] = final_pitch; + setAngles( angles ); + } + + SprayBlood( origin ); + Sound( "snd_gibhit" ); + } + +void Gib::Damage + ( + Event *ev + ) + + { + Vector direction; + Entity *blood; + Vector dir; + + if ( next_bleed_time > level.time ) + return; + + direction = ev->GetVector ( 5 ); + + // Spawn a blood spurt + + if ( blood_spurt_name.length() > 0 ) + { + blood = new Animate; + blood->setModel( blood_spurt_name.c_str() ); + + dir[0] = -direction[0]; + dir[1] = -direction[1]; + dir[2] = -direction[2]; + + blood->angles = dir.toAngles(); + blood->setAngles( blood->angles ); + + blood->setOrigin( centroid ); + blood->origin.copyTo( blood->edict->s.origin2 ); + blood->setSolidType( SOLID_NOT ); + + blood->PostEvent( EV_Remove, 1 ); + + next_bleed_time = level.time + 0.5; + } + } + +void Gib::SprayBlood + ( + Vector start + ) + + { + Vector norm; + trace_t trace; + Vector trace_end; + + trace_end = velocity; + trace_end.normalize(); + trace_end *= 1000; + trace_end += start; + + trace = G_Trace( start, vec_zero, vec_zero, trace_end, this, MASK_SOLID, false, "Gib::SprayBlood" ); + + if ( HitSky( &level.impact_trace ) || ( !level.impact_trace.ent ) || ( level.impact_trace.ent->solid != SOLID_BSP ) ) + { + return; + } + + // Do a bloodsplat + if ( blood_splat_name.length() ) + { + Decal *decal = new Decal; + decal->setShader( blood_splat_name ); + decal->setOrigin( Vector( trace.endpos ) + ( Vector( level.impact_trace.plane.normal ) * 0.2f ) ); + decal->setDirection( level.impact_trace.plane.normal ); + decal->setOrientation( "random" ); + decal->setRadius( blood_splat_size + G_Random( blood_splat_size ) ); + } + } + +void Gib::ClipGibVelocity + ( + void + ) + + { + if (velocity[0] < -400) + velocity[0] = -400; + else if (velocity[0] > 400) + velocity[0] = 400; + if (velocity[1] < -400) + velocity[1] = -400; + else if (velocity[1] > 400) + velocity[1] = 400; + if (velocity[2] < 200) + velocity[2] = 200; // always some upwards + else if (velocity[2] > 600) + velocity[2] = 600; +} + +void Gib::SetVelocity + ( + float damage + ) + + { + velocity[0] = 100.0 * crandom(); + velocity[1] = 100.0 * crandom(); + velocity[2] = 200.0 + 100.0 * random(); + + avelocity = Vector( G_Random( 600 ), G_Random( 600 ), G_Random( 600 ) ); + + if ( ( damage < -150 ) && ( G_Random() > 0.95f ) ) + velocity *= 2.0f; + else if ( damage < -100 ) + velocity *= 1.5f; + + ClipGibVelocity(); + } + +void Gib::Throw + ( + Event *ev + ) + + { + Entity *ent; + + ent = ev->GetEntity(1); + setOrigin(ent->centroid); + origin.copyTo(edict->s.origin2); + SetVelocity(ev->GetInteger(2)); + edict->s.scale = ev->GetFloat(3); + PostEvent(EV_FadeOut, 10 + G_Random(5)); + } + + +void CreateGibs + ( + Entity * ent, + float damage, + float scale, + int num, + const char * modelname + ) + + { + + } diff --git a/code/game/gibs.h b/code/game/gibs.h new file mode 100644 index 00000000..aee8a20f --- /dev/null +++ b/code/game/gibs.h @@ -0,0 +1,92 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// gibs.h: Gibs - nuff said + +#ifndef __GIBS_H__ +#define __GIBS_H__ + +#include "g_local.h" +#include "mover.h" + +#define NO_FINAL_PITCH -1000 + +class Gib : public Mover + { + private: + int sprayed; + float scale; + Mover *blood; + str blood_splat_name; + float blood_splat_size; + str blood_spurt_name; + float final_pitch; + float next_bleed_time; + public: + CLASS_PROTOTYPE( Gib ); + + qboolean fadesplat; + Gib(); + ~Gib(); + Gib( str name, qboolean blood_trail, str bloodtrailname="", str bloodspurtname="", str bloodsplatname="", + float blood_splat_size = 8, float pitch=NO_FINAL_PITCH ); + void SetVelocity( float health ); + void SprayBlood( Vector start ); + void Throw( Event *ev ); + void Splat( Event *ev ); + void Stop( Event *ev ); + void Damage( Event *ev ); + void ClipGibVelocity( void ); + virtual void Archive( Archiver &arc ); + }; + +inline void Gib::Archive + ( + Archiver &arc + ) + { + Entity::Archive( arc ); + + arc.ArchiveBoolean( &sprayed ); + arc.ArchiveFloat( &scale ); + arc.ArchiveObjectPointer( ( Class ** )&blood ); + arc.ArchiveString( &blood_splat_name ); + arc.ArchiveFloat( &blood_splat_size ); + arc.ArchiveString( &blood_spurt_name ); + arc.ArchiveFloat( &final_pitch ); + arc.ArchiveBoolean( &fadesplat ); + arc.ArchiveFloat( &next_bleed_time ); + } + + +void CreateGibs + ( + Entity * ent, + float damage = -50, + float scale = 1.0f, + int num = 1, + const char * modelname = NULL + ); + +extern Event EV_ThrowGib; + +#endif // gibs.h diff --git a/code/game/gravpath.cpp b/code/game/gravpath.cpp new file mode 100644 index 00000000..b70e11c6 --- /dev/null +++ b/code/game/gravpath.cpp @@ -0,0 +1,797 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// gravpath.cpp: Gravity path - Used for underwater currents and wells. + +#include "g_local.h" +#include "entity.h" +#include "gravpath.h" +#include "container.h" +#include "navigate.h" +#include "misc.h" +#include "player.h" + +GravPathManager gravPathManager; + +CLASS_DECLARATION( Class, GravPathManager, NULL ) + { + { NULL,NULL } + }; + +GravPathManager::~GravPathManager() + { + Reset(); + } + +void GravPathManager::Reset( void ) + { + while( pathList.NumObjects() > 0 ) + { + delete ( GravPath * )pathList.ObjectAt( 1 ); + } + + pathList.FreeObjectList(); + } + +void GravPathManager::AddPath(GravPath *p) + { + pathList.AddObject( p ); + } + +void GravPathManager::RemovePath(GravPath *p) + { + pathList.RemoveObject( p ); + } + +void GravPathManager::DrawGravPaths + ( + void + ) + + { + int i; + int num = pathList.NumObjects(); + + for( i = 1; i <= num; i++ ) + { + GravPath *p = ( GravPath * )pathList.ObjectAt( i ); + + p->DrawPath( 1,0,0 ); + } + } + +Vector GravPathManager::CalculateGravityPull(Entity &ent, Vector pos, qboolean *force, float *max_speed) + { + int i,num; + GravPath *p; + GravPathNode *node; + Vector point; + Vector newpoint; + Vector dir; + float bestdist = 99999; + float dist; + float speed; + float radius; + Vector velocity; + int bestpath = 0; + int entity_contents, grav_contents; + + num = pathList.NumObjects(); + if ( !num ) + { + return vec_zero; + } + + entity_contents = gi.PointContents( ent.origin, 0 ); + + for( i = 1; i <= num; i++ ) + { + p = ( GravPath * )pathList.ObjectAt( i ); + + if ( !p ) + continue; + + // Check to see if path is active + node = p->GetNode( 1 ); + if ( !node || !node->active ) + continue; + + // Check to see if the contents are the same + grav_contents = gi.PointContents( node->origin, 0 ); + + // If grav node is in water, make sure ent is too. + if ( ( grav_contents & CONTENTS_WATER ) && !( entity_contents & CONTENTS_WATER ) ) + continue; + + // Test to see if we are in this path's bounding box + if ( (pos.x < p->maxs.x) && (pos.y < p->maxs.y) && (pos.z < p->maxs.z) && + (pos.x > p->mins.x) && (pos.y > p->mins.y) && (pos.z > p->mins.z) ) + { + point = p->ClosestPointOnPath(pos, ent, &dist, &speed, &radius); + + // If the closest distance on the path is greater than the radius, then + // do not consider this path. + + if (dist > radius) + { + continue; + } + else if (dist < bestdist) + { + bestpath = i; + bestdist = dist; + } + } + } + + if (!bestpath) + { + return vec_zero; + } + + p = ( GravPath * )pathList.ObjectAt( bestpath ); + if ( !p ) + return velocity; + *force = p->force; + dist = p->DistanceAlongPath(pos, &speed); + newpoint = p->PointAtDistance( pos, dist + speed, ent.isSubclassOf( Player ), max_speed ); + dir = newpoint-pos; + dir.normalize(); + velocity = dir * speed; + + //velocity *= .75; + return velocity; + } + +/*****************************************************************************/ +/*QUAKED info_grav_pathnode (0 0 .5) (-16 -16 0) (16 16 32) HEADNODE FORCE PULL_UPWARDS + "radius" Radius of the effect of the pull (Default is 256) + "speed" Speed of the pull (Use negative for a repulsion) (Default is 100) + + Set HEADNODE to signify the head of the path. + Set FORCE if you want un-fightable gravity ( i.e. can't go backwards ) + Set PULL_UPWARDS if you want the gravnodes to pull you upwards also +******************************************************************************/ + +#define PULL_UPWARDS ( 1 << 2 ) + +Event EV_GravPath_Create + ( + "gravpath_create", + EV_DEFAULT, + NULL, + NULL, + "Create the grav path.", + EV_NORMAL + ); +Event EV_GravPath_Activate + ( + "activate", + EV_DEFAULT, + NULL, + NULL, + "Activate the grav path.", + EV_NORMAL + ); +Event EV_GravPath_Deactivate + ( + "deactivate", + EV_DEFAULT, + NULL, + NULL, + "Deactivate the grav path.", + EV_NORMAL + ); +Event EV_GravPath_SetSpeed + ( + "speed", + EV_DEFAULT, + "f", + "speed", + "Set the speed of the grav path.", + EV_NORMAL + ); +Event EV_GravPath_SetMaxSpeed + ( + "maxspeed", + EV_DEFAULT, + "f", + "maxspeed", + "Set the max speed of the grav path.", + EV_NORMAL + ); +Event EV_GravPath_SetRadius + ( + "radius", + EV_DEFAULT, + "f", + "radius", + "Set the radius of the grav path.", + EV_NORMAL + ); + +CLASS_DECLARATION( Entity, GravPathNode, "info_grav_pathnode" ) + { + { &EV_GravPath_Create, &GravPathNode::CreatePath }, + { &EV_GravPath_Activate, &GravPathNode::Activate }, + { &EV_GravPath_Deactivate, &GravPathNode::Deactivate }, + { &EV_GravPath_SetSpeed, &GravPathNode::SetSpeed }, + { &EV_GravPath_SetMaxSpeed, &GravPathNode::SetMaxSpeed }, + { &EV_GravPath_SetRadius, &GravPathNode::SetRadius }, + { NULL, NULL } + }; + +GravPathNode::GravPathNode() + { + if ( LoadingSavegame ) + { + // all data will be setup by the archive function + return; + } + + setMoveType( MOVETYPE_NONE ); + setSolidType( SOLID_NOT ); + hideModel(); + + speed = 100.0f; + max_speed = 200.0f; + radius = 256.0f; + headnode = spawnflags & 1; + active = true; + + // This is the head of a new path, post an event to create the path + if ( headnode ) + { + PostEvent( EV_GravPath_Create, 0 ); + } + } + +void GravPathNode::SetSpeed + ( + Event *ev + ) + + { + speed = ev->GetFloat( 1 ); + } + +void GravPathNode::SetMaxSpeed + ( + Event *ev + ) + + { + max_speed = ev->GetFloat( 1 ); + } + +void GravPathNode::SetRadius + ( + Event *ev + ) + + { + radius = ev->GetFloat( 1 ); + } + +float GravPathNode::Speed + ( + void + ) + + { + if ( active ) + return speed; + else + return 0; + } + +float GravPathNode::MaxSpeed + ( + void + ) + + { + return max_speed; + } + +void GravPathNode::Activate + ( + Event *ev + ) + + { + GravPathNode *node; + Entity *ent; + const char *target; + + active = true; + node = this; + // Go through the entire path and activate it + target = node->Target(); + while (target[0]) + { + ent = ( Entity * )G_FindTarget( NULL, target ); + if ( ent ) + { + node = (GravPathNode *)ent; + assert( node ); + node->active = true; + } + else + { + gi.Error( ERR_DROP, "GravPathNode::CreatePath: target %s not found\n",target); + } + target = node->Target(); + } + } + +void GravPathNode::Deactivate(Event *ev) + { + GravPathNode *node; + Entity *ent; + const char *target; + + active = false; + node = this; + // Go through the entire path and activate it + target = node->Target(); + while (target[0]) + { + ent = ( Entity * )G_FindTarget( NULL, target); + if ( ent ) + { + node = (GravPathNode *)ent; + assert( node ); + node->active = false; + } + else + { + gi.Error( ERR_DROP, "GravPathNode::CreatePath: target %s not found\n",target); + } + target = node->Target(); + } + } + +void GravPathNode::CreatePath(Event *ev) + { + const char *target; + GravPath *path = new GravPath; + GravPathNode *node; + Entity *ent; + + ClearBounds( path->mins, path->maxs ); + + // This node is the head of a path, create a new path in the path manager. + // and add it in, then add all of it's children in the path. + node = this; + path->AddNode(node); + path->force = spawnflags & 2; + + // Make the path from the targetlist. + target = node->Target(); + while (target[0]) + { + ent = ( Entity * )G_FindTarget( NULL, target ); + if ( ent ) + { + node = (GravPathNode *)ent; + assert( node ); + path->AddNode(node); + } + else + { + gi.Error( ERR_DROP, "GravPathNode::CreatePath: target %s not found\n",target); + } + target = node->Target(); + } + + // Set the origin. + path->origin = path->mins + path->maxs; + path->origin *= 0.5f; + } + +CLASS_DECLARATION( Listener, GravPath, NULL ) + { + { NULL, NULL } + }; + +GravPath::GravPath() + { + pathlength = 0; + from = NULL; + to = NULL; + nextnode = 1; + + if ( !LoadingSavegame ) + { + gravPathManager.AddPath(this); + } + } + +GravPath::~GravPath() + { + pathlength = 0; + from = NULL; + to = NULL; + nextnode = 1; + gravPathManager.RemovePath(this); + } + +void GravPath::Clear + ( + void + ) + + { + nextnode = 1; + pathlength = 0; + from = NULL; + to = NULL; + pathlist.FreeObjectList(); + } + +void GravPath::Reset + ( + void + ) + + { + nextnode = 1; + } + +GravPathNode *GravPath::Start + ( + void + ) + + { + return from; + } + +GravPathNode *GravPath::End + ( + void + ) + + { + return to; + } + +void GravPath::AddNode + ( + GravPathNode *node + ) + + { + int num; + Vector r,addp; + + if ( !from ) + { + from = node; + } + + to = node; + pathlist.AddObject( GravPathNodePtr( node ) ); + + num = NumNodes(); + if ( num > 1 ) + { + pathlength += ( node->origin - GetNode( num )->origin ).length(); + } + + r.setXYZ(node->Radius(),node->Radius(),node->Radius()); + addp = node->origin + r; + AddPointToBounds(addp,mins,maxs); + addp = node->origin - r; + AddPointToBounds(addp,mins,maxs); + } + +GravPathNode *GravPath::GetNode + ( + int num + ) + + { + return pathlist.ObjectAt( num ); + } + +GravPathNode *GravPath::NextNode + ( + void + ) + + { + if ( nextnode <= NumNodes() ) + { + return pathlist.ObjectAt( nextnode++ ); + } + return NULL; + } + +Vector GravPath::ClosestPointOnPath + ( + Vector pos, + Entity &ent, + float *ret_dist, + float *speed, + float *radius + ) + + { + GravPathNode *s; + GravPathNode *e; + int num; + int i; + float bestdist; + Vector bestpoint; + float dist; + float segmentlength; + Vector delta; + Vector p1; + Vector p2; + Vector p3; + float t; + trace_t trace; + + num = NumNodes(); + s = GetNode( 1 ); + trace = G_Trace( pos, ent.mins, ent.maxs, s->origin, &ent, MASK_PLAYERSOLID, false, "GravPath::ClosestPointOnPath 1" ); + bestpoint = s->origin; + delta = bestpoint - pos; + bestdist = delta.length(); + *speed = s->Speed(); + *radius = s->Radius(); + + for( i = 2; i <= num; i++ ) + { + e = GetNode( i ); + + // check if we're closest to the endpoint + delta = e->origin - pos; + dist = delta.length(); + + if ( dist < bestdist ) + { + trace = G_Trace( pos, ent.mins, ent.maxs, e->origin, &ent, MASK_PLAYERSOLID, false, "GravPath::ClosestPointOnPath 2" ); + bestdist = dist; + bestpoint = e->origin; + *speed = e->Speed(); + *radius = e->Radius(); + } + + // check if we're closest to the segment + p1 = e->origin - s->origin; + segmentlength = p1.length(); + p1 *= 1 / segmentlength; + p2 = pos - s->origin; + + t = p1 * p2; + if ( ( t > 0 ) && ( t < segmentlength ) ) + { + p3 = ( p1 * t ) + s->origin; + + delta = p3 - pos; + dist = delta.length(); + if ( dist < bestdist ) + { + trace = G_Trace( pos, ent.mins, ent.maxs, p3, &ent, MASK_PLAYERSOLID, false, "GravPath::ClosestPointOnPath 3" ); + bestdist = dist; + bestpoint = p3; + *speed = (e->Speed() * t) + (s->Speed() * (1.0f - t)); + *radius = (e->Radius() * t) + (s->Radius() * (1.0f - t)); + } + } + + s = e; + } + *ret_dist = bestdist; + return bestpoint; + } + +float GravPath::DistanceAlongPath + ( + Vector pos, + float *speed + ) + + { + GravPathNode *s; + GravPathNode *e; + int num; + int i; + float bestdist; + float dist; + float segmentlength; + Vector delta; + Vector segment; + Vector p1; + Vector p2; + Vector p3; + float t; + float pathdist; + float bestdistalongpath; + float oosl; + pathdist = 0; + + num = NumNodes(); + s = GetNode( 1 ); + delta = s->origin - pos; + bestdist = delta.length(); + bestdistalongpath = 0; + *speed = s->Speed(); + + for( i = 2; i <= num; i++ ) + { + e = GetNode( i ); + + segment = e->origin - s->origin; + segmentlength = segment.length(); + + // check if we're closest to the endpoint + delta = e->origin - pos; + dist = delta.length(); + + if ( dist < bestdist ) + { + bestdist = dist; + bestdistalongpath = pathdist + segmentlength; + *speed = e->Speed(); + } + + // check if we're closest to the segment + oosl = ( 1 / segmentlength ); + p1 = segment * oosl; + p1.normalize(); + p2 = pos - s->origin; + + t = p1 * p2; + if ( ( t > 0 ) && ( t < segmentlength ) ) + { + p3 = ( p1 * t ) + s->origin; + + delta = p3 - pos; + dist = delta.length(); + if ( dist < bestdist ) + { + bestdist = dist; + bestdistalongpath = pathdist + t; + + t *= oosl; + *speed = (e->Speed() * t) + (s->Speed() * (1.0f - t)); + } + } + + s = e; + pathdist += segmentlength; + } + + return bestdistalongpath; + } + +Vector GravPath::PointAtDistance + ( + Vector pos, + float dist, + qboolean is_player, + float *max_speed + ) + + { + GravPathNode *s; + GravPathNode *e; + int num; + int i; + Vector delta; + Vector p1; + float t; + float pathdist; + float segmentlength; + + num = NumNodes(); + s = GetNode( 1 ); + pathdist = 0; + + for( i = 2; i <= num; i++ ) + { + e = GetNode( i ); + + delta = e->origin - s->origin; + segmentlength = delta.length(); + + if ( ( pathdist + segmentlength ) > dist ) + { + t = dist - pathdist; + + p1 = delta * ( t / segmentlength ); +// return p1 + s->origin; + + if ( e->spawnflags & PULL_UPWARDS && is_player ) + p1.z = p1.length() / 2; + + *max_speed = e->MaxSpeed(); + + return p1 + pos; + } + + s = e; + pathdist += segmentlength; + } + + *max_speed = s->MaxSpeed(); + + // cap it off at start or end of path + return s->origin; + } + +void GravPath::DrawPath + ( + float r, + float g, + float b + ) + + { + Vector s; + Vector e; + Vector offset; + GravPathNode *node; + int num; + int i; + + num = NumNodes(); + node = GetNode( 1 ); + s = node->origin; + G_DebugBBox( s, Vector(8,8,8), Vector(-8,-8,-8), 0,1,0,1 ); + offset = Vector( r, g, b ) * 4 + Vector( 0, 0, 0 ); + offset = Vector(0, 0, 0); + + for( i = 2; i <= num; i++ ) + { + node = GetNode( i ); + e = node->origin; + + G_DebugLine( s + offset, e + offset, r, g, b, 1 ); + G_DebugBBox( e, Vector(8,8,8), Vector(-8,-8,-8), 0,1,0,1 ); + s = e; + } + + G_DebugBBox(origin,mins-origin,maxs-origin,1,0,0,1); + } + +int GravPath::NumNodes + ( + void + ) + + { + return pathlist.NumObjects(); + } + +float GravPath::Length + ( + void + ) + + { + return pathlength; + } diff --git a/code/game/gravpath.h b/code/game/gravpath.h new file mode 100644 index 00000000..1aae471f --- /dev/null +++ b/code/game/gravpath.h @@ -0,0 +1,206 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// gravpath.h: Gravity path - Used for underwater currents and wells. + +#ifndef __GRAVPATH_H__ +#define __GRAVPATH_H__ + +#include "g_local.h" +#include "class.h" +#include "container.h" + + +class GravPathNode : public Entity + { + private: + float speed; + float radius; + qboolean headnode; + float max_speed; + + public: + qboolean active; + + CLASS_PROTOTYPE(GravPathNode); + GravPathNode(); + void SetSpeed( Event *ev ); + void SetMaxSpeed( Event *ev ); + void SetRadius( Event *ev ); + void CreatePath( Event *ev ); + void Activate( Event *ev ); + void Deactivate( Event *ev ); + float Speed( void ); + float MaxSpeed( void ); + float Radius( void ) { return radius; }; + virtual void Archive( Archiver &arc ); + }; + +inline void GravPathNode::Archive + ( + Archiver &arc + ) + { + Entity::Archive( arc ); + + arc.ArchiveFloat( &speed ); + arc.ArchiveFloat( &radius ); + arc.ArchiveBoolean( &headnode ); + arc.ArchiveBoolean( &active ); + arc.ArchiveFloat( &max_speed ); + } + +typedef SafePtr GravPathNodePtr; + +class GravPath : public Listener + { + private: + Container pathlist; + float pathlength; + + GravPathNodePtr from; + GravPathNodePtr to; + int nextnode; + + public: + CLASS_PROTOTYPE( GravPath ); + + GravPath(); + ~GravPath(); + void Clear(void); + void Reset(void); + void AddNode(GravPathNode *node); + GravPathNode *GetNode(int num); + GravPathNode *NextNode(void); + Vector ClosestPointOnPath(Vector pos, Entity &ent,float *bestdist,float *speed,float *radius); + float DistanceAlongPath(Vector pos, float *speed); + Vector PointAtDistance( Vector pos, float dist, qboolean is_player, float *max_distance ); + void DrawPath(float r, float g, float b); + int NumNodes(void); + float Length(void); + GravPathNode *Start(void); + GravPathNode *End(void); + virtual void Archive( Archiver &arc ); + + Vector mins; + Vector maxs; + Vector origin; + qboolean force; + }; + +inline void GravPath::Archive + ( + Archiver &arc + ) + + { + GravPathNodePtr *tempPtr; + int i, num; + + Listener::Archive( arc ); + + if ( arc.Loading() ) + { + Reset(); + } + else + { + num = pathlist.NumObjects(); + } + arc.ArchiveInteger( &num ); + if ( arc.Loading() ) + { + pathlist.Resize( num ); + } + + for ( i = 1; i <= num; i++ ) + { + tempPtr = pathlist.AddressOfObjectAt( i ); + arc.ArchiveSafePointer( tempPtr ); + } + + arc.ArchiveFloat( &pathlength ); + arc.ArchiveSafePointer( &from ); + arc.ArchiveSafePointer( &to ); + arc.ArchiveInteger( &nextnode ); + arc.ArchiveVector( &mins ); + arc.ArchiveVector( &maxs ); + arc.ArchiveVector( &origin ); + arc.ArchiveBoolean( &force ); + } + +class GravPathManager : public Class + { + private: + Container pathList; + + public: + CLASS_PROTOTYPE( GravPathManager ); + ~GravPathManager(); + void Reset( void ); + void AddPath(GravPath *p); + void RemovePath(GravPath *p); + Vector CalculateGravityPull(Entity &ent, Vector position, qboolean *force, float *max_speed); + void DrawGravPaths( void ); + virtual void Archive( Archiver &arc ); + }; + +inline void GravPathManager::Archive + ( + Archiver &arc + ) + { + GravPath * ptr; + int i, num; + + Class::Archive( arc ); + + if ( arc.Saving() ) + { + num = pathList.NumObjects(); + } + else + { + Reset(); + } + arc.ArchiveInteger( &num ); + for ( i = 1; i <= num; i++ ) + { + if ( arc.Saving() ) + { + ptr = pathList.ObjectAt( i ); + } + else + { + ptr = new GravPath; + } + arc.ArchiveObject( ptr ); + if ( arc.Loading() ) + { + pathList.AddObject( ptr ); + } + } + } + +extern GravPathManager gravPathManager; + +#endif /* gravpath.h */ diff --git a/code/game/grenadehint.cpp b/code/game/grenadehint.cpp new file mode 100644 index 00000000..b10e1978 --- /dev/null +++ b/code/game/grenadehint.cpp @@ -0,0 +1,101 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// grenadehint.cpp: Grenade hint for actors. + +#include "grenadehint.h" + +CLASS_DECLARATION( SimpleEntity, GrenadeHint, "info_grenadehint" ) +{ + { NULL, NULL } +}; + +GrenadeHint *GrenadeHint::gm_pFirst; + +GrenadeHint::GrenadeHint() +{ + m_pNext = gm_pFirst; + gm_pFirst = this; +} + +void GrenadeHint::ResetHints + ( + void + ) + +{ + gm_pFirst = NULL; +} + +int GrenadeHint::GetClosestSet + ( + GrenadeHint **ppHints, + int nHints, + Vector& vOrg, + float fMaxRangeSquared + ) + +{ + int i; + int nFound = 0; + GrenadeHint *pHint; + Vector vDelta; + float afRangeSquared[ 256 ]; + float fRangeSquared; + + if( nHints > 256 ) + nHints = 256; + + // iterate through all grenade hints and get the closest + for( pHint = gm_pFirst; pHint != NULL; pHint = pHint->m_pNext ) + { + vDelta = pHint->origin - vOrg; + + fRangeSquared = VectorLengthSquared( vDelta ); + + if( fRangeSquared > fMaxRangeSquared ) + { + for( i = nFound; i > 0; i-- ) + { + if( fRangeSquared > afRangeSquared[ i - 1 ] ) + break; + + if( i < nFound || nFound < nHints ) + { + afRangeSquared[ i ] = afRangeSquared[ i - 1 ]; + ppHints[ i ] = ppHints[ i - 1 ]; + } + } + + if( i < nHints ) + { + afRangeSquared[ i ] = fRangeSquared; + ppHints[ i ] = pHint; + + if( nFound < nHints ) + nFound++; + } + } + } + + return nFound; +} diff --git a/code/game/grenadehint.h b/code/game/grenadehint.h new file mode 100644 index 00000000..f0eb4573 --- /dev/null +++ b/code/game/grenadehint.h @@ -0,0 +1,57 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// grenadehint.h: Grenade hint for actors. + +#ifndef __GRENADEHINT_H__ +#define __GRENADEHINT_H__ + +#include "g_local.h" +#include + +class GrenadeHint : public SimpleArchivedEntity { +public: + GrenadeHint *m_pNext; + static GrenadeHint *gm_pFirst; + + CLASS_PROTOTYPE( GrenadeHint ); + + GrenadeHint(); + + static void ResetHints( void ); + static int GetClosestSet( GrenadeHint **ppHints, int nHints, Vector& vOrg, float fMaxRangeSquared ); + + virtual void Archive( Archiver& arc ); +}; + +inline void GrenadeHint::Archive + ( + Archiver& arc + ) + +{ + SimpleEntity::Archive( arc ); + + arc.ArchiveObjectPointer( ( Class ** )&m_pNext ); +} + +#endif diff --git a/code/game/health.cpp b/code/game/health.cpp new file mode 100644 index 00000000..2edc1354 --- /dev/null +++ b/code/game/health.cpp @@ -0,0 +1,84 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// health.cpp: Health powerup +// + +#include "g_local.h" +#include "item.h" +#include "inventoryitem.h" +#include "sentient.h" +#include "health.h" +#include "weaputils.h" +#include "player.h" + +CLASS_DECLARATION( Item, Health, "health_020" ) +{ + { &EV_Item_Pickup, &Health::PickupHealth }, + { NULL, NULL } +}; + +Health::Health() +{ + if( DM_FLAG( DF_NO_HEALTH ) ) + { + PostEvent( EV_Remove, EV_REMOVE ); + return; + } + + setAmount( 20 ); +} + +void Health::PickupHealth + ( + Event *ev + ) + +{ + Sentient *sen; + Entity *other; + + other = ev->GetEntity( 1 ); + if( !other || !other->IsSubclassOfSentient() ) + { + return; + } + + sen = ( Sentient * )other; + + if( sen->health >= sen->max_health ) + return; + + if( !ItemPickup( other, qfalse ) ) + { + return; + } + + sen->health += amount / 100.0 * sen->max_health; + + if( sen->health > sen->max_health ) + { + sen->health = sen->max_health; + } + + gi.SendServerCommand( sen->edict - g_entities, "print \"" HUD_MESSAGE_YELLOW "%s \"", gi.LV_ConvertString( va( "Recovered %d", amount ) ) ); +} diff --git a/code/game/health.h b/code/game/health.h new file mode 100644 index 00000000..b139447b --- /dev/null +++ b/code/game/health.h @@ -0,0 +1,43 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// health.h: Health powerup +// + +#ifndef __HEALTH_H__ +#define __HEALTH_H__ + +#include "g_local.h" +#include "item.h" +#include "sentient.h" +#include "item.h" + +class Health : public Item +{ +public: + CLASS_PROTOTYPE( Health ); + + Health(); + virtual void PickupHealth( Event *ev ); +}; + +#endif /* health.h */ diff --git a/code/game/huddraw.cpp b/code/game/huddraw.cpp new file mode 100644 index 00000000..4b804d5c --- /dev/null +++ b/code/game/huddraw.cpp @@ -0,0 +1,344 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// huddraw.cpp : This is a HudDraw Functions Code section with huddraw functions reversed for +// altering clients HUD + +#include "g_local.h" +#include "hud.h" + +void HudWriteNumber( int num ) +{ + if( sv_reborn->integer ) { + gi.MSG_WriteShort( num ); + } else { + gi.MSG_WriteByte( num ); + } +} + +void HudDrawShader( int info, const char *name ) +{ + gi.SetBroadcastAll(); + gi.MSG_StartCGM(0x1B); + HudWriteNumber( info ); // c = info + gi.MSG_WriteString(name); // s = name (shader_name) + gi.MSG_EndCGM(); +} + +void HudDrawAlign( int info, int horizontalAlign, int verticalAlign ) +{ + gi.SetBroadcastAll(); + gi.MSG_StartCGM(0x1C); + HudWriteNumber( info ); // c = probably "info" + gi.MSG_WriteBits(horizontalAlign, 2); // value = 0,1,2 bits = 2 + // 0 - left \ + // 1 - center - horizontalAlign + // 2 - right / + + gi.MSG_WriteBits(verticalAlign, 2); // value = 0,1,2 bits = 2 + // 0 - top \ + // 1 - center - verticalAlign + // 2 - bottom / + + gi.MSG_EndCGM(); + +} + +void HudDrawRect(int info, int x, int y, int width, int height) +{ + gi.SetBroadcastAll(); + gi.MSG_StartCGM(0x1D); + HudWriteNumber( info ); // c = probably "info" + gi.MSG_WriteShort(x); // c = probably "x" + gi.MSG_WriteShort(y); // c = probably "y" + gi.MSG_WriteShort(width); // c = probably "width" + gi.MSG_WriteShort(height); // c = probably "height" + gi.MSG_EndCGM(); + +} + +void HudDrawVirtualSize(int info, int virtualScreen) +{ + gi.SetBroadcastAll(); + gi.MSG_StartCGM(0x1E); + HudWriteNumber( info ); // c = info + + /*__asm + { + pushad + pushfd + mov eax, virtualScreen + NEG eax + SBB eax, eax + NEG eax + mov virtualScreen, eax + popfd + popad + }*/ + + gi.MSG_WriteBits(!!virtualScreen, 1); // value = ? bits = 1 + // value = esi + // esi = virtualScreen + // NEG esi + // SBB esi, esi + // NEG esi + // call + + gi.MSG_EndCGM(); + +} + +void HudDrawColor(int info, float *color) +{ + long int temp[3]; + temp[0] = (long int)(color[0]*255.0f); + temp[1] = (long int)(color[1]*255.0f); + temp[2] = (long int)(color[2]*255.0f); + + + gi.SetBroadcastAll(); + gi.MSG_StartCGM(0x1F); + HudWriteNumber( info ); // c = info + gi.MSG_WriteByte(temp[0]); // c = color[2] + gi.MSG_WriteByte(temp[1]); // c = color[1] - Values can be messed up. To be tested. + gi.MSG_WriteByte(temp[2]); // c = color[3] / + gi.MSG_EndCGM(); + + // Note: Each float value is multiplied by 255.0 and converted to long using ftol function, thats why it's using WriteByte +} + +void HudDrawAlpha(int info, float alpha) +{ + long int temp; + temp = (long int)(alpha*255.0f); + + gi.SetBroadcastAll(); + gi.MSG_StartCGM(0x20); + HudWriteNumber( info ); // c = info + gi.MSG_WriteByte(temp); // c = alpha + gi.MSG_EndCGM(); + + // Note: alpha is multiplied by 255.0 and converted to long using ftol function + +} + +void HudDrawString(int info, const char *string) +{ + gi.SetBroadcastAll(); + gi.MSG_StartCGM(0x21); + HudWriteNumber( info ); // c = info + gi.MSG_WriteString(string); // s = string (to show) + gi.MSG_EndCGM(); + +} + +void HudDrawFont(int info, const char *fontName) +{ + gi.SetBroadcastAll(); + gi.MSG_StartCGM(0x22); + HudWriteNumber( info ); // c = info + gi.MSG_WriteString(fontName); // s = fontName (to use) + gi.MSG_EndCGM(); + +} + +void HudDraw3d( int index, vec3_t vector, int ent_num, qboolean bAlwaysShow, qboolean depth ) +{ + gi.SetBroadcastAll(); + + gi.MSG_StartCGM( CGM_HUDDRAW_3D ); + HudWriteNumber( index ); + gi.MSG_WriteCoord( vector[0] ); + gi.MSG_WriteCoord( vector[1] ); + gi.MSG_WriteCoord( vector[2] ); + + gi.MSG_WriteShort( ent_num ); + + gi.MSG_WriteByte( bAlwaysShow ); + gi.MSG_WriteByte( depth ); + gi.MSG_EndCGM(); +} + +void HudDrawTimer( int index, float duration, float fade_out_time ) +{ + gi.SetBroadcastAll(); + + gi.MSG_StartCGM( CGM_HUDDRAW_TIMER ); + HudWriteNumber( index ); + gi.MSG_WriteFloat( duration ); + gi.MSG_WriteFloat( fade_out_time ); + gi.MSG_EndCGM(); +} + +void iHudDrawShader( int cl_num, int info, const char *name ) +{ + gi.MSG_SetClient(cl_num); + gi.MSG_StartCGM(0x1B); + HudWriteNumber( info ); // c = info + gi.MSG_WriteString(name); // s = name (shader_name) + gi.MSG_EndCGM(); + +} + +void iHudDrawAlign(int cl_num, int info, int horizontalAlign, int verticalAlign ) +{ + gi.MSG_SetClient(cl_num); + gi.MSG_StartCGM(0x1C); + HudWriteNumber( info ); // c = probably "info" + gi.MSG_WriteBits(horizontalAlign, 2); // value = 0,1,2 bits = 2 + // 0 - left \ + // 1 - center - horizontalAlign + // 2 - right / + + gi.MSG_WriteBits(verticalAlign, 2); // value = 0,1,2 bits = 2 + // 0 - top \ + // 1 - center - verticalAlign + // 2 - bottom / + + gi.MSG_EndCGM(); + +} + +void iHudDrawRect(int cl_num, int info, int x, int y, int width, int height) +{ + gi.MSG_SetClient(cl_num); + gi.MSG_StartCGM(0x1D); + HudWriteNumber( info ); // c = probably "info" + gi.MSG_WriteShort(x); // c = probably "x" + gi.MSG_WriteShort(y); // c = probably "y" + gi.MSG_WriteShort(width); // c = probably "width" + gi.MSG_WriteShort(height); // c = probably "height" + gi.MSG_EndCGM(); +} + +void iHudDraw3d( int cl_num, int index, vec3_t vector, int ent_num, qboolean bAlwaysShow, qboolean depth ) +{ + gi.MSG_SetClient( cl_num ); + + gi.MSG_StartCGM( CGM_HUDDRAW_3D ); + HudWriteNumber( index ); + gi.MSG_WriteCoord( vector[0] ); + gi.MSG_WriteCoord( vector[1] ); + gi.MSG_WriteCoord( vector[2] ); + + gi.MSG_WriteShort( ent_num ); + + gi.MSG_WriteByte( bAlwaysShow ); + gi.MSG_WriteByte( depth ); + gi.MSG_EndCGM(); +} + +void iHudDrawTimer( int cl_num, int index, float duration, float fade_out_time ) +{ + gi.MSG_SetClient( cl_num ); + + gi.MSG_StartCGM( CGM_HUDDRAW_TIMER ); + HudWriteNumber( index ); + gi.MSG_WriteFloat( duration ); + gi.MSG_WriteFloat( fade_out_time ); + gi.MSG_EndCGM(); +} + +void iHudDrawVirtualSize(int cl_num, int info, int virtualScreen) +{ + gi.MSG_SetClient(cl_num); + gi.MSG_StartCGM(0x1E); + HudWriteNumber( info ); // c = info + + gi.MSG_WriteBits(!!virtualScreen, 1); // value = ? bits = 1 + // value = esi + // esi = virtualScreen + // NEG esi + // SBB esi, esi + // NEG esi + // call + + gi.MSG_EndCGM(); + +} + +void iHudDrawColor(int cl_num, int info, float *color) +{ + long int temp[3]; + + temp[0] = (long int)(color[0]*255.0f); + temp[1] = (long int)(color[1]*255.0f); + temp[2] = (long int)(color[2]*255.0f); + + gi.MSG_SetClient(cl_num); + gi.MSG_StartCGM(0x1F); + HudWriteNumber( info ); // c = info + gi.MSG_WriteByte(temp[0]); // c = color[2] + gi.MSG_WriteByte(temp[1]); // c = color[1] - Values can be messed up. To be tested. + gi.MSG_WriteByte(temp[2]); // c = color[3] / + gi.MSG_EndCGM(); + + // Note: Each float value is multiplied by 255.0 and converted to long using ftol function, thats why it's using WriteByte +} + +void iHudDrawAlpha(int cl_num, int info, float alpha) +{ + long int temp; + temp = (long int)(alpha*255.0f); + + gi.MSG_SetClient(cl_num); + gi.MSG_StartCGM(0x20); + HudWriteNumber( info ); // c = info + gi.MSG_WriteByte(temp); // c = alpha + gi.MSG_EndCGM(); + + // Note: alpha is multiplied by 255.0 and converted to long using ftol function + +} + +void iHudDrawString( int cl_num, int info, const char *string ) +{ + gi.MSG_SetClient(cl_num); + gi.MSG_StartCGM(0x21); + HudWriteNumber( info ); // c = info + gi.MSG_WriteString(string); // s = string (to show) + gi.MSG_EndCGM(); + +} + +void iHudDrawFont( int cl_num, int info, const char *fontName ) +{ + gi.MSG_SetClient(cl_num); + gi.MSG_StartCGM(0x22); + HudWriteNumber( info ); // c = info + gi.MSG_WriteString(fontName); // s = fontName (to use) + gi.MSG_EndCGM(); + +} +/* FONTS + + facfont-20 +courier-16 +courier-18 +courier-20 +handle-16 +handle-18 +marlett +verdana-12 +verdana-14 + + */ diff --git a/code/game/huddraw.h b/code/game/huddraw.h new file mode 100644 index 00000000..d924394d --- /dev/null +++ b/code/game/huddraw.h @@ -0,0 +1,53 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// huddraw.cpp : This is a HudDraw Functions Code section with huddraw functions reversed for +// altering clients HUD + +#ifndef __HUDDRAW_H__ +#define __HUDDRAW_H__ + +#include "g_local.h" + +void HudDraw3d( int index, vec3_t vector, int ent_num, qboolean bAlwaysShow, qboolean depth ); +void HudDrawShader( int info, const char *name ); +void HudDrawAlign( int info, int horizontalAlign, int verticalAlign ); +void HudDrawRect( int info, int x, int y, int width, int height ); +void HudDrawVirtualSize( int info, int virtualScreen ); +void HudDrawColor( int info, float *color ); +void HudDrawAlpha( int info, float alpha ); +void HudDrawString( int info, const char *string ); +void HudDrawFont( int info, const char *fontName ); +void HudDrawTimer( int index, float duration, float fade_out_time ); + +void iHudDraw3d( int cl_num, int index, vec3_t vector, int ent_num, qboolean bAlwaysShow, qboolean depth ); +void iHudDrawShader( int cl_num, int info, const char *name ); +void iHudDrawAlign( int cl_num, int info, int horizontalAlign, int verticalAlign ); +void iHudDrawRect( int cl_num, int info, int x, int y, int width, int height ); +void iHudDrawVirtualSize( int cl_num, int info, int virtualScreen ); +void iHudDrawColor( int cl_num, int info, float *color ); +void iHudDrawAlpha( int cl_num, int info, float alpha ); +void iHudDrawString( int cl_num, int info, const char *string ); +void iHudDrawFont( int cl_num, int info, const char *fontName ); +void iHudDrawTimer( int cl_num, int index, float duration, float fade_out_time ); + +#endif // __HUDDRAW_H__ diff --git a/code/game/inv.h b/code/game/inv.h new file mode 100644 index 00000000..dbbebcdb --- /dev/null +++ b/code/game/inv.h @@ -0,0 +1,166 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#define INVENTORY_NONE 0 +//armor +#define INVENTORY_ARMOR 1 +//weapons +#define INVENTORY_GAUNTLET 4 +#define INVENTORY_SHOTGUN 5 +#define INVENTORY_MACHINEGUN 6 +#define INVENTORY_GRENADELAUNCHER 7 +#define INVENTORY_ROCKETLAUNCHER 8 +#define INVENTORY_LIGHTNING 9 +#define INVENTORY_RAILGUN 10 +#define INVENTORY_PLASMAGUN 11 +#define INVENTORY_BFG10K 13 +#define INVENTORY_GRAPPLINGHOOK 14 +#define INVENTORY_NAILGUN 15 +#define INVENTORY_PROXLAUNCHER 16 +#define INVENTORY_CHAINGUN 17 +//ammo +#define INVENTORY_SHELLS 18 +#define INVENTORY_BULLETS 19 +#define INVENTORY_GRENADES 20 +#define INVENTORY_CELLS 21 +#define INVENTORY_LIGHTNINGAMMO 22 +#define INVENTORY_ROCKETS 23 +#define INVENTORY_SLUGS 24 +#define INVENTORY_BFGAMMO 25 +#define INVENTORY_NAILS 26 +#define INVENTORY_MINES 27 +#define INVENTORY_BELT 28 +//powerups +#define INVENTORY_HEALTH 29 +#define INVENTORY_TELEPORTER 30 +#define INVENTORY_MEDKIT 31 +#define INVENTORY_KAMIKAZE 32 +#define INVENTORY_PORTAL 33 +#define INVENTORY_INVULNERABILITY 34 +#define INVENTORY_QUAD 35 +#define INVENTORY_ENVIRONMENTSUIT 36 +#define INVENTORY_HASTE 37 +#define INVENTORY_INVISIBILITY 38 +#define INVENTORY_REGEN 39 +#define INVENTORY_FLIGHT 40 +#define INVENTORY_SCOUT 41 +#define INVENTORY_GUARD 42 +#define INVENTORY_DOUBLER 43 +#define INVENTORY_AMMOREGEN 44 + +#define INVENTORY_REDFLAG 45 +#define INVENTORY_BLUEFLAG 46 +#define INVENTORY_NEUTRALFLAG 47 +#define INVENTORY_REDCUBE 48 +#define INVENTORY_BLUECUBE 49 +//enemy stuff +#define ENEMY_HORIZONTAL_DIST 200 +#define ENEMY_HEIGHT 201 +#define NUM_VISIBLE_ENEMIES 202 +#define NUM_VISIBLE_TEAMMATES 203 + +// if running the mission pack +#ifdef MISSIONPACK + +//#error "running mission pack" + +#endif + +//item numbers (make sure they are in sync with bg_itemlist in bg_misc.c) +#define MODELINDEX_ARMORSHARD 1 +#define MODELINDEX_ARMORCOMBAT 2 +#define MODELINDEX_ARMORBODY 3 +#define MODELINDEX_HEALTHSMALL 4 +#define MODELINDEX_HEALTH 5 +#define MODELINDEX_HEALTHLARGE 6 +#define MODELINDEX_HEALTHMEGA 7 + +#define MODELINDEX_GAUNTLET 8 +#define MODELINDEX_SHOTGUN 9 +#define MODELINDEX_MACHINEGUN 10 +#define MODELINDEX_GRENADELAUNCHER 11 +#define MODELINDEX_ROCKETLAUNCHER 12 +#define MODELINDEX_LIGHTNING 13 +#define MODELINDEX_RAILGUN 14 +#define MODELINDEX_PLASMAGUN 15 +#define MODELINDEX_BFG10K 16 +#define MODELINDEX_GRAPPLINGHOOK 17 + +#define MODELINDEX_SHELLS 18 +#define MODELINDEX_BULLETS 19 +#define MODELINDEX_GRENADES 20 +#define MODELINDEX_CELLS 21 +#define MODELINDEX_LIGHTNINGAMMO 22 +#define MODELINDEX_ROCKETS 23 +#define MODELINDEX_SLUGS 24 +#define MODELINDEX_BFGAMMO 25 + +#define MODELINDEX_TELEPORTER 26 +#define MODELINDEX_MEDKIT 27 +#define MODELINDEX_QUAD 28 +#define MODELINDEX_ENVIRONMENTSUIT 29 +#define MODELINDEX_HASTE 30 +#define MODELINDEX_INVISIBILITY 31 +#define MODELINDEX_REGEN 32 +#define MODELINDEX_FLIGHT 33 + +#define MODELINDEX_REDFLAG 34 +#define MODELINDEX_BLUEFLAG 35 + +// mission pack only defines + +#define MODELINDEX_KAMIKAZE 36 +#define MODELINDEX_PORTAL 37 +#define MODELINDEX_INVULNERABILITY 38 + +#define MODELINDEX_NAILS 39 +#define MODELINDEX_MINES 40 +#define MODELINDEX_BELT 41 + +#define MODELINDEX_SCOUT 42 +#define MODELINDEX_GUARD 43 +#define MODELINDEX_DOUBLER 44 +#define MODELINDEX_AMMOREGEN 45 + +#define MODELINDEX_NEUTRALFLAG 46 +#define MODELINDEX_REDCUBE 47 +#define MODELINDEX_BLUECUBE 48 + +#define MODELINDEX_NAILGUN 49 +#define MODELINDEX_PROXLAUNCHER 50 +#define MODELINDEX_CHAINGUN 51 + + +// +#define WEAPONINDEX_GAUNTLET 1 +#define WEAPONINDEX_MACHINEGUN 2 +#define WEAPONINDEX_SHOTGUN 3 +#define WEAPONINDEX_GRENADE_LAUNCHER 4 +#define WEAPONINDEX_ROCKET_LAUNCHER 5 +#define WEAPONINDEX_LIGHTNING 6 +#define WEAPONINDEX_RAILGUN 7 +#define WEAPONINDEX_PLASMAGUN 8 +#define WEAPONINDEX_BFG 9 +#define WEAPONINDEX_GRAPPLING_HOOK 10 +#define WEAPONINDEX_NAILGUN 11 +#define WEAPONINDEX_PROXLAUNCHER 12 +#define WEAPONINDEX_CHAINGUN 13 diff --git a/code/game/inventoryitem.cpp b/code/game/inventoryitem.cpp new file mode 100644 index 00000000..497072e3 --- /dev/null +++ b/code/game/inventoryitem.cpp @@ -0,0 +1,98 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// inventoryitem.cpp: Inventory items + +#include "inventoryitem.h" +#include "weaputils.h" + +Event EV_InventoryItem_Shoot +( + "activateitem", + EV_DEFAULT, + "S", + "mode", + "Activates the item" +); + +Event EV_InventoryItem_Activate_Papers +( + "activatepapers", + EV_DEFAULT, + NULL, + NULL, + "The activation of the papers item" +); + +CLASS_DECLARATION( Weapon, InventoryItem, NULL ) +{ + { &EV_InventoryItem_Shoot, &InventoryItem::ActivateItem }, + { &EV_InventoryItem_Activate_Papers, &InventoryItem::ActivatePapers }, + { NULL, NULL } +}; + +InventoryItem::InventoryItem() +{ + entflags |= EF_INVENTORYITEM; + + if ( LoadingSavegame ) + { + return; + } + + weapon_class = WEAPON_CLASS_ITEM; +} + +InventoryItem::~InventoryItem() +{ + entflags &= ~EF_INVENTORYITEM; +} + +void InventoryItem::ActivateItem + ( + Event *ev + ) + +{ + if( firetype[ FIRE_PRIMARY ] == FT_CLICKITEM ) + { + Vector pos, forward, right, up, vBarrel; + + GetMuzzlePosition( &pos, &forward, &right, &up, &vBarrel ); + ClickItemAttack( + pos, + forward, + bulletrange[ FIRE_PRIMARY ], + owner ); + } + + m_fLastFireTime = level.time; +} + +void InventoryItem::ActivatePapers + ( + Event *ev + ) + +{ + GetOwner()->m_ShowPapersTime = level.inttime; +} diff --git a/code/game/inventoryitem.h b/code/game/inventoryitem.h new file mode 100644 index 00000000..f9cbd738 --- /dev/null +++ b/code/game/inventoryitem.h @@ -0,0 +1,56 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// inventoryitem.h: Items that are visible in the player's inventory + + +#ifndef __INVITEM_H__ +#define __INVITEM_H__ + +#include "weapon.h" + +class InventoryItem : public Weapon +{ +public: + CLASS_PROTOTYPE( InventoryItem ); + + InventoryItem(); + ~InventoryItem(); + + void ActivateItem( Event *ev ); + void ActivatePapers( Event *ev ) ; + +}; + +extern Event EV_InventoryItem_Use; + +class AntiSBJuice : public InventoryItem + { + public: + CLASS_PROTOTYPE( AntiSBJuice ); + AntiSBJuice(); + void Wearoff( Event *ev ); + void UseEvent( Event *ev ); + }; + + +#endif /* inventoryitem.h */ diff --git a/code/game/ipfilter.cpp b/code/game/ipfilter.cpp new file mode 100644 index 00000000..05a381b3 --- /dev/null +++ b/code/game/ipfilter.cpp @@ -0,0 +1,360 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// ipfilter.cpp: PACKET FILTERING +// +// You can add or remove addresses from the filter list with: +// +// addip +// removeip +// +// The ip address is specified in dot format, and any unspecified digits will match +// any value, so you can specify an entire class C network with "addip 192.246.40". +// +// Removeip will only remove an address specified exactly the same way. You cannot +// addip a subnet, then removeip a single host. +// +// listip +// Prints the current list of filters. +// +// writeip +// Dumps "addip " commands to listip.cfg so it can be execed at a later date. +// The filter lists are not saved and restored by default, because I beleive it would +// cause too much confusion. +// +// filterban <0 or 1> +// +// If 1 (the default), then ip addresses matching the current list will be prohibited +// from entering the game. This is the default setting. +// +// If 0, then only addresses matching the list will be allowed. This lets you easily +// set up a private game, or a game that only allows players from your local network. +// + +#include "ipfilter.h" +#include "g_local.h" + +typedef struct + { + unsigned mask; + unsigned compare; + } ipfilter_t; + +#define MAX_IPFILTERS 1024 + +ipfilter_t ipfilters[ MAX_IPFILTERS ]; +int numipfilters; + +/* +================= +StringToFilter +================= +*/ +static qboolean StringToFilter + ( + const char *s, + ipfilter_t *f + ) + + { + char num[ 128 ]; + int i; + int j; + byte b[ 4 ]; + byte m[ 4 ]; + + for( i = 0; i < 4; i++ ) + { + b[ i ] = 0; + m[ i ] = 0; + } + + for( i = 0; i < 4; i++ ) + { + if ( *s < '0' || *s > '9' ) + { + gi.SendServerCommand( NULL, "print \"Bad filter address: %s\n\"", s ); + return false; + } + + j = 0; + while( *s >= '0' && *s <= '9' ) + { + num[ j++ ] = *s++; + } + + num[ j ] = 0; + b[ i ] = atoi( num ); + if ( b[ i ] != 0 ) + { + m[ i ] = 255; + } + + if ( !*s ) + { + break; + } + + s++; + } + + f->mask = *( unsigned * )m; + f->compare = *( unsigned * )b; + + return true; + } + +/* +================= +SV_FilterPacket +================= +*/ +qboolean SV_FilterPacket + ( + const char *from + ) + + { + int i; + unsigned in; + byte m[ 4 ]; + const char *p; + + i = 0; + p = from; + while( *p && i < 4 ) + { + m[ i ] = 0; + while( *p >= '0' && *p <= '9' ) + { + m[ i ] = m[ i ] * 10 + ( *p - '0' ); + p++; + } + + if ( !*p || *p == ':' ) + { + break; + } + + i++; + p++; + } + + in = *( unsigned * )m; + for( i = 0; i < numipfilters; i++ ) + { + if ( ( in & ipfilters[ i ].mask ) == ipfilters[ i ].compare ) + { + return ( int )filterban->integer; + } + } + + return !( int )filterban->integer; + } + + +/* +================= +SV_AddIP_f +================= +*/ +void SVCmd_AddIP_f + ( + void + ) + + { + int i; + + if ( gi.Argc() < 3 ) + { + gi.SendServerCommand( NULL, "print \"Usage: addip \n\"" ); + return; + } + + for( i = 0; i < numipfilters; i++ ) + { + if ( ipfilters[ i ].compare == 0xffffffff ) + { + // free spot + break; + } + } + + if ( i == numipfilters ) + { + if ( numipfilters == MAX_IPFILTERS ) + { + gi.SendServerCommand( NULL, "print \"IP filter list is full\n\"" ); + return; + } + numipfilters++; + } + + if ( !StringToFilter( gi.Argv( 2 ), &ipfilters[ i ] ) ) + { + ipfilters[ i ].compare = 0xffffffff; + } + } + +/* +================= +SV_RemoveIP_f +================= +*/ +void SVCmd_RemoveIP_f + ( + void + ) + + { + ipfilter_t f; + int i; + int j; + + if ( gi.Argc() < 3 ) + { + gi.SendServerCommand( NULL, "print \"Usage: sv removeip \n\"" ); + return; + } + + if ( !StringToFilter( gi.Argv( 2 ), &f ) ) + { + return; + } + + for( i = 0; i < numipfilters; i++ ) + { + if ( ( ipfilters[ i ].mask == f.mask ) && ( ipfilters[ i ].compare == f.compare ) ) + { + for ( j = i + 1; j < numipfilters; j++ ) + { + ipfilters[ j - 1 ] = ipfilters[ j ]; + } + + numipfilters--; + gi.SendServerCommand( NULL, "print \"Removed.\n\"" ); + return; + } + } + + gi.SendServerCommand( NULL, "print \"Didn't find %s.\n\"", gi.Argv( 2 ) ); + } + +/* +================= +SV_ListIP_f +================= +*/ +void SVCmd_ListIP_f + ( + void + ) + + { + int i; + byte b[ 4 ]; + + gi.SendServerCommand( NULL, "print \"Filter list:\n\"", gi.Argv( 2 ) ); + for( i = 0; i < numipfilters; i++ ) + { + *( unsigned * )b = ipfilters[ i ].compare; + gi.SendServerCommand( NULL, "print \"%3i.%3i.%3i.%3i\n\"", b[ 0 ], b[ 1 ], b[ 2 ], b[ 3 ] ); + } + } + +/* +================= +SV_WriteIP_f +================= +*/ +void SVCmd_WriteIP_f + ( + void + ) + + { + FILE *f; + char name[ MAX_OSPATH ]; + byte b[ 4 ]; + int i; + + sprintf( name, "%s/listip.cfg", GAMEVERSION ); + gi.SendServerCommand( NULL, "print \"Writing %s.\n\"", name ); + + f = fopen( name, "wb" ); + if ( !f ) + { + gi.SendServerCommand( NULL, "print \"Couldn't open %s.\n\"", name ); + return; + } + + fprintf( f, "set filterban %d\n", ( int )filterban->integer ); + + for( i = 0; i < numipfilters; i++ ) + { + *( unsigned * )b = ipfilters[ i ].compare; + fprintf( f, "sv addip %i.%i.%i.%i\n", b[ 0 ], b[ 1 ], b[ 2 ], b[ 3 ] ); + } + + fclose( f ); + } + +/* +================= +G_ServerCommand + +G_ServerCommand will be called when an "sv" command is issued. +The game can issue gi.Argc() / gi.Argv() commands to get the rest +of the parameters +================= +*/ +void G_ServerCommand + ( + void + ) + + { + const char *cmd; + + cmd = gi.Argv(1); + if ( Q_stricmp( cmd, "addip" ) == 0 ) + { + SVCmd_AddIP_f(); + } + else if ( Q_stricmp( cmd, "removeip" ) == 0 ) + { + SVCmd_RemoveIP_f(); + } + else if ( Q_stricmp( cmd, "listip" ) == 0 ) + { + SVCmd_ListIP_f(); + } + else if ( Q_stricmp( cmd, "writeip" ) == 0 ) + { + SVCmd_WriteIP_f(); + } + else + { + gi.SendServerCommand( NULL, "print \"Unknown server command %s.\n\"", cmd ); + } + } diff --git a/code/game/ipfilter.h b/code/game/ipfilter.h new file mode 100644 index 00000000..a09c9216 --- /dev/null +++ b/code/game/ipfilter.h @@ -0,0 +1,33 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// ipfilter.h: DESCRIPTION: +// + +#ifndef __IPFILTER_H__ +#define __IPFILTER_H__ + +#include "g_local.h" + +qboolean SV_FilterPacket( const char *from ); + +#endif /* !__IPFILTER_H__ */ diff --git a/code/game/item.cpp b/code/game/item.cpp new file mode 100644 index 00000000..bb5a30d7 --- /dev/null +++ b/code/game/item.cpp @@ -0,0 +1,1141 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// item.cpp: Base class for respawnable, carryable objects. +// + +#include "g_local.h" +#include "entity.h" +#include "trigger.h" +#include "item.h" +#include "inventoryitem.h" +#include "scriptmaster.h" +#include "health.h" + +typedef struct { + str name; + str prefix; + bool mohprefix; +} prefix_t; + +static prefix_t r_prefixlist[ 256 ] = +{ + { "Unarmed", "unarmed", true }, + { "Binoculars", "binoculars", true }, + { "Papers", "papers", true }, + { "Packed MG42 Turret", "mg42portable", true }, + { "Colt 45", "colt45", true }, + { "Walther P38", "p38", true }, + { "Hi-Standard Silenced", "histandard", true }, + { "Webley Revolver", "webley", true }, + { "Nagant Revolver", "nagantrev", true }, + { "Beretta", "beretta", true }, + { "M1 Garand", "garand", true }, + { "Mauser KAR 98K", "kar98", true }, + { "KAR98 - Sniper", "kar98sniper", true }, + { "Springfield '03 Sniper", "springfield", true }, + { "Lee-Enfield", "enfield", true }, + { "SVT 40", "svt", true }, + { "Mosin Nagant Rifle", "mosin", true }, + { "G 43", "g43", true }, + { "Enfield L42A1", "enfieldl42a1", true }, + { "Carcano", "carcano", true }, + { "DeLisle", "delisle", true }, + { "Thompson", "thompson", true }, + { "MP40", "mp40", true }, + { "Sten Mark II", "sten", true }, + { "PPSH SMG", "ppsh", true }, + { "Moschetto", "moschetto", true }, + { "BAR", "bar", true }, + { "StG 44", "mp44", true }, + { "FG 42", "fg42", true }, + { "Vickers-Berthier", "vickers", true }, + { "Breda", "breda", true }, + { "Frag Grenade", "fraggrenade", true }, + { "Stielhandgranate", "stielhandgranate", true }, + { "F1 Grenade", "f1grenade", true }, + { "Mills Grenade", "millsgrenade", true }, + { "Nebelhandgranate", "nebelhandgranate", true }, + { "M18 Smoke Grenade", "m18smokegrenade", true }, + { "RDG-1 Smoke Grenade", "rdg1smokegrenade", true }, + { "Bomba A Mano", "bomba", true }, + { "Bomba A Mano Breda", "bombabreda", true }, + { "Landmine", "mine", true }, + { "LandmineAllies", "minedetector", true }, + { "LandmineAxis", "minedetectoraxis", true }, + { "Unarmed", "detonator", true }, + { "Bazooka", "bazooka", true }, + { "Panzerschreck", "panzerschreck", true }, + { "Gewehrgranate", "kar98mortar", true }, + { "Shotgun", "shotgun", true }, + { "PIAT", "PIAT", true }, +}; + +void AddItemToList( const char *name, const char *prefix ) +{ + for( int i = 0; i < sizeof( r_prefixlist ) / sizeof( r_prefixlist[ 0 ] ); i++ ) + { + if( !r_prefixlist[ i ].name.length() ) + { + r_prefixlist[ i ].name = name; + r_prefixlist[ i ].prefix = prefix; + r_prefixlist[ i ].mohprefix = false; + return; + } + } +} + +const char *GetItemName( const char *prefix, qboolean *mohprefix ) +{ + for( int i = 0; i < sizeof( r_prefixlist ) / sizeof( r_prefixlist[ 0 ] ); i++ ) + { + if( !r_prefixlist[ i ].prefix.c_str() ) + { + continue; + } + + if( r_prefixlist[ i ].prefix == prefix ) + { + if( mohprefix ) + { + *mohprefix = r_prefixlist[ i ].mohprefix; + } + + return r_prefixlist[ i ].name; + } + } + + if( mohprefix ) + { + *mohprefix = false; + } + + return NULL; +} + +const char *GetItemPrefix( const char *name, qboolean *mohprefix ) +{ + for( int i = 0; i < sizeof( r_prefixlist ) / sizeof( r_prefixlist[ 0 ] ); i++ ) + { + if( r_prefixlist[ i ].name == name ) + { + if( mohprefix ) + { + *mohprefix = r_prefixlist[ i ].mohprefix; + } + + return r_prefixlist[ i ].prefix; + } + } + + if( mohprefix ) + { + *mohprefix = false; + } + + return NULL; +} + +Event EV_Item_Pickup + ( + "item_pickup", + EV_DEFAULT, + "e", + "item", + "Pickup the specified item.", + EV_NORMAL + ); +Event EV_Item_DropToFloor + ( + "item_droptofloor", + EV_DEFAULT, + NULL, + NULL, + "Drops the item to the ground.", + EV_NORMAL + ); +Event EV_Item_Respawn + ( + "respawn", + EV_DEFAULT, + NULL, + NULL, + "Respawns the item.", + EV_NORMAL + ); +Event EV_Item_SetRespawn + ( + "set_respawn", + EV_DEFAULT, + "i", + "respawn", + "Turns respawn on or off.", + EV_NORMAL + ); +Event EV_Item_SetRespawnTime + ( + "set_respawn_time", + EV_DEFAULT, + "f", + "respawn_time", + "Sets the respawn time.", + EV_NORMAL + ); +Event EV_Item_SetAmount + ( + "amount", + EV_DEFAULT, + "i", + "amount", + "Sets the amount of the item.", + EV_NORMAL + ); +Event EV_Item_SetMaxAmount + ( + "maxamount", + EV_DEFAULT, + "i", + "max_amount", + "Sets the max amount of the item.", + EV_NORMAL + ); +Event EV_Item_SetItemName + ( + "name", + EV_DEFAULT, + "s", + "item_name", + "Sets the item name.", + EV_NORMAL + ); +Event EV_Item_RespawnSound + ( + "respawnsound", + EV_DEFAULT, + NULL, + NULL, + "Turns on the respawn sound for this item.", + EV_NORMAL + ); +Event EV_Item_DialogNeeded + ( + "dialogneeded", + EV_DEFAULT, + "s", + "dialog_needed", + "Sets the dialog needed string.", + EV_NORMAL + ); +Event EV_Item_NoRemove + ( + "no_remove", + EV_DEFAULT, + NULL, + NULL, + "Makes it so the item is not removed from the world when it is picked up.", + EV_NORMAL + ); +Event EV_Item_RespawnDone + ( + "respawn_done", + EV_DEFAULT, + NULL, + NULL, + "Called when the item respawn is done.", + EV_NORMAL + ); +Event EV_Item_PickupDone + ( + "pickup_done", + EV_DEFAULT, + NULL, + NULL, + "Called when the item pickup is done.", + EV_NORMAL + ); + +Event EV_Item_CoolItem + ( + "coolitem", + EV_DEFAULT, + "SS", + "dialog anim_to_play", + "Specify that this is a cool item when we pick it up for the first time.\n" + "If dialog is specified, than the dialog will be played during the pickup.\n" + "If anim_to_play is specified, than the specified anim will be played after\n" + "the initial cinematic.", + EV_NORMAL + ); + +Event EV_Item_ForceCoolItem + ( + "forcecoolitem", + EV_DEFAULT, + "SS", + "dialog anim_to_play", + "Specify that this is a cool item when we pick it up regardless of whether or not we have it.\n" + "If dialog is specified, than the dialog will be played during the pickup.\n" + "If anim_to_play is specified, than the specified anim will be played after\n" + "the initial cinematic.", + EV_NORMAL + ); + +Event EV_Item_SetPickupSound +( + "pickupsound", + EV_DEFAULT, + "s", + "name", + "sets the item's pickup sound alias" +); + +Event EV_Item_ViewModelPrefix +( + "viewmodelprefix", + EV_DEFAULT, + "s", + "prefix", + "Sets the item's prefix for viewmodelanim." +); + +Event EV_Item_UpdatePrefix +( + "_updateprefix", + EV_CODEONLY, + NULL, + NULL, + "internal event - update the custom viewmodel prefix" +); + +CLASS_DECLARATION( Trigger, Item, NULL ) +{ + { &EV_Trigger_Effect, &Item::ItemTouch }, + { &EV_Item_DropToFloor, &Item::DropToFloor }, + { &EV_Item_Respawn, &Item::Respawn }, + { &EV_Item_SetAmount, &Item::SetAmountEvent }, + { &EV_Item_SetMaxAmount, &Item::SetMaxAmount }, + { &EV_Item_SetItemName, &Item::SetItemName }, + { &EV_Item_Pickup, &Item::Pickup }, + { &EV_Use, &Item::TriggerStuff }, + { &EV_Item_RespawnSound, &Item::RespawnSound }, + { &EV_Item_DialogNeeded, &Item::DialogNeeded }, + { &EV_Item_NoRemove, &Item::SetNoRemove }, + { &EV_Item_RespawnDone, &Item::RespawnDone }, + { &EV_Item_PickupDone, &Item::PickupDone }, + { &EV_Item_SetRespawn, &Item::setRespawn }, + { &EV_Item_SetRespawnTime, &Item::setRespawnTime }, + { &EV_Item_CoolItem, &Item::CoolItemEvent }, + { &EV_Item_ForceCoolItem, &Item::ForceCoolItemEvent }, + { &EV_Stop, &Item::Landed }, + { &EV_SetAngle, &Item::SetAngleEvent }, + { &EV_Item_SetPickupSound, &Item::SetPickupSound }, + { &EV_Item_ViewModelPrefix, &Item::EventViewModelPrefix }, + { &EV_Item_UpdatePrefix, &Item::updatePrefix }, + { NULL, NULL } +}; + +Item::Item() +{ + str fullname; + + entflags |= EF_ITEM; + + if( LoadingSavegame ) + { + return; + } + + setSolidType( SOLID_NOT ); + + // Set default respawn behavior + // Derived classes should use setRespawn + // if they want to override the default behavior + setRespawn( deathmatch->integer ? true : false ); + setRespawnTime( 20 ); + + // + // set a minimum mins and maxs for the model + // + if( size.length() < 10 ) + { + mins = "-10 -10 0"; + maxs = "10 10 20"; + } + + // + // reset the mins and maxs to pickup the FL_ROTATEDBOUNDS flag + // + setSize( mins, maxs ); + + // Items can't be immediately dropped to floor, because they might + // be on an entity that hasn't spawned yet. + PostEvent( EV_Item_DropToFloor, EV_POSTSPAWN ); + + respondto = TRIGGER_PLAYERS; + + // items should collide with everything that the player does + edict->clipmask = MASK_ITEM; + + item_index = 0; + maximum_amount = 1; + playrespawn = false; + + // this is an item entity + edict->s.eType = ET_ITEM; + + amount = 1; + no_remove = false; + setName( "Unknown Item" ); + + sPickupSound = "snd_pickup"; + + m_sVMprefix = "Unarmed"; + m_bMOHPrefix = true; +} + +Item::~Item() +{ + if( owner ) + { + owner->RemoveItem( this ); + owner = NULL; + } + + entflags &= ~EF_ITEM; +} + +void Item::SetNoRemove + ( + Event *ev + ) + { + no_remove = true; + } + +/* +============ +PlaceItem + +Puts an item back in the world +============ +*/ +void Item::PlaceItem + ( + void + ) + +{ + setSolidType( SOLID_TRIGGER ); + setMoveType( MOVETYPE_TOSS ); + showModel(); + + groundentity = NULL; +} + +/* +============ +DropToFloor + +plants the object on the floor +============ +*/ +void Item::DropToFloor + ( + Event *ev + ) + +{ + str fullname; + Vector save; + + PlaceItem(); + + addOrigin( Vector( "0 0 1" ) ); + + save = origin; + if( !droptofloor( 8192 ) ) + { + gi.DPrintf( "%s (%d) stuck in world at '%5.1f %5.1f %5.1f'\n", + getClassID(), entnum, origin.x, origin.y, origin.z ); + setOrigin( save ); + setMoveType( MOVETYPE_NONE ); + } + else + { + setMoveType( MOVETYPE_NONE ); + } + // + // if the our global variable doesn't exist, lets zero it out + // + fullname = str( "playeritem_" ) + getName(); + + game.vars->GetOrCreateVariable( fullname.c_str() ); + level.vars->GetOrCreateVariable( fullname.c_str() ); + +} + +qboolean Item::Drop + ( + void + ) + +{ + if( !owner ) + { + return false; + } + + setOrigin( owner->origin + Vector( "0 0 40" ) ); + + // drop the item + PlaceItem(); + velocity = owner->velocity * 0.5 + Vector( G_CRandom( 50 ), G_CRandom( 50 ), 100 ); + setAngles( owner->angles ); + avelocity = Vector( 0, G_CRandom( 360 ), 0 ); + + trigger_time = level.time + 1; + + if( owner->isClient() ) + { + spawnflags |= DROPPED_PLAYER_ITEM; + } + else + { + spawnflags |= DROPPED_ITEM; + } + + // Remove this from the owner's item list + RemoveFromOwner(); + + PostEvent( EV_Remove, g_droppeditemlife->value ); + + return true; +} + + +void Item::ItemTouch + ( + Event *ev + ) + + { + Entity *other; + Event *e; + + if ( owner ) + { + // Don't respond to trigger events after item is picked up. + // we really don't need to see this. + //gi.DPrintf( "%s with targetname of %s was triggered unexpectedly.\n", getClassID(), TargetName() ); + return; + } + + other = ev->GetEntity( 1 ); + + e = new Event( EV_Item_Pickup ); + e->AddEntity( other ); + ProcessEvent( e ); + } + +void Item::SetOwner + ( + Sentient *ent + ) + +{ + assert( ent ); + if( !ent ) + { + // return to avoid any buggy behaviour + return; + } + + owner = ent; + setRespawn( false ); + + setSolidType( SOLID_NOT ); + hideModel(); + CancelEventsOfType( EV_Touch ); + CancelEventsOfType( EV_Item_DropToFloor ); + CancelEventsOfType( EV_Remove ); + + Event *ev = new Event( EV_Item_UpdatePrefix ); + ev->AddEntity( ent ); + + PostEvent( ev, EV_POSTSPAWN ); +} + +Sentient *Item::GetOwner + ( + void + ) + +{ + return owner; +} + +void Item::Delete + ( + void + ) + +{ + if( g_iInThinks ) + { + if( owner ) + RemoveFromOwner(); + + PostEvent( EV_Remove, 0 ); + } + else + { + delete this; + } +} + +void Item::RemoveFromOwner + ( + void + ) + +{ + owner->RemoveItem( this ); + owner = NULL; +} + +Item * Item::ItemPickup + ( + Entity *other, + qboolean add_to_inventory + ) + +{ + Sentient * sent; + Item * item = NULL; + str realname; + + if( !Pickupable( other ) ) + { + return NULL; + } + + sent = ( Sentient * )other; + + if( add_to_inventory ) + { + item = sent->giveItem( model, getAmount() ); + + if( !item ) + return NULL; + } + else + { + item = this; + } + + // + // let our sent know they received it + // we put this here so we can transfer information from the original item we picked up + // + sent->ReceivedItem( item ); + + Sound( sPickupSound ); + + if( !Removable() ) + { + // leave the item for others to pickup + return item; + } + + CancelEventsOfType( EV_Item_DropToFloor ); + CancelEventsOfType( EV_Item_Respawn ); + CancelEventsOfType( EV_FadeOut ); + + setSolidType( SOLID_NOT ); + + if( HasAnim( "pickup" ) ) + { + NewAnim( "pickup", EV_Item_PickupDone ); + } + else + { + if( !no_remove ) + { + hideModel(); + + if( !Respawnable() ) + PostEvent( EV_Remove, FRAMETIME ); + } + } + + if( !no_remove ) + { + hideModel(); + + if( !Respawnable() ) + PostEvent( EV_Remove, FRAMETIME ); + } + + if( Respawnable() ) + PostEvent( EV_Item_Respawn, RespawnTime() ); + + return item; +} + +void Item::Respawn + ( + Event *ev + ) + +{ + showModel(); + + // allow it to be touched again + setSolidType( SOLID_TRIGGER ); + + // play respawn sound + if( playrespawn ) + { + Sound( "snd_itemspawn" ); + } + + setOrigin(); + + if( HasAnim( "respawn" ) ) + NewAnim( "respawn", EV_Item_RespawnDone ); +} + +void Item::setRespawn + ( + Event *ev + ) + + { + if ( ev->NumArgs() < 1 ) + return; + + setRespawn( ev->GetInteger( 1 ) ); + } + +void Item::setRespawnTime + ( + Event *ev + ) + + { + if ( ev->NumArgs() < 1 ) + return; + + setRespawnTime( ev->GetFloat( 1 ) ); + } + +void Item::RespawnDone( Event *ev ) +{ + NewAnim( "idle" ); +} + +void Item::PickupDone( Event *ev ) +{ + if( !no_remove ) + { + hideModel(); + + if( !Respawnable() ) + PostEvent( EV_Remove, FRAMETIME ); + } + else + { + if( HasAnim( "pickup_idle" ) ) + NewAnim( "pickup_idle" ); + else + NewAnim( "pickup" ); + } +} + +void Item::setRespawn + ( + qboolean flag + ) + +{ + respawnable = flag; +} + +qboolean Item::Respawnable + ( + void + ) + + { + return respawnable; + } + +void Item::setRespawnTime + ( + float time + ) + +{ + respawntime = time; +} + +float Item::RespawnTime + ( + void + ) + + { + return respawntime; + } + +int Item::getAmount + ( + void + ) + + { + return amount; + } + +int Item::MaxAmount + ( + void + ) + + { + return maximum_amount; + } + +qboolean Item::Pickupable + ( + Entity *other + ) + +{ + if( !other->IsSubclassOfSentient() ) + { + return false; + } + else + { + Sentient * sent; + Item * item; + + sent = ( Sentient * )other; + + item = sent->FindItem( getName() ); + + if( item && ( item->getAmount() >= item->MaxAmount() ) ) + { + return false; + } + + } + return true; +} + +void Item::Pickup + ( + Event * ev + ) + +{ + ItemPickup( ev->GetEntity( 1 ) ); +} + +void Item::setName + ( + const char *i + ) + +{ + const char *prefix; + + item_name = i; + item_index = gi.itemindex( i ); + strcpy( edict->entname, i ); + + prefix = GetItemPrefix( item_name ); + if( prefix ) + { + m_sVMprefix = prefix; + m_bMOHPrefix = true; + } +} + +str Item::getName + ( + void + ) + + { + return( item_name ); + } + +int Item::getIndex + ( + void + ) + + { + return item_index; + } + +void Item::setAmount + ( + int startamount + ) + + { + amount = startamount; + if ( amount >= MaxAmount() ) + { + SetMax( amount ); + } + } + +void Item::SetMax + ( + int maxamount + ) + + { + maximum_amount = maxamount; + } + +void Item::SetAmountEvent + ( + Event *ev + ) + + { + setAmount( ev->GetInteger( 1 ) ); + } + +void Item::SetMaxAmount + ( + Event *ev + ) + + { + SetMax( ev->GetInteger( 1 ) ); + } + +void Item::SetItemName + ( + Event *ev + ) + + { + setName( ev->GetString( 1 ) ); + } + +void Item::Add + ( + int num + ) + + { + amount += num; + if ( amount >= MaxAmount() ) + amount = MaxAmount(); + } + +void Item::Remove + ( + int num + ) + { + amount -= num; + if (amount < 0) + amount = 0; + } + + +qboolean Item::Use + ( + int num + ) + + { + if ( num > amount ) + { + return false; + } + + amount -= num; + return true; + } + +qboolean Item::Removable + ( + void + ) + + { + return true; + } + +void Item::RespawnSound + ( + Event *ev + ) + + { + playrespawn = true; + } + +void Item::DialogNeeded + ( + Event *ev + ) + + { + // + // if this item is needed for a trigger, play this dialog + // + dialog_needed = ev->GetString( 1 ); + } + +str Item::GetDialogNeeded + ( + void + ) + + { + return dialog_needed; + } + +// +// once item has landed on the floor, go to movetype none +// +void Item::Landed + ( + Event *ev + ) + { + if ( groundentity && ( groundentity->entity != world ) ) + { + warning( "Item::Landed", "Item %d has landed on an entity that might move\n", entnum ); + } + setMoveType( MOVETYPE_NONE ); + } + +void Item::SetCoolItem + ( + qboolean cool, + str &dialog, + str &anim + ) +{ + +} + +void Item::CoolItemEvent + ( + Event *ev + ) + +{ + +} + +void Item::ForceCoolItemEvent + ( + Event *ev + ) + +{ + +} + +void Item::SetPickupSound + ( + Event *ev + ) + +{ + sPickupSound = ev->GetString( 1 ); +} + +void Item::EventViewModelPrefix + ( + Event *ev + ) + +{ + int i; + gentity_t *ent; + + m_sVMprefix = ev->GetString( 1 ); + + if( !GetItemPrefix( item_name, &m_bMOHPrefix ) ) + { + AddItemToList( item_name, m_sVMprefix ); + } + + for( i = 0, ent = g_entities; i < game.maxclients; i++, ent++ ) + { + if( !ent->inuse || !ent->entity ) { + continue; + } + + Event *ev = new Event( EV_Item_UpdatePrefix ); + ev->AddEntity( ent->entity ); + + PostEvent( ev, EV_POSTSPAWN ); + } +} + +void Item::updatePrefix + ( + Event *ev + ) + +{ + if( !level.reborn ) { + return; + } + + if( m_bMOHPrefix ) { + return; + } + + Entity *ent = ev->GetEntity( 1 ); + + gi.MSG_SetClient( ent->edict - g_entities ); + + gi.MSG_StartCGM( CGM_VIEWMODELPREFIX ); + gi.MSG_WriteString( item_name.c_str() ); + gi.MSG_WriteString( m_sVMprefix.c_str() ); + gi.MSG_EndCGM(); +} + +qboolean Item::IsItemCool + ( + str * dialog, + str * anim, + qboolean * forced + ) +{ + return qfalse; +} diff --git a/code/game/item.h b/code/game/item.h new file mode 100644 index 00000000..661583c0 --- /dev/null +++ b/code/game/item.h @@ -0,0 +1,155 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// item.h: Base class for respawnable, carryable objects. +// + +#ifndef __ITEM_H__ +#define __ITEM_H__ + +#include "g_local.h" +#include "entity.h" +#include "trigger.h" +#include "sentient.h" +#include + +extern Event EV_Item_Pickup; +extern Event EV_Item_DropToFloor; +extern Event EV_Item_Respawn; +extern Event EV_Item_SetAmount; +extern Event EV_Item_SetMaxAmount; +extern Event EV_Item_RespawnSound; +extern Event EV_Item_DialogNeeded; +extern Event EV_Item_PickupDone; + +#define DROPPED_ITEM 0x00008000 +#define DROPPED_PLAYER_ITEM 0x00010000 + +class Item : public Trigger +{ +protected: + SentientPtr owner; + qboolean respawnable; + qboolean playrespawn; + float respawntime; + str dialog_needed; + int item_index; + str item_name; + int maximum_amount; + int amount; + str sPickupSound; + + qboolean no_remove; + + void ItemTouch( Event *ev ); + +public: + str m_sVMprefix; + qboolean m_bMOHPrefix; + + CLASS_PROTOTYPE( Item ); + + Item(); + ~Item(); + virtual void PlaceItem( void ); + virtual void SetOwner( Sentient *ent ); + virtual Sentient* GetOwner( void ); + virtual void Delete( void ); + void RemoveFromOwner( void ); + void SetNoRemove( Event *ev ); + virtual void DropToFloor( Event *ev ); + virtual Item *ItemPickup( Entity *other, qboolean add_to_inventory = qtrue ); + virtual void Respawn( Event *ev ); + virtual void setRespawn( qboolean flag ); + void setRespawn( Event *ev ); + virtual qboolean Respawnable( void ); + virtual void setRespawnTime( float time ); + void setRespawnTime( Event *ev ); + virtual float RespawnTime( void ); + void RespawnDone( Event *ev ); + void PickupDone( Event *ev ); + virtual int GetItemIndex( void ) { return item_index; }; + virtual int getAmount( void ); + virtual void setAmount( int startamount ); + + virtual int MaxAmount( void ); + virtual qboolean Pickupable( Entity *other ); + + virtual void setName( const char *i ); + virtual str getName( void ); + virtual int getIndex( void ); + virtual void SetAmountEvent( Event *ev ); + virtual void SetMaxAmount( Event *ev ); + virtual void SetItemName( Event *ev ); + + virtual void SetMax( int maxamount ); + virtual void Add( int num ); + virtual void Remove( int num ); + virtual qboolean Use( int amount ); + virtual qboolean Removable( void ); + virtual void Pickup( Event *ev ); + virtual qboolean Drop( void ); + virtual void RespawnSound( Event *ev ); + virtual void DialogNeeded( Event *ev ); + virtual str GetDialogNeeded( void ); + void Landed( Event *ev ); + void CoolItemEvent( Event *ev ); + void ForceCoolItemEvent( Event *ev ); + qboolean IsItemCool( str * dialog, str * anim, qboolean *force ); + void SetCoolItem( qboolean cool, str &dialog, str &anim ); + + void SetPickupSound( Event *ev ); + + void EventViewModelPrefix( Event *ev ); + void updatePrefix( Event *ev ); + + virtual void Archive( Archiver &arc ); +}; + +inline void Item::Archive +( +Archiver &arc +) +{ + Trigger::Archive( arc ); + + arc.ArchiveSafePointer( &owner ); + arc.ArchiveBoolean( &respawnable ); + arc.ArchiveBoolean( &playrespawn ); + arc.ArchiveFloat( &respawntime ); + arc.ArchiveString( &dialog_needed ); + arc.ArchiveInteger( &item_index ); + arc.ArchiveString( &item_name ); + if( arc.Loading() ) + { + setName( item_name.c_str() ); + } + arc.ArchiveInteger( &maximum_amount ); + arc.ArchiveInteger( &amount ); + arc.ArchiveBoolean( &no_remove ); + arc.ArchiveString( &sPickupSound ); +} + +const char *GetItemName( const char *prefix, qboolean *mohprefix = NULL ); +const char *GetItemPrefix( const char *name, qboolean *mohprefix = NULL ); + +#endif /* item.h */ diff --git a/code/game/level.cpp b/code/game/level.cpp new file mode 100644 index 00000000..9164d7df --- /dev/null +++ b/code/game/level.cpp @@ -0,0 +1,2073 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// level.cpp : Global Level Info. + +#include "glb_local.h" +#include "level.h" +#include "parm.h" +#include "../game/navigate.h" +#include "../game/gravpath.h" + +#if defined( GAME_DLL ) +#include "../game/entity.h" +#include "../game/dm_manager.h" +#include "../game/player.h" +#endif + +#include "scriptmaster.h" +#include "scriptvariable.h" + +Level level; + +gclient_t *spawn_client = NULL; + +Event EV_Level_GetTime + ( + "time", + EV_DEFAULT, + NULL, + NULL, + "current level time", + EV_GETTER + ); + +Event EV_Level_GetTotalSecrets + ( + "total_secrets", + EV_DEFAULT, + NULL, + NULL, + "count of total secrets", + EV_GETTER + ); + +Event EV_Level_GetFoundSecrets + ( + "found_secrets", + EV_DEFAULT, + NULL, + NULL, + "count of found secrets", + EV_GETTER + ); + +Event EV_Level_PreSpawnSentient + ( + "prespawnsentient", + EV_CODEONLY, + NULL, + NULL, + "internal usage." + ); + +Event EV_Level_GetAlarm + ( + "alarm", + EV_DEFAULT, + NULL, + NULL, + "zero = global level alarm off, non-zero = alarm on", + EV_GETTER + ); + +Event EV_Level_SetAlarm + ( + "alarm", + EV_DEFAULT, + "i", + "alarm_status", + "zero = global level alarm off, non-zero = alarm on", + EV_SETTER + ); + +Event EV_Level_SetNoDropHealth + ( + "nodrophealth", + EV_DEFAULT, + "i", + "alarm_status", + "zero = automatically drop health according to cvars, non-zero = don't autodrop health (like hard mode)", + EV_SETTER + ); + +Event EV_Level_GetLoopProtection + ( + "loop_protection", + EV_DEFAULT, + NULL, + NULL, + "says if infinite loop protection is enabled", + EV_GETTER + ); + +Event EV_Level_SetLoopProtection + ( + "loop_protection", + EV_DEFAULT, + "i", + "loop_protection", + "specify if infinite loop protection is enabled", + EV_SETTER + ); + +Event EV_Level_GetPapersLevel + ( + "papers", + EV_DEFAULT, + NULL, + NULL, + "the level of papers the player currently has", + EV_GETTER + ); + +Event EV_Level_SetPapersLevel + ( + "papers", + EV_DEFAULT, + NULL, + NULL, + "the level of papers the player currently has", + EV_SETTER + ); + +Event EV_Level_GetDMRespawning + ( + "dmrespawning", + EV_DEFAULT, + NULL, + NULL, + "returns 1 if wave-based DM, 0 if respawns are disabled within a round", + EV_GETTER + ); + +Event EV_Level_SetDMRespawning + ( + "dmrespawning", + EV_DEFAULT, + "i", + "allow_respawn", + "set to 1 to turn on wave-based DM, to 0 to disable respawns within a round", + EV_SETTER + ); + +Event EV_Level_SetDMRespawning2 + ( + "dmrespawning", + EV_DEFAULT, + "i", + "allow_respawn", + "set to 1 to turn on wave-based DM, to 0 to disable respawns within a round" + ); + +Event EV_Level_GetDMRoundLimit + ( + "dmroundlimit", + EV_DEFAULT, + NULL, + NULL, + "gets the actual roundlimit, in minutes; may be 'roundlimit' cvar or the default round limit", + EV_GETTER + ); + +Event EV_Level_SetDMRoundLimit + ( + "dmroundlimit", + EV_DEFAULT, + "i", + "roundlimit", + "sets the default roundlimit, in minutes; can be overridden by 'roundlimit' cvar", + EV_SETTER + ); + +Event EV_Level_SetDMRoundLimit2 + ( + "dmroundlimit", + EV_DEFAULT, + "i", + "roundlimit", + "sets the default roundlimit, in minutes; can be overridden by 'roundlimit' cvar" + ); + +Event EV_Level_GetClockSide + ( + "clockside", + EV_DEFAULT, + NULL, + NULL, + "Gets which side the clock is on... 'axis' or 'allies' win when time is up", + EV_GETTER + ); + +Event EV_Level_SetClockSide + ( + "clockside", + EV_DEFAULT, + "s", + "axis_or_allies", + "Sets which side the clock is on... 'axis' or 'allies' win when time is up", + EV_SETTER + ); + +Event EV_Level_SetClockSide2 + ( + "clockside", + EV_DEFAULT, + "s", + "axis_allies_draw_kills", + "Sets which side the clock is on... 'axis' or 'allies' win when time is up, 'kills' gives the win to the team with more live members, 'draw' no one wins" + ); + +Event EV_Level_GetBombPlantTeam + ( + "planting_team", + EV_DEFAULT, + NULL, + NULL, + "Gets which is planting the bomb, 'axis' or 'allies'", + EV_GETTER + ); + +Event EV_Level_SetBombPlantTeam + ( + "planting_team", + EV_DEFAULT, + "s", + "axis_or_allies", + "Sets which is planting the bomb, 'axis' or 'allies'", + EV_SETTER + ); + +Event EV_Level_SetBombPlantTeam2 + ( + "planting_team", + EV_DEFAULT, + "s", + "axis_allies_draw_kills", + "which is planting the bomb, 'axis' or 'allies'" + ); + +Event EV_Level_GetTargetsToDestroy + ( + "targets_to_destroy", + EV_DEFAULT, + NULL, + NULL, + "Gets the number of bomb targets that must be destroyed", + EV_GETTER + ); + +Event EV_Level_SetTargetsToDestroy + ( + "targets_to_destroy", + EV_DEFAULT, + "i", + "num", + "Sets the number of bomb targets that must be destroyed", + EV_SETTER + ); + +Event EV_Level_SetTargetsToDestroy2 + ( + "targets_to_destroy", + EV_DEFAULT, + "i", + "num", + "the number of bomb targets that must be destroyed" + ); + +Event EV_Level_GetTargetsDestroyed + ( + "targets_destroyed", + EV_DEFAULT, + NULL, + NULL, + "Gets the number of bomb targets that have been destroyed", + EV_GETTER + ); + +Event EV_Level_SetTargetsDestroyed + ( + "targets_destroyed", + EV_DEFAULT, + "i", + "num", + "Sets the number of bomb targets that have been destroyed", + EV_SETTER + ); + +Event EV_Level_SetTargetsDestroyed2 + ( + "targets_destroyed", + EV_DEFAULT, + "i", + "num", + "the number of bomb targets that have been destroyed" + ); + +Event EV_Level_GetBombsPlanted + ( + "bombs_planted", + EV_DEFAULT, + NULL, + NULL, + "Gets the number of bombs that are set", + EV_GETTER + ); + +Event EV_Level_SetBombsPlanted + ( + "bombs_planted", + EV_DEFAULT, + "i", + "num", + "Sets the number of bombs that are set", + EV_SETTER + ); + +Event EV_Level_SetBombsPlanted2 + ( + "bombs_planted", + EV_DEFAULT, + "i", + "num", + "the number of bombs that are set" + ); + +Event EV_Level_GetRoundBased + ( + "roundbased", + EV_DEFAULT, + NULL, + NULL, + "Gets wether or not the game is currently round based or not", + EV_GETTER + ); + +Event EV_Level_Rain_Density_Set + ( + "rain_density", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain density", + EV_SETTER + ); + +Event EV_Level_Rain_Density_Get + ( + "rain_density", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain density", + EV_GETTER + ); + +Event EV_Level_Rain_Speed_Set + ( + "rain_speed", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain speed", + 3 + ); + +Event EV_Level_Rain_Speed_Get + ( + "rain_speed", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain speed", + 2 + ); + +Event EV_Level_Rain_Speed_Vary_Set + ( + "rain_speed_vary", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain speed variance", + EV_SETTER + ); + +Event EV_Level_Rain_Speed_Vary_Get + ( + "rain_speed_vary", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain speed variance", + EV_GETTER + ); + +Event EV_Level_Rain_Slant_Set + ( + "rain_slant", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain slant", + EV_SETTER + ); + +Event EV_Level_Rain_Slant_Get + ( + "rain_slant", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain slant", + EV_GETTER + ); + +Event EV_Level_Rain_Length_Set + ( + "rain_length", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain length", + EV_SETTER + ); + +Event EV_Level_Rain_Length_Get + ( + "rain_length", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain length", + EV_GETTER + ); + +Event EV_Level_Rain_Min_Dist_Set + ( + "rain_min_dist", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain min_dist", + EV_SETTER + ); + +Event EV_Level_Rain_Min_Dist_Get + ( + "rain_min_dist", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain min_dist", + EV_GETTER + ); + +Event EV_Level_Rain_Width_Set + ( + "rain_width", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain width", + EV_SETTER + ); + +Event EV_Level_Rain_Width_Get + ( + "rain_width", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain width", + EV_GETTER + ); + +Event EV_Level_Rain_Shader_Set + ( + "rain_shader", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain ", + EV_SETTER + ); + +Event EV_Level_Rain_Shader_Get + ( + "rain_shader", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain ", + EV_GETTER + ); + +Event EV_Level_Rain_NumShaders_Set + ( + "rain_numshaders", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain numshaders", + EV_SETTER + ); + +Event EV_Level_Rain_NumShaders_Get + ( + "rain_numshaders", + EV_DEFAULT, + NULL, + NULL, + "Sets the rain numshaders", + EV_GETTER + ); + +Event EV_Level_GetFlags + ( + "flag", + EV_DEFAULT, + NULL, + NULL, + "Initialized flag list", + EV_GETTER + ); + +Level::Level() +{ + Init(); +} + +Level::~Level() +{ + +} + +void Level::Archive( Archiver& arc ) +{ + bool prespawn; + bool spawn; + + Listener::Archive( arc ); + + if( arc.Saving() ) + { + prespawn = classinfo()->WaitTillDefined( "prespawn" ); + spawn = classinfo()->WaitTillDefined( "spawn" ); + } + + arc.ArchiveBool( &prespawn ); + arc.ArchiveBool( &spawn ); + + if( arc.Loading() ) + { + if( prespawn ) { + AddWaitTill( STRING_PRESPAWN ); + } + + if( spawn ) { + AddWaitTill( STRING_SPAWN ); + } + } + + arc.ArchiveInteger( &framenum ); + + arc.ArchiveString( &level_name ); + arc.ArchiveString( &mapname ); + arc.ArchiveString( &spawnpoint ); + arc.ArchiveString( &nextmap ); + + arc.ArchiveBoolean( &playerfrozen ); + + arc.ArchiveFloat( &intermissiontime ); + ArchiveEnum( intermissiontype, INTTYPE_e ); + arc.ArchiveInteger( &exitintermission ); + + arc.ArchiveInteger( &total_secrets ); + arc.ArchiveInteger( &found_secrets ); + + arc.ArchiveFloat( &earthquake_magnitude ); + arc.ArchiveInteger( &num_earthquakes ); + + for( int i = 0; i < num_earthquakes; i++ ) + { + arc.ArchiveInteger( &earthquakes[ i ].duration ); + arc.ArchiveFloat( &earthquakes[ i ].magnitude ); + arc.ArchiveBool( &earthquakes[ i ].no_rampup ); + arc.ArchiveBool( &earthquakes[ i ].no_rampdown ); + + arc.ArchiveInteger( &earthquakes[ i ].starttime ); + arc.ArchiveInteger( &earthquakes[ i ].endtime ); + + arc.ArchiveSafePointer( &earthquakes[ i ].m_Thread ); + } + + arc.ArchiveBoolean( &cinematic ); + arc.ArchiveBoolean( &ai_on ); + arc.ArchiveBoolean( &mission_failed ); + arc.ArchiveBoolean( &died_already ); + + arc.ArchiveVector( &water_color ); + arc.ArchiveVector( &lava_color ); + + arc.ArchiveFloat( &water_alpha ); + arc.ArchiveFloat( &lava_alpha ); + + arc.ArchiveString( ¤t_soundtrack ); + arc.ArchiveString( &saved_soundtrack ); + + arc.ArchiveVector( &m_fade_color ); + arc.ArchiveFloat( &m_fade_alpha ); + arc.ArchiveFloat( &m_fade_time ); + arc.ArchiveFloat( &m_fade_time_start ); + ArchiveEnum( m_fade_style, fadestyle_t ); + ArchiveEnum( m_fade_type, fadetype_t ); + + arc.ArchiveFloat( &m_letterbox_fraction ); + arc.ArchiveFloat( &m_letterbox_time ); + arc.ArchiveFloat( &m_letterbox_time_start ); + + ArchiveEnum( m_letterbox_dir, letterboxdir_t ); + arc.ArchiveInteger( &m_iCuriousVoiceTime ); + arc.ArchiveInteger( &m_iAttackEntryAnimTime ); + arc.ArchiveInteger( &mHealthPopCount ); + + arc.ArchiveBoolean( &m_bAlarm ); + arc.ArchiveBoolean( &mbNoDropHealth ); + arc.ArchiveInteger( &m_iPapersLevel ); + arc.ArchiveInteger( &m_LoopProtection ); + + memset( skel_index, 255, sizeof( skel_index ) ); + + if( arc.Loading() ) + { + str saved = saved_soundtrack; + ChangeSoundtrack( current_soundtrack ); + saved_soundtrack = saved; + + memset( &impact_trace, 0, sizeof( trace_t ) ); + } + + for( int i = 0; i < MAX_HEAD_SENTIENTS; i++ ) + { + arc.ArchiveObjectPointer( ( Class ** )&m_HeadSentient[ i ] ); + } + + // FIXME: Archive Actor::mBodyQueue + // FIXME: Archive Actor::mCurBody + + arc.ArchiveConfigString( CS_CURRENT_OBJECTIVE ); + + for( int i = CS_OBJECTIVES; i < CS_OBJECTIVES + MAX_OBJECTIVES; i++ ) + { + arc.ArchiveConfigString( i ); + } + + arc.ArchiveConfigString( CS_RAIN_DENSITY ); + arc.ArchiveConfigString( CS_RAIN_SPEED ); + arc.ArchiveConfigString( CS_RAIN_SPEEDVARY ); + arc.ArchiveConfigString( CS_RAIN_SLANT ); + arc.ArchiveConfigString( CS_RAIN_LENGTH ); + arc.ArchiveConfigString( CS_RAIN_MINDIST ); + arc.ArchiveConfigString( CS_RAIN_WIDTH ); + arc.ArchiveConfigString( CS_RAIN_SHADER ); + arc.ArchiveConfigString( CS_RAIN_NUMSHADERS ); +} + +void Level::Init( void ) +{ + m_HeadSentient[ 1 ] = NULL; + m_HeadSentient[ 0 ] = NULL; + + spawn_entnum = -1; + + current_map = NULL; + + framenum = 0; + time = 0; + frametime = 0; + + level_name = ""; + mapname = ""; + spawnpoint = ""; + nextmap = ""; + + total_secrets = 0; + found_secrets = 0; + + m_iCuriousVoiceTime = 0; + m_iAttackEntryAnimTime = 0; + + playerfrozen = false; + + intermissiontime = 0.0f; + exitintermission = 0; + + memset( &impact_trace, 0, sizeof( trace_t ) ); + + cinematic = false; + ai_on = true; + + near_exit = false; + mission_failed = false; + + m_bAlarm = false; + m_iPapersLevel = 0; + + died_already = false; + + water_color = vec_zero; + lava_color = vec_zero; + + lava_alpha = 0.0f; + water_alpha = 0.0f; + + saved_soundtrack = ""; + current_soundtrack = ""; + + automatic_cameras.ClearObjectList(); + + m_fade_time_start = 0.0f; + m_fade_time = -1.0f; + m_fade_color = vec_zero; + m_fade_style = additive; + + m_letterbox_dir = letterbox_out; + m_numArenas = 1; + + m_fade_alpha = 0; + + m_letterbox_fraction = 0; + m_letterbox_time_start = 0; + + m_voteTime = 0; + m_numVoters = 0; + + m_LoopProtection = true; + m_LoopDrop = true; + + m_letterbox_time = -1.0f; + + m_voteYes = 0; + m_voteNo = 0; + + m_vObjectiveLocation = vec_zero; + + svsEndTime = 0; + + earthquake_magnitude = 0; + + mHealthPopCount = 0; + mbNoDropHealth = false; + + spawning = false; + + m_bSpawnBot = false; + m_bScriptSpawn = false; + m_bRejectSpawn = false; +} + +gentity_t *Level::AllocEdict( Entity *entity ) +{ + int i; + gentity_t *edict; + + if( spawn_entnum >= 0 ) + { + edict = &g_entities[ spawn_entnum ]; + spawn_entnum = -1; + + assert( !edict->inuse && !edict->entity ); + + // free up the entity pointer in case we took one that still exists + if( edict->inuse && edict->entity ) + { + delete edict->entity; + } + } + else + { + edict = &g_entities[ game.maxclients ]; + + for( i = game.maxclients; i < globals.num_entities; i++, edict++ ) + { + // the first couple seconds of server time can involve a lot of + // freeing and allocating, so relax the replacement policy + if( + !edict->inuse && + ( + ( edict->freetime < 2.0f ) || + ( time - edict->freetime > 0.5f ) + ) + ) + { + break; + } + } + + // allow two spots for none and world + if( i == globals.max_entities - 2.0f ) + { + // Try one more time before failing, relax timing completely + + edict = &g_entities[ game.maxclients ]; + + for( i = game.maxclients; i < globals.num_entities; i++, edict++ ) + { + if( !edict->inuse ) + { + break; + } + } + + if( i == globals.max_entities - 2.0f ) + { + gi.Error( ERR_DROP, "Level::AllocEdict: no free edicts" ); + } + } + } + + LL_Remove( edict, next, prev ); + + InitEdict( edict ); + + LL_Add( &active_edicts, edict, next, prev ); + + // Tell the server about our data since we just spawned something + if( ( edict->s.number < ENTITYNUM_WORLD ) && ( globals.num_entities <= edict->s.number ) ) + { + globals.num_entities = edict->s.number + 1; + gi.LocateGameData( g_entities, globals.num_entities, sizeof( gentity_t ), &game.clients[ 0 ].ps, sizeof( game.clients[ 0 ] ) ); + } + + edict->entity = entity; + + return edict; +} + +void Level::FreeEdict( gentity_t *ed ) +{ + gclient_t *client; + + // unlink from world + gi.UnlinkEntity( ed ); + + LL_Remove( ed, next, prev ); + + client = ed->client; + + memset( ed, 0, sizeof( *ed ) ); + + ed->client = client; + ed->freetime = time; + ed->inuse = false; + ed->s.number = ed - g_entities; + + LL_Add( &free_edicts, ed, next, prev ); +} + +void Level::InitEdict( gentity_t *e ) +{ + int i; + + e->inuse = true; + + e->s.renderfx |= RF_FRAMELERP; + e->s.number = e - g_entities; + + // make sure a default scale gets set + e->s.scale = 1.0f; + // make sure the default constantlight gets set, initalize to r 1.0, g 1.0, b 1.0, r 0 + e->s.constantLight = 0xffffff; + + e->s.wasframe = 0; + e->spawntime = level.time; + + for( i = 0; i < NUM_BONE_CONTROLLERS; i++ ) + { + e->s.bone_tag[ i ] = -1; + VectorClear( e->s.bone_angles[ i ] ); + EulerToQuat( e->s.bone_angles[ i ], e->s.bone_quat[ i ] ); + } +} + +void Level::AddAutomaticCamera( Camera *cam ) +{ + automatic_cameras.AddUniqueObject( cam ); +} + +bool Level::PreSpawned( void ) +{ + return WaitTillDefined( "prespawn" ); +} + +bool Level::Spawned( void ) +{ + return WaitTillDefined( "spawn" ); +} + +void Level::AddEarthquake( earthquake_t *e ) +{ + if( num_earthquakes == MAX_EARTHQUAKES ) + { + if( earthquakes[ 0 ].m_Thread ) { + earthquakes[ 0 ].m_Thread->Wait( ( float )( e->endtime - inttime ) / 1000.0f - 0.5f ); + } + + num_earthquakes--; + + for( int i = 0; i < num_earthquakes; i++ ) + { + earthquakes[ i ] = earthquakes[ i + 1 ]; + } + } + + earthquakes[ num_earthquakes ] = *e; + num_earthquakes++; + + e->m_Thread->Pause(); +} + +void Level::DoEarthquakes( void ) +{ + int i, j; + earthquake_t *e; + int timedelta; + int rampuptime; + int rampdowntime; + float test_magnitude; + + if( num_earthquakes <= 0 ) { + return; + } + + earthquake_magnitude = 0.0f; + + for( i = num_earthquakes; i > 0; i-- ) + { + e = &earthquakes[ i - 1 ]; + + if( inttime >= e->endtime || !e->m_Thread ) + { + if( e->m_Thread ) { + e->m_Thread->Wait( 0 ); + } + + num_earthquakes--; + + for( j = 0; j < num_earthquakes; j++ ) + { + earthquakes[ j ] = earthquakes[ j + 1 ]; + } + } + else + { + test_magnitude = e->magnitude; + + timedelta = inttime - e->starttime; + + if( timedelta >= e->duration / 2 ) + { + rampdowntime = 2 * e->duration / 3 + e->starttime; + + if( !e->no_rampdown && inttime > rampdowntime ) + { + test_magnitude *= 1.0f - ( inttime - rampdowntime ) * 3.0f / e->duration; + } + } + else + { + rampuptime = e->duration / 3 + e->starttime; + + if( !e->no_rampup && inttime < rampuptime ) + { + test_magnitude *= ( inttime - e->starttime ) * 3.0f / e->duration; + } + } + + if( test_magnitude > earthquake_magnitude ) { + earthquake_magnitude = test_magnitude; + } + } + } +} + +void Level::CleanUp( qboolean samemap, qboolean resetConfigStrings ) +{ + DisableListenerNotify++; + + if( g_gametype->integer ) { + dmManager.Reset(); + } + + Director.Reset( samemap ); + + ClearCachedStatemaps(); + + assert( active_edicts.next ); + assert( active_edicts.next->prev == &active_edicts ); + assert( active_edicts.prev ); + assert( active_edicts.prev->next == &active_edicts ); + assert( free_edicts.next ); + assert( free_edicts.next->prev == &free_edicts ); + assert( free_edicts.prev ); + assert( free_edicts.prev->next == &free_edicts ); + + while( active_edicts.next != &active_edicts ) + { + assert( active_edicts.next != &free_edicts ); + assert( active_edicts.prev != &free_edicts ); + + assert( active_edicts.next ); + assert( active_edicts.next->prev == &active_edicts ); + assert( active_edicts.prev ); + assert( active_edicts.prev->next == &active_edicts ); + assert( free_edicts.next ); + assert( free_edicts.next->prev == &free_edicts ); + assert( free_edicts.prev ); + assert( free_edicts.prev->next == &free_edicts ); + + if( active_edicts.next->entity ) + { + delete active_edicts.next->entity; + } + else + { + FreeEdict( active_edicts.next ); + } + } + + cinematic = false; + ai_on = true; + near_exit = false; + + mission_failed = false; + died_already = false; + + globals.num_entities = game.maxclients + 1; + gi.LocateGameData( g_entities, game.maxclients + 1, sizeof( gentity_t ), &game.clients[ 0 ].ps, sizeof( gclient_t ) ); + + // clear up all AI node information + PathManager.ResetNodes(); + + // clear out automatic cameras + automatic_cameras.ClearObjectList(); + + // clear out level script variables + level.Vars()->ClearList(); + + // Clear out parm vars + parm.Vars()->ClearList(); + + // initialize the game variables + // these get restored by the persistant data, so we can safely clear them here + game.Vars()->ClearList(); + + // clearout any waiting events + L_ClearEventList(); + + // reset all edicts + ResetEdicts(); + + // reset all grenade hints + GrenadeHint::ResetHints(); + + // Reset the boss health cvar + gi.Cvar_Set( "bosshealth", "0" ); + + // FIXME: Actor::ResetBodyQueue(); + + if( world ) { + world->FreeTargetList(); + } + + num_earthquakes = 0; + + classinfo()->RemoveWaitTill( "prespawn" ); + classinfo()->RemoveWaitTill( "spawn" ); + classinfo()->RemoveWaitTill( "skip" ); + classinfo()->RemoveWaitTill( "postthink" ); + + if( g_gametype->integer >= GT_TEAM_ROUNDS ) + { + classinfo()->RemoveWaitTill( "roundstart" ); + classinfo()->RemoveWaitTill( "allieswin" ); + classinfo()->RemoveWaitTill( "axiswin" ); + classinfo()->RemoveWaitTill( "draw" ); + } + + if( resetConfigStrings ) + { + gi.SetConfigstring( CS_RAIN_DENSITY, "0" ); + gi.SetConfigstring( CS_RAIN_SPEED, "2048" ); + gi.SetConfigstring( CS_RAIN_SPEEDVARY, "512" ); + gi.SetConfigstring( CS_RAIN_SLANT, "50" ); + gi.SetConfigstring( CS_RAIN_LENGTH, "90" ); + gi.SetConfigstring( CS_RAIN_MINDIST, "512" ); + gi.SetConfigstring( CS_RAIN_WIDTH, "1" ); + gi.SetConfigstring( CS_RAIN_SHADER, "textures/rain" ); + gi.SetConfigstring( CS_RAIN_NUMSHADERS, "0" ); + gi.SetConfigstring( CS_CURRENT_OBJECTIVE, "" ); + + for( int i = CS_OBJECTIVES; i < CS_OBJECTIVES + MAX_OBJECTIVES; i++ ) + { + gi.SetConfigstring( i, "" ); + } + } + + DisableListenerNotify--; +} + +/* +============== +ResetEdicts +============== +*/ +void Level::ResetEdicts( void ) +{ + int i; + + memset( g_entities, 0, game.maxentities * sizeof( g_entities[ 0 ] ) ); + + // Add all the edicts to the free list + LL_Reset( &free_edicts, next, prev ); + LL_Reset( &active_edicts, next, prev ); + for( i = 0; i < game.maxentities; i++ ) + { + LL_Add( &free_edicts, &g_entities[ i ], next, prev ); + } + + for( i = 0; i < game.maxclients; i++ ) + { + // set client fields on player ents + g_entities[ i ].client = game.clients + i; + + G_InitClientPersistant( &game.clients[ i ] ); + } + + globals.num_entities = game.maxclients; +} + +qboolean Level::inhibitEntity( int spawnflags ) + +{ + if( !developer->integer && ( spawnflags & SPAWNFLAG_DEVELOPMENT ) ) + { + return qtrue; + } + + if( !detail->integer && ( spawnflags & SPAWNFLAG_DETAIL ) ) + { + return qtrue; + } + +#ifdef _CONSOLE + if( spawnflags & SPAWNFLAG_NOCONSOLE ) +#else + if( spawnflags & SPAWNFLAG_NOPC ) +#endif + { + return qtrue; + } + + if( g_gametype->integer ) + { + if( spawnflags & SPAWNFLAG_NOT_DEATHMATCH ) + { + return qtrue; + } + + return qfalse; + } + + switch( skill->integer ) + { + case 0: + return ( spawnflags & SPAWNFLAG_NOT_EASY ) != 0; + break; + + case 1: + return ( spawnflags & SPAWNFLAG_NOT_MEDIUM ) != 0; + break; + + case 2: + case 3: + return ( spawnflags & SPAWNFLAG_NOT_HARD ); + break; + } + + return qfalse; +} + +void Level::setSkill( int value ) +{ + int skill_level; + + skill_level = floor( ( float )value ); + skill_level = bound( skill_level, 0, 3 ); + + gi.Cvar_Set( "skill", va( "%d", skill_level ) ); +} + +void Level::setTime( int levelTime ) +{ + svsTime = levelTime; + inttime = levelTime - svsStartTime; + svsFloatTime = levelTime / 1000.0f; + time = inttime / 1000.0f; +} + +void Level::setFrametime( int frametime ) +{ + intframetime = frametime; + this->frametime = frametime / 1000.0f; +} + +void Level::SetMap( const char *themapname ) +{ + char *spawnpos; + int i; + str text; + + Init(); + + spawning = true; + + // set a specific spawnpoint if the map was started with a $ + spawnpos = strchr( ( char * )themapname, '$' ); + if( spawnpos ) + { + mapname = ( const char * )( spawnpos - themapname ); + spawnpoint = mapname; + } + else + { + mapname = themapname; + spawnpoint = ""; + } + + current_map = ( char * )themapname; + + level_name = mapname; + for( i = 0; i < level_name.length(); i++ ) + { + if( level_name[ i ] == '.' ) + { + level_name[ i ] = 0; + break; + } + } + + m_mapscript = "maps/" + level_name + ".scr"; + m_precachescript = "maps/" + level_name + "_precache.scr"; + m_pathfile = "maps/" + level_name + ".pth"; + m_mapfile = "maps/" + level_name + ".bsp"; +} + +void Level::LoadAllScripts( const char *name, const char *extension ) +{ + char **scriptFiles; + char filename[ MAX_QPATH ]; + int numScripts; + + scriptFiles = gi.FS_ListFiles( name, extension, qfalse, &numScripts ); + + if( !scriptFiles || !numScripts ) { + return; + } + + for( int i = 0; i < numScripts; i++ ) + { + Com_sprintf( filename, sizeof( filename ), "%s/%s", name, scriptFiles[ i ] ); + + // Compile the script + Director.GetScript( filename ); + } + + gi.FS_FreeFileList( scriptFiles ); +} + +void Level::Precache( void ) +{ + setTime( svsStartTime ); + setFrametime( 50 ); + + if( gi.FS_ReadFile( m_precachescript, NULL, qtrue ) != -1 ) + { + gi.DPrintf( "Adding script: '%s'\n", m_precachescript.c_str() ); + + // temporarily disable the loop protection + // because caching models require time + m_LoopProtection = false; + Director.ExecuteThread( m_precachescript ); + m_LoopProtection = true; + } + + if( !g_gametype->integer ) { + LoadAllScripts( "anim", ".scr" ); + } + + LoadAllScripts( "global", ".scr" ); +} + +void Level::SpawnEntities( char *entities, int svsTime ) +{ + int inhibit, simple = 0, count = 0; + int enttime; + const char *value; + SpawnArgs args; + Listener *listener; + Entity *ent; + + // Create the game variable list + game.CreateVars(); + + // Create the parm variable list + parm.CreateVars(); + + // Create the level variable list + CreateVars(); + + // set up time so functions still have valid times + setTime( svsTime ); + setFrametime( 50 ); + + setSkill( skill->integer ); + + // reset out count of the number of game traces + sv_numtraces = 0; + + // parse world + entities = args.Parse( entities ); + spawn_entnum = ENTITYNUM_WORLD; + args.SpawnInternal(); + + // parse ents + inhibit = 0; + enttime = gi.Milliseconds(); + + // Set up for a new map + PathManager.LoadNodes(); + + Com_Printf( "-------------------- Actual Spawning Entities -----------------------\n" ); + + for( entities = args.Parse( entities ); entities != NULL; entities = args.Parse( entities ) ) + { + // remove things (except the world) from different skill levels or deathmatch + spawnflags = 0; + value = args.getArg( "spawnflags" ); + + if( value ) + { + spawnflags = atoi( value ); + + if( inhibitEntity( spawnflags ) ) + { + inhibit++; + continue; + } + } + + listener = args.SpawnInternal(); + + if( listener ) + { + simple++; + + if( listener->isSubclassOf( Entity ) ) + { + count++; + + ent = ( Entity * )listener; + ent->radnum = simple; + + Q_strncpyz( ent->edict->entname, ent->getClassID(), sizeof( ent->edict->entname ) ); + } + } + } + + Com_Printf( "-------------------- Actual Spawning Entities Done ------------------ %i ms\n", gi.Milliseconds() - enttime ); + + world->UpdateConfigStrings(); + + Event *ev = new Event( EV_Level_PreSpawnSentient ); + PostEvent( ev, EV_SPAWNENTITIES ); + + L_ProcessPendingEvents(); + + if( g_gametype->integer ) { + dmManager.InitGame(); + } + + if( game.maxclients == 1 ) + { + spawn_entnum = 0; + new Player; + } + + m_LoopProtection = false; + AddWaitTill( STRING_PRESPAWN ); + Unregister( STRING_PRESPAWN ); + m_LoopProtection = true; + + Com_Printf( "%i entities spawned\n", count ); + Com_Printf( "%i simple entities spawned\n", simple ); + Com_Printf( "%i entities inhibited\n", inhibit ); + + Com_Printf( "-------------------- Spawning Entities Done ------------------ %i ms\n", gi.Milliseconds() - enttime ); +} + +void Level::PreSpawnSentient( Event *ev ) +{ + GameScript *script; + + // general initialization + FindTeams(); + + script = Director.GetScript( m_mapscript ); + if( script ) + { + gi.DPrintf( "Adding script: '%s'\n", m_mapscript.c_str() ); + + m_LoopProtection = false; + Director.ExecuteThread( m_mapscript ); + m_LoopProtection = true; + } + + PathManager.CreatePaths(); +} + +/* +================ +FindTeams + +Chain together all entities with a matching team field. +Entity teams are used for item groups and multi-entity mover groups. + +All but the first will have the FL_TEAMSLAVE flag set and teammaster field set +All but the last will have the teamchain field set to the next one +================ +*/ +void Level::FindTeams() +{ + gentity_t *ent, *ent2; + Entity *e, *e2; + int i, j; + int c, c2; + + c = 0; + c2 = 0; + for( i = 1, ent = g_entities + i; i < globals.num_entities; i++, ent++ ) + { + if( !ent->inuse ) + continue; + + e = ent->entity; + + if( !e->moveteam.length() ) + continue; + + if( e->flags & FL_TEAMSLAVE ) + continue; + + e->teammaster = e; + c++; + c2++; + + for( j = i + 1, ent2 = ent + 1; j < globals.num_entities; j++, ent2++ ) + { + if( !ent2->inuse ) + continue; + + e2 = ent->entity; + + if( !e2->moveteam.length() ) + continue; + + if( e2->flags & FL_TEAMSLAVE ) + continue; + + if( !strcmp( e->moveteam, e2->moveteam ) ) + { + c2++; + e2->teamchain = e->teamchain; + e->teamchain = e2; + e2->teammaster = e; + e2->flags |= FL_TEAMSLAVE; + + // make sure that targets only point at the master + if( e2->targetname ) { + e->targetname = e2->targetname; + e2->targetname = NULL; + } + } + } + } + + G_Printf( "%i teams with %i entities\n", c, c2 ); +} + +void Level::ServerSpawned( void ) +{ + int i; + gclient_t *client; + gentity_t *ent; + + for( i = 0, client = game.clients; i < game.maxclients; i++, client++ ) + { + client->ps.commandTime = svsTime; + } + + if( !WaitTillDisabled( STRING_SPAWN ) ) + { + AddWaitTill( STRING_SPAWN ); + + Director.iPaused++; + + for( ent = active_edicts.next; ent != &active_edicts; ent = ent->next ) + { + ent->entity->Unregister( STRING_SPAWN ); + } + + if( Director.iPaused-- == 1 ) { + Director.ExecuteRunning(); + } + + Unregister( STRING_SPAWN ); + } + else + { + Director.LoadMenus(); + } + + spawning = false; +} + +void Level::CheckVote + ( + void + ) + +{ + // FIXME: show the vote HUD like in SH and BT + + if( !m_voteTime ) + return; + + if( time - m_voteTime >= 30000.0f ) + { + dmManager.PrintAllClients( "Vote failed.\n" ); + m_voteTime = 0; + return; + } + + if( m_voteYes > m_numVoters / 2 ) + { + dmManager.PrintAllClients( "Vote passed.\n" ); + + // Pass arguments to console + gi.SendConsoleCommand( va( "%s", level.m_voteString.c_str() ) ); + m_voteTime = 0; + return; + } + + if( m_voteNo >= m_numVoters / 2 ) + { + dmManager.PrintAllClients( "Vote failed.\n" ); + m_voteTime = 0; + return; + } +} + +void Level::GetTime + ( + Event *ev + ) + +{ + ev->AddFloat( level.time ); +} + +void Level::GetTotalSecrets + ( + Event *ev + ) + +{ + ev->AddInteger( total_secrets ); +} + +void Level::GetFoundSecrets + ( + Event *ev + ) + +{ + ev->AddInteger( found_secrets ); +} + +void Level::GetAlarm + ( + Event *ev + ) + +{ + ev->AddInteger( m_bAlarm ); +} + +void Level::SetAlarm + ( + Event *ev + ) + +{ + m_bAlarm = ev->GetInteger( 1 ); +} + +void Level::SetNoDropHealth + ( + Event *ev + ) + +{ + mbNoDropHealth = ev->GetInteger( 1 ); +} + +void Level::GetLoopProtection + ( + Event *ev + ) + +{ + ev->AddInteger( m_LoopProtection ); +} + +void Level::SetLoopProtection + ( + Event *ev + ) + +{ + m_LoopProtection = ev->GetInteger( 1 ); +} + +void Level::GetPapersLevel + ( + Event *ev + ) + +{ + ev->AddInteger( m_iPapersLevel ); +} + +void Level::SetPapersLevel + ( + Event *ev + ) + +{ + m_iPapersLevel = ev->GetInteger( 1 ); +} + +void Level::EventGetDMRespawning + ( + Event *ev + ) + +{ + ev->AddInteger( dmManager.GameAllowsRespawns() ); +} + +void Level::EventSetDMRespawning + ( + Event *ev + ) + +{ + dmManager.SetGameAllowsRespawns( ev->GetBoolean( 1 ) ); +} + +void Level::EventGetDMRoundLimit + ( + Event *ev + ) + +{ + ev->AddInteger( dmManager.GetRoundLimit() ); +} + +void Level::EventSetDMRoundLimit + ( + Event *ev + ) + +{ + int round_limit = ev->GetInteger( 1 ); + + if( round_limit < 0 ) + { + ScriptError( "round limit must be greater than 0" ); + } + + dmManager.SetDefaultRoundLimit( round_limit ); +} + +void Level::EventGetClockSide + ( + Event *ev + ) + +{ + ev->AddConstString( dmManager.GetClockSide() ); +} + +void Level::EventSetClockSide + ( + Event *ev + ) + +{ + const_str clockside = ev->GetConstString( 1 ); + + if( clockside < STRING_ALLIES || clockside > STRING_DRAW ) + { + ScriptError( "clockside must be 'axis', 'allies', 'kills', or 'draw'" ); + } + + dmManager.SetClockSide( clockside ); +} + +void Level::EventGetBombPlantTeam + ( + Event *ev + ) + +{ + ev->AddConstString( dmManager.GetBombPlantTeam() ); +} + +void Level::EventSetBombPlantTeam + ( + Event *ev + ) + +{ + const_str plant_team = ev->GetConstString( 1 ); + + if( plant_team < STRING_ALLIES || plant_team > STRING_AXIS ) + { + ScriptError( "bombplantteam must be 'axis' or 'allies'" ); + } + + dmManager.SetBombPlantTeam( plant_team ); +} + +void Level::EventGetTargetsToDestroy + ( + Event *ev + ) + +{ + ev->AddInteger( dmManager.GetTargetsToDestroy() ); +} + +void Level::EventSetTargetsToDestroy + ( + Event *ev + ) + +{ + dmManager.SetTargetsToDestroy( ev->GetInteger( 1 ) ); +} + +void Level::EventGetTargetsDestroyed + ( + Event *ev + ) + +{ + ev->AddInteger( dmManager.GetTargetsDestroyed() ); +} + +void Level::EventSetTargetsDestroyed + ( + Event *ev + ) + +{ + dmManager.SetTargetsDestroyed( ev->GetInteger( 1 ) ); +} + +void Level::EventGetBombsPlanted + ( + Event *ev + ) + +{ + ev->AddInteger( dmManager.GetBombsPlanted() ); +} + +void Level::EventSetBombsPlanted + ( + Event *ev + ) + +{ + dmManager.SetBombsPlanted( ev->GetInteger( 1 ) ); +} + +void Level::EventGetRoundBased + ( + Event *ev + ) + +{ + ev->AddInteger( g_gametype->integer >= GT_TEAM_ROUNDS ); +} + +void Level::EventRainDensitySet + ( + Event *ev + ) + +{ + gi.SetConfigstring( CS_RAIN_DENSITY, ev->GetString( 1 ) ); +} + +void Level::EventRainDensityGet + ( + Event *ev + ) + +{ + ev->AddString( gi.GetConfigstring( CS_RAIN_DENSITY ) ); +} + +void Level::EventRainSpeedSet + ( + Event *ev + ) + +{ + gi.SetConfigstring( CS_RAIN_SPEED, ev->GetString( 1 ) ); +} + +void Level::EventRainSpeedGet + ( + Event *ev + ) + +{ + ev->AddString( gi.GetConfigstring( CS_RAIN_SPEED ) ); +} + +void Level::EventRainSpeedVarySet + ( + Event *ev + ) + +{ + gi.SetConfigstring( CS_RAIN_SPEEDVARY, ev->GetString( 1 ) ); +} + +void Level::EventRainSpeedVaryGet + ( + Event *ev + ) + +{ + ev->AddString( gi.GetConfigstring( CS_RAIN_SPEEDVARY ) ); +} + +void Level::EventRainSlantSet + ( + Event *ev + ) + +{ + gi.SetConfigstring( CS_RAIN_SLANT, ev->GetString( 1 ) ); +} + +void Level::EventRainSlantGet + ( + Event *ev + ) + +{ + ev->AddString( gi.GetConfigstring( CS_RAIN_SLANT ) ); +} + +void Level::EventRainLengthSet + ( + Event *ev + ) + +{ + gi.SetConfigstring( CS_RAIN_LENGTH, ev->GetString( 1 ) ); +} + +void Level::EventRainLengthGet + ( + Event *ev + ) + +{ + ev->AddString( gi.GetConfigstring( CS_RAIN_LENGTH ) ); +} + +void Level::EventRainMin_DistSet + ( + Event *ev + ) + +{ + gi.SetConfigstring( CS_RAIN_MINDIST, ev->GetString( 1 ) ); +} + +void Level::EventRainMin_DistGet + ( + Event *ev + ) + +{ + ev->AddString( gi.GetConfigstring( CS_RAIN_MINDIST ) ); +} + +void Level::EventRainWidthSet + ( + Event *ev + ) + +{ + gi.SetConfigstring( CS_RAIN_WIDTH, ev->GetString( 1 ) ); +} + +void Level::EventRainWidthGet + ( + Event *ev + ) + +{ + ev->AddString( gi.GetConfigstring( CS_RAIN_WIDTH ) ); +} + +void Level::EventRainShaderSet + ( + Event *ev + ) + +{ + gi.SetConfigstring( CS_RAIN_SHADER, ev->GetString( 1 ) ); +} + +void Level::EventRainShaderGet + ( + Event *ev + ) + +{ + ev->AddString( gi.GetConfigstring( CS_RAIN_SHADER ) ); +} + +void Level::EventRainNumShadersSet + ( + Event *ev + ) + +{ + gi.SetConfigstring( CS_RAIN_NUMSHADERS, ev->GetString( 1 ) ); +} + +void Level::EventRainNumShadersGet + ( + Event *ev + ) + +{ + ev->AddString( gi.GetConfigstring( CS_RAIN_NUMSHADERS ) ); +} + +void Level::EventGetFlags + ( + Event *ev + ) + +{ +} + +CLASS_DECLARATION( Listener, Level, NULL ) +{ + { &EV_Level_GetTime, &Level::GetTime }, + { &EV_Level_GetTotalSecrets, &Level::GetTotalSecrets }, + { &EV_Level_GetFoundSecrets, &Level::GetFoundSecrets }, + { &EV_Level_PreSpawnSentient, &Level::PreSpawnSentient }, + { &EV_Level_GetAlarm, &Level::GetAlarm }, + { &EV_Level_SetAlarm, &Level::SetAlarm }, + { &EV_Level_SetNoDropHealth, &Level::SetNoDropHealth }, + { &EV_Level_GetLoopProtection, &Level::GetLoopProtection }, + { &EV_Level_SetLoopProtection, &Level::SetLoopProtection }, + { &EV_Level_GetPapersLevel, &Level::GetPapersLevel }, + { &EV_Level_SetPapersLevel, &Level::SetPapersLevel }, + { &EV_Level_GetDMRespawning, &Level::EventGetDMRespawning }, + { &EV_Level_SetDMRespawning, &Level::EventSetDMRespawning }, + { &EV_Level_SetDMRespawning2, &Level::EventSetDMRespawning }, + { &EV_Level_GetDMRoundLimit, &Level::EventGetDMRoundLimit }, + { &EV_Level_SetDMRoundLimit, &Level::EventSetDMRoundLimit }, + { &EV_Level_SetDMRoundLimit2, &Level::EventSetDMRoundLimit }, + { &EV_Level_GetClockSide, &Level::EventGetClockSide }, + { &EV_Level_SetClockSide, &Level::EventSetClockSide }, + { &EV_Level_SetClockSide2, &Level::EventSetClockSide }, + { &EV_Level_GetBombPlantTeam, &Level::EventGetBombPlantTeam }, + { &EV_Level_SetBombPlantTeam, &Level::EventSetBombPlantTeam }, + { &EV_Level_SetBombPlantTeam2, &Level::EventSetBombPlantTeam }, + { &EV_Level_GetTargetsToDestroy, &Level::EventGetTargetsToDestroy }, + { &EV_Level_SetTargetsToDestroy, &Level::EventSetTargetsToDestroy }, + { &EV_Level_SetTargetsToDestroy2, &Level::EventSetTargetsToDestroy }, + { &EV_Level_GetTargetsDestroyed, &Level::EventGetTargetsDestroyed }, + { &EV_Level_SetTargetsDestroyed, &Level::EventSetTargetsDestroyed }, + { &EV_Level_SetTargetsDestroyed2, &Level::EventSetTargetsDestroyed }, + { &EV_Level_GetBombsPlanted, &Level::EventGetBombsPlanted }, + { &EV_Level_SetBombsPlanted, &Level::EventSetBombsPlanted }, + { &EV_Level_SetBombsPlanted2, &Level::EventSetBombsPlanted }, + { &EV_Level_GetRoundBased, &Level::EventGetRoundBased }, + { &EV_Level_Rain_Density_Set, &Level::EventRainDensitySet }, + { &EV_Level_Rain_Density_Get, &Level::EventRainDensityGet }, + { &EV_Level_Rain_Speed_Set, &Level::EventRainSpeedSet }, + { &EV_Level_Rain_Speed_Get, &Level::EventRainSpeedGet }, + { &EV_Level_Rain_Speed_Vary_Set, &Level::EventRainSpeedVarySet }, + { &EV_Level_Rain_Speed_Vary_Get, &Level::EventRainSpeedVaryGet }, + { &EV_Level_Rain_Slant_Set, &Level::EventRainSlantSet }, + { &EV_Level_Rain_Slant_Get, &Level::EventRainSlantGet }, + { &EV_Level_Rain_Length_Set, &Level::EventRainLengthSet }, + { &EV_Level_Rain_Length_Get, &Level::EventRainLengthGet }, + { &EV_Level_Rain_Min_Dist_Set, &Level::EventRainMin_DistSet }, + { &EV_Level_Rain_Min_Dist_Get, &Level::EventRainMin_DistGet }, + { &EV_Level_Rain_Width_Set, &Level::EventRainWidthSet }, + { &EV_Level_Rain_Width_Get, &Level::EventRainWidthGet }, + { &EV_Level_Rain_Shader_Set, &Level::EventRainShaderSet }, + { &EV_Level_Rain_Shader_Get, &Level::EventRainShaderGet }, + { &EV_Level_Rain_NumShaders_Set, &Level::EventRainShaderSet }, + { &EV_Level_Rain_NumShaders_Get, &Level::EventRainShaderGet }, + { &EV_Level_GetFlags, &Level::EventGetFlags }, + { NULL, NULL } +}; diff --git a/code/game/level.h b/code/game/level.h new file mode 100644 index 00000000..81ff927b --- /dev/null +++ b/code/game/level.h @@ -0,0 +1,294 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// level.h: General Level Info + +#ifndef __LEVEL_H__ +#define __LEVEL_H__ + +#include "listener.h" + +#define MAX_HEAD_SENTIENTS 2 +#define MAX_EARTHQUAKES 10 + +enum INTTYPE_e { TRANS_BSP, TRANS_LEVEL, TRANS_MISSION, TRANS_MISSION_FAILED }; +enum fadetype_t { fadein, fadeout }; +enum fadestyle_t { alphablend, additive }; +enum letterboxdir_t { letterbox_in, letterbox_out }; + +typedef struct earthquake_s { + int duration; + float magnitude; + bool no_rampup; + bool no_rampdown; + + int starttime; + int endtime; + SafePtr< ScriptThread > m_Thread; +} earthquake_t; + +extern gclient_t *spawn_client; + +class Camera; +class SimpleArchivedEntity; + +class Level : public Listener +{ +public: + char *current_map; + + int mHealthPopCount; + + // Map name stuff + str m_mapscript; + str m_precachescript; + str m_pathfile; + str m_mapfile; + + // Spawning variables + int spawn_entnum; + int spawnflags; + + // Level time + int framenum; + int inttime; + int intframetime; + + float time; + float frametime; + + // Server time + int svsTime; + float svsFloatTime; + int svsStartTime; + int svsEndTime; + + // Level name variables + str level_name; + str mapname; + str spawnpoint; + str nextmap; + + // AI variables + int m_iCuriousVoiceTime; + int m_iAttackEntryAnimTime; + + // Global players variables + qboolean playerfrozen; + + // Intermission variables + float intermissiontime; + INTTYPE_e intermissiontype; + int exitintermission; + + // Secrets + int total_secrets; + int found_secrets; + + // Trace + trace_t impact_trace; + + // Earthquake stuff + float earthquake_magnitude; + + // Cinematic + qboolean cinematic; + + // AI variables + qboolean ai_on; + qboolean m_bAlarm; + qboolean mbNoDropHealth; + int m_iPapersLevel; + + // Mission state + qboolean mission_failed; + qboolean died_already; + qboolean near_exit; + + // Water variables + Vector water_color; + Vector lava_color; + float water_alpha; + float lava_alpha; + + // Soundtrack variables + str current_soundtrack; + str saved_soundtrack; + + // Screen state + Vector m_fade_color; + float m_fade_alpha; + float m_fade_time; + float m_fade_time_start; + fadetype_t m_fade_type; + fadestyle_t m_fade_style; + + // Letterbox state + float m_letterbox_fraction; + float m_letterbox_time; + float m_letterbox_time_start; + letterboxdir_t m_letterbox_dir; + + Container automatic_cameras; + + // Quake remnants ? + int m_numArenas; + + // Voting variables + float m_voteTime; + int m_voteYes; + int m_voteNo; + int m_numVoters; + str m_voteString; + + // Intermission locations + Vector m_intermission_origin; + Vector m_intermission_angle; + + // Skeleton variables + int frame_skel_index; + int skel_index[ MAX_GENTITIES ]; + + // script variables + qboolean m_LoopProtection; + qboolean m_LoopDrop; // kill the server in loop exception + + Container m_SimpleArchivedEntities; + class Sentient *m_HeadSentient[ MAX_HEAD_SENTIENTS ]; + + // Earthquake stuff + earthquake_t earthquakes[ MAX_EARTHQUAKES ]; + int num_earthquakes; + + // Objective stuff + Vector m_vObjectiveLocation; + + // Current level state + bool spawning; + + // New Stuff + + // don't put in the game class because it can be changed in another level + qboolean reborn; + + bool m_bSpawnBot; + + // Script stuff + bool m_bScriptSpawn; + bool m_bRejectSpawn; + +public: + CLASS_PROTOTYPE( Level ); + + Level(); + virtual ~Level(); + + void Init(); + void CleanUp( qboolean samemap = qfalse, qboolean resetConfigStrings = qfalse ); + void ResetEdicts(); + gentity_t *AllocEdict( Entity *ent ); + void FreeEdict( gentity_t *ent ); + void InitEdict( gentity_t *ent ); + void LoadAllScripts( const char *name, const char *extension ); + void Precache(); + void SetMap( const char *themapname ); + void FindTeams(); + void SpawnEntities( char *entities, int _svsTime_ ); + void PreSpawnSentient( Event *ev ); + void ServerSpawned(); + qboolean inhibitEntity( int spawnflags ); + void setSkill( int value ); + void setTime( int _svsTime_ ); + void setFrametime( int frameTime ); + void AddAutomaticCamera( Camera *cam ); + void GetTime( Event *ev ); + void GetTotalSecrets( Event *ev ); + void GetFoundSecrets( Event *ev ); + void CheckVote(); + void GetAlarm( Event *ev ); + void SetAlarm( Event *ev ); + void SetNoDropHealth( Event *ev ); + void GetLoopProtection( Event *ev ); + void SetLoopProtection( Event *ev ); + void GetPapersLevel( Event *ev ); + void SetPapersLevel( Event *ev ); + void EventGetDMRespawning( Event *ev ); + void EventSetDMRespawning( Event *ev ); + void EventGetDMRoundLimit( Event *ev ); + void EventSetDMRoundLimit( Event *ev ); + void EventGetClockSide( Event *ev ); + void EventSetClockSide( Event *ev ); + void EventGetBombPlantTeam( Event *ev ); + void EventSetBombPlantTeam( Event *ev ); + void EventGetTargetsToDestroy( Event *ev ); + void EventSetTargetsToDestroy( Event *ev ); + void EventGetTargetsDestroyed( Event *ev ); + void EventSetTargetsDestroyed( Event *ev ); + void EventGetBombsPlanted( Event *ev ); + void EventSetBombsPlanted( Event *ev ); + void EventGetRoundBased( Event *ev ); + void EventRainDensitySet( Event *ev ); + void EventRainDensityGet( Event *ev ); + void EventRainSpeedSet( Event *ev ); + void EventRainSpeedGet( Event *ev ); + void EventRainSpeedVarySet( Event *ev ); + void EventRainSpeedVaryGet( Event *ev ); + void EventRainSlantSet( Event *ev ); + void EventRainSlantGet( Event *ev ); + void EventRainLengthSet( Event *ev ); + void EventRainLengthGet( Event *ev ); + void EventRainMin_DistSet( Event *ev ); + void EventRainMin_DistGet( Event *ev ); + void EventRainWidthSet( Event *ev ); + void EventRainWidthGet( Event *ev ); + void EventRainShaderSet( Event *ev ); + void EventRainShaderGet( Event *ev ); + void EventRainNumShadersSet( Event *ev ); + void EventRainNumShadersGet( Event *ev ); + void EventGetFlags( Event *ev ); + str GetRandomHeadModel( const char *model ); + str GetRandomHeadSkin( const char *model ); + + bool PreSpawned( void ); + bool Spawned( void ); + + void AddEarthquake( earthquake_t * ); + void DoEarthquakes( void ); + + qboolean Reborn( void ); + + virtual void Archive( Archiver& arc ); +}; + +extern Level level; + +inline +qboolean Level::Reborn + ( + void + ) + +{ + return reborn; +} + +#endif diff --git a/code/game/light.cpp b/code/game/light.cpp new file mode 100644 index 00000000..71eaa67f --- /dev/null +++ b/code/game/light.cpp @@ -0,0 +1,152 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// light.cpp: Classes for creating and controlling lights. +// + +#include "g_local.h" +#include "entity.h" +#include "trigger.h" +#include "light.h" +#include "scriptmaster.h" + +/*****************************************************************************/ +/*QUAKED light (0.75 0.5 0) (-8 -8 -8) (8 8 8) LINEAR NO_ENTITIES ENTITY_TRACE + +Non-displayed light. If it targets another entity it will become a spot light +if "LINEAR" is set, it will be a linear light +if "NO_ENTITIES" is set, this light will only effect the world, not entities +if "ENTITY_TRACE" is set, a trace is done betwee the light and the entity.\ +The light is only added if the trace is clear + +"no_entity_light" - this light will not effect entities, just the world +"light" - the intensity of the light, default 300 +"color" - the color of the light +"falloff" - if linear, specify the linear falloff (defaults to 1) +"radius" - make this a spot light of the given radius +"angles" - make this a spot light centered on angles +"spot_angle" - if this is a spot light, what angle to use (default 45) +"entity_trace" - trace between the entity and the light + +******************************************************************************/ + +Event EV_Light_SetLight + ( + "light", + EV_DEFAULT, + NULL, + NULL, + "Set the intensity of the light", + EV_NORMAL + ); + +Event EV_Light_SetColor + ( + "color", + EV_DEFAULT, + NULL, + NULL, + "", + EV_NORMAL + ); + +Event EV_Light_SetFalloff + ( + "falloff", + EV_CODEONLY, + NULL, + NULL, + "", + EV_NORMAL + ); + +Event EV_Light_SetRadius + ( + "falloff", + EV_CODEONLY, + NULL, + NULL, + "", + EV_NORMAL + ); + +Event EV_Light_SpotDir + ( + "spot_dir", + EV_CODEONLY, + NULL, + NULL, + "", + EV_NORMAL + ); + +Event EV_Light_SpotRadiusByDistance + ( + "spot_radiusbydistance", + EV_CODEONLY, + NULL, + NULL, + "", + EV_NORMAL + ); + +Event EV_Light_NoEntityLight + ( + "no_entity_light", + EV_CODEONLY, + NULL, + NULL, + "", + EV_NORMAL + ); + +Event EV_Light_EntityTrace + ( + "entity_trace", + EV_CODEONLY, + NULL, + NULL, + "", + EV_NORMAL + ); + +Event EV_Light_SpotAngle + ( + "spot_angle", + EV_CODEONLY, + NULL, + NULL, + "", + EV_NORMAL + ); + +CLASS_DECLARATION( Entity, Light, "light" ) + { + { &EV_Light_SetLight, NULL }, + { NULL, NULL } + }; + +Light::Light() + { + PostEvent( EV_Remove, 0 ); + } + diff --git a/code/game/light.h b/code/game/light.h new file mode 100644 index 00000000..9bbcaa66 --- /dev/null +++ b/code/game/light.h @@ -0,0 +1,40 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// light.h: Classes for creating and controlling lights. +// + +#ifndef __LIGHT_H__ +#define __LIGHT_H__ + +#include "g_local.h" +#include "entity.h" + +class Light : public Entity + { + public: + CLASS_PROTOTYPE( Light ); + + Light(); + }; + +#endif /* light.h */ diff --git a/code/game/lodthing.cpp b/code/game/lodthing.cpp new file mode 100644 index 00000000..ee18b9ec --- /dev/null +++ b/code/game/lodthing.cpp @@ -0,0 +1,299 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// lodthing.cpp : Level of detail manager + +#include "lodthing.h" +#include "player.h" + +Event EV_LODTool_Spawn +( + "lod_spawn", + EV_CONSOLE, + "s", + "model", + "Edit LOD on the specified model" +); +Event EV_LODTool_Think +( + "lod_think", + EV_DEFAULT, + NULL, + NULL, + "Called every frame to process the view thing." +); +Event EV_LODTool_SetModel +( + "lod_model", + EV_DEFAULT, + NULL, + NULL, + "Set the model of the current viewthing" +); +Event EV_LODTool_SetYaw +( + "lod_yaw", + EV_CONSOLE, + "f", + "yaw", + "Set the yaw of the model" +); +Event EV_LODTool_SetRoll +( + "lod_roll", + EV_CONSOLE, + "f", + "roll", + "Set the roll of the model" +); +Event EV_LODTool_SetAngles +( + "lod_angles", + EV_CONSOLE, + "f[0,360]f[0,360]f[0,360]", + "pitch yaw roll", + "Set the angles of the model" +); +Event EV_LODTool_Discard +( + "lod_discard", + EV_CONSOLE, + NULL, + NULL, + "Discard LOD changes" +); + +LODMaster LODModel; + +CLASS_DECLARATION( Listener, LODMaster, "lodmaster" ) +{ + { &EV_LODTool_Spawn, &LODMaster::Spawn }, + { &EV_LODTool_SetYaw, &LODMaster::PassEvent }, + { &EV_LODTool_SetRoll, &LODMaster::PassEvent }, + { &EV_LODTool_SetAngles, &LODMaster::PassEvent }, + { &EV_LODTool_Discard, &LODMaster::PassEvent }, + { NULL, NULL } +}; + +void LODMaster::Init + ( + void + ) + +{ + gi.AddCommand( "lod_spawn", NULL ); + gi.AddCommand( "lod_yaw", NULL ); + gi.AddCommand( "lod_pitch", NULL ); + gi.AddCommand( "lod_roll", NULL ); + gi.AddCommand( "lod_angles", NULL ); + gi.AddCommand( "lod_discard", NULL ); +} + +void LODMaster::Spawn + ( + Event *ev + ) + +{ + const char *mdl; + Vector forward, up, delta; + Entity *ent; + LODSlave *m_lodmodel; + + mdl = ev->GetString( 1 ); + + if( !mdl || !*mdl ) + { + ScriptError( "Must specify a model name" ); + } + + gi.Cvar_Set( "lod_tikiname", mdl ); + gi.Cvar_Set( "lod_tool", "1" ); + + ent = g_entities->entity; + + if( ent->IsSubclassOfPlayer() ) + { + ( ( Player* )ent )->SetFov( 80 ); + ent->setOriginEvent( Vector( 2000, 0, 0 ) ); + } + + if( m_current ) + { + m_current->PostEvent( EV_Remove, 0 ); + } + + m_lodmodel = new LODSlave; + m_current = m_lodmodel; + + ent->angles.AngleVectorsLeft( &forward, NULL, &up ); + + m_lodmodel->m_baseorigin = Vector( -1600, 0, 0 ); + m_lodmodel->setOrigin( m_lodmodel->m_baseorigin ); + m_lodmodel->m_baseorigin = m_lodmodel->origin; + + delta = Vector( "1 0 0" ); + delta.toAngles(); + + m_lodmodel->setAngles( delta ); + m_lodmodel->setScale( 1.0f ); + + Event *event = new Event( EV_LODTool_SetModel ); + + event->AddString( mdl ); + m_lodmodel->ProcessEvent( event ); + + if( !m_lodmodel->edict->tiki ) + { + m_current = NULL; + + ScriptError( "Error in model '%s', LOD model not spawned.", mdl ); + } + + for( int i = 0; i < MAX_FRAMEINFOS; i++ ) + { + m_lodmodel->Pause( i ); + } + + gi.SendConsoleCommand( "cg_drawvidemodel 0\n" ); + gi.SendConsoleCommand( "cg_shadows 0\n" ); + gi.SendConsoleCommand( "ui_compass 0\n" ); + gi.SendConsoleCommand( "r_fastsky 1\n" ); + gi.SendConsoleCommand( "r_drawworld 0\n" ); +} + +void LODMaster::PassEvent + ( + Event *ev + ) + +{ + if( !m_current ) + { + ScriptError( "No LOD Model" ); + } + + Event *event = new Event( ev ); + m_current->ProcessEvent( event ); +} + +CLASS_DECLARATION( Animate, LODSlave, "lodslave" ) +{ + { &EV_LODTool_Think, &LODSlave::ThinkEvent }, + { &EV_LODTool_SetModel, &LODSlave::SetModelEvent }, + { &EV_LODTool_Discard, &LODSlave::Delete }, + { NULL, NULL } +}; + +void LODSlave::UpdateCvars + ( + qboolean quiet, + qboolean updateFrame + ) + +{ + +} + +LODSlave::LODSlave + ( + void + ) + +{ + m_baseorigin = origin; + LODModel.m_current = this; + + edict->s.eType = ET_MODELANIM_SKEL; + edict->s.renderfx |= RF_SHADOW; + edict->s.renderfx |= RF_ADDITIVE_DLIGHT; + + PostEvent( EV_LODTool_Think, level.frametime ); +} + +static float lod_yaw = 0.0f; + +void LODSlave::ThinkEvent + ( + Event *ev + ) + +{ + cvar_t *cvar; + Entity *ent; + Vector position; + + PostEvent( EV_LODTool_Think, level.frametime ); + + lod_yaw += 2.0f; + if( lod_yaw > 180.0f ) { + lod_yaw = lod_yaw - 360.0f; + } + + cvar = gi.Cvar_Get( "lod_pitch_val", "", 0 ); + + angles[ 0 ] = cvar->value; + angles[ 1 ] = lod_yaw; + + setAngles( angles ); + + ent = g_entities->entity; + if( ent->IsSubclassOfPlayer() ) + { + ( ( Player * )ent )->SetFov( 80.0 ); + ent->setOrigin( Vector( -4000, 0, 0 ) ); + } + + cvar = gi.Cvar_Get( "lod_position", "", 0 ); + sscanf( cvar->string, "%f %f %f", &position[ 0 ], &position[ 1 ], &position[ 2 ] ); + + cvar = gi.Cvar_Get( "lod_zee_val", "", 0 ); + position[ 2 ] -= cvar->value; + + setOrigin( position ); +} + +void LODSlave::SetModelEvent + ( + Event *ev + ) + +{ + str modelname = ev->GetString( 1 ); + + setModel( modelname ); + + if( edict->tiki ) + { + NewAnim( "idle" ); + SetFrame(); + } +} + +void LODSlave::Delete + ( + Event *ev + ) + +{ + ScriptError( "DELETE" ); +} diff --git a/code/game/lodthing.h b/code/game/lodthing.h new file mode 100644 index 00000000..16d2093f --- /dev/null +++ b/code/game/lodthing.h @@ -0,0 +1,80 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// lodthing.cpp : Level of detail manager + +#include "animate.h" + +class LODMaster : public Listener { +public: + CLASS_PROTOTYPE( LODMaster ); + + SafePtr< Entity > m_current; + + void Init( void ); + void Spawn( Event *ev ); + void PassEvent( Event *ev ); + + virtual void Archive( Archiver& arc ); +}; + +inline void LODMaster::Archive + ( + Archiver& arc + ) + +{ + Listener::Archive( arc ); + + arc.ArchiveSafePointer( &m_current ); +} + +class LODSlave : public Animate { +public: + CLASS_PROTOTYPE( LODSlave ); + + Vector m_baseorigin; + float m_scale; + + LODSlave(); + + void UpdateCvars( qboolean quiet, qboolean updateFrame ); + void ThinkEvent( Event *ev ); + void SetModelEvent( Event *ev ); + void Delete( Event *ev ); + + virtual void Archive( Archiver& arc ); +}; + +inline void LODSlave::Archive + ( + Archiver& arc + ) + +{ + Animate::Archive( arc ); + + arc.ArchiveVector( &m_baseorigin ); + arc.ArchiveFloat( &m_scale ); +} + +extern LODMaster LODModel; diff --git a/code/game/match.h b/code/game/match.h new file mode 100644 index 00000000..a29d8fa6 --- /dev/null +++ b/code/game/match.h @@ -0,0 +1,134 @@ +/* +=========================================================================== +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 Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// make sure this is the same character as we use in chats in g_cmd.c +#define EC "\x19" + +//match template contexts +#define MTCONTEXT_MISC 2 +#define MTCONTEXT_INITIALTEAMCHAT 4 +#define MTCONTEXT_TIME 8 +#define MTCONTEXT_TEAMMATE 16 +#define MTCONTEXT_ADDRESSEE 32 +#define MTCONTEXT_PATROLKEYAREA 64 +#define MTCONTEXT_REPLYCHAT 128 +#define MTCONTEXT_CTF 256 + +//message types +#define MSG_NEWLEADER 1 //new leader +#define MSG_ENTERGAME 2 //enter game message +#define MSG_HELP 3 //help someone +#define MSG_ACCOMPANY 4 //accompany someone +#define MSG_DEFENDKEYAREA 5 //defend a key area +#define MSG_RUSHBASE 6 //everyone rush to base +#define MSG_GETFLAG 7 //get the enemy flag +#define MSG_STARTTEAMLEADERSHIP 8 //someone wants to become the team leader +#define MSG_STOPTEAMLEADERSHIP 9 //someone wants to stop being the team leader +#define MSG_WHOISTEAMLAEDER 10 //who is the team leader +#define MSG_WAIT 11 //wait for someone +#define MSG_WHATAREYOUDOING 12 //what are you doing? +#define MSG_JOINSUBTEAM 13 //join a sub-team +#define MSG_LEAVESUBTEAM 14 //leave a sub-team +#define MSG_CREATENEWFORMATION 15 //create a new formation +#define MSG_FORMATIONPOSITION 16 //tell someone his/her position in a formation +#define MSG_FORMATIONSPACE 17 //set the formation intervening space +#define MSG_DOFORMATION 18 //form a known formation +#define MSG_DISMISS 19 //dismiss commanded team mates +#define MSG_CAMP 20 //camp somewhere +#define MSG_CHECKPOINT 21 //remember a check point +#define MSG_PATROL 22 //patrol between certain keypoints +#define MSG_LEADTHEWAY 23 //lead the way +#define MSG_GETITEM 24 //get an item +#define MSG_KILL 25 //kill someone +#define MSG_WHEREAREYOU 26 //where is someone +#define MSG_RETURNFLAG 27 //return the flag +#define MSG_WHATISMYCOMMAND 28 //ask the team leader what to do +#define MSG_WHICHTEAM 29 //ask which team a bot is in +#define MSG_TASKPREFERENCE 30 //tell your teamplay task preference +#define MSG_ATTACKENEMYBASE 31 //attack the enemy base +#define MSG_HARVEST 32 //go harvest +#define MSG_SUICIDE 33 //order to suicide +// +#define MSG_ME 100 +#define MSG_EVERYONE 101 +#define MSG_MULTIPLENAMES 102 +#define MSG_NAME 103 +#define MSG_PATROLKEYAREA 104 +#define MSG_MINUTES 105 +#define MSG_SECONDS 106 +#define MSG_FOREVER 107 +#define MSG_FORALONGTIME 108 +#define MSG_FORAWHILE 109 +// +#define MSG_CHATALL 200 +#define MSG_CHATTEAM 201 +#define MSG_CHATTELL 202 +// +#define MSG_CTF 300 //ctf message + +//command sub types +#define ST_SOMEWHERE 0 +#define ST_NEARITEM 1 +#define ST_ADDRESSED 2 +#define ST_METER 4 +#define ST_FEET 8 +#define ST_TIME 16 +#define ST_HERE 32 +#define ST_THERE 64 +#define ST_I 128 +#define ST_MORE 256 +#define ST_BACK 512 +#define ST_REVERSE 1024 +#define ST_SOMEONE 2048 +#define ST_GOTFLAG 4096 +#define ST_CAPTUREDFLAG 8192 +#define ST_RETURNEDFLAG 16384 +#define ST_TEAM 32768 +#define ST_1FCTFGOTFLAG 65535 +//ctf task preferences +#define ST_DEFENDER 1 +#define ST_ATTACKER 2 +#define ST_ROAMER 4 + + +//word replacement variables +#define THE_ENEMY 7 +#define THE_TEAM 7 +//team message variables +#define NETNAME 0 +#define PLACE 1 +#define FLAG 1 +#define MESSAGE 2 +#define ADDRESSEE 2 +#define ITEM 3 +#define TEAMMATE 4 +#define TEAMNAME 4 +#define ENEMY 4 +#define KEYAREA 5 +#define FORMATION 5 +#define POSITION 5 +#define NUMBER 5 +#define TIME 6 +#define NAME 6 +#define MORE 6 + + diff --git a/code/game/misc.cpp b/code/game/misc.cpp new file mode 100644 index 00000000..fbf23465 --- /dev/null +++ b/code/game/misc.cpp @@ -0,0 +1,3725 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// misc.cpp: Basically the big stew pot of the DLLs, or maybe a garbage bin, whichever +// metaphore you prefer. This really should be cleaned up. Anyway, this +// should contain utility functions that could be used by any entity. +// Right now it contains everything from entities that could be in their +// own file to my mother's pot roast recipes. +// + +#include "glb_local.h" +#include "entity.h" +#include "trigger.h" +#include "explosion.h" +#include "misc.h" +#include "navigate.h" +#include "specialfx.h" +#include "player.h" +#include "weaputils.h" +#include + +/*****************************************************************************/ +/*QUAKED detail (0.5 0 1.0) ? + +Used to fake detail brushes, convenient for grouping + +******************************************************************************/ + +/*****************************************************************************/ +/*QUAKED func_group (0.5 0.5 0.5) ? + +Used to group brushes together just for editor convenience. + +******************************************************************************/ + +/*****************************************************************************/ +/*QUAKED func_remove (0.75 0.75 0.75) ? + +Used for lighting and such + +******************************************************************************/ + +CLASS_DECLARATION( Entity, FuncRemove, "func_remove" ) + { + { NULL, NULL } + }; + +FuncRemove::FuncRemove() + { + PostEvent( EV_Remove, EV_REMOVE ); + } + +/*****************************************************************************/ +/*QUAKED misc_model (1 0.5 1) (0 0 0) (0 0 0) +"model" arbitrary .tik file to display +******************************************************************************/ + +CLASS_DECLARATION( Entity, MiscModel, "misc_model" ) + { + { NULL, NULL } + }; + +MiscModel::MiscModel() + { + PostEvent( EV_Remove, EV_REMOVE ); + } + + +/*****************************************************************************/ +/*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4) + +Used as a positional target for spotlights, etc. + +******************************************************************************/ + +CLASS_DECLARATION( Entity, InfoNull, "info_null" ) + { + { NULL, NULL } + }; + +InfoNull::InfoNull() + { + PostEvent( EV_Remove, EV_REMOVE ); + } + +/*****************************************************************************/ +/*QUAKED info_notnull (0 0.5 0) (-4 -4 -4) (4 4 4) + +Used as a positional target for lightning. + +******************************************************************************/ + +CLASS_DECLARATION( Entity, InfoNotNull, "info_notnull" ) + { + { NULL, NULL } + }; + + + +/*****************************************************************************/ +/*QUAKED func_explodingwall (0 0.25 0.5) ? RANDOMANGLES LANDSHATTER NOT_PLAYERS MONSTERS PROJECTILES INVISIBLE ACCUMALATIVE TWOSTAGE + +Blows up on activation or when attacked + +"explosions" number of explosions to spawn ( default 1 ) +"land_angles" The angles you want this piece to\ + orient to when it lands on the ground +"land_radius" The distance of the ground the piece\ + should be when on the ground ( default 16 ) +"anglespeed" Speed at which pieces rotate ( default 100 ) \ + if RANDOMANGLES ( default is 600 ) +"key" The item needed to activate this. (default nothing) +"base_velocity" The speed that the debris will have when triggered. (default 0 0 280) +"random_velocity" The variation of the velocity. x & y will be from -n < X,Y < n and z is 0 <= Z < n. (default 140 140 140) + + +IF RANDOMANGLES is set, object randomly spins while in the air. +IF LANDSHATTER is set, object shatters when it hits the ground. +IF TWOSTAGE is set, object can be shattered once it lands on the ground. +IF ACCUMALATIVE is set, damage is accumlative not threshold +IF INVISIBLE is set, these are invisible and not solid until triggered +If NOT_PLAYERS is set, the trigger does not respond to players +If MONSTERS is set, the trigger will respond to monsters +If PROJECTILES is set, the trigger will respond to projectiles (rockets, grenades, etc.) + +******************************************************************************/ +#define RANDOMANGLES ( 1 << 0 ) +#define LANDSHATTER ( 1 << 1 ) +#define INVISIBLE ( 1 << 5 ) +#define ACCUMULATIVE ( 1 << 6 ) +#define TWOSTAGE ( 1 << 7 ) + +Event EV_ExplodingWall_StopRotating + ( + "stoprotating", + EV_DEFAULT, + NULL, + NULL, + "Stop rotating the wall.", + EV_NORMAL + ); +Event EV_ExplodingWall_OnGround + ( + "checkonground", + EV_DEFAULT, + NULL, + NULL, + "Check if exploding wall is on ground.", + EV_NORMAL + ); +Event EV_ExplodingWall_AngleSpeed + ( + "anglespeed", + EV_DEFAULT, + "f", + "speed", + "Set the angle speed.", + EV_NORMAL + ); +Event EV_ExplodingWall_LandRadius + ( + "land_radius", + EV_DEFAULT, + "f", + "radius", + "Set the land radius.", + EV_NORMAL + ); +Event EV_ExplodingWall_LandAngles + ( + "land_angles", + EV_DEFAULT, + "v", + "angles", + "Set the land angles.", + EV_NORMAL + ); +Event EV_ExplodingWall_BaseVelocity + ( + "base_velocity", + EV_DEFAULT, + "v", + "velocity", + "Set the base velocity.", + EV_NORMAL + ); +Event EV_ExplodingWall_RandomVelocity + ( + "random_velocity", + EV_DEFAULT, + "v", + "velocity", + "Set the amount of random variation of the base velocity.", + EV_NORMAL + ); +Event EV_ExplodingWall_SetDmg + ( + "dmg", + EV_DEFAULT, + "i", + "dmg", + "Set the damage from the exploding wall.", + EV_NORMAL + ); +Event EV_ExplodingWall_SetExplosions + ( + "explosions", + EV_DEFAULT, + "i", + "explosions", + "Set the number of explosions.", + EV_NORMAL + ); +Event EV_ExplodingWall_Setup + ( + "setup", + EV_CODEONLY, + NULL, + NULL, + "Initializes the exploding wall.", + EV_NORMAL + ); + +CLASS_DECLARATION( Trigger, ExplodingWall, "func_explodingwall" ) + { + { &EV_ExplodingWall_Setup, &ExplodingWall::Setup }, + { &EV_Trigger_Effect, &ExplodingWall::Explode }, + { &EV_Damage, &ExplodingWall::DamageEvent }, + { &EV_Touch, &ExplodingWall::TouchFunc }, + { &EV_ExplodingWall_StopRotating, &ExplodingWall::StopRotating }, + { &EV_ExplodingWall_OnGround, &ExplodingWall::CheckOnGround }, + { &EV_ExplodingWall_AngleSpeed, &ExplodingWall::AngleSpeed }, + { &EV_ExplodingWall_LandRadius, &ExplodingWall::LandRadius }, + { &EV_ExplodingWall_LandAngles, &ExplodingWall::LandAngles }, + { &EV_ExplodingWall_BaseVelocity, &ExplodingWall::BaseVelocity }, + { &EV_ExplodingWall_RandomVelocity, &ExplodingWall::RandomVelocity }, + { &EV_ExplodingWall_SetDmg, &ExplodingWall::SetDmg }, + { &EV_ExplodingWall_SetExplosions, &ExplodingWall::SetExplosions }, + { NULL, NULL } + }; + +void ExplodingWall::AngleSpeed + ( + Event *ev + ) + + { + angle_speed = ev->GetFloat( 1 ); + } + +void ExplodingWall::LandRadius + ( + Event *ev + ) + + { + land_radius = ev->GetFloat( 1 ); + } + +void ExplodingWall::LandAngles + ( + Event *ev + ) + + { + land_angles = ev->GetVector( 1 ); + } + +void ExplodingWall::BaseVelocity + ( + Event *ev + ) + + { + base_velocity = ev->GetVector( 1 ); + } + +void ExplodingWall::RandomVelocity + ( + Event *ev + ) + + { + random_velocity = ev->GetVector( 1 ); + } + +void ExplodingWall::SetDmg + ( + Event *ev + ) + + { + dmg = ev->GetInteger( 1 ); + } + +void ExplodingWall::SetExplosions + ( + Event *ev + ) + + { + explosions = ev->GetInteger( 1 ); + } + +void ExplodingWall::Explode + ( + Event *ev + ) + + { + Entity *other; + Vector pos; + Vector mins, maxs; + int i; + + if ( spawnflags & INVISIBLE ) + { + showModel(); + setSolidType( SOLID_BSP ); + takedamage = DAMAGE_YES; + } + + if ( takedamage == DAMAGE_NO ) + { + return; + } + + other = ev->GetEntity( 1 ); + + health = 0; + takedamage = DAMAGE_NO; + + // Create explosions + for( i = 0; i < explosions; i++ ) + { + pos[ 0 ] = absmin[ 0 ] + G_Random( size[ 0 ] ); + pos[ 1 ] = absmin[ 1 ] + G_Random( size[ 1 ] ); + pos[ 2 ] = absmin[ 2 ] + G_Random( size[ 2 ] ); + + CreateExplosion( pos, dmg, this, other, this ); + } + + // throw itself + state = 1; + on_ground = false; + PostEvent( EV_ExplodingWall_OnGround, FRAMETIME ); + + velocity.x = base_velocity.x + G_CRandom( random_velocity.x ); + velocity.y = base_velocity.y + G_CRandom( random_velocity.y ); + velocity.z = base_velocity.z + G_Random( random_velocity.z ); + + setMoveType( MOVETYPE_BOUNCE ); + setSolidType( SOLID_BBOX ); + if ( spawnflags & RANDOMANGLES ) + { + avelocity[ 0 ] = G_Random( angle_speed ); + avelocity[ 1 ] = G_Random( angle_speed ); + avelocity[ 2 ] = G_Random( angle_speed ); + } + else + { + Vector delta; + float most; + float time; + int t; + + delta = land_angles - angles; + if ( delta[ 0 ] > 180 ) + delta[ 0 ] -= 360; + if ( delta[ 0 ] < -180 ) + delta[ 0 ] += 360; + if ( delta[ 1 ] > 180 ) + delta[ 1 ] -= 360; + if ( delta[ 1 ] < -180 ) + delta[ 1 ] += 360; + if ( delta[ 2 ] > 180 ) + delta[ 2 ] -= 360; + if ( delta[ 2 ] < -180 ) + delta[ 2 ] += 360; + most = MaxValue( delta ); + if ( !angle_speed ) + angle_speed = 1; + t = 10 * most / angle_speed; + time = (float)t / 10; + delta = delta * (1.0/time); + avelocity = delta; + PostEvent( EV_ExplodingWall_StopRotating, time ); + state = 2; + } + + ActivateTargets( ev ); + + if ( land_radius > 0 ) + { + mins[0] = mins[1] = mins[2] = -land_radius; + maxs[0] = maxs[1] = maxs[2] = land_radius; + setSize( mins, maxs ); + } + + attack_finished = 0; + } + +void ExplodingWall::DamageEvent + ( + Event *ev + ) + + { + Event *event; + Entity *inflictor; + Entity *attacker; + int damage; + + if ( takedamage == DAMAGE_NO ) + { + return; + } + + if ( on_ground ) + { + GroundDamage( ev ); + return; + } + + attacker = ev->GetEntity( 1 ); + damage = ev->GetInteger( 2 ); + inflictor = ev->GetEntity( 3 ); + + if ( spawnflags & ACCUMULATIVE ) + { + health -= damage; + if ( health > 0 ) + return; + } + else + { + if ( damage < health ) + { + return; + } + } + + event = new Event( EV_Activate ); + event->AddEntity( attacker ); + ProcessEvent( event ); + } + +void ExplodingWall::GroundDamage + ( + Event *ev + ) + + { + Entity *inflictor; + Entity *attacker; + Vector pos; + int damage; + + if ( takedamage == DAMAGE_NO ) + { + return; + } + + damage = ev->GetInteger( 1 ); + inflictor = ev->GetEntity( 2 ); + attacker = ev->GetEntity( 3 ); + + if ( spawnflags & ACCUMULATIVE ) + { + health -= damage; + if ( health > 0 ) + return; + } + else + { + if ( damage < health ) + { + return; + } + } + + if ( explosions ) + { + pos[ 0 ] = absmin[ 0 ] + G_Random( size[ 0 ] ); + pos[ 1 ] = absmin[ 1 ] + G_Random( size[ 1 ] ); + pos[ 2 ] = absmin[ 2 ] + G_Random( size[ 2 ] ); + + CreateExplosion( pos, damage, this, attacker, this ); + } + takedamage = DAMAGE_NO; + hideModel(); + BroadcastAIEvent(); + PostEvent( EV_Remove, 0 ); + } + +void ExplodingWall::SetupSecondStage + ( + void + ) + + { + health = max_health; + takedamage = DAMAGE_YES; + } + +void ExplodingWall::StopRotating + ( + Event *ev + ) + + { + avelocity = vec_zero; + setAngles( land_angles ); + if ( spawnflags & TWOSTAGE ) + SetupSecondStage(); + } + +void ExplodingWall::CheckOnGround + ( + Event *ev + ) + + { + if ( ( velocity == vec_zero ) && groundentity ) + { + Vector delta; + float most; + float time; + int t; + + delta = land_angles - angles; + if ( delta.length() > 1 ) + { + if ( delta[ 0 ] > 180 ) + delta[ 0 ] -= 360; + if ( delta[ 0 ] < -180 ) + delta[ 0 ] += 360; + if ( delta[ 1 ] > 180 ) + delta[ 1 ] -= 360; + if ( delta[ 1 ] < -180 ) + delta[ 1 ] += 360; + if ( delta[ 2 ] > 180 ) + delta[ 2 ] -= 360; + if ( delta[ 2 ] < -180 ) + delta[ 2 ] += 360; + most = MaxValue( delta ); + if ( angle_speed > 3 ) + t = 10.0f * most / ( angle_speed / 3 ); + else + t = 10.0f * most; + time = (float)t / 10; + delta = delta * (1.0/time); + avelocity = delta; + PostEvent( EV_ExplodingWall_StopRotating, time ); + } + state = 2; + setSize( orig_mins, orig_maxs ); + on_ground = true; + } + else + PostEvent( ev, FRAMETIME ); + } + +void ExplodingWall::TouchFunc + ( + Event *ev + ) + + { + Entity *other; + + if ( ( velocity == vec_zero ) || ( level.time < attack_finished ) ) + { + return; + } + + other = ev->GetEntity( 1 ); + + if ( ( spawnflags & LANDSHATTER ) && ( other == world ) ) + { + Vector pos; + + takedamage = DAMAGE_NO; + + if ( explosions ) + { + pos[ 0 ] = absmin[ 0 ] + G_Random( size[ 0 ] ); + pos[ 1 ] = absmin[ 1 ] + G_Random( size[ 1 ] ); + pos[ 2 ] = absmin[ 2 ] + G_Random( size[ 2 ] ); + + CreateExplosion( pos, dmg, this, other, this ); + } + hideModel(); + BroadcastAIEvent(); + PostEvent( EV_Remove, 0 ); + return; + } + + if ( other->takedamage ) + { + other->Damage( this, activator, dmg, origin, vec_zero, vec_zero, 20, 0, MOD_EXPLODEWALL ); + Sound( "debris_generic", CHAN_WEAPON ); + attack_finished = level.time + FRAMETIME; + } + } + +void ExplodingWall::Setup + ( + Event *ev + ) + + { + if ( spawnflags & INVISIBLE ) + { + if ( Targeted() ) + takedamage = DAMAGE_YES; + else + takedamage = DAMAGE_NO; + hideModel(); + setSolidType( SOLID_NOT ); + } + else + { + showModel(); + setSolidType( SOLID_BSP ); + takedamage = DAMAGE_YES; + } + + setMoveType( MOVETYPE_PUSH ); + setOrigin(); + } + +ExplodingWall::ExplodingWall() + { + if ( LoadingSavegame ) + { + return; + } + + health = 60; + max_health = health; + on_ground = false; + + state = 0; + angle_speed = ( spawnflags & RANDOMANGLES ) ? 600 : 100; + land_radius = 16; + dmg = 10; + explosions = 1; + + base_velocity = Vector( 0, 0, 280 ); + random_velocity = Vector( 140, 140, 140 ); + + orig_mins = mins; + orig_maxs = maxs; + + respondto = spawnflags ^ TRIGGER_PLAYERS; + + PostEvent( EV_ExplodingWall_Setup, EV_POSTSPAWN ); + } + +/*****************************************************************************/ +/*QUAKED trigger_teleport (0.5 0.5 0.5) ? VISIBLE x NOT_PLAYERS NOT_MONSTERS NOT_PROJECTILES NO_EFFECTS + +Touching this entity will teleport players to the targeted object. + +"key" The item needed to activate this. (default nothing) + +"teleportthread" The thread that is run when the player is teleported + +If NOT_PLAYERS is set, the teleporter does not teleport players +If NOT_MONSTERS is set, the teleporter does not teleport monsters +If NOT_PROJECTILES is set, the teleporter does not teleport projectiles (rockets, grenades, etc.) +If NO_EFFECTS is set, the special effect will not happen and the teleport will be instant + +******************************************************************************/ + +#define NO_EFFECTS ( 1 << 5 ) + +Event EV_Teleporter_Teleport + ( + "teleport", + EV_CODEONLY, + "e", + "entity", + "Teleports the entity to destination.", + EV_NORMAL + ); + +Event EV_Teleporter_StopTeleport + ( + "stopteleport", + EV_CODEONLY, + "e", + "entity", + "Releases the entity at the end of the teleport.", + EV_NORMAL + ); + +Event EV_Teleporter_SetThread + ( + "teleportthread", + EV_CODEONLY, + "s", + "thread_name", + "Sets the thread to run when the player is teleported.", + EV_NORMAL + ); + +CLASS_DECLARATION( Trigger, Teleporter, "trigger_teleport" ) + { + { &EV_Trigger_Effect, &Teleporter::StartTeleport }, + { &EV_Teleporter_Teleport, &Teleporter::Teleport }, + { &EV_Teleporter_StopTeleport, &Teleporter::StopTeleport }, + { &EV_Teleporter_SetThread, &Teleporter::SetThread }, + { NULL, NULL } + }; + +void Teleporter::SetThread + ( + Event *ev + ) + { + teleport_label.SetThread( ev->GetValue( 1 ) ); + } + +void Teleporter::StartTeleport + ( + Event *ev + ) + { + Animate *fx; + Entity *other; + Event *event; + qboolean is_sentient; + Vector new_position; + + + if ( in_use ) + return; + + in_use = true; + + other = ev->GetEntity( 1 ); + + if ( !other ) + return; + + if ( spawnflags & NO_EFFECTS ) + { + event = new Event( EV_Teleporter_Teleport ); + event->AddEntity( other ); + ProcessEvent( event ); + return; + } + + if ( other->isSubclassOf( Sentient ) ) + is_sentient = true; + else + is_sentient = false; + + if ( is_sentient ) + { + new_position = origin; + new_position.z += mins.z; + other->setOrigin( new_position ); + other->NoLerpThisFrame(); + } + + // Create the teleport special effect + + fx = new Animate; + fx->setOrigin( other->origin ); + + fx->NewAnim( "idle", EV_Remove ); + + if ( is_sentient ) + { + fx->setModel( "fx_bigteleport.tik" ); + //fx->Sound( "sound/environment/electric/singles/dimming.wav" ); + } + else + { + fx->setModel( "fx_teleport2.tik" ); + } + + if ( is_sentient ) + { + // Freeze the entity that went into the teleporter + + other->flags |= FL_IMMOBILE; + other->takedamage = DAMAGE_NO; + } + + // Make the entity teleport + + event = new Event( EV_Teleporter_Teleport ); + event->AddEntity( other ); + + if ( is_sentient ) + PostEvent( event, 4 ); + else + PostEvent( event, 0 ); + + if ( is_sentient ) + { + other->PostEvent( EV_CODEONLY, 2 ); + + /* if ( !( spawnflags & NO_EFFECTS ) ) + { + event = new Event( EV_Sound ); + event->AddString( "snd_teleport" ); + other->PostEvent( event, 2 ); + } */ + } + } + +void Teleporter::Teleport + ( + Event *ev + ) + + { + Entity *dest; + int i; + Entity *other; + Vector mid; + Animate *fx; + Event *event; + + other = ev->GetEntity( 1 ); + + if ( !other || ( other == world ) ) + return; + + dest = ( Entity * )G_FindTarget( NULL, Target() ); + if ( !dest ) + { + warning( "Teleport", "Couldn't find destination\n" ); + return; + } + + assert( dest ); + + // unlink to make sure it can't possibly interfere with KillBox + other->unlink(); + + if ( other->isSubclassOf( Sentient ) ) + { + other->origin = dest->origin + Vector( 0, 0, 1 ); + other->velocity = vec_zero; + } + else + { + mid = ( absmax - absmin ) * 0.5; + other->origin = dest->origin + Vector( 0, 0, 1 ); + other->origin += mid; + } + + // set angles + other->setAngles( dest->angles ); + + if ( other->client ) + { + client = other->client; + + // clear the velocity and hold them in place briefly + client->ps.pm_time = 100; + client->ps.pm_flags |= PMF_RESPAWNED; + + // cut the camera on the client + ( ( Player * )other )->CameraCut(); + + for( i = 0; i < 3; i++ ) + { + client->ps.delta_angles[ i ] = ANGLE2SHORT( dest->angles[ i ] - client->cmd_angles[ i ] ); + } + + VectorCopy( angles, client->ps.viewangles ); + } + + if ( dest->isSubclassOf( TeleporterDestination ) ) + { + float len; + + len = other->velocity.length(); + // + // give them a bit of a push + // + if ( len < 400 ) + len = 400; + other->velocity = ( ( TeleporterDestination * )dest )->movedir * len; + } + + // kill anything at the destination + KillBox( other ); + + other->setOrigin( other->origin ); + other->origin.copyTo( other->edict->s.origin2 ); + + // Run the teleport thread if set + + if ( teleport_label.IsSet() && other->isSubclassOf( Player ) ) + { + teleport_label.Execute( this ); + } + + // Skip effects if no_effects set + + if ( spawnflags & NO_EFFECTS ) + { + Event *event = new Event( EV_Teleporter_StopTeleport ); + event->AddEntity( other ); + ProcessEvent( event ); + return; + } + + // Spawn in effect + + fx = new Animate; + + fx->setOrigin( other->origin ); + + fx->NewAnim( "idle", EV_Remove ); + + if ( other->isSubclassOf( Sentient ) ) + { + fx->setModel( "fx_bigteleport.tik" ); + } + else + { + fx->setModel( "fx_teleport2.tik" ); + } + + event = new Event( EV_Teleporter_StopTeleport ); + event->AddEntity( other ); + + if ( other->isSubclassOf( Sentient ) ) + PostEvent( event, 1.75 ); + else + PostEvent( event, FRAMETIME ); + } + +void Teleporter::StopTeleport + ( + Event *ev + ) + + { + Entity *other; + + other = ev->GetEntity( 1 ); + + if ( other->isSubclassOf( Sentient ) ) + { + other->flags &= ~FL_IMMOBILE; + other->takedamage = DAMAGE_AIM; + other->showModel(); + } + + //if ( !( spawnflags & NO_EFFECTS ) ) + // other->Sound( "snd_teleport" ); + + in_use = false; + } + +Teleporter::Teleporter() + { + if ( LoadingSavegame ) + { + return; + } + + if ( spawnflags & 1 ) + { + PostEvent( EV_Show, EV_POSTSPAWN ); + } + + //respondto = spawnflags ^ ( TRIGGER_PLAYERS | TRIGGER_MONSTERS | TRIGGER_PROJECTILES ); + respondto = spawnflags ^ ( TRIGGER_PLAYERS ); + + in_use = false; + + // Cache all needed stuff + + if ( !( spawnflags & NO_EFFECTS ) ) + { + CacheResource( "models/fx_bigteleport.tik" ); + //CacheResource( "sound/environment/electric/singles/dimming.wav", this ); + CacheResource( "fx_teleport2.tik" ); + //CacheResource( "snd_teleport", this ); + } + } + +/*****************************************************************************/ +/*QUAKED func_teleportdest (0 0.25 0.5) (-32 -32 0) (32 32 8) + +Point trigger_teleport at these. + +******************************************************************************/ + +CLASS_DECLARATION( Entity, TeleporterDestination, "func_teleportdest" ) +{ + { &EV_SetAngle, &TeleporterDestination::SetMoveDir }, + { NULL, NULL } +}; + +TeleporterDestination::TeleporterDestination() + { + movedir = G_GetMovedir( 0 ); + } + +void TeleporterDestination::SetMoveDir + ( + Event *ev + ) + { + float angle; + + angle = ev->GetFloat( 1 ); + movedir = G_GetMovedir( angle ); + setAngles( movedir.toAngles() ); + } + +/*****************************************************************************/ +/*QUAKED func_useanim (0 0.5 0) ? VISIBLE TOUCHABLE CONTINUOUS + +This object allows you to place the player into a specific animation for the +purposes of using an object within the world-> + +This object should point at a func_useanimdest which contains specific +information about how the player is supposed to be posed. + +"count" - how many times this should trigger (default -1, infinite) +"thread" - thread to fire when used +"triggertarget" - what to trigger when used. +"delay" - how long it takes to be re-triggered ( default 3 seconds ) +"key" - item needed to activate this + +VISIBLE - if this is checked the trigger itself will be visible +TOUCHABLE - if this is set we can activate the trigger by standing in it. +CONTINUOUS - if this is checked the thing will re-trigger continously, otherwise +it waits until the player has left the trigger field. + +******************************************************************************/ + +Event EV_UseAnim_Reset + ( + "_reset", + EV_CODEONLY, + NULL, + NULL, + "Reset's the Use Anim after it has no longer been touched.", + EV_NORMAL + ); + +Event EV_UseAnim_Thread + ( + "setthread", + EV_DEFAULT, + "s", + "label", + "Sets which thread to use when this UseAnim is triggered.", + EV_NORMAL + ); + +Event EV_UseAnim_Count + ( + "count", + EV_DEFAULT, + "i", + "newCount", + "Sets how many times the UseAnim can be triggered.", + EV_NORMAL + ); + +Event EV_UseAnim_TriggerTarget + ( + "triggertarget", + EV_DEFAULT, + "s", + "targetname", + "Sets what should be triggered, when this UseAnim is triggered.", + EV_NORMAL + ); + +Event EV_UseAnim_SetAnim + ( + "anim", + EV_DEFAULT, + "s", + "animName", + "set the animation to use for player.", + EV_NORMAL + ); + +Event EV_UseAnim_SetKey + ( + "key", + EV_DEFAULT, + "s", + "keyName", + "set the key needed to make this UseAnim function.", + EV_NORMAL + ); + + +Event EV_UseAnim_SetState + ( + "state", + EV_CHEAT, + "s", + "stateName", + "set the state to use for the player.", + EV_NORMAL + ); + +Event EV_UseAnim_SetCamera + ( + "camera", + EV_DEFAULT, + "s", + "cameraPosition", + "set the camera to use when in this animation.\n" + "topdown, behind, front, side, behind_fixed, side_left, side_right", + EV_NORMAL + ); + +Event EV_UseAnim_SetNumLoops + ( + "num_loops", + EV_DEFAULT, + "i", + "loopCount", + "set the number of times to loop an animation per use.", + EV_NORMAL + ); + +Event EV_UseAnim_SetDelay + ( + "delay", + EV_DEFAULT, + "f", + "delayTime", + "how long it takes for the UseAnim to be retriggered once you leave it.", + EV_NORMAL + ); + + +CLASS_DECLARATION( Entity, UseAnim, "func_useanim" ) + { + { &EV_Use, NULL }, + { &EV_Touch, &UseAnim::Touched }, + { &EV_UseAnim_Reset, &UseAnim::Reset }, + { &EV_UseAnim_Thread, &UseAnim::SetThread }, + { &EV_UseAnim_TriggerTarget, &UseAnim::SetTriggerTarget }, + { &EV_UseAnim_Count, &UseAnim::SetCount }, + { &EV_UseAnim_SetAnim, &UseAnim::SetAnim }, + { &EV_UseAnim_SetState, &UseAnim::SetState }, + { &EV_UseAnim_SetKey, &UseAnim::SetKey }, + { &EV_UseAnim_SetNumLoops, &UseAnim::SetNumLoops }, + { &EV_UseAnim_SetCamera, &UseAnim::SetCamera }, + { NULL, NULL } + }; + +UseAnim::UseAnim() + { + if ( LoadingSavegame ) + { + return; + } + + setMoveType( MOVETYPE_NONE ); + + anim = "stand_use"; + num_loops = 1; + hideModel(); + + // + // make it not solid unless we want it touchable + // + if ( !( spawnflags & 2 ) ) + { + setSolidType( SOLID_BBOX ); + setContents( CONTENTS_BODY ); + } + else + { + setSolidType( SOLID_TRIGGER ); + edict->r.svFlags |= SVF_NOCLIENT; + } + + // by default this can activated infinitely + count = -1; + // clear out the triggertarget + triggertarget = ""; + // clear out the thread + thread.Set( "" ); + // set the default delay + delay = 3; + // initialize the last time the door was triggered + last_active_time = -delay; + // initially its not active + active = 0; + // set the default camera to be side view + camera = "behind"; + // + // only make it visible if so desired + // + if ( spawnflags & 1 ) + { + PostEvent( EV_Show, EV_POSTSPAWN ); + } + } + +void UseAnim::Touched + ( + Event *ev + ) + + { + Entity *other; + + if ( active && ( !( spawnflags & 4 ) ) ) + { + CancelEventsOfType( EV_UseAnim_Reset ); + PostEvent( EV_UseAnim_Reset, 0.25f ); + return; + } + + // don't retrigger to soon + if ( level.time < last_active_time ) + return; + + other = ev->GetEntity( 1 ); + if ( other->isSubclassOf( Player ) ) + { + ( ( Player * ) other )->TouchedUseAnim( this ); + } + } + +bool UseAnim::canBeUsed + ( + Entity * activator + ) + + { + Entity *dest; + + // if this is no longer usable, return false + if ( !count ) + { + return false; + } + + // don't retrigger to soon + if ( level.time < last_active_time ) + { + return false; + } + + if ( key.length() ) + { + if ( !activator->isSubclassOf( Sentient ) ) + { + return false; + } + if ( !( ( (Sentient *)activator )->HasItem( key.c_str() ) ) ) + { + qboolean setModel; + Item *item; + ClassDef *cls; + str dialog; + + cls = FindClass( key.c_str(), &setModel ); + if ( !cls || !checkInheritance( "Item", cls->classname ) ) + { + gi.DPrintf( "No item named '%s'\n", key.c_str() ); + return true; + } + item = ( Item * )cls->newInstance(); + if ( setModel ) + { + item->setModel( key.c_str() ); + } + item->CancelEventsOfType( EV_Item_DropToFloor ); + item->CancelEventsOfType( EV_Remove ); + item->ProcessPendingEvents(); + dialog = item->GetDialogNeeded(); + if ( dialog.length() > 0 ) + { + activator->Sound( dialog ); + } + else + { + gi.centerprintf ( activator->edict, "You need the %s", item->getName().c_str() ); + } + delete item; + + // don't retrigger for 5 seconds + last_active_time = level.time + 5; + return false; + } + else + { + return qtrue; + } + } + + if ( isSubclassOf( TouchAnim ) ) + { + return true; + } + + dest = ( Entity * )G_FindTarget( NULL, Target() ); + if ( !dest || !dest->isSubclassOf( UseAnimDestination ) ) + { + warning( "UseAnim", "Couldn't find destination\n" ); + return false; + } + + return true; + } + +bool UseAnim::GetInformation + ( + Entity *activator, + Vector *org, + Vector *angles, + str *animation, + int *loopcount, + str *state, + str *camera + ) + + { + Entity *dest; + UseAnimDestination *uadest; + + // if this is no longer usable, return false + if ( !count ) + { + return false; + } + + dest = ( Entity * )G_FindTarget( NULL, Target() ); + + if ( !dest || !dest->isSubclassOf( UseAnimDestination ) ) + { + // grab the information from this entity instead + // set the destination origin + *org = origin; + // set the destination angles + *angles = this->angles; + // set the desination animation + *animation = anim; + // set the number of loops + *loopcount = num_loops; + // get the state if necessary + *state = this->state; + // set the camera + *camera = this->camera; + } + else + { + uadest = ( UseAnimDestination * )dest; + + // set the destination origin + *org = uadest->origin; + // set the destination angles + *angles = uadest->angles; + // set the desination animation + *animation = uadest->GetAnim(); + // set the number of loops + *loopcount = uadest->GetNumLoops(); + // get the state if necessary + *state = uadest->GetState(); + // set the camera + *camera = this->camera; + } + + + // make this guy active + active = qtrue; + + // if this is a TouchAnim see if it is linked to another TouchAnim + if ( isSubclassOf( TouchAnim ) ) + { + dest = NULL; + do { + dest = ( Entity * )G_FindTarget( dest, Target() ); + if ( dest ) + { + if ( dest->isSubclassOf( UseAnim ) ) + { + // make our linked UseAnim's active as well + ( ( UseAnim * )dest )->active = qtrue; + } + } + else + { + break; + } + } + while( 1 ); + } + // + // decrement the use + // + if ( count > 0 ) + { + count--; + } + + return true; + } + +void UseAnim::TriggerTargets + ( + Entity *activator + ) + + { + // + // fire off our trigger target if appropriate + // + if ( triggertarget.length() ) + { + Event *event; + Entity *ent; + + ent = NULL; + do + { + ent = ( Entity * )G_FindTarget( ent, triggertarget.c_str() ); + if ( !ent ) + { + break; + } + event = new Event( EV_Activate ); + event->AddEntity( activator ); + ent->PostEvent( event, 0 ); + } + while ( 1 ); + } + + // + // fire off a thread if necessary + // + if ( thread.IsSet() ) + { + thread.Execute( this ); + } + } + +void UseAnim::Reset + ( + Event *ev + ) + + { + // + // find out if our triggertarget is of type door and only reset if the door is closed + // + if ( triggertarget.length() ) + { + Entity *ent; + + ent = NULL; + do + { + ent = ( Entity * )G_FindTarget( ent, triggertarget.c_str() ); + if ( !ent ) + { + break; + } + if ( ent->isSubclassOf( Door ) ) + { + if ( !( ( Door * )ent )->isCompletelyClosed() ) + { + CancelEventsOfType( EV_UseAnim_Reset ); + PostEvent( EV_UseAnim_Reset, 0.25f ); + // + // wait for a little bit + // + return; + } + } + } + while ( 1 ); + } + + active = qfalse; + last_active_time = level.time + delay; + + // if this is a TouchAnim see if it is linked to another TouchAnim + if ( isSubclassOf( TouchAnim ) ) + { + Entity *dest; + + dest = NULL; + do { + dest = ( Entity * )G_FindTarget( dest, Target() ); + if ( dest ) + { + if ( dest->isSubclassOf( UseAnim ) ) + { + // make our linked UseAnim's reset as well + ( ( UseAnim * )dest )->active = qfalse; + ( ( UseAnim * )dest )->last_active_time = level.time + delay; + } + } + else + { + break; + } + } + while( 1 ); + } + } + +void UseAnim::SetThread + ( + Event *ev + ) + + { + thread.SetThread( ev->GetValue( 1 ) ); + } + +void UseAnim::SetDelay + ( + Event *ev + ) + + { + delay = ev->GetFloat( 1 ); + } + +void UseAnim::SetTriggerTarget + ( + Event *ev + ) + + { + triggertarget = ev->GetString( 1 ); + } + +void UseAnim::SetCount + ( + Event *ev + ) + + { + count = ev->GetInteger( 1 ); + } + +void UseAnim::SetAnim + ( + Event *ev + ) + { + anim = ev->GetString( 1 ); + } + +void UseAnim::SetState + ( + Event *ev + ) + { + state = ev->GetString( 1 ); + } + +void UseAnim::SetKey + ( + Event *ev + ) + { + key = ev->GetString( 1 ); + } + +void UseAnim::SetCamera + ( + Event *ev + ) + { + camera = ev->GetString( 1 ); + } + +void UseAnim::SetNumLoops + ( + Event *ev + ) + { + num_loops = ev->GetInteger( 1 ); + } + + +CLASS_DECLARATION( UseAnim, TouchAnim, "func_touchanim" ) + { + { NULL, NULL } + }; + +TouchAnim::TouchAnim() + { + if ( LoadingSavegame ) + { + return; + } + + spawnflags |= 2; + + if ( spawnflags & 8 ) + { + setSize( Vector( "-32 -32 0" ), Vector( "32 32 96" ) ); + } + else + { + setSize( Vector( "-16 -16 0" ), Vector( "16 16 96" ) ); + } + + setSolidType( SOLID_TRIGGER ); + edict->r.svFlags |= SVF_NOCLIENT; + } + +/*****************************************************************************/ +/* func_useanimdest (0 0.25 0.5) (0 0 0) (0 0 0) + +Point func_useanim's at these. + +The player will be lerped to this position and this orientation +and placed into the specified animation + +"anim" specifies the animation that the player should be in. +"state" instead of an animation, sets a state the player should go into +"camera" camera position to use when player is in animation +"num_loops" number of animation loops to play. + + +******************************************************************************/ + +CLASS_DECLARATION( Entity, UseAnimDestination, "func_useanimdest" ) + { + { &EV_UseAnim_SetAnim, &UseAnimDestination::SetAnim }, + { &EV_UseAnim_SetState, &UseAnimDestination::SetState }, + { &EV_UseAnim_SetNumLoops, &UseAnimDestination::SetNumLoops }, + { NULL, NULL } + }; + +UseAnimDestination::UseAnimDestination() + { + if ( LoadingSavegame ) + { + // Archive function will setup all necessary data + return; + } + // + // default animation to use + // + anim = "stand_use"; + num_loops = 1; + setSolidType( SOLID_NOT ); + hideModel(); + } + +void UseAnimDestination::SetAnim + ( + Event *ev + ) + { + anim = ev->GetString( 1 ); + } + +void UseAnimDestination::SetState + ( + Event *ev + ) + { + state = ev->GetString( 1 ); + } + +str UseAnimDestination::GetAnim + ( + void + ) + { + return anim; + } + +str UseAnimDestination::GetState + ( + void + ) + { + return state; + } + +void UseAnimDestination::SetNumLoops + ( + Event *ev + ) + { + num_loops = ev->GetInteger( 1 ); + } + +int UseAnimDestination::GetNumLoops + ( + void + ) + { + return num_loops; + } + +Event EV_UseObject_MoveThread + ( + "move_thread", + EV_DEFAULT, + "s", + "label", + "Sets which move thread to use when this UseObject has finshed looping.", + EV_NORMAL + ); + +Event EV_UseObject_StopThread + ( + "stop_thread", + EV_DEFAULT, + "s", + "label", + "Sets which stop thread to use when this UseObject is finished.", + EV_NORMAL + ); + +Event EV_UseObject_ResetThread + ( + "reset_thread", + EV_DEFAULT, + "s", + "label", + "Sets which thread to call when resetting.", + EV_NORMAL + ); + +Event EV_UseObject_Count + ( + "count", + EV_DEFAULT, + "i", + "newCount", + "Sets how many times the UseObject can be triggered.", + EV_NORMAL + ); + +Event EV_UseObject_Cone + ( + "cone", + EV_DEFAULT, + "f", + "newCone", + "Sets the cone in angles of where the Useobject can be used.", + EV_NORMAL + ); + +Event EV_UseObject_Offset + ( + "offset", + EV_DEFAULT, + "v", + "newOffset", + "Sets the offset to use for this UseObject.", + EV_NORMAL + ); + +Event EV_UseObject_YawOffset + ( + "yaw_offset", + EV_DEFAULT, + "f", + "newYawOffset", + "Sets the yaw offset to use for this UseObject.", + EV_NORMAL + ); + +Event EV_UseObject_State + ( + "state", + EV_DEFAULT, + "s", + "newState", + "Sets the state to use for this UseObject.", + EV_NORMAL + ); + +Event EV_UseObject_StateBackwards + ( + "state_backwards", + EV_DEFAULT, + "s", + "newState", + "Sets the backward state to use for this UseObject.", + EV_NORMAL + ); + +Event EV_UseObject_TriggerTarget + ( + "triggertarget", + EV_DEFAULT, + "s", + "targetname", + "Sets what should be triggered, when this UseObject is triggered.", + EV_NORMAL + ); + +Event EV_UseObject_ResetTime + ( + "reset_time", + EV_DEFAULT, + "f", + "newResetTime", + "Sets the time it takes for the UseObject to reset itself.", + EV_NORMAL + ); + +Event EV_UseObject_DamageType + ( + "damage_type", + EV_DEFAULT, + "s", + "newDamageType", + "Sets what kind of damage is needed to activate the trigger.", + EV_NORMAL + ); + +Event EV_UseObject_Reset + ( + "_useobject_reset", + EV_DEFAULT, + NULL, + NULL, + "Resets the useobject to the start state after a certain amount of time.", + EV_NORMAL + ); + +Event EV_UseObject_Resetting + ( + "_useobject_resetting", + EV_DEFAULT, + NULL, + NULL, + "Intermediate function for useobject reset.", + EV_NORMAL + ); + +Event EV_UseObject_DamageTriggered + ( + "_useobject_damagetriggered", + EV_DEFAULT, + "e", + "activator", + "Intermediate function for when the useobject was triggered by damage.", + EV_NORMAL + ); + +Event EV_UseObject_Activate + ( + "activate", + EV_DEFAULT, + NULL, + NULL, + "Allow the useobject to be used.", + EV_NORMAL + ); + +Event EV_UseObject_Deactivate + ( + "deactivate", + EV_DEFAULT, + NULL, + NULL, + "Do not allow the useobject to be used.", + EV_NORMAL + ); + +Event EV_UseObject_UseMaterial + ( + "usematerial", + EV_DEFAULT, + "s", + "nameOfUseMaterial", + "the name of the material that glows when active.", + EV_NORMAL + ); + +Event EV_UseObject_SetActiveState + ( + "_setactivestate", + EV_DEFAULT, + NULL, + NULL, + "event that sets up the proper skin for the useobject.", + EV_NORMAL + ); + + + +#define MULTI_STATE ( 1 << 0 ) + +/*****************************************************************************/ +/*QUAKED func_useobject (0 0.5 0) ? MULTI-STATE + +Allows you to setup a special object that places the player into a specific state +sequence. Primarily used for levers and cranks. + +Object starts out in the "start" animation, when used the following occurs: + +It is determined whether or not the player is in the right position to activate +the object, if it is, the player is moved to the exact offset and angle specified +by "offset" and "yaw_offset". The right position is determined by a dot product +with "offset" and "yaw_offset". The "cone" parameter controls the cone in which the +object can be triggered. Once the player is in the right position, the player is placed +into "state" and the "move" animation is played. Once the player animation ends, the +"move_thread" will be called. If the use button is continued to be held down and count +is not finite, the animation will be continued to be played until the use key is held +down. Once the use key is let go, the "stop" animation will be played on the lever and +the "stop_thread" will be called. + +"activate" - turns the useobject on +"deactivate" - turns the useobject off +"offset" - vector offset of where the player should stand +"state" - state to go into when used +"state_backwards" - what state to use when reversing the object +"yaw_offset" - what direction the player should be facing when using the object +"cone" - the cone in which the object can be used +"count" - how many times this should trigger (default -1, infinite) +"move_thread" - thread that is fired when the object has cycled one animation +"stop_thread" - thread that is fired when the object has finished animating +"reset_thread" - thread that is fired when the object is resetting itself +"reset_time" - the time it takes for the object to reset, (default 0, it doesn't) +"triggertarget" - target to trigger when finished animating, if reset_time is set, target +will be fired again when resetting +"damage_type" - if set, can be triggered by using a weapon to activate it. If set to "all", +any damage will activate it. + +MULTI-STATE - the object has two different states and must be used each time to set the state +when multi state is active, the reset_thread is called instead of stop_thread. All UseObjects +have two states on and off. When reset_time is set, the object will automatically return to the +off state after a preset amount of time. When multi-state is set this must be done manually. + +******************************************************************************/ + +CLASS_DECLARATION( Animate, UseObject, "func_useobject" ) + { + { &EV_Use, NULL }, + { &EV_UseObject_MoveThread, &UseObject::SetMoveThread }, + { &EV_UseObject_StopThread, &UseObject::SetStopThread }, + { &EV_UseObject_ResetThread, &UseObject::SetResetThread }, + { &EV_UseObject_TriggerTarget, &UseObject::SetTriggerTarget }, + { &EV_UseObject_Offset, &UseObject::SetOffset }, + { &EV_UseObject_YawOffset, &UseObject::SetYawOffset }, + { &EV_UseObject_Count, &UseObject::SetCount }, + { &EV_UseObject_Cone, &UseObject::SetCone }, + { &EV_UseObject_State, &UseObject::SetState }, + { &EV_UseObject_StateBackwards, &UseObject::SetBackwardsState }, + { &EV_UseObject_ResetTime, &UseObject::SetResetTime }, + { &EV_UseObject_Reset, &UseObject::Reset }, + { &EV_UseObject_DamageType, &UseObject::DamageType }, + { &EV_UseObject_Resetting, &UseObject::Resetting }, + { &EV_UseObject_DamageTriggered, &UseObject::DamageTriggered }, + { &EV_Damage, &UseObject::DamageFunc }, + { &EV_UseObject_Activate, &UseObject::ActivateEvent }, + { &EV_UseObject_Deactivate, &UseObject::DeactivateEvent }, + { &EV_UseObject_UseMaterial, &UseObject::UseMaterialEvent }, + { &EV_UseObject_SetActiveState, &UseObject::SetActiveState }, + { NULL, NULL } + }; + +UseObject::UseObject() + { + Event * e; + + if ( LoadingSavegame ) + { + // Archive function will setup all necessary data + return; + } + + setMoveType( MOVETYPE_NONE ); + setSolidType( SOLID_BBOX ); + setContents( CONTENTS_BODY ); + + // make sure the bounds get rotated with the object + flags |= FL_ROTATEDBOUNDS; + // by default this can activated infinitely + count = -1; + // clear out the triggertarget + triggertarget = ""; + // clear out the move thread + move_thread.Set( "" ); + // clear out the stop thread + stop_thread.Set( "" ); + // clear out the reset thread + reset_thread.Set( "" ); + // clear out the damage type, by default useobjects do not respond to damage + damage_type = MOD_NONE; + // turn on damage taking ability + takedamage = DAMAGE_YES; + // give it some health + health = 100; + // set the default yaw offset + yaw_offset = 0; + // set the cone + cone = cos( DEG2RAD( 90 ) ); + // set the state + state = ""; + // set the backwards state + state_backwards = ""; + // clear out the reset_time + reset_time = 0; + // clear out the object state + objectState = 0; + // the useobject is active by default + active = qtrue; + + // start off in the start animation + e = new Event( EV_SetAnim ); + e->AddString( "start" ); + PostEvent( e, 0 ); + PostEvent( EV_Show, 0 ); + // setup our skins once we are spawned + PostEvent( EV_UseObject_SetActiveState, 0 ); + + } + +void UseObject::SetActiveState + ( + Event *ev + ) + { + if ( !useMaterial.length() ) + { + return; + } + + if ( active && count ) + { + SurfaceCommand( useMaterial.c_str(), "+skin1" ); + } + else + { + SurfaceCommand( useMaterial.c_str(), "-skin1" ); + } + if ( objectState ) + { + SurfaceCommand( useMaterial.c_str(), "+skin2" ); + } + else + { + SurfaceCommand( useMaterial.c_str(), "-skin2" ); + } + } + +void UseObject::SetMoveThread + ( + Event *ev + ) + + { + move_thread.SetThread( ev->GetValue( 1 ) ); + } + +void UseObject::SetStopThread + ( + Event *ev + ) + + { + stop_thread.SetThread( ev->GetValue( 1 ) ); + } + +void UseObject::SetResetThread + ( + Event *ev + ) + + { + reset_thread.SetThread( ev->GetValue( 1 ) ); + } + +void UseObject::ActivateEvent + ( + Event *ev + ) + + { + active = qtrue; + PostEvent( EV_UseObject_SetActiveState, 0 ); + } + +void UseObject::DeactivateEvent + ( + Event *ev + ) + + { + active = qfalse; + PostEvent( EV_UseObject_SetActiveState, 0 ); + } + +void UseObject::SetTriggerTarget + ( + Event *ev + ) + + { + triggertarget = ev->GetString( 1 ); + } + +void UseObject::SetOffset + ( + Event *ev + ) + + { + offset = ev->GetVector( 1 ); + } + +void UseObject::SetYawOffset + ( + Event *ev + ) + + { + yaw_offset = ev->GetFloat( 1 ); + } + +void UseObject::SetCount + ( + Event *ev + ) + + { + count = ev->GetInteger( 1 ); + } + +void UseObject::SetCone + ( + Event *ev + ) + + { + cone = cos( DEG2RAD( ev->GetFloat( 1 ) ) ); + } + +void UseObject::SetState + ( + Event *ev + ) + + { + state = ev->GetString( 1 ); + } + +void UseObject::SetBackwardsState + ( + Event *ev + ) + + { + state_backwards = ev->GetString( 1 ); + } + +void UseObject::UseMaterialEvent + ( + Event *ev + ) + + { + useMaterial = ev->GetString( 1 ); + } + +void UseObject::SetResetTime + ( + Event *ev + ) + + { + reset_time = ev->GetFloat( 1 ); + } + +void UseObject::Reset( Event *ev ) +{ + NewAnim( "move_backward", EV_UseObject_Resetting ); +} + +void UseObject::Resetting + ( + Event *ev + ) + + { + SetActiveState( NULL ); + NewAnim( "start" ); + + // reset the count + count = 1; + + // + // fire off our trigger target if appropriate + // + if ( triggertarget.length() ) + { + Event *event; + Entity *ent; + + ent = NULL; + do + { + ent = ( Entity * )G_FindTarget( ent, triggertarget.c_str() ); + if ( !ent ) + { + break; + } + event = new Event( EV_Activate ); + event->AddEntity( this ); + ent->PostEvent( event, 0 ); + } + while ( 1 ); + } + + // + // fire off a thread if necessary + // + if( reset_thread.IsSet() ) + { + reset_thread.Execute( this ); + } + } + +bool UseObject::canBeUsed + ( + Vector org, + Vector dir + ) + + { + float dot; + Vector forward; + Vector diff; + Vector ang; + + // see if it is active + if ( !active ) + { + return false; + } + + // if this is no longer usable, return false + if ( !count ) + { + return false; + } + + // convert our yawoffset to a vector + ang = vec_zero; + ang[ YAW ] = angles[ YAW ] + yaw_offset; + ang.AngleVectors( &forward ); + dot = forward * dir; + if ( dot < cone ) + { + return false; + } + +/* + // convert our offset to a vector in worldspace + forward = getLocalVector( offset ); + forward.normalize(); + diff = org - origin; +// diff = origin - org; + diff.normalize(); + dot = forward * dir; + if ( dot < cone ) + { + return false; + } +*/ + + return true; + } + +void UseObject::DamageFunc + ( + Event *ev + ) + + { + Event *e; + Entity *attacker; + int mod; + + // if this is no longer usable, return false + if ( !count ) + { + return; + } + + // what kind of damage hit us + mod = ev->GetInteger( 9 ); + + // if we don't respond to any kind of damage, and our damage types do not match, return + if ( !MOD_matches( mod, damage_type ) ) + { + return; + } + + // get the attacker + attacker = ev->GetEntity( 1 ); + + // + // decrement the use + // + if ( count > 0 ) + { + count--; + } + // setup our damage triggered event + e = new Event( EV_UseObject_DamageTriggered ); + // add our attacker + e->AddEntity( attacker ); + // start up the object with our special event + Start( e ); + } + +void UseObject::DamageTriggered + ( + Event * ev + ) + + { + // grab the attacker from our event + Stop( ev->GetEntity( 1 ) ); + } + +void UseObject::Setup + ( + Entity *activator, + Vector *org, + Vector *ang, + str *newstate + ) + + { + if ( ( spawnflags & MULTI_STATE ) && objectState ) + { + *newstate = state_backwards; + } + else + { + *newstate = state; + } + + // convert our offset to a vector in worldspace + MatrixTransformVector( offset, orientation, *org ); + *org += origin; + + *ang = angles; + ang->y += yaw_offset; + + // + // decrement the use + // + if ( count > 0 ) + { + count--; + } + } + +void UseObject::Start + ( + Event * ev + ) + + { + // + // fire off the move_thread + // + if ( move_thread.IsSet() ) + { + move_thread.Execute( this ); + } + + if ( ( spawnflags & MULTI_STATE ) && objectState ) + { + NewAnim( "move_backward", ev ); + } + else + { + NewAnim( "move", ev ); + } + + SetActiveState( NULL ); + } + +bool UseObject::Loop + ( + void + ) + + { + if ( !count ) + return qfalse; + + return qtrue; + } + +void UseObject::Stop + ( + Entity *activator + ) + + { + if( ( spawnflags & MULTI_STATE ) && objectState ) + { + NewAnim( "start" ); + } + else + { + NewAnim( "stop" ); + } + + // + // fire off our trigger target if appropriate + // + if ( triggertarget.length() ) + { + Event *event; + Entity *ent; + + ent = NULL; + do + { + ent = ( Entity * )G_FindTarget( ent, triggertarget.c_str() ); + if ( !ent ) + { + break; + } + event = new Event( EV_Activate ); + event->AddEntity( activator ); + ent->PostEvent( event, 0 ); + } + while ( 1 ); + } + + // + // fire off a thread if necessary + // + if ( ( spawnflags & MULTI_STATE ) && objectState ) + { + if ( reset_thread.IsSet() ) + { + reset_thread.Execute( this ); + } + } + else + { + if ( stop_thread.IsSet() ) + { + stop_thread.Execute( this ); + } + } + + // toggle the state + objectState ^= 1; + + if ( reset_time ) + { + count = 0; + PostEvent( EV_UseObject_Reset, reset_time ); + } + + SetActiveState( NULL ); + } + +/*****************************************************************************/ +/*QUAKED info_waypoint (0 0.5 0) (-8 -8 -8) (8 8 8) + +Used as a positioning device for objects + +******************************************************************************/ + +CLASS_DECLARATION( SimpleArchivedEntity, Waypoint, "info_waypoint" ) +{ + { NULL, NULL } +}; + +CLASS_DECLARATION( SimpleArchivedEntity, TempWaypoint, NULL ) +{ + { NULL, NULL } +}; + +/*****************************************************************************/ +/*QUAKED info_vehiclepoint (0.15 0.5 0.25) (-8 -8 -8) (8 8 8) START_STOPPING START_SKIDDING STOP_SKIDDING + +Like info_waypoints, but with spawnflags for vehicles. + +******************************************************************************/ + +Event EV_VehiclePoint_SetSpawnFlags + ( + "spawnflags", + EV_DEFAULT, + "i", + "spawn_flags", + "Sets the spawn flags." + ); + +CLASS_DECLARATION( Waypoint, VehiclePoint, NULL ) +{ + { &EV_VehiclePoint_SetSpawnFlags, &VehiclePoint::SetSpawnFlags }, +}; + +void VehiclePoint::SetSpawnFlags + ( + Event *ev + ) + +{ + spawnflags = ev->GetInteger( 1 ); +} + +/*****************************************************************************/ +/*QUAKED func_monkeybars (0.75 0.75 0.75) ? + +Monkey bars + +******************************************************************************/ + +CLASS_DECLARATION( Entity, MonkeyBars, "func_monkeybars" ) +{ + { &EV_SetAngle, &MonkeyBars::SetAngleEvent }, + { NULL, NULL } +}; + +MonkeyBars::MonkeyBars() + { + if ( LoadingSavegame ) + { + // Archive function will setup all necessary data + return; + } + setMoveType( MOVETYPE_NONE ); + setContents( CONTENTS_SHOOTONLY | MASK_SOLID ); + PostEvent( EV_BecomeSolid, 0 ); + dir = 0; + } + +void MonkeyBars::SetAngleEvent + ( + Event *ev + ) + + { + dir = ev->GetFloat( 1 ); + } + +/*****************************************************************************/ +/*QUAKED func_horizontalpipe (0.75 0.75 0.75) ? + +Horizontal pipe that play can crawl upside down on. + +******************************************************************************/ + +CLASS_DECLARATION( Entity, HorizontalPipe, "func_horizontalpipe" ) + { + { &EV_SetAngle, &HorizontalPipe::SetAngleEvent }, + { NULL, NULL } + }; + +HorizontalPipe::HorizontalPipe() + { + if ( LoadingSavegame ) + { + // Archive function will setup all necessary data + return; + } + setMoveType( MOVETYPE_NONE ); + setContents( CONTENTS_SHOOTONLY | MASK_SOLID ); + PostEvent( EV_BecomeSolid, 0 ); + dir = 0; + } + +void HorizontalPipe::SetAngleEvent + ( + Event *ev + ) + + { + dir = ev->GetFloat( 1 ); + } + +/*****************************************************************************/ +// TossObject +/*****************************************************************************/ + +Event EV_TossObject_SetBounceSound + ( + "bouncesound", + EV_DEFAULT, + "s", + "sound", + "When bouncing, what sound to play on impact", + EV_NORMAL + ); + +Event EV_TossObject_SetBounceSoundChance + ( + "bouncesoundchance", + EV_DEFAULT, + "f[0,1]", + "chance", + "When bouncing, the chance that the bounce sound will be played", + EV_NORMAL + ); + +CLASS_DECLARATION( Animate, TossObject, "TossObject" ) + { + { &EV_Touch, &TossObject::Touch }, + { &EV_Stop, &TossObject::Stop }, + { &EV_TossObject_SetBounceSound, &TossObject::SetBounceSound }, + { &EV_TossObject_SetBounceSoundChance, &TossObject::SetBounceSoundChance }, + { NULL, NULL } + }; + +TossObject::TossObject() + { + if ( LoadingSavegame ) + { + // Archive function will setup all necessary data + return; + } + setMoveType( MOVETYPE_GIB ); + setSolidType( SOLID_NOT ); + bouncesound = ""; + bouncesoundchance = 1.0f; + } + +TossObject::TossObject( str model ) + { + setMoveType( MOVETYPE_GIB ); + setSolidType( SOLID_NOT ); + bouncesound = ""; + bouncesoundchance = 1.0f; + setModel( model ); + } + +void TossObject::SetBounceSound + ( + str bounce + ) + + { + bouncesound = bounce; + } + +void TossObject::SetBounceSound + ( + Event *ev + ) + + { + bouncesound = ev->GetString( 1 ); + } + +void TossObject::SetBounceSoundChance + ( + float chance + ) + + { + bouncesoundchance = chance; + } + +void TossObject::SetBounceSoundChance + ( + Event *ev + ) + + { + bouncesoundchance = ev->GetFloat( 1 ); + } + +void TossObject::Stop + ( + Event *ev + ) + + { + setMoveType( MOVETYPE_NONE ); + setSolidType( SOLID_NOT ); + // cancel the previous fade out command + CancelEventsOfType( EV_FadeOut ); + PostEvent( EV_FadeOut, 7 + G_Random( 5 ) ); + setAngles( Vector( "0 0 0" ) ); + NewAnim( "landed" ); + } + +void TossObject::Touch + ( + Event *ev + ) + + { + Entity * ent; + + ent = ev->GetEntity( 1 ); + + // only touch the world + if ( !ent || ( ent != world ) ) + { + return; + } + // + // every time we bounce try to go back to our nominal angles + // + setAngles( angles * 0.5f ); + + if ( bouncesound.length() ) + { + if ( G_Random( 1 ) < bouncesoundchance ) + { + Sound( bouncesound ); + } + } + } + +void TossObject::SetVelocity + ( + float severity + ) + + { + setSolidType( SOLID_BBOX ); + velocity[0] = 100.0 * crandom(); + velocity[1] = 100.0 * crandom(); + velocity[2] = 200.0 + 100.0 * random(); + + avelocity = Vector( G_Random( 600 ), G_Random( 600 ), G_Random( 600 ) ); + + velocity *= severity; + + if (velocity[0] < -400) + velocity[0] = -400; + else if (velocity[0] > 400) + velocity[0] = 400; + if (velocity[1] < -400) + velocity[1] = -400; + else if (velocity[1] > 400) + velocity[1] = 400; + if (velocity[2] < 200) + velocity[2] = 200; // always some upwards + else if (velocity[2] > 600) + velocity[ 2 ] = 600; + + NewAnim( "idle" ); + + // we give it 8 seconds to fall, if not it will get faded out + PostEvent( EV_FadeOut, 8 ); + } + +/*****************************************************************************/ +/*QUAKED func_pushobject (0.75 0.75 0.75) ? + +Pushable object + +"dmg" how much damage to cause when blocked. (default 2) +"pushsound" Sound to play when object is pushed (default is none) + +******************************************************************************/ + +Event EV_PushObject_Start + ( + "start", + EV_DEFAULT, + NULL, + NULL, + "Sets up the pushobject.", + EV_NORMAL + ); + +Event EV_PushObject_SetDamage + ( + "dmg", + EV_DEFAULT, + "i", + "damage", + "Set the damage.", + EV_NORMAL + ); + +Event EV_PushObject_SetPushSound + ( + "pushsound", + EV_DEFAULT, + "s", + "sound", + "Set the pushing sound", + EV_NORMAL + ); + +CLASS_DECLARATION( Entity, PushObject, "func_pushobject" ) + { + { &EV_PushObject_Start, &PushObject::Start }, + { &EV_Blocked, &PushObject::BlockFunc }, + { &EV_PushObject_SetDamage, &PushObject::SetDamage }, + { &EV_PushObject_SetPushSound, &PushObject::SetPushSound }, + { NULL, NULL } + }; + +PushObject::PushObject() + { + if ( LoadingSavegame ) + { + // Archive function will setup all necessary data + return; + } + dmg = 2; + attack_finished = 0; + + pushsound = "object_slide"; + + PostEvent( EV_PushObject_Start, EV_POSTSPAWN ); + } + +void PushObject::SetPushSound + ( + Event *ev + ) + + { + pushsound = ev->GetString( 1 ); + } + +void PushObject::Start + ( + Event *ev + ) + + { + // make sure that this touches triggers + flags |= FL_TOUCH_TRIGGERS; + edict->clipmask = MASK_SOLID; + setSolidType( SOLID_BSP ); + setMoveType( MOVETYPE_PUSH ); + + // fix the bounding box so that the object isn't stuck in the ground + setSize( mins + Vector( 1, 1, 2 ), maxs - Vector( 1, 1, 1 ) ); + } + +qboolean PushObject::canPush + ( + Vector dir + ) + + { + trace_t trace; + + Vector end( origin.x + dir.x, origin.y + dir.y, origin.z ); + + trace = G_Trace( origin, mins, maxs, end, this, MASK_DEADSOLID, false, "PushObject::Push" ); + return ( !trace.startsolid && ( trace.fraction == 1.0f ) ); + } + +qboolean PushObject::Push + ( + Entity *pusher, + Vector move + ) + + { + trace_t trace; + + if ( pushsound.length() ) + { + if ( !edict->s.loopSound ) + { + LoopSound( pushsound ); + PostEvent( EV_StopLoopSound, level.frametime * 5 ); + } + } + + Vector end( origin.x + move.x, origin.y + move.y, origin.z ); + + trace = G_Trace( origin, mins, maxs, end, this, MASK_DEADSOLID, false, "PushObject::Push" ); + if ( !trace.startsolid && ( trace.fraction > 0 ) ) + { + owner = pusher; + + G_PushMove( this, trace.endpos - origin, vec_zero ); + + if ( edict->s.loopSound ) + PostEvent( EV_StopLoopSound, 0.f ); + + return qtrue; + } + + return qfalse; + } + +Entity *PushObject::getOwner + ( + void + ) + + { + return ( Entity * )owner; + } + +void PushObject::BlockFunc + ( + Event *ev + ) + + { + Entity *other; + + if ( ( dmg != 0 ) && ( level.time >= attack_finished ) ) + { + attack_finished = level.time + 0.5f; + other = ev->GetEntity( 1 ); + if ( other != owner ) + { + other->Damage( this, this, dmg, origin, vec_zero, vec_zero, 0, 0, MOD_CRUSH ); + } + } + } + +void PushObject::SetDamage + ( + Event *ev + ) + + { + dmg = ev->GetInteger( 1 ); + } + +#define SPAWN_AUTO_RESET ( 1 << 0 ) +#define NO_RANDOMNESS ( 1 << 1 ) +#define REMOVE_ON_GROUND ( 1 << 2 ) +/*****************************************************************************/ +/*QUAKED func_fallingrock (0.75 0.75 0.75) ? AUTO_RESET NO_RANDOMNESS REMOVE_ON_GROUND + +Creates a rock that, when triggered, begins falling and bounces along a path +specified by targetname. Use info_waypoint for the path. + +"targetname" the path to follow. +"dmg" how much damage to cause creatures it hits (default 20). +"speed" how fast to move (default 200). +"wait" how long to wait before falling when triggered (default 0). +"noise" sound to play when rock touches the world + +AUTO_RESET - when done falling, automatically return to the start +NO_RANDOMNESS - don't use any randomness when making the rocks fall +REMOVE_ON_GROUND - remove the rocks when done + +******************************************************************************/ + +Event EV_FallingRock_Bounce + ( + "bounce", + EV_DEFAULT, + NULL, + NULL, + "sent to entity when touched.", + EV_NORMAL + ); + +Event EV_FallingRock_Rotate + ( + "rotate", + EV_DEFAULT, + NULL, + NULL, + "rotates the falling rock.", + EV_NORMAL + ); + +Event EV_FallingRock_SetWait + ( + "wait", + EV_DEFAULT, + "f", + "wait", + "How long to wait before rock starts falling.", + EV_NORMAL + ); + +Event EV_FallingRock_Start + ( + "start", + EV_DEFAULT, + NULL, + NULL, + "Starts rock falling.", + EV_NORMAL + ); + +Event EV_FallingRock_SetDmg + ( + "dmg", + EV_DEFAULT, + "i", + "dmg", + "Set the damage from the rock.", + EV_NORMAL + ); + +Event EV_FallingRock_SetSpeed + ( + "speed", + EV_DEFAULT, + "f", + "speed", + "Set the speed that the rock moves at.", + EV_NORMAL + ); + +Event EV_FallingRock_SetBounceSound + ( + "noise", + EV_DEFAULT, + "s", + "sound", + "Set the sound to play when the rock bounces", + EV_NORMAL + ); + +CLASS_DECLARATION( Entity, FallingRock, "func_fallingrock" ) + { + { &EV_Activate, &FallingRock::Activate }, + { &EV_Touch, &FallingRock::Touch }, + { &EV_FallingRock_Bounce, &FallingRock::Bounce }, + { &EV_FallingRock_Rotate, &FallingRock::Rotate }, + { &EV_FallingRock_Start, &FallingRock::StartFalling }, + { &EV_FallingRock_SetWait, &FallingRock::SetWait }, + { &EV_FallingRock_SetSpeed, &FallingRock::SetSpeed }, + { &EV_FallingRock_SetDmg, &FallingRock::SetDmg }, + { &EV_FallingRock_SetBounceSound, &FallingRock::SetBounceSound }, + { NULL, NULL } + }; + +FallingRock::FallingRock() + { + if ( LoadingSavegame ) + { + // Archive function will setup all necessary data + return; + } + active = 0; + current = NULL; + setMoveType( MOVETYPE_NONE ); + wait = 0; + dmg = 20; + speed = 200; + activator = NULL; + attack_finished = 0; + + SetBounceSound( "impact_rock" ); + } + +Entity *FallingRock::SetNextBounceDir + ( + void + ) + + { + Entity *ent; + + if ( !current->target.length() ) + { + return NULL; + } + + ent = ( Entity * )G_FindTarget( NULL, current->target.c_str() ); + if ( !ent ) + { + gi.Error( ERR_DROP, "FallingRock :: Entity with targetname of '%s' not found", current->target.c_str() ); + } + + bounce_dir = ent->origin - current->origin; + bounce_dir.normalize(); + + return ent; + } + + +void FallingRock::NextBounce + ( + void + ) + + { + float time; + float distance; + Vector delta, xydelta; + float xy_speed; + float vertical_speed; + + delta = current->origin - origin; + xydelta = delta; + xydelta.z = 0; + xy_speed = speed; + + distance = xydelta.normalize(); + + time = distance / xy_speed; + + if ( !( spawnflags & NO_RANDOMNESS ) ) + { + if ( time > 1.0f ) + { + time = 0.75f + G_Random( 1 ); + } + + if ( time < 0.4f ) + { + time = 0.4f; + } + } + + vertical_speed = ( delta.z / time ) + ( 0.5f * gravity * sv_gravity->value * time ); + if ( vertical_speed < 0 ) + { + vertical_speed = 0; + } + + velocity = xydelta * xy_speed; + velocity.z = vertical_speed; + + Vector ang( 0, vectoyaw( delta ), 0 ); + ang.AngleVectors( NULL, &rotateaxis ); + + // make sure it leaves the ground + groundentity = NULL; + } + +void FallingRock::Rotate + ( + Event *ev + ) + + { + float mat[ 3 ][ 3 ]; + float ang; + + ang = 360.0f * FRAMETIME; + RotatePointAroundVector( mat[ 0 ], rotateaxis, orientation[ 0 ], ang ); + RotatePointAroundVector( mat[ 1 ], rotateaxis, orientation[ 1 ], ang ); + RotatePointAroundVector( mat[ 2 ], rotateaxis, orientation[ 2 ], ang ); + MatrixToEulerAngles( mat, angles ); + setAngles( angles ); + + if ( velocity != vec_zero ) + { + PostEvent( EV_FallingRock_Rotate, FRAMETIME ); + } + } + +void FallingRock::SetWait + ( + Event *ev + ) + + { + wait = ev->GetFloat( 1 ); + } + +void FallingRock::SetSpeed + ( + Event *ev + ) + + { + speed = ev->GetFloat( 1 ); + } + +void FallingRock::SetDmg + ( + Event *ev + ) + + { + dmg = ev->GetInteger( 1 ); + } + +void FallingRock::SetBounceSound + ( + str sound + ) + +{ + bouncesound = sound; + // cache the sound in + CacheResource( bouncesound.c_str() ); +} + +void FallingRock::SetBounceSound + ( + Event *ev + ) + + { + SetBounceSound( ev->GetString( 1 ) ); + } + +void FallingRock::Activate + ( + Event *ev + ) + + { + if ( active == 1 ) + return; + + if ( ( active == 2 ) && ( spawnflags & SPAWN_AUTO_RESET ) ) + { + current = NULL; + activator = NULL; + setMoveType( MOVETYPE_NONE ); + NoLerpThisFrame(); + setOrigin( start_origin ); + } + + activator = ev->GetEntity( 1 ); + + if ( wait ) + { + PostEvent( EV_FallingRock_Start, wait ); + } + else + { + ProcessEvent( EV_FallingRock_Start ); + } + } + +void FallingRock::StartFalling + ( + Event *ev + ) + + { + if ( current ) + { + return; + } + + if ( !active ) + { + start_origin = origin; + } + + active = 1; + setMoveType( MOVETYPE_BOUNCE ); + setSolidType( SOLID_BBOX ); + PostEvent( EV_FallingRock_Rotate, FRAMETIME ); + edict->clipmask = MASK_SOLID|CONTENTS_BODY; + + last_bounce_origin = origin; + current = this; + current = SetNextBounceDir(); + if ( current ) + { + NextBounce(); + } + } + +void FallingRock::Touch + ( + Event *ev + ) + + { + Entity *other; + + other = ev->GetEntity( 1 ); + + if ( other != world ) + { + if ( ( velocity != vec_zero ) && ( other->takedamage ) && ( level.time >= attack_finished ) ) + { + other->Damage( this, activator, dmg, origin, vec_zero, vec_zero, 20, 0, MOD_THROWNOBJECT ); + attack_finished = level.time + FRAMETIME; + } + } + + if ( !current || ( other != world ) ) + { + return; + } + if ( bouncesound.length() ) + { + Vector delta( origin - last_bounce_origin ); + + if ( delta.length() > 8 ) + { + last_bounce_origin = origin; + Sound( bouncesound.c_str(), CHAN_VOICE ); + } + } + + // we have to wait to set the velocity since the physics code + // will modify it when we return. + PostEvent( EV_FallingRock_Bounce, 0 ); + } + +void FallingRock::Bounce + ( + Event *ev + ) + + { + Vector delta; + + if ( !current ) + { + return; + } + + do + { + // check if we've passed the waypoint + delta = origin - current->origin; + if ( ( delta * bounce_dir ) >= ( -2 * edict->r.radius ) ) + { + // call any threads on the current waypoint + if ( current->isSubclassOf( Trigger ) ) + { + current->ProcessEvent( EV_Trigger_StartThread ); + } + current = SetNextBounceDir(); + if ( !current ) + { + velocity = vec_zero; + if ( spawnflags & SPAWN_AUTO_RESET ) + { + active = 2; + } + else if ( spawnflags & REMOVE_ON_GROUND ) + { + PostEvent( EV_Remove, 0 ); + } + break; + } + } + else + { + NextBounce(); + break; + } + } + while( 1 ); + } + +/*****************************************************************************/ +/*QUAKED func_ladder (0.75 0.75 0.75) ? + +Ladder trigger volume + +******************************************************************************/ + +Event EV_LadderSetup +( + "_ladder_setup", + EV_CODEONLY, + NULL, + NULL, + "Does the post spawn setup of the ladder" +); + +CLASS_DECLARATION( Entity, FuncLadder, "func_ladder" ) +{ + { &EV_Use, NULL }, + { &EV_Touch, NULL }, + { &EV_SetAngle, &FuncLadder::SetLadderFacing }, + { &EV_LadderSetup, &FuncLadder::LadderSetup }, + { NULL, NULL } +}; + +FuncLadder::FuncLadder() +{ + if( LoadingSavegame ) + { + return; + } + + PostEvent( EV_LadderSetup, EV_POSTSPAWN ); +} + +void FuncLadder::LadderSetup( Event *ev ) +{ + setMoveType( MOVETYPE_PUSH ); + + setContents( CONTENTS_LADDER ); + setSolidType( SOLID_BSP ); + + // never send to clients + edict->r.svFlags |= SVF_NOCLIENT; +} + +qboolean FuncLadder::CanUseLadder( Entity *pUser ) +{ + int iMask; + Vector vDelta; + Vector vUserFacing; + Vector start, end; + trace_t trace; + + vDelta = origin - pUser->origin; + vDelta[ 2 ] = 0; + + if( vDelta.length() > 52.0f ) { + return qfalse; + } + + AngleVectorsLeft( pUser->angles, vUserFacing, NULL, NULL ); + + iMask = pUser->client ? MASK_PLAYERSOLID : MASK_MONSTERSOLID; + + if( pUser->origin[ 2 ] + pUser->maxs[ 2 ] > absmax[ 2 ] ) + { + if( DotProduct( vUserFacing, m_vFacingDir ) <= 0.15f ) + { + vDelta = pUser->origin - origin; + vDelta[ 2 ] = 0.0f; + + if( DotProduct( m_vFacingDir, vDelta ) >= 0.0f ) + { + start = origin + m_vFacingDir * 26.0f; + start[ 2 ] = absmax[ 2 ] + 16.0f; + + end = start - Vector( 0, 0, 16 ); + + trace = G_Trace( + start, + pUser->mins, + pUser->maxs, + end, + pUser, + MASK_PLAYERSOLID, + qfalse, + "FuncLadder::CanUseLadder" + ); + + start = trace.endpos; + trace = G_Trace( + start, + pUser->mins, + pUser->maxs, + start, + pUser, + MASK_PLAYERSOLID, + qfalse, + "FuncLadder::CanUseLadder" + ); + + if( !trace.startsolid ) + { + // client can use ladder + return qtrue; + } + } + } + + return qfalse; + } + + vDelta = ( pUser->origin - origin ); + vDelta[ 2 ] = 0.0f; + + if( DotProduct( vUserFacing, m_vFacingDir ) < -0.15f || + DotProduct( vDelta, m_vFacingDir ) > 0.0f ) + { + return qfalse; + } + + start = origin - m_vFacingDir * 29.0f; + start[ 2 ] = absmin[ 2 ] + 16.0f; + + end = start; + end[ 2 ] = start[ 2 ] - 16.0f; + + trace = G_Trace( + start, + pUser->mins, + pUser->maxs, + end, + pUser, + MASK_PLAYERSOLID, + qfalse, + "FuncLadder::CanUseLadder" + ); + + if( !trace.allsolid ) + { + // client can use ladder + return qtrue; + } + + gi.DPrintf( "ladder start position is blocked by a solid object\n" ); + return qfalse; +} + +void FuncLadder::PositionOnLadder( Entity *pUser ) +{ + Vector vPos; + Vector vStart; + Vector vEnd; + trace_t trace; + + if( pUser->origin[ 2 ] + pUser->maxs[ 2 ] > absmax[ 2 ] ) + { + vEnd = origin + m_vFacingDir * 26.0f; + vEnd[ 2 ] = absmax[ 2 ] + 2.0f; + } + else if( absmin[ 2 ] + 32.0f > pUser->origin[ 2 ] ) + { + vEnd = origin - m_vFacingDir * 29.0f; + vEnd[ 2 ] = absmin[ 2 ] + 2.0f; + } + else + { + vEnd = origin - m_vFacingDir * 16.0f; + vEnd[ 2 ] = pUser->origin[ 2 ] + 8.0f; + } + + vStart = vEnd; + + trace = G_Trace( + vStart, + pUser->mins, + pUser->maxs, + vEnd, + pUser, + MASK_PLAYERSOLID, + qtrue, + "FuncLadder::PositionOnLadder" ); + + if( trace.allsolid ) + { + vStart = pUser->origin; + vStart[ 2 ] = pUser->origin[ 2 ] + 4.0f; + + vEnd = origin - m_vFacingDir * 16.0f; + vEnd[ 2 ] = pUser->origin[ 2 ] + 4.0f; + + trace = G_Trace( + vStart, + pUser->mins, + pUser->maxs, + vEnd, + pUser, + MASK_PLAYERSOLID, + qtrue, + "FuncLadder::PositionOnLadder2" ); + } + + pUser->setOrigin( trace.endpos ); + pUser->setAngles( m_vFacingAngles ); +} + +void FuncLadder::SetLadderFacing( Event *ev ) +{ + m_vFacingAngles = vec_zero; + m_vFacingAngles[ 1 ] = AngleMod( ev->GetFloat( 1 ) ); + + AngleVectorsLeft( m_vFacingAngles, m_vFacingDir, NULL, NULL ); +} + +void FuncLadder::AdjustPositionOnLadder( Entity *pUser ) +{ + float fHeight; + Vector vDelta; + Vector vPos; + Vector vStart; + trace_t trace; + + vDelta = pUser->origin - origin; + vDelta[ 2 ] = 0; + + fHeight = ( ( int )( pUser->origin[ 2 ] + 8.0f ) & ~15 ); + + if( vDelta.length() > 16.0f && pUser->origin[ 2 ] == fHeight ) + { + return; + } + + vPos = origin - m_vFacingDir * 16.0f; + vPos[ 2 ] = fHeight; + + vStart = vPos + m_vFacingDir * -16.0f; + + trace = G_Trace( vStart, + pUser->mins, + pUser->maxs, + vPos, + pUser, + MASK_PLAYERSOLID, + qtrue, + "FuncLadder::AdjustPositionOnLadder" ); + + if( trace.allsolid || trace.startsolid ) + { + trace = G_Trace( pUser->origin, + pUser->mins, + pUser->maxs, + vPos, + pUser, + MASK_PLAYERSOLID, + qtrue, + "FuncLadder::AdjustPositionOnLadder" ); + } + + pUser->setOrigin( trace.endpos ); +} + +void FuncLadder::EnsureOverLadder( Entity *pUser ) +{ + float fHeight = absmax[ 2 ]; + Vector vStart; + Vector vPos; + trace_t trace; + + if( pUser->origin[ 2 ] - fHeight >= 8.0f ) { + return; + } + + vPos = pUser->origin; + vPos[ 2 ] = fHeight + 16.0f; + + vStart = pUser->origin + m_vFacingDir * -16.0f; + + trace = G_Trace( vStart, + pUser->mins, + pUser->maxs, + vPos, + pUser->edict, + MASK_PLAYERSOLID, + true, + "FuncLadder::EnsureOverLadder" ); + + if( trace.startsolid || trace.allsolid ) + { + trace = G_Trace( origin, + mins, + maxs, + vPos, + pUser->edict, + MASK_PLAYERSOLID, + true, + "FuncLadder::EnsureOverLadder" ); + } + + pUser->setOrigin( trace.endpos ); +} + +void FuncLadder::EnsureForwardOffLadder( Entity *pUser ) +{ + int iMask; + Vector vStart; + Vector vPos; + Vector vDelta; + trace_t trace; + + if( pUser->origin[ 2 ] - absmax[ 2 ] >= 8.0f ) { + return; + } + + iMask = pUser->client ? MASK_PLAYERSOLID : MASK_MONSTERSOLID; + + vPos = pUser->origin; + vPos[ 2 ] = absmax[ 2 ] + 16.0f; + + vStart = vPos + m_vFacingDir * -16.0f; + + trace = G_Trace( + vStart, + pUser->mins, + pUser->maxs, + vPos, + pUser, + iMask, + qtrue, + "FuncLadder::EnsureOverLadder" ); + + if( trace.allsolid || trace.startsolid ) + { + trace = G_Trace( + pUser->origin, + pUser->mins, + pUser->maxs, + vPos, + pUser, + iMask, + qtrue, + "FuncLadder::EnsureOverLadder" ); + } + + pUser->setOrigin( trace.endpos ); +} diff --git a/code/game/misc.h b/code/game/misc.h new file mode 100644 index 00000000..3547eb3b --- /dev/null +++ b/code/game/misc.h @@ -0,0 +1,604 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// misc.h: +// Basically the big stew pot of the DLLs, or maybe a garbage bin, whichever +// metaphore you prefer. This really should be cleaned up. Anyway, this +// should contain utility functions that could be used by any entity. +// Right now it contains everything from entities that could be in their +// own file to my mother pot roast recipes. +// + +#ifndef __MISC_H__ +#define __MISC_H__ + +#include "g_local.h" +#include "entity.h" +#include "mover.h" +#include "animate.h" + +class InfoNull : public Entity + { + public: + CLASS_PROTOTYPE( InfoNull ); + + InfoNull(); + }; + +class FuncRemove : public Entity + { + public: + CLASS_PROTOTYPE( FuncRemove ); + + FuncRemove(); + }; + +class MiscModel : public Entity + { + public: + CLASS_PROTOTYPE( MiscModel ); + + MiscModel(); + }; + +class InfoNotNull : public Entity + { + public: + CLASS_PROTOTYPE( InfoNotNull ); + }; + +class ExplodingWall : public Trigger + { + protected: + int dmg; + int explosions; + float attack_finished; + Vector land_angles; + float land_radius; + float angle_speed; + int state; + Vector base_velocity; + Vector random_velocity; + Vector orig_mins, orig_maxs; + qboolean on_ground; + + public: + CLASS_PROTOTYPE( ExplodingWall ); + + ExplodingWall(); + void Setup( Event *ev ); + void AngleSpeed( Event *ev ); + void LandRadius( Event *ev ); + void LandAngles( Event *ev ); + void BaseVelocity( Event *ev ); + void RandomVelocity( Event *ev ); + void SetDmg( Event *ev ); + void SetExplosions( Event *ev ); + void SetupSecondStage( void ); + void Explode( Event *ev ); + void DamageEvent( Event *ev ); + void GroundDamage( Event *ev ); + void TouchFunc( Event *ev ); + void StopRotating( Event *ev ); + void CheckOnGround( Event *ev ); + void Archive( Archiver &arc ); + }; + +inline void ExplodingWall::Archive + ( + Archiver &arc + ) + { + Trigger::Archive( arc ); + + arc.ArchiveInteger( &dmg ); + arc.ArchiveInteger( &explosions ); + arc.ArchiveFloat( &attack_finished ); + arc.ArchiveVector( &land_angles ); + arc.ArchiveFloat( &land_radius ); + arc.ArchiveFloat( &angle_speed ); + arc.ArchiveInteger( &state ); + arc.ArchiveVector( &base_velocity ); + arc.ArchiveVector( &random_velocity ); + arc.ArchiveVector( &orig_mins ); + arc.ArchiveVector( &orig_maxs ); + arc.ArchiveBoolean( &on_ground ); + } + + +class Teleporter : public Trigger + { + public: + ScriptThreadLabel teleport_label; + qboolean in_use; + + CLASS_PROTOTYPE( Teleporter ); + + Teleporter(); + virtual void StartTeleport( Event *ev ); + virtual void Teleport( Event *ev ); + virtual void StopTeleport( Event *ev ); + void SetThread( Event *ev ); + virtual void Archive( Archiver &arc ); + }; + +inline void Teleporter::Archive + ( + Archiver &arc + ) + { + Trigger::Archive( arc ); + + arc.ArchiveBoolean( &in_use ); + } + +class TeleporterDestination : public Entity + { + public: + Vector movedir; + + CLASS_PROTOTYPE( TeleporterDestination ); + + TeleporterDestination(); + void SetMoveDir( Event *ev ); + virtual void Archive( Archiver &arc ); + }; + +inline void TeleporterDestination::Archive + ( + Archiver &arc + ) + { + Entity::Archive( arc ); + + arc.ArchiveVector( &movedir ); + } + +class UseAnim : public Entity + { + public: + int count; + qboolean active; + ScriptThreadLabel thread; + str triggertarget; + int num_loops; + str state; + str camera; + str anim; + str key; + float delay; + float last_active_time; + + CLASS_PROTOTYPE( UseAnim ); + + UseAnim(); + virtual void Touched( Event *ev ); + void Reset( Event *ev ); + void SetThread( Event * ev ); + void SetTriggerTarget( Event * ev ); + void SetCount( Event * ev ); + void SetAnim( Event *ev ); + void SetState( Event *ev ); + void SetKey( Event *ev ); + void SetCamera( Event *ev ); + void SetNumLoops( Event *ev ); + void SetDelay( Event *ev ); + bool canBeUsed( Entity *activator ); + bool GetInformation( Entity *activator, Vector * org, Vector * angles, str * animatoin, int * loopcount, str * state, str * camera ); + void TriggerTargets( Entity *activator ); + virtual void Archive( Archiver &arc ); + }; + +inline void UseAnim::Archive + ( + Archiver &arc + ) + { + Entity::Archive( arc ); + + arc.ArchiveInteger( &count ); + arc.ArchiveBoolean( &active ); + arc.ArchiveString( &triggertarget ); + arc.ArchiveInteger( &num_loops ); + arc.ArchiveString( &state ); + arc.ArchiveString( &camera ); + arc.ArchiveString( &anim ); + arc.ArchiveString( &key ); + arc.ArchiveFloat( &delay ); + arc.ArchiveFloat( &last_active_time ); + } + +class TouchAnim : public UseAnim + { + public: + + CLASS_PROTOTYPE( TouchAnim ); + + TouchAnim(); + }; + + +class UseAnimDestination : public Entity + { + public: + int num_loops; + str state; + str anim; + + CLASS_PROTOTYPE( UseAnimDestination ); + + UseAnimDestination(); + void SetAnim( Event *ev ); + void SetState( Event *ev ); + void SetNumLoops( Event *ev ); + int GetNumLoops( void ); + str GetAnim( void ); + str GetState( void ); + virtual void Archive( Archiver &arc ); + }; + +inline void UseAnimDestination::Archive + ( + Archiver &arc + ) + { + Entity::Archive( arc ); + + arc.ArchiveInteger( &num_loops ); + arc.ArchiveString( &state ); + arc.ArchiveString( &anim ); + } + +class UseObject : public Animate + { + public: + ScriptThreadLabel move_thread; + ScriptThreadLabel stop_thread; + ScriptThreadLabel reset_thread; + str triggertarget; + Vector offset; + float yaw_offset; + int count; + float cone; + str state; + str state_backwards; + str useMaterial; + int objectState; + float reset_time; + qboolean active; + + CLASS_PROTOTYPE( UseObject ); + + UseObject(); + void SetMoveThread( Event * ev ); + void SetStopThread( Event * ev ); + void SetResetThread( Event * ev ); + void SetTriggerTarget( Event * ev ); + void SetOffset( Event * ev ); + void SetYawOffset( Event * ev ); + void SetCount( Event * ev ); + void SetCone( Event * ev ); + void SetState( Event * ev ); + void SetBackwardsState( Event * ev ); + void SetResetTime( Event * ev ); + void Reset( Event * ev ); + void Resetting( Event * ev ); + void DamageTriggered( Event * ev ); + void DamageFunc( Event * ev ); + bool canBeUsed( Vector org, Vector dir ); + void Setup( Entity *activator, Vector *org, Vector *ang, str *newstate ); + void Start( Event * ev = NULL ); + bool Loop( void ); + void SetActiveState( Event *ev ); + void Stop( Entity *activator ); + void ActivateEvent( Event *ev ); + void DeactivateEvent( Event *ev ); + void UseMaterialEvent( Event *ev ); + virtual void Archive( Archiver &arc ); + }; + +inline void UseObject::Archive + ( + Archiver &arc + ) + { + Animate::Archive( arc ); + + arc.ArchiveString( &triggertarget ); + arc.ArchiveVector( &offset ); + arc.ArchiveFloat( &yaw_offset ); + arc.ArchiveInteger( &count ); + arc.ArchiveFloat( &cone ); + arc.ArchiveString( &state ); + arc.ArchiveString( &state_backwards ); + arc.ArchiveString( &useMaterial ); + arc.ArchiveInteger( &objectState ); + arc.ArchiveFloat( &reset_time ); + arc.ArchiveBoolean( &active ); + } + + +class Waypoint : public SimpleArchivedEntity +{ +public: + CLASS_PROTOTYPE( Waypoint ); +}; + +class TempWaypoint : public SimpleArchivedEntity +{ +public: + CLASS_PROTOTYPE( TempWaypoint ); +}; + +class VehiclePoint : public Waypoint +{ +public: + unsigned int spawnflags; + + CLASS_PROTOTYPE( VehiclePoint ); + + void SetSpawnFlags( Event *ev ); + virtual void Archive( Archiver& arc ); +}; + +inline void VehiclePoint::Archive + ( + Archiver &arc + ) + +{ + SimpleArchivedEntity::Archive( arc ); + + arc.ArchiveUnsigned( &spawnflags ); +} + +class MonkeyBars : public Entity + { + public: + float dir; + + CLASS_PROTOTYPE( MonkeyBars ); + + MonkeyBars(); + void SetAngleEvent( Event *ev ); + + virtual void Archive( Archiver &arc ); + }; + +inline void MonkeyBars::Archive + ( + Archiver &arc + ) + + { + Entity::Archive( arc ); + + arc.ArchiveFloat( &dir ); + } + +class HorizontalPipe : public Entity + { + public: + float dir; + + CLASS_PROTOTYPE( HorizontalPipe ); + + HorizontalPipe(); + void SetAngleEvent( Event *ev ); + + virtual void Archive( Archiver &arc ); + }; + +inline void HorizontalPipe::Archive + ( + Archiver &arc + ) + + { + Entity::Archive( arc ); + + arc.ArchiveFloat( &dir ); + } + +class TossObject : public Animate + { + private: + str bouncesound; + float bouncesoundchance; + void Stop( Event *ev ); + void Touch( Event *ev ); + void SetBounceSound( Event *ev ); + void SetBounceSoundChance( Event *ev ); + public: + CLASS_PROTOTYPE( TossObject ); + + TossObject(); + TossObject( str modelname ); + void SetBounceSound( str bounce ); + void SetBounceSoundChance( float chance ); + void SetVelocity( float severity ); + virtual void Archive( Archiver &arc ); + }; + +inline void TossObject::Archive + ( + Archiver &arc + ) + + { + Animate::Archive( arc ); + + arc.ArchiveString( &bouncesound ); + arc.ArchiveFloat( &bouncesoundchance ); + } + + +class PushObject : public Entity + { + private: + EntityPtr owner; + float attack_finished; + int dmg; + str pushsound; + + public: + CLASS_PROTOTYPE( PushObject ); + + PushObject(); + void Start( Event *ev ); + void SetDamage( Event *ev ); + void BlockFunc( Event *ev ); + void SetPushSound( Event *ev ); + qboolean Push( Entity *pusher, Vector move ); + qboolean canPush( Vector dir ); + + Entity *getOwner( void ); + + virtual void Archive( Archiver &arc ); + }; + +inline void PushObject::Archive + ( + Archiver &arc + ) + { + Entity::Archive( arc ); + + arc.ArchiveSafePointer( &owner ); + arc.ArchiveFloat( &attack_finished ); + arc.ArchiveInteger( &dmg ); + arc.ArchiveString( &pushsound ); + } + +class FallingRock : public Entity + { + private: + int active; + Vector start_origin; + Vector last_bounce_origin; + Entity *current; + Entity *activator; + Vector bounce_dir; + Vector rotateaxis; + float attack_finished; + float wait; + float speed; + int dmg; + str bouncesound; + + void Touch( Event *ev ); + void Bounce( Event *ev ); + void Rotate( Event *ev ); + void Activate( Event *ev ); + void NextBounce( void ); + void StartFalling( Event *ev ); + void SetWait( Event *ev ); + void SetSpeed( Event *ev ); + void SetDmg( Event *ev ); + Entity *SetNextBounceDir( void ); + void SetBounceSound( str sound ); + void SetBounceSound( Event *ev ); + virtual void Archive( Archiver &arc ); + + public: + CLASS_PROTOTYPE( FallingRock ); + + FallingRock(); + }; + +inline void FallingRock::Archive + ( + Archiver &arc + ) + + { + Entity::Archive( arc ); + + arc.ArchiveInteger( &active ); + arc.ArchiveVector( &start_origin ); + arc.ArchiveVector( &last_bounce_origin ); + arc.ArchiveObjectPointer( ( Class ** )¤t ); + arc.ArchiveObjectPointer( ( Class ** )&activator ); + arc.ArchiveVector( &bounce_dir ); + arc.ArchiveVector( &rotateaxis ); + arc.ArchiveFloat( &attack_finished ); + arc.ArchiveFloat( &wait ); + arc.ArchiveFloat( &speed ); + arc.ArchiveInteger( &dmg ); + arc.ArchiveString( &bouncesound ); + if ( arc.Loading() ) + { + SetBounceSound( bouncesound ); + } + } + + +class SupplyWater : public Trigger + { + private: + int maxwater; + int amount; + public: + CLASS_PROTOTYPE( SupplyWater ); + + SupplyWater(); + void Activate( Event *ev ); + void MaxWater( Event *ev ); + void ChargeOff( Event *ev ); + virtual void Archive( Archiver &arc ); + }; + +inline void SupplyWater::Archive + ( + Archiver &arc + ) + + { + Trigger::Archive( arc ); + + arc.ArchiveInteger( &amount ); + arc.ArchiveInteger( &maxwater ); + } + +class FuncLadder : public Entity { +private: + Vector m_vFacingAngles; + Vector m_vFacingDir; + +public: + CLASS_PROTOTYPE( FuncLadder ); + + FuncLadder(); + + void LadderSetup( Event *ev ); + + qboolean CanUseLadder( Entity *pUser ); + void PositionOnLadder( Entity *pUser ); + + void SetLadderFacing( Event *ev ); + void AdjustPositionOnLadder( Entity *pUser ); + + void EnsureOverLadder( Entity *pUser ); + void EnsureForwardOffLadder( Entity *pUser ); +}; + +#endif /* misc.h */ diff --git a/code/game/movegrid.cpp b/code/game/movegrid.cpp new file mode 100644 index 00000000..78e82a7c --- /dev/null +++ b/code/game/movegrid.cpp @@ -0,0 +1,151 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// movegrid.h: Move grid +// + +#include "movegrid.h" + +// FIXME: undone class + +cMoveGrid::cMoveGrid( int x, int y, int z ) +{ + m_iXRes = x; + m_iYRes = y; + m_iZRes = z; + + GridPoints = ( gridpoint_t * )gi.Malloc( sizeof( gridpoint_t ) * x * y * z ); +} + +cMoveGrid::~cMoveGrid() +{ + gi.Free( GridPoints ); +} + +void cMoveGrid::SetOrientation + ( + float( *v )[ 3 ] + ) + +{ + for( int i = 0; i < 3; i++ ) + { + VectorCopy( v[ i ], orientation[ i ] ); + } +} + +void cMoveGrid::SetMoveInfo + ( + vmove_t *vm + ) + +{ + memcpy( &v, vm, sizeof( vmove_t ) ); +} + +void cMoveGrid::CalculateBoxPoints + ( + void + ) + +{ + // FIXME: stub +} + +gridpoint_t *cMoveGrid::GetGridPoint + ( + int x, + int y, + int z + ) + +{ + return &GridPoints[ x * m_iZRes + y * m_iXRes + z ]; +} + +void cMoveGrid::Move + ( + void + ) + +{ + int x; + int y; + int z; + Vector vBoxSize; + Vector old_origin; + + CalculateBoxPoints(); + + for( x = 0; x < m_iXRes; x++ ) + { + for( y = 0; y < m_iYRes; y++ ) + { + for( z = 0; z < m_iZRes; z++ ) + { + } + } + } + + // FIXME: stub + // this is not called anyways +} + +qboolean cMoveGrid::CheckStuck + ( + void + ) + +{ + int x; + int y; + int z; + trace_t trace; + + for( x = 0; x < m_iXRes; x++ ) + { + for( y = 0; y < m_iYRes; y++ ) + { + for( z = 0; z < m_iZRes; z++ ) + { + gi.Trace( &trace, v.vs->origin, v.mins, v.maxs, v.vs->origin, v.vs->entityNum, v.tracemask, false, false ); + + if( trace.allsolid || trace.startsolid || trace.fraction == 0.0f ) + { + return true; + } + } + } + } + + return false; +} + +void cMoveGrid::GetMoveInfo + ( + vmove_t *vm + ) + +{ + memcpy( vm, &v, sizeof( vmove_t ) ); +} + diff --git a/code/game/movegrid.h b/code/game/movegrid.h new file mode 100644 index 00000000..1ba6eb1a --- /dev/null +++ b/code/game/movegrid.h @@ -0,0 +1,123 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// movegrid.h: Move grid +// + +#ifndef __MOVEGRID_H__ +#define __MOVEGRID_H__ + +#include "g_local.h" +#include +#include + +typedef struct vehicleState_s { + float origin[ 3 ]; + float velocity[ 3 ]; + int groundEntityNum; + qboolean walking; + qboolean groundPlane; + trace_t groundTrace; + int entityNum; + float desired_dir[ 2 ]; + qboolean hit_obstacle; + float hit_origin[ 3 ]; + float obstacle_normal[ 3 ]; + qboolean useGravity; +} vehicleState_t; + +typedef struct vmove_s { + vehicleState_t *vs; + float frametime; + float desired_speed; + int tracemask; + int numtouch; + int touchents[ 32 ]; + float mins[ 3 ]; + float maxs[ 3 ]; +} vmove_t; + +typedef struct gridpoint_s { + Vector origin; + Vector neworigin; + Vector origindelta; + Vector changed; + Vector newvel; + gentity_t *groundentity; + vmove_t vm; + vehicleState_t vs; +} gridpoint_t; + +class cMoveGrid : public Class +{ +public: + gridpoint_t *GridPoints; + +private: + vmove_t v; + float orientation[ 3 ][ 3 ]; + int m_iXRes; + int m_iYRes; + int m_iZRes; + +public: + cMoveGrid( int x, int y, int z ); + virtual ~cMoveGrid(); + + void SetOrientation( float( *v)[ 3 ] ); + void SetMoveInfo( vmove_t *vm ); + void CalculateBoxPoints( void ); + gridpoint_t *GetGridPoint( int x, int y, int z ); + void Move( void ); + qboolean CheckStuck( void ); + void GetMoveInfo( vmove_t *vm ); + void Archive( Archiver& arc ); +}; + +inline void cMoveGrid::Archive + ( + Archiver& arc + ) + +{ + arc.ArchiveInteger( &m_iXRes ); + arc.ArchiveInteger( &m_iYRes ); + arc.ArchiveInteger( &m_iZRes ); + arc.ArchiveRaw( &v, sizeof( vmove_t ) ); + arc.ArchiveVec3( orientation[ 0 ] ); + arc.ArchiveVec3( orientation[ 1 ] ); + arc.ArchiveVec3( orientation[ 2 ] ); + + if( arc.Loading() ) + { + if( GridPoints ) + { + if( m_iXRes != 3 && m_iYRes != 3 && m_iZRes != 1 ) + { + gi.Free( GridPoints ); + GridPoints = ( gridpoint_t * )gi.Malloc( sizeof( gridpoint_t ) * m_iXRes * m_iYRes * m_iZRes ); + } + } + } +} + +#endif diff --git a/code/game/mover.cpp b/code/game/mover.cpp new file mode 100644 index 00000000..40186450 --- /dev/null +++ b/code/game/mover.cpp @@ -0,0 +1,283 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// mover.cpp: Base class for any object that needs to move to specific locations over a +// period of time. This class is kept separate from most entities to keep +// class size down for objects that don't need such behavior. +// + +#include "g_local.h" +#include "entity.h" +#include "trigger.h" +#include "mover.h" + +#define MOVE_ANGLES 1 +#define MOVE_ORIGIN 2 + +CLASS_DECLARATION( Trigger, Mover, "mover" ) + { + { &EV_MoveDone, &Mover::MoveDone }, + { NULL, NULL } + }; + + +Mover::Mover() + { + endevent = NULL; + } + +Mover::~Mover() + { + } + +void Mover::MoveDone + ( + Event *ev + ) + +{ + Event * event; + Vector move; + Vector amove; + + // zero out the movement + if( moveflags & MOVE_ANGLES ) + { + avelocity = vec_zero; + amove = angledest - localangles; + } + else + { + amove = vec_zero; + } + + if( moveflags & MOVE_ORIGIN ) + { + velocity = vec_zero; + move = finaldest - localorigin; + } + else + { + move = vec_zero; + } + + if( !G_PushMove( this, move, amove ) ) + { + // Delay finish till we can move into the final position + PostEvent( EV_MoveDone, FRAMETIME ); + return; + } + + // + // After moving, set origin to exact final destination + // + if( moveflags & MOVE_ORIGIN ) + { + setLocalOrigin( finaldest ); + } + + if( moveflags & MOVE_ANGLES ) + { + localangles = angledest; + + if( ( localangles.x >= 360 ) || ( localangles.x < 0 ) ) + { + localangles.x -= ( ( int )localangles.x / 360 ) * 360; + } + if( ( localangles.y >= 360 ) || ( localangles.y < 0 ) ) + { + localangles.y -= ( ( int )localangles.y / 360 ) * 360; + } + if( ( localangles.z >= 360 ) || ( localangles.z < 0 ) ) + { + localangles.z -= ( ( int )localangles.z / 360 ) * 360; + } + } + + event = endevent; + endevent = NULL; + + if( event ) + ProcessEvent( event ); +} + +/* +============= +MoveTo + +calculate self.velocity and self.nextthink to reach dest from +self.origin traveling at speed +=============== +*/ +void Mover::MoveTo( Vector tdest, Vector angdest, float tspeed, Event& event ) +{ + Vector vdestdelta; + Vector angdestdelta; + float len; + float traveltime; + + assert( tspeed >= 0.0f ); + + if( !tspeed ) + { + error( "MoveTo", "No speed is defined!" ); + } + + if( tspeed < 0.0f ) + { + error( "MoveTo", "Speed is negative!" ); + } + + // Cancel previous moves + CancelEventsOfType( EV_MoveDone ); + + moveflags = 0; + + if( endevent ) + { + delete endevent; + } + + endevent = new Event( event ); + + finaldest = tdest; + angledest = angdest; + + if( finaldest != localorigin ) + { + moveflags |= MOVE_ORIGIN; + } + if( angledest != localangles ) + { + moveflags |= MOVE_ANGLES; + } + + if( !moveflags ) + { + // stop the object from moving + velocity = vec_zero; + avelocity = vec_zero; + + // post the event so we don't wait forever + PostEvent( EV_MoveDone, FRAMETIME ); + return; + } + + // set destdelta to the vector needed to move + vdestdelta = tdest - localorigin; + angdestdelta[ 0 ] = angledist( angdest[ 0 ] - localangles[ 0 ] ); + angdestdelta[ 1 ] = angledist( angdest[ 1 ] - localangles[ 1 ] ); + angdestdelta[ 2 ] = angledist( angdest[ 2 ] - localangles[ 2 ] ); + + if( tdest == localorigin ) + { + // calculate length of vector based on angles + len = angdestdelta.length(); + } + else + { + // calculate length of vector based on distance + len = vdestdelta.length(); + } + + // divide by speed to get time to reach dest + traveltime = len / tspeed; + + if( traveltime < level.frametime ) + { + traveltime = level.frametime; + vdestdelta = vec_zero; + angdestdelta = vec_zero; + } + + // scale the destdelta vector by the time spent traveling to get velocity + if( moveflags & MOVE_ORIGIN ) + { + velocity = vdestdelta * ( 1.0f / traveltime ); + } + + if( moveflags & MOVE_ANGLES ) + { + avelocity = angdestdelta * ( 1.0f / traveltime ); + } + + PostEvent( EV_MoveDone, traveltime ); +} + +/* +============= +LinearInterpolate +=============== +*/ +void Mover::LinearInterpolate + ( + Vector tdest, + Vector angdest, + float time, + Event &event + ) + +{ + Vector vdestdelta; + Vector angdestdelta; + float t; + + if( endevent ) + { + delete endevent; + } + endevent = new Event( event ); + finaldest = tdest; + angledest = angdest; + + // Cancel previous moves + CancelEventsOfType( EV_MoveDone ); + + // Quantize to FRAMETIME + if( time < FRAMETIME ) + { + time = FRAMETIME; + } + + moveflags = 0; + t = 1 / time; + // scale the destdelta vector by the time spent traveling to get velocity + if( finaldest != localorigin ) + { + vdestdelta = tdest - localorigin; + velocity = vdestdelta * t; + moveflags |= MOVE_ORIGIN; + } + + if( angledest != localangles ) + { + angdestdelta = angdest - localangles; + avelocity = angdestdelta * t; + moveflags |= MOVE_ANGLES; + } + + if( g_bBeforeThinks ) + time -= FRAMETIME; + + PostEvent( EV_MoveDone, time ); +} + diff --git a/code/game/mover.h b/code/game/mover.h new file mode 100644 index 00000000..c49f9ccb --- /dev/null +++ b/code/game/mover.h @@ -0,0 +1,68 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// mover.h: DESCRIPTION: +// Base class for any object that needs to move to specific locations over a +// period of time. This class is kept separate from most entities to keep +// class size down for objects that don't need such behavior. +// + +#ifndef __MOVER_H__ +#define __MOVER_H__ + +#include "g_local.h" +#include "entity.h" +#include "trigger.h" + +class Mover : public Trigger + { + private: + Vector finaldest; + Vector angledest; + Event *endevent; + int moveflags; + + public: + CLASS_PROTOTYPE( Mover ); + + Mover(); + virtual ~Mover(); + void MoveDone( Event *ev ); + void MoveTo( Vector tdest, Vector angdest, float tspeed, Event &event ); + void LinearInterpolate( Vector tdest, Vector angdest, float time, Event &event ); + virtual void Archive( Archiver &arc ); + }; + +inline void Mover::Archive + ( + Archiver &arc + ) + { + Trigger::Archive( arc ); + + arc.ArchiveVector( &finaldest ); + arc.ArchiveVector( &angledest ); + arc.ArchiveEventPointer( &endevent ); + arc.ArchiveInteger( &moveflags ); + } + +#endif diff --git a/code/game/nature.cpp b/code/game/nature.cpp new file mode 100644 index 00000000..122ea8b5 --- /dev/null +++ b/code/game/nature.cpp @@ -0,0 +1,175 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// nature.cpp: nature + +#include "nature.h" + +/*****************************************************************************/ +/*QUAKED func_emitter (0 0.25 0.5) ? + +"emitter" - Name of emitter to use. +******************************************************************************/ +Event EV_Emitter_EmitterName + ( + "emitter", + EV_DEFAULT, + "s", + "name", + "Emitter to use", + EV_NORMAL + ); + +CLASS_DECLARATION( Entity, Emitter, "func_emitter" ) + { + { &EV_Emitter_EmitterName, &Emitter::EmitterName }, + }; + +Emitter::Emitter + ( + ) + + { + edict->s.eType = ET_EMITTER; + } + +void Emitter::setEmitter + ( + str name + ) + + { + emitterName = name; + edict->s.tag_num = gi.imageindex( emitterName ); + } + +void Emitter::EmitterName + ( + Event *ev + ) + + { + setEmitter( ev->GetString( 1 ) ); + } + +/*****************************************************************************/ +/*QUAKED func_rain (0 0.25 0.5) ? + +This creates a raining effect in the brush + +"emitter" - Name of emitter to use for the rain. +******************************************************************************/ + +CLASS_DECLARATION( Entity, Rain, "func_rain" ) + { + { NULL, NULL } + }; + + +Rain::Rain + ( + ) + + { + if ( LoadingSavegame ) + { + // Archive function will setup all necessary data + return; + } + setSolidType( SOLID_NOT ); + edict->s.eType = ET_RAIN; + setRainName( "defaultrain" ); + } + +void Rain::setRainName + ( + str name + ) + + { + rainName = name; + edict->s.tag_num = gi.imageindex( rainName ); + } + + +/*****************************************************************************/ +/* Plant Puffdaddy */ +/*****************************************************************************/ + +Event EV_PuffDaddy_Idle + ( + "idle", + EV_DEFAULT, + NULL, + NULL, + "Animates the puff daddy.", + EV_NORMAL + ); + +CLASS_DECLARATION( Animate, PuffDaddy, "plant_puffdaddy" ) + { + { &EV_Touch, &PuffDaddy::Touch }, + { &EV_PuffDaddy_Idle, &PuffDaddy::Idle }, + { NULL, NULL } + }; + +void PuffDaddy::Idle( Event *ev ) +{ + NewAnim( "idle" ); +} + +void PuffDaddy::Touch + ( + Event *ev + ) + + { + Entity *other; + + other = ev->GetEntity( 1 ); + + if ( !other->inheritsFrom( "Sentient" ) ) + return; + + NewAnim( "touch", EV_PuffDaddy_Idle ); + //SetFrame( 0 ); + + SurfaceCommand( "puffdaddy", "+nodraw" ); + setSolidType( SOLID_NOT ); + } + +PuffDaddy::PuffDaddy + ( + ) + + { + if ( LoadingSavegame ) + { + // Archive function will setup all necessary data + return; + } + setSolidType( SOLID_TRIGGER ); + edict->s.eType = ET_MODELANIM; + setModel( "plant_puffdaddy.tik" ); + PostEvent( EV_Show, 0 ); + //showModel(); + } diff --git a/code/game/nature.h b/code/game/nature.h new file mode 100644 index 00000000..e3c4dda0 --- /dev/null +++ b/code/game/nature.h @@ -0,0 +1,91 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// nature.h: + +#include "g_local.h" +#include "trigger.h" + +class Emitter : public Entity + { + private: + str emitterName; + void setEmitter( str name ); + void EmitterName( Event *ev ); + public: + CLASS_PROTOTYPE( Emitter ); + Emitter(); + virtual void Archive( Archiver &arc ); + }; + +inline void Emitter::Archive + ( + Archiver &arc + ) + { + Entity::Archive( arc ); + + arc.ArchiveString( &emitterName ); + if ( arc.Loading() ) + { + setEmitter( emitterName ); + } + } + + +class Rain : public Emitter + { + private: + str rainName; + void setRainName( str name ); + public: + CLASS_PROTOTYPE( Rain ); + Rain(); + virtual void Archive( Archiver &arc ); + }; + +inline void Rain::Archive + ( + Archiver &arc + ) + { + Entity::Archive( arc ); + + arc.ArchiveString( &rainName ); + if ( arc.Loading() ) + { + setRainName( rainName ); + } + } + + +class PuffDaddy : public Animate + { + private: + void Touch( Event *ev ); + void Idle( Event *ev ); + + public: + CLASS_PROTOTYPE( PuffDaddy ); + PuffDaddy(); + }; + diff --git a/code/game/navigate.cpp b/code/game/navigate.cpp new file mode 100644 index 00000000..41c44084 --- /dev/null +++ b/code/game/navigate.cpp @@ -0,0 +1,3486 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// navigate.cpp: C++ implementation of the A* search algorithm. +// + +#include "g_local.h" +#include "navigate.h" +#include "misc.h" +#include "doors.h" +#include "actor.h" +#include "player.h" + +#define PATHFILE_VERSION 103 + +int path_checkthisframe; +cvar_t *ai_showroutes; +cvar_t *ai_showroutes_distance; +cvar_t *ai_shownodenums; +cvar_t *ai_shownode; +cvar_t *ai_showallnode; +cvar_t *ai_showpath; +cvar_t *ai_fallheight; +cvar_t *ai_debugpath; +cvar_t *ai_pathchecktime; +cvar_t *ai_pathcheckdist; + +static float *path_start; +static float *path_end; +static PathNode *Node; +static float path_totaldir[ 2 ]; +static float path_p[ 3 ]; +static float path_startdir[ 2 ]; + +static Entity *IgnoreObjects[ MAX_GENTITIES ]; +static int NumIgnoreObjects; + +static qboolean pathnodesinitialized = false; +static qboolean loadingarchive = false; +static qboolean pathnodescalculated = false; +int ai_maxnode; + +MapCell PathSearch::PathMap[ PATHMAP_GRIDSIZE ][ PATHMAP_GRIDSIZE ]; +PathNode *PathSearch::open; +int PathSearch::findFrame; +qboolean PathSearch::m_bNodesloaded; +qboolean PathSearch::m_NodeCheckFailed; +int PathSearch::m_LoadIndex; + +PathNode *PathSearch::pathnodes[ MAX_PATHNODES ]; +int PathSearch::nodecount; +float PathSearch::total_dist; +char *PathSearch::last_error; + +byte *bulkNavMemory = NULL; +byte *startBulkNavMemory = NULL; + +static Vector PLAYER_BASE_MIN( -15.5f, -15.5f, 0 ); +static Vector PLAYER_BASE_MAX( 15.5f, 15.5f, 0 ); +Vector testpos[ 200 ]; +Vector ai_startpath; +Vector ai_endpath; + +float NODE_MINS[ 3 ] = { -15, -15, 0 }; +float NODE_MAXS[ 3 ] = { 15, 15, 94 }; +float COLOR_PATHNODE_ERROR[ 3 ] = { 0, 0, 0 }; +float COLOR_PATHNODE_COVER[ 3 ] = { 0, 1, 0 }; +float COLOR_PATHNODE_CORNER_LEFT[ 3 ] = { 1, 1, 0 }; +float COLOR_PATHNODE_CORNER_RIGHT[ 3 ] = { 0.7f, 1, 0 }; +float COLOR_PATHNODE_SNIPER[ 3 ] = { 1, 0, 0 }; +float COLOR_PATHNODE_CRATE[ 3 ] = { 3, 0, 0 }; +float COLOR_PATHNODE_CONCEALMENT[ 3 ] = { 0, 0, 1 }; +float COLOR_PATHNODE_DUCK[ 3 ] = { 0, 1, 1 }; +float COLOR_PATHNODE_DEFAULT[ 3 ] = { 1, 0, 1 }; + +int testcount = 0; +static ActorPath *test_path = NULL; + +struct { + float fMinRangeSquared; + float fMaxRangeSquared; + float fMinAngle; + float fMaxAngle; +} + +g_AttackParms[] = +{ + { 64 * 64, 2048 * 2048, 150.0f, 210.0f }, + { 64 * 64, 2048 * 2048, 150.0f, 210.0f }, + { 96 * 96, 2048 * 2048, 320.0f, 40.0f }, +}; + +PathSearch PathManager; + +int path_checksthisframe; + +void AI_AddNode + ( + PathNode *node + ) + +{ + int i = PathSearch::nodecount; + + assert( node ); + + if( i < MAX_PATHNODES ) + { + if( i > ai_maxnode ) + { + ai_maxnode = i; + } + PathSearch::pathnodes[ i ] = node; + node->nodenum = i; + PathSearch::nodecount++; + return; + } + + gi.Error( ERR_DROP, "Exceeded MAX_PATHNODES!\n" ); +} + +qboolean CheckMove + ( + Vector &origin, + Vector &pos, + short int *path_fallheight, + float size + ) + +{ + mmove_t mm; + int i; + float air_z; + float fallheight; + float test_fallheight; + float error; + trace_t trace; + vec3_t dir; + vec3_t end; + + memset( &mm, 0, sizeof( mmove_t ) ); + + VectorClear( mm.velocity ); + VectorCopy( origin, mm.origin ); + mm.desired_speed = 150.0f; + mm.entityNum = ENTITYNUM_NONE; + mm.tracemask = MASK_PATHSOLID; + mm.frametime = 0.1f; + mm.desired_dir[ 0 ] = pos[ 0 ] - origin[ 0 ]; + mm.desired_dir[ 1 ] = pos[ 1 ] - origin[ 1 ]; + VectorNormalize2D( mm.desired_dir ); + + mm.groundPlane = qfalse; + mm.walking = qfalse; + + mm.mins[ 0 ] = -size; + mm.mins[ 1 ] = -size; + mm.mins[ 2 ] = 0; + mm.maxs[ 0 ] = size; + mm.maxs[ 1 ] = size; + mm.maxs[ 2 ] = 94.0f; + + testcount = 0; + fallheight = 0.0f; + air_z = mm.origin[ 2 ]; + + for( i = 200; i != 1; i-- ) + { + testpos[ i - 1 ] = mm.origin; + testcount++; + + MmoveSingle( &mm ); + + if( mm.groundPlane ) + { + test_fallheight = air_z - mm.origin[ 2 ]; + + if( test_fallheight > fallheight ) + { + if( test_fallheight > 1024.0f ) + return false; + + fallheight = test_fallheight; + } + + air_z = mm.origin[ 2 ]; + } + + dir[ 0 ] = pos[ 0 ] - mm.origin[ 0 ]; + dir[ 1 ] = pos[ 1 ] - mm.origin[ 1 ]; + + if( DotProduct2D( dir, mm.desired_dir ) <= 0.1f ) + { + error = mm.origin[ 2 ] - pos[ 2 ]; + + gi.Printf( "error = %f\n", error ); + + *path_fallheight = ( short )fallheight; + if( fabs( error ) > 94.0f ) + { + if( mm.groundPlane ) + return false; + + mm.desired_dir[ 0 ] = dir[ 0 ]; + mm.desired_dir[ 1 ] = dir[ 1 ]; + VectorNormalize2D( mm.desired_dir ); + } + else if( error > 0.0f && !mm.groundPlane ) + { + end[ 0 ] = mm.origin[ 0 ]; + end[ 1 ] = mm.origin[ 1 ]; + end[ 2 ] = pos[ 2 ]; + + trace = G_Trace( mm.origin, + mm.mins, + mm.maxs, + end, + NULL, + MASK_PATHSOLID, + true, + "CheckMove" ); + + test_fallheight = mm.origin[ 2 ] - trace.endpos[ 2 ]; + + if( test_fallheight <= 18.0f ) + { + *path_fallheight = ( short )test_fallheight + fallheight; + return test_fallheight + fallheight <= 1024.0f; + } + + if( mm.groundPlane ) + return false; + + mm.desired_dir[ 0 ] = dir[ 0 ]; + mm.desired_dir[ 1 ] = dir[ 1 ]; + VectorNormalize2D( mm.desired_dir ); + } + else + { + return true; + } + } + + if( mm.hit_obstacle ) + { + gi.DPrintf( "obstacle hit\n" ); + return false; + } + } + + return false; +} + +/*****************************************************************************/ +/*QUAKED info_pathnode (1 0 0) (-24 -24 0) (24 24 32) FLEE DUCK COVER DOOR JUMP LADDER + +FLEE marks the node as a safe place to flee to. Actor will be removed when it reaches a flee node and is not visible to a player. + +DUCK marks the node as a good place to duck behind during weapon fire. + +COVER marks the node as a good place to hide behind during weapon fire. + +DOOR marks the node as a door node. If an adjacent node has DOOR marked as well, the actor will only use the path if the door in between them is unlocked. + +JUMP marks the node as one to jump from when going to the node specified by target. +"target" the pathnode to jump to. + +******************************************************************************/ + +Event EV_Path_SetNodeFlags + ( + "spawnflags", + EV_DEFAULT, + "i", + "node_flags", + "Sets the path nodes flags.", + EV_NORMAL + ); + +CLASS_DECLARATION( SimpleEntity, PathNode, "info_pathnode" ) +{ + { &EV_Path_SetNodeFlags, &PathNode::SetNodeFlags }, + { &EV_IsTouching, &PathNode::IsTouching }, + { &EV_Delete, &PathNode::Remove }, + { &EV_Remove, &PathNode::Remove }, + { NULL, NULL } +}; + +static Vector pathNodesChecksum; +static int numLoadNodes = 0; +static int numNodes = 0; + +void *PathNode::operator new( size_t size ) +{ + return PathManager.AllocPathNode(); +} + +void PathNode::operator delete( void *ptr ) +{ + return PathManager.FreePathNode( ptr ); +} + +PathNode::PathNode() +{ + entflags |= EF_PATHNODE; + findCount = 0; + numChildren = 0; + iAvailableTime = -1; + + if( !loadingarchive ) + { + // our archive function will take care of this stuff + AI_AddNode( this ); + nodeflags = 0; + virtualNumChildren = 0; + iAvailableTime = -1; + Child = NULL; + } +} + +PathNode::~PathNode() +{ + entflags &= ~EF_PATHNODE; +} + +void PathNode::Claim + ( + Entity *pClaimer + ) + +{ + pLastClaimer = pClaimer; + iAvailableTime = 0; +} + +const_str PathNode::GetSpecialAttack + ( + Actor *pActor + ) + +{ + int iSpecialAttack; + const_str csAnimation; + float fRangeSquared; + float vDelta[ 2 ]; + float fMinAngle; + float fMaxAngle; + + if( nodeflags & AI_CORNER_LEFT ) + { + iSpecialAttack = 0; + csAnimation = STRING_ANIM_CORNERLEFT_SCR; + } + else if( nodeflags & AI_CORNER_RIGHT ) + { + iSpecialAttack = 1; + csAnimation = STRING_ANIM_CORNERRIGHT_SCR; + } + else + { + if( nodeflags >= 0 ) + return 0; + + iSpecialAttack = 2; + csAnimation = STRING_ANIM_OVERATTACK_SCR; + } + + if( pActor->m_Enemy ) + { + vDelta[ 0 ] = pActor->m_Enemy->origin[ 0 ] - origin[ 0 ]; + vDelta[ 1 ] = pActor->m_Enemy->origin[ 1 ] - origin[ 1 ]; + } + else + { + vDelta[ 0 ] = pActor->m_vLastEnemyPos[ 0 ] - origin[ 0 ]; + vDelta[ 1 ] = pActor->m_vLastEnemyPos[ 1 ] - origin[ 1 ]; + } + + fRangeSquared = vDelta[ 0 ] * vDelta[ 0 ] + vDelta[ 1 ] * vDelta[ 1 ]; + + if( fRangeSquared < g_AttackParms[ iSpecialAttack ].fMinRangeSquared || fRangeSquared > g_AttackParms[ iSpecialAttack ].fMaxRangeSquared ) + return 0; + + fMinAngle = atan2( vDelta[ 0 ], vDelta[ 1 ] ) * ( 180.0f / M_PI ) - angles[ 1 ]; + + if( fMinAngle > -360.0f ) + { + if( fMinAngle >= 0.0f ) + { + if( fMinAngle >= 720.0f ) + fMaxAngle = fMinAngle - 720.0f; + else if( fMinAngle >= 360.0f ) + fMaxAngle = fMinAngle - 360.0f; + else + fMaxAngle = fMinAngle; + } + else + { + fMaxAngle = fMinAngle + 360.0f; + } + } + else + { + fMaxAngle = fMinAngle + 720.0f; + } + + if( g_AttackParms[ iSpecialAttack ].fMinAngle <= g_AttackParms[ iSpecialAttack ].fMaxAngle ) + { + if( g_AttackParms[ iSpecialAttack ].fMinAngle > fMaxAngle ) + return 0; + } + else + { + if( g_AttackParms[ iSpecialAttack ].fMinAngle <= fMaxAngle ) + return 0; + } + + if( fMaxAngle > g_AttackParms[ iSpecialAttack ].fMaxAngle ) + return 0; + + return csAnimation; +} + +Entity *PathNode::GetClaimHolder + ( + void + ) const + +{ + if( iAvailableTime ) + return NULL; + else + return pLastClaimer; +} + +bool PathNode::IsClaimedByOther + ( + Entity *pPossibleClaimer + ) const + +{ + if( pLastClaimer == pPossibleClaimer ) + return false; + + if( iAvailableTime ) + { + return ( level.inttime < iAvailableTime ); + } + else + { + return ( pLastClaimer != NULL ); + } +} + +qboolean PathNode::IsTouching + ( + Entity *e1 + ) + +{ + return e1->absmin[ 0 ] <= origin[ 0 ] + 15.5f && + e1->absmin[ 1 ] <= origin[ 1 ] + 15.5f && + e1->absmin[ 0 ] <= origin[ 2 ] + 94.0f && + origin[ 0 ] - 15.5f <= e1->absmax[ 0 ] && + origin[ 1 ] - 15.5f <= e1->absmax[ 1 ] && + origin[ 2 ] + 0.0f <= e1->absmax[ 2 ]; +} + +void PathNode::SetNodeFlags + ( + Event *ev + ) + +{ + nodeflags = ev->GetInteger( 1 ); +} + +void PathNode::IsTouching + ( + Event *ev + ) + +{ + Entity *ent = ev->GetEntity( 1 ); + + if( !ent ) + { + ScriptError( "IsTouching used with a NULL entity.\n" ); + } + + ev->AddInteger( IsTouching( ev->GetEntity( 1 ) ) ); +} + +void PathNode::Remove + ( + Event *ev + ) + +{ + // Pathnodes mustn't be removed + ScriptError( "Not allowed to delete a path node" ); +} + +void PathNode::setOriginEvent + ( + Vector org + ) + +{ + if( !PathManager.m_bNodesloaded ) + { + origin = org; + centroid = org; + } +} + +void PathNode::Archive + ( + Archiver &arc + ) + +{ +} + +void PathNode::ArchiveDynamic + ( + Archiver &arc + ) + +{ + SimpleEntity::SimpleArchive( arc ); + + arc.ArchiveObjectPosition( this ); + arc.ArchiveSafePointer( &pLastClaimer ); + arc.ArchiveInteger( &iAvailableTime ); + arc.ArchiveInteger( &numChildren ); + + if( numChildren != virtualNumChildren ) + { + for( int i = 0; i < virtualNumChildren; i++ ) + { + arc.ArchiveByte( &Child[ i ].numBlockers ); + arc.ArchiveShort( &Child[ i ].node ); + arc.ArchiveShort( &Child[ i ].fallheight ); + arc.ArchiveFloat( &Child[ i ].dist ); + arc.ArchiveVec2( Child[ i ].dir ); + arc.ArchiveVec3( Child[ i ].pos1 ); + arc.ArchiveVec3( Child[ i ].pos2 ); + } + } +} + +void PathNode::ArchiveStatic + ( + Archiver &arc + ) + +{ + arc.ArchiveVector( &origin ); + arc.ArchiveVector( ¢roid ); + arc.ArchiveInteger( &nodeflags ); + arc.ArchiveInteger( &virtualNumChildren ); + + numChildren = virtualNumChildren; + + if( arc.Loading() ) + { + bulkNavMemory -= virtualNumChildren * sizeof( pathway_t ) * sizeof( pathway_t * ); + Child = virtualNumChildren ? ( pathway_t * )bulkNavMemory : NULL; + } + + for( int i = 0; i < virtualNumChildren; i++ ) + { + arc.ArchiveShort( &Child[ i ].node ); + arc.ArchiveShort( &Child[ i ].fallheight ); + arc.ArchiveFloat( &Child[ i ].dist ); + arc.ArchiveVec2( Child[ i ].dir ); + arc.ArchiveVec3( Child[ i ].pos1 ); + arc.ArchiveVec3( Child[ i ].pos2 ); + + if( arc.Loading() ) + Child[ i ].numBlockers = 0; + } +} + +void PathNode::ConnectChild + ( + int i + ) + +{ + int j; + pathway_t child = Child[ i ]; + + for( j = i - 1; j >= numChildren; j-- ) + { + Child[ j + 1 ] = Child[ j ]; + } + + Child[ numChildren ] = child; + numChildren++; +} + +void PathNode::DisconnectChild + ( + int i + ) + +{ + int j; + pathway_t child = Child[ i ]; + + for( j = i + 1; j < numChildren; j++ ) + { + Child[ j - 1 ] = Child[ j ]; + } + + numChildren--; + Child[ numChildren ] = child; +} + +void PathNode::ConnectTo + ( + PathNode *node + ) + +{ + Child[ virtualNumChildren ].node = nodenum; + Child[ virtualNumChildren ].numBlockers = 0; + virtualNumChildren++; + numChildren++; +} + +bool PathNode::CheckPathTo + ( + PathNode *node + ) + +{ + + if( virtualNumChildren < NUM_PATHSPERNODE ) + { + CheckPathToDefault( node, &Child[ virtualNumChildren ] ); + return true; + } + else + { + Com_Printf( "^~^~^ %d paths per node at (%.2f %.2f %.2f) exceeded\n - use DONT_LINK on some nodes to conserve cpu and memory usage\n", NUM_PATHSPERNODE, node->origin[ 0 ], node->origin[ 1 ], node->origin[ 2 ] ); + PathSearch::m_NodeCheckFailed = true; + return false; + } +} + +void PathNode::CheckPathToDefault + ( + PathNode *node, + pathway_t *pathway + ) + +{ + float dist; + float delta[ 2 ]; + Vector start; + Vector end; + + delta[ 0 ] = node->origin[ 0 ] - origin[ 0 ]; + delta[ 1 ] = node->origin[ 1 ] - origin[ 1 ]; + + dist = VectorNormalize2D( delta ); + + if( dist >= 384.0f ) + return; + + start = origin + Vector( 0, 0, 36.0f ); + end = start - Vector( 0, 0, 2048.0f ); + + trace_t trace = G_Trace( + start, + PLAYER_BASE_MIN, + PLAYER_BASE_MAX, + end, + NULL, + MASK_PATHSOLID, + qfalse, + "droptofloor" ); + + start = node->origin + Vector( 0, 0, 36.0f ); + end = start - Vector( 0, 0, 2048.0f ); + + trace_t trace2 = G_Trace( + start, + PLAYER_BASE_MIN, + PLAYER_BASE_MAX, + end, + NULL, + MASK_PATHSOLID, + qfalse, + "droptofloor" ); + + start = trace.endpos; + end = trace2.endpos; + + if( CheckMove( start, end, &pathway->fallheight, 15.5f ) ) + { + pathway->dist = dist; + pathway->dir[ 0 ] = delta[ 0 ]; + pathway->dir[ 1 ] = delta[ 1 ]; + VectorCopy( start, pathway->pos1 ); + VectorCopy( end, pathway->pos2 ); + Child[ virtualNumChildren ].node = node->nodenum; + Child[ virtualNumChildren ].numBlockers = 0; + + virtualNumChildren++; + numChildren++; + } +} + +void PathNode::MarkTemporarilyBad + ( + void + ) + +{ + iAvailableTime = level.inttime + 5000; + pLastClaimer = NULL; +} + +void PathNode::Relinquish + ( + void + ) + +{ + iAvailableTime = level.inttime + 4000; +} + +void PathNode::DrawConnections + ( + void + ) + +{ + int i; + pathway_t *path; + PathNode *node; + + for( i = 0; i < numChildren; i++ ) + { + path = &Child[ i ]; + node = PathSearch::pathnodes[ path->node ]; + + G_DebugLine( origin + Vector( "0 0 24" ), node->origin + Vector( "0 0 24" ), 0.7f, 0.7f, 0, 1 ); + } +} + +static bool IsValidPathnode + ( + int spawnflags + ) + +{ + if( ( spawnflags & AI_DUCK ) && ( spawnflags & AI_COVERFLAGS2 ) ) + return false; + + if( ( spawnflags & AI_CONCEALMENT ) && ( spawnflags & AI_SNIPERFLAGS ) ) + return false; + + if( ( spawnflags & AI_CORNER_LEFT ) && ( spawnflags & AI_COVER_LEFT_FLAGS ) ) + return false; + + if( ( spawnflags & AI_CORNER_RIGHT ) && ( spawnflags & AI_COVER_RIGHT_FLAGS ) ) + return false; + + if( ( spawnflags & AI_SNIPER ) && ( spawnflags & AI_CRATEFLAGS ) ) + return false; + + if( ( spawnflags & AI_ALL ) && ( spawnflags & AI_COVERFLAGS3 ) ) + return false; + + return true; +} + +static void GetPathnodeColor + ( + int spawnflags, + vec3_t color + ) + +{ + if( IsValidPathnode( spawnflags ) ) + { + if( spawnflags & AI_CORNER_LEFT ) + { + VectorCopy( COLOR_PATHNODE_CORNER_LEFT, color ); + } + else if( spawnflags & AI_CORNER_RIGHT ) + { + VectorCopy( COLOR_PATHNODE_CORNER_RIGHT, color ); + } + else if( spawnflags & AI_DUCK ) + { + VectorCopy( COLOR_PATHNODE_DUCK, color ); + } + else if( spawnflags & AI_SNIPER ) + { + VectorCopy( COLOR_PATHNODE_SNIPER, color ); + } + else if( spawnflags & AI_CONCEALMENT ) + { + VectorCopy( COLOR_PATHNODE_CONCEALMENT, color ); + } + else if( spawnflags & AI_COVER ) + { + VectorCopy( COLOR_PATHNODE_COVER, color ); + } + else if( spawnflags & AI_CRATE ) + { + VectorCopy( COLOR_PATHNODE_CRATE, color ); + } + else + { + VectorCopy( COLOR_PATHNODE_DEFAULT, color ); + } + } + else + { + VectorCopy( COLOR_PATHNODE_ERROR, color ); + } +} + +void DrawNode + ( + int iNodeCount + ) + +{ + Vector down; + Vector up; + Vector dir; + Vector p1; + Vector p2; + Vector p3; + Vector p4; + Vector q1; + Vector q2; + Vector q3; + Vector q4; + Vector playerorigin; + Vector aStart; + Vector aEnd; + PathNode *node; + PathNode *nodelist[ 4096 ]; + Vector end; + Vector start; + Vector p; + vec3_t color; + + playerorigin = g_entities[ 0 ].client->ps.origin; + + if( iNodeCount > 4096 ) + iNodeCount = 4096; + + if( ai_showallnode->integer ) + iNodeCount = PathSearch::DebugNearestNodeList2( playerorigin, nodelist, iNodeCount ); + else + iNodeCount = PathSearch::DebugNearestNodeList( playerorigin, nodelist, iNodeCount ); + + if( iNodeCount ) + { + for( int i = 0; i < iNodeCount; i++ ) + { + node = nodelist[ i ]; + GetPathnodeColor( node->nodeflags, color ); + + p1.x = PLAYER_BASE_MAX.x + node->origin.x; + p1.y = PLAYER_BASE_MAX.y + node->origin.y; + + p2.x = PLAYER_BASE_MAX.x + node->origin.x; + p2.y = PLAYER_BASE_MIN.y + node->origin.y; + + p3.x = PLAYER_BASE_MIN.x + node->origin.x; + p3.y = PLAYER_BASE_MIN.y + node->origin.y; + + p4.x = PLAYER_BASE_MIN.x + node->origin.x; + p4.y = PLAYER_BASE_MAX.y + node->origin.y; + + start = node->origin + Vector( 0, 0, 18 ); + end = node->origin + Vector( 0, 0, 18 ); + + aStart = start; + aEnd[ 0 ] = node->origin[ 0 ] + cos( M_PI / 180.0f * node->angles[ 1 ] ) * 16.0f; + aEnd[ 1 ] = node->origin[ 1 ] + sin( M_PI / 180.0f * node->angles[ 1 ] ) * 16.0f; + aEnd[ 2 ] = end[ 2 ]; + + G_DebugLine( aStart, aEnd, 1, 1, 1, 1 ); + + p1.z = node->origin.z + 36.0f; + p2.z = node->origin.z + 36.0f; + p3.z = node->origin.z + 36.0f; + p4.z = node->origin.z + 36.0f; + + G_DebugLine( p1, p2, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + G_DebugLine( p2, p3, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + G_DebugLine( p3, p4, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + G_DebugLine( p4, p1, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + + q1 = p1; + q2 = p2; + q3 = p3; + q4 = p4; + + q1.z = node->origin.z; + q2.z = node->origin.z; + q3.z = node->origin.z; + q4.z = node->origin.z; + + G_DebugLine( q1, q2, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + G_DebugLine( q2, q3, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + G_DebugLine( q3, q4, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + G_DebugLine( q4, q1, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + + G_DebugLine( p1, q1, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + G_DebugLine( p2, q2, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + G_DebugLine( p3, q3, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + G_DebugLine( p4, q4, color[ 0 ], color[ 1 ], color[ 2 ], 1 ); + } + } + else + { + G_DebugCircle( playerorigin + Vector( 0, 0, 48 ), 128, 1, 0, 0, 1, true ); + } +} + +void DrawAllConnections + ( + void + ) + +{ + pathway_t *path; + pathway_t *path2; + PathNode *node; + PathNode *to; + Vector down; + Vector up; + Vector dir; + Vector p1; + Vector p2; + Vector p3; + Vector p4; + Vector playerorigin; + qboolean showroutes; + qboolean shownums; + bool reverse; + + showroutes = ( ai_showroutes->integer != 0 ); + shownums = ( ai_shownodenums->integer != 0 ); + + // Figure out where the camera is + + if( !g_entities[ 0 ].client ) + return; + + playerorigin.x = g_entities[ 0 ].client->ps.origin[ 0 ]; + playerorigin.y = g_entities[ 0 ].client->ps.origin[ 1 ]; + playerorigin.z = g_entities[ 0 ].client->ps.origin[ 2 ]; + + playerorigin[ 2 ] += g_entities[ 0 ].client->ps.viewheight; + + for( int i = 0; i < PathSearch::nodecount; i++ ) + { + node = PathSearch::pathnodes[ i ]; + + if( Vector( node->origin - playerorigin ).length() > ai_showroutes_distance->integer ) + { + continue; + } + + if( shownums ) + { + G_DrawDebugNumber( node->origin + Vector( 0, 0, 14 ), node->nodenum, 1.5, 1, 1, 0 ); + } + + for( int j = 0; j < node->numChildren; j++ ) + { + path = &node->Child[ j ]; + + if( path->fallheight > ai_fallheight->integer ) + continue; + + reverse = false; + to = PathSearch::pathnodes[ path->node ]; + + for( int k = to->numChildren - 1; k >= 0; k-- ) + { + path2 = &to->Child[ k ]; + + if( path2->fallheight < ai_fallheight->integer && PathSearch::pathnodes[ path2->node ] == node ) + { + reverse = true; + break; + } + } + + p1 = path->pos1 + Vector( 0, 0, 36 ); + p2 = path->pos2 + Vector( 0, 0, 36 ); + + if( node->nodenum < to->nodenum || !reverse ) + { + // draw connected lines in green + G_DebugLine( p1, p2, 0, 1, 0, 1 ); + + if( !reverse ) + { + dir = Vector( path->pos2 ) - Vector( path->pos1 ); + dir.z = 0; + VectorNormalize( dir ); + + p3 = dir * 8.0f + dir * 8.0f; + p4 = dir * 8.0f; + p4.z += 8.0f; + + G_DebugLine( p1 + p3 + up , p1 + p3 + up - p4, 1, 0, 0, 1 ); + + p4.z -= 16.0f; + + G_DebugLine( p1 + p3 + down, p1 + p3 + down - p4, 1, 0, 0, 1 ); + } + } + } + + if( !node->numChildren ) + { + // Put a little X where the node is to show that it had no connections + p1 = node->origin; + p1.z += 2; + + if( node->nodeflags & PATH_DONT_LINK ) + { + G_DebugCircle( p1, 12, 0, 0, 1, 1, true ); + } + else + { + p2 = Vector( 12, 12, 0 ); + G_DebugLine( p1 - p2, p1 + p2, 1, 0, 0, 1 ); + + p2.x = -12; + G_DebugLine( p1 - p2, p1 + p2, 1, 0, 0, 1 ); + } + } + } +} + +MapCell::MapCell() +{ + numnodes = 0; + nodes = NULL; +} + +MapCell::~MapCell() +{ + numnodes = 0; + nodes = NULL; +} +qboolean MapCell::AddNode + ( + PathNode *node + ) + +{ + nodes[ numnodes ] = ( short )node->nodenum; + numnodes++; + + return true; +} + +int MapCell::NumNodes + ( + void + ) + +{ + return numnodes; +} + + +/* All + work and no play + makes Jim a dull boy. All + work and no play makes Jim a + dull boy. All work and no play + makes Jim a dull boy. All work and no + play makes Jim a dull boy. All work and + no play makes Jim a dull boy. All work and + no play makes Jim a dull boy. All work and no + play makes Jim a dull boy. All work and no play + makes Jim a dull boy. All work and no play makes + Jim a dull boy. All work and no play makes Jim a + dull boy. All work and no play makes Jim a dull boy. + All work and no play makes Jim a dull boy. All work + and no play makes Jim a dull boy. All work and no play + makes Jim a dull boy. All work and no play makes Jim a + dull boy. All work and no play makes Jim a dull boy. All + work and no play makes Jim a dull boy. All work and no + play makes Jim a dull boy. All work and no play makes Jim + a dull boy. All work and no play makes Jim a dull boy. + All work and no play makes Jim a dull boy. All work and + no play makes Jim a dull boy. All work and no play makes + Jim a dull boy. All work and no play makes Jim a dull + boy. All work and no play makes Jim a dull boy. All work + and no play makes Jim a dull boy. All work and no play + makes Jim a dull boy. All work and no play makes Jim a + dull boy. All work and no play makes Jim a dull boy. All + work and no play makes Jim a dull boy. All work and no + play makes Jim a dull boy. All work and no play makes + Jim a dull boy. All work and no play makes Jim a dull + boy. All work and no play makes Jim a dull boy. All + work and no play makes Jim a dull boy. All work and + no play makes Jim a dull boy. All work and no + play makes Jim a dull boy. All work and no play + makes Jim a dull boy. All work and no play + makes Jim a dull boy. All work and no play + makes Jim a dull boy. All work and no + play makes Jim a dull boy. All work + and no play makes Jim a dull boy. + All work and no play makes + Jim a dull boy. All work + and no play makes + Jim a +*/ + +CLASS_DECLARATION( Class, PathSearch, NULL ) +{ + { NULL, NULL } +}; + + +PathSearch::PathSearch() +{ + memset( pathnodes, 0, sizeof( pathnodes ) ); + open = 0; + findFrame = 0; +} + +PathSearch::~PathSearch() +{ + ResetNodes(); +} + +void PathSearch::AddToGrid + ( + PathNode *node, + int x, + int y + ) + +{ + MapCell *cell; + + if( x > PATHMAP_GRIDSIZE || y > PATHMAP_GRIDSIZE ) + cell = NULL; + else + cell = &PathMap[ x ][ y ]; + + if( !cell ) + return; + + if( cell->NumNodes() >= PATHMAP_NODES ) + Com_Printf( "^~^~^ PathSearch::AddToGrid: Node overflow at ( %d, %d )\n", x, y ); + else + cell->AddNode( node ); +} + +int PathSearch::NodeCoordinate + ( + float coord + ) + +{ + float c; + + //return ( ( int )coord + MAX_MAP_BOUNDS - ( PATHMAP_CELLSIZE / 2 ) ) / PATHMAP_CELLSIZE; + + c = coord + MAX_MAP_BOUNDS - ( PATHMAP_CELLSIZE / 2 ); + + if( c < 0 ) + c = coord + MAX_MAP_BOUNDS + ( PATHMAP_CELLSIZE / 2 ) - 1; + + return ( int )c >> 8; +} + +int PathSearch::GridCoordinate + ( + float coord + ) + +{ + float c; + + //return ( ( int )coord + MAX_MAP_BOUNDS ) / PATHMAP_CELLSIZE; + + c = coord + MAX_MAP_BOUNDS; + + if( c < 0 ) + c = coord + MAX_MAP_BOUNDS + PATHMAP_CELLSIZE - 1; + + return ( int )c >> 8; +} + +void PathSearch::AddNode + ( + PathNode *node + ) + +{ + int x; + int y; + + assert( node ); + + x = NodeCoordinate( node->origin[ 0 ] ); + y = NodeCoordinate( node->origin[ 1 ] ); + + AddToGrid( node, x, y ); + AddToGrid( node, x + 1, y ); + AddToGrid( node, x, y + 1 ); + AddToGrid( node, x + 1, y + 1 ); +} + +void PathSearch::LoadAddToGrid + ( + int x, + int y + ) + +{ + MapCell *cell; + + if( x > PATHMAP_GRIDSIZE || y > PATHMAP_GRIDSIZE ) + cell = NULL; + else + cell = &PathMap[ x ][ y ]; + + if( cell ) + cell->numnodes++; +} + +void PathSearch::LoadAddToGrid2 + ( + PathNode *node, + int x, + int y + ) + +{ + MapCell *cell; + + if( x > PATHMAP_GRIDSIZE || y > PATHMAP_GRIDSIZE ) + cell = NULL; + else + cell = &PathMap[ x ][ y ]; + + if( cell ) + cell->AddNode( node ); +} + +MapCell *PathSearch::GetNodesInCell + ( + int x, + int y + ) + +{ + if( ( x < 0 ) || ( x >= PATHMAP_GRIDSIZE ) || ( y < 0 ) || ( y >= PATHMAP_GRIDSIZE ) ) + { + return NULL; + } + + return &PathMap[ x ][ y ]; +} + +MapCell *PathSearch::GetNodesInCell + ( + float *pos + ) + +{ + int x; + int y; + + x = GridCoordinate( pos[ 0 ] ); + y = GridCoordinate( pos[ 1 ] ); + + return GetNodesInCell( x, y ); +} + + +PathNode *PathSearch::DebugNearestStartNode + ( + float *pos, + Entity *ent + ) + +{ + PathNode *node = NULL; + int i; + MapCell *cell; + int nodes[ 128 ]; + vec3_t deltas[ 128 ]; + vec3_t start; + vec3_t end; + + cell = GetNodesInCell( pos ); + + if( !cell ) + return NULL; + + int node_count = NearestNodeSetup( pos, cell, nodes, deltas ); + + if( !node_count ) + return NULL; + + VectorCopy( pos, start ); + start[ 2 ] += 32.0f; + + for( i = 0; i < node_count; i++ ) + { + node = pathnodes[ cell->nodes[ nodes[ i ] ] ]; + + VectorCopy( start, end ); + VectorAdd( end, deltas[ nodes[ i ] ], end ); + + Vector vStart = start; + Vector vMins = Vector( -15, -15, 0 ); + Vector vMaxs = Vector( 15, 15, 62 ); + Vector vEnd = end; + + if( G_SightTrace( + vStart, + vMins, + vMaxs, + vEnd, + ent, + NULL, + MASK_TARGETPATH, + qtrue, + "PathSearch::DebugNearestStartNode" ) ) + { + return node; + } + } + + return pathnodes[ cell->nodes[ nodes[ 0 ] ] ]; +} + +PathNode *PathSearch::NearestStartNode + ( + float *pos, + SimpleActor *ent + ) + +{ + // FIXME: stub + STUB(); + return NULL; +} + +PathNode *PathSearch::NearestEndNode + ( + float *pos + ) + +{ + PathNode *node = NULL; + int i; + MapCell *cell; + int nodes[ 128 ]; + vec3_t deltas[ 128 ]; + vec3_t start; + vec3_t end; + + cell = GetNodesInCell( pos ); + + if( !cell ) + return NULL; + + int node_count = NearestNodeSetup( pos, cell, nodes, deltas ); + int n = 0; + int j = 0; + + if( !node_count ) + return NULL; + + VectorCopy( pos, start ); + start[ 2 ] += 32.0f; + + for( i = 0; i < node_count; i++ ) + { + node = pathnodes[ cell->nodes[ nodes[ i ] ] ]; + + VectorCopy( start, end ); + VectorAdd( end, deltas[ nodes[ i ] ], end ); + + Vector vStart = start; + Vector vMins = Vector( -15, -15, 0 ); + Vector vMaxs = Vector( 15, 15, 62 ); + Vector vEnd = end; + + if( G_SightTrace( + vStart, + vMins, + vMaxs, + vEnd, + ( gentity_t * )NULL, + ( gentity_t * )NULL, + MASK_TARGETPATH, + qtrue, + "PathSearch::NearestEndNode" ) ) + { + return node; + } + } + + return pathnodes[ cell->nodes[ nodes[ 0 ] ] ]; +} + +int PathSearch::DebugNearestNodeList + ( + float *pos, + PathNode **nodelist, + int iMaxNodes + ) + +{ + PathNode *node; + int i; + MapCell *cell; + int nodes[ 128 ]; + vec3_t deltas[ 128 ]; + vec3_t start; + vec3_t end; + + cell = GetNodesInCell( pos ); + + if( !cell ) + return 0; + + int node_count = NearestNodeSetup( pos, cell, nodes, deltas ); + int n = 0; + int j = 0; + + for( i = 0; i < node_count && j < iMaxNodes; i++ ) + { + node = pathnodes[ cell->nodes[ nodes[ i ] ] ]; + + VectorCopy( pos, start ); + VectorCopy( pos, end ); + + VectorAdd( end, deltas[ i ], end ); + + Vector vStart = start; + Vector vMins = Vector( -15, -15, 0 ); + Vector vMaxs = Vector( 15, 15, 62 ); + Vector vEnd = end; + + if( G_SightTrace( + vStart, + vMins, + vMaxs, + vEnd, + ( gentity_t *)NULL, + ( gentity_t * )NULL, + MASK_PATHSOLID, + qtrue, + "PathSearch::DebugNearestNodeList" ) ) + { + nodelist[ n ] = node; + n++; + } + } + + if( !n && node_count ) + { + nodelist[ 0 ] = pathnodes[ cell->nodes[ nodes[ 0 ] ] ]; + return 1; + } + else + { + return n; + } + + return 0; +} + +int PathSearch::DebugNearestNodeList2 + ( + float *pos, + PathNode **nodelist, + int iMaxNodes + ) + +{ + vec3_t delta; + PathNode *node; + float dist; + int n = 0; + int i; + int j; + static float node_dist[ MAX_PATHNODES ]; + int node_count; + + node_count = nodecount; + + for( i = 0; i < node_count; i++ ) + { + node = pathnodes[ i ]; + + if( pos[ 2 ] > node->origin[ 2 ] + 94.0f ) + continue; + + if( node->origin[ 2 ] > pos[ 2 ] + 94.0f ) + continue; + + delta[ 0 ] = node->origin[ 0 ] - pos[ 0 ]; + delta[ 1 ] = node->origin[ 1 ] - pos[ 1 ]; + delta[ 2 ] = node->origin[ 2 ] - pos[ 2 ]; + + dist = VectorLengthSquared( delta ); + + for( j = n; j > 0; j-- ) + { + if( dist >= node_dist[ j - 1 ] ) + break; + + node_dist[ j ] = node_dist[ j - 1 ]; + nodelist[ j ] = nodelist[ j - 1 ]; + } + + n++; + nodelist[ j ] = node; + node_dist[ j ] = dist; + } + + return n; +} + +void PathSearch::ArchiveStaticLoad + ( + Archiver& arc + ) + +{ + int i; + PathNode *node; + int total_nodes; + int total_children; + int x; + int y; + int size; + + loadingarchive = true; + + arc.ArchiveInteger( &nodecount ); + arc.ArchiveInteger( &total_nodes ); + arc.ArchiveInteger( &total_children ); + + size = total_nodes + total_children * ( sizeof( pathway_t ) * 2 ) + nodecount * ( sizeof( PathNode ) / 2 ); + size *= 2; + + gi.DPrintf( "%d memory allocated for navigation.\n", size ); + + if( size ) + startBulkNavMemory = ( byte * )gi.Malloc( size ); + else + startBulkNavMemory = NULL; + + bulkNavMemory = startBulkNavMemory + size; + + for( i = 0; i < nodecount; i++ ) + { + node = new PathNode; + + arc.ArchiveObjectPosition( node ); + node->ArchiveStatic( arc ); + node->nodenum = i; + + pathnodes[ i ] = node; + + if( !( node->nodeflags & PATH_DONT_LINK ) ) + { + x = NodeCoordinate( node->origin[ 0 ] ); + y = NodeCoordinate( node->origin[ 1 ] ); + + LoadAddToGrid( x, y ); + LoadAddToGrid( x + 1, y ); + LoadAddToGrid( x, y + 1 ); + LoadAddToGrid( x + 1, y + 1 ); + } + } + + for( x = 0; x < PATHMAP_GRIDSIZE; x++ ) + { + for( y = 0; y < PATHMAP_GRIDSIZE; y++ ) + { + bulkNavMemory -= PathMap[ x ][ y ].numnodes * sizeof( short ); + + PathMap[ x ][ y ].nodes = PathMap[ x ][ y ].numnodes ? ( short * )bulkNavMemory : NULL; + PathMap[ x ][ y ].numnodes = 0; + } + } + + for( i = 0; i < nodecount; i++ ) + { + node = pathnodes[ i ]; + + if( !( node->nodeflags & PATH_DONT_LINK ) ) + { + x = NodeCoordinate( node->origin[ 0 ] ); + y = NodeCoordinate( node->origin[ 1 ] ); + + LoadAddToGrid2( node, x, y ); + LoadAddToGrid2( node, x + 1, y ); + LoadAddToGrid2( node, x, y + 1 ); + LoadAddToGrid2( node, x + 1, y + 1 ); + } + } + + loadingarchive = false; +} + +void PathSearch::ArchiveStaticSave + ( + Archiver& arc + ) + +{ + int i; + PathNode *node; + int total_nodes = 0; + int total_children = 0; + int x = 0; + int y = 0; + + for( x = 0; x < PATHMAP_GRIDSIZE; x++ ) + { + for( y = 0; y < PATHMAP_GRIDSIZE; y++ ) + { + total_nodes += PathMap[ x ][ y ].NumNodes(); + } + } + + for( i = 0; i < nodecount; i++ ) + { + node = pathnodes[ i ]; + total_children += node->virtualNumChildren; + } + + arc.ArchiveInteger( &nodecount ); + arc.ArchiveInteger( &total_nodes ); + arc.ArchiveInteger( &total_children ); + + for( i = 0; i < nodecount; i++ ) + { + node = pathnodes[ i ]; + arc.ArchiveObjectPosition( node ); + node->ArchiveStatic( arc ); + } +} + +void PathSearch::ArchiveLoadNodes + ( + void + ) + +{ + Archiver arc; + qboolean success; + + success = qfalse; + if( arc.Read( level.m_pathfile, false ) ) + { + int file_version; + str maptime; + + // get file values + arc.ArchiveInteger( &file_version ); + if( file_version != PATHFILE_VERSION ) + { + Com_Printf( "Expecting version %d path file. Path file is version %d.\n", PATHFILE_VERSION, file_version ); + arc.Close(); + return; + } + + arc.ArchiveString( &maptime ); + if( gi.MapTime() == maptime && gi.FS_FileNewer( level.m_mapfile.c_str(), level.m_pathfile.c_str() ) <= 0 ) + { + arc.ArchiveInteger( &m_NodeCheckFailed ); + + if( !g_nodecheck->integer || !m_NodeCheckFailed ) + { + ArchiveStaticLoad( arc ); + m_bNodesloaded = arc.NoErrors(); + } + else + { + gi.Printf( "Rebuilding pathnodes to view node errors.\n" ); + } + } + else + { + gi.Printf( "Pathnodes have changed, rebuilding.\n" ); + } + } + + arc.Close(); +} + +qboolean PathSearch::ArchiveSaveNodes + ( + void + ) + +{ + Archiver arc; + str maptime; + int tempInt; + + arc.Create( level.m_pathfile ); + tempInt = PATHFILE_VERSION; + arc.ArchiveInteger( &tempInt ); + maptime = gi.MapTime(); + arc.ArchiveString( &maptime ); + arc.ArchiveInteger( &m_NodeCheckFailed ); + ArchiveStaticSave( arc ); + arc.Close(); + + return true; +} + +void PathSearch::Connect + ( + PathNode *node + ) + +{ + int x; + int y; + + findFrame++; + node->findCount = findFrame; + + x = NodeCoordinate( node->origin[ 0 ] ); + y = NodeCoordinate( node->origin[ 1 ] ); + + if( Connect( node, x - 1, y - 1 ) ) + { + if( Connect( node, x - 1, y ) ) + { + if( Connect( node, x - 1, y + 1 ) ) + { + if( Connect( node, x, y - 1 ) ) + { + if( Connect( node, x, y ) ) + { + if( Connect( node, x, y + 1 ) ) + { + if( Connect( node, x + 1, y - 1 ) ) + { + if( Connect( node, x + 1, y ) ) + { + Connect( node, x + 1, y + 1 ); + } + } + } + } + } + } + } + } +} + +bool PathSearch::Connect + ( + PathNode *node, + int x, + int y + ) + +{ + MapCell *cell; + int i; + PathNode *node2; + + if( x > PATHMAP_GRIDSIZE || y > PATHMAP_GRIDSIZE ) + cell = NULL; + else + cell = &PathMap[ x ][ y ]; + + if( !cell ) + return true; + + if( cell->numnodes <= 0 ) + return true; + + for( i = 0; i < cell->numnodes; i++ ) + { + node2 = pathnodes[ cell->nodes[ i ] ]; + + if( node2->findCount != findFrame ) + { + node2->findCount = findFrame; + + if( !node->CheckPathTo( node2 ) ) + return false; + } + } + + return true; +} + +void PathSearch::ShowNodes + ( + void + ) + +{ + if( g_entities->client ) + { + if( ai_shownode->integer ) + { + DrawNode( ai_shownode->integer ); + } + if( ai_showroutes->integer || ai_shownodenums->integer ) + { + DrawAllConnections(); + } + } + + if( ai_showpath->integer ) + { + if( !test_path ) + test_path = new ActorPath; + + if( ai_showpath->integer == 1 ) + { + ai_startpath = g_entities[ 0 ].entity->origin; + } + if( ai_showpath->integer == 2 ) + { + ai_endpath = g_entities[ 0 ].entity->origin; + } + if( ai_showpath->integer <= 2 ) + { + test_path->SetFallHeight( ai_fallheight->integer ); + test_path->FindPath( ai_startpath, ai_endpath, NULL, 0, NULL, 0 ); + } + if( ai_showpath->integer == 3 ) + { + if( test_path->CurrentNode() ) + { + test_path->UpdatePos( g_entities[ 0 ].entity->origin ); + + Vector vStart = g_entities[ 0 ].entity->origin + Vector( 0, 0, 32 ); + Vector vEnd = g_entities[ 0 ].entity->origin + test_path->CurrentDelta() + Vector( 0, 0, 32 ); + + G_DebugLine( vStart, vEnd, 1, 1, 0, 1 ); + } + } + + G_DebugLine( ai_startpath, ai_endpath, 0, 0, 1, 1 ); + + if( test_path->CurrentNode() ) + { + PathInfo *pos = test_path->CurrentNode(); + + while( pos != test_path->LastNode() ) + { + Vector vStart = pos->point + Vector( 0, 0, 32 ); + + pos--; + + Vector vEnd = pos->point + Vector( 0, 0, 32 ); + + G_DebugLine( vStart, vEnd, 1, 0, 0, 1 ); + } + } + } +} + +void PathSearch::LoadNodes + ( + void + ) + +{ + ai_showroutes = gi.Cvar_Get( "ai_showroutes", "0", 0 ); + ai_showroutes_distance = gi.Cvar_Get( "ai_showroutes_distance", "1000", 0 ); + ai_shownodenums = gi.Cvar_Get( "ai_shownodenums", "0", 0 ); + ai_shownode = gi.Cvar_Get( "ai_shownode", "0", 0 ); + ai_showallnode = gi.Cvar_Get( "ai_showallnode", "0", 0 ); + ai_showpath = gi.Cvar_Get( "ai_showpath", "0", 0 ); + ai_fallheight = gi.Cvar_Get( "ai_fallheight", "96", 0 ); + ai_debugpath = gi.Cvar_Get( "ai_debugpath", "0", 0 ); + ai_pathchecktime = gi.Cvar_Get( "ai_pathchecktime", "1.5", CVAR_CHEAT ); + ai_pathcheckdist = gi.Cvar_Get( "ai_pathcheckdist", "4096", CVAR_CHEAT ); + + ArchiveLoadNodes(); +} + +void PathSearch::CreatePaths + ( + void + ) + +{ + int i; + int j; + int x; + int y; + PathNode *node; + Vector start; + Vector end; + gentity_t *ent; + int t1; + int t2; + + if( m_bNodesloaded ) + return; + + if( !nodecount ) + { + m_bNodesloaded = true; + return; + } + + m_NodeCheckFailed = false; + + gi.DPrintf( "***********************************\n" + "***********************************\n" + "\n" + "Creating paths...\n" + "\n" + "***********************************\n" + "***********************************\n" ); + + t1 = gi.Milliseconds(); + + for( i = 0, ent = g_entities; i < game.maxentities; i++, ent++ ) + { + if( ent->entity && ent->entity->IsSubclassOfDoor() ) + gi.UnlinkEntity( ent ); + } + + for( x = 0; x < PATHMAP_GRIDSIZE; x++ ) + { + for( y = 0; y < PATHMAP_GRIDSIZE; y++ ) + { + MapCell *cell = &PathMap[ x ][ y ]; + + cell->nodes = ( short * )gi.Malloc( PATHMAP_CELLSIZE ); + cell->numnodes = 0; + memset( cell->nodes, 0, PATHMAP_CELLSIZE ); + } + } + + for( i = 0; i < nodecount; i++ ) + { + node = pathnodes[ i ]; + + start = node->origin + Vector( 0, 0, 36.0f ); + end = node->origin - Vector( 0, 0, 2048.0f ); + + trace_t trace = G_Trace( start, + PLAYER_BASE_MIN, + PLAYER_BASE_MAX, + end, + NULL, + MASK_PATHSOLID, + qfalse, + "droptofloor" ); + + node->origin = trace.endpos; + node->centroid = trace.endpos; + + if( !( node->nodeflags & PATH_DONT_LINK ) ) + { + for( j = i - 1; j >= 0; j-- ) + { + PathNode *node2 = pathnodes[ j ]; + + if( node2->origin == node->origin ) + { + Com_Printf( "^~^~^ Duplicate node at (%.2f %.2f %.2f) not linked\n", node->origin[ 0 ], node->origin[ 1 ], node->origin[ 2 ] ); + node->nodeflags |= PATH_DONT_LINK; + break; + } + } + + if( !( node->nodeflags & PATH_DONT_LINK ) ) + node->Child = ( pathway_t * )gi.Malloc( sizeof( pathway_t ) * PATHMAP_NODES ); + } + } + + for( i = 0; i < nodecount; i++ ) + { + node = pathnodes[ i ]; + + if( node->nodeflags & PATH_DONT_LINK ) + continue; + + AddNode( node ); + } + + for( i = 0; i < nodecount; i++ ) + { + node = pathnodes[ i ]; + + if( node->nodeflags & PATH_DONT_LINK ) + continue; + + Connect( node ); + } + + for( i = 0, ent = g_entities; i < game.maxentities; i++, ent++ ) + { + if( ent->entity && ent->entity->IsSubclassOfDoor() ) + ent->entity->link(); + } + + gi.DPrintf( "\nSaving path nodes to '%s'\n", level.m_pathfile.c_str() ); + Com_Printf( "Archiving\n" ); + ArchiveSaveNodes(); + m_bNodesloaded = true; + Com_Printf( "done.\n" ); + + t2 = gi.Milliseconds(); + Com_Printf( "Path connection: %5.2f seconds\n", ( t2 - t1 ) / 1000.0f ); + Com_Printf( "Number of nodes: %d\n", nodecount ); + gi.ClearResource(); + + if( g_nodecheck->integer && m_NodeCheckFailed ) + { + gi.Error( ERR_DROP, "Node check failed" ); + } +} + +void *PathSearch::AllocPathNode + ( + void + ) + +{ + if( bulkNavMemory && !m_bNodesloaded ) + { + bulkNavMemory -= sizeof( PathNode ); + return bulkNavMemory; + } + else + { + return gi.Malloc( sizeof( PathNode ) ); + } +} + +void PathSearch::FreePathNode + ( + void *ptr + ) + +{ + if( !bulkNavMemory || m_bNodesloaded ) + { + gi.Free( ptr ); + } +} + +void PathSearch::ResetNodes + ( + void + ) + +{ + int i; + int x; + int y; + + m_LoadIndex = -1; + m_bNodesloaded = false; + + if( !startBulkNavMemory ) + { + for( x = PATHMAP_GRIDSIZE - 1; x >= 0; x-- ) + { + for( y = PATHMAP_GRIDSIZE - 1; y >= 0; y-- ) + { + if( PathMap[ x ][ y ].nodes ) + gi.Free( PathMap[ x ][ y ].nodes ); + } + } + + for( i = 0; i < nodecount; i++ ) + { + if( pathnodes[ i ]->Child ) + gi.Free( pathnodes[ i ]->Child ); + } + } + + for( x = PATHMAP_GRIDSIZE - 1; x >= 0; x-- ) + { + for( y = PATHMAP_GRIDSIZE - 1; y >= 0; y-- ) + { + PathMap[ x ][ y ].numnodes = 0; + PathMap[ x ][ y ].nodes = NULL; + } + } + + for( i = 0; i < nodecount; i++ ) + { + delete pathnodes[ i ]; + pathnodes[ i ] = NULL; + } + + nodecount = 0; + + // Free the bulk nav' memory + if( startBulkNavMemory ) + { + gi.Free( startBulkNavMemory ); + bulkNavMemory = NULL; + startBulkNavMemory = NULL; + } +} + +PathInfo *PathSearch::GeneratePath + ( + PathInfo *path + ) + +{ + PathNode *ParentNode; + pathway_t *pathway; + float dist; + float dir[ 2 ]; + PathInfo *current_path; + + current_path = path; + + dir[ 0 ] = path_end[ 0 ] - Node->m_PathPos[ 0 ]; + dir[ 1 ] = path_end[ 1 ] - Node->m_PathPos[ 1 ]; + + dist = VectorNormalize2D( dir ); + + total_dist = dist + Node->g; + + path->point[ 0 ] = path_end[ 0 ]; + path->point[ 1 ] = path_end[ 1 ]; + path->point[ 2 ] = path_end[ 2 ]; + + ParentNode = Node->Parent; + if( ParentNode ) + { + pathway = &ParentNode->Child[ Node->pathway ]; + + path->dir[ 0 ] = path_end[ 0 ] - pathway->pos2[ 0 ]; + path->dir[ 1 ] = path_end[ 1 ] - pathway->pos2[ 1 ]; + path->dist = VectorNormalize2D( path->dir ); + + if( path->dist ) + { + path->bAccurate = false; + current_path = path + 1; + } + + if( pathway->dist ) + { + VectorCopy( pathway->pos2, current_path->point ); + current_path->dir[ 0 ] = pathway->dir[ 0 ]; + current_path->dir[ 1 ] = pathway->dir[ 1 ]; + current_path->dist = pathway->dist; + current_path->bAccurate = true; + current_path++; + } + + for( Node = ParentNode, ParentNode = ParentNode->Parent; ParentNode != NULL; Node = ParentNode, ParentNode = ParentNode->Parent ) + { + pathway = &ParentNode->Child[ Node->pathway ]; + if( pathway->dist ) + { + VectorCopy( pathway->pos2, current_path->point ); + current_path->dir[ 0 ] = pathway->dir[ 0 ]; + current_path->dir[ 1 ] = pathway->dir[ 1 ]; + current_path->dist = pathway->dist; + current_path->bAccurate = true; + current_path++; + } + } + + VectorCopy( pathway->pos1, current_path->point ); + current_path->dir[ 0 ] = path_startdir[ 0 ]; + current_path->dir[ 1 ] = path_startdir[ 1 ]; + current_path->dist = Node->g; + } + else + { + path->dir[ 0 ] = path_totaldir[ 0 ]; + path->dir[ 1 ] = path_totaldir[ 1 ]; + path->dist = Node->h; + } + + if( current_path->dist ) + { + current_path->bAccurate = false; + current_path++; + + VectorCopy( path_start, current_path->point ); + current_path->dist = 0; + VectorClear2D( current_path->dir ); + } + + current_path->bAccurate = false; + return current_path; +} + +PathInfo *PathSearch::GeneratePathNear + ( + PathInfo *path + ) + +{ + PathInfo *current_path = path; + pathway_t *pathway; + PathNode *ParentNode; + + total_dist = Node->g; + VectorCopy( Node->m_PathPos, path->point ); + + ParentNode = Node->Parent; + if( ParentNode ) + { + pathway = &ParentNode->Child[ Node->pathway ]; + + if( pathway->dist ) + { + VectorCopy( pathway->pos2, path->point ); + path->dir[ 0 ] = pathway->dir[ 0 ]; + path->dir[ 1 ] = pathway->dir[ 1 ]; + path->dist = pathway->dist; + + current_path->bAccurate = true; + current_path++; + } + + for( Node = ParentNode, ParentNode = ParentNode->Parent; ParentNode != NULL; Node = ParentNode, ParentNode = ParentNode->Parent ) + { + pathway = &ParentNode->Child[ Node->pathway ]; + if( pathway->dist ) + { + VectorCopy( pathway->pos2, current_path->point ); + current_path->dir[ 0 ] = pathway->dir[ 0 ]; + current_path->dir[ 1 ] = pathway->dir[ 1 ]; + current_path->dist = pathway->dist; + current_path->bAccurate = true; + current_path++; + } + } + + VectorCopy( pathway->pos1, current_path->point ); + current_path->dir[ 0 ] = path_startdir[ 0 ]; + current_path->dir[ 1 ] = path_startdir[ 1 ]; + + current_path->dist = Node->g; + } + else + { + path->dir[ 0 ] = path_totaldir[ 0 ]; + path->dir[ 1 ] = path_totaldir[ 1 ]; + path->dist = Node->h; + } + + if( current_path->dist ) + { + current_path->bAccurate = false; + current_path++; + + VectorCopy( path_start, current_path->point ); + current_path->dist = 0; + VectorClear2D( current_path->dir ); + } + + current_path->bAccurate = false; + return current_path; +} + +PathInfo *PathSearch::GeneratePathAway + ( + PathInfo *path + ) + +{ + PathInfo *current_path = path; + pathway_t *pathway; + PathNode *ParentNode; + + VectorCopy( Node->m_PathPos, path->point ); + + ParentNode = Node->Parent; + if( ParentNode ) + { + pathway = &ParentNode->Child[ Node->pathway ]; + + if( pathway->dist ) + { + VectorCopy( pathway->pos2, path->point ); + path->dir[ 0 ] = pathway->dir[ 0 ]; + path->dir[ 1 ] = pathway->dir[ 1 ]; + path->dist = pathway->dist; + + current_path->bAccurate = true; + current_path++; + } + + for( Node = ParentNode, ParentNode = ParentNode->Parent; ParentNode != NULL; Node = ParentNode, ParentNode = ParentNode->Parent ) + { + pathway = &ParentNode->Child[ Node->pathway ]; + if( pathway->dist ) + { + VectorCopy( pathway->pos2, current_path->point ); + current_path->dir[ 0 ] = pathway->dir[ 0 ]; + current_path->dir[ 1 ] = pathway->dir[ 1 ]; + current_path->dist = pathway->dist; + current_path->bAccurate = true; + current_path++; + } + } + + VectorCopy( pathway->pos1, current_path->point ); + current_path->dir[ 0 ] = path_startdir[ 0 ]; + current_path->dir[ 1 ] = path_startdir[ 1 ]; + + current_path->dist = Node->g; + + if( Node->g ) + { + current_path->bAccurate = false; + current_path++; + VectorCopy( path_start, current_path->point ); + current_path->dist = 0; + VectorClear2D( current_path->dir ); + } + } + else + { + VectorClear2D( path->dir ); + path->dist = 0; + } + + current_path->bAccurate = false; + return current_path; +} + +PathNode *PathSearch::GetSpawnNode + ( + ClassDef *cls + ) + +{ + if( m_bNodesloaded ) + { + return pathnodes[ m_LoadIndex++ ]; + } + else + { + // Otherwise create a new node + return ( PathNode * )cls->newInstance(); + } +} + +int PathSearch::FindPath + ( + float *start, + float *end, + Entity *ent, + float maxPath, + float *vLeashHome, + float fLeashDistSquared, + int fallheight + ) + +{ + int i; + int g; + PathNode *NewNode; + pathway_t *pathway; + PathNode *prev; + PathNode *next; + int f; + vec2_t delta; + PathNode *to; + + if( ent ) + { + if( ent->IsSubclassOfActor() ) + { + Node = NearestStartNode( start, ( SimpleActor * )ent ); + } + else + { + Node = DebugNearestStartNode( start, ent ); + } + } + else + { + Node = DebugNearestStartNode( start ); + } + + if( !Node ) + { + last_error = "couldn't find start node"; + return NULL; + } + + to = NearestEndNode( end ); + if( !to ) + { + last_error = "couldn't find end node"; + return NULL; + } + + total_dist = 9e+11f; + + if( !maxPath ) + maxPath = 9e+11f; + + findFrame++; + open = NULL; + + path_startdir[ 0 ] = Node->origin[ 0 ] - start[ 0 ]; + path_startdir[ 1 ] = Node->origin[ 1 ] - start[ 1 ]; + + Node->g = VectorNormalize2D( path_startdir ); + + path_totaldir[ 0 ] = end[ 0 ] - start[ 0 ]; + path_totaldir[ 1 ] = end[ 1 ] - start[ 1 ]; + + Node->h = VectorNormalize2D( path_totaldir ); + Node->inopen = true; + Node->Parent = NULL; + Node->m_Depth = 3; + Node->m_PathPos = start; + Node->findCount = findFrame; + Node->PrevNode = NULL; + Node->NextNode = NULL; + + open = Node; + + while( 1 ) + { + Node = open; + Node->inopen = false; + + open = Node->NextNode; + if( open ) + open->PrevNode = NULL; + + if( Node == to ) + break; + + for( i = Node->numChildren - 1; i >= 0; i-- ) + { + vec2_t vDist; + + pathway = &Node->Child[ i ]; + + NewNode = pathnodes[ pathway->node ]; + + if( vLeashHome ) + { + vDist[ 0 ] = pathway->pos2[ 0 ] - vLeashHome[ 0 ]; + vDist[ 1 ] = pathway->pos2[ 1 ] - vLeashHome[ 1 ]; + } + + if( !vLeashHome || VectorLength2DSquared( vDist ) <= fLeashDistSquared ) + { + g = ( int )( pathway->dist + Node->g + 1.0f ); + + if( NewNode->findCount == findFrame ) + { + if( g >= NewNode->g ) + continue; + + if( NewNode->inopen ) + { + NewNode->inopen = false; + next = NewNode->NextNode; + prev = NewNode->PrevNode; + + if( next ) + next->PrevNode = prev; + + if( prev ) + prev->NextNode = next; + else + open = next; + } + } + + delta[ 0 ] = end[ 0 ] - pathway->pos2[ 0 ]; + delta[ 1 ] = end[ 1 ] - pathway->pos2[ 1 ]; + + NewNode->h = VectorLength2D( delta ); + + f = ( int )( ( float )g + NewNode->h ); + + if( f >= maxPath ) + { + last_error = "specified path distance exceeded"; + return NULL; + } + + if( pathway->fallheight <= fallheight ) + { + NewNode->f = f; + NewNode->pathway = i; + NewNode->g = g; + NewNode->Parent = Node; + NewNode->m_Depth = Node->m_Depth + 1; + NewNode->inopen = true; + NewNode->m_PathPos = pathway->pos2; + NewNode->findCount = findFrame; + + if( !open ) + { + NewNode->NextNode = NULL; + NewNode->PrevNode = NULL; + open = NewNode; + continue; + } + + if( open->f >= f ) + { + NewNode->PrevNode = NULL; + NewNode->NextNode = open; + + open->PrevNode = NewNode; + open = NewNode; + continue; + } + + prev = open; + next = open->NextNode; + while( next && next->f < f ) + { + prev = next; + next = next->NextNode; + } + + NewNode->NextNode = next; + if( next ) + next->PrevNode = NewNode; + prev->NextNode = NewNode; + NewNode->PrevNode = prev; + } + } + } + + if( !open ) + { + last_error = "unreachable path"; + return NULL; + } + } + + path_start = start; + path_end = end; + + return Node->m_Depth; +} + +int PathSearch::FindPathAway + ( + float *start, + float *avoid, + float *vPreferredDir, + Entity *ent, + float fMinSafeDist, + float *vLeashHome, + float fLeashDistSquared, + int fallheight + ) + +{ + int i; + int g; + PathNode *NewNode; + pathway_t *pathway; + PathNode *prev; + PathNode *next; + int f; + float fBias; + vec2_t delta; + float fMinSafeDistSquared = fMinSafeDist * fMinSafeDist; + + if( ent ) + { + if( ent->IsSubclassOfActor() ) + { + Node = NearestStartNode( start, ( SimpleActor * )ent ); + } + else + { + Node = DebugNearestStartNode( start, ent ); + } + } + else + { + Node = DebugNearestStartNode( start ); + } + + if( !Node ) + { + last_error = "couldn't find start node"; + return 0; + } + + findFrame++; + open = NULL; + + path_startdir[ 0 ] = Node->origin[ 0 ] - start[ 0 ]; + path_startdir[ 1 ] = Node->origin[ 1 ] - start[ 1 ]; + + delta[ 0 ] = start[ 0 ] - avoid[ 0 ]; + delta[ 1 ] = start[ 1 ] - avoid[ 1 ]; + + fBias = VectorLength2D( vPreferredDir ); + + Node->inopen = true; + Node->g = VectorNormalize2D( path_startdir ); + Node->h = fMinSafeDist - VectorNormalize2D( delta ); + Node->h += fBias - DotProduct2D( vPreferredDir, delta ); + Node->Parent = NULL; + Node->m_Depth = 2; + Node->findCount = findFrame; + Node->PrevNode = NULL; + Node->NextNode = NULL; + Node->m_PathPos = start; + + open = Node; + + while( 1 ) + { + Node = open; + Node->inopen = false; + + open = Node->NextNode; + + if( open ) + open->PrevNode = NULL; + + delta[ 0 ] = Node->m_PathPos[ 0 ] - avoid[ 0 ]; + delta[ 1 ] = Node->m_PathPos[ 1 ] - avoid[ 1 ]; + + if( VectorLength2DSquared( delta ) >= fMinSafeDistSquared ) + break; + + for( i = Node->numChildren - 1; i >= 0; i-- ) + { + vec2_t vDist; + + pathway = &Node->Child[ i ]; + NewNode = pathnodes[ pathway->node ]; + + if( vLeashHome ) + { + vDist[ 0 ] = pathway->pos2[ 0 ] - vLeashHome[ 0 ]; + vDist[ 1 ] = pathway->pos2[ 1 ] - vLeashHome[ 1 ]; + } + + if( !vLeashHome || VectorLength2DSquared( vDist ) <= fLeashDistSquared ) + { + g = ( int )( pathway->dist + Node->g + 1.0f ); + + if( NewNode->findCount == findFrame ) + { + if( g >= NewNode->g ) + continue; + + if( NewNode->inopen ) + { + NewNode->inopen = false; + next = NewNode->NextNode; + prev = NewNode->PrevNode; + + if( next ) + next->PrevNode = prev; + + if( prev ) + prev->NextNode = next; + else + open = next; + } + } + + delta[ 0 ] = pathway->pos2[ 0 ] - avoid[ 0 ]; + delta[ 1 ] = pathway->pos2[ 1 ] - avoid[ 1 ]; + + NewNode->h = fMinSafeDist - VectorNormalize2D( delta ); + f = NewNode->h + fBias - DotProduct2D( vPreferredDir, delta ); + NewNode->h += f; + + if( pathway->fallheight <= fallheight ) + { + NewNode->Parent = Node; + NewNode->m_Depth = Node->m_Depth + 1; + NewNode->g = g; + NewNode->pathway = i; + NewNode->inopen = true; + NewNode->m_PathPos = pathway->pos2; + NewNode->findCount = findFrame; + NewNode->f = f; + + if( !open ) + { + NewNode->NextNode = NULL; + NewNode->PrevNode = NULL; + open = NewNode; + continue; + } + + if( open->f >= f ) + { + NewNode->PrevNode = NULL; + NewNode->NextNode = open; + + open->PrevNode = NewNode; + open = NewNode; + continue; + } + + prev = open; + next = open->NextNode; + while( next && next->f < f ) + { + prev = next; + next = next->NextNode; + } + + NewNode->NextNode = next; + if( next ) + next->PrevNode = NewNode; + prev->NextNode = NewNode; + NewNode->PrevNode = prev; + } + } + } + + if( !open ) + { + last_error = "unreachable path"; + return NULL; + } + } + + path_start = start; + return Node->m_Depth; +} + +int PathSearch::FindPathNear + ( + float *start, + float *end, + Entity *ent, + float maxPath, + float fRadiusSquared, + float *vLeashHome, + float fLeashDistSquared, + int fallheight + ) + +{ + int i; + int g; + PathNode *NewNode; + pathway_t *pathway; + PathNode *prev; + PathNode *next; + int f; + vec2_t dir; + vec2_t delta; + + if( ent ) + { + if( ent->IsSubclassOfActor() ) + { + Node = NearestStartNode( start, ( SimpleActor * )ent ); + } + else + { + Node = DebugNearestStartNode( start, ent ); + } + } + else + { + Node = DebugNearestStartNode( start ); + } + + if( !Node ) + { + last_error = "no start node"; + return 0; + } + + total_dist = 9e11f; + + if( !maxPath ) + maxPath = 9e11f; + + findFrame++; + open = NULL; + + path_startdir[ 0 ] = Node->origin[ 0 ] - start[ 0 ]; + path_startdir[ 1 ] = Node->origin[ 1 ] - start[ 1 ]; + + dir[ 0 ] = end[ 0 ] - start[ 0 ]; + dir[ 1 ] = end[ 1 ] - start[ 1 ]; + + Node->inopen = true; + Node->g = VectorNormalize2D( path_startdir ); + Node->h = VectorNormalize2D( delta ); + Node->Parent = NULL; + Node->m_Depth = 3; + Node->findCount = findFrame; + Node->PrevNode = NULL; + Node->NextNode = NULL; + Node->m_PathPos = start; + + open = Node; + + while( 1 ) + { + Node = open; + Node->inopen = false; + + open = Node->NextNode; + + if( open ) + open->PrevNode = NULL; + + delta[ 0 ] = end[ 0 ] - Node->m_PathPos[ 0 ]; + delta[ 1 ] = end[ 1 ] - Node->m_PathPos[ 1 ]; + + if( fRadiusSquared >= VectorLength2DSquared( delta ) ) + break; + + for( i = Node->numChildren - 1; i >= 0; i-- ) + { + pathway = &Node->Child[ i ]; + NewNode = pathnodes[ pathway->node ]; + + g = ( int )( pathway->dist + Node->g + 1.0f ); + + if( NewNode->findCount == findFrame ) + { + if( g >= NewNode->g ) + continue; + + if( NewNode->inopen ) + { + NewNode->inopen = false; + next = NewNode->NextNode; + prev = NewNode->PrevNode; + + if( next ) + next->PrevNode = prev; + + if( prev ) + prev->NextNode = next; + else + open = next; + } + } + + delta[ 0 ] = end[ 0 ] - pathway->pos2[ 0 ]; + delta[ 1 ] = end[ 1 ] - pathway->pos2[ 1 ]; + + NewNode->h = VectorLength2D( delta ); + f = ( int )( ( float )g + NewNode->h ); + + if( f >= maxPath ) + { + last_error = "specified path distance exceeded"; + return NULL; + } + + if( pathway->fallheight <= fallheight ) + { + NewNode->f = f; + NewNode->pathway = i; + NewNode->g = g; + NewNode->Parent = Node; + NewNode->m_Depth = Node->m_Depth + 1; + NewNode->inopen = true; + NewNode->m_PathPos = pathway->pos2; + NewNode->findCount = findFrame; + + if( !open ) + { + NewNode->NextNode = NULL; + NewNode->PrevNode = NULL; + open = NewNode; + continue; + } + + if( open->f >= f ) + { + NewNode->PrevNode = NULL; + NewNode->NextNode = open; + + open->PrevNode = NewNode; + open = NewNode; + continue; + } + + prev = open; + next = open->NextNode; + while( next && next->f < f ) + { + prev = next; + next = next->NextNode; + } + + NewNode->NextNode = next; + if( next ) + next->PrevNode = NewNode; + prev->NextNode = NewNode; + NewNode->PrevNode = prev; + } + } + + if( !open ) + { + last_error = "unreachable path"; + return NULL; + } + } + + path_start = start; + path_end = end; + return Node->m_Depth; +} + +PathNode *PathSearch::FindCornerNodeForWall + ( + float *start, + float *end, + SimpleActor *ent, + float maxPath, + float *plane + ) + +{ + // FIXME: stub + STUB(); + return NULL; +} + +PathNode *PathSearch::FindCornerNodeForExactPath + ( + SimpleActor *self, + Sentient *enemy, + float fMaxPath + ) + +{ + // FIXME: stub + STUB(); + return NULL; +} + +int PathSearch::FindPotentialCover + ( + SimpleActor *pEnt, + Vector& vPos, + Entity *pEnemy, + PathNode **ppFoundNodes, + int iMaxFind + ) + +{ + // FIXME: stub + STUB(); + return NULL; +} + +void PathSearch::PlayerCover + ( + Player *pPlayer + ) + +{ + int i; + PathNode *node; + Vector delta; + Entity *pOwner; + + for( i = 0; i < nodecount; i++ ) + { + node = pathnodes[ i ]; + + if( !node || !( node->nodeflags & AI_COVERFLAGS ) ) + continue; + + pOwner = node->GetClaimHolder(); + + delta = node->origin - pPlayer->origin; + + // Check if we need to cover + if( VectorLengthSquared( delta ) > 2304.0f ) + { + if( pOwner == pPlayer ) + node->Relinquish(); + + continue; + } + + if( pOwner != pPlayer ) + { + if( pOwner ) + pOwner->PathnodeClaimRevoked( node ); + + // Player claim the node + node->Claim( pPlayer ); + } + } +} + +PathNode *PathSearch::FindNearestCover + ( + SimpleActor *pEnt, + Vector& vPos, + Entity *pEnemy + ) + +{ + // FIXME: stub + STUB(); + return NULL; +} + +PathNode *PathSearch::FindNearestSniperNode + ( + SimpleActor *pEnt, + Vector& vPos, + Entity *pEnemy + ) + +{ + // FIXME: stub + STUB(); + return NULL; +} + +int PathSearch::NearestNodeSetup + ( + vec3_t pos, + MapCell *cell, + int *nodes, + vec3_t *deltas + ) + +{ + vec3_t delta; + PathNode *node; + float dist; + int n = 0; + int i; + int j; + float node_dist[ 128 ]; + int node_count; + + node_count = cell->numnodes; + + for( i = 0; i < node_count; i++ ) + { + node = pathnodes[ cell->nodes[ i ] ]; + + if( pos[ 2 ] > node->origin[ 2 ] + 94.0f ) + continue; + + if( node->origin[ 2 ] > pos[ 2 ] + 94.0f ) + continue; + + delta[ 0 ] = node->origin[ 0 ] - pos[ 0 ]; + delta[ 1 ] = node->origin[ 1 ] - pos[ 1 ]; + delta[ 2 ] = node->origin[ 2 ] - pos[ 2 ]; + + VectorCopy( delta, deltas[ i ] ); + + dist = VectorLengthSquared( delta ); + + for( j = n; j > 0; j-- ) + { + if( dist >= node_dist[ j - 1 ] ) + break; + + node_dist[ j ] = node_dist[ j - 1 ]; + nodes[ j ] = nodes[ j - 1 ]; + } + + n++; + nodes[ j ] = i; + node_dist[ j ] = dist; + } + + return n; +} + +void PathSearch::Init + ( + void + ) + +{ + ai_showroutes = gi.Cvar_Get( "ai_showroutes", "0", 0 ); + ai_showroutes_distance = gi.Cvar_Get( "ai_showroutes_distance", "1000", 0 ); + ai_shownodenums = gi.Cvar_Get( "ai_shownodenums", "0", 0 ); + ai_shownode = gi.Cvar_Get( "ai_shownode", "0", 0 ); + ai_showallnode = gi.Cvar_Get( "ai_showallnode", "0", 0 ); + ai_showpath = gi.Cvar_Get( "ai_showpath", "0", 0 ); + ai_fallheight = gi.Cvar_Get( "ai_fallheight", "4096", 0 ); + ai_debugpath = gi.Cvar_Get( "ai_debugpath", "0", 0 ); + ai_pathchecktime = gi.Cvar_Get( "ai_pathchecktime", "1.5", CVAR_CHEAT ); + ai_pathcheckdist = gi.Cvar_Get( "ai_pathcheckdist", "4096", CVAR_CHEAT ); +} + +Event EV_AttractiveNode_GetPriority + ( + "priority", + EV_DEFAULT, + NULL, + NULL, + "Get the node priority", + EV_GETTER + ); + +Event EV_AttractiveNode_SetPriority + ( + "priority", + EV_DEFAULT, + "i", + "priority", + "Set the node priority", + EV_SETTER + ); + +Event EV_AttractiveNode_GetDistance + ( + "max_dist", + EV_DEFAULT, + NULL, + NULL, + "Get the max distance for this node", + EV_GETTER + ); + +Event EV_AttractiveNode_SetDistance + ( + "max_dist", + EV_DEFAULT, + "f", + "max_dist", + "Set the max distance for this node to be attracted, -1 for unlimited distance.", + EV_SETTER + ); + +Event EV_AttractiveNode_GetStayTime + ( + "stay_time", + EV_DEFAULT, + NULL, + NULL, + "Get the max stay time for this node", + EV_GETTER + ); + +Event EV_AttractiveNode_SetStayTime + ( + "stay_time", + EV_DEFAULT, + "f", + "stay_time", + "Set the maximum stay time AI will stay on this node", + EV_SETTER + ); + +Event EV_AttractiveNode_GetRespawnTime + ( + "respawn_time", + EV_DEFAULT, + NULL, + NULL, + "Get the how much time will this node re-attract already attracted AIs", + EV_GETTER + ); + +Event EV_AttractiveNode_SetRespawnTime + ( + "respawn_time", + EV_DEFAULT, + "f", + "respawn_time", + "Set the how much time will this node re-attract already attracted AIs. The minimum required value is 1, otherwise AI will get stuck.", + EV_SETTER + ); + +Event EV_AttractiveNode_GetTeam + ( + "team", + EV_DEFAULT, + NULL, + NULL, + "Get the attractive node team. 'none' for no team.", + EV_GETTER + ); + +Event EV_AttractiveNode_SetTeam + ( + "team", + EV_DEFAULT, + "s", + "team", + "Set the attractive node team. 'none' for no team.", + EV_SETTER + ); + +Event EV_AttractiveNode_SetUse + ( + "setuse", + EV_DEFAULT, + "b", + "use", + "Set if AI should use or not" + ); + +CLASS_DECLARATION( SimpleArchivedEntity, AttractiveNode, NULL ) +{ + { &EV_AttractiveNode_GetPriority, &AttractiveNode::GetPriority }, + { &EV_AttractiveNode_SetPriority, &AttractiveNode::SetPriority }, + { &EV_AttractiveNode_GetDistance, &AttractiveNode::GetDistance }, + { &EV_AttractiveNode_SetDistance, &AttractiveNode::SetDistance }, + { &EV_AttractiveNode_GetStayTime, &AttractiveNode::GetStayTime }, + { &EV_AttractiveNode_SetStayTime, &AttractiveNode::SetStayTime }, + { &EV_AttractiveNode_GetRespawnTime, &AttractiveNode::GetRespawnTime }, + { &EV_AttractiveNode_SetRespawnTime, &AttractiveNode::SetRespawnTime }, + { &EV_AttractiveNode_GetTeam, &AttractiveNode::GetTeam }, + { &EV_AttractiveNode_SetTeam, &AttractiveNode::SetTeam }, + { &EV_AttractiveNode_SetUse, &AttractiveNode::SetUse }, + { NULL, NULL } +}; + +Container< AttractiveNode * > attractiveNodes; + +AttractiveNode::AttractiveNode() +{ + + m_iPriority = 0; // set to default 0 + m_fMaxStayTime = 0; // set to default 0, could be just a pickup + m_fMaxDistance = 1024; + m_fMaxDistanceSquared = m_fMaxDistance * m_fMaxDistance; + m_fRespawnTime = 15.0f; // set to default 15 seconds + m_bUse = false; + m_csTeam = STRING_NONE; + m_iTeam = TEAM_NONE; + + attractiveNodes.AddObject( this ); +} + +AttractiveNode::~AttractiveNode() +{ + attractiveNodes.RemoveObject( this ); +} + +bool AttractiveNode::CheckTeam + ( + Sentient *sent + ) + +{ + if( !m_iTeam ) + { + return true; + } + + if( sent->IsSubclassOfPlayer() ) + { + Player *p = ( Player * )sent; + + if( ( m_iTeam == TEAM_FREEFORALL && g_gametype->integer >= GT_TEAM ) || + p->GetTeam() != m_iTeam ) + { + return false; + } + } + else + { + if( m_iTeam == TEAM_ALLIES && sent->m_Team != TEAM_AMERICAN ) + { + return false; + } + else if( m_iTeam == TEAM_AXIS && sent->m_Team != TEAM_GERMAN ) + { + return false; + } + } + + return true; +} + +void AttractiveNode::setMaxDist + ( + float dist + ) + +{ + m_fMaxDistance = dist; + + if( dist < 0 ) + { + m_fMaxDistanceSquared = -1; + } + else + { + m_fMaxDistanceSquared = dist * dist; + } +} + +void AttractiveNode::GetPriority + ( + Event *ev + ) + +{ + ev->AddInteger( m_iPriority ); +} + +void AttractiveNode::SetPriority + ( + Event *ev + ) + +{ + m_iPriority = ev->GetInteger( 1 ); +} + +void AttractiveNode::GetDistance + ( + Event *ev + ) + +{ + ev->AddFloat( m_fMaxDistance ); +} + +void AttractiveNode::SetDistance + ( + Event *ev + ) + +{ + setMaxDist( ev->GetFloat( 1 ) ); +} + +void AttractiveNode::GetStayTime + ( + Event *ev + ) + +{ + ev->AddFloat( m_fMaxStayTime ); +} + +void AttractiveNode::SetStayTime + ( + Event *ev + ) + +{ + m_fMaxStayTime = ev->GetFloat( 1 ); +} + +void AttractiveNode::GetRespawnTime + ( + Event *ev + ) + +{ + ev->AddFloat( m_fRespawnTime ); +} + +void AttractiveNode::SetRespawnTime + ( + Event *ev + ) + +{ + m_fRespawnTime = ev->GetFloat( 1 ); + if( m_fRespawnTime < 1.0f ) + { + m_fRespawnTime = 1.0f; + } +} + +void AttractiveNode::GetTeam + ( + Event *ev + ) + +{ + ev->AddConstString( m_csTeam ); +} + +void AttractiveNode::SetTeam + ( + Event *ev + ) + +{ + if( ev->IsNilAt( 1 ) ) + { + m_csTeam = STRING_NONE; + m_iTeam = TEAM_NONE; + return; + } + + m_csTeam = ev->GetConstString( 1 ); + + switch( m_csTeam ) + { + case STRING_NONE: + m_iTeam = TEAM_NONE; + break; + case STRING_SPECTATOR: + m_iTeam = TEAM_SPECTATOR; + break; + case STRING_FREEFORALL: + m_iTeam = TEAM_FREEFORALL; + break; + case STRING_ALLIES: + case STRING_AMERICAN: + m_iTeam = TEAM_ALLIES; + break; + case STRING_AXIS: + case STRING_GERMAN: + m_iTeam = TEAM_AXIS; + break; + default: + m_iTeam = TEAM_NONE; + ScriptError( "Invalid team %s\n", ev->GetString( 1 ).c_str() ); + } +} + +void AttractiveNode::SetUse + ( + Event *ev + ) + +{ + m_bUse = ev->GetBoolean( 1 ); +} diff --git a/code/game/navigate.h b/code/game/navigate.h new file mode 100644 index 00000000..e25d0bd0 --- /dev/null +++ b/code/game/navigate.h @@ -0,0 +1,366 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// navigate.h: +// Potentially could be an C++ implementation of the A* search algorithm, but +// is currently unfinished. +// + +#ifndef __NAVIGATE_H__ +#define __NAVIGATE_H__ + +#include "g_local.h" +#include "class.h" +#include "entity.h" +#include "stack.h" +#include "container.h" +#include "doors.h" +#include "../qcommon/qfiles.h" + + +extern Event EV_AI_SavePaths; +extern Event EV_AI_SaveNodes; +extern Event EV_AI_LoadNodes; +extern Event EV_AI_ClearNodes; +extern Event EV_AI_RecalcPaths; +extern Event EV_AI_CalcPath; +extern Event EV_AI_DisconnectPath; + +extern cvar_t *ai_showroutes; +extern cvar_t *ai_showroutes_distance; +extern cvar_t *ai_shownodenums; +extern cvar_t *ai_shownode; +extern cvar_t *ai_showallnode; +extern cvar_t *ai_showpath; +extern cvar_t *ai_fallheight; +extern cvar_t *ai_debugpath; +extern cvar_t *ai_pathchecktime; +extern cvar_t *ai_pathcheckdist; + +extern int ai_maxnode; + +#define MAX_PATHCHECKSPERFRAME 4 + +extern int path_checksthisframe; + +#define MAX_PATH_LENGTH 128 // should be more than plenty +#define NUM_PATHSPERNODE 48 + +class Path; +class PathNode; + +#define NUM_WIDTH_VALUES 16 +#define WIDTH_STEP 8 +#define MAX_WIDTH ( WIDTH_STEP * NUM_WIDTH_VALUES ) +#define MAX_HEIGHT 128 + +#define CHECK_PATH( path, width, height ) \ + ( ( ( ( width ) >= MAX_WIDTH ) || ( ( width ) < 0 ) ) ? false : \ + ( ( int )( path )->maxheight[ ( ( width ) / WIDTH_STEP ) - 1 ] < ( int )( height ) ) ) + +class pathway_ref { +public: + short int from; + short int to; +}; + +typedef struct { + byte numBlockers; + short int node; + short int fallheight; + float dist; + float dir[ 2 ]; + float pos1[ 3 ]; + float pos2[ 3 ]; +} pathway_t; + +class PathInfo { +public: + bool bAccurate; + float point[ 3 ]; + float dist; + float dir[ 2 ]; + +public: + void Archive( Archiver& arc ); +}; + +inline void PathInfo::Archive + ( + Archiver& arc + ) + +{ + arc.ArchiveBool( &bAccurate ); + arc.ArchiveVec3( point ); + arc.ArchiveFloat( &dist ); + arc.ArchiveVec2( dir ); +} + +typedef enum { NOT_IN_LIST, IN_OPEN, IN_CLOSED } pathlist_t; + +#define PATH_DONT_LINK 1 +#define AI_DUCK 2 +#define AI_COVER 4 +#define AI_CONCEALMENT 8 +#define AI_CORNER_LEFT 16 +#define AI_CORNER_RIGHT 32 +#define AI_SNIPER 64 +#define AI_CRATE 128 + +#define AI_COVERFLAGS (AI_CRATE|AI_SNIPER|AI_CORNER_RIGHT|AI_CORNER_LEFT|AI_CONCEALMENT|AI_COVER) +#define AI_COVERFLAGS2 (AI_SNIPER|AI_CORNER_RIGHT|AI_CORNER_LEFT|AI_CONCEALMENT) +#define AI_COVERFLAGS3 (AI_SNIPER|AI_CORNER_RIGHT|AI_CORNER_LEFT|AI_CONCEALMENT|AI_DUCK|AI_CONCEALMENT) +#define AI_SNIPERFLAGS (AI_SNIPER|AI_CORNER_RIGHT|AI_CORNER_LEFT|AI_COVER) +#define AI_CRATEFLAGS (AI_CRATE|AI_CORNER_LEFT|AI_CORNER_RIGHT|AI_CONCEALMENT|AI_COVER|AI_DUCK) +#define AI_COVER_LEFT_FLAGS (AI_CRATE|AI_SNIPER|AI_CORNER_LEFT|AI_CONCEALMENT|AI_DUCK) +#define AI_COVER_RIGHT_FLAGS (AI_CRATE|AI_SNIPER|AI_CORNER_RIGHT|AI_CONCEALMENT|AI_DUCK) +#define AI_ALL (AI_DUCK|AI_COVER|AI_CONCEALMENT|AI_CORNER_LEFT|AI_CORNER_RIGHT|AI_SNIPER|AI_CRATE) + +void DrawNode( int iNodeCount ); +void DrawAllConnections( void ); + +class PathNode : public SimpleEntity + { + public: + int findCount; + pathway_t *Child; + int numChildren; + int virtualNumChildren; + float f; + float h; + float g; + class PathNode *Parent; + bool inopen; + PathNode *PrevNode; + PathNode *NextNode; + short int pathway; + vec_t *m_PathPos; + float dist; + float dir[ 2 ]; + int nodeflags; + SafePtr pLastClaimer; + int iAvailableTime; + int nodenum; + short int m_Depth; + + friend class PathSearch; + friend void DrawAllConnections( void ); + + private: + void ConnectTo( PathNode *node ); + void SetNodeFlags( Event *ev ); + void Remove( Event *ev ); + + public: + CLASS_PROTOTYPE( PathNode ); + + void *operator new( size_t size ); + void operator delete( void *ptr ); + + PathNode(); + virtual ~PathNode(); + + virtual void Archive( Archiver& arc ); + void ArchiveDynamic( Archiver& arc ); + void ArchiveStatic( Archiver& arc ); + + bool CheckPathTo( PathNode *node ); + void CheckPathToDefault( PathNode *node, pathway_t *pathway ); + qboolean LadderTo( PathNode *node, pathway_t *pathway ); + + void DrawConnections( void ); + void Claim( Entity *pClaimer ); + void Relinquish( void ); + Entity *GetClaimHolder( void ) const; + bool IsClaimedByOther( Entity *pPossibleClaimer ) const; + void MarkTemporarilyBad( void ); + void ConnectChild( int i ); + void DisconnectChild( int i ); + const_str GetSpecialAttack( class Actor *pActor ); + void IsTouching( Event *ev ); + qboolean IsTouching( Entity *e1 ); + void setOriginEvent( Vector org ); + + }; + +typedef SafePtr PathNodePtr; + +#define PATHMAP_CELLSIZE 256 +#define PATHMAP_GRIDSIZE ( MAX_MAP_BOUNDS * 2 / PATHMAP_CELLSIZE ) + +#define PATHMAP_NODES 128 // 128 - sizeof( int ) / sizeof( short ) + +#define MAX_PATHNODES 4096 + +class MapCell : public Class +{ +private: + int numnodes; + short *nodes; + + friend class PathSearch; + +public: + MapCell(); + ~MapCell(); + + qboolean AddNode( PathNode *node ); + int NumNodes( void ); +}; + +class PathSearch : public Listener +{ + friend class PathNode; + +private: + static MapCell PathMap[ PATHMAP_GRIDSIZE ][ PATHMAP_GRIDSIZE ]; + static PathNode *open; + static int findFrame; + static qboolean m_bNodesloaded; + static qboolean m_NodeCheckFailed; + static int m_LoadIndex; + +public: + static PathNode *pathnodes[ 4096 ]; + static int nodecount; + static float total_dist; + static char *last_error; + +private: + static void LoadAddToGrid( int x, int y ); + static void LoadAddToGrid2( PathNode *node, int x, int y ); + static void AddToGrid( PathNode *node, int x, int y ); + static bool Connect( PathNode *node, int x, int y ); + static int NodeCoordinate( float coord ); + static int GridCoordinate( float coord ); + static qboolean ArchiveSaveNodes( void ); + static void ArchiveLoadNodes( void ); + static void Init( void ); + +public: + CLASS_PROTOTYPE( PathSearch ); + + PathSearch(); + virtual ~PathSearch(); + + static void ArchiveStaticLoad( Archiver& arc ); + static void ArchiveStaticSave( Archiver& arc ); + static bool ArchiveDynamic( Archiver& arc ); + static void AddNode( PathNode *node ); + static void Connect( PathNode *node ); + static void UpdateNode( PathNode *node ); + static MapCell *GetNodesInCell( int x, int y ); + static MapCell *GetNodesInCell( float *pos ); + static class PathNode *DebugNearestStartNode( float *pos, Entity *ent = NULL ); + static class PathNode *NearestStartNode( float *pos, class SimpleActor *ent ); + static class PathNode *NearestEndNode( float *pos ); + static int DebugNearestNodeList( float *pos, PathNode **nodelist, int iMaxNodes ); + static int DebugNearestNodeList2( float *pos, PathNode **nodelist, int iMaxNodes ); + static void ShowNodes( void ); + static void LoadNodes( void ); + static void CreatePaths( void ); + static void *AllocPathNode( void ); + static void FreePathNode( void * ); + static void ResetNodes( void ); + static PathInfo *GeneratePath( PathInfo *path ); + static PathInfo *GeneratePathNear( PathInfo *path ); + static PathInfo *GeneratePathAway( PathInfo *path ); + static class PathNode *GetSpawnNode( ClassDef *cls ); + static int FindPath( float *start, float *end, Entity *ent, float maxPath, float *vLeashHome, float fLeashDistSquared, int fallheight ); + static int FindPathAway( float *start, float *avoid, float *vPreferredDir, Entity *ent, float fMinSafeDist, float *vLeashHome, float fLeashDistSquared, int fallheight ); + static int FindPathNear( float *start, float *end, Entity *ent, float maxPath, float fRadiusSquared, float *vLeashHome, float fLeashDistSquared, int fallheight ); + static class PathNode *FindCornerNodeForWall( float *start, float *end, class SimpleActor *ent, float maxPath, float *plane ); + static class PathNode *FindCornerNodeForExactPath( class SimpleActor *self, Sentient *enemy, float fMaxPath ); + static int FindPotentialCover( class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy, PathNode **ppFoundNodes, int iMaxFind ); + static void PlayerCover( class Player *pPlayer ); + static class PathNode *FindNearestCover( class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy ); + static class PathNode *FindNearestSniperNode( class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy ); + +private: + static int NearestNodeSetup( vec3_t pos, MapCell *cell, int *nodes, vec3_t *deltas ); + +}; + +extern PathSearch PathManager; + +PathNode *AI_FindNode( const char *name ); +void AI_AddNode( PathNode *node ); +void AI_RemoveNode( PathNode *node ); +void AI_ResetNodes( void ); + +class AttractiveNode : public SimpleArchivedEntity +{ +public: + int m_iPriority; + bool m_bUse; + float m_fMaxStayTime; + float m_fMaxDistance; + float m_fMaxDistanceSquared; + float m_fRespawnTime; + const_str m_csTeam; + int m_iTeam; + +private: +// Container< SafePtr< Sentient > > m_pSentList; + +public: + CLASS_PROTOTYPE( AttractiveNode ); + + AttractiveNode(); + ~AttractiveNode(); + + bool CheckTeam( Sentient *sent ); + void setMaxDist( float dist ); + + void GetPriority( Event *ev ); + void SetPriority( Event *ev ); + void GetDistance( Event *ev ); + void SetDistance( Event *ev ); + void GetStayTime( Event *ev ); + void SetStayTime( Event *ev ); + void GetRespawnTime( Event *ev ); + void SetRespawnTime( Event *ev ); + void GetTeam( Event *ev ); + void SetTeam( Event *ev ); + void SetUse( Event *ev ); + + void Archive( Archiver& arc ); +}; + +typedef SafePtr< AttractiveNode > AttractiveNodePtr; + +inline void AttractiveNode::Archive + ( + Archiver& arc + ) + +{ + arc.ArchiveInteger( &m_iPriority ); + arc.ArchiveBool( &m_bUse ); + arc.ArchiveFloat( &m_fMaxStayTime ); + arc.ArchiveFloat( &m_fMaxDistanceSquared ); +} + +extern Container< AttractiveNode * > attractiveNodes; + +#endif diff --git a/code/game/player.cpp b/code/game/player.cpp new file mode 100644 index 00000000..37a19b05 --- /dev/null +++ b/code/game/player.cpp @@ -0,0 +1,14703 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// player.h: Class definition of the player. + +#include "g_local.h" +#include "bg_local.h" +#include "entity.h" +#include "player.h" +#include "world.h" +#include "weapon.h" +#include "trigger.h" +#include "scriptmaster.h" +#include "navigate.h" +#include "misc.h" +#include "earthquake.h" +#include "gravpath.h" +#include "armor.h" +#include "inventoryitem.h" +#include "gibs.h" +#include "actor.h" +#include "object.h" +#include "characterstate.h" +#include "weaputils.h" +#include "dm_manager.h" +#include +#include "body.h" +#include "PlayerStart.h" +#include "weapturret.h" +#include "vehicleturret.h" + +//Forward +//Back +//TurnRight +//TurnLeft +//Moveleft (strafe) +//Moveright (strafe) +//Moveup (Jump) +//Movedown (Duck) +//Action (Use) +//Sneak (Toggle or Momentary) +//Speed/Walk (Toggle or Momentary) +//Fire Left hand +//Fire Right hand + +#define SLOPE_45_MIN 0.7071f +#define SLOPE_45_MAX 0.831f +#define SLOPE_22_MIN SLOPE_45_MAX +#define SLOPE_22_MAX 0.95f + +#define MIN_Z -999999 +#define PUSH_OBJECT_DISTANCE 16.0f + +#define ARMS_NAME "Bip01 Spine2" + +const Vector power_color( 0.0, 1.0, 0.0 ); +const Vector acolor( 1.0, 1.0, 1.0 ); +const Vector bcolor( 1.0, 0.0, 0.0 ); + +static Vector min_box_8x8( -4, -4, -4 ); +static Vector max_box_8x8( 4, 4, 4 ); +static Vector min4x4( -4, -4, 0 ); +static Vector max4x4x0( 4, 4, 0 ); +static Vector max4x4x8( 4, 4, 8 ); + +qboolean TryPush( int entnum, vec3_t move_origin, vec3_t move_end ); + +Event EV_Player_DumpState + ( + "state", + EV_CHEAT, + NULL, + NULL, + "Dumps the player's state to the console.", + EV_NORMAL + ); +Event EV_Player_ForceLegsState + ( + "forcelegsstate", + EV_DEFAULT, + "s", + "legsstate", + "Force the player's legs to a certain state", + EV_NORMAL + ); +Event EV_Player_ForceTorsoState + ( + "forcetorsostate", + EV_DEFAULT, + "s", + "torsostate", + "Force the player's torso to a certain state", + EV_NORMAL + ); +Event EV_Player_GiveAllCheat + ( + "wuss", + EV_CONSOLE | EV_CHEAT, + NULL, + NULL, + "Gives player all weapons.", + EV_NORMAL + ); +Event EV_Player_EndLevel + ( + "endlevel", + EV_DEFAULT, + NULL, + NULL, + "Called when the player gets to the end of the level.", + EV_NORMAL + ); +Event EV_Player_DevGodCheat + ( + "dog", + EV_CHEAT | EV_CONSOLE, + "I", + "god_mode", + "Sets the god mode cheat or toggles it.", + EV_NORMAL + ); +Event EV_Player_FullHeal + ( + "fullheal", + EV_CHEAT | EV_CONSOLE, + NULL, + NULL, + "Heals player.", + EV_NORMAL + ); +Event EV_Player_Face +( + "face", + EV_CHEAT | EV_CONSOLE, + "v", + "angles", + "Force angles to specified vector", + EV_NORMAL +); +Event EV_Player_DevNoTargetCheat + ( + "notarget", + EV_CHEAT, + NULL, + NULL, + "Toggles the notarget cheat.", + EV_NORMAL + ); +Event EV_Player_DevNoClipCheat + ( + "noclip", + EV_CHEAT | EV_CONSOLE, + NULL, + NULL, + "Toggles the noclip cheat.", + EV_NORMAL + ); +Event EV_Player_Teleport +( + "tele", + EV_CHEAT | EV_CONSOLE, + "v", + "location", + "Teleport to location", + EV_NORMAL +); +Event EV_Player_PrevItem + ( + "invprev", + EV_CONSOLE, + NULL, + NULL, + "Cycle to player's previous item.", + EV_NORMAL + ); +Event EV_Player_NextItem + ( + "invnext", + EV_CONSOLE, + NULL, + NULL, + "Cycle to player's next item.", + EV_NORMAL + ); +Event EV_Player_PrevWeapon + ( + "weapprev", + EV_CONSOLE, + NULL, + NULL, + "Cycle to player's previous weapon.", + EV_NORMAL + ); +Event EV_Player_NextWeapon + ( + "weapnext", + EV_CONSOLE, + NULL, + NULL, + "Cycle to player's next weapon.", + EV_NORMAL + ); +Event EV_Player_DropWeapon + ( + "weapdrop", + EV_CONSOLE, + NULL, + NULL, + "Drops the player's current weapon.", + EV_NORMAL + ); +Event EV_Player_GiveCheat + ( + "give", + EV_CONSOLE | EV_CHEAT, + "sI", + "name amount", + "Gives the player the specified thing (weapon, ammo, item, etc.) and optionally the amount.", + EV_NORMAL + ); +Event EV_Player_GiveWeaponCheat + ( + "giveweapon", + EV_CONSOLE | EV_CHEAT, + "s", + "weapon_name", + "Gives the player the specified weapon.", + EV_NORMAL + ); +Event EV_Player_GameVersion + ( + "gameversion", + EV_CONSOLE, + NULL, + NULL, + "Prints the game version.", + EV_NORMAL + ); +Event EV_Player_Fov + ( + "fov", + EV_CONSOLE, + "F", + "fov", + "Sets the fov.", + EV_NORMAL + ); +Event EV_Player_Dead + ( + "dead", + EV_DEFAULT, + NULL, + NULL, + "Called when the player is dead.", + EV_NORMAL + ); +Event EV_Player_SpawnEntity + ( + "spawn", + EV_CHEAT, + "sSSSSSSSS", + "entityname keyname1 value1 keyname2 value2 keyname3 value3 keyname4 value4", + "Spawns an entity.", + EV_NORMAL + ); +Event EV_Player_SpawnActor + ( + "actor", + EV_CHEAT, + "sSSSSSSSS", + "modelname keyname1 value1 keyname2 value2 keyname3 value3 keyname4 value4", + "Spawns an actor.", + EV_NORMAL + ); +Event EV_Player_Respawn + ( + "respawn", + EV_DEFAULT, + NULL, + NULL, + "Respawns the player.", + EV_NORMAL + ); +Event EV_Player_TestThread + ( + "testthread", + EV_CHEAT, + "sS", + "scriptfile label", + "Starts the named thread at label if provided.", + EV_NORMAL + ); +Event EV_Player_PowerupTimer + ( + "poweruptimer", + EV_DEFAULT, + "ii", + "poweruptimer poweruptype", + "Sets the powerup timer and powerup type.", + EV_NORMAL + ); +Event EV_Player_UpdatePowerupTimer + ( + "updatepoweruptime", + EV_DEFAULT, + NULL, + NULL, + "Called once a second to decrement powerup time.", + EV_NORMAL + ); +Event EV_Player_ResetState + ( + "resetstate", + EV_CHEAT, + NULL, + NULL, + "Reset the player's state table.", + EV_NORMAL + ); +Event EV_Player_WhatIs + ( + "whatis", + EV_CHEAT, + "i", + "entity_number", + "Prints info on the specified entity.", + EV_NORMAL + ); +Event EV_Player_ActorInfo + ( + "actorinfo", + EV_CHEAT, + "i", + "actor_number", + "Prints info on the specified actor.", + EV_NORMAL + ); +Event EV_Player_KillEnt + ( + "killent", + EV_CHEAT, + "i", + "entity_number", + "Kills the specified entity.", + EV_NORMAL + ); +Event EV_Player_KillClass + ( + "killclass", + EV_CHEAT, + "sI", + "classname except_entity_number", + "Kills all of the entities in the specified class.", + EV_NORMAL + ); +Event EV_Player_RemoveEnt + ( + "removeent", + EV_CHEAT, + "i", + "entity_number", + "Removes the specified entity.", + EV_NORMAL + ); +Event EV_Player_RemoveClass + ( + "removeclass", + EV_CHEAT, + "sI", + "classname except_entity_number", + "Removes all of the entities in the specified class.", + EV_NORMAL + ); +Event EV_Player_Jump + ( + "jump", + EV_DEFAULT, + "f", + "height", + "Makes the player jump.", + EV_NORMAL + ); +Event EV_Player_SwordAttack + ( + "swordattack", + EV_DEFAULT, + "s", + "hand", + "Makes the player attack with the sword in the specified sword.", + EV_NORMAL + ); +Event EV_Player_AnimLoop_Torso + ( + "animloop_torso", + EV_DEFAULT, + NULL, + NULL, + "Called when the torso animation has finished.", + EV_NORMAL + ); +Event EV_Player_ActionAnimEnd + ( + "actionanimend", + EV_DEFAULT, + NULL, + NULL, + "Called when the action animation has finished." + ); +Event EV_Player_AnimLoop_Legs + ( + "animloop_legs", + EV_DEFAULT, + NULL, + NULL, + "Called when the legs animation has finished.", + EV_NORMAL + ); +Event EV_Player_DoUse + ( + "usestuff", + EV_DEFAULT, + NULL, + NULL, + "Makes the player try to use whatever is in front of her.", + EV_NORMAL + ); +Event EV_Player_ListInventory + ( + "listinventory", + EV_CONSOLE, + NULL, + NULL, + "List of the player's inventory.", + EV_NORMAL + ); +Event EV_Player_Turn + ( + "turn", + EV_DEFAULT, + "f", + "yawangle", + "Causes player to turn the specified amount.", + EV_NORMAL + ); +Event EV_Player_TurnUpdate + ( + "turnupdate", + EV_DEFAULT, + "ff", + "yaw timeleft", + "Causes player to turn the specified amount.", + EV_NORMAL + ); +Event EV_Player_TurnLegs + ( + "turnlegs", + EV_DEFAULT, + "f", + "yawangle", + "Turns the players legs instantly by the specified amount.", + EV_NORMAL + ); +Event EV_Player_NextPainTime + ( + "nextpaintime", + EV_DEFAULT, + "f", + "seconds", + "Set the next time the player experiences pain (Current time + seconds specified).", + EV_NORMAL + ); + +Event EV_Player_FinishUseAnim + ( + "finishuseanim", + EV_DEFAULT, + NULL, + NULL, + "Fires off all targets associated with a particular useanim.", + EV_NORMAL + ); +Event EV_Player_Holster + ( + "holster", + EV_CONSOLE, + NULL, + NULL, + "Holsters all wielded weapons, or unholsters previously put away weapons", + EV_NORMAL + ); +Event EV_Player_SafeHolster + ( + "safeholster", + EV_CONSOLE, + "b", + "putaway", + "Holsters all wielded weapons, or unholsters previously put away weapons\n" + "preserves state, so it will not holster or unholster unless necessary", + EV_NORMAL + ); +Event EV_Player_StartUseObject + ( + "startuseobject", + EV_DEFAULT, + NULL, + NULL, + "starts up the useobject's animations.", + EV_NORMAL + ); +Event EV_Player_FinishUseObject + ( + "finishuseobject", + EV_DEFAULT, + NULL, + NULL, + "Fires off all targets associated with a particular useobject.", + EV_NORMAL + ); +Event EV_Player_WatchActor + ( + "watchactor", + EV_DEFAULT, + "e", + "actor_to_watch", + "Makes the player's camera watch the specified actor.", + EV_NORMAL + ); +Event EV_Player_StopWatchingActor + ( + "stopwatchingactor", + EV_DEFAULT, + "e", + "actor_to_stop_watching", + "Makes the player's camera stop watching the specified actor.", + EV_NORMAL + ); +Event EV_Player_SetDamageMultiplier + ( + "damage_multiplier", + EV_DEFAULT, + "f", + "damage_multiplier", + "Sets the current damage multiplier", + EV_NORMAL + ); +Event EV_Player_WaitForState + ( + "waitForState", + EV_DEFAULT, + "s", + "stateToWaitFor", + "When set, the player will clear waitforplayer when this state is hit\n" + "in the legs or torso.", + EV_NORMAL + ); +Event EV_Player_LogStats + ( + "logstats", + EV_CHEAT, + "b", + "state", + "Turn on/off the debugging playlog", + EV_NORMAL + ); +Event EV_Player_TakePain + ( + "takepain", + EV_DEFAULT, + "b", + "bool", + "Set whether or not to take pain", + EV_NORMAL + ); +Event EV_Player_SkipCinematic + ( + "skipcinematic", + EV_CONSOLE, + NULL, + NULL, + "Skip the current cinematic", + EV_NORMAL + ); +Event EV_Player_ResetHaveItem + ( + "resethaveitem", + EV_CONSOLE, + "s", + "weapon_name", + "Resets the game var that keeps track that we have gotten this weapon", + EV_NORMAL + ); +Event EV_Player_ModifyHeight +( + "modheight", + EV_DEFAULT, + "s", + "height", + "change the maximum height of the player\ncan specify 'stand', 'duck' or 'prone'.", + 0 +); +Event EV_Player_PrimaryDMWeapon +( + "primarydmweapon", + EV_CONSOLE, + "s", + "weaptype", + "Sets the player's primary DM weapon", + EV_NORMAL +); +Event EV_Player_DeadBody +( + "deadbody", + EV_DEFAULT, + NULL, + NULL, + "Spawn a dead body" +); + +Event EV_Player_Physics_On +( + "physics_on", + EV_DEFAULT, + NULL, + NULL, + "turn player physics on." +); + +Event EV_Player_Physics_Off +( + "physics_off", + EV_DEFAULT, + NULL, + NULL, + "turn player physics off." +); + +Event EV_Player_AttachToLadder +( + "attachtoladder", + EV_DEFAULT, + NULL, + NULL, + "Attaches the sentient to a ladder" +); + +Event EV_Player_UnattachFromLadder +( + "unattachfromladder", + EV_DEFAULT, + NULL, + NULL, + "Unattaches the sentient from a ladder" +); + +Event EV_Player_TweakLadderPos +( + "tweakladderpos", + EV_DEFAULT, + NULL, + NULL, + "Tweaks the player's position on a ladder to be proper" +); + +Event EV_Player_EnsureOverLadder +( + "ensureoverladder", + EV_DEFAULT, + NULL, + NULL, + "Ensures that the player is at the proper height when getting off the top of a ladder" +); + +Event EV_Player_EnsureForwardOffLadder +( + "ensureforwardoffladder", + EV_DEFAULT, + NULL, + NULL, + "Ensures that the player went forward off the ladder." +); + +Event EV_Player_GetIsDisguised +( + "is_disguised", + EV_DEFAULT, + NULL, + NULL, + "zero = not disguised, non-zero = disguised", + EV_GETTER +); + +Event EV_Player_GetHasDisguise +( + "has_disguise", + EV_DEFAULT, + NULL, + NULL, + "zero = does not have a disguise, non-zero = has a disguise", + EV_GETTER +); + +Event EV_Player_SetHasDisguise +( + "has_disguise", + -1, + "i", + "is_disguised", + "zero = does not have a disguise, non-zero = has a disguise", + EV_SETTER +); + +Event EV_Player_ObjectiveCount +( + "objective", + EV_DEFAULT, + "ii", + "num_completed out_of", + "Sets the number of objectives completed and the total number of objectives" +); + +Event EV_Player_Stats +( + "stats", + EV_CONSOLE, + NULL, + NULL, + "Display the MissionLog." +); + +Event EV_Player_Reload +( + "reload", + EV_CONSOLE, + NULL, + NULL, + "Reloads the player's weapon", + EV_NORMAL +); +Event EV_Player_CorrectWeaponAttachments +( + "correctweaponattachments", + EV_CONSOLE, + NULL, + NULL, + "makes sure the weapons is properly attached when interupting a reload", + EV_NORMAL +); +Event EV_Player_Score +( + "score", + EV_CONSOLE, + NULL, + NULL, + "Show the score for the current deathmatch game", + EV_NORMAL +); +Event EV_Player_SetMovePosFlags +( + "moveposflags", + EV_DEFAULT, + "sS", + "position movement", + "used by the state files to tell the game dll what the player is doing", + EV_NORMAL +); +Event EV_Player_GetPosition +( + "getposition", + EV_DEFAULT, + NULL, + NULL, + "returns the player current position", + EV_RETURN +); +Event EV_Player_GetMovement +( + "getmovement", + EV_DEFAULT, + NULL, + NULL, + "returns the player current movement", + EV_RETURN +); +Event EV_Player_Spectator +( + "spectator", + EV_CONSOLE, + NULL, + NULL, + "Become a spectator", + EV_NORMAL +); +Event EV_Player_SetViewModelAnim +( + "viewmodelanim", + EV_DEFAULT, + "sI", + "name force_restart", + "Sets the player's view model animation.", + EV_NORMAL +); +Event EV_Player_DMMessage +( + "dmmessage", + EV_CONSOLE, + "is", + "mode stuffstrings", + "sends a DM message to the appropriate players", + EV_NORMAL +); +Event EV_Player_IPrint +( + "iprint", + EV_CONSOLE, + "sI", + "string bold", + "prints a string to the player, optionally in bold", + EV_NORMAL +); +Event EV_Player_DMDeathDrop +( + "dmdeathdrop", + EV_DEFAULT, + NULL, + NULL, + "Drops the player inventory in DM after's he's been killed" +); +Event EV_Player_Stopwatch +( + "stopwatch", + EV_DEFAULT, + "i", + "duration", + "Starts a stopwatch for a given duration... use 0 to clear the stopwatch" +); +Event EV_Player_EnterIntermission +( + "_enterintermission", + EV_CODEONLY, + NULL, + NULL, + "CODE USE ONLY" +); +Event EV_Player_SetPerferredWeapon +( + "perferredweapon", + EV_DEFAULT, + "s", + "weapon_name", + "Overrides your perferred weapon that is displayed in the stats screen." +); +Event EV_Player_SetVoiceType +( + "voicetype", + EV_DEFAULT, + "s", + "voice_name", + "Sets the voice type to use the player." +); +Event EV_Player_Coord +( + "coord", + EV_CONSOLE, + NULL, + NULL, + "Prints out current location and angles" +); +Event EV_GetViewangles +( + "viewangles", + EV_DEFAULT, + NULL, + NULL, + "get the angles of the entity.", + EV_GETTER +); +Event EV_SetViewangles +( + "viewangles", + EV_DEFAULT, + "v", + "newAngles", + "set the view angles of the entity to newAngles.", + EV_SETTER +); +Event EV_GetUseHeld +( + "useheld", + EV_DEFAULT, + NULL, + NULL, + "returns 1 if this player is holding use, or 0 if he is not", + EV_GETTER +); + +Event EV_GetFireHeld +( + "fireheld", + EV_DEFAULT, + NULL, + NULL, + "returns 1 if this player is holding fire, or 0 if he is not", + EV_GETTER +); + +Event EV_Player_GetReady +( + "ready", + EV_DEFAULT, + NULL, + NULL, + "returns 1 if this player is ready, 0 otherwise", + EV_GETTER + ); + +Event EV_Player_SetReady +( + "ready", + EV_CONSOLE, + NULL, + NULL, + "makes this player ready for the round to start" +); + +Event EV_Player_SetNotReady +( + "notready", + EV_CONSOLE, + NULL, + NULL, + "makes this player not ready for the round to start" +); + +Event EV_Player_GetDMTeam +( + "dmteam", + EV_DEFAULT, + NULL, + NULL, + "returns 'allies', 'axis', 'spectator', or 'freeforall'", + EV_GETTER +); +Event EV_Player_StuffText +( + "stufftext", + EV_DEFAULT, + "s", + "stuffstrings", + "Stuffs text to the player's console" +); +Event EV_Player_TurretEnter +( + "turretenter", + EV_DEFAULT, + "es", + "turret driver_anim", + "Called when someone gets into a turret." +); +Event EV_Player_TurretExit +( + "turretexit", + EV_DEFAULT, + "e", + "turret", + "Called when driver gets out of the turret." +); +Event EV_Player_SafeZoom +( + "safezoom", + EV_DEFAULT, + "b", + "zoomin", + "0 turns off zoom, and 1 returns zoom to previous setting" +); +Event EV_Player_ZoomOff +( + "zoomoff", + EV_DEFAULT, + NULL, + NULL, + "makes sure that zoom is off" +); + +// reborn stuff +Event EV_Player_AddKills +( + "addkills", + EV_DEFAULT, + "i", + "kills", + "adds kills number to player", + EV_NORMAL +); + +Event EV_Player_AddDeaths +( + "adddeaths", + EV_DEFAULT, + "i", + "deaths", + "adds deaths number to player", + EV_NORMAL +); + +Event EV_Player_AdminRights +( + "adminrights", + EV_DEFAULT, + NULL, + NULL, + "returns client admin rights", + EV_GETTER +); + +Event EV_Player_BindWeap +( + "bindweap", + EV_DEFAULT, + "ei", + "weapon handnum", + "binds weapon to player and sets him as weapon owner", + EV_NORMAL +); + +Event EV_Player_CanSwitchTeams +( + "canswitchteams", + EV_DEFAULT, + "bB", + "allow_team_change allow_spectate", + "Specify if this player is allowed to switch teams and spectate. Doesn't override global canswitchteams.", + EV_NORMAL +); + +Event EV_Player_ClearCommand +( + "clearcommand", + EV_DEFAULT, + "S", + "command", + "Clears any or a specific client command", + EV_NORMAL +); + +Event EV_Player_Dive +( + "dive", + EV_DEFAULT, + "fF", + "height airborne_duration", + "Makes the player dive into prone position.", + EV_NORMAL +); + +Event EV_Player_Earthquake +( + "earthquake2", + EV_DEFAULT, + "ffbbVF", + "duration magnitude no_rampup no_rampdown location radius", + "Create a smooth realistic earthquake for a player. Requires sv_reborn to be set.", + EV_NORMAL +); + +Event EV_Player_FreezeControls +( + "freezecontrols", + EV_DEFAULT, + "b", + "freeze_state", + "Blocks or unblocks control input from this player.", + EV_NORMAL +); + +Event EV_Player_GetConnState +( + "getconnstate", + EV_DEFAULT, + NULL, + NULL, + "gets connection state. [DEPRECATED]", + EV_RETURN +); + +Event EV_Player_GetDamageMultiplier +( + "damage_multiplier", + EV_DEFAULT, + "Gets the current damage multiplier", + NULL, + NULL, + EV_GETTER +); + +Event EV_Player_GetKillHandler +( + "killhandler", + EV_DEFAULT, + "s", + "label", + "Gets the player's current killed event handler. Returns NIL if no custom killhandler was set.", + EV_GETTER +); + + +Event EV_Player_GetKills +( + "getkills", + EV_DEFAULT, + NULL, + NULL, + "gets kills number of player", + EV_RETURN +); + +Event EV_Player_GetDeaths +( + "getdeaths", + EV_DEFAULT, + NULL, + NULL, + "gets deaths number of player", + EV_RETURN +); + +Event EV_Player_GetLegsState +( + "getlegsstate", + EV_DEFAULT, + NULL, + NULL, + "Gets the player's current legs state name", + EV_RETURN +); + +Event EV_Player_GetStateFile +( + "statefile", + EV_DEFAULT, + NULL, + NULL, + "Gets the player's current state file.", + EV_GETTER +); + +Event EV_Player_GetTorsoState +( + "gettorsostate", + EV_DEFAULT, + NULL, + NULL, + "Gets the player's current torso state name", + EV_RETURN +); + +Event EV_Player_HideEnt +( + "hideent", + EV_DEFAULT, + "e", + "entity", + "Hides the specified entity to the player.", + EV_NORMAL +); + +Event EV_Player_Inventory +( + "inventory", + EV_DEFAULT, + NULL, + NULL, + "returns player's inventory", + EV_GETTER +); + +Event EV_Player_InventorySet +( + "inventory", + EV_DEFAULT, + "e", + "array", + "Set up the player's inventory", + EV_SETTER +); + +Event EV_Player_IsAdmin +( + "isadmin", + EV_DEFAULT, + NULL, + NULL, + "checks if player is logged as admin", + EV_RETURN +); + +Event EV_Player_IsSpectator +( + "isspectator", + EV_DEFAULT, + NULL, + NULL, + "checks if player is in spectator", + EV_RETURN +); + +Event EV_Player_JoinDMTeam +( + "join_team", + EV_CONSOLE, + "s", + "team", + "Join the specified team (allies or axis)", + EV_NORMAL +); + +Event EV_Player_AutoJoinDMTeam +( + "auto_join_team", + EV_CONSOLE, + NULL, + NULL, + "Join the team with fewer players" +); + +Event EV_Player_JoinArena +( + "join_arena", + EV_CONSOLE, + "i", + "arena_id_num", + "Join the specified arena" +); + +Event EV_Player_LeaveArena +( + "leave_arena", + EV_CONSOLE, + NULL, + NULL, + "Leave the current arena" +); + +Event EV_Player_CreateTeam +( + "create_team", + EV_CONSOLE, + NULL, + NULL, + "Create a team in the current arena" +); + +Event EV_Player_LeaveTeam +( + "leave_team", + EV_CONSOLE, + NULL, + NULL, + "Leave the current team" +); + +Event EV_Player_RefreshArenaUI +( + "arena_ui", + EV_CONSOLE, + NULL, + NULL, + "Refresh the arena UI" +); + +Event EV_Player_CallVote +( + "callvote", + EV_CONSOLE, + "ss", + "arg1 arg2", + "Player calls a vote" +); + +Event EV_Player_Vote +( + "vote", + EV_CONSOLE, + "s", + "arg1", + "Player votes either yes or no" +); + +Event EV_Player_LeanLeftHeld +( + "leanleftheld", + EV_DEFAULT, + NULL, + NULL, + "Returns 1 if this player is holding lean left key, or 0 if he is not", + EV_GETTER +); + +Event EV_Player_LeanRightHeld +( + "leanrightheld", + EV_DEFAULT, + NULL, + NULL, + "returns EV_RETURN if this player is holding lean right key, or 0 if he is not", + EV_GETTER +); + +Event EV_Player_ModifyHeightFloat +( + "modheightfloat", + EV_DEFAULT, + "ff", + "height max_z", + "Specify the view height of the player and the height of his bounding box.", + EV_NORMAL +); + +Event EV_Player_MoveSpeedScale +( + "moveSpeedScale", + EV_DEFAULT, + "f", + "speed", + "Sets the player's speed multiplier (default 1.0).", + EV_SETTER +); + +Event EV_Player_MoveSpeedScaleGet +( + "moveSpeedScale", + EV_DEFAULT, + NULL, + NULL, + "Gets the player's speed multiplier.", + EV_GETTER +); + +Event EV_Player_PlayLocalSound +( + "playlocalsound", + EV_DEFAULT, + "sBF", + "soundName loop time", + "Plays a local sound to the player. The sound must be aliased globally. Requires sv_reborn to be set for stereo sounds.", + EV_NORMAL +); + +Event EV_Player_Replicate +( + "replicate", + EV_DEFAULT, + "s", + "variable", + "Replicate a variable to the client (needs patch 1.12).", + EV_NORMAL +); + +Event EV_Player_RunHeld +( + "runheld", + EV_DEFAULT, + NULL, + NULL, + "returns 1 if this player is holding run key, or 0 if he is not", + EV_GETTER +); + +Event EV_Player_SecFireHeld +( + "secfireheld", + EV_DEFAULT, + NULL, + NULL, + "returns EV_RETURN if this player is holding secondary fire, or 0 if he is not", + EV_GETTER +); + +Event EV_Player_SetAnimSpeed +( + "setanimspeed", + EV_DEFAULT, + "f", + "speed", + "set the player's animation speed multiplier (default 1.0).", + EV_NORMAL +); + +Event EV_Player_SetFov +( + "setfov", + EV_DEFAULT, + "f", + "fov", + "set the player's fov (default 80).", + EV_NORMAL +); + +Event EV_Player_SetKillHandler +( + "killhandler", + EV_DEFAULT, + "s", + "label", + "Replace the player's killed event by a new scripted handler. None or an empty string will revert to the default killed event handler.", + EV_SETTER +); + +Event EV_Player_SetClientFlag +( + "setclientflag", + EV_DEFAULT, + "s", + "name", + "Calls a flag to the script client.", + EV_NORMAL +); + +Event EV_Player_SetEntityShader +( + "setentshader", + EV_DEFAULT, + "es", + "entity shadername", + "Sets an entity shader for this player. An empty string will revert to the normal entity shader.", + EV_NORMAL +); + +Event EV_Player_SetLocalSoundRate +( + "setlocalsoundrate", + EV_DEFAULT, + "sfF", + "name rate time", + "Sets the local sound rate.", + EV_NORMAL +); + +Event EV_Player_SetSpeed +( + "setspeed", + EV_DEFAULT, + "fI", + "speed index", + "Sets the player's speed multiplier (default 1.0). Index specify which array value will be used (maximum 4).", + EV_NORMAL +); + +Event EV_Player_SetStateFile +( + "statefile", + EV_DEFAULT, + "S", + "statefile", + "Sets the player's current state file (setting NIL, NULL or an empty string will revert to the global statefile).", + EV_SETTER +); + +Event EV_Player_SetTeam +( + "setteam", + EV_DEFAULT, + "s", + "team_name", + "sets the player's team without respawning.\n" + "Available team names are 'none', 'spectator', 'freeforall', 'axis' and 'allies'.", + EV_NORMAL +); + +Event EV_Player_SetViewModelAnimSpeed +( + "setvmaspeed", + EV_DEFAULT, + "sf", + "name speed", + "Sets the player's animation speed when playing it.", + EV_NORMAL +); + +Event EV_Player_ShowEnt +( + "showent", + EV_DEFAULT, + "e", + "entity", + "Shows the specified entity to the player.", + EV_NORMAL +); + +Event EV_Player_StopLocalSound +( + "stoplocalsound", + EV_DEFAULT, + "sF", + "soundName time", + "Stops the specified sound.", + EV_NORMAL +); + +Event EV_Player_UseHeld +( + "useheld", + EV_DEFAULT, + NULL, + NULL, + "returns 1 if this player is holding use key, or 0 if he is not", + EV_GETTER +); + +Event EV_Player_Userinfo +( + "userinfo", + EV_DEFAULT, + NULL, + NULL, + "returns userinfo string", + EV_GETTER +); + +Event EV_Player_ViewModelGetAnim +( + "viewmodelgetanim", + EV_DEFAULT, + "B", + "fullanim", + "Gets the player's current view model animation.", + EV_RETURN +); + +Event EV_Player_ViewModelAnimFinished +( + "viewmodelanimfinished", + EV_DEFAULT, + NULL, + NULL, + "True if the player's current view model finished its animation.", + EV_RETURN +); + +Event EV_Player_ViewModelAnimValid + ( + "viewmodelanimvalid", + EV_DEFAULT, + "sB", + "anim fullanim", + "True if the view model animation is valid.", + EV_RETURN + ); + +Event EV_Player_VisionSetBlur +( + "visionsetblur", + EV_DEFAULT, + "fF", + "level transition_time", + "Sets the player's blur level. Level is a fraction from 0-1", + EV_NORMAL +); + +Event EV_Player_VisionGetNaked +( + "visiongetnaked", + EV_DEFAULT, + NULL, + NULL, + "Gets the player's current naked-eye vision.", + EV_RETURN +); + +Event EV_Player_VisionSetNaked +( + "visionsetnaked", + EV_DEFAULT, + "sFF", + "vision_name transition_time phase", + "Sets the player's naked-eye vision. Optionally give a transition time from the current vision. If vision_name is an empty string, it will revert to the current global vision.", + EV_NORMAL +); + +/* +============================================================================== + +PLAYER + +============================================================================== +*/ + +CLASS_DECLARATION( Sentient, Player, "player" ) +{ + { &EV_Vehicle_Enter, &Player::EnterVehicle }, + { &EV_Vehicle_Exit, &Player::ExitVehicle }, + { &EV_Turret_Enter, &Player::EnterTurret }, + { &EV_Turret_Exit, &Player::ExitTurret }, + { &EV_Player_EndLevel, &Player::EndLevel }, + { &EV_Player_PrevItem, &Player::SelectPreviousItem }, + { &EV_Player_NextItem, &Player::SelectNextItem }, + { &EV_Player_PrevWeapon, &Player::SelectPreviousWeapon }, + { &EV_Player_NextWeapon, &Player::SelectNextWeapon }, + { &EV_Player_DropWeapon, &Player::DropCurrentWeapon }, + { &EV_Player_Reload, &Player::PlayerReload }, + { &EV_Player_CorrectWeaponAttachments, &Player::EventCorrectWeaponAttachments }, + { &EV_Player_GiveCheat, &Player::GiveCheat }, + { &EV_Player_GiveWeaponCheat, &Player::GiveWeaponCheat }, + { &EV_Player_GiveAllCheat, &Player::GiveAllCheat }, + { &EV_Player_DevGodCheat, &Player::GodCheat }, + { &EV_Player_FullHeal, &Player::FullHeal }, + { &EV_Player_DevNoTargetCheat, &Player::NoTargetCheat }, + { &EV_Player_DevNoClipCheat, &Player::NoclipCheat }, + { &EV_Player_GameVersion, &Player::GameVersion }, + { &EV_Player_DumpState, &Player::DumpState }, + { &EV_Player_ForceTorsoState, &Player::ForceTorsoState }, + { &EV_Player_ForceLegsState, &Player::ForceLegsState }, + { &EV_Player_Fov, &Player::EventSetSelectedFov }, + { &EV_Kill, &Player::Kill }, + { &EV_Player_Dead, &Player::Dead }, + { &EV_Player_SpawnEntity, &Player::SpawnEntity }, + { &EV_Player_SpawnActor, &Player::SpawnActor }, + { &EV_Player_Respawn, &Player::Respawn }, + { &EV_Player_DoUse, &Player::DoUse }, + { &EV_Pain, &Player::Pain }, + { &EV_Killed, &Player::Killed }, + { &EV_GotKill, &Player::GotKill }, + { &EV_Player_TestThread, &Player::TestThread }, + { &EV_Player_PowerupTimer, &Player::SetPowerupTimer }, + { &EV_Player_UpdatePowerupTimer, &Player::UpdatePowerupTimer }, + { &EV_Player_ResetState, &Player::ResetState }, + { &EV_Player_WhatIs, &Player::WhatIs }, + { &EV_Player_ActorInfo, &Player::ActorInfo }, + { &EV_Player_KillEnt, &Player::KillEnt }, + { &EV_Player_RemoveEnt, &Player::RemoveEnt }, + { &EV_Player_KillClass, &Player::KillClass }, + { &EV_Player_RemoveClass, &Player::RemoveClass }, + { &EV_Player_AnimLoop_Legs, &Player::EndAnim_Legs }, + { &EV_Player_AnimLoop_Torso, &Player::EndAnim_Torso }, + { &EV_Player_ActionAnimEnd, &Player::EndActionAnim }, + { &EV_Player_Jump, &Player::Jump }, + { &EV_Sentient_JumpXY, &Player::JumpXY }, + { &EV_Player_ListInventory, &Player::ListInventoryEvent }, + { &EV_Player_NextPainTime, &Player::NextPainTime }, + { &EV_Player_Turn, &Player::Turn }, + { &EV_Player_TurnUpdate, &Player::TurnUpdate }, + { &EV_Player_TurnLegs, &Player::TurnLegs }, + { &EV_Player_FinishUseAnim, &Player::FinishUseAnim }, + { &EV_Player_Holster, &Player::HolsterToggle }, + { &EV_Player_SafeHolster, &Player::Holster }, + { &EV_Player_SafeZoom, &Player::SafeZoomed }, + { &EV_Player_ZoomOff, &Player::ZoomOffEvent }, + { &EV_Player_StartUseObject, &Player::StartUseObject }, + { &EV_Player_FinishUseObject, &Player::FinishUseObject }, + { &EV_Player_WatchActor, &Player::WatchActor }, + { &EV_Player_StopWatchingActor, &Player::StopWatchingActor }, + { &EV_Player_SetDamageMultiplier, &Player::SetDamageMultiplier }, + { &EV_Player_WaitForState, &Player::WaitForState }, + { &EV_Player_LogStats, &Player::LogStats }, + { &EV_Player_TakePain, &Player::SetTakePain }, + { &EV_Player_SkipCinematic, &Player::SkipCinematic }, + { &EV_Player_ResetHaveItem, &Player::ResetHaveItem }, + { &EV_Show, &Player::PlayerShowModel }, + { &EV_Player_ModifyHeight, &Player::ModifyHeight }, + { &EV_Player_SetMovePosFlags, &Player::SetMovePosFlags }, + { &EV_Player_GetPosition, &Player::GetPositionForScript }, + { &EV_Player_GetMovement, &Player::GetMovementForScript }, + { &EV_Player_Teleport, &Player::EventTeleport }, + { &EV_Player_Face, &Player::EventFace }, + { &EV_Player_Coord, &Player::EventCoord }, + { &EV_Player_Score, &Player::Score }, + { &EV_Player_JoinDMTeam, &Player::Join_DM_Team }, + { &EV_Player_AutoJoinDMTeam, &Player::Auto_Join_DM_Team }, + { &EV_Player_LeaveTeam, &Player::Leave_DM_Team }, + { &EV_Player_Spectator, &Player::Spectator }, + { &EV_Player_CallVote, &Player::CallVote }, + { &EV_Player_Vote, &Player::Vote }, + { &EV_Player_PrimaryDMWeapon, &Player::EventPrimaryDMWeapon }, + { &EV_Player_DeadBody, &Player::DeadBody }, + { &EV_Player_Physics_On, &Player::PhysicsOn }, + { &EV_Player_Physics_Off, &Player::PhysicsOff }, + { &EV_Player_AttachToLadder, &Player::AttachToLadder }, + { &EV_Player_UnattachFromLadder, &Player::UnattachFromLadder }, + { &EV_Player_TweakLadderPos, &Player::TweakLadderPos }, + { &EV_Player_EnsureOverLadder, &Player::EnsureOverLadder }, + { &EV_Player_EnsureForwardOffLadder, &Player::EnsureForwardOffLadder }, + { &EV_Damage, &Player::ArmorDamage }, + { &EV_Player_GetIsDisguised, &Player::GetIsDisguised }, + { &EV_Player_GetHasDisguise, &Player::GetHasDisguise }, + { &EV_Player_SetHasDisguise, &Player::SetHasDisguise }, + { &EV_Player_ObjectiveCount, &Player::SetObjectiveCount }, + { &EV_Player_Stats, &Player::Stats }, + { &EV_Player_StuffText, &Player::EventStuffText }, + { &EV_Player_DMMessage, &Player::EventDMMessage }, + { &EV_Player_IPrint, &Player::EventIPrint }, + { &EV_SetViewangles, &Player::SetViewangles }, + { &EV_GetViewangles, &Player::GetViewangles }, + { &EV_GetUseHeld, &Player::EventGetUseHeld }, + { &EV_GetFireHeld, &Player::EventGetFireHeld }, + { &EV_Player_GetReady, &Player::EventGetReady }, + { &EV_Player_SetReady, &Player::EventSetReady }, + { &EV_Player_SetNotReady, &Player::EventSetNotReady }, + { &EV_Player_GetDMTeam, &Player::EventGetDMTeam }, + { &EV_Player_SetViewModelAnim, &Player::EventSetViewModelAnim }, + { &EV_Player_DMDeathDrop, &Player::EventDMDeathDrop }, + { &EV_Player_Stopwatch, &Player::EventStopwatch }, + { &EV_Player_EnterIntermission, &Player::EventEnterIntermission }, + { &EV_Player_SetPerferredWeapon, &Player::EventSetPerferredWeapon }, + { &EV_Player_SetVoiceType, &Player::EventSetVoiceType }, + + { &EV_Player_AddDeaths, &Player::AddDeaths }, + { &EV_Player_AddKills, &Player::AddKills }, + { &EV_Player_AdminRights, &Player::AdminRights }, + { &EV_Player_BindWeap, &Player::BindWeap }, + { &EV_Player_CanSwitchTeams, &Player::CanSwitchTeams }, + { &EV_Player_ClearCommand, &Player::ClearCommand }, + { &EV_Player_Dive, &Player::Dive }, + { &EV_Player_DMMessage, &Player::EventDMMessage }, + { &EV_Player_Earthquake, &Player::EventEarthquake }, + { &EV_Player_FreezeControls, &Player::FreezeControls }, + { &EV_Player_SetTeam, &Player::EventSetTeam }, + { &EV_Player_GetConnState, &Player::GetConnState }, + { &EV_Player_GetDamageMultiplier, &Player::GetDamageMultiplier }, + { &EV_Player_GetDeaths, &Player::GetDeaths }, + { &EV_Player_GetKillHandler, &Player::GetKillHandler }, + { &EV_Player_GetKills, &Player::GetKills }, + { &EV_Player_GetLegsState, &Player::GetLegsState }, + { &EV_Player_GetStateFile, &Player::GetStateFile }, + { &EV_Player_GetTorsoState, &Player::GetTorsoState }, + { &EV_Player_HideEnt, &Player::HideEntity }, + { &EV_Player_Inventory, &Player::Inventory }, + { &EV_Player_InventorySet, &Player::InventorySet }, + { &EV_Player_IsSpectator, &Player::EventIsSpectator }, + { &EV_Player_IsAdmin, &Player::IsAdmin }, + { &EV_Player_LeanLeftHeld, &Player::LeanLeftHeld }, + { &EV_Player_LeanRightHeld, &Player::LeanRightHeld }, + { &EV_Player_ModifyHeight, &Player::ModifyHeight }, + { &EV_Player_ModifyHeightFloat, &Player::ModifyHeightFloat }, + { &EV_Player_MoveSpeedScale, &Player::SetSpeed }, + { &EV_Player_MoveSpeedScaleGet, &Player::GetMoveSpeedScale }, + { &EV_Player_PlayLocalSound, &Player::PlayLocalSound }, + { &EV_Player_Replicate, &Player::EventReplication }, + { &EV_Player_RunHeld, &Player::RunHeld }, + { &EV_Player_SecFireHeld, &Player::SecFireHeld }, + { &EV_Player_SetAnimSpeed, &Player::SetAnimSpeed }, + { &EV_Player_SetClientFlag, &Player::SetClientFlag }, + { &EV_Player_SetEntityShader, &Player::SetEntityShader }, + { &EV_Player_SetKillHandler, &Player::SetKillHandler }, + { &EV_Player_SetLocalSoundRate, &Player::SetLocalSoundRate }, + { &EV_Player_SetSpeed, &Player::SetSpeed }, + { &EV_Player_SetStateFile, &Player::SetStateFile }, + { &EV_Player_SetViewModelAnimSpeed, &Player::SetVMASpeed }, + { &EV_Player_ShowEnt, &Player::ShowEntity }, + { &EV_Player_Spectator, &Player::Spectator }, + { &EV_Player_StopLocalSound, &Player::StopLocalSound }, + { &EV_Player_UseHeld, &Player::UseHeld }, + { &EV_Player_Userinfo, &Player::Userinfo }, + { &EV_Player_ViewModelAnimFinished, &Player::EventGetViewModelAnimFinished }, + { &EV_Player_ViewModelGetAnim, &Player::EventGetViewModelAnim }, + { &EV_Player_ViewModelAnimValid, &Player::EventGetViewModelAnimValid }, + { &EV_Player_VisionGetNaked, &Player::VisionGetNaked }, + { &EV_Player_VisionSetBlur, &Player::VisionSetBlur }, + { &EV_Player_VisionSetNaked, &Player::VisionSetNaked }, + { NULL, NULL } +}; + +qboolean Player::checkturnleft + ( + Conditional &condition + ) + +{ + float yaw; + + yaw = SHORT2ANGLE( last_ucmd.angles[ YAW ] + client->ps.delta_angles[ YAW ] ); + + return ( angledist( old_v_angle[ YAW ] - yaw ) < -8.0f ); +} + +qboolean Player::checkturnright + ( + Conditional &condition + ) + +{ + float yaw; + + yaw = SHORT2ANGLE( last_ucmd.angles[ YAW ] + client->ps.delta_angles[ YAW ] ); + + return ( angledist( old_v_angle[ YAW ] - yaw ) > 8.0f ); +} + +qboolean Player::checkforward + ( + Conditional &condition + ) + +{ + return last_ucmd.forwardmove > 0; +} + +qboolean Player::checkbackward + ( + Conditional &condition + ) + +{ + return last_ucmd.forwardmove < 0; +} + +qboolean Player::checkstrafeleft + ( + Conditional &condition + ) + + { + return last_ucmd.rightmove < 0; + } + +qboolean Player::checkstraferight + ( + Conditional &condition + ) + + { + return last_ucmd.rightmove > 0; + } + +qboolean Player::checkrise + ( + Conditional &condition + ) + +{ + return false; +} + +qboolean Player::checkjump + ( + Conditional &condition + ) + + { + return last_ucmd.upmove > 0; + } + +qboolean Player::checkcrouch( Conditional &condition ) +{ + if ( last_ucmd.upmove < 0 ) // check for downward movement + { + return true; + } + + return false; +} + +qboolean Player::checkjumpflip + ( + Conditional &condition + ) + + { + return velocity.z < ( sv_gravity->value * 0.5f ); + } + +qboolean Player::checkanimdone_legs + ( + Conditional &condition + ) + +{ + return animdone_Legs; +} + +qboolean Player::checkanimdone_torso + ( + Conditional &condition + ) + +{ + return animdone_Torso; +} + + +qboolean Player::checkattackleft + ( + Conditional &condition + ) + +{ + if( level.playerfrozen || m_bFrozen || ( flags & FL_IMMOBILE ) || !m_bAllowFighting ) + { + return false; + } + + if( last_ucmd.buttons & BUTTON_ATTACK ) + { + Weapon *weapon; + + last_attack_button = BUTTON_ATTACK; + + weapon = GetActiveWeapon( WEAPON_MAIN ); + if( weapon ) + { + return true; + } + + // No ammo + return false; + } + else + { + return false; + } +} + +qboolean Player::checkattackbuttonleft + ( + Conditional &condition + ) + +{ + if( level.playerfrozen || m_bFrozen || ( flags & FL_IMMOBILE ) || !m_bAllowFighting ) + { + return false; + } + + return ( last_ucmd.buttons & BUTTON_ATTACK ); +} + + +qboolean Player::checkattackright + ( + Conditional &condition + ) + +{ + if( level.playerfrozen || m_bFrozen || ( flags & FL_IMMOBILE ) || !m_bAllowFighting ) + { + return false; + } + + if( last_ucmd.buttons & BUTTON_ATTACK2 ) + { + Weapon *weapon; + + last_attack_button = BUTTON_ATTACK2; + + weapon = GetActiveWeapon( WEAPON_MAIN ); + if( weapon ) + { + return true; + } + + // No ammo + return false; + } + else + { + return false; + } +} + +qboolean Player::checkattackbuttonright + ( + Conditional &condition + ) + +{ + if( level.playerfrozen || m_bFrozen || ( flags & FL_IMMOBILE ) || !m_bAllowFighting ) + { + return false; + } + + return ( last_ucmd.buttons & BUTTON_ATTACK2 ); +} + +qboolean Player::checksneak + ( + Conditional &condition + ) + +{ + return ( last_ucmd.upmove ) < 0; +} + +qboolean Player::checkrun + ( + Conditional &condition + ) + +{ + return ( last_ucmd.buttons & BUTTON_RUN ) != 0; +} + +qboolean Player::checkholsterweapon + ( + Conditional &condition + ) + + { + return ( last_ucmd.buttons & BUTTON_HOLSTER ) != 0; + } + +qboolean Player::checkuse + ( + Conditional &condition + ) + + { + return ( last_ucmd.buttons & BUTTON_USE ) != 0; + } + +qboolean Player::checkcanmoveleft + ( + Conditional &condition + ) + + { + if ( condition.numParms() ) + { + return move_left_vel >= atof( condition.getParm( 1 ) ); + } + + return move_left_vel > 1.0f; + } + +qboolean Player::checkcanturn + ( + Conditional &condition + ) + + { + float yaw; + Vector oldang( v_angle ); + qboolean result; + + yaw = atof( condition.getParm( 1 ) ); + + v_angle[ YAW ] = ( int )( anglemod( v_angle[ YAW ] + yaw ) / 22.5f ) * 22.5f; + SetViewAngles( v_angle ); + + result = CheckMove( vec_zero ); + + SetViewAngles( oldang ); + + return result; + } + +qboolean Player::checkcanmoveright + ( + Conditional &condition + ) + + { + if ( condition.numParms() ) + { + return move_right_vel >= atof( condition.getParm( 1 ) ); + } + + return move_right_vel > 1.0f; + } + +qboolean Player::checkcanmovebackward + ( + Conditional &condition + ) + + { + if ( condition.numParms() ) + { + return move_backward_vel >= atof( condition.getParm( 1 ) ); + } + + return move_backward_vel > 1.0f; + } + +qboolean Player::checkcanmoveforward + ( + Conditional &condition + ) + + { + if ( condition.numParms() ) + { + return move_forward_vel >= atof( condition.getParm( 1 ) ); + } + + return move_forward_vel > 1.0f; + } + +qboolean Player::checkcanwallhug + ( + Conditional &condition + ) + + { + trace_t trace; + Vector start( origin.x, origin.y, origin.z + 4 ); + Vector end( start - yaw_forward * 15.0f ); + + while( end.z < absmax.z - 4.0f ) + { + trace = G_Trace( start, min_box_8x8, max_box_8x8, end, this, MASK_DEADSOLID, true, "checkcanwallhug" ); + if ( ( trace.fraction == 1.0f ) || ( trace.ent->entity->getSolidType() != SOLID_BSP ) ) + { + return false; + } + + start.z += 16.0f; + end.z += 16.0f; + } + + return true; + } + +qboolean Player::checkblocked( Conditional &condition ) +{ + int test_moveresult; + + test_moveresult = moveresult; + + if( flags & FL_IMMOBILE ) + test_moveresult = MOVERESULT_BLOCKED; + + if ( condition.numParms() ) + { + return test_moveresult >= atoi( condition.getParm( 1 ) ); + } + + return test_moveresult >= MOVERESULT_BLOCKED; +} + +qboolean Player::checkhasvelocity( Conditional &condition ) +{ + float fSpeed; + + if( condition.numParms() ) + { + fSpeed = atof( condition.getParm( 1 ) ); + } + else + { + fSpeed = 4.0f; + } + + return ( ( move_forward_vel > fSpeed ) || ( move_backward_vel > fSpeed ) || + ( move_right_vel > fSpeed ) || ( move_left_vel > fSpeed ) ); +} + +qboolean Player::checkheight( Conditional &condition ) +{ + str sHeight = condition.getParm( 1 ); + float fHeight; + Vector newmaxs; + trace_t trace; + + if( !sHeight.icmp( "stand" ) ) + { + fHeight = 94.0f; + } + else if( !sHeight.icmp( "duckrun" ) ) + { + fHeight = 60.0f; + } + else if( !sHeight.icmp( "duck" ) ) + { + fHeight = 54.0f; + } + else if( !sHeight.icmp( "prone" ) ) + { + fHeight = 20.0f; + } + else + { + fHeight = atoi( sHeight.c_str() ); + } + + if( fHeight < 16.0f ) { + fHeight = 16.0f; + } + + if( maxs[ 2 ] >= fHeight ) + { + return true; + } + else + { + newmaxs = maxs; + newmaxs[ 2 ] = fHeight; + + trace = G_Trace( origin, + mins, + newmaxs, + origin, + edict, + MASK_PLAYERSOLID, + true, + "Player::checkheight" ); + + if( trace.startsolid ) + { + return false; + } + else + { + return true; + } + } +} + +qboolean Player::checkonground + ( + Conditional &condition + ) + +{ + if( groundentity || client->ps.walking ) + { + falling = 0; + return qtrue; + } + else + { + return qfalse; + } +} + +qboolean Player::check22degreeslope + ( + Conditional &condition + ) + + { + if ( client->ps.walking && client->ps.groundPlane && ( client->ps.groundTrace.plane.normal[ 2 ] < SLOPE_22_MAX ) && + ( client->ps.groundTrace.plane.normal[ 2 ] >= SLOPE_22_MIN ) ) + { + return qtrue; + } + + return qfalse; + } + +qboolean Player::check45degreeslope + ( + Conditional &condition + ) + + { + if ( client->ps.walking && client->ps.groundPlane && ( client->ps.groundTrace.plane.normal[ 2 ] < SLOPE_45_MAX ) && + ( client->ps.groundTrace.plane.normal[ 2 ] >= SLOPE_45_MIN ) ) + { + return qtrue; + } + + return qfalse; + } + +qboolean Player::checklookingup( Conditional &condition ) +{ + float angle = 0 - atof( condition.getParm( 1 ) ); + + return angle > m_vViewAng[ 0 ]; +} + +qboolean Player::checkrightleghigh + ( + Conditional &condition + ) + + { + float groundyaw; + float yawdelta; + int which; + + groundyaw = ( int )vectoyaw( client->ps.groundTrace.plane.normal ); + yawdelta = anglemod( v_angle.y - groundyaw ); + which = ( ( int )yawdelta + 45 ) / 90; + + return ( which == 3 ); + } + +qboolean Player::checkleftleghigh + ( + Conditional &condition + ) + + { + float groundyaw; + float yawdelta; + int which; + + groundyaw = ( int )vectoyaw( client->ps.groundTrace.plane.normal ); + yawdelta = anglemod( v_angle.y - groundyaw ); + which = ( ( int )yawdelta + 45 ) / 90; + + return ( which == 1 ); + } + +qboolean Player::checkfacingupslope + ( + Conditional &condition + ) + + { + float groundyaw; + float yawdelta; + int which; + + groundyaw = ( int )vectoyaw( client->ps.groundTrace.plane.normal ); + yawdelta = anglemod( v_angle.y - groundyaw ); + which = ( ( int )yawdelta + 45 ) / 90; + + return ( which == 2 ); + } + +qboolean Player::checkfacingdownslope + ( + Conditional &condition + ) + + { + float groundyaw; + float yawdelta; + int which; + + groundyaw = ( int )vectoyaw( client->ps.groundTrace.plane.normal ); + yawdelta = anglemod( v_angle.y - groundyaw ); + which = ( ( int )yawdelta + 45 ) / 90; + + return ( ( which == 0 ) || ( which == 4 ) ); + } + +qboolean Player::checkfalling + ( + Conditional &condition + ) + + { + return falling; + } + +qboolean Player::checkgroundentity + ( + Conditional &condition + ) + + { + return ( groundentity != NULL ); + } + +qboolean Player::checkhardimpact( Conditional &condition ) +{ + return hardimpact; +} + + +qboolean Player::checkmediumimpact( Conditional &condition ) +{ + return mediumimpact; +} + +qboolean Player::checkcanfall + ( + Conditional &condition + ) + + { + return canfall; + } + +qboolean Player::checkatdoor + ( + Conditional &condition + ) + + { + // Check if the player is at a door + return ( atobject && atobject->isSubclassOf( Door ) ); + } + +qboolean Player::checkatuseanim + ( + Conditional &condition + ) + + { + // Check if the player is at a useanim + if ( atobject && atobject->isSubclassOf( UseAnim ) ) + { + return ( ( UseAnim * )( Entity * )atobject )->canBeUsed( this ); + } + + return false; + } + +qboolean Player::checktouchuseanim + ( + Conditional &condition + ) + + { + if ( toucheduseanim ) + { + return ( ( UseAnim * )( Entity * )toucheduseanim )->canBeUsed( this ); + } + + return qfalse; + } + +qboolean Player::checkuseanimfinished + ( + Conditional &condition + ) + + { + return ( useanim_numloops <= 0 ); + } + +qboolean Player::checkatuseobject + ( + Conditional &condition + ) + + { + // Check if the player is at a useanim + if ( atobject && atobject->isSubclassOf( UseObject ) ) + { + return ( ( UseObject * )( Entity * )atobject )->canBeUsed( origin, yaw_forward ); + } + + return false; + } + +qboolean Player::checkloopuseobject + ( + Conditional &condition + ) + + { + // Check if the player is at a useanim + if ( useitem_in_use && useitem_in_use->isSubclassOf( UseObject ) ) + { + return ( ( UseObject * )( Entity * )useitem_in_use )->Loop(); + } + + return false; + } + +qboolean Player::checkdead + ( + Conditional &condition + ) + + { + return ( deadflag ); + } + +qboolean Player::checkhealth + ( + Conditional &condition + ) + + { + return health < atoi( condition.getParm( 1 ) ); + } + +qboolean Player::checkpain + ( + Conditional &condition + ) + + { + return ( pain != 0 || knockdown != 0 ); + } + +qboolean Player::checkknockdown + ( + Conditional &condition + ) + + { + if ( knockdown ) + { + knockdown = false; + return true; + } + else + { + return false; + } + } + +qboolean Player::checkpaintype + ( + Conditional &condition + ) + +{ + if( pain_type == MOD_NameToNum( condition.getParm( 1 ) ) ) + { + return qtrue; + } + else + { + return qfalse; + } +} + +qboolean Player::checkpaindirection + ( + Conditional &condition + ) + +{ + if( pain_dir == Pain_string_to_int( condition.getParm( 1 ) ) ) + { + return qtrue; + } + else + { + return qfalse; + } +} + +qboolean Player::checkpainlocation + ( + Conditional &condition + ) + +{ + str sLocationName; + int iLocationNum; + + sLocationName = condition.getParm( 1 ); + + if( !sLocationName.icmp( "miss" ) ) + iLocationNum = LOCATION_MISS; + else if( !sLocationName.icmp( "general" ) ) + iLocationNum = LOCATION_GENERAL; + else if( !sLocationName.icmp( "head" ) ) + iLocationNum = LOCATION_HEAD; + else if( !sLocationName.icmp( "helmet" ) ) + iLocationNum = LOCATION_HELMET; + else if( !sLocationName.icmp( "neck" ) ) + iLocationNum = LOCATION_NECK; + else if( !sLocationName.icmp( "torso_upper" ) ) + iLocationNum = LOCATION_TORSO_UPPER; + else if( !sLocationName.icmp( "torso_mid" ) ) + iLocationNum = LOCATION_TORSO_MID; + else if( !sLocationName.icmp( "torso_lower" ) ) + iLocationNum = LOCATION_TORSO_LOWER; + else if( !sLocationName.icmp( "pelvis" ) ) + iLocationNum = LOCATION_PELVIS; + else if( !sLocationName.icmp( "r_arm_upper" ) ) + iLocationNum = LOCATION_R_ARM_UPPER; + else if( !sLocationName.icmp( "l_arm_upper" ) ) + iLocationNum = LOCATION_L_ARM_UPPER; + else if( !sLocationName.icmp( "r_leg_upper" ) ) + iLocationNum = LOCATION_R_LEG_UPPER; + else if( !sLocationName.icmp( "l_leg_upper" ) ) + iLocationNum = LOCATION_L_LEG_UPPER; + else if( !sLocationName.icmp( "r_arm_lower" ) ) + iLocationNum = LOCATION_R_ARM_LOWER; + else if( !sLocationName.icmp( "l_arm_lower" ) ) + iLocationNum = LOCATION_L_ARM_LOWER; + else if( !sLocationName.icmp( "r_leg_lower" ) ) + iLocationNum = LOCATION_R_LEG_LOWER; + else if( !sLocationName.icmp( "l_leg_lower" ) ) + iLocationNum = LOCATION_L_LEG_LOWER; + else if( !sLocationName.icmp( "r_hand" ) ) + iLocationNum = LOCATION_R_HAND; + else if( !sLocationName.icmp( "l_hand" ) ) + iLocationNum = LOCATION_L_HAND; + else if( !sLocationName.icmp( "r_foot" ) ) + iLocationNum = LOCATION_R_FOOT; + else if( !sLocationName.icmp( "l_foot" ) ) + iLocationNum = LOCATION_L_FOOT; + else + { + Com_Printf( "CondPainLocation: Unknown player hit location %s\n", sLocationName.c_str() ); + } + + return ( pain_location == iLocationNum ); +} + +qboolean Player::checkpainthreshold + ( + Conditional &condition + ) + + { + float threshold = atof( condition.getParm( 1 ) ); + + if ( ( pain >= threshold ) && ( level.time > nextpaintime ) ) + { + pain = 0; // zero out accumulation since we are going into a pain anim right now + return true; + } + else + { + return false; + } + } + +qboolean Player::checklegsstate + ( + Conditional &condition + ) + + { + if ( currentState_Legs ) + { + str current = currentState_Legs->getName(); + str compare = condition.getParm( 1 ); + + if ( current == compare ) + { + return true; + } + } + + return false; + } + +qboolean Player::checktorsostate + ( + Conditional &condition + ) + + { + if ( currentState_Torso ) + { + str current = currentState_Torso->getName(); + str compare = condition.getParm( 1 ); + + if ( current == compare ) + { + return true; + } + } + + return false; + } + +qboolean Player::checkhasweapon + ( + Conditional &condition + ) + + { + return WeaponsOut(); + } + +qboolean Player::checknewweapon + ( + Conditional &condition + ) + + { + Weapon * weapon; + + weapon = GetNewActiveWeapon(); + + if ( weapon ) + return true; + else + return false; + } + +qboolean Player::checkreload( Conditional &condition ) +{ + Weapon *weapon; + weaponhand_t hand = WEAPON_MAIN; + + + if( condition.numParms() > 0 ) + { + hand = WeaponHandNameToNum( condition.getParm( 1 ) ); + if( hand == WEAPON_ERROR ) + return qfalse; + } + + weapon = GetActiveWeapon( WEAPON_MAIN ); + + if( !weapon ) + return qfalse; + + if( weapon->ShouldReload() && weapon->HasAmmo( FIRE_PRIMARY ) ) + return qtrue; + + return qfalse; +} + +// Check to see if a weapon has been raised +qboolean Player::checkuseweapon + ( + Conditional &condition + ) + + { + const char *weaponName; + const char *parm; + + weaponhand_t hand; + Weapon *weap; + + weap = GetNewActiveWeapon(); + parm = condition.getParm( 1 ); + + if ( !str::icmp( parm, "ERROR" ) ) + { + if ( weap ) + warning( "Player::checkuseweapon", "%s does not have a valid RAISE_WEAPON state\n", weap->item_name.c_str() ); + else + warning( "Player::checkuseweapon", "New Active weapon does not exist\n" ); + + ClearNewActiveWeapon(); + return qtrue; + } + + hand = WeaponHandNameToNum( parm ); + + if ( hand == WEAPON_ERROR ) + return false; + + weaponName = condition.getParm( 2 ); + + if ( + ( weap != NULL ) && + ( GetNewActiveWeaponHand() == hand ) && + ( !Q_stricmp( weap->item_name, weaponName ) ) + ) + { + return true; + } + else + { + return false; + } + } + +qboolean Player::checkuseweaponclass( Conditional &condition ) +{ + const char *weaponClass; + const char *parm; + + weaponhand_t hand; + Weapon *weap; + + weap = GetNewActiveWeapon(); + parm = condition.getParm( 1 ); + + if( !str::icmp( parm, "ERROR" ) ) + { + if( weap ) + warning( "Player::checkuseweaponclass", "%s does not have a valid RAISE_WEAPON state\n", weap->getName().c_str() ); + else + warning( "Player::checkuseweaponclass", "New Active weapon does not exist\n" ); + + ClearNewActiveWeapon(); + return qtrue; + } + + hand = WeaponHandNameToNum( parm ); + + if( hand == WEAPON_ERROR ) + return false; + + weaponClass = condition.getParm( 2 ); + + if( + ( weap != NULL ) && + ( weap->isSubclassOf( Weapon ) ) && + ( GetNewActiveWeaponHand() == hand ) && + ( weap->GetWeaponClass() & G_WeaponClassNameToNum( weaponClass ) ) + ) + { + return true; + } + else + { + return false; + } +} + +// Checks to see if any weapon is active in the specified hand +qboolean Player::checkanyweaponactive + ( + Conditional &condition + ) + + { + weaponhand_t hand; + Weapon *weap; + + hand = WeaponHandNameToNum( condition.getParm( 1 ) ); + + if ( hand == WEAPON_ERROR ) + return false; + + weap = GetActiveWeapon( hand ); + return ( weap != NULL ); + } + +// Checks to see if any weapon is active in the specified hand +qboolean Player::checkweaponhasammo + ( + Conditional &condition + ) + + { + weaponhand_t hand; + Weapon *weap; + firemode_t mode = FIRE_PRIMARY; + + hand = WeaponHandNameToNum( condition.getParm( 1 ) ); + + if ( condition.numParms() > 1 ) + mode = WeaponModeNameToNum( condition.getParm( 2 ) ); + + if ( hand == WEAPON_ERROR ) + return false; + + weap = GetActiveWeapon( hand ); + + if ( !weap ) + return false; + else + return ( weap->HasAmmo( mode ) ); + } + +qboolean Player::checkweaponhasammoinclip( Conditional &condition ) +{ + weaponhand_t hand; + Weapon *weap; + firemode_t mode = FIRE_PRIMARY; + + hand = WeaponHandNameToNum( condition.getParm( 1 ) ); + + if( condition.numParms() > 1 ) + mode = WeaponModeNameToNum( condition.getParm( 2 ) ); + + if( hand == WEAPON_ERROR ) + return false; + + weap = GetActiveWeapon( hand ); + + if( !weap ) + return false; + else + return ( weap->HasAmmoInClip( mode ) ); +} + +qboolean Player::checkmuzzleclear + ( + Conditional &condition + ) + + { + weaponhand_t hand; + + hand = WeaponHandNameToNum( condition.getParm( 1 ) ); + + if ( hand == WEAPON_ERROR ) + return false; + + Weapon *weapon = GetActiveWeapon( hand ); + return ( weapon && weapon->MuzzleClear() ); + } + +// Checks to see if weapon is active +qboolean Player::checkweaponactive( Conditional &condition ) +{ + const char *weaponName; + weaponhand_t hand; + + weaponName = condition.getParm( 2 ); + hand = WeaponHandNameToNum( condition.getParm( 1 ) ); + + if ( hand == WEAPON_ERROR ) + return false; + + Weapon *weapon = GetActiveWeapon( hand ); + + return ( weapon && !Q_stricmp( weaponName, weapon->item_name ) ); +} + +qboolean Player::checkweaponclassactive( Conditional &condition ) +{ + const char *weaponClass; + weaponhand_t hand; + + weaponClass = condition.getParm( 2 ); + hand = WeaponHandNameToNum( condition.getParm( 1 ) ); + + if( hand == WEAPON_ERROR ) + return false; + + Weapon *weapon = GetActiveWeapon( hand ); + + return ( weapon && G_WeaponClassNameToNum( weaponClass ) & weapon->GetWeaponClass() ); +} + +// Checks to see if weapon is active and ready to fire +qboolean Player::checkweaponreadytofire + ( + Conditional &condition + ) + +{ + firemode_t mode = FIRE_PRIMARY; + str weaponName = "None"; + weaponhand_t hand; + qboolean ready; + + if( level.playerfrozen || m_bFrozen || ( flags & FL_IMMOBILE ) ) + { + return false; + } + + hand = WeaponHandNameToNum( condition.getParm( 1 ) ); + + if( condition.numParms() > 1 ) + weaponName = condition.getParm( 2 ); + + if( hand == WEAPON_ERROR ) + return false; + + Weapon *weapon = GetActiveWeapon( hand ); + + // Weapon there check + if( !weapon ) + return false; + + // Name check + if( condition.numParms() > 1 ) + { + if( strcmp( weaponName, weapon->item_name ) ) + { + return false; + } + } + + // Ammo check + ready = weapon->ReadyToFire( mode ); + return( ready ); +} + +// Checks to see if weapon is active and ready to fire +qboolean Player::checkweaponclassreadytofire( Conditional &condition ) +{ + firemode_t mode = FIRE_PRIMARY; + str weaponClass = "None"; + weaponhand_t hand; + qboolean ready; + + if( level.playerfrozen || m_bFrozen || ( flags & FL_IMMOBILE ) ) + { + return false; + } + + hand = WeaponHandNameToNum( condition.getParm( 1 ) ); + + if( condition.numParms() > 1 ) + weaponClass = condition.getParm( 2 ); + + if( hand == WEAPON_ERROR ) + return false; + + Weapon *weapon = GetActiveWeapon( hand ); + + // Weapon there check + if( !weapon ) + return qfalse; + + // Name check + if( condition.numParms() > 1 ) + { + if( !( G_WeaponClassNameToNum( weaponClass ) & weapon->GetWeaponClass() ) ) + { + return qfalse; + } + } + + // Ammo check + ready = weapon->ReadyToFire( mode ); + return( ready ); +} + +qboolean Player::checkweaponreadytofire_nosound + ( + Conditional &condition + ) + +{ + firemode_t mode = FIRE_PRIMARY; + str weaponName = "None"; + weaponhand_t hand; + qboolean ready; + + if( level.playerfrozen || m_bFrozen || ( flags & FL_IMMOBILE ) ) + { + return false; + } + + hand = WeaponHandNameToNum( condition.getParm( 1 ) ); + + if( condition.numParms() > 1 ) + weaponName = condition.getParm( 2 ); + + if( hand == WEAPON_ERROR ) + return false; + + Weapon *weapon = GetActiveWeapon( hand ); + + // Weapon there check + if( !weapon ) + return qfalse; + + // Name check + if( condition.numParms() > 1 ) + { + if( strcmp( weaponName, weapon->item_name ) ) + { + return qfalse; + } + } + + // Ammo check + ready = weapon->ReadyToFire( mode, qfalse ); + return( ready ); +} + +qboolean Player::checkweaponsemiauto + ( + Conditional &condition + ) + +{ + firemode_t mode = FIRE_PRIMARY; + str handname; + weaponhand_t hand; + + handname = condition.getParm( 1 ); + + hand = WeaponHandNameToNum( handname ); + + if( hand != WEAPON_ERROR ) + { + return GetActiveWeapon( hand )->m_bSemiAuto; + } + else + { + return qfalse; + } +} + +// Check to see if any of the active weapons need to be put away +qboolean Player::checkputawayleft + ( + Conditional &condition + ) + + { + Weapon *weapon = GetActiveWeapon( WEAPON_OFFHAND ); + + return weapon && weapon->GetPutaway(); + } + +qboolean Player::checkputawayright + ( + Conditional &condition + ) + +{ + Weapon *weapon = GetActiveWeapon( WEAPON_MAIN ); + + return weapon && weapon->GetPutaway(); +} + +qboolean Player::returnfalse( Conditional &condition ) +{ + return false; +} + +qboolean Player::returntrue( Conditional &condition ) +{ + return true; +} + +qboolean Player::checkstatename + ( + Conditional &condition + ) + + { + str part = condition.getParm( 1 ); + str statename = condition.getParm( 2 ); + + if ( currentState_Legs && !part.icmp( "legs" ) ) + { + return ( !statename.icmpn( currentState_Legs->getName(), statename.length() ) ); + } + else if ( !part.icmp( "torso" ) ) + { + return ( !statename.icmpn( currentState_Torso->getName(), statename.length() ) ); + } + + return false; + } + +qboolean Player::checkattackblocked + ( + Conditional &condition + ) + + { + if ( attack_blocked ) + { + attack_blocked = qfalse; + return true; + } + else + { + return false; + } + } + +qboolean Player::checkblockdelay + ( + Conditional &condition + ) + + { + float t = atof ( condition.getParm( 1 ) ); + return ( level.time > ( attack_blocked_time + t ) ); + } + +qboolean Player::checkpush + ( + Conditional &condition + ) + + { + // Check if the player is at a pushobject + if ( atobject && atobject->isSubclassOf( PushObject ) && ( atobject_dist < ( PUSH_OBJECT_DISTANCE + 15.0f ) ) ) + { + Vector dir; + + dir = atobject_dir * 8.0f; + return ( ( PushObject * )( Entity * )atobject )->canPush( dir ); + } + + return qfalse; + } + +qboolean Player::checkpull + ( + Conditional &condition + ) + + { + // Check if the player is at a pushobject + if ( atobject && atobject->isSubclassOf( PushObject ) && ( atobject_dist < ( PUSH_OBJECT_DISTANCE + 15.0f ) ) ) + { + Vector dir; + + dir = atobject_dir * -64.0f; + return ( ( PushObject * )( Entity * )atobject )->canPush( dir ); + } + + return qfalse; + } + +#define LADDER_HAND_HEIGHT ( MAXS_X - MINS_X ) + +qboolean Player::checkladder + ( + Conditional &condition + ) + +{ + trace_t trace; + Vector forward; + Vector start, end; + + AngleVectors( m_vViewAng, forward, NULL, NULL ); + + start = ( m_vViewPos - forward * 12.0f ); + end = ( m_vViewPos + forward * 128.0f ); + + trace = G_Trace( start, vec_zero, vec_zero, end, this, MASK_LADDER, qfalse, "checkladder" ); + if( trace.fraction == 1.0f || !trace.ent || + !trace.ent->entity || !trace.ent->entity->isSubclassOf( FuncLadder ) ) + { + return qfalse; + } + + return ( ( FuncLadder * )trace.ent->entity )->CanUseLadder( this ); +} + +qboolean Player::checktopladder +( +Conditional &condition +) +{ + if( !m_pLadder ) { + return false; + } + + if( maxs[ 2 ] + origin[ 2 ] > m_pLadder->absmax[ 2 ] ) { + return true; + } + + return false; +} + +qboolean Player::checkcangetoffladdertop +( +Conditional &condition +) +{ + Vector vForward, vStart, vEnd; + trace_t trace; + + angles.AngleVectorsLeft( &vForward ); + + vStart = origin - vForward * 12.0f; + vStart[ 2 ] += maxs[ 2 ] - 8.0f; + + vEnd = vStart + vForward * 40.0f; + + trace = G_Trace( vStart, + vec_zero, + vec_zero, + vEnd, + this, + MASK_LADDER, + qtrue, + "Player::CondCanGetOffLadderTop 1" ); + + if( trace.fraction >= 1.0f ) + { + vStart = origin; + + vEnd = origin; + vEnd[ 2 ] += 98.0f; + + if( G_SightTrace( vStart, + mins, + maxs, + vEnd, + this, + NULL, + MASK_BEAM, + true, + "Player::CondCanGetOffLadderTop 2" ) ) + { + vStart = vEnd; + vEnd = vStart + yaw_forward * 16.0f; + + return G_SightTrace( vStart, + mins, + maxs, + vEnd, + this, + NULL, + MASK_BEAM, + true, + "Player::CondCanGetOffLadderTop 3" ); + } + } + + return false; +} + +qboolean Player::checkcangetoffladderbottom +( +Conditional &condition +) +{ + Vector vStart, vEnd; + trace_t trace; + + vStart = origin; + + vEnd = origin; + vEnd[ 2 ] -= 40.0f; + + trace = G_Trace( + vStart, + mins, + maxs, + vEnd, + edict, + MASK_BEAM, + true, + "Player::checkcangetoffladerbottom" ); + + if( trace.fraction != 1.0f ) + { + return ( trace.entityNum == ENTITYNUM_WORLD ); + } + + return false; +} + +qboolean Player::checkcanclimbupladder + ( + Conditional &condition + ) + +{ + trace_t trace; + Vector fwd; + Vector vec; + Vector start, end; + + AngleVectorsLeft( angles, fwd, NULL, NULL ); + + start = origin - fwd * 12.0f; + start[ 2 ] += maxs[ 2 ] - 8.0f; + + end = start + fwd * 40.0f; + + // check the normal bounding box first and trace to that position + trace = G_Trace( start, vec_zero, vec_zero, end, this, MASK_LADDER, qtrue, "Player::CondCanClimbUpLadder" ); + if( ( trace.fraction == 1.0f ) || ( !trace.ent ) || ( !trace.ent->entity ) || + ( !trace.ent->entity->isSubclassOf( FuncLadder ) ) ) + { + return qfalse; + } + + Vector vEnd = ( origin + Vector( 0, 0, 16 ) ); + + return G_SightTrace( origin, + mins, + maxs, + vEnd, + this, + NULL, + MASK_BEAM, + qtrue, + "Player::CondCanClimbUpLadder" ); +} + + +qboolean Player::checkcanclimbdownladder + ( + Conditional &condition + ) + +{ + Vector vEnd = origin - Vector( 0, 0, 16 ); + + return G_SightTrace( origin, + mins, + maxs, + vEnd, + this, + NULL, + MASK_BEAM, + qtrue, + "Player::CondCanClimbDownLadder" ); +} + +qboolean Player::checkfeetatladder + ( + Conditional &condition + ) + + { + trace_t trace; + Vector newmins, newmaxs; + Vector end( origin + yaw_forward * 20.0f ); + + // the bounding box is made skinnier to account for the feet + newmaxs.x = MAXS_X / 2; + newmaxs.y = MAXS_Y / 2; + // just underneath the feet + newmaxs.z = 28; + newmins.x = MINS_X / 2; + newmins.y = MINS_Y / 2; + newmins.z = 0; + trace = G_Trace( origin, newmins, newmaxs, end, this, MASK_SOLID, true, "checkfeetatladder" ); + if ( ( trace.fraction == 1.0f ) || !( trace.surfaceFlags & SURF_LADDER ) ) + { + return qfalse; + } + + return qtrue; + } + +qboolean Player::checkonladder +( +Conditional &condition +) +{ + return m_pLadder != NULL; +} + +qboolean Player::checkcanstand + ( + Conditional &condition + ) + + { + Vector newmins( mins ); + Vector newmaxs( maxs ); + trace_t trace; + + newmins[ 2 ] = MINS_Z; + newmaxs[ 2 ] = MAXS_Z; + + trace = G_Trace( origin, newmins, newmaxs, origin, this, MASK_PLAYERSOLID, true, "checkcanstand" ); + if ( trace.startsolid ) + { + return qfalse; + } + + return qtrue; + } + +qboolean Player::checkchance + ( + Conditional &condition + ) + + { + float percent_chance; + + percent_chance = atof( condition.getParm( 1 ) ); + + return ( G_Random() < percent_chance ); + } + +qboolean Player::checkinturret( Conditional &condition ) +{ + return ( m_pTurret != NULL ); +} + +qboolean Player::checkinvehicle( Conditional &condition ) +{ + return ( m_pVehicle != NULL ); +} + +qboolean Player::checkturrettype( Conditional &condition ) +{ + str name = condition.getParm( 1 ); + + if( m_pTurret ) + { + return m_pTurret->getName() == name; + } + else + { + return name == "none"; + } +} + +qboolean Player::checkduckedviewinwater( Conditional &condition ) +{ + Vector vPos = origin; + vPos[ 2 ] += 48.0f; + + return ( gi.PointContents( vPos, 0 ) & MASK_WATER ) != 0; +} + +qboolean Player::checkviewinwater( Conditional &condition ) +{ + return ( gi.PointContents( m_vViewPos, 0 ) & MASK_WATER ) != 0; +} + +qboolean Player::checksolidforward + ( + Conditional &condition + ) + +{ + // Trace out forward to see if there is a solid ahead + float dist = atof( condition.getParm( 1 ) ); + Vector end( centroid + yaw_forward * dist ); + Vector vMins( mins.x, mins.y, -8 ); + Vector vMaxs( maxs.x, maxs.y, 8 ); + + trace_t trace = G_Trace( centroid, vMins, vMaxs, + end, this, MASK_SOLID, true, "Player::checksolidforward" ); + + return ( trace.fraction < 0.7f ); +} + +qboolean Player::checkweaponsholstered + ( + Conditional &condition + ) + +{ + if( holsteredWeapon ) + { + return qtrue; + } + else + { + return qfalse; + } +} + +qboolean Player::checkmovementtype( Conditional &condition ) +{ + int flags = 0; + str s; + + s = condition.getParm( 1 ); + + if( !s.icmp( "walking" ) ) + { + flags = MPF_MOVEMENT_WALKING; + } + else if( !s.icmp( "running" ) ) + { + flags = MPF_MOVEMENT_RUNNING; + } + else if( !s.icmp( "falling" ) ) + { + flags = MPF_MOVEMENT_FALLING; + } + + return ( m_iMovePosFlags & flags ); +} + +qboolean Player::checkpositiontype( Conditional &condition ) +{ + int flags = 0; + str s; + + s = condition.getParm( 1 ); + + if( !s.icmp( "crouching" ) ) + { + flags = MPF_POSITION_CROUCHING; + } + else if( !s.icmp( "prone" ) ) + { + flags = MPF_POSITION_PRONE; + } + else if( !s.icmp( "offground" ) ) + { + flags = MPF_POSITION_OFFGROUND; + } + else + { + flags = MPF_POSITION_STANDING; + } + + return ( m_iMovePosFlags & flags ); +} + +qboolean Player::checkforwardvelocity( Conditional &condition ) +{ + if( condition.numParms() ) + { + return move_forward_vel >= atof( condition.getParm( 1 ) ); + } + else + { + return move_forward_vel > 4.0f; + } + + return qfalse; +} + +qboolean Player::checkminchargetimemet( Conditional &condition ) +{ + const char *handname; + weaponhand_t hand; + Weapon *weap; + + handname = condition.getParm( 1 ); + hand = WeaponHandNameToNum( handname ); + + if( hand != WEAPON_ERROR ) + { + weap = GetActiveWeapon( hand ); + if( weap ) + { + float charge_time = weap->GetMinChargeTime( FIRE_PRIMARY ); + if( charge_time ) + { + if( charge_start_time ) + { + return level.time - charge_start_time >= charge_time; + } + else + { + return qfalse; + } + } + else + { + return qtrue; + } + } + } + + return qfalse; +} + +qboolean Player::checkmaxchargetimemet( Conditional &condition ) +{ + const char *handname; + weaponhand_t hand; + Weapon *weap; + + handname = condition.getParm( 1 ); + hand = WeaponHandNameToNum( handname ); + + if( hand != WEAPON_ERROR ) + { + weap = GetActiveWeapon( hand ); + if( weap ) + { + float charge_time = weap->GetMaxChargeTime( FIRE_PRIMARY ); + if( charge_time ) + { + if( charge_start_time ) + { + return level.time - charge_start_time >= charge_time; + } + else + { + return qfalse; + } + } + else + { + return qtrue; + } + } + } + + return qfalse; +} + +qboolean Player::checkimmediateswitch( Conditional &condition ) +{ + static cvar_t *g_immediateswitch = NULL; + + if( !g_immediateswitch ) + g_immediateswitch = gi.Cvar_Get( "g_immediateswitch", "0", 0 ); + + return ( g_gametype->integer && g_immediateswitch->integer ); +} + +qboolean Player::CondAnimDoneVM( Conditional &condition ) +{ + return animDoneVM; +} + +qboolean Player::CondClientCommand( Conditional &condition ) +{ + str command = condition.getParm( 1 ); + + if( !command.icmp( m_lastcommand ) ) + { + return qtrue; + } + else + { + return qfalse; + } +} + +qboolean Player::CondVMAnim( Conditional &condition ) +{ + return condition.getParm( 1 ) == m_sVMcurrent; +} + +qboolean Player::CondVariable( Conditional &condition ) +{ + // parameters + str var_name; + str value_operator; + Player * player = ( Player* )this; + + // variables + int cmp_int = 0, var_int = 0; + float cmp_float = 0.0f, var_float = 0.0f; + char *cmp_str = NULL; + char *var_str = NULL; + ScriptVariableList * variableList = NULL; + ScriptVariable * variable = NULL; + char _operator[ 2 ]; + size_t i, nLength; + size_t indexval = -1; + int founds = 0; + qboolean isString = qfalse, isFloat = qfalse, isInteger = qfalse; + + var_name = condition.getParm( 1 ); + value_operator = condition.getParm( 2 ); + + if( !var_name ) + { + gi.Printf( "Var_CompareValue : the variable was not specified !\n", condition.getName() ); + return qfalse; + } + else if( !value_operator ) + { + gi.Printf( "Var_CompareValue : the value was not specified !\n", condition.getName() ); + return qfalse; + } + + nLength = value_operator.length(); + + // Lookup for the operator, until we found one + for( i = 0; i < nLength; i++ ) + { + if( ( value_operator[ i ] == '<' && value_operator[ i + 1 ] == '=' ) || ( value_operator[ i ] == '>' && value_operator[ i + 1 ] == '=' ) + || ( value_operator[ i ] == '=' && value_operator[ i + 1 ] == '=' ) || ( value_operator[ i ] == '!' && value_operator[ i + 1 ] == '=' ) + || value_operator[ i ] == '<' || value_operator[ i ] == '>' + || value_operator[ i ] == '&' ) + { + if( indexval == -1 ) { + indexval = i; + } + + founds++; + } + } + + // Fail if we didn't found/found multiples operators + if( !founds ) + { + gi.Printf( "Var_CompareValue : unknown/no comparison/relational operator was specified (var_name=\"%s\"|value=\"%s\") !\n", var_name.c_str(), value_operator.c_str() ); + return qfalse; + } + else if( founds > 1 ) + { + gi.Printf( "Var_CompareValue : more than one operator was specified (var_name='%s'|value='%s') !\n", var_name.c_str(), value_operator.c_str() ); + return qfalse; + } + + _operator[ 0 ] = value_operator[ indexval ]; + _operator[ 1 ] = value_operator[ indexval + 1 ]; + + // If this is not a greater/less than operator, then the loop + // shouldn't encounter a part of the operator + if( ( _operator[ 0 ] == '<' && _operator[ 1 ] != '=' ) || ( _operator[ 0 ] == '>' && _operator[ 1 ] != '=' ) ) + i = indexval; + else + i = indexval + 2; + + while( ( value_operator[ i ] == ' ' || value_operator[ i ] == '\0' ) && i < nLength ) + i++; + + indexval = -1; + founds = 0; + + // Loop until we find a character after the operator + for( ; i < nLength; i++ ) + { + if( value_operator[ i ] != '\0' && value_operator[ i ] != ' ' && value_operator[ i ] != _operator[ 0 ] && value_operator[ i ] != _operator[ 1 ] ) + { + if( indexval == -1 ) + indexval = i; + + founds++; + } + } + + if( !founds ) + { + gi.Printf( "Var_CompareValue : no value was specified after the operator ! (var_name=\"%s\") !\n", var_name.c_str() ); + return qfalse; + } + + // Get the variable list from the player + + variableList = this->Vars(); + + // Get the variable from the variable list + variable = variableList->GetVariable( var_name ); + + if( variable != NULL ) + { + isFloat = variable->GetType() == VARIABLE_FLOAT; + isInteger = variable->GetType() == VARIABLE_INTEGER; + isString = variable->GetType() == VARIABLE_STRING || variable->GetType() == VARIABLE_CONSTSTRING; + + if( !isFloat && !isString && !isInteger ) { + gi.Printf( "Var_CompareValue : invalid type \"%s\" (%d) for variable \"%s\"\n", typenames[ variable->GetType() ], variable->GetType(), var_name.c_str() ); + return qfalse; + } + + // Retrieve the values from the variable + if( isFloat ) { + var_float = variable->floatValue(); + } + else { + var_int = variable->intValue(); + } + } + + cmp_str = ( char * )value_operator.c_str() + indexval; + + if( !isString ) + { + cmp_int = atoi( cmp_str ); + cmp_float = ( float )atof( cmp_str ); + } + + // If this is a string, compare between the two strings + if( isString ) + { + if( _operator[ 0 ] == '=' && _operator[ 1 ] == '=' ) + { + // == (EQUAL TO) operator + + return strcmp( cmp_str, var_str ) == 0; + } + else if( _operator[ 0 ] == '!' && _operator[ 1 ] == '=' ) + { + // != (NOT EQUAL TO) operator + + return strcmp( cmp_str, var_str ) != 0; + } + } + + // Now compare between the two values with the right operator and return + if( _operator[ 0 ] == '<' ) + { + // < (LESS THAN) operator + + if( isFloat ) { + return var_float < cmp_float; + } + + return var_int < cmp_int; + } + else if( _operator[ 0 ] == '>' ) + { + // > (GREATER THAN) operator + + if( isFloat ) { + return var_float > cmp_float; + } + + return var_int > cmp_int; + } + else if( _operator[ 0 ] == '<' && _operator[ 1 ] == '=' ) + { + // <= (LESS THAN OR EQUAL TO) operator + + if( isFloat ) { + return var_float <= cmp_float; + } + + return var_int <= cmp_int; + } + else if( _operator[ 0 ] == '>' && _operator[ 1 ] == '=' ) + { + // >= (GREATER THAN OR EQUAL TO) operator + + if( isFloat ) { + return var_float >= cmp_float; + } + + return var_int >= cmp_int; + } + else if( _operator[ 0 ] == '!' && _operator[ 1 ] == '=' ) + { + // != (NOT EQUAL TO) operator + + if( isFloat ) { + return var_float != cmp_float; + } + + return var_int != cmp_int; + } + else if( _operator[ 0 ] == '=' && _operator[ 1 ] == '=' ) + { + // == (EQUAL TO) operator + + if( isFloat ) { + return var_float == cmp_float; + } + + return var_int == cmp_int; + } + else if( _operator[ 0 ] == '&' ) + { + // & (BITWISE AND) operator + + return var_int & cmp_int; + } + + return qtrue; +} + +CLASS_DECLARATION( Class, Conditional, NULL ) +{ + { NULL, NULL } +}; + +Condition Player::Conditions[] = +{ + { "default", &Player::returntrue }, + { "SNEAK", &Player::checksneak }, + { "RUN", &Player::checkrun }, + { "HOLSTERWEAPON", &Player::checkholsterweapon }, + { "USE", &Player::checkuse }, + { "LEFT", &Player::checkturnleft }, + { "RIGHT", &Player::checkturnright }, + { "FORWARD", &Player::checkforward }, + { "BACKWARD", &Player::checkbackward }, + { "STRAFE_LEFT", &Player::checkstrafeleft }, + { "STRAFE_RIGHT", &Player::checkstraferight }, + { "JUMP", &Player::checkjump }, + { "RISE", &Player::checkrise }, + { "CROUCH", &Player::checkcrouch }, + { "DO_JUMP_FLIP", &Player::checkjumpflip }, + { "ANIMDONE_LEGS", &Player::checkanimdone_legs }, + { "ANIMDONE_TORSO", &Player::checkanimdone_torso }, + { "CAN_TURN", &Player::checkcanturn }, + { "CAN_MOVE_LEFT", &Player::checkcanmoveleft }, + { "CAN_MOVE_RIGHT", &Player::checkcanmoveright }, + { "CAN_MOVE_BACKWARD", &Player::checkcanmovebackward }, + { "CAN_MOVE_FORWARD", &Player::checkcanmoveforward }, + { "CAN_WALL_HUG", &Player::checkcanwallhug }, + { "BLOCKED", &Player::checkblocked }, + { "HAS_VELOCITY", &Player::checkhasvelocity }, + { "CHECK_HEIGHT", &Player::checkheight }, + { "ONGROUND", &Player::checkonground }, + { "SLOPE_22", &Player::check22degreeslope }, + { "SLOPE_45", &Player::check45degreeslope }, + { "LOOKING_UP", &Player::checklookingup }, + { "RIGHT_LEG_HIGH", &Player::checkrightleghigh }, + { "LEFT_LEG_HIGH", &Player::checkleftleghigh }, + { "CAN_FALL", &Player::checkcanfall }, + { "AT_DOOR", &Player::checkatdoor }, + { "FALLING", &Player::checkfalling }, + { "HARD_IMPACT", &Player::checkhardimpact }, + { "MEDIUM_IMPACT", &Player::checkmediumimpact }, + { "KILLED", &Player::checkdead }, + { "HEALTH", &Player::checkhealth }, + { "PAIN", &Player::checkpain }, + { "PAIN_TYPE", &Player::checkpaintype }, + { "PAIN_DIRECTION", &Player::checkpaindirection }, + { "PAIN_LOCATION", &Player::checkpainlocation }, + { "PAIN_THRESHOLD", &Player::checkpainthreshold }, + { "KNOCKDOWN", &Player::checkknockdown }, + { "LEGS", &Player::checklegsstate }, + { "TORSO", &Player::checktorsostate }, + { "AT_USEANIM", &Player::checkatuseanim }, + { "TOUCHEDUSEANIM", &Player::checktouchuseanim }, + { "FINISHEDUSEANIM", &Player::checkuseanimfinished }, + { "AT_USEOBJECT", &Player::checkatuseobject }, + { "LOOP_USEOBJECT", &Player::checkloopuseobject }, + { "CAN_PUSH", &Player::checkpush }, + { "CAN_PULL", &Player::checkpull }, + { "AT_LADDER", &Player::checkladder }, + { "AT_TOP_OF_LADDER", &Player::checktopladder }, + { "CAN_GET_OFF_LADDER_TOP", &Player::checkcangetoffladdertop }, + { "CAN_GET_OFF_LADDER_BOTTOM", &Player::checkcangetoffladderbottom }, + { "FEET_AT_LADDER", &Player::checkfeetatladder }, + { "CAN_CLIMB_UP_LADDER", &Player::checkcanclimbupladder }, + { "CAN_CLIMB_DOWN_LADDER", &Player::checkcanclimbdownladder }, + { "ON_LADDER", &Player::checkonladder }, + { "CAN_STAND", &Player::checkcanstand }, + { "CHANCE", &Player::checkchance }, + { "FACING_UP_SLOPE", &Player::checkfacingupslope }, + { "FACING_DOWN_SLOPE", &Player::checkfacingdownslope }, + { "IS_USING_TURRET", &Player::checkinturret }, + { "IS_USING_VEHICLE", &Player::checkinvehicle }, + { "TURRET_TYPE", &Player::checkturrettype }, + { "DUCKED_VIEW_IN_WATER", &Player::checkduckedviewinwater }, + { "VIEW_IN_WATER", &Player::checkviewinwater }, + { "SOLID_FORWARD", &Player::checksolidforward }, + { "GROUNDENTITY", &Player::checkgroundentity }, + { "MOVEMENT_TYPE", &Player::checkmovementtype }, + { "POSITION_TYPE", &Player::checkpositiontype }, + { "FORWARD_VELOCITY", &Player::checkforwardvelocity }, + + // Weapon conditions + { "ATTACK_PRIMARY", &Player::checkattackleft }, // Checks to see if there is an active weapon as well as the button being pressed + { "ATTACK_SECONDARY", &Player::checkattackright }, // Checks to see if there is an active weapon as well as the button being pressed + { "ATTACK_PRIMARY_BUTTON", &Player::checkattackbuttonleft }, // Checks to see if the left attack button is pressed + { "ATTACK_SECONDARY_BUTTON", &Player::checkattackbuttonright },// Checks to see if the right attack button is pressed + { "HAS_WEAPON", &Player::checkhasweapon }, + { "NEW_WEAPON", &Player::checknewweapon }, + { "RELOAD", &Player::checkreload }, + { "IS_NEW_WEAPON", &Player::checkuseweapon }, + { "IS_NEW_WEAPONCLASS", &Player::checkuseweaponclass }, + { "IS_WEAPON_ACTIVE", &Player::checkweaponactive }, + { "IS_WEAPONCLASS_ACTIVE", &Player::checkweaponclassactive }, + { "IS_WEAPON_READY_TO_FIRE", &Player::checkweaponreadytofire }, + { "IS_WEAPONCLASS_READY_TO_FIRE", &Player::checkweaponclassreadytofire }, + { "IS_WEAPON_READY_TO_FIRE_NOSOUND", &Player::checkweaponreadytofire_nosound }, + { "IS_WEAPON_SEMIAUTO", &Player::checkweaponsemiauto }, + { "PUTAWAYLEFT", &Player::checkputawayleft }, + { "PUTAWAYMAIN", &Player::checkputawayright }, + { "ANY_WEAPON_ACTIVE", &Player::checkanyweaponactive }, + { "ATTACK_BLOCKED", &Player::checkattackblocked }, + { "STATE_ACTIVE", &Player::checkstatename }, + { "BLOCK_DELAY", &Player::checkblockdelay }, + { "MUZZLE_CLEAR", &Player::checkmuzzleclear }, + { "HAS_AMMO", &Player::checkweaponhasammo }, + { "HAS_AMMO_IN_CLIP", &Player::checkweaponhasammoinclip }, + { "WEAPONS_HOLSTERED", &Player::checkweaponsholstered }, + { "MIN_CHARGE_TIME_MET", &Player::checkminchargetimemet }, + { "MAX_CHARGE_TIME_MET", &Player::checkmaxchargetimemet }, + { "IMMEDIATE_SWITCH", &Player::checkimmediateswitch }, + { "ANIMDONE_VM", &Player::CondAnimDoneVM }, + { "CLIENT_COMMAND", &Player::CondClientCommand }, + { "IS_VM_ANIM", &Player::CondVMAnim }, + { "VAR_OPERATOR", &Player::CondVariable }, + { NULL, NULL }, +}; + +movecontrolfunc_t Player::MoveStartFuncs[] = +{ + NULL, // MOVECONTROL_USER, // Quake style + NULL, // MOVECONTROL_LEGS, // Quake style, legs state system active + NULL, // MOVECONTROL_USER_MOVEANIM, // Quake style, legs state system active + NULL, // MOVECONTROL_ANIM, // move based on animation, with full collision testing + NULL, // MOVECONTROL_ABSOLUTE, // move based on animation, with full collision testing but no turning + NULL, // MOVECONTROL_HANGING, // move based on animation, with full collision testing, hanging + NULL, // MOVECONTROL_ROPE_GRAB + NULL, // MOVECONTROL_ROPE_RELEASE + NULL, // MOVECONTROL_ROPE_MOVE + NULL, // MOVECONTROL_PICKUPENEMY + &Player::StartPush, // MOVECONTROL_PUSH + NULL, // MOVECONTROL_CLIMBWALL + &Player::StartUseAnim, // MOVECONTROL_USEANIM + NULL, // MOVECONTROL_CROUCH + &Player::StartLoopUseAnim, // MOVECONTROL_LOOPUSEANIM + &Player::SetupUseObject, // MOVECONTROL_USEOBJECT + NULL, // MOVECONTROL_COOLOBJECT +}; + +Player::Player() +{ + // + // set the entity type + // + entflags |= EF_PLAYER; + + mCurTrailOrigin = 0; + m_pLastSpawnpoint = NULL; + + if( LoadingSavegame ) { + return; + } + + edict->s.eType = ET_PLAYER; + + buttons = 0; + server_new_buttons = 0; + statemap_Legs = NULL; + statemap_Torso = NULL; + new_buttons = 0; + + m_iPartSlot[ 1 ] = 2; + + respawn_time = -1.0f; + m_fPartBlends[ 0 ] = 0; + m_fPartBlends[ 1 ] = 0; + + m_iPartSlot[ 0 ] = 0; + partBlendMult[ 0 ] = 0; + partBlendMult[ 1 ] = 0; + + m_fOldActionAnimFadeTime = 0; + m_bActionAnimPlaying = false; + m_fLastDeltaTime = level.time; + m_iBaseActionAnimSlot = 0; + m_iActionAnimType = 0; + + m_fOldActionAnimWeight = 0; + m_fOldActionAnimFadeTime = 0; + m_bMovementAnimPlaying = false; + m_fOldMovementWeight = 0; + + camera = NULL; + atobject = NULL; + atobject_dist = 0; + toucheduseanim = NULL; + useitem_in_use = NULL; + + damage_blood = 0; + damage_count = 0; + damage_from = vec_zero; + damage_alpha = 0; + damage_yaw = 0; + + fAttackerDispTime = 0; + pAttackerDistPointer = NULL; + moveresult = 0; + last_attack_button = 0; + attack_blocked = false; + canfall = false; + + move_left_vel = 0; + move_right_vel = 0; + move_backward_vel = 0; + move_forward_vel = 0; + move_up_vel = 0; + move_down_vel = 0; + animspeed = 0; + airspeed = 200.0f; + + weapons_holstered_by_code = false; + + actor_camera = NULL; + dm_team = TEAM_NONE; + damage_multiplier = 1.0f; + take_pain = true; + current_team = NULL; + + num_deaths = 0; + num_kills = 0; + num_won_matches = 0; + m_bTempSpectator = false; + m_bSpectator = false; + m_iPlayerSpectating = 0; + m_bAllowFighting = false; + m_bReady = true; + m_fTeamSelectTime = -30.0f; + voted = false; + votecount = 0; + m_fWeapSelectTime = 0; + + SetSelectedFov( atof( Info_ValueForKey( client->pers.userinfo, "fov" ) ) ); + SetFov( selectedfov ); + + m_iInZoomMode = 0; + m_iNumShotsFired = 0; + m_iNumGroinShots = 0; + m_iNumHeadShots = 0; + m_iNumHits = 0; + m_iNumLeftArmShots = 0; + m_iNumLeftLegShots = 0; + m_iNumRightArmShots = 0; + m_iNumRightLegShots = 0; + m_iNumTorsoShots = 0; + + m_sPerferredWeaponOverride = ""; + + SetTargetName( "player" ); + + disable_spectate = false; + disable_team_change = false; + m_bFrozen = false; + animDoneVM = true; + m_fVMAtime = 0; + m_fpsTiki = NULL; + + for( int i = 0; i < MAX_SPEED_MULTIPLIERS; i++ ) + { + speed_multiplier[ i ] = 1.0f; + } + + m_pKilledEvent = NULL; + m_bConnected = false; + + Init(); + + for( int i = 0; i < MAX_TRAILS; i++ ) + { + mvTrail[ i ] = vec_zero; + } + + for( int i = 0; i < MAX_TRAILS; i++ ) + { + mvTrailEyes[ i ] = vec_zero; + } + + client->ps.pm_flags &= ~PMF_NO_HUD; +} + +Player::~Player() +{ + int i, num; + Conditional *cond; + + num = legs_conditionals.NumObjects(); + for( i = num; i>0; i-- ) + { + cond = legs_conditionals.ObjectAt( i ); + delete cond; + } + + num = torso_conditionals.NumObjects(); + for( i = num; i>0; i-- ) + { + cond = torso_conditionals.ObjectAt( i ); + delete cond; + } + + legs_conditionals.FreeObjectList(); + torso_conditionals.FreeObjectList(); +} + +static qboolean logfile_started = qfalse; + +void Player::Init( void ) +{ + InitClient(); + InitPhysics(); + InitPowerups(); + InitWorldEffects(); + InitSound(); + InitView(); + InitState(); + InitEdict(); + InitWeapons(); + InitInventory(); + InitHealth(); + InitStats(); + + InitModel(); + LoadStateTable(); + + if( g_gametype->integer ) + { + InitDeathmatch(); + } + else if( !LoadingSavegame ) + { + ChooseSpawnPoint(); + JoinNearbySquads(); + } + + InitMaxAmmo(); + + // notify scripts for the spawning player + parm.other = this; + level.Unregister( "playerspawn" ); + + // make sure we put the player back into the world + link(); + logfile_started = qfalse; + + if( !m_bConnected ) + { + m_bConnected = true; + + Event *ev = new Event; + ev->AddEntity( this ); + scriptedEvents[ SE_CONNECTED ].Trigger( ev ); + } + + Spawned(); +} + +void Player::InitEdict( void ) +{ + // entity state stuff + setSolidType( SOLID_BBOX ); + setMoveType( MOVETYPE_WALK ); + edict->clipmask = MASK_PLAYERSOLID; + + setSize( Vector( -16, -16, 0 ), Vector( 16, 16, 72 ) ); + + edict->r.contents = CONTENTS_BODY; + edict->r.ownerNum = ENTITYNUM_NONE; + + // clear entity state values + edict->s.eFlags = 0; + edict->s.wasframe = 0; + + // players have precise shadows + edict->s.renderfx |= RF_SHADOW_PRECISE | RF_SHADOW; +} + +void Player::InitSound + ( + void + ) + + { + // + // reset the music + // + client->ps.current_music_mood = mood_normal; + client->ps.fallback_music_mood = mood_normal; + ChangeMusic( "normal", "normal", false ); + + client->ps.music_volume = 1.0; + client->ps.music_volume_fade_time = 0.0; + ChangeMusicVolume( 1.0, 0.0 ); + + music_forced = false; + + // Reset the reverb stuff + + client->ps.reverb_type = eax_generic; + client->ps.reverb_level = 0; + SetReverb( client->ps.reverb_type, client->ps.reverb_level ); + } + +void Player::InitClient( void ) +{ + clientPersistant_t saved; + + // deathmatch wipes most client data every spawn + if ( g_gametype->integer ) + { + char userinfo[ MAX_INFO_STRING ]; + char dm_primary[ MAX_QPATH ]; + float enterTime = client->pers.enterTime; + teamtype_t team = client->pers.team; + int round_kills = client->pers.kills; + + memcpy( userinfo, client->pers.userinfo, sizeof( userinfo ) ); + memcpy( dm_primary, client->pers.weapon, sizeof( dm_primary ) ); + G_InitClientPersistant( client ); + G_ClientUserinfoChanged( edict, userinfo ); + + memcpy( client->pers.weapon, dm_primary, sizeof( client->pers.weapon ) ); + client->pers.enterTime = enterTime; + client->pers.team = team; + client->pers.kills = round_kills; + } + + // clear everything but the persistant data and fov + saved = client->pers; + + memset( client, 0, sizeof( *client ) ); + client->pers = saved; + + client->ps.clientNum = client - game.clients; + client->lastActiveTime = level.inttime; + client->ps.commandTime = level.svsTime; + + gi.SendServerCommand( client - game.clients, "stopwatch 0 0" ); +} + +void Player::InitState + ( + void + ) + +{ + gibbed = false; + pain = 0; + nextpaintime = 0; + knockdown = false; + pain_dir = PAIN_NONE; + pain_type = MOD_NONE; + pain_location = -2; + m_iMovePosFlags = MPF_POSITION_STANDING; + takedamage = DAMAGE_AIM; + deadflag = DEAD_NO; + flags &= ~FL_TEAMSLAVE; + flags |= ( FL_POSTTHINK | FL_THINK | FL_DIE_EXPLODE | FL_BLOOD ); + + if( !com_blood->integer ) + { + flags &= ~( FL_DIE_EXPLODE | FL_BLOOD ); + } +} + +void Player::InitHealth + ( + void + ) + + { + // Don't do anything if we're loading a server game. + // This is either a loadgame or a restart + if ( LoadingSavegame ) + { + return; + } + + // reset the health values + health = 100; + max_health = 100; + } + +void Player::InitModel + ( + void + ) + +{ + gi.clearmodel( edict ); + + if( !g_gametype->integer ) + { + setModel( "models/player/" + str( g_playermodel->string ) + ".tik" ); + } + else if( dm_team != TEAM_AXIS ) + { + if( Q_stricmpn( client->pers.playermodel, "american", 8 ) && + Q_stricmpn( client->pers.playermodel, "allied", 6 ) ) + { + setModel( "models/player/american_army.tik" ); + } + else + { + setModel( "models/player/" + str( client->pers.playermodel ) + ".tik" ); + } + } + else + { + if( Q_stricmpn( client->pers.playermodel, "german", 6 ) && + Q_stricmpn( client->pers.playermodel, "axis", 4 ) ) + { + setModel( "models/player/german_wehrmacht_soldier.tik" ); + } + else + { + setModel( "models/player/" + str( client->pers.playergermanmodel ) + ".tik" ); + } + } + + if( !edict->tiki ) + { + if( dm_team == TEAM_AXIS ) + { + setModel( "models/player/german_wehrmacht_soldier.tik" ); + } + else + { + setModel( "models/player/american_army.tik" ); + } + } + + SetControllerTag( HEAD_TAG, gi.Tag_NumForName( edict->tiki, "Bip01 Head" ) ); + SetControllerTag( TORSO_TAG, gi.Tag_NumForName( edict->tiki, "Bip01 Spine2" ) ); + SetControllerTag( ARMS_TAG, gi.Tag_NumForName( edict->tiki, "Bip01 Spine1" ) ); + SetControllerTag( PELVIS_TAG, gi.Tag_NumForName( edict->tiki, "Bip01 Pelvis" ) ); + + if( g_gametype->integer ) + { + if( IsSpectator() ) + { + hideModel(); + } + else + { + showModel(); + } + } + else + { + showModel(); + } + + if( GetActiveWeapon( WEAPON_MAIN ) ) + { + edict->s.eFlags &= ~EF_UNARMED; + } + else + { + edict->s.eFlags |= EF_UNARMED; + } + + edict->s.eFlags &= ~( EF_ALLIES | EF_AXIS ); + + if( dm_team == TEAM_ALLIES ) + { + edict->s.eFlags |= EF_ALLIES; + } + else if( dm_team == TEAM_AXIS ) + { + edict->s.eFlags |= EF_AXIS; + } + + client->ps.iViewModelAnim = 0; + client->ps.iViewModelAnimChanged = 0; + + if( dm_team == TEAM_AXIS ) + { + if( m_voiceType >= PVT_AXIS_END ) + { + m_voiceType = PVT_AXIS_AXIS4; + } + } + else + { + if( m_voiceType >= PVT_ALLIED_END ) + { + m_voiceType = PVT_ALLIED_PILOT; + } + } + + char model_name[ MAX_STRING_TOKENS ]; + char *model_replace; + + strcpy( model_name, model.c_str() ); + int len = strlen( model_name ); + + model_replace = model_name + len - 4; + + strcpy( model_replace, "_fps.tik" ); + + m_fpsTiki = gi.modeltiki( model_name ); +} + +void Player::InitPhysics + ( + void + ) + +{ + // Physics stuff + oldvelocity = vec_zero; + velocity = vec_zero; + old_v_angle = v_angle; + gravity = 1.0; + falling = false; + mediumimpact = false; + hardimpact = false; + setContents( CONTENTS_BODY ); + mass = 500; + memset( &last_ucmd, 0, sizeof( last_ucmd ) ); + + client->ps.groundTrace.fraction = 1.0f; +} + +void Player::InitPowerups + ( + void + ) + + { + // powerups + poweruptimer = 0; + poweruptype = 0; + } + +void Player::InitWorldEffects + ( + void + ) + +{ + // world effects + next_painsound_time = 0; +} + +void Player::InitWeapons + ( + void + ) + + { + // Don't do anything if we're loading a server game. + // This is either a loadgame or a restart + if ( LoadingSavegame ) + { + return; + } + + + } + +void Player::InitInventory + ( + void + ) + + { + } + +void Player::InitView + ( + void + ) + +{ + // view stuff + camera = NULL; + v_angle = vec_zero; + SetViewAngles( v_angle ); + viewheight = DEFAULT_VIEWHEIGHT; + + // blend stuff + damage_blend = vec_zero; + + damage_count = 0; + damage_blood = 0; + damage_alpha = 0; + damage_angles = vec_zero; +} + +void Player::InitDeathmatch( void ) +{ + fAttackerDispTime = 0.0f; + m_iInfoClient = -1; + m_fWeapSelectTime = level.time - 9.0f; + + m_fDamageMultipliers[ 0 ] = 2.0f; + m_fDamageMultipliers[ 1 ] = 2.0f; + m_fDamageMultipliers[ 2 ] = 2.0f; + m_fDamageMultipliers[ 3 ] = 1.0f; + m_fDamageMultipliers[ 4 ] = 0.95f; + m_fDamageMultipliers[ 5 ] = 0.90f; + m_fDamageMultipliers[ 6 ] = 0.85f; + m_fDamageMultipliers[ 7 ] = 0.80f; + m_fDamageMultipliers[ 8 ] = 0.80f; + m_fDamageMultipliers[ 9 ] = 0.80f; + m_fDamageMultipliers[ 10 ] = 0.80f; + m_fDamageMultipliers[ 11 ] = 0.60f; + m_fDamageMultipliers[ 12 ] = 0.60f; + m_fDamageMultipliers[ 13 ] = 0.60f; + m_fDamageMultipliers[ 14 ] = 0.60f; + m_fDamageMultipliers[ 15 ] = 0.50f; + m_fDamageMultipliers[ 16 ] = 0.50f; + m_fDamageMultipliers[ 17 ] = 0.50f; + m_fDamageMultipliers[ 18 ] = 0.50f; + + if( current_team ) + { + m_bSpectator = false; + m_bTempSpectator = false; + client->ps.pm_flags &= ~PMF_SPECTATING; + + if( dmManager.GetMatchStartTime() > 0.0f && !dmManager.AllowRespawn() && + g_allowjointime->value > 0.0f && level.time - dmManager.GetMatchStartTime() > g_allowjointime->value ) + { + m_bTempSpectator = true; + } + + if( g_gametype->integer >= GT_TEAM_ROUNDS && g_gametype->integer <= GT_OBJECTIVE && m_bTempSpectator ) + { + if( !IsSpectator() ) { + respawn_time = level.time + 1.0f; + } + + Spectator(); + } + else + { + BeginFight(); + } + } + else + { + if( client->pers.team ) + { + SetTeam( client->pers.team ); + } + else + { + SetTeam( TEAM_SPECTATOR ); + } + } + + edict->s.eFlags &= ~( TEAM_ALLIES | TEAM_AXIS ); + + if( GetTeam() == TEAM_ALLIES ) + { + edict->s.eFlags |= TEAM_ALLIES; + } + else if( GetTeam() == TEAM_AXIS ) + { + edict->s.eFlags |= TEAM_AXIS; + } + + if( g_gametype->integer >= GT_TEAM_ROUNDS ) + { + if( client->pers.kills ) + { + num_deaths = client->pers.kills; + client->pers.kills = 0; + } + } + + ChooseSpawnPoint(); + + // spectators should not have weapons + if( IsSpectator() ) + { + FreeInventory(); + } + else + { + Event *ev = new Event( "use" ); + + if( !Q_stricmp( client->pers.weapon, "rifle" ) ) + { + if( dm_team == TEAM_ALLIES ) + { + giveItem( "models/weapons/m1_garand.tik" ); + ev->AddString( "models/weapons/m1_garand.tik" ); + } + else + { + giveItem( "models/weapons/kar98.tik" ); + ev->AddString( "models/weapons/kar98.tik" ); + } + + GiveAmmo( "rifle", 100 ); + } + else if( !Q_stricmp( client->pers.weapon, "sniper" ) ) + { + if( dm_team == TEAM_ALLIES ) + { + giveItem( "models/weapons/springfield.tik" ); + ev->AddString( "models/weapons/springfield.tik" ); + } + else + { + giveItem( "models/weapons/kar98sniper.tik" ); + ev->AddString( "models/weapons/kar98sniper.tik" ); + } + } + else if( !Q_stricmp( client->pers.weapon, "smg" ) ) + { + if( dm_team == TEAM_ALLIES ) + { + giveItem( "models/weapons/thompsonsmg.tik" ); + ev->AddString( "models/weapons/thompsonsmg.tik" ); + } + else + { + giveItem( "models/weapons/mp40.tik" ); + ev->AddString( "models/weapons/mp40.tik" ); + } + } + else if( !Q_stricmp( client->pers.weapon, "mg" ) ) + { + if( dm_team == TEAM_ALLIES ) + { + giveItem( "models/weapons/bar.tik" ); + ev->AddString( "models/weapons/bar.tik" ); + } + else + { + giveItem( "models/weapons/mp44.tik" ); + ev->AddString( "models/weapons/mp44.tik" ); + } + } + else if( !Q_stricmp( client->pers.weapon, "heavy" ) ) + { + if( dm_team == TEAM_ALLIES ) + { + giveItem( "models/weapons/bazooka.tik" ); + ev->AddString( "models/weapons/bazooka.tik" ); + } + else + { + giveItem( "models/weapons/panzerschreck.tik" ); + ev->AddString( "models/weapons/panzerschreck.tik" ); + } + } + else if( !Q_stricmp( client->pers.weapon, "shotgun" ) ) + { + giveItem( "models/weapons/shotgun.tik" ); + ev->AddString( "models/weapons/shotgun.tik" ); + } + + PostEvent( ev, 0.3f ); + + if( dm_team == TEAM_ALLIES ) + { + giveItem( "models/weapons/colt45.tik" ); + giveItem( "models/weapons/m2frag_grenade.tik" ); + } + else + { + giveItem( "models/weapons/p38.tik" ); + giveItem( "models/weapons/steilhandgranate.tik" ); + } + + giveItem( "models/items/binoculars.tik" ); + } + + if( current_team ) { + current_team->m_bHasSpawnedPlayers = qtrue; + } +} + +void Player::InitMaxAmmo + ( + void + ) + +{ + GiveAmmo( "pistol", 0, 200 ); + GiveAmmo( "rifle", 0, 200 ); + GiveAmmo( "smg", 0, 300 ); + GiveAmmo( "mg", 0, 500 ); + GiveAmmo( "grenade", 0, 5 ); + GiveAmmo( "agrenade", 0, 5 ); + GiveAmmo( "heavy", 0, 5 ); + GiveAmmo( "shotgun", 0, 50 ); +} + +void Player::InitStats + ( + void + ) + +{ + m_iNumObjectives = 0; + m_iObjectivesCompleted = 0; + m_iNumHitsTaken = 0; + m_iNumEnemiesKilled = 0; + m_iNumObjectsDestroyed = 0; +} + +void Player::ChooseSpawnPoint( void ) +{ + // set up the player's spawn location + PlayerStart *p = SelectSpawnPoint( this ); + setOrigin( p->origin + Vector( "0 0 1" ) ); + origin.copyTo( edict->s.origin2 ); + edict->s.renderfx |= RF_FRAMELERP; + + if( g_gametype->integer && !IsSpectator() ) + { + KillBox( this ); + } + + setAngles( p->angles ); + SetViewAngles( p->angles ); + + if( g_gametype->integer ) + { + for( int i = 1; i <= 4; i++ ) + { + Event *ev = new Event( EV_SetViewangles ); + ev->AddVector( p->angles ); + PostEvent( ev, level.frametime * i ); + } + } + + if( p->m_bDeleteOnSpawn ) + { + delete p; + } + else + { + p->Unregister( STRING_SPAWN ); + m_pLastSpawnpoint = p; + } +} + +void Player::Disconnect( void ) +{ + Event *ev = new Event; + + ev->AddListener( this ); + scriptedEvents[ SE_DISCONNECTED ].Trigger( ev ); + + if( g_gametype->integer ) { + dmManager.RemovePlayer( this ); + } +} + +void Player::EndLevel + ( + Event *ev + ) + + { + InitPowerups(); + if ( health > max_health ) + { + health = max_health; + } + + if ( health < 1 ) + { + health = 1; + } + } + +void Player::Respawn + ( + Event *ev + ) + +{ + if( g_gametype->integer ) + { + if( health <= 0.0f ) + { + DeadBody(); + hideModel(); + } + + respawn_time = level.time; + + // This is not present in MOHAA + ProcessEvent( EV_Player_UnattachFromLadder ); + RemoveFromVehiclesAndTurrets(); + + FreeInventory(); + Init(); + + client->ps.pm_flags |= PMF_RESPAWNED; + } + else + { + if( g_lastsave->string && *g_lastsave->string ) + { + gi.SendConsoleCommand( "loadlastgame\n" ); + } + else + { + gi.SendConsoleCommand( "restart\n" ); + } + + logfile_started = qfalse; + } + + Unregister( STRING_RESPAWN ); +} + +Vector Player::GunTarget + ( + bool bNoCollision + ) + +{ + Vector vForward; + Vector vOut; + Vector vDest; + trace_t trace; + solid_t prev_solid = SOLID_BBOX; + + if( bNoCollision ) + { + AngleVectors( m_vViewAng, vForward, NULL, NULL ); + vOut = m_vViewPos + vForward * 1024.0f; + + return vOut; + } + else if( m_pVehicle ) + { + AngleVectors( m_vViewAng, vForward, NULL, NULL ); + vDest = m_vViewPos + vForward * 4096.0f; + + prev_solid = m_pVehicle->edict->solid; + + m_pVehicle->setSolidType( SOLID_NOT ); + + if( m_pVehicle->IsSubclassOfVehicle() ) + { + m_pVehicle->SetSlotsNonSolid(); + } + + trace = G_Trace( + m_vViewPos, + vec_zero, + vec_zero, + vDest, + this, + MASK_OPAQUE, + qfalse, + "Player::GunTarget" ); + + vOut = trace.endpos; + } + else + { + AngleVectors( m_vViewAng, vForward, NULL, NULL ); + vDest = m_vViewPos + vForward * 1024.0f; + + trace = G_Trace( m_vViewPos, + vec_zero, + vec_zero, + vDest, + this, + MASK_PLAYERSOLID, + qfalse, + "Player::GunTarget" ); + + if( !m_pTurret || ( Vector( trace.endpos ) - m_vViewPos ).lengthSquared() >= 16384.0f ) + { + vOut = trace.endpos; + } + else + { + vOut = vDest; + } + } + + if( m_pVehicle ) + { + m_pVehicle->setSolidType( prev_solid ); + + if( m_pVehicle->IsSubclassOfVehicle() ) + { + m_pVehicle->SetSlotsSolid(); + } + } + + return vOut; +} + +void Player::SetDeltaAngles + ( + void + ) + + { + int i; + + // Use v_angle since we may be in a camera + for( i = 0; i < 3; i++ ) + { + client->ps.delta_angles[ i ] = ANGLE2SHORT( v_angle[ i ] ); + } + } + +void Player::Obituary( Entity *attacker, Entity *inflictor, int meansofdeath, int iLocation ) +{ + const char *s1; + const char *s2; + qboolean bDispLocation; + + if( !g_gametype->integer ) { + return; + } + + s1 = NULL; + s2 = NULL; + bDispLocation = qfalse; + + if( attacker != this ) + { + if( attacker && attacker->client ) + { + Weapon *pAttackerWeap = NULL; + + if( attacker->IsSubclassOfPlayer() ) + { + pAttackerWeap = ( ( Player * )attacker )->GetActiveWeapon( WEAPON_MAIN ); + } + + switch( meansofdeath ) + { + case MOD_CRUSH: + case MOD_CRUSH_EVERY_FRAME: + s1 = "was crushes by"; + break; + case MOD_TELEFRAG: + s1 = "was telefragged by"; + break; + case MOD_FALLING: + s1 = "was pushed over the edge by"; + break; + case MOD_EXPLOSION: + s1 = "was blown away by"; + break; + case MOD_GRENADE: + if( G_Random() >= 0.5f ) + { + s1 = "tripped on"; + s2 = "'s' grenade"; + } + else + { + s1 = "is picking"; + s2 = "'s' shrapnel out of his teeth"; + } + break; + case MOD_ROCKET: + s1 = "took"; + if( G_Random() >= 0.5f ) + { + s2 = "'s rocket right in the kisser"; + } + else + { + s2 = "'s rocket in the face"; + } + break; + case MOD_IMPACT: + s1 = "was knocked out by"; + break; + case MOD_BULLET: + case MOD_FAST_BULLET: + s1 = "was shot by"; + + if( pAttackerWeap ) + { + if( pAttackerWeap->GetWeaponClass() & WEAPON_CLASS_PISTOL ) + { + s1 = "was gunned down by"; + } + else if( pAttackerWeap->GetWeaponClass() & WEAPON_CLASS_RIFLE ) + { + if( pAttackerWeap->m_iZoom ) + { + s1 = "was sniped by"; + } + else + { + s1 = "was rifled by"; + } + } + else if( pAttackerWeap->GetWeaponClass() & WEAPON_CLASS_SMG ) + { + s1 = "was perforated by"; + s2 = "'s' SMG"; + } + else if( pAttackerWeap->GetWeaponClass() & WEAPON_CLASS_MG ) + { + s1 = "was machine-gunned by"; + } + } + + if( iLocation > -1 ) + { + bDispLocation = qtrue; + } + break; + case MOD_VEHICLE: + s1 = "was run over by"; + break; + case MOD_LAVA: + case MOD_SLIME: + case MOD_FIRE: + case MOD_ON_FIRE: + s1 = "was burned up by"; + break; + case MOD_IMPALE: + s1 = "was impaled by"; + break; + case MOD_BASH: + if( G_Random() >= 0.5f ) + { + s1 = "was bashed by"; + } + else + { + s1 = "was clubbed by"; + } + break; + case MOD_SHOTGUN: + if( G_Random() >= 0.5f ) + { + s1 = "was hunted down by"; + } + else + { + s1 = "was pumped full of buckshot by"; + } + break; + default: + s1 = "was killed by"; + break; + } + + if( bDispLocation ) + { + str szConv1 = gi.LV_ConvertString( s1 ); + str szConv2; + str szConv3; + str szArg1 = "in the " + str( G_LocationNumToDispString( iLocation ) ); + + szConv3 = gi.LV_ConvertString( szArg1 ); + + if( s2 ) + { + szConv2 = gi.LV_ConvertString( s2 ); + + if( dedicated->integer ) + { + gi.DPrintf( "%s %s %s%s %s\n", + client->pers.netname, + szConv1.c_str(), + attacker->client->pers.netname, + szConv2.c_str(), + szConv3.c_str() ); + } + + G_PrintDeathMessage( va( "%s %s %s%s %s\n", + client->pers.netname, + szConv1.c_str(), + attacker->client->pers.netname, + szConv2.c_str(), + szConv3.c_str() ) ); + } + else + { + if( dedicated->integer ) + { + gi.DPrintf( "%s %s %s %s\n", + client->pers.netname, + szConv1.c_str(), + attacker->client->pers.netname, + szConv3.c_str() ); + } + + G_PrintDeathMessage( va( "%s %s %s %s\n", + client->pers.netname, + szConv1.c_str(), + attacker->client->pers.netname, + szConv3.c_str() ) ); + } + } + else + { + + str szConv1 = gi.LV_ConvertString( s1 ); + str szConv2; + + if( s2 ) + { + szConv2 = gi.LV_ConvertString( s2 ); + + if( dedicated->integer ) + { + gi.DPrintf( "%s %s %s %s\n", + client->pers.netname, + szConv1.c_str(), + attacker->client->pers.netname, + szConv2.c_str() ); + } + + G_PrintDeathMessage( va( "%s %s %s %s\n", + client->pers.netname, + szConv1.c_str(), + attacker->client->pers.netname, + szConv2.c_str() ) ); + } + else + { + if( dedicated->integer ) + { + gi.DPrintf( "%s %s %s\n", + client->pers.netname, + szConv1.c_str(), + attacker->client->pers.netname ); + } + + G_PrintDeathMessage( va( "%s %s %s\n", + client->pers.netname, + szConv1.c_str(), + attacker->client->pers.netname ) ); + } + } + } + else + { + switch( meansofdeath ) + { + case MOD_LAVA: + case MOD_SLIME: + s1 = "was burned to a crisp"; + break; + case MOD_FALLING: + s1 = "cratered"; + break; + case MOD_EXPLOSION: + case MOD_GRENADE: + s1 = "blew up"; + break; + case MOD_ROCKET: + s1 = "caught a rocket"; + break; + case MOD_BULLET: + case MOD_FAST_BULLET: + if( iLocation > -1 ) + { + s1 = "was shot in the"; + } + else + { + s1 = "was shot"; + bDispLocation = qtrue; + } + break; + default: + s1 = "died"; + break; + } + + if( bDispLocation ) + { + str szConv1 = gi.LV_ConvertString( s1 + str( "in the " ) + G_LocationNumToDispString( iLocation ) ); + + if( dedicated->integer ) + { + gi.Printf( "%s %s\n", client->pers.netname, szConv1.c_str() ); + } + + G_PrintDeathMessage( va( "%s %s", + client->pers.netname, + szConv1.c_str() ) ); + } + else + { + str szConv1 = gi.LV_ConvertString( s1 ); + + if( dedicated->integer ) + { + gi.Printf( "%s %s\n", client->pers.netname, szConv1.c_str() ); + } + + G_PrintDeathMessage( va( "%s %s", + client->pers.netname, + szConv1.c_str() ) ); + } + } + } + else + { + switch( meansofdeath ) + { + case MOD_SUICIDE: + s1 = "took himself out of commision"; + break; + case MOD_LAVA: + case MOD_SLIME: + s1 = "was burned to a crisp"; + break; + case MOD_FALLING: + s1 = "cratered"; + break; + case MOD_EXPLOSION: + s1 = "blew himself up"; + break; + case MOD_GRENADE: + if( G_Random() >= 0.5f ) + { + s1 = "played catch with himself"; + } + else + { + s1 = "tripped on his own grenade"; + } + break; + case MOD_ROCKET: + s1 = "rocketed himself"; + break; + case MOD_BULLET: + case MOD_FAST_BULLET: + if( iLocation > -1 ) + { + s1 = "shot himself"; + } + else + { + s1 = "shot himself in the"; + bDispLocation = qtrue; + } + default: + s1 = "died"; + break; + } + + if( bDispLocation ) + { + str szConv1 = gi.LV_ConvertString( s1 + str( " " ) + G_LocationNumToDispString( meansofdeath ) ); + + if( dedicated->integer ) + { + gi.Printf( "%s %s\n", client->pers.netname, szConv1.c_str() ); + } + + G_PrintDeathMessage( va( "%s %s\n", client->pers.netname, szConv1.c_str() ) ); + } + else + { + str szConv1 = gi.LV_ConvertString( s1 ); + + if( dedicated->integer ) + { + gi.Printf( "%s %s\n", client->pers.netname, szConv1.c_str() ); + } + + G_PrintDeathMessage( va( "%s %s\n", client->pers.netname, szConv1.c_str() ) ); + } + } +} + +void Player::Dead + ( + Event *ev + ) + +{ + if( deadflag == DEAD_DEAD ) { + return; + } + + health = 0; + deadflag = DEAD_DEAD; + + edict->s.renderfx &= ~RF_SHADOW; + server_new_buttons = 0; + + CancelEventsOfType( EV_Player_Dead ); + + // stop animating + StopPartAnimating( legs ); + + // pause the torso anim + PausePartAnim( torso ); + + partAnim[ torso ] = ""; + + respawn_time = level.time + 1.0f; + + if( g_gametype->integer ) + { + if( !dmManager.AllowRespawn() ) + { + respawn_time = level.time + 2.0f; + } + } + else + { + if( level.current_map && *level.current_map ) + { + G_BeginIntermission( level.current_map, TRANS_LEVEL ); + } + } + + ZoomOff(); +} + +void Player::Killed + ( + Event *ev + ) + +{ + Entity *attacker; + Entity *inflictor; + int meansofdeath; + int location; + Event *event; + + // Custom killed event will do the job + if( m_pKilledEvent ) + { + event = new Event( m_pKilledEvent ); + for( int i = 1; i <= ev->NumArgs(); i++ ) + event->AddValue( ev->GetValue( i ) ); + ProcessEvent( event ); + + Unregister( STRING_DEATH ); + return; + } + + if( g_gametype->integer ) + { + current_team->AddDeaths( this, 1 ); + } + else + { + AddDeaths( 1 ); + } + + attacker = ev->GetEntity( 1 ); + inflictor = ev->GetEntity( 3 ); + meansofdeath = ev->GetInteger( 9 ); + location = ev->GetInteger( 10 ); + + pain_type = ( meansOfDeath_t )meansofdeath; + + if( attacker ) { + Obituary( attacker, inflictor, meansofdeath, location ); + } + + RemoveFromVehiclesAndTurrets(); + + if( g_gametype->integer && attacker && attacker->IsSubclassOfPlayer() ) + { + ( ( Player * )attacker )->KilledPlayerInDeathmatch( this ); + } + + deadflag = DEAD_DYING; + health = 0; + + event = new Event( EV_Pain ); + + event->AddEntity( attacker ); + event->AddFloat( ev->GetFloat( 2 ) ); + event->AddEntity( inflictor ); + event->AddVector( ev->GetVector( 4 ) ); + event->AddVector( ev->GetVector( 5 ) ); + event->AddVector( ev->GetVector( 6 ) ); + event->AddInteger( ev->GetInteger( 7 ) ); + event->AddInteger( ev->GetInteger( 8 ) ); + event->AddInteger( ev->GetInteger( 9 ) ); + event->AddInteger( ev->GetInteger( 10 ) ); + + ProcessEvent( event ); + + if( g_gametype->integer ) + { + if( HasItem( "Binoculars" ) ) { + takeItem( "Binoculars" ); + } + + PostEvent( EV_Player_DMDeathDrop, 0.1f ); + edict->s.eFlags |= EF_DEAD; + } + + edict->clipmask = MASK_DEADSOLID; + setContents( CONTENTS_CORPSE ); + setSolidType( SOLID_NOT ); + setMoveType( MOVETYPE_FLY ); + + angles.x = 0; + angles.z = 0; + setAngles( angles ); + + // + // change music + // + ChangeMusic( "failure", "normal", true ); + + takedamage = DAMAGE_NO; + + // Post a dead event just in case + PostEvent( EV_Player_Dead, 5.0f ); + ZoomOff(); + + if( g_voiceChat->integer ) + { + if( m_voiceType == PVT_ALLIED_MANON ) + { + Sound( "manon_death", CHAN_VOICE, -1.0f, 160, NULL, -1.0f, 1, 0, 1, 1200 ); + } + else + { + Sound( "player_death" ); + } + } + else + { + Sound( "player_death" ); + } + + event = new Event; + + event->AddEntity( ev->GetEntity( 1 ) ); + event->AddFloat( ev->GetFloat( 2 ) ); + event->AddEntity( ev->GetEntity( 3 ) ); + event->AddVector( ev->GetVector( 4 ) ); + event->AddVector( ev->GetVector( 5 ) ); + event->AddVector( ev->GetVector( 6 ) ); + event->AddInteger( ev->GetInteger( 7 ) ); + event->AddInteger( ev->GetInteger( 8 ) ); + event->AddInteger( ev->GetInteger( 9 ) ); + event->AddInteger( ev->GetInteger( 10 ) ); + event->AddEntity( this ); + + scriptedEvents[ SE_KILL ].Trigger( event ); + + Unregister( STRING_DEATH ); +} + +void Player::KilledPlayerInDeathmatch + ( + Player *killed + ) + +{ + DM_Team *pDMTeam; + + if( killed == this ) + { + AddKills( -1 ); + gi.SendServerCommand( edict - g_entities, "print \"" HUD_MESSAGE_WHITE "%s\n\"", gi.LV_ConvertString( "You killed yourself" ) ); + } + else + { + pDMTeam = killed->GetDM_Team(); + + if( pDMTeam != GetDM_Team() || g_gametype->integer <= GT_FFA || g_gametype->integer > GT_OBJECTIVE ) + { + current_team->AddKills( this, 1 ); + } + else + { + current_team->AddKills( this, -1 ); + } + + gi.SendServerCommand( edict - g_entities, "print \"" HUD_MESSAGE_WHITE "%s %s\n\"", gi.LV_ConvertString( "You killed" ), killed->client->pers.netname ); + } +} + +void Player::ArmorDamage + ( + Event *ev + ) + +{ + int mod = ev->GetInteger( 9 ); + + if( g_gametype->integer ) + { + // players that are not allowed fighting mustn't take damage + if( !m_bAllowFighting && mod != MOD_TELEFRAG ) + { + return; + } + + Player *attacker = ( Player * )ev->GetEntity( 1 ); + + if( attacker && attacker->IsSubclassOfPlayer() ) + { + if( attacker != this ) + { + if( g_gametype->integer > 1 && !g_teamdamage->integer ) + { + // check for team damage + if( attacker->GetDM_Team() == GetDM_Team() && mod != MOD_TELEFRAG ) + { + return; + } + } + + pAttackerDistPointer = attacker; + fAttackerDispTime = g_drawattackertime->value + level.time; + } + } + } + + m_iNumHitsTaken++; + + Sentient::ArmorDamage( ev ); + + Event *event = new Event; + + event->AddEntity( ev->GetEntity( 1 ) ); + event->AddFloat( ev->GetFloat( 2 ) ); + event->AddEntity( ev->GetEntity( 3 ) ); + event->AddVector( ev->GetVector( 4 ) ); + event->AddVector( ev->GetVector( 5 ) ); + event->AddVector( ev->GetVector( 6 ) ); + event->AddInteger( ev->GetInteger( 7 ) ); + event->AddInteger( ev->GetInteger( 8 ) ); + event->AddInteger( ev->GetInteger( 9 ) ); + event->AddInteger( ev->GetInteger( 10 ) ); + event->AddEntity( this ); + + scriptedEvents[ SE_DAMAGE ].Trigger( event ); +} + +void Player::Pain + ( + Event *ev + ) + +{ + float damage, yawdiff; + Entity *attacker; + int meansofdeath; + Vector dir, pos, attack_angle; + int iLocation; + + attacker = ev->GetEntity( 1 ); + damage = ev->GetFloat( 2 ); + pos = ev->GetVector( 4 ); + dir = ev->GetVector( 5 ); + meansofdeath = ev->GetInteger( 9 ); + iLocation = ev->GetInteger( 10 ); + + if( !damage && !knockdown ) + return; + + client->ps.stats[ STAT_LAST_PAIN ] = damage; + + // Determine direction + attack_angle = dir.toAngles(); + yawdiff = angles[ YAW ] - attack_angle[ YAW ] + 180; + yawdiff = AngleNormalize180( yawdiff ); + + if( yawdiff > -45 && yawdiff < 45 ) + pain_dir = PAIN_FRONT; + else if( yawdiff < -45 && yawdiff > -135 ) + pain_dir = PAIN_LEFT; + else if( yawdiff > 45 && yawdiff < 135 ) + pain_dir = PAIN_RIGHT; + else + pain_dir = PAIN_REAR; + + // accumulate pain for animation purposes + if( take_pain ) + { + pain += damage; + } + + // Spawn off any damage effect if we get hit with a certain type of damage + SpawnDamageEffect( ( meansOfDeath_t )meansofdeath ); + + pain_type = ( meansOfDeath_t )meansofdeath; + pain_location = iLocation; + + // Only set the regular pain level if enough time since last pain has passed + if( ( level.time > nextpaintime ) && take_pain ) + { + pain = damage; + } + + // add to the damage inflicted on a player this frame + // the total will be turned into screen blends and view angle kicks + // at the end of the frame + damage_blood += damage; + damage_from += dir * damage; + damage_yaw = dir.toYaw() * 10.0f; + + if( damage_yaw == client->ps.stats[ STAT_DAMAGEDIR ] ) + { + if( damage_yaw < 1800.0f ) + damage_yaw += 1.0f; + else + damage_yaw -= 1.0f; + } + + if( g_gametype->integer && + attacker && + attacker->client && + attacker != this ) + { + gi.MSG_SetClient( attacker->edict - g_entities ); + if( IsDead() ) + gi.MSG_StartCGM( 36 ); + else + gi.MSG_StartCGM( 35 ); + gi.MSG_EndCGM(); + } + + if( IsDead() ) { + return; + } + + if( g_voiceChat->integer ) + { + if( m_voiceType == PVT_ALLIED_MANON ) + { + Sound( "manon_pain", CHAN_DIALOG, -1, 160, NULL, -1, 1, 0, 1, 1200 ); + } + else + { + Sound( "player_pain" ); + } + } + else + { + Sound( "player_pain" ); + } +} + +void Player::DeadBody + ( + void + ) +{ + Body *body; + + if( knockdown ) { + return; + } + + knockdown = true; + + body = new Body; + body->setModel( model ); + + for( int i = 0; i < MAX_FRAMEINFOS; i++ ) + { + body->edict->s.frameInfo[ i ] = edict->s.frameInfo[ i ]; + } + + body->edict->s.actionWeight = edict->s.actionWeight; + body->edict->s.scale = edict->s.scale; + + body->setOrigin( origin ); + body->setAngles( angles ); + + body->edict->s.eFlags &= ~( EF_AXIS | EF_ALLIES ); + + if( GetTeam() == TEAM_ALLIES ) + { + edict->s.eFlags |= EF_ALLIES; + } + else if( GetTeam() == TEAM_AXIS ) + { + edict->s.eFlags |= EF_AXIS; + } +} + +void Player::DeadBody + ( + Event *ev + ) +{ + DeadBody(); +} + +qboolean Player::canUse() +{ + int touch[ MAX_GENTITIES ]; + int num = getUseableEntities( touch, MAX_GENTITIES ); + + return num ? true : false; +} + +qboolean Player::canUse( Entity *entity, bool requiresLookAt ) +{ + gentity_t *hit; + int touch[ MAX_GENTITIES ]; + int num; + int i; + + num = getUseableEntities( touch, MAX_GENTITIES, requiresLookAt ); + + for( i = 0; i < num; i++ ) + { + hit = &g_entities[ touch[ i ] ]; + + if( !hit->inuse || hit->entity == NULL ) { + continue; + } + + if( hit->entity == entity ) { + return true; + } + } + + return false; +} + +int Player::getUseableEntities( int *touch, int maxcount, bool requiresLookAt ) +{ + Vector end; + Vector start; + trace_t trace; + Vector offset; + Vector max; + Vector min; + + if( ( g_gametype->integer && IsSpectator() ) || IsDead() ) { + return 0; + } + + if( m_pTurret ) + { + *touch = m_pTurret->entnum; + return 1; + } + + if( m_pTurret ) { + return 0; + } + + AngleVectors( client->ps.viewangles, offset, NULL, NULL ); + + start = origin; + start.z += client->ps.viewheight; + + if( requiresLookAt ) + { + min = Vector( -4.f, -4.f, -4.f ); + max = Vector( 4.f, 4.f, 4.f ); + + end[ 0 ] = start[ 0 ] + ( offset[ 0 ] * 64.f ); + end[ 1 ] = start[ 1 ] + ( offset[ 1 ] * 64.f ); + + if( v_angle[ 0 ] <= 0.0f ) { + end[ 2 ] = start[ 2 ] + ( offset[ 2 ] * 40.f ); + } else { + end[ 2 ] = start[ 2 ] + ( offset[ 2 ] * 88.f ); + } + + trace = G_Trace( start, + min, + max, + end, + this, + MASK_SOLID, + false, + "Player::getUseableEntity" ); + + offset = trace.endpos; + + min = offset - Vector( 16.f, 16.f, 16.f ); + max = offset + Vector( 16.f, 16.f, 16.f ); + } + else + { + min = start - Vector( 31.f, 31.f, 31.f ); + max = start + Vector( 31.f, 31.f, 31.f ); + } + + return gi.AreaEntities( min, max, touch, maxcount ); +} + +void Player::DoUse + ( + Event *ev + ) + +{ + gentity_t *hit; + int touch[ MAX_GENTITIES ]; + int num; + int i; + + if( g_gametype->integer && IsSpectator() ) + { + return; + } + + if( IsDead() ) + { + return; + } + + if( m_pVehicle ) + { + Event *event = new Event( EV_Use ); + event->AddEntity( this ); + m_pVehicle->ProcessEvent( event ); + } + else if( m_pTurret ) + { + m_pTurret->TurretEndUsed(); + } + else + { + num = getUseableEntities( touch, MAX_GENTITIES, true ); + + for( i = 0; i < num; i++ ) + { + hit = &g_entities[ touch[ i ] ]; + + if( !hit->inuse || hit->entity == NULL || hit->entity == this ) { + continue; + } + + Event *event = new Event( EV_Use ); + event->AddListener( this ); + + hit->entity->ProcessEvent( event ); + } + } + + // FIXME: reborn feature +#if 0 + + // Now retrieve entities that doesn't require to look at + num = getUseableEntities( touch, MAX_GENTITIES, false ); + + for( i = 0; i < num; i++ ) + { + hit = &g_entities[ touch[ i ] ]; + + if( !hit->inuse || hit->entity == NULL || hit->entity == this ) { + continue; + } + + Event *event = new Event( EV_Use ); + event->AddListener( this ); + + hit->entity->ProcessEvent( event ); + } +#endif +} + +void Player::TouchStuff + ( + pmove_t *pm + ) + +{ + gentity_t *other; + Event *event; + int i; + int j; + + // + // clear out any conditionals that are controlled by touching + // + toucheduseanim = NULL; + + if( getMoveType() != MOVETYPE_NOCLIP ) + { + G_TouchTriggers( this ); + } + + // touch other objects + for( i = 0; i < pm->numtouch; i++ ) + { + other = &g_entities[ pm->touchents[ i ] ]; + + for( j = 0; j < i; j++ ) + { + gentity_t *ge = &g_entities[ j ]; + + if( ge == other ) + break; + } + + if( j != i ) + { + // duplicated + continue; + } + + // Don't bother touching the world + if( ( !other->entity ) || ( other->entity == world ) ) + { + continue; + } + + event = new Event( EV_Touch ); + event->AddEntity( this ); + other->entity->ProcessEvent( event ); + + event = new Event( EV_Touch ); + event->AddEntity( other->entity ); + ProcessEvent( event ); + } +} + +void Player::GetMoveInfo + ( + pmove_t *pm + ) + +{ + moveresult = pm->moveresult; + + if( !deadflag || ( g_gametype->integer && IsSpectator() ) ) + { + v_angle[ 0 ] = pm->ps->viewangles[ 0 ]; + v_angle[ 1 ] = pm->ps->viewangles[ 1 ]; + v_angle[ 2 ] = pm->ps->viewangles[ 2 ]; + + if( moveresult == MOVERESULT_TURNED ) + { + angles.y = v_angle[ 1 ]; + setAngles( angles ); + SetViewAngles( angles ); + } + } + + setOrigin( Vector( pm->ps->origin[ 0 ], pm->ps->origin[ 1 ], pm->ps->origin[ 2 ] ) ); + + if( pm->ps->groundEntityNum != ENTITYNUM_NONE ) + { + float backoff; + float change; + int i; + + backoff = DotProduct( pm->ps->groundTrace.plane.normal, pm->ps->velocity ); + + for( i = 0; i < 3; i++ ) + { + change = pm->ps->groundTrace.plane.normal[ i ] * backoff; + pm->ps->velocity[ i ] -= change; + } + } + + // Set the ground entity + groundentity = NULL; + if( pm->ps->groundEntityNum != ENTITYNUM_NONE ) + { + groundentity = &g_entities[ pm->ps->groundEntityNum ]; + airspeed = 200; + + if( !groundentity->entity || groundentity->entity->getMoveType() == MOVETYPE_NONE ) + { + m_vPushVelocity = vec_zero; + } + + // Disable predictions when the groundentity is moving up/down, looks like shaky otherwise + if( groundentity->entity && groundentity->entity != this && groundentity->entity->velocity[ 2 ] != 0 ) + { + pm->ps->pm_flags |= PMF_NO_PREDICTION; + } + } + + velocity = Vector( pm->ps->velocity[ 0 ], pm->ps->velocity[ 1 ], pm->ps->velocity[ 2 ] ); + + if( ( client->ps.pm_flags & PMF_FROZEN ) || ( client->ps.pm_flags & PMF_NO_MOVE ) ) + { + velocity = vec_zero; + } + else + { + setSize( pm->mins, pm->maxs ); + viewheight = pm->ps->viewheight; + } + + // water type and level is set in the predicted code + waterlevel = pm->waterlevel; + watertype = pm->watertype; +} + +void Player::SetMoveInfo + ( + pmove_t *pm, + usercmd_t *ucmd + ) + +{ + Vector move; + + // set up for pmove + memset( pm, 0, sizeof( pmove_t ) ); + + velocity.copyTo( client->ps.velocity ); + + pm->ps = &client->ps; + + if( ucmd ) + { + pm->cmd = *ucmd; + } + + pm->tracemask = MASK_PLAYERSOLID; + pm->trace = gi.Trace; + pm->pointcontents = gi.PointContents; + + pm->ps->origin[ 0 ] = origin.x; + pm->ps->origin[ 1 ] = origin.y; + pm->ps->origin[ 2 ] = origin.z; + + pm->mins[ 0 ] = mins.x; + pm->mins[ 1 ] = mins.y; + pm->mins[ 2 ] = mins.z; + + pm->maxs[ 0 ] = maxs.x; + pm->maxs[ 1 ] = maxs.y; + pm->maxs[ 2 ] = maxs.z; + + pm->ps->velocity[ 0 ] = velocity.x; + pm->ps->velocity[ 1 ] = velocity.y; + pm->ps->velocity[ 2 ] = velocity.z; + + pm->pmove_fixed = pmove_fixed->integer; + pm->pmove_msec = pmove_msec->integer; + + if( pmove_msec->integer < 8 ) + { + pm->pmove_msec = 8; + } + else if( pmove_msec->integer > 33 ) + { + pm->pmove_msec = 33; + } +} + +pmtype_t Player::GetMovePlayerMoveType + ( + void + ) + +{ + if( getMoveType() == MOVETYPE_NOCLIP || IsSpectator() ) + { + return PM_NOCLIP; + } + else if( deadflag ) + { + return PM_DEAD; + } + else if( movecontrol == MOVECONTROL_CLIMBWALL ) + { + return PM_CLIMBWALL; + } + else + { + return PM_NORMAL; + } +} + +void Player::CheckGround + ( + void + ) + +{ + pmove_t pm; + + SetMoveInfo( &pm, current_ucmd ); + Pmove_GroundTrace( &pm ); + GetMoveInfo( &pm ); +} + +qboolean Player::AnimMove + ( + Vector &move, + Vector *endpos + ) + +{ + Vector up; + Vector down; + trace_t trace; + int mask; + Vector start( origin ); + Vector end( origin + move ); + + mask = MASK_PLAYERSOLID; + + // test the player position if they were a stepheight higher + trace = G_Trace( start, mins, maxs, end, this, mask, true, "AnimMove" ); + if( trace.fraction < 1 ) + { + if( ( movecontrol == MOVECONTROL_HANGING ) || ( movecontrol == MOVECONTROL_CLIMBWALL ) ) + { + up = origin; + up.z += move.z; + trace = G_Trace( origin, mins, maxs, up, this, mask, true, "AnimMove" ); + if( trace.fraction < 1 ) + { + if( endpos ) + { + *endpos = origin; + } + return qfalse; + } + + origin = trace.endpos; + end = origin; + end.x += move.x; + end.y += move.y; + + trace = G_Trace( origin, mins, maxs, end, this, mask, true, "AnimMove" ); + if( endpos ) + { + *endpos = trace.endpos; + } + + return ( trace.fraction > 0 ); + } + else + { + return TestMove( move, endpos ); + } + } + else + { + if( endpos ) + { + *endpos = trace.endpos; + } + + return qtrue; + } +} + +qboolean Player::TestMove + ( + Vector &move, + Vector *endpos + ) + + { + trace_t trace; + Vector pos( origin + move ); + + trace = G_Trace( origin, mins, maxs, pos, this, MASK_PLAYERSOLID, true, "TestMove" ); + if ( trace.allsolid ) + { + // player is completely trapped in another solid + if ( endpos ) + { + *endpos = origin; + } + return qfalse; + } + + if ( trace.fraction < 1.0f ) + { + Vector up( origin ); + up.z += STEPSIZE; + + trace = G_Trace( origin, mins, maxs, up, this, MASK_PLAYERSOLID, true, "TestMove" ); + if ( trace.fraction == 0.0f ) + { + if ( endpos ) + { + *endpos = origin; + } + return qfalse; + } + + Vector temp( trace.endpos ); + Vector end( temp + move ); + + trace = G_Trace( temp, mins, maxs, end, this, MASK_PLAYERSOLID, true, "TestMove" ); + if ( trace.fraction == 0.0f ) + { + if ( endpos ) + { + *endpos = origin; + } + return qfalse; + } + + temp = trace.endpos; + + Vector down( trace.endpos ); + down.z = origin.z; + + trace = G_Trace( temp, mins, maxs, down, this, MASK_PLAYERSOLID, true, "TestMove" ); + } + + if ( endpos ) + { + *endpos = trace.endpos; + } + + return qtrue; + } + +float Player::TestMoveDist + ( + Vector &move + ) + + { + Vector endpos; + + TestMove( move, &endpos ); + endpos -= origin; + + return endpos.length(); + } + +static Vector vec_up = Vector( 0, 0, 1 ); + +void Player::CheckMoveFlags + ( + void + ) + +{ + trace_t trace; + Vector start; + Vector end; + float oldsp; + Vector olddir( oldvelocity.x, oldvelocity.y, 0 ); + + // + // Check if moving forward will cause the player to fall + // + start = origin + yaw_forward * 52.0f; + end = start; + end.z -= STEPSIZE * 2; + + trace = G_Trace( start, mins, maxs, end, this, MASK_PLAYERSOLID, true, "CheckMoveFlags" ); + canfall = ( trace.fraction >= 1.0f ); + + if( !groundentity && !( client->ps.walking ) ) + { + falling = true; + hardimpact = false; + mediumimpact = false; + } + else + { + falling = false; + mediumimpact = oldvelocity.z <= -180.0f; + hardimpact = oldvelocity.z < -400.0f; + } + + // check for running into walls + oldsp = VectorNormalize( olddir ); + if( ( oldsp > 220.0f ) && ( velocity * olddir < 2.0f ) ) + { + moveresult = MOVERESULT_HITWALL; + } + + move_forward_vel = DotProduct( yaw_forward, velocity ); + move_backward_vel = -move_forward_vel; + + if( move_forward_vel < 0.0f ) { + move_forward_vel = 0.0f; + } + + if( move_backward_vel < 0.0f ) { + move_backward_vel = 0.0f; + } + + move_left_vel = DotProduct( yaw_left, velocity ); + move_right_vel = -move_left_vel; + + if( move_left_vel < 0.0f ) { + move_left_vel = 0.0f; + } + + if( move_right_vel < 0.0f ) { + move_right_vel = 0.0f; + } + + move_up_vel = DotProduct( vec_up, velocity ); + move_down_vel = -move_up_vel; + + if( move_up_vel < 0.0f ) { + move_up_vel = 0.0f; + } + + if( move_down_vel < 0.0f ) { + move_down_vel = 0.0f; + } +} + +qboolean Player::CheckMove + ( + Vector &move, + Vector *endpos + ) +{ + return AnimMove( move, endpos ); +} + +float Player::CheckMoveDist + ( + Vector &move + ) + + { + Vector endpos; + + CheckMove( move, &endpos ); + endpos -= origin; + + return endpos.length(); + } + +void Player::ClientMove + ( + usercmd_t *ucmd + ) + +{ + pmove_t pm; + Vector move; + + oldorigin = origin; + + client->ps.pm_type = GetMovePlayerMoveType(); + // set move flags + client->ps.pm_flags &= ~( PMF_FROZEN | PMF_NO_PREDICTION | PMF_NO_MOVE | PMF_DUCKED | PMF_NO_GRAVITY | PMF_VIEW_PRONE | PMF_VIEW_DUCK_RUN | PMF_VIEW_JUMP_START ); + + if( level.playerfrozen || m_bFrozen ) + { + client->ps.pm_flags |= PMF_FROZEN; + } + + if( ( flags & FL_IMMOBILE ) || ( flags & FL_PARTIAL_IMMOBILE ) ) + { + client->ps.pm_flags |= PMF_NO_MOVE; + client->ps.pm_flags |= PMF_NO_PREDICTION; + } + + if( maxs.z == 60.0f ) + { + client->ps.pm_flags |= PMF_DUCKED; + } + else if( maxs.z == 54.0f ) + { + client->ps.pm_flags |= PMF_DUCKED | PMF_VIEW_PRONE; + } + else if( maxs.z == 20.0f ) + { + client->ps.pm_flags |= PMF_VIEW_PRONE; + } + else if( maxs.z == 53.0f ) + { + client->ps.pm_flags |= PMF_VIEW_DUCK_RUN; + } + else if( viewheight == 52 ) + { + client->ps.pm_flags |= PMF_VIEW_JUMP_START; + } + + switch( movecontrol ) + { + case MOVECONTROL_USER: + case MOVECONTROL_LEGS: + case MOVECONTROL_USER_MOVEANIM: + break; + + case MOVECONTROL_CROUCH: + client->ps.pm_flags |= PMF_NO_PREDICTION | PMF_DUCKED | PMF_VIEW_PRONE; + break; + + default: + client->ps.pm_flags |= PMF_NO_PREDICTION; + } + + if( movetype == MOVETYPE_NOCLIP ) + { + if( !( last_ucmd.buttons & BUTTON_RUN ) ) + { + client->ps.speed = sv_walkspeed->integer; + } + else + { + client->ps.speed = sv_runspeed->integer; + } + } + else if( !groundentity ) + { + client->ps.speed = airspeed; + } + else + { + int runspeed; + + if( m_iMovePosFlags & MPF_MOVEMENT_WALKING ) + { + runspeed = sv_walkspeed->integer; + } + else + { + runspeed = sv_runspeed->integer; + } + + if( m_iMovePosFlags & MPF_POSITION_CROUCHING ) + { + client->ps.speed = ( int )( ( float )runspeed * sv_crouchspeedmult->value ); + } + else + { + client->ps.speed = runspeed; + } + } + + + if( g_gametype->integer ) + { + client->ps.speed = ( int )( ( float )client->ps.speed * sv_dmspeedmult->value ); + } + + for( int i = 0; i < MAX_SPEED_MULTIPLIERS; i++ ) + { + client->ps.speed = ( int )( ( float )client->ps.speed * speed_multiplier[ i ] ); + } + + for( int i = 0; i < MAX_ACTIVE_WEAPONS; i++ ) + { + if( activeWeaponList[ i ] != NULL ) + { + client->ps.speed *= activeWeaponList[ i ]->m_fMovementSpeed; + } + } + + client->ps.gravity = sv_gravity->value * gravity; + + if( ( movecontrol != MOVECONTROL_ABSOLUTE ) && ( movecontrol != MOVECONTROL_PUSH ) && + ( movecontrol != MOVECONTROL_CLIMBWALL ) ) + { + Vector oldpos( origin ); + + SetMoveInfo( &pm, ucmd ); + Pmove( &pm ); + GetMoveInfo( &pm ); + ProcessPmoveEvents( pm.pmoveEvent ); + + // if we're not moving, set the blocked flag in case the user is trying to move + if( ucmd->forwardmove && ( ( oldpos - origin ).length() < 0.005f ) ) + { + moveresult = MOVERESULT_BLOCKED; + } + if( client->ps.walking && moveresult >= MOVERESULT_BLOCKED ) + { + setOrigin( oldpos ); + VectorCopy( origin, client->ps.origin ); + } + } + else + { + if( movecontrol == MOVECONTROL_CLIMBWALL ) + { + PM_UpdateViewAngles( &client->ps, ucmd ); + v_angle = client->ps.viewangles; + } + else if( !deadflag ) + { + v_angle = client->ps.viewangles; + } + + // should collect objects to touch against + memset( &pm, 0, sizeof( pmove_t ) ); + + // keep the command time up to date or else the next PMove we run will try to catch up + client->ps.commandTime = ucmd->serverTime; + + velocity = vec_zero; + } + + if( ( getMoveType() != MOVETYPE_NOCLIP ) && ( client->ps.pm_flags & PMF_NO_PREDICTION ) ) + { + if( ( movecontrol == MOVECONTROL_ABSOLUTE ) || ( movecontrol == MOVECONTROL_CLIMBWALL ) ) + { + velocity = vec_zero; + } + + if( ( movecontrol == MOVECONTROL_ANIM ) || ( movecontrol == MOVECONTROL_CLIMBWALL ) || + ( movecontrol == MOVECONTROL_USEANIM ) || ( movecontrol == MOVECONTROL_LOOPUSEANIM ) || + ( movecontrol == MOVECONTROL_USER_MOVEANIM ) ) + { + Vector delta = vec_zero; + PlayerAnimDelta( delta ); + + // using PM_NOCLIP for a smooth move + //client->ps.pm_type = PM_NOCLIP; + + if( delta != vec_zero ) + { + float mat[ 3 ][ 3 ]; + AngleVectors( angles, mat[ 0 ], mat[ 1 ], mat[ 2 ] ); + MatrixTransformVector( delta, mat, move ); + AnimMove( move, &origin ); + setOrigin( origin ); + CheckGround(); + } + } + } + + m_fLastDeltaTime = level.time; + + TouchStuff( &pm ); + + if( ( whereami->integer ) && ( origin != oldorigin ) ) + { + gi.DPrintf( "x %8.2f y%8.2f z %8.2f area %2d\n", origin[ 0 ], origin[ 1 ], origin[ 2 ], edict->r.areanum ); + } +} + +void Player::VehicleMove + ( + usercmd_t *ucmd + ) + +{ + if( !m_pVehicle ) { + return; + } + + oldorigin = origin; + + client->ps.pm_type = GetMovePlayerMoveType(); + + // set move flags + client->ps.pm_flags &= ~( PMF_FROZEN | PMF_NO_PREDICTION | PMF_NO_MOVE | PMF_DUCKED | PMF_NO_GRAVITY | PMF_VIEW_PRONE | PMF_VIEW_DUCK_RUN | PMF_VIEW_JUMP_START ); + + // disable HUD and prediction + client->ps.pm_flags |= PMF_NO_HUD | PMF_NO_PREDICTION; + + if( level.playerfrozen || m_bFrozen ) + { + client->ps.pm_flags |= PMF_FROZEN; + } + + if( m_pVehicle->Drive( ucmd ) ) + { + client->ps.commandTime = ucmd->serverTime; + } + else + { + ClientMove( ucmd ); + } +} + +void Player::TurretMove + ( + usercmd_t *ucmd + ) + +{ + if( !m_pTurret ) { + return; + } + + oldorigin = origin; + + client->ps.pm_type = GetMovePlayerMoveType(); + + // set move flags + client->ps.pm_flags &= ~( PMF_FROZEN | PMF_NO_PREDICTION | PMF_NO_MOVE | PMF_DUCKED | PMF_NO_GRAVITY | PMF_VIEW_PRONE | PMF_VIEW_DUCK_RUN | PMF_VIEW_JUMP_START ); + + // disable HUD and prediction + client->ps.pm_flags |= PMF_NO_HUD | PMF_NO_PREDICTION; + + if( level.playerfrozen || m_bFrozen ) + { + client->ps.pm_flags |= PMF_FROZEN; + } + + if( !m_pTurret->IsSubclassOfTurretGun() || ( m_pTurret->IsSubclassOfTurretGun() && m_pTurret->UserAim( ucmd ) ) ) + { + ClientMove( ucmd ); + } + else + { + client->ps.commandTime = ucmd->serverTime; + } +} + +void Player::ClientInactivityTimer + ( + void + ) + +{ + if( !g_gametype->integer ) + return; + + if( g_inactivekick->integer && g_inactivekick->integer < 60 ) + gi.Cvar_Set( "g_inactiveKick", "60" ); + + if( g_inactivespectate->integer && g_inactivespectate->integer < 20 ) + gi.Cvar_Set( "g_inactiveSpectate", "20" ); + + if( current_ucmd->buttons & BUTTON_MOUSE || + ( !g_inactivespectate->integer && !g_inactivekick->integer ) || + current_ucmd->upmove ) + { + client->lastActiveTime = level.inttime; + client->activeWarning = 0; + return; + } + + if( m_bTempSpectator ) + { + if( client->lastActiveTime >= level.inttime - 5000 ) + { + client->lastActiveTime = level.inttime; + client->activeWarning = 0; + } + } + + if( g_inactivekick->integer && client->lastActiveTime < level.inttime - 1000 * g_inactivekick->integer ) + { + const char *s = Info_ValueForKey( client->pers.userinfo, "ip" ); + + if( strcmp( s, "localhost" ) ) + { + gi.DropClient( client->ps.clientNum, "was dropped for inactivity" ); + return; + } + + if( m_bSpectator ) + return; + + SetTeam( TEAM_SPECTATOR ); + + if( deadflag ) + deadflag = DEAD_DEAD; + + PostEvent( EV_Player_Respawn, 0 ); + return; + } + + if( g_inactivespectate->integer && + client->lastActiveTime < level.inttime - g_inactivespectate->integer * 1000 && + !m_bSpectator ) + { + SetTeam( TEAM_SPECTATOR ); + + if( deadflag ) + deadflag = 2; + + PostEvent( EV_Player_Respawn, 0 ); + } + + if( g_inactivekick->integer ) + { + static struct { + int iLevel; + int iTime; + } warnkick[ 7 ] = + { + 1, 30, + 8, 15, + 9, 5, + 10, 4, + 11, 3, + 12, 2, + 13, 1 + }; + + int iKickWait = g_inactivekick->integer - ( level.inttime - client->lastActiveTime ) / 1000 - 1; + + for( int i = 0; i < 7; i++ ) + { + if( client->activeWarning < warnkick[ i ].iLevel && + iKickWait < warnkick[ i ].iTime ) + { + client->activeWarning = warnkick[ i ].iLevel; + + gi.centerprintf( edict, "%s %i %s", + gi.LV_ConvertString( "You will be kicked for inactivity in" ), + warnkick[ i ].iTime, + gi.LV_ConvertString( "seconds" ) ); + + return; + } + } + } + + if( g_inactivespectate->integer && dm_team != TEAM_SPECTATOR ) + { + static struct { + int iLevel; + int iTime; + } warnspectate[ 6 ] = + { + 2, 15, + 3, 5, + 4, 4, + 5, 3, + 6, 2, + 7, 1 + }; + + int iSpectateWait = g_inactivespectate->integer - ( level.inttime - client->lastActiveTime ) / 1000 - 1; + + for( int i = 0; i < 6; i++ ) + { + if( client->activeWarning < warnspectate[ i ].iLevel && + iSpectateWait < warnspectate[ i ].iTime ) + { + client->activeWarning = warnspectate[ i ].iLevel; + + gi.centerprintf( edict, "%s %i %s", + gi.LV_ConvertString( "You will be moved to spectator for inactivity in" ), + warnspectate[ i ].iTime, + gi.LV_ConvertString( "seconds" ) ); + + return; + } + } + } +} + +/* +============== +ClientThink + +This will be called once for each client frame, which will +usually be a couple times for each server frame. +============== +*/ +void Player::ClientThink + ( + void + ) + +{ + // sanity check the command time to prevent speedup cheating + if( current_ucmd->serverTime > level.svsTime ) + { + // + // we don't want any future commands, these could be from the previous game + // + return; + } + + if( current_ucmd->serverTime < level.svsTime - 1000 ) + { + current_ucmd->serverTime = level.svsTime - 1000; + } + + if( ( current_ucmd->serverTime - client->ps.commandTime ) < 1 ) + { + return; + } + + last_ucmd = *current_ucmd; + server_new_buttons |= current_ucmd->buttons & ~buttons; + new_buttons = current_ucmd->buttons & ~buttons; + buttons = current_ucmd->buttons; + + if( camera ) + { + m_vViewPos = camera->origin; + m_vViewAng = camera->angles; + } + else + { + m_vViewPos[ 0 ] = ( float )current_eyeinfo->ofs[ 0 ] + origin[ 0 ]; + m_vViewPos[ 1 ] = ( float )current_eyeinfo->ofs[ 1 ] + origin[ 1 ]; + m_vViewPos[ 2 ] = ( float )current_eyeinfo->ofs[ 2 ] + origin[ 2 ]; + + m_vViewAng[ 0 ] = current_eyeinfo->angles[ 0 ]; + m_vViewAng[ 1 ] = current_eyeinfo->angles[ 1 ]; + m_vViewAng[ 2 ] = 0.0f; + } + + VectorCopy( m_vViewPos, client->ps.vEyePos ); + + if( level.intermissiontime ) + { + if( g_gametype->integer ) + { + client->ps.pm_flags |= PMF_FROZEN; + client->ps.pm_flags |= PMF_INTERMISSION; + + if( level.time - level.intermissiontime > 5.0f && ( new_buttons & ( BUTTON_ATTACK | BUTTON_ATTACK2 ) ) ) + { + level.exitintermission = true; + } + } + else + { + if( level.intermissiontype == TRANS_MISSION_FAILED ) + { + gi.Cvar_Set( "g_success", "0" ); + } + else + { + gi.Cvar_Set( "g_success", "1" ); + } + + gi.Cvar_Set( "g_failed", "0" ); + + // prevent getting medals from cheats + if( g_medal0->modificationCount > 1 || + g_medal1->modificationCount > 1 || + g_medal2->modificationCount > 1 || + g_medal3->modificationCount > 1 || + g_medal4->modificationCount > 1 || + g_medal5->modificationCount > 1 || + g_eogmedal0->modificationCount > 1 || + g_eogmedal1->modificationCount > 1 || + g_eogmedal2->modificationCount > 1 + ) + { + gi.Cvar_Set( "g_gotmedal", "0" ); + } + else + { + gi.Cvar_Set( "g_gotmedal", "1" ); + } + + if( level.time - level.intermissiontime > 4.0f ) + { + if( level.intermissiontype ) + { + if( ( new_buttons & BUTTON_ATTACK ) || ( new_buttons & BUTTON_ATTACK2 ) ) + { + if( level.intermissiontype == TRANS_MISSION_FAILED ) + { + G_MissionFailed(); + } + else + { + g_medal0->modificationCount = 1; + g_medal1->modificationCount = 1; + g_medal2->modificationCount = 1; + g_medal3->modificationCount = 1; + g_medal4->modificationCount = 1; + g_medal5->modificationCount = 1; + g_eogmedal0->modificationCount = 1; + g_eogmedal1->modificationCount = 1; + g_eogmedal2->modificationCount = 1; + g_medal0->modified = false; + g_medal1->modified = false; + g_medal2->modified = false; + g_medal3->modified = false; + g_medal4->modified = false; + g_medal5->modified = false; + g_eogmedal0->modified = false; + g_eogmedal1->modified = false; + g_eogmedal2->modified = false; + + level.exitintermission = true; + } + } + } + else + { + level.exitintermission = true; + } + } + } + + // Save cmd angles so that we can get delta angle movements next frame + client->cmd_angles[ 0 ] = SHORT2ANGLE( current_ucmd->angles[ 0 ] ); + client->cmd_angles[ 1 ] = SHORT2ANGLE( current_ucmd->angles[ 1 ] ); + client->cmd_angles[ 2 ] = SHORT2ANGLE( current_ucmd->angles[ 2 ] ); + + return; + } + + if( new_buttons & BUTTON_ATTACK2 ) + { + Weapon *weapon = GetActiveWeapon( WEAPON_MAIN ); + + if( ( weapon ) && ( weapon->GetZoom() ) ) + { + if( ( weapon->GetZoom() == fov ) && m_iInZoomMode == -1 ) + { + SetFov( selectedfov ); + m_iInZoomMode = 0; + } + else + { + SetFov( weapon->GetZoom() ); + m_iInZoomMode = -1; + } + } + } + + if( new_buttons & BUTTON_USE ) + { + DoUse( NULL ); + } + + moveresult = MOVERESULT_NONE; + + if( m_pTurret ) + { + TurretMove( current_ucmd ); + } + else if( m_pVehicle ) + { + VehicleMove( current_ucmd ); + } + else + { + ClientMove( current_ucmd ); + } + + // Save cmd angles so that we can get delta angle movements next frame + client->cmd_angles[ 0 ] = SHORT2ANGLE( current_ucmd->angles[ 0 ] ); + client->cmd_angles[ 1 ] = SHORT2ANGLE( current_ucmd->angles[ 1 ] ); + client->cmd_angles[ 2 ] = SHORT2ANGLE( current_ucmd->angles[ 2 ] ); + + ClientInactivityTimer(); + + if( g_gametype->integer && g_smoothClients->integer && !IsSubclassOfBot() ) + { + VectorCopy( client->ps.velocity, edict->s.pos.trDelta ); + edict->s.pos.trTime = client->ps.commandTime; + } + else + { + VectorClear( edict->s.pos.trDelta ); + edict->s.pos.trTime = 0; + } +} + +void Player::UpdateEnemies + ( + void + ) + +{ + float fFov; + float fMaxDist; + float fMaxCosSquared; + Vector vLookDir; + + if( g_gametype->integer ) + { + return; + } + + if( m_pNextSquadMate == this ) + { + return; + } + + fFov = fov * 0.9f; + fMaxDist = world->farplane_distance * 0.7867f; + fMaxCosSquared = 0.0f; + + AngleVectors( m_vViewAng, vLookDir, NULL, NULL ); + + if( m_Enemy ) + { + m_Enemy->m_iAttackerCount -= 3; + m_Enemy = NULL; + } + + for( Sentient *obj = level.m_HeadSentient[ 0 ]; obj != NULL; obj = obj->m_NextSentient ) + { + Vector vDelta; + float fDot; + float fDotSquared; + + if( CanSee( obj, fFov, fMaxDist ) ) + { + obj->m_fPlayerSightLevel += level.frametime; + + vDelta = obj->origin - origin; + fDot = DotProduct( vDelta, vLookDir ); + fDotSquared = fDot * fDot; + + if( fDotSquared > fMaxCosSquared * vDelta.lengthSquared() ) + { + fMaxCosSquared = fDotSquared / vDelta.lengthSquared(); + m_Enemy = obj; + } + } + else + { + obj->m_fPlayerSightLevel = 0.0f; + } + } + + if( m_Enemy ) + { + m_Enemy->m_iAttackerCount += 3; + } +} + +void Player::Think + ( + void + ) + +{ + static cvar_t *g_aimLagTime = NULL; + + int m_iClientWeaponCommand; + Event *m_pWeaponCommand = NULL; + Weapon *pWeap; + + edict->s.eFlags &= ~EF_UNARMED; + + if( whereami->integer && + origin != oldorigin ) + { + gi.DPrintf( "x %8.2f y %8.2f z %8.2f area %2d\n", origin[ 0 ], origin[ 1 ], origin[ 2 ], edict->r.areanum ); + } + + if( !g_gametype->integer && g_playermodel->modified ) + { + setModel( "models/player/" + str( g_playermodel->string ) + ".tik" ); + + if( !edict->tiki ) + { + setModel( "models/player/american_army.tik" ); + } + + g_playermodel->modified = qfalse; + } + + if( !g_gametype->integer ) + { + m_bIsDisguised = false; + + if( m_bHasDisguise && !level.m_bAlarm ) + { + pWeap = GetActiveWeapon( WEAPON_MAIN ); + + if( !pWeap || pWeap->IsSubclassOfInventoryItem() ) + { + m_bIsDisguised = true; + + for( Sentient *pSent = level.m_HeadSentient[ 0 ]; pSent != NULL; pSent = pSent->m_NextSentient ) + { + Actor *act = ( Actor * )pSent; + + if( pSent->m_Enemy == this && act->m_ThinkStates[ 0 ] == THINKSTATE_ATTACK ) + { + m_bIsDisguised = false; + break; + } + } + } + } + + PathSearch::PlayerCover( this ); + UpdateEnemies(); + } + + if( movetype == MOVETYPE_NOCLIP ) + { + StopPartAnimating( torso ); + SetPartAnim( "idle" ); + + client->ps.walking = qfalse; + groundentity = 0; + } + else + { + CheckMoveFlags(); + EvaluateState(); + } + + oldvelocity = velocity; + old_v_angle = v_angle; + + if( ( !g_gametype->integer ) && + ( ( server_new_buttons & BUTTON_ATTACK ) || ( server_new_buttons & BUTTON_ATTACK2 ) ) && + ( !GetActiveWeapon( WEAPON_MAIN ) ) && + ( !IsDead() ) && + ( !IsNewActiveWeapon() ) && + ( !LoadingSavegame ) ) + { + Event *ev = new Event( "useweaponclass" ); + ev->AddString( "item1" ); + + ProcessEvent( ev ); + } + + if( deadflag == DEAD_DEAD && level.time >= respawn_time ) + { + if( dmManager.AllowRespawn() ) + { + if( ( ( server_new_buttons & BUTTON_ATTACK ) || ( server_new_buttons & BUTTON_ATTACK2 ) ) || + g_forcerespawn->integer > 0 && level.time > g_forcerespawn->integer + respawn_time ) + { + m_bSpectator = false; + m_bTempSpectator = false; + client->ps.pm_flags &= ~PMF_SPECTATING; + PostEvent( EV_Player_Respawn, 0 ); + } + } + else + { + if( !IsSpectator() ) + { + BeginTempSpectator(); + } + } + } + + if( IsSpectator() && !m_bTempSpectator ) + { + if( level.time <= respawn_time || ( !( server_new_buttons & BUTTON_ATTACK ) || ( server_new_buttons & BUTTON_ATTACK2 ) ) ) + { + if( level.time - 10.0f > m_fWeapSelectTime ) + { + m_fWeapSelectTime = level.time; + gi.centerprintf( edict, gi.LV_ConvertString( "Press fire to join the battle!" ) ); + } + } + else if( !current_team || dm_team == TEAM_SPECTATOR ) + { + gi.SendServerCommand( edict - g_entities, "stufftext \"pushmenu_teamselect\"" ); + } + else if( !client->pers.weapon[ 0 ] ) + { + if( level.time > m_fWeapSelectTime ) + { + m_fWeapSelectTime = level.time + 1.0f; + gi.SendServerCommand( edict - g_entities, "stufftext \"pushmenu_weaponselect\"" ); + } + } + else if( ( g_gametype->integer == GT_FFA || + ( g_gametype->integer && dm_team > TEAM_FREEFORALL ) ) && + ( deadflag != DEAD_DEAD ) ) + { + m_bSpectator = false; + m_bTempSpectator = false; + client->ps.pm_flags &= ~PMF_SPECTATING; + + if( deadflag ) { + deadflag = DEAD_DEAD; + } + + PostEvent( EV_Player_Respawn, 0 ); + } + } + else if( !client->pers.weapon[ 0 ] ) + { + Spectator(); + gi.SendServerCommand( edict - g_entities, "stufftext \"pushmenu_weaponselect\"" ); + } + + if( IsSpectator() ) + { + if( ( server_new_buttons & BUTTON_USE ) ) + { + SetPlayerSpectate(); + } + + if( ( g_gametype->integer <= GT_FFA ) || + ( !g_forceteamspectate->integer ) || + ( dm_team <= TEAM_FREEFORALL ) ) + { + if( last_ucmd.upmove ) + { + m_iPlayerSpectating = 0; + } + + if( m_iPlayerSpectating ) + { + gentity_t *ent = g_entities + m_iPlayerSpectating - 1; + Player *player = ( Player * )ent->entity; + + if( ( !ent->inuse ) || + ( !player ) || + ( player->deadflag >= DEAD_DEAD ) || + ( + ( player->IsSpectator() ) || + ( + g_gametype->integer > GT_FFA && + g_forceteamspectate->integer && + dm_team > TEAM_FREEFORALL && + player->GetTeam() != GetTeam() + ) + ) ) + { + SetPlayerSpectate(); + } + + } + } + else + { + if( !m_iPlayerSpectating ) + { + SetPlayerSpectate(); + } + else + { + gentity_t *ent = g_entities + m_iPlayerSpectating - 1; + Player *player = ( Player * )ent->entity; + + if( !ent->inuse ) + { + SetPlayerSpectate(); + } + else if( !player ) + { + SetPlayerSpectate(); + } + else if( player->deadflag >= DEAD_DEAD ) + { + SetPlayerSpectate(); + } + else if( player->IsSpectator() ) + { + SetPlayerSpectate(); + } + else if( g_gametype->integer > GT_FFA ) + { + if( ( dm_team > TEAM_FREEFORALL ) && + ( g_forceteamspectate->integer ) && + ( GetDM_Team()->NumLivePlayers() ) && + ( player->GetTeam() != GetTeam() ) ) + { + SetPlayerSpectate(); + } + } + } + } + } + else + { + m_iPlayerSpectating = 0; + } + + if( g_logstats->integer ) + { + if( !logfile_started ) + { + ProcessEvent( EV_Player_LogStats ); + logfile_started = qtrue; + } + } + + if( !IsDead() ) + { + + m_iClientWeaponCommand = ( server_new_buttons & 0x780 ) >> 7; + + switch( m_iClientWeaponCommand ) + { + case 0: + break; + case 1: + m_pWeaponCommand = new Event( EV_Sentient_UseWeaponClass ); + m_pWeaponCommand->AddString( "pistol" ); + break; + case 2: + m_pWeaponCommand = new Event( EV_Sentient_UseWeaponClass ); + m_pWeaponCommand->AddString( "rifle" ); + break; + case 3: + m_pWeaponCommand = new Event( EV_Sentient_UseWeaponClass ); + m_pWeaponCommand->AddString( "smg" ); + break; + case 4: + m_pWeaponCommand = new Event( EV_Sentient_UseWeaponClass ); + m_pWeaponCommand->AddString( "mg" ); + break; + case 5: + m_pWeaponCommand = new Event( EV_Sentient_UseWeaponClass ); + m_pWeaponCommand->AddString( "grenade" ); + break; + case 6: + m_pWeaponCommand = new Event( EV_Sentient_UseWeaponClass ); + m_pWeaponCommand->AddString( "heavy" ); + break; + case 7: + m_pWeaponCommand = new Event( EV_Sentient_ToggleItemUse ); + break; + case 8: + m_pWeaponCommand = new Event( EV_Sentient_UseWeaponClass ); + m_pWeaponCommand->AddString( "item2" ); + break; + case 9: + m_pWeaponCommand = new Event( EV_Sentient_UseWeaponClass ); + m_pWeaponCommand->AddString( "item3" ); + break; + case 10: + m_pWeaponCommand = new Event( EV_Sentient_UseWeaponClass ); + m_pWeaponCommand->AddString( "item4" ); + break; + case 11: + m_pWeaponCommand = new Event( EV_Player_PrevWeapon ); + break; + case 12: + m_pWeaponCommand = new Event( EV_Player_NextWeapon ); + break; + case 13: + m_pWeaponCommand = new Event( EV_Sentient_UseLastWeapon ); + break; + case 14: + m_pWeaponCommand = new Event( EV_Player_Holster ); + break; + case 15: + m_pWeaponCommand = new Event( EV_Player_DropWeapon ); + break; + default: + gi.DPrintf( "Unrecognized weapon command %d\n", m_iClientWeaponCommand ); + } + + if( m_pWeaponCommand ) + { + ProcessEvent( m_pWeaponCommand ); + } + } + + if( !g_aimLagTime ) + { + g_aimLagTime = gi.Cvar_Get( "g_aimLagTime", "250", 0 ); + } + + if( mLastTrailTime + g_aimLagTime->integer < level.inttime ) + { + mLastTrailTime = level.inttime; + + mvTrail[ 0 ] = centroid; + mvTrailEyes[ 0 ] = centroid; + mvTrailEyes[ 0 ][ 0 ] = EyePosition()[ 0 ]; + } + + UpdateFootsteps(); + + if( !animDoneVM ) + { + int index; + float anim_time; + vma_t *vma = vmalist.find( m_sVMcurrent ); + + index = m_fpsTiki == NULL ? -1 : gi.Anim_NumForName( m_fpsTiki, m_sVMAcurrent ); + + if( index >= 0 ) + { + anim_time = gi.Anim_Time( m_fpsTiki, index ); + + if( m_fVMAtime < anim_time ) + { + if( vma ) + { + m_fVMAtime += level.frametime * vma->speed; + } + else + { + m_fVMAtime += level.frametime; + } + } + else + { + animDoneVM = true; + m_fVMAtime = 0; + + Notify( "viewmodelanim_done" ); + } + } + else + { + animDoneVM = true; + m_fVMAtime = 0; + + Notify( "viewmodelanim_done" ); + } + } + + server_new_buttons = 0; +} + +void Player::Postthink + ( + void + ) + +{ + if( bindmaster ) + { + SetViewAngles( GetViewAngles() + Vector( 0, bindmaster->avelocity[ YAW ] * level.frametime, 0 ) ); + } +} + +void Player::InitLegsStateTable( void ) +{ + animdone_Legs = false; + currentState_Legs = statemap_Legs->FindState( "STAND" ); + + str legsAnim( currentState_Legs->getLegAnim( *this, &legs_conditionals ) ); + if( legsAnim == "" ) + { + StopPartAnimating( legs ); + } + else if( legsAnim != "none" ) + { + SetPartAnim( legsAnim.c_str(), legs ); + } +} + +void Player::InitTorsoStateTable( void ) +{ + animdone_Torso = false; + + currentState_Torso = statemap_Torso->FindState( "STAND" ); + + str torsoAnim( currentState_Torso->getActionAnim( *this, &torso_conditionals ) ); + if( torsoAnim == "" ) + { + StopPartAnimating( torso ); + } + else if( torsoAnim != "none" ) + { + SetPartAnim( torsoAnim.c_str(), torso ); + } +} + +void Player::LoadStateTable( void ) +{ + statemap_Legs = NULL; + statemap_Torso = NULL; + + legs_conditionals.FreeObjectList(); + torso_conditionals.FreeObjectList(); + + statemap_Legs = GetStatemap( str( g_statefile->string ) + "_Legs.st", ( Condition * )Conditions, &legs_conditionals, false ); + statemap_Torso = GetStatemap( str( g_statefile->string ) + "_Torso.st", ( Condition * )Conditions, &torso_conditionals, false ); + + movecontrol = MOVECONTROL_LEGS; + + InitLegsStateTable(); + InitTorsoStateTable(); + + movecontrol = currentState_Legs->getMoveType(); + if( !movecontrol ) { + movecontrol = MOVECONTROL_LEGS; + } + + for( int i = 1; i <= legs_conditionals.NumObjects(); i++ ) + { + Conditional *c = legs_conditionals.ObjectAt( i ); + + if( Q_stricmp( c->getName(), "PAIN" ) && !c->parmList.NumObjects() ) + { + m_pLegsPainCond = c; + break; + } + } + + for( int i = 1; i <= torso_conditionals.NumObjects(); i++ ) + { + Conditional *c = torso_conditionals.ObjectAt( i ); + + if( Q_stricmp( c->getName(), "PAIN" ) && !c->parmList.NumObjects() ) + { + m_pTorsoPainCond = c; + break; + } + } + + if( ( movecontrol < ( sizeof( MoveStartFuncs ) / sizeof( MoveStartFuncs[ 0 ] ) ) ) && ( MoveStartFuncs[ movecontrol ] ) ) + { + ( this->*MoveStartFuncs[ movecontrol ] )( ); + } + + SetViewAngles( v_angle ); +} + +void Player::ResetState + ( + Event *ev + ) + +{ + movecontrol = MOVECONTROL_LEGS; + LoadStateTable(); +} + +void Player::StartPush + ( + void + ) + + { + trace_t trace; + Vector end( origin + yaw_forward * 64.0f ); + + trace = G_Trace( origin, mins, maxs, end, this, MASK_SOLID, true, "StartPush" ); + if ( trace.fraction == 1.0f ) + { + return; + } + v_angle.y = vectoyaw( trace.plane.normal ) - 180; + SetViewAngles( v_angle ); + + setOrigin( trace.endpos - yaw_forward * 0.4f ); + } + +void Player::StartClimbWall + ( + void + ) + + { + trace_t trace; + Vector end( origin + yaw_forward * 20.0f ); + + trace = G_Trace( origin, mins, maxs, end, this, MASK_SOLID, true, "StartClimbWall" ); + if ( ( trace.fraction == 1.0f ) || !( trace.surfaceFlags & SURF_LADDER ) ) + { + return; + } + + v_angle.y = vectoyaw( trace.plane.normal ) - 180; + SetViewAngles( v_angle ); + + setOrigin( trace.endpos - yaw_forward * 0.4f ); + } + +void Player::StartUseAnim + ( + void + ) + +{ + UseAnim *ua; + Vector neworg; + Vector newangles; + str newanim; + str state; + str camera; + trace_t trace; + + if( toucheduseanim ) + { + ua = ( UseAnim * )( Entity * )toucheduseanim; + } + else if( atobject ) + { + ua = ( UseAnim * )( Entity * )atobject; + } + else + { + return; + } + + useitem_in_use = ua; + toucheduseanim = NULL; + atobject = NULL; + + if( ua->GetInformation( this, &neworg, &newangles, &newanim, &useanim_numloops, &state, &camera ) ) + { + trace = G_Trace( origin, mins, maxs, neworg, this, MASK_PLAYERSOLID, true, "StartUseAnim" ); + if( trace.startsolid || ( trace.fraction < 1.0f ) ) + { + gi.DPrintf( "Move to UseAnim was blocked.\n" ); + } + + if( !trace.startsolid ) + { + setOrigin( trace.endpos ); + } + + setAngles( newangles ); + v_angle.y = newangles.y; + SetViewAngles( v_angle ); + + movecontrol = MOVECONTROL_ABSOLUTE; + + if( state.length() ) + { + State * newState; + + newState = statemap_Torso->FindState( state ); + if( newState ) + { + EvaluateState( newState ); + } + else + { + gi.DPrintf( "Could not find state %s on UseAnim\n", state.c_str() ); + } + } + else + { + if( currentState_Torso ) + { + if( camera.length() ) + { + currentState_Torso->setCameraType( camera ); + } + else + { + currentState_Torso->setCameraType( "behind" ); + } + } + SetPartAnim( newanim, legs ); + } + } +} + +void Player::StartLoopUseAnim + ( + void + ) + + { + useanim_numloops--; + } + +void Player::FinishUseAnim + ( + Event *ev + ) + + { + UseAnim *ua; + + if ( !useitem_in_use ) + return; + + ua = ( UseAnim * )( Entity * )useitem_in_use; + ua->TriggerTargets( this ); + useitem_in_use = NULL; + } + +void Player::SetupUseObject + ( + void + ) + + { + UseObject *uo; + Vector neworg; + Vector newangles; + str state; + trace_t trace; + + if ( atobject ) + { + uo = ( UseObject * )( Entity * )atobject; + } + else + { + return; + } + + useitem_in_use = uo; + + uo->Setup( this, &neworg, &newangles, &state ); + { + trace = G_Trace( neworg, mins, maxs, neworg, this, MASK_PLAYERSOLID, true, "SetupUseObject - 1" ); + if ( trace.startsolid || trace.allsolid ) + { + trace = G_Trace( origin, mins, maxs, neworg, this, MASK_PLAYERSOLID, true, "SetupUseObject - 2" ); + if ( trace.startsolid || ( trace.fraction < 1.0f ) ) + { + gi.DPrintf( "Move to UseObject was blocked.\n" ); + } + } + + if ( !trace.startsolid ) + { + setOrigin( trace.endpos ); + } + + setAngles( newangles ); + v_angle.y = newangles.y; + SetViewAngles( v_angle ); + + movecontrol = MOVECONTROL_ABSOLUTE; + + if ( state.length() ) + { + State * newState; + + newState = statemap_Torso->FindState( state ); + if ( newState ) + { + EvaluateState( newState ); + } + else + { + gi.DPrintf( "Could not find state %s on UseObject\n", state.c_str() ); + } + } + } + } + +void Player::StartUseObject + ( + Event *ev + ) + + { + UseObject *uo; + + if ( !useitem_in_use ) + return; + + uo = ( UseObject * )( Entity * )useitem_in_use; + uo->Start(); + } + +void Player::FinishUseObject + ( + Event *ev + ) + + { + UseObject *uo; + + if ( !useitem_in_use ) + return; + + uo = ( UseObject * )( Entity * )useitem_in_use; + uo->Stop( this ); + useitem_in_use = NULL; + } + +void Player::Turn + ( + Event *ev + ) + + { + float yaw; + Vector oldang( v_angle ); + + yaw = ev->GetFloat( 1 ); + + v_angle[ YAW ] = ( int )( anglemod( v_angle[ YAW ] ) / 22.5f ) * 22.5f; + SetViewAngles( v_angle ); + + if ( !CheckMove( vec_zero ) ) + { + SetViewAngles( oldang ); + return; + } + + CancelEventsOfType( EV_Player_TurnUpdate ); + + ev = new Event( EV_Player_TurnUpdate ); + ev->AddFloat( yaw / 5.0f ); + ev->AddFloat( 0.5f ); + ProcessEvent( ev ); + } + +void Player::TurnUpdate + ( + Event *ev + ) + + { + float yaw; + float timeleft; + Vector oldang( v_angle ); + + yaw = ev->GetFloat( 1 ); + timeleft = ev->GetFloat( 2 ); + timeleft -= 0.1f; + + if ( timeleft > 0 ) + { + ev = new Event( EV_Player_TurnUpdate ); + ev->AddFloat( yaw ); + ev->AddFloat( timeleft ); + PostEvent( ev, 0.1f ); + + v_angle[ YAW ] += yaw; + SetViewAngles( v_angle ); + } + else + { + v_angle[ YAW ] = ( int )( anglemod( v_angle[ YAW ] ) / 22.5f ) * 22.5f; + SetViewAngles( v_angle ); + } + + if ( !CheckMove( vec_zero ) ) + { + SetViewAngles( oldang ); + } + } + +void Player::TurnLegs + ( + Event *ev + ) + + { + float yaw; + + yaw = ev->GetFloat( 1 ); + + angles[ YAW ] += yaw; + setAngles( angles ); + } + +void Player::EvaluateState + ( + State *forceTorso, + State *forceLegs + ) + +{ + int count; + State *laststate_Legs; + State *laststate_Torso; + State *startstate_Legs; + State *startstate_Torso; + movecontrol_t move; + + if( getMoveType() == MOVETYPE_NOCLIP ) + { + return; + } + + // Evaluate the current state. + // When the state changes, we reevaluate the state so that if the + // conditions aren't met in the new state, we don't play one frame of + // the animation for that state before going to the next state. + startstate_Torso = laststate_Torso = currentState_Torso; + count = 0; + do + { + // since we could get into an infinite loop here, do a check + // to make sure we don't. + count++; + if( count > 10 ) + { + gi.DPrintf( "Possible infinite loop in state '%s'\n", currentState_Torso->getName() ); + if( count > 20 ) + { + assert( 0 ); + gi.Error( ERR_DROP, "Stopping due to possible infinite state loop\n" ); + break; + } + } + + laststate_Torso = currentState_Torso; + + if( forceTorso ) + currentState_Torso = forceTorso; + else + currentState_Torso = currentState_Torso->Evaluate( *this, &torso_conditionals ); + + if( currentState_Torso ) + { + // Process exit commands of the last state + laststate_Torso->ProcessExitCommands( this ); + + // Process entry commands of the new state + currentState_Torso->ProcessEntryCommands( this ); + + if( waitForState.length() && ( !waitForState.icmpn( currentState_Torso->getName(), waitForState.length() ) ) ) + { + waitForState = ""; + PlayerDone( NULL ); + } + + + move = currentState_Torso->getMoveType(); + + // use the current movecontrol + if( move == MOVECONTROL_NONE ) { + move = movecontrol; + } + + str legsAnim; + str torsoAnim( currentState_Torso->getActionAnim( *this, &torso_conditionals ) ); + + if( move == MOVECONTROL_LEGS ) + { + if( !currentState_Legs ) + { + animdone_Legs = false; + currentState_Legs = statemap_Legs->FindState( "STAND" ); + legsAnim = currentState_Legs->getLegAnim( *this, &legs_conditionals ); + + if( legsAnim == "" ) + { + StopPartAnimating( legs ); + } + else if( legsAnim != "none" ) + { + SetPartAnim( legsAnim.c_str(), legs ); + } + } + + if( torsoAnim == "none" ) + { + StopPartAnimating( torso ); + animdone_Torso = true; + } + else if( torsoAnim != "" ) + { + SetPartAnim( torsoAnim.c_str(), torso ); + } + } + else + { + if( torsoAnim == "none" ) + { + StopPartAnimating( torso ); + animdone_Torso = true; + } + else if( torsoAnim != "" ) + { + SetPartAnim( torsoAnim.c_str(), torso ); + } + + legsAnim = currentState_Torso->getLegAnim( *this, &torso_conditionals ); + + if( legsAnim == "none" || legsAnim == "" ) + { + StopPartAnimating( legs ); + } + else + { + SetPartAnim( legsAnim.c_str(), legs ); + } + } + + if( movecontrol != move ) + { + movecontrol = move; + if( ( move < ( sizeof( MoveStartFuncs ) / sizeof( MoveStartFuncs[ 0 ] ) ) ) && ( MoveStartFuncs[ move ] ) ) + { + ( this->*MoveStartFuncs[ move ] )( ); + } + + if( movecontrol == MOVECONTROL_CLIMBWALL ) + { + edict->s.eFlags |= EF_CLIMBWALL; + } + else + { + edict->s.eFlags &= ~EF_CLIMBWALL; + } + } + + SetViewAngles( v_angle ); + } + else + { + currentState_Torso = laststate_Torso; + } + } while( laststate_Torso != currentState_Torso ); + + // Evaluate the current state. + // When the state changes, we reevaluate the state so that if the + // conditions aren't met in the new state, we don't play one frame of + // the animation for that state before going to the next state. + startstate_Legs = laststate_Legs = currentState_Legs; + if( movecontrol == MOVECONTROL_LEGS ) + { + count = 0; + do + { + // since we could get into an infinite loop here, do a check + // to make sure we don't. + count++; + if( count > 10 ) + { + gi.DPrintf( "Possible infinite loop in state '%s'\n", currentState_Legs->getName() ); + if( count > 20 ) + { + assert( 0 ); + gi.Error( ERR_DROP, "Stopping due to possible infinite state loop\n" ); + break; + } + } + + if( !laststate_Legs ) + { + if( ( m_iMovePosFlags & MPF_POSITION_CROUCHING ) ) + currentState_Legs = statemap_Legs->FindState( "CROUCH_IDLE" ); + else + currentState_Legs = statemap_Legs->FindState( "STAND" ); + } + + laststate_Legs = currentState_Legs; + + if( forceLegs ) + currentState_Legs = forceLegs; + else + currentState_Legs = currentState_Legs->Evaluate( *this, &legs_conditionals ); + + animdone_Legs = false; + if( currentState_Legs ) + { + // Process exit commands of the last state + laststate_Legs->ProcessExitCommands( this ); + + // Process entry commands of the new state + currentState_Legs->ProcessEntryCommands( this ); + + if( waitForState.length() && ( !waitForState.icmpn( currentState_Legs->getName(), waitForState.length() ) ) ) + { + waitForState = ""; + PlayerDone( NULL ); + } + + str legsAnim( currentState_Legs->getLegAnim( *this, &legs_conditionals ) ); + + if( legsAnim == "none" ) + { + StopPartAnimating( legs ); + animdone_Legs = true; + } + else if( legsAnim != "" ) + { + SetPartAnim( legsAnim, legs ); + } + } + else + { + currentState_Legs = laststate_Legs; + } + } while( laststate_Legs != currentState_Legs ); + } + else + { + currentState_Legs = NULL; + } + + if( g_showplayeranim->integer ) + { + if( last_leg_anim_name != AnimName( legs ) ) + { + gi.DPrintf( "Legs change from %s to %s\n", last_leg_anim_name.c_str(), AnimName( legs ) ); + last_leg_anim_name = AnimName( legs ); + } + + if( last_torso_anim_name != AnimName( torso ) ) + { + gi.DPrintf( "Torso change from %s to %s\n", last_torso_anim_name.c_str(), AnimName( torso ) ); + last_torso_anim_name = AnimName( torso ); + } + } + + if( g_showplayerstate->integer ) + { + if( startstate_Legs != currentState_Legs ) + { + gi.DPrintf( "Legs change from %s to %s\n", + startstate_Legs ? startstate_Legs->getName() : "NULL", + currentState_Legs ? currentState_Legs->getName() : "NULL" ); + } + + if( startstate_Torso != currentState_Torso ) + { + gi.DPrintf( "Torso change from %s to %s\n", + startstate_Torso ? startstate_Torso->getName() : "NULL", + currentState_Torso ? currentState_Torso->getName() : "NULL" ); + } + } + + // This is so we don't remember pain when we change to a state that has a PAIN condition + pain = 0; +} + +void Player::GiveWeaponCheat + ( + Event *ev + ) + + { + giveItem( ev->GetString( 1 ) ); + } + +void Player::GiveCheat + ( + Event *ev + ) + + { + str name; + + if ( deadflag ) + { + return; + } + + name = ev->GetString( 1 ); + + if ( !name.icmp( "all" ) ) + { + GiveAllCheat( ev ); + return; + } + EventGiveItem( ev ); + } + +void Player::GiveAllCheat + ( + Event *ev + ) + + { + char *buffer; + char *buf; + char com_token[MAX_STRING_CHARS]; + + if ( deadflag ) + { + return; + } + + if ( gi.FS_ReadFile( "global/giveall.scr", ( void ** )&buf, true ) != -1 ) + { + buffer = buf; + while ( 1 ) + { + strcpy( com_token, COM_ParseExt( &buffer, qtrue ) ); + + if (!com_token[0]) + break; + + // Create the event + ev = new Event( com_token ); + + // get the rest of the line + while( 1 ) + { + strcpy( com_token, COM_ParseExt( &buffer, qfalse ) ); + if (!com_token[0]) + break; + + ev->AddToken( com_token ); + } + + this->ProcessEvent( ev ); + } + gi.FS_FreeFile( buf ); + } + } + +void Player::GodCheat + ( + Event *ev + ) + + { + const char *msg; + + if ( ev->NumArgs() > 0 ) + { + if ( ev->GetInteger( 1 ) ) + { + flags |= FL_GODMODE; + } + else + { + flags &= ~FL_GODMODE; + } + } + else + { + flags ^= FL_GODMODE; + } + + if ( !ev->IsFromScript() ) + { + if( !( flags & FL_GODMODE ) ) + { + msg = "godmode OFF\n"; + } + else + { + msg = "godmode ON\n"; + } + + gi.SendServerCommand( edict-g_entities, "print \"%s\"", msg ); + } + } + + + +void Player::FullHeal + ( + Event *ev + ) + +{ + if( IsDead() ) + { + if( !ev->IsFromScript() ) + { + HUDPrint( "TESTING: Cannot resurrect yourself with the fullheal.\n" ); + } + } + else + { + if( !ev->IsFromScript() ) + { + HUDPrint( "TESTING: You used the fullheal.\n" ); + } + + health = max_health; + } +} + +void Player::EventFace + ( + Event *ev + ) + +{ + SetViewAngles( Vector( ev->GetFloat( 1 ), ev->GetFloat( 2 ), ev->GetFloat( 3 ) ) ); +} + +void Player::Kill + ( + Event *ev + ) + + { + if ( ( level.time - respawn_time ) < 5 ) + { + return; + } + + flags &= ~FL_GODMODE; + health = 1; + Damage( this, this, 10, origin, vec_zero, vec_zero, 0, DAMAGE_NO_PROTECTION, MOD_SUICIDE ); + } + +void Player::NoTargetCheat + ( + Event *ev + ) + + { + const char *msg; + + flags ^= FL_NOTARGET; + if( !( flags & FL_NOTARGET ) ) + { + msg = "notarget OFF\n"; + } + else + { + msg = "notarget ON\n"; + } + + gi.SendServerCommand( edict-g_entities, "print \"%s\"", msg ); + } + +void Player::NoclipCheat + ( + Event *ev + ) + +{ + const char *msg; + + if( m_pVehicle ) + { + msg = "Must exit vehicle first\n"; + } + else if( m_pTurret ) + { + msg = "Must exit turret first\n"; + } + else if( getMoveType() == MOVETYPE_NOCLIP ) + { + setMoveType( MOVETYPE_WALK ); + msg = "noclip OFF\n"; + + // reset the state machine so that his animations are correct + ResetState( NULL ); + } + else + { + client->ps.feetfalling = false; + movecontrol = MOVECONTROL_LEGS; + + setMoveType( MOVETYPE_NOCLIP ); + msg = "noclip ON\n"; + } + + gi.SendServerCommand( edict - g_entities, "print \"%s\"", msg ); +} + +void Player::EventTeleport + ( + Event *ev + ) + +{ + if( ev->NumArgs() == 1 ) + { + setOrigin( ev->GetVector( 1 ) ); + } + else + { + setOrigin( Vector( ev->GetFloat( 1 ), ev->GetFloat( 2 ), ev->GetFloat( 3 ) ) ); + } +} + +void Player::GameVersion + ( + Event *ev + ) + + { + gi.SendServerCommand( edict-g_entities, "print \"%s : %s\n\"", GAMEVERSION, __DATE__ ); + } + +void Player::SetFov + ( + float newFov + ) + +{ + fov = newFov; + + if( fov < 1 ) + { + fov = 80; + } + else if( fov > 160 ) + { + fov = 160; + } +} + +void Player::EventSetSelectedFov + ( + Event *ev + ) + +{ + if( ev->NumArgs() < 1 ) + { + gi.SendServerCommand( edict - g_entities, "print \"Fov = %d\n\"", ( unsigned int )fov ); + return; + } + + SetSelectedFov( ev->GetFloat( 1 ) ); + SetFov( selectedfov ); +} + +void Player::SetSelectedFov + ( + float newFov + ) + +{ + selectedfov = newFov; + + if( selectedfov < 1 ) + { + selectedfov = 80; + } + else if( selectedfov > 160 ) + { + selectedfov = 160; + } + + /* + if( g_gametype->integer && !developer->integer ) + { + if( selectedfov < 80 ) + { + selectedfov = 80; + } + else if( selectedfov > 80 ) + { + selectedfov = 80; + } + } + */ +} + +void Player::SafeZoomed + ( + Event *ev + ) + +{ + if( ev->GetInteger( 1 ) ) + { + if( m_iInZoomMode > 0 ) + { + SetFov( m_iInZoomMode ); + m_iInZoomMode = -1; + } + } + else + { + if( m_iInZoomMode == -1 ) + { + m_iInZoomMode = fov; + SetFov( selectedfov ); + } + } +} + +void Player::ToggleZoom + ( + int iZoom + ) + +{ + if( iZoom && m_iInZoomMode == -1 ) + { + SetFov( selectedfov ); + m_iInZoomMode = 0; + } + else + { + SetFov( iZoom ); + m_iInZoomMode = -1; + } +} + +void Player::ZoomOff + ( + void + ) + +{ + SetFov( selectedfov ); + m_iInZoomMode = 0; +} + +void Player::ZoomOffEvent + ( + Event *ev + ) + +{ + ZoomOff(); +} + +qboolean Player::IsZoomed + ( + void + ) + +{ + return m_iInZoomMode == -1; +} + +/* +=============== +CalcRoll + +=============== +*/ +float Player::CalcRoll + ( + void + ) + + { + float sign; + float side; + float value; + Vector l; + + angles.AngleVectors( NULL, &l, NULL ); + side = velocity * l; + sign = side < 0 ? 4 : -4; + side = fabs( side ); + + value = sv_rollangle->value; + + if ( side < sv_rollspeed->value ) + { + side = side * value / sv_rollspeed->value; + } + else + { + side = value; + } + + return side * sign; + } + +// +// PMove Events +// +void Player::ProcessPmoveEvents + ( + int event + ) + +{ + float damage; + + switch( event ) + { + case EV_NONE: + break; + case EV_FALL_SHORT: + case EV_FALL_MEDIUM: + case EV_FALL_FAR: + case EV_FALL_FATAL: + if( event == EV_FALL_FATAL ) + { + damage = max_health + 1.0f; + } + else if( event == EV_FALL_FAR ) + { + damage = 20; + } + else if( event == EV_FALL_MEDIUM ) + { + damage = 10; + } + else + { + damage = 5; + } + if( !DM_FLAG( DF_NO_FALLING ) ) + { + Damage( world, world, ( int )damage, origin, vec_zero, vec_zero, 0, DAMAGE_NO_ARMOR, MOD_FALLING ); + } + break; + case EV_TERMINAL_VELOCITY: + Sound( "snd_fall", CHAN_VOICE ); + break; + + // fakk2 remnants +/* + case EV_WATER_TOUCH: // foot touches + if( watertype & CONTENTS_LAVA ) + { + Sound( "snd_burn", CHAN_LOCAL ); + } + else + { + Animate *water; + trace_t trace; + Vector start; + float scale; + + Sound( "impact_playersplash", CHAN_AUTO ); + + // Find the correct place to put the splash + + start = origin + Vector( 0, 0, 90 ); + trace = G_Trace( start, vec_zero, vec_zero, origin, NULL, MASK_WATER, false, "ProcessPmoveEvents" ); + + // Figure out a good scale for the splash + + scale = 1 + ( velocity[ 2 ] + 400 ) / -1500; + + if( scale < 1 ) + scale = 1; + else if( scale > 1.5 ) + scale = 1.5; + + // Spawn in a water splash + + water = new Animate; + + water->setOrigin( trace.endpos ); + water->setModel( "fx_splashsmall.tik" ); + water->setScale( scale ); + water->NewAnim( "idle" ); + water->PostEvent( EV_Remove, 5 ); + + } + break; +*/ + case EV_WATER_LEAVE: // foot leaves + Sound( "impact_playerleavewater", CHAN_AUTO ); + break; + case EV_WATER_UNDER: // head touches + Sound( "impact_playersubmerge", CHAN_AUTO ); + break; + case EV_WATER_CLEAR: // head leaves + Sound( "snd_gasp", CHAN_LOCAL ); + break; + } +} + +/* +============= +WorldEffects +============= +*/ +void Player::WorldEffects + ( + void + ) + +{ + if( deadflag == DEAD_DEAD ) + { + // if we are dead, no world effects + return; + } + + // + // check for on fire + // + if( on_fire ) + { + if( next_painsound_time < level.time ) + { + next_painsound_time = level.time + 4; + Sound( "snd_onfire", CHAN_LOCAL ); + } + } +} + +/* +============= +AddBlend +============= +*/ +void Player::AddBlend + ( + float r, + float g, + float b, + float a + ) + + { + float a2; + float a3; + + if ( a <= 0 ) + { + return; + } + + // new total alpha + a2 = blend[ 3 ] + ( 1 - blend[ 3 ] ) * a; + + // fraction of color from old + a3 = blend[ 3 ] / a2; + + blend[ 0 ] = blend[ 0 ] * a3 + r * ( 1 - a3 ); + blend[ 1 ] = blend[ 1 ] * a3 + g * ( 1 - a3 ); + blend[ 2 ] = blend[ 2 ] * a3 + b * ( 1 - a3 ); + blend[ 3 ] = a2; + } + +/* +============= +CalcBlend +============= +*/ +void Player::CalcBlend + ( + void + ) + + { + int contents; + Vector vieworg; + + client->ps.stats[STAT_ADDFADE] =0; + blend[ 0 ] = blend[ 1 ] = blend[ 2 ] = blend[ 3 ] = 0; + + // add for contents + vieworg = m_vViewPos; + + contents = gi.PointContents( vieworg, 0 ); + + if ( contents & CONTENTS_SOLID ) + { + // Outside of world + //AddBlend( 0.8, 0.5, 0.0, 0.2 ); + } + else if ( contents & CONTENTS_LAVA ) + { + AddBlend( level.lava_color[0], level.lava_color[1], level.lava_color[2], level.lava_alpha ); + } + else if ( contents & CONTENTS_WATER ) + { + AddBlend( level.water_color[0], level.water_color[1], level.water_color[2], level.water_alpha ); + } + + // add for damage + if ( damage_alpha > 0 ) + { + AddBlend( damage_blend[ 0 ], damage_blend[ 1 ], damage_blend[ 2 ], damage_alpha ); + + // drop the damage value + damage_alpha -= 0.06f; + if ( damage_alpha < 0 ) + { + damage_alpha = 0; + } + client->ps.blend[0] = blend[0]; + client->ps.blend[1] = blend[1]; + client->ps.blend[2] = blend[2]; + client->ps.blend[3] = blend[3]; + } + + // Do the cinematic fading + float alpha=1; + + level.m_fade_time -= level.frametime; + + // Return if we are completely faded in + if ( ( level.m_fade_time <= 0 ) && ( level.m_fade_type == fadein ) ) + { + client->ps.blend[3] = 0 + damage_alpha; + return; + } + + // If we are faded out, and another fade out is coming in, then don't bother + if ( ( level.m_fade_time_start > 0 ) && ( level.m_fade_type == fadeout ) ) + { + if ( client->ps.blend[3] >= 1 ) + return; + } + + if ( level.m_fade_time_start > 0 ) + alpha = level.m_fade_time / level.m_fade_time_start; + + if ( level.m_fade_type == fadeout ) + alpha = 1.0f - alpha; + + if ( alpha < 0 ) + alpha = 0; + + if ( alpha > 1 ) + alpha = 1; + + if ( level.m_fade_style == additive ) + { + client->ps.blend[0] = level.m_fade_color[0] * level.m_fade_alpha * alpha; + client->ps.blend[1] = level.m_fade_color[1] * level.m_fade_alpha * alpha; + client->ps.blend[2] = level.m_fade_color[2] * level.m_fade_alpha * alpha; + client->ps.blend[3] = level.m_fade_alpha * alpha; + client->ps.stats[STAT_ADDFADE] = 1; + } + else + { + client->ps.blend[0] = level.m_fade_color[0]; + client->ps.blend[1] = level.m_fade_color[1]; + client->ps.blend[2] = level.m_fade_color[2]; + client->ps.blend[3] = level.m_fade_alpha * alpha; + client->ps.stats[STAT_ADDFADE] = 0; + } + } + +/* +=============== +P_DamageFeedback + +Handles color blends and view kicks +=============== +*/ + +void Player::DamageFeedback + ( + void + ) + +{ + float realcount; + float count; + + // if we are dead, don't setup any feedback + if( health <= 0 ) + { + damage_count = 0; + damage_blood = 0; + damage_alpha = 0; + VectorClear( damage_angles ); + return; + } + +#define DAMAGE_MAX_PITCH_SCALE 0.3f +#define DAMAGE_MAX_YAW_SCALE 0.3f + + if( damage_blood > damage_count ) + { + float pitch_delta; + float yaw_delta; + + damage_angles = damage_from.toAngles(); + pitch_delta = AngleDelta( angles.x, damage_angles.x ) / 90.0f; + yaw_delta = AngleDelta( angles.y, damage_angles.y ) / 90.0f; + + if( pitch_delta > DAMAGE_MAX_PITCH_SCALE ) + pitch_delta = DAMAGE_MAX_PITCH_SCALE; + else if( pitch_delta < -DAMAGE_MAX_PITCH_SCALE ) + pitch_delta = -DAMAGE_MAX_PITCH_SCALE; + + if( yaw_delta > DAMAGE_MAX_YAW_SCALE ) + yaw_delta = DAMAGE_MAX_YAW_SCALE; + else if( yaw_delta < -DAMAGE_MAX_YAW_SCALE ) + yaw_delta = -DAMAGE_MAX_YAW_SCALE; + + damage_angles[ PITCH ] = pitch_delta; + damage_angles[ ROLL ] = yaw_delta; + damage_count = damage_blood * 2.0f; + } + + if( damage_count ) + { + // decay damage_count over time + damage_count *= 0.90f; + if( damage_count < 0.1f ) + damage_count = 0; + + } + + // total points of damage shot at the player this frame + if( !damage_blood ) + { + // didn't take any damage + return; + } + + count = damage_blood; + realcount = count; + if( count < 10 ) + { + // always make a visible effect + count = 10; + } + + // the total alpha of the blend is always proportional to count + if( damage_alpha < 0 ) + { + damage_alpha = 0; + } + + damage_alpha += count * 0.001; + if( damage_alpha < 0.2f ) + { + damage_alpha = 0.2f; + } + if( damage_alpha > 0.6f ) + { + // don't go too saturated + damage_alpha = 0.6f; + } + + // the color of the blend will vary based on how much was absorbed + // by different armors + damage_blend = vec_zero; + if( damage_blood ) + { + damage_blend += ( damage_blood / realcount ) * bcolor; + } + + // + // clear totals + // + damage_blood = 0; +} + +void Player::GetPlayerView + ( + Vector *pos, + Vector *angle + ) + +{ + if( pos ) + { + *pos = origin; + pos->z += viewheight; + } + + if( angle ) + { + *angle = Vector( client->ps.viewangles ); + } +} + +void Player::SetPlayerView + ( + Camera *camera, + Vector position, + float cameraoffset, + Vector ang, + Vector vel, + float camerablend[ 4 ], + float camerafov + ) + +{ + client->ps.viewangles[ 0 ] = ang[ 0 ]; + client->ps.viewangles[ 1 ] = ang[ 1 ]; + client->ps.viewangles[ 2 ] = ang[ 2 ]; + client->ps.viewheight = cameraoffset; + + client->ps.origin[ 0 ] = position[ 0 ]; + client->ps.origin[ 1 ] = position[ 1 ]; + client->ps.origin[ 2 ] = position[ 2 ]; + + client->ps.velocity[ 0 ] = vel[ 0 ]; + client->ps.velocity[ 1 ] = vel[ 1 ]; + client->ps.velocity[ 2 ] = vel[ 2 ]; + + /* + client->ps.blend[ 0 ] = camerablend[ 0 ]; + client->ps.blend[ 1 ] = camerablend[ 1 ]; + client->ps.blend[ 2 ] = camerablend[ 2 ]; + client->ps.blend[ 3 ] = camerablend[ 3 ]; + */ + + client->ps.fov = camerafov; + + if( camera ) + { + if( camera->IsSubclassOfCamera() ) + { + client->ps.camera_angles[ 0 ] = camera->angles[ 0 ]; + client->ps.camera_angles[ 1 ] = camera->angles[ 1 ]; + client->ps.camera_angles[ 2 ] = camera->angles[ 2 ]; + + client->ps.camera_origin[ 0 ] = camera->origin[ 0 ]; + client->ps.camera_origin[ 1 ] = camera->origin[ 1 ]; + client->ps.camera_origin[ 2 ] = camera->origin[ 2 ]; + + Vector vOfs = camera->GetPositionOffset(); + VectorCopy( vOfs, client->ps.camera_posofs ); + + client->ps.pm_flags |= PMF_CAMERA_VIEW; + + // + // clear out the flags, but preserve the CF_CAMERA_CUT_BIT + // + client->ps.camera_flags = client->ps.camera_flags & CF_CAMERA_CUT_BIT; + } + else if( camera->IsSubclassOfPlayer() ) + { + if( !g_spectatefollow_firstperson->integer ) + { + Vector forward, right, up; + Vector vAngles, vCamOfs; + Vector start; + trace_t trace; + + // spectating a player + Player *m_player = ( Player * )camera; + + vAngles = m_player->GetVAngles(); + + AngleVectors( vAngles, forward, right, up ); + + vCamOfs = m_player->origin; + vCamOfs[ 2 ] += m_player->viewheight; + + vCamOfs += forward * g_spectatefollow_forward->value; + vCamOfs += right * g_spectatefollow_right->value; + vCamOfs += up * g_spectatefollow_up->value; + + if( m_player->client->ps.fLeanAngle != 0.0f ) + { + vCamOfs += client->ps.fLeanAngle * 0.65f * forward; + } + + start = m_player->origin; + start[ 2 ] += m_player->maxs[ 2 ] - 2.0; + + Vector vMins = Vector( -2, -2, 2 ); + Vector vMaxs = Vector( 2, 2, 2 ); + + trace = G_Trace( + start, + vMins, + vMaxs, + vCamOfs, + m_player, + MASK_SHOT, + false, + "Player::GetSpectateFollowOrientation" ); + + vAngles[ 0 ] += g_spectatefollow_pitch->value * trace.fraction; + VectorCopy( vAngles, client->ps.camera_angles ); + VectorCopy( trace.endpos, client->ps.camera_origin ); + + SetViewAngles( vAngles ); + setOrigin( trace.endpos ); + + VectorClear( client->ps.camera_posofs ); + client->ps.camera_flags = client->ps.camera_flags & CF_CAMERA_CUT_BIT; + client->ps.pm_flags |= PMF_CAMERA_VIEW; + } + else + { + Player *m_player = ( Player * )camera; + + client->ps.camera_angles[ 0 ] = m_player->angles[ 0 ]; + client->ps.camera_angles[ 1 ] = m_player->angles[ 1 ]; + client->ps.camera_angles[ 2 ] = m_player->angles[ 2 ]; + + client->ps.camera_origin[ 0 ] = m_player->origin[ 0 ]; + client->ps.camera_origin[ 1 ] = m_player->origin[ 1 ]; + client->ps.camera_origin[ 2 ] = m_player->origin[ 2 ]; + + SetViewAngles( m_player->GetViewAngles() ); + setOrigin( m_player->origin ); + + VectorClear( client->ps.camera_posofs ); + client->ps.camera_flags = client->ps.camera_flags & CF_CAMERA_CUT_BIT; + client->ps.pm_flags |= PMF_CAMERA_VIEW; + } + } + else + { + client->ps.camera_angles[ 0 ] = ang[ 0 ]; + client->ps.camera_angles[ 1 ] = ang[ 1 ]; + client->ps.camera_angles[ 2 ] = ang[ 2 ]; + + client->ps.camera_origin[ 0 ] = position[ 0 ]; + client->ps.camera_origin[ 1 ] = position[ 1 ]; + client->ps.camera_origin[ 2 ] = position[ 2 ]; + + VectorClear( client->ps.camera_posofs ); + client->ps.camera_flags = client->ps.camera_flags & CF_CAMERA_CUT_BIT; + client->ps.pm_flags |= PMF_CAMERA_VIEW; + } + } + else + { + client->ps.pm_flags &= ~PMF_CAMERA_VIEW; + // + // make sure the third person camera is setup correctly. + // + + if( getMoveType() != MOVETYPE_NOCLIP ) + { + qboolean do_cut; + int camera_type; + + camera_type = currentState_Torso->getCameraType(); + if( last_camera_type != camera_type ) + { + // + // clear out the flags, but preserve the CF_CAMERA_CUT_BIT + // + client->ps.camera_flags = client->ps.camera_flags & CF_CAMERA_CUT_BIT; + do_cut = qtrue; + switch( camera_type ) + { + case CAMERA_TOPDOWN: + client->ps.camera_flags |= CF_CAMERA_ANGLES_IGNORE_PITCH; + client->ps.camera_offset[ PITCH ] = -75; + client->ps.camera_flags |= CF_CAMERA_ANGLES_ALLOWOFFSET; + do_cut = qfalse; + break; + case CAMERA_FRONT: + client->ps.camera_flags |= CF_CAMERA_ANGLES_IGNORE_PITCH; + client->ps.camera_flags |= CF_CAMERA_ANGLES_ALLOWOFFSET; + client->ps.camera_offset[ YAW ] = 180; + client->ps.camera_offset[ PITCH ] = 0; + break; + case CAMERA_SIDE: + client->ps.camera_flags |= CF_CAMERA_ANGLES_IGNORE_PITCH; + client->ps.camera_flags |= CF_CAMERA_ANGLES_ALLOWOFFSET; + // randomly invert the YAW + if( G_Random( 1 ) > 0.5f ) + { + client->ps.camera_offset[ YAW ] = -90; + } + else + { + client->ps.camera_offset[ YAW ] = 90; + } + client->ps.camera_offset[ PITCH ] = 0; + break; + case CAMERA_SIDE_LEFT: + client->ps.camera_flags |= CF_CAMERA_ANGLES_IGNORE_PITCH; + client->ps.camera_flags |= CF_CAMERA_ANGLES_ALLOWOFFSET; + client->ps.camera_offset[ YAW ] = 90; + client->ps.camera_offset[ PITCH ] = 0; + break; + case CAMERA_SIDE_RIGHT: + client->ps.camera_flags |= CF_CAMERA_ANGLES_IGNORE_PITCH; + client->ps.camera_flags |= CF_CAMERA_ANGLES_ALLOWOFFSET; + client->ps.camera_offset[ YAW ] = -90; + client->ps.camera_offset[ PITCH ] = 0; + break; + case CAMERA_BEHIND_FIXED: + do_cut = qfalse; + client->ps.camera_offset[ YAW ] = 0; + client->ps.camera_offset[ PITCH ] = 0; + client->ps.camera_flags |= CF_CAMERA_ANGLES_ALLOWOFFSET; + break; + case CAMERA_BEHIND_NOPITCH: + do_cut = qfalse; + client->ps.camera_flags |= CF_CAMERA_ANGLES_IGNORE_PITCH; + client->ps.camera_offset[ YAW ] = 0; + client->ps.camera_offset[ PITCH ] = 0; + break; + case CAMERA_BEHIND: + do_cut = qfalse; + client->ps.camera_offset[ YAW ] = 0; + client->ps.camera_offset[ PITCH ] = 0; + break; + default: + do_cut = qfalse; + client->ps.camera_offset[ YAW ] = 0; + client->ps.camera_offset[ PITCH ] = 0; + break; + } + last_camera_type = camera_type; + if( do_cut ) + CameraCut(); + } + } + + // + // these are explicitly not cleared so that when the client lerps it still has the last + // camera position for reference. Additionally this causes no extra hits to the network + // traffic. + // + //VectorClear( client->ps.camera_angles ); + //VectorClear( client->ps.camera_origin ); + } + +#define EARTHQUAKE_SCREENSHAKE_PITCH 2 +#define EARTHQUAKE_SCREENSHAKE_YAW 2 +#define EARTHQUAKE_SCREENSHAKE_ROLL 3 + + if( level.earthquake_magnitude > 0.0f ) + { + client->ps.damage_angles[ PITCH ] = G_CRandom() * level.earthquake_magnitude * EARTHQUAKE_SCREENSHAKE_PITCH; + client->ps.damage_angles[ YAW ] = G_CRandom() * level.earthquake_magnitude * EARTHQUAKE_SCREENSHAKE_YAW; + client->ps.damage_angles[ ROLL ] = G_CRandom() * level.earthquake_magnitude * EARTHQUAKE_SCREENSHAKE_ROLL; + } + else if( damage_count ) + { + client->ps.damage_angles[ PITCH ] = damage_angles[ PITCH ] * damage_count; + client->ps.damage_angles[ ROLL ] = damage_angles[ ROLL ] * damage_count; + } + else + { + VectorClear( client->ps.damage_angles ); + } + + if( m_vViewVariation != vec_zero ) + { + for( int i = 0; i < 3; i++ ) + { + if( m_vViewVariation[ i ] == 0.0f ) + { + continue; + } + + client->ps.damage_angles[ i ] += ( ( rand() & 0x7FFF ) * 0.00003f + + ( rand() & 0x7FFF ) * 0.00003f + - 1.0f ) + * m_vViewVariation[ i ]; + + m_vViewVariation[ i ] = m_vViewVariation[ i ] - m_vViewVariation[ i ] * level.frametime * 8.0f; + + if( m_vViewVariation[ i ] < 0.01f ) + { + m_vViewVariation[ i ] = 0.0f; + } + } + } +} + +void Player::SetupView + ( + void + ) + +{ + // if we currently are not in a camera or the camera we are looking through is automatic, evaluate our camera choices + + if( actor_to_watch || actor_camera ) + { + Vector dir; + Vector watch_angles; + float dist = 0; + Vector focal_point; + Vector left; + trace_t trace; + qboolean delete_actor_camera = false; + Vector camera_mins; + Vector camera_maxs; + + if( actor_to_watch ) + { + dir = actor_to_watch->origin - origin; + dist = dir.length(); + } + + // See if we still want to watch this actor + + if( !actor_to_watch || dist > 150 || actor_to_watch->deadflag ) + { + delete_actor_camera = true; + } + else + { + // Create the camera if we don't have one yet + + if( !actor_camera ) + { + actor_camera = new Camera(); + + if( G_Random() < .5 ) + { + actor_camera_right = true; + starting_actor_camera_right = true; + } + else + { + actor_camera_right = false; + starting_actor_camera_right = false; + } + } + + // Setup the new position of the actor camera + + // Go a little above the view height + + actor_camera->origin = origin; + actor_camera->origin[ 2 ] += DEFAULT_VIEWHEIGHT + 10; + + // Find the focal point ( either the actor's watch offset or top of the bounding box) + + if( actor_to_watch->watch_offset != vec_zero ) + { + MatrixTransformVector( actor_to_watch->watch_offset, actor_to_watch->orientation, focal_point ); + focal_point += actor_to_watch->origin; + } + else + { + focal_point = actor_to_watch->origin; + focal_point[ 2 ] = actor_to_watch->maxs[ 2 ]; + } + + // Shift the camera back just a little + + dir = focal_point - actor_camera->origin; + dir.normalize(); + actor_camera->origin -= dir * 15; + + // Shift the camera a little to the left or right + + watch_angles = dir.toAngles(); + watch_angles.AngleVectors( NULL, &left ); + + if( actor_camera_right ) + actor_camera->origin -= left * 15; + else + actor_camera->origin += left * 15; + + // Make sure this camera position is ok + + camera_mins = "-5 -5 -5"; + camera_maxs = "5 5 5"; + + trace = G_Trace( actor_camera->origin, camera_mins, camera_maxs, actor_camera->origin, actor_camera, MASK_DEADSOLID, false, "SetupView" ); + + if( trace.startsolid ) + { + // Try other side + + if( actor_camera_right == starting_actor_camera_right ) + { + if( actor_camera_right ) + actor_camera->origin += left * 30; + else + actor_camera->origin -= left * 30; + + actor_camera_right = !actor_camera_right; + + trace = G_Trace( actor_camera->origin, camera_mins, camera_maxs, actor_camera->origin, actor_camera, MASK_DEADSOLID, false, "SetupView2" ); + + if( trace.startsolid ) + { + // Both spots have failed stop doing actor camera + delete_actor_camera = true; + } + } + else + { + // Both spots have failed stop doing actor camera + delete_actor_camera = true; + } + } + + if( !delete_actor_camera ) + { + // Set the camera's position + + actor_camera->setOrigin( actor_camera->origin ); + + // Set the camera's angles + + dir = focal_point - actor_camera->origin; + watch_angles = dir.toAngles(); + actor_camera->setAngles( watch_angles ); + + // Set this as our camera + + SetCamera( actor_camera, .5 ); + } + } + + if( delete_actor_camera ) + { + // Get rid of this camera + + actor_to_watch = NULL; + + if( actor_camera ) + { + delete actor_camera; + actor_camera = NULL; + SetCamera( NULL, .5 ); + } + } + } + else if( ( level.automatic_cameras.NumObjects() > 0 ) && ( !camera || camera->IsAutomatic() ) ) + { + int i; + float score, bestScore; + Camera *cam, *bestCamera; + + bestScore = 999; + bestCamera = NULL; + for( i = 1; i <= level.automatic_cameras.NumObjects(); i++ ) + { + cam = level.automatic_cameras.ObjectAt( i ); + score = cam->CalculateScore( this, currentState_Torso->getName() ); + // if this is our current camera, scale down the score a bit to favor it. + if( cam == camera ) + { + score *= 0.9f; + } + + if( score < bestScore ) + { + bestScore = score; + bestCamera = cam; + } + } + if( bestScore <= 1.0f ) + { + // we have a camera to switch to + if( bestCamera != camera ) + { + float time; + + if( camera ) + { + camera->AutomaticStop( this ); + } + time = bestCamera->AutomaticStart( this ); + SetCamera( bestCamera, time ); + } + } + else + { + // we don't have a camera to switch to + if( camera ) + { + float time; + + time = camera->AutomaticStop( this ); + SetCamera( NULL, time ); + } + } + } + + if( IsSpectator() && + m_iPlayerSpectating != 0 ) + { + gentity_t *ent = g_entities + m_iPlayerSpectating - 1; + + if( ent->inuse && + ent->entity && + ent->entity->deadflag <= DEAD_DYING ) + { + Player *m_player = ( Player * )ent->entity; + Vector vAngles; + + m_player->GetPlayerView( NULL, &vAngles ); + + SetPlayerView( ( Camera * )m_player, m_player->origin, m_player->viewheight, vAngles, m_player->velocity, blend, m_player->fov ); + return; + } + } + + // If there is no camera, use the player's view + if( !camera ) + { + SetPlayerView( NULL, origin, viewheight, v_angle, velocity, blend, fov ); + } + else + { + SetPlayerView( camera, origin, viewheight, v_angle, velocity, blend, camera->Fov() ); + } +} + +/* +================== +SwingAngles +================== +*/ +void Player::SwingAngles + ( + float destination, + float swingTolerance, + float clampTolerance, + float speed, + float *angle, + qboolean *swinging + ) + + { + float swing; + float move; + float scale; + + if ( !*swinging ) + { + // see if a swing should be started + swing = AngleSubtract( *angle, destination ); + if ( swing > swingTolerance || swing < -swingTolerance ) + { + *swinging = qtrue; + // we intentionally return so that we can start the animation before turning + return; + } + } + + if ( !*swinging ) + { + return; + } + + // modify the speed depending on the delta + // so it doesn't seem so linear + swing = AngleSubtract( destination, *angle ); + scale = fabs( swing ); + +#if 0 + if ( scale < swingTolerance * 0.5 ) + { + scale = 0.5; + } + else if ( scale < swingTolerance ) + { + scale = 1.0; + } + else + { + scale = 2.0; + } +#else + scale = 1.0f; +#endif + + // swing towards the destination angle + if ( swing >= 0 ) + { + move = level.intframetime * scale * speed; + if ( move >= swing ) + { + move = swing; + *swinging = qfalse; + } + + *angle = AngleMod( *angle + move ); + } + else if ( swing < 0 ) + { + move = level.intframetime * scale * -speed; + if ( move <= swing ) + { + move = swing; + *swinging = qfalse; + } + *angle = AngleMod( *angle + move ); + } + + // clamp to no more than tolerance + swing = AngleSubtract( destination, *angle ); + if ( swing > clampTolerance ) + { + *angle = AngleMod( destination - ( clampTolerance - 1 ) ); + } + else if ( swing < -clampTolerance ) + { + *angle = AngleMod( destination + ( clampTolerance - 1 ) ); + } + } + +qboolean Player::GetTagPositionAndOrientation + ( + int tagnum, + orientation_t *new_or + ) + + { + int i; + orientation_t tag_or; + vec3_t axis[3]; + + tag_or = G_TIKI_Orientation( edict, tagnum ); + + /*tag_or = gi.Tag_OrientationEx( edict->tiki, + CurrentAnim( 1 ), + CurrentTime( 1 ), + tagnum & TAG_MASK, + edict->s.scale, + edict->s.bone_tag, + edict->s.bone_quat, + 0, + 0, + 1.0f, + ( edict->s.anim & ANIM_BLEND ) != 0, + ( edict->s.torso_anim & ANIM_BLEND ) != 0, + CurrentAnim( 2 ), + CurrentTime( 2 ), + 0, + 0, + 1.0f + );*/ + + AnglesToAxis( angles, axis ); + VectorCopy( origin, new_or->origin ); + + for ( i=0; i<3; i++ ) + VectorMA( new_or->origin, tag_or.origin[i], axis[i], new_or->origin ); + + MatrixMultiply( tag_or.axis, axis, new_or->axis ); + return true; + } + +qboolean Player::GetTagPositionAndOrientation + ( + str tagname, + orientation_t *new_or + ) + + { + int tagnum; + + tagnum = gi.Tag_NumForName( edict->tiki, tagname ); + + if ( tagnum < 0 ) + { + warning( "Player::GetTagPositionAndOrientation", "Could not find tag \"%s\"", tagname.c_str() ); + return false; + } + + return GetTagPositionAndOrientation( tagnum, new_or ); + } + +Vector Player::GetAngleToTarget + ( + Entity *ent, + str tag, + float yawclamp, + float pitchclamp, + Vector baseangles + ) + + { + assert( ent ); + + if ( ent ) + { + Vector delta,angs; + orientation_t tag_or; + + int tagnum = gi.Tag_NumForName( edict->tiki, tag.c_str() ); + + if ( tagnum < 0 ) + return Vector( 0,0,0 ); + + GetTagPositionAndOrientation( tagnum, &tag_or ); + + delta = ent->centroid - tag_or.origin; + delta.normalize(); + + angs = delta.toAngles(); + + AnglesSubtract( angs, baseangles, angs ); + + angs[PITCH] = AngleNormalize180( angs[PITCH] ); + angs[YAW] = AngleNormalize180( angs[YAW] ); + + if ( angs[PITCH] > pitchclamp ) + angs[PITCH] = pitchclamp; + else if ( angs[PITCH] < -pitchclamp ) + angs[PITCH] = -pitchclamp; + + if ( angs[YAW] > yawclamp ) + angs[YAW] = yawclamp; + else if ( angs[YAW] < -yawclamp ) + angs[YAW] = -yawclamp; + + return angs; + } + else + { + return Vector( 0,0,0 ); + } + } + +void Player::DebugWeaponTags + ( + int controller_tag, + Weapon *weapon, + str weapon_tagname + ) + + { + int i; + orientation_t bone_or, tag_weapon_or, barrel_or, final_barrel_or; + + GetTagPositionAndOrientation( edict->s.bone_tag[controller_tag], &bone_or ); + //G_DrawCoordSystem( Vector( bone_or.origin ), Vector( bone_or.axis[0] ), Vector( bone_or.axis[1] ), Vector( bone_or.axis[2] ), 20 ); + + GetTagPositionAndOrientation( gi.Tag_NumForName( edict->tiki, weapon_tagname ), &tag_weapon_or ); + //G_DrawCoordSystem( Vector( tag_weapon_or.origin ), Vector( tag_weapon_or.axis[0] ), Vector( tag_weapon_or.axis[1] ), Vector( tag_weapon_or.axis[2] ), 40 ); + + weapon->GetRawTag( "tag_barrel", &barrel_or ); + VectorCopy( tag_weapon_or.origin, final_barrel_or.origin ); + + for ( i = 0 ; i < 3 ; i++ ) + VectorMA( final_barrel_or.origin, barrel_or.origin[i], tag_weapon_or.axis[i], final_barrel_or.origin ); + + MatrixMultiply( barrel_or.axis, tag_weapon_or.axis, final_barrel_or.axis ); + //G_DrawCoordSystem( Vector( final_barrel_or.origin ), Vector( final_barrel_or.axis[0] ), Vector( final_barrel_or.axis[1] ), Vector( final_barrel_or.axis[2] ), 80 ); + +#if 0 + if ( g_crosshair->integer ) + { + trace_t trace; + Vector start,end,ang,dir,delta; + vec3_t mat[3]; + + AnglesToAxis( v_angle, mat ); + + dir = mat[0]; + start = final_barrel_or.origin; + end = start + ( dir * MAX_MAP_BOUNDS ); + + G_DrawCoordSystem( start, Vector( mat[0] ), Vector( mat[1] ), Vector( mat[2] ), 80 ); + + trace = G_Trace( start, vec_zero, vec_zero, end, this, MASK_PROJECTILE|MASK_WATER, qfalse, "Crosshair" ); + crosshair->setOrigin( trace.endpos ); + + delta = trace.endpos - start; + float length = delta.length(); + float scale = g_crosshair_maxscale->value * length / MAX_MAP_BOUNDS; + + if ( scale < 1 ) + scale = 1; + + crosshair->setScale( scale ); + + if ( trace.ent ) + { + vectoangles( trace.plane.normal, ang ); + } + else + { + vectoangles( dir, ang ); + } + + crosshair->setAngles( ang ); + } +#endif + } + +void Player::AcquireTarget + ( + void + ) + + { + + } + +void Player::RemoveTarget + ( + Entity *ent_to_remove + ) + + { + + } + +void Player::AutoAim + ( + void + ) + +{ + +} + +/* +=============== +PlayerAngles +=============== +*/ +void Player::PlayerAngles + ( + void + ) + +{ + PmoveAdjustAngleSettings( v_angle, angles, &client->ps, &edict->s ); + + SetViewAngles( v_angle ); + setAngles( angles ); +} + +void Player::FinishMove + ( + void + ) +{ + // + // If the origin or velocity have changed since ClientThink(), + // update the pmove values. This will happen when the client + // is pushed by a bmodel or kicked by an explosion. + // + // If it wasn't updated here, the view position would lag a frame + // behind the body position when pushed -- "sinking into plats", + // + if( !( client->ps.pm_flags & PMF_FROZEN ) && !( client->ps.pm_flags & PMF_NO_MOVE ) ) + { + origin.copyTo( client->ps.origin ); + velocity.copyTo( client->ps.velocity ); + } + + // This check is in mohaa but the animation will look bad + //if( !( client->ps.pm_flags & PMF_FROZEN ) ) + //{ + PlayerAngles(); + AdjustAnimBlends(); + //} + + // burn from lava, etc + WorldEffects(); + + // determine the view offsets + DamageFeedback(); + CalcBlend(); + + if( g_gametype->integer && g_smoothClients->integer && !IsSubclassOfBot() ) + { + VectorCopy( client->ps.velocity, edict->s.pos.trDelta ); + edict->s.pos.trTime = client->ps.commandTime; + } + else + { + VectorClear( edict->s.pos.trDelta ); + edict->s.pos.trTime = 0; + } +} + +void Player::CopyStats + ( + Player *player + ) + +{ + gentity_t *ent; + int i; + + origin = player->origin; + SetViewAngles( player->GetViewAngles() ); + + client->ps.bobCycle = player->client->ps.bobCycle; + + client->ps.pm_flags |= player->client->ps.pm_flags & ( PMF_DUCKED | PMF_VIEW_DUCK_RUN | PMF_VIEW_JUMP_START | PMF_VIEW_PRONE ); + + memcpy( &client->ps.stats, &player->client->ps.stats, sizeof( client->ps.stats ) ); + memcpy( &client->ps.activeItems, &player->client->ps.activeItems, sizeof( client->ps.activeItems ) ); + memcpy( &client->ps.ammo_name_index, &player->client->ps.ammo_name_index, sizeof( client->ps.ammo_name_index ) ); + memcpy( &client->ps.ammo_amount, &player->client->ps.ammo_amount, sizeof( client->ps.ammo_amount ) ); + memcpy( &client->ps.max_ammo_amount, &player->client->ps.max_ammo_amount, sizeof( client->ps.max_ammo_amount ) ); + + VectorCopy( player->client->ps.origin, client->ps.origin ); + VectorCopy( player->client->ps.velocity, client->ps.velocity ); + + if( client->ps.iViewModelAnim != player->client->ps.iViewModelAnim ) + { + ViewModelAnim( player->m_sVMcurrent, qfalse, 0 ); + } + else if( client->ps.iViewModelAnimChanged != player->client->ps.iViewModelAnimChanged ) + { + ViewModelAnim( player->m_sVMcurrent, qtrue, 0 ); + } + + client->ps.gravity = player->client->ps.gravity; + client->ps.speed = player->client->ps.speed; + + // copy angles + memcpy( &client->ps.delta_angles, &player->client->ps.delta_angles, sizeof( client->ps.delta_angles ) ); + + memcpy( &client->ps.blend, &player->client->ps.blend, sizeof( client->ps.blend ) ); + memcpy( &client->ps.damage_angles, &player->client->ps.damage_angles, sizeof( client->ps.damage_angles ) ); + memcpy( &client->ps.viewangles, &player->client->ps.viewangles, sizeof( client->ps.delta_angles ) ); + + // copy camera stuff + //memcpy( &client->ps.camera_origin, &player->client->ps.camera_origin, sizeof( client->ps.camera_origin ) ); + //memcpy( &client->ps.camera_angles, &player->client->ps.camera_angles, sizeof( client->ps.camera_angles ) ); + //memcpy( &client->ps.camera_offset, &player->client->ps.camera_offset, sizeof( client->ps.camera_offset ) ); + //memcpy( &client->ps.camera_posofs, &player->client->ps.camera_posofs, sizeof( client->ps.camera_posofs ) ); + //client->ps.camera_time = player->client->ps.camera_time; + //client->ps.camera_flags = player->client->ps.camera_flags; + + client->ps.fLeanAngle = player->client->ps.fLeanAngle; + client->ps.fov = player->client->ps.fov; + + client->ps.viewheight = player->client->ps.viewheight; + client->ps.walking = player->client->ps.walking; + client->ps.groundPlane = player->client->ps.groundPlane; + client->ps.groundEntityNum = player->client->ps.groundEntityNum; + memcpy( &client->ps.groundTrace, &player->client->ps.groundTrace, sizeof( trace_t ) ); + + edict->s.eFlags &= ~EF_UNARMED; + edict->r.svFlags &= ~SVF_NOCLIENT; + edict->s.renderfx &= ~RF_DONTDRAW; + + player->edict->r.svFlags |= SVF_PORTAL; + player->edict->r.singleClient = client->ps.clientNum; + + edict->r.svFlags |= SVF_SINGLECLIENT; + edict->r.singleClient = client->ps.clientNum; + + client->ps.pm_flags |= PMF_FROZEN | PMF_NO_MOVE | PMF_NO_PREDICTION; + + memcpy( &edict->s.frameInfo, &player->edict->s.frameInfo, sizeof( edict->s.frameInfo ) ); + + DetachAllChildren(); + + for( i = 0; i < MAX_MODEL_CHILDREN; i++ ) + { + Entity *dest; + + if( player->children[ i ] == ENTITYNUM_NONE ) { + continue; + } + + ent = g_entities + player->children[ i ]; + + if( !ent->inuse || !ent->entity ) { + continue; + } + + dest = new Entity; + + CloneEntity( dest, ent->entity ); + + dest->edict->r.svFlags |= SVF_SINGLECLIENT; + dest->edict->r.singleClient = client->ps.clientNum; + + dest->edict->s.modelindex = ent->entity->edict->s.modelindex; + dest->edict->tiki = ent->entity->edict->tiki; + dest->edict->s.actionWeight = ent->entity->edict->s.actionWeight; + memcpy( &dest->edict->s.frameInfo, &ent->entity->edict->s.frameInfo, sizeof( dest->edict->s.frameInfo ) ); + dest->CancelPendingEvents(); + dest->attach( entnum, ent->entity->edict->s.tag_num ); + + dest->PostEvent( EV_DetachAllChildren, level.frametime ); + } +} + +void Player::UpdateStats + ( + void + ) + +{ + int i, count; + Vector vObjectiveLocation; + + // + // Health + // + + if( g_spectatefollow_firstperson->integer && + IsSpectator() && + m_iPlayerSpectating != 0 ) + { + gentity_t *ent = g_entities + ( m_iPlayerSpectating - 1 ); + + if( ent->inuse && + ent->entity && + ent->entity->deadflag <= DEAD_DYING ) + { + CopyStats( ( Player * )ent->entity ); + return; + } + } + + if( !g_gametype->integer ) + { + client->ps.stats[ STAT_TEAM ] = TEAM_ALLIES; + client->ps.stats[ STAT_KILLS ] = 0; + client->ps.stats[ STAT_DEATHS ] = 0; + client->ps.stats[ STAT_HIGHEST_SCORE ] = 0; + client->ps.stats[ STAT_ATTACKERCLIENT ] = -1; + client->ps.stats[ STAT_INFOCLIENT ] = -1; + client->ps.stats[ STAT_INFOCLIENT_HEALTH ] = 0; + + vObjectiveLocation = level.m_vObjectiveLocation; + } + else + { + client->ps.stats[ STAT_TEAM ] = dm_team; + + if( g_gametype->integer >= GT_TEAM && current_team != NULL ) + { + client->ps.stats[ STAT_KILLS ] = current_team->m_teamwins; + client->ps.stats[ STAT_DEATHS ] = current_team->m_iDeaths; + } + else + { + client->ps.stats[ STAT_KILLS ] = num_kills; + client->ps.stats[ STAT_DEATHS ] = num_deaths; + } + + if( g_gametype->integer <= GT_FFA ) + { + gentity_t *ent; + int i; + int bestKills = -9999; + + // Get the best player + for( i = 0, ent = g_entities; i < game.maxclients; i++, ent++ ) + { + if( !ent->inuse || !ent->client || !ent->entity ) + continue; + + Player *p = ( Player * )ent->entity; + if( p->GetNumKills() > bestKills ) + bestKills = p->GetNumKills(); + } + + client->ps.stats[ STAT_HIGHEST_SCORE ] = bestKills; + } + else + { + if( dmManager.GetTeamAxis()->m_teamwins > dmManager.GetTeamAllies()->m_teamwins ) + { + client->ps.stats[ STAT_HIGHEST_SCORE ] = dmManager.GetTeamAxis()->m_teamwins; + } + else + { + client->ps.stats[ STAT_HIGHEST_SCORE ] = dmManager.GetTeamAllies()->m_teamwins; + } + } + + if( !pAttackerDistPointer ) + { + client->ps.stats[ STAT_ATTACKERCLIENT ] = -1; + } + else if( fAttackerDispTime <= level.time && !deadflag ) + { + pAttackerDistPointer = NULL; + client->ps.stats[ STAT_ATTACKERCLIENT ] = -1; + } + else + { + client->ps.stats[ STAT_ATTACKERCLIENT ] = pAttackerDistPointer->edict - g_entities; + } + + client->ps.stats[ STAT_INFOCLIENT ] = -1; + client->ps.stats[ STAT_INFOCLIENT_HEALTH ] = 0; + + if( IsSpectator() || g_gametype->integer > GT_FFA ) + { + if( IsSpectator() && m_iPlayerSpectating ) + { + gentity_t *ent = g_entities + ( m_iPlayerSpectating - 1 ); + + if( ent->inuse && ent->entity && !deadflag ) + { + m_iInfoClient = ent - g_entities; + m_iInfoClientHealth = ent->entity->health; + m_fInfoClientTime = level.time; + + float percent = ent->entity->health / ent->entity->max_health * 100.0f; + + if( percent > 0.0f && percent < 1.0f ) + percent = 1.0f; + + client->ps.stats[ STAT_INFOCLIENT_HEALTH ] = percent; + } + } + else + { + Vector vForward; + trace_t trace; + + AngleVectors( m_vViewAng, vForward, NULL, NULL ); + + Vector vEnd = m_vViewPos + vForward * 2048.0f; + + trace = G_Trace( m_vViewPos, + vec_zero, + vec_zero, + vEnd, + this, + MASK_BEAM, + qfalse, + "infoclientcheck" ); + + if( trace.ent && trace.ent->entity->IsSubclassOfPlayer() ) + { + Player *p = ( Player * )trace.ent->entity; + + if( IsSpectator() || p->dm_team == dm_team ) + { + m_iInfoClient = trace.ent - g_entities; + m_iInfoClientHealth = p->health; + m_fInfoClientTime = level.time; + + float percent = trace.ent->entity->health / trace.ent->entity->max_health * 100.0f; + + if( percent > 0.0f && percent < 1.0f ) + percent = 1.0f; + + client->ps.stats[ STAT_INFOCLIENT_HEALTH ] = percent; + } + } + } + + if( m_iInfoClient != -1 ) + { + if( level.time <= m_fInfoClientTime + 1.5f ) + { + client->ps.stats[ STAT_INFOCLIENT ] = m_iInfoClient; + client->ps.stats[ STAT_INFOCLIENT_HEALTH ] = m_iInfoClientHealth; + } + else + { + m_iInfoClient = -1; + } + } + } + + if( g_gametype->integer > GT_FFA && !IsDead() && !IsSpectator() ) + { + gentity_t *ent; + int i; + Player *p; + float fNearest = 9999.0f; + float fLength; + + vObjectiveLocation = vec_zero; + + // match the compass direction to the nearest player + for( i = 0, ent = g_entities; i < game.maxclients; i++, ent++ ) + { + if( !ent->inuse || !ent->client || !ent->entity || ent->entity == this ) + continue; + + p = ( Player * )ent->entity; + if( p->IsDead() || p->IsSpectator() || p->dm_team != dm_team ) + continue; + + fLength = ( p->centroid - centroid ).length(); + + if( fLength < fNearest ) + { + fNearest = fLength; + vObjectiveLocation = p->centroid; + } + } + } + } + + TurretGun *pTurret = NULL; + + if( !m_pVehicle ) + { + pTurret = m_pTurret; + } + + if( ( health < 1 ) && ( health > 0 ) ) + { + client->ps.stats[ STAT_HEALTH ] = 1; + } + else + { + client->ps.stats[ STAT_HEALTH ] = ( int )( health / max_health * 100.0f ); + } + + client->ps.stats[ STAT_MAX_HEALTH ] = 100; + + Weapon *activeweap = GetActiveWeapon( WEAPON_MAIN ); + + client->ps.stats[ STAT_WEAPONS ] = 0; + client->ps.stats[ STAT_EQUIPPED_WEAPON ] = 0; + client->ps.stats[ STAT_AMMO ] = 0; + client->ps.stats[ STAT_MAXAMMO ] = 0; + client->ps.stats[ STAT_CLIPAMMO ] = 0; + client->ps.stats[ STAT_MAXCLIPAMMO ] = 0; + + client->ps.activeItems[ ITEM_AMMO ] = -1; + client->ps.activeItems[ ITEM_WEAPON ] = -1; + client->ps.activeItems[ 2 ] = -1; + client->ps.activeItems[ 3 ] = -1; + client->ps.activeItems[ 4 ] = -1; + client->ps.activeItems[ 5 ] = -1; + + if( pTurret ) + { + client->ps.activeItems[ ITEM_WEAPON ] = pTurret->getIndex(); + } + else if( activeweap ) + { + client->ps.stats[ STAT_AMMO ] = AmmoCount( activeweap->GetAmmoType( FIRE_PRIMARY ) ); + client->ps.stats[ STAT_MAXAMMO ] = MaxAmmoCount( activeweap->GetAmmoType( FIRE_PRIMARY ) ); + client->ps.stats[ STAT_CLIPAMMO ] = activeweap->ClipAmmo( FIRE_PRIMARY ); + client->ps.stats[ STAT_MAXCLIPAMMO ] = activeweap->GetClipSize( FIRE_PRIMARY ); + + client->ps.activeItems[ ITEM_AMMO ] = AmmoIndex( activeweap->GetAmmoType( FIRE_PRIMARY ) ); + + // grenade and rockets must match the number of ammo + if( client->ps.stats[ STAT_MAXCLIPAMMO ] == 1 ) + { + client->ps.stats[ STAT_MAXAMMO ]++; + client->ps.stats[ STAT_AMMO ] += client->ps.stats[ STAT_CLIPAMMO ]; + } + + if( !activeweap->IsSubclassOfInventoryItem() ) + { + client->ps.stats[ STAT_EQUIPPED_WEAPON ] = activeweap->GetWeaponClass(); + } + + client->ps.activeItems[ ITEM_WEAPON ] = activeweap->getIndex(); + } + + // + // set boss health + // + client->ps.stats[ STAT_BOSSHEALTH ] = bosshealth->value * 100.0f; + + if( bosshealth->value * 100.0f > 0 && client->ps.stats[ STAT_BOSSHEALTH ] == 0 ) + client->ps.stats[ STAT_BOSSHEALTH ] = 1; + + // Set cinematic stuff + + client->ps.stats[ STAT_CINEMATIC ] = 0; + + if( level.cinematic ) + client->ps.stats[ STAT_CINEMATIC ] = ( 1 << 0 ); + + if( actor_camera ) + client->ps.stats[ STAT_CINEMATIC ] += ( 1 << 1 ); + + count = inventory.NumObjects(); + + if( count > MAX_WEAPONS ) + { + count = MAX_WEAPONS; + warning( "Player::UpdateStats", "Max inventory exceeded\n" ); + } + + count = inventory.NumObjects(); + + int iItem = 0; + + for( i = 1; i <= count; i++ ) + { + int entnum = inventory.ObjectAt( i ); + Weapon *weapon = ( Weapon * )G_GetEntity( entnum ); + int weapon_class; + + if( weapon->IsSubclassOfWeapon() ) + { + if( weapon->IsSubclassOfInventoryItem() ) + { + if( iItem <= 3 ) + { + client->ps.activeItems[ iItem + 2 ] = weapon->getIndex(); + weapon->weapon_class = ( 256 << iItem ) & WEAPON_CLASS_ITEMINDEX | weapon->weapon_class & ~WEAPON_CLASS_ITEMINDEX; + + if( activeweap && weapon == activeweap ) + { + client->ps.stats[ STAT_EQUIPPED_WEAPON ] = 256 << iItem; + } + + iItem++; + } + else + { + weapon->weapon_class &= ~WEAPON_CLASS_ITEMINDEX; + } + } + else + { + weapon_class = weapon->GetWeaponClass(); + + if( weapon_class & WEAPON_CLASS_GRENADE ) + { + if( weapon->HasAmmo( FIRE_PRIMARY ) ) + client->ps.stats[ STAT_WEAPONS ] |= weapon_class; + } + else + { + client->ps.stats[ STAT_WEAPONS ] |= weapon_class; + } + } + } + } + + // Go through all the player's ammo and send over the names/amounts + memset( client->ps.ammo_amount, 0, sizeof( client->ps.ammo_amount ) ); + memset( client->ps.ammo_name_index, 0, sizeof( client->ps.ammo_name_index ) ); + memset( client->ps.max_ammo_amount, 0, sizeof( client->ps.max_ammo_amount ) ); + + count = ammo_inventory.NumObjects(); + + for( i = 1; i <= count; i++ ) + { + Ammo *ammo = ammo_inventory.ObjectAt( i ); + + if( ammo ) + { + client->ps.ammo_amount[ i - 1 ] = ammo->getAmount(); + client->ps.max_ammo_amount[ i - 1 ] = ammo->getMaxAmount(); + client->ps.ammo_name_index[ i - 1 ] = ammo->getIndex(); + } + } + + if( m_iInZoomMode == -1 ) + { + client->ps.stats[ STAT_INZOOM ] = fov; + } + else + { + client->ps.stats[ STAT_INZOOM ] = 0; + } + + client->ps.stats[ STAT_CROSSHAIR ] = ( !client->ps.stats[ STAT_INZOOM ] || client->ps.stats[ STAT_INZOOM ] > 30 ) && + ( activeweap && !activeweap->IsSubclassOfInventoryItem() && activeweap->HasCrosshair() ) || + pTurret || ( m_pVehicle && m_pVehicle->IsSubclassOfVehicleTank() ); + + + client->ps.stats[ STAT_COMPASSNORTH ] = ANGLE2SHORT( world->m_fNorth ); + + if( VectorCompare( vObjectiveLocation, vec_zero ) ) + { + client->ps.stats[ STAT_OBJECTIVELEFT ] = 1730; + client->ps.stats[ STAT_OBJECTIVERIGHT ] = 1870; + client->ps.stats[ STAT_OBJECTIVECENTER ] = 1800; + } + else + { + Vector vDelta; + float yaw; + float fOffset; + + vDelta = vObjectiveLocation - centroid; + yaw = AngleSubtract( v_angle[ 1 ], vDelta.toYaw() ) + 180.0f; + + vDelta = yaw_left * 300.0f + yaw_forward * vDelta.length() + centroid - centroid; + fOffset = AngleSubtract( vDelta.toYaw(), v_angle[ 1 ] ); + if( fOffset < 0.0f ) + fOffset = -fOffset; + + fOffset = 53.0f - fOffset + 7.0f; + if( fOffset < 7.0f ) + fOffset = 7.0f; + + client->ps.stats[ STAT_OBJECTIVELEFT ] = anglemod( yaw - fOffset ) * 10.0f; + if( client->ps.stats[ STAT_OBJECTIVELEFT ] <= 0 ) + { + client->ps.stats[ STAT_OBJECTIVELEFT ] = 1; + } + else if( client->ps.stats[ STAT_OBJECTIVELEFT ] > 3599 ) + { + client->ps.stats[ STAT_OBJECTIVELEFT ] = 3599; + } + + client->ps.stats[ STAT_OBJECTIVERIGHT ] = anglemod( yaw + fOffset ) * 10.0f; + if( client->ps.stats[ STAT_OBJECTIVERIGHT ] <= 0 ) + { + client->ps.stats[ STAT_OBJECTIVERIGHT ] = 1; + } + else if( client->ps.stats[ STAT_OBJECTIVERIGHT ] > 3599 ) + { + client->ps.stats[ STAT_OBJECTIVERIGHT ] = 3599; + } + + client->ps.stats[ STAT_OBJECTIVECENTER ] = anglemod( yaw ) * 10.0f; + if( client->ps.stats[ STAT_OBJECTIVECENTER ] <= 0 ) + { + client->ps.stats[ STAT_OBJECTIVECENTER ] = 1; + } + else if( client->ps.stats[ STAT_OBJECTIVECENTER ] > 3599 ) + { + client->ps.stats[ STAT_OBJECTIVECENTER ] = 3599; + } + } + + client->ps.stats[ STAT_DAMAGEDIR ] = damage_yaw; + if( client->ps.stats[ STAT_DAMAGEDIR ] < 0 ) + { + client->ps.stats[ STAT_DAMAGEDIR ] = 0; + } + else if( client->ps.stats[ STAT_DAMAGEDIR ] > 3600 ) + { + client->ps.stats[ STAT_DAMAGEDIR ] = 3600; + } + + // Do letterbox + + // Check for letterbox fully out + if( ( level.m_letterbox_time <= 0 ) && ( level.m_letterbox_dir == letterbox_in ) ) + { + client->ps.stats[ STAT_LETTERBOX ] = level.m_letterbox_fraction * MAX_LETTERBOX_SIZE; + return; + } + else if( ( level.m_letterbox_time <= 0 ) && ( level.m_letterbox_dir == letterbox_out ) ) + { + client->ps.stats[ STAT_LETTERBOX ] = 0; + return; + } + + float frac; + + level.m_letterbox_time -= level.intframetime; + + frac = level.m_letterbox_time / level.m_letterbox_time_start; + + if( frac > 1 ) + frac = 1; + if( frac < 0 ) + frac = 0; + + if( level.m_letterbox_dir == letterbox_in ) + frac = 1.0f - frac; + + client->ps.stats[ STAT_LETTERBOX ] = ( frac * level.m_letterbox_fraction ) * MAX_LETTERBOX_SIZE; +} + +void Player::UpdateStatus + ( + const char *s + ) + +{ + gi.SendServerCommand( edict - g_entities, "status \"%s\"", s ); +} + +void Player::UpdateMusic + ( + void + ) +{ + if( music_forced ) + { + client->ps.current_music_mood = music_current_mood; + client->ps.fallback_music_mood = music_fallback_mood; + } + + // Copy music volume and fade time to player state + client->ps.music_volume = music_current_volume; + client->ps.music_volume_fade_time = music_volume_fade_time; +} + +void Player::SetReverb + ( + int type, + float level + ) + + { + reverb_type = type; + reverb_level = level; + } + +void Player::SetReverb + ( + str type, + float level + ) + + { + reverb_type = EAXMode_NameToNum( type ); + reverb_level = level; + } + +void Player::SetReverb + ( + Event *ev + ) + { + if ( ev->NumArgs() < 2 ) + return; + + SetReverb( ev->GetInteger( 1 ), ev->GetFloat( 2 ) ); + } + +void Player::UpdateReverb + ( + void + ) + { + client->ps.reverb_type = reverb_type; + client->ps.reverb_level = reverb_level; + } + +void Player::EndAnim_Legs + ( + Event *ev + ) + +{ + animdone_Legs = true; + + if( ( animFlags[ m_iPartSlot[ legs ] ] & ANIM_LOOP ) ) { + SetAnimDoneEvent( EV_Player_AnimLoop_Legs, m_iPartSlot[ legs ] ); + } + + EvaluateState(); +} + +void Player::EndAnim_Torso + ( + Event *ev + ) + +{ + animdone_Torso = true; + + if( ( animFlags[ m_iPartSlot[ torso ] ] & ANIM_LOOP ) ) { + SetAnimDoneEvent( EV_Player_AnimLoop_Torso, m_iPartSlot[ torso ] ); + } + + EvaluateState(); +} + +void Player::EndActionAnim + ( + Event *ev + ) + +{ + m_bActionAnimDone = qtrue; + EvaluateState(); +} + +void Player::SetPartAnim + ( + const char *anim, + bodypart_t slot + ) +{ + int animnum; + + if( getMoveType() == MOVETYPE_NOCLIP && slot ) + { + StopPartAnimating( torso ); + return; + } + + animnum = gi.Anim_NumForName( edict->tiki, anim ); + if( animnum == CurrentAnim() && partAnim[ slot ] == anim ) + { + return; + } + + if( animnum == -1 ) + { + Event *ev; + + if( slot ) + { + ev = new Event( EV_Player_AnimLoop_Torso ); + } + else + { + ev = new Event( EV_Player_AnimLoop_Legs ); + } + + PostEvent( ev, level.frametime ); + gi.DPrintf( "^~^~^ Warning: Can't find player animation '%s'.\n", anim ); + + return; + } + + if( m_fPartBlends[ slot ] < 0.5f ) + { + SetAnimDoneEvent( NULL, m_iPartSlot[ slot ] ); + + float m_fCrossTime = gi.Anim_CrossTime( edict->tiki, animnum ); + + partBlendMult[ slot ] = m_fCrossTime; + if( m_fCrossTime <= 0.0f ) + { + partOldAnim[ slot ] = ""; + m_fPartBlends[ slot ] = 0.0f; + } + else + { + m_iPartSlot[ slot ] ^= 1; + partBlendMult[ slot ] = 1.0f / m_fCrossTime; + partOldAnim[ slot ] = partAnim[ slot ]; + m_fPartBlends[ slot ] = 1.0f; + } + } + + if( slot ) + { + animdone_Torso = false; + } + else + { + animdone_Legs = false; + } + + edict->s.frameInfo[ m_iPartSlot[ slot ] ].index = gi.Anim_NumForName( edict->tiki, "idle" ); + + partAnim[ slot ] = anim; + + if( slot ) + { + NewAnim( animnum, EV_Player_AnimLoop_Torso, m_iPartSlot[ slot ] ); + } + else + { + NewAnim( animnum, EV_Player_AnimLoop_Legs, m_iPartSlot[ legs ] ); + } + + SetTime( m_iPartSlot[ slot ] ); +} + +static float m_fPartMult[ 2 ] = +{ + 0.2f, + 0.2f +}; + +void Player::StopPartAnimating + ( + bodypart_t part + ) +{ + if( partAnim[ part ] == "" ) { + return; + } + + if( m_fPartBlends[ part ] < 0.5f ) + { + SetAnimDoneEvent( NULL, m_iPartSlot[ part ] ); + + m_iPartSlot[ part ] ^= 1; + partOldAnim[ part ] = partAnim[ part ]; + m_fPartBlends[ part ] = 1.0f; + } + + partAnim[ part ] = ""; + partBlendMult[ part ] = 1.0f / m_fPartMult[ part ]; + + StopAnimating( m_iPartSlot[ part ] ); + + if( part ) + { + animdone_Torso = false; + } + else + { + animdone_Legs = false; + } +} + +void Player::PausePartAnim +( +bodypart_t part +) +{ + Pause( m_iPartSlot[ part ], 1 ); + Pause( m_iPartSlot[ part ] ^ 1, 1 ); +} + +void Player::AdjustAnimBlends + ( + void + ) +{ + int iPartSlot; + int iOldPartSlot; + float fWeightTotal; + + iPartSlot = m_iPartSlot[ legs ]; + iOldPartSlot = m_iPartSlot[ legs ] ^ 1; + + if( m_fPartBlends[ legs ] <= 0.0f ) + { + if( partOldAnim[ legs ] == "" ) + { + goto __blend_torso; + } + + StopAnimating( iOldPartSlot ); + } + else + { + m_fPartBlends[ legs ] = m_fPartBlends[ legs ] - level.frametime * partBlendMult[ legs ]; + if( m_fPartBlends[ legs ] >= 0.01f ) + { + if( partOldAnim[ legs ] != "" ) + { + edict->s.frameInfo[ iOldPartSlot ].weight = m_fPartBlends[ legs ]; + } + if( partAnim[ legs ] != "" ) + { + edict->s.frameInfo[ iPartSlot ].weight = 1.0f - m_fPartBlends[ legs ]; + } + + goto __blend_torso; + } + + m_fPartBlends[ legs ] = 0.0f; + StopAnimating( iOldPartSlot ); + partOldAnim[ legs ] = ""; + } + + if( partAnim[ legs ] != "" ) + { + edict->s.frameInfo[ iPartSlot ].weight = 1.0f; + } + else + { + edict->s.frameInfo[ iPartSlot ].weight = 0.0f; + } + +__blend_torso: + iPartSlot = m_iPartSlot[ torso ]; + iOldPartSlot = m_iPartSlot[ torso ] ^ 1; + + if( m_fPartBlends[ torso ] <= 0.0f ) + { + if( partOldAnim[ torso ] != "" ) + { + StopAnimating( iOldPartSlot ); + partOldAnim[ torso ] = ""; + } + } + else + { + m_fPartBlends[ torso ] = m_fPartBlends[ torso ] - level.frametime * partBlendMult[ torso ]; + if( m_fPartBlends[ torso ] >= 0.01f ) + { + fWeightTotal = 0.0f; + + if( partOldAnim[ torso ] != "" ) + { + edict->s.frameInfo[ iOldPartSlot ].weight = m_fPartBlends[ torso ]; + fWeightTotal += m_fPartBlends[ torso ]; + } + if( partAnim[ torso ] != "" ) + { + edict->s.frameInfo[ iPartSlot ].weight = 1.0f - m_fPartBlends[ torso ]; + fWeightTotal += 1.0f - m_fPartBlends[ torso ]; + } + + edict->s.actionWeight = fWeightTotal; + } + else + { + m_fPartBlends[ torso ] = 0.0f; + StopAnimating( iOldPartSlot ); + partOldAnim[ torso ] = ""; + edict->s.frameInfo[ iPartSlot ].weight = partAnim[ torso ] != "" ? 1.0f : 0.0f; + edict->s.actionWeight = partAnim[ torso ] != "" ? 1.0f : 0.0f; + } + } +} + +void Player::PlayerAnimDelta + ( + float *vDelta + ) + +{ + float fTimeDelta; + float fBackTime; + float vNewDelta[ 3 ]; + int animnum; + + VectorClear( vDelta ); + + if( m_fLastDeltaTime >= level.time ) { + return; + } + + fTimeDelta = level.time - m_fLastDeltaTime; + + animnum = -1; + + if( partAnim[ legs ] != "" ) + { + animnum = CurrentAnim( m_iPartSlot[ legs ] ); + } + + if( animnum != -1 ) + { + fBackTime = GetTime( m_iPartSlot[ legs ] ) - fTimeDelta; + if( fBackTime < 0.0f ) { + fBackTime = 0.0f; + } + + float fTime = GetTime( m_iPartSlot[ legs ] ); + + // get the anim delta + gi.Anim_DeltaOverTime( edict->tiki, animnum, fBackTime, fTime, vNewDelta ); + + VectorMA( vDelta, edict->s.frameInfo[ m_iPartSlot[ legs ] ].weight, vNewDelta, vDelta ); + } + + animnum = -1; + + if( partAnim[ torso ] != "" ) + { + animnum = CurrentAnim( m_iPartSlot[ torso ] ); + } + + if( animnum != -1 ) + { + fBackTime = GetTime( m_iPartSlot[ torso ] ) - fTimeDelta; + if( fBackTime < 0.0f ) { + fBackTime = 0.0f; + } + + float fTime = GetTime( m_iPartSlot[ torso ] ); + + gi.Anim_DeltaOverTime( edict->tiki, animnum, fBackTime, fTime, vNewDelta ); + + VectorMA( vDelta, edict->s.frameInfo[ m_iPartSlot[ torso ] ].weight, vNewDelta, vDelta ); + } +} + +void Player::CheckReloadWeapons + ( + void + ) + +{ + Weapon *weap; + + weap = GetActiveWeapon( WEAPON_OFFHAND ); + if( weap ) + { + weap->CheckReload( FIRE_PRIMARY ); + } + + weap = GetActiveWeapon( WEAPON_MAIN ); + if( weap ) + { + weap->CheckReload( FIRE_PRIMARY ); + } +} + +void Player::UpdateMisc + ( + void + ) + +{ + // + // clear out the level exit flag + // + client->ps.pm_flags &= ~PMF_LEVELEXIT; + + // + // see if our camera is the level exit camera + // + if( camera && camera->IsLevelExit() ) + { + client->ps.pm_flags |= PMF_LEVELEXIT; + } + else if( level.near_exit ) + { + client->ps.pm_flags |= PMF_LEVELEXIT; + } + + // + // do anything special for respawns + // + if( client->ps.pm_flags & PMF_RESPAWNED ) + { + // + // change music + // + if( music_current_mood != mood_success ) + { + ChangeMusic( "success", "normal", false ); + } + } +} + +/* +================= +EndFrame + +Called for each player at the end of the server frame +and right after spawning +================= +*/ +void Player::EndFrame + ( + void + ) + +{ + FinishMove(); + UpdateStats(); + UpdateMusic(); + UpdateReverb(); + UpdateMisc(); + + if( !g_spectatefollow_firstperson->integer || + !IsSpectator() || + !m_iPlayerSpectating ) + { + SetupView(); + } + else + { + gentity_t *ent = g_entities + m_iPlayerSpectating - 1; + + if( !ent->inuse || + !ent->entity || + ent->entity->deadflag >= DEAD_DEAD ) + { + SetupView(); + } + } +} + +void Player::GibEvent + ( + Event *ev + ) + + { + qboolean hidemodel; + + hidemodel = !ev->GetInteger( 1 ); + + if ( com_blood->integer ) + { + if ( hidemodel ) + { + gibbed = true; + takedamage = DAMAGE_NO; + setSolidType( SOLID_NOT ); + hideModel(); + } + + CreateGibs( this, health, 0.75f, 3 ); + } + } + +void Player::GotKill + ( + Event *ev + ) + + { +/* + Entity *victim; + Entity *inflictor; + float damage; + int meansofdeath; + qboolean gibbed; + + if ( deathmatch->integer ) + { + return; + } + + victim = ev->GetEntity( 1 ); + damage = ev->GetInteger( 2 ); + inflictor = ev->GetEntity( 3 ); + meansofdeath = ev->GetInteger( 4 ); + gibbed = ev->GetInteger( 5 ); +*/ + } + +void Player::SetPowerupTimer + ( + Event *ev + ) + + { + Event *event; + + poweruptimer = ev->GetInteger( 1 ); + poweruptype = ev->GetInteger( 2 ); + event = new Event( EV_Player_UpdatePowerupTimer ); + PostEvent ( event, 1 ); + } + +void Player::UpdatePowerupTimer + ( + Event *ev + ) + + { + poweruptimer -= 1; + if ( poweruptimer > 0 ) + { + PostEvent( ev, 1 ); + } + else + { + poweruptype = 0; + } + } + +void Player::ChangeMusic + ( + const char * current, + const char * fallback, + qboolean force + ) + +{ + int current_mood_num; + int fallback_mood_num; + + music_forced = force; + + if( current ) + { + current_mood_num = MusicMood_NameToNum( current ); + if( current_mood_num < 0 ) + { + gi.DPrintf( "current music mood %s not found", current ); + } + else + { + music_current_mood = current_mood_num; + } + } + + if( fallback ) + { + fallback_mood_num = MusicMood_NameToNum( fallback ); + if( fallback_mood_num < 0 ) + { + gi.DPrintf( "fallback music mood %s not found", fallback ); + fallback = NULL; + } + else + { + music_fallback_mood = fallback_mood_num; + } + } +} + +void Player::ChangeMusicVolume + ( + float volume, + float fade_time + ) + + { + music_volume_fade_time = fade_time; + music_saved_volume = music_current_volume; + music_current_volume = volume; + } + +void Player::RestoreMusicVolume + ( + float fade_time + ) + + { + music_volume_fade_time = fade_time; + music_current_volume = music_saved_volume; + music_saved_volume = -1.0; + } + +void Player::Jump + ( + Event *ev + ) + + { + float maxheight; + + maxheight = ev->GetFloat( 1 ); + + if ( maxheight > 16 ) + { + // v^2 = 2ad + velocity[ 2 ] += sqrt( 2 * sv_gravity->integer * maxheight ); + + // make sure the player leaves the ground + client->ps.walking = qfalse; + } + } + +void Player::JumpXY + ( + Event *ev + ) + +{ + float forwardmove; + float sidemove; + float distance; + float time; + float speed; + + forwardmove = ev->GetFloat( 1 ); + sidemove = ev->GetFloat( 2 ); + speed = ev->GetFloat( 3 ); + + velocity = yaw_forward * forwardmove - yaw_left * sidemove; + distance = velocity.length(); + velocity *= speed / distance; + time = distance / speed; + velocity[ 2 ] = sv_gravity->integer * time * 0.5f; + + airspeed = distance; + + // make sure the player leaves the ground + client->ps.walking = qfalse; +} + +Vector Player::EyePosition + ( + void + ) + +{ + return m_vViewPos; +} + +void Player::GetViewangles + ( + Event *ev + ) + +{ + ev->AddVector( v_angle ); +} + +void Player::SetViewangles + ( + Event *ev + ) + +{ + SetViewAngles( ev->GetVector( 1 ) ); +} + +void Player::SetViewAngles + ( + Vector newViewangles + ) + +{ + // set the delta angle + client->ps.delta_angles[ 0 ] = ANGLE2SHORT( newViewangles.x - client->cmd_angles[ 0 ] ); + client->ps.delta_angles[ 1 ] = ANGLE2SHORT( newViewangles.y - client->cmd_angles[ 1 ] ); + client->ps.delta_angles[ 2 ] = ANGLE2SHORT( newViewangles.z - client->cmd_angles[ 2 ] ); + + v_angle = newViewangles; + + // get the pitch and roll from our leg angles + newViewangles.x = angles.x; + newViewangles.z = angles.z; + AnglesToMat( newViewangles, orientation ); + yaw_forward = orientation[ 0 ]; + yaw_left = orientation[ 1 ]; +} + +Vector Player::GetViewAngles + ( + void + ) + +{ + return v_angle; +} + +void Player::DumpState + ( + Event *ev + ) + + { + gi.DPrintf( "Legs: %s Torso: %s\n", currentState_Legs ? currentState_Legs->getName() : "NULL", currentState_Torso->getName() ); + } + +void Player::ForceLegsState + ( + Event *ev + ) + +{ + State *ls = statemap_Legs->FindState( ev->GetString( 1 ) ); + EvaluateState( NULL, ls ); +} + +void Player::ForceTorsoState + ( + Event *ev + ) + +{ + State *ts = statemap_Torso->FindState( ev->GetString( 1 ) ); + EvaluateState( ts ); +} + +int Player::GetNumKills( void ) const +{ + return num_kills; +} + +int Player::GetNumDeaths( void ) const +{ + return num_deaths; +} + +void Player::AddKills( int num ) +{ + num_kills += num; + + if( g_gametype->integer >= GT_TEAM_ROUNDS ) + { + num_deaths += num; + } +} + +void Player::AddDeaths( int num ) +{ + num_deaths += num; +} + +DM_Team *Player::GetDM_Team() +{ + return current_team; +} + +void Player::SetDM_Team( DM_Team *team ) +{ + current_team = team; + + if( team ) + { + dm_team = team->teamType; + if( dm_team == TEAM_ALLIES ) + { + edict->s.eFlags |= EF_ALLIES; + } + else if( dm_team == TEAM_AXIS ) + { + edict->s.eFlags |= EF_AXIS; + } + } + else + { + dm_team = TEAM_NONE; + } + + client->pers.team = dm_team; + + if( m_fTeamSelectTime != level.time && ( edict->s.eFlags & ( EF_ALLIES | EF_AXIS ) ) ) + { + InitModel(); + } +} + +teamtype_t Player::GetTeam() +{ + return dm_team; +} + +void Player::SetTeam( teamtype_t team ) +{ + dmManager.JoinTeam( this, team ); + + if( dm_team == TEAM_SPECTATOR ) + { + Spectator(); + } +} + +void Player::BeginTempSpectator( void ) +{ + m_bTempSpectator = true; + + RemoveFromVehiclesAndTurrets(); + + m_iPlayerSpectating = 0; + + takedamage = DAMAGE_NO; + health = max_health; + deadflag = 0; + + client->ps.feetfalling = 0; + client->ps.pm_flags |= PMF_SPECTATING; + + EvaluateState( statemap_Torso->FindState( "STAND" ), statemap_Legs->FindState( "STAND" ) ); + setSolidType( SOLID_NOT ); + setMoveType( MOVETYPE_NOCLIP ); + + FreeInventory(); + + hideModel(); + + SetPlayerSpectate(); +} + +void Player::EndSpectator( void ) +{ + m_bSpectator = false; + m_bTempSpectator = false; + + client->ps.pm_flags &= ~( PMF_SPECTATING | PMF_SPECTATE_FOLLOW ); +} + +void Player::Spectator( void ) +{ + if( !IsSpectator() ) { + respawn_time = level.time + 1.0f; + } + + RemoveFromVehiclesAndTurrets(); + + takedamage = DAMAGE_NO; + m_iPlayerSpectating = 0; + health = max_health; + deadflag = 0; + + m_bSpectator = m_bTempSpectator ^ 1; + + client->ps.feetfalling = 0; + client->ps.pm_flags |= PMF_SPECTATING; + + movecontrol = MOVECONTROL_USER; + EvaluateState( statemap_Torso->FindState( "STAND" ), statemap_Legs->FindState( "STAND" ) ); + + setSolidType( SOLID_NOT ); + setMoveType( MOVETYPE_NOCLIP ); + + FreeInventory(); + + hideModel(); + + SetPlayerSpectate(); +} + +bool Player::IsValidSpectatePlayer( Player *pPlayer ) +{ + if( g_gametype->integer <= GT_FFA ) { + return true; + } + + if( GetTeam() <= TEAM_FREEFORALL + || !g_forceteamspectate->integer + || !GetDM_Team()->NumLivePlayers() + || pPlayer->GetTeam() == GetTeam() ) + { + return true; + } + else + { + return false; + } +} + +void Player::SetPlayerSpectate( void ) +{ + int i; + gentity_t *ent; + Player *pPlayer; + + if( m_iPlayerSpectating >= game.maxclients ) + m_iPlayerSpectating = 0; + + while( 1 ) + { + for( i = m_iPlayerSpectating, ent = g_entities + i; i < game.maxclients; i++, ent++ ) + { + if( !ent->inuse || !ent->entity ) { + continue; + } + + pPlayer = ( Player * )ent->entity; + + if( !pPlayer->IsDead() && !pPlayer->IsSpectator() && IsValidSpectatePlayer( pPlayer ) ) + { + m_iPlayerSpectating = i + 1; + client->ps.camera_flags = client->ps.camera_flags & ~CF_CAMERA_CUT_BIT | client->ps.camera_flags & CF_CAMERA_CUT_BIT ^ CF_CAMERA_CUT_BIT; + return; + } + } + + if( !m_iPlayerSpectating ) + return; + + m_iPlayerSpectating = 0; + } +} + +void Player::Spectator + ( + Event *ev + ) + +{ + client->pers.weapon[ 0 ] = 0; + SetTeam( TEAM_SPECTATOR ); +} + +bool Player::IsSpectator( void ) +{ + return ( m_bSpectator || m_bTempSpectator ); +} + +void Player::BeginFight( void ) +{ + m_bAllowFighting = true; +} + +void Player::EndFight( void ) +{ + m_bAllowFighting = false; +} + +void Player::EventGetUseHeld + ( + Event *ev + ) + +{ + ev->AddInteger( buttons & BUTTON_USE ? qtrue : qfalse ); +} + +void Player::EventGetFireHeld + ( + Event *ev + ) + +{ + ev->AddInteger( buttons & ( BUTTON_ATTACK | BUTTON_ATTACK2 ) ? qtrue : qfalse ); +} + +void Player::Score + ( + Event *ev + ) + +{ + dmManager.Score( this ); +} + +void Player::WonMatch( void ) +{ + num_won_matches++; +} + +void Player::LostMatch( void ) +{ + num_lost_matches++; +} + +void Player::HUDPrint( const char *s ) +{ + gi.SendServerCommand( edict - g_entities, "hudprint \"%s\"\n", s ); +} + +void Player::GetIsDisguised + ( + Event *ev + ) + +{ + ev->AddInteger( m_bIsDisguised ); +} + +void Player::GetHasDisguise + ( + Event *ev + ) + +{ + ev->AddInteger( m_bHasDisguise ); +} + +void Player::SetHasDisguise + ( + Event *ev + ) + +{ + m_bHasDisguise = ev->GetBoolean( 1 ); +} + +void Player::SetObjectiveCount + ( + Event *ev + ) + +{ + m_iObjectivesCompleted = ev->GetInteger( 1 ); + m_iNumObjectives = ev->GetInteger( 2 ); +} + +void Player::EventDMDeathDrop + ( + Event *ev + ) +{ + Weapon *weapon = GetActiveWeapon( WEAPON_MAIN ); + SpawnArgs args; + ClassDef *cls; + + if( !m_bDontDropWeapons && weapon && weapon->IsSubclassOfWeapon() ) + { + weapon->Drop(); + } + + args.setArg( "model", "models/items/dm_50_healthbox.tik" ); + + cls = args.getClassDef(); + if( cls ) + { + Item *item = ( Item * )cls->newInstance(); + if( item ) + { + if( item->IsSubclassOfItem() ) + { + item->setModel( "models/items/dm_50_healthbox.tik" ); + + item->SetOwner( this ); + item->ProcessPendingEvents(); + item->Drop(); + } + else + { + // useless and not pickupable, delete it + delete item; + } + } + } + + FreeInventory(); +} + +void Player::EventStopwatch + ( + Event *ev + ) +{ + int iDuration = ev->GetInteger( 1 ); + if( iDuration < 0 ) + { + ScriptError( "duration < 0" ); + } + + SetStopwatch( iDuration ); +} + +void Player::SetStopwatch + ( + int iDuration + ) +{ + int iStartTime = 0; + char szCmd[ 256 ]; + + if( iDuration ) + { + iStartTime = ( int )level.svsFloatTime; + } + + sprintf( szCmd, "stopwatch %i %i", iStartTime, iDuration ); + gi.SendServerCommand( edict - g_entities, szCmd ); +} + +void Player::CallVote + ( + Event *ev + ) + +{ + str arg1; + str arg2; + + if( !g_gametype->integer ) + return; + + if( !g_allowvote->integer ) + { + HUDPrint( gi.LV_ConvertString( "Voting not allowed here." ) ); + return; + } + + if( level.m_voteTime != 0.0f ) + { + HUDPrint( gi.LV_ConvertString( "A vote is already in progress." ) ); + return; + } + + if( votecount >= MAX_VOTE_COUNT ) + { + HUDPrint( va( "%s (%d).\n", gi.LV_ConvertString( "You have called the maximum number of votes" ), MAX_VOTE_COUNT ) ); + return; + } + + arg1 = ev->GetString( 1 ); + arg2 = ev->GetString( 2 ); + + if( strchr( arg1.c_str(), ';' ) || strchr( arg2.c_str(), ';' ) ) + { + HUDPrint( gi.LV_ConvertString( "Invalid vote string." ) ); + return; + } + + if( Q_stricmp( arg1.c_str(), "restart" ) && + Q_stricmp( arg1.c_str(), "nextmap" ) && + Q_stricmp( arg1.c_str(), "map" ) && + Q_stricmp( arg1.c_str(), "g_gametype" ) && + Q_stricmp( arg1.c_str(), "kick" ) && + Q_stricmp( arg1.c_str(), "clientkick" ) && + Q_stricmp( arg1.c_str(), "fraglimit" ) ) + { + HUDPrint( gi.LV_ConvertString( "Invalid vote string." ) ); + HUDPrint( va( "%s restart, nextmap, map , g_gametype , fraglimit , timelimit , kick , and clientkick .", + gi.LV_ConvertString( "Vote commands are:" ) ) ); + + return; + } + + if( !Q_stricmp( arg1.c_str(), "kick" ) ) + { + gentity_t *ent; + int i; + + for( i = 0; i < game.maxclients; i++ ) + { + ent = &g_entities[ i ]; + + if( !ent->inuse || !ent->client || !ent->entity ) + continue; + + if( !Q_stricmp( ent->client->pers.netname, arg2.c_str() ) ) + { + // Prevent the player from kicking himself out + if( ent->entity == this ) + { + HUDPrint( gi.LV_ConvertString( "You are not allowed to kick yourself." ) ); + return; + } + + break; + } + } + + if( i == game.maxclients ) + { + HUDPrint( va("%s %s", gi.LV_ConvertString( "is not a valid player name to kick." ) ) ); + } + } + else if( !Q_stricmp( arg1.c_str(), "map" ) && *sv_nextmap->string ) + { + level.m_voteString = va( "%s %s; set next map \"%s\"", arg1.c_str(), arg2.c_str(), arg2.c_str() ); + } + else + { + level.m_voteString = va( "%s %s", arg1.c_str(), arg2.c_str() ); + } + + dmManager.PrintAllClients( va( "%s %s: %s\n", client->pers.netname, gi.LV_ConvertString( "called a vote" ), level.m_voteString.c_str() ) ); + + level.m_voteYes = 1; + level.m_voteNo = 0; + level.m_voteTime = level.time; + + // Reset all player's vote + for( int i = 0; i < game.maxclients; i++ ) + { + gentity_t *ent = &g_entities[ i ]; + + if( !ent->client || !ent->inuse ) + continue; + + Player *p = ( Player * )ent->entity; + + p->voted = false; + } + + voted = true; + votecount++; + + level.m_numVoters = 0; +} + +void Player::Vote + ( + Event *ev + ) + +{ + if( level.m_voteTime == 0.0f ) + { + HUDPrint( gi.LV_ConvertString( "No vote in progress." ) ); + return; + } + + if( voted ) + { + HUDPrint( gi.LV_ConvertString( "Vote already cast." ) ); + return; + } + + if( ev->NumArgs() != 1 ) + { + HUDPrint( va( "%s: vote <1|0|y|n>", gi.LV_ConvertString( "Usage" ) ) ); + return; + } + + HUDPrint( gi.LV_ConvertString( "Vote cast." ) ); + voted = true; + + str arg1 = ev->GetString( 1 ); + + if( *arg1 == 'y' || *arg1 == 'Y' || *arg1 == '1' ) + level.m_voteYes++; + else + level.m_voteNo++; +} + +void Player::EventCoord + ( + Event *ev + ) + +{ + const char *s = va( "location: %.2f %.2f %.2f\nangles: %.2f %.2f %.2f\n(use 'tele' or 'face' to set)\n", + origin[ 0 ], origin[ 1 ], origin[ 2 ], v_angle[ 0 ], v_angle[ 1 ], v_angle[ 2 ] ); + + HUDPrint( s ); + gi.Printf( s ); +} + +void Player::EventStuffText + ( + Event *ev + ) + +{ + if( level.spawning ) + { + Event *event = new Event( EV_Player_StuffText ); + event->AddValue( ev->GetValue( 1 ) ); + PostEvent( event, level.frametime, 0 ); + } + else + { + gi.SendServerCommand( edict - g_entities, "stufftext \"%s\"", ev->GetString( 1 ).c_str() ); + } +} + + +void Player::EventSetVoiceType + ( + Event *ev + ) + +{ + str sVoiceName = ev->GetString( 1 ); + + if( !sVoiceName.icmp( "airborne" ) ) + { + m_voiceType = PVT_ALLIED_AIRBORNE; + } + else if( !sVoiceName.icmp( "manon" ) ) + { + m_voiceType = PVT_ALLIED_MANON; + } + else if( !sVoiceName.icmp( "SAS" ) ) + { + m_voiceType = PVT_ALLIED_SAS; + } + else if( !sVoiceName.icmp( "pilot" ) ) + { + m_voiceType = PVT_ALLIED_PILOT; + } + else if( !sVoiceName.icmp( "army" ) ) + { + m_voiceType = PVT_ALLIED_ARMY; + } + else if( !sVoiceName.icmp( "ranger" ) ) + { + m_voiceType = PVT_ALLIED_RANGER; + } + else if( !sVoiceName.icmp( "axis1" ) ) + { + m_voiceType = PVT_AXIS_AXIS1; + } + else if( !sVoiceName.icmp( "axis2" ) ) + { + m_voiceType = PVT_AXIS_AXIS2; + } + else if( !sVoiceName.icmp( "axis3" ) ) + { + m_voiceType = PVT_AXIS_AXIS3; + } + else if( !sVoiceName.icmp( "axis4" ) ) + { + m_voiceType = PVT_AXIS_AXIS4; + } + else if( !sVoiceName.icmp( "axis5" ) ) + { + m_voiceType = PVT_AXIS_AXIS5; + } + else + { + m_voiceType = PVT_NONE_SET; + } +} + +void Player::EventEnterIntermission + ( + Event *ev + ) + +{ + if( !level.intermissiontime ) { + return; + } + + if( level.intermissiontype ) + { + G_DisplayScores( this ); + + if( level.intermissiontype == TRANS_MISSION_FAILED || IsDead() ) + { + gi.Cvar_Set( "g_success", "0" ); + gi.Cvar_Set( "g_failed", "1" ); + } + else + { + gi.Cvar_Set( "g_success", "1" ); + gi.Cvar_Set( "g_failed", "0" ); + } + } + else + { + G_HideScores( this ); + } +} + +void Player::EnterTurret + ( + Event *ev + ) + +{ + TurretGun *ent = ( TurretGun * )ev->GetEntity( 1 ); + + if( !ent ) { + return; + } + + if( ent->IsSubclassOfTurretGun() ) { + return; + } + + EnterTurret( ent ); +} + +void Player::EnterTurret + ( + TurretGun *ent + ) + +{ + flags |= FL_PARTIAL_IMMOBILE; + viewheight = DEFAULT_VIEWHEIGHT; + + velocity = vec_zero; + + m_pTurret = ent; + setMoveType( MOVETYPE_TURRET ); + + SafeHolster( true ); +} + +void Player::ExitTurret + ( + Event *ev + ) + +{ + ExitTurret(); +} + +void Player::ExitTurret + ( + void + ) + +{ + flags &= ~FL_PARTIAL_IMMOBILE; + setMoveType( MOVETYPE_WALK ); + + m_pTurret = NULL; + + SafeHolster( qfalse ); +} + +void Player::TouchedUseAnim + ( + Entity * ent + ) + { + toucheduseanim = ent; + } + +void Player::NextPainTime + ( + Event *ev + ) + +{ + float time = ev->GetFloat( 1 ); + + nextpaintime = level.time + time; + + if( time >= 0.0f ) + { + pain = 0.0f; + pain_type = MOD_NONE; + pain_location = LOCATION_MISS; + + m_pLegsPainCond->clearCheck(); + m_pTorsoPainCond->clearCheck(); + } +} + +void Player::SetMouthAngle + ( + Event *ev + ) + + { + int tag_num; + float angle_percent; + Vector mouth_angles; + + + angle_percent = ev->GetFloat( 1 ); + + if ( angle_percent < 0 ) + angle_percent = 0; + + if ( angle_percent > 1 ) + angle_percent = 1; + + tag_num = gi.Tag_NumForName( edict->tiki, "tag_mouth" ); + + if ( tag_num != -1 ) + { + SetControllerTag( MOUTH_TAG, tag_num ); + + mouth_angles = vec_zero; + mouth_angles[PITCH] = max_mouth_angle * angle_percent; + + SetControllerAngles( MOUTH_TAG, mouth_angles ); + } + } + +void Player::EnterVehicle + ( + Event *ev + ) + +{ + Entity *ent; + + ent = ev->GetEntity( 1 ); + if( ent && ent->IsSubclassOfVehicle() ) + { + flags |= FL_PARTIAL_IMMOBILE; + viewheight = STAND_EYE_HEIGHT; + velocity = vec_zero; + m_pVehicle = ( Vehicle * )ent; + if( m_pVehicle->IsDrivable() ) + setMoveType( MOVETYPE_VEHICLE ); + else + setMoveType( MOVETYPE_NOCLIP ); + + SafeHolster( true ); + } +} + +void Player::ExitVehicle + ( + Event *ev + ) + +{ + flags &= ~FL_PARTIAL_IMMOBILE; + setMoveType( MOVETYPE_WALK ); + m_pVehicle = NULL; +} + +void Player::WeaponsNotHolstered + ( + void + ) + { + } + +void Player::WeaponsHolstered + ( + void + ) + { + } + +void Player::HolsterToggle + ( + Event *ev + ) +{ + if( deadflag ) + { + return; + } + + if( WeaponsOut() ) + { + // fucking compiler bug + // it won't call the parent's override function + ( ( Sentient * )this )->Holster( qtrue ); + } + else + { + ( ( Sentient * )this )->Holster( qfalse ); + } +} + +void Player::Holster + ( + Event *ev + ) +{ + SafeHolster( ev->GetBoolean( 1 ) ); +} + +void Player::WatchActor + ( + Event *ev + ) + + { + if ( camera || currentState_Torso->getCameraType() != CAMERA_BEHIND ) + return; + + actor_to_watch = (Actor *)ev->GetEntity( 1 ); + } + +void Player::StopWatchingActor + ( + Event *ev + ) + + { + Actor *old_actor; + + old_actor = (Actor *)ev->GetEntity( 1 ); + + if ( old_actor == actor_to_watch ) + actor_to_watch = NULL; + } + +void Player::setAngles + ( + Vector ang + ) + +{ + // set the angles normally + + if( bindmaster ) + { + ang -= bindmaster->angles; + } + + Entity::setAngles( ang ); +} + +void Player::PlayerDone + ( + Event *ev + ) + +{ + // This is used to let scripts know that the player is done doing something +} + +painDirection_t Player::Pain_string_to_int + ( + str pain + ) + + { + if ( !pain.icmp( pain, "Front" ) ) + return PAIN_FRONT; + else if ( !pain.icmp( pain, "Left" ) ) + return PAIN_LEFT; + else if ( !pain.icmp( pain, "Right" ) ) + return PAIN_RIGHT; + else if ( !pain.icmp( pain, "Rear" ) ) + return PAIN_REAR; + else + return PAIN_NONE; + } + +void Player::ArchivePersistantData + ( + Archiver &arc + ) + +{ + str model_name; + + Sentient::ArchivePersistantData( arc ); + + model_name = g_playermodel->string; + + arc.ArchiveString( &model_name ); + + if( arc.Loading() ) + { + // set the cvar + gi.Cvar_Set( "g_playermodel", model_name.c_str() ); + + model_name += ".tik"; + setModel( model_name.c_str() ); + } + + str name; + if( arc.Saving() ) + { + if( holsteredWeapon ) + { + name = holsteredWeapon->getName(); + } + else + { + name = "none"; + } + } + arc.ArchiveString( &name ); + if( arc.Loading() ) + { + if( name != "none" ) + { + holsteredWeapon = ( Weapon * )FindItem( name ); + } + } + + UpdateWeapons(); + + // Force a re-evaluation of the player's state + LoadStateTable(); +} + +void Player::SpawnDamageEffect + ( + meansOfDeath_t mod + ) + +{ + switch( mod ) + { + case MOD_ELECTRIC: + case MOD_ELECTRICWATER: + { + SpawnEffect( "fx_elecstrike.tik", origin ); + Sound( "sound/weapons/sword/electric/hitmix2.wav", 0 ); + } + default: + { + } + } +} + +void Player::VelocityModified + ( + void + ) + +{ + +} + +int Player::GetKnockback + ( + int original_knockback, + qboolean blocked + ) + +{ + int new_knockback; + + new_knockback = original_knockback - 50; + + // See if we still have enough knockback to knock the player down + if( new_knockback >= 200 && take_pain ) + { + knockdown = true; + + if( blocked ) + { + float damage; + + damage = new_knockback / 50; + + if( damage > 10 ) + damage = 10; + + Damage( world, world, damage, origin, vec_zero, vec_zero, 0, DAMAGE_NO_ARMOR, MOD_CRUSH ); + } + } + + // Make sure knockback is still at least 0 + + if( new_knockback < 0 ) + new_knockback = 0; + + return new_knockback; +} + +int Player::GetMoveResult + ( + void + ) + +{ + return moveresult; +} + +void Player::ResetHaveItem + ( + Event *ev + ) + { + str fullname; + ScriptVariable * var; + + fullname = str( "playeritem_" ) + ev->GetString( 1 ); + + var = game.vars->GetVariable( fullname.c_str() ); + + if ( var ) + var->setIntValue( 0 ); + } + +void Player::Join_DM_Team + ( + Event *ev + ) + +{ + teamtype_t team; + str teamname; + const char *join_message; + + teamname = ev->GetString( 1 ); + + if( !teamname.icmp( "allies" ) ) + { + team = TEAM_ALLIES; + } + else if( !teamname.icmp( "axis" ) || + !teamname.icmp( "german" ) || + !teamname.icmp( "nazi" ) ) + { + team = TEAM_AXIS; + } + else + { + team = TEAM_AXIS; + } + + if( current_team && current_team->m_teamnumber == team ) + { + return; + } + + float startTime = dmManager.GetMatchStartTime(); + + if( startTime >= 0.0f && ( level.time - startTime ) > 20.0f && + ( level.time - m_fTeamSelectTime ) < g_teamswitchdelay->integer && team != TEAM_SPECTATOR ) + { + gi.SendServerCommand( edict - g_entities, "print \"" HUD_MESSAGE_WHITE "%s %i %s\n\"", gi.LV_ConvertString( "Can not change teams again for another" ), ( int )( g_teamswitchdelay->integer - ( level.time - m_fTeamSelectTime ) + 1.0f ), gi.LV_ConvertString( "seconds" ) ); + return; + } + + m_fTeamSelectTime = level.time; + SetTeam( team ); + + if( client->pers.weapon[ 0 ] ) + { + if( IsSpectator() ) + { + EndSpectator(); + PostEvent( EV_Player_Respawn, 0 ); + } + else if( g_gametype->integer <= 1 ) + { + PostEvent( EV_Kill, 0 ); + } + else + { + PostEvent( EV_Player_Respawn, 0 ); + } + } + else + { + gi.SendServerCommand( edict - g_entities, "stufftext \"wait 250;pushmenu_weaponselect\"" ); + } + + if( g_gametype->integer > 1 ) + { + if( GetTeam() == TEAM_ALLIES ) + { + join_message = "has joined the Allies"; + } + else if( GetTeam() == TEAM_AXIS ) + { + join_message = "has joined the Axis"; + } + else + { + return; + } + + G_PrintToAllClients( va( "%s %s\n", client->pers.netname, gi.LV_ConvertString( join_message ) ) ); + } +} + +void Player::Auto_Join_DM_Team + ( + Event *ev + ) + +{ + Event *event = new Event( EV_Player_JoinDMTeam ); + + if( dmManager.GetAutoJoinTeam() == TEAM_AXIS ) + { + event->AddString( "axis" ); + } + else + { + event->AddString( "allies" ); + } + + ProcessEvent( event ); +} + +void Player::Leave_DM_Team + ( + Event *ev + ) + +{ + // FIXME: should it stays disabled ? +#if 0 + if( current_team ) + { + dmManager.LeaveTeam( this ); + } + else + { + gi.centerprintf( edict, gi.LV_ConvertString( "You are not on a team" ) ); + } +#endif +} + +void Player::EventPrimaryDMWeapon + ( + Event *ev + ) + +{ + str dm_weapon = ev->GetString( 1 ); + + Q_strncpyz( client->pers.weapon, dm_weapon.c_str(), sizeof( client->pers.weapon ) ); + + if( m_bSpectator ) + { + if( current_team && ( current_team->teamType == TEAM_AXIS || current_team->teamType == TEAM_ALLIES ) ) + { + EndSpectator(); + + if( deadflag ) { + deadflag = DEAD_DEAD; + } + + PostEvent( EV_Player_Respawn, 0 ); + + gi.centerprintf( edict, "" ); + } + else + { + gi.SendServerCommand( edict - g_entities, "stufftext \"wait 250;pushmenu_teamselect\"" ); + } + } + else + { + gi.SendServerCommand( edict - g_entities, "print \"" HUD_MESSAGE_WHITE "%s\n\"", "Will switch to new weapon next time you respawn" ); + } +} + +void Player::PlayerReload + ( + Event *ev + ) + +{ + Weapon *weapon; + + if( deadflag ) + return; + + weapon = GetActiveWeapon( WEAPON_MAIN ); + + if( !weapon ) + return; + + if( weapon->CheckReload( FIRE_PRIMARY ) ) + weapon->SetShouldReload( true ); +} + +void Player::EventCorrectWeaponAttachments + ( + Event *ev + ) + +{ + int iChild; + int iNumChildren; + int iTagRight; + int iTagLeft; + qboolean iUseAngles; + Vector vOffset; + Entity *pChild; + + iTagRight = gi.Tag_NumForName( edict->tiki, "tag_weapon_right" ); + iTagLeft = gi.Tag_NumForName( edict->tiki, "tag_weapon_left" ); + iNumChildren = numchildren; + + for( int i = 0; i < iNumChildren; i++ ) + { + iChild = children[ i ]; + + if( iChild == ENTITYNUM_NONE ) { + continue; + } + + pChild = G_GetEntity( iChild ); + if( !pChild ) { + continue; + } + + if( pChild->edict->s.tag_num == iTagLeft || pChild->edict->s.tag_num == iTagRight ) + { + if( pChild->IsSubclassOfWeapon() ) + { + if( pChild->edict->s.tag_num == iTagLeft ) + { + iUseAngles = edict->s.attach_use_angles; + vOffset = edict->s.attach_offset; + + // reattach to the right tag + detach(); + attach( entnum, iTagRight, iUseAngles, vOffset ); + } + } + else + { + // Remove entities like ammoclip + pChild->PostEvent( EV_Remove, 0 ); + } + } + } +} + +void Player::SelectNextItem + ( + Event *ev + ) + +{ + if( deadflag ) + { + return; + } + + Item *item = GetActiveWeapon( WEAPON_MAIN ); + + item = NextItem( item ); + + if( item ) + { + useWeapon( ( Weapon * )item, WEAPON_MAIN ); + } +} + +void Player::SelectPreviousItem + ( + Event *ev + ) + +{ + if( deadflag ) + { + return; + } + + Item *item = GetActiveWeapon( WEAPON_MAIN ); + + item = PrevItem( item ); + + if( item ) + { + useWeapon( ( Weapon * )item, WEAPON_MAIN ); + } +} + +void Player::SelectNextWeapon + ( + Event *ev + ) + +{ + if( deadflag ) + { + return; + } + + Weapon *weapon = GetActiveWeapon( WEAPON_MAIN ); + Weapon *activeWeapon = weapon; + + if( weapon ) + { + weapon = NextWeapon( weapon ); + + if( g_gametype->integer ) + { + while( weapon && weapon != activeWeapon && weapon->IsSubclassOfInventoryItem() ) + { + weapon = NextWeapon( weapon ); + } + } + } + else + { + weapon = WorstWeapon(); + } + + if( weapon && weapon != activeWeapon ) + { + useWeapon( weapon ); + } +} + +void Player::SelectPreviousWeapon + ( + Event *ev + ) + +{ + if( deadflag ) + { + return; + } + + Weapon *weapon = GetActiveWeapon( WEAPON_MAIN ); + Weapon *activeWeapon = weapon; + + if( weapon ) + { + weapon = PreviousWeapon( weapon ); + + if( g_gametype->integer ) + { + while( weapon && weapon != activeWeapon && weapon->IsSubclassOfInventoryItem() ) + { + weapon = PreviousWeapon( weapon ); + } + } + } + else + { + weapon = BestWeapon(); + } + + if( weapon && weapon != activeWeapon ) + { + useWeapon( weapon ); + } +} + +void Player::DropCurrentWeapon + ( + Event *ev + ) + +{ + Weapon *weapon; + Vector forward; + + if( !g_gametype->integer ) + { + return; + } + + weapon = GetActiveWeapon( WEAPON_MAIN ); + + if( !weapon ) + { + return; + } + + // Don't drop the weapon if we're charging + if( charge_start_time ) + { + return; + } + + if( ( weapon->GetWeaponClass() & WEAPON_CLASS_ITEM ) ) + { + SelectNextWeapon( NULL ); + takeItem( weapon->model ); + } + else + { + if( weapon->GetCurrentAttachToTag() != "tag_weapon_right" ) + { + EventCorrectWeaponAttachments( NULL ); + } + + // This check isn't in MOHAA + if( !weapon->IsDroppable() ) + { + return; + } + + weapon->Drop(); + + AngleVectors( m_vViewAng, forward, NULL, NULL ); + + // make the weapon looks like it's thrown + weapon->velocity = forward * 200.0f; + + edict->s.eFlags |= EF_UNARMED; + + SelectNextWeapon( NULL ); + + if( holsteredWeapon == weapon ) + { + holsteredWeapon = NULL; + } + if( lastActiveWeapon.weapon == weapon ) + { + lastActiveWeapon.weapon = NULL; + } + } +} + +void Player::ModifyHeight + ( + Event *ev + ) + +{ + str height = ev->GetString( 1 ); + + if ( !height.icmp( "stand" ) ) + { + viewheight = DEFAULT_VIEWHEIGHT; + maxs.z = 94.0f; + } + else if( !height.icmp( "jumpstart" ) ) + { + viewheight = JUMP_START_VIEWHEIGHT; + maxs.z = 94.0f; + } + else if( !height.icmp( "duck" ) ) + { + viewheight = CROUCH_VIEWHEIGHT; + maxs.z = 54.0f; + } + else if( !height.icmp( "duckrun" ) ) + { + viewheight = CROUCH_RUN_VIEWHEIGHT; + maxs.z = 60.0f; + } + else if( !height.icmp( "prone" ) ) + { + viewheight = PRONE_VIEWHEIGHT; + maxs.z = 20.0f; + } + else + { + gi.Printf( "Unknown modheight '%s' defaulting to stand\n", height.c_str() ); + viewheight = DEFAULT_VIEWHEIGHT; + maxs.z = 94.0f; + } +} + +void Player::SetMovePosFlags + ( + Event *ev + ) + +{ + str sParm; + + if( ev->NumArgs() <= 0 ) + { + Com_Printf( "moveposflags command without any parameters\n" ); + return; + } + + sParm = ev->GetString( 1 ); + + if( !sParm.icmp( "crouching" ) ) + { + m_iMovePosFlags = MPF_POSITION_CROUCHING; + } + else if( !sParm.icmp( "prone" ) ) + { + m_iMovePosFlags = MPF_POSITION_PRONE; + } + else if( !sParm.icmp( "offground" ) ) + { + m_iMovePosFlags = MPF_POSITION_OFFGROUND; + } + else + { + m_iMovePosFlags = MPF_POSITION_STANDING; + } + + if( ev->NumArgs() > 1 ) + { + sParm = ev->GetString( 2 ); + + if( !sParm.icmp( "walking" ) || + !sParm.icmp( "walking\"" ) // there is a mistake in WALK_FORWARD + ) + { + m_iMovePosFlags |= MPF_MOVEMENT_WALKING; + } + else if( !sParm.icmp( "running" ) ) + { + m_iMovePosFlags |= MPF_MOVEMENT_RUNNING; + } + else if( !sParm.icmp( "falling" ) ) + { + m_iMovePosFlags |= MPF_MOVEMENT_FALLING; + } + } +} + +void Player::GetPositionForScript + ( + Event *ev + ) + +{ + if( m_iMovePosFlags & MPF_POSITION_CROUCHING ) + { + ev->AddConstString( STRING_CROUCHING ); + } + else if( m_iMovePosFlags & MPF_POSITION_PRONE ) + { + ev->AddConstString( STRING_PRONE ); + } + else if( m_iMovePosFlags & MPF_POSITION_OFFGROUND ) + { + ev->AddConstString( STRING_OFFGROUND ); + } + else + { + ev->AddConstString( STRING_STANDING ); + } +} + +void Player::GetMovementForScript + ( + Event *ev + ) + +{ + if( m_iMovePosFlags & MPF_MOVEMENT_WALKING ) + { + ev->AddConstString( STRING_WALKING ); + } + else if( m_iMovePosFlags & MPF_MOVEMENT_RUNNING ) + { + ev->AddConstString( STRING_RUNNING ); + } + else if( m_iMovePosFlags & MPF_MOVEMENT_FALLING ) + { + ev->AddConstString( STRING_FALLING ); + } + else + { + ev->AddConstString( STRING_STANDING ); + } +} + +void Player::EventSetViewModelAnim + ( + Event *ev + ) + +{ + str anim; + int force_restart = 0; + qboolean bfullanim = 0; + + anim = ev->GetString( 1 ); + + if ( ev->NumArgs() > 1 ) { + force_restart = ev->GetInteger( 2 ); + } + + if ( ev->NumArgs() > 2 ) { + bfullanim = ev->GetInteger( 3 ); + } + + ViewModelAnim( anim, force_restart, bfullanim ); +} + +void Player::EventDMMessage + ( + Event *ev + ) + +{ + int mode; + str stuffstrings; + str convertedstuff; + str string; + str voiceName; + str soundName; + AliasListNode_t *list = NULL; + const char *prefix = NULL; + qboolean bInstaMessage = qfalse; + qboolean met_comment = false; + + if( !g_gametype->integer ) { + return; + } + + mode = ev->GetInteger( 1 ); + + if( ev->NumArgs() <= 1 ) { + return; + } + + string = ev->GetString( 2 ); + + // Check for taunts + if( string.length() == 3 && *string == '*' ) + { + char num1 = string[ 1 ]; + char num2 = string[ 2 ]; + + if( num1 > '0' && num1 <= '9' + && num2 > '0' && num2 <= '9' ) + { + if( IsSpectator() || IsDead() ) { + return; + } + + if( dm_team == TEAM_AXIS ) { + voiceName = "axis_"; + } else { + voiceName = "allied_"; + } + } + + switch( m_voiceType ) + { + case PVT_ALLIED_AIRBORNE: + voiceName += "airborne_"; + break; + + case PVT_ALLIED_MANON: + voiceName += "manon_"; + break; + + case PVT_ALLIED_SAS: + voiceName += "sas_"; + break; + + case PVT_ALLIED_PILOT: + voiceName += "pilot_"; + break; + + case PVT_ALLIED_ARMY: + voiceName += "army_"; + break; + + case PVT_ALLIED_RANGER: + voiceName += "ranger_"; + break; + + case PVT_AXIS_AXIS1: + voiceName += "axis1_"; + break; + + case PVT_AXIS_AXIS2: + voiceName += "axis2_"; + break; + + case PVT_AXIS_AXIS3: + voiceName += "axis3_"; + break; + + case PVT_AXIS_AXIS4: + voiceName += "axis4_"; + break; + + case PVT_AXIS_AXIS5: + voiceName += "axis5_"; + break; + + default: + if( dm_team != TEAM_AXIS ) { + voiceName += "army_"; + } else { + voiceName += "axis4_"; + } + } + + voiceName += va( "%c%c", num1 + '0', num2 + '0' ); + + FindAlias( soundName, voiceName, &list ); + + if( list ) + { + bInstaMessage = qtrue; + } + } + + if( !bInstaMessage ) + { + for( int i = 2; i <= ev->NumArgs(); i++ ) + { + string = ev->GetString( i ); + + if( strstr( string, "/*" ) ) { + met_comment = true; + } + + if( strstr( string, "*/" ) && met_comment ) + { + G_WarnPlayer( this, "Line comments ('/*' and '*/') are not allowed in messages.\n" ); + return; + } + + stuffstrings += " " + string; + convertedstuff += gi.LV_ConvertString( string ); + } + } + else + { + stuffstrings = " " + str( list->subtitle ); + } + + stuffstrings += "\n"; + + // Protect again buffer overflow exploit + if( stuffstrings.length() >= MAX_STRING_CHARS ) + { + HUDPrint( "The message you entered is too long.\n" ); + return; + } + + if( convertedstuff.length() >= MAX_STRING_CHARS ) + { + HUDPrint( "The message you entered is too long.\n" ); + return; + } + + // Prevent the comment glitch + // ley: The problem seems to be an issue with COM_Parse, which skips all C comments + if( strstr( client->pers.netname, "/*" ) ) { + met_comment = true; + } + + if( strstr( client->pers.netname, "//" ) || strstr( client->pers.netname, "*/" ) ) + { + HUDPrint( "C comments ('//', '/*' and '*/') are not allowed in names.\n" ); + return; + } + + if( IsSpectator() ) + { + if( mode > 0 && mode <= game.maxclients ) + { + const char *error = "Message Error: Spectators are not allowed to send private messages to non-spectators.\n"; + + gi.SendServerCommand( client->ps.clientNum, "print \"" HUD_MESSAGE_CHAT_WHITE "%s\"", error ); + return; + } + + prefix = gi.LV_ConvertString( "(spectator) " ); + string = prefix + str( client->pers.netname ) + ":" + str( stuffstrings ); + } + else if( IsDead() ) + { + if( mode > 0 && mode <= game.maxclients ) + { + const char *error = "Message Error: Dead players are not allowed to send private messages to active players.\n"; + + gi.SendServerCommand( client->ps.clientNum, "print \"" HUD_MESSAGE_CHAT_WHITE "%s\"", error ); + return; + } + + prefix = gi.LV_ConvertString( "(dead) " ); + string = prefix + str( client->pers.netname ) + ":" + str( stuffstrings ); + } + else + { + if( mode == -1 ) + { + string = "(team) " + str( client->pers.netname ) + ":" + str( stuffstrings ); + } + else + { + string = str( client->pers.netname ) + ":" + str( stuffstrings ); + } + } + + cvar_t *sv_chatter = gi.Cvar_Get( "sv_chatter", "0", 0 ); + if( sv_chatter && sv_chatter->integer ) + { + gi.Printf( "CHAT: %s", string.c_str() ); + } + + if( voiceName.length() ) + { + if( !IsDead() && ( !IsSpectator() || g_spectate_allow_full_chat->integer ) ) + { + gentity_t *ent; + int i; + + for( i = 0, ent = g_entities; i < game.maxclients; i++, ent++ ) + { + if( !ent->inuse || !ent->entity ) { + continue; + } + + gi.SendServerCommand( i, "print \"" HUD_MESSAGE_CHAT_WHITE "%s\"", string.c_str() ); + + if( bInstaMessage ) + { + gi.MSG_SetClient( i ); + gi.MSG_StartCGM( 37 ); + gi.MSG_WriteCoord( m_vViewPos[ 0 ] ); + gi.MSG_WriteCoord( m_vViewPos[ 1 ] ); + gi.MSG_WriteCoord( m_vViewPos[ 2 ] ); + gi.MSG_WriteBits( 1, 1 ); + gi.MSG_WriteBits( edict - g_entities, 6 ); + gi.MSG_WriteString( voiceName.c_str() ); + gi.MSG_EndCGM(); + } + } + + return; + } + } + + if( mode == -1 ) + { + int i; + gentity_t *ent; + Player *p; + + // team message + for( i = 0, ent = g_entities; i < game.maxclients; i++, ent++ ) + { + if( !ent->inuse || !ent->entity ) { + continue; + } + + p = ( Player * ) ent->entity; + + if( p->GetTeam() == GetTeam() ) + { + gi.SendServerCommand( i, "print \"" HUD_MESSAGE_CHAT_WHITE "%s\"", string.c_str() ); + } + } + } + else if( mode > 0 ) + { + gentity_t *ent = g_entities + mode; + + if( mode > game.maxclients || !ent->inuse || !ent->entity ) + { + gi.SendServerCommand( client->ps.clientNum, "print \"" HUD_MESSAGE_CHAT_WHITE "Message Error: %d is a bad client number\n\"", mode ); + return; + } + + gi.SendServerCommand( client->ps.clientNum, "print \"" HUD_MESSAGE_CHAT_WHITE "%s\"", string.c_str() ); + } + + gi.SendServerCommand( mode - 1, "print \"" HUD_MESSAGE_CHAT_WHITE "%s\"", string.c_str() ); +} + +void Player::EventIPrint + ( + Event *ev + ) + +{ + str sString = ev->GetString( 1 ); + qboolean iBold = qfalse; + + if( ev->NumArgs() > 1 ) + { + iBold = ev->GetInteger( 2 ); + } + + if( iBold ) + { + gi.SendServerCommand( edict - g_entities, "print \"" HUD_MESSAGE_WHITE "%s\n\"", sString.c_str() ); + } + else + { + gi.SendServerCommand( edict - g_entities, "print \"" HUD_MESSAGE_YELLOW "%s\n\"", sString.c_str() ); + } +} + +qboolean Player::ViewModelAnim( str anim, qboolean force_restart, qboolean bFullAnim ) +{ + Unregister( "viewmodelanim_done" ); + + if ( client == NULL ) { + return true; + } + + int viewModelAnim; + playerState_t * playerState = &client->ps; + + if ( !anim.length() ) { + anim = ""; + } + + if ( Q_stricmp( anim, "charge" ) == 0 ) { + viewModelAnim = VMA_CHARGE; + } else if ( Q_stricmp( anim, "fire" ) == 0 ) { + viewModelAnim = VMA_FIRE; + } else if ( Q_stricmp( anim, "fire_secondary" ) == 0 ) { + viewModelAnim = VMA_FIRE_SECONDARY; + } else if ( Q_stricmp( anim, "rechamber" ) == 0 ) { + viewModelAnim = VMA_RECHAMBER; + } else if ( Q_stricmp( anim, "reload" ) == 0 ) { + viewModelAnim = VMA_RELOAD; + } else if ( Q_stricmp( anim, "reload_single" ) == 0 ) { + viewModelAnim = VMA_RELOAD_SINGLE; + } else if ( Q_stricmp( anim, "reload_end" ) == 0 ) { + viewModelAnim = VMA_RELOAD_END; + } else if ( Q_stricmp( anim, "pullout" ) == 0 ) { + viewModelAnim = VMA_PULLOUT; + } else if ( Q_stricmp( anim, "putaway" ) == 0 ) { + viewModelAnim = VMA_PUTAWAY; + } else if ( Q_stricmp( anim, "ladderstep" ) == 0 ) { + viewModelAnim = VMA_LADDERSTEP; + } else if ( Q_stricmp( anim, "idle" ) == 0 ) { + viewModelAnim = VMA_IDLE; + } + else if ( level.reborn ) + { + if ( !anim.icmp( "enable" ) ) { + viewModelAnim = VMA_ENABLE; + } else { + viewModelAnim = VMA_CUSTOMANIMATION; + } + } + else + { + ScriptError( "Invalid view model animation %s !\n", anim.c_str() ); + + return false; + } + + // Copy the item prefix and the anim name + Item *item = GetActiveWeapon( WEAPON_MAIN ); + + if( !item ) + { + item = ( Item * )newActiveWeapon.weapon.Pointer(); + } + + if( item ) + { + m_sVMAcurrent = GetItemPrefix( item->getName() ) + str( "_" ) + anim; + } + else + { + m_sVMAcurrent = "unarmed_" + anim; + } + + m_sVMcurrent = anim; + + if ( level.reborn && viewModelAnim == VMA_CUSTOMANIMATION ) + { + gi.MSG_SetClient( edict - g_entities ); + + gi.MSG_StartCGM( CGM_VIEWMODELANIM ); + gi.MSG_WriteString( anim.c_str() ); + gi.MSG_WriteByte( bFullAnim ); + gi.MSG_EndCGM(); + } + + if ( viewModelAnim != playerState->iViewModelAnim || force_restart ) { + playerState->iViewModelAnimChanged = ( playerState->iViewModelAnimChanged + 1 ) & 3; + } + + playerState->iViewModelAnim = viewModelAnim; + + if( m_fpsTiki && gi.Anim_NumForName( m_fpsTiki, m_sVMAcurrent ) < 0 ) + { + gi.DPrintf( "WARNING: Invalid view model anim \"%s\"\n", m_sVMAcurrent.c_str() ); + } + + animDoneVM = false; + + m_fVMAtime = 0; + + return true; +} + +void Player::FindAlias( str &output, str name, AliasListNode_t **node ) +{ + const char *alias = gi.Alias_FindRandom( edict->tiki, name, node ); + + if( alias == NULL ) { + alias = gi.GlobalAlias_FindRandom( name, node ); + } + + if( alias != NULL ) { + output = alias; + } +} + +bool Player::IsReady + ( + void + ) const + +{ + return m_bReady; +} + +void Player::EventGetReady + ( + Event *ev + ) + +{ + ev->AddInteger( m_bReady ); +} + +void Player::EventSetReady + ( + Event *ev + ) + +{ + if( m_bReady ) + return; + + m_bReady = true; + gi.Printf( "%s is ready\n", client->pers.netname ); +} + +void Player::EventSetNotReady + ( + Event *ev + ) + +{ + if( !m_bReady ) + return; + + m_bReady = false; + gi.Printf( "%s is not ready\n", client->pers.netname ); +} + +void Player::EventGetDMTeam + ( + Event *ev + ) + +{ + if( dm_team == TEAM_FREEFORALL ) + { + ev->AddConstString( STRING_FREEFORALL ); + } + else if( dm_team == TEAM_AXIS ) + { + ev->AddConstString( STRING_AXIS ); + } + else if( dm_team == TEAM_ALLIES ) + { + ev->AddConstString( STRING_ALLIES ); + } + else if( dm_team == TEAM_SPECTATOR ) + { + ev->AddConstString( STRING_SPECTATOR ); + } + else + { + ScriptError( "dmteam is invalid in single player" ); + } +} + +void Player::EventSetPerferredWeapon + ( + Event *ev + ) + +{ + m_sPerferredWeaponOverride = ev->GetString( 1 ); +} + +void Player::ReceivedItem + ( + Item * item + ) + +{ + +} + +void Player::RemovedItem +( +Item * item +) + +{ + +} + +void Player::AmmoAmountChanged + ( + Ammo * ammo, + int ammo_in_clip + ) + +{ + str fullname; + ScriptVariable * var; + + // + // set our level variables + // + fullname = str( "playerammo_" ) + ammo->getName(); + + var = level.vars->GetVariable( fullname.c_str() ); + if( !var ) + { + level.vars->SetVariable( fullname.c_str(), ammo->getAmount() + ammo_in_clip ); + } + else + { + var->setIntValue( ammo->getAmount() + ammo_in_clip ); + } +} + +void Player::PhysicsOff + ( + Event *ev + ) + +{ + flags |= FL_IMMOBILE; +} + +void Player::PhysicsOn + ( + Event *ev + ) + +{ + flags &= ~FL_IMMOBILE; +} + +void Player::AttachToLadder + ( + Event *ev + ) + +{ + Vector vStart, vEnd, vOffset; + trace_t trace; + FuncLadder *pLadder; + + if( deadflag ) { + return; + } + + AngleVectors( m_vViewAng, vOffset, NULL, NULL ); + + vStart = m_vViewPos - vOffset * 12.0f; + vEnd = m_vViewPos + vOffset * 128.0f; + + trace = G_Trace( + vStart, + vec_zero, + vec_zero, + vEnd, + this, + MASK_LADDER, + qfalse, + "Player::AttachToLadder" ); + + if( trace.fraction == 1.0f || !trace.ent || !trace.ent->entity || + !trace.ent->entity->isSubclassOf( FuncLadder ) ) { + return; + } + + pLadder = ( FuncLadder * )trace.ent->entity; + m_pLadder = pLadder; + + pLadder->PositionOnLadder( this ); + + SetViewAngles( Vector( v_angle[ 0 ], angles[ 1 ], v_angle[ 2 ] ) ); +} + +void Player::UnattachFromLadder + ( + Event *ev + ) + +{ + m_pLadder = NULL; +} + +void Player::TweakLadderPos + ( + Event *ev + ) + +{ + FuncLadder *pLadder = ( FuncLadder * )m_pLadder.Pointer(); + + if( pLadder ) { + pLadder->AdjustPositionOnLadder( this ); + } +} + +void Player::EnsureOverLadder + ( + Event *ev + ) + +{ + FuncLadder *pLadder = ( FuncLadder * )m_pLadder.Pointer(); + + if( pLadder ) { + pLadder->EnsureOverLadder( this ); + } +} + +void Player::EnsureForwardOffLadder + ( + Event *ev + ) + +{ + FuncLadder *pLadder = ( FuncLadder * )m_pLadder.Pointer(); + + if( pLadder ) { + pLadder->EnsureForwardOffLadder( this ); + } +} + +void Player::RemoveFromVehiclesAndTurrets + ( + void + ) + +{ + if( m_pVehicle && m_pVehicle->isLocked() ) + { + m_pVehicle->UnLock(); + + if( m_pTurret ) + { + VehicleTurretGun *turret = ( VehicleTurretGun * )m_pTurret.Pointer(); + + if( turret->isLocked() ) + { + turret->UnLock(); + DoUse( NULL ); + turret->Lock(); + } + else + { + DoUse( NULL ); + } + } + else + { + DoUse( NULL ); + } + + m_pVehicle->Lock(); + } + + if( m_pTurret ) + { + VehicleTurretGun *turret = ( VehicleTurretGun * )m_pTurret.Pointer(); + + if( turret->isLocked() ) + { + turret->UnLock(); + DoUse( NULL ); + turret->Lock(); + } + else + { + DoUse( NULL ); + } + } + else + { + DoUse( NULL ); + } +} + +void Player::WaitForState + ( + Event *ev + ) + +{ + waitForState = ev->GetString( 1 ); +} + + +void Player::SetDamageMultiplier + ( + Event *ev + ) + +{ + damage_multiplier = ev->GetFloat( 1 ); +} + +void Player::SetTakePain + ( + Event *ev + ) + +{ + take_pain = ev->GetBoolean( 1 ); +} + +void Player::Loaded + ( + void + ) + +{ + UpdateWeapons(); +} + +void Player::PlayerShowModel + ( + Event *ev + ) + +{ + Entity::showModel(); + UpdateWeapons(); +} + +void Player::showModel + ( + void + ) + +{ + Entity::showModel(); + UpdateWeapons(); +} + +void Player::Spawned + ( + void + ) + +{ + Event *ev = new Event; + + ev->AddEntity( this ); + scriptedEvents[ SE_SPAWN ].Trigger( ev ); +} + +// reborn stuff +void Player::AddKills + ( + Event *ev + ) + +{ + AddKills( ev->GetInteger( 1 ) ); +} + +void Player::AddDeaths + ( + Event *ev + ) + +{ + AddDeaths( ev->GetInteger( 1 ) ); +} + +void Player::AdminRights + ( + Event *ev + ) + +{ + // FIXME: Admin manager ? + ev->AddInteger( 0 ); +} + +void Player::BindWeap + ( + Event *ev + ) + +{ + // FIXME: TODO +} + +void Player::CanSwitchTeams + ( + Event *ev + ) + +{ + qboolean bAllow = ev->GetBoolean( 1 ); + + disable_team_change = !bAllow; + if( ev->NumArgs() > 1 ) + { + qboolean bAllow2 = ev->GetBoolean( 2 ); + + disable_spectate = !bAllow2; + } +} + +void Player::ClearCommand + ( + Event *ev + ) + +{ + str command; + int clientNum = G_GetClientNumber( this ); + + if( ev->NumArgs() > 0 ) { + command = ev->GetString( 1 ); + } + + m_lastcommand = ""; +} + +void Player::Dive + ( + Event *ev + ) + +{ + float height, airborne_duration, speed; + + Vector forwardvector = orientation[ 0 ]; + + height = ev->GetFloat( 1 ); + + if( ev->NumArgs() < 2 || ev->IsNilAt( 2 ) ) { + airborne_duration = 1; + } else { + airborne_duration = ev->GetFloat( 2 ); + } + + speed = height * airborne_duration; + + velocity[ 0 ] += height * forwardvector[ 0 ] * ( speed / 16 ); + velocity[ 1 ] += height * forwardvector[ 1 ] * ( speed / 16 ); + velocity[ 2 ] += height * speed / 6.80f; +} + +void Player::EventEarthquake + ( + Event *ev + ) + +{ + float duration = ev->GetFloat( 1 ); + float magnitude = ev->GetFloat( 2 ); + qboolean no_rampup = ev->GetBoolean( 3 ); + qboolean no_rampdown = ev->GetBoolean( 4 ); + + // full realistic, smooth earthquake + if( ev->NumArgs() > 4 ) + { + Vector location = ev->GetVector( 5 ); + float radius = 1.0f; + + if( ev->NumArgs() > 5 ) { + radius = ev->GetFloat( 6 ); + } + + gi.SendServerCommand( edict - g_entities, "eq %f %f %d %d %f %f %f %f", duration, magnitude, no_rampup, no_rampdown, location[ 0 ], location[ 1 ], location[ 2 ], radius ); + } + else + { + gi.SendServerCommand( edict - g_entities, "eq %f %f %d %d", duration, magnitude, no_rampup, no_rampdown ); + } +} + +void Player::EventIsSpectator + ( + Event *ev + ) + +{ + ev->AddInteger( IsSpectator() ); +} + +void Player::EventReplication + ( + Event *ev + ) + +{ + str variable; + ScriptVariable *pVar; + + variable = ev->GetString( 1 ); + + pVar = vars->GetVariable( variable ); + + if( pVar == NULL ) { + ScriptError( "invalid variable '%s'.", variable.c_str() ); + } + + gi.MSG_SetClient( client->ps.clientNum ); + gi.MSG_StartCGM( CGM_REPLICATION ); + gi.MSG_WriteBits( pVar->GetType(), 4 ); + gi.MSG_WriteString( variable ); + + Vector vec; + + switch( pVar->GetType() ) + { + case VARIABLE_CHAR: + gi.MSG_WriteChar( pVar->charValue() ); + break; + + case VARIABLE_CONSTSTRING: + case VARIABLE_STRING: + gi.MSG_WriteString( pVar->stringValue() ); + break; + + case VARIABLE_FLOAT: + gi.MSG_WriteFloat( pVar->floatValue() ); + break; + + case VARIABLE_INTEGER: + gi.MSG_WriteLong( pVar->intValue() ); + break; + + case VARIABLE_VECTOR: + vec = pVar->vectorValue(); + + gi.MSG_WriteCoord( vec[ 0 ] ); + gi.MSG_WriteCoord( vec[ 1 ] ); + gi.MSG_WriteCoord( vec[ 2 ] ); + + break; + } + + gi.MSG_EndCGM(); +} + +void Player::EventSetTeam + ( + Event *ev + ) + +{ + str team_name; + teamtype_t teamType; + + team_name = ev->GetString( 1 ); + if( !team_name.length() ) + { + ScriptError( "Invalid team name !" ); + return; + } + + if( Q_stricmp( team_name, "none" ) == 0 ) + teamType = TEAM_NONE; + else if( Q_stricmp( team_name, "spectator" ) == 0 ) + teamType = TEAM_SPECTATOR; + else if( Q_stricmp( team_name, "freeforall" ) == 0 ) + teamType = TEAM_FREEFORALL; + else if( Q_stricmp( team_name, "allies" ) == 0 ) + teamType = TEAM_ALLIES; + else if( Q_stricmp( team_name, "axis" ) == 0 ) + teamType = TEAM_AXIS; + else + { + ScriptError( "Unknown team name \"%s\"\n", team_name.c_str() ); + return; + } + + SetTeam( teamType ); + + gi.Printf( "Player::SetTeam : Player is now on team \"%s\"\n", team_name.c_str() ); +} + +void Player::EventGetViewModelAnim + ( + Event *ev + ) + +{ + ev->AddString( m_sVMcurrent ); +} + +void Player::EventGetViewModelAnimFinished + ( + Event *ev + ) + +{ + ev->AddInteger( animDoneVM ); +} + +void Player::EventGetViewModelAnimValid + ( + Event *ev + ) + +{ + str anim_name = ev->GetString( 1 ); + str fullanim; + bool bFullAnim = false; + + if( ev->NumArgs() > 1 ) + { + bFullAnim = ev->GetBoolean( 2 ); + } + + if( !bFullAnim ) + { + // Copy the item prefix and the anim name + Item *item = GetActiveWeapon( WEAPON_MAIN ); + + if( !item ) + { + item = ( Item * )newActiveWeapon.weapon.Pointer(); + } + + if( item ) + { + fullanim = GetItemPrefix( item->getName() ) + str( "_" ) + anim_name; + } + else + { + fullanim = "unarmed_" + anim_name; + } + } + else + { + fullanim = anim_name; + } + + if( !m_fpsTiki || gi.Anim_NumForName( m_fpsTiki, fullanim.c_str() ) < 0 ) + { + ev->AddInteger( 0 ); + } + else + { + ev->AddInteger( 1 ); + } +} + +void Player::FreezeControls + ( + Event *ev + ) + +{ + m_bFrozen = ev->GetBoolean( 1 ); +} + +void Player::GetConnState + ( + Event *ev + ) + +{ + ScriptDeprecated( "Player::GetConnState" ); +} + +void Player::GetDamageMultiplier + ( + Event *ev + ) + +{ + ev->AddFloat( damage_multiplier ); +} + +void Player::GetDeaths + ( + Event *ev + ) + +{ + ev->AddInteger( num_deaths ); +} + +void Player::GetKillHandler + ( + Event *ev + ) + +{ + if( m_pKilledEvent ) { + ev->AddValue( m_pKilledEvent->GetValue( 1 ) ); + } + else { + ev->AddNil(); + } +} + +void Player::GetKills + ( + Event *ev + ) + +{ + ev->AddInteger( num_kills ); +} + +void Player::GetMoveSpeedScale + ( + Event *ev + ) + +{ + ev->AddFloat( speed_multiplier[ 0 ] ); +} + +void Player::GetLegsState + ( + Event *ev + ) + +{ + const char *name; + + if( currentState_Legs != NULL ) { + name = currentState_Legs->getName(); + } + else { + name = "none"; + } + + ev->AddString( name ); +} + +void Player::GetStateFile + ( + Event *ev + ) + +{ + int clientNum = G_GetClientNumber( this ); + + if( m_sStateFile.length() ) + { + ev->AddString( m_sStateFile ); + } + else + { + ev->AddString( g_statefile->string ); + } +} + +void Player::GetTorsoState + ( + Event *ev + ) + +{ + const char *name; + + if( currentState_Torso != NULL ) { + name = currentState_Torso->getName(); + } + else { + name = "none"; + } + + ev->AddString( name ); +} + +void Player::HideEntity + ( + Event *ev + ) + +{ + // FIXME: todo +} + +void Player::ShowEntity + ( + Event *ev + ) + +{ + // FIXME: REDO +} + +void Player::Inventory + ( + Event *ev + ) + +{ + Entity *ent = NULL; + ScriptVariable *ref = new ScriptVariable, *array = new ScriptVariable; + int i = 0; + + ref->setRefValue( array ); + + for( i = 0; i < inventory.NumObjects(); i++ ) + { + ent = G_GetEntity( inventory[ i ] ); + + if( ent == NULL ) { + continue; + } + + ScriptVariable *index = new ScriptVariable, *value = new ScriptVariable; + + index->setIntValue( i + 1 ); + value->setListenerValue( ( Listener * )ent ); + + ref->setArrayAt( *index, *value ); + } + + ev->AddValue( *array ); +} + +void Player::InventorySet + ( + Event *ev + ) + +{ + ScriptVariable array; + ScriptVariable * value; + Entity * ent; + int arraysize; + + if( ev->IsNilAt( 1 ) ) + { + // Just clear the inventory + inventory.ClearObjectList(); + return; + } + + // Retrieve the array + array = ev->GetValue( 1 ); + + // Cast the array + array.CastConstArrayValue(); + arraysize = array.arraysize(); + + // Detach all active weapons and free the inventory + + if( inventory.NumObjects() > 0 ) { + inventory.FreeObjectList(); + } + + if( arraysize < 1 ) { + return; + } + + // Allocate an inventory + for( int i = 1; i <= arraysize; i++ ) + { + // Retrieve the value from the array + value = array[ i ]; + + // Get the entity from the value + ent = ( Entity * )value->entityValue(); + + if( ent == NULL || !ent->edict->inuse ) { + continue; + } + + // Add the entity to the inventory + inventory.AddObject( ent->entnum ); + } + + // Clear the variable + array.Clear(); +} + +void Player::IsAdmin + ( + Event *ev + ) + +{ + // FIXME: Admin manager ? + ev->AddInteger( 0 ); +} + +void Player::LeanLeftHeld + ( + Event *ev + ) + +{ + Player *player = NULL; + int buttonheld = 0; + + player = ( Player * )this; + + buttonheld = !!( player->buttons & BUTTON_LEANLEFT ); + + ev->AddInteger( buttonheld ); +} + +void Player::LeanRightHeld + ( + Event *ev + ) + +{ + Player *player = NULL; + int buttonheld = 0; + + player = ( Player * )this; + + buttonheld = !!( player->buttons & BUTTON_LEANRIGHT ); + + ev->AddInteger( buttonheld ); +} + +// Specify the view height of the player and the height of his bounding box +void Player::ModifyHeightFloat + ( + Event *ev + ) + +{ + // params + int height; + float max_z; + + height = ev->GetInteger( 1 ); + max_z = ev->GetFloat( 2 ); + + viewheight = height; + + if( max_z >= 94.0 ) { + max_z = 94.0; + } + else if( max_z >= 74.0 && max_z < 94.0 ) { + max_z = 54.0; + } + else if( max_z >= 30.0 && max_z < 54.0 ) { + max_z = 20.0; + } + else if( max_z <= 20.0 ) { + max_z = 20.0; + } + + maxs.z = max_z; + + client->ps.pm_flags &= ~( PMF_DUCKED | PMF_VIEW_PRONE | PMF_VIEW_DUCK_RUN | PMF_VIEW_JUMP_START ); + + if( sv_reborn->integer ) + { + gi.MSG_SetClient( edict - g_entities); + + gi.MSG_StartCGM( CGM_MODHEIGHTFLOAT ); + gi.MSG_WriteLong( height ); + gi.MSG_WriteFloat( max_z ); + gi.MSG_EndCGM(); + } +} + +void Player::PlayLocalSound + ( + Event *ev + ) + +{ + str soundName = ev->GetString( 1 ); + qboolean loop = false; + float time; + + if( ev->NumArgs() > 1 ) { + loop = ev->GetBoolean( 2 ); + } + + if( ev->NumArgs() > 2 ) { + time = ev->GetFloat( 3 ); + } + else { + time = 0.0f; + } + + AliasListNode_t *alias = NULL; + + const char *found = gi.GlobalAlias_FindRandom( soundName, &alias ); + + if( found == NULL ) + { + gi.DPrintf( "ERROR: Player::PlayLocalSound: %s needs to be aliased - Please fix.\n", soundName.c_str() ); + return; + } + + if( sv_reborn->integer ) + { + gi.MSG_SetClient( client->ps.clientNum ); + + gi.MSG_StartCGM( CGM_PLAYLOCALSOUND ); + gi.MSG_WriteString( found ); + gi.MSG_WriteBits( !!loop, 1 ); + gi.MSG_WriteFloat( time ); + gi.MSG_WriteFloat( alias->volume ); + gi.MSG_EndCGM(); + + return; + } + + if( loop ) + { + edict->s.loopSound = gi.soundindex( found, alias->streamed ); + edict->s.loopSoundVolume = 1.0f; + edict->s.loopSoundMinDist = 0; + edict->s.loopSoundMaxDist = 96; + edict->s.loopSoundPitch = 1.0f; + edict->s.loopSoundFlags = 1; // local sound + } + else + { + gi.Sound( &edict->s.origin, + entnum, + CHAN_LOCAL, + found, + 1.0f, + 0, + 1.0f, + 96, + alias->streamed ); + } +} + +void Player::RunHeld + ( + Event *ev + ) + +{ + Player *player = NULL; + int buttonheld = 0; + + player = ( Player * )this; + + buttonheld = !!( player->buttons & BUTTON_RUN ); + + ev->AddInteger( buttonheld ); +} + +void Player::SecFireHeld + ( + Event *ev + ) + +{ + Player *player = NULL; + int buttonheld = 0; + + player = ( Player * )this; + + buttonheld = !!( player->buttons & BUTTON_ATTACK2 ); + + ev->AddInteger( buttonheld ); +} + +void Player::SetAnimSpeed + ( + Event *ev + ) + +{ + float speed; + Player * player = ( Player * )this; + + speed = ev->GetFloat( 1 ); + + if( speed < 0.0f ) + speed = 0.0f; + + //player->baseSentient.baseAnimate.baseEntity.client->customanimspeed = speed; +} + +void Player::SetClientFlag + ( + Event *ev + ) + +{ + str name = ev->GetString( 1 ); + + gi.SendServerCommand( client->ps.clientNum, "cf %s", name.c_str() ); +} + +void Player::SetEntityShader + ( + Event *ev + ) + +{ + Entity *entity = ev->GetEntity( 1 ); + str shadername = ev->GetString( 2 ); + qboolean fReset = false; + + if( entity == NULL ) { + ScriptError( "Invalid entity !" ); + } + + if( !shadername.length() ) + { + shadername = "default"; + fReset = true; + } + + gi.SendServerCommand( edict - g_entities, "setshader %d %s %d", entity->entnum, shadername.c_str(), fReset ); +} + +void Player::SetKillHandler + ( + Event *ev + ) + +{ + if( ev->IsNilAt( 1 ) || ( ev->IsStringAt( 1 ) && !ev->GetString( 1 ).icmp( "none" ) ) ) + { + if( m_pKilledEvent != NULL ) + { + delete m_pKilledEvent; + m_pKilledEvent = NULL; + } + } + else + { + m_pKilledEvent = new Event( EV_Listener_ExecuteScript ); + m_pKilledEvent->AddValue( ev->GetValue( 1 ) ); + } +} + +void Player::SetLocalSoundRate + ( + Event *ev + ) + +{ + str name = ev->GetString( 1 ); + float rate = ev->GetFloat( 2 ); + float time; + + if( ev->NumArgs() > 2 ) { + time = ev->GetFloat( 3 ); + } + else { + time = 0.0f; + } + + AliasListNode_t *alias = NULL; + const char *found = gi.GlobalAlias_FindRandom( name, &alias ); + + if( found == NULL ) + { + gi.DPrintf( "ERROR: Player::SetLocalSoundRate: %s needs to be aliased - Please fix.\n", name.c_str() ); + return; + } + + gi.MSG_SetClient( client->ps.clientNum ); + + gi.MSG_StartCGM( CGM_SETLOCALSOUNDRATE ); + gi.MSG_WriteString( found ); + gi.MSG_WriteFloat( rate ); + gi.MSG_WriteFloat( time ); + gi.MSG_EndCGM(); +} + +void Player::SetSpeed + ( + Event *ev + ) + +{ + float speed; + Player * player = ( Player * )this; + int clientNum = G_GetClientNumber( this ); + int index = 0; + + speed = ev->GetFloat( 1 ); + + if( speed < 0.0f ) + speed = 0.0f; + + if( ev->NumArgs() > 1 ) + { + index = ev->GetInteger( 2 ); + + /* Reserve a space for moveSpeedScale */ + if( index < 1 || index > MAX_SPEED_MULTIPLIERS ) { + gi.Printf( "Player::SetSpeed : invalid index %d. Index must be between 1-%d\n", index, speed_multiplier ); + + return; + } + } + + speed_multiplier[ index ] = speed; +} + +void Player::SetStateFile + ( + Event *ev + ) + +{ + int clientNum = G_GetClientNumber( this ); + qboolean bRemove = false; + str string = NULL; + + if( ev->NumArgs() <= 0 ) { + bRemove = true; + } + else + { + string = ev->GetString( 1 ); + + if( !string ) { + bRemove = true; + } + } + + if( bRemove ) { + m_sStateFile = ""; + } else { + m_sStateFile = string; + } +} + +void Player::SetVMASpeed + ( + Event *ev + ) + +{ + str name = ev->GetString( 1 ); + float speed = ev->GetFloat( 2 ); + + if( !client || !level.reborn ) { + return; + } + + vma_t *vma = &vmalist[ name ]; + + if( speed < 0.0f ) { + speed = 0.0f; + } + + vma->name = name; + vma->speed = speed; + + gi.MSG_SetClient( edict - g_entities ); + + gi.MSG_StartCGM( CGM_SETVMASPEED ); + gi.MSG_WriteString( name ); + gi.MSG_WriteFloat( speed ); + gi.MSG_EndCGM(); +} + +void Player::StopLocalSound + ( + Event *ev + ) + +{ + str soundName = ev->GetString( 1 ); + float time; + + if( ev->NumArgs() > 1 ) { + time = ev->GetFloat( 2 ); + } + else { + time = 0.0f; + } + + AliasListNode_t *alias = NULL; + const char *found = gi.GlobalAlias_FindRandom( soundName, &alias ); + + if( found == NULL ) + { + gi.DPrintf( "ERROR: Player::StopLocalSound: %s needs to be aliased - Please fix.\n", soundName.c_str() ); + return; + } + + if( level.reborn ) + { + gi.MSG_SetClient( client->ps.clientNum ); + + gi.MSG_StartCGM( CGM_STOPLOCALSOUND ); + gi.MSG_WriteString( found ); + gi.MSG_WriteFloat( time ); + gi.MSG_EndCGM(); + } + else + { + edict->s.loopSound = 0; + gi.StopSound( entnum, CHAN_LOCAL ); + } +} + +void Player::UseHeld + ( + Event *ev + ) + +{ + int buttonheld = 0; + + buttonheld = !!( buttons & BUTTON_USE ); + + ev->AddInteger( buttonheld ); +} + +void Player::Userinfo + ( + Event *ev + ) + +{ + if( !client ) + { + ScriptError( "Entity is probably not of player type - userinfo\n" ); + return; + } + + ev->AddString( client->pers.userinfo ); + +} + +void Player::VisionGetNaked + ( + Event *ev + ) + +{ + // return the global vision + if( !m_sVision.length() ) { + ev->AddString( vision_current ); + } + else { + ev->AddString( m_sVision ); + } +} + +void Player::VisionSetBlur + ( + Event *ev + ) + +{ + float blur_level = ev->GetFloat( 1 ); + float fade_time; + + if( ev->NumArgs() > 1 ) { + fade_time = ev->GetFloat( 2 ); + } + else { + fade_time = 0.0f; + } + + gi.SendServerCommand( edict - g_entities, "vsb %f %f", blur_level, fade_time ); +} + +void Player::VisionSetNaked + ( + Event *ev + ) + +{ + str vision = ev->GetString( 1 ); + float fade_time; + float phase; + + if( ev->NumArgs() > 1 ) { + fade_time = ev->GetFloat( 2 ); + } + else { + fade_time = 0.0f; + } + + if( ev->NumArgs() > 2 ) { + phase = ev->GetFloat( 3 ); + } + else { + phase = 0.0f; + } + + if( !vision.length() ) { + vision = vision_current; + } + + if( vision.length() >= MAX_STRING_TOKENS ) { + ScriptError( "vision_name exceeds the maximum vision name limit (256) !\n" ); + } + + m_sVision = vision; + + gi.SendServerCommand( edict - g_entities, "vsn %s %f %f", vision.c_str(), fade_time, phase ); +} diff --git a/code/game/player.h b/code/game/player.h new file mode 100644 index 00000000..8fbefe1d --- /dev/null +++ b/code/game/player.h @@ -0,0 +1,1149 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// player.h: Class definition of the player. + +#ifndef __PLAYER_H__ +#define __PLAYER_H__ + +#include "g_local.h" +#include "vector.h" +#include "entity.h" +#include "weapon.h" +#include "sentient.h" +#include "navigate.h" +#include "misc.h" +#include "bspline.h" +#include "camera.h" +#include "specialfx.h" +#include "characterstate.h" +#include "actor.h" +#include "vehicle.h" +#include "dm_team.h" + +extern Event EV_Player_EndLevel; +extern Event EV_Player_GiveCheat; +extern Event EV_Player_GodCheat; +extern Event EV_Player_NoTargetCheat; +extern Event EV_Player_NoClipCheat; +extern Event EV_Player_GameVersion; +extern Event EV_Player_Fov; +extern Event EV_Player_WhatIs; +extern Event EV_Player_Respawn; +extern Event EV_Player_WatchActor; +extern Event EV_Player_StopWatchingActor; +extern Event EV_Player_DoStats; +extern Event EV_Player_EnterIntermission; +extern Event EV_GetViewangles; +extern Event EV_SetViewangles; +extern Event EV_Player_AutoJoinDMTeam; +extern Event EV_Player_JoinDMTeam; +extern Event EV_Player_Respawn; +extern Event EV_Player_PrimaryDMWeapon; +extern Event EV_Player_StuffText; + +enum painDirection_t + { + PAIN_NONE, + PAIN_FRONT, + PAIN_LEFT, + PAIN_RIGHT, + PAIN_REAR + }; + +typedef enum +{ + PVT_NONE_SET, + PVT_ALLIED_START, + PVT_ALLIED_AIRBORNE, + PVT_ALLIED_MANON, + PVT_ALLIED_SAS, + PVT_ALLIED_PILOT, + PVT_ALLIED_ARMY, + PVT_ALLIED_RANGER, + PVT_ALLIED_END, + PVT_AXIS_START, + PVT_AXIS_AXIS1, + PVT_AXIS_AXIS2, + PVT_AXIS_AXIS3, + PVT_AXIS_AXIS4, + PVT_AXIS_AXIS5, + PVT_AXIS_END +} voicetype_t; + +typedef void ( Player::*movecontrolfunc_t )( void ); + +typedef struct vma_s { + str name; + float speed; +} vma_t; + +#define MAX_SPEED_MULTIPLIERS 4 +#define MAX_ANIM_SLOT 16 +#define MAX_TRAILS 2 + +class Player : public Sentient +{ + friend class Camera; + friend class Vehicle; + friend class TurretGun; + friend class VehicleTurretGun; + +private: + static Condition Conditions[]; + static movecontrolfunc_t MoveStartFuncs[]; + + StateMap *statemap_Legs; + StateMap *statemap_Torso; + + State *currentState_Legs; + State *currentState_Torso; + + str last_torso_anim_name; + str last_leg_anim_name; + str partAnim[ 2 ]; + int m_iPartSlot[ 2 ]; + float m_fPartBlends[ 2 ]; + str partOldAnim[ 2 ]; + float partBlendMult[ 2 ]; + + bool animdone_Legs; + bool animdone_Torso; + Container legs_conditionals; + Container torso_conditionals; + Conditional *m_pLegsPainCond; + Conditional *m_pTorsoPainCond; + + float m_fLastDeltaTime; + qboolean m_bActionAnimPlaying; + int m_iBaseActionAnimSlot; + str m_sActionAnimName; + int m_iActionAnimType; + qboolean m_bActionAnimDone; + str m_sOldActionAnimName; + float m_fOldActionAnimWeight; + float m_fOldActionAnimFadeTime; + int m_iOldActionAnimType; + qboolean m_bMovementAnimPlaying; + int m_iBaseMovementAnimSlot; + str m_sMovementAnimName; + str m_sOldMovementAnimName; + float m_fOldMovementWeight; + float m_fOldMovementFadeTime; + str m_sSlotAnimNames[ MAX_ANIM_SLOT ]; + + movecontrol_t movecontrol; + int m_iMovePosFlags; + int last_camera_type; + + Vector oldvelocity; + Vector old_v_angle; + Vector oldorigin; + float animspeed; + float airspeed; + Vector m_vPushVelocity; + + // blend + float blend[ 4 ]; + float fov; + float selectedfov; + qboolean m_iInZoomMode; + + // aiming direction + Vector v_angle; + Vector m_vViewPos; + Vector m_vViewAng; + + int buttons; + int new_buttons; + int server_new_buttons; + + float respawn_time; + int last_attack_button; + + // damage blend + float damage_blood; + float damage_alpha; + Vector damage_blend; + Vector damage_from; + Vector damage_angles; + float damage_count; + float damage_yaw; + float next_painsound_time; + str waitForState; + + SafePtr camera; + SafePtr actor_camera; + SimpleActorPtr actor_to_watch; + + qboolean actor_camera_right; + qboolean starting_actor_camera_right; + + // music stuff + int music_current_mood; + int music_fallback_mood; + float music_current_volume; + float music_saved_volume; + float music_volume_fade_time; + + int reverb_type; + float reverb_level; + + qboolean gibbed; + float pain; + painDirection_t pain_dir; + meansOfDeath_t pain_type; + int pain_location; + bool take_pain; + int nextpaintime; + bool knockdown; + + bool canfall; + bool falling; + int feetfalling; + Vector falldir; + + bool mediumimpact; + bool hardimpact; + + qboolean music_forced; + + usercmd_t last_ucmd; + usereyes_t last_eyeinfo; + + // movement variables + float animheight; + Vector yaw_forward; + Vector yaw_left; + + SafePtr atobject; + float atobject_dist; + Vector atobject_dir; + + SafePtr toucheduseanim; + int useanim_numloops; + SafePtr useitem_in_use; + + float move_left_vel; + float move_right_vel; + float move_backward_vel; + float move_forward_vel; + float move_up_vel; + float move_down_vel; + int moveresult; + + float damage_multiplier; + + voicetype_t m_voiceType; + + int num_deaths; + int num_kills; + int num_won_matches; + int num_lost_matches; + + bool m_bTempSpectator; + bool m_bSpectator; + bool m_bAllowFighting; + bool m_bReady; + int m_iPlayerSpectating; + + teamtype_t dm_team; + class SafePtr current_team; + float m_fTeamSelectTime; + class PlayerStart *m_pLastSpawnpoint; + + bool voted; + int votecount; + + float m_fWeapSelectTime; + float fAttackerDispTime; + SafePtr pAttackerDistPointer; + + int m_iInfoClient; + int m_iInfoClientHealth; + float m_fInfoClientTime; + +public: + int m_iNumObjectives; + int m_iObjectivesCompleted; + + str m_sPerferredWeaponOverride; + + Vector mvTrail[ MAX_TRAILS ]; + Vector mvTrailEyes[ MAX_TRAILS ]; + int mCurTrailOrigin; + int mLastTrailTime; + int m_iNumHitsTaken; + int m_iNumEnemiesKilled; + int m_iNumObjectsDestroyed; + int m_iNumShotsFired; + int m_iNumHits; + float m_fAccuracy; + float m_fTimeUsed; + int m_iNumHeadShots; + int m_iNumTorsoShots; + int m_iNumLeftLegShots; + int m_iNumRightLegShots; + int m_iNumGroinShots; + int m_iNumLeftArmShots; + int m_iNumRightArmShots; + + qboolean yawing_left; + qboolean yawing_right; + qboolean yawing; + + Vector headAngles; + Vector torsoAngles; + Vector headAimAngles; + Vector torsoAimAngles; + + // new variables + str m_sVision; // current vision + str m_sStateFile; // custom statefile + bool disable_spectate; + bool disable_team_change; + bool m_bFrozen; // if player is frozen + bool animDoneVM; + float speed_multiplier[ MAX_SPEED_MULTIPLIERS ]; + Event *m_pKilledEvent; + con_map< str, vma_t > vmalist; + str m_sVMAcurrent; + str m_sVMcurrent; + float m_fVMAtime; + dtiki_t *m_fpsTiki; + bool m_bConnected; + str m_lastcommand; + +public: + qboolean returnfalse( Conditional &condition ); + qboolean returntrue( Conditional &condition ); + qboolean checkturnleft( Conditional &condition ); + qboolean checkturnright( Conditional &condition ); + qboolean checkforward( Conditional &condition ); + qboolean checkbackward( Conditional &condition ); + qboolean checkstrafeleft( Conditional &condition ); + qboolean checkstraferight( Conditional &condition ); + qboolean checkjump( Conditional &condition ); + qboolean checkcrouch( Conditional &condition ); + qboolean checkjumpflip( Conditional &condition ); + qboolean checkanimdone_legs( Conditional &condition ); + qboolean checkanimdone_torso( Conditional &condition ); + qboolean checkattackleft( Conditional &condition ); + qboolean checkattackright( Conditional &condition ); + qboolean checkattackbuttonleft( Conditional &condition ); + qboolean checkattackbuttonright( Conditional &condition ); + qboolean checksneak( Conditional &condition ); + qboolean checkrun( Conditional &condition ); + qboolean checkholsterweapon( Conditional &condition ); + qboolean checkuse( Conditional &condition ); + qboolean checkcanturn( Conditional &condition ); + qboolean checkcanmoveright( Conditional &condition ); + qboolean checkcanmoveleft( Conditional &condition ); + qboolean checkcanmovebackward( Conditional &condition ); + qboolean checkcanmoveforward( Conditional &condition ); + qboolean checkcanwallhug( Conditional &condition ); + qboolean checkblocked( Conditional &condition ); + qboolean checkhasvelocity( Conditional &condition ); + qboolean checkheight( Conditional &condition ); + qboolean checkonground( Conditional &condition ); + qboolean check22degreeslope( Conditional &condition ); + qboolean check45degreeslope( Conditional &condition ); + qboolean checklookingup( Conditional &condition ); + qboolean checkrightleghigh( Conditional &condition ); + qboolean checkleftleghigh( Conditional &condition ); + qboolean checkcanfall( Conditional &condition ); + qboolean checkatdoor( Conditional &condition ); + qboolean checkfalling( Conditional &condition ); + qboolean checkgroundentity( Conditional &condition ); + qboolean checkhardimpact( Conditional &condition ); + qboolean checkmediumimpact( Conditional &condition ); + qboolean checkdead( Conditional &condition ); + qboolean checkhealth( Conditional &condition ); + qboolean checkpain( Conditional &condition ); + qboolean checkpaindirection( Conditional &condition ); + qboolean checkpainlocation( Conditional &condition ); + qboolean checkpaintype( Conditional &condition ); + qboolean checkpainthreshold( Conditional &condition ); + qboolean checkknockdown( Conditional &condition ); + qboolean checklegsstate( Conditional &condition ); + qboolean checktorsostate( Conditional &condition ); + qboolean checkatuseanim( Conditional &condition ); + qboolean checktouchuseanim( Conditional &condition ); + qboolean checkatuseobject( Conditional &condition ); + qboolean checkloopuseobject( Conditional &condition ); + qboolean checkuseweaponleft( Conditional &condition ); + qboolean checknewweapon( Conditional &condition ); + qboolean checkreload( Conditional &condition ); + qboolean checkuseweapon( Conditional &condition ); + qboolean checkuseweaponclass( Conditional &condition ); + qboolean checkhasweapon( Conditional &condition ); + qboolean checkweaponactive( Conditional &condition ); + qboolean checkweaponclassactive( Conditional &condition ); + qboolean checkweaponreadytofire( Conditional &condition ); + qboolean checkweaponclassreadytofire( Conditional &condition ); + qboolean checkweaponreadytofire_nosound( Conditional &condition ); + qboolean checkweaponsemiauto( Conditional &condition ); + qboolean checkmuzzleclear( Conditional &condition ); + qboolean checkputawayleft( Conditional &condition ); + qboolean checkputawayright( Conditional &condition ); + qboolean checkanyweaponactive( Conditional &condition ); + qboolean checkstatename( Conditional &condition ); + qboolean checkattackblocked( Conditional &condition ); + qboolean checkblockdelay( Conditional &condition ); + qboolean checkcanstand( Conditional &condition ); + qboolean checkpush( Conditional &condition ); + qboolean checkpull( Conditional &condition ); + qboolean checkladder( Conditional &condition ); + qboolean checktopladder( Conditional &condition ); + qboolean checkcangetoffladdertop( Conditional &condition ); + qboolean checkcangetoffladderbottom( Conditional &condition ); + qboolean checkfeetatladder( Conditional &condition ); + qboolean checkcanclimbupladder( Conditional &condition ); + qboolean checkcanclimbdownladder( Conditional &condition ); + qboolean checkonladder( Conditional &condition ); + qboolean checkuseanimfinished( Conditional &condition ); + qboolean checkchance( Conditional &condition ); + qboolean checkfacingupslope( Conditional &condition ); + qboolean checkfacingdownslope( Conditional &condition ); + qboolean checkinturret( Conditional &condition ); + qboolean checkinvehicle( Conditional &condition ); + qboolean checkturrettype( Conditional &condition ); + qboolean checkduckedviewinwater( Conditional &condition ); + qboolean checkviewinwater( Conditional &condition ); + qboolean checkwaterlevel( Conditional &condition ); + qboolean checksolidforward( Conditional &condition ); + qboolean checkholstercomplete( Conditional &condition ); + qboolean checkweaponhasammo( Conditional &condition ); + qboolean checkweaponhasammoinclip( Conditional &condition ); + qboolean checkrise( Conditional &condition ); + qboolean checkweaponsholstered( Conditional &condition ); + qboolean checkmovementtype( Conditional &condition ); + qboolean checkpositiontype( Conditional &condition ); + qboolean checkforwardvelocity( Conditional &condition ); + qboolean checkminchargetimemet( Conditional &condition ); + qboolean checkmaxchargetimemet( Conditional &condition ); + qboolean checkimmediateswitch( Conditional &condition ); + qboolean CondAnimDoneVM( Conditional &condition ); + qboolean CondClientCommand( Conditional &condition ); + qboolean CondVMAnim( Conditional &condition ); + qboolean CondVariable( Conditional &condition ); + + // movecontrol functions + void StartPush( void ); + void StartClimbWall( void ); + void StartUseAnim( void ); + void StartLoopUseAnim( void ); + void SetupUseObject( void ); + + void StartUseObject( Event *ev ); + void FinishUseObject( Event *ev ); + void FinishUseAnim( Event *ev ); + void Turn( Event *ev ); + void TurnUpdate( Event *ev ); + void TurnLegs( Event *ev ); + + CLASS_PROTOTYPE( Player ); + + Player(); + ~Player(); + void Init( void ); + + void InitSound( void ); + void InitEdict( void ); + void InitClient( void ); + void InitPhysics( void ); + void InitPowerups( void ); + void InitWorldEffects( void ); + void InitWeapons( void ); + void InitView( void ); + void InitModel( void ); + void InitState( void ); + void InitHealth( void ); + void InitWaterPower( void ); + void InitInventory( void ); + void InitDeathmatch( void ); + void InitMaxAmmo( void ); + void InitStats( void ); + void ChooseSpawnPoint( void ); + + void Disconnect( void ); + + void EndLevel( Event *ev ); + void Respawn( Event *ev ); + + virtual Vector GunTarget( bool bNoCollision = false ); + void SetDeltaAngles( void ); + virtual void setAngles( Vector ang ); + + qboolean canUse(); + qboolean canUse( Entity *entity, bool requiresLookAt ); + int getUseableEntities( int *touch, int maxcount, bool requiresLookAt = true ); + void DoUse( Event *ev ); + void Obituary( Entity *attacker, Entity *inflictor, int meansofdeath, int iLocation ); + void Killed( Event *ev ); + void KilledPlayerInDeathmatch( Player *killed ); + void Dead( Event *ev ); + void ArmorDamage( Event *ev ); + void Pain( Event *ev ); + void DeadBody( void ); + void DeadBody( Event *ev ); + + void TouchStuff( pmove_t *pm ); + + void GetMoveInfo( pmove_t *pm ); + void SetMoveInfo( pmove_t *pm, usercmd_t *ucmd ); + pmtype_t GetMovePlayerMoveType( void ); + void ClientMove( usercmd_t *ucmd ); + void VehicleMove( usercmd_t *ucmd ); + void TurretMove( usercmd_t *ucmd ); + // qboolean feetOnGround( Vector pos ); + // Vector findBestFallPos( Vector pos ); + // void CheckFeet( void ); + void CheckMoveFlags( void ); + void ClientInactivityTimer( void ); + virtual void ClientThink( void ); + void UpdateEnemies( void ); + + virtual void Think(); + virtual void Postthink(); + + void InitLegsStateTable( void ); + void InitTorsoStateTable( void ); + void LoadStateTable( void ); + void ResetState( Event *ev ); + void EvaluateState( State *forceTorso = NULL, State *forceLegs = NULL ); + + void CheckGround( void ); + void UpdateViewAngles( usercmd_t *cmd ); + qboolean AnimMove( Vector &move, Vector *endpos = NULL ); + qboolean TestMove( Vector &pos, Vector *endpos = NULL ); + qboolean CheckMove( Vector &move, Vector *endpos = NULL ); + + float CheckMoveDist( Vector &delta ); + float TestMoveDist( Vector &pos ); + + void EndAnim_Legs( Event *ev ); + void EndAnim_Torso( Event *ev ); + void EndActionAnim( Event *ev ); + void SetPartAnim( const char *anim, bodypart_t slot = legs ); + void StopPartAnimating( bodypart_t part ); + void PausePartAnim( bodypart_t part ); + void AdjustAnimBlends( void ); + void PlayerAnimDelta( float *vDelta ); + + void TouchedUseAnim( Entity * ent ); + + void GiveCheat( Event *ev ); + void GiveWeaponCheat( Event *ev ); + void GiveAllCheat( Event *ev ); + void GodCheat( Event *ev ); + void FullHeal( Event *ev ); + void EventFace( Event *ev ); + void NoTargetCheat( Event *ev ); + void NoclipCheat( Event *ev ); + void EventTeleport( Event *ev ); + void Kill( Event *ev ); + void GibEvent( Event *ev ); + void SpawnEntity( Event *ev ); + void SpawnActor( Event *ev ); + void ListInventoryEvent( Event *ev ); + + void GameVersion( Event *ev ); + void Fov( Event *ev ); + void SafeZoomed( Event *ev ); + void ToggleZoom( int iZoom ); + void ZoomOff( void ); + void ZoomOffEvent( Event *ev ); + qboolean IsZoomed( void ); + + void GetPlayerView( Vector *pos, Vector *angle ); + + float CalcRoll( void ); + void WorldEffects( void ); + void AddBlend( float r, float g, float b, float a ); + void CalcBlend( void ); + void DamageFeedback( void ); + + void CopyStats( Player *player ); + void UpdateStats( void ); + void UpdateStatus( const char * s ); + void StatCount( int index, int count ); + void UpdateMusic( void ); + void UpdateReverb( void ); + void UpdateMisc( void ); + + void SetReverb( str type, float level ); + void SetReverb( int type, float level ); + void SetReverb( Event *ev ); + + Camera *CurrentCamera( void ); + void SetCamera( Camera *ent, float switchTime ); + void CameraCut( void ); + void CameraCut( Camera *ent ); + + void SetPlayerView( Camera * camera, Vector position, float cameraoffset, Vector ang, Vector vel, float camerablend[ 4 ], float camerafov ); + void SetupView( void ); + + void ProcessPmoveEvents( int event ); + + void SwingAngles( float destination, float swingTolerance, float clampTolerance, float speed, float *angle, qboolean *swinging ); + void PlayerAngles( void ); + void FinishMove( void ); + virtual void EndFrame( void ); + + void TestThread( Event *ev ); + void useWeapon( const char *weaponname, weaponhand_t hand = WEAPON_MAIN ); + void useWeapon( Weapon *weapon, weaponhand_t hand = WEAPON_MAIN ); + + void GotKill( Event *ev ); + void SetPowerupTimer( Event *ev ); + void UpdatePowerupTimer( Event *ev ); + + void WhatIs( Event *ev ); + void ActorInfo( Event *ev ); + void Taunt( Event *ev ); + + void ChangeMusic( const char * current, const char * fallback, qboolean force ); + void ChangeMusicVolume( float volume, float fade_time ); + void RestoreMusicVolume( float fade_time ); + + void Archive( Archiver &arc ); + void ArchivePersistantData( Archiver &arc ); + + void GiveOxygen( float time ); + + void KillEnt( Event *ev ); + void RemoveEnt( Event *ev ); + void KillClass( Event *ev ); + void RemoveClass( Event *ev ); + + void Jump( Event *ev ); + void JumpXY( Event *ev ); + + virtual Vector EyePosition( void ); + + void GetViewangles( Event *ev ); + void SetViewangles( Event *ev ); + virtual void SetViewAngles( Vector angles ); + virtual Vector GetViewAngles( void ); + void SetFov( float newFov ); + void EventSetSelectedFov( Event *ev ); + void SetSelectedFov( float newFov ); + + void AdjustAnglesForAttack( void ); + Entity *FindEnemyInFOV( float fov, float maxdist ); + Entity *FindEnemyInFOVFromTagWithOffset( float fov, float maxdist, str tagname, Vector offset ); + void DumpState( Event *ev ); + void ForceLegsState( Event *ev ); + void ForceTorsoState( Event *ev ); + + Vector GetAngleToTarget( Entity *ent, str tag, float yawclamp, float pitchclamp, Vector baseangles ); + + void AutoAim( void ); + void AcquireTarget( void ); + void RemoveTarget( Entity *ent_to_remove ); + void AcquireHeadTarget( void ); + + void SetCurrentCombo( Event *ev ); + + qboolean GetTagPositionAndOrientation( str tagname, orientation_t *new_or ); + qboolean GetTagPositionAndOrientation( int tagnum, orientation_t *new_or ); + + void DebugWeaponTags( int controller_tag, Weapon *weapon, str weapon_tagname ); + void CheckReloadWeapons( void ); + void NextPainTime( Event *ev ); + void SetTakePain( Event *ev ); + + void SetMouthAngle( Event *ev ); + + void EnterVehicle( Event *ev ); + void ExitVehicle( Event *ev ); + void Holster( Event *ev ); + void HolsterToggle( Event *ev ); + void SetWaterPower( Event *ev ); + + // team stuff + int GetNumKills() const; + int GetNumDeaths() const; + void AddKills( int num ); + void AddDeaths( int num ); + + DM_Team *GetDM_Team(); + void SetDM_Team( DM_Team *team ); + teamtype_t GetTeam(); + void SetTeam( teamtype_t team ); + + PlayerStart *GetLastSpawnpoint() const { return m_pLastSpawnpoint; } + Vector GetLastSpawnPos() const { return ( ( Entity * )m_pLastSpawnpoint )->origin; } + + void BeginTempSpectator( void ); + void EndSpectator( void ); + void Spectator( void ); + void Spectator( Event *ev ); + bool IsSpectator( void ); + bool IsValidSpectatePlayer( Player *pPlayer ); + void SetPlayerSpectate( void ); + void BeginFight( void ); + void EndFight( void ); + + void EventGetUseHeld( Event *ev ); + void EventGetFireHeld( Event *ev ); + + void Score( Event *ev ); + + void WonMatch( void ); + void LostMatch( void ); + + void HUDPrint( const char *s ); + + void GetIsDisguised( Event *ev ); + void GetHasDisguise( Event *ev ); + void SetHasDisguise( Event *ev ); + void SetObjectiveCount( Event *ev ); + + void EventDMDeathDrop( Event *ev ); + void EventStopwatch( Event *ev ); + void SetStopwatch( int iDuration ); + void CallVote( Event *ev ); + void Vote( Event *ev ); + void EventCoord( Event *ev ); + void EventStuffText( Event *ev ); + void EventSetVoiceType( Event *ev ); + + void EventEnterIntermission( Event *ev ); + + void EnterTurret( Event *ev ); + void EnterTurret( TurretGun *ent ); + void ExitTurret( Event *ev ); + void ExitTurret( void ); + + void WatchActor( Event *ev ); + void StopWatchingActor( Event *ev ); + void WeaponCommand( Event *ev ); + void PlayerDone( Event *ev ); + painDirection_t Pain_string_to_int( str pain ); + inline Vector GetVAngles( void ){ return v_angle; } + void SpawnDamageEffect( meansOfDeath_t mod ); + virtual void GetStateAnims( Container *c ); + virtual void VelocityModified( void ); + int GetKnockback( int original_knockback, qboolean blocked ); + int GetMoveResult( void ); + virtual void ReceivedItem( Item * item ); + virtual void RemovedItem( Item * item ); + virtual void AmmoAmountChanged( Ammo * ammo, int inclip = 0 ); + + void PhysicsOn( Event *ev ); + void PhysicsOff( Event *ev ); + + // ladder stuff + void AttachToLadder( Event *ev ); + void UnattachFromLadder( Event *ev ); + void TweakLadderPos( Event *ev ); + void EnsureOverLadder( Event *ev ); + void EnsureForwardOffLadder( Event *ev ); + + void RemoveFromVehiclesAndTurrets( void ); + void WaitForState( Event *ev ); + void SkipCinematic( Event *ev ); + void SetDamageMultiplier( Event *ev ); + void LogStats( Event *ev ); + void Stats( Event *ev ); + void WeaponsHolstered( void ); + void WeaponsNotHolstered( void ); + void Loaded( void ); + void PlayerShowModel( Event *ev ); + virtual void showModel( void ); + void ResetHaveItem( Event *ev ); + void Join_DM_Team( Event *ev ); + void Auto_Join_DM_Team( Event *ev ); + void Leave_DM_Team( Event *ev ); + void EventPrimaryDMWeapon( Event *ev ); + void PlayerReload( Event *ev ); + void EventCorrectWeaponAttachments( Event *ev ); + void SelectNextItem( Event *ev ); + void SelectPreviousItem( Event *ev ); + void SelectNextWeapon( Event *ev ); + void SelectPreviousWeapon( Event *ev ); + void DropCurrentWeapon( Event *ev ); + void ModifyHeight( Event *ev ); + void SetMovePosFlags( Event *ev ); + void GetPositionForScript( Event *ev ); + void GetMovementForScript( Event *ev ); + void EventSetViewModelAnim( Event *ev ); + void EventDMMessage( Event *ev ); + void EventIPrint( Event *ev ); + qboolean ViewModelAnim( str anim, qboolean force_restart, qboolean bFullAnim ); + void FindAlias( str &output, str name, AliasListNode_t **node ); + virtual void Spawned( void ); + + bool IsReady( void ) const; + void EventGetReady( Event *ev ); + void EventSetReady( Event *ev ); + void EventSetNotReady( Event *ev ); + void EventGetDMTeam( Event *ev ); + void EventSetPerferredWeapon( Event *ev ); + + // reborn stuff + void AddKills( Event *ev ); + void AddDeaths( Event *ev ); + void AdminRights( Event *ev ); + void BindWeap( Event *ev ); + void CanSwitchTeams( Event *ev ); + void ClearCommand( Event *ev ); + void Dive( Event *ev ); + void EventEarthquake( Event *ev ); + void EventIsSpectator( Event *ev ); + void EventReplication( Event *ev ); + void EventSetTeam( Event *ev ); + void EventGetViewModelAnim( Event *ev ); + void EventGetViewModelAnimFinished( Event *ev ); + void EventGetViewModelAnimValid( Event *ev ); + void FreezeControls( Event *ev ); + void GetConnState( Event *ev ); + void GetDamageMultiplier( Event *ev ); + void GetKills( Event *ev ); + void GetDeaths( Event *ev ); + void GetKillHandler( Event *ev ); + void GetMoveSpeedScale( Event *ev ); + void GetLegsState( Event *ev ); + void GetStateFile( Event *ev ); + void GetTorsoState( Event *ev ); + void HideEntity( Event *ev ); + void Inventory( Event *ev ); + void InventorySet( Event *ev ); + void IsAdmin( Event *ev ); + void JoinDMTeamReal( Event *ev ); + void JoinDMTeam( Event *ev ); + void LeanLeftHeld( Event *ev ); + void LeanRightHeld( Event *ev ); + void ModifyHeightFloat( Event *ev ); + void PlayLocalSound( Event *ev ); + void RunHeld( Event *ev ); + void SecFireHeld( Event *ev ); + void SetAnimSpeed( Event *ev ); + void SetClientFlag( Event *ev ); + void SetEntityShader( Event *ev ); + void SetKillHandler( Event *ev ); + void SetLocalSoundRate( Event *ev ); + void SetSpeed( Event *ev ); + void SetStateFile( Event *ev ); + void SetVMASpeed( Event *ev ); + void ShowEntity( Event *ev ); + void StopLocalSound( Event *ev ); + void UseHeld( Event *ev ); + void Userinfo( Event *ev ); + void VisionGetNaked( Event *ev ); + void VisionSetBlur( Event *ev ); + void VisionSetNaked( Event *ev ); +}; + +inline void Player::Archive + ( + Archiver &arc + ) + +{ + str tempStr; + + Sentient::Archive( arc ); + + arc.ArchiveInteger( &m_iPartSlot[ 0 ] ); + arc.ArchiveInteger( &m_iPartSlot[ 1 ] ); + + arc.ArchiveFloat( &m_fPartBlends[ 0 ] ); + arc.ArchiveFloat( &m_fPartBlends[ 1 ] ); + arc.ArchiveFloat( &partBlendMult[ 0 ] ); + arc.ArchiveFloat( &partBlendMult[ 0 ] ); + + arc.ArchiveString( &last_torso_anim_name ); + arc.ArchiveString( &last_leg_anim_name ); + arc.ArchiveString( &partAnim[ 0 ] ); + arc.ArchiveString( &partAnim[ 1 ] ); + arc.ArchiveString( &partOldAnim[ 0 ] ); + arc.ArchiveString( &partOldAnim[ 1 ] ); + + arc.ArchiveString( &m_sPerferredWeaponOverride ); + + arc.ArchiveBool( &animdone_Legs ); + arc.ArchiveBool( &animdone_Torso ); + arc.ArchiveBoolean( &m_bActionAnimPlaying ); + arc.ArchiveInteger( &m_iBaseActionAnimSlot ); + arc.ArchiveString( &m_sActionAnimName ); + arc.ArchiveInteger( &m_iActionAnimType ); + arc.ArchiveBoolean( &m_bActionAnimDone ); + arc.ArchiveString( &m_sOldActionAnimName ); + arc.ArchiveFloat( &m_fOldActionAnimWeight ); + arc.ArchiveFloat( &m_fOldActionAnimFadeTime ); + arc.ArchiveInteger( &m_iOldActionAnimType ); + arc.ArchiveBoolean( &m_iBaseActionAnimSlot ); + arc.ArchiveInteger( &m_iBaseMovementAnimSlot ); + arc.ArchiveString( &m_sMovementAnimName ); + arc.ArchiveString( &m_sOldMovementAnimName ); + arc.ArchiveFloat( &m_fOldMovementWeight ); + arc.ArchiveFloat( &m_fOldMovementFadeTime ); + + for( int i = 0; i < MAX_ANIM_SLOT; i++ ) + { + arc.ArchiveString( &m_sSlotAnimNames[ i ] ); + } + + arc.ArchiveInteger( &m_iMovePosFlags ); + ArchiveEnum( movecontrol, movecontrol_t ); + arc.ArchiveInteger( &last_camera_type ); + + arc.ArchiveVector( &oldvelocity ); + arc.ArchiveVector( &old_v_angle ); + arc.ArchiveVector( &oldorigin ); + arc.ArchiveFloat( &animspeed ); + arc.ArchiveFloat( &airspeed ); + + arc.ArchiveVector( &m_vPushVelocity ); + + arc.ArchiveRaw( blend, sizeof( blend ) ); + arc.ArchiveFloat( &fov ); + arc.ArchiveFloat( &selectedfov ); + arc.ArchiveInteger( &m_iInZoomMode ); + + arc.ArchiveVector( &v_angle ); + arc.ArchiveVector( &m_vViewPos ); + arc.ArchiveVector( &m_vViewAng ); + + arc.ArchiveInteger( &buttons ); + arc.ArchiveInteger( &new_buttons ); + arc.ArchiveFloat( &respawn_time ); + + arc.ArchiveInteger( &last_attack_button ); + + arc.ArchiveFloat( &damage_blood ); + arc.ArchiveFloat( &damage_alpha ); + arc.ArchiveVector( &damage_blend ); + arc.ArchiveVector( &damage_from ); + arc.ArchiveVector( &damage_angles ); + arc.ArchiveFloat( &damage_count ); + arc.ArchiveFloat( &next_painsound_time ); + + arc.ArchiveSafePointer( &camera ); + arc.ArchiveSafePointer( &actor_camera ); + arc.ArchiveSafePointer( &actor_to_watch ); + + arc.ArchiveBoolean( &actor_camera_right ); + arc.ArchiveBoolean( &starting_actor_camera_right ); + + arc.ArchiveInteger( &music_current_mood ); + arc.ArchiveInteger( &music_fallback_mood ); + + arc.ArchiveFloat( &music_current_volume ); + arc.ArchiveFloat( &music_saved_volume ); + arc.ArchiveFloat( &music_volume_fade_time ); + + arc.ArchiveInteger( &reverb_type ); + arc.ArchiveFloat( &reverb_level ); + + arc.ArchiveBoolean( &gibbed ); + arc.ArchiveFloat( &pain ); + + ArchiveEnum( pain_dir, painDirection_t ); + ArchiveEnum( pain_type, meansOfDeath_t ); + + arc.ArchiveInteger( &pain_location ); + arc.ArchiveBool( &take_pain ); + arc.ArchiveInteger( &nextpaintime ); + + arc.ArchiveBool( &knockdown ); + arc.ArchiveBool( &canfall ); + arc.ArchiveBool( &falling ); + + arc.ArchiveInteger( &feetfalling ); + arc.ArchiveVector( &falldir ); + + arc.ArchiveBool( &mediumimpact ); + arc.ArchiveBool( &hardimpact ); + + arc.ArchiveBoolean( &music_forced ); + + arc.ArchiveRaw( &last_ucmd, sizeof( usercmd_t ) ); + arc.ArchiveRaw( &last_eyeinfo, sizeof( usereyes_t ) ); + + arc.ArchiveFloat( &animheight ); + + arc.ArchiveVector( &yaw_forward ); + arc.ArchiveVector( &yaw_left ); + + arc.ArchiveSafePointer( &atobject ); + arc.ArchiveFloat( &atobject_dist ); + arc.ArchiveVector( &atobject_dir ); + + arc.ArchiveSafePointer( &toucheduseanim ); + arc.ArchiveInteger( &useanim_numloops ); + arc.ArchiveSafePointer( &useitem_in_use ); + + arc.ArchiveFloat( &move_left_vel ); + arc.ArchiveFloat( &move_right_vel ); + arc.ArchiveFloat( &move_backward_vel ); + arc.ArchiveFloat( &move_forward_vel ); + arc.ArchiveFloat( &move_up_vel ); + arc.ArchiveFloat( &move_down_vel ); + arc.ArchiveInteger( &moveresult ); + + arc.ArchiveFloat( &damage_multiplier ); + + arc.ArchiveString( &waitForState ); + arc.ArchiveInteger( &m_iNumObjectives ); + arc.ArchiveInteger( &m_iObjectivesCompleted ); + + for( int i = 0; i < MAX_TRAILS; i++ ) + { + arc.ArchiveVector( &mvTrail[ i ] ); + } + + for( int i = 0; i < MAX_TRAILS; i++ ) + { + arc.ArchiveVector( &mvTrailEyes[ i ] ); + } + + arc.ArchiveInteger( &mCurTrailOrigin ); + arc.ArchiveInteger( &mLastTrailTime ); + + arc.ArchiveInteger( &m_iNumHitsTaken ); + arc.ArchiveInteger( &m_iNumEnemiesKilled ); + arc.ArchiveInteger( &m_iNumObjectsDestroyed ); + arc.ArchiveInteger( &m_iNumShotsFired ); + arc.ArchiveInteger( &m_iNumHits ); + arc.ArchiveFloat( &m_fAccuracy ); + arc.ArchiveFloat( &m_fTimeUsed ); + arc.ArchiveInteger( &m_iNumHeadShots ); + arc.ArchiveInteger( &m_iNumTorsoShots ); + arc.ArchiveInteger( &m_iNumLeftLegShots ); + arc.ArchiveInteger( &m_iNumRightLegShots ); + arc.ArchiveInteger( &m_iNumGroinShots ); + arc.ArchiveInteger( &m_iNumLeftArmShots ); + arc.ArchiveInteger( &m_iNumRightArmShots ); + + arc.ArchiveFloat( &m_fLastDeltaTime ); + + // make sure we have the state machine loaded up + if( arc.Loading() ) + { + LoadStateTable(); + } + + if( arc.Saving() ) + { + if( currentState_Legs ) + { + tempStr = currentState_Legs->getName(); + } + else + { + tempStr = "NULL"; + } + arc.ArchiveString( &tempStr ); + + if( currentState_Torso ) + { + tempStr = currentState_Torso->getName(); + } + else + { + tempStr = "NULL"; + } + arc.ArchiveString( &tempStr ); + } + else + { + arc.ArchiveString( &tempStr ); + if( tempStr != "NULL" ) + { + currentState_Legs = statemap_Legs->FindState( tempStr ); + } + else + { + currentState_Legs = NULL; + } + arc.ArchiveString( &tempStr ); + if( tempStr != "NULL" ) + { + currentState_Torso = statemap_Torso->FindState( tempStr ); + } + else + { + currentState_Torso = NULL; + } + } + + if( arc.Loading() ) + { + UpdateWeapons(); + } +} + +inline Camera *Player::CurrentCamera + ( + void + ) + + { + return camera; + } + +inline void Player::CameraCut + ( + void + ) + + { + // + // toggle the camera cut bit + // + client->ps.camera_flags = + ( ( client->ps.camera_flags & CF_CAMERA_CUT_BIT ) ^ CF_CAMERA_CUT_BIT ) | + ( client->ps.camera_flags & ~CF_CAMERA_CUT_BIT ); + } + +inline void Player::CameraCut + ( + Camera * ent + ) + + { + if ( ent == camera ) + { + // if the camera we are currently looking through cut, than toggle the cut bits + CameraCut(); + } + } + +inline void Player::SetCamera + ( + Camera *ent, + float switchTime + ) + +{ + camera = ent; + client->ps.camera_time = switchTime; + if( switchTime <= 0.0f ) + { + CameraCut(); + } +} + +#endif /* player.h */ diff --git a/code/game/player_combat.cpp b/code/game/player_combat.cpp new file mode 100644 index 00000000..9abd7d7d --- /dev/null +++ b/code/game/player_combat.cpp @@ -0,0 +1,275 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// player_combat.cpp: Player combat system and combat utility functions +// + +#include "player.h" +#include "weaputils.h" + +static Entity *FindClosestEntityInRadius + ( + Vector origin, + Vector forward, + float fov, + float maxdist + ) + + { + float dist,dot; + float fovdot = cos( fov * 0.5 * M_PI / 180.0 ); + Entity *ent; + Entity *bestent=NULL; + int bestdist = 999999; + qboolean valid_entity; + + // Find closest enemy in radius + ent = findradius( NULL, origin, maxdist ); + + while( ent ) + { + valid_entity = false; + + if( ent->flags & FL_AUTOAIM ) + { + valid_entity = true; + } + + if ( valid_entity ) + { + // Check to see if the enemy is closest to us + Vector delta = ( ent->centroid ) - origin; + + dist = delta.length(); + + if ( dist < bestdist ) + { + delta.normalize(); + + // It's close, now check to see if it's in our FOV. + dot = DotProduct( forward, delta ); + + if ( dot > fovdot ) + { + trace_t trace; + // Do a trace to see if we can get to it + trace = G_Trace( origin, + vec_zero, + vec_zero, + ent->centroid, + NULL, + MASK_OPAQUE, + false, + "FindClosestEntityInRadius" ); + + if ( ( trace.ent && trace.entityNum == ent->entnum ) || ( trace.fraction == 1 ) ) + { + // dir = delta; + bestent = ent; + bestdist = dist; + } + } + } + } + ent = findradius( ent, origin, maxdist ); + } + return bestent; + } + +static Entity *FindHeadTarget + ( + Vector origin, + Vector forward, + float fov, + float maxdist + ) + +{ +} + +Entity *Player::FindEnemyInFOVFromTagWithOffset + ( + float fov, + float maxdist, + str tagname, + Vector offset + ) + + { + vec3_t mat[3]; + orientation_t tag_or; + + GetTagPositionAndOrientation( gi.Tag_NumForName( edict->tiki, tagname ), &tag_or ); + + AnglesToAxis( torsoAngles, mat ); + + //G_DebugLine( tag_or.origin + offset, tag_or.origin + offset + Vector( mat[0] ) * 100, 1,1,1,1 ); + + return FindClosestEntityInRadius( tag_or.origin + offset, mat[0], fov, maxdist ); + } + +//==================== +//FindEnemyInFOV +//Returns entity if an enemy is in the player's FOV +//==================== +Entity *Player::FindEnemyInFOV + ( + float fov, + float maxdist + ) + + { + vec3_t mat[3]; + + AnglesToAxis( headAngles, mat ); + return FindClosestEntityInRadius( this->centroid, mat[0], fov, maxdist ); + } + +//==================== +//AdjustAnglesForAttack +//Adjust the player angles toward an enemy if they are attacking it +//==================== +void Player::AdjustAnglesForAttack + ( + void + ) + + { + /* + Vector dir; + Vector newAngles; + Vector moveToAngles; + + if ( FindEnemyInFOV( 180, 1000 ) ) + { + G_DrawCoordSystem( origin, dir,dir,dir,100 ); + + if ( buttons & ( BUTTON_ATTACKRIGHT|BUTTON_ATTACKLEFT ) ) + { + // Adjust for a percentage of the total + float deltayaw = AngleSubtract( dir.toYaw(), v_angle[YAW] ); + + if ( fabs( deltayaw ) > 5 ) + { + v_angle[YAW] += deltayaw * 0.1f; + client->ps.delta_angles[YAW] += ANGLE2SHORT( deltayaw * 0.1f ); + } + } + } + */ + } + + +//==================== +//useWeapon +//==================== +void Player::useWeapon + ( + const char *weaponname, + weaponhand_t hand + ) + + { + Weapon *weapon; + + weapon = ( Weapon * )FindItem( weaponname ); + + // Check to see if player has the weapon + if ( !weapon ) + { + warning( "Player::useWeapon", "Player does not have weapon %s", weaponname ); + return; + } + + useWeapon( weapon, hand ); + } + +void Player::useWeapon + ( + Weapon *weapon, + weaponhand_t hand + ) + +{ + Weapon * activeWeapon; + + if( !weapon ) + { + warning( "Player::useWeapon", "Null weapon used.\n" ); + return; + } + + // Check to see if we are already in the process of using a new weapon. + if( newActiveWeapon.weapon ) + { + return; + } + + if( weapon->isSubclassOf( Weapon ) ) + { + + // Check to see if weapon has ammo and if useNoAmmo is allowed + if( !weapon->HasAmmo( FIRE_PRIMARY ) && !weapon->HasAmmo( FIRE_SECONDARY ) && !weapon->GetUseNoAmmo() ) + { + Sound( "snd_noammo" ); + return; + } + } + + // Now get the active weapon in the specified hand + activeWeapon = GetActiveWeapon( hand ); + + // Check to see if this weapon is already being used in this hand and just put it away and return + if( activeWeapon == weapon ) + { + // Set the putaway flag to true. The state machine will then play the correct animation to put away the active weapon + activeWeapon->PutAway(); + return; + } + + // If activeWeapon is set, and it's not == weapon then put away this weapon + if( activeWeapon ) + { + // Set the putaway flag to true. The state machine will then play the correct animation to put away the active weapon + activeWeapon->PutAway(); + } + + // Check to see if this weapon is being used in a different hand and put it away as well (if it's in a different hand) + if( IsActiveWeapon( weapon ) ) + { + weapon->PutAway(); + } + + // Set the newActiveWeapon as the weapon specified, the state machine will play the appropriate animation and + // trigger when to attach it to the player model. + newActiveWeapon.weapon = weapon; + newActiveWeapon.hand = hand; +} + +void Player::AcquireHeadTarget + ( + void + ) + +{ + +} diff --git a/code/game/player_util.cpp b/code/game/player_util.cpp new file mode 100644 index 00000000..28661ef9 --- /dev/null +++ b/code/game/player_util.cpp @@ -0,0 +1,631 @@ +/* +=========================================================================== +Copyright (C) 2015 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA 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. + +OpenMoHAA 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 OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +// player_util.cpp: This file is used to hold the utility functions that are issued by the +// player at the console. Most of these are developer commands + +#include "player.h" +#include "object.h" +#include + +//==================== +//Player::ActorInfo +//==================== +void Player::ActorInfo + ( + Event *ev + ) + + { + int num; + Entity *ent; + + if ( ev->NumArgs() != 1 ) + { + gi.SendServerCommand( edict-g_entities, "print \"Usage: actorinfo \n\"" ); + return; + } + + num = ev->GetInteger( 1 ); + if ( ( num < 0 ) || ( num >= globals.max_entities ) ) + { + gi.SendServerCommand( edict-g_entities, "print \"Value out of range. Possible values range from 0 to %d.\n\"", globals.max_entities ); + return; + } + + ent = G_GetEntity( num ); + if ( !ent || !ent->isSubclassOf( Actor ) ) + { + gi.SendServerCommand( edict-g_entities, "print \"Entity not an Actor.\n\"" ); + } + else + { + ( ( Actor * )ent )->ShowInfo(); + } + } + +//==================== +//Player::WhatIs +//==================== +void Player::WhatIs + ( + Event *ev + ) + + { + int num; + Entity *ent; + + if ( ev->NumArgs() != 1 ) + { + gi.SendServerCommand( edict-g_entities, "print \"Usage: whatis \n\"" ); + return; + } + + num = ev->GetInteger( 1 ); + if ( ( num < 0 ) || ( num >= globals.max_entities ) ) + { + gi.SendServerCommand( edict-g_entities, "print \"Value out of range. Possible values range from 0 to %d.\n\"", globals.max_entities ); + return; + } + + ent = G_GetEntity( num ); + if ( !ent ) + { + gi.SendServerCommand( edict-g_entities, "print \"Entity not in use.\n\"", globals.max_entities ); + } + else + { + const char * animname; + + animname = NULL; + if ( gi.modeltiki( ent->model ) ) + { + animname = gi.Anim_NameForNum( ent->edict->tiki, ent->edict->s.frameInfo[ 0 ].index & ANIM_MASK ); + } + + if ( !animname ) + { + animname = "( N/A )"; + } + + gi.SendServerCommand( edict-g_entities, "print \"" + "Entity # : %d\n" + "Class ID : %s\n" + "Classname : %s\n" + "Targetname : %s\n" + "Modelname : %s\n" + "Animname : %s\n" + "Origin : ( %f, %f, %f )\n" + "Angles : ( %f, %f, %f )\n" + "Bounds : Mins( %.2f, %.2f, %.2f ) Maxs( %.2f, %.2f, %.2f )\n" + "Velocity : ( %f, %f, %f )\n" + "SVFLAGS : %x\n" + "Movetype : %i\n" + "Solidtype : %i\n" + "Contents : %x\n" + "Areanum : %i\n" + "Parent : %i\n" + "Health : %.1f\n" + "Max Health : %.1f\n" + "Edict Owner: %i\n\"", + num, + ent->getClassID(), + ent->getClassname(), + ent->TargetName().c_str(), + ent->model.c_str(), + animname, + ent->origin.x, ent->origin.y, ent->origin.z, + ent->angles.x, ent->angles.y, ent->angles.z, + ent->mins.x, ent->mins.y, ent->mins.z, ent->maxs.x, ent->maxs.y, ent->maxs.z, + ent->velocity.x, ent->velocity.y, ent->velocity.z, + ent->edict->r.svFlags, + ent->movetype, + ent->edict->solid, + ent->edict->r.contents, + ent->edict->r.areanum, + ent->edict->s.parent, + ent->health, + ent->max_health, + ent->edict->r.ownerNum + ); + } + } + +//==================== +//Player::KillEnt +//==================== +void Player::KillEnt + ( + Event * ev + ) + + { + int num; + Entity *ent; + + if ( ev->NumArgs() != 1 ) + { + gi.SendServerCommand( edict-g_entities, "print \"Usage: killent \n\"" ); + return; + } + + num = ev->GetInteger( 1 ); + if ( ( num < 0 ) || ( num >= globals.max_entities ) ) + { + gi.SendServerCommand( edict-g_entities, "print \"Value out of range. Possible values range from 0 to %d.\n\"", globals.max_entities ); + return; + } + + ent = G_GetEntity( num ); + ent->Damage( world, world, ent->max_health + 25, origin, vec_zero, vec_zero, 0, 0, 0 ); + } + +//==================== +//Player::RemoveEnt +//==================== +void Player::RemoveEnt + ( + Event * ev + ) + + { + int num; + Entity *ent; + + if ( ev->NumArgs() != 1 ) + { + gi.SendServerCommand( edict-g_entities, "print \"Usage: removeent \n\"" ); + return; + } + + num = ev->GetInteger( 1 ); + if ( ( num < 0 ) || ( num >= globals.max_entities ) ) + { + gi.SendServerCommand( edict-g_entities, "print \"Value out of range. Possible values range from 0 to %d.\n\"", globals.max_entities ); + return; + } + + ent = G_GetEntity( num ); + ent->PostEvent( Event( EV_Remove ), 0 ); + } + +//==================== +//Player::KillClass +//==================== +void Player::KillClass + ( + Event * ev + ) + + { + int except; + str classname; + gentity_t * from; + Entity *ent; + + if ( ev->NumArgs() < 1 ) + { + gi.SendServerCommand( edict-g_entities, "print \"Usage: killclass [except entity number]\n\"" ); + return; + } + + classname = ev->GetString( 1 ); + + except = 0; + if ( ev->NumArgs() == 2 ) + { + except = ev->GetInteger( 1 ); + } + + for ( from = this->edict + 1; from < &g_entities[ globals.num_entities ]; from++ ) + { + if ( !from->inuse ) + { + continue; + } + + assert( from->entity ); + + ent = from->entity; + + if ( ent->entnum == except ) + { + continue; + } + + if ( ent->inheritsFrom( classname.c_str() ) ) + { + ent->Damage( world, world, ent->max_health + 25, origin, vec_zero, vec_zero, 0, 0, 0 ); + } + } + } + +//==================== +//Player::RemoveClass +//==================== +void Player::RemoveClass + ( + Event * ev + ) + + { + int except; + str classname; + gentity_t * from; + Entity *ent; + + if ( ev->NumArgs() < 1 ) + { + gi.SendServerCommand( edict-g_entities, "print \"Usage: removeclass [except entity number]\n\"" ); + return; + } + + classname = ev->GetString( 1 ); + + except = 0; + if ( ev->NumArgs() == 2 ) + { + except = ev->GetInteger( 1 ); + } + + for ( from = this->edict + 1; from < &g_entities[ globals.num_entities ]; from++ ) + { + if ( !from->inuse ) + { + continue; + } + + assert( from->entity ); + + ent = from->entity; + + if ( ent->entnum == except ) + continue; + + if ( ent->inheritsFrom( classname.c_str() ) ) + { + ent->PostEvent( Event( EV_Remove ), 0 ); + } + } + } + +//==================== +//Player::TestThread +//==================== +void Player::TestThread + ( + Event *ev + ) + + { + const char *scriptfile; + const char *label = NULL; + + if ( ev->NumArgs() < 1 ) + { + gi.SendServerCommand( edict-g_entities, "print \"Syntax: testthread scriptfile